fix crash when meshing certain models

This commit is contained in:
David Rose 2004-05-07 17:42:39 +00:00
parent 2d6e682f31
commit 95f8fa1fb8
3 changed files with 59 additions and 15 deletions

View File

@ -24,9 +24,62 @@
#include <math.h>
////////////////////////////////////////////////////////////////////
// Function: MesherFanMaker::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
template <class PrimType>
MesherFanMaker<PrimType>::
MesherFanMaker(const Vertex *vertex, Strip *tri, Mesher *mesher) {
_vertex = vertex;
const Edge *edge = tri->find_opposite_edge(vertex);
if (edge != (const Edge *)NULL) {
_edges.push_back(edge);
}
_strips.push_back(tri);
_planar = tri->_planar;
_mesher = mesher;
_bucket = _mesher->_bucket;
}
////////////////////////////////////////////////////////////////////
// Function: MesherFanMaker::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
template <class PrimType>
MesherFanMaker<PrimType>::
MesherFanMaker(const MesherFanMaker<PrimType> &copy) :
_vertex(copy._vertex),
_edges(copy._edges),
_strips(copy._strips),
_planar(copy._planar),
_bucket(copy._bucket),
_mesher(copy._mesher)
{
}
////////////////////////////////////////////////////////////////////
// Function: MesherFanMaker::Copy Assignment Operator
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
template <class PrimType>
void MesherFanMaker<PrimType>::
operator = (const MesherFanMaker<PrimType> &copy) {
_vertex = copy._vertex;
_edges = copy._edges;
_strips = copy._strips;
_planar = copy._planar;
_bucket = copy._bucket;
_mesher = copy._mesher;
}
template <class PrimType>
INLINE bool MesherFanMaker<PrimType>::
operator < (const MesherFanMaker &other) const {
nassertr(!_edges.empty() && !other._edges.empty(), false);
return _edges.front() < other._edges.front();
}
@ -68,20 +121,6 @@ is_coplanar_with(const MesherFanMaker &other) const {
_bucket->_coplanar_threshold);
}
template <class PrimType>
MesherFanMaker<PrimType>::
MesherFanMaker(const Vertex *vertex, Strip *tri, Mesher *mesher) {
_vertex = vertex;
const Edge *edge = tri->find_opposite_edge(vertex);
if (edge != (const Edge *)NULL) {
_edges.push_back(edge);
}
_strips.push_back(tri);
_planar = tri->_planar;
_mesher = mesher;
_bucket = _mesher->_bucket;
}
template <class PrimType>
bool MesherFanMaker<PrimType>::
join(MesherFanMaker &other) {

View File

@ -52,6 +52,8 @@ public:
MesherFanMaker() {}
MesherFanMaker(const Vertex *vertex, Strip *tri, Mesher *mesher);
MesherFanMaker(const MesherFanMaker<PrimType> &copy);
void operator = (const MesherFanMaker<PrimType> &copy);
INLINE bool operator < (const MesherFanMaker &other) const;
INLINE bool operator != (const MesherFanMaker &other) const;

View File

@ -534,7 +534,10 @@ find_fans() {
++si) {
Strip *strip = *si;
if (strip->_type == BPT_tri) {
fans.push_back(FanMaker(&v, strip, this));
FanMaker fan(&v, strip, this);
if (!fan._edges.empty()) {
fans.push_back(fan);
}
}
}
}