From fca74b0bf0a0833f5701e9c0de7b3bc15b2233dd Mon Sep 17 00:00:00 2001 From: dan miller Date: Fri, 19 Oct 2007 05:20:07 +0000 Subject: dont ask --- .../GIMPACT/include/GIMPACT/gim_boxpruning.h | 323 ---- .../ode-0.9/GIMPACT/include/GIMPACT/gim_contact.h | 115 -- .../ode-0.9/GIMPACT/include/GIMPACT/gim_geometry.h | 1872 -------------------- .../ode-0.9/GIMPACT/include/GIMPACT/gim_math.h | 147 -- .../ode-0.9/GIMPACT/include/GIMPACT/gim_memory.h | 1040 ----------- .../GIMPACT/include/GIMPACT/gim_radixsort.h | 258 --- .../include/GIMPACT/gim_tri_capsule_collision.h | 111 -- .../GIMPACT/include/GIMPACT/gim_tri_collision.h | 253 --- .../include/GIMPACT/gim_tri_sphere_collision.h | 51 - .../ode-0.9/GIMPACT/include/GIMPACT/gim_trimesh.h | 539 ------ .../ode-0.9/GIMPACT/include/GIMPACT/gimpact.h | 45 - 11 files changed, 4754 deletions(-) delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_boxpruning.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_contact.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_geometry.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_math.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_memory.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_radixsort.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_capsule_collision.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_collision.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_sphere_collision.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_trimesh.h delete mode 100644 libraries/ode-0.9/GIMPACT/include/GIMPACT/gimpact.h (limited to 'libraries/ode-0.9/GIMPACT/include') diff --git a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_boxpruning.h b/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_boxpruning.h deleted file mode 100644 index 68b68d0..0000000 --- a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_boxpruning.h +++ /dev/null @@ -1,323 +0,0 @@ -#ifndef GIM_BOXPRUNING_H_INCLUDED -#define GIM_BOXPRUNING_H_INCLUDED - -/*! \file gim_boxpruning.h -\author Francisco León -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) 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. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - - 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 files - GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -#include "GIMPACT/gim_radixsort.h" -#include "GIMPACT/gim_geometry.h" - -/*! \defgroup BOX_PRUNNING - -\brief -Tools for find overlapping objects on a scenary. These functions sort boxes for faster collisioin queries, using radix sort or quick sort as convenience. See \ref SORTING . - -*/ -//! @{ -//! Overlapping pair -struct GIM_PAIR -{ - GUINT m_index1; - GUINT m_index2; -}; -//typedef struct _GIM_PAIR GIM_PAIR; - -//! Box container -struct GIM_AABB_SET -{ - GUINT m_count; - aabb3f m_global_bound;//!< Global calculated bound of all boxes - aabb3f * m_boxes; - GUINT * m_maxcoords;//!m_sorted_mincoords == 0, then it allocs the sorted coordinates -*/ -void gim_aabbset_sort(GIM_AABB_SET * aabbset, char calc_global_bound); - -//! log(N) Complete box pruning. Returns a list of overlapping pairs of boxes, each box of the pair belongs to the same set. -/*! -\pre aabbset must be allocated and sorted, the boxes must be already set. -\param aabbset Must be sorted. Global bound isn't required -\param collision_pairs Array of GIM_PAIR elements. Must be initialized before (Reserve size ~ 100) -*/ -void gim_aabbset_self_intersections_sorted(GIM_AABB_SET * aabbset, GDYNAMIC_ARRAY * collision_pairs); - -//! NxN Complete box pruning. Returns a list of overlapping pairs of boxes, each box of the pair belongs to the same set. -/*! -\pre aabbset must be allocated, the boxes must be already set. -\param aabbset Global bound isn't required. Doen't need to be sorted. -\param collision_pairs Array of GIM_PAIR elements. Must be initialized before (Reserve size ~ 100) -*/ -void gim_aabbset_self_intersections_brute_force(GIM_AABB_SET * aabbset, GDYNAMIC_ARRAY * collision_pairs); - -//! log(N) Bipartite box pruning. Returns a list of overlapping pairs of boxes, each box of the pair belongs to a different set. -/*! -\pre aabbset1 and aabbset2 must be allocated and sorted, the boxes must be already set. -\param aabbset1 Must be sorted, Global bound is required. -\param aabbset2 Must be sorted, Global bound is required. -\param collision_pairs Array of GIM_PAIR elements. Must be initialized before (Reserve size ~ 100) -*/ -void gim_aabbset_bipartite_intersections_sorted(GIM_AABB_SET * aabbset1, GIM_AABB_SET * aabbset2, GDYNAMIC_ARRAY * collision_pairs); - -//! NxM Bipartite box pruning. Returns a list of overlapping pairs of boxes, each box of the pair belongs to a different set. -/*! -\pre aabbset1 and aabbset2 must be allocated and sorted, the boxes must be already set. -\param aabbset1 Must be sorted, Global bound is required. -\param aabbset2 Must be sorted, Global bound is required. -\param collision_pairs Array of GIM_PAIR elements. Must be initialized before (Reserve size ~ 100) -*/ -void gim_aabbset_bipartite_intersections_brute_force(GIM_AABB_SET * aabbset1,GIM_AABB_SET * aabbset2, GDYNAMIC_ARRAY * collision_pairs); - - -/* - Brute-Force Vs Sorted pruning -Different approaches must be applied when colliding sets with different number of -elements. When sets have less of 100 boxes, is often better to apply force brute -approach instead of sorted methods, because at lowlevel bruteforce routines gives -better perormance and consumes less resources, due of their simplicity. -But when sets are larger, the complexiity of bruteforce increases exponencially. -In the case of large sets, sorted approach is applied. So GIMPACT has the following -strategies: - -On Sorting sets: -!) When sets have more of 140 boxes, the boxes are sorted by its coded min coord -and the global box is calculated. But when sets are smaller (less of 140 boxes), -Is convenient to apply brute force approach. - -*******************************************************************************/ - -//! Constant for apply approaches between brute force and sorted pruning on bipartite queries -#define GIM_MIN_SORTED_BIPARTITE_PRUNING_BOXES 600 -//! Constant for apply approaches between brute force and sorted pruning for box collision -#define GIM_MIN_SORTED_PRUNING_BOXES 140 - - -//Use these functions for general initialization - -//! Initalizes the set. Sort Boxes if needed. -/*! -\pre aabbset must be allocated. And the boxes must be already set. -\post If the set has less of GIM_MIN_SORTED_BIPARTITE_PRUNING_BOXES boxes, only calcs the global box, - else it Sorts the entire set( Only applicable for large sets) -*/ -void gim_aabbset_update(GIM_AABB_SET * aabbset); - -///Use these functions for general collision - -//! Complete box pruning. Returns a list of overlapping pairs of boxes, each box of the pair belongs to the same set. -/*! -This function sorts the set and then it calls to gim_aabbset_self_intersections_brute_force or gim_aabbset_self_intersections_sorted. This is an example of how to use this function: -\code -//Create contact list -GDYNAMIC_ARRAY collision_pairs; -GIM_CREATE_PAIR_SET(collision_pairs); -//Do collision -gim_aabbset_self_intersections(&aabbset,&collision_pairs); -if(collision_pairs.m_size==0) -{ - GIM_DYNARRAY_DESTROY(collision_pairs);// - return; //no collisioin -} - -//pair pointer -GIM_PAIR *pairs = GIM_DYNARRAY_POINTER(GIM_PAIR,collision_pairs); -GUINT i, ti1,ti2; -for (i=0;im_count >= GIM_MIN_SORTED_PRUNING_BOXES, then it calls to gim_aabbset_sort and then to gim_aabbset_self_intersections_sorted. Global box won't be calculated. -*/ -void gim_aabbset_self_intersections(GIM_AABB_SET * aabbset, GDYNAMIC_ARRAY * collision_pairs); - -//! Collides two sets. Returns a list of overlapping pairs of boxes, each box of the pair belongs to a different set. -/*! -\pre aabbset1 and aabbset2 must be allocated and updated. See gim_aabbset_update. -\param aabbset1 Must be updated. -\param aabbset2 Must be updated. -\param collision_pairs Array of GIM_PAIR elements. Must be initialized before (Reserve size ~ 100) -*/ -void gim_aabbset_bipartite_intersections(GIM_AABB_SET * aabbset1, GIM_AABB_SET * aabbset2, GDYNAMIC_ARRAY * collision_pairs); - -///Function for create Box collision result set - -#define GIM_CREATE_BOXQUERY_LIST(dynarray) GIM_DYNARRAY_CREATE(GUINT,dynarray,G_ARRAY_GROW_SIZE) - -//! Finds intersections between a box and a set. Return the colliding boxes of the set -/*! -\pre aabbset must be allocated and initialized. -\param test_aabb Box for collision query -\param aabbset Set of boxes .Global bound is required. -\param collided Array of GUINT elements, indices of boxes. Must be initialized before (Reserve size ~ 100) -*/ -void gim_aabbset_box_collision(aabb3f *test_aabb, GIM_AABB_SET * aabbset, GDYNAMIC_ARRAY * collided); - -//! Finds intersections between a box and a set. Return the colliding boxes of the set -/*! -\pre aabbset must be allocated and initialized. -\param vorigin Origin point of ray. -\param vdir Direction vector of ray. -\param tmax Max distance param for ray. -\param aabbset Set of boxes .Global bound is required. -\param collided Array of GUINT elements, indices of boxes. Must be initialized before (Reserve size ~ 100) -*/ -void gim_aabbset_ray_collision(vec3f vorigin,vec3f vdir, GREAL tmax, GIM_AABB_SET * aabbset, GDYNAMIC_ARRAY * collided); - - -/* -For sorting, each box corner must be discretized to a 32 bit integer. -For this, we take the x and z coordinates from the box corner (a vector vec3f) -Then convert the (x,z) pair to an integer. For convenience, we choose an error -constant for converting the coordinates (0.05). -*******************************************************************************/ - -/** - For fitting the coordinate to an integer, we need to constraint the range of its values. So each coord component (x, z) must lie between 0 and 65536. - 20 give us a 0.05 floating point error -*/ -#define ERROR_AABB 20.0f - -/** -An error of 0.05 allows to make coordinates up to 1638.0f and no less of -1638.0f. -So the maximum size of a room should be about 3276x3276 . Its dimensions must lie between [-1638,1638.0f] -*/ -#define MAX_AABB_SIZE 1638.0f - -//! Converts a vector coordinate to an integer for box sorting -/*! -\param vx X component -\param vz Z component -\param uint_key a GUINT -*/ -#define GIM_CONVERT_VEC3F_GUINT_XZ(vx,vz,uint_key)\ -{\ - GUINT _z = ((GUINT)(vz*ERROR_AABB))+32768;\ - uint_key = ((GUINT)(vx*ERROR_AABB))+32768;\ - uint_key = (uint_key<<16) + _z;\ -}\ - -//! Converts a vector coordinate to an integer for box sorting,rounding to the upper int -/*! -\param vx X component -\param vz Z component -\param uint_key a GUINT -*/ -#define GIM_CONVERT_VEC3F_GUINT_XZ_UPPER(vx,vz,uint_key)\ -{\ - GUINT _z = ((GUINT)ceilf(vz*ERROR_AABB))+32768;\ - uint_key = ((GUINT)ceilf(vx*ERROR_AABB))+32768;\ - uint_key = (uint_key<<16) + _z;\ -}\ - - -//! Converts a vector coordinate to an integer for box sorting. Secure clamped -/*! -\param vx X component -\param vz Z component -\param uint_key a GUINT -*/ -#define GIM_CONVERT_VEC3F_GUINT_XZ_CLAMPED(vx,vz,uint_key)\ -{\ - GREAL _cx = CLAMP(vx,-MAX_AABB_SIZE,MAX_AABB_SIZE);\ - GREAL _cz = CLAMP(vz,-MAX_AABB_SIZE,MAX_AABB_SIZE);\ - GUINT _z = ((GUINT)(_cz*ERROR_AABB))+32768;\ - uint_key = ((GUINT)(_cx*ERROR_AABB))+32768;\ - uint_key = (uint_key<<16) + _z;\ -}\ - -//! Converts a vector coordinate to an integer for box sorting. Secure clamped, rounded -/*! -\param vx X component -\param vz Z component -\param uint_key a GUINT -*/ -#define GIM_CONVERT_VEC3F_GUINT_XZ_UPPER_CLAMPED(vx,vz,uint_key)\ -{\ - GREAL _cx = CLAMP(vx,-MAX_AABB_SIZE,MAX_AABB_SIZE);\ - GREAL _cz = CLAMP(vz,-MAX_AABB_SIZE,MAX_AABB_SIZE);\ - GUINT _z = ((GUINT)ceilf(_cz*ERROR_AABB))+32768;\ - uint_key = ((GUINT)ceilf(_cx*ERROR_AABB))+32768;\ - uint_key = (uint_key<<16) + _z;\ -}\ - -//! @} - -#endif // GIM_BOXPRUNING_H_INCLUDED diff --git a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_contact.h b/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_contact.h deleted file mode 100644 index bad8f0f..0000000 --- a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_contact.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef GIM_CONTACT_H_INCLUDED -#define GIM_CONTACT_H_INCLUDED - -/*! \file gim_contact.h -\author Francisco León -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) 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. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - - 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 files - GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -#include "GIMPACT/gim_geometry.h" -#include "GIMPACT/gim_radixsort.h" - -/*! \defgroup CONTACTS -\brief -Functions for managing and sorting contacts resulting from a collision query. - - -*/ -//! @{ -/// Structure for collision results -struct GIM_CONTACT -{ - vec3f m_point; - vec3f m_normal; - GREAL m_depth;//Positive value indicates interpenetration - void * m_handle1; - void * m_handle2; - GUINT m_feature1;//Face number - GUINT m_feature2;//Face number -}; -//typedef struct _GIM_CONTACT GIM_CONTACT; - -#define CONTACT_DIFF_EPSILON 0.00001f - -#define GIM_CALC_KEY_CONTACT(pos,hash)\ -{\ - GINT _coords[] = {(GINT)(pos[0]*1000.0f+1.0f),(GINT)(pos[1]*1333.0f),(GINT)(pos[2]*2133.0f+3.0f)};\ - GUINT _hash=0;\ - GUINT *_uitmp = (GUINT *)(&_coords[0]);\ - _hash = *_uitmp;\ - _uitmp++;\ - _hash += (*_uitmp)<<4;\ - _uitmp++;\ - _hash += (*_uitmp)<<8;\ - hash = _hash;\ -}\ - -///Creates a contact list for queries -#define GIM_CREATE_CONTACT_LIST(contact_array) GIM_DYNARRAY_CREATE(GIM_CONTACT,contact_array,100) - -#define GIM_PUSH_CONTACT(contact_array, point, normal, deep,handle1, handle2, feat1, feat2)\ -{\ - GIM_DYNARRAY_PUSH_EMPTY(GIM_CONTACT,contact_array);\ - GIM_CONTACT * _last = GIM_DYNARRAY_POINTER_LAST(GIM_CONTACT,contact_array);\ - VEC_COPY(_last->m_point,point);\ - VEC_COPY(_last->m_normal,normal);\ - _last->m_depth = deep;\ - _last->m_handle1 = handle1;\ - _last->m_handle2 = handle2;\ - _last->m_feature1 = feat1;\ - _last->m_feature2 = feat2;\ -}\ - -///Receive pointer to contacts -#define GIM_COPY_CONTACTS(dest_contact, source_contact)\ -{\ - VEC_COPY(dest_contact->m_point,source_contact->m_point);\ - VEC_COPY(dest_contact->m_normal,source_contact->m_normal);\ - dest_contact->m_depth = source_contact->m_depth;\ - dest_contact->m_handle1 = source_contact->m_handle1;\ - dest_contact->m_handle2 = source_contact->m_handle2;\ - dest_contact->m_feature1 = source_contact->m_feature1;\ - dest_contact->m_feature2 = source_contact->m_feature2;\ -}\ - -//! Merges duplicate contacts with minimum depth criterion -void gim_merge_contacts(GDYNAMIC_ARRAY * source_contacts, - GDYNAMIC_ARRAY * dest_contacts); - - -//! Merges to an unique contact -void gim_merge_contacts_unique(GDYNAMIC_ARRAY * source_contacts, - GDYNAMIC_ARRAY * dest_contacts); - -//! @} -#endif // GIM_CONTACT_H_INCLUDED diff --git a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_geometry.h b/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_geometry.h deleted file mode 100644 index 6d89a94..0000000 --- a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_geometry.h +++ /dev/null @@ -1,1872 +0,0 @@ -#ifndef GIM_VECTOR_H_INCLUDED -#define GIM_VECTOR_H_INCLUDED - -/*! \file gim_geometry.h -\author Francisco León -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) 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. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - - 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 files - GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -#include "GIMPACT/gim_math.h" - -/*! \defgroup GEOMETRIC_TYPES -\brief -Basic types and constants for geometry -*/ -//! @{ - -//! Integer vector 2D -typedef GINT vec2i[2]; -//! Integer vector 3D -typedef GINT vec3i[3]; -//! Integer vector 4D -typedef GINT vec4i[4]; - -//! Float vector 2D -typedef GREAL vec2f[2]; -//! Float vector 3D -typedef GREAL vec3f[3]; -//! Float vector 4D -typedef GREAL vec4f[4]; - -//! Matrix 2D, row ordered -typedef GREAL mat2f[2][2]; -//! Matrix 3D, row ordered -typedef GREAL mat3f[3][3]; -//! Matrix 4D, row ordered -typedef GREAL mat4f[4][4]; - -//! Quaternion -typedef GREAL quatf[4]; - -//! Axis aligned box -struct aabb3f{ - GREAL minX; - GREAL maxX; - GREAL minY; - GREAL maxY; - GREAL minZ; - GREAL maxZ; -}; -//typedef struct _aabb3f aabb3f; -//! @} - - -/*! \defgroup VECTOR_OPERATIONS -Operations for vectors : vec2f,vec3f and vec4f -*/ -//! @{ - -//! Zero out a 2D vector -#define VEC_ZERO_2(a) \ -{ \ - (a)[0] = (a)[1] = 0.0f; \ -}\ - - -//! Zero out a 3D vector -#define VEC_ZERO(a) \ -{ \ - (a)[0] = (a)[1] = (a)[2] = 0.0f; \ -}\ - - -/// Zero out a 4D vector -#define VEC_ZERO_4(a) \ -{ \ - (a)[0] = (a)[1] = (a)[2] = (a)[3] = 0.0f; \ -}\ - - -/// Vector copy -#define VEC_COPY_2(b,a) \ -{ \ - (b)[0] = (a)[0]; \ - (b)[1] = (a)[1]; \ -}\ - - -/// Copy 3D vector -#define VEC_COPY(b,a) \ -{ \ - (b)[0] = (a)[0]; \ - (b)[1] = (a)[1]; \ - (b)[2] = (a)[2]; \ -}\ - - -/// Copy 4D vector -#define VEC_COPY_4(b,a) \ -{ \ - (b)[0] = (a)[0]; \ - (b)[1] = (a)[1]; \ - (b)[2] = (a)[2]; \ - (b)[3] = (a)[3]; \ -}\ - - -/// Vector difference -#define VEC_DIFF_2(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] - (v1)[0]; \ - (v21)[1] = (v2)[1] - (v1)[1]; \ -}\ - - -/// Vector difference -#define VEC_DIFF(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] - (v1)[0]; \ - (v21)[1] = (v2)[1] - (v1)[1]; \ - (v21)[2] = (v2)[2] - (v1)[2]; \ -}\ - - -/// Vector difference -#define VEC_DIFF_4(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] - (v1)[0]; \ - (v21)[1] = (v2)[1] - (v1)[1]; \ - (v21)[2] = (v2)[2] - (v1)[2]; \ - (v21)[3] = (v2)[3] - (v1)[3]; \ -}\ - - -/// Vector sum -#define VEC_SUM_2(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] + (v1)[0]; \ - (v21)[1] = (v2)[1] + (v1)[1]; \ -}\ - - -/// Vector sum -#define VEC_SUM(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] + (v1)[0]; \ - (v21)[1] = (v2)[1] + (v1)[1]; \ - (v21)[2] = (v2)[2] + (v1)[2]; \ -}\ - - -/// Vector sum -#define VEC_SUM_4(v21,v2,v1) \ -{ \ - (v21)[0] = (v2)[0] + (v1)[0]; \ - (v21)[1] = (v2)[1] + (v1)[1]; \ - (v21)[2] = (v2)[2] + (v1)[2]; \ - (v21)[3] = (v2)[3] + (v1)[3]; \ -}\ - - -/// scalar times vector -#define VEC_SCALE_2(c,a,b) \ -{ \ - (c)[0] = (a)*(b)[0]; \ - (c)[1] = (a)*(b)[1]; \ -}\ - - -/// scalar times vector -#define VEC_SCALE(c,a,b) \ -{ \ - (c)[0] = (a)*(b)[0]; \ - (c)[1] = (a)*(b)[1]; \ - (c)[2] = (a)*(b)[2]; \ -}\ - - -/// scalar times vector -#define VEC_SCALE_4(c,a,b) \ -{ \ - (c)[0] = (a)*(b)[0]; \ - (c)[1] = (a)*(b)[1]; \ - (c)[2] = (a)*(b)[2]; \ - (c)[3] = (a)*(b)[3]; \ -}\ - - -/// accumulate scaled vector -#define VEC_ACCUM_2(c,a,b) \ -{ \ - (c)[0] += (a)*(b)[0]; \ - (c)[1] += (a)*(b)[1]; \ -}\ - - -/// accumulate scaled vector -#define VEC_ACCUM(c,a,b) \ -{ \ - (c)[0] += (a)*(b)[0]; \ - (c)[1] += (a)*(b)[1]; \ - (c)[2] += (a)*(b)[2]; \ -}\ - - -/// accumulate scaled vector -#define VEC_ACCUM_4(c,a,b) \ -{ \ - (c)[0] += (a)*(b)[0]; \ - (c)[1] += (a)*(b)[1]; \ - (c)[2] += (a)*(b)[2]; \ - (c)[3] += (a)*(b)[3]; \ -}\ - - -/// Vector dot product -#define VEC_DOT_2(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1]) - - -/// Vector dot product -#define VEC_DOT(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2]) - -/// Vector dot product -#define VEC_DOT_4(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] + (a)[3]*(b)[3]) - -/// vector impact parameter (squared) -#define VEC_IMPACT_SQ(bsq,direction,position) {\ - GREAL _llel_ = VEC_DOT(direction, position);\ - bsq = VEC_DOT(position, position) - _llel_*_llel_;\ -}\ - - -/// vector impact parameter -#define VEC_IMPACT(bsq,direction,position) {\ - VEC_IMPACT_SQ(bsq,direction,position); \ - GIM_SQRT(bsq,bsq); \ -}\ - -/// Vector length -#define VEC_LENGTH_2(a,l)\ -{\ - GREAL _pp = VEC_DOT_2(a,a);\ - GIM_SQRT(_pp,l);\ -}\ - - -/// Vector length -#define VEC_LENGTH(a,l)\ -{\ - GREAL _pp = VEC_DOT(a,a);\ - GIM_SQRT(_pp,l);\ -}\ - - -/// Vector length -#define VEC_LENGTH_4(a,l)\ -{\ - GREAL _pp = VEC_DOT_4(a,a);\ - GIM_SQRT(_pp,l);\ -}\ - -/// Vector inv length -#define VEC_INV_LENGTH_2(a,l)\ -{\ - GREAL _pp = VEC_DOT_2(a,a);\ - GIM_INV_SQRT(_pp,l);\ -}\ - - -/// Vector inv length -#define VEC_INV_LENGTH(a,l)\ -{\ - GREAL _pp = VEC_DOT(a,a);\ - GIM_INV_SQRT(_pp,l);\ -}\ - - -/// Vector inv length -#define VEC_INV_LENGTH_4(a,l)\ -{\ - GREAL _pp = VEC_DOT_4(a,a);\ - GIM_INV_SQRT(_pp,l);\ -}\ - - - -/// distance between two points -#define VEC_DISTANCE(_len,_va,_vb) {\ - vec3f _tmp_; \ - VEC_DIFF(_tmp_, _vb, _va); \ - VEC_LENGTH(_tmp_,_len); \ -}\ - - -/// Vector length -#define VEC_CONJUGATE_LENGTH(a,l)\ -{\ - GREAL _pp = 1.0 - a[0]*a[0] - a[1]*a[1] - a[2]*a[2];\ - GIM_SQRT(_pp,l);\ -}\ - - -/// Vector length -#define VEC_NORMALIZE(a) { \ - GREAL len;\ - VEC_INV_LENGTH(a,len); \ - if(len -Last column is added as the position -*/ -#define MAT_DOT_VEC_3X4(p,m,v) \ -{ \ - p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]*v[2] + m[0][3]; \ - p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]*v[2] + m[1][3]; \ - p[2] = m[2][0]*v[0] + m[2][1]*v[1] + m[2][2]*v[2] + m[2][3]; \ -}\ - -/*! vector transpose times matrix */ -/*! p[j] = v[0]*m[0][j] + v[1]*m[1][j] + v[2]*m[2][j]; */ -#define VEC_DOT_MAT_3X3(p,v,m) \ -{ \ - p[0] = v[0]*m[0][0] + v[1]*m[1][0] + v[2]*m[2][0]; \ - p[1] = v[0]*m[0][1] + v[1]*m[1][1] + v[2]*m[2][1]; \ - p[2] = v[0]*m[0][2] + v[1]*m[1][2] + v[2]*m[2][2]; \ -}\ - - -/*! affine matrix times vector */ -/** The matrix is assumed to be an affine matrix, with last two - * entries representing a translation */ -#define MAT_DOT_VEC_2X3(p,m,v) \ -{ \ - p[0] = m[0][0]*v[0] + m[0][1]*v[1] + m[0][2]; \ - p[1] = m[1][0]*v[0] + m[1][1]*v[1] + m[1][2]; \ -}\ - - -/** inverse transpose of matrix times vector - * - * This macro computes inverse transpose of matrix m, - * and multiplies vector v into it, to yeild vector p - * - * DANGER !!! Do Not use this on normal vectors!!! - * It will leave normals the wrong length !!! - * See macro below for use on normals. - */ -#define INV_TRANSP_MAT_DOT_VEC_2X2(p,m,v) \ -{ \ - GREAL det; \ - \ - det = m[0][0]*m[1][1] - m[0][1]*m[1][0]; \ - p[0] = m[1][1]*v[0] - m[1][0]*v[1]; \ - p[1] = - m[0][1]*v[0] + m[0][0]*v[1]; \ - \ - /* if matrix not singular, and not orthonormal, then renormalize */ \ - if ((det!=1.0f) && (det != 0.0f)) { \ - det = 1.0f / det; \ - p[0] *= det; \ - p[1] *= det; \ - } \ -}\ - - -/** transform normal vector by inverse transpose of matrix - * and then renormalize the vector - * - * This macro computes inverse transpose of matrix m, - * and multiplies vector v into it, to yeild vector p - * Vector p is then normalized. - */ -#define NORM_XFORM_2X2(p,m,v) \ -{ \ - double len; \ - \ - /* do nothing if off-diagonals are zero and diagonals are \ - * equal */ \ - if ((m[0][1] != 0.0) || (m[1][0] != 0.0) || (m[0][0] != m[1][1])) { \ - p[0] = m[1][1]*v[0] - m[1][0]*v[1]; \ - p[1] = - m[0][1]*v[0] + m[0][0]*v[1]; \ - \ - len = p[0]*p[0] + p[1]*p[1]; \ - GIM_INV_SQRT(len,len); \ - p[0] *= len; \ - p[1] *= len; \ - } else { \ - VEC_COPY_2 (p, v); \ - } \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define OUTER_PRODUCT_2X2(m,v,t) \ -{ \ - m[0][0] = v[0] * t[0]; \ - m[0][1] = v[0] * t[1]; \ - \ - m[1][0] = v[1] * t[0]; \ - m[1][1] = v[1] * t[1]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define OUTER_PRODUCT_3X3(m,v,t) \ -{ \ - m[0][0] = v[0] * t[0]; \ - m[0][1] = v[0] * t[1]; \ - m[0][2] = v[0] * t[2]; \ - \ - m[1][0] = v[1] * t[0]; \ - m[1][1] = v[1] * t[1]; \ - m[1][2] = v[1] * t[2]; \ - \ - m[2][0] = v[2] * t[0]; \ - m[2][1] = v[2] * t[1]; \ - m[2][2] = v[2] * t[2]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define OUTER_PRODUCT_4X4(m,v,t) \ -{ \ - m[0][0] = v[0] * t[0]; \ - m[0][1] = v[0] * t[1]; \ - m[0][2] = v[0] * t[2]; \ - m[0][3] = v[0] * t[3]; \ - \ - m[1][0] = v[1] * t[0]; \ - m[1][1] = v[1] * t[1]; \ - m[1][2] = v[1] * t[2]; \ - m[1][3] = v[1] * t[3]; \ - \ - m[2][0] = v[2] * t[0]; \ - m[2][1] = v[2] * t[1]; \ - m[2][2] = v[2] * t[2]; \ - m[2][3] = v[2] * t[3]; \ - \ - m[3][0] = v[3] * t[0]; \ - m[3][1] = v[3] * t[1]; \ - m[3][2] = v[3] * t[2]; \ - m[3][3] = v[3] * t[3]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define ACCUM_OUTER_PRODUCT_2X2(m,v,t) \ -{ \ - m[0][0] += v[0] * t[0]; \ - m[0][1] += v[0] * t[1]; \ - \ - m[1][0] += v[1] * t[0]; \ - m[1][1] += v[1] * t[1]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define ACCUM_OUTER_PRODUCT_3X3(m,v,t) \ -{ \ - m[0][0] += v[0] * t[0]; \ - m[0][1] += v[0] * t[1]; \ - m[0][2] += v[0] * t[2]; \ - \ - m[1][0] += v[1] * t[0]; \ - m[1][1] += v[1] * t[1]; \ - m[1][2] += v[1] * t[2]; \ - \ - m[2][0] += v[2] * t[0]; \ - m[2][1] += v[2] * t[1]; \ - m[2][2] += v[2] * t[2]; \ -}\ - - -/** outer product of vector times vector transpose - * - * The outer product of vector v and vector transpose t yeilds - * dyadic matrix m. - */ -#define ACCUM_OUTER_PRODUCT_4X4(m,v,t) \ -{ \ - m[0][0] += v[0] * t[0]; \ - m[0][1] += v[0] * t[1]; \ - m[0][2] += v[0] * t[2]; \ - m[0][3] += v[0] * t[3]; \ - \ - m[1][0] += v[1] * t[0]; \ - m[1][1] += v[1] * t[1]; \ - m[1][2] += v[1] * t[2]; \ - m[1][3] += v[1] * t[3]; \ - \ - m[2][0] += v[2] * t[0]; \ - m[2][1] += v[2] * t[1]; \ - m[2][2] += v[2] * t[2]; \ - m[2][3] += v[2] * t[3]; \ - \ - m[3][0] += v[3] * t[0]; \ - m[3][1] += v[3] * t[1]; \ - m[3][2] += v[3] * t[2]; \ - m[3][3] += v[3] * t[3]; \ -}\ - - -/** determinant of matrix - * - * Computes determinant of matrix m, returning d - */ -#define DETERMINANT_2X2(d,m) \ -{ \ - d = m[0][0] * m[1][1] - m[0][1] * m[1][0]; \ -}\ - - -/** determinant of matrix - * - * Computes determinant of matrix m, returning d - */ -#define DETERMINANT_3X3(d,m) \ -{ \ - d = m[0][0] * (m[1][1]*m[2][2] - m[1][2] * m[2][1]); \ - d -= m[0][1] * (m[1][0]*m[2][2] - m[1][2] * m[2][0]); \ - d += m[0][2] * (m[1][0]*m[2][1] - m[1][1] * m[2][0]); \ -}\ - - -/** i,j,th cofactor of a 4x4 matrix - * - */ -#define COFACTOR_4X4_IJ(fac,m,i,j) \ -{ \ - int __ii[4], __jj[4], __k; \ - \ - for (__k=0; __k (aabb2).maxX ||\ - (aabb1).maxX < (aabb2).minX ||\ - (aabb1).minY > (aabb2).maxY ||\ - (aabb1).maxY < (aabb2).minY ||\ - (aabb1).minZ > (aabb2).maxZ ||\ - (aabb1).maxZ < (aabb2).minZ )\ - {\ - intersected = 0;\ - }\ -}\ - -#define AXIS_INTERSECT(min,max, a, d,tfirst, tlast,is_intersected) {\ - if(IS_ZERO(d))\ - {\ - is_intersected = !(a < min || a > max);\ - }\ - else\ - {\ - GREAL a0, a1;\ - a0 = (min - a) / (d);\ - a1 = (max - a) / (d);\ - if(a0 > a1) SWAP_NUMBERS(a0, a1);\ - tfirst = MAX(a0, tfirst);\ - tlast = MIN(a1, tlast);\ - if (tlast < tfirst)\ - {\ - is_intersected = 0;\ - }\ - else\ - {\ - is_intersected = 1;\ - }\ - }\ -}\ - -/*! \brief Finds the Ray intersection parameter. - -\param aabb Aligned box -\param vorigin A vec3f with the origin of the ray -\param vdir A vec3f with the direction of the ray -\param tparam Output parameter -\param tmax Max lenght of the ray -\param is_intersected 1 if the ray collides the box, else false - -*/ -#define BOX_INTERSECTS_RAY(aabb, vorigin, vdir, tparam, tmax,is_intersected) { \ - GREAL _tfirst = 0.0f, _tlast = tmax;\ - AXIS_INTERSECT(aabb.minX,aabb.maxX,vorigin[0], vdir[0], _tfirst, _tlast,is_intersected);\ - if(is_intersected)\ - {\ - AXIS_INTERSECT(aabb.minY,aabb.maxY,vorigin[1], vdir[1], _tfirst, _tlast,is_intersected);\ - }\ - if(is_intersected)\ - {\ - AXIS_INTERSECT(aabb.minZ,aabb.maxZ,vorigin[2], vdir[2], _tfirst, _tlast,is_intersected);\ - }\ - tparam = _tfirst;\ -}\ - -#define AABB_PROJECTION_INTERVAL(aabb,direction, vmin, vmax)\ -{\ - GREAL _center[] = {(aabb.minX + aabb.maxX)*0.5f, (aabb.minY + aabb.maxY)*0.5f, (aabb.minZ + aabb.maxZ)*0.5f};\ - \ - GREAL _extend[] = {aabb.maxX-_center[0],aabb.maxY-_center[1],aabb.maxZ-_center[2]};\ - GREAL _fOrigin = VEC_DOT(direction,_center);\ - GREAL _fMaximumExtent = _extend[0]*fabsf(direction[0]) + \ - _extend[1]*fabsf(direction[1]) + \ - _extend[2]*fabsf(direction[2]); \ -\ - vmin = _fOrigin - _fMaximumExtent; \ - vmax = _fOrigin + _fMaximumExtent; \ -}\ - -/*! -classify values: -
    -
  1. 0 : In back of plane -
  2. 1 : Spanning -
  3. 2 : In front of -
