/* * Collision-detection pseudo-tree class * * Class for performing several collision detection algorithms automatically * * Copyright (C) 2008 Alejandro Valenzuela Roca, * * This file is part of MotorJ, a free framework for videogame development. * * * * MotorJ 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 3 of the License, or * (at your option) any later version. * * MotorJ is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY 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 MotorJ. If not, see . * */ #ifndef COLTREE_CLASS_H #define COLTREE_CLASS_H #include "support.h" #include "data_structs.h" #include "collisions.h" //! Types of branches available to the Collision Tree enum MJCOLTREEBRANCHTYPE {COL_DIST, COL_SPH_SPH, COL_AABB_PT, COL_AAB_AAB, COL_OBB_OBB, COL_RAY_TR, COL_RAY_TRSTRIP, COL_PT_AACYL}; typedef struct { //! Type of branch MJCOLTREEBRANCHTYPE colType; //! The actual branch data void * argumentStructure; } mjColTreeBranch; typedef struct { float dist; vector3 * pt1; vector3 * pt0_pt1; } mjColTreeDistColBranch; typedef struct { float r0; float r1; vector3 * sphcen1; vector3 * sph0_sph1; } mjColTreeSphSphColBranch; typedef struct { vector3 * vaabb0; vector3 * vaabb1; } mjColTreeAABBPtColBranch; typedef struct { vector3 * vaabb00; vector3 * vaabb01; vector3 * vaabb10; vector3 * vaabb11; } mjColTreeAABBAABBColBranch; typedef struct { obb * obb0; obb * obb1; } mjColTreeOBBOBBColBranch; typedef struct { vector3 * ray_dir; triangle * tr; } mjColTreeRayTrColBranch; typedef struct { vector3 * ray_dir; triangle ** tr_strip; } mjColTreeRayTrStripColBranch; typedef struct { vector3 * cyl_base; float cyl_height; float cyl_radius; } mjColTreePtAACylColBranch; class mjColTree{ public: mjColTree(); ~mjColTree(); short CalcCollision (vector3 & pos, vector3 * correction); void AddColBranch(short expectedResult, MJCOLTREEBRANCHTYPE colType, void * argumentStructure); private: list_header clist; list_node * lnode; mjColTreeBranch * cbranch; }; #endif