Adds handling for the proper updated exporting of mesh for convexShapes

This commit is contained in:
Areloch 2018-03-04 15:10:44 -06:00
parent 49639a908f
commit 787b8be82c
4 changed files with 80 additions and 3 deletions

View file

@ -697,6 +697,57 @@ bool ConvexShape::buildPolyList( PolyListContext context, AbstractPolyList *plis
return true;
}
bool ConvexShape::buildExportPolyList(PolyListContext context, ColladaUtils::ExportData* exportData, const Box3F &box, const SphereF &)
{
if (mGeometry.points.empty())
return false;
//Get the collision mesh geometry
{
ColladaUtils::ExportData::colMesh* colMesh;
exportData->colMeshes.increment();
colMesh = &exportData->colMeshes.last();
colMesh->mesh.setTransform(&mObjToWorld, mObjScale);
colMesh->mesh.setObject(this);
//Just get the visible
buildPolyList(PLC_Export, &colMesh->mesh, getWorldBox(), getWorldSphere());
colMesh->colMeshName = String::ToString("ColMesh%d-1", exportData->colMeshes.size());
}
//Next, process the geometry and materials.
//Convex shapes only have the one 'level', so we'll just rely on the export post-process to back-fill
if (isServerObject() && getClientObject())
{
ConvexShape* clientShape = dynamic_cast<ConvexShape*>(getClientObject());
exportData->meshData.increment();
//Prep a meshData for this shape in particular
ColladaUtils::ExportData::meshLODData* meshData = &exportData->meshData.last();
//Fill out the info we'll need later to actually append our mesh data for the detail levels during the processing phase
meshData->shapeInst = nullptr;
meshData->originatingObject = this;
meshData->meshTransform = mObjToWorld;
meshData->scale = mObjScale;
meshData->fillWithSingleDetail = true;
meshData->meshDetailLevels.increment();
ColladaUtils::ExportData::detailLevel* curDetail = &meshData->meshDetailLevels.last();
//Make sure we denote the size this detail level has
curDetail->size = getNextPow2(getObjBox().len());
bool t = true;
}
return true;
}
void ConvexShape::_export( OptimizedPolyList *plist, const Box3F &box, const SphereF &sphere )
{
BaseMatInstance *matInst = mMaterialInst;

View file

@ -172,6 +172,7 @@ public:
virtual void prepRenderImage( SceneRenderState *state );
virtual void buildConvex( const Box3F &box, Convex *convex );
virtual bool buildPolyList( PolyListContext context, AbstractPolyList *polyList, const Box3F &box, const SphereF &sphere );
virtual bool buildExportPolyList(PolyListContext context, ColladaUtils::ExportData* exportData, const Box3F &box, const SphereF &);
virtual bool castRay( const Point3F &start, const Point3F &end, RayInfo *info );
virtual bool collideBox( const Point3F &start, const Point3F &end, RayInfo *info );

View file

@ -26,6 +26,9 @@
#include "ts/collada/colladaUtils.h"
#include "materials/matInstance.h"
//special handling for export classes
#include "T3D/convexShape.h"
using namespace ColladaUtils;
#define MAX_PATH_LENGTH 256
@ -2994,10 +2997,27 @@ void ColladaUtils::ExportData::processData()
curDetail->mesh.setTransform(&meshData[m].meshTransform, meshData[m].scale);
curDetail->mesh.setObject(meshData[m].originatingObject);
if (!meshData[m].shapeInst->buildPolyList(&curDetail->mesh, detailLevelIdx))
if (meshData[m].shapeInst != nullptr)
{
Con::errorf("TSStatic::buildExportPolyList - failed to build polylist for LOD %i", i);
continue;
if (!meshData[m].shapeInst->buildPolyList(&curDetail->mesh, detailLevelIdx))
{
Con::errorf("TSStatic::buildExportPolyList - failed to build polylist for LOD %i", i);
continue;
}
}
else
{
//special handling classes
ConvexShape* convexShp = dynamic_cast<ConvexShape*>(meshData[m].originatingObject);
if (convexShp != nullptr)
{
if (!convexShp->buildPolyList(PLC_Export, &curDetail->mesh, meshData[m].originatingObject->getWorldBox(), meshData[m].originatingObject->getWorldSphere()))
{
Con::errorf("TSStatic::buildExportPolyList - failed to build ConvexShape polylist for LOD %i", i);
continue;
}
}
}
//lastly, get material

View file

@ -140,6 +140,8 @@ namespace ColladaUtils
Point3F scale;
bool fillWithSingleDetail;
S32 hasDetailLevel(S32 size)
{
for (U32 i = 0; i < meshDetailLevels.size(); ++i)
@ -152,6 +154,9 @@ namespace ColladaUtils
return -1;
}
meshLODData() : shapeInst(nullptr), meshTransform(true), originatingObject(nullptr), scale(0), fillWithSingleDetail(false)
{}
};
struct colMesh