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

Method DrawMesh

engine/Poseidon/World/Terrain/LandscapeRender.cpp:58–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56extern bool EnableObjOcc;
57
58void Landscape::DrawMesh(Scene& scene, TLVertexTable& table, const Shape& vMesh, Vector3Par offset,
59 const LandBegEnd& rect, bool isWater)
60{
61 GTerrainProfile.drawMeshCalls++;
62 // exact per-segment clip rejection
63 Vector3Val bCenter = vMesh.BSphereCenter() + offset;
64 float bRadius = vMesh.BSphereRadius();
65
66 // Point3 bCenterView(VFastTransform,GScene->ScaledInvTransform(),bCenter);
67 if (scene.GetCamera()->IsClipped(bCenter, bRadius, 1))
68 {
69 GTerrainProfile.drawMeshClipped++;
70 return;
71 }
72 ClipFlags clip = scene.GetCamera()->MayBeClipped(bCenter, bRadius, 1);
73 ClipFlags andClip = ClipNone;
74 ClipFlags orClip = table.CheckClipping(*scene.GetCamera(), clip, andClip);
75 if (andClip & ClipAll)
76 {
77 return;
78 }
79
80 // select lights on per-segment basis
81 LightList work(true);
82 const LightList& lights = scene.SelectLights(bCenter, bRadius, work);
83
84 table.DoLightingColorized(lights, _colorizePalette, vMesh, 0);
85
86 // there will be many vertices clipped
87 // we want vertex mesh and table to grow fast to avoid many allocations
88
89 if (isWater)
90 {
91 // animate all vertices
92 Texture* tex = _texture[0];
93 if (tex)
94 {
95 for (int i = 0; i < table.NVertex(); i++)
96 {
97 Vector3Val pos = vMesh.Pos(i);
98 float u = tex->UToLogical(table.U(i));
99 float v = tex->VToLogical(table.V(i));
100 float x = pos.X() * _invLandGrid;
101 float z = pos.Z() * _invLandGrid;
102 float mw = MoveWater(x, z, 0.3);
103 table.SetUV(i, tex->UToPhysical(u + mw * 0.5), tex->VToPhysical(v + mw));
104 }
105 }
106 }
107
108 // prepare surface for drawing
109 const FaceArray& sFaces = vMesh.Faces();
110 const FaceArray* drawFaces = &sFaces;
111 FaceArray clippedFaces;
112 // copy all faces and perform per-face clipping
113
114 if (orClip || isWater)
115 {

Callers

nothing calls this directly

Calls 15

MoveWaterFunction · 0.85
fastFmodFunction · 0.85
saturateFunction · 0.85
saturateMinFunction · 0.85
floatMaxFunction · 0.85
BSphereCenterMethod · 0.80
BSphereRadiusMethod · 0.80
IsClippedMethod · 0.80
GetCameraMethod · 0.80
MayBeClippedMethod · 0.80
CheckClippingMethod · 0.80
DoLightingColorizedMethod · 0.80

Tested by

no test coverage detected