MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / RecalcShadow

Method RecalcShadow

engine/Poseidon/Graphics/Rendering/Shape/Shadow.cpp:332–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332Ref<Shape> Object::RecalcShadow(int level, const FrameBase& frame, bool retainStructure, LODShapeWithShadow* forceShape)
333{
334 // all polygons cast shadows
335 // project all points to ground level
336 int i;
337 Matrix4Val iTrans = frame.GetInvTransform();
338 float y = GEngine->ZShadowEpsilon();
339
340 Ref<LODShape> shadow = nullptr;
341 if (!forceShape)
342 {
343 forceShape = _shape;
344 }
345 if (retainStructure)
346 {
347 // note: _shape may be used only when retainStructure is true
348 forceShape->CreateShadow();
349 shadow = forceShape->Shadow();
350 }
351 else
352 {
353 shadow = forceShape->MakeShadow();
354 }
355
356 if (!shadow)
357 {
358 return nullptr;
359 }
360 Ref<Shape> shape = shadow->Level(level);
361 Shape* orig = forceShape->Level(level);
362 if (shape && shape->NFaces() >= 0)
363 {
364 Vector3Val lightDir = GScene->MainLight()->ShadowDirection();
365 Vector3 modelLightDir = iTrans.Rotate(lightDir);
366 if ((orig->GetAndHints() & ClipDecalMask) == ClipDecalVertical &&
367 (orig->GetOrHints() & ClipDecalMask) == ClipDecalVertical)
368 {
369 // special case - shadow casted by vertical decal
370 LOG_DEBUG(Graphics, "Vertical decal shadow obsolete");
371 return nullptr;
372 }
373 else
374 {
375 FaceArray dest;
376 if (!retainStructure)
377 {
378 dest.ReserveFaces(1024, false);
379 // reserve same size as source
380 dest.ReserveRaw(shape->Faces().RawSize());
381 }
382 // make sure offsets in both shapes match
383
384 for (Offset f = shape->BeginFaces(), e = shape->EndFaces(); f < e; shape->NextFace(f))
385 {
386 const Poly& sFace = orig->Face(f);
387 Poly& face = shape->Face(f);
388 // make sure both sFace and face are valid face pointers
389 if (face.N() < 3)

Callers 2

DrawExShadowMethod · 0.80
InitMethod · 0.80

Calls 15

CreateShadowMethod · 0.80
MakeShadowMethod · 0.80
LevelMethod · 0.80
ShadowDirectionMethod · 0.80
MainLightMethod · 0.80
ReserveRawMethod · 0.80
BeginFacesMethod · 0.80
EndFacesMethod · 0.80
NextFaceMethod · 0.80
GetVertexMethod · 0.80
PosMethod · 0.80
ShadowPosMethod · 0.80

Tested by

no test coverage detected