diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 0b65f80c21..e29085f428 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2596,11 +2596,11 @@ CopyAllHeaders('panda/src/downloader') CopyAllHeaders('panda/metalibs/pandaexpress') CopyAllHeaders('panda/src/pipeline') +CopyAllHeaders('panda/src/linmath') CopyAllHeaders('panda/src/putil') CopyAllHeaders('dtool/src/prckeys') CopyAllHeaders('panda/src/audio') CopyAllHeaders('panda/src/event') -CopyAllHeaders('panda/src/linmath') CopyAllHeaders('panda/src/mathutil') CopyAllHeaders('panda/src/gsgbase') CopyAllHeaders('panda/src/pnmimage') @@ -3036,6 +3036,25 @@ if (not RUNTIME): TargetAdd('libp3pipeline.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pipeline', 'SRCDIR:panda/src/pipeline']) TargetAdd('libp3pipeline_igate.obj', input='libp3pipeline.in', opts=["DEPENDENCYONLY"]) +# +# DIRECTORY: panda/src/linmath/ +# + +if (not RUNTIME): + OPTS=['DIR:panda/src/linmath', 'BUILDING:PANDA'] + TargetAdd('p3linmath_composite1.obj', opts=OPTS, input='p3linmath_composite1.cxx') + TargetAdd('p3linmath_composite2.obj', opts=OPTS, input='p3linmath_composite2.cxx') + IGATEFILES=GetDirectoryContents('panda/src/linmath', ["*.h", "*_composite*.cxx"]) + for ifile in IGATEFILES[:]: + if "_src." in ifile: + IGATEFILES.remove(ifile) + IGATEFILES.remove('cast_to_double.h') + IGATEFILES.remove('lmat_ops.h') + IGATEFILES.remove('cast_to_float.h') + TargetAdd('libp3linmath.in', opts=OPTS, input=IGATEFILES) + TargetAdd('libp3linmath.in', opts=['IMOD:panda3d.core', 'ILIB:libp3linmath', 'SRCDIR:panda/src/linmath']) + TargetAdd('libp3linmath_igate.obj', input='libp3linmath.in', opts=["DEPENDENCYONLY"]) + # # DIRECTORY: panda/src/putil/ # @@ -3076,25 +3095,6 @@ if (not RUNTIME): TargetAdd('libp3event.in', opts=['IMOD:panda3d.core', 'ILIB:libp3event', 'SRCDIR:panda/src/event']) TargetAdd('libp3event_igate.obj', input='libp3event.in', opts=["DEPENDENCYONLY"]) -# -# DIRECTORY: panda/src/linmath/ -# - -if (not RUNTIME): - OPTS=['DIR:panda/src/linmath', 'BUILDING:PANDA'] - TargetAdd('p3linmath_composite1.obj', opts=OPTS, input='p3linmath_composite1.cxx') - TargetAdd('p3linmath_composite2.obj', opts=OPTS, input='p3linmath_composite2.cxx') - IGATEFILES=GetDirectoryContents('panda/src/linmath', ["*.h", "*_composite*.cxx"]) - for ifile in IGATEFILES[:]: - if "_src." in ifile: - IGATEFILES.remove(ifile) - IGATEFILES.remove('cast_to_double.h') - IGATEFILES.remove('lmat_ops.h') - IGATEFILES.remove('cast_to_float.h') - TargetAdd('libp3linmath.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3linmath.in', opts=['IMOD:panda3d.core', 'ILIB:libp3linmath', 'SRCDIR:panda/src/linmath']) - TargetAdd('libp3linmath_igate.obj', input='libp3linmath.in', opts=["DEPENDENCYONLY"]) - # # DIRECTORY: panda/src/mathutil/ # diff --git a/panda/src/event/buttonEventList.h b/panda/src/event/buttonEventList.h index e470cb8230..ead1a5968c 100644 --- a/panda/src/event/buttonEventList.h +++ b/panda/src/event/buttonEventList.h @@ -34,7 +34,7 @@ class DatagramIterator; // but it may be used anywhere a list of ButtonEvents // is desired. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_EVENT ButtonEventList : public EventStoreValueBase { +class EXPCL_PANDA_EVENT ButtonEventList : public ParamValueBase { public: INLINE ButtonEventList(); INLINE ButtonEventList(const ButtonEventList ©); @@ -64,15 +64,15 @@ protected: public: void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { - EventStoreValueBase::init_type(); + ParamValueBase::init_type(); register_type(_type_handle, "ButtonEventList", - EventStoreValueBase::get_class_type()); + ParamValueBase::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); diff --git a/panda/src/event/config_event.cxx b/panda/src/event/config_event.cxx index 1b241f462d..1ceaf7572a 100644 --- a/panda/src/event/config_event.cxx +++ b/panda/src/event/config_event.cxx @@ -42,12 +42,8 @@ ConfigureFn(config_event) { PointerEventList::init_type(); Event::init_type(); EventHandler::init_type(); - EventStoreValueBase::init_type(); EventStoreInt::init_type("EventStoreInt"); EventStoreDouble::init_type("EventStoreDouble"); - EventStoreString::init_type("EventStoreString"); - EventStoreWstring::init_type("EventStoreWstring"); - EventStoreTypedRefCount::init_type(); GenericAsyncTask::init_type(); #ifdef HAVE_PYTHON PythonTask::init_type(); @@ -56,6 +52,4 @@ ConfigureFn(config_event) { ButtonEventList::register_with_read_factory(); EventStoreInt::register_with_read_factory(); EventStoreDouble::register_with_read_factory(); - EventStoreString::register_with_read_factory(); } - diff --git a/panda/src/event/eventParameter.I b/panda/src/event/eventParameter.I index d6e65cd95f..9f92511566 100644 --- a/panda/src/event/eventParameter.I +++ b/panda/src/event/eventParameter.I @@ -13,10 +13,6 @@ //////////////////////////////////////////////////////////////////// - -template -TypeHandle EventStoreValue::_type_handle; - //////////////////////////////////////////////////////////////////// // Function: EventParameter::Default constructor // Access: Published @@ -299,175 +295,3 @@ operator << (ostream &out, const EventParameter ¶m) { param.output(out); return out; } - - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValueBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE EventStoreValueBase:: -EventStoreValueBase() { -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreTypedRefCount::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -INLINE EventStoreTypedRefCount:: -EventStoreTypedRefCount(const TypedReferenceCount *value) : - _value((TypedReferenceCount *)value) -{ -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreTypedRefCount::set_value -// Access: Published -// Description: Changes the value stored in the parameter. It is -// dangerous to do this for a parameter already added to -// an event, since the parameters may be shared. -//////////////////////////////////////////////////////////////////// -INLINE void EventStoreTypedRefCount:: -set_value(const TypedReferenceCount *value) { - _value = (TypedReferenceCount *)value; -} - - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreTypedRefCount::get_value -// Access: Published -// Description: Retrieves the value stored in the parameter. -//////////////////////////////////////////////////////////////////// -INLINE TypedReferenceCount *EventStoreTypedRefCount:: -get_value() const { - return _value; -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::Default Constructor -// Access: Private -// Description: This constructor is only for make_from_bam(). -//////////////////////////////////////////////////////////////////// -template -EventStoreValue:: -EventStoreValue() { -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -template -EventStoreValue:: -EventStoreValue(const Type &value) : - _value(value) -{ -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -template -EventStoreValue:: -~EventStoreValue() { -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::set_value -// Access: Public -// Description: Changes the value stored in the parameter. It is -// dangerous to do this for a parameter already added to -// an event, since the parameters may be shared. -//////////////////////////////////////////////////////////////////// -template -INLINE void EventStoreValue:: -set_value(const Type &value) { - _value = value; -} - - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::get_value -// Access: Public -// Description: Retrieves the value stored in the parameter. -//////////////////////////////////////////////////////////////////// -template -INLINE const Type &EventStoreValue:: -get_value() const { - return _value; -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -template -void EventStoreValue:: -output(ostream &out) const { - out << _value; -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// -template -void EventStoreValue:: -register_with_read_factory() { - BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// -template -void EventStoreValue:: -write_datagram(BamWriter *manager, Datagram &dg) { - TypedWritable::write_datagram(manager, dg); - generic_write_datagram(dg, _value); -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// -template -TypedWritable *EventStoreValue:: -make_from_bam(const FactoryParams ¶ms) { - EventStoreValue *esv = new EventStoreValue; - DatagramIterator scan; - BamReader *manager; - - parse_params(params, scan, manager); - esv->fillin(scan, manager); - - return esv; -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValue::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Lens. -//////////////////////////////////////////////////////////////////// -template -void EventStoreValue:: -fillin(DatagramIterator &scan, BamReader *manager) { - TypedWritable::fillin(scan, manager); - generic_read_datagram(_value, scan); -} diff --git a/panda/src/event/eventParameter.cxx b/panda/src/event/eventParameter.cxx index 3663d37f74..76bef88f9b 100644 --- a/panda/src/event/eventParameter.cxx +++ b/panda/src/event/eventParameter.cxx @@ -20,21 +20,18 @@ #pragma implementation #endif -TypeHandle EventStoreValueBase::_type_handle; -TypeHandle EventStoreTypedRefCount::_type_handle; - //////////////////////////////////////////////////////////////////// // Function: EventParameter::output // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// void EventParameter:: output(ostream &out) const { if (_ptr == (TypedWritableReferenceCount *)NULL) { out << "(empty)"; - } else if (_ptr->is_of_type(EventStoreValueBase::get_class_type())) { - const EventStoreValueBase *sv_ptr; + } else if (_ptr->is_of_type(ParamValueBase::get_class_type())) { + const ParamValueBase *sv_ptr; DCAST_INTO_V(sv_ptr, _ptr); sv_ptr->output(out); @@ -42,36 +39,3 @@ output(ostream &out) const { out << _ptr->get_type(); } } - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreValueBase::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -EventStoreValueBase:: -~EventStoreValueBase() { -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreTypedRefCount::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -EventStoreTypedRefCount:: -~EventStoreTypedRefCount() { -} - -//////////////////////////////////////////////////////////////////// -// Function: EventStoreTypedRefCount::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -void EventStoreTypedRefCount:: -output(ostream &out) const { - if (_value == (TypedReferenceCount *)NULL) { - out << "(empty)"; - - } else { - out << _value->get_type(); - } -} diff --git a/panda/src/event/eventParameter.h b/panda/src/event/eventParameter.h index 4cdf1ddd8b..e44e5be9df 100644 --- a/panda/src/event/eventParameter.h +++ b/panda/src/event/eventParameter.h @@ -23,6 +23,7 @@ #include "pointerTo.h" #include "bamReader.h" #include "bamWriter.h" +#include "paramValue.h" //////////////////////////////////////////////////////////////////// // Class : EventParameter @@ -32,8 +33,7 @@ // object, which of course could be pretty much // anything. To store a simple value like a double or a // string, the EventParameter constructors transparently -// use the EventStoreValue template class, defined -// below. +// use the ParamValue template class from paramValue.h. //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_EVENT EventParameter { PUBLISHED: @@ -77,138 +77,15 @@ private: INLINE ostream &operator << (ostream &out, const EventParameter ¶m); -//////////////////////////////////////////////////////////////////// -// Class : EventStoreValueBase -// Description : A non-template base class of EventStoreValue (below), -// which serves mainly to define the placeholder for the -// virtual output function. -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_EVENT EventStoreValueBase : public TypedWritableReferenceCount { -public: - INLINE EventStoreValueBase(); +typedef ParamTypedRefCount EventStoreTypedRefCount; -PUBLISHED: - virtual ~EventStoreValueBase(); - virtual void output(ostream &out) const=0; +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, ParamValue); -public: - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - TypedWritableReferenceCount::init_type(); - register_type(_type_handle, "EventStoreValueBase", - TypedWritableReferenceCount::get_class_type()); - } - -private: - static TypeHandle _type_handle; -}; - -//////////////////////////////////////////////////////////////////// -// Class : EventStoreTypedRefCount -// Description : A class object for storing specifically objects of -// type TypedReferenceCount, which is different than -// TypedWritableReferenceCount. -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_EVENT EventStoreTypedRefCount : public EventStoreValueBase { -PUBLISHED: - INLINE EventStoreTypedRefCount(const TypedReferenceCount *value); - virtual ~EventStoreTypedRefCount(); - - INLINE void set_value(const TypedReferenceCount *value); - INLINE TypedReferenceCount *get_value() const; - - virtual void output(ostream &out) const; - -public: - PT(TypedReferenceCount) _value; - -public: - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - EventStoreValueBase::init_type(); - register_type(_type_handle, "EventStoreTypedRefCount", - EventStoreValueBase::get_class_type()); - } - -private: - static TypeHandle _type_handle; -}; - -//////////////////////////////////////////////////////////////////// -// Class : EventStoreValue -// Description : A handy class object for storing simple values (like -// integers or strings) passed along with an Event. -// This is essentially just a wrapper around whatever -// data type you like, to make it a -// TypedWritableReferenceCount object which can be -// passed along inside an EventParameter. -//////////////////////////////////////////////////////////////////// -template -class EventStoreValue : public EventStoreValueBase { -private: - INLINE EventStoreValue(); -public: - INLINE EventStoreValue(const Type &value); - virtual ~EventStoreValue(); - - INLINE void set_value(const Type &value); - INLINE const Type &get_value() const; - - virtual void output(ostream &out) const; - - Type _value; - -public: - static void register_with_read_factory(); - virtual void write_datagram(BamWriter *manager, Datagram &dg); - -protected: - static TypedWritable *make_from_bam(const FactoryParams ¶ms); - void fillin(DatagramIterator &scan, BamReader *manager); - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type(const string &type_name = "UndefinedEventStoreValue") { - EventStoreValueBase::init_type(); - _type_handle = register_dynamic_type - (type_name, EventStoreValueBase::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() { - // In this case, we can't do anything, since we don't have the - // class' type_name. - return get_class_type(); - } - -private: - static TypeHandle _type_handle; -}; - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, EventStoreValue); - -typedef EventStoreValue EventStoreInt; -typedef EventStoreValue EventStoreDouble; -typedef EventStoreValue EventStoreString; -typedef EventStoreValue EventStoreWstring; +typedef ParamValue EventStoreInt; +typedef ParamValue EventStoreDouble; +typedef ParamString EventStoreString; +typedef ParamWstring EventStoreWstring; #include "eventParameter.I" @@ -218,4 +95,3 @@ typedef EventStoreValue EventStoreWstring; #endif #endif - diff --git a/panda/src/event/pointerEventList.h b/panda/src/event/pointerEventList.h index 7c84462f40..dd0c6a765e 100644 --- a/panda/src/event/pointerEventList.h +++ b/panda/src/event/pointerEventList.h @@ -34,7 +34,7 @@ class DatagramIterator; // but it may be used anywhere a list of PointerEvents // is desired. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_EVENT PointerEventList : public EventStoreValueBase { +class EXPCL_PANDA_EVENT PointerEventList : public ParamValueBase { PUBLISHED: INLINE PointerEventList(); @@ -53,16 +53,15 @@ PUBLISHED: INLINE void clear(); INLINE void pop_front(); void add_event(bool in_win, int xpos, int ypos, int seq, double time); - + bool encircles(int x, int y) const; double total_turns(double sec) const; double match_pattern(const string &pattern, double rot, double seglen); - + public: INLINE PointerEventList(const PointerEventList ©); INLINE void operator = (const PointerEventList ©); - virtual void output(ostream &out) const; void write(ostream &out, int indent_level = 0) const; @@ -76,9 +75,9 @@ public: return _type_handle; } static void init_type() { - EventStoreValueBase::init_type(); + ParamValueBase::init_type(); register_type(_type_handle, "PointerEventList", - EventStoreValueBase::get_class_type()); + ParamValueBase::get_class_type()); } virtual TypeHandle get_type() const { return get_class_type(); diff --git a/panda/src/mathutil/config_mathutil.cxx b/panda/src/mathutil/config_mathutil.cxx index 7b912f13d3..598c83b112 100644 --- a/panda/src/mathutil/config_mathutil.cxx +++ b/panda/src/mathutil/config_mathutil.cxx @@ -24,7 +24,6 @@ #include "boundingPlane.h" #include "unionBoundingVolume.h" #include "intersectionBoundingVolume.h" -#include "linmath_events.h" #include "dconfig.h" #include "pandaSystem.h" @@ -80,17 +79,9 @@ init_libmathutil() { IntersectionBoundingVolume::init_type(); BoundingLine::init_type(); BoundingPlane::init_type(); - EventStoreVec2::init_type("EventStoreVec2"); - EventStoreVec3::init_type("EventStoreVec3"); - EventStoreMat4::init_type("EventStoreMat4"); - - EventStoreVec2::register_with_read_factory(); - EventStoreVec3::register_with_read_factory(); - EventStoreMat4::register_with_read_factory(); #ifdef HAVE_FFTW PandaSystem *ps = PandaSystem::get_global_ptr(); ps->add_system("fftw"); #endif // FFTW } - diff --git a/panda/src/mathutil/linmath_events.h b/panda/src/mathutil/linmath_events.h index 2e24b302ea..fbb38dfa46 100644 --- a/panda/src/mathutil/linmath_events.h +++ b/panda/src/mathutil/linmath_events.h @@ -17,29 +17,22 @@ #include "pandabase.h" -#include "eventParameter.h" +#include "paramValue.h" #include "luse.h" //////////////////////////////////////////////////////////////////// // // This file defines a few more EventStore classes for storing linmath -// objects in an EventParameter. We can't define this with the other -// EventStore classes, because linmath hasn't been defined yet at that -// point. +// objects in an EventParameter. These are just for backward +// compatibility; they are defined as typedefs to ParamVecBase types. // -// See eventParameter.h. +// See paramValue.h. // //////////////////////////////////////////////////////////////////// - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, EventStoreValue); - -typedef EventStoreValue EventStoreVec2; -typedef EventStoreValue EventStoreVec3; -typedef EventStoreValue EventStoreMat4; - +typedef ParamVecBase2 EventStoreVec2; +typedef ParamVecBase3 EventStoreVec3; +typedef ParamMatrix4 EventStoreMat4; // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ diff --git a/panda/src/pgraph/eventStorePandaNode.h b/panda/src/pgraph/eventStorePandaNode.h index 9495e294d7..b71636c79c 100644 --- a/panda/src/pgraph/eventStorePandaNode.h +++ b/panda/src/pgraph/eventStorePandaNode.h @@ -24,7 +24,7 @@ // Description : A class object for storing specifically objects of // type PandaNode. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_PGRAPH EventStorePandaNode : public EventStoreValueBase { +class EXPCL_PANDA_PGRAPH EventStorePandaNode : public ParamValueBase { PUBLISHED: INLINE EventStorePandaNode(const PandaNode *value); virtual ~EventStorePandaNode(); @@ -46,9 +46,9 @@ public: return _type_handle; } static void init_type() { - EventStoreValueBase::init_type(); + ParamValueBase::init_type(); register_type(_type_handle, "EventStorePandaNode", - EventStoreValueBase::get_class_type()); + ParamValueBase::get_class_type()); } private: diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index 7e98890b70..e36adb2670 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -1,6 +1,6 @@ #define OTHER_LIBS p3interrogatedb:c p3dconfig:c p3dtoolconfig:m \ p3dtoolutil:c p3dtoolbase:c p3dtool:m p3prc:c -#define LOCAL_LIBS p3pipeline p3express p3pandabase +#define LOCAL_LIBS p3pipeline p3linmath p3express p3pandabase #define USE_PACKAGES zlib #begin lib_target @@ -57,6 +57,7 @@ modifierButtons.I modifierButtons.h mouseButton.h \ mouseData.I mouseData.h nameUniquifier.I nameUniquifier.h \ nodeCachedReferenceCount.h nodeCachedReferenceCount.I \ + paramValue.I paramValue.h \ pbitops.I pbitops.h \ portalMask.h \ pta_ushort.h \ @@ -107,6 +108,7 @@ modifierButtons.cxx mouseButton.cxx mouseData.cxx \ nameUniquifier.cxx \ nodeCachedReferenceCount.cxx \ + paramValue.cxx \ pbitops.cxx \ pta_ushort.cxx \ pythonCallbackObject.cxx \ @@ -167,8 +169,9 @@ modifierButtons.h mouseButton.h mouseData.I mouseData.h \ nameUniquifier.I nameUniquifier.h \ nodeCachedReferenceCount.h nodeCachedReferenceCount.I \ - portalMask.h \ + paramValue.I paramValue.h \ pbitops.I pbitops.h \ + portalMask.h \ pta_ushort.h \ pythonCallbackObject.h pythonCallbackObject.I \ simpleHashMap.I simpleHashMap.h \ diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_util.cxx index a8c68a6f42..a6ef2bcb70 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_util.cxx @@ -34,6 +34,7 @@ #include "factoryParam.h" #include "namable.h" #include "nodeCachedReferenceCount.h" +#include "paramValue.h" #include "pythonCallbackObject.h" #include "referenceCount.h" #include "sparseArray.h" @@ -62,7 +63,7 @@ ConfigVariableEnum bam_endian "particular platform.")); ConfigVariableBool bam_stdfloat_double -("bam-stdfloat-double", +("bam-stdfloat-double", #ifdef STDFLOAT_DOUBLE true, #else @@ -70,7 +71,7 @@ ConfigVariableBool bam_stdfloat_double #endif PRC_DESC("The default width of floating-point numbers to write to a bam " "file. Set this true to force doubles (64-bit floats), or false " - "to force sinles (32-bit floats). The default is whichever width " + "to force singles (32-bit floats). The default is whichever width " "Panda has been compiled to use natively. Normally, this setting " "should not be changed from the default.")); @@ -79,8 +80,6 @@ ConfigVariableEnum bam_texture_mode PRC_DESC("Set this to specify how textures should be written into Bam files." "See the panda source or documentation for available options.")); - - ConfigureFn(config_util) { init_libputil(); } @@ -200,6 +199,23 @@ init_libputil() { FactoryParam::init_type(); Namable::init_type(); NodeCachedReferenceCount::init_type(); + ParamMatrix3d::init_type("ParamMatrix3d"); + ParamMatrix3f::init_type("ParamMatrix3f"); + ParamMatrix4d::init_type("ParamMatrix4d"); + ParamMatrix4f::init_type("ParamMatrix4f"); + ParamString::init_type("ParamString"); + ParamTypedRefCount::init_type(); + ParamValueBase::init_type(); + ParamVecBase2d::init_type("ParamVecBase2d"); + ParamVecBase2f::init_type("ParamVecBase2f"); + ParamVecBase2i::init_type("ParamVecBase2i"); + ParamVecBase3d::init_type("ParamVecBase3d"); + ParamVecBase3f::init_type("ParamVecBase3f"); + ParamVecBase3i::init_type("ParamVecBase3i"); + ParamVecBase4f::init_type("ParamVecBase4f"); + ParamVecBase4d::init_type("ParamVecBase4d"); + ParamVecBase4i::init_type("ParamVecBase4i"); + ParamWstring::init_type("ParamWstring"); #ifdef HAVE_PYTHON PythonCallbackObject::init_type(); #endif @@ -218,4 +234,19 @@ init_libputil() { BamCacheIndex::register_with_read_factory(); BamCacheRecord::register_with_read_factory(); + ParamMatrix3d::register_with_read_factory(); + ParamMatrix3f::register_with_read_factory(); + ParamMatrix4d::register_with_read_factory(); + ParamMatrix4f::register_with_read_factory(); + ParamString::register_with_read_factory(); + ParamVecBase2d::register_with_read_factory(); + ParamVecBase2f::register_with_read_factory(); + ParamVecBase2i::register_with_read_factory(); + ParamVecBase3d::register_with_read_factory(); + ParamVecBase3f::register_with_read_factory(); + ParamVecBase3i::register_with_read_factory(); + ParamVecBase4d::register_with_read_factory(); + ParamVecBase4f::register_with_read_factory(); + ParamVecBase4i::register_with_read_factory(); + ParamWstring::register_with_read_factory(); } diff --git a/panda/src/putil/p3putil_composite2.cxx b/panda/src/putil/p3putil_composite2.cxx index 9cae69467c..bb0b5fea5a 100644 --- a/panda/src/putil/p3putil_composite2.cxx +++ b/panda/src/putil/p3putil_composite2.cxx @@ -12,6 +12,7 @@ #include "mouseData.cxx" #include "nameUniquifier.cxx" #include "nodeCachedReferenceCount.cxx" +#include "paramValue.cxx" #include "pbitops.cxx" #include "pta_ushort.cxx" #include "pythonCallbackObject.cxx" diff --git a/panda/src/putil/paramValue.I b/panda/src/putil/paramValue.I new file mode 100644 index 0000000000..30846fe300 --- /dev/null +++ b/panda/src/putil/paramValue.I @@ -0,0 +1,209 @@ +// Filename: paramValue.I +// Created by: drose (08Feb99) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +template +TypeHandle ParamValue::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: ParamValueBase::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ParamValueBase:: +ParamValueBase() { +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValueBase::get_value_type +// Access: Published, Virtual +// Description: Returns the type of the underlying value. +//////////////////////////////////////////////////////////////////// +INLINE TypeHandle ParamValueBase:: +get_value_type() const { + return TypeHandle::none(); +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamTypedRefCount::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ParamTypedRefCount:: +ParamTypedRefCount(const TypedReferenceCount *value) : + _value((TypedReferenceCount *)value) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamTypedRefCount::get_value_type +// Access: Published +// Description: Retrieves the type of the value stored in the +// parameter. +//////////////////////////////////////////////////////////////////// +INLINE TypeHandle ParamTypedRefCount:: +get_value_type() const { + if (_value == NULL) { + return TypeHandle::none(); + } else { + return _value->get_type(); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamTypedRefCount::get_value +// Access: Published +// Description: Retrieves the value stored in the parameter. +//////////////////////////////////////////////////////////////////// +INLINE TypedReferenceCount *ParamTypedRefCount:: +get_value() const { + return _value; +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::Constructor +// Access: Protected +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE ParamValue:: +ParamValue() {} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE ParamValue:: +ParamValue(const Type &value) : + _value(value) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::Destructor +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE ParamValue:: +~ParamValue() { +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::get_value_type +// Access: Public, Virtual +// Description: Retrieves the type of the value stored in the +// parameter. +//////////////////////////////////////////////////////////////////// +template +INLINE TypeHandle ParamValue:: +get_value_type() const { + return get_type_handle(Type); +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::set_value +// Access: Public, Virtual +// Description: Changes the value stored in the parameter. +//////////////////////////////////////////////////////////////////// +template +INLINE void ParamValue:: +set_value(const Type &type) { + _value = type; + mark_bam_modified(); +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::get_value +// Access: Public +// Description: Retrieves the value stored in the parameter. +//////////////////////////////////////////////////////////////////// +template +INLINE const Type &ParamValue:: +get_value() const { + return _value; +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::output +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE void ParamValue:: +output(ostream &out) const { + out << _value; +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::register_with_read_factory +// Access: Public, Static +// Description: Tells the BamReader how to create objects of type +// ParamValue. +//////////////////////////////////////////////////////////////////// +template +INLINE void ParamValue:: +register_with_read_factory() { + BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::write_datagram +// Access: Public, Virtual +// Description: Writes the contents of this object to the datagram +// for shipping out to a Bam file. +//////////////////////////////////////////////////////////////////// +template +INLINE void ParamValue:: +write_datagram(BamWriter *manager, Datagram &dg) { + TypedWritable::write_datagram(manager, dg); + generic_write_datagram(dg, _value); +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::make_from_bam +// Access: Protected, Static +// Description: This function is called by the BamReader's factory +// when a new object of type ParamValue is encountered +// in the Bam file. It should create the ParamValue +// and extract its information from the file. +//////////////////////////////////////////////////////////////////// +template +INLINE TypedWritable *ParamValue:: +make_from_bam(const FactoryParams ¶ms) { + ParamValue *esv = new ParamValue; + DatagramIterator scan; + BamReader *manager; + + parse_params(params, scan, manager); + esv->fillin(scan, manager); + + return esv; +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamValue::fillin +// Access: Protected +// Description: This internal function is called by make_from_bam to +// read in all of the relevant data from the BamFile for +// the new ParamValue. +//////////////////////////////////////////////////////////////////// +template +INLINE void ParamValue:: +fillin(DatagramIterator &scan, BamReader *manager) { + TypedWritable::fillin(scan, manager); + generic_read_datagram(_value, scan); +} diff --git a/panda/src/putil/paramValue.cxx b/panda/src/putil/paramValue.cxx new file mode 100644 index 0000000000..c8482dc409 --- /dev/null +++ b/panda/src/putil/paramValue.cxx @@ -0,0 +1,57 @@ +// Filename: paramValue.cxx +// Created by: drose (08Feb99) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "paramValue.h" +#include "dcast.h" + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma implementation +#endif + +TypeHandle ParamValueBase::_type_handle; +TypeHandle ParamTypedRefCount::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: ParamValueBase::Destructor +// Access: Published, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +ParamValueBase:: +~ParamValueBase() { +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamTypedRefCount::Destructor +// Access: Published, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +ParamTypedRefCount:: +~ParamTypedRefCount() { +} + +//////////////////////////////////////////////////////////////////// +// Function: ParamTypedRefCount::output +// Access: Published, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void ParamTypedRefCount:: +output(ostream &out) const { + if (_value == (TypedReferenceCount *)NULL) { + out << "(empty)"; + + } else { + out << _value->get_type(); + } +} diff --git a/panda/src/putil/paramValue.h b/panda/src/putil/paramValue.h new file mode 100644 index 0000000000..694c34529d --- /dev/null +++ b/panda/src/putil/paramValue.h @@ -0,0 +1,221 @@ +// Filename: paramValue.h +// Created by: drose (08Feb99) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef PARAMVALUE_H +#define PARAMVALUE_H + +#include "pandabase.h" + +#include "typedef.h" +#include "typedObject.h" +#include "typedWritableReferenceCount.h" +#include "pointerTo.h" +#include "bamReader.h" +#include "bamWriter.h" +#include "luse.h" + +//////////////////////////////////////////////////////////////////// +// Class : ParamValueBase +// Description : A non-template base class of ParamValue (below), +// which serves mainly to define the placeholder for the +// virtual output function. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA_PUTIL ParamValueBase : public TypedWritableReferenceCount { +public: + INLINE ParamValueBase(); + +PUBLISHED: + virtual ~ParamValueBase(); + INLINE virtual TypeHandle get_value_type() const; + virtual void output(ostream &out) const=0; + +public: + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + TypedWritableReferenceCount::init_type(); + register_type(_type_handle, "ParamValueBase", + TypedWritableReferenceCount::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +//////////////////////////////////////////////////////////////////// +// Class : ParamTypedRefCount +// Description : A class object for storing specifically objects of +// type TypedReferenceCount, which is different than +// TypedWritableReferenceCount. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA_PUTIL ParamTypedRefCount : public ParamValueBase { +PUBLISHED: + INLINE ParamTypedRefCount(const TypedReferenceCount *value); + virtual ~ParamTypedRefCount(); + + INLINE virtual TypeHandle get_value_type() const; + INLINE TypedReferenceCount *get_value() const; + + virtual void output(ostream &out) const; + +private: + PT(TypedReferenceCount) _value; + +public: + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + ParamValueBase::init_type(); + register_type(_type_handle, "ParamTypedRefCount", + ParamValueBase::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +//////////////////////////////////////////////////////////////////// +// Class : ParamValue +// Description : A handy class object for storing simple values (like +// integers or strings) passed along with an Event +// or to be used as a shader input. +// This is essentially just a wrapper around whatever +// data type you like, to make it a +// TypedWritableReferenceCount object which can be +// passed along inside an EventParameter or ShaderInput. +//////////////////////////////////////////////////////////////////// +template +class ParamValue : public ParamValueBase { +protected: + INLINE ParamValue(); + +PUBLISHED: + INLINE ParamValue(const Type &value); + INLINE virtual ~ParamValue(); + + INLINE virtual TypeHandle get_value_type() const; + INLINE void set_value(const Type &value); + INLINE const Type &get_value() const; + + INLINE virtual void output(ostream &out) const; + +private: + Type _value; + +public: + INLINE static void register_with_read_factory(); + INLINE virtual void write_datagram(BamWriter *manager, Datagram &dg); + +protected: + INLINE static TypedWritable *make_from_bam(const FactoryParams ¶ms); + INLINE void fillin(DatagramIterator &scan, BamReader *manager); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type(const string &type_name = "UndefinedParamValue") { + ParamValueBase::init_type(); + _type_handle = register_dynamic_type + (type_name, ParamValueBase::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() { + // In this case, we can't do anything, since we don't have the + // class' type_name. + return get_class_type(); + } + +private: + static TypeHandle _type_handle; +}; + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); + +typedef ParamValue ParamString; +typedef ParamValue ParamWstring; + +typedef ParamValue ParamVecBase2d; +typedef ParamValue ParamVecBase2f; +typedef ParamValue ParamVecBase2i; + +typedef ParamValue ParamVecBase3d; +typedef ParamValue ParamVecBase3f; +typedef ParamValue ParamVecBase3i; + +typedef ParamValue ParamVecBase4d; +typedef ParamValue ParamVecBase4f; +typedef ParamValue ParamVecBase4i; + +typedef ParamValue ParamMatrix3d; +typedef ParamValue ParamMatrix3f; + +typedef ParamValue ParamMatrix4d; +typedef ParamValue ParamMatrix4f; + +#ifdef STDFLOAT_DOUBLE +typedef ParamVecBase2d ParamVecBase2; +typedef ParamVecBase3d ParamVecBase3; +typedef ParamVecBase4d ParamVecBase4; + +typedef ParamMatrix3d ParamMatrix3; +typedef ParamMatrix4d ParamMatrix4; +#else +typedef ParamVecBase2f ParamVecBase2; +typedef ParamVecBase3f ParamVecBase3; +typedef ParamVecBase4f ParamVecBase4; + +typedef ParamMatrix3f ParamMatrix3; +typedef ParamMatrix4f ParamMatrix4; +#endif + +#include "paramValue.I" + +// Tell GCC that we'll take care of the instantiation explicitly here. +#ifdef __GNUC__ +#pragma interface +#endif + +#endif