mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
fix crashes
This commit is contained in:
parent
3b7565e025
commit
6b54ff8fb9
@ -73,7 +73,7 @@
|
|||||||
eggTriangleStrip.cxx \
|
eggTriangleStrip.cxx \
|
||||||
eggUserData.cxx \
|
eggUserData.cxx \
|
||||||
eggUtilities.cxx eggVertex.cxx eggVertexPool.cxx eggVertexUV.cxx \
|
eggUtilities.cxx eggVertex.cxx eggVertexPool.cxx eggVertexUV.cxx \
|
||||||
eggXfmAnimData.cxx eggXfmSAnim.cxx xx xx pt_EggMaterial.cxx \
|
eggXfmAnimData.cxx eggXfmSAnim.cxx pt_EggMaterial.cxx \
|
||||||
vector_PT_EggMaterial.cxx pt_EggTexture.cxx \
|
vector_PT_EggMaterial.cxx pt_EggTexture.cxx \
|
||||||
vector_PT_EggTexture.cxx pt_EggVertex.cxx \
|
vector_PT_EggTexture.cxx pt_EggVertex.cxx \
|
||||||
vector_PT_EggVertex.cxx
|
vector_PT_EggVertex.cxx
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "eggCompositePrimitive.h"
|
#include "eggCompositePrimitive.h"
|
||||||
|
#include "eggGroupNode.h"
|
||||||
|
|
||||||
TypeHandle EggCompositePrimitive::_type_handle;
|
TypeHandle EggCompositePrimitive::_type_handle;
|
||||||
|
|
||||||
@ -113,10 +114,10 @@ write_body(ostream &out, int indent_level) const {
|
|||||||
for (int i = 0; i < get_num_components(); i++) {
|
for (int i = 0; i < get_num_components(); i++) {
|
||||||
const EggAttributes *attrib = get_component(i);
|
const EggAttributes *attrib = get_component(i);
|
||||||
if (attrib->compare_to(*this) != 0) {
|
if (attrib->compare_to(*this) != 0) {
|
||||||
indent(out, indent_level + 2)
|
indent(out, indent_level)
|
||||||
<< "<Component> " << i << " {\n";
|
<< "<Component> " << i << " {\n";
|
||||||
attrib->write(out, indent_level + 4);
|
attrib->write(out, indent_level + 2);
|
||||||
indent(out, indent_level + 2) << "}\n";
|
indent(out, indent_level) << "}\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,8 +305,8 @@ set_coordinate_system(CoordinateSystem new_coordsys) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void EggData::
|
void EggData::
|
||||||
write(ostream &out, int indent_level) const {
|
write(ostream &out, int indent_level) const {
|
||||||
EggCoordinateSystem ecs(_coordsys);
|
PT(EggCoordinateSystem) ecs = new EggCoordinateSystem(_coordsys);
|
||||||
ecs.write(out, indent_level);
|
ecs->write(out, indent_level);
|
||||||
EggGroupNode::write(out, indent_level);
|
EggGroupNode::write(out, indent_level);
|
||||||
out << flush;
|
out << flush;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "indent.h"
|
#include "indent.h"
|
||||||
#include "string_utils.h"
|
#include "string_utils.h"
|
||||||
#include "lmatrix.h"
|
#include "lmatrix.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
|
|
||||||
TypeHandle EggGroup::_type_handle;
|
TypeHandle EggGroup::_type_handle;
|
||||||
@ -61,14 +62,14 @@ operator = (const EggGroup ©) {
|
|||||||
EggTransform3d::operator = (copy);
|
EggTransform3d::operator = (copy);
|
||||||
_flags = copy._flags;
|
_flags = copy._flags;
|
||||||
_flags2 = copy._flags2;
|
_flags2 = copy._flags2;
|
||||||
_collide_mask = copy._collide_mask;
|
// _collide_mask = copy._collide_mask;
|
||||||
_from_collide_mask = copy._from_collide_mask;
|
// _from_collide_mask = copy._from_collide_mask;
|
||||||
_into_collide_mask = copy._into_collide_mask;
|
// _into_collide_mask = copy._into_collide_mask;
|
||||||
_billboard_center = copy._billboard_center;
|
// _billboard_center = copy._billboard_center;
|
||||||
_object_types = copy._object_types;
|
_object_types = copy._object_types;
|
||||||
_collision_name = copy._collision_name;
|
_collision_name = copy._collision_name;
|
||||||
_fps = copy._fps;
|
_fps = copy._fps;
|
||||||
_lod = copy._lod;
|
// _lod = copy._lod;
|
||||||
|
|
||||||
_tag_data = copy._tag_data;
|
_tag_data = copy._tag_data;
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "dSearchPath.h"
|
#include "dSearchPath.h"
|
||||||
#include "deg_2_rad.h"
|
#include "deg_2_rad.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -282,6 +283,7 @@ get_next_child() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
EggNode *EggGroupNode::
|
EggNode *EggGroupNode::
|
||||||
add_child(EggNode *node) {
|
add_child(EggNode *node) {
|
||||||
|
test_ref_count_integrity();
|
||||||
PT(EggNode) ptnode = node;
|
PT(EggNode) ptnode = node;
|
||||||
if (node->_parent != NULL) {
|
if (node->_parent != NULL) {
|
||||||
node->_parent->remove_child(node);
|
node->_parent->remove_child(node);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "eggMaterial.h"
|
#include "eggMaterial.h"
|
||||||
|
|
||||||
#include "nameUniquifier.h"
|
#include "nameUniquifier.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include "eggCompositePrimitive.h"
|
#include "eggCompositePrimitive.h"
|
||||||
#include "eggTriangleStrip.h"
|
#include "eggTriangleStrip.h"
|
||||||
#include "config_egg.h"
|
#include "config_egg.h"
|
||||||
|
#include "eggGroupNode.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "eggMesherEdge.h"
|
#include "eggMesherEdge.h"
|
||||||
|
#include "eggMesherStrip.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggMesherEdge::remove
|
// Function: EggMesherEdge::remove
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
#include "eggMesherStrip.h"
|
#include "eggMesherStrip.h"
|
||||||
#include "eggMesherEdge.h"
|
#include "eggMesherEdge.h"
|
||||||
#include "eggPrimitive.h"
|
#include "eggPrimitive.h"
|
||||||
|
#include "eggTriangleStrip.h"
|
||||||
#include "eggPolygon.h"
|
#include "eggPolygon.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
#include "config_egg.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggMesherStrip::Constructor
|
// Function: EggMesherStrip::Constructor
|
||||||
@ -118,8 +121,6 @@ make_prim(const EggVertexPool *vertex_pool) {
|
|||||||
prim = new EggTriangleStrip;
|
prim = new EggTriangleStrip;
|
||||||
prim->copy_attributes(*_prims.front());
|
prim->copy_attributes(*_prims.front());
|
||||||
|
|
||||||
PrimType type = dest_type;
|
|
||||||
|
|
||||||
// Now store all the vertices. Each individual triangle's
|
// Now store all the vertices. Each individual triangle's
|
||||||
// attributes, if any, get applied to the third vertex of each
|
// attributes, if any, get applied to the third vertex of each
|
||||||
// triangle.
|
// triangle.
|
||||||
@ -140,7 +141,7 @@ make_prim(const EggVertexPool *vertex_pool) {
|
|||||||
// with the third completes a triangle.
|
// with the third completes a triangle.
|
||||||
const EggAttributes *attrib = (*pi);
|
const EggAttributes *attrib = (*pi);
|
||||||
++pi;
|
++pi;
|
||||||
// prim->set_component(count - 2, *attrib);
|
DCAST(EggCompositePrimitive, prim)->set_component(count - 3, attrib);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,16 +21,18 @@
|
|||||||
|
|
||||||
#include "pandabase.h"
|
#include "pandabase.h"
|
||||||
#include "eggVertexPool.h"
|
#include "eggVertexPool.h"
|
||||||
|
#include "eggPrimitive.h"
|
||||||
|
#include "eggMesherEdge.h"
|
||||||
#include "plist.h"
|
#include "plist.h"
|
||||||
|
|
||||||
class EggMesherEdge;
|
class EggMesherEdge;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
// Class : EggMesherStrip
|
// Class : EggMesherStrip
|
||||||
// Description : Represents a triangle strip in progress, as assembled
|
// Description : Represents a triangle strip or quad strip in
|
||||||
// by the mesher. It might also represent a single
|
// progress, as assembled by the mesher. It might also
|
||||||
// polygon such as a triangle or quad, since that's how
|
// represent a single polygon such as a triangle or
|
||||||
// all triangle strips start out.
|
// quad, since that's how strips generally start out.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EggMesherStrip {
|
class EggMesherStrip {
|
||||||
public:
|
public:
|
||||||
|
@ -68,7 +68,7 @@ INLINE EggMorphList<MorphType>::
|
|||||||
template<class MorphType>
|
template<class MorphType>
|
||||||
INLINE bool EggMorphList<MorphType>::
|
INLINE bool EggMorphList<MorphType>::
|
||||||
operator == (const EggMorphList<MorphType> &other) const {
|
operator == (const EggMorphList<MorphType> &other) const {
|
||||||
return compare_to(other) == 0;
|
return (_morphs == other._morphs);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -79,7 +79,7 @@ operator == (const EggMorphList<MorphType> &other) const {
|
|||||||
template<class MorphType>
|
template<class MorphType>
|
||||||
INLINE bool EggMorphList<MorphType>::
|
INLINE bool EggMorphList<MorphType>::
|
||||||
operator != (const EggMorphList<MorphType> &other) const {
|
operator != (const EggMorphList<MorphType> &other) const {
|
||||||
return compare_to(other) != 0;
|
return (_morphs != other._morphs);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -90,18 +90,20 @@ operator != (const EggMorphList<MorphType> &other) const {
|
|||||||
template<class MorphType>
|
template<class MorphType>
|
||||||
INLINE bool EggMorphList<MorphType>::
|
INLINE bool EggMorphList<MorphType>::
|
||||||
operator < (const EggMorphList<MorphType> &other) const {
|
operator < (const EggMorphList<MorphType> &other) const {
|
||||||
return compare_to(other) < 0;
|
return (_morphs < other._morphs);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggMorphList::compare_to
|
// Function: EggMorphList::compare_to
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description:
|
// Description: compare_to() compares a different space than the
|
||||||
|
// operator methods, which only check the morph's name.
|
||||||
|
// compare_to() compares the name and the value as well.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
template<class MorphType>
|
template<class MorphType>
|
||||||
int EggMorphList<MorphType>::
|
int EggMorphList<MorphType>::
|
||||||
compare_to(const EggMorphList<MorphType> &other) const {
|
compare_to(const EggMorphList<MorphType> &other) const {
|
||||||
if (_morphs.size() < other._morphs.size()) {
|
if (_morphs.size() != other._morphs.size()) {
|
||||||
return (int)_morphs.size() - (int)other._morphs.size();
|
return (int)_morphs.size() - (int)other._morphs.size();
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < _morphs.size(); i++) {
|
for (size_t i = 0; i < _morphs.size(); i++) {
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "eggNameUniquifier.h"
|
#include "eggNameUniquifier.h"
|
||||||
#include "eggNode.h"
|
#include "eggNode.h"
|
||||||
#include "eggGroupNode.h"
|
#include "eggGroupNode.h"
|
||||||
|
#include "config_egg.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "eggGroupNode.h"
|
#include "eggGroupNode.h"
|
||||||
#include "config_egg.h"
|
#include "config_egg.h"
|
||||||
#include "eggTextureCollection.h"
|
#include "eggTextureCollection.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -309,6 +310,7 @@ update_under(int depth_offset) {
|
|||||||
_vertex_to_node = NULL;
|
_vertex_to_node = NULL;
|
||||||
_node_to_vertex = NULL;
|
_node_to_vertex = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
_parent->test_ref_count_integrity();
|
||||||
depth = _parent->_depth + 1;
|
depth = _parent->_depth + 1;
|
||||||
_under_flags = _parent->_under_flags;
|
_under_flags = _parent->_under_flags;
|
||||||
_vertex_frame = _parent->_vertex_frame;
|
_vertex_frame = _parent->_vertex_frame;
|
||||||
|
@ -16,149 +16,3 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::Constructor
|
|
||||||
// Access: Public
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE EggObject::
|
|
||||||
EggObject() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::Copy constructor
|
|
||||||
// Access: Public
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE EggObject::
|
|
||||||
EggObject(const EggObject ©) :
|
|
||||||
TypedReferenceCount(copy),
|
|
||||||
_user_data(copy._user_data),
|
|
||||||
_default_user_data(copy._default_user_data)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::Copy assignment operator
|
|
||||||
// Access: Public
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE EggObject &EggObject::
|
|
||||||
operator = (const EggObject ©) {
|
|
||||||
TypedReferenceCount::operator = (copy);
|
|
||||||
_user_data = copy._user_data;
|
|
||||||
_default_user_data = copy._default_user_data;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::set_user_data
|
|
||||||
// Access: Public
|
|
||||||
// Description: Sets the user data associated with this object. This
|
|
||||||
// may be any EggUserData-derived object. The egg
|
|
||||||
// library will do nothing with this pointer, except to
|
|
||||||
// hold its reference count and return the pointer on
|
|
||||||
// request.
|
|
||||||
//
|
|
||||||
// The EggObject maintains multiple different
|
|
||||||
// EggUserData pointers, one for each unique type (as
|
|
||||||
// reported by get_type()). If you know that only one
|
|
||||||
// type of EggUserData object will be added in your
|
|
||||||
// application, you may use the query functions that
|
|
||||||
// accept no parameters, but it is recommended that in
|
|
||||||
// general you pass in the type of your particular user
|
|
||||||
// data, to allow multiple applications to coexist in
|
|
||||||
// the same egg data.
|
|
||||||
//
|
|
||||||
// This pointer is also copied by the copy assignment
|
|
||||||
// operator and copy constructor.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void EggObject::
|
|
||||||
set_user_data(EggUserData *user_data) {
|
|
||||||
_user_data[user_data->get_type()] = user_data;
|
|
||||||
_default_user_data = user_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::get_user_data
|
|
||||||
// Access: Public
|
|
||||||
// Description: Returns the user data pointer most recently stored on
|
|
||||||
// this object, or NULL if nothing was previously
|
|
||||||
// stored.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE EggUserData *EggObject::
|
|
||||||
get_user_data() const {
|
|
||||||
return _default_user_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::get_user_data
|
|
||||||
// Access: Public
|
|
||||||
// Description: Returns the user data pointer of the indicated type,
|
|
||||||
// if it exists, or NULL if it does not.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE EggUserData *EggObject::
|
|
||||||
get_user_data(TypeHandle type) const {
|
|
||||||
UserData::const_iterator ui;
|
|
||||||
ui = _user_data.find(type);
|
|
||||||
if (ui != _user_data.end()) {
|
|
||||||
return (*ui).second;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::has_user_data
|
|
||||||
// Access: Public
|
|
||||||
// Description: Returns true if a generic user data pointer has
|
|
||||||
// recently been set and not yet cleared, false
|
|
||||||
// otherwise.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE bool EggObject::
|
|
||||||
has_user_data() const {
|
|
||||||
return !_default_user_data.is_null();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::has_user_data
|
|
||||||
// Access: Public
|
|
||||||
// Description: Returns true if the user data pointer of the
|
|
||||||
// indicated type has been set, false otherwise.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE bool EggObject::
|
|
||||||
has_user_data(TypeHandle type) const {
|
|
||||||
UserData::const_iterator ui;
|
|
||||||
ui = _user_data.find(type);
|
|
||||||
return (ui != _user_data.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::clear_user_data
|
|
||||||
// Access: Public
|
|
||||||
// Description: Removes *all* user data pointers from the node.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void EggObject::
|
|
||||||
clear_user_data() {
|
|
||||||
_user_data.clear();
|
|
||||||
_default_user_data.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: EggObject::clear_user_data
|
|
||||||
// Access: Public
|
|
||||||
// Description: Removes the user data pointer of the indicated type.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void EggObject::
|
|
||||||
clear_user_data(TypeHandle type) {
|
|
||||||
UserData::iterator ui;
|
|
||||||
ui = _user_data.find(type);
|
|
||||||
if (ui != _user_data.end()) {
|
|
||||||
if ((*ui).second == _default_user_data) {
|
|
||||||
_default_user_data.clear();
|
|
||||||
}
|
|
||||||
_user_data.erase(ui);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -21,11 +21,157 @@
|
|||||||
TypeHandle EggObject::_type_handle;
|
TypeHandle EggObject::_type_handle;
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::Constructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
EggObject::
|
||||||
|
EggObject() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::Copy constructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
EggObject::
|
||||||
|
EggObject(const EggObject ©) :
|
||||||
|
TypedReferenceCount(copy),
|
||||||
|
_user_data(copy._user_data),
|
||||||
|
_default_user_data(copy._default_user_data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::Copy assignment operator
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
EggObject &EggObject::
|
||||||
|
operator = (const EggObject ©) {
|
||||||
|
TypedReferenceCount::operator = (copy);
|
||||||
|
_user_data = copy._user_data;
|
||||||
|
_default_user_data = copy._default_user_data;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: EggObject::Destructor
|
// Function: EggObject::Destructor
|
||||||
// Access: Public, Virtual
|
// Access: Published, Virtual
|
||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
EggObject::
|
EggObject::
|
||||||
~EggObject() {
|
~EggObject() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::set_user_data
|
||||||
|
// Access: Published
|
||||||
|
// Description: Sets the user data associated with this object. This
|
||||||
|
// may be any EggUserData-derived object. The egg
|
||||||
|
// library will do nothing with this pointer, except to
|
||||||
|
// hold its reference count and return the pointer on
|
||||||
|
// request.
|
||||||
|
//
|
||||||
|
// The EggObject maintains multiple different
|
||||||
|
// EggUserData pointers, one for each unique type (as
|
||||||
|
// reported by get_type()). If you know that only one
|
||||||
|
// type of EggUserData object will be added in your
|
||||||
|
// application, you may use the query functions that
|
||||||
|
// accept no parameters, but it is recommended that in
|
||||||
|
// general you pass in the type of your particular user
|
||||||
|
// data, to allow multiple applications to coexist in
|
||||||
|
// the same egg data.
|
||||||
|
//
|
||||||
|
// This pointer is also copied by the copy assignment
|
||||||
|
// operator and copy constructor.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggObject::
|
||||||
|
set_user_data(EggUserData *user_data) {
|
||||||
|
_user_data[user_data->get_type()] = user_data;
|
||||||
|
_default_user_data = user_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::get_user_data
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the user data pointer most recently stored on
|
||||||
|
// this object, or NULL if nothing was previously
|
||||||
|
// stored.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
EggUserData *EggObject::
|
||||||
|
get_user_data() const {
|
||||||
|
return _default_user_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::get_user_data
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the user data pointer of the indicated type,
|
||||||
|
// if it exists, or NULL if it does not.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
EggUserData *EggObject::
|
||||||
|
get_user_data(TypeHandle type) const {
|
||||||
|
UserData::const_iterator ui;
|
||||||
|
ui = _user_data.find(type);
|
||||||
|
if (ui != _user_data.end()) {
|
||||||
|
return (*ui).second;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::has_user_data
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns true if a generic user data pointer has
|
||||||
|
// recently been set and not yet cleared, false
|
||||||
|
// otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool EggObject::
|
||||||
|
has_user_data() const {
|
||||||
|
return !_default_user_data.is_null();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::has_user_data
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns true if the user data pointer of the
|
||||||
|
// indicated type has been set, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool EggObject::
|
||||||
|
has_user_data(TypeHandle type) const {
|
||||||
|
UserData::const_iterator ui;
|
||||||
|
ui = _user_data.find(type);
|
||||||
|
return (ui != _user_data.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::clear_user_data
|
||||||
|
// Access: Published
|
||||||
|
// Description: Removes *all* user data pointers from the node.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggObject::
|
||||||
|
clear_user_data() {
|
||||||
|
_user_data.clear();
|
||||||
|
_default_user_data.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: EggObject::clear_user_data
|
||||||
|
// Access: Published
|
||||||
|
// Description: Removes the user data pointer of the indicated type.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void EggObject::
|
||||||
|
clear_user_data(TypeHandle type) {
|
||||||
|
UserData::iterator ui;
|
||||||
|
ui = _user_data.find(type);
|
||||||
|
if (ui != _user_data.end()) {
|
||||||
|
if ((*ui).second == _default_user_data) {
|
||||||
|
_default_user_data.clear();
|
||||||
|
}
|
||||||
|
_user_data.erase(ui);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -32,19 +32,19 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_PANDAEGG EggObject : public TypedReferenceCount {
|
class EXPCL_PANDAEGG EggObject : public TypedReferenceCount {
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
INLINE EggObject();
|
EggObject();
|
||||||
INLINE EggObject(const EggObject ©);
|
EggObject(const EggObject ©);
|
||||||
INLINE EggObject &operator = (const EggObject ©);
|
EggObject &operator = (const EggObject ©);
|
||||||
|
|
||||||
virtual ~EggObject();
|
virtual ~EggObject();
|
||||||
|
|
||||||
INLINE void set_user_data(EggUserData *user_data);
|
void set_user_data(EggUserData *user_data);
|
||||||
INLINE EggUserData *get_user_data() const;
|
EggUserData *get_user_data() const;
|
||||||
INLINE EggUserData *get_user_data(TypeHandle type) const;
|
EggUserData *get_user_data(TypeHandle type) const;
|
||||||
INLINE bool has_user_data() const;
|
bool has_user_data() const;
|
||||||
INLINE bool has_user_data(TypeHandle type) const;
|
bool has_user_data(TypeHandle type) const;
|
||||||
INLINE void clear_user_data();
|
void clear_user_data();
|
||||||
INLINE void clear_user_data(TypeHandle type);
|
void clear_user_data(TypeHandle type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef pmap<TypeHandle, PT(EggUserData) > UserData;
|
typedef pmap<TypeHandle, PT(EggUserData) > UserData;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "eggPrimitive.h"
|
#include "eggPrimitive.h"
|
||||||
#include "eggTexture.h"
|
#include "eggTexture.h"
|
||||||
#include "pt_EggTexture.h"
|
#include "pt_EggTexture.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
#include "nameUniquifier.h"
|
#include "nameUniquifier.h"
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "eggPrimitive.h"
|
#include "eggPrimitive.h"
|
||||||
#include "eggGroupNode.h"
|
#include "eggGroupNode.h"
|
||||||
#include "pt_EggTexture.h"
|
#include "pt_EggTexture.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "luse.h"
|
#include "luse.h"
|
||||||
#include "lmatrix.h"
|
#include "lmatrix.h"
|
||||||
#include "compose_matrix.h"
|
#include "compose_matrix.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
TypeHandle EggXfmAnimData::_type_handle;
|
TypeHandle EggXfmAnimData::_type_handle;
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "indent.h"
|
#include "indent.h"
|
||||||
#include "compose_matrix.h"
|
#include "compose_matrix.h"
|
||||||
|
#include "dcast.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -228,6 +228,7 @@ egg:
|
|||||||
empty
|
empty
|
||||||
| egg node
|
| egg node
|
||||||
{
|
{
|
||||||
|
assert(!egg_stack.empty());
|
||||||
DCAST(EggData, egg_stack.back())->add_child(DCAST(EggNode, $2));
|
DCAST(EggData, egg_stack.back())->add_child(DCAST(EggNode, $2));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -1713,7 +1714,6 @@ primitive_component_body:
|
|||||||
*/
|
*/
|
||||||
primitive_body:
|
primitive_body:
|
||||||
empty
|
empty
|
||||||
| primitive_body COMPONENT '{' primitive_component_body '}'
|
|
||||||
| primitive_body COMPONENT integer '{'
|
| primitive_body COMPONENT integer '{'
|
||||||
{
|
{
|
||||||
if (!egg_stack.back()->is_of_type(EggCompositePrimitive::get_class_type())) {
|
if (!egg_stack.back()->is_of_type(EggCompositePrimitive::get_class_type())) {
|
||||||
@ -1723,17 +1723,17 @@ primitive_body:
|
|||||||
if ($3 < 0 || $3 >= comp->get_num_components()) {
|
if ($3 < 0 || $3 >= comp->get_num_components()) {
|
||||||
eggyyerror("Invalid component number");
|
eggyyerror("Invalid component number");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// We temporarily add an EggPolygon to the stack, just to receive
|
// We temporarily add an EggPolygon to the stack, just to receive
|
||||||
// the component attributes.
|
// the component attributes.
|
||||||
egg_stack.push_back(new EggPolygon);
|
egg_stack.push_back(new EggPolygon);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
primitive_component_body '}'
|
primitive_component_body '}'
|
||||||
{
|
{
|
||||||
PT(EggPrimitive) prim = DCAST(EggPrimitive, egg_stack.back());
|
PT(EggPrimitive) prim = DCAST(EggPrimitive, egg_stack.back());
|
||||||
egg_stack.pop_back();
|
egg_stack.pop_back();
|
||||||
PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, egg_stack.back());
|
PT(EggCompositePrimitive) comp = DCAST(EggCompositePrimitive, egg_stack.back());
|
||||||
comp->set_component($3, prim);
|
comp->set_component((int)$3, prim);
|
||||||
}
|
}
|
||||||
| primitive_body TREF '{' primitive_tref_body '}'
|
| primitive_body TREF '{' primitive_tref_body '}'
|
||||||
| primitive_body TEXTURE '{' primitive_texture_body '}'
|
| primitive_body TEXTURE '{' primitive_texture_body '}'
|
||||||
|
@ -126,7 +126,8 @@ LODInstance(EggNode *egg_node) {
|
|||||||
EggLoader::
|
EggLoader::
|
||||||
EggLoader() {
|
EggLoader() {
|
||||||
// We need to enforce whatever coordinate system the user asked for.
|
// We need to enforce whatever coordinate system the user asked for.
|
||||||
_data.set_coordinate_system(egg_coordinate_system);
|
_data = new EggData;
|
||||||
|
_data->set_coordinate_system(egg_coordinate_system);
|
||||||
_error = false;
|
_error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ EggLoader() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
EggLoader::
|
EggLoader::
|
||||||
EggLoader(const EggData &data) :
|
EggLoader(const EggData &data) :
|
||||||
_data(data)
|
_data(new EggData(data))
|
||||||
{
|
{
|
||||||
_error = false;
|
_error = false;
|
||||||
}
|
}
|
||||||
@ -157,11 +158,11 @@ build_graph() {
|
|||||||
|
|
||||||
// Then bin up the polysets and LOD nodes.
|
// Then bin up the polysets and LOD nodes.
|
||||||
EggBinner binner(*this);
|
EggBinner binner(*this);
|
||||||
binner.make_bins(&_data);
|
binner.make_bins(_data);
|
||||||
|
|
||||||
// Now build up the scene graph.
|
// Now build up the scene graph.
|
||||||
_root = new ModelRoot(_data.get_egg_filename().get_basename());
|
_root = new ModelRoot(_data->get_egg_filename().get_basename());
|
||||||
make_node(&_data, _root);
|
make_node(_data, _root);
|
||||||
_builder.build();
|
_builder.build();
|
||||||
|
|
||||||
reparent_decals();
|
reparent_decals();
|
||||||
@ -735,7 +736,7 @@ void EggLoader::
|
|||||||
load_textures() {
|
load_textures() {
|
||||||
// First, collect all the textures that are referenced.
|
// First, collect all the textures that are referenced.
|
||||||
EggTextureCollection tc;
|
EggTextureCollection tc;
|
||||||
tc.find_used_textures(&_data);
|
tc.find_used_textures(_data);
|
||||||
|
|
||||||
EggTextureCollection::iterator ti;
|
EggTextureCollection::iterator ti;
|
||||||
for (ti = tc.begin(); ti != tc.end(); ++ti) {
|
for (ti = tc.begin(); ti != tc.end(); ++ti) {
|
||||||
|
@ -210,7 +210,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
PT(PandaNode) _root;
|
PT(PandaNode) _root;
|
||||||
EggData _data;
|
PT(EggData) _data;
|
||||||
bool _error;
|
bool _error;
|
||||||
|
|
||||||
friend class EggRenderState;
|
friend class EggRenderState;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
static PT(PandaNode)
|
static PT(PandaNode)
|
||||||
load_from_loader(EggLoader &loader) {
|
load_from_loader(EggLoader &loader) {
|
||||||
loader._data.load_externals();
|
loader._data->load_externals();
|
||||||
|
|
||||||
loader.build_graph();
|
loader.build_graph();
|
||||||
|
|
||||||
@ -85,9 +85,9 @@ load_egg_file(const string &filename, CoordinateSystem cs) {
|
|||||||
|
|
||||||
|
|
||||||
EggLoader loader;
|
EggLoader loader;
|
||||||
loader._data.set_egg_filename(egg_filename);
|
loader._data->set_egg_filename(egg_filename);
|
||||||
loader._data.set_auto_resolve_externals(true);
|
loader._data->set_auto_resolve_externals(true);
|
||||||
loader._data.set_coordinate_system(cs);
|
loader._data->set_coordinate_system(cs);
|
||||||
|
|
||||||
bool okflag;
|
bool okflag;
|
||||||
VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
|
VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
|
||||||
@ -97,7 +97,7 @@ load_egg_file(const string &filename, CoordinateSystem cs) {
|
|||||||
<< "Could not open " << egg_filename << " for reading.\n";
|
<< "Could not open " << egg_filename << " for reading.\n";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
okflag = loader._data.read(*istr);
|
okflag = loader._data->read(*istr);
|
||||||
vfs->close_read_file(istr);
|
vfs->close_read_file(istr);
|
||||||
|
|
||||||
if (!okflag) {
|
if (!okflag) {
|
||||||
@ -124,10 +124,10 @@ load_egg_data(EggData &data, CoordinateSystem cs) {
|
|||||||
children_holder.steal_children(data);
|
children_holder.steal_children(data);
|
||||||
|
|
||||||
EggLoader loader(data);
|
EggLoader loader(data);
|
||||||
loader._data.steal_children(children_holder);
|
loader._data->steal_children(children_holder);
|
||||||
|
|
||||||
loader._data.set_auto_resolve_externals(true);
|
loader._data->set_auto_resolve_externals(true);
|
||||||
loader._data.set_coordinate_system(cs);
|
loader._data->set_coordinate_system(cs);
|
||||||
|
|
||||||
return load_from_loader(loader);
|
return load_from_loader(loader);
|
||||||
}
|
}
|
||||||
|
@ -499,6 +499,7 @@ ns_update_type(ReferenceCount *ptr, TypeHandle type) {
|
|||||||
express_cat.error()
|
express_cat.error()
|
||||||
<< "Attempt to update type to " << type << " for unrecorded pointer "
|
<< "Attempt to update type to " << type << " for unrecorded pointer "
|
||||||
<< (void *)ptr << "!\n";
|
<< (void *)ptr << "!\n";
|
||||||
|
nassertv(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,9 +141,10 @@ close_primitive() {
|
|||||||
if (num_vertices_per_primitive == 0) {
|
if (num_vertices_per_primitive == 0) {
|
||||||
// This is a complex primitive type like a triangle strip: each
|
// This is a complex primitive type like a triangle strip: each
|
||||||
// primitive uses a different number of vertices.
|
// primitive uses a different number of vertices.
|
||||||
if (cdata->_lengths.empty() ||
|
if (cdata->_lengths.empty()) {
|
||||||
cdata->_lengths.back() != (int)cdata->_vertices.size()) {
|
|
||||||
cdata->_lengths.push_back((int)cdata->_vertices.size());
|
cdata->_lengths.push_back((int)cdata->_vertices.size());
|
||||||
|
} else if (cdata->_lengths.back() != (int)cdata->_vertices.size()) {
|
||||||
|
cdata->_lengths.push_back((int)cdata->_vertices.size() - cdata->_lengths.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -86,12 +86,17 @@ decompose_impl() {
|
|||||||
CPTA_ushort::const_iterator vi;
|
CPTA_ushort::const_iterator vi;
|
||||||
vi = vertices.begin();
|
vi = vertices.begin();
|
||||||
|
|
||||||
|
cerr << "starting vertices, size = " << vertices.size() << "\n";
|
||||||
|
|
||||||
CPTA_int::const_iterator li;
|
CPTA_int::const_iterator li;
|
||||||
for (li = lengths.begin(); li != lengths.end(); ++li) {
|
for (li = lengths.begin(); li != lengths.end(); ++li) {
|
||||||
int length = (*li);
|
int length = (*li);
|
||||||
|
cerr << "length = " << length << "\n";
|
||||||
nassertr(length >= 2, triangles.p());
|
nassertr(length >= 2, triangles.p());
|
||||||
|
nassertr(vi != vertices.end(), this);
|
||||||
int v0 = (*vi);
|
int v0 = (*vi);
|
||||||
++vi;
|
++vi;
|
||||||
|
nassertr(vi != vertices.end(), this);
|
||||||
int v1 = (*vi);
|
int v1 = (*vi);
|
||||||
++vi;
|
++vi;
|
||||||
bool reversed = false;
|
bool reversed = false;
|
||||||
@ -107,6 +112,7 @@ decompose_impl() {
|
|||||||
}
|
}
|
||||||
triangles->add_vertex(*vi);
|
triangles->add_vertex(*vi);
|
||||||
v0 = v1;
|
v0 = v1;
|
||||||
|
nassertr(vi != vertices.end(), this);
|
||||||
v1 = *vi;
|
v1 = *vi;
|
||||||
triangles->close_primitive();
|
triangles->close_primitive();
|
||||||
++vi;
|
++vi;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user