From: <spo...@us...> - 2007-03-19 01:18:00
|
Revision: 329 http://svn.sourceforge.net/opengate/?rev=329&view=rev Author: spom_spom Date: 2007-03-17 13:08:40 -0700 (Sat, 17 Mar 2007) Log Message: ----------- Added Paths: ----------- branches/ogsector/externals/ogreopcode/Makefile branches/ogsector/externals/ogreopcode/Makefile.global branches/ogsector/externals/ogreopcode/include/ branches/ogsector/externals/ogreopcode/include/BP_Endpoint.h branches/ogsector/externals/ogreopcode/include/BP_Proxy.h branches/ogsector/externals/ogreopcode/include/BP_Scene.h branches/ogsector/externals/ogreopcode/include/GEN_List.h branches/ogsector/externals/ogreopcode/include/IOgreCollisionShape.h branches/ogsector/externals/ogreopcode/include/OgreBoxCollisionShape.h branches/ogsector/externals/ogreopcode/include/OgreBroadPhase.h branches/ogsector/externals/ogreopcode/include/OgreCapsule.h branches/ogsector/externals/ogreopcode/include/OgreCollisionContext.h branches/ogsector/externals/ogreopcode/include/OgreCollisionManager.h branches/ogsector/externals/ogreopcode/include/OgreCollisionObject.h branches/ogsector/externals/ogreopcode/include/OgreCollisionReporter.h branches/ogsector/externals/ogreopcode/include/OgreCollisionTypes.h branches/ogsector/externals/ogreopcode/include/OgreEntityCollisionShape.h branches/ogsector/externals/ogreopcode/include/OgreMeshCollisionShape.h branches/ogsector/externals/ogreopcode/include/OgreNodes.h branches/ogsector/externals/ogreopcode/include/OgreOpcode.h branches/ogsector/externals/ogreopcode/include/OgreOpcodeDebugObject.h branches/ogsector/externals/ogreopcode/include/OgreOpcodeExports.h branches/ogsector/externals/ogreopcode/include/OgreOpcodeLine.h branches/ogsector/externals/ogreopcode/include/OgreOpcodeMath.h branches/ogsector/externals/ogreopcode/include/OgreOpcodeRay.h branches/ogsector/externals/ogreopcode/include/OgreOpcodeUtils.h branches/ogsector/externals/ogreopcode/include/OgreOrientedBox.h branches/ogsector/externals/ogreopcode/include/OgrePtrCollisionShape.h branches/ogsector/externals/ogreopcode/include/OgreSphereMeshCollisionShape.h branches/ogsector/externals/ogreopcode/include/OgreTerrainCollisionShape.h branches/ogsector/externals/ogreopcode/include/OgreTriangle.h branches/ogsector/externals/ogreopcode/opcode132/ branches/ogsector/externals/ogreopcode/opcode132/Ice/ branches/ogsector/externals/ogreopcode/opcode132/Ice/IceAABB.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceAABB.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceAxes.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceBoundingSphere.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceContainer.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceContainer.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceFPU.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceHPoint.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceHPoint.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceIndexedTriangle.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceIndexedTriangle.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceLSS.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceMatrix3x3.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceMatrix3x3.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceMatrix4x4.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceMatrix4x4.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceMemoryMacros.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceOBB.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceOBB.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IcePairs.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IcePlane.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IcePlane.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IcePoint.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IcePoint.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IcePreprocessor.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceRandom.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceRandom.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceRay.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceRay.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceRevisitedRadix.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceRevisitedRadix.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceSegment.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceSegment.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceTriList.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceTriangle.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceTriangle.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceTypes.h branches/ogsector/externals/ogreopcode/opcode132/Ice/IceUtils.cpp branches/ogsector/externals/ogreopcode/opcode132/Ice/IceUtils.h branches/ogsector/externals/ogreopcode/opcode132/Makefile branches/ogsector/externals/ogreopcode/opcode132/Makefile.am branches/ogsector/externals/ogreopcode/opcode132/OPC_AABBCollider.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_AABBCollider.h branches/ogsector/externals/ogreopcode/opcode132/OPC_AABBTree.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_AABBTree.h branches/ogsector/externals/ogreopcode/opcode132/OPC_BaseModel.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_BaseModel.h branches/ogsector/externals/ogreopcode/opcode132/OPC_BoxBoxOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_BoxPruning.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_BoxPruning.h branches/ogsector/externals/ogreopcode/opcode132/OPC_Collider.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_Collider.h branches/ogsector/externals/ogreopcode/opcode132/OPC_Common.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_Common.h branches/ogsector/externals/ogreopcode/opcode132/OPC_HybridModel.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_HybridModel.h branches/ogsector/externals/ogreopcode/opcode132/OPC_IceHook.h branches/ogsector/externals/ogreopcode/opcode132/OPC_LSSAABBOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_LSSCollider.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_LSSCollider.h branches/ogsector/externals/ogreopcode/opcode132/OPC_LSSTriOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_MeshInterface.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_MeshInterface.h branches/ogsector/externals/ogreopcode/opcode132/OPC_Model.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_Model.h branches/ogsector/externals/ogreopcode/opcode132/OPC_OBBCollider.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_OBBCollider.h branches/ogsector/externals/ogreopcode/opcode132/OPC_OptimizedTree.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_OptimizedTree.h branches/ogsector/externals/ogreopcode/opcode132/OPC_Picking.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_Picking.h branches/ogsector/externals/ogreopcode/opcode132/OPC_PlanesAABBOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_PlanesCollider.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_PlanesCollider.h branches/ogsector/externals/ogreopcode/opcode132/OPC_PlanesTriOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_RayAABBOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_RayCollider.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_RayCollider.h branches/ogsector/externals/ogreopcode/opcode132/OPC_RayTriOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_Settings.h branches/ogsector/externals/ogreopcode/opcode132/OPC_SphereAABBOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_SphereCollider.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_SphereCollider.h branches/ogsector/externals/ogreopcode/opcode132/OPC_SphereTriOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_SweepAndPrune.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_SweepAndPrune.h branches/ogsector/externals/ogreopcode/opcode132/OPC_TreeBuilders.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_TreeBuilders.h branches/ogsector/externals/ogreopcode/opcode132/OPC_TreeCollider.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_TreeCollider.h branches/ogsector/externals/ogreopcode/opcode132/OPC_TriBoxOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_TriTriOverlap.h branches/ogsector/externals/ogreopcode/opcode132/OPC_TriTriOverlapGilvan.h branches/ogsector/externals/ogreopcode/opcode132/OPC_VolumeCollider.cpp branches/ogsector/externals/ogreopcode/opcode132/OPC_VolumeCollider.h branches/ogsector/externals/ogreopcode/opcode132/Opcode.cpp branches/ogsector/externals/ogreopcode/opcode132/Opcode.h branches/ogsector/externals/ogreopcode/opcode132/Opcode_SDK.cbp branches/ogsector/externals/ogreopcode/opcode132/Opcode_vc70.vcproj branches/ogsector/externals/ogreopcode/opcode132/Opcode_vc71.vcproj branches/ogsector/externals/ogreopcode/opcode132/Opcode_vc8.vcproj branches/ogsector/externals/ogreopcode/opcode132/Opcode_vc8SDK.vcproj branches/ogsector/externals/ogreopcode/opcode132/ReadMe.txt branches/ogsector/externals/ogreopcode/opcode132/StdAfx.cpp branches/ogsector/externals/ogreopcode/opcode132/Stdafx.h branches/ogsector/externals/ogreopcode/opcode132/TemporalCoherence.txt branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so.13 branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so.13.1 branches/ogsector/externals/ogreopcode/opcode132/scales TODO.txt branches/ogsector/externals/ogreopcode/src/ branches/ogsector/externals/ogreopcode/src/BP_Endpoint.cpp branches/ogsector/externals/ogreopcode/src/BP_Proxy.cpp branches/ogsector/externals/ogreopcode/src/BP_Scene.cpp branches/ogsector/externals/ogreopcode/src/IOgreCollisionShape.cpp branches/ogsector/externals/ogreopcode/src/Makefile branches/ogsector/externals/ogreopcode/src/OgreBoxCollisionShape.cpp branches/ogsector/externals/ogreopcode/src/OgreCapsule.cpp branches/ogsector/externals/ogreopcode/src/OgreCollisionContext.cpp branches/ogsector/externals/ogreopcode/src/OgreCollisionManager.cpp branches/ogsector/externals/ogreopcode/src/OgreCollisionObject.cpp branches/ogsector/externals/ogreopcode/src/OgreEntityCollisionShape.cpp branches/ogsector/externals/ogreopcode/src/OgreMeshCollisionShape.cpp branches/ogsector/externals/ogreopcode/src/OgreOpcode.dox branches/ogsector/externals/ogreopcode/src/OgreOpcodeDebugObject.cpp branches/ogsector/externals/ogreopcode/src/OgreOpcodeLine.cpp branches/ogsector/externals/ogreopcode/src/OgreOpcodeMath.cpp branches/ogsector/externals/ogreopcode/src/OgreOpcodeRay.cpp branches/ogsector/externals/ogreopcode/src/OgreOrientedBox.cpp branches/ogsector/externals/ogreopcode/src/OgrePtrCollisionShape.cpp branches/ogsector/externals/ogreopcode/src/OgreSphereMeshCollisionShape.cpp branches/ogsector/externals/ogreopcode/src/OgreTerrainCollisionShape.cpp branches/ogsector/externals/ogreopcode/src/OgreTriangle.cpp branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so.0 branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so.0.3 Added: branches/ogsector/externals/ogreopcode/Makefile =================================================================== --- branches/ogsector/externals/ogreopcode/Makefile (rev 0) +++ branches/ogsector/externals/ogreopcode/Makefile 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,45 @@ +include Makefile.global + +CFLAGS = -O2 -fPIC +INCLUDES = +LIBS = + +OPCODE_DIR = opcode132/ +OGREOPCODE_DIR = src/ +EXAMPLE_DIR = example/src/ + +.PHONY : all +all: opcode ogreopcode + +opcode: + $(MAKE) -C $(OPCODE_DIR) + +ogreopcode: opcode + $(MAKE) -C $(OGREOPCODE_DIR) + +example: ogreopcode + $(MAKE) -C $(EXAMPLE_DIR) + + +static: opcode_static ogreopcode_static + + +opcode_static: + $(MAKE) -C $(OPCODE_DIR) static + +ogreopcode_static: opcode_static + $(MAKE) -C $(OGREOPCODE_DIR) static + +example_static: ogreopcode_static + $(MAKE) -C $(EXAMPLE_DIR) static + + +.PHONY : clean +clean: + rm -f $(OPCODE_DIR)*.a \ + $(OPCODE_DIR)*.o \ + $(OPCODE_DIR)*.so* \ + $(OGREOPCODE_DIR)*.a \ + $(OGREOPCODE_DIR)*.o \ + $(OGREOPCODE_DIR)*.so* +# $(MAKE) -C $(EXAMPLE_DIR) clean Added: branches/ogsector/externals/ogreopcode/Makefile.global =================================================================== --- branches/ogsector/externals/ogreopcode/Makefile.global (rev 0) +++ branches/ogsector/externals/ogreopcode/Makefile.global 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,7 @@ +CC = g++ + +OGRE_CFLAGS=`pkg-config OGRE --cflags` +OGRE_LIBS=`pkg-config OGRE --libs` +CEGUI_CFLAGS=`pkg-config CEGUI-OGRE --cflags` `pkg-config CEGUI --cflags` +CEGUI_LIBS=`pkg-config CEGUI-OGRE --libs` `pkg-config CEGUI --libs` + Added: branches/ogsector/externals/ogreopcode/include/BP_Endpoint.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/BP_Endpoint.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/BP_Endpoint.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,61 @@ +/* +* SOLID - Software Library for Interference Detection +* Copyright (c) 2001 Dtecta <gi...@dt...> +* +* All rights reserved. +*/ + +#ifndef BP_ENDPOINT_H +#define BP_ENDPOINT_H + +#include "GEN_List.h" +//#include "MT_Scalar.h" + +namespace OgreOpcode +{ + namespace Details + { + + class BP_Scene; + class BP_Proxy; + + typedef bool (*T_Overlap)(const BP_Proxy&, const BP_Proxy&); + + class BP_Endpoint : public GEN_Link { + public: + enum Type { MINIMUM, MAXIMUM }; + + BP_Endpoint() : m_proxy(0) {} + BP_Endpoint(Ogre::Real pos, Type type, BP_Proxy *proxy, + GEN_List& endpointList); + ~BP_Endpoint(); + + Ogre::Real getPos() const { return m_pos; } + void setPos(Ogre::Real pos) { m_pos = pos; } + + void move(Ogre::Real x, BP_Scene& scene, T_Overlap); + + friend void encounters(const BP_Endpoint& a, const BP_Endpoint& b, + BP_Scene& scene, T_Overlap overlap); + + friend bool operator<(const BP_Endpoint& a, const BP_Endpoint& b); + + private: + Ogre::Real m_pos; + Type m_type; + BP_Proxy *m_proxy; + + inline int MT_sign(Ogre::Real x) + { + return x < Ogre::Real(0.0) ? -1 : x > Ogre::Real(0.0) ? 1 : 0; + } + }; + + inline bool operator<(const BP_Endpoint& a, const BP_Endpoint& b) { + return a.m_pos < b.m_pos || (a.m_pos == b.m_pos && a.m_type < b.m_type); + } + + } +} + +#endif Added: branches/ogsector/externals/ogreopcode/include/BP_Proxy.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/BP_Proxy.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/BP_Proxy.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,50 @@ +/* +* SOLID - Software Library for Interference Detection +* Copyright (c) 2001 Dtecta <gi...@dt...> +* +* All rights reserved. +*/ + +#ifndef BP_PROXY_H +#define BP_PROXY_H + +#include "BP_Endpoint.h" +namespace OgreOpcode +{ + namespace Details + { + + class BP_Scene; + + class BP_Proxy { + public: + BP_Proxy(void *object, + BP_Scene& scene, + const Ogre::Vector3& min, + const Ogre::Vector3& max); + + void setBBox(const Ogre::Vector3& min, const Ogre::Vector3& max); + + void *getObject() { return m_object; } + + Ogre::Real getMin(int i) const { return m_min[i].getPos(); } + Ogre::Real getMax(int i) const { return m_max[i].getPos(); } + + private: + void *m_object; + BP_Scene& m_scene; + BP_Endpoint m_min[3]; + BP_Endpoint m_max[3]; + }; + + inline bool BP_overlap(const BP_Proxy& a, const BP_Proxy& b) + { + return a.getMin(0) <= b.getMax(0) && b.getMin(0) <= a.getMax(0) && + a.getMin(1) <= b.getMax(1) && b.getMin(1) <= a.getMax(1) && + a.getMin(2) <= b.getMax(2) && b.getMin(2) <= a.getMax(2); + } + + } +} + +#endif Added: branches/ogsector/externals/ogreopcode/include/BP_Scene.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/BP_Scene.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/BP_Scene.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,69 @@ +/* +* SOLID - Software Library for Interference Detection +* Copyright (c) 2001 Dtecta <gi...@dt...> +* +* All rights reserved. +*/ + +#ifndef BP_SCENE_H +#define BP_SCENE_H + +#include <vector> + +#include "OgreBroadPhase.h" +#include "GEN_List.h" +namespace OgreOpcode +{ + namespace Details + { + + class BP_Proxy; + class Ogre::Vector3; + + class BP_Scene { + public: + BP_Scene(void *client_data, + BP_Callback beginOverlap, + BP_Callback endOverlap) : + m_client_data(client_data), + m_beginOverlap(beginOverlap), + m_endOverlap(endOverlap) {} + + ~BP_Scene(); + + BP_Proxy *createProxy(void *object, + const Ogre::Vector3& min, + const Ogre::Vector3& max); + + void deleteProxy(BP_Proxy *proxy); + + void callBeginOverlap(void *object1, void *object2) { + m_beginOverlap(m_client_data, object1, object2); + } + + void callEndOverlap(void *object1, void *object2) { + m_endOverlap(m_client_data, object1, object2); + } + + GEN_List *getLists() { return m_endpointList; } + + private: + typedef std::vector<BP_Proxy *> T_ProxyList; + + void *m_client_data; + BP_Callback m_beginOverlap; + BP_Callback m_endOverlap; + T_ProxyList m_proxyList; + GEN_List m_endpointList[3]; + }; + } +} + +#endif + + + + + + + Added: branches/ogsector/externals/ogreopcode/include/GEN_List.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/GEN_List.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/GEN_List.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,117 @@ +/* +SOLID - Software Library for Interference Detection +Copyright (C) 1997-1998 Gino van den Bergen + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free +Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Please send remarks, questions and bug reports to gi...@wi..., +or write to: +Gino van den Bergen +Department of Mathematics and Computing Science +Eindhoven University of Technology +P.O. Box 513, 5600 MB Eindhoven, The Netherlands +*/ + +#ifndef GEN_LIST_H +#define GEN_LIST_H + +#include <Ogre.h> + +namespace OgreOpcode +{ + namespace Details + { + + class GEN_Link { + public: + GEN_Link() : m_next(0), m_prev(0) {} + GEN_Link(GEN_Link *next, GEN_Link *prev) : m_next(next), m_prev(prev) {} + + GEN_Link *getNext() const { return m_next; } + GEN_Link *getPrev() const { return m_prev; } + + bool isHead() const { return m_prev == 0; } + bool isTail() const { return m_next == 0; } + + void attachBefore(GEN_Link *link) { + m_next = link; + link->m_prev = this; + } + + void attachAfter(GEN_Link *link) { + m_prev = link; + link->m_next = this; + } + + void insertBefore(GEN_Link *link) { + attachAfter(link->m_prev); + attachBefore(link); + } + + void insertAfter(GEN_Link *link) { + attachBefore(link->m_next); + attachAfter(link); + } + + void remove() { + m_next->m_prev = m_prev; + m_prev->m_next = m_next; + m_next = m_prev = 0; + } + + private: + GEN_Link *m_next; + GEN_Link *m_prev; + }; + + + class GEN_List { + public: + GEN_List() : m_head(&m_tail, 0), m_tail(0, &m_head) {} + + GEN_Link *getHead() const { return m_head.getNext(); } + GEN_Link *getTail() const { return m_tail.getPrev(); } + + void clear() { m_head.attachBefore(&m_tail); } + + void addHead(GEN_Link *link) { link->insertAfter(&m_head); } + void addTail(GEN_Link *link) { link->insertBefore(&m_tail); } + + void appendHead(GEN_List& list) { + list.getTail()->attachBefore(getHead()); + list.getHead()->attachAfter(&m_head); + list.clear(); + } + + void appendTail(GEN_List& list) { + list.getHead()->attachAfter(getTail()); + list.getTail()->attachBefore(&m_tail); + list.clear(); + } + + bool isEmpty() const { return getHead()->isTail(); } + + private: + GEN_Link m_head; + GEN_Link m_tail; + }; + + } +} + +#endif + + + Added: branches/ogsector/externals/ogreopcode/include/IOgreCollisionShape.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/IOgreCollisionShape.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/IOgreCollisionShape.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,184 @@ +/////////////////////////////////////////////////////////////////////////////// +/// @file IOgreCollisionShape.h +/// @brief Abstract base class for collision shapes +/// +/// @author The OgreOpcode Team +/// +/////////////////////////////////////////////////////////////////////////////// +/// +/// This file is part of OgreOpcode. +/// +/// A lot of the code is based on the Nebula Opcode Collision module, see docs/Nebula_license.txt +/// +/// OgreOpcode is free software; you can redistribute it and/or +/// modify it under the terms of the GNU Lesser General Public +/// License as published by the Free Software Foundation; either +/// version 2.1 of the License, or (at your option) any later version. +/// +/// OgreOpcode 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 +/// Lesser General Public License for more details. +/// +/// You should have received a copy of the GNU Lesser General Public +/// License along with OgreOpcode; if not, write to the Free Software +/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/// +/////////////////////////////////////////////////////////////////////////////// +#ifndef __IOgreCollisionShape_h__ +# define __IOgreCollisionShape_h__ + +#include "OgreOpcodeExports.h" +# include <Ogre.h> + +#include "OgreCollisionTypes.h" +#include "OgreOpcodeDebugObject.h" +#include "Opcode.h" + +namespace OgreOpcode +{ + class CollisionPair; + + /// Describes shapes for collision system. + /// Holds a triangle list describing a collision shape. + class _OgreOpcode_Export ICollisionShape + { + public: + /// Constructs a ICollisionShape + ICollisionShape(const Ogre::String& name); + virtual ~ICollisionShape(); + + /// visualize the collide shape + virtual void visualize(Details::OgreOpcodeDebugger* activeDebugger); + /// Clear visualization buffer + virtual void clearViz() + { + mDebugObject->clear(); + } + + virtual void setStatic(bool newstatic = true) + { + mShapeIsStatic = newstatic; + } + /// visualise OPCODE AABB tree + virtual void visualizeAABBs(Details::OgreOpcodeDebugger* activeDebugger); + /// return current center in world space + virtual Ogre::Vector3& getCenter(); + /// return current center in object space + virtual Ogre::Vector3& getLocalCenter(); + /// returns the name of the shape + virtual Ogre::String& getName(); + /// get radius of collide mesh + virtual Ogre::Real& getRadius(); + /// return the full transformation matrix + virtual Ogre::Matrix4 getFullTransform(void) const; + /// return the local transformation matrix + virtual Ogre::Matrix4& getLocalTransform(void) const; + /// + virtual void setTransform(const Ogre::Matrix4 newTransform); + /// returns the scenenode which this shape is attached to + virtual Ogre::SceneNode* getParentSceneNode(void) const; + + ///// returns the IceMaths::AABB used for pruning + //virtual IceMaths::AABB* getIceABB(void) const; + + /// is this shape a static? + virtual const bool isStatic() const + { + return mShapeIsStatic; + }; + + /// Retrieve current vertex data from mesh and refit collision tree. + /// This is an O(n) operation in the number of vertices in the mesh. + virtual bool refit() { return true; }; + /// return current world space AABB min and max + virtual void getMinMax(Ogre::Vector3& bMin, Ogre::Vector3& bMax) const; + /// return current object space AABB min and max + virtual void getLocalMinMax(Ogre::Vector3& bMin, Ogre::Vector3& bMax) const; + /// perform collision with other ICollisionShape + virtual bool collide(CollisionType collType, Ogre::Matrix4& ownMatrix, ICollisionShape* otherShape, Ogre::Matrix4& otherMatrix, CollisionPair& collPair); + /// perform collision with line + virtual bool rayCheck(CollisionType collType, const Ogre::Matrix4& ownMatrix, const Ogre::Ray& line, const Ogre::Real dist, CollisionPair& collPair, bool rayCulling); + /// perform a sphere check + virtual bool sphereCheck(CollisionType collType, const Ogre::Matrix4& ownMatrix, const Ogre::Sphere& ball, CollisionPair& collPair); + /// perform a swept sphere check + virtual bool sweptSphereCheck(CollisionType collType, const Ogre::Matrix4& ownMatrix, const Ogre::Vector3& position, const Ogre::Vector3& movementVector, const Ogre::Real& radius, CollisionPair& collPair); + /// get tri coords from tri index + virtual void getTriCoords(int index, Ogre::Vector3& v0, Ogre::Vector3& v1, Ogre::Vector3& v2); + + Opcode::Model opcModel; + + ///// calculate SAP AABB + //virtual void computeIceABB(); + + protected: + + /// has object been initialized? + virtual bool isInitialized(); + /// visualize the AABBTree of the opcode model + virtual void visualizeAABBCollisionNode(const Opcode::AABBCollisionNode* node); + /// visualize the AABBTree of the opcode model (for no leaf trees) + virtual void visualizeAABBNoLeafNode(const Opcode::AABBNoLeafNode* node); + /// prepare OPCODE parameters + virtual void _prepareOpcodeCreateParams(Opcode::OPCODECREATE& opcc); + /// calculates the shape radius + virtual void calculateSize(); + + Opcode::BVTCache* opcTreeCache; ///< + Opcode::CollisionFaces* opcFaceCache; ///< + Opcode::MeshInterface opcMeshAccess; ///< + int numVertices; ///< + int numFaces; ///< + float* mVertexBuf; ///< + int* mFaceBuf; ///< + Ogre::Real mRadius; ///< + Ogre::SceneNode* mParentNode; ///< + Ogre::String mName; ///< + bool mInitialized; ///< + bool mShapeIsStatic; ///< + bool mHasCostumTransform; ///< + bool mDoVisualizeAABBNodes; ///< + int refCount; ///< + mutable Ogre::Matrix4 mFullTransform; ///< + mutable Ogre::Matrix4 mLocalTransform; ///< + //IceMaths::AABB* mIceABB; ///< + Ogre::Vector3 mCenter; ///< + Ogre::Vector3 mLocalCenter; ///< + Details::OgreOpcodeDebugger* mActiveDebugger; + Ogre::ManualObject* mDebugObject; + }; + inline + bool + ICollisionShape::isInitialized() + { + return mInitialized; + } + + inline Ogre::SceneNode* ICollisionShape::getParentSceneNode(void) const + { + return mParentNode; + } + + inline + Ogre::Real& + ICollisionShape::getRadius() + { + return mRadius; + } + + /// Extract triangle coordinates from triangle index. + inline + void + ICollisionShape::getTriCoords(int index, Ogre::Vector3& v0, Ogre::Vector3& v1, Ogre::Vector3& v2) + { + int* indexPtr = &(mFaceBuf[3 * index]); + float* vp0 = &(mVertexBuf[3 * indexPtr[0]]); + float* vp1 = &(mVertexBuf[3 * indexPtr[1]]); + float* vp2 = &(mVertexBuf[3 * indexPtr[2]]); + v0 = Ogre::Vector3(vp0[0], vp0[1], vp0[2]); + v1 = Ogre::Vector3(vp1[0], vp1[1], vp1[2]); + v2 = Ogre::Vector3(vp2[0], vp2[1], vp2[2]); + } +}; // namespace OgreOpcode + +#endif // __IOgreCollisionShape_h__ Added: branches/ogsector/externals/ogreopcode/include/OgreBoxCollisionShape.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/OgreBoxCollisionShape.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/OgreBoxCollisionShape.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,72 @@ +/////////////////////////////////////////////////////////////////////////////// +/// @file OgreBoxCollisionShape.h +/// @brief <TODO: insert file description here> +/// +/// @author The OgreOpcode Team +/// +/////////////////////////////////////////////////////////////////////////////// +/// +/// This file is part of OgreOpcode. +/// +/// A lot of the code is based on the Nebula Opcode Collision module, see docs/Nebula_license.txt +/// +/// OgreOpcode is free software; you can redistribute it and/or +/// modify it under the terms of the GNU Lesser General Public +/// License as published by the Free Software Foundation; either +/// version 2.1 of the License, or (at your option) any later version. +/// +/// OgreOpcode 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 +/// Lesser General Public License for more details. +/// +/// You should have received a copy of the GNU Lesser General Public +/// License along with OgreOpcode; if not, write to the Free Software +/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/// +/////////////////////////////////////////////////////////////////////////////// +#ifndef __OgreBoxCollisionShape_h__ +# define __OgreBoxCollisionShape_h__ + +#include "OgreOpcodeExports.h" +# include <Ogre.h> + +#include "IOgreCollisionShape.h" +#include "OgreCollisionTypes.h" +#include "OgreOpcodeDebugObject.h" +#include "Opcode.h" + +namespace OgreOpcode +{ + class CollisionPair; + + /// Describes shapes for collision system. + /// Holds a triangle list describing a collision shape. + /// One BoxCollisionShape object may be shared between several + /// CollisionObject%s. 2 BoxCollisionShape objects may also + /// be queried directly whether they intersect. + /// + /// BoxCollisionShape objects are also able to load themselves + /// from a mesh file. + class _OgreOpcode_Export BoxCollisionShape : public ICollisionShape + { + public: + /// Constructs a BoxCollisionShape + BoxCollisionShape(const Ogre::String& name); + virtual ~BoxCollisionShape(); + + /// load collide geometry from mesh, and build a collision tree + virtual bool load(Ogre::SceneNode* scnNode, int height, int width, int depth); + + protected: + virtual void _prepareOpcodeCreateParams(Opcode::OPCODECREATE& opcc); + + private: + /// prevent default construction + BoxCollisionShape(); + + }; + +}; // namespace OgreOpcode + +#endif // __OgreBoxCollisionShape_h__ Added: branches/ogsector/externals/ogreopcode/include/OgreBroadPhase.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/OgreBroadPhase.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/OgreBroadPhase.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////////// +/// @file OgreTriangle.h +/// @brief This class represents a Triangle, which is composed by +/// +/// @author The OgreOpcode Team +/// +/////////////////////////////////////////////////////////////////////////////// +/// +/// This file is part of OgreOpcode. +/// +/// A lot of the code is based on the Nebula Opcode Collision module, see docs/Nebula_license.txt +/// +/// OgreOpcode is free software; you can redistribute it and/or +/// modify it under the terms of the GNU Lesser General Public +/// License as published by the Free Software Foundation; either +/// version 2.1 of the License, or (at your option) any later version. +/// +/// OgreOpcode 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 +/// Lesser General Public License for more details. +/// +/// You should have received a copy of the GNU Lesser General Public +/// License along with OgreOpcode; if not, write to the Free Software +/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/// +/////////////////////////////////////////////////////////////////////////////// +#ifndef __OgreBroadPhase_h__ +#define __OgreBroadPhase_h__ + +namespace OgreOpcode +{ + namespace Details + { + typedef void (*BP_Callback)(void *client_data, void *object1, void *object2); + } +} + +#endif // __OgreBroadPhase_h__ Added: branches/ogsector/externals/ogreopcode/include/OgreCapsule.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/OgreCapsule.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/OgreCapsule.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,125 @@ +/////////////////////////////////////////////////////////////////////////////// +/// @file OgreCapsule.h +/// @brief This class represents a Capsule, which is defined by 2 endpoints and a radius. +/// You can interpret it as a sphere that is sweept along a line. +/// +/// @author The OgreOpcode Team +/// +/////////////////////////////////////////////////////////////////////////////// +/// +/// This file is part of OgreOpcode. +/// +/// A lot of the code is based on the Nebula Opcode Collision module, see docs/Nebula_license.txt +/// +/// OgreOpcode is free software; you can redistribute it and/or +/// modify it under the terms of the GNU Lesser General Public +/// License as published by the Free Software Foundation; either +/// version 2.1 of the License, or (at your option) any later version. +/// +/// OgreOpcode 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 +/// Lesser General Public License for more details. +/// +/// You should have received a copy of the GNU Lesser General Public +/// License along with OgreOpcode; if not, write to the Free Software +/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/// +/////////////////////////////////////////////////////////////////////////////// +#ifndef __OgreOpcodeCapsule_h__ +#define __OgreOpcodeCapsule_h__ + +#include "OgreOpcodeLine.h" + +namespace OgreOpcode +{ + namespace Details + { + /// Represents a Capsule defined by 2 endpoints and a radius + /// TODO: add methods to this capsule. + class _OgreOpcode_Export Capsule + { + public: + + /** Default constructor: degenerated as an unitary sphere at origin + */ + Capsule():start(),end(),radius(1.0) + { + } + + /** Copy-constructor + */ + Capsule(const Capsule& c):start(c.start),end(c.end),radius(c.radius) + { + } + + /** Complete constructor + */ + Capsule(const Ogre::Vector3& s, const Ogre::Vector3& e, Ogre::Real r ):start(s),end(e),radius(r) + { + } + + /** Complete, headache constructor + */ + Capsule( Ogre::Real sx, Ogre::Real sy, Ogre::Real sz, + Ogre::Real ex, Ogre::Real ey, Ogre::Real ez, + Ogre::Real r + ):start(sx,sy,sz),end(ex,ey,ez),radius(r) + { + } + + /// Gets the length of this line segment + Ogre::Real length() const { return (start - end).length(); } + /// Gets the squared length of this line segment + Ogre::Real length2() const { return (start - end).squaredLength(); } + + /// Gets the surface area of this capsule + Ogre::Real area() const + { + return Ogre::Math::TWO_PI*radius*(2.0*radius + length() ); + } + + /// Gets the volume are this capsule + Ogre::Real volume() const + { + return Ogre::Math::PI*radius*radius*( 1.333333333333333*length() ); + } +// -------------------------------------------------------------------- +// intersection tests + + /** Does this capsule contain the given point? + */ + bool contains( const Ogre::Vector3& point ) const; + + /** Tests intersection between this capsule and the given Axis-Aligned + * Bounding Box + */ + bool intersects( const Aabb& aabb ) const; + + /** Tests intersection between this capsule and the given sphere + */ + bool intersects( const sphere& s ) const; + + /** Tests intersection between this capsule and the given Oriented Bounding Box + */ + bool intersects( const OrientedBox& obb ) const; + + /** Tests intersection between this capsule and the given one + */ + bool intersects( const Capsule& cap ) const; + + + /** The start point of this capsule. + */ + Ogre::Vector3 start; + /** The end point of this capsule. + */ + Ogre::Vector3 end; + /** The radius of this capsule. + */ + Ogre::Real radius; + }; + } +} + +#endif Added: branches/ogsector/externals/ogreopcode/include/OgreCollisionContext.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/OgreCollisionContext.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/OgreCollisionContext.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,203 @@ +/////////////////////////////////////////////////////////////////////////////// +/// @file OgreCollisionContext.h +/// @brief Contains the definition of the CollisionContext class. +/// +/// @author The OgreOpcode Team +/// +/////////////////////////////////////////////////////////////////////////////// +/// +/// This file is part of OgreOpcode. +/// +/// A lot of the code is based on the Nebula Opcode Collision module, see docs/Nebula_license.txt +/// +/// OgreOpcode is free software; you can redistribute it and/or +/// modify it under the terms of the GNU Lesser General Public +/// License as published by the Free Software Foundation; either +/// version 2.1 of the License, or (at your option) any later version. +/// +/// OgreOpcode 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 +/// Lesser General Public License for more details. +/// +/// You should have received a copy of the GNU Lesser General Public +/// License along with OgreOpcode; if not, write to the Free Software +/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/// +/////////////////////////////////////////////////////////////////////////////// +#ifndef __OgreCollisionContext_h__ +#define __OgreCollisionContext_h__ + +#include <Ogre.h> +#include "OgreNodes.h" +#include "OgreCollisionReporter.h" +#include "OgreCollisionTypes.h" +#include "OgreOpcodeDebugObject.h" +//#include "BP_Scene.h" +#include <Opcode.h> + +namespace OgreOpcode +{ + class CollisionObject; + + namespace Details + { + typedef int CollisionClass; + + class BP_Scene; + + class Encounter + { + public: + CollisionObject* obj1; + CollisionObject* obj2; + + Encounter(CollisionObject* o1, CollisionObject* o2) + { + obj1 = o2; + obj2 = o1; + } + }; + + inline bool operator<(const Encounter& x, const Encounter& y) + { + return x.obj1 < y.obj1 || (!(y.obj1 < x.obj1) && x.obj2 < y.obj2); + } + + }; + + /// Defines a collision space. + /// A CollisionContext creates a collision context, defined by + /// a collection of CollisionObject%s which can collide with + /// each other. CollisionObject%s can be added and removed + /// from the context at any time. + // class _OgreOpcode_Export CollisionContext : public nNode + class _OgreOpcode_Export CollisionContext + { + public: + /// constructor + CollisionContext(const Ogre::String& name); + /// destructor + virtual ~CollisionContext(); + /// create a collide object + virtual CollisionObject *createObject(const Ogre::String& name); + /// kills a collide object + virtual void destroyObject(CollisionObject *collObj); + /// add collide object to context + virtual void addObject(CollisionObject *collObj); + /// remove collide object from context + virtual void removeObject(CollisionObject *collObj); + /// compute contacts between collision objects in context + virtual int collide(Ogre::Real dt=1.0); + /// debug visualization of the collide context + virtual void visualize(bool doVisualize, bool doRadii, bool doContacts, bool doBBs, bool doShapes, bool doAABBs); + /// get the collide reports for the collisions computed inside collide() + virtual int getCollisions(CollisionObject *collObj, CollisionPair **&cpPtr); + /// get reporter for for last collide() call. + const CollisionReporter& getCollisionReport(); + /// get reporter for for last Check...() call. + const CollisionReporter& getCheckReport(); + /// get number of collisions for last collide call. + const int getNumCollisions(); + /// do a "moving sphere" check against collide object radii in the context + virtual int sweptSphereCheck(const Ogre::Vector3& position, const Ogre::Vector3& translateVector, Ogre::Real radius, Details::CollisionClass collClass, CollisionPair **& cpPtr); + /// do a line-model check + virtual int rayCheck(const Ogre::Ray line, const Ogre::Real dist, CollisionType collType, Details::CollisionClass collClass, CollisionPair**& cpPtr); + /// do a sphere-model check + virtual int sphereCheck(const Ogre::Sphere& ball, CollisionType collType, Details::CollisionClass collClass, CollisionPair**& cpPtr); + /// reset position and timestamp of all objects + void reset(); + /// + void update(Ogre::Real dt=1.0); + + Details::BP_Scene* getBroadPhase() { return mBroadPhase; }; + /// + + virtual const Ogre::String& getName() { return mName; }; + + /// + virtual CollisionObject* getAttachedObject(Ogre::String name); + + /// + virtual const std::vector<CollisionObject*> getAttachedObjects() + { + return attached_list; + }; + + /// + virtual const std::list<CollisionObject*>& getPotentialColliders(const CollisionObject* collidee); + + /// + virtual const std::vector<CollisionObject*> getOwnedObjects() + { + return owned_list; + }; + + /// + virtual const int getAttachedObjectCount() + { + return static_cast< int >( attached_list.size() ); + } + + /// + virtual const int getOwnedObjectCount() + { + return static_cast< int >( owned_list.size() ); + } + + /// + virtual void setRayCulling(bool rayCulling = true) + { + mRayCulling = rayCulling; + } + + Details::OgreOpcodeDebugger* getVisualDebugger() + { + return mVisualDebugger; + } + + private: + + friend class CollisionObject; ///< + + static const int max_aabbs = 256; ///< + static const int maxnum_collisions = 4096; ///< + + CollisionReporter collideReportHandler; ///< collide reports for collide() + CollisionReporter checkReportHandler; ///< collide reports for Check() functions + + IceMaths::AABB* aabb_array[max_aabbs]; ///< + typedef std::multimap<int,CollisionObject*> CollObjAABBPairs;///< + typedef CollObjAABBPairs::const_iterator CollObjAABBPair_Iterator;///< + CollObjAABBPairs collAABB_pairs; ///< + Details::BP_Scene* mBroadPhase; ///< + typedef std::vector<CollisionObject*>::iterator rw_attached_list_iterator; ///< + typedef std::vector<CollisionObject*>::iterator rw_owned_list_iterator; ///< + typedef std::set<Details::Encounter> ProxList; + ProxList proxList; + + static void addPair(void *client_data, void *object1, void *object2) + { + ((ProxList *)client_data)->insert(Details::Encounter((CollisionObject*)object1, (CollisionObject*)object2)); + } + + static void removePair(void *client_data, void *object1, void *object2) + { + ((ProxList *)client_data)->erase(Details::Encounter((CollisionObject*)object1, (CollisionObject*)object2)); + } + + protected: + std::vector<CollisionObject*> owned_list; ///< list of CollisionObject%s created by this context + typedef std::vector<CollisionObject*>::const_iterator owned_list_iterator; ///< + std::vector<CollisionObject*> attached_list; ///< the list of objects currently attached to the context + typedef std::vector<CollisionObject*>::const_iterator attached_list_iterator; ///< + int unique_id; ///< + Ogre::String mName; ///< + bool mRayCulling; ///< + bool mIsSAPDirty; ///< + std::list<CollisionInfo> mRecentContactList; ///< + Details::OgreOpcodeDebugger* mVisualDebugger; ///< + }; +} + +#endif // __OgreCollisionContext_h__ Added: branches/ogsector/externals/ogreopcode/include/OgreCollisionManager.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/OgreCollisionManager.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/OgreCollisionManager.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,207 @@ +/////////////////////////////////////////////////////////////////////////////// +/// @file OgreCollisionManager.h +/// @brief Collision Manager +/// +/// @author The OgreOpcode Team +/// +/////////////////////////////////////////////////////////////////////////////// +/// +/// This file is part of OgreOpcode. +/// +/// A lot of the code is based on the Nebula Opcode Collision module, see docs/Nebula_license.txt +/// +/// OgreOpcode is free software; you can redistribute it and/or +/// modify it under the terms of the GNU Lesser General Public +/// License as published by the Free Software Foundation; either +/// version 2.1 of the License, or (at your option) any later version. +/// +/// OgreOpcode 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 +/// Lesser General Public License for more details. +/// +/// You should have received a copy of the GNU Lesser General Public +/// License along with OgreOpcode; if not, write to the Free Software +/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/// +/////////////////////////////////////////////////////////////////////////////// +#ifndef __OgreCollisionManager_h__ +#define __OgreCollisionManager_h__ + +#include "OgreOpcodeExports.h" +#include <Ogre.h> +#include "OgreCollisionTypes.h" +#include "OgreNodes.h" +#include "OgreCollisionContext.h" +#include "Opcode.h" +#include "IOgreCollisionShape.h" + +#include <list> +#include <map> + +/// Main %OgreOpcode namespace +namespace OgreOpcode +{ + namespace Details + { + typedef int CollisionClass; + }; + + /// Shape types + enum ShapeType + { + SHAPETYPE_ENTITY = 0, ///< entity based shape + SHAPETYPE_MESH = 1, ///< mesh based shape + SHAPETYPE_PTR = 2, ///< raw ptr based shape + SHAPETYPE_BOX = 3, ///< box shape + SHAPETYPE_SPHERE = 4, ///< sphere shape + SHAPETYPE_CAPSULE = 5, ///< capsule shape + SHAPETYPE_TERRAIN = 6 ///< terrain shape + }; + + class MeshCollisionShape; + class EntityCollisionShape; + class BoxCollisionShape; + class SphereMeshCollisionShape; + class PtrCollisionShape; + class TerrainCollisionShape; + + /// Collision manager. + /// The CollisionManager object serves as factory object of the + /// different classes of the collision system, namely + /// CollisionContext and ICollisionShape. A CollisionContext + /// serves as factory for CollisionObject%s. + class _OgreOpcode_Export CollisionManager : public Ogre::Singleton<CollisionManager> + { + //friend class EntityCollisionShape; + public: + ///TODO: Put these back into the private section!! + Opcode::AABBTreeCollider opcTreeCollider; ///< + Opcode::RayCollider opcRayCollider; ///< + Opcode::SphereCollider opcSphereCollider; ///< + Opcode::PlanesCollider opcPlanesCollider; ///< + Opcode::LSSCollider opcSweptSphereCollider; ///< + Opcode::BVTCache opcTreeCache; ///< + Opcode::CollisionFaces opcFaceCache; ///< + Opcode::SphereCache opcSphereCache; ///< + Opcode::PlanesCache opcPlanesCache; ///< + Opcode::LSSCache opcSweptSphereCache; ///< + + CollisionManager(Ogre::SceneManager *); + virtual ~CollisionManager(); + + static CollisionManager& getSingleton(void); + static CollisionManager* getSingletonPtr(void); + + /// + CollisionContext *createContext(const Ogre::String&); + /// + void destroyContext(CollisionContext *); + + /// + MeshCollisionShape* createMeshCollisionShape(const Ogre::String&); + /// + EntityCollisionShape* createEntityCollisionShape(const Ogre::String&); + /// + BoxCollisionShape* createBoxCollisionShape(const Ogre::String&); + /// + SphereMeshCollisionShape* createSphereMeshCollisionShape(const Ogre::String&); + /// + PtrCollisionShape* createPtrCollisionShape(const Ogre::String&); + /// + TerrainCollisionShape* createTerrainCollisionShape(const Ogre::String&); + + /// + void destroyShape(ICollisionShape *); + + /// + void attachContext(CollisionContext *); + /// + void attachShape(ICollisionShape *); + /// + void detachContext(CollisionContext *); + /// + void detachShape(ICollisionShape *); + + /// + CollisionContext *getDefaultContext(void); + /// + CollisionContext *getContext(const Ogre::String& name); + /// + Ogre::SceneManager *getSceneManager(void); + /// + void setSceneManager(Ogre::SceneManager* newSceneMgr) + { + mSceneMgr = newSceneMgr; + } + + /// + const int getShapeCount() + { + return static_cast< int >( shape_list.size() ); + } + + // define collision classes and collision check relationships + /// + void addCollClass(const Ogre::String &); + /// + void addCollType(const Ogre::String&, const Ogre::String&, CollisionType); + /// + Details::CollisionClass queryCollClass(const Ogre::String&); + /// + CollisionType queryCollType(const Ogre::String&, const Ogre::String&); + /// + CollisionType queryCollType(Details::CollisionClass cc1, Details::CollisionClass cc2); + /// + Ogre::String getCollisionTypeEnum(CollisionType colltype); + + protected: + /// + ICollisionShape *createShape(const Ogre::String&, const ShapeType shpType = SHAPETYPE_MESH); + + int unique_id; ///< + typedef std::map<Ogre::String,CollisionContext*> ContextList;///< + typedef ContextList::const_iterator ContextIterator;///< + ContextList context_list;///< + + typedef HashMap<Ogre::String,ICollisionShape*> ShapeList;///< + // TODO: Do I own these shapes? Or do I pass the responsibility on? + ShapeList shape_list;///< + typedef ShapeList::const_iterator ShapeIterator;///< + + typedef std::map<Ogre::String, Details::CollisionClass> CollClassList;///< + CollClassList collclass_list;///< + typedef CollClassList::const_iterator CollClassIterator;///< + typedef std::map<int, CollisionType> CollTypeList;///< + CollTypeList colltype_table;///< + typedef CollTypeList::const_iterator CollTypeIterator;///< + + CollisionContext *default_context;///< + + Ogre::SceneManager *mSceneMgr;///< + /// + Ogre::String getResourceID(const Ogre::String&); + private: + + // Merge the 2 object id's into 1 32 bit id, + // order them, so that any combination of 2 id's + // results in the same merged id. Return true + // a swap happened (because other attributes + // may have to be swapped as well). + bool get_merged_id(int id1, int id2, int& mrg) + { + if (id1 > id2) + { + mrg = ((id2 & 0xffff)<<16) | (id1 & 0xffff); + return true; + } else + { + mrg = ((id1 & 0xffff)<<16) | (id2 & 0xffff); + return false; + } + }; + }; + +}; // namespace OgreOpcode + +#endif // __OgreCollisionManager_h__ Added: branches/ogsector/externals/ogreopcode/include/OgreCollisionObject.h =================================================================== --- branches/ogsector/externals/ogreopcode/include/OgreCollisionObject.h (rev 0) +++ branches/ogsector/externals/ogreopcode/include/OgreCollisionObject.h 2007-03-17 20:08:40 UTC (rev 329) @@ -0,0 +1,385 @@ +/////////////////////////////////////////////////////////////////////////////// +/// @file OgreCollisionObject.h +/// @brief <TODO: insert file description here> +/// +/// @author The OgreOpcode Team +/// +/////////////////////////////////////////////////////////////////////////////// +/// +/// This file is part of OgreOpcode. +/// +/// A lot of the code is based on the Nebula Opcode Collision module, see docs/Nebula_license.txt +/// +/// OgreOpcode is free software; you can redistribute it and/or +/// modify it under the terms of the GNU Lesser General Public +/// License as published by the Free Software Foundation; either +/// version 2.1 of the License, or (at your option) any later version. +/// +/// OgreOpcode 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 +/// Lesser General Public License for more details. +/// +/// You should have received a copy of the GNU Lesser General Public +/// License along with OgreOpcode; if not, write to the Free Software +/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/// +/////////////////////////////////////////////////////////////////////////////// +#ifndef __OgreCollisionObject_h__ +#define __OgreCollisionObject_h__ + +#include <Ogre.h> +#include "OgreNodes.h" +#include "OgreCollisionManager.h" +#include "OgreCollisionContext.h" +#include "OgreOpcodeMath.h" + +namespace OgreOpcode +{ + class CollisionContext; + class CollisionPair; + + namespace Details + { + class BP_Proxy; + } + /// Collision system object. + /// CollisionObject is an actual collision system object which can + /// be positioned and oriented in space. It points to an + /// EntityCollisionShape which describes the actual shape of the + /// object. + /// CollisionObject%s are kept in sorted list (one for each dimension) + /// by the CollisionContext they belong to. + class _OgreOpcode_Export CollisionObject : public Ogre::Node::Listener + { + friend class CollisionContext; + + public: + CollisionObject(const Ogre::String& name) + : mContext(0), + mName(name), + mRadius(0.0f), + //old_center_offset(0,0,0), + //new_center_offset(0,0,0), + new_pos(0,0,0), + old_pos(0,0,0), + mShape(0), + coll_class(0), + m_tdelta(-1.0), + client_data(0), + is_attached(false), + num_colls(0), + old_matrix(Ogre::Matrix4::IDENTITY), + new_matrix(Ogre::Matrix4::IDENTITY), + mNeedsUpdating(true), + mForcedUpdate(true), + mProxy(0) + { + mRecentContactList.clear(); + }; + + virtual ~CollisionObject() + { + //remove_broadphase(); + getShape()->getParentSceneNode()->setListener(0); + } + + void setForcedUpdate(bool newupdate = true) + { + mForcedUpdate = newupdate; + }; + + /// <TODO: insert function description here> + /// @param [in, out] c CollisionContext * <TODO: insert parameter description here> + /// @return void <TODO: insert return value description here> + void setContext(CollisionContext *c) + { + // c may be 0!!! + mContext = c; + }; + + /// <TODO: insert function description here> + /// @return CollisionContext * <TODO: insert return value description here> + CollisionContext *getContext(void) + { + return mContext; + }; + + /// <TODO: insert function description here> + /// @param [in] i int <TODO: insert parameter description here> + /// @return void <TODO: insert return value description here> + void setId(int i) + { + id = i; + }; + + /// <TODO: insert function description here> + /// @return int <TODO: insert return value description here> + int getId(void) + { + return id; + }; + + Ogre::String getName() const + { + return mName; + }; + + /// <TODO: insert function description here> + /// @param [in] b bool <TODO: insert parameter description here> + /// @return void <TODO: insert return value description here> + void setAttached(bool b) + { + is_attached = b; + }; + + /// <TODO: insert function description here> + /// @return bool <TODO: insert return value description here> + bool isAttached(void) + { + return is_attached; + }; + + /// <TODO: insert function description here> + /// @param [in] f float <TODO: insert parameter description here> + /// @return void <TODO: insert return value description here> + void setRadius(float f) + { + mRadius = f; + }; + + /// <TODO: insert function description here> + /// @return float <TODO: insert return value description here> + float getRadius(void) + { + return mRadius; + }; + + /// <TODO: insert function description here> + /// @param [in, out] s EntityCollisionShape * <TODO: insert parameter description here> + /// @return void <TODO: insert return value description here> + void setShape(ICollisionShape *s) + { + mShape = s; + if (s) + { + setRadius(s->getRadius()); + getShape()->getParentSceneNode()->setListener(this); + } + else + { + setRadius(0.0f); + } + }; + + /// <TODO: insert function description here> + /// @return EntityCollisionShape * <TODO: insert return value description here> + ICollisionShape *getShape(void) + { + return mShape; + }; + + /// <TODO: insert function description here> + /// @param [in] cc CollisionClass <TODO: insert parameter description here> + /// @return void + void setCollClass(Details::CollisionClass cc) + { + coll_class = cc; + }; + + /// <TODO: insert function description here> + /// @param [in] ccstr registered CollisionClass string + /// @return void + void setCollClass(const char *ccstr) + { + coll_class = CollisionManager::getSingletonPtr()->queryCollClass(ccstr); + }; + + /// <TODO: insert function description here> + /// @return CollisionClass <TODO: insert return value description here> + Details::CollisionClass getCollClass(void) + { + return coll_class; + }; + + /// <TODO: insert function description here> + /// @param [in, out] d void * <TODO: insert parameter description here> + /// @return void <TODO: insert return value description here> + void setClientData(void *d) + { + client_data = d; + }; + + /// <TODO: insert function description here> + /// @return void * <TODO: insert return value description here> + void *getClientData(void) + { + return client_data; + }; + + /// <TODO: insert function description here> + /// @return const Matrix4 & <TODO: insert return value description here> + const Ogre::Matrix4& getTransform(void) + { + new_matrix = getShape()->getFullTransform(); + //getShape()->getEntity()->getSubEntity(0)->getWorldTransforms(&new_matrix); + return new_matrix; + }; + + /// <TODO: insert function description here> + /// @return const Matrix4 & <TODO: insert return value description here> + const Ogre::Matrix4& getPrevTransform(void) + { + return old_matrix; + }; + + /// Return the 'time' between the current and previous transforms + /// @return Real The elapsed 'time' (actually just whatever the user + /// told us it was when calling update()). Negative if no + /// update()'s have been performed since the last reset() + Ogre::Real getTimeDelta(void) + { + return m_tdelta; + }; + + /// <TODO: insert function description here> + /// @return void <TODO: insert return value description here> + void clearCollisions(void) + ... [truncated message content] |
From: <spo...@us...> - 2007-03-19 01:18:26
|
Revision: 330 http://svn.sourceforge.net/opengate/?rev=330&view=rev Author: spom_spom Date: 2007-03-17 13:10:28 -0700 (Sat, 17 Mar 2007) Log Message: ----------- Removed Paths: ------------- branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so.13 branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so.13.1 branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so.0 branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so.0.3 Deleted: branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so =================================================================== --- branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so 2007-03-17 20:08:40 UTC (rev 329) +++ branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so 2007-03-17 20:10:28 UTC (rev 330) @@ -1 +0,0 @@ -link libOpcode.so.13 \ No newline at end of file Deleted: branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so.13 =================================================================== --- branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so.13 2007-03-17 20:08:40 UTC (rev 329) +++ branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so.13 2007-03-17 20:10:28 UTC (rev 330) @@ -1 +0,0 @@ -link libOpcode.so.13.1 \ No newline at end of file Deleted: branches/ogsector/externals/ogreopcode/opcode132/libOpcode.so.13.1 =================================================================== (Binary files differ) Deleted: branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so =================================================================== --- branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so 2007-03-17 20:08:40 UTC (rev 329) +++ branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so 2007-03-17 20:10:28 UTC (rev 330) @@ -1 +0,0 @@ -link libOgreOpcode.so.0 \ No newline at end of file Deleted: branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so.0 =================================================================== --- branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so.0 2007-03-17 20:08:40 UTC (rev 329) +++ branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so.0 2007-03-17 20:10:28 UTC (rev 330) @@ -1 +0,0 @@ -link libOgreOpcode.so.0.3 \ No newline at end of file Deleted: branches/ogsector/externals/ogreopcode/src/libOgreOpcode.so.0.3 =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |