changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Drawables / Geometry / Instancing / OSGGeoInstancer.cpp
blob59e2633a3f048e7679ec30bd214de1ac29096f33
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
45 #include <boost/bind.hpp>
47 #include "OSGConfig.h"
49 #include "OSGGLEXT.h"
50 #include "OSGWindow.h"
52 #include "OSGGeoInstancer.h"
53 #include "OSGDrawEnv.h"
55 #include "OSGGLFuncProtos.h"
57 #include "OSGConceptPropertyChecks.h"
58 #include "OSGIntersectAction.h"
59 #include "OSGGeometry.h"
60 #include "OSGRenderAction.h"
62 OSG_USING_NAMESPACE
64 // Documentation for this class is emited in the
65 // OSGGeoInstancerBase.cpp file.
66 // To modify it, please change the .fcd file (OSGGeoInstancer.fcd) and
67 // regenerate the base file.
70 /***************************************************************************\
71 * Class variables *
72 \***************************************************************************/
74 /***************************************************************************\
75 * Class methods *
76 \***************************************************************************/
78 void GeoInstancer::initMethod(InitPhase ePhase)
80 Inherited::initMethod(ePhase);
82 if(ePhase == TypeObject::SystemPost)
84 IntersectAction::registerEnterDefault(
85 getClassType(),
86 reinterpret_cast<Action::Callback>(&GeoInstancer::intersectEnter));
88 RenderAction::registerEnterDefault(
89 getClassType(),
90 reinterpret_cast<Action::Callback>(
91 &MaterialDrawable::renderEnter));
93 RenderAction::registerLeaveDefault(
94 getClassType(),
95 reinterpret_cast<Action::Callback>(
96 &MaterialDrawable::renderLeave));
101 /***************************************************************************\
102 * Instance methods *
103 \***************************************************************************/
105 /*-------------------------------------------------------------------------*\
106 - private -
107 \*-------------------------------------------------------------------------*/
109 /*----------------------- constructors & destructors ----------------------*/
111 GeoInstancer::GeoInstancer(void) :
112 Inherited()
116 GeoInstancer::GeoInstancer(const GeoInstancer &source) :
117 Inherited(source)
121 GeoInstancer::~GeoInstancer(void)
126 /*------------------------- Chunk Class Access ---------------------------*/
128 /*----------------------------- class specific ----------------------------*/
130 void GeoInstancer::changed(ConstFieldMaskArg whichField,
131 UInt32 origin,
132 BitVector details)
134 Inherited::changed(whichField, origin, details);
137 void GeoInstancer::dump( UInt32 ,
138 const BitVector ) const
140 SLOG << "GeoInstancer:" << std::endl;
143 /*------------------------------ State ------------------------------------*/
146 /*-------------------------- Comparison -----------------------------------*/
148 const SFUnrecMaterialPtr *GeoInstancer::getSFMaterial (void) const
150 if(_sfBaseGeometry.getValue() != NULL)
152 return _sfBaseGeometry.getValue()->getSFMaterial();
155 return NULL;
158 SFUnrecMaterialPtr *GeoInstancer::editSFMaterial(void)
160 if(_sfBaseGeometry.getValue() != NULL)
162 return _sfBaseGeometry.getValue()->editSFMaterial();
165 return NULL;
168 Material *GeoInstancer::getMaterial(void) const
170 if(_sfBaseGeometry.getValue() != NULL)
172 return _sfBaseGeometry.getValue()->getMaterial();
175 return NULL;
178 void GeoInstancer::setMaterial(Material * const value)
180 if(_sfBaseGeometry.getValue() != NULL)
182 return _sfBaseGeometry.getValue()->setMaterial(value);
186 void GeoInstancer::drawPrimitives(DrawEnv *pEnv)
188 if(_sfBaseGeometry.getValue() == NULL)
189 return;
191 _sfBaseGeometry.getValue()->drawPrimitives(pEnv,
192 _sfNumInstances.getValue());
195 Action::ResultE GeoInstancer::intersectEnter(Action *action)
197 if(_sfBaseGeometry.getValue() == NULL)
198 return Action::Continue;
200 return _sfBaseGeometry.getValue()->intersectEnter(action);
202 return Action::Continue;
205 void GeoInstancer::adjustVolume(Volume &volume)
207 if(_sfBaseGeometry.getValue() == NULL)
208 return;
210 _sfBaseGeometry.getValue()->adjustVolume(volume);
213 void GeoInstancer::fill(DrawableStatsAttachment *pStat)
217 GetFieldHandlePtr GeoInstancer::getHandleMaterial(void) const
219 if(_sfBaseGeometry.getValue() != NULL)
221 return _sfBaseGeometry.getValue()->getHandleMaterial();
224 return GetFieldHandlePtr();
227 EditFieldHandlePtr GeoInstancer::editHandleMaterial(void)
229 if(_sfBaseGeometry.getValue() != NULL)
231 return _sfBaseGeometry.getValue()->editHandleMaterial();
234 return EditFieldHandlePtr();