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

Method SurfaceSplit

engine/Poseidon/Graphics/Rendering/Shape/ClipShape.cpp:302–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302void FaceArray::SurfaceSplit(const FaceArray& faces, TLVertexTable& tlMesh, Scene& scene, ClipFlags clipFlags, float y)
303{
304 // note: it may be clipped by any plane
305 clipFlags = ClipAll;
306 // clear the object data
307 Matrix3Val nTrans = scene.CamNormalTrans();
308 Matrix4Val pTrans = scene.ScaledInvTransform();
309
310 Clear();
311
312 // fill with surface split
313 const Camera& camera = *scene.GetCamera();
314 Realloc(faces.Size() * 2 + 8);
315
316 // determine range of landscape squares polygon is in
317 Vector3Val sNo = nTrans.DirectionAside();
318 Vector3Val uNo = nTrans.Direction();
319 Vector3 cNo(VMultiply, nTrans, Vector3(+H_SQRT2 / 2, 0, +H_SQRT2 / 2));
320
321 Poly zTemp1, zTemp2;
322 Poly xTemp1, xTemp2;
323 Poly splitA, splitB;
324 for (int s = 0; s < faces._sections.Size(); s++)
325 {
326 const ShapeSection& sec = faces._sections[s];
327 ShapeSection& dstSec = _sections.Append();
328 dstSec = sec;
329 dstSec.beg = End();
330 for (Offset i = sec.beg, e = sec.end; i < e; faces.Next(i))
331 {
332 Poly source;
333 source = faces[i];
334
335 if (!(source.Special() & OnSurface))
336 {
337 source.CheckClip(tlMesh, camera, clipFlags);
338 if (source.N() >= 3)
339 {
340 Add(source);
341 }
342 continue;
343 }
344
345 Vector3 pos(VFastTransform, scene.CamInvTrans(), tlMesh.TransPosA(source.GetVertex(0)));
346 float xFMin = pos.X(), xFMax = xFMin;
347 float yFMin = pos.Y(), yFMax = yFMin;
348 float zFMin = pos.Z(), zFMax = zFMin;
349 for (int ii = 1; ii < source.N(); ii++)
350 {
351 Vector3 pos(VFastTransform, scene.CamInvTrans(), tlMesh.TransPosA(source.GetVertex(ii)));
352 xFMin = floatMin(xFMin, pos.X());
353 xFMax = floatMax(xFMax, pos.X());
354 yFMin = floatMin(yFMin, pos.Y());
355 yFMax = floatMax(yFMax, pos.Y());
356 zFMin = floatMin(zFMin, pos.Z());
357 zFMax = floatMax(zFMax, pos.Z());
358 }
359

Callers 4

FinalMethod · 0.45
DrawMethod · 0.45
InitMethod · 0.45
DrawShadowMethod · 0.45

Calls 15

AddClass · 0.85
floatMinFunction · 0.85
floatMaxFunction · 0.85
swapFunction · 0.85
GetCameraMethod · 0.80
CheckClipMethod · 0.80
TransPosAMethod · 0.80
GetVertexMethod · 0.80
SplitMethod · 0.80
NormalMethod · 0.80
DMethod · 0.80
CopyPropertiesMethod · 0.80

Tested by

no test coverage detected