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

Method Init

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

Source from the content-addressed store, hash-verified

41RemmemberShadow::RemmemberShadow() : _object(nullptr), _lightDir(NoInit), _splitOnly(false) {}
42
43void RemmemberShadow::Init(Object* object, Vector3Par lightDir, int level, Matrix4Par pos, bool splitOnly)
44{
45 // splitOnly is used for object that should be split
46 // but not shadow projected
47 // such shapes also preserve original y offset
48 _object = object;
49 _lightDir = lightDir;
50 _objectPos = pos;
51 _level = level;
52 _lastUsed = Glob.time;
53 _splitOnly = splitOnly;
54 if (splitOnly)
55 {
56 // copy source data
57 _shadow = new Shape(*object->GetShape()->Level(level), false);
58 }
59 else
60 {
61 // A frozen-pose dynamic caster (settled corpse) shares its shape with
62 // every other instance of the model — the shared shape holds whichever
63 // instance animated last, so this object's pose must be skinned in
64 // before projecting. Statics skip this (Animate is a no-op).
65 const bool animatePose = !object->Static();
66 if (animatePose)
67 {
68 object->Animate(level);
69 }
70 // retainStructure = false -> force duplicating source data
71 _shadow = object->RecalcShadow(level, *object, false);
72 if (animatePose)
73 {
74 object->Deanimate(level);
75 }
76 }
77 if (_shadow)
78 {
79 _shadow->SurfaceSplit(GScene->GetLandscape(), object->Transform(), GLOB_ENGINE->ZShadowEpsilon(),
80 splitOnly ? object->Scale() : 0);
81 // it is already fitted - prevent future surface fitting
82 _shadow->CalculateMinMax();
83 _shadow->AndSpecial(~OnSurface);
84 _shadow->OrSpecial(IsOnSurface);
85 // make sure buffer is regenerated
86 _shadow->ReleaseVBuffer();
87 // optimize it for HW rendering
88 _shadow->FindSections();
89 if (_shadow->NVertex() > 1024)
90 {
91 _shadow->ConvertToVBuffer(VBBigDiscardable);
92 }
93 else
94 {
95 _shadow->ConvertToVBuffer(VBSmallDiscardable);
96 }
97
98 // table should be exact - for best memory usage
99 _shadow->Compact();
100 }

Callers 6

ReserveFacesMethod · 0.45
FaceArrayMethod · 0.45
ExtractPathMethod · 0.45
ShadowMethod · 0.45
InitConvexComponentsMethod · 0.45
SetSectionsMethod · 0.45

Calls 15

LevelMethod · 0.80
RecalcShadowMethod · 0.80
GetLandscapeMethod · 0.80
ReleaseVBufferMethod · 0.80
FindSectionsMethod · 0.80
ConvertToVBufferMethod · 0.80
GetShapeMethod · 0.45
AnimateMethod · 0.45
DeanimateMethod · 0.45
SurfaceSplitMethod · 0.45
TransformMethod · 0.45
ZShadowEpsilonMethod · 0.45

Tested by

no test coverage detected