applied the 64-bit pointer patch submitted by Ken Hughes

This commit is contained in:
Erwin Coumans 2005-11-28 06:51:54 +00:00
parent 427cae9eeb
commit e1c66eb145
17 changed files with 91 additions and 47 deletions

@ -35,18 +35,23 @@
#include <config.h>
#endif
unsigned int KX_Hash(unsigned int inDWord)
unsigned int KX_Hash(void * inDWord)
{
unsigned int key = inDWord;
#if defined(_WIN64)
unsigned __int64 key = (unsigned __int64)inDWord;
#else
unsigned long key = (unsigned long)inDWord;
#endif
key += ~(key << 16);
key ^= (key >> 5);
key += (key << 3);
key ^= (key >> 13);
key += ~(key << 9);
key ^= (key >> 17);
return key;
};
return (unsigned int)(key & 0xffffffff);
}
CHashedPtr::CHashedPtr(void* val) : m_valptr(val)
@ -57,5 +62,5 @@ CHashedPtr::CHashedPtr(void* val) : m_valptr(val)
unsigned int CHashedPtr::hash() const
{
return KX_Hash((unsigned int) m_valptr);
return KX_Hash(m_valptr);
}

@ -32,7 +32,7 @@
#ifndef __KX_HASHEDPTR
#define __KX_HASHEDPTR
unsigned int KX_Hash(unsigned int inDWord);
unsigned int KX_Hash(void * inDWord);
class CHashedPtr
{

@ -38,6 +38,12 @@
#include <config.h>
#endif
#if defined(_WIN64)
typedef unsigned __int64 uint_ptr;
#else
typedef unsigned long uint_ptr;
#endif
bool KX_CameraIpoSGController::Update(double currentTime)
{
if (m_modified)
@ -92,10 +98,10 @@ SG_Controller* KX_CameraIpoSGController::GetReplica(class SG_Node* destnode)
iporeplica->AddInterpolator(copyipo);
MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
int orgbase = (int)this;
int orgloc = (int)scaal;
int offset = orgloc-orgbase;
int newaddrbase = (int)iporeplica + offset;
uint_ptr orgbase = (uint_ptr)this;
uint_ptr orgloc = (uint_ptr)scaal;
uint_ptr offset = orgloc-orgbase;
uint_ptr newaddrbase = (uint_ptr)iporeplica + offset;
MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
copyipo->SetNewTarget((MT_Scalar*)blaptr);
}

@ -35,6 +35,12 @@
#include <config.h>
#endif
#if defined(_WIN64)
typedef unsigned __int64 uint_ptr;
#else
typedef unsigned long uint_ptr;
#endif
#ifdef WIN32
// This warning tells us about truncation of __long__ stl-generated names.
// It can occasionally cause DevStudio to have internal compiler warnings.
@ -1068,12 +1074,12 @@ PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self,
PyObject* kwds)
{
KX_IPhysicsController* ctrl = GetPhysicsController();
int physid=0;
uint_ptr physid=0;
if (ctrl)
{
physid= (int)ctrl->GetUserData();
physid= (uint_ptr)ctrl->GetUserData();
}
return PyInt_FromLong(physid);
return PyInt_FromLong((long)physid);
}
KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo,

@ -35,6 +35,12 @@
#include <config.h>
#endif
#if defined(_WIN64)
typedef unsigned __int64 uint_ptr;
#else
typedef unsigned long uint_ptr;
#endif
#ifdef WIN32
// This warning tells us about truncation of __long__ stl-generated names.
// It can occasionally cause DevStudio to have internal compiler warnings.
@ -168,10 +174,10 @@ SG_Controller* KX_IpoSGController::GetReplica(class SG_Node* destnode)
iporeplica->AddInterpolator(copyipo);
MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
int orgbase = (int)&m_ipo_xform;
int orgloc = (int)scaal;
int offset = orgloc-orgbase;
int newaddrbase = (int)&iporeplica->m_ipo_xform;
uint_ptr orgbase = (uint_ptr)&m_ipo_xform;
uint_ptr orgloc = (uint_ptr)scaal;
uint_ptr offset = orgloc-orgbase;
uint_ptr newaddrbase = (uint_ptr)&iporeplica->m_ipo_xform;
newaddrbase += offset;
MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
copyipo->SetNewTarget((MT_Scalar*)blaptr);

@ -38,6 +38,12 @@
#include <config.h>
#endif
#if defined(_WIN64)
typedef unsigned __int64 uint_ptr;
#else
typedef unsigned long uint_ptr;
#endif
bool KX_LightIpoSGController::Update(double currentTime)
{
if (m_modified)
@ -97,10 +103,10 @@ SG_Controller* KX_LightIpoSGController::GetReplica(class SG_Node* destnode)
iporeplica->AddInterpolator(copyipo);
MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
int orgbase = (int)this;
int orgloc = (int)scaal;
int offset = orgloc-orgbase;
int newaddrbase = (int)iporeplica + offset;
uint_ptr orgbase = (uint_ptr)this;
uint_ptr orgloc = (uint_ptr)scaal;
uint_ptr offset = orgloc-orgbase;
uint_ptr newaddrbase = (uint_ptr)iporeplica + offset;
MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
copyipo->SetNewTarget((MT_Scalar*)blaptr);
}

