From decb6d20074beff7e1d4dd2300e0a9e65764dce5 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 2 May 2001 18:49:29 +0000 Subject: [PATCH] *** empty log message *** --- pandatool/src/flt/fltGeometry.I | 8 +++++++- pandatool/src/flt/fltGeometry.cxx | 8 ++++---- pandatool/src/flt/fltGeometry.h | 4 ++-- pandatool/src/flt/fltVertex.I | 5 ++++- pandatool/src/flt/fltVertex.cxx | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pandatool/src/flt/fltGeometry.I b/pandatool/src/flt/fltGeometry.I index 0311e38c31..0ef893e9c7 100644 --- a/pandatool/src/flt/fltGeometry.I +++ b/pandatool/src/flt/fltGeometry.I @@ -56,5 +56,11 @@ get_material() const { //////////////////////////////////////////////////////////////////// INLINE bool FltGeometry:: has_color() const { - return ((_flags & F_no_color) == 0) || has_material(); + // Even if the no_color bit is not set, if the color_index is -1, + // the face doesn't have a color (unless we've got packed color). + // On the other hand, if we have a material than we always have + // color. + return ((_flags & F_no_color) == 0 && + (_color_index != -1 || ((_flags & F_packed_color) != 0))) + || has_material(); } diff --git a/pandatool/src/flt/fltGeometry.cxx b/pandatool/src/flt/fltGeometry.cxx index d4634da2ee..3d05845a9b 100644 --- a/pandatool/src/flt/fltGeometry.cxx +++ b/pandatool/src/flt/fltGeometry.cxx @@ -189,8 +189,8 @@ extract_record(FltRecordReader &reader) { if (_header->get_flt_version() >= 15.2) { _texture_mapping_index = iterator.get_be_int16(); iterator.skip_bytes(2); - _color_index = iterator.get_be_uint32(); - _alt_color_index = iterator.get_be_uint32(); + _color_index = iterator.get_be_int32(); + _alt_color_index = iterator.get_be_int32(); iterator.skip_bytes(2 + 2); } @@ -242,8 +242,8 @@ build_record(FltRecordWriter &writer) const { // New with 15.2 datagram.add_be_int16(_texture_mapping_index); datagram.pad_bytes(2); - datagram.add_be_uint32(_color_index); - datagram.add_be_uint32(_alt_color_index); + datagram.add_be_int32(_color_index); + datagram.add_be_int32(_alt_color_index); datagram.pad_bytes(2 + 2); } diff --git a/pandatool/src/flt/fltGeometry.h b/pandatool/src/flt/fltGeometry.h index c0bdf94c0b..653fd8f700 100644 --- a/pandatool/src/flt/fltGeometry.h +++ b/pandatool/src/flt/fltGeometry.h @@ -83,8 +83,8 @@ public: FltPackedColor _packed_color; FltPackedColor _alt_packed_color; int _texture_mapping_index; - unsigned int _color_index; - unsigned int _alt_color_index; + int _color_index; + int _alt_color_index; public: INLINE bool has_texture() const; diff --git a/pandatool/src/flt/fltVertex.I b/pandatool/src/flt/fltVertex.I index c0ce7b9cca..d022e3dd3c 100644 --- a/pandatool/src/flt/fltVertex.I +++ b/pandatool/src/flt/fltVertex.I @@ -12,5 +12,8 @@ //////////////////////////////////////////////////////////////////// INLINE bool FltVertex:: has_color() const { - return (_flags & F_no_color) == 0; + // Even if the no_color bit is not set, if the color_index is -1, + // the vertex doesn't have a color (unless we've got packed color). + return ((_flags & F_no_color) == 0 && + (_color_index != -1 || ((_flags & F_packed_color) != 0))); } diff --git a/pandatool/src/flt/fltVertex.cxx b/pandatool/src/flt/fltVertex.cxx index ea29533aad..56d67441bb 100644 --- a/pandatool/src/flt/fltVertex.cxx +++ b/pandatool/src/flt/fltVertex.cxx @@ -194,7 +194,7 @@ extract_record(FltRecordReader &reader) { return false; } if (_header->get_flt_version() >= 15.2) { - _color_index = iterator.get_be_uint32(); + _color_index = iterator.get_be_int32(); if (_has_normal && iterator.get_remaining_size() > 0) { // If we extracted a normal, our double-word alignment is off; now