1 /************************************************************************* 2 * D bindings for ODE * 3 * * 4 * C header port by Daniel "q66" Kolesa <quaker66@gmail.com> * 5 * * 6 * Open Dynamics Engine, Copyright (C) 2001-2003 Russell L. Smith. * 7 * All rights reserved. Email: russ@q12.org Web: www.q12.org * 8 * * 9 * This library is free software; you can redistribute it and/or * 10 * modify it under the terms of EITHER: * 11 * (1) The GNU Lesser General Public License as published by the Free * 12 * Software Foundation; either version 2.1 of the License, or (at * 13 * your option) any later version. The text of the GNU Lesser * 14 * General Public License is included with this library in the * 15 * file LICENSE.TXT. * 16 * (2) The BSD-style license that is included with this library in * 17 * the file LICENSE-BSD.TXT. * 18 * * 19 * This library is distributed in the hope that it will be useful, * 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * 22 * LICENSE.TXT and LICENSE-BSD.TXT for more details. * 23 * * 24 *************************************************************************/ 25 26 module deimos.ode.collision_space; 27 28 private import deimos.ode.common; 29 30 extern (C): 31 nothrow: 32 33 /** 34 * @brief User callback for geom-geom collision testing. 35 * 36 * @param data The user data object, as passed to dSpaceCollide. 37 * @param o1 The first geom being tested. 38 * @param o2 The second geom being test. 39 * 40 * @remarks The callback function can call dCollide on o1 and o2 to generate 41 * contact points between each pair. Then these contact points may be added 42 * to the simulation as contact joints. The user's callback function can of 43 * course chose not to call dCollide for any pair, e.g. if the user decides 44 * that those pairs should not interact. 45 * 46 * @ingroup collide 47 */ 48 alias void function(void* data, dGeomID o1, dGeomID o2) dNearCallback; 49 50 dSpaceID dSimpleSpaceCreate(dSpaceID space); 51 dSpaceID dHashSpaceCreate(dSpaceID space); 52 dSpaceID dQuadTreeSpaceCreate(dSpaceID space, in dVector3 Center, in dVector3 Extents, int Depth); 53 54 55 // SAP 56 // Order XZY or ZXY usually works best, if your Y is up. 57 enum 58 { 59 dSAP_AXES_XYZ = ((0)|(1<<2)|(2<<4)), 60 dSAP_AXES_XZY = ((0)|(2<<2)|(1<<4)), 61 dSAP_AXES_YXZ = ((1)|(0<<2)|(2<<4)), 62 dSAP_AXES_YZX = ((1)|(2<<2)|(0<<4)), 63 dSAP_AXES_ZXY = ((2)|(0<<2)|(1<<4)), 64 dSAP_AXES_ZYX = ((2)|(1<<2)|(0<<4)) 65 } 66 67 dSpaceID dSweepAndPruneSpaceCreate(dSpaceID space, int axisorder); 68 69 void dSpaceDestroy(dSpaceID); 70 71 void dHashSpaceSetLevels(dSpaceID space, int minlevel, int maxlevel); 72 void dHashSpaceGetLevels(dSpaceID space, int* minlevel, int* maxlevel); 73 74 void dSpaceSetCleanup(dSpaceID space, int mode); 75 int dSpaceGetCleanup(dSpaceID space); 76 77 /** 78 * @brief Sets sublevel value for a space. 79 * 80 * Sublevel affects how the space is handled in dSpaceCollide2 when it is collided 81 * with another space. If sublevels of both spaces match, the function iterates 82 * geometries of both spaces and collides them with each other. If sublevel of one 83 * space is greater than the sublevel of another one, only the geometries of the 84 * space with greater sublevel are iterated, another space is passed into 85 * collision callback as a geometry itself. By default all the spaces are assigned 86 * zero sublevel. 87 * 88 * @note 89 * The space sublevel @e IS @e NOT automatically updated when one space is inserted 90 * into another or removed from one. It is a client's responsibility to update sublevel 91 * value if necessary. 92 * 93 * @param space the space to modify 94 * @param sublevel the sublevel value to be assigned 95 * @ingroup collide 96 * @see dSpaceGetSublevel 97 * @see dSpaceCollide2 98 */ 99 void dSpaceSetSublevel(dSpaceID space, int sublevel); 100 101 /** 102 * @brief Gets sublevel value of a space. 103 * 104 * Sublevel affects how the space is handled in dSpaceCollide2 when it is collided 105 * with another space. See @c dSpaceSetSublevel for more details. 106 * 107 * @param space the space to query 108 * @returns the sublevel value of the space 109 * @ingroup collide 110 * @see dSpaceSetSublevel 111 * @see dSpaceCollide2 112 */ 113 int dSpaceGetSublevel(dSpaceID space); 114 115 116 /** 117 * @brief Sets manual cleanup flag for a space. 118 * 119 * Manual cleanup flag marks a space as eligible for manual thread data cleanup. 120 * This function should be called for every space object right after creation in 121 * case if ODE has been initialized with @c dInitFlagManualThreadCleanup flag. 122 * 123 * Failure to set manual cleanup flag for a space may lead to some resources 124 * remaining leaked until the program exit. 125 * 126 * @param space the space to modify 127 * @param mode 1 for manual cleanup mode and 0 for default cleanup mode 128 * @ingroup collide 129 * @see dSpaceGetManualCleanup 130 * @see dInitODE2 131 */ 132 void dSpaceSetManualCleanup(dSpaceID space, int mode); 133 134 /** 135 * @brief Get manual cleanup flag of a space. 136 * 137 * Manual cleanup flag marks a space space as eligible for manual thread data cleanup. 138 * See @c dSpaceSetManualCleanup for more details. 139 * 140 * @param space the space to query 141 * @returns 1 for manual cleanup mode and 0 for default cleanup mode of the space 142 * @ingroup collide 143 * @see dSpaceSetManualCleanup 144 * @see dInitODE2 145 */ 146 int dSpaceGetManualCleanup(dSpaceID space); 147 148 void dSpaceAdd(dSpaceID, dGeomID); 149 void dSpaceRemove(dSpaceID, dGeomID); 150 int dSpaceQuery(dSpaceID, dGeomID); 151 void dSpaceClean(dSpaceID); 152 int dSpaceGetNumGeoms(dSpaceID); 153 dGeomID dSpaceGetGeom(dSpaceID, int i); 154 155 /** 156 * @brief Given a space, this returns its class. 157 * 158 * The ODE classes are: 159 * @li dSimpleSpaceClass 160 * @li dHashSpaceClass 161 * @li dSweepAndPruneSpaceClass 162 * @li dQuadTreeSpaceClass 163 * @li dFirstUserClass 164 * @li dLastUserClass 165 * 166 * The class id not defined by the user should be between 167 * dFirstSpaceClass and dLastSpaceClass. 168 * 169 * User-defined class will return their own number. 170 * 171 * @param space the space to query 172 * @returns The space class ID. 173 * @ingroup collide 174 */ 175 int dSpaceGetClass(dSpaceID space);