2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
2005-04-20 01:03:36 +00:00
|
|
|
// Copyright (C) 2005 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-04-20 01:03:36 +00:00
|
|
|
|
|
|
|
|
#include "Motion.h"
|
2005-04-21 00:28:25 +00:00
|
|
|
|
2006-06-03 09:43:09 +00:00
|
|
|
#include "rulesets/Entity.h"
|
2006-06-01 00:12:45 +00:00
|
|
|
|
2006-06-03 09:43:09 +00:00
|
|
|
#include "physics/Vector3D.h"
|
|
|
|
|
#include "physics/Collision.h"
|
2006-06-01 00:12:45 +00:00
|
|
|
|
2006-06-03 09:43:09 +00:00
|
|
|
#include "common/compose.hpp"
|
|
|
|
|
#include "common/debug.h"
|
|
|
|
|
#include "common/const.h"
|
|
|
|
|
#include "common/log.h"
|
2006-06-01 00:12:45 +00:00
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
2006-06-03 11:17:10 +00:00
|
|
|
static const bool debug_flag = false;
|
2006-06-01 00:12:45 +00:00
|
|
|
|
2006-06-05 01:01:02 +00:00
|
|
|
Motion::Motion(Entity & body) : m_entity(body), m_serialno(0)
|
2005-04-21 00:28:25 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Motion::~Motion()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motion::setMode(const std::string & mode)
|
|
|
|
|
{
|
|
|
|
|
m_mode = mode;
|
|
|
|
|
// FIXME Re-configure stuff, and possible schedule an update?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motion::adjustPostion()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Operation * Motion::genUpdateOperation()
|
|
|
|
|
{
|
2005-04-23 15:18:47 +00:00
|
|
|
return 0;
|
2005-04-21 00:28:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Operation * Motion::genMoveOperation()
|
|
|
|
|
{
|
2005-04-23 15:18:47 +00:00
|
|
|
return 0;
|
2005-04-21 00:28:25 +00:00
|
|
|
}
|
2006-06-01 00:12:45 +00:00
|
|
|
|
|
|
|
|
float Motion::checkCollisions()
|
|
|
|
|
{
|
|
|
|
|
// Check to see whether a collision is going to occur from now until the
|
|
|
|
|
// the next tick in consts::move_tick seconds
|
|
|
|
|
float collTime = consts::move_tick;
|
|
|
|
|
debug( std::cout << "checking " << m_entity.getId()
|
|
|
|
|
<< m_entity.m_location.pos()
|
|
|
|
|
<< m_entity.m_location.velocity() << " in "
|
|
|
|
|
<< m_entity.m_location.m_loc->getId()
|
|
|
|
|
<< " against"; );
|
|
|
|
|
m_collEntity = NULL;
|
|
|
|
|
m_collLocChange = false;
|
2006-06-01 01:26:17 +00:00
|
|
|
m_collision = false;
|
2006-06-01 00:12:45 +00:00
|
|
|
// Check against everything within the current container
|
|
|
|
|
EntitySet::const_iterator I = m_entity.m_location.m_loc->m_contains.begin();
|
|
|
|
|
EntitySet::const_iterator Iend = m_entity.m_location.m_loc->m_contains.end();
|
|
|
|
|
for (; I != Iend; ++I) {
|
|
|
|
|
// Don't check for collisions with ourselves
|
|
|
|
|
if ((*I) == &m_entity) { continue; }
|
|
|
|
|
const Location & other_location = (*I)->m_location;
|
|
|
|
|
if (!other_location.bBox().isValid() || !other_location.isSolid()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
debug( std::cout << " " << (*I)->getId(); );
|
|
|
|
|
Vector3D normal;
|
|
|
|
|
float t = consts::move_tick + 1;
|
|
|
|
|
if (!predictCollision(m_entity.m_location, other_location, t, normal) || (t < 0)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
debug( std::cout << (*I)->getId() << other_location.pos() << other_location.velocity(); );
|
|
|
|
|
debug( std::cout << "[" << t << "]"; );
|
|
|
|
|
if (t <= collTime) {
|
|
|
|
|
m_collEntity = *I;
|
|
|
|
|
m_collNormal = normal;
|
|
|
|
|
collTime = t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
debug( std::cout << std::endl << std::flush; );
|
|
|
|
|
if (m_collEntity == NULL) {
|
|
|
|
|
// Check whethe we are moving out of parents bounding box
|
|
|
|
|
// If ref has no bounding box, or itself has no ref, then we can't
|
|
|
|
|
// Move out of it.
|
2006-06-03 09:43:09 +00:00
|
|
|
const Location & parent_location = m_entity.m_location.m_loc->m_location;
|
|
|
|
|
if (!parent_location.bBox().isValid() || (parent_location.m_loc == 0)) {
|
2006-06-01 00:12:45 +00:00
|
|
|
return consts::move_tick;
|
|
|
|
|
}
|
2006-06-03 09:43:09 +00:00
|
|
|
// float t = m_entity.m_location.timeToExit(parent_location);
|
2006-06-01 00:12:45 +00:00
|
|
|
float t = 0;
|
2006-06-03 09:43:09 +00:00
|
|
|
predictEmergence(m_entity.m_location, parent_location, t);
|
2006-06-01 00:12:45 +00:00
|
|
|
// if (t == 0) { return; }
|
|
|
|
|
// if (t < 0) { t = 0; }
|
2006-06-08 00:22:04 +00:00
|
|
|
if (t > consts::move_tick) { return consts::move_tick; }
|
2006-06-01 00:12:45 +00:00
|
|
|
collTime = t;
|
|
|
|
|
debug(std::cout << "Collision with parent bounding box in "
|
|
|
|
|
<< collTime << std::endl << std::flush;);
|
2006-06-03 09:43:09 +00:00
|
|
|
m_collEntity = m_entity.m_location.m_loc;
|
2006-06-01 00:12:45 +00:00
|
|
|
m_collLocChange = true;
|
|
|
|
|
} else if (!m_collEntity->m_location.isSimple()) {
|
|
|
|
|
debug(std::cout << "Collision with complex object" << std::endl
|
|
|
|
|
<< std::flush;);
|
|
|
|
|
// Non solid container - check for collision with its contents.
|
|
|
|
|
const Location & lc2 = m_collEntity->m_location;
|
|
|
|
|
Location rloc(m_entity.m_location);
|
|
|
|
|
rloc.m_loc = m_collEntity;
|
|
|
|
|
if (lc2.orientation().isValid()) {
|
|
|
|
|
rloc.m_pos = m_entity.m_location.m_pos.toLocalCoords(lc2.pos(), lc2.orientation());
|
|
|
|
|
} else {
|
|
|
|
|
static const Quaternion identity(1, 0, 0, 0);
|
|
|
|
|
rloc.m_pos = m_entity.m_location.m_pos.toLocalCoords(lc2.pos(), identity);
|
|
|
|
|
}
|
|
|
|
|
float coll2Time = consts::move_tick;
|
|
|
|
|
// rloc is now m_entity.m_location of character with loc set to m_collEntity
|
|
|
|
|
I = m_collEntity->m_contains.begin();
|
|
|
|
|
Iend = m_collEntity->m_contains.end();
|
|
|
|
|
for (; I != Iend; ++I) {
|
|
|
|
|
const Location & other_location = (*I)->m_location;
|
|
|
|
|
if (!other_location.bBox().isValid()) { continue; }
|
|
|
|
|
Vector3D normal;
|
|
|
|
|
float t = consts::move_tick + 1;
|
|
|
|
|
if (!predictCollision(rloc, other_location, t, normal) || (t < 0)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (t <= coll2Time) {
|
|
|
|
|
coll2Time = t;
|
|
|
|
|
}
|
|
|
|
|
// What to do with the normal?
|
|
|
|
|
}
|
|
|
|
|
// There is a small possibility that if
|
|
|
|
|
// coll2Time == collTime == move_tick, we will miss a collision
|
|
|
|
|
if ((coll2Time - collTime) > (consts::move_tick / 10)) {
|
|
|
|
|
debug( std::cout << "passing into it " << collTime << ":"
|
|
|
|
|
<< coll2Time << std::endl << std::flush;);
|
|
|
|
|
// We are entering collEntity.
|
|
|
|
|
m_collLocChange = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
assert(m_collEntity != NULL);
|
2006-06-01 01:26:17 +00:00
|
|
|
m_collision = true;
|
2006-06-01 00:12:45 +00:00
|
|
|
debug( std::cout << "COLLISION" << std::endl << std::flush; );
|
|
|
|
|
debug( std::cout << "Setting target loc to "
|
|
|
|
|
<< m_entity.m_location.pos() << "+"
|
|
|
|
|
<< m_entity.m_location.velocity() << "*" << collTime;);
|
|
|
|
|
return collTime;
|
|
|
|
|
}
|
2006-06-03 09:43:09 +00:00
|
|
|
|
|
|
|
|
bool Motion::resolveCollision()
|
|
|
|
|
{
|
|
|
|
|
Location & location(m_entity.m_location);
|
|
|
|
|
bool moving = true;
|
|
|
|
|
|
|
|
|
|
if (m_collLocChange) {
|
|
|
|
|
// We are changing container (LOC)
|
|
|
|
|
static const Quaternion identity(Quaternion().identity());
|
|
|
|
|
debug(std::cout << "CONTACT " << m_collEntity->getId()
|
|
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
if (m_collEntity == location.m_loc) {
|
|
|
|
|
// Passing out of current container
|
|
|
|
|
debug(std::cout << "OUT"
|
|
|
|
|
<< m_collEntity->m_location.pos()
|
|
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
const Quaternion & collOrientation = m_collEntity->m_location.orientation().isValid() ?
|
|
|
|
|
m_collEntity->m_location.orientation() :
|
|
|
|
|
identity;
|
|
|
|
|
location.m_pos = location.m_pos.toParentCoords(m_collEntity->m_location.pos(), collOrientation);
|
|
|
|
|
location.m_orientation *= collOrientation;
|
|
|
|
|
location.m_velocity.rotate(collOrientation);
|
2006-06-05 22:52:54 +00:00
|
|
|
|
2006-06-05 23:18:55 +00:00
|
|
|
m_entity.changeContainer(m_collEntity->m_location.m_loc);
|
2006-06-03 09:43:09 +00:00
|
|
|
} else if (m_collEntity->m_location.m_loc == location.m_loc) {
|
|
|
|
|
// Passing into new container
|
|
|
|
|
debug(std::cout << "IN" << std::endl << std::flush;);
|
|
|
|
|
const Quaternion & collOrientation = m_collEntity->m_location.orientation().isValid() ?
|
|
|
|
|
m_collEntity->m_location.orientation() :
|
|
|
|
|
identity;
|
|
|
|
|
location.m_pos = location.m_pos.toLocalCoords(m_collEntity->m_location.pos(), collOrientation);
|
|
|
|
|
location.m_orientation /= collOrientation;
|
|
|
|
|
location.m_velocity.rotate(collOrientation.inverse());
|
2006-06-05 22:52:54 +00:00
|
|
|
|
2006-06-05 23:18:55 +00:00
|
|
|
m_entity.changeContainer(m_collEntity);
|
2006-06-03 09:43:09 +00:00
|
|
|
} else {
|
|
|
|
|
// Container we are supposed to changing to is wrong.
|
|
|
|
|
// Just stop where we currently are. Debugging is required to work out
|
|
|
|
|
// why this happens
|
|
|
|
|
log(ERROR, String::compose("BAD COLLISION: %1(%2) with %3(%4)%5 when LOC is currently %6(%7)%8.",
|
|
|
|
|
m_entity.getId(),
|
|
|
|
|
m_entity.getType(),
|
|
|
|
|
m_collEntity->getId(),
|
|
|
|
|
m_collEntity->getType(),
|
|
|
|
|
location.m_pos,
|
|
|
|
|
location.m_loc->getId(),
|
|
|
|
|
location.m_loc->getType(),
|
|
|
|
|
location.m_pos).c_str());
|
|
|
|
|
// reset();
|
|
|
|
|
location.m_velocity = Vector3D(0,0,0);
|
|
|
|
|
moving = false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// We have arrived at our target position and must
|
|
|
|
|
// stop, or be deflected
|
|
|
|
|
if (location.m_loc != m_collEntity->m_location.m_loc) {
|
|
|
|
|
// Race condition
|
|
|
|
|
// This occurs if we get asked for a new update before
|
|
|
|
|
// the last move has taken effect, so we make the new
|
|
|
|
|
// pos exactly as it was when the last collision was
|
|
|
|
|
// predicted.
|
2006-06-08 00:22:04 +00:00
|
|
|
log(ERROR, "NON COLLISION - target does not have common parent");
|
2006-06-03 09:43:09 +00:00
|
|
|
} else {
|
|
|
|
|
// FIXME Generate touch ops
|
|
|
|
|
// This code relies on m_collNormal being a unit vector
|
|
|
|
|
float vel_square_mag = location.velocity().sqrMag();
|
|
|
|
|
location.m_velocity -= m_collNormal * Dot(m_collNormal, location.m_velocity);
|
|
|
|
|
if ((location.m_velocity.mag() / consts::base_velocity) > 0.05) {
|
|
|
|
|
m_collEntity = NULL;
|
|
|
|
|
location.m_velocity.normalize();
|
|
|
|
|
location.m_velocity *= sqrt(vel_square_mag);
|
|
|
|
|
} else {
|
|
|
|
|
// reset();
|
|
|
|
|
location.m_velocity = Vector3D(0,0,0);
|
|
|
|
|
moving = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-06-03 10:19:38 +00:00
|
|
|
clearCollision();
|
2006-06-03 09:43:09 +00:00
|
|
|
return moving;
|
|
|
|
|
}
|