00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "physxActor.h"
00016 #include "physxActorDesc.h"
00017 #include "physxBodyDesc.h"
00018 #include "physxShapeDesc.h"
00019 #include "physxManager.h"
00020
00021 TypeHandle PhysxActor::_type_handle;
00022
00023
00024
00025
00026
00027
00028 void PhysxActor::
00029 link(NxActor *actorPtr) {
00030
00031
00032 _ptr = actorPtr;
00033 _ptr->userData = this;
00034 _error_type = ET_ok;
00035
00036 set_name(actorPtr->getName());
00037
00038 PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
00039 scene->_actors.add(this);
00040
00041
00042 NxShape * const *shapes = _ptr->getShapes();
00043 NxU32 nShapes = _ptr->getNbShapes();
00044
00045 for (NxU32 i=0; i < nShapes; i++) {
00046 PhysxShape *shape = PhysxShape::factory(shapes[i]->getType());
00047 shape->link(shapes[i]);
00048 }
00049 }
00050
00051
00052
00053
00054
00055
00056 void PhysxActor::
00057 unlink() {
00058
00059
00060 NxShape * const *shapes = _ptr->getShapes();
00061 NxU32 nShapes = _ptr->getNbShapes();
00062
00063 for (NxU32 i=0; i < nShapes; i++) {
00064 PhysxShape *shape = (PhysxShape *)shapes[i]->userData;
00065 shape->unlink();
00066 }
00067
00068
00069 _ptr->userData = NULL;
00070 _error_type = ET_released;
00071
00072 PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
00073 scene->_actors.remove(this);
00074 }
00075
00076
00077
00078
00079
00080
00081 void PhysxActor::
00082 release() {
00083
00084 nassertv(_error_type == ET_ok);
00085
00086 unlink();
00087 _ptr->getScene().releaseActor(*_ptr);
00088 _ptr = NULL;
00089 }
00090
00091
00092
00093
00094
00095
00096 void PhysxActor::
00097 link_controller(PhysxController *controller) {
00098
00099 _controller = controller;
00100 }
00101
00102
00103
00104
00105
00106
00107
00108 bool PhysxActor::
00109 save_body_to_desc(PhysxBodyDesc &bodyDesc) const {
00110
00111 nassertr(_error_type == ET_ok, false);
00112 return _ptr->saveBodyToDesc(bodyDesc._desc);
00113 }
00114
00115
00116
00117
00118
00119
00120
00121 void PhysxActor::
00122 save_to_desc(PhysxActorDesc &actorDesc) const {
00123
00124 nassertv(_error_type == ET_ok);
00125 _ptr->saveToDesc(actorDesc._desc);
00126 }
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 void PhysxActor::
00137 set_name(const char *name) {
00138
00139 nassertv(_error_type == ET_ok);
00140
00141 _name = name ? name : "";
00142 _ptr->setName(_name.c_str());
00143 }
00144
00145
00146
00147
00148
00149
00150 const char *PhysxActor::
00151 get_name() const {
00152
00153 nassertr(_error_type == ET_ok, "");
00154 return _ptr->getName();
00155 }
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 void PhysxActor::
00166 update_transform(const LMatrix4f m) {
00167
00168
00169
00170
00171
00172
00173 if (_error_type != ET_ok) return;
00174
00175 if (_np.is_empty()) return;
00176
00177 if (_controller) {
00178 LVector3f hpr(_controller->get_h(), 0.0f, 0.0f);
00179 LPoint3f pos = _controller->get_pos();
00180 _np.set_transform(_np.get_top(), TransformState::make_pos_hpr(pos, hpr));
00181 }
00182 else {
00183 _np.set_transform(_np.get_top(), TransformState::make_mat(m));
00184 }
00185 }
00186
00187
00188
00189
00190
00191
00192 LPoint3f PhysxActor::
00193 get_global_pos() const {
00194
00195 nassertr(_error_type == ET_ok, LPoint3f::zero());
00196 return PhysxManager::nxVec3_to_point3(_ptr->getGlobalPosition());
00197 }
00198
00199
00200
00201
00202
00203
00204 LMatrix4f PhysxActor::
00205 get_global_mat() const {
00206
00207 nassertr(_error_type == ET_ok, LMatrix4f::zeros_mat());
00208 return PhysxManager::nxMat34_to_mat4(_ptr->getGlobalPose());
00209 }
00210
00211
00212
00213
00214
00215
00216 LQuaternionf PhysxActor::
00217 get_global_quat() const {
00218
00219 nassertr(_error_type == ET_ok, LQuaternionf::zero());
00220 return PhysxManager::nxQuat_to_quat(_ptr->getGlobalOrientation());
00221 }
00222
00223
00224
00225
00226
00227
00228
00229
00230 void PhysxActor::
00231 set_global_pos(const LPoint3f &pos) {
00232
00233 nassertv(_error_type == ET_ok);
00234 nassertv_always(!pos.is_nan());
00235
00236 _ptr->setGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
00237 }
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274 void PhysxActor::
00275 set_global_mat(const LMatrix4f &mat) {
00276
00277 nassertv(_error_type == ET_ok);
00278 nassertv_always(!mat.is_nan());
00279
00280 _ptr->setGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
00281 }
00282
00283
00284
00285
00286
00287
00288
00289
00290 void PhysxActor::
00291 set_global_hpr(float h, float p, float r) {
00292
00293 nassertv(_error_type == ET_ok);
00294
00295 LQuaternionf q;
00296 q.set_hpr(LVector3f(h, p, r));
00297 _ptr->setGlobalOrientationQuat(PhysxManager::quat_to_nxQuat(q));
00298 }
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310 void PhysxActor::
00311 move_global_pos(const LPoint3f &pos) {
00312
00313 nassertv(_error_type == ET_ok);
00314 nassertv_always(!pos.is_nan());
00315
00316 _ptr->moveGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
00317 }
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 void PhysxActor::
00346 move_global_mat(const LMatrix4f &mat) {
00347
00348 nassertv(_error_type == ET_ok);
00349 nassertv_always(!mat.is_nan());
00350
00351 _ptr->moveGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
00352 }
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364 void PhysxActor::
00365 move_global_hpr(float h, float p, float r) {
00366
00367 nassertv(_error_type == ET_ok);
00368
00369 LQuaternionf q;
00370 q.set_hpr(LVector3f(h, p, r));
00371 _ptr->moveGlobalOrientationQuat(PhysxManager::quat_to_nxQuat(q));
00372 }
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 void PhysxActor::
00386 attach_node_path(const NodePath &np) {
00387
00388 nassertv(_error_type == ET_ok);
00389 nassertv_always(!np.is_empty());
00390
00391 _np = NodePath(np);
00392 }
00393
00394
00395
00396
00397
00398
00399
00400
00401 void PhysxActor::
00402 detach_node_path() {
00403
00404 nassertv(_error_type == ET_ok);
00405
00406 _np = NodePath();
00407 }
00408
00409
00410
00411
00412
00413
00414
00415
00416 NodePath PhysxActor::
00417 get_node_path() const {
00418
00419 nassertr(_error_type == ET_ok, NodePath::fail());
00420
00421 return _np;
00422 }
00423
00424
00425
00426
00427
00428
00429 PhysxScene *PhysxActor::
00430 get_scene() const {
00431
00432 nassertr(_error_type == ET_ok, NULL);
00433
00434 NxScene *scenePtr = &(_ptr->getScene());
00435 PhysxScene *scene = (PhysxScene *)(scenePtr->userData);
00436
00437 return scene;
00438 }
00439
00440
00441
00442
00443
00444
00445
00446 unsigned int PhysxActor::
00447 get_num_shapes() const {
00448
00449 nassertr(_error_type == ET_ok, -1);
00450
00451 return _ptr->getNbShapes();
00452 }
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466 PhysxShape *PhysxActor::
00467 create_shape(PhysxShapeDesc &desc) {
00468
00469 nassertr(_error_type == ET_ok, NULL);
00470 nassertr(desc.is_valid(),NULL);
00471
00472 PhysxShape *shape = PhysxShape::factory(desc.ptr()->getType());
00473 nassertr(shape, NULL);
00474
00475 NxShape *shapePtr = _ptr->createShape(*desc.ptr());
00476 nassertr(shapePtr, NULL);
00477
00478 shape->link(shapePtr);
00479
00480 return shape;
00481 }
00482
00483
00484
00485
00486
00487
00488
00489
00490 PhysxShape *PhysxActor::
00491 get_shape(unsigned int idx) const {
00492
00493 nassertr(_error_type == ET_ok, NULL);
00494 nassertr_always(idx < _ptr->getNbShapes(), NULL);
00495
00496 NxShape * const *shapes = _ptr->getShapes();
00497 NxShape *shapePtr = shapes[idx];
00498 PhysxShape *shape = (PhysxShape *)(shapePtr->userData);
00499
00500 return shape;
00501 }
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511 PhysxShape *PhysxActor::
00512 get_shape_by_name(const char *name) const {
00513
00514 nassertr(_error_type == ET_ok, NULL);
00515
00516 NxShape * const *shapes = _ptr->getShapes();
00517 NxShape *shapePtr = NULL;
00518 NxU32 nShapes = _ptr->getNbShapes();
00519
00520 for (NxU32 i=0; i < nShapes; i++) {
00521 shapePtr = shapes[i];
00522
00523 if (strcmp(shapePtr->getName(), name) == 0) {
00524 return (PhysxShape *) shapePtr->userData;
00525 }
00526 }
00527
00528 return NULL;
00529 }
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546 void PhysxActor::
00547 add_force(const LVector3f force, PhysxForceMode mode, bool wakeup) {
00548
00549 nassertv(_error_type == ET_ok);
00550 nassertv_always(!force.is_nan());
00551
00552 _ptr->addForce(PhysxManager::vec3_to_nxVec3(force), (NxForceMode)mode, wakeup);
00553 }
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576 void PhysxActor::
00577 add_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
00578
00579 nassertv(_error_type == ET_ok);
00580 nassertv_always(!force.is_nan());
00581 nassertv_always(!pos.is_nan());
00582
00583 _ptr->addForceAtPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
00584 }
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607 void PhysxActor::
00608 add_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
00609
00610 nassertv(_error_type == ET_ok);
00611 nassertv_always(!force.is_nan());
00612 nassertv_always(!pos.is_nan());
00613
00614 _ptr->addForceAtLocalPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
00615 }
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630 void PhysxActor::
00631 add_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) {
00632
00633 nassertv(_error_type == ET_ok);
00634 nassertv_always(!torque.is_nan());
00635
00636 _ptr->addTorque(PhysxManager::vec3_to_nxVec3(torque), (NxForceMode)mode, wakeup);
00637 }
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653 void PhysxActor::
00654 add_local_force(const LVector3f force, PhysxForceMode mode, bool wakeup) {
00655
00656 nassertv(_error_type == ET_ok);
00657 nassertv_always(!force.is_nan());
00658
00659 _ptr->addLocalForce(PhysxManager::vec3_to_nxVec3(force), (NxForceMode)mode, wakeup);
00660 }
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683 void PhysxActor::
00684 add_local_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
00685
00686 nassertv(_error_type == ET_ok);
00687 nassertv_always(!force.is_nan());
00688 nassertv_always(!pos.is_nan());
00689
00690 _ptr->addLocalForceAtPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
00691 }
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714 void PhysxActor::
00715 add_local_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
00716
00717 nassertv(_error_type == ET_ok);
00718 nassertv_always(!force.is_nan());
00719 nassertv_always(!pos.is_nan());
00720
00721 _ptr->addLocalForceAtLocalPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
00722 }
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737 void PhysxActor::
00738 add_local_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) {
00739
00740 nassertv(_error_type == ET_ok);
00741 nassertv_always(!torque.is_nan());
00742
00743 _ptr->addLocalTorque(PhysxManager::vec3_to_nxVec3(torque), (NxForceMode)mode, wakeup);
00744 }
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781 bool PhysxActor::
00782 update_mass_from_shapes(float density, float totalMass) {
00783
00784 nassertr(_error_type == ET_ok, false);
00785 return _ptr->updateMassFromShapes(density, totalMass);
00786 }
00787
00788
00789
00790
00791
00792
00793
00794
00795 float PhysxActor::
00796 compute_kinetic_energy() const {
00797
00798 nassertr(_error_type == ET_ok, 0.0f);
00799 return _ptr->computeKineticEnergy();
00800 }
00801
00802
00803
00804
00805
00806
00807 bool PhysxActor::
00808 is_dynamic() const {
00809
00810 nassertr(_error_type == ET_ok, false);
00811 return _ptr->isDynamic();
00812 }
00813
00814
00815
00816
00817
00818
00819
00820 void PhysxActor::
00821 set_shape_group(unsigned int group) {
00822
00823 nassertv(_error_type == ET_ok);
00824 nassertv(group >= 0 && group < 32);
00825
00826 NxShape * const *shapes = _ptr->getShapes();
00827 NxU32 nShapes = _ptr->getNbShapes();
00828
00829 for (NxU32 i=0; i < nShapes; i++) {
00830 shapes[i]->setGroup( group );
00831 }
00832 }
00833
00834
00835
00836
00837
00838
00839 void PhysxActor::
00840 set_body_flag(PhysxBodyFlag flag, bool value) {
00841
00842 if (value == true) {
00843 _ptr->raiseBodyFlag((NxBodyFlag)flag);
00844 }
00845 else {
00846 _ptr->clearBodyFlag((NxBodyFlag)flag);
00847 }
00848 }
00849
00850
00851
00852
00853
00854
00855 bool PhysxActor::
00856 get_body_flag(PhysxBodyFlag flag) const {
00857
00858 nassertr(_error_type == ET_ok, false);
00859 return ptr()->readBodyFlag((NxBodyFlag)flag);
00860 }
00861
00862
00863
00864
00865
00866
00867 void PhysxActor::
00868 set_actor_flag(PhysxActorFlag flag, bool value) {
00869
00870 if (value == true) {
00871 _ptr->raiseActorFlag((NxActorFlag)flag);
00872 }
00873 else {
00874 _ptr->clearActorFlag((NxActorFlag)flag);
00875 }
00876 }
00877
00878
00879
00880
00881
00882
00883 bool PhysxActor::
00884 get_actor_flag(PhysxActorFlag flag) const {
00885
00886 nassertr(_error_type == ET_ok, false);
00887 return ptr()->readActorFlag((NxActorFlag)flag);
00888 }
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907 void PhysxActor::
00908 set_contact_report_flag(PhysxContactPairFlag flag, bool value) {
00909
00910 nassertv(_error_type == ET_ok);
00911
00912 NxU32 flags = _ptr->getContactReportFlags();
00913
00914 if (value == true) {
00915 flags |= flag;
00916 }
00917 else {
00918 flags &= ~(flag);
00919 }
00920
00921 _ptr->setContactReportFlags(flags);
00922 }
00923
00924
00925
00926
00927
00928
00929
00930 void PhysxActor::
00931 set_contact_report_threshold(float threshold) {
00932
00933 nassertv(_error_type == ET_ok);
00934 nassertv(threshold >= 0.0f);
00935
00936 _ptr->setContactReportThreshold(threshold);
00937 }
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955 void PhysxActor::
00956 set_group(unsigned int group) {
00957
00958 nassertv(_error_type == ET_ok);
00959 nassertv(group >= 0 && group < 0x8000);
00960
00961 ptr()->setGroup(group);
00962 }
00963
00964
00965
00966
00967
00968
00969
00970 unsigned int PhysxActor::
00971 get_group() const {
00972
00973 nassertr(_error_type == ET_ok, 0);
00974
00975 return ptr()->getGroup();
00976 }
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996 void PhysxActor::
00997 set_dominance_group(unsigned int group) {
00998
00999 nassertv(_error_type == ET_ok);
01000 nassertv(group >= 0 && group < 32);
01001 nassertv(is_dynamic() == true);
01002
01003 _ptr->setDominanceGroup(group);
01004 }
01005
01006
01007
01008
01009
01010
01011 unsigned int PhysxActor::
01012 get_dominance_group() const {
01013
01014 nassertr(_error_type == ET_ok, 0);
01015
01016 return ptr()->getDominanceGroup();
01017 }
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028 void PhysxActor::
01029 set_angular_damping(float angDamp) {
01030
01031 nassertv(_error_type == ET_ok);
01032 nassertv(angDamp >= 0.0f);
01033
01034 _ptr->setAngularDamping(angDamp);
01035 }
01036
01037
01038
01039
01040
01041
01042
01043 float PhysxActor::
01044 get_angular_damping() const {
01045
01046 nassertr(_error_type == ET_ok, 0.0f);
01047 return _ptr->getAngularDamping();
01048 }
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058 void PhysxActor::
01059 set_linear_damping(float linDamp) {
01060
01061 nassertv(_error_type == ET_ok);
01062 nassertv(linDamp >= 0.0f);
01063
01064 _ptr->setLinearDamping(linDamp);
01065 }
01066
01067
01068
01069
01070
01071
01072
01073 float PhysxActor::
01074 get_linear_damping() const {
01075
01076 nassertr(_error_type == ET_ok, 0.0f);
01077 return _ptr->getLinearDamping();
01078 }
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093 void PhysxActor::
01094 set_linear_velocity(const LVector3f &linVel) {
01095
01096 nassertv(_error_type == ET_ok);
01097 nassertv(_ptr->isDynamic());
01098
01099 _ptr->setLinearVelocity(PhysxManager::vec3_to_nxVec3(linVel));
01100 }
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115 void PhysxActor::
01116 set_angular_velocity(const LVector3f &angVel) {
01117
01118 nassertv(_error_type == ET_ok);
01119 nassertv(_ptr->isDynamic());
01120
01121 _ptr->setAngularVelocity(PhysxManager::vec3_to_nxVec3(angVel));
01122 }
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150 void PhysxActor::
01151 set_max_angular_velocity(float maxAngVel) {
01152
01153 nassertv(_error_type == ET_ok);
01154 nassertv(_ptr->isDynamic());
01155
01156 _ptr->setMaxAngularVelocity(maxAngVel);
01157 }
01158
01159
01160
01161
01162
01163
01164
01165 LVector3f PhysxActor::
01166 get_linear_velocity() const {
01167
01168 nassertr(_error_type == ET_ok, LVector3f::zero());
01169 return PhysxManager::nxVec3_to_vec3(_ptr->getLinearVelocity());
01170 }
01171
01172
01173
01174
01175
01176
01177
01178 LVector3f PhysxActor::
01179 get_angular_velocity() const {
01180
01181 nassertr(_error_type == ET_ok, LVector3f::zero());
01182 return PhysxManager::nxVec3_to_vec3(_ptr->getAngularVelocity());
01183 }
01184
01185
01186
01187
01188
01189
01190
01191 float PhysxActor::
01192 get_max_angular_velocity() const {
01193
01194 nassertr(_error_type == ET_ok, 0.0f);
01195 return _ptr->getMaxAngularVelocity();
01196 }
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207 LVector3f PhysxActor::
01208 get_point_velocity(const LPoint3f &point) const {
01209
01210 nassertr(_error_type == ET_ok, LVector3f::zero());
01211 nassertr_always(!point.is_nan(), LVector3f::zero());
01212
01213 NxVec3 nPoint = PhysxManager::point3_to_nxVec3(point);
01214 return PhysxManager::nxVec3_to_vec3(_ptr->getPointVelocity(nPoint));
01215 }
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226 LVector3f PhysxActor::
01227 get_local_point_velocity(const LPoint3f &point) const {
01228
01229 nassertr(_error_type == ET_ok, LVector3f::zero());
01230 nassertr_always(!point.is_nan(), LVector3f::zero());
01231
01232 NxVec3 nPoint = PhysxManager::point3_to_nxVec3(point);
01233 return PhysxManager::nxVec3_to_vec3(_ptr->getLocalPointVelocity(nPoint));
01234 }
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247 void PhysxActor::
01248 set_linear_momentum(const LVector3f &momentum) {
01249
01250 nassertv(_error_type == ET_ok);
01251 _ptr->setLinearMomentum(PhysxManager::vec3_to_nxVec3(momentum));
01252 }
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265 void PhysxActor::
01266 set_angular_momentum(const LVector3f &momentum) {
01267
01268 nassertv(_error_type == ET_ok);
01269 _ptr->setAngularMomentum(PhysxManager::vec3_to_nxVec3(momentum));
01270 }
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280 LVector3f PhysxActor::
01281 get_linear_momentum() const {
01282
01283 nassertr(_error_type == ET_ok, LVector3f::zero());
01284 return PhysxManager::nxVec3_to_vec3(_ptr->getLinearMomentum());
01285 }
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295 LVector3f PhysxActor::
01296 get_angular_momentum() const {
01297
01298 nassertr(_error_type == ET_ok, LVector3f::zero());
01299 return PhysxManager::nxVec3_to_vec3(_ptr->getAngularMomentum());
01300 }
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315 void PhysxActor::
01316 set_sleep_linear_velocity(float threshold) {
01317
01318 nassertv(_error_type == ET_ok);
01319 _ptr->setSleepLinearVelocity(threshold);
01320 }
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335 void PhysxActor::
01336 set_sleep_angular_velocity(float threshold) {
01337
01338 nassertv(_error_type == ET_ok);
01339 _ptr->setSleepAngularVelocity(threshold);
01340 }
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357 void PhysxActor::
01358 set_sleep_energy_threshold(float threshold) {
01359
01360 nassertv(_error_type == ET_ok);
01361 _ptr->setSleepEnergyThreshold(threshold);
01362 }
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372 float PhysxActor::
01373 get_sleep_linear_velocity() const {
01374
01375 nassertr(_error_type == ET_ok, 0.0f);
01376 return _ptr->getSleepLinearVelocity();
01377 }
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387 float PhysxActor::
01388 get_sleep_angular_velocity() const {
01389
01390 nassertr(_error_type == ET_ok, 0.0f);
01391 return _ptr->getSleepAngularVelocity();
01392 }
01393
01394
01395
01396
01397
01398
01399
01400
01401 float PhysxActor::
01402 get_sleep_energy_threshold() const {
01403
01404 nassertr(_error_type == ET_ok, 0.0f);
01405 return _ptr->getSleepEnergyThreshold();
01406 }
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423 bool PhysxActor::
01424 is_sleeping() const {
01425
01426 nassertr(_error_type == ET_ok, false);
01427 return _ptr->isSleeping();
01428 }
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442 void PhysxActor::
01443 wake_up(float wakeCounterValue) {
01444
01445 nassertv(_error_type == ET_ok);
01446 _ptr->wakeUp(wakeCounterValue);
01447 }
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462 void PhysxActor::
01463 put_to_sleep() {
01464
01465 nassertv(_error_type == ET_ok);
01466 _ptr->putToSleep();
01467 }
01468
01469
01470
01471
01472
01473
01474 void PhysxActor::
01475 set_mass(float mass) {
01476
01477 nassertv(_error_type == ET_ok);
01478 _ptr->setMass(mass);
01479 }
01480
01481
01482
01483
01484
01485
01486 float PhysxActor::
01487 get_mass() const {
01488
01489 nassertr(_error_type == ET_ok, 0.0f);
01490 return _ptr->getMass();
01491 }
01492
01493
01494
01495
01496
01497
01498
01499 void PhysxActor::
01500 set_c_mass_offset_local_mat(const LMatrix4f &mat) {
01501
01502 nassertv(_error_type == ET_ok);
01503 _ptr->setCMassOffsetLocalPose(PhysxManager::mat4_to_nxMat34(mat));
01504 }
01505
01506
01507
01508
01509
01510
01511
01512 void PhysxActor::
01513 set_c_mass_offset_local_pos(const LPoint3f &pos) {
01514
01515 nassertv(_error_type == ET_ok);
01516 _ptr->setCMassOffsetLocalPosition(PhysxManager::point3_to_nxVec3(pos));
01517 }
01518
01519
01520
01521
01522
01523
01524
01525 void PhysxActor::
01526 set_c_mass_offset_local_orientation(const LMatrix3f &mat) {
01527
01528 nassertv(_error_type == ET_ok);
01529 _ptr->setCMassOffsetLocalOrientation(PhysxManager::mat3_to_nxMat33(mat));
01530 }
01531
01532
01533
01534
01535
01536
01537
01538 void PhysxActor::
01539 set_c_mass_offset_global_mat(const LMatrix4f &mat) {
01540
01541 nassertv(_error_type == ET_ok);
01542 _ptr->setCMassOffsetGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
01543 }
01544
01545
01546
01547
01548
01549
01550
01551 void PhysxActor::
01552 set_c_mass_offset_global_pos(const LPoint3f &pos) {
01553
01554 nassertv(_error_type == ET_ok);
01555 _ptr->setCMassOffsetGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
01556 }
01557
01558
01559
01560
01561
01562
01563
01564 void PhysxActor::
01565 set_c_mass_offset_global_orientation(const LMatrix3f &mat) {
01566
01567 nassertv(_error_type == ET_ok);
01568 _ptr->setCMassOffsetGlobalOrientation(PhysxManager::mat3_to_nxMat33(mat));
01569 }
01570
01571
01572
01573
01574
01575
01576
01577 void PhysxActor::
01578 set_c_mass_global_mat(const LMatrix4f &mat) {
01579
01580 nassertv(_error_type == ET_ok);
01581 _ptr->setCMassGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
01582 }
01583
01584
01585
01586
01587
01588
01589
01590 void PhysxActor::
01591 set_c_mass_global_pos(const LPoint3f &pos) {
01592
01593 nassertv(_error_type == ET_ok);
01594 _ptr->setCMassGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
01595 }
01596
01597
01598
01599
01600
01601
01602
01603 void PhysxActor::
01604 set_c_mass_global_orientation(const LMatrix3f &mat) {
01605
01606 nassertv(_error_type == ET_ok);
01607 _ptr->setCMassGlobalOrientation(PhysxManager::mat3_to_nxMat33(mat));
01608 }
01609
01610
01611
01612
01613
01614
01615
01616 void PhysxActor::
01617 set_mass_space_inertia_tensor(const LVector3f &m) {
01618
01619 nassertv(_error_type == ET_ok);
01620 _ptr->setMassSpaceInertiaTensor(PhysxManager::vec3_to_nxVec3(m));
01621 }
01622
01623
01624
01625
01626
01627
01628
01629 LMatrix4f PhysxActor::
01630 get_c_mass_global_mat() const {
01631
01632 nassertr(_error_type == ET_ok, LMatrix4f::zeros_mat());
01633 return PhysxManager::nxMat34_to_mat4(_ptr->getCMassGlobalPose());
01634 }
01635
01636
01637
01638
01639
01640
01641
01642 LPoint3f PhysxActor::
01643 get_c_mass_global_pos() const {
01644
01645 nassertr(_error_type == ET_ok, LPoint3f::zero());
01646 return PhysxManager::nxVec3_to_point3(_ptr->getCMassGlobalPosition());
01647 }
01648
01649
01650
01651
01652
01653
01654
01655 LMatrix3f PhysxActor::
01656 get_c_mass_global_orientation() const {
01657
01658 nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
01659 return PhysxManager::nxMat33_to_mat3(_ptr->getCMassGlobalOrientation());
01660 }
01661
01662
01663
01664
01665
01666
01667
01668 LMatrix4f PhysxActor::
01669 get_c_mass_local_mat() const {
01670
01671 nassertr(_error_type == ET_ok, LMatrix4f::zeros_mat());
01672 return PhysxManager::nxMat34_to_mat4(_ptr->getCMassLocalPose());
01673 }
01674
01675
01676
01677
01678
01679
01680
01681 LPoint3f PhysxActor::
01682 get_c_mass_local_pos() const {
01683
01684 nassertr(_error_type == ET_ok, LPoint3f::zero());
01685 return PhysxManager::nxVec3_to_point3(_ptr->getCMassLocalPosition());
01686 }
01687
01688
01689
01690
01691
01692
01693
01694 LMatrix3f PhysxActor::
01695 get_c_mass_local_orientation() const {
01696
01697 nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
01698 return PhysxManager::nxMat33_to_mat3(_ptr->getCMassLocalOrientation());
01699 }
01700
01701
01702
01703
01704
01705
01706
01707 LVector3f PhysxActor::
01708 get_mass_space_inertia_tensor() const {
01709
01710 nassertr(_error_type == ET_ok, LVector3f::zero());
01711 return PhysxManager::nxVec3_to_vec3(_ptr->getMassSpaceInertiaTensor());
01712 }
01713
01714
01715
01716
01717
01718
01719
01720 LMatrix3f PhysxActor::
01721 get_global_inertia_tensor() const {
01722
01723 nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
01724 return PhysxManager::nxMat33_to_mat3(_ptr->getGlobalInertiaTensor());
01725 }
01726
01727
01728
01729
01730
01731
01732
01733 LMatrix3f PhysxActor::
01734 get_global_inertia_tensor_inverse() const {
01735
01736 nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
01737 return PhysxManager::nxMat33_to_mat3(_ptr->getGlobalInertiaTensorInverse());
01738 }
01739