00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "physxUtilLib.h"
00016 #include "physxManager.h"
00017 #include "physxBounds3.h"
00018 #include "physxBox.h"
00019 #include "physxCapsule.h"
00020 #include "physxPlane.h"
00021 #include "physxRay.h"
00022 #include "physxSegment.h"
00023 #include "physxSphere.h"
00024
00025
00026
00027
00028
00029
00030 void PhysxUtilLib::
00031 set_fpu_exceptions(bool b) {
00032
00033 _ptr->NxSetFPUExceptions(b);
00034 }
00035
00036
00037
00038
00039
00040
00041 void PhysxUtilLib::
00042 set_fpu_precision24() {
00043
00044 _ptr->NxSetFPUPrecision24();
00045 }
00046
00047
00048
00049
00050
00051
00052 void PhysxUtilLib::
00053 set_fpu_precision53() {
00054
00055 _ptr->NxSetFPUPrecision53();
00056 }
00057
00058
00059
00060
00061
00062
00063 void PhysxUtilLib::
00064 set_fpu_precision64() {
00065
00066 _ptr->NxSetFPUPrecision64();
00067 }
00068
00069
00070
00071
00072
00073
00074 void PhysxUtilLib::
00075 set_fpu_rounding_chop() {
00076
00077 _ptr->NxSetFPURoundingChop();
00078 }
00079
00080
00081
00082
00083
00084
00085 void PhysxUtilLib::
00086 set_fpu_rounding_down() {
00087
00088 _ptr->NxSetFPURoundingDown();
00089 }
00090
00091
00092
00093
00094
00095
00096 void PhysxUtilLib::
00097 set_fpu_rounding_near() {
00098
00099 _ptr->NxSetFPURoundingNear();
00100 }
00101
00102
00103
00104
00105
00106
00107 void PhysxUtilLib::
00108 set_fpu_rounding_up() {
00109
00110 _ptr->NxSetFPURoundingUp();
00111 }
00112
00113
00114
00115
00116
00117
00118 int PhysxUtilLib::
00119 int_ceil(const float &f) {
00120
00121 return _ptr->NxIntCeil(f);
00122 }
00123
00124
00125
00126
00127
00128
00129 int PhysxUtilLib::
00130 int_chop(const float &f) {
00131
00132 return _ptr->NxIntChop(f);
00133 }
00134
00135
00136
00137
00138
00139
00140 int PhysxUtilLib::
00141 int_floor(const float &f) {
00142
00143 return _ptr->NxIntFloor(f);
00144 }
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 bool PhysxUtilLib::
00155 box_contains_point(const PhysxBox &box, const LPoint3f &p) {
00156
00157 return _ptr->NxBoxContainsPoint(box._box, PhysxManager::point3_to_nxVec3(p));
00158 }
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 PhysxBox PhysxUtilLib::
00170 create_box(const PhysxBounds3 &aabb, const LMatrix4f &mat) {
00171
00172 PhysxBox box;
00173 _ptr->NxCreateBox(box._box, aabb._bounds, PhysxManager::mat4_to_nxMat34(mat));
00174 return box;
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 LVector3f PhysxUtilLib::
00189 compute_box_world_edge_normal(const PhysxBox &box, unsigned int edge_index) {
00190
00191 NxVec3 nNormal;
00192
00193 nassertr(edge_index < 12, LVector3f::zero());
00194
00195 _ptr->NxComputeBoxWorldEdgeNormal(box._box, edge_index, nNormal);
00196 return PhysxManager::nxVec3_to_vec3(nNormal);
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206 PhysxCapsule PhysxUtilLib::
00207 compute_capsule_around_box(const PhysxBox &box) {
00208
00209 PhysxCapsule capsule;
00210 _ptr->NxComputeCapsuleAroundBox(box._box, capsule._capsule);
00211 return capsule;
00212 }
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223 bool PhysxUtilLib::
00224 is_box_a_inside_box_b(const PhysxBox &a, const PhysxBox &b) {
00225
00226 return _ptr->NxIsBoxAInsideBoxB(a._box, b._box);
00227 }
00228
00229
00230
00231
00232
00233
00234
00235
00236 PhysxBox PhysxUtilLib::
00237 compute_box_around_capsule(const PhysxCapsule &capsule) {
00238
00239 PhysxBox box;
00240 _ptr->NxComputeBoxAroundCapsule(capsule._capsule, box._box);
00241 return box;
00242 }
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 float PhysxUtilLib::
00254 compute_distance_squared(const PhysxRay &ray, const LPoint3f &point) {
00255
00256 NxF32 t;
00257 return _ptr->NxComputeDistanceSquared(ray._ray, PhysxManager::point3_to_nxVec3(point), &t);
00258 }
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 float PhysxUtilLib::
00270 compute_square_distance(const PhysxSegment &seg, const LPoint3f &point) {
00271
00272 NxF32 t;
00273 return _ptr->NxComputeSquareDistance(seg._segment, PhysxManager::point3_to_nxVec3(point), &t);
00274 }
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 PhysxSphere PhysxUtilLib::
00286 merge_spheres(const PhysxSphere &sphere0, const PhysxSphere &sphere1) {
00287
00288 PhysxSphere merged;
00289 _ptr->NxMergeSpheres(merged._sphere, sphere0._sphere, sphere1._sphere);
00290 return merged;
00291 }
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 void PhysxUtilLib::
00303 normal_to_tangents(const LVector3f &n, LVector3f &t1, LVector3f &t2) {
00304
00305 NxVec3 nt1;
00306 NxVec3 nt2;
00307
00308 _ptr->NxNormalToTangents(PhysxManager::vec3_to_nxVec3(n), nt1, nt2);
00309
00310 t1.set_x(nt1.x);
00311 t1.set_y(nt1.y);
00312 t1.set_z(nt1.z);
00313
00314 t2.set_x(nt2.x);
00315 t2.set_y(nt2.y);
00316 t2.set_z(nt2.z);
00317 }
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328 LMatrix3f PhysxUtilLib::
00329 find_rotation_matrix(const LVector3f &x, const LVector3f &b) {
00330
00331 NxMat33 nmat;
00332 _ptr->NxFindRotationMatrix(PhysxManager::vec3_to_nxVec3(x),
00333 PhysxManager::vec3_to_nxVec3(b),
00334 nmat);
00335 return PhysxManager::nxMat33_to_mat3(nmat);
00336 }
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 float PhysxUtilLib::
00348 compute_sphere_mass(float radius, float density) {
00349
00350 return _ptr->NxComputeSphereMass(radius, density);
00351 }
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 float PhysxUtilLib::
00363 compute_sphere_density(float radius, float mass) {
00364
00365 return _ptr->NxComputeSphereDensity(radius, mass);
00366 }
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377 float PhysxUtilLib::
00378 compute_box_mass(const LVector3f &extents, float density) {
00379
00380 return _ptr->NxComputeBoxMass(PhysxManager::vec3_to_nxVec3(extents), density);
00381 }
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392 float PhysxUtilLib::
00393 compute_box_density(const LVector3f &extents, float mass) {
00394
00395 return _ptr->NxComputeBoxDensity(PhysxManager::vec3_to_nxVec3(extents), mass);
00396 }
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 float PhysxUtilLib::
00408 compute_ellipsoid_mass(const LVector3f &extents, float density ) {
00409
00410 return _ptr->NxComputeEllipsoidMass(PhysxManager::vec3_to_nxVec3(extents), density);
00411 }
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422 float PhysxUtilLib::
00423 compute_ellipsoid_density(const LVector3f &extents, float mass) {
00424
00425 return _ptr->NxComputeEllipsoidDensity(PhysxManager::vec3_to_nxVec3(extents), mass);
00426 }
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437 float PhysxUtilLib::
00438 compute_cylinder_mass(float radius, float length, float density) {
00439
00440 return _ptr->NxComputeCylinderMass(radius, length, density);
00441 }
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 float PhysxUtilLib::
00453 compute_cylinder_density(float radius, float length, float mass) {
00454
00455 return _ptr->NxComputeCylinderDensity(radius, length, mass);
00456 }
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 float PhysxUtilLib::
00468 compute_cone_mass(float radius, float length, float density) {
00469
00470 return _ptr->NxComputeConeMass(radius, length, density);
00471 }
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482 float PhysxUtilLib::
00483 compute_cone_density(float radius, float length, float mass) {
00484
00485 return _ptr->NxComputeConeDensity(radius, length, mass);
00486 }
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498 LVector3f PhysxUtilLib::
00499 compute_box_inertia_tensor(float mass, float xlength, float ylength, float zlength) {
00500
00501 NxVec3 tensor;
00502 _ptr->NxComputeBoxInertiaTensor(tensor, mass, xlength, ylength, zlength);
00503 return PhysxManager::nxVec3_to_vec3(tensor);
00504 }
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515 LVector3f PhysxUtilLib::
00516 compute_sphere_inertia_tensor(float mass, float radius, bool hollow) {
00517
00518 NxVec3 tensor;
00519 _ptr->NxComputeSphereInertiaTensor(tensor, mass, radius, hollow);
00520 return PhysxManager::nxVec3_to_vec3(tensor);
00521 }
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538 bool PhysxUtilLib::
00539 box_box_intersect(const LVector3f &extents0, const LPoint3f ¢er0, const LMatrix3f &rotation0, const LVector3f &extents1, const LPoint3f ¢er1, const LMatrix3f &rotation1, bool full_test) {
00540
00541 nassertr_always(!extents0.is_nan(), false);
00542 nassertr_always(!center0.is_nan(), false);
00543 nassertr_always(!rotation0.is_nan(), false);
00544 nassertr_always(!extents1.is_nan(), false);
00545 nassertr_always(!center1.is_nan(), false);
00546 nassertr_always(!rotation1.is_nan(), false);
00547
00548 return _ptr->NxBoxBoxIntersect(
00549 PhysxManager::vec3_to_nxVec3(extents0),
00550 PhysxManager::point3_to_nxVec3(center0),
00551 PhysxManager::mat3_to_nxMat33(rotation0),
00552 PhysxManager::vec3_to_nxVec3(extents1),
00553 PhysxManager::point3_to_nxVec3(center1),
00554 PhysxManager::mat3_to_nxMat33(rotation1), full_test);
00555 }
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569 bool PhysxUtilLib::
00570 tri_box_intersect(const LPoint3f &vertex0, const LPoint3f &vertex1, const LPoint3f &vertex2, const LPoint3f ¢er, const LVector3f &extents) {
00571
00572 nassertr_always(!vertex0.is_nan(), false);
00573 nassertr_always(!vertex1.is_nan(), false);
00574 nassertr_always(!vertex2.is_nan(), false);
00575 nassertr_always(!center.is_nan(), false);
00576 nassertr_always(!extents.is_nan(), false);
00577
00578 return _ptr->NxTriBoxIntersect(
00579 PhysxManager::point3_to_nxVec3(vertex0),
00580 PhysxManager::point3_to_nxVec3(vertex1),
00581 PhysxManager::point3_to_nxVec3(vertex2),
00582 PhysxManager::point3_to_nxVec3(center),
00583 PhysxManager::point3_to_nxVec3(extents));
00584 }
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595 bool PhysxUtilLib::
00596 ray_plane_intersect(const PhysxRay &ray, const PhysxPlane &plane, LPoint3f &point_on_plane) {
00597
00598 NxReal dist;
00599 NxVec3 nPointOnPlane;
00600
00601 bool result = _ptr->NxRayPlaneIntersect(ray._ray, plane._plane, dist, nPointOnPlane);
00602
00603 PhysxManager::update_point3_from_nxVec3(point_on_plane, nPointOnPlane);
00604 return result;
00605 }
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621 bool PhysxUtilLib::
00622 ray_sphere_intersect(const LPoint3f &origin, const LVector3f &dir, float length, const LPoint3f ¢er, float radius, LPoint3f &hit_pos) {
00623
00624 nassertr_always(!origin.is_nan(), false);
00625 nassertr_always(!dir.is_nan(), false);
00626 nassertr_always(!center.is_nan(), false);
00627
00628 NxReal nHitTime;
00629 NxVec3 nPointOnPlane;
00630
00631 bool result = _ptr->NxRaySphereIntersect(
00632 PhysxManager::point3_to_nxVec3(origin),
00633 PhysxManager::vec3_to_nxVec3(dir),
00634 length,
00635 PhysxManager::point3_to_nxVec3(center),
00636 radius,
00637 nHitTime,
00638 nPointOnPlane);
00639
00640 PhysxManager::update_point3_from_nxVec3(hit_pos, nPointOnPlane);
00641 return result;
00642 }
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656 bool PhysxUtilLib::
00657 segment_box_intersect(const LPoint3f &p1, const LPoint3f &p2, const LPoint3f &bbox_min, const LPoint3f &bbox_max, LPoint3f &intercept) {
00658
00659 nassertr_always(!p1.is_nan(), false);
00660 nassertr_always(!p2.is_nan(), false);
00661 nassertr_always(!bbox_min.is_nan(), false);
00662 nassertr_always(!bbox_max.is_nan(), false);
00663
00664 NxVec3 nIntercept;
00665
00666 bool result =_ptr->NxSegmentBoxIntersect(
00667 PhysxManager::point3_to_nxVec3(p1),
00668 PhysxManager::point3_to_nxVec3(p2),
00669 PhysxManager::point3_to_nxVec3(bbox_min),
00670 PhysxManager::point3_to_nxVec3(bbox_max),
00671 nIntercept);
00672
00673 PhysxManager::update_point3_from_nxVec3(intercept, nIntercept);
00674 return result;
00675 }
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689 bool PhysxUtilLib::
00690 ray_aabb_intersect(const LPoint3f &min, const LPoint3f &max, const LPoint3f &origin, const LVector3f &dir, LPoint3f &coord) {
00691
00692 nassertr_always(!min.is_nan(), false);
00693 nassertr_always(!max.is_nan(), false);
00694 nassertr_always(!origin.is_nan(), false);
00695 nassertr_always(!dir.is_nan(), false);
00696
00697 NxVec3 nCoord;
00698
00699 bool result = _ptr->NxRayAABBIntersect(
00700 PhysxManager::point3_to_nxVec3(min),
00701 PhysxManager::point3_to_nxVec3(max),
00702 PhysxManager::point3_to_nxVec3(origin),
00703 PhysxManager::vec3_to_nxVec3(dir),
00704 nCoord);
00705
00706 PhysxManager::update_point3_from_nxVec3(coord, nCoord);
00707 return result;
00708 }
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722 bool PhysxUtilLib::
00723 segment_obb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot) {
00724
00725 nassertr_always(!p0.is_nan(), false);
00726 nassertr_always(!p1.is_nan(), false);
00727 nassertr_always(!center.is_nan(), false);
00728 nassertr_always(!extents.is_nan(), false);
00729 nassertr_always(!rot.is_nan(), false);
00730
00731 return _ptr->NxSegmentOBBIntersect(
00732 PhysxManager::point3_to_nxVec3(p0),
00733 PhysxManager::point3_to_nxVec3(p1),
00734 PhysxManager::point3_to_nxVec3(center),
00735 PhysxManager::vec3_to_nxVec3(extents),
00736 PhysxManager::mat3_to_nxMat33(rot));
00737 }
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750 bool PhysxUtilLib::
00751 segment_aabb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &min, const LPoint3f &max) {
00752
00753 nassertr_always(!p0.is_nan(), false);
00754 nassertr_always(!p1.is_nan(), false);
00755 nassertr_always(!min.is_nan(), false);
00756 nassertr_always(!max.is_nan(), false);
00757
00758 return _ptr->NxSegmentAABBIntersect(
00759 PhysxManager::point3_to_nxVec3(p0),
00760 PhysxManager::point3_to_nxVec3(p1),
00761 PhysxManager::point3_to_nxVec3(min),
00762 PhysxManager::point3_to_nxVec3(max));
00763 }
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776 bool PhysxUtilLib::
00777 ray_obb_intersect(const PhysxRay &ray, const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot) {
00778
00779 nassertr_always(!center.is_nan(), false);
00780 nassertr_always(!extents.is_nan(), false);
00781 nassertr_always(!rot.is_nan(), false);
00782
00783 return _ptr->NxRayOBBIntersect(
00784 ray._ray,
00785 PhysxManager::point3_to_nxVec3(center),
00786 PhysxManager::point3_to_nxVec3(extents),
00787 PhysxManager::mat3_to_nxMat33(rot));
00788 }
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800 unsigned int PhysxUtilLib::
00801 ray_capsule_intersect(const LPoint3f &origin, const LVector3f &dir, const PhysxCapsule &capsule) {
00802
00803 nassertr_always(!origin.is_nan(), -1);
00804 nassertr_always(!dir.is_nan(), -1);
00805
00806 NxReal t[2] = { 0.0f, 0.0f };
00807
00808 return _ptr->NxRayCapsuleIntersect(
00809 PhysxManager::point3_to_nxVec3(origin),
00810 PhysxManager::vec3_to_nxVec3(dir),
00811 capsule._capsule, t);
00812 }
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826 bool PhysxUtilLib::
00827 swept_spheres_intersect(const PhysxSphere &sphere0, const LVector3f &velocity0, const PhysxSphere &sphere1, const LVector3f &velocity1) {
00828
00829 nassertr_always(!velocity0.is_nan(), false);
00830 nassertr_always(!velocity1.is_nan(), false);
00831
00832 return _ptr->NxSweptSpheresIntersect(
00833 sphere0._sphere,
00834 PhysxManager::vec3_to_nxVec3(velocity0),
00835 sphere1._sphere,
00836 PhysxManager::vec3_to_nxVec3(velocity1));
00837 }
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855 bool PhysxUtilLib::
00856 ray_tri_intersect(const LPoint3f &orig, const LVector3f &dir, const LPoint3f &vert0, const LPoint3f &vert1, const LPoint3f &vert2, LVector3f &hit, bool cull) {
00857
00858 nassertr_always(!orig.is_nan(), false);
00859 nassertr_always(!dir.is_nan(), false);
00860 nassertr_always(!vert0.is_nan(), false);
00861 nassertr_always(!vert1.is_nan(), false);
00862 nassertr_always(!vert2.is_nan(), false);
00863
00864 NxReal t, u, v;
00865
00866 bool result = _ptr->NxRayTriIntersect(
00867 PhysxManager::point3_to_nxVec3(orig),
00868 PhysxManager::vec3_to_nxVec3(dir),
00869 PhysxManager::point3_to_nxVec3(vert0),
00870 PhysxManager::point3_to_nxVec3(vert1),
00871 PhysxManager::point3_to_nxVec3(vert2),
00872 t, u, v, cull);
00873
00874 hit.set_x(t);
00875 hit.set_y(u);
00876 hit.set_z(v);
00877
00878 return result;
00879 }
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894 bool PhysxUtilLib::
00895 sweep_box_capsule(const PhysxBox &box, const PhysxCapsule &lss, const LVector3f &dir, float length, LVector3f &normal) {
00896
00897 nassertr_always(!dir.is_nan(), false);
00898
00899 NxReal min_dist;
00900 NxVec3 nNormal;
00901
00902 bool result = _ptr->NxSweepBoxCapsule(
00903 box._box, lss._capsule,
00904 PhysxManager::vec3_to_nxVec3(dir),
00905 length, min_dist, nNormal);
00906
00907 PhysxManager::update_vec3_from_nxVec3(normal, nNormal);
00908 return result;
00909 }
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924 bool PhysxUtilLib::
00925 sweep_box_sphere(const PhysxBox &box, const PhysxSphere &sphere, const LVector3f &dir, float length, LVector3f &normal) {
00926
00927 nassertr_always(!dir.is_nan(), false);
00928
00929 NxReal min_dist;
00930 NxVec3 nNormal;
00931
00932 bool result = _ptr->NxSweepBoxSphere(
00933 box._box, sphere._sphere,
00934 PhysxManager::vec3_to_nxVec3(dir),
00935 length, min_dist, nNormal);
00936
00937 PhysxManager::update_vec3_from_nxVec3(normal, nNormal);
00938 return result;
00939 }
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955 bool PhysxUtilLib::
00956 sweep_capsule_capsule(const PhysxCapsule &lss0, const PhysxCapsule &lss1, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal) {
00957
00958 nassertr_always(!dir.is_nan(), false);
00959
00960 NxReal min_dist;
00961 NxVec3 nIp;
00962 NxVec3 nNormal;
00963
00964 bool result = _ptr->NxSweepCapsuleCapsule(
00965 lss0._capsule, lss1._capsule,
00966 PhysxManager::vec3_to_nxVec3(dir),
00967 length, min_dist, nIp, nNormal);
00968
00969 PhysxManager::update_point3_from_nxVec3(ip, nIp);
00970 PhysxManager::update_vec3_from_nxVec3(normal, nNormal);
00971 return result;
00972 }
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988 bool PhysxUtilLib::
00989 sweep_sphere_capsule(const PhysxSphere &sphere, const PhysxCapsule &lss, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal) {
00990
00991 nassertr_always(!dir.is_nan(), false);
00992
00993 NxReal min_dist;
00994 NxVec3 nIp;
00995 NxVec3 nNormal;
00996
00997 bool result = _ptr->NxSweepSphereCapsule(
00998 sphere._sphere, lss._capsule,
00999 PhysxManager::vec3_to_nxVec3(dir),
01000 length, min_dist, nIp, nNormal);
01001
01002 PhysxManager::update_point3_from_nxVec3(ip, nIp);
01003 PhysxManager::update_vec3_from_nxVec3(normal, nNormal);
01004 return result;
01005 }
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021 bool PhysxUtilLib::
01022 sweep_box_box(const PhysxBox &box0, const PhysxBox &box1, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal) {
01023
01024 nassertr_always(!dir.is_nan(), false);
01025
01026 NxReal min_dist;
01027 NxVec3 nIp;
01028 NxVec3 nNormal;
01029
01030 bool result = _ptr->NxSweepBoxBox(
01031 box0._box, box1._box,
01032 PhysxManager::vec3_to_nxVec3(dir),
01033 length, nIp, nNormal, min_dist);
01034
01035 PhysxManager::update_point3_from_nxVec3(ip, nIp);
01036 PhysxManager::update_vec3_from_nxVec3(normal, nNormal);
01037 return result;
01038 }
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052 float PhysxUtilLib::
01053 point_obb_sqr_dist(const LPoint3f &point, const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot, LPoint3f ¶ms) {
01054
01055 nassertr_always(!point.is_nan(), 0.0f);
01056 nassertr_always(!center.is_nan(), 0.0f);
01057 nassertr_always(!extents.is_nan(), 0.0f);
01058 nassertr_always(!rot.is_nan(), 0.0f);
01059
01060 NxVec3 nParams;
01061
01062 float result = _ptr->NxPointOBBSqrDist(
01063 PhysxManager::point3_to_nxVec3(point),
01064 PhysxManager::point3_to_nxVec3(center),
01065 PhysxManager::vec3_to_nxVec3(extents),
01066 PhysxManager::mat3_to_nxMat33(rot),
01067 &nParams);
01068
01069 PhysxManager::update_point3_from_nxVec3(params, nParams);
01070 return result;
01071 }
01072