mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 18:03:56 -04:00
add make_point_primitives()
This commit is contained in:
parent
b387c726b4
commit
0368aaaf82
@ -805,7 +805,7 @@ steal_vrefs(EggGroup *other) {
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef _DEBUG
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggGroup::test_vref_integrity
|
||||
@ -826,7 +826,7 @@ test_vref_integrity() const {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NDEBUG
|
||||
#endif // _DEBUG
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggGroup::add_group_ref
|
||||
|
@ -299,11 +299,11 @@ public:
|
||||
INLINE VertexRef::size_type vref_size() const;
|
||||
|
||||
PUBLISHED:
|
||||
#ifndef NDEBUG
|
||||
#ifdef _DEBUG
|
||||
void test_vref_integrity() const;
|
||||
#else
|
||||
void test_vref_integrity() const { }
|
||||
#endif // NDEBUG
|
||||
#endif // _DEBUG
|
||||
|
||||
void add_group_ref(EggGroup *group);
|
||||
int get_num_group_refs() const;
|
||||
|
@ -856,6 +856,39 @@ mesh_triangles(int flags) {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggGroupNode::make_point_primitives
|
||||
// Access: Published
|
||||
// Description: Creates PointLight primitives to reference any
|
||||
// otherwise unreferences vertices discovered in this
|
||||
// group or below.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void EggGroupNode::
|
||||
make_point_primitives() {
|
||||
// Create a temporary node to hold the EggPoint objects we might
|
||||
// create while we iterate. (We don't add them during the iteration
|
||||
// to avoid invalidating the iterator.)
|
||||
PT(EggGroupNode) temp = new EggGroup("temp");
|
||||
|
||||
EggGroupNode::iterator ci;
|
||||
for (ci = begin(); ci != end(); ++ci) {
|
||||
if ((*ci)->is_of_type(EggGroupNode::get_class_type())) {
|
||||
EggGroupNode *group_child = DCAST(EggGroupNode, *ci);
|
||||
group_child->make_point_primitives();
|
||||
|
||||
} else if ((*ci)->is_of_type(EggVertexPool::get_class_type())) {
|
||||
EggVertexPool *vpool = DCAST(EggVertexPool, *ci);
|
||||
PT(EggPrimitive) prim = new EggPoint;
|
||||
vpool->add_unused_vertices_to_prim(prim);
|
||||
if (!prim->empty()) {
|
||||
temp->add_child(prim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
steal_children(*temp);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggGroupNode::rename_nodes
|
||||
// Access: Published
|
||||
|
@ -142,6 +142,7 @@ PUBLISHED:
|
||||
|
||||
int triangulate_polygons(int flags);
|
||||
void mesh_triangles(int flags);
|
||||
void make_point_primitives();
|
||||
|
||||
int rename_nodes(vector_string strip_prefix, bool recurse);
|
||||
|
||||
|
@ -287,7 +287,7 @@ parse_egg(const string &egg_syntax) {
|
||||
return (egg_error_count() == 0);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef _DEBUG
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggNode::test_under_integrity
|
||||
@ -324,7 +324,7 @@ test_under_integrity() const {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NDEBUG
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -84,11 +84,11 @@ PUBLISHED:
|
||||
virtual void write(ostream &out, int indent_level) const=0;
|
||||
bool parse_egg(const string &egg_syntax);
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef _DEBUG
|
||||
void test_under_integrity() const;
|
||||
#else
|
||||
void test_under_integrity() const { }
|
||||
#endif // NDEBUG
|
||||
#endif // _DEBUG
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -638,12 +638,10 @@ remove_nonunique_verts() {
|
||||
Vertices new_vertices;
|
||||
int num_removed = 0;
|
||||
|
||||
pset<EggVertex *> unique_vertices;
|
||||
for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
|
||||
bool okflag = true;
|
||||
for (vj = _vertices.begin(); vj != vi && okflag; ++vj) {
|
||||
okflag = ((*vi) != (*vj));
|
||||
}
|
||||
if (okflag) {
|
||||
bool inserted = unique_vertices.insert(*vi).second;
|
||||
if (inserted) {
|
||||
new_vertices.push_back(*vi);
|
||||
} else {
|
||||
prepare_remove_vertex(*vi, vi - _vertices.begin() - num_removed,
|
||||
@ -803,7 +801,7 @@ copy_vertices(const EggPrimitive &other) {
|
||||
other.test_vref_integrity();
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef _DEBUG
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggPrimitive::test_vref_integrity
|
||||
@ -850,7 +848,7 @@ test_vref_integrity() const {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NDEBUG
|
||||
#endif // _DEBUG
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggPrimitive::prepare_add_vertex
|
||||
|
@ -182,11 +182,11 @@ PUBLISHED:
|
||||
|
||||
virtual void write(ostream &out, int indent_level) const=0;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef _DEBUG
|
||||
void test_vref_integrity() const;
|
||||
#else
|
||||
void test_vref_integrity() const { }
|
||||
#endif // NDEBUG
|
||||
#endif // _DEBUG
|
||||
|
||||
protected:
|
||||
Vertices _vertices;
|
||||
|
@ -670,7 +670,7 @@ has_pref(const EggPrimitive *prim) const {
|
||||
return _pref.count((EggPrimitive *)prim);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef _DEBUG
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggVertex::test_gref_integrity
|
||||
|
@ -129,13 +129,13 @@ public:
|
||||
PUBLISHED:
|
||||
int has_pref(const EggPrimitive *prim) const;
|
||||
|
||||
#ifndef NDEBUG
|
||||
#ifdef _DEBUG
|
||||
void test_gref_integrity() const;
|
||||
void test_pref_integrity() const;
|
||||
#else
|
||||
void test_gref_integrity() const { }
|
||||
void test_pref_integrity() const { }
|
||||
#endif // NDEBUG
|
||||
#endif // _DEBUG
|
||||
|
||||
void output(ostream &out) const;
|
||||
|
||||
|
@ -651,6 +651,23 @@ remove_unused_vertices() {
|
||||
return num_removed;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: EggVertexPool::add_unused_vertices_to_prim
|
||||
// Access: Public
|
||||
// Description: Adds all of the unused vertices in this vertex pool
|
||||
// to the indicated primitive, in ascending order.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void EggVertexPool::
|
||||
add_unused_vertices_to_prim(EggPrimitive *prim) {
|
||||
IndexVertices::iterator ivi;
|
||||
for (ivi = _index_vertices.begin(); ivi != _index_vertices.end(); ++ivi) {
|
||||
EggVertex *vertex = (*ivi).second;
|
||||
if (vertex->pref_size() == 0) {
|
||||
prim->add_vertex(vertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A function object for split_vertex(), used in transform(), below.
|
||||
class IsLocalVertexSplitter {
|
||||
public:
|
||||
|
@ -128,6 +128,7 @@ PUBLISHED:
|
||||
|
||||
void remove_vertex(EggVertex *vertex);
|
||||
int remove_unused_vertices();
|
||||
void add_unused_vertices_to_prim(EggPrimitive *prim);
|
||||
|
||||
void transform(const LMatrix4d &mat);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user