mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-28 13:31:59 +00:00
ran everything though mark's newline stomper.
This was SVN commit r322.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CModelDef Constructor
|
||||
CModelDef::CModelDef()
|
||||
: m_pVertices(0), m_NumVertices(0), m_pFaces(0), m_NumFaces(0), m_Bones(0), m_NumBones(0),
|
||||
: m_pVertices(0), m_NumVertices(0), m_pFaces(0), m_NumFaces(0), m_Bones(0), m_NumBones(0),
|
||||
m_NumPropPoints(0), m_PropPoints(0)
|
||||
{
|
||||
}
|
||||
@@ -24,23 +24,23 @@ CModelDef::~CModelDef()
|
||||
{
|
||||
delete[] m_pVertices;
|
||||
delete[] m_pFaces;
|
||||
delete[] m_Bones;
|
||||
delete[] m_Bones;
|
||||
delete[] m_PropPoints;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// FindPropPoint: find and return pointer to prop point matching given name;
|
||||
// return null if no match (case insensitive search)
|
||||
SPropPoint* CModelDef::FindPropPoint(const char* name) const
|
||||
{
|
||||
for (uint i=0;i<m_NumPropPoints;i++) {
|
||||
if (stricmp(name,m_PropPoints[i].m_Name)==0) {
|
||||
return &m_PropPoints[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// FindPropPoint: find and return pointer to prop point matching given name;
|
||||
// return null if no match (case insensitive search)
|
||||
SPropPoint* CModelDef::FindPropPoint(const char* name) const
|
||||
{
|
||||
for (uint i=0;i<m_NumPropPoints;i++) {
|
||||
if (stricmp(name,m_PropPoints[i].m_Name)==0) {
|
||||
return &m_PropPoints[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Load: read and return a new CModelDef initialised with data from given file
|
||||
@@ -71,26 +71,26 @@ CModelDef* CModelDef::Load(const char* filename)
|
||||
if (mdef->m_NumBones) {
|
||||
mdef->m_Bones=new CBoneState[mdef->m_NumBones];
|
||||
unpacker.UnpackRaw(mdef->m_Bones,mdef->m_NumBones*sizeof(CBoneState));
|
||||
}
|
||||
|
||||
if (unpacker.GetVersion()>=2) {
|
||||
}
|
||||
|
||||
if (unpacker.GetVersion()>=2) {
|
||||
// versions >=2 also have prop point data
|
||||
unpacker.UnpackRaw(&mdef->m_NumPropPoints,sizeof(mdef->m_NumPropPoints));
|
||||
if (mdef->m_NumPropPoints) {
|
||||
mdef->m_PropPoints=new SPropPoint[mdef->m_NumPropPoints];
|
||||
for (u32 i=0;i<mdef->m_NumPropPoints;i++) {
|
||||
unpacker.UnpackString(mdef->m_PropPoints[i].m_Name);
|
||||
unpacker.UnpackRaw(&mdef->m_PropPoints[i].m_Position.X,sizeof(mdef->m_PropPoints[i].m_Position));
|
||||
unpacker.UnpackRaw(&mdef->m_PropPoints[i].m_Rotation.m_V.X,sizeof(mdef->m_PropPoints[i].m_Rotation));
|
||||
unpacker.UnpackRaw(&mdef->m_PropPoints[i].m_BoneIndex,sizeof(mdef->m_PropPoints[i].m_BoneIndex));
|
||||
|
||||
// build prop point transform
|
||||
mdef->m_PropPoints[i].m_Transform.SetIdentity();
|
||||
mdef->m_PropPoints[i].m_Transform.Rotate(mdef->m_PropPoints[i].m_Rotation);
|
||||
mdef->m_PropPoints[i].m_Transform.Translate(mdef->m_PropPoints[i].m_Position);
|
||||
}
|
||||
}
|
||||
}
|
||||
unpacker.UnpackRaw(&mdef->m_NumPropPoints,sizeof(mdef->m_NumPropPoints));
|
||||
if (mdef->m_NumPropPoints) {
|
||||
mdef->m_PropPoints=new SPropPoint[mdef->m_NumPropPoints];
|
||||
for (u32 i=0;i<mdef->m_NumPropPoints;i++) {
|
||||
unpacker.UnpackString(mdef->m_PropPoints[i].m_Name);
|
||||
unpacker.UnpackRaw(&mdef->m_PropPoints[i].m_Position.X,sizeof(mdef->m_PropPoints[i].m_Position));
|
||||
unpacker.UnpackRaw(&mdef->m_PropPoints[i].m_Rotation.m_V.X,sizeof(mdef->m_PropPoints[i].m_Rotation));
|
||||
unpacker.UnpackRaw(&mdef->m_PropPoints[i].m_BoneIndex,sizeof(mdef->m_PropPoints[i].m_BoneIndex));
|
||||
|
||||
// build prop point transform
|
||||
mdef->m_PropPoints[i].m_Transform.SetIdentity();
|
||||
mdef->m_PropPoints[i].m_Transform.Rotate(mdef->m_PropPoints[i].m_Rotation);
|
||||
mdef->m_PropPoints[i].m_Transform.Translate(mdef->m_PropPoints[i].m_Position);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
delete mdef;
|
||||
throw CFileUnpacker::CFileEOFError();
|
||||
@@ -118,17 +118,17 @@ void CModelDef::Save(const char* filename,const CModelDef* mdef)
|
||||
if (mdef->m_NumBones) {
|
||||
packer.PackRaw(mdef->m_Bones,sizeof(CBoneState)*mdef->m_NumBones);
|
||||
}
|
||||
|
||||
packer.PackRaw(&mdef->m_NumPropPoints,sizeof(mdef->m_NumPropPoints));
|
||||
for (u32 i=0;i<mdef->m_NumPropPoints;i++) {
|
||||
packer.PackString(mdef->m_PropPoints[i].m_Name);
|
||||
packer.PackRaw(&mdef->m_PropPoints[i].m_Position.X,sizeof(mdef->m_PropPoints[i].m_Position));
|
||||
packer.PackRaw(&mdef->m_PropPoints[i].m_Rotation.m_V.X,sizeof(mdef->m_PropPoints[i].m_Rotation));
|
||||
packer.PackRaw(&mdef->m_PropPoints[i].m_BoneIndex,sizeof(mdef->m_PropPoints[i].m_BoneIndex));
|
||||
}
|
||||
|
||||
|
||||
packer.PackRaw(&mdef->m_NumPropPoints,sizeof(mdef->m_NumPropPoints));
|
||||
for (u32 i=0;i<mdef->m_NumPropPoints;i++) {
|
||||
packer.PackString(mdef->m_PropPoints[i].m_Name);
|
||||
packer.PackRaw(&mdef->m_PropPoints[i].m_Position.X,sizeof(mdef->m_PropPoints[i].m_Position));
|
||||
packer.PackRaw(&mdef->m_PropPoints[i].m_Rotation.m_V.X,sizeof(mdef->m_PropPoints[i].m_Rotation));
|
||||
packer.PackRaw(&mdef->m_PropPoints[i].m_BoneIndex,sizeof(mdef->m_PropPoints[i].m_BoneIndex));
|
||||
}
|
||||
|
||||
|
||||
// flush everything out to file
|
||||
packer.Write(filename,FILE_VERSION,"PSMD");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user