Commit e5d1c690 authored by aap's avatar aap

commiting old changes and fixes

parent f3165340
Pipeline #163 skipped
......@@ -8,7 +8,7 @@ void
CAnimBlendClumpData::ctor(void)
{
this->numFrames = 0;
this->d = 0;
this->pedPosition = NULL;
this->frames = NULL;
this->nextAssoc = NULL;
this->prevAssoc = NULL;
......
This diff is collapsed.
#include "iii_anim.h"
#define RAD2DEG(x) (180.0f*(x)/M_PI)
//WRAPPER void CPedIK::RotateTorso(AnimBlendFrameData*, LimbOrientation*, bool) { EAXJMP(0x4EDDB0); }
WRAPPER void __stdcall CPedIK::ExtractYawAndPitchLocal(RwMatrixTag *, float *, float *) { EAXJMP(0x4ED2C0); }
WRAPPER void __stdcall CPedIK::ExtractYawAndPitchWorld(RwMatrixTag *, float *, float *) { EAXJMP(0x4ED140); }
WRAPPER RwMatrix *CPedIK::GetWorldMatrix(RwFrame *, RwMatrixTag *) { EAXJMP(0x4ED060); }
......@@ -16,8 +12,9 @@ float *CPedIK::ms_lowerArmInfo = (float*)0x5F9FBC;
WRAPPER double CGeneral__LimitRadianAngle(float) { EAXJMP(0x48CB90); }
RwV3d xAxis = { 1.0f, 0.0f, 0.0f};
RwV3d zAxis = { 0.0f, 0.0f, 1.0f};
const RwV3d xAxis = { 1.0f, 0.0f, 0.0f};
const RwV3d yAxis = { 0.0f, 1.0f, 0.0f};
const RwV3d zAxis = { 0.0f, 0.0f, 1.0f};
void
CPedIK::GetComponentPosition(RwV3d *pos, int id)
......@@ -36,10 +33,8 @@ CPedIK::GetComponentPosition(RwV3d *pos, int id)
}else{
f = this->ped->frames[id]->frame;
mat = &f->modelling;
pos->x = mat->pos.x;
pos->y = mat->pos.y;
pos->z = mat->pos.z;
for(f = (RwFrame *)f->object.parent; f; f = (RwFrame *)f->object.parent)
*pos = mat->pos;
for(f = (RwFrame*)f->object.parent; f; f = (RwFrame*)f->object.parent)
RwV3dTransformPoints(pos, pos, 1, &f->modelling);
}
}
......@@ -59,7 +54,7 @@ CPedIK::RotateHead(void)
RtQuat *q = &this->ped->frames[2]->hanimframe->q;
RtQuatRotate(q, &xAxis, RAD2DEG(this->headOrient.phi), rwCOMBINEREPLACE);
RtQuatRotate(q, &zAxis, RAD2DEG(this->headOrient.theta), rwCOMBINEPOSTCONCAT);
this->ped->someFlags |= 0x20;
this->ped->bfFlagsI |= 0x20;
}
int
......@@ -68,6 +63,7 @@ CPedIK::LookInDirection(float phi, float theta)
int ret;
ret = 1;
RwMatrix mat;
AnimBlendFrameData *frameData = this->ped->frames[2];
float alpha, beta;
if(IsClumpSkinned(this->ped->clump)){
......@@ -76,9 +72,8 @@ CPedIK::LookInDirection(float phi, float theta)
CPedIK::ExtractYawAndPitchLocalSkinned(frameData, &this->headOrient.phi, &this->headOrient.theta);
}
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(this->ped->clump);
RwInt32 idx = RpHAnimIDGetIndex(hier, this->ped->frames[2]->nodeID);
RwMatrix mat;
memcpy(&mat, &RpHAnimHierarchyGetMatrixArray(hier)[idx], 0x40);
RwInt32 idx = RpHAnimIDGetIndex(hier, 8);
mat = RpHAnimHierarchyGetMatrixArray(hier)[idx];
CPedIK::ExtractYawAndPitchWorld(&mat, &alpha, &beta);
int foo = CPedIK::MoveLimb(&this->headOrient, CGeneral__LimitRadianAngle(phi - alpha),
......@@ -111,9 +106,8 @@ CPedIK::LookInDirection(float phi, float theta)
int foo = CPedIK::MoveLimb(&this->headOrient, alpha, beta, CPedIK::ms_headInfo);
if(foo == 0)
ret = 0;
if(foo != 2){
if((this->flags & 2) == 0 &&
CPedIK::MoveLimb(&this->torsoOrient, CGeneral__LimitRadianAngle(phi - this->ped->someAngle),
if(foo != 2 && (this->flags & 2) == 0){
if(CPedIK::MoveLimb(&this->torsoOrient, CGeneral__LimitRadianAngle(phi - this->ped->fRotationCur),
theta, CPedIK::ms_torsoInfo))
ret = 1;
}
......@@ -179,11 +173,12 @@ CPedIK::RestoreLookAt(void)
void
CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool flag)
{
// TODO: this seems to be too simplistic
if(IsClumpSkinned(this->ped->clump)){
RtQuat *q = &animBlend->hanimframe->q;
RtQuatRotate(q, &xAxis, RAD2DEG(limb->phi), rwCOMBINEPRECONCAT);
RtQuatRotate(q, &zAxis, RAD2DEG(limb->theta), rwCOMBINEPRECONCAT);
this->ped->someFlags |= 0x20;
this->ped->bfFlagsI |= 0x20;
return;
}
......@@ -194,8 +189,8 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool f
vec1.y = mat->up.z;
vec1.z = mat->at.z;
RwV3d pos = f->modelling.pos;
float c = cos(ped->someAngle);
float s = sin(ped->someAngle);
float c = cos(ped->fRotationCur);
float s = sin(ped->fRotationCur);
vec2.x = -(c * mat->right.x) - s * mat->right.y;
vec2.y = -(c * mat->up.x) - s * mat->up.y;
vec2.z = -(c * mat->at.x) - s * mat->at.y;
......@@ -213,19 +208,18 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool f
float dot = mat->at.x*v3.x + mat->at.y*v3.y + mat->at.z*v3.z;
if(dot > 1.0f) dot = 1.0f;
if(dot < -1.0f) dot = -1.0f;
float alpha = 3.141592653589793116f * 0.5f - atan2(sqrt(1.0f - dot * dot), dot);
float alpha = acos(dot);
if(mat->at.z < 0.0f)
alpha = -alpha;
float c = cos(ped->someAngle);
float s = sin(ped->someAngle);
float c = cos(ped->fRotationCur);
float s = sin(ped->fRotationCur);
vec3.x = s * mat->right.x - c * mat->right.y;
vec3.y = s * mat->up.x - c * mat->up.y;
vec3.z = s * mat->at.x - c * mat->at.y;
float a, b;
CPedIK::ExtractYawAndPitchWorld(mat, &a, &b);
a -= ped->someAngle;
RwMatrixRotate(&f->modelling, &vec2, RAD2DEG(limb->theta), rwCOMBINEPOSTCONCAT);
RwMatrixRotate(&f->modelling, &vec1, RAD2DEG(limb->theta - a), rwCOMBINEPOSTCONCAT);
RwMatrixRotate(&f->modelling, &vec1, RAD2DEG(limb->phi - (a - ped->fRotationCur)), rwCOMBINEPOSTCONCAT);
RwMatrixRotate(&f->modelling, &vec3, RAD2DEG(alpha), rwCOMBINEPOSTCONCAT);
}else{
RwMatrixRotate(&f->modelling, &vec2, RAD2DEG(limb->theta), rwCOMBINEPOSTCONCAT);
......@@ -242,25 +236,27 @@ CPedIK::PointGunInDirectionUsingArm(float phi, float theta)
RwMatrix *mat;
float alpha, beta;
RwV3d vec1, vec2, pos;
vec1.x = 0.0f;
vec1.y = 0.0f;
vec1.z = 1.0f;
if(IsClumpSkinned(this->ped->clump)){
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(this->ped->clump);
mat = RwMatrixCreate();
RwInt32 idx = RpHAnimIDGetIndex(hier, this->ped->frames[2]->nodeID);
memcpy(mat, &RpHAnimHierarchyGetMatrixArray(hier)[idx], 0x40);
*mat = RpHAnimHierarchyGetMatrixArray(hier)[idx];
CPedIK::ExtractYawAndPitchWorld(mat, &alpha, &beta);
RwMatrixDestroy(mat);
}else{
RwFrame *f = this->ped->frames[4]->frame;
mat = CPedIK::GetWorldMatrix((RwFrame*)f->object.parent, RwMatrixCreate());
vec2.x = mat->right.z;
vec2.y = mat->up.z;
vec2.z = mat->at.z;
CPedIK::ExtractYawAndPitchWorld(mat, &alpha, &beta);
RwMatrixDestroy(mat);
}
vec1.x = 0.0f;
vec1.y = 0.0f;
vec1.z = 1.0f;
if(IsClumpSkinned(this->ped->clump))
theta += 0.17453294f;
else{
......@@ -273,15 +269,24 @@ CPedIK::PointGunInDirectionUsingArm(float phi, float theta)
this->flags |= 1;
ret = true;
}
// flag == 0 only on PC and PS2...wtf?
if(flag == 0){
// only on PC and PS2...wtf?
}
if(IsClumpSkinned(this->ped->clump)){
RtQuat *q = &this->ped->frames[4]->hanimframe->q;
RtQuatRotate(q, &xAxis, RAD2DEG(this->upperArmOrient.phi), rwCOMBINEPOSTCONCAT);
RtQuatRotate(q, &zAxis, RAD2DEG(this->upperArmOrient.theta), rwCOMBINEPOSTCONCAT);
this->ped->someFlags |= 0x20;
this->ped->bfFlagsI |= 0x20;
}else{
RwFrame *f = this->ped->frames[4]->frame;
pos = f->modelling.pos;
// mat = CPedIK::GetWorldMatrix((RwFrame*)f->object.parent, RwMatrixCreate());
// vec2.x = mat->right.z;
// vec2.y = mat->up.z;
// vec2.z = mat->at.z;
// RwMatrixDestroy(mat);
RwMatrixRotate(&f->modelling, &vec1, RAD2DEG(this->upperArmOrient.theta), rwCOMBINEPOSTCONCAT);
RwMatrixRotate(&f->modelling, &vec2, RAD2DEG(this->upperArmOrient.phi), rwCOMBINEPOSTCONCAT);
f->modelling.pos = pos;
......@@ -304,12 +309,12 @@ CPedIK::PointGunInDirection(float phi, float theta)
{
bool ret = true;
char flag = 0;
phi = CGeneral__LimitRadianAngle(phi - this->ped->someAngle);
phi = CGeneral__LimitRadianAngle(phi - this->ped->fRotationCur);
this->flags &= ~1;
this->flags |= 2;
if(this->flags & 4){
flag = this->PointGunInDirectionUsingArm(phi, theta);
phi = CGeneral__LimitRadianAngle(phi - this->ped->someAngle);
phi = CGeneral__LimitRadianAngle(phi - this->ped->fRotationCur);
}
if(flag){
if(this->flags & 4 && this->torsoOrient.phi * this->upperArmOrient.phi < 0.0f)
......
......@@ -3,7 +3,7 @@
WRAPPER void CVisibilityPlugins__SetClumpModelInfo(RpClump *clump, int clumpModelInfo) { EAXJMP(0x528ED0); }
WRAPPER void __fastcall CBaseModelInfo__AddTexDictionaryRef(int self) { EAXJMP(0x4F6B80); }
WRAPPER void CClumpModelInfo::SetFrameIds(int ids) { EAXJMP(0x4F8BB0); }
WRAPPER void __fastcall CPedModelInfo__CreateHitColModel(int self) { EAXJMP(0x5104D0); }
//WRAPPER void __fastcall CPedModelInfo__CreateHitColModel(int self) { EAXJMP(0x5104D0); }
WRAPPER void __fastcall CPedModelInfo__DeleteRwObject_orig(CPedModelInfo*) { EAXJMP(0x510280); }
static RpAtomic*
......@@ -34,14 +34,15 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
RpClump*
CClumpModelInfo::CreateInstance(void)
{
RpClump *clone, *clone2;
RpClump *clump = this->clump;
if(clump == NULL)
return NULL;
RpClump *clone2 = RpClumpClone(clump);
RpClump *clone = RpClumpClone(clone2); // to reverse order of... something again...
clone2 = RpClumpClone(clump);
clone = RpClumpClone(clone2); // to reverse order of... something again...
RpClumpDestroy(clone2);
// clone = clone2;
//clone = clone2;
// RpClump *clone = RpClumpClone(clump);
if(IsClumpSkinned(clone)){
......@@ -50,7 +51,11 @@ CClumpModelInfo::CreateInstance(void)
RpHAnimAnimation *anim = HAnimAnimationCreateForHierarchy(hier);
RpHAnimHierarchySetCurrentAnim(hier, anim);
RpHAnimHierarchySetFlags(hier, rpHANIMHIERARCHYUPDATEMODELLINGMATRICES|rpHANIMHIERARCHYUPDATELTMS);
// Xbox has more some more code (skin related)
/* xbox:
v6 = RpSkinGeometryGetSkin(v5->geometry);
RpSkinGetNumBones(v6);
RpHAnimHierarchyUpdateMatrices(v3);
*/
}
return clone;
}
......@@ -69,11 +74,11 @@ CClumpModelInfo::SetClump(RpClump *clump)
if(IsClumpSkinned(clump)){
RpHAnimHierarchy *hier = GetAnimHierarchyFromClump(clump);
// mobile
RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier);
RpAtomic *atomic = GetFirstAtomic(clump);
// RpClumpForAllAtomics(clump, SetHierarchyForSkinAtomic, hier);
// RpAtomic *atomic = GetFirstAtomic(clump);
// Xbox
// RpAtomic *atomic = IsClumpSkinned(clump);
// RpSkinAtomicSetHAnimHierarchy(atomic, hier);
RpAtomic *atomic = IsClumpSkinned(clump);
RpSkinAtomicSetHAnimHierarchy(atomic, hier);
RpSkin *skin = RpSkinGeometryGetSkin(atomic->geometry);
// ignore const, lol
......@@ -127,15 +132,14 @@ CPedModelInfo::SetClump(RpClump *clump)
if(isplayer)
RpClumpForAllAtomics(clump, (RpAtomicCallBack)0x4F8940, (void*)0x528B30); // CClumpModelInfo::SetAtomicRendererCB, CVisibilityPlugins::RenderPlayerCB
if(atomic = IsClumpSkinned(clump)){
RpClumpRemoveAtomic(clump, atomic);
RpClumpAddAtomic(clump, atomic);
LimbCBarg limbs = { this, clump, 0, 0, 0 };
RpClumpForAllAtomics(clump, CPedModelInfo__findLimbsCb, &limbs);
}
this->CClumpModelInfo::SetClump(clump);
this->SetFrameIds(0x5FE7A4); // CPedModelInfo::m_pPedIds
if(this->hitColModel == NULL && !IsClumpSkinned(clump))
CPedModelInfo__CreateHitColModel((int)this);
this->CreateHitColModel();
//CPedModelInfo__CreateHitColModel((int)this);
// again, because CClumpModelInfo::SetClump resets renderCB
if(isplayer)
RpClumpForAllAtomics(clump, (RpAtomicCallBack)0x4F8940, (void*)0x528B30); // CClumpModelInfo::SetAtomicRendererCB, CVisibilityPlugins::RenderPlayerCB
......@@ -198,4 +202,143 @@ DeleteRwObject_hook(RpClump *clump)
{
RpClumpForAllAtomics(clump, AtomicRemoveAnimFromSkinCB, NULL);
RpClumpDestroy(clump);
}
\ No newline at end of file
}
struct ColLimb
{
char *name;
int id;
int flag;
float x;
float z;
float radius;
};
ColLimb *ColLimbs = (ColLimb*)0x5FE848;
CColModel*
CPedModelInfo::AnimatePedColModelSkinned(RpClump *clump)
{
CColModel *colmodel = this->hitColModel;
if(colmodel == NULL){
this->CreateHitColModelSkinned(clump);
return this->hitColModel;
}
RwMatrix *m1, *m2;
CColSphere *spheres = colmodel->spheres;
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(clump);
m1 = RwMatrixCreate();
m2 = RwMatrixCreate();
RwMatrixInvert(m1, &RpClumpGetFrame(clump)->modelling);
for(int i = 0; i < 8; i++){
*m2 = *m1;
int id = ConvertPedNode2BoneTag(ColLimbs[i].id);
int idx = RpHAnimIDGetIndex(hier, id);
RwMatrixTransform(m2, &RpHAnimHierarchyGetMatrixArray(hier)[idx], rwCOMBINEPRECONCAT);
RwV3d pos;
pos.x = pos.y = pos.z = 0.0f;
RwV3dTransformPoints(&pos, &pos, 1, m2);
spheres[i].center.x = pos.x + ColLimbs[i].x;
spheres[i].center.y = pos.y + 0.0f;
spheres[i].center.z = pos.z + ColLimbs[i].z;
}
RwMatrixDestroy(m1);
RwMatrixDestroy(m2);
return colmodel;
}
void
CPedModelInfo::CreateHitColModelSkinned(RpClump *clump)
{
CVector center;
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(clump);
CColModel *colmodel = (CColModel*)gta_nw(0x58);
colmodel->ctor();
CColSphere *spheres = (CColSphere*)RwMalloc(8*sizeof(CColSphere));
RwMatrix *m1, *m2;
m1 = RwMatrixCreate();
m2 = RwMatrixCreate();
RwMatrixInvert(m1, &RpClumpGetFrame(clump)->modelling);
for(int i = 0; i < 8; i++){
*m2 = *m1;
int id = ConvertPedNode2BoneTag(ColLimbs[i].id);
int idx = RpHAnimIDGetIndex(hier, id);
RwMatrixTransform(m2, &RpHAnimHierarchyGetMatrixArray(hier)[idx], rwCOMBINEPRECONCAT);
RwV3d pos;
pos.x = pos.y = pos.z = 0.0f;
RwV3dTransformPoints(&pos, &pos, 1, m2);
center.x = pos.x + ColLimbs[i].x;
center.y = pos.y + 0.0f;
center.z = pos.z + ColLimbs[i].z;
spheres[i].Set(ColLimbs[i].radius, &center, 17, ColLimbs[i].flag);
}
RwMatrixDestroy(m1);
RwMatrixDestroy(m2);
colmodel->spheres = spheres;
colmodel->numSpheres = 8;
center.x = center.y = center.z = 0.0f;
colmodel->boundingSphere.Set(2.0f, &center, 0, 0);
CVector min, max;
min.x = min.y = -0.5f;
min.z = -1.2f;
max.x = max.y = 0.5f;
max.z = 1.2f;
colmodel->boundingBox.Set(&min, &max, 0, 0);
colmodel->level = 0;
this->hitColModel = colmodel;
}
void
CPedModelInfo::CreateHitColModel(void)
{
struct {
union {
char *name;
int id;
};
RwFrame *out;
} search;
CVector center;
CColModel *colmodel = (CColModel*)gta_nw(0x58);
colmodel->ctor();
CColSphere *spheres = (CColSphere*)RwMalloc(8*sizeof(CColSphere));
RwFrame *root = RpClumpGetFrame(this->clump);
RwMatrix *mat = RwMatrixCreate();
for(int i = 0; i < 8; i++){
if(ColLimbs[i].name){
search.name = ColLimbs[i].name;
search.out = NULL;
RwFrameForAllChildren(root, (RwFrameCallBack)0x4F8960, &search);
}else{
search.id = ColLimbs[i].id;
search.out = NULL;
RwFrameForAllChildren(root, (RwFrameCallBack)0x4F8AD0, &search);
}
RwFrame *f = search.out;
if(f){
float radius = ColLimbs[i].radius;
if(ColLimbs[i].id == 6)
RwFrameForAllObjects(root, (RwObjectCallBack)0x5104A0, &radius);
*mat = f->modelling;
for(f = RwFrameGetParent(f); f != root; f = RwFrameGetParent(f))
RwMatrixTransform(mat, &f->modelling, rwCOMBINEPOSTCONCAT);
center.x = mat->pos.x + ColLimbs[i].x;
center.y = mat->pos.y + 0.0f;
center.z = mat->pos.z + ColLimbs[i].z;
spheres[i].Set(radius, &center, 17, ColLimbs[i].flag);
}
}
RwMatrixDestroy(mat);
colmodel->spheres = spheres;
colmodel->numSpheres = 8;
center.x = center.y = center.z = 0.0f;
colmodel->boundingSphere.Set(2.0f, &center, 0, 0);
CVector min, max;
min.x = min.y = -0.5f;
min.z = -1.2f;
max.x = max.y = 0.5f;
max.z = 1.2f;
colmodel->boundingBox.Set(&min, &max, 0, 0);
colmodel->level = 0;
this->hitColModel = colmodel;
}
......@@ -72,8 +72,6 @@ RpAnimBlendClumpUpdateAnimations(RpClump *clump, float timeDelta, bool doRender)
if(IsClumpSkinned(clump)){
clumpData->ForAllFrames(FrameUpdateCallBackSkinned, nodes);
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(clump);
RpHAnimHierarchyUpdateMatrices(hier);
}else
clumpData->ForAllFrames(FrameUpdateCallBack, nodes);
......@@ -272,7 +270,7 @@ RpAnimBlendClumpInitSkinned(RpClump *clump)
SkinGetBonePositionsToTable(clump, boneTab);
AnimBlendFrameData *frames = clumpData->frames;
for(int i = 0; i < numBones; i++){
for(uint i = 0; i < numBones; i++){
frames[i].nodeID = hier->pNodeInfo[i].nodeID;
frames[i].pos = boneTab[i];
frames[i].hanimframe = (RpHAnimStdKeyFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i);
......
#include "iii_anim.h"
int &CGame__currLevel = *(int*)0x941514;
void
CColModel::ctor(void)
{
this->numSpheres = 0;
this->spheres = 0;
this->numLines = 0;
this->lines = 0;
this->numBoxes = 0;
this->boxes = 0;
this->numTriangles = 0;
this->vertices = 0;
this->triangles = 0;
this->unk2 = 0;
this->level = CGame__currLevel;
this->unk1 = 1;
}
void
CColSphere::Set(float radius, CVector *center, uchar mat, uchar flag)
{
this->radius = radius;
this->center = *center;
this->mat = mat;
this->flag = flag;
}
void
CColBox::Set(CVector *min, CVector *max, uchar mat, uchar flag)
{
this->min = *min;
this->max = *max;
this->mat = mat;
this->flag = flag;
}
void
CColLine::Set(CVector *p0, CVector *p1)
{
this->p0 = *p0;
this->p1 = *p1;
}
void
CColTriangle::Set(int a, int b, int c, uchar mat)
{
this->a = a;
this->b = b;
this->c = c;
this->mat = mat;
}
typedef BYTE byte;
typedef BYTE uchar;
struct CColSphere
{
CVector center;
float radius;
uchar mat;
uchar flag;
void Set(float radius, CVector *center, uchar mat, uchar flag);
};
struct CColBox
{
CVector min;
CVector max;
uchar mat;
uchar flag;
void Set(CVector *min, CVector *max, uchar mat, uchar flag);
};
struct CColLine
{
CVector p0;
int pad0;
CVector p1;
int pad1;
void Set(CVector *p0, CVector *p1);
};
struct CColTriangle
{
short a;
short b;
short c;
uchar mat;
void Set(int a, int b, int c, uchar mat);
};
struct CColPoint
{
CVector point;
int pad1;
CVector normal;
int pad2;
byte surfaceTypeA;
byte pieceTypeA;
byte pieceTypeB;
byte surfaceTypeB;
float depth;
};
struct CColModel
{
CColSphere boundingSphere;
CColBox boundingBox;
short numSpheres;
short numLines;
short numBoxes;
short numTriangles;
int level;
byte unk1;
CColSphere *spheres;
CColLine *lines;
CColBox *boxes;
CVector *vertices;
CColTriangle *triangles;
int unk2;
void ctor(void);
};
......@@ -76,13 +76,13 @@ FrameUpdateCallBackWith3dVelocityExtraction(AnimBlendFrameData *frame, CAnimBlen
}
if(!(frame->flag & 4)){
gpAnimBlendClump->d[0] = x - curx;
gpAnimBlendClump->d[1] = y - cury;
gpAnimBlendClump->d[2] = z - curz;
gpAnimBlendClump->pedPosition->x = x - curx;
gpAnimBlendClump->pedPosition->y = y - cury;
gpAnimBlendClump->pedPosition->z = z - curz;
if(looped){
gpAnimBlendClump->d[0] += endx;
gpAnimBlendClump->d[1] += endy;
gpAnimBlendClump->d[2] += endz;
gpAnimBlendClump->pedPosition->x += endx;
gpAnimBlendClump->pedPosition->y += endy;
gpAnimBlendClump->pedPosition->z += endz;
}
mat->pos.x = pos.x - x + frame->pos.x;
mat->pos.y = pos.y - y + frame->pos.y;
......@@ -158,11 +158,11 @@ FrameUpdateCallBackWithVelocityExtraction(AnimBlendFrameData *frame, CAnimBlendN
}
if(!(frame->flag & 4)){
gpAnimBlendClump->d[0] = x - curx;
gpAnimBlendClump->d[1] = y - cury;
gpAnimBlendClump->pedPosition->x = x - curx;
gpAnimBlendClump->pedPosition->y = y - cury;
if(looped){
gpAnimBlendClump->d[0] += endx;
gpAnimBlendClump->d[1] += endy;
gpAnimBlendClump->pedPosition->x += endx;
gpAnimBlendClump->pedPosition->y += endy;
}
mat->pos.x = pos.x - x;
mat->pos.y = pos.y - y;
......@@ -190,7 +190,7 @@ FrameUpdateCallBack(AnimBlendFrameData *frame, void *arg)
CAnimBlendNode **node;
RwMatrix *mat = &frame->frame->modelling;
if (frame->flag & 8 && gpAnimBlendClump->d){
if (frame->flag & 8 && gpAnimBlendClump->pedPosition){
if(frame->flag & 0x10)
FrameUpdateCallBackWith3dVelocityExtraction(frame, nodes);
else
......@@ -313,13 +313,13 @@ FrameUpdateCallBackSkinnedWith3dVelocityExtraction(AnimBlendFrameData *frame, CA
}
if(!(frame->flag & 4)){
gpAnimBlendClump->d[0] = x - curx;
gpAnimBlendClump->d[1] = y - cury;
gpAnimBlendClump->d[2] = z - curz;
gpAnimBlendClump->pedPosition->x = x - curx;
gpAnimBlendClump->pedPosition->y = y - cury;
gpAnimBlendClump->pedPosition->z = z - curz;
if(looped){
gpAnimBlendClump->d[0] += endx;
gpAnimBlendClump->d[1] += endy;
gpAnimBlendClump->d[2] += endz;
gpAnimBlendClump->pedPosition->x += endx;
gpAnimBlendClump->pedPosition->y += endy;
gpAnimBlendClump->pedPosition->z += endz;
}
frameData->t.x = pos.x - x + frame->pos.x;
frameData->t.y = pos.y - y + frame->pos.y;
......@@ -403,11 +403,11 @@ FrameUpdateCallBackSkinnedWithVelocityExtraction(AnimBlendFrameData *frame, CAni
}
if(!(frame->flag & 4)){
gpAnimBlendClump->d[0] = x - curx;
gpAnimBlendClump->d[1] = y - cury;
gpAnimBlendClump->pedPosition->x = x - curx;
gpAnimBlendClump->pedPosition->y = y - cury;
if(looped){
gpAnimBlendClump->d[0] += endx;
gpAnimBlendClump->d[1] += endy;
gpAnimBlendClump->pedPosition->x += endx;
gpAnimBlendClump->pedPosition->y += endy;
}
frameData->t.x = pos.x - x;
frameData->t.y = pos.y - y;
......@@ -434,7 +434,7 @@ FrameUpdateCallBackSkinned(AnimBlendFrameData *frame, void *arg)
RpHAnimStdKeyFrame *frameData = frame->hanimframe;
CAnimBlendNode **node;
if (frame->flag & 8 && gpAnimBlendClump->d){
if (frame->flag & 8 && gpAnimBlendClump->pedPosition){
if(frame->flag & 0x10)
FrameUpdateCallBackSkinnedWith3dVelocityExtraction(frame, nodes);
else
......
......@@ -15,6 +15,8 @@
typedef unsigned int uint;
#define RAD2DEG(x) (180.0f*(x)/M_PI)
void pedhooks(void);
void pedikhooks(void);
......@@ -32,6 +34,7 @@ RpAtomic *GetFirstAtomic(RpClump *clump);
RpAtomic *IsClumpSkinned(RpClump*);
RpHAnimHierarchy* GetAnimHierarchyFromSkinClump(RpClump *clump);
RpHAnimHierarchy* GetAnimHierarchyFromClump(RpClump *clump);
int ConvertPedNode2BoneTag(int node);
void DeleteRwObject_hook(RpClump *clump);
......@@ -136,8 +139,15 @@ public:
void Normalize(void);
};
class CVector2D {
public:
float x, y;
};
void CrossProduct(CVector *, CVector *, CVector *);
#include "collision.h"
class CAnimBlendSequence;
class CAnimBlendHierarchy;
class CAnimBlock;
......@@ -148,40 +158,94 @@ struct AnimBlendFrameData;
class CAnimBlendClumpData;
class CAnimManager;
struct CEntity
struct CEntity;
struct CCollPoly
{
CVector vecColPolyPoint1;
CVector vecColPolyPoint2;
CVector vecColPolyPoint3;
bool bIsValidCollision;
};
struct CWeapon
{
int nWeaponId;
int nWeaponState;
int nAmmoLoaded;
int nAmmoTotal;
int dwNextShotTime;
bool bAddRotOffset;
};
struct CPlaceable
{
void **vtable;
int data1[18];
RpClump *clump;
int data2[3];