changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Drawables / Geometry / Base / OSGGeometry.inl
blob624291b08127beaeadac55aa79c4fb05480c62cc
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *               Copyright (C) 2000-2002 by the OpenSG Forum                 *
6  *                                                                           *
7  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
8  *                                                                           *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
11  *                                License                                    *
12  *                                                                           *
13  * This library is free software; you can redistribute it and/or modify it   *
14  * under the terms of the GNU Library General Public License as published    *
15  * by the Free Software Foundation, version 2.                               *
16  *                                                                           *
17  * This library is distributed in the hope that it will be useful, but       *
18  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
20  * Library General Public License for more details.                          *
21  *                                                                           *
22  * You should have received a copy of the GNU Library General Public         *
23  * License along with this library; if not, write to the Free Software       *
24  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
25  *                                                                           *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
28  *                                Changes                                    *
29  *                                                                           *
30  *                                                                           *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
38 //  Includes
39 //---------------------------------------------------------------------------
41 OSG_BEGIN_NAMESPACE
43 /***************************************************************************\
44  *                           Instance methods                              *
45 \***************************************************************************/
47 /*-------------------------------------------------------------------------*\
48  -  public                                                                 -
49 \*-------------------------------------------------------------------------*/
51 inline
52 void Geometry::invalidateDlistCache(void)
54     Window::refreshGLObject( getClassicGLId() );
55     Window::refreshGLObject( getAttGLId() );
58 inline
59 Int32  Geometry::getClassicGLId(void) const
61     return Inherited::getClassicGLId();
64 inline
65 Int32  Geometry::getAttGLId(void) const
67     return Inherited::getAttGLId();
71 /*------------------------------ access -----------------------------------*/
73 //--------------------------
74 // Property Access
75 //--------------------------
77 inline
78 GeoIntegralProperty *Geometry::getTypes(void) const
80    return _sfTypes.getValue();
83 inline
84 GeoIntegralProperty *Geometry::getLengths(void) const
86    return _sfLengths.getValue();
89 inline
90 GeoVectorProperty *Geometry::getPositions(void) const
92    return getProperty(PositionsIndex);
95 inline
96 GeoVectorProperty *Geometry::getNormals(void) const
98    return getProperty(NormalsIndex);
101 inline
102 GeoVectorProperty *Geometry::getColors(void) const
104    return getProperty(ColorsIndex);
107 inline
108 GeoVectorProperty *Geometry::getSecondaryColors(void) const
110    return getProperty(SecondaryColorsIndex);
113 inline
114 GeoVectorProperty *Geometry::getTexCoords(void) const
116    return getProperty(TexCoordsIndex);
119 inline
120 GeoVectorProperty *Geometry::getTexCoords1(void) const
122    return getProperty(TexCoords1Index);
125 inline
126 GeoVectorProperty *Geometry::getTexCoords2(void) const
128    return getProperty(TexCoords2Index);
131 inline
132 GeoVectorProperty *Geometry::getTexCoords3(void) const
134    return getProperty(TexCoords3Index);
137 inline
138 GeoVectorProperty *Geometry::getTexCoords4(void) const
140    return getProperty(TexCoords4Index);
143 inline
144 GeoVectorProperty *Geometry::getTexCoords5(void) const
146    return getProperty(TexCoords5Index);
149 inline
150 GeoVectorProperty *Geometry::getTexCoords6(void) const
152    return getProperty(TexCoords6Index);
155 inline
156 GeoVectorProperty *Geometry::getTexCoords7(void) const
158    return getProperty(TexCoords7Index);
163 inline
164 void Geometry::setPositions(GeoVectorProperty * const value)
166     setProperty(value, PositionsIndex);
169 inline
170 void Geometry::setNormals(GeoVectorProperty * const value)
172     setProperty(value, NormalsIndex);
175 inline
176 void Geometry::setColors(GeoVectorProperty * const value)
178     setProperty(value, ColorsIndex);
181 inline
182 void Geometry::setSecondaryColors(GeoVectorProperty * const value)
184     setProperty(value, SecondaryColorsIndex);
187 inline
188 void Geometry::setTexCoords(GeoVectorProperty * const value)
190     setProperty(value, TexCoordsIndex);
193 inline
194 void Geometry::setTexCoords1(GeoVectorProperty * const value)
196     setProperty(value, TexCoords1Index);
199 inline
200 void Geometry::setTexCoords2(GeoVectorProperty * const value)
202     setProperty(value, TexCoords2Index);
205 inline
206 void Geometry::setTexCoords3(GeoVectorProperty * const value)
208     setProperty(value, TexCoords3Index);
211 inline
212 void Geometry::setTexCoords4(GeoVectorProperty * const value)
214     setProperty(value, TexCoords4Index);
217 inline
218 void Geometry::setTexCoords5(GeoVectorProperty * const value)
220     setProperty(value, TexCoords5Index);
223 inline
224 void Geometry::setTexCoords6(GeoVectorProperty * const value)
226     setProperty(value, TexCoords6Index);
229 inline
230 void Geometry::setTexCoords7(GeoVectorProperty * const value)
232     setProperty(value, TexCoords7Index);
236 /*! Set the vertex properties at index.
237 * \param value  The vertex attribute buffer to assign to index.
238 * \param index  The index of the OpenGL vertex attribute to set.
240 inline
241 void Geometry::setProperty(GeoVectorProperty * const value, UInt16 index)
243     editMField(PropertiesFieldMask, _mfProperties);
245     while(_mfProperties.size() <= index)
246     {
247         _mfProperties.push_back(NULL);
248     }
249     
250     if(value  != NULL &&
251        0x0000 != (value->getUsage() & GeoProperty::UsageSystemSet))
252     {
253         switch(index)
254         {
255         case PositionsIndex:
256             value->setUsage(GeoProperty::UsageObjectSpace |
257                             GeoProperty::UsageSystemSet    );
258         break;
259         
260         case NormalsIndex:
261             value->setUsage(GeoProperty::UsageTangentSpace |
262                             GeoProperty::UsageSystemSet     );
263         break;
264         
265         case ColorsIndex:
266         case SecondaryColorsIndex:
267             value->setUsage(GeoProperty::UsageColorSpace |
268                             GeoProperty::UsageSystemSet   );
269         break;
270         
271         case TexCoordsIndex:
272         case TexCoords1Index:
273         case TexCoords2Index:
274         case TexCoords3Index:
275         case TexCoords4Index:
276         case TexCoords5Index:
277         case TexCoords6Index:
278         case TexCoords7Index:
279             value->setUsage(GeoProperty::UsageParameterSpace |
280                             GeoProperty::UsageSystemSet       );
281         break;
282         
283         default:
284             value->setUsage(GeoProperty::UsageUnspecified |
285                             GeoProperty::UsageSystemSet       );
286         }
287     }
289     _mfProperties.replace(index, value);
292 /*! Return the vertext property data stored at index. */
293 inline
294 GeoVectorProperty *Geometry::getProperty(UInt16 index) const
296     if(_mfProperties.size() <= index)
297         return NULL;
299     return _mfProperties[index];
302 /*! Add index array for the vertex data attribute at index.
303 * \param value   The list of indices to use.
304 * \param index   The index of the vertex attribute data
306 inline
307 void Geometry::setIndex(GeoIntegralProperty * const value, UInt16 index)
309     editMField(PropIndicesFieldMask, _mfPropIndices);
311     while(_mfPropIndices.size() <= index)
312     {
313         _mfPropIndices.push_back(NULL);
314     }
316     _mfPropIndices.replace(index, value);
319 /*! Return the list of indices currently being used for the vertex attributes
320 * at index index.
322 inline
323 GeoIntegralProperty *Geometry::getIndex(UInt16 index) const
325     if(_mfPropIndices.size() <= index)
326         return NULL;
328     GeoIntegralProperty *p =
329         dynamic_cast<GeoIntegralProperty *>(_mfPropIndices[index]);
331     return p;
334 inline
335 void Geometry::setMaterial(Material * const value)
337     Inherited::setMaterial(value);
341 inline Geometry::PumpGroupStorage &Geometry::getPumpGroupStorage(void)
343     return _pumps;
346 /*----------------- Property/Index MField Changes -----------------*/
348 inline void Geometry::resizeProperties(size_t newsize)
350     editMField(PropertiesFieldMask, _mfProperties);
352     _mfProperties.resize(newsize);
355 inline void Geometry::reserveProperties(size_t newsize)
357     editMField(PropertiesFieldMask, _mfProperties);
359     _mfProperties.reserve(newsize);
362 inline void Geometry::resizePropIndices(size_t newsize)
364     editMField(PropIndicesFieldMask, _mfPropIndices);
366     _mfPropIndices.resize(newsize, NULL);
369 inline void Geometry::reservePropIndices(size_t newsize)
371     editMField(PropIndicesFieldMask, _mfPropIndices);
373     _mfPropIndices.resize(newsize);
376 /*---------------- Backwards Compatibility Helpers ----------------*/
378 /*! Set all indices to the same value for all vertex attributes.
380 inline void Geometry::setIndices(GeoIntegralProperty * const value)
382     for(UInt16 i = 0; i < MaxAttribs; ++i)
383         setIndex(value, i);
386 /*! Return the indices of the first set of vertex attributes.
387 * Use in combination with setIndices.
389 inline GeoIntegralProperty *Geometry::getIndices(void)
391     return getIndex(0);
394 inline
395 UInt32 Geometry::getFuncIdDrawElementsInstanced(void)
397     return FuncIdDrawElementsInstanced;
400 inline
401 UInt32 Geometry::getFuncIdDrawArraysInstanced(void)
403     return FuncIdDrawArraysInstanced;
406 OSG_END_NAMESPACE