Skip to content

Commit

Permalink
UPBGE: Fix reinstance physics mesh with wire material.
Browse files Browse the repository at this point in the history
Previously when a mesh using a wire material was converted the
polygons (RAS_Polygons) were added but ths indices were invalid
because we followed the same condition that select to add indices
for polygons or for lines.
This caused to have invalid polygons when reinstancing physics
mesh.

To fix this issue the polygons always get the indices in the same
way for lines of real polygons.

Reported by HG1.
  • Loading branch information
panzergame committed Jun 4, 2017
1 parent fedadad commit 3801c52
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions source/gameengine/Rasterizer/RAS_MeshObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,21 @@ RAS_Polygon *RAS_MeshObject::AddPolygon(RAS_MeshMaterial *meshmat, int numverts,
poly->SetCollider(collider);
poly->SetTwoside(twoside);

for (unsigned short i = 0; i < numverts; ++i) {
poly->SetVertexOffset(i, indices[i]);
}

if (visible && !bucket->IsWire()) {
// Add the first triangle.
darray->AddIndex(indices[0]);
darray->AddIndex(indices[1]);
darray->AddIndex(indices[2]);

poly->SetVertexOffset(0, indices[0]);
poly->SetVertexOffset(1, indices[1]);
poly->SetVertexOffset(2, indices[2]);

if (numverts == 4) {
// Add the second triangle.
darray->AddIndex(indices[0]);
darray->AddIndex(indices[2]);
darray->AddIndex(indices[3]);

poly->SetVertexOffset(3, indices[3]);
}
}

Expand Down

0 comments on commit 3801c52

Please sign in to comment.