Skip to content

Commit

Permalink
UPBGE: Fix render of empty meshes.
Browse files Browse the repository at this point in the history
Previously only in VA render when a display array was containing none
vertices then the vertex pointer was NULL. This made that the VA
storage RAS_StorageVA, in function TexCoordPtr was trying to acces to
a virtual function  of a NULL instance. This raise a segmentation fault
error.

To avoid this we simply check if the tv pointer is not NULL in TexCoordPtr.

"Why not simply avoid add mesh slot of an empty mesh renderable ?"
This solution was though but rejected for some reasons:
- Empty meshes are an extremely rare case which is more an user error.
  Using a test to now if a mesh slot can be renderable will slown down all
  other mesh slots which are following the rules.
- It's complicated to detect if a display array is empty, it request
  to test it for every render stage or implement function to call when
  finishing the convertion.

It's strongly deprecated to the user to let an empty mesh visible.
  • Loading branch information
panzergame committed Sep 14, 2016
1 parent 35e7f9f commit 09e36e0
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ RAS_DisplayList *RAS_StorageVA::GetDisplayList(RAS_DisplayArrayBucket *arrayBuck

void RAS_StorageVA::TexCoordPtr(const RAS_ITexVert *tv, const unsigned int stride)
{
// Can be NULL for empty display arrays.
if (!tv) {
return;
}

/* note: this function must closely match EnableTextures to enable/disable
* the right arrays, otherwise coordinate and attribute pointers from other
* materials can still be used and cause crashes */
Expand Down

0 comments on commit 09e36e0

Please sign in to comment.