CFx SDK Documentation  2020SP3
GsMaterialNode.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef __OD_GS_MATERIAL_NODE__
25 #define __OD_GS_MATERIAL_NODE__
26 
27 #include "TD_PackPush.h"
28 
29 #include "Gs/GsNode.h"
30 #include "Gi/GiMaterial.h"
32 #include "ThreadsCounter.h"
33 #define STL_USING_MAP
34 #include "OdaSTL.h"
35 
36 // Materials cached in GsModel, but in separate cache, instead all geometry.
37 
38 // GsModel caches hierarchy:
39 // OdGsBaseModel
40 // OdGsContainerNode <-- OdGsNode - geometry cache
41 // OdGsEntityNode <-- OdGsNode
42 // OdGsLightNode - has separate array, but stored into geometry cache too
43 // OdGsLayerNode <-- OdGsNode - layers cache
44 // OdGsBaseMode::OdGsMaterialCache
45 // OdGsMaterialNode <-- OdGsNode - materials cache
46 
50 {
51 protected:
55  void update(OdGsUpdateContext& ctx, OdGsContainerNode* pParent,
56  OdSiSpatialIndex* pParentIndex);
57 
61  void display(OdGsDisplayContext& ctx);
62 
66  bool extents(OdGeExtents3d& ) const;
67 
71  virtual void propagateLayerChanges(OdGsViewImpl& view);
72 
76  struct DataEntry
77  {
80 
81  DataEntry() : m_cachedDataModified(true) { }
82  };
83  typedef std::map<const void *, DataEntry> CacheMap;
86 
89 public:
91 
95  OdGsMaterialNode(OdGsBaseModel* pModel, const OdGiDrawable* pUnderlyingDrawable, bool bSetGsNode = true);
97 
98  void destroy() {}
99 
102 
103  // Called from OdGsNode if material data changed at update.
104  // May be used by inherited nodes to update device-dependant information.
105  virtual void onModified(OdGsBaseVectorizer& view);
106 
111 
114  virtual void update(OdGsBaseVectorizer& view);
115 
120 
121  bool isDataModified() const;
122 
125 
127  void setCachedData(OdGsBaseVectorizer& view, OdRxObject *newCachedData);
128 
129  OdMutexPtr &cacheMutex() { return m_pCacheMutex; }
130 
131  virtual ENodeType nodeType() const { return kMaterialNode; }
132 
133  bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL) const;
134  bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer = NULL);
135 };
136 
137 // Cache for material nodes
138 #include "GsMaterialCache.h"
139 
140 #include "TD_PackPop.h"
141 
142 #endif // __OD_GS_MATERIAL_NODE__
OdGsMaterialNode::cachedData
const OdRxObject * cachedData(OdGsBaseVectorizer &view) const
OdSiSpatialIndex
Definition: SiSpatialIndex.h:118
NULL
#define NULL
Definition: GsProperties.h:177
OdRxObjectPtr
Definition: RxObject.h:345
GsMaterialCache.h
OdGsMaterialNode::isCachedDataModified
bool isCachedDataModified(OdGsBaseVectorizer &view) const
OdGsMaterialNode::m_pCacheMutex
OdMutexPtr m_pCacheMutex
Definition: GsMaterialNode.h:85
OdGsContainerNode
Definition: GsContainerNode.h:47
OdGsMaterialNode::setPrevNode
OdGsMaterialNode * setPrevNode(OdGsMaterialNode *newNode)
OdGsBaseVectorizer
Definition: GsBaseVectorizer.h:112
OdGsMaterialNode::m_materialTraits
OdGiMaterialTraitsData m_materialTraits
Definition: GsMaterialNode.h:73
OdGsMaterialNode::m_dataModified
bool m_dataModified
Definition: GsMaterialNode.h:75
OdGsMaterialNode::DataEntry::m_pCachedData
OdRxObjectPtr m_pCachedData
Definition: GsMaterialNode.h:79
OdGsMaterialNode::OdGsMaterialNode
OdGsMaterialNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=true)
OdRxObject
Definition: RxObject.h:564
OdaSTL.h
OdGsMaterialNode::propagateLayerChanges
virtual void propagateLayerChanges(OdGsViewImpl &view)
OdGsNode
Definition: GsNode.h:60
OdGsMaterialNode::setCachedData
void setCachedData(OdGsBaseVectorizer &view, OdRxObject *newCachedData)
OdGsMaterialNode::invalidate
void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *pView, OdUInt32 mask)
kMaterialNode
@ kMaterialNode
Definition: GsBaseModel.h:73
OdGsMaterialNode::m_pMatNext
OdGsMaterialNode * m_pMatNext
Definition: GsMaterialNode.h:88
TD_PackPop.h
OdGsMaterialNode::prevNode
OdGsMaterialNode * prevNode() const
OdGsMaterialNode::ODRX_DECLARE_MEMBERS
ODRX_DECLARE_MEMBERS(OdGsMaterialNode)
OdGsMaterialNode::isDataModified
bool isDataModified() const
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
mask
GLenum GLint GLuint mask
Definition: gles2_ext.h:262
OdGsMaterialNode
Definition: GsMaterialNode.h:50
OdGsMaterialNode::m_dataInitialized
bool m_dataInitialized
Definition: GsMaterialNode.h:74
OdGsMaterialNode::loadNodeState
bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL)
ENodeType
ENodeType
Definition: GsBaseModel.h:65
OdGsMaterialNode::setCachedDataUpdated
void setCachedDataUpdated(OdGsBaseVectorizer &view)
GsNode.h
OdGsMaterialNode::cacheMutex
OdMutexPtr & cacheMutex()
Definition: GsMaterialNode.h:129
GiMaterialTraitsData.h
ThreadsCounter.h
OdGsMaterialNode::setNextNode
OdGsMaterialNode * setNextNode(OdGsMaterialNode *newNode)
OdGsMaterialNode::~OdGsMaterialNode
~OdGsMaterialNode()
OdGiMaterialTraitsData
Definition: GiMaterialTraitsData.h:38
OdGsMaterialNode::DataEntry::DataEntry
DataEntry()
Definition: GsMaterialNode.h:81
true
true
Definition: DimVarDefs.h:2046
OdGsMaterialNode::materialTraits
OdGiMaterialTraitsData & materialTraits()
OdGsMaterialNode::update
virtual void update(OdGsBaseVectorizer &view)
GiMaterial.h
OdGiDrawable
Definition: GiDrawable.h:49
OdGsViewImpl
Definition: GsViewImpl.h:58
OdGsMaterialNode::materialTraits
const OdGiMaterialTraitsData & materialTraits() const
OdGsMaterialNode::m_pMatPrev
OdGsMaterialNode * m_pMatPrev
Definition: GsMaterialNode.h:87
TD_PackPush.h
OdGsMaterialNode::CacheMap
std::map< const void *, DataEntry > CacheMap
Definition: GsMaterialNode.h:83
OdGsMaterialNode::saveNodeState
bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL) const
OdGsMaterialNode::m_cacheMap
CacheMap m_cacheMap
Definition: GsMaterialNode.h:84
OdGsMaterialNode::DataEntry
Definition: GsMaterialNode.h:77
OdGsBaseModel
Definition: GsBaseModel.h:118
OdGeExtents3d
Definition: GeExtents3d.h:45
GS_TOOLKIT_EXPORT
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdGsMaterialNode::display
void display(OdGsDisplayContext &ctx)
OdGsMaterialNode::extents
bool extents(OdGeExtents3d &) const
OdGsMaterialNode::destroy
void destroy()
Definition: GsMaterialNode.h:98
OdGsMaterialNode::DataEntry::m_cachedDataModified
bool m_cachedDataModified
Definition: GsMaterialNode.h:78
OdGsMaterialNode::nextNode
OdGsMaterialNode * nextNode() const
OdGsMaterialNode::nodeType
virtual ENodeType nodeType() const
Definition: GsMaterialNode.h:131
OdMutexPtr
Definition: ThreadsCounter.h:38
OdGsMaterialNode::update
void update(OdGsUpdateContext &ctx, OdGsContainerNode *pParent, OdSiSpatialIndex *pParentIndex)
OdGsFiler
Definition: GsFiler.h:63
OdGsMaterialNode::onModified
virtual void onModified(OdGsBaseVectorizer &view)