mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fix couch bug, take 2
This commit is contained in:
parent
def401c39f
commit
116a6866d6
@ -149,7 +149,7 @@ compute_angle() const {
|
|||||||
|
|
||||||
template <class PrimType>
|
template <class PrimType>
|
||||||
int MesherFanMaker<PrimType>::
|
int MesherFanMaker<PrimType>::
|
||||||
build() {
|
build(pvector<Prim> &unrolled_tris) {
|
||||||
nassertr(_edges.size() == _strips.size(), 0);
|
nassertr(_edges.size() == _strips.size(), 0);
|
||||||
|
|
||||||
int num_tris = _edges.size();
|
int num_tris = _edges.size();
|
||||||
@ -215,12 +215,12 @@ build() {
|
|||||||
if ( !((*si)->_prims.front() == (*last_si)->_prims.front()) ||
|
if ( !((*si)->_prims.front() == (*last_si)->_prims.front()) ||
|
||||||
!(*si)->is_coplanar_with(*(*last_si), _bucket->_coplanar_threshold)) {
|
!(*si)->is_coplanar_with(*(*last_si), _bucket->_coplanar_threshold)) {
|
||||||
// Here's the end of a run of matching pieces.
|
// Here's the end of a run of matching pieces.
|
||||||
count += unroll(last_si, si, last_ei, ei);
|
count += unroll(last_si, si, last_ei, ei, unrolled_tris);
|
||||||
last_si = si;
|
last_si = si;
|
||||||
last_ei = ei;
|
last_ei = ei;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count += unroll(last_si, si, last_ei, ei);
|
count += unroll(last_si, si, last_ei, ei, unrolled_tris);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
@ -261,7 +261,8 @@ build() {
|
|||||||
template <class PrimType>
|
template <class PrimType>
|
||||||
int MesherFanMaker<PrimType>::
|
int MesherFanMaker<PrimType>::
|
||||||
unroll(Strips::iterator strip_begin, Strips::iterator strip_end,
|
unroll(Strips::iterator strip_begin, Strips::iterator strip_end,
|
||||||
Edges::iterator edge_begin, Edges::iterator edge_end) {
|
Edges::iterator edge_begin, Edges::iterator edge_end,
|
||||||
|
pvector<Prim> &unrolled_tris) {
|
||||||
Edges::iterator ei;
|
Edges::iterator ei;
|
||||||
Strips::iterator si;
|
Strips::iterator si;
|
||||||
|
|
||||||
@ -300,7 +301,13 @@ unroll(Strips::iterator strip_begin, Strips::iterator strip_end,
|
|||||||
|
|
||||||
if (_bucket->_show_quads) {
|
if (_bucket->_show_quads) {
|
||||||
// If we're showing quads, also show retesselated triangles.
|
// If we're showing quads, also show retesselated triangles.
|
||||||
_mesher->add_prim(poly, MO_fanpoly);
|
|
||||||
|
// We can't add it directly to the mesher, that's unsafe; instead,
|
||||||
|
// we'll just add it to the end of the unrolled_tris list. This
|
||||||
|
// does mean we won't be able to color it a fancy color, but too
|
||||||
|
// bad.
|
||||||
|
//_mesher->add_prim(poly, MO_fanpoly);
|
||||||
|
unrolled_tris.push_back(poly);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Now decompose the new polygon into triangles.
|
// Now decompose the new polygon into triangles.
|
||||||
@ -308,12 +315,8 @@ unroll(Strips::iterator strip_begin, Strips::iterator strip_end,
|
|||||||
result = expand(poly, *_bucket, back_inserter(tris));
|
result = expand(poly, *_bucket, back_inserter(tris));
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
// Now add each triangle back into the mesher.
|
unrolled_tris.insert(unrolled_tris.end(),
|
||||||
pvector<Prim>::iterator ti;
|
tris.begin(), tris.end());
|
||||||
|
|
||||||
for (ti = tris.begin(); ti != tris.end(); ++ti) {
|
|
||||||
_mesher->add_prim(*ti);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "mesherStrip.h"
|
#include "mesherStrip.h"
|
||||||
|
|
||||||
#include "plist.h"
|
#include "plist.h"
|
||||||
|
#include "pvector.h"
|
||||||
|
|
||||||
|
|
||||||
template <class PrimType>
|
template <class PrimType>
|
||||||
@ -63,9 +64,10 @@ public:
|
|||||||
bool join(MesherFanMaker &other);
|
bool join(MesherFanMaker &other);
|
||||||
float compute_angle() const;
|
float compute_angle() const;
|
||||||
|
|
||||||
int build();
|
int build(pvector<Prim> &unrolled_tris);
|
||||||
int unroll(Strips::iterator strip_begin, Strips::iterator strip_end,
|
int unroll(Strips::iterator strip_begin, Strips::iterator strip_end,
|
||||||
Edges::iterator edge_begin, Edges::iterator edge_end);
|
Edges::iterator edge_begin, Edges::iterator edge_end,
|
||||||
|
pvector<Prim> &unrolled_tris);
|
||||||
|
|
||||||
ostream &output(ostream &out) const;
|
ostream &output(ostream &out) const;
|
||||||
|
|
||||||
|
@ -495,6 +495,8 @@ template <class PrimType>
|
|||||||
void MesherTempl<PrimType>::
|
void MesherTempl<PrimType>::
|
||||||
find_fans() {
|
find_fans() {
|
||||||
#ifdef SUPPORT_FANS
|
#ifdef SUPPORT_FANS
|
||||||
|
pvector<Prim> unrolled_tris;
|
||||||
|
|
||||||
// Consider all vertices. Any vertex with over a certain number of
|
// Consider all vertices. Any vertex with over a certain number of
|
||||||
// edges connected to it is eligible to become a fan.
|
// edges connected to it is eligible to become a fan.
|
||||||
|
|
||||||
@ -555,11 +557,21 @@ find_fans() {
|
|||||||
|
|
||||||
for (fi = fans.begin(); fi != fans.end(); ++fi) {
|
for (fi = fans.begin(); fi != fans.end(); ++fi) {
|
||||||
if ((*fi).is_valid()) {
|
if ((*fi).is_valid()) {
|
||||||
(*fi).build();
|
(*fi).build(unrolled_tris);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finally, add back in the triangles we might have produced by
|
||||||
|
// unrolling some of the fans. We can't add these back in safely
|
||||||
|
// until we're done traversing all the vertices and primitives we
|
||||||
|
// had in the first place (since adding them will affect the edge
|
||||||
|
// lists).
|
||||||
|
pvector<Prim>::iterator ti;
|
||||||
|
for (ti = unrolled_tris.begin(); ti != unrolled_tris.end(); ++ti) {
|
||||||
|
add_prim(*ti);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user