00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef _SO_VERTEX_SHAPE_
00051 #define _SO_VERTEX_SHAPE_
00052
00053 #include <Inventor/nodes/SoShape.h>
00054 #include <Inventor/nodes/SoVertexProperty.h>
00055 #include <Inventor/fields/SoSFNode.h>
00056 #include <Inventor/threads/SbThreadSpinlock.h>
00057 #include <Inventor/threads/SbThreadRWMutex.h>
00058 #include <Inventor/threads/SbThreadLocalStorage.h>
00059 #include <Inventor/STL/map>
00060 #include <Inventor/nodes/SoVertexShader.h>
00061
00062
00063 #include <Inventor/caches/SoVBOMgr.h>
00064 #include <Inventor/caches/SoVBOCache.h>
00065 #include <Inventor/elements/SoNormalBindingElement.h>
00066
00068
00069
00070
00071
00072
00073
00074
00075
00077
00078 class SoGLRenderAction;
00079 class SoNormalBundle;
00080 class SoNormalCache;
00081 class SoShapeStyleElement;
00082 class SoState;
00083 class SoTextureCoordinateBundle;
00084 class SoTextureCoordinate3Bundle;
00085 class SoVertexAttribData;
00086 namespace inventor
00087 {
00088 namespace helper
00089 {
00090 class GPUPicking;
00091 }
00092 }
00093
00095 namespace inventor
00096 {
00097 namespace cache
00098 {
00099 class VertexProperty;
00100 }
00101 }
00104 #ifdef _MSC_VER
00105 #pragma warning( push )
00106 #pragma warning(disable:4251)
00107 #endif
00108
00319 class SoVertexShape : public SoShape {
00320
00321 SO_NODE_ABSTRACT_HEADER(SoVertexShape);
00322
00323 public:
00328 SoSFNode vertexProperty;
00329
00335 SoNormalCache *getNormalCache() const { return normalCache; }
00336
00337 private:
00338
00339
00340
00341
00342
00343 virtual void generateDefaultNormals(SoState *state,
00344 const SbVec3f *coords,
00345 int numCoords,
00346 SoNormalBundle *nb,
00347 SbBool storeRef = FALSE);
00348
00349
00350 void commonGenerateDefaultNormals(SoState *state, SoNormalBundle *nb);
00351
00352 virtual SbBool figureNormals(SoState *state, SoNormalBundle *nb);
00353
00354 virtual int getNumNeededNormals(SoState *state);
00355
00356 virtual void write(SoWriteAction *writeAction);
00357
00358
00359 virtual void GLRender(SoGLRenderAction *action);
00360
00361 private:
00362 static void initClass();
00363 static void exitClass();
00364
00365
00366 virtual void notify(SoNotList *list);
00367
00368
00369
00370 inline SoVBOCache* getVBOCache() const
00371 { return (SoVBOCache*)(m_VBOCache.getValue()); }
00372
00373 inline SbThreadStorage<SoVBOCache*>* getVBOCacheLocalStorage()
00374 { return &m_VBOCache; }
00375
00376 virtual void callDEBUGGLRender(SoGLRenderAction *action,uint32_t useTexCoordsAnyway);
00377
00378 inline inventor::cache::VertexProperty* getVpCache();
00379 inline void lockVpCacheMutex() const;
00380 inline void unlockVpCacheMutex() const;
00381
00391 virtual SoVertexShaderParameterBufferObject* createPrimitiveIdentifierVertexShaderParameter( SoState* state );
00392
00393 private:
00394
00395 SoVertexShape();
00396
00397 virtual ~SoVertexShape();
00398
00399
00400
00401
00402 virtual SbBool shouldGLRender(SoGLRenderAction *action,
00403 SbBool isPointsOrLines = FALSE);
00404
00405
00406
00407
00408 SoVBOMgr* allocateVBO(SoState* state, const int VBOUsage=0);
00409 void deleteVBO(SoState *state) ;
00410
00411
00412
00413
00414 virtual void exitRender(SoState *state,int stateFlag,
00415 SoTextureCoordinateBundle *tcb,
00416 SoTextureCoordinate3Bundle *tc3b);
00417
00418
00419
00420
00421 virtual int getMaxTestValueForAutoCache(){return 0;}
00422
00423
00424 virtual int getMinTestValueForAutoCache(){return 0;}
00425
00426
00427 virtual void setupRenderFunctions(SoState *state,int &stateFlag);
00428
00429 virtual void callSetupIndices(const SoShapeStyleElement* shapeStyle,uint32_t useTexCoordsAnyway);
00430
00431
00432 virtual void shouldGenerateTextureCoordinates(SoGLRenderAction *action,
00433 int &stateFlag,
00434 SoShapeStyleElement *&shapeStyle,
00435 uint32_t &useTexCoordsAnyway,
00436 SoTextureCoordinateBundle *&tcb,
00437 SoTextureCoordinate3Bundle *&tc3b);
00438
00439
00440 virtual SbBool shouldGenerateTexture3DCoordinates(){return FALSE;}
00441
00442
00443 virtual void checkAutoCaching(SoState *state,const SoShapeStyleElement *shapeStyle,SbBool settingVPCache);
00444
00445
00446 virtual SbBool checkTex3Coords(){return FALSE;}
00447
00448
00449 virtual void doRendering(SoGLRenderAction *action, const SoShapeStyleElement* shapeStyle);
00450
00451
00452 virtual void render(SoGLRenderAction *action,SbBool isPointsOrLines,SbBool setVPCache);
00453
00454
00455 virtual void shouldGenerateNormals(SoGLRenderAction *action,const SoShapeStyleElement *shapeStyle);
00456
00457
00458 virtual SbBool shouldCheckShapeHints(){ return FALSE;}
00459
00460
00461 virtual SbBool shouldSetVPCache(SoGLRenderAction *action,SbBool isPointsOrLines);
00462
00463 virtual SbBool checkVPCache(SoGLRenderAction *action,
00464 const SoShapeStyleElement *shapeStyle,
00465 SbThreadAutoWriteLock *autoLock = 0);
00466
00467
00468 virtual SbBool shapeHintsTest(){ return FALSE;}
00469
00470
00471 virtual SbBool checkShapeHints(SoGLRenderAction *action,SbThreadAutoWriteLock *autolock =0);
00472
00473
00474 virtual void setupLazyElement(SoGLRenderAction *action,const SoShapeStyleElement *shapeStyle);
00475
00476
00477 virtual void checkShapeStyle(SoState *state,const SoShapeStyleElement *shapeStyle);
00478
00479
00480
00481
00482
00483 inventor::cache::VertexProperty* vpCache;
00484
00485
00486
00487 void setNormalCache(SoState *state, int numNormals, const SbVec3f *normals, const SoNormalBindingElement::Binding binding=SoNormalBindingElement::PER_VERTEX);
00488
00489
00490 SbThreadRWMutex *vpCacheMutex;
00491
00492
00493 SoVertexAttribData* m_vertexAttribData;
00494
00495
00496
00497
00498 static int32_t* allocateSequential(const int howMany);
00499 static int32_t* getConsecutiveIndices();
00500
00504 virtual bool canUseGPUPicking( SoRayPickAction* action );
00505
00506
00507 inventor::helper::GPUPicking* m_pickingHelper;
00508
00509 private:
00510
00511 SoNormalCache* normalCache;
00512
00513
00514 SbThreadStorage<SoVBOCache*> m_VBOCache;
00515
00516 static SbThreadSpinlock s_consecutiveIndicesMutex;
00517 static std::map<int,int32_t*> s_consecutiveIndices;
00518
00519 static bool s_forceGeneratePrimitives;
00520
00521 void setupColorMaterial(SoState* state);
00522
00523
00524 enum gpuPickingMode
00525 {
00526 GPU,
00527 CPU,
00528 PICKSTYLE
00529 };
00530
00532 static gpuPickingMode s_gpuPickingDefMode;
00534 static bool s_debugGpuPicking;
00537 static int64_t s_minVerticesForGPUPicking;
00538 };
00539
00540 inline void
00541 SoVertexShape::generateDefaultNormals(SoState *, const SbVec3f *, int , SoNormalBundle *, SbBool )
00542 {}
00543
00544 inline void
00545 SoVertexShape::setupRenderFunctions(SoState *,int &)
00546 {}
00547
00548 inline void
00549 SoVertexShape::callSetupIndices(const SoShapeStyleElement* ,uint32_t )
00550 {}
00551
00552 inline int
00553 SoVertexShape::getNumNeededNormals(SoState *)
00554 {
00555 return 0;
00556 }
00557
00558 inline void
00559 SoVertexShape::callDEBUGGLRender(SoGLRenderAction *,uint32_t )
00560 {}
00561
00562 inline void
00563 SoVertexShape::doRendering(SoGLRenderAction *, const SoShapeStyleElement* )
00564 {}
00565
00566
00567 inventor::cache::VertexProperty*
00568 SoVertexShape::getVpCache()
00569 {
00570 return vpCache;
00571 }
00572
00573
00574 void
00575 SoVertexShape::lockVpCacheMutex() const
00576 {
00577 vpCacheMutex->writelock();
00578 }
00579
00580
00581 void
00582 SoVertexShape::unlockVpCacheMutex() const
00583 {
00584 vpCacheMutex->writeunlock();
00585 }
00586
00587 #ifdef _MSC_VER
00588 #pragma warning( pop )
00589 #endif
00590
00591 #endif
00592
00593