From be97920b58b4ae9f62c5d5cc9e04d36579a1c85d Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Tue, 29 Jan 2008 17:04:33 +0000 Subject: [PATCH] Added new command line option: -tbnauto --- pandatool/src/eggbase/eggBase.cxx | 6 ++++++ pandatool/src/eggbase/eggBase.h | 1 + pandatool/src/eggbase/eggWriter.cxx | 15 ++++----------- pandatool/src/mayaprogs/mayaToEgg.cxx | 1 + 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pandatool/src/eggbase/eggBase.cxx b/pandatool/src/eggbase/eggBase.cxx index cb6f948cf8..8ae8c65d1e 100644 --- a/pandatool/src/eggbase/eggBase.cxx +++ b/pandatool/src/eggbase/eggBase.cxx @@ -43,6 +43,7 @@ EggBase() { _normals_threshold = 0.0; _got_tbnall = false; + _got_tbnauto = false; _got_transform = false; _transform = LMatrix4d::ident_mat(); @@ -105,6 +106,11 @@ add_normals_options() { "Compute tangent and binormal for all texture coordinate " "sets. This is equivalent to -tbn \"*\".", &EggBase::dispatch_none, &_got_tbnall); + + add_option + ("tbnauto", "", 48, + "Compute tangent and binormal for all normal maps. ", + &EggBase::dispatch_none, &_got_tbnauto); } //////////////////////////////////////////////////////////////////// diff --git a/pandatool/src/eggbase/eggBase.h b/pandatool/src/eggbase/eggBase.h index 213bfe2974..641055f3d1 100644 --- a/pandatool/src/eggbase/eggBase.h +++ b/pandatool/src/eggbase/eggBase.h @@ -68,6 +68,7 @@ protected: double _normals_threshold; vector_string _tbn_names; bool _got_tbnall; + bool _got_tbnauto; bool _got_transform; LMatrix4d _transform; diff --git a/pandatool/src/eggbase/eggWriter.cxx b/pandatool/src/eggbase/eggWriter.cxx index 02a9a64622..a430a67dee 100644 --- a/pandatool/src/eggbase/eggWriter.cxx +++ b/pandatool/src/eggbase/eggWriter.cxx @@ -166,19 +166,12 @@ post_process_egg_file() { } if (_got_tbnall) { - nout << "Computing tangent and binormal for all UV sets.\n"; - _data->recompute_tangent_binormal(GlobPattern("*")); - needs_remove = true; - + needs_remove |= _data->recompute_tangent_binormal(GlobPattern("*")); } else { - for (vector_string::const_iterator si = _tbn_names.begin(); - si != _tbn_names.end(); - ++si) { - GlobPattern uv_name(*si); - nout << "Computing tangent and binormal for \"" << uv_name << "\"\n"; - _data->recompute_tangent_binormal(uv_name); - needs_remove = true; + if (_got_tbnauto) { + needs_remove |= _data->recompute_tangent_binormal_auto(); } + needs_remove |= _data->recompute_tangent_binormal(_tbn_names); } if (needs_remove) { diff --git a/pandatool/src/mayaprogs/mayaToEgg.cxx b/pandatool/src/mayaprogs/mayaToEgg.cxx index af11679d0d..4b793068ef 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg.cxx @@ -147,6 +147,7 @@ MayaToEgg() : _verbose = 0; _polygon_tolerance = 0.01; _transform_type = MayaToEggConverter::TT_model; + _got_tbnauto = true; } ////////////////////////////////////////////////////////////////////