mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-20 06:06:13 +00:00
Changed: #929 Some reliability fixes for the max export plugin.
This commit is contained in:
parent
46de2a84b1
commit
f97b47eef1
18 changed files with 914 additions and 765 deletions
|
@ -17,6 +17,7 @@
|
|||
#include "std_afx.h"
|
||||
#include "nel_export.h"
|
||||
#include "nel/misc/file.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/3d/shape.h"
|
||||
#include "nel/3d/animation.h"
|
||||
#include "nel/3d/skeleton_shape.h"
|
||||
|
@ -35,7 +36,11 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
|
|||
{
|
||||
// Result to return
|
||||
bool bRet = false;
|
||||
char tempName[L_tmpnam];
|
||||
tmpnam(tempName);
|
||||
|
||||
try
|
||||
{
|
||||
// Eval the object a time
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
|
||||
|
@ -43,7 +48,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
|
|||
if (os.obj)
|
||||
{
|
||||
// Skeleton shape
|
||||
CSkeletonShape *skeletonShape=NULL;
|
||||
CSmartPtr<CSkeletonShape> skeletonShape = NULL;
|
||||
TInodePtrInt *mapIdPtr=NULL;
|
||||
TInodePtrInt mapId;
|
||||
|
||||
|
@ -64,14 +69,13 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
|
|||
CExportNel::addSkeletonBindPos (node, boneBindPos);
|
||||
|
||||
// Build the skeleton based on the bind pos information
|
||||
_ExportNel->buildSkeletonShape (*skeletonShape, *skeletonRoot, &boneBindPos, mapId, time);
|
||||
_ExportNel->buildSkeletonShape(*skeletonShape.getPtr(), *skeletonRoot, &boneBindPos, mapId, time);
|
||||
|
||||
// Set the pointer to not NULL
|
||||
mapIdPtr=&mapId;
|
||||
|
||||
// Erase the skeleton
|
||||
if (skeletonShape)
|
||||
delete skeletonShape;
|
||||
skeletonShape = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,16 +83,16 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
|
|||
if (InfoLog)
|
||||
InfoLog->display("Beg buildShape %s \n", node.GetName());
|
||||
// Export in mesh format
|
||||
IShape* pShape=_ExportNel->buildShape (node, time, mapIdPtr, true);
|
||||
CSmartPtr<IShape> pShape = _ExportNel->buildShape(node, time, mapIdPtr, true);
|
||||
if (InfoLog)
|
||||
InfoLog->display("End buildShape in %d ms \n", timeGetTime()-t);
|
||||
|
||||
// Conversion success ?
|
||||
if (pShape)
|
||||
if (pShape.getPtr())
|
||||
{
|
||||
// Open a file
|
||||
COFile file;
|
||||
if (file.open (sPath))
|
||||
if (file.open(tempName))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -104,24 +108,60 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
|
|||
catch (...)
|
||||
{
|
||||
nlwarning("Shape serialization failed!");
|
||||
try
|
||||
{
|
||||
file.close();
|
||||
remove(sPath);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
}
|
||||
remove(tempName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Failed to create file %s", tempName);
|
||||
}
|
||||
|
||||
// Delete the pointer
|
||||
nldebug ("Delete the pointer");
|
||||
try
|
||||
{
|
||||
// memory leak, fixme
|
||||
// delete pShape;
|
||||
bool tempBRet = bRet;
|
||||
bRet = false;
|
||||
pShape = NULL;
|
||||
bRet = tempBRet;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
nlwarning("Failed to delete pShape pointer! Something might be wrong.");
|
||||
remove(tempName);
|
||||
bRet = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
nlwarning("Fatal exception at CNelExport::exportMesh.");
|
||||
bRet = false;
|
||||
}
|
||||
|
||||
if (bRet)
|
||||
{
|
||||
try
|
||||
{
|
||||
remove(sPath);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
}
|
||||
CFile::moveFile(sPath, tempName);
|
||||
nlinfo("MOVE %s -> %s", tempName, sPath);
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,8 @@ SLightBuild::SLightBuild()
|
|||
bool SLightBuild::canConvertFromMaxLight (INode *node, TimeValue tvTime)
|
||||
{
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node->EvalWorldState(tvTime).obj;
|
||||
ObjectState os = node->EvalWorldState(tvTime);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (!obj)
|
||||
|
@ -98,7 +99,7 @@ bool SLightBuild::canConvertFromMaxLight (INode *node, TimeValue tvTime)
|
|||
return false;
|
||||
|
||||
if( deleteIt )
|
||||
maxLight->DeleteMe();
|
||||
maxLight->MaybeAutoDelete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -107,7 +108,8 @@ bool SLightBuild::canConvertFromMaxLight (INode *node, TimeValue tvTime)
|
|||
void SLightBuild::convertFromMaxLight (INode *node,TimeValue tvTime)
|
||||
{
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node->EvalWorldState(tvTime).obj;
|
||||
ObjectState os = node->EvalWorldState(tvTime);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (!obj) return;
|
||||
|
@ -295,7 +297,7 @@ void SLightBuild::convertFromMaxLight (INode *node,TimeValue tvTime)
|
|||
this->rSoftShadowConeLength = (float)atof(sTmp.c_str());
|
||||
|
||||
if( deleteIt )
|
||||
maxLight->DeleteMe();
|
||||
maxLight->MaybeAutoDelete();
|
||||
}
|
||||
|
||||
// ***********************************************************************************************
|
||||
|
@ -2401,7 +2403,10 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB
|
|||
TempPlanes[nPlaneNb]->copyFirstLayerTo(*AllPlanes[AllPlanesPrevSize+nPlaneNb],(uint8)nLight);
|
||||
|
||||
for( nPlaneNb = 0; nPlaneNb < (sint)FaceGroupByPlane.size(); ++nPlaneNb )
|
||||
{
|
||||
delete TempPlanes[nPlaneNb];
|
||||
TempPlanes[nPlaneNb] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Next group of face with the same smooth group and the same material
|
||||
|
@ -2497,6 +2502,7 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB
|
|||
MoveFaceUV1( AllPlanes[i]->faces.begin(), AllPlanes[i]->faces.size(),
|
||||
AllPlanes[i]->x, AllPlanes[i]->y );
|
||||
delete AllPlanes[i];
|
||||
AllPlanes[i] = NULL;
|
||||
}
|
||||
|
||||
// Save the lightmap
|
||||
|
|
|
@ -264,6 +264,7 @@ void CExportNel::addParticleSystemTracks(CAnimation& animation, INode& node, con
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -281,6 +282,7 @@ void CExportNel::addParticleSystemTracks(CAnimation& animation, INode& node, con
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -325,6 +327,7 @@ void CExportNel::addNodeTracks (CAnimation& animation, INode& node, const char*
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -348,6 +351,7 @@ void CExportNel::addNodeTracks (CAnimation& animation, INode& node, const char*
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -371,6 +375,7 @@ void CExportNel::addNodeTracks (CAnimation& animation, INode& node, const char*
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -389,6 +394,7 @@ void CExportNel::addNodeTracks (CAnimation& animation, INode& node, const char*
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -413,6 +419,7 @@ void CExportNel::addNodeTracks (CAnimation& animation, INode& node, const char*
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -443,6 +450,7 @@ void CExportNel::addNodeTracks (CAnimation& animation, INode& node, const char*
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -541,7 +549,8 @@ void CExportNel::addLightTracks (NL3D::CAnimation& animation, INode& node, const
|
|||
{
|
||||
CExportDesc desc;
|
||||
|
||||
Object *obj = node.EvalWorldState(0).obj;
|
||||
ObjectState os = node.EvalWorldState(0);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (!obj)
|
||||
|
@ -567,6 +576,7 @@ void CExportNel::addLightTracks (NL3D::CAnimation& animation, INode& node, const
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -609,6 +619,7 @@ void CExportNel::addMorphTracks (NL3D::CAnimation& animation, INode& node, const
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -639,6 +650,7 @@ void CExportNel::addObjTracks (CAnimation& animation, Object& obj, const char* p
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -681,6 +693,7 @@ void CExportNel::addMtlTracks (CAnimation& animation, Mtl& mtl, const char* pare
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -705,6 +718,7 @@ void CExportNel::addMtlTracks (CAnimation& animation, Mtl& mtl, const char* pare
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -731,6 +745,7 @@ void CExportNel::addMtlTracks (CAnimation& animation, Mtl& mtl, const char* pare
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -755,6 +770,7 @@ void CExportNel::addMtlTracks (CAnimation& animation, Mtl& mtl, const char* pare
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -779,6 +795,7 @@ void CExportNel::addMtlTracks (CAnimation& animation, Mtl& mtl, const char* pare
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -862,6 +879,7 @@ void CExportNel::addTexTracks (CAnimation& animation, Texmap& tex, uint stage, c
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -884,6 +902,7 @@ void CExportNel::addTexTracks (CAnimation& animation, Texmap& tex, uint stage, c
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -906,6 +925,7 @@ void CExportNel::addTexTracks (CAnimation& animation, Texmap& tex, uint stage, c
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -928,6 +948,7 @@ void CExportNel::addTexTracks (CAnimation& animation, Texmap& tex, uint stage, c
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -950,6 +971,7 @@ void CExportNel::addTexTracks (CAnimation& animation, Texmap& tex, uint stage, c
|
|||
if (animation.getTrackByName (name.c_str()))
|
||||
{
|
||||
delete pTrack;
|
||||
pTrack = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -60,7 +60,8 @@ CCollisionMeshBuild* CExportNel::createCollisionMeshBuild(std::vector<INode *> &
|
|||
for (node=0; node<nodes.size(); ++node)
|
||||
{
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = nodes[node]->EvalWorldState(tvTime).obj;
|
||||
ObjectState os = nodes[node]->EvalWorldState(tvTime);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
|
@ -71,6 +72,8 @@ CCollisionMeshBuild* CExportNel::createCollisionMeshBuild(std::vector<INode *> &
|
|||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject*)obj->ConvertToType(tvTime, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
|
||||
if (tri)
|
||||
{
|
||||
// get the mesh name
|
||||
uint meshId = rootMeshNames.size();
|
||||
rootMeshNames.push_back(nodes[node]->GetName());
|
||||
|
@ -135,7 +138,9 @@ CCollisionMeshBuild* CExportNel::createCollisionMeshBuild(std::vector<INode *> &
|
|||
|
||||
// Delete the triObject if we should...
|
||||
if (deleteIt)
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -436,6 +441,7 @@ void CExportNel::computeCollisionRetrieverFromScene(TimeValue time,
|
|||
|
||||
// free the CCollisionMeshBuild.
|
||||
delete pCmb;
|
||||
pCmb = NULL;
|
||||
|
||||
// does igname match prefix/suffix???
|
||||
if(igname.find(igNamePrefix)==0)
|
||||
|
|
|
@ -200,7 +200,8 @@ void CExportNel::getLights (std::vector<CLight>& vectLight, TimeValue time, INod
|
|||
node=_Ip->GetRootNode();
|
||||
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node->EvalWorldState(time).obj;
|
||||
ObjectState os = node->EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
|
@ -235,9 +236,9 @@ void CExportNel::getLights (std::vector<CLight>& vectLight, TimeValue time, INod
|
|||
// Add the light in the list
|
||||
vectLight.push_back (nelLight);
|
||||
|
||||
// Delete the triObject if we should...
|
||||
// Delete the GenLight if we should...
|
||||
if (deleteIt)
|
||||
maxLight->DeleteMe();
|
||||
maxLight->MaybeAutoDelete();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ bool CExportNel::buildLodCharacter (NL3D::CLodCharacterShapeBuild& lodBuild, IN
|
|||
return false;
|
||||
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node.EvalWorldState(time).obj;
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
|
@ -55,7 +56,8 @@ bool CExportNel::buildLodCharacter (NL3D::CLodCharacterShapeBuild& lodBuild, IN
|
|||
{
|
||||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject *) obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
|
||||
if (tri)
|
||||
{
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
// pointer that called ConvertToType()
|
||||
|
@ -177,7 +179,8 @@ bool CExportNel::buildLodCharacter (NL3D::CLodCharacterShapeBuild& lodBuild, IN
|
|||
|
||||
// Delete the triObject if we should...
|
||||
if (deleteIt)
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1294,6 +1294,7 @@ ITexture* CExportNel::buildATexture (Texmap& texmap, CMaterialDesc &remap3dsTexC
|
|||
// Ok, good texture
|
||||
pTexture=pTextureCube;
|
||||
delete srcTex;
|
||||
srcTex = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -68,7 +68,8 @@ CMesh::CMeshBuild* CExportNel::createMeshBuild(INode& node, TimeValue tvTime, CM
|
|||
baseBuild = new CMeshBase::CMeshBaseBuild();
|
||||
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node.EvalWorldState(tvTime).obj;
|
||||
ObjectState os = node.EvalWorldState(tvTime);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
|
@ -79,6 +80,8 @@ CMesh::CMeshBuild* CExportNel::createMeshBuild(INode& node, TimeValue tvTime, CM
|
|||
{
|
||||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject*)obj->ConvertToType(tvTime, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
if (tri)
|
||||
{
|
||||
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
|
@ -107,7 +110,9 @@ CMesh::CMeshBuild* CExportNel::createMeshBuild(INode& node, TimeValue tvTime, CM
|
|||
|
||||
// Delete the triObject if we should...
|
||||
if (deleteIt)
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
tri = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +131,7 @@ static void copyMultiLodMeshBaseLod0Infos(CMeshBase::CMeshBaseBuild &dst, const
|
|||
|
||||
// ***************************************************************************
|
||||
// Export a mesh
|
||||
IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt *nodeMap, bool buildLods)
|
||||
NLMISC::CSmartPtr<NL3D::IShape> CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt *nodeMap, bool buildLods)
|
||||
{
|
||||
|
||||
// Is this a multi lod object ?
|
||||
|
@ -134,14 +139,15 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|||
|
||||
// Here, we must check what kind of node we can build with this mesh.
|
||||
// For the time, just Triobj is supported.
|
||||
IShape *retShape=NULL;
|
||||
CSmartPtr<IShape> retShape = NULL;
|
||||
|
||||
// If skinning, disable skin modifier
|
||||
if (nodeMap)
|
||||
enableSkinModifier (node, false);
|
||||
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node.EvalWorldState(time).obj;
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
|
@ -184,6 +190,8 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject *) obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
|
||||
if (tri)
|
||||
{
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
// pointer that called ConvertToType()
|
||||
|
@ -198,7 +206,7 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|||
else
|
||||
{
|
||||
// Mesh base ?
|
||||
CMeshBase *meshBase;
|
||||
CSmartPtr<CMeshBase> meshBase = NULL;
|
||||
|
||||
// Get the node matrix
|
||||
Matrix3 nodeMatrixMax;
|
||||
|
@ -310,6 +318,7 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|||
|
||||
// Make a CMeshMultiLod mesh object
|
||||
CMeshMultiLod *multiMesh = new CMeshMultiLod;
|
||||
++multiMesh->crefs; // hack
|
||||
|
||||
// Build it
|
||||
multiMesh->build(multiLodBuild);
|
||||
|
@ -441,7 +450,9 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|||
|
||||
// Delete the triObject if we should...
|
||||
if (deleteIt)
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
tri = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,7 +461,7 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|||
enableSkinModifier (node, true);
|
||||
|
||||
// Set the dist max for this shape
|
||||
if (retShape && !multiLodObject && buildLods)
|
||||
if (retShape.getPtr() && !multiLodObject && buildLods)
|
||||
{
|
||||
// Get the dist max for this node
|
||||
float distmax = getScriptAppData (&node, NEL3D_APPDATA_LOD_DIST_MAX, NEL3D_APPDATA_LOD_DIST_MAX_DEFAULT);
|
||||
|
@ -1173,6 +1184,7 @@ void CExportNel::getBSMeshBuild (std::vector<CMesh::CMeshBuild*> &bsList, INode
|
|||
CMeshBase::CMeshBaseBuild *dummyMBB = NULL;
|
||||
std::auto_ptr<CMesh::CMeshBuild> baseMB(createMeshBuild (node, time, dummyMBB, finalSpace));
|
||||
delete dummyMBB;
|
||||
dummyMBB = NULL;
|
||||
if (baseMB.get() == NULL) return;
|
||||
|
||||
j = 0;
|
||||
|
@ -1184,7 +1196,7 @@ void CExportNel::getBSMeshBuild (std::vector<CMesh::CMeshBuild*> &bsList, INode
|
|||
++j;
|
||||
}
|
||||
|
||||
bsList.resize (j);
|
||||
bsList.resize(j, NULL);
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < 100; ++i)
|
||||
|
@ -1198,6 +1210,7 @@ void CExportNel::getBSMeshBuild (std::vector<CMesh::CMeshBuild*> &bsList, INode
|
|||
// get the meshbuild of the morhp target
|
||||
bsList[j] = createMeshBuild (*pNode, time, pMBB, finalSpace, true);
|
||||
delete pMBB;
|
||||
pMBB = NULL;
|
||||
// copy src normals from src mesh for vertices that are on interfaces
|
||||
CMesh::CMeshBuild *mb = bsList[j];
|
||||
if (mb)
|
||||
|
@ -1281,7 +1294,8 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|||
enableSkinModifier (node, false);
|
||||
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node.EvalWorldState(time).obj;
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
|
@ -1292,12 +1306,12 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject *) obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
|
||||
if (tri)
|
||||
{
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
// pointer that called ConvertToType()
|
||||
bool deleteIt=false;
|
||||
if (obj != tri)
|
||||
deleteIt = true;
|
||||
bool deleteIt = (obj != tri);
|
||||
|
||||
// Coarse mesh ?
|
||||
bool coarseMesh=(getScriptAppData (&node, NEL3D_APPDATA_LOD_COARSE_MESH, 0)!=0) && (!_View);
|
||||
|
@ -1364,8 +1378,13 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|||
// Return this pointer
|
||||
meshGeom=meshMRMGeom;
|
||||
|
||||
#ifdef NL_DONT_FIND_MAX_CRASH
|
||||
for (uint32 bsListIt = 0; bsListIt < bsList.size(); ++bsListIt)
|
||||
{
|
||||
delete bsList[bsListIt];
|
||||
bsList[bsListIt] = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1388,7 +1407,9 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|||
|
||||
// Delete the triObject if we should...
|
||||
if (deleteIt)
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
tri = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1397,7 +1418,7 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|||
enableSkinModifier (node, true);
|
||||
|
||||
if (InfoLog)
|
||||
InfoLog->display("buidlMeshGeom : %d ms\n", timeGetTime()-t);
|
||||
InfoLog->display("buildMeshGeom : %d ms\n", timeGetTime()-t);
|
||||
if (InfoLog)
|
||||
InfoLog->display("End of %s \n", node.GetName());
|
||||
|
||||
|
@ -1657,10 +1678,15 @@ NL3D::IShape *CExportNel::buildWaterShape(INode& node, TimeValue time)
|
|||
|
||||
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node.EvalWorldState(time).obj;
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
|
||||
if (!obj) return NULL;
|
||||
|
||||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject *) obj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
TriObject *tri = (TriObject *) obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
|
||||
if (!tri) return NULL;
|
||||
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
|
@ -2033,7 +2059,8 @@ NL3D::IShape *CExportNel::buildWaterShape(INode& node, TimeValue time)
|
|||
|
||||
// Delete the triObject if we should...
|
||||
if (deleteIt)
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
tri = NULL;
|
||||
nlinfo("WaterShape : build succesful");
|
||||
return ws;
|
||||
}
|
||||
|
@ -2047,11 +2074,13 @@ NL3D::IShape *CExportNel::buildWaterShape(INode& node, TimeValue time)
|
|||
// ***************************************************************************
|
||||
bool CExportNel::buildMeshAABBox(INode &node, NLMISC::CAABBox &dest, TimeValue time)
|
||||
{
|
||||
Object *obj = node.EvalWorldState(time).obj;
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
if (!obj) return false;
|
||||
if (!obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0))) return false;
|
||||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject*)obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
if (!tri) return false;
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
// pointer that called ConvertToType()
|
||||
|
@ -2073,10 +2102,11 @@ bool CExportNel::buildMeshAABBox(INode &node, NLMISC::CAABBox &dest, TimeValue t
|
|||
//
|
||||
if (deleteIt)
|
||||
{
|
||||
#ifndef NL_DEBUG
|
||||
tri->DeleteMe();
|
||||
#ifdef NL_DONT_FIND_MAX_CRASH
|
||||
tri->MaybeAutoDelete();
|
||||
#endif // NL_DEBUG
|
||||
}
|
||||
tri = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,8 @@ struct CMeshInterface
|
|||
bool CMeshInterface::buildFromMaxMesh(INode &node, TimeValue tvTime)
|
||||
{
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node.EvalWorldState(tvTime).obj;
|
||||
ObjectState os = node.EvalWorldState(tvTime);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (!obj) return false;
|
||||
|
@ -141,6 +142,8 @@ bool CMeshInterface::buildFromMaxMesh(INode &node, TimeValue tvTime)
|
|||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject*)obj->ConvertToType(tvTime, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
|
||||
if (!tri) return false;
|
||||
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
// pointer that called ConvertToType()
|
||||
|
@ -177,9 +180,8 @@ bool CMeshInterface::buildFromMaxMesh(INode &node, TimeValue tvTime)
|
|||
}
|
||||
//
|
||||
if (deleteIt)
|
||||
{
|
||||
tri->DeleteMe();
|
||||
}
|
||||
tri->MaybeAutoDelete();
|
||||
tri = NULL;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -316,13 +318,16 @@ static void AddNodeToQuadGrid(const NLMISC::CAABBox &delimiter, TNodeFaceQG &des
|
|||
{
|
||||
nldebug((std::string("Adding ") + node.GetName() + std::string(" to mesh interface quad grid")).c_str());
|
||||
// add this node tris
|
||||
Object *obj = node.EvalWorldState(time).obj;
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
if (obj)
|
||||
{
|
||||
if (obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
|
||||
{
|
||||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject*)obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
if (tri)
|
||||
{
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
// pointer that called ConvertToType()
|
||||
|
@ -357,8 +362,8 @@ static void AddNodeToQuadGrid(const NLMISC::CAABBox &delimiter, TNodeFaceQG &des
|
|||
nldebug("%d faces where added", numFaceAdded);
|
||||
//
|
||||
if (deleteIt)
|
||||
{
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
tri = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -478,16 +483,20 @@ static void ApplyMeshInterfacesUsingSceneNormals(INode &sceneBaseNode, std::vect
|
|||
*/
|
||||
static bool SelectVerticesInMeshFromInterfaces(const std::vector<CMeshInterface> &inters, float threshold, INode &node, TimeValue tvTime)
|
||||
{
|
||||
Object *obj = node.EvalWorldState(tvTime).obj;
|
||||
ObjectState os = node.EvalWorldState(tvTime);
|
||||
Object *obj = os.obj;
|
||||
// Check if there is an object
|
||||
if (!obj) return false;
|
||||
if (obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
|
||||
{
|
||||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject*)obj->ConvertToType(tvTime, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
if (!tri) return false;
|
||||
if (obj != tri)
|
||||
{
|
||||
// not a mesh object, so do nothing
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
tri = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -511,7 +511,8 @@ std::string CExportNel::getNelObjectName (INode& node)
|
|||
{
|
||||
// Workaround for FX (don't know why, but the AppData are not copied when FX are duplicated, so try to get the name in another way)
|
||||
// If this is a particle system, try to get the name of the shape.from the param blocks
|
||||
Object *obj = node.EvalWorldState(0).obj;
|
||||
ObjectState os = node.EvalWorldState(0);
|
||||
Object *obj = os.obj;
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
{
|
||||
|
@ -542,7 +543,8 @@ std::string CExportNel::getNelObjectName (INode& node)
|
|||
}
|
||||
else
|
||||
{
|
||||
Object *obj = node.EvalWorldState(0).obj;
|
||||
ObjectState os = node.EvalWorldState(0);
|
||||
Object *obj = os.obj;
|
||||
if (obj)
|
||||
{
|
||||
ad = obj->GetAppDataChunk (MAXSCRIPT_UTILITY_CLASS_ID, UTILITY_CLASS_ID, NEL3D_APPDATA_INSTANCE_SHAPE);
|
||||
|
@ -906,7 +908,8 @@ void CExportNel::getObjectNodes (std::vector<INode*>& vectNode, TimeValue time,
|
|||
node=_Ip->GetRootNode();
|
||||
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node->EvalWorldState(time).obj;
|
||||
ObjectState os = node->EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
|
@ -1257,7 +1260,8 @@ void CExportNel::buildCamera(NL3D::CCameraInfo &cameraInfo, INode& node, TimeVal
|
|||
cameraInfo.Fov = genCamera->GetFOV(time);
|
||||
|
||||
if (deleteIt)
|
||||
genCamera->DeleteMe();
|
||||
genCamera->MaybeAutoDelete();
|
||||
genCamera = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,7 +292,7 @@ public:
|
|||
*
|
||||
* skeletonShape must be NULL if no bones.
|
||||
*/
|
||||
NL3D::IShape* buildShape (INode& node, TimeValue time, const TInodePtrInt *nodeMap,
|
||||
NLMISC::CSmartPtr<NL3D::IShape> buildShape (INode& node, TimeValue time, const TInodePtrInt *nodeMap,
|
||||
bool buildLods);
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,8 @@ using namespace NL3D;
|
|||
|
||||
IShape* CExportNel::buildParticleSystem(INode& node, TimeValue time)
|
||||
{
|
||||
Object *obj = node.EvalWorldState(time).obj;
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
nlassert(obj);
|
||||
std::string shapeName;
|
||||
// try to get the complete path
|
||||
|
|
|
@ -249,8 +249,8 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector<INode*>& vectNode, v
|
|||
clusterTemp.Name = pNode->GetName();
|
||||
|
||||
vClusters.push_back (clusterTemp);
|
||||
delete pMB;
|
||||
delete pMBB;
|
||||
delete pMB; pMB = NULL;
|
||||
delete pMBB; pMBB = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,9 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector<INode*>& vectNode, v
|
|||
|
||||
vPortals.push_back (portalTemp);
|
||||
delete pMB;
|
||||
pMB = NULL;
|
||||
delete pMBB;
|
||||
pMBB = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,7 +408,8 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector<INode*>& vectNode, v
|
|||
* If it is a FX, we read its bbox from its shape
|
||||
* If we can't read it, we use the bbox of the fx helper in max
|
||||
*/
|
||||
Object *obj = pNode->EvalWorldState(tvTime).obj;
|
||||
ObjectState os = pNode->EvalWorldState(tvTime);
|
||||
Object *obj = os.obj;
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
{
|
||||
|
@ -452,6 +455,7 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector<INode*>& vectNode, v
|
|||
buildMeshBBox = false;
|
||||
}
|
||||
delete ss.getShapePointer();
|
||||
ss.setShapePointer(NULL);
|
||||
}
|
||||
catch (NLMISC::Exception &e)
|
||||
{
|
||||
|
@ -506,8 +510,8 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector<INode*>& vectNode, v
|
|||
}
|
||||
// debug purpose : to remove
|
||||
|
||||
delete pMB;
|
||||
delete pMBB;
|
||||
delete pMB; pMB = NULL;
|
||||
delete pMBB; pMBB = NULL;
|
||||
}
|
||||
|
||||
++nNumIG;
|
||||
|
@ -911,7 +915,7 @@ void CExportNel::buildScene (NL3D::CScene &scene, NL3D::CShapeBank &shapeBank, I
|
|||
|
||||
// Swap pointer and release unlighted one.
|
||||
swap(ig, igOut);
|
||||
delete igOut;
|
||||
delete igOut; igOut = NULL;
|
||||
}
|
||||
|
||||
// Add all models to the scene
|
||||
|
|
|
@ -1386,7 +1386,8 @@ bool CExportNel::mirrorPhysiqueSelection(INode &node, TimeValue tvTime, const st
|
|||
uint vertCount;
|
||||
|
||||
// Get a pointer on the object's node.
|
||||
Object *obj = node.EvalWorldState(tvTime).obj;
|
||||
ObjectState os = node.EvalWorldState(tvTime);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
ok= false;
|
||||
|
@ -1399,6 +1400,8 @@ bool CExportNel::mirrorPhysiqueSelection(INode &node, TimeValue tvTime, const st
|
|||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject*)obj->ConvertToType(tvTime, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
|
||||
if (tri)
|
||||
{
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
// pointer that called ConvertToType()
|
||||
|
@ -1423,12 +1426,14 @@ bool CExportNel::mirrorPhysiqueSelection(INode &node, TimeValue tvTime, const st
|
|||
|
||||
// Delete the triObject if we should...
|
||||
if (deleteIt)
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
tri = NULL;
|
||||
|
||||
// ok!
|
||||
ok= true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!ok)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ bool CExportNel::buildVegetableShape (NL3D::CVegetableShape& skeletonShape, INo
|
|||
bool res = false;
|
||||
|
||||
// Get a pointer on the object's node
|
||||
Object *obj = node.EvalWorldState(time).obj;
|
||||
ObjectState os = node.EvalWorldState(time);
|
||||
Object *obj = os.obj;
|
||||
|
||||
// Check if there is an object
|
||||
if (obj)
|
||||
|
@ -43,6 +44,8 @@ bool CExportNel::buildVegetableShape (NL3D::CVegetableShape& skeletonShape, INo
|
|||
// Get a triobject from the node
|
||||
TriObject *tri = (TriObject *) obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
||||
|
||||
if (tri)
|
||||
{
|
||||
// Note that the TriObject should only be deleted
|
||||
// if the pointer to it is not equal to the object
|
||||
// pointer that called ConvertToType()
|
||||
|
@ -151,7 +154,8 @@ bool CExportNel::buildVegetableShape (NL3D::CVegetableShape& skeletonShape, INo
|
|||
}
|
||||
|
||||
if (deleteIt)
|
||||
tri->DeleteMe();
|
||||
tri->MaybeAutoDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,3 +101,8 @@ for m in getClassInstances NelMaterial do
|
|||
m.delegate.ReflectionMap = undefined
|
||||
m.delegate.RefractionMap = undefined
|
||||
)
|
||||
|
||||
actionMan.executeAction 0 "40021" -- Selection: Select All
|
||||
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
|
||||
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
|
||||
actionMan.executeAction 0 "40043" -- Selection: Select None
|
||||
|
|
|
@ -169,9 +169,12 @@ rollout assets_png_rollout "Properties"
|
|||
m.delegate.ReflectionMap = undefined
|
||||
m.delegate.RefractionMap = undefined
|
||||
)
|
||||
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
|
||||
|
||||
actionMan.executeAction 0 "40021" -- Selection: Select All
|
||||
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
|
||||
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
|
||||
actionMan.executeAction 0 "40043" -- Selection: Select None
|
||||
|
||||
return 1
|
||||
)
|
||||
|
||||
|
|
|
@ -141,3 +141,8 @@ for m in getClassInstances NelMaterial do
|
|||
m.delegate.ReflectionMap = undefined
|
||||
m.delegate.RefractionMap = undefined
|
||||
)
|
||||
|
||||
actionMan.executeAction 0 "40021" -- Selection: Select All
|
||||
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
|
||||
actionMan.executeAction 0 "63508" -- Views: Standard Display with Maps
|
||||
actionMan.executeAction 0 "40043" -- Selection: Select None
|
||||
|
|
Loading…
Reference in a new issue