15 #include "dxGeomMunger9.h" 16 #include "geomVertexReader.h" 17 #include "geomVertexWriter.h" 18 #include "config_dxgsg9.h" 20 GeomMunger *DXGeomMunger9::_deleted_chain = NULL;
30 if (_reffed_filtered_texture) {
31 unref_delete(_filtered_texture);
32 _reffed_filtered_texture =
false;
48 if (_reffed_filtered_texture) {
49 unref_delete(_filtered_texture);
50 _reffed_filtered_texture =
false;
60 CPT(GeomVertexFormat) DXGeomMunger9::
61 munge_format_impl(
const GeomVertexFormat *orig,
63 if (dxgsg9_cat.is_debug()) {
66 <<
"preparing animation type " << animation <<
" for " << *orig
73 PT(GeomVertexFormat) new_format =
new GeomVertexFormat(*orig);
74 new_format->set_animation(animation);
75 PT(GeomVertexArrayFormat) new_array_format =
new GeomVertexArrayFormat;
82 new_array_format->add_column
83 (InternalName::get_vertex(), 3, NT_float32,
85 new_format->remove_column(vertex_type->
get_name());
97 new_array_format->add_column
105 new_array_format->add_column
106 (InternalName::get_transform_index(), 1,
107 NT_packed_dcba, C_index);
112 new_format->remove_column(InternalName::get_transform_weight());
113 new_format->remove_column(InternalName::get_transform_index());
116 new_format->remove_column(InternalName::get_transform_blend());
120 new_array_format->add_column
121 (InternalName::get_normal(), 3, NT_float32, C_normal);
122 new_format->remove_column(normal_type->
get_name());
126 new_array_format->add_column
127 (InternalName::get_color(), 1, NT_packed_dabc, C_color);
128 new_format->remove_column(color_type->
get_name());
140 vector_int ff_tc_index(num_stages, 0);
147 int max_tc_index = -1;
148 for (si = 0; si < num_stages; ++si) {
150 nassertr(tc_index < num_stages, orig);
151 ff_tc_index[tc_index] = si;
152 max_tc_index = max(tc_index, max_tc_index);
158 for (tc_index = 0; tc_index <= max_tc_index; ++tc_index) {
159 si = ff_tc_index[tc_index];
166 new_array_format->add_column
171 new_array_format->add_column(name, 2, NT_float32, C_texcoord);
173 new_format->remove_column(name);
179 for (
int i = 0; i < new_format->get_num_arrays(); ++i) {
180 CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i);
181 if (orig_a->count_unused_space() != 0) {
182 PT(GeomVertexArrayFormat) new_a =
new GeomVertexArrayFormat;
183 for (
int j = 0; j < orig_a->get_num_columns(); ++j) {
188 new_format->set_array(i, new_a);
194 new_format->insert_array(0, new_array_format);
196 return GeomVertexFormat::register_format(new_format);
205 CPT(GeomVertexFormat) DXGeomMunger9::
206 premunge_format_impl(
const GeomVertexFormat *orig) {
210 PT(GeomVertexFormat) new_format =
new GeomVertexFormat(*orig);
211 PT(GeomVertexArrayFormat) new_array_format =
new GeomVertexArrayFormat;
218 new_array_format->add_column
219 (InternalName::get_vertex(), 3, NT_float32,
221 new_format->remove_column(vertex_type->
get_name());
229 new_array_format->add_column
230 (InternalName::get_normal(), 3, NT_float32, C_normal);
231 new_format->remove_column(normal_type->
get_name());
235 new_array_format->add_column
236 (InternalName::get_color(), 1, NT_packed_dabc, C_color);
237 new_format->remove_column(color_type->
get_name());
249 vector_int ff_tc_index(num_stages, 0);
256 int max_tc_index = -1;
257 for (si = 0; si < num_stages; ++si) {
259 nassertr(tc_index < num_stages, orig);
260 ff_tc_index[tc_index] = si;
261 max_tc_index = max(tc_index, max_tc_index);
267 for (tc_index = 0; tc_index <= max_tc_index; ++tc_index) {
268 si = ff_tc_index[tc_index];
275 new_array_format->add_column
280 new_array_format->add_column(name, 2, NT_float32, C_texcoord);
282 new_format->remove_column(name);
288 for (
int i = 0; i < new_format->get_num_arrays(); ++i) {
289 CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i);
290 if (orig_a->count_unused_space() != 0) {
291 PT(GeomVertexArrayFormat) new_a =
new GeomVertexArrayFormat;
292 for (
int j = 0; j < orig_a->get_num_columns(); ++j) {
297 new_format->set_array(i, new_a);
303 new_format->insert_array(0, new_array_format);
305 return GeomVertexFormat::register_format(new_format);
317 compare_to_impl(
const GeomMunger *other)
const {
319 if (_filtered_texture != om->_filtered_texture) {
320 return _filtered_texture < om->_filtered_texture ? -1 : 1;
322 if (_tex_gen != om->_tex_gen) {
323 return _tex_gen < om->_tex_gen ? -1 : 1;
326 return StandardMunger::compare_to_impl(other);
338 geom_compare_to_impl(
const GeomMunger *other)
const {
344 if (_filtered_texture != om->_filtered_texture) {
345 return _filtered_texture < om->_filtered_texture ? -1 : 1;
347 if (_tex_gen != om->_tex_gen) {
348 return _tex_gen < om->_tex_gen ? -1 : 1;
351 return StandardMunger::geom_compare_to_impl(other);
Contents get_contents() const
Returns the token representing the semantic meaning of the stored value.
virtual void wp_callback(void *)
This callback is set to be made whenever the associated _texture or _tex_gen attributes are destructe...
int get_ff_tc_index(int n) const
For each TextureStage listed in get_on_ff_stage(), this returns a unique index number for the texture...
This object describes how the vertex animation, if any, represented in a GeomVertexData is encoded...
NumericType get_numeric_type() const
Returns the token representing the numeric type of the data storage.
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
int get_num_transforms() const
This is only meaningful for animation_type AT_hardware.
bool get_indexed_transforms() const
This is only meaningful for animation_type AT_hardware.
This defines how a single column is interleaved within a vertex array stored within a Geom...
Indicates the set of TextureStages and their associated Textures that should be applied to (or remove...
int get_num_on_ff_stages() const
Returns the number of on-stages that are relevant to the classic fixed function pipeline.
int get_num_values() const
Returns the number of numeric values of the column: the number of distinct numeric values that go int...
This specialization on GeomMunger finesses vertices for DirectX rendering.
AnimationType get_animation_type() const
Returns the type of animation represented by this spec.
InternalName * get_texcoord_name() const
See set_texcoord_name.
TextureStage * get_on_ff_stage(int n) const
Returns the nth stage turned on by the attribute, sorted in render order, including only those releva...
const InternalName * get_name() const
Returns the name of this particular data field, e.g.
TypeHandle is the identifier used to differentiate C++ class types.
int get_num_components() const
Returns the number of components of the column: the number of instances of the NumericType in each el...
Defines the properties of a named stage of the multitexture pipeline.