mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -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
|
// Function: EggGroup::test_vref_integrity
|
||||||
@ -826,7 +826,7 @@ test_vref_integrity() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // NDEBUG
|
#endif // _DEBUG
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggGroup::add_group_ref
|
// Function: EggGroup::add_group_ref
|
||||||
|
@ -299,11 +299,11 @@ public:
|
|||||||
INLINE VertexRef::size_type vref_size() const;
|
INLINE VertexRef::size_type vref_size() const;
|
||||||
|
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
#ifndef NDEBUG
|
#ifdef _DEBUG
|
||||||
void test_vref_integrity() const;
|
void test_vref_integrity() const;
|
||||||
#else
|
#else
|
||||||
void test_vref_integrity() const { }
|
void test_vref_integrity() const { }
|
||||||
#endif // NDEBUG
|
#endif // _DEBUG
|
||||||
|
|
||||||
void add_group_ref(EggGroup *group);
|
void add_group_ref(EggGroup *group);
|
||||||
int get_num_group_refs() const;
|
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
|
// Function: EggGroupNode::rename_nodes
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -142,6 +142,7 @@ PUBLISHED:
|
|||||||
|
|
||||||
int triangulate_polygons(int flags);
|
int triangulate_polygons(int flags);
|
||||||
void mesh_triangles(int flags);
|
void mesh_triangles(int flags);
|
||||||
|
void make_point_primitives();
|
||||||
|
|
||||||
int rename_nodes(vector_string strip_prefix, bool recurse);
|
int rename_nodes(vector_string strip_prefix, bool recurse);
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ parse_egg(const string &egg_syntax) {
|
|||||||
return (egg_error_count() == 0);
|
return (egg_error_count() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef _DEBUG
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggNode::test_under_integrity
|
// 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;
|
virtual void write(ostream &out, int indent_level) const=0;
|
||||||
bool parse_egg(const string &egg_syntax);
|
bool parse_egg(const string &egg_syntax);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef _DEBUG
|
||||||
void test_under_integrity() const;
|
void test_under_integrity() const;
|
||||||
#else
|
#else
|
||||||
void test_under_integrity() const { }
|
void test_under_integrity() const { }
|
||||||
#endif // NDEBUG
|
#endif // _DEBUG
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -638,12 +638,10 @@ remove_nonunique_verts() {
|
|||||||
Vertices new_vertices;
|
Vertices new_vertices;
|
||||||
int num_removed = 0;
|
int num_removed = 0;
|
||||||
|
|
||||||
|
pset<EggVertex *> unique_vertices;
|
||||||
for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
|
for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) {
|
||||||
bool okflag = true;
|
bool inserted = unique_vertices.insert(*vi).second;
|
||||||
for (vj = _vertices.begin(); vj != vi && okflag; ++vj) {
|
if (inserted) {
|
||||||
okflag = ((*vi) != (*vj));
|
|
||||||
}
|
|
||||||
if (okflag) {
|
|
||||||
new_vertices.push_back(*vi);
|
new_vertices.push_back(*vi);
|
||||||
} else {
|
} else {
|
||||||
prepare_remove_vertex(*vi, vi - _vertices.begin() - num_removed,
|
prepare_remove_vertex(*vi, vi - _vertices.begin() - num_removed,
|
||||||
@ -803,7 +801,7 @@ copy_vertices(const EggPrimitive &other) {
|
|||||||
other.test_vref_integrity();
|
other.test_vref_integrity();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef _DEBUG
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggPrimitive::test_vref_integrity
|
// Function: EggPrimitive::test_vref_integrity
|
||||||
@ -850,7 +848,7 @@ test_vref_integrity() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // NDEBUG
|
#endif // _DEBUG
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggPrimitive::prepare_add_vertex
|
// Function: EggPrimitive::prepare_add_vertex
|
||||||
|
@ -182,11 +182,11 @@ PUBLISHED:
|
|||||||
|
|
||||||
virtual void write(ostream &out, int indent_level) const=0;
|
virtual void write(ostream &out, int indent_level) const=0;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef _DEBUG
|
||||||
void test_vref_integrity() const;
|
void test_vref_integrity() const;
|
||||||
#else
|
#else
|
||||||
void test_vref_integrity() const { }
|
void test_vref_integrity() const { }
|
||||||
#endif // NDEBUG
|
#endif // _DEBUG
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Vertices _vertices;
|
Vertices _vertices;
|
||||||
|
@ -670,7 +670,7 @@ has_pref(const EggPrimitive *prim) const {
|
|||||||
return _pref.count((EggPrimitive *)prim);
|
return _pref.count((EggPrimitive *)prim);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef _DEBUG
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggVertex::test_gref_integrity
|
// Function: EggVertex::test_gref_integrity
|
||||||
|
@ -129,13 +129,13 @@ public:
|
|||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
int has_pref(const EggPrimitive *prim) const;
|
int has_pref(const EggPrimitive *prim) const;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifdef _DEBUG
|
||||||
void test_gref_integrity() const;
|
void test_gref_integrity() const;
|
||||||
void test_pref_integrity() const;
|
void test_pref_integrity() const;
|
||||||
#else
|
#else
|
||||||
void test_gref_integrity() const { }
|
void test_gref_integrity() const { }
|
||||||
void test_pref_integrity() const { }
|
void test_pref_integrity() const { }
|
||||||
#endif // NDEBUG
|
#endif // _DEBUG
|
||||||
|
|
||||||
void output(ostream &out) const;
|
void output(ostream &out) const;
|
||||||
|
|
||||||
|
@ -651,6 +651,23 @@ remove_unused_vertices() {
|
|||||||
return num_removed;
|
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.
|
// A function object for split_vertex(), used in transform(), below.
|
||||||
class IsLocalVertexSplitter {
|
class IsLocalVertexSplitter {
|
||||||
public:
|
public:
|
||||||
|
@ -128,6 +128,7 @@ PUBLISHED:
|
|||||||
|
|
||||||
void remove_vertex(EggVertex *vertex);
|
void remove_vertex(EggVertex *vertex);
|
||||||
int remove_unused_vertices();
|
int remove_unused_vertices();
|
||||||
|
void add_unused_vertices_to_prim(EggPrimitive *prim);
|
||||||
|
|
||||||
void transform(const LMatrix4d &mat);
|
void transform(const LMatrix4d &mat);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user