diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index 24136015be..e459561a18 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -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 { diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index a0785ccf4a..8b6e6213b0 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -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])); diff --git a/panda/src/egg/eggTexture.cxx b/panda/src/egg/eggTexture.cxx index 592822ece5..b3dfe223bb 100644 --- a/panda/src/egg/eggTexture.cxx +++ b/panda/src/egg/eggTexture.cxx @@ -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; } diff --git a/panda/src/egg/eggTransform.I b/panda/src/egg/eggTransform.I index 6684a39417..cfc006ffca 100644 --- a/panda/src/egg/eggTransform.I +++ b/panda/src/egg/eggTransform.I @@ -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; } diff --git a/panda/src/egg/eggTransform.h b/panda/src/egg/eggTransform.h index 90e8c4312c..8f37c29cfd 100644 --- a/panda/src/egg/eggTransform.h +++ b/panda/src/egg/eggTransform.h @@ -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 { diff --git a/panda/src/egg2pg/characterMaker.cxx b/panda/src/egg2pg/characterMaker.cxx index d532f62e12..342bc32afd 100644 --- a/panda/src/egg2pg/characterMaker.cxx +++ b/panda/src/egg2pg/characterMaker.cxx @@ -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(); } diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index 820b9217e1..f1ce83b45c 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -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)); diff --git a/panda/src/egg2pg/eggRenderState.cxx b/panda/src/egg2pg/eggRenderState.cxx index 189a1bd29d..dcc709d7de 100644 --- a/panda/src/egg2pg/eggRenderState.cxx +++ b/panda/src/egg2pg/eggRenderState.cxx @@ -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); } } } diff --git a/pandatool/src/bam/bamToEgg.cxx b/pandatool/src/bam/bamToEgg.cxx index a902a839f8..6f95ec4f4c 100644 --- a/pandatool/src/bam/bamToEgg.cxx +++ b/pandatool/src/bam/bamToEgg.cxx @@ -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; } diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.cxx b/pandatool/src/eggcharbase/eggJointNodePointer.cxx index 6c21b188ea..0028a13292 100644 --- a/pandatool/src/eggcharbase/eggJointNodePointer.cxx +++ b/pandatool/src/eggcharbase/eggJointNodePointer.cxx @@ -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; } diff --git a/pandatool/src/fltegg/fltToEggLevelState.cxx b/pandatool/src/fltegg/fltToEggLevelState.cxx index b21353bcbb..db7c3f2b92 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.cxx +++ b/pandatool/src/fltegg/fltToEggLevelState.cxx @@ -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()); } } } diff --git a/pandatool/src/fltprogs/eggToFlt.cxx b/pandatool/src/fltprogs/eggToFlt.cxx index 8ffcde9d4f..44ee7eecab 100644 --- a/pandatool/src/fltprogs/eggToFlt.cxx +++ b/pandatool/src/fltprogs/eggToFlt.cxx @@ -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()); } } diff --git a/pandatool/src/lwoegg/cLwoLayer.cxx b/pandatool/src/lwoegg/cLwoLayer.cxx index 7b19ed52b8..684a2235b0 100644 --- a/pandatool/src/lwoegg/cLwoLayer.cxx +++ b/pandatool/src/lwoegg/cLwoLayer.cxx @@ -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); } } diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index 43b3c3f175..f1c8ef2eda 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -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; } diff --git a/pandatool/src/palettizer/textureReference.cxx b/pandatool/src/palettizer/textureReference.cxx index 16cb64b545..969e016de7 100644 --- a/pandatool/src/palettizer/textureReference.cxx +++ b/pandatool/src/palettizer/textureReference.cxx @@ -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. diff --git a/pandatool/src/softegg/softNodeDesc.cxx b/pandatool/src/softegg/softNodeDesc.cxx index e846483977..2f372e9a6a 100755 --- a/pandatool/src/softegg/softNodeDesc.cxx +++ b/pandatool/src/softegg/softNodeDesc.cxx @@ -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"; } } diff --git a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx index 65b9827a2e..13a360a203 100644 --- a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx +++ b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx @@ -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; diff --git a/pandatool/src/xfileegg/xFileAnimationSet.cxx b/pandatool/src/xfileegg/xFileAnimationSet.cxx index f470135ed3..24fcd783c8 100644 --- a/pandatool/src/xfileegg/xFileAnimationSet.cxx +++ b/pandatool/src/xfileegg/xFileAnimationSet.cxx @@ -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(); } diff --git a/pandatool/src/xfileegg/xFileMaker.cxx b/pandatool/src/xfileegg/xFileMaker.cxx index 7003678b8b..995c9ccbc3 100644 --- a/pandatool/src/xfileegg/xFileMaker.cxx +++ b/pandatool/src/xfileegg/xFileMaker.cxx @@ -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)) { diff --git a/pandatool/src/xfileegg/xFileToEggConverter.cxx b/pandatool/src/xfileegg/xFileToEggConverter.cxx index 43fc073441..c37e6f7a2e 100644 --- a/pandatool/src/xfileegg/xFileToEggConverter.cxx +++ b/pandatool/src/xfileegg/xFileToEggConverter.cxx @@ -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() diff --git a/pandatool/src/xfileegg/xFileVertex.cxx b/pandatool/src/xfileegg/xFileVertex.cxx index 6d9d9a27b6..4292375f36 100644 --- a/pandatool/src/xfileegg/xFileVertex.cxx +++ b/pandatool/src/xfileegg/xFileVertex.cxx @@ -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(); } }