mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Fix for conversion from TransformState (with scale) to btTransform.
This commit is contained in:
parent
9bb87232a1
commit
c23a719b26
@ -133,6 +133,28 @@ CPT(TransformState) btTrans_to_TransformState(const btTransform &trans, const LV
|
|||||||
return TransformState::make_pos_quat_scale(pos, quat, scale);
|
return TransformState::make_pos_quat_scale(pos, quat, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TransformState_to_btTrans
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
btTransform TransformState_to_btTrans(CPT(TransformState) ts) {
|
||||||
|
|
||||||
|
ts = ts->set_scale(1.0);
|
||||||
|
|
||||||
|
LMatrix4f m = ts->get_mat();
|
||||||
|
|
||||||
|
LQuaternionf quat;
|
||||||
|
quat.set_from_matrix(m.get_upper_3());
|
||||||
|
|
||||||
|
btQuaternion btq = LQuaternionf_to_btQuat(quat);
|
||||||
|
btVector3 btv = LVecBase3f_to_btVector3(m.get_row3(3));
|
||||||
|
|
||||||
|
btTransform trans;
|
||||||
|
trans.setRotation(btq);
|
||||||
|
trans.setOrigin(btv);
|
||||||
|
return trans;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: get_default_up_axis
|
// Function: get_default_up_axis
|
||||||
// Description:
|
// Description:
|
||||||
@ -160,16 +182,22 @@ BulletUpAxis get_default_up_axis() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void get_node_transform(btTransform &trans, PandaNode *node) {
|
void get_node_transform(btTransform &trans, PandaNode *node) {
|
||||||
|
|
||||||
LMatrix4f m;
|
// Get TS
|
||||||
|
CPT(TransformState) ts;
|
||||||
if (node->get_num_parents() == 0) {
|
if (node->get_num_parents() == 0) {
|
||||||
m = node->get_transform()->get_mat();
|
ts = node->get_transform();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NodePath np = NodePath::any_path(node);
|
NodePath np = NodePath::any_path(node);
|
||||||
m = np.get_net_transform()->get_mat();
|
ts = np.get_net_transform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove scale from TS, since scale fudges the orientation
|
||||||
|
ts = ts->set_scale(1.0);
|
||||||
|
|
||||||
|
// Convert
|
||||||
|
LMatrix4f m = ts->get_mat();
|
||||||
|
|
||||||
LQuaternionf quat;
|
LQuaternionf quat;
|
||||||
quat.set_from_matrix(m.get_upper_3());
|
quat.set_from_matrix(m.get_upper_3());
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ EXPCL_PANDABULLET CPT(TransformState) btTrans_to_TransformState(
|
|||||||
const btTransform &tf,
|
const btTransform &tf,
|
||||||
const LVecBase3f &scale=LVecBase3f(1.0f, 1.0f, 1.0f));
|
const LVecBase3f &scale=LVecBase3f(1.0f, 1.0f, 1.0f));
|
||||||
|
|
||||||
|
EXPCL_PANDABULLET btTransform TransformState_to_btTrans(CPT(TransformState) ts);
|
||||||
|
|
||||||
// UpAxis
|
// UpAxis
|
||||||
BEGIN_PUBLISH
|
BEGIN_PUBLISH
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user