fix obscure texcoord bug

This commit is contained in:
David Rose 2001-07-31 17:07:57 +00:00
parent 61d9c02595
commit 2b7f0ca2e6
7 changed files with 148 additions and 37 deletions

View File

@ -10,7 +10,9 @@
#define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx
#define SOURCES \
builder.I builder.h builderAttrib.I builderAttrib.h \
builder.I builder.h \
builder_compare.I builder_compare.h \
builderAttrib.I builderAttrib.h \
builderAttribTempl.I builderAttribTempl.h builderBucket.I \
builderBucket.h builderBucketNode.I builderBucketNode.h \
builderFuncs.I builderFuncs.h builderMisc.h \
@ -31,7 +33,9 @@
config_builder.cxx mesher.cxx
#define INSTALL_HEADERS \
builder.I builder.h builderAttrib.I builderAttrib.h \
builder.I builder.h \
builder_compare.I builder_compare.h \
builderAttrib.I builderAttrib.h \
builderAttribTempl.I builderAttribTempl.h builderBucket.I \
builderBucket.h builderBucketNode.I builderBucketNode.h \
builderNormalVisualizer.I builderNormalVisualizer.h \

View File

@ -242,13 +242,7 @@ clear_pixel_size() {
template <class VT, class NT, class TT, class CT>
INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
operator == (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
if (has_normal() && !(_normal == other._normal))
return false;
if (has_color() && !(_color == other._color))
return false;
return true;
return compare_to(other) == 0;
}
////////////////////////////////////////////////////////////////////
@ -278,13 +272,34 @@ operator != (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
template <class VT, class NT, class TT, class CT>
INLINE bool BuilderAttribTempl<VT, NT, TT, CT>::
operator < (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
if (has_normal() && !(_normal == other._normal))
return _normal < other._normal;
return compare_to(other) < 0;
}
if (has_color() && !(_color == other._color))
return _color < other._color;
////////////////////////////////////////////////////////////////////
// Function: BuilderAttribTempl::compare_to
// Access: Public
// Description: Returns a number less than zero if this object sorts
// before the indicated object, greater than zero if it
// sorts after, and zero if the objects are equivalent.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
int BuilderAttribTempl<VT, NT, TT, CT>::
compare_to(const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
if (has_normal()) {
int normal_compare = builder_compare(_normal, other._normal);
if (normal_compare != 0) {
return normal_compare;
}
}
return false;
if (has_color()) {
int color_compare = builder_compare(_color, other._color);
if (color_compare != 0) {
return color_compare;
}
}
return 0;
}
////////////////////////////////////////////////////////////////////
@ -293,7 +308,7 @@ operator < (const BuilderAttribTempl<VT, NT, TT, CT> &other) const {
// Description: Formats the attribs for output in some sensible way.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
INLINE ostream &BuilderAttribTempl<VT, NT, TT, CT>::
ostream &BuilderAttribTempl<VT, NT, TT, CT>::
output(ostream &out) const {
if (this!=NULL) {
if (has_normal()) {

View File

@ -65,8 +65,9 @@ public:
INLINE bool operator == (const BuilderAttribTempl &other) const;
INLINE bool operator != (const BuilderAttribTempl &other) const;
INLINE bool operator < (const BuilderAttribTempl &other) const;
int compare_to(const BuilderAttribTempl &other) const;
INLINE ostream &output(ostream &out) const;
ostream &output(ostream &out) const;
protected:
NType _normal;

View File

@ -16,7 +16,6 @@
//
////////////////////////////////////////////////////////////////////
#include <notify.h>
////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::Constructor
@ -285,15 +284,9 @@ clear_pixel_size() {
// texcoords, etc.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
bool BuilderVertexTempl<VT, NT, TT, CT>::
INLINE bool BuilderVertexTempl<VT, NT, TT, CT>::
operator == (const BuilderVertexTempl<VT, NT, TT, CT> &other) const {
if (has_coord() && !(_coord == other._coord))
return false;
if (has_texcoord() && !(_texcoord == other._texcoord))
return false;
return BuilderAttribTempl<VT, NT, TT, CT>::operator == (other);
return compare_to(other) == 0;
}
////////////////////////////////////////////////////////////////////
@ -321,15 +314,36 @@ operator != (const BuilderVertexTempl<VT, NT, TT, CT> &other) const {
// etc.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
bool BuilderVertexTempl<VT, NT, TT, CT>::
INLINE bool BuilderVertexTempl<VT, NT, TT, CT>::
operator < (const BuilderVertexTempl<VT, NT, TT, CT> &other) const {
if (has_coord() && !(_coord == other._coord))
return _coord < other._coord;
return compare_to(other) < 0;
}
if (has_texcoord() && !(_texcoord == other._texcoord))
return _texcoord < other._texcoord;
////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::compare_to
// Access: Public
// Description: Returns a number less than zero if this vertex sorts
// before the indicated vertex, greater than zero if it
// sorts after, and zero if the vertices are equivalent.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
int BuilderVertexTempl<VT, NT, TT, CT>::
compare_to(const BuilderVertexTempl<VT, NT, TT, CT> &other) const {
if (has_coord()) {
int coord_compare = builder_compare(_coord, other._coord);
if (coord_compare != 0) {
return coord_compare;
}
}
return BuilderAttribTempl<VT, NT, TT, CT>::operator < (other);
if (has_texcoord()) {
int texcoord_compare = builder_compare(_texcoord, other._texcoord);
if (texcoord_compare != 0) {
return texcoord_compare;
}
}
return BuilderAttribTempl<VT, NT, TT, CT>::compare_to(other);
}
////////////////////////////////////////////////////////////////////
@ -345,7 +359,6 @@ output(ostream &out) const {
out << get_coord();
}
/*
if (has_normal()) {
out << " normal " << get_normal();
}
@ -361,7 +374,6 @@ output(ostream &out) const {
if (has_pixel_size()) {
out << " pixel_size " << get_pixel_size();
}
*/
}
return out;
}

View File

@ -19,14 +19,15 @@
#ifndef BUILDERVERTEXTEMPL_H
#define BUILDERVERTEXTEMPL_H
#include <pandabase.h>
#include "pandabase.h"
#include "builderTypes.h"
#include "builderAttribTempl.h"
#include "builder_compare.h"
#include "notify.h"
#include "pvector.h"
/////////////////////////////////////////////////////////////////////
// Class : BuilderVertexTempl
// Description : The main body of BuilderVertex and BuilderVertexI.
@ -68,9 +69,10 @@ public:
INLINE BuilderVertexTempl &set_pixel_size(float s);
INLINE BuilderVertexTempl &clear_pixel_size();
bool operator == (const BuilderVertexTempl &other) const;
INLINE bool operator == (const BuilderVertexTempl &other) const;
INLINE bool operator != (const BuilderVertexTempl &other) const;
bool operator < (const BuilderVertexTempl &other) const;
INLINE bool operator < (const BuilderVertexTempl &other) const;
int compare_to(const BuilderVertexTempl &other) const;
ostream &output(ostream &out) const;

View File

@ -0,0 +1,37 @@
// Filename: builder_compare.I
// Created by: drose (31Jul01)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
INLINE int
builder_compare(const LVecBase2f &a, const LVecBase2f &b) {
return a.compare_to(b);
}
INLINE int
builder_compare(const LVecBase3f &a, const LVecBase3f &b) {
return a.compare_to(b);
}
INLINE int
builder_compare(const LVecBase4f &a, const LVecBase4f &b) {
return a.compare_to(b);
}
INLINE int
builder_compare(ushort a, ushort b) {
return (int)a - (int)b;
}

View File

@ -0,0 +1,40 @@
// Filename: builder_compare.h
// Created by: drose (31Jul01)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt .
//
// To contact the maintainers of this program write to
// panda3d@yahoogroups.com .
//
////////////////////////////////////////////////////////////////////
#ifndef BUILDERCOMPARE_H
#define BUILDERCOMPARE_H
#include "pandabase.h"
#include "luse.h"
// This file defines some trivial functions that return strcmp-style
// comparisonresults for the major types of our vertices. This allows
// us to write type-independent template code to compare vertex
// values for equivalence or order relationships.
INLINE int builder_compare(const LVecBase2f &a, const LVecBase2f &b);
INLINE int builder_compare(const LVecBase3f &a, const LVecBase3f &b);
INLINE int builder_compare(const LVecBase4f &a, const LVecBase4f &b);
INLINE int builder_compare(ushort a, ushort b);
#include "builder_compare.I"
#endif