summaryrefslogtreecommitdiffstats
path: root/src/modelinfo/ClumpModelInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modelinfo/ClumpModelInfo.cpp')
-rw-r--r--src/modelinfo/ClumpModelInfo.cpp61
1 files changed, 28 insertions, 33 deletions
diff --git a/src/modelinfo/ClumpModelInfo.cpp b/src/modelinfo/ClumpModelInfo.cpp
index 44a62afb..ba18bfa7 100644
--- a/src/modelinfo/ClumpModelInfo.cpp
+++ b/src/modelinfo/ClumpModelInfo.cpp
@@ -5,7 +5,7 @@
#include "NodeName.h"
#include "VisibilityPlugins.h"
#include "ModelInfo.h"
-#include "ModelIndices.h"
+#include "AnimManager.h"
void
CClumpModelInfo::DeleteRwObject(void)
@@ -14,17 +14,17 @@ CClumpModelInfo::DeleteRwObject(void)
RpClumpDestroy(m_clump);
m_clump = nil;
RemoveTexDictionaryRef();
+ if(GetAnimFileIndex() != -1)
+ CAnimManager::RemoveAnimBlockRef(GetAnimFileIndex());
}
}
-#ifdef PED_SKIN
static RpAtomic*
SetHierarchyForSkinAtomic(RpAtomic *atomic, void *data)
{
RpSkinAtomicSetHAnimHierarchy(atomic, (RpHAnimHierarchy*)data);
return nil;
}
-#endif
RwObject*
CClumpModelInfo::CreateInstance(void)
@@ -32,24 +32,17 @@ CClumpModelInfo::CreateInstance(void)
if(m_clump == nil)
return nil;
RpClump *clone = RpClumpClone(m_clump);
-#ifdef PED_SKIN
if(IsClumpSkinned(clone)){
RpHAnimHierarchy *hier;
RpHAnimAnimation *anim;
hier = GetAnimHierarchyFromClump(clone);
assert(hier);
- // This seems dangerous as only the first atomic will get a hierarchy
- // can we guarantee this if hands and head are also in the clump?
RpClumpForAllAtomics(clone, SetHierarchyForSkinAtomic, hier);
anim = HAnimAnimationCreateForHierarchy(hier);
RpHAnimHierarchySetCurrentAnim(hier, anim);
RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
- // the rest is xbox only:
- // RpSkinGetNumBones(RpSkinGeometryGetSkin(RpAtomicGetGeometry(IsClumpSkinned(clone))));
- RpHAnimHierarchyUpdateMatrices(hier);
}
-#endif
return (RwObject*)clone;
}
@@ -77,27 +70,18 @@ CClumpModelInfo::SetClump(RpClump *clump)
m_clump = clump;
CVisibilityPlugins::SetClumpModelInfo(m_clump, this);
AddTexDictionaryRef();
- RpClumpForAllAtomics(clump, SetAtomicRendererCB, nil);
-
-#ifdef PED_SKIN
+ if(GetAnimFileIndex() != -1)
+ CAnimManager::AddAnimBlockRef(GetAnimFileIndex());
if(IsClumpSkinned(clump)){
int i;
RpHAnimHierarchy *hier;
RpAtomic *skinAtomic;
RpSkin *skin;
- // mobile:
-// hier = nil;
-// RwFrameForAllChildren(RpClumpGetFrame(clump), GetHierarchyFromChildNodesCB, &hier);
-// assert(hier);
-// RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier);
-// skinAtomic = GetFirstAtomic(clump);
-
- // xbox:
hier = GetAnimHierarchyFromClump(clump);
assert(hier);
- RpSkinAtomicSetHAnimHierarchy(IsClumpSkinned(clump), hier);
- skinAtomic = IsClumpSkinned(clump);
+ RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier);
+ skinAtomic = GetFirstAtomic(clump);
assert(skinAtomic);
skin = RpSkinGeometryGetSkin(RpAtomicGetGeometry(skinAtomic));
@@ -112,17 +96,27 @@ CClumpModelInfo::SetClump(RpClump *clump)
}
RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
}
- if(strcmp(GetModelName(), "playerh") == 0){
- // playerh is incompatible with the xbox player skin
- // so check if player model is skinned and only apply skin to head if it isn't
- CPedModelInfo *body = (CPedModelInfo*)CModelInfo::GetModelInfo(MI_PLAYER);
- if(!(body->m_clump && IsClumpSkinned(body->m_clump)))
- RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
+}
+
+void
+CClumpModelInfo::SetAnimFile(const char *file)
+{
+ if(strcasecmp(file, "null") == 0)
+ return;
+
+ m_animFileName = new char[strlen(file)+1];
+ strcpy(m_animFileName, file);
+}
+
+void
+CClumpModelInfo::ConvertAnimFileIndex(void)
+{
+ if(m_animFileIndex != -1){
+ // we have a string pointer in that union
+ int32 index = CAnimManager::GetAnimationBlockIndex(m_animFileName);
+ delete[] m_animFileName;
+ m_animFileIndex = index;
}
-#else
- if(strcmp(GetModelName(), "playerh") == 0)
- RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
-#endif
}
void
@@ -154,6 +148,7 @@ CClumpModelInfo::FindFrameFromIdCB(RwFrame *frame, void *data)
return assoc->frame ? nil : frame;
}
+// unused
RwFrame*
CClumpModelInfo::FindFrameFromNameCB(RwFrame *frame, void *data)
{