forked from teamnwah/openmw-tes3coop
Changed: use MWWorld::Ptr for PhysicsSystem arguments
This commit is contained in:
parent
accf8b2f71
commit
7a7825577a
21 changed files with 93 additions and 121 deletions
|
@ -30,9 +30,8 @@ namespace MWClass
|
||||||
void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Activator::getModel(const MWWorld::Ptr &ptr) const
|
std::string Activator::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -33,9 +33,8 @@ namespace MWClass
|
||||||
void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Apparatus::getModel(const MWWorld::Ptr &ptr) const
|
std::string Apparatus::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -36,9 +36,8 @@ namespace MWClass
|
||||||
void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Armor::getModel(const MWWorld::Ptr &ptr) const
|
std::string Armor::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -32,9 +32,8 @@ namespace MWClass
|
||||||
void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Book::getModel(const MWWorld::Ptr &ptr) const
|
std::string Book::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -34,9 +34,8 @@ namespace MWClass
|
||||||
void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Clothing::getModel(const MWWorld::Ptr &ptr) const
|
std::string Clothing::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -65,9 +65,8 @@ namespace MWClass
|
||||||
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Container::getModel(const MWWorld::Ptr &ptr) const
|
std::string Container::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -94,9 +94,8 @@ namespace MWClass
|
||||||
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()){
|
if(!model.empty())
|
||||||
physics.insertActorPhysics(ptr, model);
|
physics.addActor(ptr);
|
||||||
}
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
|
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,8 @@ namespace MWClass
|
||||||
void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Door::getModel(const MWWorld::Ptr &ptr) const
|
std::string Door::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -41,9 +41,8 @@ namespace MWClass
|
||||||
void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Ingredient::getModel(const MWWorld::Ptr &ptr) const
|
std::string Ingredient::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -53,12 +53,11 @@ namespace MWClass
|
||||||
|
|
||||||
const std::string &model = ref->base->mModel;
|
const std::string &model = ref->base->mModel;
|
||||||
|
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
if (!ref->base->mSound.empty()) {
|
if (!ref->base->mSound.empty())
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop);
|
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Light::getModel(const MWWorld::Ptr &ptr) const
|
std::string Light::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -34,9 +34,8 @@ namespace MWClass
|
||||||
void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Lockpick::getModel(const MWWorld::Ptr &ptr) const
|
std::string Lockpick::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -37,9 +37,8 @@ namespace MWClass
|
||||||
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Miscellaneous::getModel(const MWWorld::Ptr &ptr) const
|
std::string Miscellaneous::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace MWClass
|
||||||
|
|
||||||
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
physics.insertActorPhysics(ptr, getModel(ptr));
|
physics.addActor(ptr);
|
||||||
MWBase::Environment::get().getMechanicsManager()->addActor(ptr);
|
MWBase::Environment::get().getMechanicsManager()->addActor(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,8 @@ namespace MWClass
|
||||||
void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Potion::getModel(const MWWorld::Ptr &ptr) const
|
std::string Potion::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -34,9 +34,8 @@ namespace MWClass
|
||||||
void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Probe::getModel(const MWWorld::Ptr &ptr) const
|
std::string Probe::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -32,9 +32,8 @@ namespace MWClass
|
||||||
void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Repair::getModel(const MWWorld::Ptr &ptr) const
|
std::string Repair::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -24,9 +24,8 @@ namespace MWClass
|
||||||
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Static::getModel(const MWWorld::Ptr &ptr) const
|
std::string Static::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -34,9 +34,8 @@ namespace MWClass
|
||||||
void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
const std::string model = getModel(ptr);
|
const std::string model = getModel(ptr);
|
||||||
if(!model.empty()) {
|
if(!model.empty())
|
||||||
physics.insertObjectPhysics(ptr, model);
|
physics.addObject(ptr);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Weapon::getModel(const MWWorld::Ptr &ptr) const
|
std::string Weapon::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <components/nifbullet/bullet_nif_loader.hpp>
|
#include <components/nifbullet/bullet_nif_loader.hpp>
|
||||||
|
|
||||||
//#include "../mwbase/world.hpp" // FIXME
|
//#include "../mwbase/world.hpp" // FIXME
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "class.hpp"
|
#include "class.hpp"
|
||||||
|
@ -249,31 +250,36 @@ namespace MWWorld
|
||||||
mEngine->removeHeightField(x, y);
|
mEngine->removeHeightField(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh,
|
void PhysicsSystem::addObject (const Ptr& ptr)
|
||||||
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position)
|
|
||||||
{
|
{
|
||||||
handleToMesh[handle] = mesh;
|
std::string mesh = MWWorld::Class::get(ptr).getModel(ptr);
|
||||||
OEngine::Physic::RigidBody* body = mEngine->createAndAdjustRigidBody(mesh,handle,scale, position, rotation);
|
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
||||||
|
handleToMesh[node->getName()] = mesh;
|
||||||
|
OEngine::Physic::RigidBody* body = mEngine->createAndAdjustRigidBody(mesh, node->getName(), node->getScale().x, node->getPosition(), node->getOrientation());
|
||||||
mEngine->addRigidBody(body);
|
mEngine->addRigidBody(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::addActor (const std::string& handle, const std::string& mesh,
|
void PhysicsSystem::addActor (const Ptr& ptr)
|
||||||
const Ogre::Vector3& position, float scale, const Ogre::Quaternion& rotation)
|
|
||||||
{
|
{
|
||||||
|
std::string mesh = MWWorld::Class::get(ptr).getModel(ptr);
|
||||||
|
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
||||||
//TODO:optimize this. Searching the std::map isn't very efficient i think.
|
//TODO:optimize this. Searching the std::map isn't very efficient i think.
|
||||||
mEngine->addCharacter(handle, mesh, position, scale, rotation);
|
mEngine->addCharacter(node->getName(), mesh, node->getPosition(), node->getScale().x, node->getOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::removeObject (const std::string& handle)
|
void PhysicsSystem::removeObject (const std::string& handle)
|
||||||
{
|
{
|
||||||
//TODO:check if actor???
|
//TODO:check if actor???
|
||||||
|
|
||||||
mEngine->removeCharacter(handle);
|
mEngine->removeCharacter(handle);
|
||||||
mEngine->removeRigidBody(handle);
|
mEngine->removeRigidBody(handle);
|
||||||
mEngine->deleteRigidBody(handle);
|
mEngine->deleteRigidBody(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::moveObject (const std::string& handle, Ogre::SceneNode* node)
|
void PhysicsSystem::moveObject (const Ptr& ptr)
|
||||||
{
|
{
|
||||||
|
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
||||||
|
std::string handle = node->getName();
|
||||||
Ogre::Vector3 position = node->getPosition();
|
Ogre::Vector3 position = node->getPosition();
|
||||||
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
|
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
|
||||||
{
|
{
|
||||||
|
@ -307,8 +313,10 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::rotateObject (const std::string& handle, Ogre::SceneNode* node)
|
void PhysicsSystem::rotateObject (const Ptr& ptr)
|
||||||
{
|
{
|
||||||
|
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
||||||
|
std::string handle = node->getName();
|
||||||
Ogre::Quaternion rotation = node->getOrientation();
|
Ogre::Quaternion rotation = node->getOrientation();
|
||||||
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
||||||
{
|
{
|
||||||
|
@ -324,23 +332,18 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::scaleObject (const std::string& handle, Ogre::SceneNode* node)
|
void PhysicsSystem::scaleObject (const Ptr& ptr)
|
||||||
{
|
{
|
||||||
|
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
||||||
|
std::string handle = node->getName();
|
||||||
if(handleToMesh.find(handle) != handleToMesh.end())
|
if(handleToMesh.find(handle) != handleToMesh.end())
|
||||||
{
|
{
|
||||||
removeObject(handle);
|
removeObject(handle);
|
||||||
|
addObject(ptr);
|
||||||
float scale = node->getScale().x;
|
|
||||||
Ogre::Quaternion quat = node->getOrientation();
|
|
||||||
Ogre::Vector3 vec = node->getPosition();
|
|
||||||
addObject(handle, handleToMesh[handle], quat, scale, vec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
||||||
{
|
act->setScale(node->getScale().x);
|
||||||
float scale = node->getScale().x;
|
|
||||||
act->setScale(scale);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PhysicsSystem::toggleCollisionMode()
|
bool PhysicsSystem::toggleCollisionMode()
|
||||||
|
@ -371,23 +374,6 @@ namespace MWWorld
|
||||||
throw std::logic_error ("can't find player");
|
throw std::logic_error ("can't find player");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){
|
|
||||||
|
|
||||||
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
|
||||||
|
|
||||||
addObject(
|
|
||||||
node->getName(),
|
|
||||||
model,
|
|
||||||
node->getOrientation(),
|
|
||||||
node->getScale().x,
|
|
||||||
node->getPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){
|
|
||||||
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
|
||||||
addActor (node->getName(), model, node->getPosition(), node->getScale().x, node->getOrientation());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PhysicsSystem::getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max)
|
bool PhysicsSystem::getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max)
|
||||||
{
|
{
|
||||||
std::string model = MWWorld::Class::get(ptr).getModel(ptr);
|
std::string model = MWWorld::Class::get(ptr).getModel(ptr);
|
||||||
|
|
|
@ -20,11 +20,9 @@ namespace MWWorld
|
||||||
std::vector< std::pair<std::string, Ogre::Vector3> > doPhysicsFixed (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors);
|
std::vector< std::pair<std::string, Ogre::Vector3> > doPhysicsFixed (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors);
|
||||||
///< do physics with fixed timestep - Usage: first call doPhysics with frame dt, then call doPhysicsFixed as often as time steps have passed
|
///< do physics with fixed timestep - Usage: first call doPhysics with frame dt, then call doPhysicsFixed as often as time steps have passed
|
||||||
|
|
||||||
void addObject (const std::string& handle, const std::string& mesh,
|
void addObject (const MWWorld::Ptr& ptr);
|
||||||
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position);
|
|
||||||
|
|
||||||
void addActor (const std::string& handle, const std::string& mesh,
|
void addActor (const MWWorld::Ptr& ptr);
|
||||||
const Ogre::Vector3& position, float scale, const Ogre::Quaternion& rotation);
|
|
||||||
|
|
||||||
void addHeightField (float* heights,
|
void addHeightField (float* heights,
|
||||||
int x, int y, float yoffset,
|
int x, int y, float yoffset,
|
||||||
|
@ -32,13 +30,14 @@ namespace MWWorld
|
||||||
|
|
||||||
void removeHeightField (int x, int y);
|
void removeHeightField (int x, int y);
|
||||||
|
|
||||||
|
// have to keep this as handle for now as unloadcell only knows scenenode names
|
||||||
void removeObject (const std::string& handle);
|
void removeObject (const std::string& handle);
|
||||||
|
|
||||||
void moveObject (const std::string& handle, Ogre::SceneNode* node);
|
void moveObject (const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
void rotateObject (const std::string& handle, Ogre::SceneNode* node);
|
void rotateObject (const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
void scaleObject (const std::string& handle, Ogre::SceneNode* node);
|
void scaleObject (const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
bool toggleCollisionMode();
|
bool toggleCollisionMode();
|
||||||
|
|
||||||
|
@ -60,10 +59,6 @@ namespace MWWorld
|
||||||
std::pair<bool, Ogre::Vector3> castRay(float mouseX, float mouseY);
|
std::pair<bool, Ogre::Vector3> castRay(float mouseX, float mouseY);
|
||||||
///< cast ray from the mouse, return true if it hit something and the first result (in OGRE coordinates)
|
///< cast ray from the mouse, return true if it hit something and the first result (in OGRE coordinates)
|
||||||
|
|
||||||
void insertObjectPhysics(const MWWorld::Ptr& ptr, std::string model);
|
|
||||||
|
|
||||||
void insertActorPhysics(const MWWorld::Ptr&, std::string model);
|
|
||||||
|
|
||||||
OEngine::Physic::PhysicEngine* getEngine();
|
OEngine::Physic::PhysicEngine* getEngine();
|
||||||
|
|
||||||
void setCurrentWater(bool hasWater, int waterHeight);
|
void setCurrentWater(bool hasWater, int waterHeight);
|
||||||
|
|
|
@ -191,7 +191,8 @@ namespace MWWorld
|
||||||
|
|
||||||
std::string playerCollisionFile = "meshes\\base_anim.nif"; //This is used to make a collision shape for our player
|
std::string playerCollisionFile = "meshes\\base_anim.nif"; //This is used to make a collision shape for our player
|
||||||
//We will need to support the 1st person file too in the future
|
//We will need to support the 1st person file too in the future
|
||||||
mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), playerCollisionFile, Ogre::Vector3 (0, 0, 0), 1, Ogre::Quaternion::ZERO);
|
mPhysics->addActor(mPlayer->getPlayer());
|
||||||
|
// mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), playerCollisionFile, Ogre::Vector3 (0, 0, 0), 1, Ogre::Quaternion::ZERO);
|
||||||
|
|
||||||
// global variables
|
// global variables
|
||||||
mGlobalVariables = new Globals (mStore);
|
mGlobalVariables = new Globals (mStore);
|
||||||
|
@ -582,39 +583,48 @@ namespace MWWorld
|
||||||
CellStore *currCell = ptr.getCell();
|
CellStore *currCell = ptr.getCell();
|
||||||
bool isPlayer = ptr == mPlayer->getPlayer();
|
bool isPlayer = ptr == mPlayer->getPlayer();
|
||||||
bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer;
|
bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer;
|
||||||
if (*currCell != newCell) {
|
if (*currCell != newCell)
|
||||||
if (isPlayer) {
|
{
|
||||||
if (!newCell.isExterior()) {
|
if (isPlayer)
|
||||||
|
if (!newCell.isExterior())
|
||||||
changeToInteriorCell(toLower(newCell.cell->mName), pos);
|
changeToInteriorCell(toLower(newCell.cell->mName), pos);
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
int cellX = newCell.cell->mData.mX;
|
int cellX = newCell.cell->mData.mX;
|
||||||
int cellY = newCell.cell->mData.mY;
|
int cellY = newCell.cell->mData.mY;
|
||||||
mWorldScene->changeCell(cellX, cellY, pos, false);
|
mWorldScene->changeCell(cellX, cellY, pos, false);
|
||||||
}
|
}
|
||||||
} else {
|
else {
|
||||||
if (!mWorldScene->isCellActive(*currCell)) {
|
if (!mWorldScene->isCellActive(*currCell))
|
||||||
copyObjectToCell(ptr, newCell, pos);
|
copyObjectToCell(ptr, newCell, pos);
|
||||||
} else if (!mWorldScene->isCellActive(newCell)) {
|
else if (!mWorldScene->isCellActive(newCell))
|
||||||
|
{
|
||||||
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
||||||
mWorldScene->removeObjectFromScene(ptr);
|
mWorldScene->removeObjectFromScene(ptr);
|
||||||
mLocalScripts.remove(ptr);
|
mLocalScripts.remove(ptr);
|
||||||
haveToMove = false;
|
haveToMove = false;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
MWWorld::Ptr copy =
|
MWWorld::Ptr copy =
|
||||||
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
|
||||||
|
|
||||||
mRendering->moveObjectToCell(copy, vec, currCell);
|
mRendering->moveObjectToCell(copy, vec, currCell);
|
||||||
|
|
||||||
if (MWWorld::Class::get(ptr).isActor()) {
|
if (MWWorld::Class::get(ptr).isActor())
|
||||||
|
{
|
||||||
MWBase::MechanicsManager *mechMgr =
|
MWBase::MechanicsManager *mechMgr =
|
||||||
MWBase::Environment::get().getMechanicsManager();
|
MWBase::Environment::get().getMechanicsManager();
|
||||||
|
|
||||||
mechMgr->removeActor(ptr);
|
mechMgr->removeActor(ptr);
|
||||||
mechMgr->addActor(copy);
|
mechMgr->addActor(copy);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
std::string script =
|
std::string script =
|
||||||
MWWorld::Class::get(ptr).getScript(ptr);
|
MWWorld::Class::get(ptr).getScript(ptr);
|
||||||
if (!script.empty()) {
|
if (!script.empty())
|
||||||
|
{
|
||||||
mLocalScripts.remove(ptr);
|
mLocalScripts.remove(ptr);
|
||||||
mLocalScripts.add(script, copy);
|
mLocalScripts.add(script, copy);
|
||||||
}
|
}
|
||||||
|
@ -623,9 +633,10 @@ namespace MWWorld
|
||||||
ptr.getRefData().setCount(0);
|
ptr.getRefData().setCount(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (haveToMove) {
|
if (haveToMove)
|
||||||
|
{
|
||||||
mRendering->moveObject(ptr, vec);
|
mRendering->moveObject(ptr, vec);
|
||||||
mPhysics->moveObject (ptr.getRefData().getHandle(), ptr.getRefData().getBaseNode());
|
mPhysics->moveObject (ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +668,7 @@ namespace MWWorld
|
||||||
ptr.getCellRef().mScale = scale;
|
ptr.getCellRef().mScale = scale;
|
||||||
//scale = scale/ptr.getRefData().getBaseNode()->getScale().x;
|
//scale = scale/ptr.getRefData().getBaseNode()->getScale().x;
|
||||||
ptr.getRefData().getBaseNode()->setScale(scale,scale,scale);
|
ptr.getRefData().getBaseNode()->setScale(scale,scale,scale);
|
||||||
mPhysics->scaleObject( ptr.getRefData().getHandle(), ptr.getRefData().getBaseNode());
|
mPhysics->scaleObject(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust)
|
void World::rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust)
|
||||||
|
@ -673,10 +684,7 @@ namespace MWWorld
|
||||||
|
|
||||||
|
|
||||||
if (ptr.getRefData().getBaseNode() != 0) {
|
if (ptr.getRefData().getBaseNode() != 0) {
|
||||||
mPhysics->rotateObject(
|
mPhysics->rotateObject(ptr);
|
||||||
ptr.getRefData().getHandle(),
|
|
||||||
ptr.getRefData().getBaseNode()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue