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

Method TryGetSurfaceData

Source/Engine/Level/Scene/SceneCSGData.cpp:67–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67bool SceneCSGData::TryGetSurfaceData(const Guid& brushId, int32 brushSurfaceIndex, SurfaceData& outData)
68{
69 if (Data == nullptr || !Data->IsLoaded() || Data->Data.IsEmpty())
70 {
71 // Missing data or not loaded
72 return false;
73 }
74
75 MemoryReadStream stream(Data->Data);
76
77 // Check if has missing cache
78 if (DataBrushLocations.IsEmpty())
79 {
80 int32 version;
81 stream.ReadInt32(&version);
82 if (version == 1)
83 {
84 int32 brushesCount;
85 stream.ReadInt32(&brushesCount);
86 if (brushesCount < 0)
87 {
88 // Invalid data
89 return false;
90 }
91 DataBrushLocations.EnsureCapacity(brushesCount);
92 for (int32 i = 0; i < brushesCount; i++)
93 {
94 Guid id;
95 int32 pos;
96 stream.Read(id);
97 stream.ReadInt32(&pos);
98 DataBrushLocations.Add(id, pos);
99 }
100 }
101 else
102 {
103 // Unknown version
104 LOG(Warning, "Unknwon version for scene CSG surface data (or corrupted file).");
105 return false;
106 }
107 }
108
109 // Find brush data
110 int32 brushLocation;
111 if (!DataBrushLocations.TryGet(brushId, brushLocation))
112 {
113 // Brush not found
114 return false;
115 }
116
117 stream.SetPosition(brushLocation);
118
119 // Skip leading surfaces data
120 int32 trianglesCount;
121 while (brushSurfaceIndex-- > 0)
122 {
123 stream.ReadInt32(&trianglesCount);
124 if (trianglesCount < 0 || trianglesCount > 100)

Callers 2

IntersectsMethod · 0.80
GetVerticesMethod · 0.80

Calls 12

IsLoadedMethod · 0.45
IsEmptyMethod · 0.45
ReadInt32Method · 0.45
EnsureCapacityMethod · 0.45
ReadMethod · 0.45
AddMethod · 0.45
TryGetMethod · 0.45
SetPositionMethod · 0.45
MoveMethod · 0.45
ClearMethod · 0.45
ResizeMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected