MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / onAdd

Method onAdd

Engine/source/environment/VolumetricFog.cpp:235–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235bool VolumetricFog::onAdd()
236{
237 if (!Parent::onAdd())
238 return false;
239
240 if (!VFRTM->IsInitialized())
241 {
242 Con::errorf("No VolumetricFogRTManager present!!");
243 return false;
244 }
245
246 resetWorldBox();
247
248 mShapeLoaded = LoadShape();
249
250 setRenderTransform(mObjToWorld);
251
252 addToScene();
253 ColBox.set(getTransform(), (mObjBox.getExtents() * getScale() * COLBOX_SCALE));
254 mObjSize = mWorldBox.getGreatestDiagonalLength();
255 mObjScale = getScale();
256 mTexTiles = mAbs(mTexTiles);
257 mSpeed.set(mSpeed1.x, mSpeed1.y, mSpeed2.x, mSpeed2.y);
258 mInvScale = (1.0f / getMax(getMax(mObjScale.x, mObjScale.y), mObjScale.z));
259
260 VFRTM->IncFogObjects();
261
262 if (isClientObject())
263 {
264 conn = GameConnection::getConnectionToServer();
265 if (!conn)
266 {
267 Con::errorf("VolumetricFog::onAdd - No Serverconnection");
268 return false;
269 }
270
271 glowFX = static_cast<PostEffect*>(Sim::findObject("VolFogGlowPostFx"));
272
273 mOldLightRayStrength = Con::getFloatVariable("$LightRayPostFX::brightScalar",1.0f);
274
275 GuiCanvas* cv = dynamic_cast<GuiCanvas*>(Sim::findObject("Canvas"));
276 if (cv == NULL)
277 {
278 Con::errorf("VolumetricFog::onAdd - Canvas not found!!");
279 return false;
280 }
281 mPlatformWindow = cv->getPlatformWindow();
282 VolumetricFogRTManager::getVolumetricFogRTMResizeSignal().notify(this, &VolumetricFog::handleResize);
283 GuiCanvas::getCanvasSizeChangeSignal().notify(this, &VolumetricFog::handleCanvasResize);
284
285 InitTexture();
286 return setupRenderer();
287 }
288
289 return true;
290}
291
292void VolumetricFog::onRemove()

Callers

nothing calls this directly

Calls 12

mAbsFunction · 0.85
getMaxFunction · 0.85
getFloatVariableFunction · 0.85
getExtentsMethod · 0.80
IncFogObjectsMethod · 0.80
getPlatformWindowMethod · 0.80
errorfFunction · 0.50
findObjectFunction · 0.50
IsInitializedMethod · 0.45
setMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected