00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __SIM_SweptCollisionUtility_h__
00021 #define __SIM_SweptCollisionUtility_h__
00022
00023 #include "SIM_API.h"
00024 #include "SIM_SweptCollisionData.h"
00025 #include <vector>
00026
00027 class SIM_Engine;
00028 class SIM_Object;
00029 class SIM_Impacts;
00030 class SIM_Geometry;
00031 class SIM_GeometryCopy;
00032 class SIM_Time;
00033 class UT_DMatrix4;
00034 class UT_Vector3;
00035
00036
00037
00038
00039
00040
00041
00042 inline bool SIMisValidIndex(const int i, const int n)
00043 {
00044 return (0 <= i) && (i < n);
00045 }
00046
00047
00048
00049 struct SIM_API SIM_MergedIdentityPoint
00050 {
00051 SIM_MergedIdentityPoint() :
00052 myIndexObject(-1),
00053 myPid(-1)
00054 {
00055 }
00056
00057
00058 int myIndexObject;
00059
00060 int myPid;
00061 };
00062
00063
00064
00065 class SIM_API SIM_MergeMap
00066 {
00067 public:
00068
00069 void getObjectAndPid(int& index_object, int& pid, const int p) const
00070 {
00071 UT_ASSERT( (0 <= p) && (p < myIdentities.size()) );
00072
00073 const SIM_MergedIdentityPoint& id(myIdentities[p]);
00074 index_object = id.myIndexObject;
00075 pid = id.myPid;
00076 }
00077
00078
00079 inline int getNumPointsMerged() const
00080 {
00081 return myIdentities.size();
00082 }
00083
00084 private:
00085
00086 std::vector<SIM_MergedIdentityPoint> myIdentities;
00087
00088 std::vector< std::pair< int, int > > myRanges;
00089
00090 friend void SIM_API
00091 SIMmergePoints(
00092 SIM_MergeMap& merged_points,
00093 const std::vector<const SIM_Geometry*>& geometries
00094 );
00095
00096 friend class SIM_MergeMapObject;
00097 };
00098
00099
00100
00101
00102
00103 class SIM_API SIM_MergeMapObject
00104 {
00105 public:
00106 SIM_MergeMapObject(
00107 const SIM_MergeMap& merged_points,
00108 const int index_object
00109 ) :
00110 myIdentities(merged_points.myIdentities),
00111 myBegin(merged_points.myRanges[index_object].first),
00112 myEnd(merged_points.myRanges[index_object].second)
00113 {
00114 UT_ASSERT( 0 <= index_object );
00115 UT_ASSERT( index_object < merged_points.myRanges.size() );
00116 }
00117
00118
00119
00120 inline int getP(const int pid) const
00121 {
00122 UT_ASSERT( (0 <= pid) && (pid < myEnd - myBegin) );
00123
00124 return myBegin + pid;
00125 }
00126
00127 inline int getNumPointsObject() const
00128 {
00129 return myEnd - myBegin;
00130 }
00131
00132 inline int getNumPointsMerged() const
00133 {
00134 return myEnd - myBegin;
00135 }
00136
00137 private:
00138 const std::vector<SIM_MergedIdentityPoint>& myIdentities;
00139 const int myBegin;
00140 const int myEnd;
00141
00142
00143 SIM_MergeMapObject(const SIM_MergeMapObject&);
00144 SIM_MergeMapObject operator=(const SIM_MergeMapObject&);
00145 };
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 void SIM_API
00156 SIMmergePoints(
00157 SIM_MergeMap& merged_points,
00158 const std::vector<const SIM_Geometry*>& geometries
00159 );
00160
00161
00162 extern void SIM_API
00163 SIMextractTriangleConnectivityMerged(
00164 SIM_TriangleConnectivity& triangles,
00165 const SIM_MergeMap& merged_points,
00166 const std::vector<const SIM_Geometry*>& geometries
00167 );
00168
00169
00170
00171
00172 extern bool SIM_API
00173 SIMgetGeometryAndTransform(
00174 const SIM_Geometry*& geometry,
00175 UT_DMatrix4& geometry_to_sim,
00176 const SIM_Object& object
00177 );
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 extern bool SIM_API
00188 SIMgetGeometryAndTransformAtTime(
00189 const SIM_Geometry*& geometry,
00190 UT_DMatrix4& geometry_to_sim,
00191 const SIM_Engine& engine,
00192 const SIM_Object& undated_object,
00193 const SIM_Time& t
00194 );
00195
00196
00197
00198
00199
00200 extern void SIM_API
00201 SIMreadThicknessPoints(
00202 std::vector<fpreal>& thickness_points,
00203 const SIM_MergeMap& merged_points,
00204 const std::vector<const SIM_Geometry*>& geometries_end,
00205 const fpreal default_thickness
00206 );
00207
00208
00209
00210
00211
00212
00213
00214 class SIM_Position;
00215 class SIM_Object;
00216 class SIM_Engine;
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 extern void SIM_API
00229 SIMreadSweptState(
00230 SIM_MergeMap& merged_points,
00231 std::vector<int>& id_objects,
00232 std::vector<fpreal>& thickness_points,
00233 SIM_PositionPoints& position_points_start,
00234 SIM_PositionPoints& position_points_end,
00235 SIM_VelocityPoints& velocity_points_end,
00236 const SIM_Engine& engine,
00237 const std::vector<const SIM_Object*>& objects,
00238 const fpreal default_thickness,
00239 const fpreal t_start,
00240 const fpreal t_end
00241 );
00242
00243 extern void SIM_API
00244 SIMextractTriangleConnectivityMerged(
00245 SIM_TriangleConnectivity& triangles,
00246 const SIM_MergeMap& merged_points,
00247 const std::vector<const SIM_Object*>& objects
00248 );
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 extern void SIM_API
00260 SIMreadPositionPoints(
00261 SIM_PositionPoints& position_points,
00262 const SIM_MergeMap& merged_points,
00263 const std::vector<UT_DMatrix4>& transforms,
00264 const std::vector<const SIM_Geometry*>& geometries
00265 );
00266
00267
00268
00269 extern void SIM_API
00270 SIMreadPositionAndVelocityPoints(
00271 SIM_PositionPoints& position_points,
00272 SIM_VelocityPoints& velocity_points,
00273 const SIM_MergeMap& merged_points,
00274 const std::vector<UT_DMatrix4>& transforms,
00275 const std::vector<const SIM_Geometry*>& geometries
00276 );
00277
00278
00279
00280
00281
00282
00283
00284
00285 extern void SIM_API
00286 SIMwritePositionAndVelocityPoints(
00287 const std::vector<SIM_GeometryCopy*>& geometries,
00288 const SIM_MergeMap& merged_points,
00289 const SIM_PositionPoints& position_points,
00290 const SIM_VelocityPoints& velocity_points,
00291 const std::vector<UT_DMatrix4>& transforms
00292 );
00293
00294
00295
00296
00297
00298 extern void SIM_API
00299 SIMreadPreviousPositionAttribute(
00300 SIM_PositionPoints& position_points,
00301 const SIM_MergeMap& merge_map,
00302 const std::vector<const SIM_Geometry*>& geometries_end
00303 );
00304
00305
00306
00307
00308
00309 extern void SIM_API
00310 SIMwritePreviousPositionAttribute(
00311 std::vector<SIM_GeometryCopy*>& geometries_end,
00312 const SIM_MergeMap& merge_map,
00313 const SIM_PositionPoints& position_points
00314 );
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326 extern bool SIM_API
00327 SIMdetectCollisionsAndGenerateImpulses(
00328 SIM_Impacts* impacts_a,
00329 SIM_Impacts* impacts_b,
00330 const SIM_Engine& engine,
00331 const SIM_Object*const undated_object_a,
00332 const SIM_Object*const undated_object_b,
00333 const SIM_Time& t_start,
00334 const SIM_Time& t_end,
00335 const int impact_flags
00336 );
00337
00338 #endif
00339