MCPcopy Create free account
hub / github.com/OpenMW/openmw / apply

Method apply

components/sceneutil/util.cpp:101–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99 }
100
101 void GlowUpdater::apply(osg::StateSet* stateset, osg::NodeVisitor* nv)
102 {
103 if (mColorChanged)
104 {
105 this->reset();
106 setDefaults(stateset);
107 mColorChanged = false;
108 }
109 if (mDone)
110 return;
111
112 // Set the starting time to measure glow duration from if this is a temporary glow
113 if ((mDuration >= 0) && mStartingTime == 0)
114 mStartingTime = nv->getFrameStamp()->getSimulationTime();
115
116 double time = nv->getFrameStamp()->getSimulationTime();
117 int index = static_cast<int>(time * 16) % mTextures.size();
118 stateset->setTextureAttribute(
119 mTexUnit, mTextures[index], osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
120
121 if ((mDuration >= 0)
122 && (time - mStartingTime > mDuration)) // If this is a temporary glow and it has finished its duration
123 {
124 if (mOriginalDuration >= 0) // if this glowupdater was a temporary glow since its creation
125 {
126 removeTexture(stateset);
127 this->reset();
128 mDone = true;
129 // normally done in StateSetUpdater::operator(), but needs doing here so the shader visitor sees the
130 // right StateSet
131 mNode->setStateSet(stateset);
132 mResourceSystem->getSceneManager()->recreateShaders(mNode);
133 }
134 if (mOriginalDuration < 0) // if this glowupdater was originally a permanent glow
135 {
136 mDuration = mOriginalDuration;
137 mStartingTime = 0;
138 mColor = mOriginalColor;
139 this->reset();
140 setDefaults(stateset);
141 }
142 }
143 }
144
145 bool GlowUpdater::isPermanentGlowUpdater()
146 {

Callers 5

cullMethod · 0.45
acceptMethod · 0.45
acceptMethod · 0.45
cullMethod · 0.45
acceptMethod · 0.45

Calls 6

getSimulationTimeMethod · 0.80
setTextureAttributeMethod · 0.80
recreateShadersMethod · 0.80
getSceneManagerMethod · 0.80
resetMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected