Skip to content

Commit

Permalink
UPBGE: Don't tag empty display array for bounding box update.
Browse files Browse the repository at this point in the history
If empty array are detected in a mesh they are not added in the
tracked list of the boundign box, if this list is empty a dummy
bounding box is created instead of a mesh bouning box.
  • Loading branch information
panzergame committed Nov 20, 2017
1 parent ca95d10 commit 99a7910
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion source/gameengine/Expressions/EXP_PyObjectPlus.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ typedef struct EXP_PYATTRIBUTE_DEF {
template <class ... Args>
inline bool EXP_ParseTupleArgsAndKeywords(PyObject *pyargs, PyObject *pykwds, const char *format, std::initializer_list<const char *> keyword, Args ... args)
{
BLI_assert((keyword.size() - 1) == (sizeof...Args));
BLI_assert((keyword.size() - 1) == (sizeof...(Args)));
static _PyArg_Parser _parser = {format, keyword.begin(), 0};
return _PyArg_ParseTupleAndKeywordsFast(pyargs, pykwds, &_parser, args ...);
}
Expand Down
20 changes: 15 additions & 5 deletions source/gameengine/Rasterizer/RAS_MeshObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,31 @@ void RAS_MeshObject::EndConversion(RAS_BoundingBoxManager *boundingBoxManager)
for (RAS_MeshMaterial *meshmat : m_materials) {
RAS_IDisplayArray *array = meshmat->GetDisplayArray();
array->UpdateCache();
arrayList.push_back(array);

const std::string materialname = meshmat->GetBucket()->GetPolyMaterial()->GetName();
if (array->GetVertexCount() == 0) {
CM_Warning("mesh \"" << m_name << "\" has no vertices for material \"" << materialname
<< "\". It introduces performance decrease for empty render.");
}
else if (array->GetPrimitiveIndexCount() == 0) {
CM_Warning("mesh \"" << m_name << "\" has no polygons for material \"" << materialname
else {
// Generate bounding box only for non-empty display arrays.
arrayList.push_back(array);
}

if (array->GetPrimitiveIndexCount() == 0) {
CM_Warning("mesh \"" << m_name << "\" has no primitives for material \"" << materialname
<< "\". It introduces performance decrease for empty render.");
}
}

// Construct the bounding box of this mesh without deformers.
m_boundingBox = boundingBoxManager->CreateMeshBoundingBox(arrayList);
if (arrayList.empty()) {
// Use a dummy bounding box if there's no valid display arrays.
m_boundingBox = boundingBoxManager->CreateBoundingBox();
}
else {
// Construct the bounding box of this mesh without deformers.
m_boundingBox = boundingBoxManager->CreateMeshBoundingBox(arrayList);
}
m_boundingBox->Update(true);

// Construct polygon range info.
Expand Down

0 comments on commit 99a7910

Please sign in to comment.