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

Method Draw

engine/Poseidon/Graphics/Rendering/Shape/ShapeDraw.cpp:78–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76SectionClassFilter GSectionFilter = SectionClassFilter::All;
77
78void Shape::Draw(class IAnimator* matSource, const LightList& lights, ClipFlags clip, int spec,
79 const Matrix4& transform, const Matrix4& invTransform)
80{
81#ifndef ACCESS_ONLY
82 // if engine has T&L interface, use it
83 // cannot use T&L on some surface types (OnSurface?)
84
85 Engine* engine = GEngine;
86
87 bool tlAble = ((spec & OnSurface) == 0 || engine->GetTLOnSurface()) && (clip & ClipUser0) == 0;
88
89 if (engine->GetTL() && EnableHWTLState && tlAble && _buffer)
90 {
91 if (BeginFaces() < EndFaces() && NSections() > 0)
92 {
93 GEngine->PrepareMeshTL(lights, transform, render::SplitLegacy(spec));
94 if (spec & (OnSurface | IsOnSurface))
95 {
96 engine->SetBias(0x10);
97 }
98 else
99 {
100 int bias = (spec & ZBiasMask) / ZBiasStep;
101 // max. bias value is 3
102 engine->SetBias(bias * 5);
103 }
104 // prepare sections (if neccessary)
105 // prepare lights and materials
106
107 // check if shape is dynamic or not
108 bool dynamic = matSource->GetAnimated(*this);
109 engine->BeginMeshTL(*this, spec, dynamic);
110 // check first face properties
111 int secBeg = -1;
112 int secEnd = -1;
113 Texture* secTexture = (Texture*)-1;
114 int secSpecial = -1;
115 int secMaterial = -1;
116 TexMaterial* secSurfMat = nullptr;
117
118 for (int i = 0; i < NSections(); i++)
119 {
120 const ShapeSection& sec = GetSection(i);
121 if (sec.properties.Special() & (IsHidden | IsHiddenProxy))
122 {
123 continue;
124 }
125
126 // per-section transparency routing: in the opaque pass draw only
127 // opaque+cutout sections, in the back-to-front pass only blend ones.
128 if (GSectionFilter != SectionClassFilter::All)
129 {
130 auto* tex = sec.properties.GetTexture();
131 const bool isBlend = tex && tex->GetAlphaClass() == Poseidon::AlphaStats::Blend;
132 if ((GSectionFilter == SectionClassFilter::BlendOnly) != isBlend)
133 {
134 continue;
135 }

Callers

nothing calls this directly

Calls 15

SplitLegacyFunction · 0.85
DrawWholeShapeInPassFunction · 0.85
GetAlphaClassMethod · 0.80
GetTLOnSurfaceMethod · 0.45
GetTLMethod · 0.45
PrepareMeshTLMethod · 0.45
SetBiasMethod · 0.45
GetAnimatedMethod · 0.45
BeginMeshTLMethod · 0.45
SpecialMethod · 0.45
GetTextureMethod · 0.45
GetMaterialMethod · 0.45

Tested by

no test coverage detected