forked from bartvdbraak/blender
- Charlie provided a work-around for some armature related crashes
- fixed some Bullet raycasting (hitfraction was not properly updated for static meshes) - removed some cvs tags in Bullet's BMF _Font files (they keep on conflicting when duplicated in different repositories) - set default linearsleepingtreshold explicitly
This commit is contained in:
parent
d3dd1da8d4
commit
ede20c166a
@ -258,19 +258,20 @@ void CollisionWorld::RayTest(const SimdVector3& rayFromWorld, const SimdVector3&
|
||||
}
|
||||
|
||||
|
||||
virtual void ReportHit(const SimdVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex )
|
||||
virtual float ReportHit(const SimdVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex )
|
||||
{
|
||||
LocalShapeInfo shapeInfo;
|
||||
CollisionWorld::LocalShapeInfo shapeInfo;
|
||||
shapeInfo.m_shapePart = partId;
|
||||
shapeInfo.m_triangleIndex = triangleIndex;
|
||||
|
||||
LocalRayResult rayResult
|
||||
CollisionWorld::LocalRayResult rayResult
|
||||
(m_collisionObject,
|
||||
&shapeInfo,
|
||||
hitNormalLocal,
|
||||
hitFraction);
|
||||
|
||||
m_resultCallback->AddSingleResult(rayResult);
|
||||
return m_resultCallback->AddSingleResult(rayResult);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -294,4 +295,4 @@ void CollisionWorld::RayTest(const SimdVector3& rayFromWorld, const SimdVector3&
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -94,6 +94,9 @@ public:
|
||||
///RayResultCallback is used to report new raycast results
|
||||
struct RayResultCallback
|
||||
{
|
||||
virtual ~RayResultCallback()
|
||||
{
|
||||
}
|
||||
float m_closestHitFraction;
|
||||
bool HasHit()
|
||||
{
|
||||
|
@ -194,8 +194,10 @@ float ConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(BroadphaseProxy* ,B
|
||||
{
|
||||
}
|
||||
|
||||
virtual void ReportHit(const SimdVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex )
|
||||
virtual float ReportHit(const SimdVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex )
|
||||
{
|
||||
//todo: handle ccd here
|
||||
return 0.f;
|
||||
|
||||
}
|
||||
};
|
||||
|
@ -87,11 +87,11 @@ void TriangleRaycastCallback::ProcessTriangle(SimdVector3* triangle,int partId,
|
||||
|
||||
if ( dist_a > 0 )
|
||||
{
|
||||
ReportHit(triangleNormal,distance,partId,triangleIndex);
|
||||
m_hitFraction = ReportHit(triangleNormal,distance,partId,triangleIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportHit(-triangleNormal,distance,partId,triangleIndex);
|
||||
m_hitFraction = ReportHit(-triangleNormal,distance,partId,triangleIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
|
||||
virtual void ProcessTriangle(SimdVector3* triangle, int partId, int triangleIndex);
|
||||
|
||||
virtual void ReportHit(const SimdVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex ) = 0;
|
||||
virtual float ReportHit(const SimdVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex ) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@ class BP_Proxy;
|
||||
float gDeactivationTime = 2.f;
|
||||
bool gDisableDeactivation = false;
|
||||
|
||||
float gLinearSleepingTreshold = 0.4f;
|
||||
float gLinearSleepingTreshold = 0.8f;
|
||||
float gAngularSleepingTreshold = 1.0f;
|
||||
|
||||
#include "Dynamics/MassProps.h"
|
||||
|
@ -1529,7 +1529,9 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep)
|
||||
|
||||
|
||||
shapeinterface->CalculateTemporalAabb(body->getCenterOfMassTransform(),
|
||||
body->getLinearVelocity(),body->getAngularVelocity(),
|
||||
body->getLinearVelocity(),
|
||||
//body->getAngularVelocity(),
|
||||
SimdVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(),
|
||||
timeStep,minAabb,maxAabb);
|
||||
|
||||
|
||||
|
@ -397,6 +397,7 @@ int BIF_read_homefile(void)
|
||||
} else {
|
||||
success = BKE_read_file_from_memory(datatoc_B_blend, datatoc_B_blend_size, NULL);
|
||||
}
|
||||
|
||||
BLI_clean(scestr);
|
||||
strcpy(G.sce, scestr);
|
||||
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
/// Returns the bone length. The end of the bone is in the local y direction.
|
||||
float GetBoneLength(Bone* bone) const;
|
||||
|
||||
virtual int GetGameObjectType() { return OBJ_ARMATURE; }
|
||||
protected:
|
||||
Object *m_objArma;
|
||||
struct bArmature *m_armature;
|
||||
|
@ -300,6 +300,9 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
|
||||
{
|
||||
CcdPhysicsEnvironment* ccdPhysEnv = new CcdPhysicsEnvironment();
|
||||
ccdPhysEnv->setDebugDrawer(new BlenderDebugDraw());
|
||||
ccdPhysEnv->setDeactivationLinearTreshold(0.8f); // default, can be overridden by Python
|
||||
ccdPhysEnv->setDeactivationAngularTreshold(1.0f); // default, can be overridden by Python
|
||||
|
||||
//todo: get a button in blender ?
|
||||
//disable / enable debug drawing (contact points, aabb's etc)
|
||||
//ccdPhysEnv->setDebugMode(1);
|
||||
|
@ -116,7 +116,13 @@ public:
|
||||
|
||||
// here come the python forwarded methods
|
||||
virtual PyObject* _getattr(const STR_String& attr);
|
||||
|
||||
virtual int GetGameObjectType() {return -1;}
|
||||
|
||||
typedef enum ObjectTypes {
|
||||
OBJ_ARMATURE=0
|
||||
}ObjectTypes;
|
||||
|
||||
};
|
||||
|
||||
#endif //SCA_IOBJECT_H
|
||||
|
@ -732,43 +732,92 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj)
|
||||
|
||||
void KX_Scene::ReplaceMesh(class CValue* gameobj,void* meshobj)
|
||||
{
|
||||
KX_GameObject* newobj = (KX_GameObject*) gameobj;
|
||||
RAS_MeshObject* mesh = (RAS_MeshObject*) meshobj;
|
||||
KX_GameObject* newobj = static_cast<KX_GameObject*>(gameobj);
|
||||
RAS_MeshObject* mesh = static_cast<RAS_MeshObject*>(meshobj);
|
||||
|
||||
const STR_String origMeshName = newobj->GetMesh(0)->GetName();
|
||||
|
||||
if( !newobj || !mesh )
|
||||
{
|
||||
std::cout << "warning: invalid object, mesh will not be replaced" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
newobj->RemoveMeshes();
|
||||
newobj->AddMesh(mesh);
|
||||
|
||||
if (newobj->m_isDeformable && mesh->m_class == 1) {
|
||||
Object* blendobj = (struct Object*)m_logicmgr->FindBlendObjByGameObj(newobj);
|
||||
Object* oldblendobj = (struct Object*)m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName());
|
||||
|
||||
if (blendobj->parent && blendobj->parent->type == OB_ARMATURE &&
|
||||
blendobj->partype==PARSKEL &&
|
||||
((Mesh*)blendobj->data)->dvert)
|
||||
bool isDeformer = (newobj->m_isDeformable && mesh->m_class == 1);
|
||||
if(isDeformer)
|
||||
{
|
||||
/* FindBlendObjByGameObj() can return 0...
|
||||
In the case of 0 here,
|
||||
the replicated object that is calling this function
|
||||
is some how not in the map. (which is strange because it's added)
|
||||
So we will search the map by the first mesh name
|
||||
to try to locate it there. If its still not found
|
||||
spit some message rather than crash
|
||||
*/
|
||||
Object* blendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameObj(newobj));
|
||||
Object* oldblendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName()));
|
||||
|
||||
bool parSkin = blendobj && blendobj->parent && blendobj->parent->type == OB_ARMATURE && blendobj->partype==PARSKEL;
|
||||
bool releaseParent = true;
|
||||
KX_GameObject* parentobj = newobj->GetParent();
|
||||
|
||||
|
||||
// lookup by mesh name if blendobj is 0
|
||||
if( !blendobj && parentobj )
|
||||
{
|
||||
// FIXME: should the old m_pDeformer be deleted?
|
||||
// it shouldn't be a problem to delete it now.
|
||||
// if we are constructing this on the fly like here,
|
||||
// make sure to release newobj->GetParent(), and things will run shipshape
|
||||
delete static_cast<BL_DeformableGameObject*>( newobj )->m_pDeformer;
|
||||
|
||||
BL_SkinDeformer* skindeformer = new BL_SkinDeformer(
|
||||
oldblendobj, blendobj,
|
||||
static_cast<BL_SkinMeshObject*>(mesh),
|
||||
true, // release ref count to BL_ArmatureObject, leak otherwise
|
||||
static_cast<BL_ArmatureObject*>(newobj->GetParent())
|
||||
);
|
||||
static_cast<BL_DeformableGameObject*>( newobj )->m_pDeformer = skindeformer;
|
||||
}
|
||||
else if (((Mesh*)blendobj->data)->dvert) {
|
||||
BL_MeshDeformer* meshdeformer = new BL_MeshDeformer(oldblendobj, (BL_SkinMeshObject*)mesh );
|
||||
blendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameMeshName(origMeshName));
|
||||
|
||||
// FIXME: should the old m_pDeformer be deleted?
|
||||
// delete ((BL_DeformableGameObject*)newobj)->m_pDeformer
|
||||
((BL_DeformableGameObject*)newobj)->m_pDeformer = meshdeformer;
|
||||
// replace the mesh on the parent armature
|
||||
if( blendobj )
|
||||
parSkin = parentobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE;
|
||||
|
||||
// can't do it
|
||||
else
|
||||
std::cout << "warning: child object for " << parentobj->GetName().ReadPtr()
|
||||
<< " not found, and can't create!" << std::endl;
|
||||
}
|
||||
|
||||
if( blendobj && oldblendobj )
|
||||
{
|
||||
isDeformer = (static_cast<Mesh*>(blendobj->data)->dvert != 0);
|
||||
BL_DeformableGameObject* deformIter =0;
|
||||
|
||||
// armature parent
|
||||
if( parSkin && isDeformer )
|
||||
{
|
||||
deformIter = static_cast<BL_DeformableGameObject*>( newobj );
|
||||
delete deformIter->m_pDeformer;
|
||||
|
||||
BL_SkinDeformer* skinDeformer = new BL_SkinDeformer(
|
||||
oldblendobj, blendobj,
|
||||
static_cast<BL_SkinMeshObject*>(mesh),
|
||||
true,
|
||||
static_cast<BL_ArmatureObject*>( parentobj )
|
||||
);
|
||||
releaseParent= false;
|
||||
deformIter->m_pDeformer = skinDeformer;
|
||||
}
|
||||
|
||||
// normal deformer
|
||||
if( !parSkin && isDeformer)
|
||||
{
|
||||
deformIter = static_cast<BL_DeformableGameObject*>( newobj );
|
||||
delete deformIter->m_pDeformer;
|
||||
|
||||
BL_MeshDeformer* meshdeformer = new BL_MeshDeformer(
|
||||
oldblendobj, static_cast<BL_SkinMeshObject*>(mesh)
|
||||
);
|
||||
|
||||
deformIter->m_pDeformer = meshdeformer;
|
||||
}
|
||||
}
|
||||
// release parent reference if its not being used
|
||||
if( releaseParent && parentobj)
|
||||
parentobj->Release();
|
||||
}
|
||||
|
||||
newobj->Bucketize();
|
||||
}
|
||||
|
||||
|
@ -1529,7 +1529,9 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep)
|
||||
|
||||
|
||||
shapeinterface->CalculateTemporalAabb(body->getCenterOfMassTransform(),
|
||||
body->getLinearVelocity(),body->getAngularVelocity(),
|
||||
body->getLinearVelocity(),
|
||||
//body->getAngularVelocity(),
|
||||
SimdVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(),
|
||||
timeStep,minAabb,maxAabb);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user