be less restrictive with transforms

This commit is contained in:
David Rose 2002-10-03 22:03:22 +00:00
parent 1604ba4bd6
commit b0355be74e
3 changed files with 16 additions and 21 deletions

View File

@ -680,7 +680,6 @@ void NodePath::
set_quat(const LQuaternionf &quat) {
nassertv_always(!is_empty());
CPT(TransformState) transform = get_transform();
nassertv(transform->has_quat());
set_transform(transform->set_quat(quat));
}
@ -693,7 +692,6 @@ LQuaternionf NodePath::
get_quat() const {
nassertr_always(!is_empty(), LQuaternionf::ident_quat());
CPT(TransformState) transform = get_transform();
nassertr(transform->has_quat(), LQuaternionf::ident_quat());
return transform->get_quat();
}
@ -707,7 +705,6 @@ void NodePath::
set_scale(const LVecBase3f &scale) {
nassertv_always(!is_empty());
CPT(TransformState) transform = get_transform();
nassertv(transform->has_scale());
set_transform(transform->set_scale(scale));
}
@ -715,7 +712,6 @@ void NodePath::
set_sx(float sx) {
nassertv_always(!is_empty());
CPT(TransformState) transform = get_transform();
nassertv(transform->has_scale());
LVecBase3f scale = transform->get_scale();
scale[0] = sx;
set_transform(transform->set_scale(scale));
@ -725,7 +721,6 @@ void NodePath::
set_sy(float sy) {
nassertv_always(!is_empty());
CPT(TransformState) transform = get_transform();
nassertv(transform->has_scale());
LVecBase3f scale = transform->get_scale();
scale[1] = sy;
set_transform(transform->set_scale(scale));
@ -735,7 +730,6 @@ void NodePath::
set_sz(float sz) {
nassertv_always(!is_empty());
CPT(TransformState) transform = get_transform();
nassertv(transform->has_scale());
LVecBase3f scale = transform->get_scale();
scale[2] = sz;
set_transform(transform->set_scale(scale));
@ -750,7 +744,6 @@ LVecBase3f NodePath::
get_scale() const {
nassertr_always(!is_empty(), LVecBase3f(0.0f, 0.0f, 0.0f));
CPT(TransformState) transform = get_transform();
nassertr(transform->has_scale(), LVecBase3f(0.0f, 0.0f, 0.0f));
return transform->get_scale();
}
@ -764,7 +757,6 @@ void NodePath::
set_pos_hpr(const LVecBase3f &pos, const LVecBase3f &hpr) {
nassertv_always(!is_empty());
CPT(TransformState) transform = get_transform();
nassertv(transform->has_components());
transform = TransformState::make_pos_hpr_scale
(pos, hpr, transform->get_scale());
set_transform(transform);
@ -1085,7 +1077,6 @@ void NodePath::
set_quat(const NodePath &other, const LQuaternionf &quat) {
nassertv_always(!is_empty());
CPT(TransformState) rel_transform = get_transform(other);
nassertv(rel_transform->has_quat());
CPT(TransformState) orig_transform = get_transform();
if (orig_transform->has_components()) {
@ -1119,7 +1110,6 @@ LQuaternionf NodePath::
get_quat(const NodePath &other) const {
nassertr_always(!is_empty(), LQuaternionf::ident_quat());
CPT(TransformState) transform = get_transform(other);
nassertr(transform->has_quat(), LQuaternionf::ident_quat());
return transform->get_quat();
}
@ -1133,7 +1123,6 @@ void NodePath::
set_scale(const NodePath &other, const LVecBase3f &scale) {
nassertv_always(!is_empty());
CPT(TransformState) rel_transform = get_transform(other);
nassertv(rel_transform->has_scale());
CPT(TransformState) orig_transform = get_transform();
if (orig_transform->has_components()) {
@ -1191,7 +1180,6 @@ LVecBase3f NodePath::
get_scale(const NodePath &other) const {
nassertr_always(!is_empty(), LVecBase3f(0.0f, 0.0f, 0.0f));
CPT(TransformState) transform = get_transform(other);
nassertr(transform->has_scale(), LVecBase3f(0.0f, 0.0f, 0.0f));
return transform->get_scale();
}
@ -1206,7 +1194,6 @@ set_pos_hpr(const NodePath &other, const LVecBase3f &pos,
const LVecBase3f &hpr) {
nassertv_always(!is_empty());
CPT(TransformState) rel_transform = get_transform(other);
nassertv(rel_transform->has_components());
CPT(TransformState) orig_transform = get_transform();
if (orig_transform->has_components()) {

View File

@ -319,7 +319,8 @@ get_pos() const {
INLINE const LVecBase3f &TransformState::
get_hpr() const {
check_hpr();
nassertr(has_hpr(), _hpr);
nassertr(!is_invalid(), _hpr);
// nassertr(has_hpr(), _hpr);
return _hpr;
}
@ -333,7 +334,8 @@ get_hpr() const {
INLINE const LQuaternionf &TransformState::
get_quat() const {
check_quat();
nassertr(has_quat(), _quat);
nassertr(!is_invalid(), _quat);
// nassertr(has_quat(), _quat);
return _quat;
}
@ -347,7 +349,8 @@ get_quat() const {
INLINE const LVecBase3f &TransformState::
get_scale() const {
check_components();
nassertr(has_scale(), _scale);
nassertr(!is_invalid(), _scale);
// nassertr(has_scale(), _scale);
return _scale;
}

View File

@ -370,6 +370,7 @@ make_mat(const LMatrix4f &mat) {
////////////////////////////////////////////////////////////////////
CPT(TransformState) TransformState::
set_pos(const LVecBase3f &pos) const {
nassertr(!is_invalid(), this);
if (is_identity() || components_given()) {
// If we started with a componentwise transform, we keep it that
// way.
@ -396,7 +397,8 @@ set_pos(const LVecBase3f &pos) const {
////////////////////////////////////////////////////////////////////
CPT(TransformState) TransformState::
set_hpr(const LVecBase3f &hpr) const {
nassertr(has_components(), this);
nassertr(!is_invalid(), this);
// nassertr(has_components(), this);
return make_pos_hpr_scale(get_pos(), hpr, get_scale());
}
@ -409,7 +411,8 @@ set_hpr(const LVecBase3f &hpr) const {
////////////////////////////////////////////////////////////////////
CPT(TransformState) TransformState::
set_quat(const LQuaternionf &quat) const {
nassertr(has_components(), this);
nassertr(!is_invalid(), this);
// nassertr(has_components(), this);
return make_pos_quat_scale(get_pos(), quat, get_scale());
}
@ -422,7 +425,8 @@ set_quat(const LQuaternionf &quat) const {
////////////////////////////////////////////////////////////////////
CPT(TransformState) TransformState::
set_scale(const LVecBase3f &scale) const {
nassertr(has_components(), this);
nassertr(!is_invalid(), this);
// nassertr(has_components(), this);
if (quat_given()) {
return make_pos_quat_scale(get_pos(), get_quat(), scale);
} else {
@ -1049,8 +1053,9 @@ calc_components() {
bool possible = decompose_matrix(mat, _scale, _hpr, _pos);
if (!possible) {
// Some matrices can't be decomposed into scale, hpr, pos. In
// this case, we now know that we cannot compute the components.
_flags |= F_components_known;
// this case, we now know that we cannot compute the components;
// but the closest approximations are stored, at least.
_flags |= F_components_known | F_hpr_known;
} else {
// Otherwise, we do have the components, or at least the hpr.