/*
===========================================================================
Copyright (C) 2000 - 2013, Raven Software, Inc.
Copyright (C) 2001 - 2013, Activision, Inc.
Copyright (C) 2013 - 2015, OpenJK contributors
This file is part of the OpenJK source code.
OpenJK is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
===========================================================================
*/
#include "ghoul2/G2.h"
#include "ghoul2/g2_local.h"
//=====================================================================================================================
// Bolt List handling routines - so entities can attach themselves to any part of the model in question
// Given a bone number, see if that bone is already in our bone list
int G2_Find_Bolt_Bone_Num(boltInfo_v &bltlist, const int boneNum)
{
// look through entire list
for(size_t i=0; imValid);
boltInfo_t tempBolt;
// first up, make sure have a surface first
if (surfNum >= (int)slist.size())
{
return -1;
}
// look through entire list - see if it's already there first
for(size_t i=0; imValid);
model_t *mod_m = (model_t *)ghlInfo->currentModel;
model_t *mod_a = (model_t *)ghlInfo->animModel;
int x, surfNum = -1;
mdxaSkel_t *skel;
mdxaSkelOffsets_t *offsets;
boltInfo_t tempBolt;
int flags;
// first up, we'll search for that which this bolt names in all the surfaces
surfNum = G2_IsSurfaceLegal((void*)mod_m, boneName, &flags);
// did we find it as a surface?
if (surfNum != -1)
{
// look through entire list - see if it's already there first
for(size_t i=0; imdxa + sizeof(mdxaHeader_t));
// walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find
for (x=0; x< mod_a->mdxa->numBones; x++)
{
skel = (mdxaSkel_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[x]);
// if name is the same, we found it
if (!Q_stricmp(skel->name, boneName))
{
break;
}
}
// check to see we did actually make a match with a bone in the model
if (x == mod_a->mdxa->numBones)
{
// didn't find it? Error
//assert(0&&x == mod_a->mdxa->numBones);
#ifdef _DEBUG
// Com_Printf("WARNING: %s not found on skeleton\n", boneName);
#endif
return -1;
}
// look through entire list - see if it's already there first
for(size_t i=0; i-1; i--)
{
if ((bltlist[i].surfaceNumber == -1) && (bltlist[i].boneNumber == -1))
{
newSize = i;
}
// once we hit one that isn't a -1, we are done.
else
{
break;
}
}
// do we need to resize?
if (newSize != bltlist.size())
{
// yes, so lets do it
bltlist.resize(newSize);
}
}
return qtrue;
}
assert(0);
// no
return qfalse;
}
// set the bolt list to all unused so the bone transformation routine ignores it.
void G2_Init_Bolt_List(boltInfo_v &bltlist)
{
bltlist.clear();
}
// remove any bolts that reference original surfaces, generated surfaces, or bones that aren't active anymore
void G2_RemoveRedundantBolts(boltInfo_v &bltlist, surfaceInfo_v &slist, int *activeSurfaces, int *activeBones)
{
// walk the bolt list
for (size_t i=0; i