MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / PerformOperation

Method PerformOperation

Source/Engine/CSG/CSGMesh.cpp:22–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22void CSG::Mesh::PerformOperation(Mesh* other)
23{
24 ASSERT(other->_brushesMeta.Count() > 0);
25
26 // Check if has more than one submeshes
27 if (other->_brushesMeta.Count() > 1)
28 {
29 // Just add all subbrushes
30 Add(other);
31 }
32 else
33 {
34 auto mode = other->_brushesMeta[0].Mode;
35
36 // Switch between mesh operation mode
37 switch (mode)
38 {
39 case Mode::Additive:
40 {
41 // Check if both meshes do not intersect
42 if (AABB::IsOutside(_bounds, other->GetBounds())) // TODO: test every sub bounds not whole _bounds
43 {
44 // Add vertices to the mesh without any additional calculations
45 Add(other);
46 }
47 else
48 {
49 // Remove common part from other mesh and then combine them
50 //intersect(other, Remove, Keep);
51 Add(other);
52
53 // TODO: ogarnac to bo to jest zle xD
54 }
55 }
56 break;
57
58 case Mode::Subtractive:
59 {
60 // Check if both meshes do not intersect
61 if (AABB::IsOutside(_bounds, other->GetBounds())) // TODO: test every sub bounds not whole _bounds
62 {
63 // Do nothing
64 }
65 else
66 {
67 // Perform intersection operations
68 intersect(other, Remove, Keep);
69 other->intersect(this, Flip, Remove);
70
71 // Merge meshes
72 Add(other);
73 }
74 }
75 break;
76 }
77 }
78}
79

Callers 1

CombineFunction · 0.80

Calls 6

IsOutsideFunction · 0.85
intersectMethod · 0.80
AddFunction · 0.50
intersectFunction · 0.50
CountMethod · 0.45
GetBoundsMethod · 0.45

Tested by

no test coverage detected