mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-28 00:29:34 +00:00
Updates to various components, added a few new ones.
This commit is contained in:
parent
e0627973fb
commit
dac8d6e1fd
52 changed files with 4566 additions and 1799 deletions
|
|
@ -20,7 +20,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "T3D/components/physics/physicsBehavior.h"
|
||||
#include "T3D/components/physics/physicsComponent.h"
|
||||
#include "platform/platform.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "core/util/safeDelete.h"
|
||||
|
|
@ -37,6 +37,8 @@
|
|||
#include "T3D/containerQuery.h"
|
||||
#include "math/mathIO.h"
|
||||
|
||||
#include "T3D/physics/physicsPlugin.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Constructor/Destructor
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -47,6 +49,11 @@ PhysicsComponent::PhysicsComponent() : Component()
|
|||
addComponentField("drag", "The drag coefficient that constantly affects the object", "float", "0.7", "");
|
||||
addComponentField("mass", "The mass of the object", "float", "1", "");
|
||||
|
||||
mFriendlyName = "Physics Component";
|
||||
mComponentType = "Physics";
|
||||
|
||||
mDescription = getDescriptionText("A stub component class that physics components should inherit from.");
|
||||
|
||||
mStatic = false;
|
||||
mAtRest = false;
|
||||
mAtRestCounter = 0;
|
||||
|
|
@ -80,7 +87,7 @@ PhysicsComponent::~PhysicsComponent()
|
|||
SAFE_DELETE_ARRAY(mDescription);
|
||||
}
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(PhysicsComponent);
|
||||
IMPLEMENT_CONOBJECT(PhysicsComponent);
|
||||
|
||||
void PhysicsComponent::onComponentAdd()
|
||||
{
|
||||
|
|
@ -92,6 +99,11 @@ void PhysicsComponent::onComponentAdd()
|
|||
mDelta.posVec = Point3F(0,0,0);
|
||||
}
|
||||
|
||||
void PhysicsComponent::onComponentRemove()
|
||||
{
|
||||
Parent::onComponentRemove();
|
||||
}
|
||||
|
||||
void PhysicsComponent::initPersistFields()
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
|
@ -101,6 +113,7 @@ void PhysicsComponent::initPersistFields()
|
|||
addField("isStatic", TypeBool, Offset(mStatic, PhysicsComponent));
|
||||
}
|
||||
|
||||
//Networking
|
||||
U32 PhysicsComponent::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
||||
{
|
||||
U32 retMask = Parent::packUpdate(con, mask, stream);
|
||||
|
|
@ -123,7 +136,6 @@ U32 PhysicsComponent::packUpdate(NetConnection *con, U32 mask, BitStream *stream
|
|||
}
|
||||
return retMask;
|
||||
}
|
||||
|
||||
void PhysicsComponent::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||
{
|
||||
Parent::unpackUpdate(con, stream);
|
||||
|
|
@ -146,7 +158,35 @@ void PhysicsComponent::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
//Setup
|
||||
void PhysicsComponent::prepCollision()
|
||||
{
|
||||
if (!mOwner)
|
||||
return;
|
||||
|
||||
if (mConvexList != NULL)
|
||||
mConvexList->nukeList();
|
||||
|
||||
mOwner->enableCollision();
|
||||
_updatePhysics();
|
||||
}
|
||||
|
||||
void PhysicsComponent::_updatePhysics()
|
||||
{
|
||||
SAFE_DELETE( mPhysicsRep );
|
||||
|
||||
if ( !PHYSICSMGR )
|
||||
return;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PhysicsComponent::buildConvex(const Box3F& box, Convex* convex)
|
||||
{
|
||||
convex = nullptr;
|
||||
}
|
||||
|
||||
//Updates
|
||||
void PhysicsComponent::interpolateTick(F32 dt)
|
||||
{
|
||||
Point3F pos = mDelta.pos + mDelta.posVec * dt;
|
||||
|
|
@ -155,10 +195,19 @@ void PhysicsComponent::interpolateTick(F32 dt)
|
|||
setRenderPosition(pos,dt);
|
||||
}
|
||||
|
||||
//
|
||||
void PhysicsComponent::updatePos(const F32 travelTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void PhysicsComponent::updateForces()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void PhysicsComponent::updateContainer()
|
||||
{
|
||||
PROFILE_SCOPE( PhysicsBehaviorInstance_updateContainer );
|
||||
PROFILE_SCOPE(PhysicsBehaviorInstance_updateContainer);
|
||||
|
||||
// Update container drag and buoyancy properties
|
||||
|
||||
|
|
@ -168,11 +217,11 @@ void PhysicsComponent::updateContainer()
|
|||
//mGravityMod = 1.0;
|
||||
//mAppliedForce.set(0,0,0);
|
||||
|
||||
ContainerQueryInfo info;
|
||||
info.box = mOwner->getWorldBox();
|
||||
info.mass = mMass;
|
||||
mLastContainerInfo = ContainerQueryInfo();
|
||||
mLastContainerInfo.box = mOwner->getWorldBox();
|
||||
mLastContainerInfo.mass = mMass;
|
||||
|
||||
mOwner->getContainer()->findObjects(info.box, WaterObjectType|PhysicalZoneObjectType,findRouter,&info);
|
||||
mOwner->getContainer()->findObjects(mLastContainerInfo.box, WaterObjectType | PhysicalZoneObjectType, findRouter, &mLastContainerInfo);
|
||||
|
||||
//mWaterCoverage = info.waterCoverage;
|
||||
//mLiquidType = info.liquidType;
|
||||
|
|
@ -182,71 +231,37 @@ void PhysicsComponent::updateContainer()
|
|||
// This value might be useful as a datablock value,
|
||||
// This is what allows the player to stand in shallow water (below this coverage)
|
||||
// without jiggling from buoyancy
|
||||
if (info.waterCoverage >= 0.25f)
|
||||
{
|
||||
if (mLastContainerInfo.waterCoverage >= 0.25f)
|
||||
{
|
||||
// water viscosity is used as drag for in water.
|
||||
// ShapeBaseData drag is used for drag outside of water.
|
||||
// Combine these two components to calculate this ShapeBase object's
|
||||
// current drag.
|
||||
mDrag = ( info.waterCoverage * info.waterViscosity ) +
|
||||
( 1.0f - info.waterCoverage ) * mDrag;
|
||||
mDrag = (mLastContainerInfo.waterCoverage * mLastContainerInfo.waterViscosity) +
|
||||
(1.0f - mLastContainerInfo.waterCoverage) * mDrag;
|
||||
//mBuoyancy = (info.waterDensity / mDataBlock->density) * info.waterCoverage;
|
||||
}
|
||||
|
||||
//mAppliedForce = info.appliedForce;
|
||||
mGravityMod = info.gravityScale;
|
||||
mGravityMod = mLastContainerInfo.gravityScale;
|
||||
}
|
||||
//
|
||||
void PhysicsComponent::_updatePhysics()
|
||||
|
||||
//Events
|
||||
void PhysicsComponent::updateVelocity(const F32 dt)
|
||||
{
|
||||
/*SAFE_DELETE( mOwner->mPhysicsRep );
|
||||
|
||||
if ( !PHYSICSMGR )
|
||||
return;
|
||||
|
||||
if (mDataBlock->simpleServerCollision)
|
||||
{
|
||||
// We only need the trigger on the server.
|
||||
if ( isServerObject() )
|
||||
{
|
||||
PhysicsCollision *colShape = PHYSICSMGR->createCollision();
|
||||
colShape->addBox( mObjBox.getExtents() * 0.5f, MatrixF::Identity );
|
||||
|
||||
PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
|
||||
mPhysicsRep = PHYSICSMGR->createBody();
|
||||
mPhysicsRep->init( colShape, 0, PhysicsBody::BF_TRIGGER | PhysicsBody::BF_KINEMATIC, this, world );
|
||||
mPhysicsRep->setTransform( getTransform() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !mShapeInstance )
|
||||
return;
|
||||
|
||||
PhysicsCollision* colShape = mShapeInstance->getShape()->buildColShape( false, getScale() );
|
||||
|
||||
if ( colShape )
|
||||
{
|
||||
PhysicsWorld *world = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
|
||||
mPhysicsRep = PHYSICSMGR->createBody();
|
||||
mPhysicsRep->init( colShape, 0, PhysicsBody::BF_KINEMATIC, this, world );
|
||||
mPhysicsRep->setTransform( getTransform() );
|
||||
}
|
||||
}*/
|
||||
return;
|
||||
}
|
||||
|
||||
PhysicsBody *PhysicsComponent::getPhysicsRep()
|
||||
void PhysicsComponent::applyImpulse(const Point3F&, const VectorF& vec)
|
||||
{
|
||||
/*if(mOwner)
|
||||
{
|
||||
Entity* ac = dynamic_cast<Entity*>(mOwner);
|
||||
if(ac)
|
||||
return ac->mPhysicsRep;
|
||||
}*/
|
||||
return NULL;
|
||||
// Items ignore angular velocity
|
||||
VectorF vel;
|
||||
vel.x = vec.x / mMass;
|
||||
vel.y = vec.y / mMass;
|
||||
vel.z = vec.z / mMass;
|
||||
setVelocity(mVelocity + vel);
|
||||
}
|
||||
//
|
||||
|
||||
//Setters
|
||||
void PhysicsComponent::setTransform(const MatrixF& mat)
|
||||
{
|
||||
mOwner->setTransform(mat);
|
||||
|
|
@ -257,8 +272,8 @@ void PhysicsComponent::setTransform(const MatrixF& mat)
|
|||
mAtRestCounter = 0;
|
||||
}
|
||||
|
||||
if ( getPhysicsRep() )
|
||||
getPhysicsRep()->setTransform( mOwner->getTransform() );
|
||||
if (getPhysicsRep())
|
||||
getPhysicsRep()->setTransform(mOwner->getTransform());
|
||||
|
||||
setMaskBits(UpdateMask);
|
||||
}
|
||||
|
|
@ -272,16 +287,15 @@ void PhysicsComponent::setPosition(const Point3F& pos)
|
|||
return;
|
||||
}
|
||||
else {
|
||||
mat.setColumn(3,pos);
|
||||
mat.setColumn(3, pos);
|
||||
}
|
||||
|
||||
mOwner->setTransform(mat);
|
||||
|
||||
if ( getPhysicsRep() )
|
||||
getPhysicsRep()->setTransform( mat );
|
||||
if (getPhysicsRep())
|
||||
getPhysicsRep()->setTransform(mat);
|
||||
}
|
||||
|
||||
|
||||
void PhysicsComponent::setRenderPosition(const Point3F& pos, F32 dt)
|
||||
{
|
||||
MatrixF mat = mOwner->getRenderTransform();
|
||||
|
|
@ -291,16 +305,12 @@ void PhysicsComponent::setRenderPosition(const Point3F& pos, F32 dt)
|
|||
return;
|
||||
}
|
||||
else {
|
||||
mat.setColumn(3,pos);
|
||||
mat.setColumn(3, pos);
|
||||
}
|
||||
|
||||
mOwner->setRenderTransform(mat);
|
||||
}
|
||||
|
||||
void PhysicsComponent::updateVelocity(const F32 dt)
|
||||
{
|
||||
}
|
||||
|
||||
void PhysicsComponent::setVelocity(const VectorF& vel)
|
||||
{
|
||||
mVelocity = vel;
|
||||
|
|
@ -310,6 +320,18 @@ void PhysicsComponent::setVelocity(const VectorF& vel)
|
|||
setMaskBits(VelocityMask);
|
||||
}
|
||||
|
||||
//Getters
|
||||
PhysicsBody *PhysicsComponent::getPhysicsRep()
|
||||
{
|
||||
/*if(mOwner)
|
||||
{
|
||||
Entity* ac = dynamic_cast<Entity*>(mOwner);
|
||||
if(ac)
|
||||
return ac->mPhysicsRep;
|
||||
}*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void PhysicsComponent::getVelocity(const Point3F& r, Point3F* v)
|
||||
{
|
||||
*v = mVelocity;
|
||||
|
|
@ -339,20 +361,6 @@ F32 PhysicsComponent::getZeroImpulse(const Point3F& r,const Point3F& normal)
|
|||
return 1 / ((1/mMass) + mDot(c, normal));
|
||||
}
|
||||
|
||||
void PhysicsComponent::accumulateForce(F32 dt, Point3F force)
|
||||
{
|
||||
mVelocity += force * dt;
|
||||
}
|
||||
|
||||
void PhysicsComponent::applyImpulse(const Point3F&,const VectorF& vec)
|
||||
{
|
||||
// Items ignore angular velocity
|
||||
VectorF vel;
|
||||
vel.x = vec.x / mMass;
|
||||
vel.y = vec.y / mMass;
|
||||
vel.z = vec.z / mMass;
|
||||
setVelocity(mVelocity + vel);
|
||||
}
|
||||
|
||||
DefineEngineMethod( PhysicsComponent, applyImpulse, bool, ( Point3F pos, VectorF vel ),,
|
||||
"@brief Apply an impulse to this object as defined by a world position and velocity vector.\n\n"
|
||||
|
|
@ -2,9 +2,10 @@
|
|||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
#pragma once
|
||||
#ifndef PHYSICS_COMPONENT_H
|
||||
#define PHYSICS_COMPONENT_H
|
||||
|
||||
#ifndef _PHYSICSBEHAVIOR_H_
|
||||
#define _PHYSICSBEHAVIOR_H_
|
||||
#include "T3D/components/component.h"
|
||||
|
||||
#ifndef __RESOURCE_H__
|
||||
|
|
@ -59,13 +60,17 @@ protected:
|
|||
VectorF mGravity;
|
||||
VectorF mVelocity;
|
||||
F32 mDrag;
|
||||
F32 mMass;
|
||||
F32 mMass;
|
||||
|
||||
F32 mGravityMod;
|
||||
|
||||
S32 csmAtRestTimer;
|
||||
F32 sAtRestVelocity; // Min speed after collisio
|
||||
|
||||
PhysicsBody* mPhysicsRep;
|
||||
PhysicsWorld* mPhysicsWorld;
|
||||
|
||||
Convex* mConvexList;
|
||||
public:
|
||||
enum MaskBits {
|
||||
PositionMask = Parent::NextFreeMask << 0,
|
||||
|
|
@ -79,7 +84,7 @@ public:
|
|||
{
|
||||
Move move; ///< Last move from server
|
||||
F32 dt; ///< Last interpolation time
|
||||
// Interpolation data
|
||||
// Interpolation data
|
||||
Point3F pos;
|
||||
Point3F posVec;
|
||||
QuatF rot[2];
|
||||
|
|
@ -91,8 +96,11 @@ public:
|
|||
};
|
||||
|
||||
StateDelta mDelta;
|
||||
|
||||
S32 mPredictionCount; ///< Number of ticks to predict
|
||||
|
||||
ContainerQueryInfo mLastContainerInfo;
|
||||
|
||||
public:
|
||||
PhysicsComponent();
|
||||
virtual ~PhysicsComponent();
|
||||
|
|
@ -100,36 +108,49 @@ public:
|
|||
|
||||
static void initPersistFields();
|
||||
|
||||
virtual void interpolateTick(F32 dt);
|
||||
virtual void updatePos(const U32 /*mask*/, const F32 dt){}
|
||||
virtual void _updatePhysics();
|
||||
virtual PhysicsBody *getPhysicsRep();
|
||||
//Components
|
||||
virtual void onComponentAdd();
|
||||
virtual void onComponentRemove();
|
||||
|
||||
//Setup
|
||||
void prepCollision();
|
||||
virtual void _updatePhysics();
|
||||
virtual void buildConvex(const Box3F& box, Convex* convex);
|
||||
|
||||
//Update
|
||||
virtual void interpolateTick(F32 dt);
|
||||
virtual void updatePos(const F32 dt);
|
||||
|
||||
virtual void updateForces();
|
||||
void updateContainer();
|
||||
|
||||
//Physics Collision Conveinence Hooks
|
||||
virtual bool updateCollision(F32 dt, Rigid& ns, CollisionList &cList) { return false; }
|
||||
virtual bool resolveContacts(Rigid& ns, CollisionList& cList, F32 dt) { return false; }
|
||||
virtual bool resolveCollision(const Point3F& p, const Point3F &normal) { return false; }
|
||||
|
||||
//Networking
|
||||
virtual U32 packUpdate(NetConnection *con, U32 mask, BitStream *stream);
|
||||
virtual void unpackUpdate(NetConnection *con, BitStream *stream);
|
||||
|
||||
virtual void onComponentAdd();
|
||||
|
||||
void updateContainer();
|
||||
|
||||
//Events
|
||||
virtual void updateVelocity(const F32 dt);
|
||||
virtual Point3F getVelocity() { return mVelocity; }
|
||||
virtual void getOriginVector(const Point3F &p, Point3F* r);
|
||||
virtual void getVelocity(const Point3F& r, Point3F* v);
|
||||
|
||||
virtual void setVelocity(const VectorF& vel);
|
||||
virtual void setTransform(const MatrixF& mat);
|
||||
virtual void setPosition(const Point3F& pos);
|
||||
void setRenderPosition(const Point3F& pos, F32 dt);
|
||||
|
||||
virtual void applyImpulse(const Point3F&, const VectorF& vec);
|
||||
virtual F32 getZeroImpulse(const Point3F& r, const Point3F& normal);
|
||||
virtual void accumulateForce(F32 dt, Point3F force);
|
||||
|
||||
//Rigid Body Collision Conveinence Hooks
|
||||
virtual bool updateCollision(F32 dt, Rigid& ns, CollisionList &cList) { return false; }
|
||||
virtual bool resolveContacts(Rigid& ns, CollisionList& cList, F32 dt) { return false; }
|
||||
//virtual bool resolveCollision(Rigid& ns, CollisionList& cList) { return false; }
|
||||
virtual bool resolveCollision(const Point3F& p, const Point3F &normal) { return false; }
|
||||
//Gets
|
||||
F32 getMass() { return mMass; }
|
||||
virtual PhysicsBody *getPhysicsRep();
|
||||
virtual Point3F getVelocity() { return mVelocity; }
|
||||
virtual void getOriginVector(const Point3F &p, Point3F* r);
|
||||
virtual void getVelocity(const Point3F& r, Point3F* v);
|
||||
virtual F32 getZeroImpulse(const Point3F& r, const Point3F& normal);
|
||||
|
||||
};
|
||||
|
||||
#endif // _COMPONENT_H_
|
||||
|
|
@ -37,7 +37,6 @@
|
|||
#include "collision/collision.h"
|
||||
#include "T3D/physics/physicsPlayer.h"
|
||||
#include "T3D/physics/physicsPlugin.h"
|
||||
#include "T3D/components/collision/collisionInterfaces.h"
|
||||
#include "T3D/trigger.h"
|
||||
#include "T3D/components/collision/collisionTrigger.h"
|
||||
|
||||
|
|
@ -58,13 +57,8 @@ IMPLEMENT_CALLBACK(PlayerControllerComponent, updateMove, void, (PlayerControlle
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
// Constructor/Destructor
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
PlayerControllerComponent::PlayerControllerComponent() : Component()
|
||||
PlayerControllerComponent::PlayerControllerComponent() : PhysicsComponent()
|
||||
{
|
||||
addComponentField("isStatic", "If enabled, object will not simulate physics", "bool", "0", "");
|
||||
addComponentField("gravity", "The direction of gravity affecting this object, as a vector", "vector", "0 0 -9", "");
|
||||
addComponentField("drag", "The drag coefficient that constantly affects the object", "float", "0.7", "");
|
||||
addComponentField("mass", "The mass of the object", "float", "1", "");
|
||||
|
||||
mBuoyancy = 0.f;
|
||||
mFriction = 0.3f;
|
||||
mElasticity = 0.4f;
|
||||
|
|
@ -122,7 +116,7 @@ PlayerControllerComponent::PlayerControllerComponent() : Component()
|
|||
mPhysicsRep = nullptr;
|
||||
mPhysicsWorld = nullptr;
|
||||
|
||||
mOwnerCollisionInterface = nullptr;
|
||||
mOwnerCollisionComp = nullptr;
|
||||
mIntegrationCount = 0;
|
||||
}
|
||||
|
||||
|
|
@ -160,6 +154,13 @@ void PlayerControllerComponent::onComponentAdd()
|
|||
{
|
||||
Parent::onComponentAdd();
|
||||
|
||||
CollisionComponent *collisionComp = mOwner->getComponent<CollisionComponent>();
|
||||
if (collisionComp)
|
||||
{
|
||||
collisionComp->onCollisionChanged.notify(this, &PlayerControllerComponent::updatePhysics);
|
||||
mOwnerCollisionComp = collisionComp;
|
||||
}
|
||||
|
||||
updatePhysics();
|
||||
}
|
||||
|
||||
|
|
@ -168,12 +169,11 @@ void PlayerControllerComponent::componentAddedToOwner(Component *comp)
|
|||
if (comp->getId() == getId())
|
||||
return;
|
||||
|
||||
//test if this is a shape component!
|
||||
CollisionInterface *collisionInterface = dynamic_cast<CollisionInterface*>(comp);
|
||||
if (collisionInterface)
|
||||
CollisionComponent *collisionComp = dynamic_cast<CollisionComponent*>(comp);
|
||||
if (collisionComp)
|
||||
{
|
||||
collisionInterface->onCollisionChanged.notify(this, &PlayerControllerComponent::updatePhysics);
|
||||
mOwnerCollisionInterface = collisionInterface;
|
||||
collisionComp->onCollisionChanged.notify(this, &PlayerControllerComponent::updatePhysics);
|
||||
mOwnerCollisionComp = collisionComp;
|
||||
updatePhysics();
|
||||
}
|
||||
}
|
||||
|
|
@ -183,12 +183,11 @@ void PlayerControllerComponent::componentRemovedFromOwner(Component *comp)
|
|||
if (comp->getId() == getId()) //?????????
|
||||
return;
|
||||
|
||||
//test if this is a shape component!
|
||||
CollisionInterface *collisionInterface = dynamic_cast<CollisionInterface*>(comp);
|
||||
if (collisionInterface)
|
||||
CollisionComponent *collisionComp = dynamic_cast<CollisionComponent*>(comp);
|
||||
if (collisionComp)
|
||||
{
|
||||
collisionInterface->onCollisionChanged.remove(this, &PlayerControllerComponent::updatePhysics);
|
||||
mOwnerCollisionInterface = NULL;
|
||||
collisionComp->onCollisionChanged.notify(this, &PlayerControllerComponent::updatePhysics);
|
||||
mOwnerCollisionComp = nullptr;
|
||||
updatePhysics();
|
||||
}
|
||||
}
|
||||
|
|
@ -219,7 +218,7 @@ void PlayerControllerComponent::initPersistFields()
|
|||
Parent::initPersistFields();
|
||||
|
||||
addField("inputVelocity", TypePoint3F, Offset(mInputVelocity, PlayerControllerComponent), "");
|
||||
addField("useDirectMoveInput", TypePoint3F, Offset(mUseDirectMoveInput, PlayerControllerComponent), "");
|
||||
addField("useDirectMoveInput", TypeBool, Offset(mUseDirectMoveInput, PlayerControllerComponent), "");
|
||||
}
|
||||
|
||||
U32 PlayerControllerComponent::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
||||
|
|
@ -579,10 +578,10 @@ void PlayerControllerComponent::updatePos(const F32 travelTime)
|
|||
haveCollisions = true;
|
||||
|
||||
//TODO: clean this up so the phys component doesn't have to tell the col interface to do this
|
||||
CollisionInterface* colInterface = mOwner->getComponent<CollisionInterface>();
|
||||
if (colInterface)
|
||||
CollisionComponent* colComp = mOwner->getComponent<CollisionComponent>();
|
||||
if (colComp)
|
||||
{
|
||||
colInterface->handleCollisionList(collisionList, mVelocity);
|
||||
colComp->handleCollisionList(collisionList, mVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -629,6 +628,8 @@ void PlayerControllerComponent::updatePos(const F32 travelTime)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateContainer();
|
||||
|
||||
MatrixF newMat;
|
||||
newMat.setPosition(newPos);
|
||||
|
|
@ -701,6 +702,9 @@ void PlayerControllerComponent::findContact(bool *run, bool *jump, VectorF *cont
|
|||
|
||||
if (mContactInfo.contacted)
|
||||
mContactInfo.contactNormal = *contactNormal;
|
||||
|
||||
mContactInfo.run = *run;
|
||||
mContactInfo.jump = *jump;
|
||||
}
|
||||
|
||||
void PlayerControllerComponent::applyImpulse(const Point3F &pos, const VectorF &vec)
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
#ifndef PLAYER_CONTORLLER_COMPONENT_H
|
||||
#define PLAYER_CONTORLLER_COMPONENT_H
|
||||
|
||||
#ifndef PHYSICSBEHAVIOR_H
|
||||
#include "T3D/components/physics/physicsBehavior.h"
|
||||
#ifndef PHYSICS_COMPONENT_H
|
||||
#include "T3D/components/physics/physicsComponent.h"
|
||||
#endif
|
||||
#ifndef __RESOURCE_H__
|
||||
#include "core/resource.h"
|
||||
|
|
@ -53,25 +53,20 @@
|
|||
#ifndef _T3D_PHYSICS_PHYSICSWORLD_H_
|
||||
#include "T3D/physics/physicsWorld.h"
|
||||
#endif
|
||||
#ifndef PHYSICS_COMPONENT_INTERFACE_H
|
||||
#include "T3D/components/physics/physicsComponentInterface.h"
|
||||
#endif
|
||||
#ifndef COLLISION_INTERFACES_H
|
||||
#include "T3D/components/collision/collisionInterfaces.h"
|
||||
#ifndef COLLISION_COMPONENT_H
|
||||
#include "T3D/components/collision/collisionComponent.h"
|
||||
#endif
|
||||
|
||||
class SceneRenderState;
|
||||
class PhysicsWorld;
|
||||
class PhysicsPlayer;
|
||||
class SimplePhysicsBehaviorInstance;
|
||||
class CollisionInterface;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class PlayerControllerComponent : public Component,
|
||||
public PhysicsComponentInterface
|
||||
class PlayerControllerComponent : public PhysicsComponent
|
||||
{
|
||||
typedef Component Parent;
|
||||
|
||||
|
|
@ -101,7 +96,7 @@ class PlayerControllerComponent : public Component,
|
|||
PhysicsPlayer *mPhysicsRep;
|
||||
PhysicsWorld *mPhysicsWorld;
|
||||
|
||||
CollisionInterface* mOwnerCollisionInterface;
|
||||
CollisionComponent* mOwnerCollisionComp;
|
||||
|
||||
struct ContactInfo
|
||||
{
|
||||
|
|
@ -113,8 +108,9 @@ class PlayerControllerComponent : public Component,
|
|||
void clear()
|
||||
{
|
||||
contacted = jump = run = false;
|
||||
contactObject = NULL;
|
||||
contactNormal.set(1, 1, 1);
|
||||
contactObject = nullptr;
|
||||
contactNormal.set(0,0,0);
|
||||
contactTime = 0;
|
||||
}
|
||||
|
||||
ContactInfo() { clear(); }
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ bool RigidBodyComponent::smNoSmoothing = false;
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
// Constructor/Destructor
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
RigidBodyComponent::RigidBodyComponent() : Component()
|
||||
RigidBodyComponent::RigidBodyComponent() : PhysicsComponent()
|
||||
{
|
||||
mMass = 20;
|
||||
mDynamicFriction = 1;
|
||||
|
|
@ -353,11 +353,11 @@ void RigidBodyComponent::findContact()
|
|||
|
||||
mPhysicsRep->findContact(&contactObject, contactNormal, &overlapObjects);
|
||||
|
||||
if (!overlapObjects.empty())
|
||||
/*if (!overlapObjects.empty())
|
||||
{
|
||||
//fire our signal that the physics sim said collisions happened
|
||||
onPhysicsCollision.trigger(*contactNormal, overlapObjects);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void RigidBodyComponent::_onPhysicsReset(PhysicsResetEvent reset)
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@
|
|||
#ifndef COLLISION_COMPONENT_H
|
||||
#include "T3D/components/collision/collisionComponent.h"
|
||||
#endif
|
||||
#ifndef PHYSICS_COMPONENT_INTERFACE_H
|
||||
#include "T3D/components/physics/physicsComponentInterface.h"
|
||||
#ifndef PHYSICS_COMPONENT_H
|
||||
#include "T3D/components/physics/physicsComponent.h"
|
||||
#endif
|
||||
|
||||
class PhysicsBody;
|
||||
|
|
@ -42,9 +42,9 @@ class PhysicsBody;
|
|||
///
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class RigidBodyComponent : public Component, public PhysicsComponentInterface
|
||||
class RigidBodyComponent : public PhysicsComponent
|
||||
{
|
||||
typedef Component Parent;
|
||||
typedef PhysicsComponent Parent;
|
||||
|
||||
enum SimType
|
||||
{
|
||||
|
|
|
|||
391
Engine/source/T3D/components/physics/simplePhysicsComponent.cpp
Normal file
391
Engine/source/T3D/components/physics/simplePhysicsComponent.cpp
Normal file
|
|
@ -0,0 +1,391 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "T3D/components/physics/simplePhysicsComponent.h"
|
||||
#include "T3D/components/collision/collisionComponent.h"
|
||||
#include "platform/platform.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "core/util/safeDelete.h"
|
||||
#include "core/resourceManager.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/consoleObject.h"
|
||||
#include "ts/tsShapeInstance.h"
|
||||
#include "core/stream/bitStream.h"
|
||||
#include "gfx/gfxTransformSaver.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "lighting/lightQuery.h"
|
||||
#include "T3D/gameBase/gameConnection.h"
|
||||
#include "collision/collision.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Callbacks
|
||||
IMPLEMENT_CALLBACK( SimplePhysicsComponent, updateMove, void, ( SimplePhysicsComponent* obj ), ( obj ),
|
||||
"Called when the player updates it's movement, only called if object is set to callback in script(doUpdateMove).\n"
|
||||
"@param obj the Player object\n" );
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Constructor/Destructor
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SimplePhysicsComponent::SimplePhysicsComponent() : PhysicsComponent()
|
||||
{
|
||||
mBuoyancy = 0.f;
|
||||
mFriction = 0.3f;
|
||||
mElasticity = 0.4f;
|
||||
mMaxVelocity = 3000.f;
|
||||
mSticky = false;
|
||||
|
||||
mDrag = 0.5;
|
||||
|
||||
mVelocity = Point3F::Zero;
|
||||
|
||||
moveSpeed = Point3F(1, 1, 1);
|
||||
|
||||
mFriendlyName = "Simple Physics";
|
||||
mComponentType = "Physics";
|
||||
|
||||
mDescription = getDescriptionText("Simple physics Component that allows gravity and impulses.");
|
||||
}
|
||||
|
||||
SimplePhysicsComponent::~SimplePhysicsComponent()
|
||||
{
|
||||
for(S32 i = 0;i < mFields.size();++i)
|
||||
{
|
||||
ComponentField &field = mFields[i];
|
||||
SAFE_DELETE_ARRAY(field.mFieldDescription);
|
||||
}
|
||||
|
||||
SAFE_DELETE_ARRAY(mDescription);
|
||||
}
|
||||
|
||||
IMPLEMENT_CONOBJECT(SimplePhysicsComponent);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SimplePhysicsComponent::onAdd()
|
||||
{
|
||||
if(! Parent::onAdd())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SimplePhysicsComponent::onRemove()
|
||||
{
|
||||
Parent::onRemove();
|
||||
}
|
||||
|
||||
void SimplePhysicsComponent::initPersistFields()
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField( "moveSpeed", TypePoint3F, Offset(moveSpeed, SimplePhysicsComponent), "");
|
||||
}
|
||||
|
||||
U32 SimplePhysicsComponent::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
||||
{
|
||||
U32 retMask = Parent::packUpdate(con, mask, stream);
|
||||
return retMask;
|
||||
}
|
||||
|
||||
void SimplePhysicsComponent::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||
{
|
||||
Parent::unpackUpdate(con, stream);
|
||||
}
|
||||
|
||||
//
|
||||
void SimplePhysicsComponent::processTick()
|
||||
{
|
||||
Parent::processTick();
|
||||
|
||||
if (!isServerObject() || !isActive())
|
||||
return;
|
||||
|
||||
//
|
||||
//if (mCollisionObject && !--mCollisionTimeout)
|
||||
// mCollisionObject = 0;
|
||||
|
||||
// Warp to catch up to server
|
||||
if (mDelta.warpCount < mDelta.warpTicks)
|
||||
{
|
||||
mDelta.warpCount++;
|
||||
|
||||
// Set new pos.
|
||||
mOwner->getTransform().getColumn(3,&mDelta.pos);
|
||||
mDelta.pos += mDelta.warpOffset;
|
||||
//mDelta.rot[0] = mDelta.rot[1];
|
||||
//mDelta.rot[1].interpolate(mDelta.warpRot[0],mDelta.warpRot[1],F32(mDelta.warpCount)/mDelta.warpTicks);
|
||||
MatrixF trans;
|
||||
mDelta.rot[1].setMatrix(&trans);
|
||||
trans.setPosition(mDelta.pos);
|
||||
setTransform(trans);
|
||||
|
||||
// Pos backstepping
|
||||
mDelta.posVec.x = -mDelta.warpOffset.x;
|
||||
mDelta.posVec.y = -mDelta.warpOffset.y;
|
||||
mDelta.posVec.z = -mDelta.warpOffset.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save current rigid state interpolation
|
||||
mDelta.posVec = mOwner->getPosition();
|
||||
//mDelta.rot[0] = mOwner->getTransform();
|
||||
|
||||
updateForces();
|
||||
updatePos(TickSec);
|
||||
|
||||
// Wrap up interpolation info
|
||||
mDelta.pos = mOwner->getPosition();
|
||||
mDelta.posVec -= mOwner->getPosition();
|
||||
//mDelta.rot[1] = mRigid.angPosition;
|
||||
|
||||
// Update container database
|
||||
setTransform(mOwner->getTransform());
|
||||
setMaskBits(UpdateMask);
|
||||
updateContainer();
|
||||
}
|
||||
}
|
||||
|
||||
void SimplePhysicsComponent::interpolateTick(F32 dt)
|
||||
{
|
||||
// Client side interpolation
|
||||
Point3F pos = mDelta.pos + mDelta.posVec * dt;
|
||||
MatrixF mat = mOwner->getRenderTransform();
|
||||
mat.setColumn(3,pos);
|
||||
mOwner->setRenderTransform(mat);
|
||||
mDelta.dt = dt;
|
||||
}
|
||||
|
||||
void SimplePhysicsComponent::updatePos(const F32 travelTime)
|
||||
{
|
||||
mOwner->getTransform().getColumn(3,&mDelta.posVec);
|
||||
|
||||
// When mounted to another object, only Z rotation used.
|
||||
if (mOwner->isMounted()) {
|
||||
mVelocity = mOwner->getObjectMount()->getVelocity();
|
||||
setPosition(Point3F(0.0f, 0.0f, 0.0f));
|
||||
setMaskBits(UpdateMask);
|
||||
return;
|
||||
}
|
||||
|
||||
Point3F newPos;
|
||||
|
||||
if ( mVelocity.isZero() )
|
||||
newPos = mDelta.posVec;
|
||||
else
|
||||
newPos = _move( travelTime );
|
||||
//}
|
||||
|
||||
// Set new position
|
||||
// If on the client, calc delta for backstepping
|
||||
if (isClientObject())
|
||||
{
|
||||
mDelta.pos = newPos;
|
||||
mDelta.posVec = mDelta.posVec - mDelta.pos;
|
||||
mDelta.dt = 1.0f;
|
||||
}
|
||||
|
||||
setPosition( newPos );
|
||||
setMaskBits( UpdateMask );
|
||||
updateContainer();
|
||||
|
||||
/*if (!isGhost())
|
||||
{
|
||||
// Do mission area callbacks on the server as well
|
||||
checkMissionArea();
|
||||
}*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Point3F SimplePhysicsComponent::_move( const F32 travelTime )
|
||||
{
|
||||
// Try and move to new pos
|
||||
F32 totalMotion = 0.0f;
|
||||
|
||||
Point3F start;
|
||||
Point3F initialPosition;
|
||||
mOwner->getTransform().getColumn(3,&start);
|
||||
initialPosition = start;
|
||||
|
||||
VectorF firstNormal(0.0f, 0.0f, 0.0f);
|
||||
//F32 maxStep = mDataBlock->maxStepHeight;
|
||||
F32 time = travelTime;
|
||||
U32 count = 0;
|
||||
S32 sMoveRetryCount = 5;
|
||||
|
||||
CollisionComponent* colComp = mOwner->getComponent<CollisionComponent>();
|
||||
|
||||
if(!colComp)
|
||||
return start + mVelocity * time;
|
||||
|
||||
colComp->clearCollisionList();
|
||||
|
||||
for (; count < sMoveRetryCount; count++)
|
||||
{
|
||||
F32 speed = mVelocity.len();
|
||||
if (!speed)
|
||||
break;
|
||||
|
||||
Point3F end = start + mVelocity * time;
|
||||
Point3F distance = end - start;
|
||||
|
||||
bool collided = colComp->checkCollisions(time, &mVelocity, start);
|
||||
|
||||
if (colComp->getCollisionList()->getCount() != 0 && colComp->getCollisionList()->getTime() < 1.0f)
|
||||
{
|
||||
// Set to collision point
|
||||
F32 velLen = mVelocity.len();
|
||||
|
||||
F32 dt = time * getMin(colComp->getCollisionList()->getTime(), 1.0f);
|
||||
start += mVelocity * dt;
|
||||
time -= dt;
|
||||
|
||||
totalMotion += velLen * dt;
|
||||
|
||||
// Back off...
|
||||
if ( velLen > 0.f )
|
||||
{
|
||||
F32 newT = getMin(0.01f / velLen, dt);
|
||||
start -= mVelocity * newT;
|
||||
totalMotion -= velLen * newT;
|
||||
}
|
||||
|
||||
// Pick the surface most parallel to the face that was hit.
|
||||
U32 colCount = colComp->getCollisionList()->getCount();
|
||||
|
||||
const Collision *collision = colComp->getCollision(0);
|
||||
const Collision *cp = collision + 1;
|
||||
const Collision *ep = collision + colComp->getCollisionList()->getCount();
|
||||
for (; cp != ep; cp++)
|
||||
{
|
||||
U32 colCountLoop = colComp->getCollisionList()->getCount();
|
||||
|
||||
//TODO: Move this somewhere else
|
||||
if(Entity* colEnt = dynamic_cast<Entity*>(collision->object))
|
||||
{
|
||||
if(CollisionComponent *collidingEntityColComp = colEnt->getComponent<CollisionComponent>())
|
||||
{
|
||||
if(!collidingEntityColComp->doesBlockColliding())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cp->faceDot > collision->faceDot)
|
||||
collision = cp;
|
||||
}
|
||||
|
||||
//check the last/first one just incase
|
||||
if(Entity* colEnt = dynamic_cast<Entity*>(collision->object))
|
||||
{
|
||||
if(CollisionComponent *collidingEntityColComp = colEnt->getComponent<CollisionComponent>())
|
||||
{
|
||||
if(!collidingEntityColComp->doesBlockColliding())
|
||||
{
|
||||
//if our ideal surface doesn't stop us, just move along
|
||||
return start + mVelocity * time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//F32 bd = _doCollisionImpact( collision, wasFalling );
|
||||
F32 bd = -mDot( mVelocity, collision->normal);
|
||||
|
||||
// Subtract out velocity
|
||||
F32 sNormalElasticity = 0.01f;
|
||||
VectorF dv = collision->normal * (bd + sNormalElasticity);
|
||||
mVelocity += dv;
|
||||
if (count == 0)
|
||||
{
|
||||
firstNormal = collision->normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count == 1)
|
||||
{
|
||||
// Re-orient velocity along the crease.
|
||||
if (mDot(dv,firstNormal) < 0.0f &&
|
||||
mDot(collision->normal,firstNormal) < 0.0f)
|
||||
{
|
||||
VectorF nv;
|
||||
mCross(collision->normal,firstNormal,&nv);
|
||||
F32 nvl = nv.len();
|
||||
if (nvl)
|
||||
{
|
||||
if (mDot(nv,mVelocity) < 0.0f)
|
||||
nvl = -nvl;
|
||||
nv *= mVelocity.len() / nvl;
|
||||
mVelocity = nv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
totalMotion += (end - start).len();
|
||||
start = end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
U32 colCountThree = colComp->getCollisionList()->getCount();
|
||||
|
||||
if (colCountThree != 0)
|
||||
bool derp = true;
|
||||
|
||||
if (count == sMoveRetryCount)
|
||||
{
|
||||
// Failed to move
|
||||
start = initialPosition;
|
||||
mVelocity.set(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
void SimplePhysicsComponent::updateForces()
|
||||
{
|
||||
// Acceleration due to gravity
|
||||
mVelocity += (mGravity * mGravityMod) * TickMs;
|
||||
F32 len = mVelocity.len();
|
||||
|
||||
if (mMaxVelocity > 0 && mAbs(len) > mMaxVelocity)
|
||||
{
|
||||
Point3F excess = mVelocity * (1.0 - (mMaxVelocity / len));
|
||||
excess *= 0.1f;
|
||||
mVelocity -= excess;
|
||||
}
|
||||
|
||||
// Container buoyancy & drag
|
||||
if(mOwner->getContainerInfo().waterCoverage > 0.65f)
|
||||
mVelocity -= mBuoyancy * (mGravity * mGravityMod) * TickMs;
|
||||
|
||||
mVelocity -= mVelocity * mDrag * TickMs;
|
||||
|
||||
if( mVelocity.isZero() )
|
||||
mVelocity = Point3F::Zero;
|
||||
else
|
||||
setMaskBits(VelocityMask);
|
||||
}
|
||||
|
||||
//
|
||||
void SimplePhysicsComponent::setVelocity(const VectorF& vel)
|
||||
{
|
||||
Parent::setVelocity(vel);
|
||||
|
||||
// Clamp against the maximum velocity.
|
||||
if ( mMaxVelocity > 0 )
|
||||
{
|
||||
F32 len = mVelocity.magnitudeSafe();
|
||||
if ( len > mMaxVelocity )
|
||||
{
|
||||
Point3F excess = mVelocity * ( 1.0f - (mMaxVelocity / len ) );
|
||||
mVelocity -= excess;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef SIMPLE_PHYSICS_COMPONENT_H
|
||||
#define SIMPLE_PHYSICS_COMPONENT_H
|
||||
|
||||
#ifndef PHYSICS_COMPONENT_H
|
||||
#include "T3D/components/physics/physicsComponent.h"
|
||||
#endif
|
||||
|
||||
#ifndef __RESOURCE_H__
|
||||
#include "core/resource.h"
|
||||
#endif
|
||||
#ifndef _TSSHAPE_H_
|
||||
#include "ts/tsShape.h"
|
||||
#endif
|
||||
#ifndef _SCENERENDERSTATE_H_
|
||||
#include "scene/sceneRenderState.h"
|
||||
#endif
|
||||
#ifndef _MBOX_H_
|
||||
#include "math/mBox.h"
|
||||
#endif
|
||||
#ifndef _ENTITY_H_
|
||||
#include "T3D/Entity.h"
|
||||
#endif
|
||||
#ifndef _CONVEX_H_
|
||||
#include "collision/convex.h"
|
||||
#endif
|
||||
#ifndef _BOXCONVEX_H_
|
||||
#include "collision/boxConvex.h"
|
||||
#endif
|
||||
|
||||
class SceneRenderState;
|
||||
class PhysicsBody;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
///
|
||||
///
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class SimplePhysicsComponent : public PhysicsComponent
|
||||
{
|
||||
typedef PhysicsComponent Parent;
|
||||
|
||||
protected:
|
||||
F32 mBuoyancy;
|
||||
F32 mFriction;
|
||||
F32 mElasticity;
|
||||
F32 mMaxVelocity;
|
||||
bool mSticky;
|
||||
|
||||
U32 mIntegrationCount;
|
||||
|
||||
Point3F moveSpeed;
|
||||
|
||||
Point3F mStickyCollisionPos;
|
||||
Point3F mStickyCollisionNormal;
|
||||
|
||||
public:
|
||||
SimplePhysicsComponent();
|
||||
virtual ~SimplePhysicsComponent();
|
||||
DECLARE_CONOBJECT(SimplePhysicsComponent);
|
||||
|
||||
virtual bool onAdd();
|
||||
virtual void onRemove();
|
||||
static void initPersistFields();
|
||||
|
||||
virtual U32 packUpdate(NetConnection *con, U32 mask, BitStream *stream);
|
||||
virtual void unpackUpdate(NetConnection *con, BitStream *stream);
|
||||
|
||||
virtual void processTick();
|
||||
virtual void interpolateTick(F32 dt);
|
||||
virtual void updatePos(const F32 dt);
|
||||
void updateForces();
|
||||
|
||||
void updateMove(const Move* move);
|
||||
Point3F _move(const F32 travelTime);
|
||||
|
||||
//virtual void onComponentRemove();
|
||||
|
||||
virtual VectorF getVelocity() { return mVelocity; }
|
||||
virtual void setVelocity(const VectorF& vel);
|
||||
|
||||
//
|
||||
DECLARE_CALLBACK(void, updateMove, (SimplePhysicsComponent* obj));
|
||||
};
|
||||
|
||||
#endif // _COMPONENT_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue