mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
disambiguate get_transform2d() and get_transform3d()
This commit is contained in:
parent
201213e3d5
commit
923a4086d8
@ -1113,7 +1113,7 @@ adjust_under() {
|
||||
|
||||
// Our own transform also affects our node frame.
|
||||
_node_frame =
|
||||
new MatrixFrame(get_transform() * get_node_frame());
|
||||
new MatrixFrame(get_transform3d() * get_node_frame());
|
||||
_node_frame_inv =
|
||||
new MatrixFrame(invert(get_node_frame()));
|
||||
_vertex_to_node =
|
||||
@ -1175,7 +1175,7 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
|
||||
mat1.set_row(3, LVector3d(0.0, 0.0, 0.0));
|
||||
inv1.set_row(3, LVector3d(0.0, 0.0, 0.0));
|
||||
|
||||
internal_set_transform(inv1 * get_transform() * mat);
|
||||
internal_set_transform(inv1 * get_transform3d() * mat);
|
||||
|
||||
EggGroupNode::r_transform(mat1, inv1, to_cs);
|
||||
} else {
|
||||
|
@ -1037,7 +1037,7 @@ r_apply_texmats(EggTextureCollection &textures) {
|
||||
|
||||
// We've got a texture with a matrix applied. Save the matrix,
|
||||
// and get a new texture without the matrix.
|
||||
LMatrix4d mat = texture->get_transform();
|
||||
LMatrix4d mat = texture->get_transform3d();
|
||||
EggTexture new_texture(*texture);
|
||||
new_texture.clear_transform();
|
||||
EggTexture *unique = textures.create_unique_texture(new_texture, ~0);
|
||||
@ -1056,7 +1056,7 @@ r_apply_texmats(EggTextureCollection &textures) {
|
||||
EggVertex new_vertex(*vertex);
|
||||
PT(EggVertexUV) new_uv_obj = new EggVertexUV(*uv_obj);
|
||||
TexCoord3d uvw = uv_obj->get_uvw() * mat;
|
||||
if (uv_obj->has_w() || !texture->is_transform_2d()) {
|
||||
if (uv_obj->has_w() || texture->has_transform3d()) {
|
||||
new_uv_obj->set_uvw(uvw);
|
||||
} else {
|
||||
new_uv_obj->set_uv(TexCoordd(uvw[0], uvw[1]));
|
||||
|
@ -323,7 +323,7 @@ is_equivalent_to(const EggTexture &other, int eq) const {
|
||||
}
|
||||
|
||||
if (has_transform() && other.has_transform()) {
|
||||
if (!get_transform().almost_equal(other.get_transform(), 0.0001)) {
|
||||
if (!get_transform3d().almost_equal(other.get_transform3d(), 0.0001)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -399,7 +399,7 @@ sorts_less_than(const EggTexture &other, int eq) const {
|
||||
}
|
||||
|
||||
if (has_transform() && other.has_transform()) {
|
||||
int compare = get_transform().compare_to(other.get_transform());
|
||||
int compare = get_transform3d().compare_to(other.get_transform3d());
|
||||
if (compare != 0) {
|
||||
return compare < 0;
|
||||
}
|
||||
|
@ -160,7 +160,8 @@ add_matrix4(const LMatrix4d &mat) {
|
||||
// Access: Public
|
||||
// Description: Returns true if the transform is nonempty, false if
|
||||
// it is empty (no transform components have been
|
||||
// added).
|
||||
// added). This is true for either a 2-d or a 3-d
|
||||
// transform.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool EggTransform::
|
||||
has_transform() const {
|
||||
@ -168,57 +169,74 @@ has_transform() const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTransform::is_transform_2d
|
||||
// Function: EggTransform::has_transform2d
|
||||
// Access: Public
|
||||
// Description: Returns true if the transform is specified as a 2-d
|
||||
// transform, e.g. with a 3x3 matrix, or false if it is
|
||||
// specified as a 3-d transform, with a 4x4 matrix.
|
||||
// specified as a 3-d transform (with a 4x4 matrix), or
|
||||
// not specified at all.
|
||||
//
|
||||
// Normally, EggTextures have a 2-d matrix (but
|
||||
// occasionally they use a 3-d matrix), and EggGroups
|
||||
// always have a 3-d matrix.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool EggTransform::
|
||||
is_transform_2d() const {
|
||||
return _is_transform_2d;
|
||||
has_transform2d() const {
|
||||
return has_transform() && _is_transform_2d;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTransform::set_transform_2d
|
||||
// Function: EggTransform::set_transform2d
|
||||
// Access: Public
|
||||
// Description: Sets the overall transform as a 3x3 matrix. This
|
||||
// completely replaces whatever componentwise transform
|
||||
// may have been defined.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void EggTransform::
|
||||
set_transform_2d(const LMatrix3d &mat) {
|
||||
set_transform2d(const LMatrix3d &mat) {
|
||||
internal_set_transform(mat);
|
||||
transform_changed();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTransform::set_transform
|
||||
// Function: EggTransform::has_transform3d
|
||||
// Access: Public
|
||||
// Description: Returns true if the transform is specified as a 3-d
|
||||
// transform, e.g. with a 4x4 matrix, or false if it is
|
||||
// specified as a 2-d transform (with a 2x2 matrix), or
|
||||
// not specified at all.
|
||||
//
|
||||
// Normally, EggTextures have a 3-d matrix (but
|
||||
// occasionally they use a 3-d matrix), and EggGroups
|
||||
// always have a 3-d matrix.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool EggTransform::
|
||||
has_transform3d() const {
|
||||
return has_transform() && !_is_transform_2d;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTransform::set_transform3d
|
||||
// Access: Public
|
||||
// Description: Sets the overall transform as a 4x4 matrix. This
|
||||
// completely replaces whatever componentwise transform
|
||||
// may have been defined.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void EggTransform::
|
||||
set_transform(const LMatrix4d &mat) {
|
||||
set_transform3d(const LMatrix4d &mat) {
|
||||
internal_set_transform(mat);
|
||||
transform_changed();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTransform::get_transform_2d
|
||||
// Function: EggTransform::get_transform2d
|
||||
// Access: Public
|
||||
// Description: Returns the overall transform as a 3x3 matrix. It is
|
||||
// only valid to call this if is_transform_2d() has
|
||||
// returned true.
|
||||
// an error to call this if has_transform3d() is true.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE LMatrix3d EggTransform::
|
||||
get_transform_2d() const {
|
||||
nassertr(is_transform_2d(), LMatrix3d::ident_mat());
|
||||
get_transform2d() const {
|
||||
nassertr(!has_transform3d(), LMatrix3d::ident_mat());
|
||||
const LMatrix4d &t = _transform;
|
||||
return LMatrix3d(t(0, 0), t(0, 1), t(0, 3),
|
||||
t(1, 0), t(1, 1), t(1, 3),
|
||||
@ -226,12 +244,15 @@ get_transform_2d() const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggTransform::get_transform
|
||||
// Function: EggTransform::get_transform3d
|
||||
// Access: Public
|
||||
// Description: Returns the overall transform as a 4x4 matrix.
|
||||
// Description: Returns the overall transform as a 4x4 matrix. It is
|
||||
// valid to call this even if has_transform2d() is true;
|
||||
// in this case, the 3x3 transform will be expanded to a
|
||||
// 4x4 matrix.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const LMatrix4d &EggTransform::
|
||||
get_transform() const {
|
||||
get_transform3d() const {
|
||||
return _transform;
|
||||
}
|
||||
|
||||
|
@ -57,11 +57,12 @@ PUBLISHED:
|
||||
INLINE void add_matrix4(const LMatrix4d &mat);
|
||||
|
||||
INLINE bool has_transform() const;
|
||||
INLINE bool is_transform_2d() const;
|
||||
INLINE void set_transform_2d(const LMatrix3d &mat);
|
||||
INLINE void set_transform(const LMatrix4d &mat);
|
||||
INLINE LMatrix3d get_transform_2d() const;
|
||||
INLINE const LMatrix4d &get_transform() const;
|
||||
INLINE bool has_transform2d() const;
|
||||
INLINE void set_transform2d(const LMatrix3d &mat);
|
||||
INLINE bool has_transform3d() const;
|
||||
INLINE void set_transform3d(const LMatrix4d &mat);
|
||||
INLINE LMatrix3d get_transform2d() const;
|
||||
INLINE const LMatrix4d &get_transform3d() const;
|
||||
INLINE bool transform_is_identity() const;
|
||||
|
||||
enum ComponentType {
|
||||
|
@ -253,7 +253,7 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) {
|
||||
// it to single-precision.
|
||||
LMatrix4d matd;
|
||||
if (egg_group->has_transform()) {
|
||||
matd = egg_group->get_transform();
|
||||
matd = egg_group->get_transform3d();
|
||||
} else {
|
||||
matd = LMatrix4d::ident_mat();
|
||||
}
|
||||
|
@ -2040,7 +2040,7 @@ make_vertex_data(const EggRenderState *render_state,
|
||||
BakeInUVs::const_iterator buv = render_state->_bake_in_uvs.find(iname);
|
||||
if (buv != render_state->_bake_in_uvs.end()) {
|
||||
// If we are to bake in a texture matrix, do so now.
|
||||
uvw = uvw * (*buv).second->get_transform();
|
||||
uvw = uvw * (*buv).second->get_transform3d();
|
||||
}
|
||||
|
||||
gvw.set_data3f(LCAST(float, uvw));
|
||||
@ -2055,7 +2055,7 @@ make_vertex_data(const EggRenderState *render_state,
|
||||
TexCoord3d duvw = morph.get_offset();
|
||||
if (buv != render_state->_bake_in_uvs.end()) {
|
||||
TexCoord3d new_uvw = orig_uvw + duvw;
|
||||
duvw = (new_uvw * (*buv).second->get_transform()) - uvw;
|
||||
duvw = (new_uvw * (*buv).second->get_transform3d()) - uvw;
|
||||
}
|
||||
|
||||
gvw.add_data3f(LCAST(float, duvw));
|
||||
|
@ -171,7 +171,7 @@ fill_state(EggPrimitive *egg_prim) {
|
||||
// with a different transform, it will increase
|
||||
// tex_mats[uv_name].size() to at least 2, indicating we can't
|
||||
// bake in the texture matrix.
|
||||
tex_mats[uv_name][egg_tex->get_transform()].push_back(&def);
|
||||
tex_mats[uv_name][egg_tex->get_transform3d()].push_back(&def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ apply_node_properties(EggGroup *egg_group, PandaNode *node) {
|
||||
} else if (transform->has_mat()) {
|
||||
// Otherwise, we store the raw matrix.
|
||||
const LMatrix4f &mat = transform->get_mat();
|
||||
egg_group->set_transform(LCAST(double, mat));
|
||||
egg_group->set_transform3d(LCAST(double, mat));
|
||||
}
|
||||
any_applied = true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ EggJointNodePointer(EggObject *object) {
|
||||
// Quietly insist that the joint has a transform, for neatness. If
|
||||
// it does not, give it the identity transform.
|
||||
if (!_joint->has_transform()) {
|
||||
_joint->set_transform(LMatrix4d::ident_mat());
|
||||
_joint->set_transform3d(LMatrix4d::ident_mat());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ get_num_frames() const {
|
||||
LMatrix4d EggJointNodePointer::
|
||||
get_frame(int n) const {
|
||||
nassertr(n == 0, LMatrix4d::ident_mat());
|
||||
return _joint->get_transform();
|
||||
return _joint->get_transform3d();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -91,7 +91,7 @@ get_frame(int n) const {
|
||||
void EggJointNodePointer::
|
||||
set_frame(int n, const LMatrix4d &mat) {
|
||||
nassertv(n == 0);
|
||||
_joint->set_transform(mat);
|
||||
_joint->set_transform3d(mat);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -180,7 +180,7 @@ do_rebuild() {
|
||||
return false;
|
||||
}
|
||||
|
||||
_joint->set_transform(_rebuild_frames[0]);
|
||||
_joint->set_transform3d(_rebuild_frames[0]);
|
||||
_rebuild_frames.clear();
|
||||
return true;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ set_transform(const FltBead *flt_bead, EggGroup *egg_group) {
|
||||
}
|
||||
|
||||
if (!componentwise_ok) {
|
||||
egg_group->set_transform(flt_bead->get_transform());
|
||||
egg_group->set_transform3d(flt_bead->get_transform());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -450,9 +450,9 @@ apply_transform(EggTransform *egg_transform, FltBead *flt_node) {
|
||||
|
||||
if (components_ok) {
|
||||
// Verify that the transform was computed correctly.
|
||||
if (!flt_node->get_transform().almost_equal(egg_transform->get_transform())) {
|
||||
if (!flt_node->get_transform().almost_equal(egg_transform->get_transform3d())) {
|
||||
nout << "Incorrect transform! Expected:\n";
|
||||
egg_transform->get_transform().write(nout, 2);
|
||||
egg_transform->get_transform3d().write(nout, 2);
|
||||
nout << "Computed:\n";
|
||||
flt_node->get_transform().write(nout, 2);
|
||||
nout << "\n";
|
||||
@ -462,7 +462,7 @@ apply_transform(EggTransform *egg_transform, FltBead *flt_node) {
|
||||
|
||||
if (!components_ok) {
|
||||
// Just store the overall transform.
|
||||
flt_node->set_transform(egg_transform->get_transform());
|
||||
flt_node->set_transform(egg_transform->get_transform3d());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ make_egg() {
|
||||
// If we have a nonzero pivot point, that's a translation
|
||||
// transform.
|
||||
LPoint3d translate = LCAST(double, _layer->_pivot);
|
||||
_egg_group->set_transform(LMatrix4d::translate_mat(translate));
|
||||
_egg_group->set_transform3d(LMatrix4d::translate_mat(translate));
|
||||
_egg_group->set_group_type(EggGroup::GT_instance);
|
||||
}
|
||||
}
|
||||
|
@ -679,7 +679,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc,
|
||||
}
|
||||
get_joint_transform(node_desc->get_dag_path(), tgroup);
|
||||
EggXfmSAnim *anim = _tree.get_egg_anim(node_desc);
|
||||
if (!anim->add_data(tgroup->get_transform())) {
|
||||
if (!anim->add_data(tgroup->get_transform3d())) {
|
||||
mayaegg_cat.error()
|
||||
<< "Invalid transform on " << node_desc->get_name()
|
||||
<< " frame " << frame.value() << ".\n";
|
||||
@ -1055,7 +1055,7 @@ get_joint_transform(const MDagPath &dag_path, EggGroup *egg_group) {
|
||||
ident_mat.setToIdentity();
|
||||
|
||||
if (!mat.isEquivalent(ident_mat, 0.0001)) {
|
||||
egg_group->set_transform
|
||||
egg_group->set_transform3d
|
||||
(LMatrix4d(mat[0][0], mat[0][1], mat[0][2], mat[0][3],
|
||||
mat[1][0], mat[1][1], mat[1][2], mat[1][3],
|
||||
mat[2][0], mat[2][1], mat[2][2], mat[2][3],
|
||||
@ -2430,7 +2430,7 @@ apply_texture_properties(EggTexture &tex, const MayaShaderColorDef &color_def) {
|
||||
|
||||
LMatrix3d mat = color_def.compute_texture_matrix();
|
||||
if (!mat.almost_equal(LMatrix3d::ident_mat())) {
|
||||
tex.set_transform_2d(mat);
|
||||
tex.set_transform2d(mat);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2470,7 +2470,7 @@ compare_texture_properties(EggTexture &tex,
|
||||
m(1, 0), m(1, 1), 0.0, m(1, 2),
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
m(2, 0), m(2, 1), 0.0, m(2, 2));
|
||||
if (!mat4.almost_equal(tex.get_transform())) {
|
||||
if (!mat4.almost_equal(tex.get_transform3d())) {
|
||||
okflag = false;
|
||||
}
|
||||
|
||||
|
@ -86,8 +86,8 @@ from_egg(EggFile *egg_file, EggData *data, EggTexture *egg_tex) {
|
||||
_egg_data = data;
|
||||
_tref_name = egg_tex->get_name();
|
||||
|
||||
if (_egg_tex->has_transform() && egg_tex->is_transform_2d()) {
|
||||
_tex_mat = _egg_tex->get_transform_2d();
|
||||
if (_egg_tex->has_transform2d()) {
|
||||
_tex_mat = _egg_tex->get_transform2d();
|
||||
if (!_inv_tex_mat.invert_from(_tex_mat)) {
|
||||
_inv_tex_mat = LMatrix3d::ident_mat();
|
||||
}
|
||||
@ -474,7 +474,7 @@ update_egg() {
|
||||
|
||||
// Compose the new texture matrix with whatever matrix was already
|
||||
// there, if any.
|
||||
_egg_tex->set_transform_2d(_tex_mat * new_tex_mat);
|
||||
_egg_tex->set_transform2d(_tex_mat * new_tex_mat);
|
||||
|
||||
// Finally, go back and actually adjust the UV's to match what we
|
||||
// claimed they could be.
|
||||
|
@ -487,7 +487,7 @@ get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global) {
|
||||
matrix[2][0], matrix[2][1], matrix[2][2], matrix[2][3],
|
||||
matrix[3][0], matrix[3][1], matrix[3][2], matrix[3][3]);
|
||||
if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) {
|
||||
egg_group->set_transform(m4d);
|
||||
egg_group->set_transform3d(m4d);
|
||||
softegg_cat.spam() << "set transform in egg_group\n";
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ vrml_transform(const VrmlNode *node, EggGroup *group,
|
||||
}
|
||||
|
||||
if (any_transform) {
|
||||
group->set_transform(local_transform);
|
||||
group->set_transform3d(local_transform);
|
||||
}
|
||||
|
||||
LMatrix4d next_transform = local_transform * net_transform;
|
||||
|
@ -94,7 +94,7 @@ create_hierarchy(XFileToEggConverter *converter) {
|
||||
EggGroup *joint = (*ti).second._joint;
|
||||
if (anim_table->empty() && joint != (EggGroup *)NULL) {
|
||||
// If there's no animation data, assign the rest transform.
|
||||
anim_table->add_data(joint->get_transform());
|
||||
anim_table->add_data(joint->get_transform3d());
|
||||
}
|
||||
anim_table->optimize();
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ add_group(EggGroup *egg_group, XFileNode *x_parent) {
|
||||
|
||||
// Set the transform on the frame, if we have one.
|
||||
if (egg_group->has_transform()) {
|
||||
x_frame->add_FrameTransformMatrix(egg_group->get_transform());
|
||||
x_frame->add_FrameTransformMatrix(egg_group->get_transform3d());
|
||||
}
|
||||
|
||||
if (!recurse_nodes(egg_group, x_frame)) {
|
||||
|
@ -437,7 +437,7 @@ convert_transform(XFileDataNode *obj, EggGroupNode *egg_parent) {
|
||||
|
||||
if (egg_parent->is_of_type(EggGroup::get_class_type())) {
|
||||
EggGroup *egg_group = DCAST(EggGroup, egg_parent);
|
||||
egg_group->set_transform(mat);
|
||||
egg_group->set_transform3d(mat);
|
||||
|
||||
} else {
|
||||
xfile_cat.error()
|
||||
|
@ -60,8 +60,8 @@ set_from_egg(EggVertex *egg_vertex, EggPrimitive *egg_prim) {
|
||||
if (egg_prim->has_texture()) {
|
||||
// Check if there's a texture matrix on the texture.
|
||||
EggTexture *egg_tex = egg_prim->get_texture();
|
||||
if (egg_tex->has_transform() && egg_tex->is_transform_2d()) {
|
||||
uv = uv * egg_tex->get_transform_2d();
|
||||
if (egg_tex->has_transform2d()) {
|
||||
uv = uv * egg_tex->get_transform2d();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user