@ -37,6 +37,13 @@
#include <config.h>
#endif
#if defined(_WIN64)
typedef unsigned __int64 uint_ptr;
#else
typedef unsigned long uint_ptr;
#endif
bool KX_ObColorIpoSGController::Update(double currentTime)
{
if (m_modified)
@ -87,10 +94,10 @@ SG_Controller* KX_ObColorIpoSGController::GetReplica(class SG_Node* destnode)
iporeplica->AddInterpolator(copyipo);
MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
int orgbase = (int)this;
int orgloc = (int)scaal;
int offset = orgloc-orgbase;
int newaddrbase = (int)iporeplica + offset;
uint_ptr orgbase = (uint_ptr)this;
uint_ptr orgloc = (uint_ptr)scaal;
uint_ptr offset = orgloc-orgbase;
uint_ptr newaddrbase = (uint_ptr)iporeplica + offset;
MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
copyipo->SetNewTarget((MT_Scalar*)blaptr);
}

@ -352,13 +352,17 @@ static PyObject* gPyRemoveConstraint(PyObject* self,
PyObject* args,
PyObject* kwds)
{
int constraintid;
if (PyArg_ParseTuple(args,"i",&constraintid))
#if defined(_WIN64)
__int64 constraintid;
if (PyArg_ParseTuple(args,"L",&constraintid))
#else
long constraintid;
if (PyArg_ParseTuple(args,"l",&constraintid))
#endif
{
if (PHY_GetActiveEnvironment())
{
PHY_GetActiveEnvironment()->removeConstraint(constraintid);
PHY_GetActiveEnvironment()->removeConstraint((void *)constraintid);
}
}
Py_INCREF(Py_None); return Py_None;

@ -37,6 +37,12 @@
#include <config.h>
#endif
#if defined(_WIN64)
typedef unsigned __int64 uint_ptr;
#else
typedef unsigned long uint_ptr;
#endif
bool KX_WorldIpoController::Update(double currentTime)
{
if (m_modified)
@ -92,10 +98,10 @@ SG_Controller* KX_WorldIpoController::GetReplica(class SG_Node* destnode)
iporeplica->AddInterpolator(copyipo);
MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
int orgbase = (int)this;
int orgloc = (int)scaal;
int offset = orgloc-orgbase;
int newaddrbase = (int)iporeplica + offset;
uint_ptr orgbase = (uint_ptr)this;
uint_ptr orgloc = (uint_ptr)scaal;
uint_ptr offset = orgloc-orgbase;
uint_ptr newaddrbase = (uint_ptr)iporeplica + offset;
MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
copyipo->SetNewTarget((MT_Scalar*)blaptr);
}

@ -53,7 +53,7 @@ public:
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ);
virtual void removeConstraint(int constraintid);
virtual void removeConstraint(void * constraintid);
virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);

@ -192,7 +192,7 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
if ((&p2p->GetRigidBodyA() == ctrl->GetRigidBody() ||
(&p2p->GetRigidBodyB() == ctrl->GetRigidBody())))
{
removeConstraint(int(p2p));
removeConstraint(p2p);
//only 1 constraint per constroller
break;
}
@ -209,7 +209,7 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
if ((&p2p->GetRigidBodyA() == ctrl->GetRigidBody() ||
(&p2p->GetRigidBodyB() == ctrl->GetRigidBody())))
{
removeConstraint(int(p2p));
removeConstraint(p2p);
//only 1 constraint per constroller
break;
}
@ -768,13 +768,11 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
}
void CcdPhysicsEnvironment::removeConstraint(int constraintid)
void CcdPhysicsEnvironment::removeConstraint(void* p2p)
{
Point2PointConstraint* p2p = (Point2PointConstraint*) constraintid;
std::vector<Point2PointConstraint*>::iterator i =
std::find(m_p2pConstraints.begin(), m_p2pConstraints.end(), p2p);
std::find(m_p2pConstraints.begin(), m_p2pConstraints.end(),
(Point2PointConstraint *)p2p);
if (!(i == m_p2pConstraints.end()) )
{

@ -75,7 +75,7 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ);
virtual void removeConstraint(int constraintid);
virtual void removeConstraint(void* constraintid);
virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ,

@ -101,7 +101,7 @@ int DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ct
}
void DummyPhysicsEnvironment::removeConstraint(int constraintid)
void DummyPhysicsEnvironment::removeConstraint(void * constraintid)
{
if (constraintid)
{

@ -61,7 +61,7 @@ public:
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ);
virtual void removeConstraint(int constraintid);
virtual void removeConstraint(void * constraintid);
virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);

@ -117,7 +117,7 @@ int SumoPhysicsEnvironment::createConstraint(
return constraintid;
}
void SumoPhysicsEnvironment::removeConstraint(int constraintid)
void SumoPhysicsEnvironment::removeConstraint(void * constraintid)
{
if (constraintid)
{

@ -66,7 +66,7 @@ public:
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ);
virtual void removeConstraint(int constraintid);
virtual void removeConstraint(void * constraintid);
virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);

@ -83,7 +83,7 @@ class PHY_IPhysicsEnvironment
virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ)=0;
virtual void removeConstraint(int constraintid)=0;
virtual void removeConstraint(void * constraintid)=0;
virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)=0;