-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement mmBoundTemplate::ComputeEdges() #156
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,74 @@ define_dummy_symbol(mmdyna_bndtmpl); | |
|
||
#include "bndtmpl.h" | ||
|
||
#include "vector7/geomath.h" | ||
|
||
#include "bndtmpl2.h" | ||
#include "poly.h" | ||
|
||
void mmBoundTemplate::ComputeBounds() | ||
{ | ||
GetBoundInfo(NumVerts, Verts, &BBMin, &BBMax, &Center, &Radius); | ||
RadiusSqr = Radius * Radius; | ||
} | ||
|
||
void mmBoundTemplate::ComputeEdges() | ||
{ | ||
i32 total_verts = 0; | ||
|
||
for (i32 i = 0; i < NumPolys; ++i) | ||
{ | ||
total_verts += Polygons[i].GetNumVerts(); | ||
} | ||
|
||
i32* edge_1s = new i32[4 * total_verts]; | ||
i32* edge_2s = new i32[4 * total_verts]; | ||
|
||
i32 num_edges = 0; | ||
|
||
for (i32 j = 0; j < NumPolys; ++j) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can use |
||
{ | ||
mmPolygon& poly = Polygons[j + 1]; | ||
|
||
i32 num_verts = poly.GetNumVerts(); | ||
|
||
i32 v1 = poly.MtlIndex + num_verts; // ? | ||
// Original line: v1 = *((__int16 *)&this->Polygons[j + 1].MtlIndex + num_verts); | ||
Comment on lines
+54
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's doing |
||
|
||
for (i32 k = 0; k < num_verts; ++k) | ||
{ | ||
i32 v2 = poly.VertIndices[k]; | ||
|
||
if (!EdgeInList(v1, v2, num_edges, edge_1s, edge_2s)) | ||
{ | ||
edge_1s[num_edges] = v1; | ||
edge_2s[num_edges++] = v2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather move the |
||
} | ||
|
||
v1 = v2; | ||
} | ||
} | ||
|
||
if (num_edges) | ||
{ | ||
EdgeVerts1 = new u32[4 * num_edges]; | ||
EdgeVerts2 = new u32[4 * num_edges]; | ||
HotVerts = Verts; | ||
NumHotVerts2 = NumVerts; | ||
|
||
for (i32 m = 0; m < num_edges; ++m) | ||
{ | ||
EdgeVerts1[m] = edge_1s[m]; | ||
EdgeVerts2[m] = edge_2s[m]; | ||
} | ||
|
||
NumEdges = num_edges; | ||
} | ||
|
||
delete[] edge_1s; | ||
delete[] edge_2s; | ||
} | ||
|
||
#ifdef ARTS_DEV_BUILD | ||
void mmBoundTemplate::DrawGraph() | ||
{} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code allocates
4 * total_verts
bytes, which is justtotal_verts
ints.