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

Method buildPartition

Engine/source/lighting/common/blobShadow.cpp:225–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223//--------------------------------------------------------------
224
225void BlobShadow::buildPartition(const Point3F & p, const Point3F & lightDir, F32 radius, F32 shadowLen)
226{
227 setLightMatrices(lightDir,p);
228
229 Point3F extent(2.0f*radius,shadowLen,2.0f*radius);
230 smDepthSortList.clear();
231 smDepthSortList.set(mWorldToLight,extent);
232 smDepthSortList.setInterestNormal(lightDir);
233
234 if (shadowLen<1.0f)
235 // no point in even this short of a shadow...
236 shadowLen = 1.0f;
237 mInvShadowDistance = 1.0f / shadowLen;
238
239 // build world space box and sphere around shadow
240
241 Point3F x,y,z;
242 mLightToWorld.getColumn(0,&x);
243 mLightToWorld.getColumn(1,&y);
244 mLightToWorld.getColumn(2,&z);
245 x *= radius;
246 y *= shadowLen;
247 z *= radius;
248 gBlobShadowBox.maxExtents.set(mFabs(x.x)+mFabs(y.x)+mFabs(z.x),
249 mFabs(x.y)+mFabs(y.y)+mFabs(z.y),
250 mFabs(x.z)+mFabs(y.z)+mFabs(z.z));
251 y *= 0.5f;
252 gBlobShadowSphere.radius = gBlobShadowBox.maxExtents.len();
253 gBlobShadowSphere.center = p + y;
254 gBlobShadowBox.minExtents = y + p - gBlobShadowBox.maxExtents;
255 gBlobShadowBox.maxExtents += y + p;
256
257 // get polys
258
259 gClientContainer.findObjects(STATIC_COLLISION_TYPEMASK, BlobShadow::collisionCallback, this);
260
261 // setup partition list
262 gBlobShadowPoly[0].set(-radius,0,-radius);
263 gBlobShadowPoly[1].set(-radius,0, radius);
264 gBlobShadowPoly[2].set( radius,0, radius);
265 gBlobShadowPoly[3].set( radius,0,-radius);
266
267 mPartition.clear();
268 mPartitionVerts.clear();
269 smDepthSortList.depthPartition(gBlobShadowPoly,4,mPartition,mPartitionVerts);
270
271 if(mPartitionVerts.empty())
272 return;
273
274 // Find the rough distance of the shadow verts
275 // from the object position and use that to scale
276 // the visibleAlpha so that the shadow fades out
277 // the further away from you it gets
278 F32 dist = 0.0f;
279
280 // Calculate the center of the partition verts
281 Point3F shadowCenter(0.0f, 0.0f, 0.0f);
282 for (U32 i = 0; i < mPartitionVerts.size(); i++)

Callers

nothing calls this directly

Calls 15

mFabsFunction · 0.85
mClampFFunction · 0.85
setInterestNormalMethod · 0.80
getColumnMethod · 0.80
findObjectsMethod · 0.80
depthPartitionMethod · 0.80
mulPMethod · 0.80
getFadeValMethod · 0.80
clearMethod · 0.45
setMethod · 0.45
lenMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected