forked from mirror/openmw-tes3mp
btScaledBvhTriangleMeshShapes
This commit is contained in:
parent
ac6b455592
commit
33fe80723c
6 changed files with 14 additions and 11 deletions
|
@ -237,6 +237,7 @@ namespace MWWorld
|
||||||
void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh,
|
void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh,
|
||||||
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position)
|
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position)
|
||||||
{
|
{
|
||||||
|
handleToMesh[handle] = mesh;
|
||||||
OEngine::Physic::RigidBody* body = mEngine->createRigidBody(mesh,handle,scale);
|
OEngine::Physic::RigidBody* body = mEngine->createRigidBody(mesh,handle,scale);
|
||||||
mEngine->addRigidBody(body);
|
mEngine->addRigidBody(body);
|
||||||
btTransform tr;
|
btTransform tr;
|
||||||
|
|
|
@ -72,6 +72,7 @@ namespace MWWorld
|
||||||
OEngine::Physic::PhysicEngine* mEngine;
|
OEngine::Physic::PhysicEngine* mEngine;
|
||||||
bool mFreeFly;
|
bool mFreeFly;
|
||||||
playerMove* playerphysics;
|
playerMove* playerphysics;
|
||||||
|
std::map<std::string, std::string> handleToMesh;
|
||||||
|
|
||||||
PhysicsSystem (const PhysicsSystem&);
|
PhysicsSystem (const PhysicsSystem&);
|
||||||
PhysicsSystem& operator= (const PhysicsSystem&);
|
PhysicsSystem& operator= (const PhysicsSystem&);
|
||||||
|
|
|
@ -324,24 +324,24 @@ namespace Physic
|
||||||
|
|
||||||
RigidBody* PhysicEngine::createRigidBody(std::string mesh,std::string name,float scale)
|
RigidBody* PhysicEngine::createRigidBody(std::string mesh,std::string name,float scale)
|
||||||
{
|
{
|
||||||
char uniqueID[8];
|
/*char uniqueID[8];
|
||||||
sprintf( uniqueID, "%07.3f", scale );
|
sprintf( uniqueID, "%07.3f", scale );
|
||||||
std::string sid = uniqueID;
|
std::string sid = uniqueID;
|
||||||
std::string outputstring = mesh + uniqueID + "\"|";
|
std::string outputstring = mesh + uniqueID + "\"|";*/
|
||||||
//std::cout << "The string" << outputstring << "\n";
|
//std::cout << "The string" << outputstring << "\n";
|
||||||
|
|
||||||
//get the shape from the .nif
|
//get the shape from the .nif
|
||||||
mShapeLoader->load(outputstring,"General");
|
mShapeLoader->load(mesh,"General");
|
||||||
BulletShapeManager::getSingletonPtr()->load(outputstring,"General");
|
BulletShapeManager::getSingletonPtr()->load(mesh,"General");
|
||||||
BulletShapePtr shape = BulletShapeManager::getSingleton().getByName(outputstring,"General");
|
BulletShapePtr shape = BulletShapeManager::getSingleton().getByName(mesh,"General");
|
||||||
shape->Shape->setLocalScaling(btVector3(scale,scale,scale));
|
//shape->Shape->setLocalScaling();
|
||||||
|
btScaledBvhTriangleMeshShape* scaled = new btScaledBvhTriangleMeshShape(dynamic_cast<btBvhTriangleMeshShape*> (shape->Shape), btVector3(scale,scale,scale));
|
||||||
|
|
||||||
//create the motionState
|
//create the motionState
|
||||||
CMotionState* newMotionState = new CMotionState(this,name);
|
CMotionState* newMotionState = new CMotionState(this,name);
|
||||||
|
|
||||||
//create the real body
|
//create the real body
|
||||||
btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo(0,newMotionState,shape->Shape);
|
btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo(0,newMotionState,scaled);
|
||||||
RigidBody* body = new RigidBody(CI,name);
|
RigidBody* body = new RigidBody(CI,name);
|
||||||
body->collide = shape->collide;
|
body->collide = shape->collide;
|
||||||
return body;
|
return body;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "BulletShapeLoader.h"
|
#include "BulletShapeLoader.h"
|
||||||
|
#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
|
||||||
|
|
||||||
class btRigidBody;
|
class btRigidBody;
|
||||||
class btBroadphaseInterface;
|
class btBroadphaseInterface;
|
||||||
|
|
|
@ -1430,7 +1430,7 @@ static void PM_GroundTrace( void )
|
||||||
// if the trace didn't hit anything, we are in free fall
|
// if the trace didn't hit anything, we are in free fall
|
||||||
if ( trace.fraction == 1.0)
|
if ( trace.fraction == 1.0)
|
||||||
{
|
{
|
||||||
if(pm->ps.velocity.z > 50.0f && pm->ps.bSnap)
|
if(pm->ps.velocity.z > 50.0f && pm->ps.bSnap && pm->ps.speed > 1000.0f)
|
||||||
pm->ps.velocity.z = 50.0f;
|
pm->ps.velocity.z = 50.0f;
|
||||||
if(pm->ps.snappingImplemented){
|
if(pm->ps.snappingImplemented){
|
||||||
if(pm->ps.bSnap && pm->ps.counter <= 0)
|
if(pm->ps.bSnap && pm->ps.counter <= 0)
|
||||||
|
|
|
@ -42,7 +42,7 @@ static const Ogre::Vector3 halfExtents(14.64f * 2, 14.24f * 2, 33.25f * 2);
|
||||||
#define ENTITYNUM_NONE (MAX_GENTITIES - 1)
|
#define ENTITYNUM_NONE (MAX_GENTITIES - 1)
|
||||||
#define ENTITYNUM_WORLD (MAX_GENTITIES - 2)
|
#define ENTITYNUM_WORLD (MAX_GENTITIES - 2)
|
||||||
#define MIN_WALK_NORMAL .7f // can't walk on very steep slopes
|
#define MIN_WALK_NORMAL .7f // can't walk on very steep slopes
|
||||||
#define JUMP_VELOCITY (540)
|
#define JUMP_VELOCITY (270)
|
||||||
#define PS_PMOVEFRAMECOUNTBITS 6
|
#define PS_PMOVEFRAMECOUNTBITS 6
|
||||||
#define MINS_Z -24
|
#define MINS_Z -24
|
||||||
#define DEFAULT_VIEWHEIGHT 26
|
#define DEFAULT_VIEWHEIGHT 26
|
||||||
|
@ -90,7 +90,7 @@ struct playerMove
|
||||||
{
|
{
|
||||||
struct playerStruct
|
struct playerStruct
|
||||||
{
|
{
|
||||||
playerStruct() : gravity(800.0f), speed(2000.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0), snappingImplemented(true), bSnap(false), counter(-1)
|
playerStruct() : gravity(800.0f), speed(480.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0), snappingImplemented(true), bSnap(false), counter(-1)
|
||||||
{
|
{
|
||||||
origin = Ogre::Vector3(733.164f,900.0f, 839.432f);
|
origin = Ogre::Vector3(733.164f,900.0f, 839.432f);
|
||||||
velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f);
|
velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f);
|
||||||
|
|
Loading…
Reference in a new issue