-*/ -#define PLANE_CLASSIFY_BOX(plane,aabb,classify)\ -{\ - GREAL _fmin,_fmax; \ - AABB_PROJECTION_INTERVAL(aabb,plane, _fmin, _fmax); \ - if(plane[3] >= _fmax) \ - { \ - classify = 0;/*In back of*/ \ - } \ - else \ - { \ - if(plane[3]+0.000001f>=_fmin) \ - { \ - classify = 1;/*Spanning*/ \ - } \ - else \ - { \ - classify = 2;/*In front of*/ \ - } \ - } \ -}\ -//! @} - -/*! \defgroup GEOMETRIC_OPERATIONS -*/ -//! @{ - - -#define PLANEDIREPSILON 0.0000001f -#define PARALELENORMALS 0.000001f - -#define TRIANGLE_NORMAL(v1,v2,v3,n){\ - vec3f _dif1,_dif2; \ - VEC_DIFF(_dif1,v2,v1); \ - VEC_DIFF(_dif2,v3,v1); \ - VEC_CROSS(n,_dif1,_dif2); \ - VEC_NORMALIZE(n); \ -}\ - -/// plane is a vec4f -#define TRIANGLE_PLANE(v1,v2,v3,plane) {\ - TRIANGLE_NORMAL(v1,v2,v3,plane);\ - plane[3] = VEC_DOT(v1,plane);\ -}\ - -/// Calc a plane from an edge an a normal. plane is a vec4f -#define EDGE_PLANE(e1,e2,n,plane) {\ - vec3f _dif; \ - VEC_DIFF(_dif,e2,e1); \ - VEC_CROSS(plane,_dif,n); \ - VEC_NORMALIZE(plane); \ - plane[3] = VEC_DOT(e1,plane);\ -}\ - -#define DISTANCE_PLANE_POINT(plane,point) (VEC_DOT(plane,point) - plane[3]) - -#define PROJECT_POINT_PLANE(point,plane,projected) {\ - GREAL _dis;\ - _dis = DISTANCE_PLANE_POINT(plane,point);\ - VEC_SCALE(projected,-_dis,plane);\ - VEC_SUM(projected,projected,point); \ -}\ - -#define POINT_IN_HULL(point,planes,plane_count,outside)\ -{\ - GREAL _dis;\ - outside = 0;\ - GUINT _i = 0;\ - do\ - {\ - _dis = DISTANCE_PLANE_POINT(planes[_i],point);\ - if(_dis>0.0f) outside = 1;\ - _i++;\ - }while(_i -
  • 0 : Segment in front of plane, s1 closest -
  • 1 : Segment in front of plane, s2 closest -
  • 2 : Segment in back of plane, s1 closest -
  • 3 : Segment in back of plane, s2 closest -
  • 4 : Segment collides plane, s1 in back -
  • 5 : Segment collides plane, s2 in back - -*/ -#define PLANE_CLIP_SEGMENT2(s1,s2,plane,clipped,intersection_type) \ -{\ - GREAL _dis1,_dis2;\ - _dis1 = DISTANCE_PLANE_POINT(plane,s1);\ - _dis2 = DISTANCE_PLANE_POINT(plane,s2);\ - if(_dis1 >-G_EPSILON && _dis2 >-G_EPSILON)\ - {\ - if(_dis1<_dis2) intersection_type = 0;\ - else intersection_type = 1;\ - }\ - else if(_dis1 _dis2) intersection_type = 2;\ - else intersection_type = 3; \ - }\ - else\ - {\ - if(_dis1<_dis2) intersection_type = 4;\ - else intersection_type = 5;\ - VEC_DIFF(clipped,s2,s1);\ - _dis2 = VEC_DOT(clipped,plane);\ - VEC_SCALE(clipped,-_dis1/_dis2,clipped);\ - VEC_SUM(clipped,clipped,s1); \ - }\ -}\ - -//! Confirms if the plane intersect the edge or not -/*! -clipped1 and clipped2 are the vertices behind the plane. -clipped1 is the closest - -intersection_type must have the following values -
      -
    • 0 : Segment in front of plane, s1 closest -
    • 1 : Segment in front of plane, s2 closest -
    • 2 : Segment in back of plane, s1 closest -
    • 3 : Segment in back of plane, s2 closest -
    • 4 : Segment collides plane, s1 in back -
    • 5 : Segment collides plane, s2 in back -
    -*/ -#define PLANE_CLIP_SEGMENT_CLOSEST(s1,s2,plane,clipped1,clipped2,intersection_type)\ -{\ - PLANE_CLIP_SEGMENT2(s1,s2,plane,clipped1,intersection_type);\ - if(intersection_type == 0)\ - {\ - VEC_COPY(clipped1,s1);\ - VEC_COPY(clipped2,s2);\ - }\ - else if(intersection_type == 1)\ - {\ - VEC_COPY(clipped1,s2);\ - VEC_COPY(clipped2,s1);\ - }\ - else if(intersection_type == 2)\ - {\ - VEC_COPY(clipped1,s1);\ - VEC_COPY(clipped2,s2);\ - }\ - else if(intersection_type == 3)\ - {\ - VEC_COPY(clipped1,s2);\ - VEC_COPY(clipped2,s1);\ - }\ - else if(intersection_type == 4)\ - { \ - VEC_COPY(clipped2,s1);\ - }\ - else if(intersection_type == 5)\ - { \ - VEC_COPY(clipped2,s2);\ - }\ -}\ - - -//! Finds the 2 smallest cartesian coordinates of a plane normal -#define PLANE_MINOR_AXES(plane, i0, i1)\ -{\ - GREAL A[] = {fabs(plane[0]),fabs(plane[1]),fabs(plane[2])};\ - if(A[0]>A[1])\ - {\ - if(A[0]>A[2])\ - {\ - i0=1; /* A[0] is greatest */ \ - i1=2;\ - }\ - else \ - {\ - i0=0; /* A[2] is greatest */ \ - i1=1; \ - }\ - }\ - else /* A[0]<=A[1] */ \ - {\ - if(A[2]>A[1]) \ - { \ - i0=0; /* A[2] is greatest */ \ - i1=1; \ - }\ - else \ - {\ - i0=0; /* A[1] is greatest */ \ - i1=2; \ - }\ - } \ -}\ - -//! Ray plane collision -#define RAY_PLANE_COLLISION(plane,vDir,vPoint,pout,tparam,does_intersect)\ -{\ - GREAL _dis,_dotdir; \ - _dotdir = VEC_DOT(plane,vDir);\ - if(_dotdir1.0f)\ - {\ - VEC_COPY(cp,e2);\ - }\ - else \ - {\ - VEC_SCALE(cp,_scalar,_n);\ - VEC_SUM(cp,cp,e1);\ - } \ -}\ - - -/*! \brief Finds the line params where these lines intersect. - -\param dir1 Direction of line 1 -\param point1 Point of line 1 -\param dir2 Direction of line 2 -\param point2 Point of line 2 -\param t1 Result Parameter for line 1 -\param t2 Result Parameter for line 2 -\param dointersect 0 if the lines won't intersect, else 1 - -*/ -#define LINE_INTERSECTION_PARAMS(dir1,point1, dir2, point2,t1,t2,dointersect) {\ - GREAL det;\ - GREAL e1e1 = VEC_DOT(dir1,dir1);\ - GREAL e1e2 = VEC_DOT(dir1,dir2);\ - GREAL e2e2 = VEC_DOT(dir2,dir2);\ - vec3f p1p2;\ - VEC_DIFF(p1p2,point1,point2);\ - GREAL p1p2e1 = VEC_DOT(p1p2,dir1);\ - GREAL p1p2e2 = VEC_DOT(p1p2,dir2);\ - det = e1e2*e1e2 - e1e1*e2e2;\ - if(IS_ZERO(det))\ - {\ - dointersect = 0;\ - }\ - else\ - {\ - t1 = (e1e2*p1p2e2 - e2e2*p1p2e1)/det;\ - t2 = (e1e1*p1p2e2 - e1e2*p1p2e1)/det;\ - dointersect = 1;\ - }\ -}\ - -//! Find closest points on segments -#define SEGMENT_COLLISION(vA1,vA2,vB1,vB2,vPointA,vPointB)\ -{\ - vec3f _AD,_BD,_N;\ - vec4f _M;\ - VEC_DIFF(_AD,vA2,vA1);\ - VEC_DIFF(_BD,vB2,vB1);\ - VEC_CROSS(_N,_AD,_BD);\ - VEC_CROSS(_M,_N,_BD);\ - _M[3] = VEC_DOT(_M,vB1);\ - float _tp; \ - LINE_PLANE_COLLISION(_M,_AD,vA1,vPointA,_tp,0.0f, 1.0f);\ - /*Closest point on segment*/ \ - VEC_DIFF(vPointB,vPointA,vB1);\ - _tp = VEC_DOT(vPointB, _BD); \ - _tp/= VEC_DOT(_BD, _BD); \ - _tp = CLAMP(_tp,0.0f,1.0f); \ - VEC_SCALE(vPointB,_tp,_BD);\ - VEC_SUM(vPointB,vPointB,vB1);\ -}\ - -//! @} - -///Additional Headers for Collision -#include "GIMPACT/gim_tri_collision.h" -#include "GIMPACT/gim_tri_sphere_collision.h" -#include "GIMPACT/gim_tri_capsule_collision.h" - -#endif // GIM_VECTOR_H_INCLUDED diff --git a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_math.h b/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_math.h deleted file mode 100644 index 68f226e..0000000 --- a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_math.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef GIM_MATH_H_INCLUDED -#define GIM_MATH_H_INCLUDED - -/*! \file gim_math.h -\author Francisco León -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) 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. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - - 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 files - GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -#include -#include - - -/*! \defgroup BASIC_TYPES -Basic types and constants -Conventions: -Types starting with G -Constants starting with G_ -*/ -//! @{ -/*! Types */ -#define GREAL float -#define GINT long -#define GUINT unsigned long -/*! Constants for integers*/ -#define GUINT_BIT_COUNT 32 -#define GUINT_EXPONENT 5 - -#define G_FASTMATH 1 -#define G_PI 3.14159265358979f -#define G_HALF_PI 1.5707963f -//267948966 -#define G_TWO_PI 6.28318530f -//71795864 -#define G_ROOT3 1.73205f -#define G_ROOT2 1.41421f -#define G_UINT_INFINITY 65534 -#define G_REAL_INFINITY FLT_MAX -#define G_SIGN_BITMASK 0x80000000 -#define G_USE_EPSILON_TEST -#define G_EPSILON 0.0000001f -//! @} - -/*! \defgroup MATH_FUNCTIONS -mathematical functions -*/ -//! @{ -#define G_DEGTORAD(X) ((X)*3.1415926f/180.0f) -#define G_RADTODEG(X) ((X)*180.0f/3.1415926f) - -//! Integer representation of a floating-point value. -#define IR(x) ((GUINT&)(x)) - -//! Signed integer representation of a floating-point value. -#define SIR(x) ((GINT&)(x)) - -//! Absolute integer representation of a floating-point value -#define AIR(x) (IR(x)&0x7fffffff) - -//! Floating-point representation of an integer value. -#define FR(x) ((GREAL&)(x)) - -#define MAX(a,b) (ab?b:a) - -#define MAX3(a,b,c) MAX(a,MAX(b,c)) -#define MIN3(a,b,c) MIN(a,MIN(b,c)) - -#define IS_ZERO(value) (value < G_EPSILON && value > -G_EPSILON) - -#define IS_NEGATIVE(value) (value <= -G_EPSILON) - -#define IS_POSISITVE(value) (value >= G_EPSILON) - -///returns a clamped number -#define CLAMP(number,minval,maxval) (numbermaxval?maxval:number)) - -///Swap numbers -#define SWAP_NUMBERS(a,b){ \ - a = a+b; \ - b = a-b; \ - a = a-b; \ -}\ - -#define GIM_INV_SQRT(va,isva)\ -{\ - if(va<=0.0000001f)\ - {\ - isva = G_REAL_INFINITY;\ - }\ - else\ - {\ - GREAL _x = va * 0.5f;\ - GUINT _y = 0x5f3759df - ( IR(va) >> 1);\ - isva = FR(_y);\ - isva = isva * ( 1.5f - ( _x * isva * isva ) );\ - }\ -}\ - -#define GIM_SQRT(va,sva)\ -{\ - GIM_INV_SQRT(va,sva);\ - sva = 1.0f/sva;\ -}\ - -//! Computes 1.0f / sqrtf(x). Comes from Quake3. See http://www.magic-software.com/3DGEDInvSqrt.html -GREAL gim_inv_sqrt(GREAL f); - -//! Computes sqrtf(x) faster. -/*! -\sa gim_inv_sqrt -*/ -GREAL gim_sqrt(GREAL f); - -//!Initializes mathematical functions -void gim_init_math(); - -//! Generates an unit random -GREAL gim_unit_random(); -//! @} - -#endif // GIM_MATH_H_INCLUDED diff --git a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_memory.h b/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_memory.h deleted file mode 100644 index 58661f1..0000000 --- a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_memory.h +++ /dev/null @@ -1,1040 +0,0 @@ -#ifndef GIM_MEMORY_H_INCLUDED -#define GIM_MEMORY_H_INCLUDED -/*! \file gim_memory.h -\author Francisco León -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) 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. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - - 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 files - GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - - -#include "GIMPACT/gim_math.h" -#include - -//#define PREFETCH 1 -//! \defgroup PREFETCH -//! @{ -#ifdef PREFETCH -#include // for prefetch -#define pfval 64 -#define pfval2 128 -//! Prefetch 64 -#define pf(_x,_i) _mm_prefetch((void *)(_x + _i + pfval), 0) -//! Prefetch 128 -#define pf2(_x,_i) _mm_prefetch((void *)(_x + _i + pfval2), 0) -#else -//! Prefetch 64 -#define pf(_x,_i) -//! Prefetch 128 -#define pf2(_x,_i) -#endif -//! @} - -/*! \defgroup ARRAY_UTILITIES -\brief -Functions for manip packed arrays of numbers -*/ -//! @{ -#define GIM_COPY_ARRAYS(dest_array,source_array,element_count)\ -{\ - GUINT _i_;\ - for (_i_=0;_i_ -
  • For initializes a dynamic array, use GIM_DYNARRAY_CREATE or GIM_DYNARRAY_CREATE_SIZED. -
  • When an array is no longer used, must be terminated with the macro GIM_DYNARRAY_DESTROY. - -*/ -//! @{ -#define G_ARRAY_GROW_SIZE 100 - -//! Dynamic array handle. -struct GDYNAMIC_ARRAY -{ - char * m_pdata; - GUINT m_size; - GUINT m_reserve_size; -}; -//typedef struct _GDYNAMIC_ARRAY GDYNAMIC_ARRAY; - -//! Creates a dynamic array zero sized -#define GIM_DYNARRAY_CREATE(type,array_data,reserve_size) \ -{ \ - array_data.m_pdata = (char *)gim_alloc(reserve_size*sizeof(type)); \ - array_data.m_size = 0; \ - array_data.m_reserve_size = reserve_size; \ -}\ - -//! Creates a dynamic array with n = size elements -#define GIM_DYNARRAY_CREATE_SIZED(type,array_data,size) \ -{ \ - array_data.m_pdata = (char *)gim_alloc(size*sizeof(type)); \ - array_data.m_size = size; \ - array_data.m_reserve_size = size; \ -}\ - -//! Reserves memory for a dynamic array. -#define GIM_DYNARRAY_RESERVE_SIZE(type,array_data,reserve_size) \ -{ \ - if(reserve_size>array_data.m_reserve_size )\ - { \ - array_data.m_pdata = (char *) gim_realloc(array_data.m_pdata,array_data.m_size*sizeof(type),reserve_size*sizeof(type));\ - array_data.m_reserve_size = reserve_size; \ - }\ -}\ - -//! Set the size of the array -#define GIM_DYNARRAY_SET_SIZE(type,array_data,size) \ -{ \ - GIM_DYNARRAY_RESERVE_SIZE(type,array_data,size);\ - array_data.m_size = size;\ -}\ - -//! Gets a pointer from the beginning of the array -#define GIM_DYNARRAY_POINTER(type,array_data) (type *)(array_data.m_pdata) - -//! Gets a pointer from the last elemento of the array -#define GIM_DYNARRAY_POINTER_LAST(type,array_data) (((type *)array_data.m_pdata)+array_data.m_size-1) - -//! Inserts an element at the last position -#define GIM_DYNARRAY_PUSH_ITEM(type,array_data,item)\ -{\ - if(array_data.m_reserve_size<=array_data.m_size)\ - {\ - GIM_DYNARRAY_RESERVE_SIZE(type,array_data,(array_data.m_size+G_ARRAY_GROW_SIZE));\ - }\ - type * _pt = GIM_DYNARRAY_POINTER(type,array_data);\ - memcpy(&_pt[array_data.m_size],&item,sizeof(type));\ - array_data.m_size++; \ -}\ - -//! Inserts an element at the last position -#define GIM_DYNARRAY_PUSH_EMPTY(type,array_data)\ -{\ - if(array_data.m_reserve_size<=array_data.m_size)\ - {\ - GIM_DYNARRAY_RESERVE_SIZE(type,array_data,(array_data.m_size+G_ARRAY_GROW_SIZE));\ - }\ - array_data.m_size++; \ -}\ - -//! Inserts an element -#define GIM_DYNARRAY_INSERT_ITEM(type,array_data,item,index) \ -{ \ - if(array_data.m_reserve_size<=array_data.m_size)\ - {\ - GIM_DYNARRAY_RESERVE_SIZE(type,array_data,(array_data.m_size+G_ARRAY_GROW_SIZE));\ - }\ - type * _pt = GIM_DYNARRAY_POINTER(type,array_data);\ - if(index0) \ - { \ - array_data.m_size--; \ - } \ -}\ - -//! Destroys the array -void GIM_DYNARRAY_DESTROY(GDYNAMIC_ARRAY & array_data); -//! @} - -/*! \defgroup BITSET -\brief -Bitsets , based on \ref DYNAMIC_ARRAYS . -
      -
    • For initializes a bitset array, use \ref GIM_BITSET_CREATE or \ref GIM_BITSET_CREATE_SIZED. -
    • When the bitset is no longer used, must be terminated with the macro \ref GIM_DYNARRAY_DESTROY. -
    • For putting a mark on the bitset, call \ref GIM_BITSET_SET -
    • For clearing a mark on the bitset, call \ref GIM_BITSET_CLEAR -
    • For retrieving a bit value from a bitset, call \ref GIM_BITSET_GET- -
    -*/ -//! @{ - -//! Creates a bitset -#define GIM_BITSET_CREATE(array_data) GIM_DYNARRAY_CREATE(GUINT,array_data,G_ARRAY_GROW_SIZE) - -//! Creates a bitset, with their bits set to 0. -#define GIM_BITSET_CREATE_SIZED(array_data,bits_count)\ -{\ - array_data.m_size = bits_count/GUINT_BIT_COUNT + 1;\ - GIM_DYNARRAY_CREATE(GUINT,array_data,array_data.m_size);\ - GUINT * _pt = GIM_DYNARRAY_POINTER(GUINT,array_data);\ - memset(_pt,0,sizeof(GUINT)*(array_data.m_size));\ -}\ - -//! Gets the bitset bit count. -#define GIM_BITSET_SIZE(array_data) (array_data.m_size*GUINT_BIT_COUNT) - -//! Resizes a bitset, with their bits set to 0. -#define GIM_BITSET_RESIZE(array_data,new_bits_count)\ -{ \ - GUINT _oldsize = array_data.m_size;\ - array_data.m_size = new_bits_count/GUINT_BIT_COUNT + 1; \ - if(_oldsize array_data.m_reserve_size)\ - {\ - GIM_DYNARRAY_RESERVE_SIZE(GUINT,array_data,array_data.m_size+G_ARRAY_GROW_SIZE);\ - }\ - GUINT * _pt = GIM_DYNARRAY_POINTER(GUINT,array_data);\ - memset(&_pt[_oldsize],0,sizeof(GUINT)*(array_data.m_size-_oldsize));\ - }\ -}\ - -//! Sets all bitset bit to 0. -#define GIM_BITSET_CLEAR_ALL(array_data)\ -{\ - memset(array_data.m_pdata,0,sizeof(GUINT)*array_data.m_size);\ -}\ - -//! Sets all bitset bit to 1. -#define GIM_BITSET_SET_ALL(array_data)\ -{\ - memset(array_data.m_pdata,0xFF,sizeof(GUINT)*array_data.m_size);\ -}\ - -///Sets the desired bit to 1 -#define GIM_BITSET_SET(array_data,bit_index)\ -{\ - if(bit_index>=GIM_BITSET_SIZE(array_data))\ - {\ - GIM_BITSET_RESIZE(array_data,bit_index);\ - }\ - GUINT * _pt = GIM_DYNARRAY_POINTER(GUINT,array_data);\ - _pt[bit_index >> GUINT_EXPONENT] |= (1 << (bit_index & (GUINT_BIT_COUNT-1)));\ -}\ - -///Return 0 or 1 -#define GIM_BITSET_GET(array_data,bit_index,get_value) \ -{\ - if(bit_index>=GIM_BITSET_SIZE(array_data))\ - {\ - get_value = 0;\ - }\ - else\ - {\ - GUINT * _pt = GIM_DYNARRAY_POINTER(GUINT,array_data);\ - get_value = _pt[bit_index >> GUINT_EXPONENT] & (1 << (bit_index & (GUINT_BIT_COUNT-1)));\ - }\ -}\ - -///Sets the desired bit to 0 -#define GIM_BITSET_CLEAR(array_data,bit_index) \ -{\ - if(bit_index> GUINT_EXPONENT] &= ~(1 << (bit_index & (GUINT_BIT_COUNT-1)));\ - }\ -}\ -//! @} - -/*! \defgroup MEMORY_ACCESS_CONSTANTS -\brief -Memory Access constants. -\sa BUFFERS -*/ -//! @{ -#define G_MA_READ_ONLY 1 -#define G_MA_WRITE_ONLY 2 -#define G_MA_READ_WRITE 3 -//! @} - -/*! \defgroup MEMORY_USAGE_CONSTANTS -\brief -Memory usage constants. -\sa BUFFERS -*/ -//! @{ -/// Don't care how memory is used -#define G_MU_EITHER 0 -/// specified once, doesn't allow read information -#define G_MU_STATIC_WRITE 1 -/// specified once, allows to read information from a shadow buffer -#define G_MU_STATIC_READ 2 -/// write directly on buffer, allows to read information from a shadow buffer -#define G_MU_STATIC_READ_DYNAMIC_WRITE 3 -/// upload data to buffer from the shadow buffer, allows to read information from a shadow buffer -#define G_MU_STATIC_READ_DYNAMIC_WRITE_COPY 4 -/// specified once, allows to read information directly from memory -#define G_MU_STATIC_WRITE_DYNAMIC_READ 5 -/// write directly on buffer, allows to read information directly from memory -#define G_MU_DYNAMIC_READ_WRITE 6 -//! @} - -/*! \defgroup BUFFER_ERRORS -\brief -Buffer operation errors -\sa BUFFERS -*/ -//! @{ -#define G_BUFFER_OP_SUCCESS 0 -#define G_BUFFER_OP_INVALID 1 -#define G_BUFFER_OP_STILLREFCOUNTED 2 -//! @} - -/*! \defgroup BUFFER_MANAGER_IDS -\brief -Buffer manager identifiers -\sa BUFFERS, BUFFER_MANAGERS -*/ -//! @{ -#define G_BUFFER_MANAGER_SYSTEM 0 -#define G_BUFFER_MANAGER_SHARED 1 -#define G_BUFFER_MANAGER_USER 2 -//! @} - -/*! \defgroup BUFFERS -\brief -Buffer operations and structs. -
      -
    • Before using buffers you must initializes GIMPACT buffer managers by calling \ref gimpact_init. -
    • For initializes a buffer, use \ref gim_create_buffer, \ref gim_create_buffer_from_data , \ref gim_create_common_buffer, \ref gim_create_common_buffer_from_data or \ref gim_create_shared_buffer_from_data. -
    • For accessing to the buffer memory, you must call \ref gim_lock_buffer, and then \ref gim_unlock_buffer for finish the access. -
    • When a buffer is no longer needed, you must free it by calling \ref gim_buffer_free. -
    • You must call \ref gimpact_terminate when finish your application. -
    • For a safe manipulation of buffers, use \ref BUFFER_ARRAYS -
    -\sa BUFFER_MANAGERS, BUFFER_ARRAYS -*/ -//! @{ - -//! Buffer handle. -struct GBUFFER_ID -{ - GUINT m_buffer_id; - GUINT m_buffer_manager_id; -}; -//typedef struct _GBUFFER_ID GBUFFER_ID; - -//! Buffer internal data -struct GBUFFER_DATA -{ - GUINT m_buffer_handle;//!< if 0, buffer doesn't exists - GUINT m_size; - GUINT m_usage; - GINT m_access; - GUINT m_lock_count; - char * m_mapped_pointer; - GBUFFER_ID m_shadow_buffer; - GUINT m_refcount;//! Reference counting for safe garbage collection -}; -//typedef struct _GBUFFER_DATA GBUFFER_DATA; -//! @} - -/*! \defgroup BUFFERS_MANAGER_PROTOTYPES -\brief -Function prototypes to allocate and free memory for buffers -\sa BUFFER_MANAGERS, BUFFERS -*/ -//! @{ - -//! Returns a Buffer handle -typedef GUINT gim_buffer_alloc_function(GUINT size,int usage); - -//! Returns a Buffer handle, and copies the pdata to the buffer -typedef GUINT gim_buffer_alloc_data_function(const void * pdata,GUINT size,int usage); - -//! Changes the size of the buffer preserving the content, and returns the new buffer id -typedef GUINT gim_buffer_realloc_function(GUINT buffer_handle,GUINT oldsize,int old_usage,GUINT newsize,int new_usage); - -//! It changes the m_buffer_handle member to 0/0 -typedef void gim_buffer_free_function(GUINT buffer_handle,GUINT size); - -//! It maps the m_mapped_pointer. Returns a pointer -typedef char * gim_lock_buffer_function(GUINT buffer_handle,int access); - -//! It sets the m_mapped_pointer to 0 -typedef void gim_unlock_buffer_function(GUINT buffer_handle); - -typedef void gim_download_from_buffer_function( - GUINT source_buffer_handle, - GUINT source_pos, - void * destdata, - GUINT copysize); - -typedef void gim_upload_to_buffer_function( - GUINT dest_buffer_handle, - GUINT dest_pos, - void * sourcedata, - GUINT copysize); - -typedef void gim_copy_buffers_function( - GUINT source_buffer_handle, - GUINT source_pos, - GUINT dest_buffer_handle, - GUINT dest_pos, - GUINT copysize); -//! @} - - -/*! \defgroup BUFFER_MANAGERS -\brief -Buffer Manager operations -*/ -//! @{ -//! Buffer manager prototype -struct GBUFFER_MANAGER_PROTOTYPE -{ - gim_buffer_alloc_function * alloc_fn; - gim_buffer_alloc_data_function *alloc_data_fn; - gim_buffer_realloc_function * realloc_fn; - gim_buffer_free_function * free_fn; - gim_lock_buffer_function * lock_buffer_fn; - gim_unlock_buffer_function * unlock_buffer_fn; - gim_download_from_buffer_function * download_from_buffer_fn; - gim_upload_to_buffer_function * upload_to_buffer_fn; - gim_copy_buffers_function * copy_buffers_fn; -}; -//typedef struct _GBUFFER_MANAGER_PROTOTYPE GBUFFER_MANAGER_PROTOTYPE; - -//! Buffer manager -struct GBUFFER_MANAGER_DATA -{ - GDYNAMIC_ARRAY m_buffer_array;//!< Array of GBUFFER_DATA objects - GDYNAMIC_ARRAY m_free_positions;//!< Array of GUINT elements. Free positions - GBUFFER_MANAGER_PROTOTYPE m_prototype;//! Prototype of functions - GUINT m_active; //!< 0 or 1 -}; -//typedef struct _GBUFFER_MANAGER_DATA GBUFFER_MANAGER_DATA; - -//! Adds a buffer Manager to the Memory Singleton -void gim_create_buffer_manager(GBUFFER_MANAGER_PROTOTYPE * prototype,GUINT buffer_manager_id); -//! Gets buffer manager -GUINT gim_get_buffer_manager_count(); -//! Destroys a buffer manager -void gim_destroy_buffer_manager(GUINT buffer_manager_id); -void gim_get_buffer_manager_data(GUINT buffer_manager_id,GBUFFER_MANAGER_DATA ** pbm_data); -void gim_init_buffer_managers(); -void gim_terminate_buffer_managers(); - -//! @} - - -/*! \addtogroup BUFFERS -*/ -//! @{ - -//!Creates a buffer on the buffer manager specified by buffer_manager_id -/*! -\param buffer_manager_id -\param buffer_size -\param usage An usage constant. Use G_MU_DYNAMIC_READ_WRITE as default. -\param buffer_id a pointer for receive the new buffer id -\return An error code. 0 if success. -\post m_refcount = 0 -*/ -GUINT gim_create_buffer( - GUINT buffer_manager_id, - GUINT buffer_size, - int usage, - GBUFFER_ID * buffer_id); - -//!Creates a buffer on the buffer manager specified by buffer_manager_id -/*! -\param buffer_manager_id -\param pdata Data for allocating -\param buffer_size Size of the data buffer -\param usage An usage constant. Use G_MU_DYNAMIC_READ_WRITE as default. -\param buffer_id a pointer for receive the new buffer id -\return An error code. 0 if success. -\post m_refcount = 0 -*/ -GUINT gim_create_buffer_from_data( - GUINT buffer_manager_id, - const void * pdata, - GUINT buffer_size, - int usage, - GBUFFER_ID * buffer_id); - -//!Allocates on the G_BUFFER_MANAGER_SYSTEM -GUINT gim_create_common_buffer(GUINT buffer_size, GBUFFER_ID * buffer_id); -//!Allocates on the G_BUFFER_MANAGER_SYSTEM, and copies the data -GUINT gim_create_common_buffer_from_data( - const void * pdata, GUINT buffer_size, GBUFFER_ID * buffer_id); -//!Creates a buffer with shared data -GUINT gim_create_shared_buffer_from_data( - const void * pdata, GUINT buffer_size, GBUFFER_ID * buffer_id); - - -//! Add reference counting to buffer. -GINT gim_buffer_add_ref(GBUFFER_ID * buffer_id); - -//! Function for resize buffer, preserving the content -/*! -\param buffer_id -\param newsize -\return An error code. 0 if success. -\post If m_refcount>0 then it decrements it. -*/ -GINT gim_buffer_realloc(GBUFFER_ID * buffer_id,GUINT newsize); - -//! Eliminates the buffer. -/*! -If the buffer reference counting is <= 1 and is unlocked, then it eliminates the buffer. -*/ -GINT gim_buffer_free(GBUFFER_ID * buffer_id); - -//! Locks the buffer for memory access. -/*! -\param buffer_id Id from buffer. -\param access Must have the following values: G_MA_READ_ONLY,G_MA_WRITE_ONLY or G_MA_READ_WRITE. -\param map_pointer Dest Pointer of the memory address from buffer. -\post m_lock_count increases. -*/ -GINT gim_lock_buffer(GBUFFER_ID * buffer_id,int access,char ** map_pointer); - -//! Unlocks the buffer for memory access. -GINT gim_unlock_buffer(GBUFFER_ID * buffer_id); - -//! Gets the buffer size in bytes -GINT gim_get_buffer_size(GBUFFER_ID * buffer_id,GUINT * buffer_size); - -//! Determines if the buffer is locked -GINT gim_get_buffer_is_locked(GBUFFER_ID * buffer_id,GUINT * lock_count); - -//! Copies the content of the buffer to a dest pointer -GINT gim_download_from_buffer( - GBUFFER_ID * buffer_id, - GUINT source_pos, - void * destdata, - GUINT copysize); - -//! Copies the content of a memory pointer to the buffer -GINT gim_upload_to_buffer( - GBUFFER_ID * buffer_id, - GUINT dest_pos, - void * sourcedata, - GUINT copysize); - -//! Copies two buffers. -GINT gim_copy_buffers( - GBUFFER_ID * source_buffer_id, - GUINT source_pos, - GBUFFER_ID * dest_buffer_id, - GUINT dest_pos, - GUINT copysize); -//! @} - - -/*! \defgroup BUFFER_ARRAYS - -\brief -Buffered Arrays, for manip elements on a buffer and treat it as an array. -
      -
    • Before using buffer arrays you must initializes GIMPACT buffer managers by calling gimpact_init. -
    • Before creating buffer arrays, you must create a buffer. see \ref BUFFERS. -
    • Create a buffer narray by calling \ref GIM_BUFFER_ARRAY_INIT_TYPE, \ref GIM_BUFFER_ARRAY_INIT_TYPE_OFFSET or \ref GIM_BUFFER_ARRAY_INIT_OFFSET_STRIDE. -
    • For accessing to the array elements, you must call \ref gim_buffer_array_lock, and then \ref gim_buffer_array_unlock for finish the access. -
    • When a buffer array is no longer needed, you must free it by calling \ref GIM_BUFFER_ARRAY_DESTROY. -
    -The following example shows how Buffer arrays can be used: - -\code -int main() -{ - //init gimpact - gimpact_init(); - - //Buffer handle to use - GBUFFER_ID bufferhandle; - - //Create a memory buffer of 100 float numbers - gim_create_common_buffer(100*sizeof(float), &bufferhandle); - - //Create a buffer array from the bufferhandle - GBUFFER_ARRAY buffer_float_array; - GIM_BUFFER_ARRAY_INIT_TYPE(float,buffer_float_array,bufferhandle,100); - - ////Access to the buffer data, set all elements of the array - - int i, count; - count = buffer_float_array.m_element_count; - //Locks the array - gim_buffer_array_lock(&buffer_float_array,G_MA_READ_WRITE); - float * pelements = GIM_BUFFER_ARRAY_POINTER(float, buffer_float_array, 0); // A pointer to the buffer memory - - //fill the array with random numbers - for (i = 0;i < count;i++ ) - { - pelements[i] = gim_unit_random(); - } - //unlock buffer - gim_buffer_array_unlock(&buffer_float_array); - - //Program code - .... - .... - - //Destroy array - GIM_BUFFER_ARRAY_DESTROY(buffer_float_array); - - //terminate gimpact - gimpact_terminate(); -} -\endcode - -\sa BUFFERS -*/ -//! @{ - -//! Buffer managed array struct. -struct GBUFFER_ARRAY -{ - GBUFFER_ID m_buffer_id; - char * m_buffer_data; - char m_byte_stride; - GUINT m_byte_offset; - GUINT m_element_count; -}; -//typedef struct _GBUFFER_ARRAY GBUFFER_ARRAY; - -//! Sets offset for a buffered array. -#define GIM_BUFFER_ARRAY_SET_OFFSET(_array_data,_offset) (_array_data).m_byte_offset = _offset*(_array_data).m_byte_stride; - -//! Sets offset for a buffered array. -#define GIM_BUFFER_ARRAY_GET_OFFSET(_array_data,_offset) _offset = (_array_data).m_byte_offset/(_array_data).m_byte_stride; - -//!Return a pointer of the element at the _index -#define GIM_BUFFER_ARRAY_POINTER(_type,_array_data,_index) (_type *)((_array_data).m_buffer_data + _index*(_array_data).m_byte_stride) - -//! Sets stride for a buffered array. -#define GIM_BUFFER_ARRAY_SET_STRIDE(_type,_array_data) (_array_data).m_byte_stride = sizeof(_type); - -//! Is array stride equal to the size of the type ? -#define GIM_BUFFER_ARRAY_IS_ALIGNED(_type,_array_data) ((_array_data).m_byte_stride == sizeof(_type)) - -///Verify if two arrays have the same data -#define GIM_BUFFER_ARRAY_ARE_SAME(_array_data1,_array_data2,aresame)\ -{\ - aresame = 1;\ - if((_array_data1).m_buffer_id.m_buffer_id != (_array_data2).m_buffer_id.m_buffer_id || (_array_data1).m_buffer_id.m_buffer_manager_id != (_array_data2).m_buffer_id.m_buffer_manager_id || (_array_data1).m_byte_offset != (_array_data2).m_byte_offset)\ - {\ - aresame = 0;\ - }\ -}\ - -//! Reserve size for a buffered array. -/*! -\pre array_data must be unlocked, and must be the aligned (GIM_BUFFER_ARRAY_IS_ALIGNED ) -*/ -#define GIM_BUFFER_ARRAY_RESERVE_SIZE(type,array_data,reserve_size)\ -{ \ - if(reserve_size>(array_data).m_element_count)\ - {\ - GUINT _buffer_size,_newarray_size;\ - gim_get_buffer_size(&(array_data).m_buffer_id,_buffer_size);\ - _newarray_size = reserve_size*(array_data).m_byte_stride;\ - if(_newarray_size>_buffer_size)\ - { \ - _newarray_size += G_ARRAY_GROW_SIZE*(array_data).m_byte_stride;\ - gim_buffer_realloc(&(array_data).m_buffer_id,_newarray_size);\ - }\ - }\ -}\ - -//! Pushes an element at last position -/*! -\pre array_data must be unlocked, and must be the aligned (GIM_BUFFER_ARRAY_IS_ALIGNED ) -*/ -#define GIM_BUFFER_ARRAY_PUSH_ITEM(type,array_data,item)\ -{\ - GIM_BUFFER_ARRAY_RESERVE_SIZE(type,array_data,(array_data).m_element_count+1);\ - gim_buffer_array_lock(&array_data,G_MA_WRITE_ONLY);\ - type * _pt = GIM_BUFFER_ARRAY_POINTER(type,array_data,(array_data).m_element_count);\ - memcpy(_pt,&item,sizeof(type));\ - gim_buffer_array_unlock(&array_data);\ - (array_data)->m_element_count++; \ -}\ - -//! Pushes a new element at last position -/*! -\pre array_data must be unlocked, and must be the aligned (GIM_BUFFER_ARRAY_IS_ALIGNED ) -*/ -#define GIM_BUFFER_ARRAY_PUSH_EMPTY(type,array_data)\ -{\ - GIM_BUFFER_ARRAY_RESERVE_SIZE(type,array_data,(array_data).m_element_count+1);\ - array_data->m_element_count++; \ -}\ - -//! Inserts an element -/*! -\pre array_data must be unlocked, and must be the aligned (GIM_BUFFER_ARRAY_IS_ALIGNED ) -*/ -#define GIM_BUFFER_ARRAY_INSERT_ITEM(type,array_data,item,index) \ -{ \ - GIM_BUFFER_ARRAY_RESERVE_SIZE(type,array_data,(array_data).m_element_count+1);\ - gim_buffer_array_lock(&array_data,G_MA_WRITE_ONLY);\ - type * _pt = GIM_BUFFER_ARRAY_POINTER(type,array_data,0);\ - if(index<(array_data)->m_element_count-1) \ - { \ - memcpy(&_pt[index+1],&_pt[index],((array_data).m_element_count-index)*sizeof(type));\ - } \ - memcpy(&_pt[index],&item,sizeof(type));\ - gim_buffer_array_unlock(&array_data);\ - (array_data).m_element_count++; \ -}\ - -//! Deletes an element -/*! -\pre array_data must be unlocked, and must be the aligned (GIM_BUFFER_ARRAY_IS_ALIGNED ) -*/ -#define GIM_BUFFER_ARRAY_DELETE_ITEM(type,array_data,index) \ -{ \ - if(index<(array_data).m_element_count-1) \ - { \ - gim_buffer_array_lock(&array_data,G_MA_WRITE_ONLY);\ - type * _pt = GIM_BUFFER_ARRAY_POINTER(type,array_data,0);\ - memcpy(&_pt[index],&_pt[index+1],((array_data).m_element_count-index-1)*sizeof(type));\ - gim_buffer_array_unlock(&array_data);\ - } \ - (array_data).m_element_count--; \ -}\ - -//! Deletes an element at last position -/*! -\pre array_data must be unlocked, and must be the aligned (GIM_BUFFER_ARRAY_IS_ALIGNED ) -*/ -#define GIM_BUFFER_ARRAY_POP_ITEM(array_data) \ -{ \ - if((array_data).m_element_count>0) \ - { \ - (array_data).m_element_count--; \ - } \ -}\ - - -//! Initializes an GBUFFER_ARRAY object from a buffer ID -/*! -m_buffer_data will be 0, for acces to the elements, you'd need to call lock_array -\param array_data Array structure to be filled -\param buffer_id A GBUFFER_ID structure which this array_daya will refer to -\param element_count Number of elements -\param offset element offset, it isn't byte offset. 0 is recomended -\param byte_stride size of each element. 0 is recomended. -\post Adds reference to the buffer -\sa gim_buffer_add_ref -*/ -#define GIM_BUFFER_ARRAY_INIT_OFFSET_STRIDE(array_data,buffer_id,element_count,offset,byte_stride)\ -{\ - (array_data).m_buffer_id.m_buffer_id = (buffer_id).m_buffer_id;\ - (array_data).m_buffer_id.m_buffer_manager_id = (buffer_id).m_buffer_manager_id;\ - (array_data).m_buffer_data = 0;\ - (array_data).m_element_count = element_count;\ - (array_data).m_byte_stride = byte_stride;\ - GIM_BUFFER_ARRAY_SET_OFFSET(array_data,offset);\ - gim_buffer_add_ref(&(buffer_id));\ -}\ - -//! Initializes an GBUFFER_ARRAY object from a buffer ID and a Given type -/*! -m_buffer_data will be 0, for acces to the elements, you'd need to call lock_array -\param type Type of the Array. It determines the stride. -\param array_data Array structure to be filled -\param buffer_id A GBUFFER_ID structure which this array_daya will refer to -\param element_count Number of elements -\param offset element offset, it isn't byte offset. 0 is recomended -\post Adds reference to the buffer -\sa gim_buffer_add_ref -*/ -#define GIM_BUFFER_ARRAY_INIT_TYPE_OFFSET(type,array_data,buffer_id,element_count,offset)\ -{\ - (array_data).m_buffer_id.m_buffer_id = (buffer_id).m_buffer_id;\ - (array_data).m_buffer_id.m_buffer_manager_id = (buffer_id).m_buffer_manager_id;\ - (array_data).m_buffer_data = 0;\ - (array_data).m_element_count = element_count;\ - GIM_BUFFER_ARRAY_SET_STRIDE(type,array_data);\ - GIM_BUFFER_ARRAY_SET_OFFSET(array_data,offset);\ - gim_buffer_add_ref(&(buffer_id));\ -}\ - -//! Initializes a buffer array giving a data type and a buffer id -/*! -m_buffer_data will be 0, for acces to the elements, you'd need to call lock_array. -\param type Type of the Array. It determines the stride. -\param array_data Array structure to be filled -\param buffer_id A GBUFFER_ID structure which this array_daya will refer to -\param element_count Number of elements -\post Adds reference to the buffer -\sa gim_buffer_add_ref -*/ -#define GIM_BUFFER_ARRAY_INIT_TYPE(type,array_data,buffer_id,element_count) GIM_BUFFER_ARRAY_INIT_TYPE_OFFSET(type,array_data,buffer_id,element_count,0) - -//! Gain access to the array buffer through the m_buffer_data element -/*! -m_buffer_data pointer will be located at the m_byte_offset position of the buffer m_buffer -Then, You'd need to call unlock_array when finish to using the array access. - -\pre if m_buffer_data != 0, the function returns -\param array_data Array structure to be locked -\param access A constant for access to the buffer. can be G_MA_READ_ONLY,G_MA_WRITE_ONLY or G_MA_READ_WRITE -\return an Buffer error code -*/ -GINT gim_buffer_array_lock(GBUFFER_ARRAY * array_data, int access); - -//! close the access to the array buffer through the m_buffer_data element -/*! -\param array_data Array structure to be locked -\return an Buffer error code -*/ -GINT gim_buffer_array_unlock(GBUFFER_ARRAY * array_data); - -//! Copy an array by reference -/*! -\post A reference to the m_buffer_id is increased. -*/ -void gim_buffer_array_copy_ref(GBUFFER_ARRAY * source_data,GBUFFER_ARRAY * dest_data); - - -//! Copy an array by value -/*! -\post A new buffer is created -*/ -void gim_buffer_array_copy_value(GBUFFER_ARRAY * source_data,GBUFFER_ARRAY * dest_data, GUINT buffer_manager_id,int usage); - -//! Destroys an GBUFFER_ARRAY object -/*! -\post Attemps to destroy the buffer, decreases reference counting -*/ -void GIM_BUFFER_ARRAY_DESTROY(GBUFFER_ARRAY & array_data); - -//! Copy the content of the array to a pointer -/*! -\pre dest_data must have the same size as the array_data -\param type -\param array_data A GBUFFERED_ARRAY structure -\param dest_data A type pointer -*/ -#define GIM_BUFFER_ARRAY_DOWNLOAD(type,array_data,dest_data)\ -{\ - if(GIM_BUFFER_ARRAY_IS_ALIGNED(type,array_data))\ - {\ - gim_download_from_buffer(&(array_data).m_buffer_id, (array_data).m_byte_offset,(void *) dest_data, (array_data).m_element_count*(array_data).m_byte_stride);\ - }\ - else\ - {\ - GUINT _k_, _ecount_= (array_data).m_element_count;\ - type * _source_vert_;\ - type * _dest_vert_ = dest_data;\ - gim_buffer_array_lock(&(array_data),G_MA_READ_ONLY);\ - for (_k_ = 0;_k_< _ecount_; _k_++)\ - {\ - _source_vert_ = GIM_BUFFER_ARRAY_POINTER(type,array_data,_k_);\ - memcpy(_dest_vert_,_source_vert_,sizeof(type));\ - _dest_vert_++;\ - }\ - gim_buffer_array_unlock(&(array_data));\ - }\ -}\ - -//! Upload the content of a a pointer to a buffered array -/*! -\pre source_data must have the same size as the array_data -\param type -\param array_data A GBUFFERED_ARRAY structure -\param source_data A void pointer -*/ -#define GIM_BUFFER_ARRAY_UPLOAD(type,array_data,source_data)\ -{\ - if(GIM_BUFFER_ARRAY_IS_ALIGNED(type,array_data))\ - {\ - gim_upload_to_buffer(&(array_data).m_buffer_id, (array_data).m_byte_offset,(void *) source_data, (array_data).m_element_count*(array_data).m_byte_stride);\ - }\ - else\ - {\ - GUINT _k_, _ecount_= (array_data).m_element_count;\ - type * _source_vert_ = source_data;\ - type * _dest_vert_;\ - gim_buffer_array_lock(&(array_data),G_MA_WRITE_ONLY);\ - for (_k_ = 0;_k_< _ecount_; _k_++)\ - {\ - _dest_vert_ = GIM_BUFFER_ARRAY_POINTER(type,array_data,_k_);\ - memcpy(_dest_vert_,_source_vert_,sizeof(type));\ - _source_vert_++;\ - }\ - gim_buffer_array_unlock(&(array_data));\ - }\ -}\ - - -//!Kernel function prototype for process streams, given a buffered array as source and -/*! -\param 1 the uniform arguments -\param 2 the source stream -\param 3 the destination stream -*/ -typedef void (* gim_kernel_func)(void *,GBUFFER_ARRAY *,GBUFFER_ARRAY *); - -//! Generic Stream Processingp loop -/*! - -This macro executes a kernel macro or function for each element of the streams -\pre _src_array->m_count <= _dst_array->m_count - -\param _uniform_data An argument to be passed to the Kernel function -\param _src_array An GBUFFER_ARRAY structure passed as the source stream -\param _dst_array An GBUFFER_ARRAY structure passed as the source stream -\param _kernel Macro or function of the kernel -\param _src_type Required. Type of all elements of the source stream -\param _dst_type Required. Type of all elements of the dest stream -*/ -#define GIM_PROCESS_BUFFER_ARRAY(_uniform_data,_src_array,_dst_array,_kernel,_src_type,_dst_type) {\ -\ - gim_buffer_array_lock(&_src_array,G_MA_READ_ONLY);\ - gim_buffer_array_lock(&_dst_array,G_MA_WRITE_ONLY);\ -\ - GUINT _i_, _count_=(_src_array).m_element_count;\ -\ - _src_type * _source_vert_;\ - _dst_type * _dest_vert_;\ - if(GIM_BUFFER_ARRAY_IS_ALIGNED(_src_type,_src_array) && GIM_BUFFER_ARRAY_IS_ALIGNED(_dst_type,_dst_array))\ - {\ -\ - _source_vert_ = GIM_BUFFER_ARRAY_POINTER(_src_type,_src_array,0);\ - _dest_vert_ = GIM_BUFFER_ARRAY_POINTER(_dst_type,_dst_array,0);\ - for (_i_ = 0;_i_< _count_; _i_++)\ - {\ - _kernel(_uniform_data,(*_source_vert_),(*_dest_vert_));\ - _source_vert_++;\ - _dest_vert_++;\ - }\ - }\ - else\ - {\ - for (_i_ = 0;_i_< _count_; _i_++)\ - {\ - _source_vert_ = GIM_BUFFER_ARRAY_POINTER(_src_type,_src_array,_i_);\ - _dest_vert_ = GIM_BUFFER_ARRAY_POINTER(_dst_type,_dst_array,_i_);\ - _kernel(_uniform_data,(*_source_vert_),(*_dest_vert_));\ - }\ - }\ - gim_buffer_array_unlock(&_src_array);\ - gim_buffer_array_unlock(&_dst_array);\ -}\ - -//! @} - -#endif // GIM_MEMORY_H_INCLUDED diff --git a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_radixsort.h b/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_radixsort.h deleted file mode 100644 index a5f8e12..0000000 --- a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_radixsort.h +++ /dev/null @@ -1,258 +0,0 @@ -#ifndef GIM_RADIXSORT_H_INCLUDED -#define GIM_RADIXSORT_H_INCLUDED -/*! \file gim_radixsort.h -\author Francisco León. -Based on the work of Michael Herf : "fast floating-point radix sort" -Avaliable on http://www.stereopsis.com/radix.html -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) 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. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - - 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 files - GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -#include "GIMPACT/gim_memory.h" - -/*! \defgroup SORTING -\brief -Macros for sorting. -*/ -//! @{ -struct GIM_RSORT_TOKEN -{ - GUINT m_key; - GUINT m_value; -}; -//typedef struct _GIM_RSORT_TOKEN GIM_RSORT_TOKEN; - -//comparator for sorting -#define RSORT_TOKEN_COMPARATOR(x, y) ((int)((x.m_key) - (y.m_key))) - -// ---- utils for accessing 11-bit quantities -#define D11_0(x) (x & 0x7FF) -#define D11_1(x) (x >> 11 & 0x7FF) -#define D11_2(x) (x >> 22 ) - - -//COMMON FUNCTIONS FOR ACCESSING THE KEY OF AN ELEMENT - - -//For the type of your array, you need to declare a macro for obtaining the key, like these: -#define SIMPLE_GET_FLOAT32KEY(e,key) {key =(GREAL)(e);} - -#define SIMPLE_GET_INTKEY(e,key) {key =(GINT)(e);} - -#define SIMPLE_GET_UINTKEY(e,key) {key =(GUINT)(e);} - -//For the type of your array, you need to declare a macro for copy elements, like this: - -#define SIMPLE_COPY_ELEMENTS(dest,src) {dest = src;} - -#define kHist 2048 - -///Radix sort for unsigned integer keys - -#define GIM_RADIX_SORT_RTOKENS(array,sorted,element_count)\ -{\ - GUINT i;\ - GUINT b0[kHist * 3];\ - GUINT *b1 = b0 + kHist;\ - GUINT *b2 = b1 + kHist;\ - for (i = 0; i < kHist * 3; i++)\ - {\ - b0[i] = 0;\ - }\ - GUINT fi;\ - GUINT pos;\ - for (i = 0; i < element_count; i++)\ - {\ - fi = array[i].m_key;\ - b0[D11_0(fi)] ++;\ - b1[D11_1(fi)] ++;\ - b2[D11_2(fi)] ++;\ - }\ - {\ - GUINT sum0 = 0, sum1 = 0, sum2 = 0;\ - GUINT tsum;\ - for (i = 0; i < kHist; i++)\ - {\ - tsum = b0[i] + sum0;\ - b0[i] = sum0 - 1;\ - sum0 = tsum;\ - tsum = b1[i] + sum1;\ - b1[i] = sum1 - 1;\ - sum1 = tsum;\ - tsum = b2[i] + sum2;\ - b2[i] = sum2 - 1;\ - sum2 = tsum;\ - }\ - }\ - for (i = 0; i < element_count; i++)\ - {\ - fi = array[i].m_key;\ - pos = D11_0(fi);\ - pos = ++b0[pos];\ - sorted[pos].m_key = array[i].m_key;\ - sorted[pos].m_value = array[i].m_value;\ - }\ - for (i = 0; i < element_count; i++)\ - {\ - fi = sorted[i].m_key;\ - pos = D11_1(fi);\ - pos = ++b1[pos];\ - array[pos].m_key = sorted[i].m_key;\ - array[pos].m_value = sorted[i].m_value;\ - }\ - for (i = 0; i < element_count; i++)\ - {\ - fi = array[i].m_key;\ - pos = D11_2(fi);\ - pos = ++b2[pos];\ - sorted[pos].m_key = array[i].m_key;\ - sorted[pos].m_value = array[i].m_value;\ - }\ -}\ - -/// Get the sorted tokens from an array. For generic use. Tokens are GIM_RSORT_TOKEN -#define GIM_RADIX_SORT_ARRAY_TOKENS(array, sorted_tokens, element_count, get_uintkey_macro)\ -{\ - GIM_RSORT_TOKEN * _unsorted = (GIM_RSORT_TOKEN *) gim_alloc(sizeof(GIM_RSORT_TOKEN )*element_count);\ - GUINT _i;\ - for (_i=0;_i 0)\ - {\ - _stack_index_ --;\ - _start_ = _start_stack_[_stack_index_];\ - _end_ = _end_stack_[_stack_index_];\ - while (_end_ - _start_ > 2)\ - {\ - _p_ = _start_;\ - _i_ = _start_ + 1;\ - _j_ = _end_ - 1;\ - while (_i_<_j_) \ - {\ - for(; _i_<=_j_ && comp_macro(((array)[_i_]),((array)[_p_]))<=0; _i_++) ;\ - if (_i_ > _j_) \ - {\ - exchange_macro(type, array, _j_, _p_);\ - _i_ = _j_;\ - }\ - else\ - {\ - for(; _i_<=_j_ && comp_macro(((array)[_j_]),((array)[_p_]))>=0; _j_--) ;\ - if (_i_ > _j_) \ - {\ - exchange_macro(type, array, _j_, _p_);\ - _i_ = _j_;\ - }\ - else if (_i_ < _j_)\ - {\ - exchange_macro(type, array, _i_, _j_);\ - if (_i_+2 < _j_) {_i_++; _j_--;}\ - else if (_i_+1 < _j_) _i_++;\ - }\ - }\ - }\ - if (_i_-_start_ > 1 && _end_-_j_ > 1) \ - {\ - if (_i_-_start_ < _end_-_j_-1) \ - {\ - _start_stack_[_stack_index_] = _j_+1;\ - _end_stack_[_stack_index_] = _end_;\ - _stack_index_ ++;\ - _end_ = _i_;\ - }\ - else\ - {\ - _start_stack_[_stack_index_] = _start_;\ - _end_stack_[_stack_index_] = _i_;\ - _stack_index_ ++;\ - _start_ = _j_+1;\ - }\ - }\ - else\ - {\ - if (_i_-_start_ > 1)\ - {\ - _end_ = _i_;\ - }\ - else \ - {\ - _start_ = _j_+1;\ - }\ - }\ - }\ - if (_end_ - _start_ == 2) \ - {\ - if (comp_macro(((array)[_start_]),((array)[_end_-1])) > 0) \ - {\ - exchange_macro(type, array, _start_, _end_-1);\ - }\ - }\ - }\ -}\ - -#define GIM_DEF_EXCHANGE_MACRO(type, _array, _i, _j)\ -{\ - type _e_tmp_ =(_array)[(_i)];\ - (_array)[(_i)]=(_array)[(_j)];\ - (_array)[(_j)]= _e_tmp_;\ -}\ - -#define GIM_COMP_MACRO(x, y) ((GINT)((x) - (y))) -//! @} -#endif // GIM_RADIXSORT_H_INCLUDED diff --git a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_capsule_collision.h b/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_capsule_collision.h deleted file mode 100644 index 2b31604..0000000 --- a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_capsule_collision.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef GIM_TRI_CAPSULE_COLLISION_H_INCLUDED -#define GIM_TRI_CAPSULE_COLLISION_H_INCLUDED - -/*! \file gim_tri_capsule_collision.h -\author Francisco León -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) 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. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - - 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 files - GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -#include "GIMPACT/gim_memory.h" - -/*! \addtogroup GEOMETRIC_OPERATIONS -*/ -//! @{ - -//! Capsule struct -struct GIM_CAPSULE_DATA -{ - GREAL m_radius; - vec3f m_point1; - vec3f m_point2; -}; -//typedef struct _GIM_CAPSULE_DATA GIM_CAPSULE_DATA; - -#define CALC_CAPSULE_AABB(capsule,aabb)\ -{\ - if(capsule.m_point1[0]G_EPSILON ?1:0; \ - if(_classif == 0) \ - { \ - if(_prevclassif==1) \ - {\ - if(clipped_count u*axe1[i1] + ((vecproj[i2] - u*axe1[i2])/axe2[i2])*axe2[i1] = vecproj[i1] - - --> u*axe1[i1] + vecproj[i2]*axe2[i1]/axe2[i2] - u*axe1[i2]*axe2[i1]/axe2[i2] = vecproj[i1] - - --> u*(axe1[i1] - axe1[i2]*axe2[i1]/axe2[i2]) = vecproj[i1] - vecproj[i2]*axe2[i1]/axe2[i2] - - --> u*((axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1])/axe2[i2]) = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1])/axe2[i2] - - --> u*(axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1]) = vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1] - - --> u = (vecproj[i1]*axe2[i2] - vecproj[i2]*axe2[i1]) /(axe1[i1]*axe2[i2] - axe1[i2]*axe2[i1]) - -if 0.0<= u+v <=1.0 then they are inside of triangle - - */ -#define TRIANGLE_GET_UVPARAMETERS(point,vec1,vec2,vec3,tri_plane,u,v,outside)\ -{\ - vec3f _axe1, _axe2, _vecproj;\ - VEC_DIFF(_axe1,vec2,vec1);\ - VEC_DIFF(_axe2,vec3,vec1);\ - VEC_DIFF(_vecproj,point,vec1);\ - GUINT _i1,_i2;\ - PLANE_MINOR_AXES(tri_plane, _i1, _i2);\ - if(fabsf(_axe2[_i2])G_EPSILON)\ - {\ - outside = 1;\ - }\ - else\ - {\ - outside = 0;\ - }\ - }\ -}\ - -//! Finds the collision of a ray and a triangle. -#define RAY_TRIANGLE_INTERSECTION(vOrigin,vDir,vec1,vec2,vec3,tri_plane,pout,u,v,tparam,tmax,does_intersect)\ -{\ - RAY_PLANE_COLLISION(tri_plane,vDir,vOrigin,pout,tparam,does_intersect);\ - if(does_intersect != 0)\ - {\ - if(tparam<-G_EPSILON||tparam>tmax+G_EPSILON)\ - {\ - does_intersect = 0;\ - }\ - else\ - {\ - TRIANGLE_GET_UVPARAMETERS(pout,vec1,vec2,vec3,tri_plane,u,v,does_intersect);\ - does_intersect = !does_intersect;\ - }\ - }\ -}\ - - -//! @} - -#endif // GIM_TRI_COLLISION_H_INCLUDED diff --git a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_sphere_collision.h b/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_sphere_collision.h deleted file mode 100644 index a2a81d6..0000000 --- a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_sphere_collision.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef GIM_TRI_SPHERE_COLLISION_H_INCLUDED -#define GIM_TRI_SPHERE_COLLISION_H_INCLUDED - -/*! \file gim_tri_sphere_collision.h -\author Francisco León -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) 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. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - - 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 files - GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -/*! \addtogroup GEOMETRIC_OPERATIONS -*/ -//! @{ - -//! Finds the contact points from a collision of a triangle and a sphere -/*! -\param tri -\param center -\param radius -\param contact_data Contains the closest points on the Sphere, and the normal is pointing to triangle -*/ -int gim_triangle_sphere_collision( - GIM_TRIANGLE_DATA *tri, - vec3f center, GREAL radius, - GIM_TRIANGLE_CONTACT_DATA * contact_data); - -//! @} -#endif // GIM_TRI_SPHERE_COLLISION_H_INCLUDED diff --git a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_trimesh.h b/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_trimesh.h deleted file mode 100644 index b1cdf7f..0000000 --- a/libraries/ode-0.9/GIMPACT/include/GIMPACT/gim_trimesh.h +++ /dev/null @@ -1,539 +0,0 @@ -#ifndef GIM_TRIMESH_H_INCLUDED -#define GIM_TRIMESH_H_INCLUDED -/*! \file gim_trimesh.h -\author Francisco León -*/ -/* ------------------------------------------------------------------------------ -This source file is part of GIMPACT Library. - -For the latest info, see http://gimpact.sourceforge.net/ - -Copyright (c) 2006 Francisco Leon. C.C. 80087371. -email: projectileman@yahoo.com - - This library is free software; you can redistribute it and/or - modify it under the terms of EITHER: - (1) 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. The text of the GNU Lesser - General Public License is included with this library in the - file GIMPACT-LICENSE-LGPL.TXT. - (2) The BSD-style license that is included with this library in - the file GIMPACT-LICENSE-BSD.TXT. - - 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 files - GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details. - ------------------------------------------------------------------------------ -*/ - -#include "GIMPACT/gim_boxpruning.h" -#include "GIMPACT/gim_contact.h" - - -///MAsk defines -#define GIM_TRIMESH_TRANSFORMED_REPLY 1 -#define GIM_TRIMESH_NEED_UPDATE 2 - -/*! \addtogroup TRIMESH -\brief -A Trimesh is the basic geometric structure for representing solid objects. -

    CREATING TRIMESHES

    -
      -
    • For creating trimeshes, you must initialize Buffer managers by calling \ref gimpact_init -
    • Then you must define the vertex and index sources by creating them with \ref BUFFER_ARRAYS routines, and then call \ref gim_trimesh_create_from_arrays. -
    • An alternative way for creaing trimesh objects is calling \ref gim_trimesh_create_from_data. -
    • For access to the trimesh data (vertices, triangle indices), you must call \ref gim_trimesh_locks_work_data , and \ref gim_trimesh_unlocks_work_data for finish the access. -
    • Each time when the trimesh data is modified, you must call \ref gim_trimesh_update after. -
    • When a trimesh is no longer needed, you must call \ref gim_trimesh_destroy. -
    - -

    This is an example of how to create a deformable trimesh that shares vertices with the user application:

    -\code -//Declaration of vertices -vec3f trimeshvertices[200]; -//Declaration of indices -GUINT trimeshindices[100]; - -... Initializing vertices and triangle indices at beginning - -//Then create trimesh -GIM_TRIMESH mytrimesh; - -//Calling trimesh create function - -gim_trimesh_create_from_data( -&mytrimesh, -trimeshvertices,200, -0 ,//copy_vertices is 0 -trimeshindices, -100, -0, //copy_indices is 0 -0 //transformed_reply is 0 -); -\endcode -

    Note that parameter transformed_reply is 0, that means that m_transformed_vertex_buffer is a reference to m_source_vertex on the trimesh, and transformations are not avaliable. Use that configuration if you have to simulate a deformable trimesh like cloth or elastic bodies.

    -

    When the trimesh is no longer needed, destroy it safely with gim_trimesh_destroy()

    -

    UPDATING TRIMESHES

    -

    On simulation loops, is needed to update trimeshes every time for update vertices althought updating triangle boxes and planes cache. There is two ways for update trimeshes:

    -
      -
    • Updating vertices directly. You need to access to the \ref GIM_TRIMESH.m_source_vertex_buffer member; a vertex buffer which has access to the source vertices. -\code -// Access to the source vertices -gim_buffer_array_lock(&mytrimesh.m_source_vertex_buffer, G_MA_READ_WRITE); - -//Get a pointer to the vertex buffer -vec3f * vertexpointer = GIM_BUFFER_ARRAY_POINTER(vec3f,mytrimesh.m_source_vertex_buffer,0); - -//Get the amount of vertices -int veccount = mytrimesh.m_source_vertex_buffer.m_element_count; - -//Modify vertices -for (int i=0;itransformed_reply = 0. -
    -
      -
    • Aplying a transformation. Simply use \ref gim_trimesh_set_tranform . Remember that with this method trimeshes must be created with \ref gim_trimesh_create_from_data with parameter transformed_reply = 1. -
    -

    After updating vertices, you must call \ref gim_trimesh_update()

    -

    TRIMESHES COLLISION

    -

    Before collide trimeshes, you need to update them first.

    -

    Then you must use \ref gim_trimesh_trimesh_collision().

    - -*/ -//! @{ - -//! Prototype for updating vertices -typedef void * gim_update_trimesh_function(struct _GIM_TRIMESH *); - -//! Trimesh -struct GIM_TRIMESH -{ - ///Original - //@{ - GBUFFER_ARRAY m_source_vertex_buffer;//!< Buffer of vec3f coordinates - - //! (GUINT) Indices of triangles,groups of three elements. - /*! - Array of GUINT. Triangle indices. Each triple contains indices of the vertices for each triangle. - \invariant must be aligned - */ - GBUFFER_ARRAY m_tri_index_buffer; - //@} - ///Allocated - //@{ - char m_mask;//!< Don't use directly - - //! Allocated transformed vertices vec3f - /*! - Array of vec3f.If gim_trimesh_has_tranformed_reply(this) == 1 then it refers to the m_source_vertex_buffer - \invariant must be aligned - */ - GBUFFER_ARRAY m_transformed_vertex_buffer; - //@} - ///Auxiliary data - //@{ - GIM_AABB_SET m_aabbset; - GDYNAMIC_ARRAY m_planes_cache_buffer;//! Allocated GIM_TRIPLANES_CACHE - GDYNAMIC_ARRAY m_planes_cache_bitset; - gim_update_trimesh_function * m_update_callback;//! If null, then m_transform is applied. - mat4f m_transform; - //@} -}; -//typedef struct _GIM_TRIMESH GIM_TRIMESH; - -/// Info about mesh -//! Return the trimesh triangle count -GUINT gim_trimesh_get_triangle_count(GIM_TRIMESH * trimesh); - -//! Returns 1 if the m_transformed_vertex_buffer is a reply of m_source_vertex_buffer -char gim_trimesh_has_tranformed_reply(GIM_TRIMESH * trimesh); - -//! Returns 1 if the trimesh needs to update their aabbset and the planes cache. -char gim_trimesh_needs_update(GIM_TRIMESH * trimesh); - -//! Change the state of the trimesh for force it to update -/*! -Call it after made changes to the trimesh. -\post gim_trimesh_need_update(trimesh) will return 1 -\sa gim_trimesh_needs_update,gim_trimesh_has_tranformed_reply -*/ -void gim_trimesh_post_update(GIM_TRIMESH * trimesh); - -//! Creates the aabb set and the triangles cache -/*! - -\param trimesh -\param vertex_array -\param triindex_array -\param transformed_reply If 1, then the m_transformed_vertices is a reply of the source vertices. Else it just be a reference to the original array. -\post it copies the arrays by reference, and creates the auxiliary data (m_aabbset,m_planes_cache_buffer) -*/ -void gim_trimesh_create_from_arrays(GIM_TRIMESH * trimesh, GBUFFER_ARRAY * vertex_array, GBUFFER_ARRAY * triindex_array,char transformed_reply); - - - -//! Create a trimesh from vertex array and an index array -/*! -\param trimesh An uninitialized GIM_TRIMESH structure -\param vertex_array A buffer to a vec3f array -\param vertex_count -\param triindex_array -\param index_count -\param copy_vertices If 1, it copies the source vertices in another buffer. Else (0) it constructs a reference to the data. -\param copy_indices If 1, it copies the source vertices in another buffer. Else (0) it constructs a reference to the data. -\param transformed_reply If 1, then the m_transformed_vertices is a reply of the source vertices. Else it just be a reference to the original array. Use 1 if you will apply transformations to the trimesh. See \ref gim_trimesh_set_tranform(). -*/ -void gim_trimesh_create_from_data(GIM_TRIMESH * trimesh, vec3f * vertex_array, GUINT vertex_count,char copy_vertices, GUINT * triindex_array, GUINT index_count,char copy_indices,char transformed_reply); - -//! Clears auxiliary data and releases buffer arrays -void gim_trimesh_destroy(GIM_TRIMESH * trimesh); - -//! Copies two meshes -/*! -\param source_trimesh -\param dest_trimesh -\param copy_by_reference If 1, it attach a reference to the source vertices, else it copies the vertices -\param transformed_reply If 1, transformed vertices are reply of source vertives. 1 Is recommended -*/ -void gim_trimesh_copy(GIM_TRIMESH * source_trimesh,GIM_TRIMESH * dest_trimesh, char copy_by_reference, char transformed_reply); - - -//! Locks the trimesh for working with it -/*! -\post locks m_tri_index_buffer and m_transformed_vertex_buffer. -\param trimesh -*/ -void gim_trimesh_locks_work_data(GIM_TRIMESH * trimesh); - - -//! unlocks the trimesh -/*! -\post unlocks m_tri_index_buffer and m_transformed_vertex_buffer. -\param trimesh -*/ -void gim_trimesh_unlocks_work_data(GIM_TRIMESH * trimesh); - -//! Updates m_transformed_vertex_buffer -/*! -\pre m_transformed_vertex_buffer must be unlocked -*/ -void gim_trimesh_update_vertices(GIM_TRIMESH * trimesh); - -//! Updates m_aabbset and m_planes_cache_bitset -/*! -\pre gim_trimesh_locks_work_data must be called before -*/ -void gim_trimesh_update_aabbset(GIM_TRIMESH * trimesh); - -//! Calls before perfom collisions. Updates the trimesh if needed -/*! -\post If gim_trimesh_needs_update returns 1, then it calls gim_trimesh_update_vertices and gim_trimesh_update_aabbset -*/ -void gim_trimesh_update(GIM_TRIMESH * trimesh); - -//! Set the transform of a trimesh -/*! -\post This function calls to gim_trimesh_post_update -*/ -void gim_trimesh_set_tranform(GIM_TRIMESH * trimesh, mat4f transform); - -//! Fetch triangle data -/*! -\pre gim_trimesh_locks_work_data must be called before -*/ -void gim_trimesh_get_triangle_data(GIM_TRIMESH * trimesh, GUINT triangle_index, GIM_TRIANGLE_DATA * tri_data); - -//! Fetch triangle vertices -/*! -\pre gim_trimesh_locks_work_data must be called before -*/ -void gim_trimesh_get_triangle_vertices(GIM_TRIMESH * trimesh, GUINT triangle_index, vec3f v1,vec3f v2,vec3f v3); - -//! Trimesh Trimesh Collisions -/*! -Before use this function you must update each trimesh: -\code -gim_trimesh_update(TriMesh1); -gim_trimesh_update(TriMesh2); -\endcode -Then you must use the trimesh collision in this way: -\code -int collide_trimeshes(GIM_TRIMESH * TriMesh1, GIM_TRIMESH * TriMesh2) -{ - //Create contact list - GDYNAMIC_ARRAY trimeshcontacts; - GIM_CREATE_CONTACT_LIST(trimeshcontacts); - - //Collide trimeshes - gim_trimesh_trimesh_collision(TriMesh1,TriMesh2,&trimeshcontacts); - - if(trimeshcontacts.m_size == 0) //do nothing - { - GIM_DYNARRAY_DESTROY(trimeshcontacts);//clean contact array - return 0; - } - - //Getting a pointer to the contact array - GIM_CONTACT * ptrimeshcontacts = GIM_DYNARRAY_POINTER(GIM_CONTACT,trimeshcontacts); - - int contactcount = trimeshcontacts.m_size; - int i; - //Process contacts - for (i=0;i -
  • m_handle1 points to trimesh1. -
  • m_handle2 points to trimesh2. -
  • m_feature1 Is a triangle index of trimesh1. -
  • m_feature2 Is a triangle index of trimesh2. - - -\param trimesh1 Collider -\param trimesh2 Collidee -\param contacts A GIM_CONTACT array. Must be initialized -*/ -void gim_trimesh_trimesh_collision(GIM_TRIMESH * trimesh1, GIM_TRIMESH * trimesh2, GDYNAMIC_ARRAY * contacts); - - -//! Trimesh Sphere Collisions -/*! -Before use this function you must update the trimesh: -\code -gim_trimesh_update(trimesh); -\endcode -Then you must use this function in this way: -\code -int collide_trimesh_sphere(GIM_TRIMESH * trimesh, vec3f center,GREAL radius) -{ - //Create contact list - GDYNAMIC_ARRAY trimeshcontacts; - GIM_CREATE_CONTACT_LIST(trimeshcontacts); - - //Collide trimeshes - gim_trimesh_sphere_collision(trimesh,center,radius,&trimeshcontacts); - - if(trimeshcontacts.m_size == 0) //do nothing - { - GIM_DYNARRAY_DESTROY(trimeshcontacts);//clean contact array - return 0; - } - - //Getting a pointer to the contact array - GIM_CONTACT * ptrimeshcontacts = GIM_DYNARRAY_POINTER(GIM_CONTACT,trimeshcontacts); - - int contactcount = trimeshcontacts.m_size; - int i; - //Process contacts - for (i=0;i -
  • m_handle1 points to trimesh. -
  • m_handle2 points to NULL. -
  • m_feature1 Is a triangle index of trimesh. - - -\param trimesh -\param center -\param radius -\param contacts A GIM_CONTACT array. Must be initialized -*/ -void gim_trimesh_sphere_collision(GIM_TRIMESH * trimesh,vec3f center,GREAL radius, GDYNAMIC_ARRAY * contacts); - - -//! Trimesh Capsule collision -/*! -Find the closest primitive collided by the ray. - -Before use this function you must update the trimesh: -\code -gim_trimesh_update(trimesh); -\endcode -Then you must use this function in this way: -\code -int collide_trimesh_capsule(GIM_TRIMESH * trimesh, GIM_CAPSULE_DATA * capsule) -{ - //Create contact list - GDYNAMIC_ARRAY trimeshcontacts; - GIM_CREATE_CONTACT_LIST(trimeshcontacts); - - //Collide trimeshes - gim_trimesh_capsule_collision(trimesh,capsule,&trimeshcontacts); - - if(trimeshcontacts.m_size == 0) //do nothing - { - GIM_DYNARRAY_DESTROY(trimeshcontacts);//clean contact array - return 0; - } - - //Getting a pointer to the contact array - GIM_CONTACT * ptrimeshcontacts = GIM_DYNARRAY_POINTER(GIM_CONTACT,trimeshcontacts); - - int contactcount = trimeshcontacts.m_size; - int i; - //Process contacts - for (i=0;i -
  • m_handle1 points to trimesh. -
  • m_handle2 points to NULL. -
  • m_feature1 Is a triangle index of trimesh. - - -\param trimesh -\param capsule -\param contacts A GIM_CONTACT array. Must be initialized -*/ -void gim_trimesh_capsule_collision(GIM_TRIMESH * trimesh, GIM_CAPSULE_DATA * capsule, GDYNAMIC_ARRAY * contacts); - - -///Function for create Trimesh Plane collision result -#define GIM_CREATE_TRIMESHPLANE_CONTACTS(dynarray) GIM_DYNARRAY_CREATE(vec4f,dynarray,G_ARRAY_GROW_SIZE) - -//! Trimesh Plane Collisions -/*! - -Before use this function you must update the trimesh: -\code -gim_trimesh_update(trimesh); -\endcode -Then you must use this function in this way: -\code -int collide_trimesh_plane(GIM_TRIMESH * trimesh, vec4f plane) -{ - //Create contact list - GDYNAMIC_ARRAY tri_plane_contacts; - GIM_CREATE_TRIMESHPLANE_CONTACTS(tri_plane_contacts); - - //Collide trimeshes - gim_trimesh_plane_collision(trimesh,plane,&tri_plane_contacts); - - if(tri_plane_contacts.m_size == 0) //do nothing - { - GIM_DYNARRAY_DESTROY(tri_plane_contacts);//clean contact array - return 0; - } - - //Getting a pointer to the contact array - vec4f * planecontacts = GIM_DYNARRAY_POINTER(vec4f,tri_plane_contacts); - - int contactcount = tri_plane_contacts.m_size; - int i; - //Process contacts - for (i=0;i