1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-05 10:35:54 +00:00

CClumpModelInfo; little fixes

This commit is contained in:
aap 2020-05-10 11:20:27 +02:00
parent f0442960a2
commit 1b936f6ffb
6 changed files with 62 additions and 49 deletions

View file

@ -382,7 +382,11 @@ CWorld::ProcessVerticalLine(const CVector &point1, float z2, CColPoint &point, C
{
AdvanceCurrentScanCode();
CVector point2(point1.x, point1.y, z2);
return ProcessVerticalLineSector(*GetSector(GetSectorIndexX(point1.x), GetSectorIndexY(point1.y)),
int secX = GetSectorIndexX(point1.x);
int secY = GetSectorIndexY(point1.y);
secX = clamp(secX, 0, NUMSECTORS_X-1);
secY = clamp(secY, 0, NUMSECTORS_Y-1);
return ProcessVerticalLineSector(*GetSector(secX, secY),
CColLine(point1, point2), point, entity, checkBuildings, checkVehicles,
checkPeds, checkObjects, checkDummies, ignoreSeeThrough, poly);
}

View file

@ -5,6 +5,7 @@
#include "NodeName.h"
#include "VisibilityPlugins.h"
#include "ModelInfo.h"
#include "AnimManager.h"
void
CClumpModelInfo::DeleteRwObject(void)
@ -13,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)
@ -31,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);
RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
}
#endif
return (RwObject*)clone;
}
@ -76,31 +70,19 @@ CClumpModelInfo::SetClump(RpClump *clump)
m_clump = clump;
CVisibilityPlugins::SetClumpModelInfo(m_clump, this);
AddTexDictionaryRef();
RpClumpForAllAtomics(clump, SetAtomicRendererCB, nil);
if(GetAnimFileIndex() != -1)
CAnimManager::AddAnimBlockRef(GetAnimFileIndex());
// TODO: also set for player?
if(strncmp(GetName(), "playerh", 8) == 0)
RpClumpForAllAtomics(clump, SetAtomicRendererCB, (void*)CVisibilityPlugins::RenderPlayerCB);
#ifdef PED_SKIN
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));
@ -113,9 +95,29 @@ CClumpModelInfo::SetClump(RpClump *clump)
weights->w2 /= sum;
weights->w3 /= sum;
}
// RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
RpHAnimHierarchySetFlags(hier, (RpHAnimHierarchyFlag)(rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS));
}
}
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;
}
#endif
}
void
@ -139,27 +141,26 @@ CClumpModelInfo::FindFrameFromIdCB(RwFrame *frame, void *data)
{
RwObjectIdAssociation *assoc = (RwObjectIdAssociation*)data;
if(CVisibilityPlugins::GetFrameHierarchyId(frame) != assoc->id){
RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc);
return assoc->frame ? nil : frame;
}else{
if(CVisibilityPlugins::GetFrameHierarchyId(frame) == assoc->id){
assoc->frame = frame;
return nil;
}
RwFrameForAllChildren(frame, FindFrameFromIdCB, assoc);
return assoc->frame ? nil : frame;
}
//--MIAMI: unused
RwFrame*
CClumpModelInfo::FindFrameFromNameCB(RwFrame *frame, void *data)
{
RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data;
if(CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc);
return assoc->frame ? nil : frame;
}else{
if(!CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
assoc->frame = frame;
return nil;
}
RwFrameForAllChildren(frame, FindFrameFromNameCB, assoc);
return assoc->frame ? nil : frame;
}
RwFrame*
@ -167,14 +168,13 @@ CClumpModelInfo::FindFrameFromNameWithoutIdCB(RwFrame *frame, void *data)
{
RwObjectNameAssociation *assoc = (RwObjectNameAssociation*)data;
if(CVisibilityPlugins::GetFrameHierarchyId(frame) ||
CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc);
return assoc->frame ? nil : frame;
}else{
if(CVisibilityPlugins::GetFrameHierarchyId(frame) == 0 &&
!CGeneral::faststricmp(GetFrameNodeName(frame), assoc->name)){
assoc->frame = frame;
return nil;
}
RwFrameForAllChildren(frame, FindFrameFromNameWithoutIdCB, assoc);
return assoc->frame ? nil : frame;
}
RwFrame*

View file

@ -30,9 +30,13 @@ class CClumpModelInfo : public CBaseModelInfo
{
public:
RpClump *m_clump;
union {
int32 m_animFileIndex;
char *m_animFileName;
};
CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) {}
CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) {}
CClumpModelInfo(void) : CBaseModelInfo(MITYPE_CLUMP) { m_animFileIndex = -1; }
CClumpModelInfo(ModelInfoType id) : CBaseModelInfo(id) { m_animFileIndex = -1; }
~CClumpModelInfo() {}
void DeleteRwObject(void);
RwObject *CreateInstance(void);
@ -40,6 +44,9 @@ public:
RwObject *GetRwObject(void) { return (RwObject*)m_clump; }
virtual void SetClump(RpClump *);
virtual void SetAnimFile(const char *file);
virtual void ConvertAnimFileIndex(void);
virtual int GetAnimFileIndex(void) { return m_animFileIndex; }
static RpAtomic *SetAtomicRendererCB(RpAtomic *atomic, void *data);
void SetFrameIds(RwObjectNameIdAssocation *assocs);

View file

@ -4,6 +4,8 @@
#include "AnimManager.h"
#include "VisibilityPlugins.h"
//--MIAMI: file done
void
CWeaponModelInfo::SetAnimFile(const char *file)
{

View file

@ -398,10 +398,10 @@ CBoat::ProcessControl(void)
}
// Slow down or push down boat as it approaches the world limits
m_vecMoveSpeed.x = Min(m_vecMoveSpeed.x, -(GetPosition().x - 1900.0f)*0.01f); // east
m_vecMoveSpeed.x = Max(m_vecMoveSpeed.x, -(GetPosition().x - -1515.0f)*0.01f); // west
m_vecMoveSpeed.y = Min(m_vecMoveSpeed.y, -(GetPosition().y - 600.0f)*0.01f); // north
m_vecMoveSpeed.y = Max(m_vecMoveSpeed.y, -(GetPosition().y - -1900.0f)*0.01f); // south
m_vecMoveSpeed.x = Min(m_vecMoveSpeed.x, -(GetPosition().x - (WORLD_MAX_X-50.0f))*0.01f); // east
m_vecMoveSpeed.x = Max(m_vecMoveSpeed.x, -(GetPosition().x - (WORLD_MIN_X+50.0f))*0.01f); // west
m_vecMoveSpeed.y = Min(m_vecMoveSpeed.y, -(GetPosition().y - (WORLD_MAX_Y-50.0f))*0.01f); // north
m_vecMoveSpeed.y = Max(m_vecMoveSpeed.y, -(GetPosition().y - (WORLD_MIN_Y+50.0f))*0.01f); // south
if(!onLand && bBoatInWater)
ApplyWaterResistance();

View file

@ -806,7 +806,7 @@ CPlane::LoadPath(char const *filename, int32 &numNodes, float &totalLength, bool
for(i = 0; i < numNodes; i++){
*gString = '\0';
for(lp = 0; work_buff[bp] != '\n'; bp++, lp++)
for(lp = 0; work_buff[bp] != '\n' && work_buff[bp] != '\0'; bp++, lp++)
gString[lp] = work_buff[bp];
bp++;
// BUG: game doesn't terminate string