CFx SDK Documentation  2023 SP0
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__
true
Definition: DimVarDefs.h:2046
ENodeType
Definition: GsBaseModel.h:65
@ kMaterialNode
Definition: GsBaseModel.h:73
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
#define NULL
Definition: GsProperties.h:177
unsigned int OdUInt32
void setCachedData(OdGsBaseVectorizer &view, OdRxObject *newCachedData)
OdGiMaterialTraitsData m_materialTraits
void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *pView, OdUInt32 mask)
OdGiMaterialTraitsData & materialTraits()
bool saveNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL) const
OdGsMaterialNode * m_pMatNext
OdGsMaterialNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=true)
OdGsMaterialNode * prevNode() const
virtual void onModified(OdGsBaseVectorizer &view)
void update(OdGsUpdateContext &ctx, OdGsContainerNode *pParent, OdSiSpatialIndex *pParentIndex)
bool extents(OdGeExtents3d &) const
OdGsMaterialNode * nextNode() const
bool loadNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer=NULL)
bool isDataModified() const
void setCachedDataUpdated(OdGsBaseVectorizer &view)
virtual void update(OdGsBaseVectorizer &view)
OdMutexPtr & cacheMutex()
const OdRxObject * cachedData(OdGsBaseVectorizer &view) const
void display(OdGsDisplayContext &ctx)
const OdGiMaterialTraitsData & materialTraits() const
OdGsMaterialNode * setPrevNode(OdGsMaterialNode *newNode)
OdGsMaterialNode * m_pMatPrev
OdGsMaterialNode * setNextNode(OdGsMaterialNode *newNode)
virtual ENodeType nodeType() const
ODRX_DECLARE_MEMBERS(OdGsMaterialNode)
bool isCachedDataModified(OdGsBaseVectorizer &view) const
OdMutexPtr m_pCacheMutex
virtual void propagateLayerChanges(OdGsViewImpl &view)
std::map< const void *, DataEntry > CacheMap
GLenum GLint GLuint mask
Definition: gles2_ext.h:262
DataEntry()
bool m_cachedDataModified
OdRxObjectPtr m_pCachedData