Though this change isn't fully set in stone. We have to revisit if we
add motion between physical domains. This change would at least prevent
segfaults when domains are destroyed.
Collision detection should fully be handled by the domain, as should
sight checking.
The plan is to let the domain keep a separate structure of all collision
geometry, optimized in something like a quad or oct tree. Since the vast
majority of geometry is static, in the sense that it very seldom moves,
the Domain should keep a flat representation of all geometry, with
precomputer meshes for fast lookup.
Similarily it should keep a separate structure, or structures, for sight
checks.
And it should of course also use Bullet for collision detection.
* rulesets/Motion.cpp, rulesets/Motion.h: Remove the support for
hierarchical location model from the collision system. From
now on there will be a flat movement space.
* physics/Vector3D.h, physics/Vector3D.cpp: Move a bunch of inline
functions in the header to be non-inline in the body. Use
the forward declaraions in wfmath/const.h instead of having to
include the full headers.
* rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.h,
rulesets/Py_Point3D.h, rulesets/Py_Vector3D.h: Include wfmath
headers as required.
* rulesets/Motion.cpp: Add more thorough assert checks.
* tests/IGEntityExerciser.h: Ensure the containership is complete and
legal on entities to be tested, so collision code called from
update handler works correctly.
* rulesets/LocatedEntity.cpp, rulesets/LocatedEntity.h:
Don't allocated storage for m_contains by default, only
on demand. Add a convenience method which checks, and
allocates the storage if required. Set up the ID property
on this base class rather then Entity.
* rulesets/Py_Thing.cpp: Remove special handling of ID attribute
as it is now handled by the property.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/MemMap.cpp,
rulesets/Motion.cpp, rulesets/Py_Mind.cpp, rulesets/Py_Thing.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/WorldRouter.cpp:
Make sure all parts of the code where contains is used have
the right checks, as it could be null.
* rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/LocatedEntity.cpp, rulesets/LocatedEntity.h,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Thing.cpp, rulesets/World.cpp,
server/WorldRouter.cpp: Change LocatedEntity::m_contains into
a pointer so that the majority of entities that can not contain
anything don't waste the storage.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/Py_CreatorClient.cpp, common/BaseWorld.h, common/types.h,
modules/Location.cpp, modules/Location.h,
rulesets/AtlasProperties.cpp, rulesets/AtlasProperties.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/EntityProperties.cpp, rulesets/LocatedEntity.cpp,
rulesets/LocatedEntity.h, rulesets/MemEntity.cpp,
rulesets/MemEntity.h, rulesets/MemMap.cpp, rulesets/Motion.cpp,
rulesets/Motion.h, rulesets/Py_Location.h, rulesets/Py_Mind.cpp,
rulesets/Py_Thing.cpp, rulesets/Py_Thing.h,
rulesets/PythonMindScript.h, rulesets/PythonScript.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Script.cpp, rulesets/Script.h,
rulesets/Thing.cpp, rulesets/World.cpp, server/WorldRouter.cpp,
server/WorldRouter.h: Refactor all the entity code so there is now
a new base class for entities in the world simulation, and in the
mind which only contains things which are trully common to both.
This moves a lot of functionality which should not have been
present in mind entities away, and makes that code safer and more
efficient.
* tests/TestWorld.h: Update the test world API to match the base
class.
* rulesets/Character.cpp, rulesets/MemMap.cpp, rulesets/Motion.cpp,
rulesets/Python_API.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp: Don't use camel casing for
local variables or function arguments.
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
* rulesets/Motion.cpp: Ensure collision prediction returns move_tick
when a collision is not predicted. Remove pointless assignments.
Clarify error message.
* rulesets/Entity.h, rulesets/Entity.cpp: Add a function to handle
all the changes required when the LOC or container of an entity
changes.
* rulesets/Motion.cpp, rulesets/Thing.cpp: Use changeContainer()
rather than repeating the code in three places.
* rulesets/Thing.cpp: Add some assert checks when altering the
container of an entity.
* rulesets/Motion.cpp: Fix the code in collision resolution that
handler container changes so it does reference counting,
inserting and removing from contains lists, and flagging entity
changes.
* rulesets/Motion.cpp, rulesets/Motion.h: Add method and storage
to note what the reference number of the next update op should
be.
* rulesets/Thing.cpp: Note the current serialno as the refno of the
expected update op, and ignore all others obsolete update ops.
* rulesets/Motion.h: Rename to clearCollision() to adhere to
convention.
* rulesets/Motion.cpp: Implicitly clear a pending collision whenever
one is resolved.
* rulesets/Thing.cpp: Cut in the new collision resolution code.
* rulesets/Motion.h, rulesets/Motion.cpp: Add flag and time to sore
info about collisions.
* rulesets/Thing.cpp: Rambling messy code to detect and act on
predicted collisions.
* rulesets/Motion.h, rulesets/Motion.cpp: Add method to check for
collisions.
* rulesets/Thing.cpp: Use Motion::checkCollisions to output debug
data about collisions.
* rulesets/Motion.h, rulesets/Motion.cpp: Add a little more API,
and provide stubs of existing methods.
* rulesets/Thing.cpp: Add a motion instance to all physical
entities, and pass mode setting to it.