diff --git a/.travis.yml b/.travis.yml index 26088946eb..92732bb929 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,12 @@ compiler: - clang before_script: - sudo apt-get install python-dev libpng-dev zlib1g-dev libssl-dev libx11-dev libgl1-mesa-dev libxrandr-dev libxxf86dga-dev libxcursor-dev bison flex libfreetype6-dev libvorbis-dev libjpeg-dev libopenal-dev libode-dev nvidia-cg-toolkit -script: python makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT +script: python makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT --installer notifications: irc: channels: - "chat.freenode.net#panda3d" on_success: change - on_failure: change + on_failure: always use_notice: true skip_join: true diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index 9be83fda34..c0e711ecc6 100755 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -20,6 +20,10 @@ #include "dcSwitchParameter.h" #include "dcClass.h" +#ifdef HAVE_PYTHON +#include "py_panda.h" +#endif + DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = NULL; int DCPacker::StackElement::_num_ever_allocated = 0; diff --git a/direct/src/dcparser/dcPacker.h b/direct/src/dcparser/dcPacker.h index 0c7cfb58ab..bbbcb3e2d3 100755 --- a/direct/src/dcparser/dcPacker.h +++ b/direct/src/dcparser/dcPacker.h @@ -220,7 +220,7 @@ private: const DCPackerCatalog *_catalog; const DCPackerCatalog::LiveCatalog *_live_catalog; - class StackElement { + class EXPCL_DIRECT StackElement { public: // As an optimization, we implement operator new and delete here // to minimize allocation overhead during push() and pop(). diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index 240af9be5c..e39a59f13e 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -26,11 +26,7 @@ #include "pStatTimer.h" #ifdef HAVE_PYTHON -#ifndef CPPPARSER -#include "py_panda.h" -IMPORT_THIS struct Dtool_PyTypedObject Dtool_DatagramIterator; -IMPORT_THIS struct Dtool_PyTypedObject Dtool_DCClass; -#endif +#include "py_panda.h" #endif const string CConnectionRepository::_overflow_event_name = "CRDatagramOverflow"; @@ -42,14 +38,13 @@ PStatCollector CConnectionRepository::_update_pcollector("App:Show code:readerPo //////////////////////////////////////////////////////////////////// // Function: CConnectionRepository::Constructor // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// CConnectionRepository:: CConnectionRepository(bool has_owner_view, bool threaded_net) : _lock("CConnectionRepository::_lock"), #ifdef HAVE_PYTHON _python_repository(NULL), - _python_ai_datagramiterator(NULL), #endif #ifdef HAVE_OPENSSL _http_conn(NULL), @@ -82,19 +77,12 @@ CConnectionRepository(bool has_owner_view, bool threaded_net) : } #endif _tcp_header_size = tcp_header_size; - -#ifdef HAVE_PYTHON - PyObject * PyDitterator = DTool_CreatePyInstance(&_di,Dtool_DatagramIterator,false,false); - if(PyDitterator != NULL) - _python_ai_datagramiterator = Py_BuildValue("(O)",PyDitterator); -#endif - } //////////////////////////////////////////////////////////////////// // Function: CConnectionRepository::Destructor // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// CConnectionRepository:: ~CConnectionRepository() { @@ -182,7 +170,7 @@ try_connect_net(const URLSpec &url) { disconnect(); - _net_conn = + _net_conn = _qcm.open_TCP_client_connection(url.get_server(), url.get_port(), game_server_timeout_ms); @@ -315,7 +303,7 @@ check_datagram() { _msg_channels.push_back(schan); } _msg_sender = _di.get_uint64(); - + #ifdef HAVE_PYTHON // For now, we need to stuff this field onto the Python // structure, to support legacy code that expects to find it @@ -361,7 +349,7 @@ check_datagram() { } break; #endif // HAVE_PYTHON - + default: // Some unknown message; let the caller deal with it. return true; @@ -372,9 +360,6 @@ check_datagram() { return false; } - - - //////////////////////////////////////////////////////////////////// // Function: CConnectionRepository::is_connected // Access: Published @@ -745,7 +730,7 @@ handle_update_field() { PStatTimer timer(_update_pcollector); unsigned int do_id = _di.get_uint32(); - if (_python_repository != (PyObject *)NULL) + if (_python_repository != (PyObject *)NULL) { PyObject *doId2do = PyObject_GetAttrString(_python_repository, "doId2do"); @@ -794,9 +779,9 @@ handle_update_field() { // method might get into trouble if it tried to delete the // object from the doId2do map. Py_INCREF(distobj); - dclass->receive_update(distobj, _di); + dclass->receive_update(distobj, _di); Py_DECREF(distobj); - + if (PyErr_Occurred()) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_Release(gstate); @@ -810,7 +795,7 @@ handle_update_field() { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_Release(gstate); #endif - #endif // HAVE_PYTHON + #endif // HAVE_PYTHON return true; } @@ -880,9 +865,9 @@ handle_update_field_owner() { // make a copy of the datagram iterator so that we can use the main // iterator for the non-owner update DatagramIterator _odi(_di); - dclass->receive_update(distobjOV, _odi); + dclass->receive_update(distobjOV, _odi); Py_DECREF(distobjOV); - + if (PyErr_Occurred()) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_Release(gstate); @@ -919,9 +904,9 @@ handle_update_field_owner() { // method might get into trouble if it tried to delete the // object from the doId2do map. Py_INCREF(distobj); - dclass->receive_update(distobj, _di); + dclass->receive_update(distobj, _di); Py_DECREF(distobj); - + if (PyErr_Occurred()) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_Release(gstate); @@ -935,7 +920,7 @@ handle_update_field_owner() { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_Release(gstate); #endif -#endif // HAVE_PYTHON +#endif // HAVE_PYTHON return true; } @@ -948,17 +933,17 @@ handle_update_field_owner() { // output stream. //////////////////////////////////////////////////////////////////// void CConnectionRepository:: -describe_message(ostream &out, const string &prefix, +describe_message(ostream &out, const string &prefix, const Datagram &dg) const { DCPacker packer; - + packer.set_unpack_data(dg.get_message()); CHANNEL_TYPE do_id; int msg_type; bool is_update = false; string full_prefix = "CR::" + prefix; - if (!_client_datagram) + if (!_client_datagram) { unsigned char mcnt = packer.raw_unpack_uint8(); for( ;mcnt > 0; mcnt--) @@ -967,7 +952,7 @@ describe_message(ostream &out, const string &prefix, packer.RAW_UNPACK_CHANNEL(); // msg_sender msg_type = packer.raw_unpack_uint16(); is_update = (msg_type == STATESERVER_OBJECT_UPDATE_FIELD); - + } else { msg_type = packer.raw_unpack_uint16(); is_update = (msg_type == CLIENT_OBJECT_UPDATE_FIELD); @@ -1045,12 +1030,12 @@ describe_message(ostream &out, const string &prefix, Py_DECREF(dclass_this); } } - #endif // HAVE_PYTHON + #endif // HAVE_PYTHON int field_id = packer.raw_unpack_uint16(); if (dclass == (DCClass *)NULL) { - out << full_prefix << "update for unknown object " << do_id + out << full_prefix << "update for unknown object " << do_id << ", field " << field_id << "\n"; } else { @@ -1059,7 +1044,7 @@ describe_message(ostream &out, const string &prefix, DCField *field = dclass->get_field_by_index(field_id); if (field == (DCField *)NULL) { out << "unknown field " << field_id << "\n"; - + } else { out << field->get_name(); packer.begin_unpack(field); @@ -1070,148 +1055,3 @@ describe_message(ostream &out, const string &prefix, } } } - - - - -#ifdef HAVE_PYTHON -#ifdef WANT_NATIVE_NET - -bool CConnectionRepository::network_based_reader_and_yielder(PyObject *PycallBackFunction,ClockObject &clock, float returnBy) -{ - ReMutexHolder holder(_lock); - while(is_connected()) - { - check_datagram_ai(PycallBackFunction); - if(is_connected()) - _bdc.Flush(); - float currentTime = clock.get_real_time(); - float dif_time = returnBy - currentTime; - if(dif_time <= 0.001) // to avoi over runs.. - break; - if(is_connected()) - _bdc.WaitForNetworkReadEvent(dif_time); - } - return false; -} - -bool CConnectionRepository::check_datagram_ai(PyObject *PycallBackFunction) -{ - ReMutexHolder holder(_lock); - // these could be static .. not - PyObject *doId2do = NULL; - float startTime =0; - float endTime = 0; - // this seems weird...here - _bdc.Flush(); - while (_bdc.GetMessage(_dg)) - { - if (get_verbose()) - describe_message(nout, "RECV", _dg); - - if (_time_warning > 0) - startTime = ClockObject::get_global_clock()->get_real_time(); - - // Start breaking apart the datagram. - _di.assign(_dg); - unsigned char wc_cnt = _di.get_uint8(); - _msg_channels.clear(); - for(unsigned char lp1 = 0; lp1 < wc_cnt; lp1++) - _msg_channels.push_back(_di.get_uint64()); - - _msg_sender = _di.get_uint64(); - _msg_type = _di.get_uint16(); - - if( _msg_type == STATESERVER_OBJECT_UPDATE_FIELD) - { - if(doId2do == NULL) - { - // this is my attemp to take it out of the inner loop RHH - doId2do =PyObject_GetAttrString(_python_repository, "doId2do"); - nassertr(doId2do != NULL, false); - } - - if (!handle_update_field_ai(doId2do)) - { - Py_XDECREF(doId2do); - if (_time_warning > 0) { - endTime = ClockObject::get_global_clock()->get_real_time(); - if ( _time_warning < (endTime - startTime)) { - nout << "msg " << _msg_type <<" from " << _msg_sender << " took "<< (endTime-startTime) << "secs to process\n"; - _dg.dump_hex(nout,2); - } - } - return false; - } - } - else - { - PyObject * result = PyEval_CallObject(PycallBackFunction, _python_ai_datagramiterator); - if (PyErr_Occurred()) - { - Py_XDECREF(doId2do); - if (_time_warning > 0) { - endTime = ClockObject::get_global_clock()->get_real_time(); - if ( _time_warning < (endTime - startTime)) { - nout << "msg " << _msg_type <<" from " << _msg_sender << " took "<< (endTime-startTime) << "secs to process\n"; - _dg.dump_hex(nout,2); - } - } - return true; - } - } - - if (_time_warning > 0) { - endTime = ClockObject::get_global_clock()->get_real_time(); - if ( _time_warning < (endTime - startTime)) { - nout << "msg " << _msg_type <<" from " << _msg_sender << " took "<< (endTime-startTime) << "secs to process\n"; - _dg.dump_hex(nout,2); - } - } - - } - - - Py_XDECREF(doId2do); - return false; -} - -#endif // #ifdef WANT_NATIVE_NET -#endif // #ifdef HAVE_PYTHON - - -#ifdef HAVE_PYTHON -#ifdef WANT_NATIVE_NET - - -bool CConnectionRepository::handle_update_field_ai(PyObject *doId2do) -{ - PStatTimer timer(_update_pcollector); - unsigned int do_id = _di.get_uint32(); - - PyObject *doId = PyLong_FromUnsignedLong(do_id); - PyObject *distobj = PyDict_GetItem(doId2do, doId); - Py_DECREF(doId); - - if (distobj != NULL) - { - PyObject *dclass_obj = PyObject_GetAttrString(distobj, "dclass"); - nassertr(dclass_obj != NULL, false); - - DCClass *dclass = NULL; - DTOOL_Call_ExtractThisPointerForType(dclass_obj, &Dtool_DCClass, (void **) &dclass); - if(dclass == NULL) - return false; - - Py_INCREF(distobj); - dclass->receive_update(distobj, _di); - Py_DECREF(distobj); - - if (PyErr_Occurred()) - return false; - } - return true; -} - -#endif // #ifdef WANT_NATIVE_NET -#endif // #ifdef HAVE_PYTHON diff --git a/direct/src/distributed/cConnectionRepository.h b/direct/src/distributed/cConnectionRepository.h index d7adac4714..06f581764c 100644 --- a/direct/src/distributed/cConnectionRepository.h +++ b/direct/src/distributed/cConnectionRepository.h @@ -100,7 +100,7 @@ PUBLISHED: #endif #ifdef HAVE_NET BLOCKING bool try_connect_net(const URLSpec &url); - + INLINE QueuedConnectionManager &get_qcm(); INLINE ConnectionWriter &get_cw(); INLINE QueuedConnectionReader &get_qcr(); @@ -117,13 +117,7 @@ PUBLISHED: #endif BLOCKING bool check_datagram(); -#ifdef HAVE_PYTHON -#ifdef WANT_NATIVE_NET - BLOCKING bool check_datagram_ai(PyObject *PycallBackFunction); - BLOCKING bool network_based_reader_and_yielder(PyObject *PycallBackFunction,ClockObject &clock, float returnBy); -#endif -#endif - + BLOCKING INLINE void get_datagram(Datagram &dg); BLOCKING INLINE void get_datagram_iterator(DatagramIterator &di); BLOCKING INLINE CHANNEL_TYPE get_msg_channel(int offset = 0) const; @@ -167,18 +161,11 @@ PUBLISHED: INLINE float get_time_warning() const; private: -#ifdef HAVE_PYTHON -#ifdef WANT_NATIVE_NET - bool handle_update_field_ai(PyObject *doId2do); -#endif -#endif - - bool do_check_datagram(); bool handle_update_field(); bool handle_update_field_owner(); - void describe_message(ostream &out, const string &prefix, + void describe_message(ostream &out, const string &prefix, const Datagram &dg) const; private: @@ -186,7 +173,6 @@ private: #ifdef HAVE_PYTHON PyObject *_python_repository; - PyObject *_python_ai_datagramiterator; #endif #ifdef HAVE_OPENSSL diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index e0e5c12ec5..cdea47c29f 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -382,19 +382,12 @@ $[cdefine USE_GENERIC_DXERR_LIBRARY] /* Define if we have zlib installed. */ $[cdefine HAVE_ZLIB] -/* Define if we have OpenGL installed and want to build for GL. */ -$[cdefine HAVE_GL] +/* Define the preconfigured minimum GL version number. */ #if HAVE_GL # define MIN_GL_VERSION_MAJOR $[word 1,$[MIN_GL_VERSION]] # define MIN_GL_VERSION_MINOR $[word 2,$[MIN_GL_VERSION]] #endif -/* Define if we have OpenGL ES installed and want to build for GLES. */ -$[cdefine HAVE_GLES] - -/* Define if we have OpenGL ES installed and want to build for GLES2. */ -$[cdefine HAVE_GLES2] - /* Define if we have OpenCV installed and want to build for OpenCV. */ $[cdefine HAVE_OPENCV] $[cdefine OPENCV_VER_23] diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h index a7844da3f0..2ead06d0fe 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h @@ -21,7 +21,10 @@ #ifdef WIN32_VC #include "numeric_types.h" -#define WIN32_LEAN_AND_MEAN + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/dtoolbase/cmath.I b/dtool/src/dtoolbase/cmath.I index 194e6d24cf..03b03f5640 100644 --- a/dtool/src/dtoolbase/cmath.I +++ b/dtool/src/dtoolbase/cmath.I @@ -358,26 +358,68 @@ cpow(int x, int y) { } } +//////////////////////////////////////////////////////////////////// +// Function: cnan +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool +cnan(float v) { +#if __FINITE_MATH_ONLY__ + // GCC's isnan breaks when using -ffast-math. + union { float f; uint32_t x; } u = { v }; + return ((u.x << 1) > 0xff000000u); +#elif !defined(_WIN32) + return std::isnan(v); +#else + return (_isnan(v) != 0); +#endif +} + //////////////////////////////////////////////////////////////////// // Function: cnan // Description: //////////////////////////////////////////////////////////////////// INLINE bool cnan(double v) { -#ifndef _WIN32 +#if __FINITE_MATH_ONLY__ + // GCC's isnan breaks when using -ffast-math. + union { double d; uint64_t x; } u = { v }; + return ((u.x << 1) > 0xff70000000000000ull); +#elif !defined(_WIN32) return std::isnan(v); #else return (_isnan(v) != 0); #endif } +//////////////////////////////////////////////////////////////////// +// Function: cinf +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool +cinf(float v) { +#if __FINITE_MATH_ONLY__ + // GCC's isinf breaks when using -ffast-math. + union { float f; uint32_t x; } u = { v }; + return ((u.x << 1) == 0xff000000u); +#elif !defined(_WIN32) + return std::isinf(v); +#else + return (_isnan(v) == 0 && _finite(v) == 0); +#endif +} + //////////////////////////////////////////////////////////////////// // Function: cinf // Description: //////////////////////////////////////////////////////////////////// INLINE bool cinf(double v) { -#ifndef _WIN32 +#if __FINITE_MATH_ONLY__ + // GCC's isinf breaks when using -ffast-math. + union { double d; uint64_t x; } u = { v }; + return ((u.x << 1) == 0xff70000000000000ull); +#elif !defined(_WIN32) return std::isinf(v); #else return (_isnan(v) == 0 && _finite(v) == 0); diff --git a/dtool/src/dtoolbase/cmath.h b/dtool/src/dtoolbase/cmath.h index 6e5c1ef8e8..42d83f77d5 100644 --- a/dtool/src/dtoolbase/cmath.h +++ b/dtool/src/dtoolbase/cmath.h @@ -61,9 +61,11 @@ INLINE int cpow(int x, int y); // Returns true if the number is NaN, false if it's a genuine number // or infinity. +INLINE bool cnan(float v); INLINE bool cnan(double v); // Returns true if the number is infinity. +INLINE bool cinf(float v); INLINE bool cinf(double v); // Return NaN and infinity, respectively. diff --git a/dtool/src/dtoolbase/dlmalloc.h b/dtool/src/dtoolbase/dlmalloc.h index 1bb3ed8abc..c79fb95e76 100644 --- a/dtool/src/dtoolbase/dlmalloc.h +++ b/dtool/src/dtoolbase/dlmalloc.h @@ -148,10 +148,15 @@ void* dlvalloc(size_t); */ int dlmallopt(int, int); +#ifndef M_TRIM_THRESHOLD #define M_TRIM_THRESHOLD (-1) +#endif +#ifndef M_GRANULARITY #define M_GRANULARITY (-2) +#endif +#ifndef M_MMAP_THRESHOLD #define M_MMAP_THRESHOLD (-3) - +#endif /* malloc_footprint(); diff --git a/dtool/src/dtoolbase/dlmalloc_src.cxx b/dtool/src/dtoolbase/dlmalloc_src.cxx index 93e843ea75..4e21f4c914 100644 --- a/dtool/src/dtoolbase/dlmalloc_src.cxx +++ b/dtool/src/dtoolbase/dlmalloc_src.cxx @@ -462,7 +462,9 @@ DEFAULT_MMAP_THRESHOLD default: 256K #endif /* _WIN32 */ #endif /* WIN32 */ #ifdef WIN32 -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include #define HAVE_MMAP 1 #define HAVE_MORECORE 0 @@ -597,9 +599,15 @@ DEFAULT_MMAP_THRESHOLD default: 256K malloc does support the following options. */ +#ifndef M_TRIM_THRESHOLD #define M_TRIM_THRESHOLD (-1) +#endif +#ifndef M_GRANULARITY #define M_GRANULARITY (-2) +#endif +#ifndef M_MMAP_THRESHOLD #define M_MMAP_THRESHOLD (-3) +#endif /* ------------------------ Mallinfo declarations ------------------------ */ diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 81829bb3e0..7a4fb2445b 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -103,6 +103,15 @@ #endif #endif +// This is a workaround for a glibc bug that is triggered by +// clang when compiling with -ffast-math. +#ifdef __clang__ +#include +#ifndef __extern_always_inline +#define __extern_always_inline extern __always_inline +#endif +#endif + #ifdef HAVE_PYTHON #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE diff --git a/dtool/src/dtoolbase/memoryHook.cxx b/dtool/src/dtoolbase/memoryHook.cxx index 567097e213..b132ed5754 100644 --- a/dtool/src/dtoolbase/memoryHook.cxx +++ b/dtool/src/dtoolbase/memoryHook.cxx @@ -19,7 +19,9 @@ #ifdef WIN32 // Windows case. -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include #else diff --git a/dtool/src/dtoolbase/mutexWin32Impl.h b/dtool/src/dtoolbase/mutexWin32Impl.h index 5513d120a8..1c66583a9c 100644 --- a/dtool/src/dtoolbase/mutexWin32Impl.h +++ b/dtool/src/dtoolbase/mutexWin32Impl.h @@ -19,7 +19,9 @@ #include "selectThreadImpl.h" #ifdef WIN32_VC -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx b/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx index 1de71ccb98..7ecfde41f1 100644 --- a/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx +++ b/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx @@ -482,7 +482,9 @@ int tsd_key_next; #elif defined(WIN32) /* Win32 emulation */ -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #define _WIN32_WINNT 0x600 #include diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.h b/dtool/src/dtoolutil/pandaFileStreamBuf.h index 4421251afd..0561c3bcba 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.h +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.h @@ -20,7 +20,9 @@ #ifdef USE_PANDAFILESTREAM #if defined(_WIN32) -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include #endif diff --git a/dtool/src/dtoolutil/pfstreamBuf.h b/dtool/src/dtoolutil/pfstreamBuf.h index 02243f0af6..5e35723997 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.h +++ b/dtool/src/dtoolutil/pfstreamBuf.h @@ -28,7 +28,9 @@ #endif #ifdef WIN_PIPE_CALLS -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include #else // WIN_PIPE_CALLS diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index d402f983da..a6326a6ba1 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -162,6 +162,18 @@ call_function(ostream &out, int indent_level, bool convert_result, string defconstruct = builder.in_defconstruct(_cpptype->get_local_name(&parser)); if (pexprs.empty() && !defconstruct.empty()) { return_expr = defconstruct; + } else if (_extension) { + // Extension constructors are a special case. We assume there is a + // default constructor for the class, and the actual construction is + // done by an __init__ method. + InterfaceMaker::indent(out, indent_level); + _return_type->get_new_type()->output_instance(out, "result", &parser); + out << " = new " << _cpptype->get_local_name(&parser) << ";\n"; + + InterfaceMaker::indent(out, indent_level) + << get_call_str("result", pexprs) << ";\n"; + + return_expr = "result"; } else { return_expr = "new " + get_call_str(container, pexprs); } @@ -329,7 +341,7 @@ make_wrapper_entry(FunctionIndex function_index) { // understands that if the destructor function is zero, it // should use the regular class destructor. - // nout << "Warning! Destructor for " + // nout << "Warning! Destructor for " // << *_return_type->get_orig_type() // << " is unavailable.\n" // << " Cannot manage return value for:\n " @@ -385,11 +397,13 @@ get_call_str(const string &container, const vector_string &pexprs) const { call << "Extension<" << _cpptype->get_local_name(&parser) << ">::"; } - call << _cppfunc->get_local_name(); - call << "("; - + if (_type == T_constructor) { + // Constructor extensions are named __init__, by convention. + call << "__init__"; + } else { + call << _cppfunc->get_local_name(); + } } else { - if (_type == T_constructor) { // Constructors are called differently. call << _cpptype->get_local_name(&parser); @@ -402,9 +416,8 @@ get_call_str(const string &container, const vector_string &pexprs) const { } else { call << _cppfunc->get_local_name(&parser); } - - call << "("; } + call << "("; if (_flags & F_explicit_self) { // Pass on the PyObject * that we stripped off above. @@ -690,7 +703,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } if (_has_this || _type == T_constructor) { - if ((int)_parameters.size() > first_param && _parameters[first_param]._name == "self" && + if (_parameters.size() > (size_t)first_param && _parameters[first_param]._name == "self" && TypeManager::is_pointer_to_PyObject(_parameters[first_param]._remap->get_orig_type())) { // Here's a special case. If the first parameter of a nonstatic // method is a PyObject * called "self", then we will diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index b6ea426020..f945fe3600 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -3413,7 +3413,7 @@ write_function_instance(ostream &out, << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" << "#endif\n"; - pexpr_string = "basic_string(" + + pexpr_string = "std::wstring(" + param_name + "_str, " + param_name + "_len)"; extra_cleanup @@ -3439,7 +3439,7 @@ write_function_instance(ostream &out, << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" << "#endif\n"; - pexpr_string = "&basic_string(" + + pexpr_string = "&std::wstring(" + param_name + "_str, " + param_name + "_len)"; extra_cleanup @@ -3473,10 +3473,10 @@ write_function_instance(ostream &out, } if (TypeManager::is_const_ptr_to_basic_string_char(orig_type)) { - pexpr_string = "&basic_string(" + + pexpr_string = "&std::string(" + param_name + "_str, " + param_name + "_len)"; } else { - pexpr_string = "basic_string(" + + pexpr_string = "std::string(" + param_name + "_str, " + param_name + "_len)"; } expected_params += "str"; diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 4ac0c6c4ea..9be10dc81f 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -214,6 +214,22 @@ do_command(const string &command, const string ¶ms) { } else if (command == "noinclude") { insert_param_list(_noinclude, params); + } else if (command == "forceinclude") { + size_t nchars = params.size(); + if (nchars >= 2 && params[0] == '"' && params[nchars-1] == '"') { + string incfile = params.substr(1, nchars - 2); + _include_files[incfile] = '"'; + + } else if (nchars >= 2 && params[0] == '<' && params[nchars-1] == '>') { + string incfile = params.substr(1, nchars - 2); + _include_files[incfile] = '<'; + + } else { + nout << "Ignoring invalid forceinclude " << params << "\n" + "Expected to be in one of the following forms:\n" + " forceinclude \"file.h\"\n" + " forceinclude \n"; + } } else { nout << "Ignoring " << command << " " << params << "\n"; } diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index fb25057007..9292f04b02 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -112,7 +112,7 @@ int write_python_table_native(ostream &out) { pset::iterator ii; for(ii = libraries.begin(); ii != libraries.end(); ii++) { printf("Referencing Library %s\n", (*ii).c_str()); - out << "IMPORT_THIS LibraryDef " << *ii << "_moddef;\n"; + out << "extern LibraryDef " << *ii << "_moddef;\n"; } out << "\n" diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 678643fae9..789f35d974 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -981,6 +981,9 @@ def CompileCxx(obj,src,opts): else: cmd += " -D_HAS_EXCEPTIONS=0" + if 'RTTI' not in opts: + cmd += " /GR-" + if GetTargetArch() == 'x64': cmd += " /DWIN64_VC /DWIN64" @@ -1104,6 +1107,8 @@ def CompileCxx(obj,src,opts): arch = GetTargetArch() if GetTarget() == "android": + # Most of the specific optimization flags here were + # just copied from the default Android Makefiles. cmd += ' -I%s/include' % (SDK["ANDROID_STL"]) cmd += ' -I%s/libs/%s/include' % (SDK["ANDROID_STL"], SDK["ANDROID_ABI"]) cmd += ' -ffunction-sections -funwind-tables' @@ -1158,6 +1163,12 @@ def CompileCxx(obj,src,opts): if PkgSkip("SSE2") == 0 and not arch.startswith("arm"): cmd += " -msse2" + if optlevel >= 3: + cmd += " -ffast-math" + if optlevel == 3: + # Fast math is nice, but we'd like to see NaN in dev builds. + cmd += " -fno-finite-math-only" + if (optlevel==1): cmd += " -ggdb -D_DEBUG" if (optlevel==2): cmd += " -O1 -D_DEBUG" if (optlevel==3): cmd += " -O2" @@ -1292,8 +1303,8 @@ def CompileIgate(woutd,wsrc,opts): if (opt=="ALWAYS") or (opt in opts): cmd += ' -D' + var + '=' + val - building = GetValueOption(opts, "BUILDING:") - if (building): cmd += " -DBUILDING_"+building + #building = GetValueOption(opts, "BUILDING:") + #if (building): cmd += " -DBUILDING_"+building cmd += ' -module ' + module + ' -library ' + library for x in wsrc: if (x.startswith("/")): @@ -1518,6 +1529,10 @@ def CompileLink(dll, obj, opts): else: cmd = cxx + ' -shared' if ("MODULE" not in opts): cmd += " -Wl,-soname=" + os.path.basename(dll) + if GetOrigExt(dll) == ".pyd" and not os.path.basename(dll).startswith('core'): + # Tell the other libraries where to find core.so. + # Not sure if this is the best way to do that, but it works. + cmd += " -Wl,-rpath '-Wl,$ORIGIN'" cmd += ' -o ' + dll + ' -L' + GetOutputDir() + '/lib -L' + GetOutputDir() + '/tmp' for x in obj: @@ -1947,9 +1962,6 @@ DTOOL_CONFIG=[ ("USE_PANDAFILESTREAM", '1', '1'), ("USE_DELETED_CHAIN", '1', '1'), ("HAVE_WIN_TOUCHINPUT", 'UNDEF', 'UNDEF'), - ("HAVE_GL", '1', 'UNDEF'), - ("HAVE_GLES", 'UNDEF', 'UNDEF'), - ("HAVE_GLES2", 'UNDEF', 'UNDEF'), ("HAVE_GLX", 'UNDEF', '1'), ("HAVE_EGL", 'UNDEF', 'UNDEF'), ("HAVE_WGL", '1', 'UNDEF'), @@ -2938,6 +2950,7 @@ TargetAdd('libp3dtoolconfig.dll', input='libp3dtool.dll') TargetAdd('libp3dtoolconfig.dll', opts=['ADVAPI', 'OPENSSL', 'WINGDI', 'WINUSER']) if not PkgSkip("PYTHON"): + OPTS=['DIR:dtool/metalibs/dtoolconfig'] TargetAdd('dtoolconfig_pydtool.obj', opts=OPTS, input="pydtool.cxx") TargetAdd('dtoolconfig.pyd', input='dtoolconfig_pydtool.obj') TargetAdd('dtoolconfig.pyd', input='libp3dtoolconfig.dll') @@ -3017,11 +3030,13 @@ TargetAdd('p3pandabase_pandabase.obj', opts=OPTS, input='pandabase.cxx') OPTS=['DIR:panda/src/express', 'BUILDING:PANDAEXPRESS', 'OPENSSL', 'ZLIB'] TargetAdd('p3express_composite1.obj', opts=OPTS, input='p3express_composite1.cxx') TargetAdd('p3express_composite2.obj', opts=OPTS, input='p3express_composite2.cxx') -TargetAdd('p3express_ext_composite.obj', opts=OPTS, input='p3express_ext_composite.cxx') + +OPTS=['DIR:panda/src/express', 'OPENSSL', 'ZLIB'] IGATEFILES=GetDirectoryContents('panda/src/express', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3express.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3express.in', opts=['IMOD:panda3d.core', 'ILIB:libp3express', 'SRCDIR:panda/src/express']) TargetAdd('libp3express_igate.obj', input='libp3express.in', opts=["DEPENDENCYONLY"]) +TargetAdd('p3express_ext_composite.obj', opts=OPTS, input='p3express_ext_composite.cxx') # # DIRECTORY: panda/src/downloader/ @@ -3030,6 +3045,8 @@ TargetAdd('libp3express_igate.obj', input='libp3express.in', opts=["DEPENDENCYON OPTS=['DIR:panda/src/downloader', 'BUILDING:PANDAEXPRESS', 'OPENSSL', 'ZLIB'] TargetAdd('p3downloader_composite1.obj', opts=OPTS, input='p3downloader_composite1.cxx') TargetAdd('p3downloader_composite2.obj', opts=OPTS, input='p3downloader_composite2.cxx') + +OPTS=['DIR:panda/src/downloader', 'OPENSSL', 'ZLIB'] IGATEFILES=GetDirectoryContents('panda/src/downloader', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3downloader.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3downloader.in', opts=['IMOD:panda3d.core', 'ILIB:libp3downloader', 'SRCDIR:panda/src/downloader']) @@ -3044,11 +3061,8 @@ TargetAdd('pandaexpress_pandaexpress.obj', opts=OPTS, input='pandaexpress.cxx') TargetAdd('libpandaexpress.dll', input='pandaexpress_pandaexpress.obj') TargetAdd('libpandaexpress.dll', input='p3downloader_composite1.obj') TargetAdd('libpandaexpress.dll', input='p3downloader_composite2.obj') -TargetAdd('libpandaexpress.dll', input='libp3downloader_igate.obj') TargetAdd('libpandaexpress.dll', input='p3express_composite1.obj') TargetAdd('libpandaexpress.dll', input='p3express_composite2.obj') -TargetAdd('libpandaexpress.dll', input='p3express_ext_composite.obj') -TargetAdd('libpandaexpress.dll', input='libp3express_igate.obj') TargetAdd('libpandaexpress.dll', input='p3pandabase_pandabase.obj') TargetAdd('libpandaexpress.dll', input=COMMON_DTOOL_LIBS) TargetAdd('libpandaexpress.dll', opts=['ADVAPI', 'WINSOCK2', 'OPENSSL', 'ZLIB', 'WINGDI', 'WINUSER']) @@ -3062,6 +3076,8 @@ if (not RUNTIME): TargetAdd('p3pipeline_composite1.obj', opts=OPTS, input='p3pipeline_composite1.cxx') TargetAdd('p3pipeline_composite2.obj', opts=OPTS, input='p3pipeline_composite2.cxx') TargetAdd('p3pipeline_contextSwitch.obj', opts=OPTS, input='contextSwitch.c') + + OPTS=['DIR:panda/src/pipeline'] IGATEFILES=GetDirectoryContents('panda/src/pipeline', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pipeline.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3pipeline.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pipeline', 'SRCDIR:panda/src/pipeline']) @@ -3075,6 +3091,8 @@ 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') + + OPTS=['DIR:panda/src/linmath'] IGATEFILES=GetDirectoryContents('panda/src/linmath', ["*.h", "*_composite*.cxx"]) for ifile in IGATEFILES[:]: if "_src." in ifile: @@ -3094,12 +3112,15 @@ if (not RUNTIME): OPTS=['DIR:panda/src/putil', 'BUILDING:PANDA', 'ZLIB'] TargetAdd('p3putil_composite1.obj', opts=OPTS, input='p3putil_composite1.cxx') TargetAdd('p3putil_composite2.obj', opts=OPTS, input='p3putil_composite2.cxx') + + OPTS=['DIR:panda/src/putil', 'ZLIB'] IGATEFILES=GetDirectoryContents('panda/src/putil', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("test_bam.h") TargetAdd('libp3putil.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3putil.in', opts=['IMOD:panda3d.core', 'ILIB:libp3putil', 'SRCDIR:panda/src/putil']) TargetAdd('libp3putil_igate.obj', input='libp3putil.in', opts=["DEPENDENCYONLY"]) TargetAdd('p3putil_typedWritable_ext.obj', opts=OPTS, input='typedWritable_ext.cxx') + TargetAdd('p3putil_pythonCallbackObject.obj', opts=OPTS, input='pythonCallbackObject.cxx') # # DIRECTORY: panda/src/audio/ @@ -3108,6 +3129,8 @@ if (not RUNTIME): if (not RUNTIME): OPTS=['DIR:panda/src/audio', 'BUILDING:PANDA'] TargetAdd('p3audio_composite1.obj', opts=OPTS, input='p3audio_composite1.cxx') + + OPTS=['DIR:panda/src/audio'] IGATEFILES=["audio.h"] TargetAdd('libp3audio.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3audio.in', opts=['IMOD:panda3d.core', 'ILIB:libp3audio', 'SRCDIR:panda/src/audio']) @@ -3121,6 +3144,9 @@ if (not RUNTIME): OPTS=['DIR:panda/src/event', 'BUILDING:PANDA'] TargetAdd('p3event_composite1.obj', opts=OPTS, input='p3event_composite1.cxx') TargetAdd('p3event_composite2.obj', opts=OPTS, input='p3event_composite2.cxx') + + OPTS=['DIR:panda/src/event'] + TargetAdd('p3event_pythonTask.obj', opts=OPTS, input='pythonTask.cxx') IGATEFILES=GetDirectoryContents('panda/src/event', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3event.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3event.in', opts=['IMOD:panda3d.core', 'ILIB:libp3event', 'SRCDIR:panda/src/event']) @@ -3134,6 +3160,8 @@ if (not RUNTIME): OPTS=['DIR:panda/src/mathutil', 'BUILDING:PANDA', 'FFTW'] TargetAdd('p3mathutil_composite1.obj', opts=OPTS, input='p3mathutil_composite1.cxx') TargetAdd('p3mathutil_composite2.obj', opts=OPTS, input='p3mathutil_composite2.cxx') + + OPTS=['DIR:panda/src/mathutil', 'FFTW'] IGATEFILES=GetDirectoryContents('panda/src/mathutil', ["*.h", "*_composite*.cxx"]) for ifile in IGATEFILES[:]: if "_src." in ifile: @@ -3149,6 +3177,8 @@ if (not RUNTIME): if (not RUNTIME): OPTS=['DIR:panda/src/gsgbase', 'BUILDING:PANDA'] TargetAdd('p3gsgbase_composite1.obj', opts=OPTS, input='p3gsgbase_composite1.cxx') + + OPTS=['DIR:panda/src/gsgbase'] IGATEFILES=GetDirectoryContents('panda/src/gsgbase', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3gsgbase.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3gsgbase.in', opts=['IMOD:panda3d.core', 'ILIB:libp3gsgbase', 'SRCDIR:panda/src/gsgbase']) @@ -3162,6 +3192,8 @@ if (not RUNTIME): OPTS=['DIR:panda/src/pnmimage', 'BUILDING:PANDA', 'ZLIB'] TargetAdd('p3pnmimage_composite1.obj', opts=OPTS, input='p3pnmimage_composite1.cxx') TargetAdd('p3pnmimage_composite2.obj', opts=OPTS, input='p3pnmimage_composite2.cxx') + + OPTS=['DIR:panda/src/pnmimage', 'ZLIB'] IGATEFILES=GetDirectoryContents('panda/src/pnmimage', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pnmimage.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3pnmimage.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pnmimage', 'SRCDIR:panda/src/pnmimage']) @@ -3175,6 +3207,8 @@ if (not RUNTIME): if (not RUNTIME): OPTS=['DIR:panda/src/nativenet', 'OPENSSL', 'BUILDING:PANDA'] TargetAdd('p3nativenet_composite1.obj', opts=OPTS, input='p3nativenet_composite1.cxx') + + OPTS=['DIR:panda/src/nativenet', 'OPENSSL'] IGATEFILES=GetDirectoryContents('panda/src/nativenet', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3nativenet.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3nativenet.in', opts=['IMOD:panda3d.core', 'ILIB:libp3nativenet', 'SRCDIR:panda/src/nativenet']) @@ -3188,6 +3222,8 @@ if (not RUNTIME): OPTS=['DIR:panda/src/net', 'BUILDING:PANDA'] TargetAdd('p3net_composite1.obj', opts=OPTS, input='p3net_composite1.cxx') TargetAdd('p3net_composite2.obj', opts=OPTS, input='p3net_composite2.cxx') + + OPTS=['DIR:panda/src/net'] IGATEFILES=GetDirectoryContents('panda/src/net', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("datagram_ui.h") TargetAdd('libp3net.in', opts=OPTS, input=IGATEFILES) @@ -3202,6 +3238,8 @@ if (not RUNTIME): OPTS=['DIR:panda/src/pstatclient', 'BUILDING:PANDA'] TargetAdd('p3pstatclient_composite1.obj', opts=OPTS, input='p3pstatclient_composite1.cxx') TargetAdd('p3pstatclient_composite2.obj', opts=OPTS, input='p3pstatclient_composite2.cxx') + + OPTS=['DIR:panda/src/pstatclient'] IGATEFILES=GetDirectoryContents('panda/src/pstatclient', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pstatclient.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3pstatclient.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pstatclient', 'SRCDIR:panda/src/pstatclient']) @@ -3212,25 +3250,28 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/gobj', 'BUILDING:PANDA', 'NVIDIACG', 'ZLIB', 'SQUISH', "BIGOBJ"] + OPTS=['DIR:panda/src/gobj', 'BUILDING:PANDA', 'NVIDIACG', 'ZLIB', 'SQUISH'] TargetAdd('p3gobj_composite1.obj', opts=OPTS, input='p3gobj_composite1.cxx') TargetAdd('p3gobj_composite2.obj', opts=OPTS, input='p3gobj_composite2.cxx') + + OPTS=['DIR:panda/src/gobj', 'NVIDIACG', 'ZLIB', 'SQUISH'] IGATEFILES=GetDirectoryContents('panda/src/gobj', ["*.h", "*_composite*.cxx"]) if ("cgfx_states.h" in IGATEFILES): IGATEFILES.remove("cgfx_states.h") TargetAdd('libp3gobj.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3gobj.in', opts=['IMOD:panda3d.core', 'ILIB:libp3gobj', 'SRCDIR:panda/src/gobj']) TargetAdd('libp3gobj_igate.obj', input='libp3gobj.in', opts=["DEPENDENCYONLY"]) - TargetAdd('p3gobj_geomVertexArrayData_ext.obj', opts=OPTS, input='geomVertexArrayData_ext.cxx') - TargetAdd('p3gobj_internalName_ext.obj', opts=OPTS, input='internalName_ext.cxx') + TargetAdd('p3gobj_ext_composite.obj', opts=OPTS, input='p3gobj_ext_composite.cxx') # # DIRECTORY: panda/src/pgraphnodes/ # if (not RUNTIME): - OPTS=['DIR:panda/src/pgraphnodes', 'BUILDING:PANDA', "BIGOBJ"] + OPTS=['DIR:panda/src/pgraphnodes', 'BUILDING:PANDA'] TargetAdd('p3pgraphnodes_composite1.obj', opts=OPTS, input='p3pgraphnodes_composite1.cxx') TargetAdd('p3pgraphnodes_composite2.obj', opts=OPTS, input='p3pgraphnodes_composite2.cxx') + + OPTS=['DIR:panda/src/pgraphnodes'] IGATEFILES=GetDirectoryContents('panda/src/pgraphnodes', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pgraphnodes.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3pgraphnodes.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pgraphnodes', 'SRCDIR:panda/src/pgraphnodes']) @@ -3241,12 +3282,14 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/pgraph', 'BUILDING:PANDA','BIGOBJ'] + OPTS=['DIR:panda/src/pgraph', 'BUILDING:PANDA'] TargetAdd('p3pgraph_nodePath.obj', opts=OPTS, input='nodePath.cxx') TargetAdd('p3pgraph_composite1.obj', opts=OPTS, input='p3pgraph_composite1.cxx') TargetAdd('p3pgraph_composite2.obj', opts=OPTS, input='p3pgraph_composite2.cxx') TargetAdd('p3pgraph_composite3.obj', opts=OPTS, input='p3pgraph_composite3.cxx') TargetAdd('p3pgraph_composite4.obj', opts=OPTS, input='p3pgraph_composite4.cxx') + + OPTS=['DIR:panda/src/pgraph'] IGATEFILES=GetDirectoryContents('panda/src/pgraph', ["*.h", "nodePath.cxx", "*_composite*.cxx"]) TargetAdd('libp3pgraph.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3pgraph.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pgraph', 'SRCDIR:panda/src/pgraph']) @@ -3258,9 +3301,11 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/cull', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/cull', 'BUILDING:PANDA'] TargetAdd('p3cull_composite1.obj', opts=OPTS, input='p3cull_composite1.cxx') TargetAdd('p3cull_composite2.obj', opts=OPTS, input='p3cull_composite2.cxx') + + OPTS=['DIR:panda/src/cull'] IGATEFILES=GetDirectoryContents('panda/src/cull', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3cull.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3cull.in', opts=['IMOD:panda3d.core', 'ILIB:libp3cull', 'SRCDIR:panda/src/cull']) @@ -3271,9 +3316,11 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/chan', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/chan', 'BUILDING:PANDA'] TargetAdd('p3chan_composite1.obj', opts=OPTS, input='p3chan_composite1.cxx') TargetAdd('p3chan_composite2.obj', opts=OPTS, input='p3chan_composite2.cxx') + + OPTS=['DIR:panda/src/chan'] IGATEFILES=GetDirectoryContents('panda/src/chan', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove('movingPart.h') IGATEFILES.remove('animChannelFixed.h') @@ -3286,9 +3333,11 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/char', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/char', 'BUILDING:PANDA'] TargetAdd('p3char_composite1.obj', opts=OPTS, input='p3char_composite1.cxx') TargetAdd('p3char_composite2.obj', opts=OPTS, input='p3char_composite2.cxx') + + OPTS=['DIR:panda/src/char'] IGATEFILES=GetDirectoryContents('panda/src/char', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3char.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3char.in', opts=['IMOD:panda3d.core', 'ILIB:libp3char', 'SRCDIR:panda/src/char']) @@ -3302,6 +3351,8 @@ if (not RUNTIME): OPTS=['DIR:panda/src/dgraph', 'BUILDING:PANDA'] TargetAdd('p3dgraph_composite1.obj', opts=OPTS, input='p3dgraph_composite1.cxx') TargetAdd('p3dgraph_composite2.obj', opts=OPTS, input='p3dgraph_composite2.cxx') + + OPTS=['DIR:panda/src/dgraph'] IGATEFILES=GetDirectoryContents('panda/src/dgraph', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3dgraph.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3dgraph.in', opts=['IMOD:panda3d.core', 'ILIB:libp3dgraph', 'SRCDIR:panda/src/dgraph']) @@ -3312,9 +3363,11 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/display', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/display', 'BUILDING:PANDA'] TargetAdd('p3display_composite1.obj', opts=OPTS, input='p3display_composite1.cxx') TargetAdd('p3display_composite2.obj', opts=OPTS, input='p3display_composite2.cxx') + + OPTS=['DIR:panda/src/display'] IGATEFILES=GetDirectoryContents('panda/src/display', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("renderBuffer.h") TargetAdd('libp3display.in', opts=OPTS, input=IGATEFILES) @@ -3322,6 +3375,7 @@ if (not RUNTIME): TargetAdd('libp3display_igate.obj', input='libp3display.in', opts=["DEPENDENCYONLY"]) TargetAdd('p3display_graphicsStateGuardian_ext.obj', opts=OPTS, input='graphicsStateGuardian_ext.cxx') TargetAdd('p3display_graphicsWindow_ext.obj', opts=OPTS, input='graphicsWindow_ext.cxx') + TargetAdd('p3display_pythonGraphicsWindowProc.obj', opts=OPTS, input='pythonGraphicsWindowProc.cxx') if RTDIST and GetTarget() == 'darwin': OPTS=['DIR:panda/src/display'] @@ -3333,9 +3387,11 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/device', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/device', 'BUILDING:PANDA'] TargetAdd('p3device_composite1.obj', opts=OPTS, input='p3device_composite1.cxx') TargetAdd('p3device_composite2.obj', opts=OPTS, input='p3device_composite2.cxx') + + OPTS=['DIR:panda/src/device'] IGATEFILES=GetDirectoryContents('panda/src/device', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3device.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3device.in', opts=['IMOD:panda3d.core', 'ILIB:libp3device', 'SRCDIR:panda/src/device']) @@ -3348,6 +3404,8 @@ if (not RUNTIME): if (PkgSkip("FREETYPE")==0 and not RUNTIME): OPTS=['DIR:panda/src/pnmtext', 'BUILDING:PANDA', 'FREETYPE'] TargetAdd('p3pnmtext_composite1.obj', opts=OPTS, input='p3pnmtext_composite1.cxx') + + OPTS=['DIR:panda/src/pnmtext', 'FREETYPE'] IGATEFILES=GetDirectoryContents('panda/src/pnmtext', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pnmtext.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3pnmtext.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pnmtext', 'SRCDIR:panda/src/pnmtext']) @@ -3358,9 +3416,11 @@ if (PkgSkip("FREETYPE")==0 and not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/text', 'BUILDING:PANDA', 'ZLIB', 'FREETYPE', 'BIGOBJ'] + OPTS=['DIR:panda/src/text', 'BUILDING:PANDA', 'ZLIB', 'FREETYPE'] TargetAdd('p3text_composite1.obj', opts=OPTS, input='p3text_composite1.cxx') TargetAdd('p3text_composite2.obj', opts=OPTS, input='p3text_composite2.cxx') + + OPTS=['DIR:panda/src/text', 'ZLIB', 'FREETYPE'] IGATEFILES=GetDirectoryContents('panda/src/text', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3text.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3text.in', opts=['IMOD:panda3d.core', 'ILIB:libp3text', 'SRCDIR:panda/src/text']) @@ -3373,6 +3433,8 @@ if (not RUNTIME): if (not RUNTIME): OPTS=['DIR:panda/src/movies', 'BUILDING:PANDA', 'VORBIS'] TargetAdd('p3movies_composite1.obj', opts=OPTS, input='p3movies_composite1.cxx') + + OPTS=['DIR:panda/src/movies', 'VORBIS'] IGATEFILES=GetDirectoryContents('panda/src/movies', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3movies.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3movies.in', opts=['IMOD:panda3d.core', 'ILIB:libp3movies', 'SRCDIR:panda/src/movies']) @@ -3383,10 +3445,12 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/grutil', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/grutil', 'BUILDING:PANDA'] TargetAdd('p3grutil_multitexReducer.obj', opts=OPTS, input='multitexReducer.cxx') TargetAdd('p3grutil_composite1.obj', opts=OPTS, input='p3grutil_composite1.cxx') TargetAdd('p3grutil_composite2.obj', opts=OPTS, input='p3grutil_composite2.cxx') + + OPTS=['DIR:panda/src/grutil'] IGATEFILES=GetDirectoryContents('panda/src/grutil', ["*.h", "*_composite*.cxx"]) if 'convexHull.h' in IGATEFILES: IGATEFILES.remove('convexHull.h') TargetAdd('libp3grutil.in', opts=OPTS, input=IGATEFILES) @@ -3398,9 +3462,11 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/tform', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/tform', 'BUILDING:PANDA'] TargetAdd('p3tform_composite1.obj', opts=OPTS, input='p3tform_composite1.cxx') TargetAdd('p3tform_composite2.obj', opts=OPTS, input='p3tform_composite2.cxx') + + OPTS=['DIR:panda/src/tform'] IGATEFILES=GetDirectoryContents('panda/src/tform', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3tform.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3tform.in', opts=['IMOD:panda3d.core', 'ILIB:libp3tform', 'SRCDIR:panda/src/tform']) @@ -3411,9 +3477,11 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/collide', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/collide', 'BUILDING:PANDA'] TargetAdd('p3collide_composite1.obj', opts=OPTS, input='p3collide_composite1.cxx') TargetAdd('p3collide_composite2.obj', opts=OPTS, input='p3collide_composite2.cxx') + + OPTS=['DIR:panda/src/collide'] IGATEFILES=GetDirectoryContents('panda/src/collide', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3collide.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3collide.in', opts=['IMOD:panda3d.core', 'ILIB:libp3collide', 'SRCDIR:panda/src/collide']) @@ -3424,9 +3492,11 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/parametrics', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/parametrics', 'BUILDING:PANDA'] TargetAdd('p3parametrics_composite1.obj', opts=OPTS, input='p3parametrics_composite1.cxx') TargetAdd('p3parametrics_composite2.obj', opts=OPTS, input='p3parametrics_composite2.cxx') + + OPTS=['DIR:panda/src/parametrics'] IGATEFILES=GetDirectoryContents('panda/src/parametrics', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3parametrics.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3parametrics.in', opts=['IMOD:panda3d.core', 'ILIB:libp3parametrics', 'SRCDIR:panda/src/parametrics']) @@ -3437,9 +3507,11 @@ if (not RUNTIME): # if (not RUNTIME): - OPTS=['DIR:panda/src/pgui', 'BUILDING:PANDA', 'BIGOBJ'] + OPTS=['DIR:panda/src/pgui', 'BUILDING:PANDA'] TargetAdd('p3pgui_composite1.obj', opts=OPTS, input='p3pgui_composite1.cxx') TargetAdd('p3pgui_composite2.obj', opts=OPTS, input='p3pgui_composite2.cxx') + + OPTS=['DIR:panda/src/pgui'] IGATEFILES=GetDirectoryContents('panda/src/pgui', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pgui.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3pgui.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pgui', 'SRCDIR:panda/src/pgui']) @@ -3462,6 +3534,8 @@ if (not RUNTIME): OPTS=['DIR:panda/src/recorder', 'BUILDING:PANDA'] TargetAdd('p3recorder_composite1.obj', opts=OPTS, input='p3recorder_composite1.cxx') TargetAdd('p3recorder_composite2.obj', opts=OPTS, input='p3recorder_composite2.cxx') + + OPTS=['DIR:panda/src/recorder'] IGATEFILES=GetDirectoryContents('panda/src/recorder', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3recorder.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3recorder.in', opts=['IMOD:panda3d.core', 'ILIB:libp3recorder', 'SRCDIR:panda/src/recorder']) @@ -3481,6 +3555,8 @@ if (RUNTIME or RTDIST): if (not RUNTIME): OPTS=['DIR:panda/src/dxml', 'BUILDING:PANDA', 'TINYXML'] TargetAdd('p3dxml_composite1.obj', opts=OPTS, input='p3dxml_composite1.cxx') + + OPTS=['DIR:panda/src/dxml', 'TINYXML'] IGATEFILES=GetDirectoryContents('panda/src/dxml', ["*.h", "p3dxml_composite1.cxx"]) TargetAdd('libp3dxml.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3dxml.in', opts=['IMOD:panda3d.core', 'ILIB:libp3dxml', 'SRCDIR:panda/src/dxml']) @@ -3500,108 +3576,71 @@ if (not RUNTIME): TargetAdd('libpanda.dll', input='panda_panda.obj') TargetAdd('libpanda.dll', input='p3recorder_composite1.obj') TargetAdd('libpanda.dll', input='p3recorder_composite2.obj') - TargetAdd('libpanda.dll', input='libp3recorder_igate.obj') TargetAdd('libpanda.dll', input='p3pgraphnodes_composite1.obj') TargetAdd('libpanda.dll', input='p3pgraphnodes_composite2.obj') - TargetAdd('libpanda.dll', input='libp3pgraphnodes_igate.obj') TargetAdd('libpanda.dll', input='p3pgraph_nodePath.obj') TargetAdd('libpanda.dll', input='p3pgraph_composite1.obj') TargetAdd('libpanda.dll', input='p3pgraph_composite2.obj') TargetAdd('libpanda.dll', input='p3pgraph_composite3.obj') TargetAdd('libpanda.dll', input='p3pgraph_composite4.obj') - TargetAdd('libpanda.dll', input='libp3pgraph_igate.obj') TargetAdd('libpanda.dll', input='p3cull_composite1.obj') TargetAdd('libpanda.dll', input='p3cull_composite2.obj') TargetAdd('libpanda.dll', input='p3movies_composite1.obj') - TargetAdd('libpanda.dll', input='libp3movies_igate.obj') TargetAdd('libpanda.dll', input='p3grutil_multitexReducer.obj') TargetAdd('libpanda.dll', input='p3grutil_composite1.obj') TargetAdd('libpanda.dll', input='p3grutil_composite2.obj') - TargetAdd('libpanda.dll', input='libp3grutil_igate.obj') TargetAdd('libpanda.dll', input='p3chan_composite1.obj') TargetAdd('libpanda.dll', input='p3chan_composite2.obj') - TargetAdd('libpanda.dll', input='libp3chan_igate.obj') TargetAdd('libpanda.dll', input='p3pstatclient_composite1.obj') TargetAdd('libpanda.dll', input='p3pstatclient_composite2.obj') - TargetAdd('libpanda.dll', input='libp3pstatclient_igate.obj') TargetAdd('libpanda.dll', input='p3char_composite1.obj') TargetAdd('libpanda.dll', input='p3char_composite2.obj') - TargetAdd('libpanda.dll', input='libp3char_igate.obj') TargetAdd('libpanda.dll', input='p3collide_composite1.obj') TargetAdd('libpanda.dll', input='p3collide_composite2.obj') - TargetAdd('libpanda.dll', input='libp3collide_igate.obj') TargetAdd('libpanda.dll', input='p3device_composite1.obj') TargetAdd('libpanda.dll', input='p3device_composite2.obj') - TargetAdd('libpanda.dll', input='libp3device_igate.obj') TargetAdd('libpanda.dll', input='p3dgraph_composite1.obj') TargetAdd('libpanda.dll', input='p3dgraph_composite2.obj') - TargetAdd('libpanda.dll', input='libp3dgraph_igate.obj') TargetAdd('libpanda.dll', input='p3display_composite1.obj') TargetAdd('libpanda.dll', input='p3display_composite2.obj') - TargetAdd('libpanda.dll', input='libp3display_igate.obj') TargetAdd('libpanda.dll', input='p3pipeline_composite1.obj') TargetAdd('libpanda.dll', input='p3pipeline_composite2.obj') TargetAdd('libpanda.dll', input='p3pipeline_contextSwitch.obj') - TargetAdd('libpanda.dll', input='libp3pipeline_igate.obj') TargetAdd('libpanda.dll', input='p3event_composite1.obj') TargetAdd('libpanda.dll', input='p3event_composite2.obj') - TargetAdd('libpanda.dll', input='libp3event_igate.obj') TargetAdd('libpanda.dll', input='p3gobj_composite1.obj') TargetAdd('libpanda.dll', input='p3gobj_composite2.obj') - TargetAdd('libpanda.dll', input='libp3gobj_igate.obj') TargetAdd('libpanda.dll', input='p3gsgbase_composite1.obj') - TargetAdd('libpanda.dll', input='libp3gsgbase_igate.obj') TargetAdd('libpanda.dll', input='p3linmath_composite1.obj') TargetAdd('libpanda.dll', input='p3linmath_composite2.obj') - TargetAdd('libpanda.dll', input='libp3linmath_igate.obj') TargetAdd('libpanda.dll', input='p3mathutil_composite1.obj') TargetAdd('libpanda.dll', input='p3mathutil_composite2.obj') - TargetAdd('libpanda.dll', input='libp3mathutil_igate.obj') TargetAdd('libpanda.dll', input='p3parametrics_composite1.obj') TargetAdd('libpanda.dll', input='p3parametrics_composite2.obj') - TargetAdd('libpanda.dll', input='libp3parametrics_igate.obj') TargetAdd('libpanda.dll', input='p3pnmimagetypes_composite1.obj') TargetAdd('libpanda.dll', input='p3pnmimagetypes_composite2.obj') TargetAdd('libpanda.dll', input='p3pnmimage_composite1.obj') TargetAdd('libpanda.dll', input='p3pnmimage_composite2.obj') - TargetAdd('libpanda.dll', input='libp3pnmimage_igate.obj') TargetAdd('libpanda.dll', input='p3text_composite1.obj') TargetAdd('libpanda.dll', input='p3text_composite2.obj') - TargetAdd('libpanda.dll', input='libp3text_igate.obj') TargetAdd('libpanda.dll', input='p3tform_composite1.obj') TargetAdd('libpanda.dll', input='p3tform_composite2.obj') - TargetAdd('libpanda.dll', input='libp3tform_igate.obj') TargetAdd('libpanda.dll', input='p3putil_composite1.obj') TargetAdd('libpanda.dll', input='p3putil_composite2.obj') - TargetAdd('libpanda.dll', input='libp3putil_igate.obj') TargetAdd('libpanda.dll', input='p3audio_composite1.obj') - TargetAdd('libpanda.dll', input='libp3audio_igate.obj') TargetAdd('libpanda.dll', input='p3pgui_composite1.obj') TargetAdd('libpanda.dll', input='p3pgui_composite2.obj') - TargetAdd('libpanda.dll', input='libp3pgui_igate.obj') TargetAdd('libpanda.dll', input='p3net_composite1.obj') TargetAdd('libpanda.dll', input='p3net_composite2.obj') - TargetAdd('libpanda.dll', input='libp3net_igate.obj') TargetAdd('libpanda.dll', input='p3nativenet_composite1.obj') - TargetAdd('libpanda.dll', input='libp3nativenet_igate.obj') TargetAdd('libpanda.dll', input='p3pandabase_pandabase.obj') TargetAdd('libpanda.dll', input='libpandaexpress.dll') TargetAdd('libpanda.dll', input='p3dxml_composite1.obj') - TargetAdd('libpanda.dll', input='libp3dxml_igate.obj') TargetAdd('libpanda.dll', input='libp3dtoolconfig.dll') TargetAdd('libpanda.dll', input='libp3dtool.dll') - TargetAdd('libpanda.dll', input='p3putil_typedWritable_ext.obj') - TargetAdd('libpanda.dll', input='p3pnmimage_pfmFile_ext.obj') - TargetAdd('libpanda.dll', input='p3gobj_geomVertexArrayData_ext.obj') - TargetAdd('libpanda.dll', input='p3gobj_internalName_ext.obj') - TargetAdd('libpanda.dll', input='p3pgraph_ext_composite.obj') - TargetAdd('libpanda.dll', input='p3display_graphicsStateGuardian_ext.obj') - TargetAdd('libpanda.dll', input='p3display_graphicsWindow_ext.obj') - if PkgSkip("FREETYPE")==0: TargetAdd('libpanda.dll', input="p3pnmtext_composite1.obj") - TargetAdd('libpanda.dll', input="libp3pnmtext_igate.obj") TargetAdd('libpanda.dll', dep='dtool_have_freetype.dat') TargetAdd('libpanda.dll', opts=OPTS) @@ -3644,9 +3683,56 @@ if (not RUNTIME): TargetAdd('core_module.obj', opts=['IMOD:panda3d.core', 'ILIB:core']) + OPTS=['WINSOCK2'] + TargetAdd('core.pyd', input='libp3downloader_igate.obj') + TargetAdd('core.pyd', input='p3express_ext_composite.obj') + TargetAdd('core.pyd', input='libp3express_igate.obj') + + TargetAdd('core.pyd', input='libp3recorder_igate.obj') + TargetAdd('core.pyd', input='libp3pgraphnodes_igate.obj') + TargetAdd('core.pyd', input='libp3pgraph_igate.obj') + TargetAdd('core.pyd', input='libp3movies_igate.obj') + TargetAdd('core.pyd', input='libp3grutil_igate.obj') + TargetAdd('core.pyd', input='libp3chan_igate.obj') + TargetAdd('core.pyd', input='libp3pstatclient_igate.obj') + TargetAdd('core.pyd', input='libp3char_igate.obj') + TargetAdd('core.pyd', input='libp3collide_igate.obj') + TargetAdd('core.pyd', input='libp3device_igate.obj') + TargetAdd('core.pyd', input='libp3dgraph_igate.obj') + TargetAdd('core.pyd', input='libp3display_igate.obj') + TargetAdd('core.pyd', input='libp3pipeline_igate.obj') + TargetAdd('core.pyd', input='libp3event_igate.obj') + TargetAdd('core.pyd', input='libp3gobj_igate.obj') + TargetAdd('core.pyd', input='libp3gsgbase_igate.obj') + TargetAdd('core.pyd', input='libp3linmath_igate.obj') + TargetAdd('core.pyd', input='libp3mathutil_igate.obj') + TargetAdd('core.pyd', input='libp3parametrics_igate.obj') + TargetAdd('core.pyd', input='libp3pnmimage_igate.obj') + TargetAdd('core.pyd', input='libp3text_igate.obj') + TargetAdd('core.pyd', input='libp3tform_igate.obj') + TargetAdd('core.pyd', input='libp3putil_igate.obj') + TargetAdd('core.pyd', input='libp3audio_igate.obj') + TargetAdd('core.pyd', input='libp3pgui_igate.obj') + TargetAdd('core.pyd', input='libp3net_igate.obj') + TargetAdd('core.pyd', input='libp3nativenet_igate.obj') + TargetAdd('core.pyd', input='libp3dxml_igate.obj') + + if PkgSkip("FREETYPE")==0: + TargetAdd('core.pyd', input="libp3pnmtext_igate.obj") + + TargetAdd('core.pyd', input='p3putil_typedWritable_ext.obj') + TargetAdd('core.pyd', input='p3putil_pythonCallbackObject.obj') + TargetAdd('core.pyd', input='p3pnmimage_pfmFile_ext.obj') + TargetAdd('core.pyd', input='p3event_pythonTask.obj') + TargetAdd('core.pyd', input='p3gobj_ext_composite.obj') + TargetAdd('core.pyd', input='p3pgraph_ext_composite.obj') + TargetAdd('core.pyd', input='p3display_graphicsStateGuardian_ext.obj') + TargetAdd('core.pyd', input='p3display_graphicsWindow_ext.obj') + TargetAdd('core.pyd', input='p3display_pythonGraphicsWindowProc.obj') + TargetAdd('core.pyd', input='core_module.obj') TargetAdd('core.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('core.pyd', opts=['PYTHON']) + TargetAdd('core.pyd', opts=OPTS) # # DIRECTORY: panda/src/vision/ @@ -4527,6 +4613,8 @@ if (PkgSkip("DIRECT")==0): TargetAdd('p3dcparser_dcLexer.obj', opts=OPTS, input='dcLexer.lxx') TargetAdd('p3dcparser_composite1.obj', opts=OPTS, input='p3dcparser_composite1.cxx') TargetAdd('p3dcparser_composite2.obj', opts=OPTS, input='p3dcparser_composite2.cxx') + + OPTS=['DIR:direct/src/dcparser', 'WITHINPANDA'] IGATEFILES=GetDirectoryContents('direct/src/dcparser', ["*.h", "*_composite*.cxx"]) if "dcParser.h" in IGATEFILES: IGATEFILES.remove("dcParser.h") if "dcmsgtypes.h" in IGATEFILES: IGATEFILES.remove('dcmsgtypes.h') @@ -4541,6 +4629,8 @@ if (PkgSkip("DIRECT")==0): if (PkgSkip("DIRECT")==0): OPTS=['DIR:direct/src/deadrec', 'BUILDING:DIRECT'] TargetAdd('p3deadrec_composite1.obj', opts=OPTS, input='p3deadrec_composite1.cxx') + + OPTS=['DIR:direct/src/deadrec'] IGATEFILES=GetDirectoryContents('direct/src/deadrec', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3deadrec.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3deadrec.in', opts=['IMOD:panda3d.direct', 'ILIB:libp3deadrec', 'SRCDIR:direct/src/deadrec']) @@ -4555,6 +4645,8 @@ if (PkgSkip("DIRECT")==0): TargetAdd('p3distributed_config_distributed.obj', opts=OPTS, input='config_distributed.cxx') TargetAdd('p3distributed_cConnectionRepository.obj', opts=OPTS, input='cConnectionRepository.cxx') TargetAdd('p3distributed_cDistributedSmoothNodeBase.obj', opts=OPTS, input='cDistributedSmoothNodeBase.cxx') + + OPTS=['DIR:direct/src/distributed', 'WITHINPANDA', 'OPENSSL'] IGATEFILES=GetDirectoryContents('direct/src/distributed', ["*.h", "*.cxx"]) TargetAdd('libp3distributed.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3distributed.in', opts=['IMOD:panda3d.direct', 'ILIB:libp3distributed', 'SRCDIR:direct/src/distributed']) @@ -4567,6 +4659,8 @@ if (PkgSkip("DIRECT")==0): if (PkgSkip("DIRECT")==0): OPTS=['DIR:direct/src/interval', 'BUILDING:DIRECT'] TargetAdd('p3interval_composite1.obj', opts=OPTS, input='p3interval_composite1.cxx') + + OPTS=['DIR:direct/src/interval'] IGATEFILES=GetDirectoryContents('direct/src/interval', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3interval.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3interval.in', opts=['IMOD:panda3d.direct', 'ILIB:libp3interval', 'SRCDIR:direct/src/interval']) @@ -4581,6 +4675,8 @@ if (PkgSkip("DIRECT")==0): TargetAdd('p3showbase_showBase.obj', opts=OPTS, input='showBase.cxx') if GetTarget() == 'darwin': TargetAdd('p3showbase_showBase_assist.obj', opts=OPTS, input='showBase_assist.mm') + + OPTS=['DIR:direct/src/showbase'] IGATEFILES=GetDirectoryContents('direct/src/showbase', ["*.h", "showBase.cxx"]) TargetAdd('libp3showbase.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3showbase.in', opts=['IMOD:panda3d.direct', 'ILIB:libp3showbase', 'SRCDIR:direct/src/showbase']) @@ -4600,19 +4696,14 @@ if (PkgSkip("DIRECT")==0): TargetAdd('libp3direct.dll', input='p3dcparser_composite2.obj') TargetAdd('libp3direct.dll', input='p3dcparser_dcParser.obj') TargetAdd('libp3direct.dll', input='p3dcparser_dcLexer.obj') - TargetAdd('libp3direct.dll', input='libp3dcparser_igate.obj') TargetAdd('libp3direct.dll', input='p3showbase_showBase.obj') if GetTarget() == 'darwin': TargetAdd('libp3direct.dll', input='p3showbase_showBase_assist.obj') - TargetAdd('libp3direct.dll', input='libp3showbase_igate.obj') TargetAdd('libp3direct.dll', input='p3deadrec_composite1.obj') - TargetAdd('libp3direct.dll', input='libp3deadrec_igate.obj') TargetAdd('libp3direct.dll', input='p3interval_composite1.obj') - TargetAdd('libp3direct.dll', input='libp3interval_igate.obj') TargetAdd('libp3direct.dll', input='p3distributed_config_distributed.obj') TargetAdd('libp3direct.dll', input='p3distributed_cConnectionRepository.obj') TargetAdd('libp3direct.dll', input='p3distributed_cDistributedSmoothNodeBase.obj') - TargetAdd('libp3direct.dll', input='libp3distributed_igate.obj') TargetAdd('libp3direct.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3direct.dll', opts=['ADVAPI', 'OPENSSL', 'WINUSER', 'WINGDI']) @@ -4625,6 +4716,12 @@ if (PkgSkip("DIRECT")==0): TargetAdd('direct_module.obj', opts=OPTS) TargetAdd('direct_module.obj', opts=['IMOD:panda3d.direct', 'ILIB:direct']) + TargetAdd('direct.pyd', input='libp3dcparser_igate.obj') + TargetAdd('direct.pyd', input='libp3showbase_igate.obj') + TargetAdd('direct.pyd', input='libp3deadrec_igate.obj') + TargetAdd('direct.pyd', input='libp3interval_igate.obj') + TargetAdd('direct.pyd', input='libp3distributed_igate.obj') + TargetAdd('direct.pyd', input='direct_module.obj') TargetAdd('direct.pyd', input='libp3direct.dll') TargetAdd('direct.pyd', input='core.pyd') @@ -5246,9 +5343,8 @@ if (PkgSkip("PANDATOOL")==0): if (PkgSkip("PANDATOOL")==0): OPTS=['DIR:pandatool/src/flt', 'ZLIB'] - TargetAdd('p3flt_fltVectorRecord.obj', opts=OPTS, input='fltVectorRecord.cxx') TargetAdd('p3flt_composite1.obj', opts=OPTS, input='p3flt_composite1.cxx') - TargetAdd('libp3flt.lib', input=['p3flt_fltVectorRecord.obj', 'p3flt_composite1.obj']) + TargetAdd('libp3flt.lib', input=['p3flt_composite1.obj']) # # DIRECTORY: pandatool/src/fltegg/ diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index 5c774d4a13..f467d73a8b 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -29,7 +29,7 @@ #include "cmath.h" #include "mathNumbers.h" #include "geom.h" -#include "geomTrifans.h" +#include "geomTriangles.h" #include "geomVertexWriter.h" #include "config_mathutil.h" #include "dcast.h" @@ -80,7 +80,7 @@ setup_box(){ // Function: CollisionBox::setup_points // Access: Private // Description: Computes the plane and 2d projection of points that -// make up this side +// make up this side. //////////////////////////////////////////////////////////////////// void CollisionBox:: setup_points(const LPoint3 *begin, const LPoint3 *end, int plane) { @@ -552,7 +552,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PN_stdfloat near_t = 0.0; bool intersect; LPlane plane; - LPlane near_plane; + LPlane near_plane; //Returns the details about the first plane of the box that the //segment intersects. @@ -589,7 +589,6 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } ++j; } - if(!intersect) { //No intersection with ANY of the box's planes has been detected @@ -645,22 +644,50 @@ fill_viz_geom() { PT(GeomVertexData) vdata = new GeomVertexData ("collision", GeomVertexFormat::get_v3(), Geom::UH_static); - GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - - for(int i = 0; i < 6; i++) { - for(int j = 0; j < 4; j++) - vertex.add_data3(get_point(plane_def[i][j])); - PT(GeomTrifans) body = new GeomTrifans(Geom::UH_static); - body->add_consecutive_vertices(i*4, 4); - body->close_primitive(); + vdata->unclean_set_num_rows(8); - PT(Geom) geom = new Geom(vdata); - geom->add_primitive(body); + { + GeomVertexWriter vertex(vdata, InternalName::get_vertex()); + vertex.set_data3(_min[0], _min[1], _min[2]); + vertex.set_data3(_min[0], _max[1], _min[2]); + vertex.set_data3(_max[0], _max[1], _min[2]); + vertex.set_data3(_max[0], _min[1], _min[2]); - _viz_geom->add_geom(geom, get_solid_viz_state()); - _bounds_viz_geom->add_geom(geom, get_solid_bounds_viz_state()); + vertex.set_data3(_min[0], _min[1], _max[2]); + vertex.set_data3(_min[0], _max[1], _max[2]); + vertex.set_data3(_max[0], _max[1], _max[2]); + vertex.set_data3(_max[0], _min[1], _max[2]); } + + PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); + + // Bottom + tris->add_vertices(0, 1, 2); + tris->add_vertices(2, 3, 0); + + // Top + tris->add_vertices(4, 7, 6); + tris->add_vertices(6, 5, 4); + + // Sides + tris->add_vertices(0, 4, 1); + tris->add_vertices(1, 4, 5); + + tris->add_vertices(1, 5, 2); + tris->add_vertices(2, 5, 6); + + tris->add_vertices(2, 6, 3); + tris->add_vertices(3, 6, 7); + + tris->add_vertices(3, 7, 0); + tris->add_vertices(0, 7, 4); + + PT(Geom) geom = new Geom(vdata); + geom->add_primitive(tris); + + _viz_geom->add_geom(geom, get_solid_viz_state()); + _bounds_viz_geom->add_geom(geom, get_solid_bounds_viz_state()); } //////////////////////////////////////////////////////////////////// @@ -675,7 +702,7 @@ fill_viz_geom() { // planes), or false otherwise. //////////////////////////////////////////////////////////////////// bool CollisionBox:: -apply_clip_plane(CollisionBox::Points &new_points, +apply_clip_plane(CollisionBox::Points &new_points, const ClipPlaneAttrib *cpa, const TransformState *net_transform, int plane_no) const { bool all_in = true; @@ -687,9 +714,9 @@ apply_clip_plane(CollisionBox::Points &new_points, NodePath plane_path = cpa->get_on_plane(i); PlaneNode *plane_node = DCAST(PlaneNode, plane_path.node()); if ((plane_node->get_clip_effect() & PlaneNode::CE_collision) != 0) { - CPT(TransformState) new_transform = + CPT(TransformState) new_transform = net_transform->invert_compose(plane_path.get_net_transform()); - + LPlane plane = plane_node->get_plane() * new_transform->get_mat(); if (first_plane) { first_plane = false; diff --git a/panda/src/display/Sources.pp b/panda/src/display/Sources.pp index 98c9e3d24e..26aa3b5187 100644 --- a/panda/src/display/Sources.pp +++ b/panda/src/display/Sources.pp @@ -14,6 +14,7 @@ standardMunger.I standardMunger.h \ config_display.h \ $[if $[HAVE_PYTHON], pythonGraphicsWindowProc.h] \ + $[if $[HAVE_PYTHON], pythonGraphicsWindowProc.cxx] \ callbackGraphicsWindow.I callbackGraphicsWindow.h \ drawableRegion.I drawableRegion.h \ displayRegion.I displayRegion.h \ @@ -54,7 +55,6 @@ #define INCLUDED_SOURCES \ standardMunger.cxx \ config_display.cxx \ - $[if $[HAVE_PYTHON], pythonGraphicsWindowProc.cxx] \ callbackGraphicsWindow.cxx \ drawableRegion.cxx \ displayRegion.cxx \ diff --git a/panda/src/display/callbackGraphicsWindow.h b/panda/src/display/callbackGraphicsWindow.h index 484e87754f..7af1ddc33f 100644 --- a/panda/src/display/callbackGraphicsWindow.h +++ b/panda/src/display/callbackGraphicsWindow.h @@ -40,7 +40,7 @@ protected: PUBLISHED: virtual ~CallbackGraphicsWindow(); - class WindowCallbackData : public CallbackData { + class EXPCL_PANDA_DISPLAY WindowCallbackData : public CallbackData { public: INLINE WindowCallbackData(CallbackGraphicsWindow *window); @@ -68,8 +68,7 @@ PUBLISHED: static TypeHandle _type_handle; }; - - class EventsCallbackData : public WindowCallbackData { + class EXPCL_PANDA_DISPLAY EventsCallbackData : public WindowCallbackData { public: INLINE EventsCallbackData(CallbackGraphicsWindow *window); @@ -94,7 +93,7 @@ PUBLISHED: static TypeHandle _type_handle; }; - class PropertiesCallbackData : public WindowCallbackData { + class EXPCL_PANDA_DISPLAY PropertiesCallbackData : public WindowCallbackData { public: INLINE PropertiesCallbackData(CallbackGraphicsWindow *window, WindowProperties &properties); @@ -131,7 +130,7 @@ PUBLISHED: RCT_end_flip, }; - class RenderCallbackData : public WindowCallbackData { + class EXPCL_PANDA_DISPLAY RenderCallbackData : public WindowCallbackData { public: INLINE RenderCallbackData(CallbackGraphicsWindow *window, RenderCallbackType callback_type, FrameMode frame_mode); diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index f6a6189737..8e2fc71e4e 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -636,7 +636,7 @@ void DisplayRegion:: compute_pixels() { if (_window != (GraphicsOutput *)NULL) { CDWriter cdata(_cycler, false); - for (int i = 0; i < cdata->_regions.size(); ++i) { + for (size_t i = 0; i < cdata->_regions.size(); ++i) { do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), cdata); } @@ -658,7 +658,7 @@ compute_pixels_all_stages() { if (_window != (GraphicsOutput *)NULL) { OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); - for (int i = 0; i < cdata->_regions.size(); ++i) { + for (size_t i = 0; i < cdata->_regions.size(); ++i) { do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), cdata); } @@ -677,7 +677,7 @@ compute_pixels_all_stages() { void DisplayRegion:: compute_pixels(int x_size, int y_size) { CDWriter cdata(_cycler, false); - for (int i = 0; i < cdata->_regions.size(); ++i) { + for (size_t i = 0; i < cdata->_regions.size(); ++i) { do_compute_pixels(i, x_size, y_size, cdata); } } @@ -695,7 +695,7 @@ void DisplayRegion:: compute_pixels_all_stages(int x_size, int y_size) { OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); - for (int i = 0; i < cdata->_regions.size(); ++i) { + for (size_t i = 0; i < cdata->_regions.size(); ++i) { do_compute_pixels(i, x_size, y_size, cdata); } } diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index c6c80db277..6dda4cb69a 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -936,13 +936,13 @@ fetch_specified_value(Shader::ShaderMatSpec &spec, int altered) { LVecBase3 v; if (altered & spec._dep[0]) { - const LMatrix4 *t = fetch_specified_part(spec._part[0], spec._arg[0], spec._cache[0]); + const LMatrix4 *t = fetch_specified_part(spec._part[0], spec._arg[0], spec._cache[0], spec._index); if (t != &spec._cache[0]) { spec._cache[0] = *t; } } if (altered & spec._dep[1]) { - const LMatrix4 *t = fetch_specified_part(spec._part[1], spec._arg[1], spec._cache[1]); + const LMatrix4 *t = fetch_specified_part(spec._part[1], spec._arg[1], spec._cache[1], spec._index); if (t != &spec._cache[1]) { spec._cache[1] = *t; } @@ -987,8 +987,9 @@ fetch_specified_value(Shader::ShaderMatSpec &spec, int altered) { // Description: See fetch_specified_value //////////////////////////////////////////////////////////////////// const LMatrix4 *GraphicsStateGuardian:: -fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4 &t) { - switch(part) { +fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, + LMatrix4 &t, int index) { + switch (part) { case Shader::SMO_identity: { return &LMatrix4::ident_mat(); } @@ -1223,6 +1224,25 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4 & t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,p[0],p[1],p[2],p[3]); return &t; } + case Shader::SMO_apiview_clipplane_i: { + const ClipPlaneAttrib *cpa = DCAST(ClipPlaneAttrib, _target_rs->get_attrib_def(ClipPlaneAttrib::get_class_slot())); + if (index >= cpa->get_num_on_planes()) { + return &LMatrix4::zeros_mat(); + } + + const NodePath &plane = cpa->get_on_plane(index); + nassertr(!plane.is_empty(), &LMatrix4::zeros_mat()); + const PlaneNode *plane_node; + DCAST_INTO_R(plane_node, plane.node(), &LMatrix4::zeros_mat()); + + CPT(TransformState) transform = + get_scene()->get_cs_world_transform()->compose( + plane.get_transform(_scene_setup->get_scene_root().get_parent())); + + LPlane xformed_plane = plane_node->get_plane() * transform->get_mat(); + t.set_row(3, xformed_plane); + return &t; + } case Shader::SMO_mat_constant_x: { return &_target_shader->get_shader_input_matrix(name, t); } @@ -1377,6 +1397,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4 & static const CPT_InternalName IN_diffuse("diffuse"); static const CPT_InternalName IN_specular("specular"); static const CPT_InternalName IN_position("position"); + static const CPT_InternalName IN_halfVector("halfVector"); static const CPT_InternalName IN_spotDirection("spotDirection"); static const CPT_InternalName IN_spotCutoff("spotCutoff"); static const CPT_InternalName IN_spotCosCutoff("spotCosCutoff"); @@ -1435,6 +1456,39 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4 & t = LMatrix4::translate_mat(pos); return &t; } + + } else if (attrib == IN_halfVector) { + if (np.node()->is_of_type(DirectionalLight::get_class_type())) { + DirectionalLight *light; + DCAST_INTO_R(light, np.node(), &LMatrix4::ident_mat()); + + CPT(TransformState) transform = np.get_transform(_scene_setup->get_scene_root().get_parent()); + LVector3 dir = -(light->get_direction() * transform->get_mat()); + dir *= get_scene()->get_cs_world_transform()->get_mat(); + dir.normalize(); + dir += LVector3(0, 0, 1); + dir.normalize(); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,dir[0],dir[1],dir[2],1); + return &t; + } else { + LightLensNode *light; + DCAST_INTO_R(light, np.node(), &LMatrix4::ident_mat()); + Lens *lens = light->get_lens(); + nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + + CPT(TransformState) transform = + get_scene()->get_cs_world_transform()->compose( + np.get_transform(_scene_setup->get_scene_root().get_parent())); + + const LMatrix4 &light_mat = transform->get_mat(); + LPoint3 pos = lens->get_nodal_point() * light_mat; + pos.normalize(); + pos += LVector3(0, 0, 1); + pos.normalize(); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,pos[0],pos[1],pos[2],1); + return &t; + } + } else if (attrib == IN_spotDirection) { LightLensNode *light; DCAST_INTO_R(light, np.node(), &LMatrix4::ident_mat()); diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 31282aa820..b546a61945 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -255,7 +255,8 @@ public: virtual void clear(DrawableRegion *clearable); const LMatrix4 *fetch_specified_value(Shader::ShaderMatSpec &spec, int altered); - const LMatrix4 *fetch_specified_part(Shader::ShaderMatInput input, InternalName *name, LMatrix4 &t); + const LMatrix4 *fetch_specified_part(Shader::ShaderMatInput input, InternalName *name, + LMatrix4 &t, int index); const Shader::ShaderPtrData *fetch_ptr_parameter(const Shader::ShaderPtrSpec& spec); virtual void prepare_display_region(DisplayRegionPipelineReader *dr); diff --git a/panda/src/display/graphicsStateGuardian_ext.cxx b/panda/src/display/graphicsStateGuardian_ext.cxx index 2f1c2d916e..53407f500f 100644 --- a/panda/src/display/graphicsStateGuardian_ext.cxx +++ b/panda/src/display/graphicsStateGuardian_ext.cxx @@ -18,7 +18,7 @@ #ifdef HAVE_PYTHON #ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject Dtool_Texture; +extern struct Dtool_PyTypedObject Dtool_Texture; #endif static bool traverse_callback(TextureContext *tc, void *data) { diff --git a/panda/src/display/graphicsWindowProc.h b/panda/src/display/graphicsWindowProc.h index 88df028bfd..f8b8551d83 100644 --- a/panda/src/display/graphicsWindowProc.h +++ b/panda/src/display/graphicsWindowProc.h @@ -12,7 +12,6 @@ // //////////////////////////////////////////////////////////////////// - #ifndef GRAPHICSWINDOWPROC_H #define GRAPHICSWINDOWPROC_H @@ -25,18 +24,21 @@ #include #endif +class GraphicsWindow; + //////////////////////////////////////////////////////////////////// // Class : GraphicsWindowProc // Description : Defines an interface for storing platform-specific // window processor methods. //////////////////////////////////////////////////////////////////// -class GraphicsWindowProc{ +class EXPCL_PANDA_DISPLAY GraphicsWindowProc { public: GraphicsWindowProc(); #if defined(__WIN32__) || defined(_WIN32) - virtual LONG wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); + virtual LONG wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, + UINT msg, WPARAM wparam, LPARAM lparam); #endif //purely virtual class }; -#endif //GRAPHICSWINDOWPROC_H +#endif // GRAPHICSWINDOWPROC_H diff --git a/panda/src/display/p3display_composite2.cxx b/panda/src/display/p3display_composite2.cxx index 4d613bb588..66abd308d0 100644 --- a/panda/src/display/p3display_composite2.cxx +++ b/panda/src/display/p3display_composite2.cxx @@ -4,9 +4,6 @@ #include "graphicsWindow.cxx" #include "graphicsWindowProc.cxx" #include "graphicsWindowProcCallbackData.cxx" -#ifdef HAVE_PYTHON -#include "pythonGraphicsWindowProc.cxx" -#endif #include "graphicsWindowInputDevice.cxx" #include "lru.cxx" #include "nativeWindowHandle.cxx" diff --git a/panda/src/display/pythonGraphicsWindowProc.cxx b/panda/src/display/pythonGraphicsWindowProc.cxx index 0037641a50..4e829d5c59 100644 --- a/panda/src/display/pythonGraphicsWindowProc.cxx +++ b/panda/src/display/pythonGraphicsWindowProc.cxx @@ -15,6 +15,8 @@ #include "pythonGraphicsWindowProc.h" #include "graphicsWindowProcCallbackData.h" +#ifdef HAVE_PYTHON + TypeHandle PythonGraphicsWindowProc::_type_handle; //////////////////////////////////////////////////////////////////// @@ -72,3 +74,5 @@ PyObject* PythonGraphicsWindowProc:: get_name(){ return _name; } + +#endif // HAVE_PYTHON diff --git a/panda/src/display/pythonGraphicsWindowProc.h b/panda/src/display/pythonGraphicsWindowProc.h index 6ce1c7c5be..5160ca6372 100644 --- a/panda/src/display/pythonGraphicsWindowProc.h +++ b/panda/src/display/pythonGraphicsWindowProc.h @@ -19,25 +19,29 @@ #include "graphicsWindowProc.h" #include "pythonCallbackObject.h" +#ifdef HAVE_PYTHON + //////////////////////////////////////////////////////////////////// // Class : PythonGraphicsWindowProc // Description : Extends GraphicsWindowProc to provde callback functionality // to a python program. //////////////////////////////////////////////////////////////////// -class PythonGraphicsWindowProc: public GraphicsWindowProc, public PythonCallbackObject{ +class PythonGraphicsWindowProc: public GraphicsWindowProc, + public PythonCallbackObject { public: PythonGraphicsWindowProc(PyObject *function, PyObject* name); virtual ~PythonGraphicsWindowProc(); ALLOC_DELETED_CHAIN(PythonGraphicsWindowProc); #ifdef WIN32 - virtual LONG wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); + virtual LONG wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, + UINT msg, WPARAM wparam, LPARAM lparam); #endif - PyObject* get_name(); + PyObject *get_name(); private: - PyObject* _name; + PyObject *_name; public: static TypeHandle get_class_type() { @@ -57,4 +61,6 @@ private: static TypeHandle _type_handle; }; -#endif //PYTHONGRAPHICSWINDOWPROC_H +#endif // HAVE_PYTHON + +#endif // PYTHONGRAPHICSWINDOWPROC_H diff --git a/panda/src/downloader/httpAuthorization.h b/panda/src/downloader/httpAuthorization.h index 95461b0771..dd27c23c95 100644 --- a/panda/src/downloader/httpAuthorization.h +++ b/panda/src/downloader/httpAuthorization.h @@ -35,12 +35,8 @@ class URLSpec; // authorization requests in the past, which can // possibly be re-used for future requests to the same // server. -// -// This class does not need to be exported from the DLL -// because it has no public interface; it is simply a -// helper class for HTTPChannel. //////////////////////////////////////////////////////////////////// -class HTTPAuthorization : public ReferenceCount { +class EXPCL_PANDAEXPRESS HTTPAuthorization : public ReferenceCount { public: typedef pmap Tokens; typedef pmap AuthenticationSchemes; diff --git a/panda/src/dxgsg9/dxgsg9base.h b/panda/src/dxgsg9/dxgsg9base.h index a31730b47e..9c00e41816 100755 --- a/panda/src/dxgsg9/dxgsg9base.h +++ b/panda/src/dxgsg9/dxgsg9base.h @@ -19,7 +19,9 @@ #include "graphicsWindow.h" #include "pmap.h" -#define WIN32_LEAN_AND_MEAN // get rid of mfc win32 hdr stuff +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 // get rid of mfc win32 hdr stuff +#endif #ifndef STRICT // enable strict type checking in windows.h, see msdn #define STRICT diff --git a/panda/src/dxml/config_dxml.h b/panda/src/dxml/config_dxml.h index 5e78df63a6..8a08d45ad4 100755 --- a/panda/src/dxml/config_dxml.h +++ b/panda/src/dxml/config_dxml.h @@ -36,10 +36,10 @@ extern EXPCL_PANDA void init_libdxml(); class TiXmlDocument; class TiXmlNode; BEGIN_PUBLISH -TiXmlDocument *read_xml_stream(istream &in); -void write_xml_stream(ostream &out, TiXmlDocument *doc); -void print_xml(TiXmlNode *xnode); -void print_xml_to_file(const Filename &filename, TiXmlNode *xnode); +EXPCL_PANDA TiXmlDocument *read_xml_stream(istream &in); +EXPCL_PANDA void write_xml_stream(ostream &out, TiXmlDocument *doc); +EXPCL_PANDA void print_xml(TiXmlNode *xnode); +EXPCL_PANDA void print_xml_to_file(const Filename &filename, TiXmlNode *xnode); END_PUBLISH #endif diff --git a/panda/src/dxml/tinyxml.h b/panda/src/dxml/tinyxml.h index d80c5c4e37..562a4efc84 100644 --- a/panda/src/dxml/tinyxml.h +++ b/panda/src/dxml/tinyxml.h @@ -96,7 +96,7 @@ const int TIXML_PATCH_VERSION = 1; /* Internal structure for tracking location of items in the XML file. */ -struct TiXmlCursor +struct EXPCL_PANDA TiXmlCursor { TiXmlCursor() { Clear(); } void Clear() { row = col = -1; } @@ -125,7 +125,7 @@ struct TiXmlCursor @sa TiXmlNode::Accept() */ -class TiXmlVisitor +class EXPCL_PANDA TiXmlVisitor { public: virtual ~TiXmlVisitor() {} @@ -191,7 +191,7 @@ const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; A Decleration contains: Attributes (not on tree) @endverbatim */ -class TiXmlBase +class EXPCL_PANDA TiXmlBase { friend class TiXmlNode; friend class TiXmlElement; @@ -420,7 +420,7 @@ private: in a document, or stand on its own. The type of a TiXmlNode can be queried, and it can be cast to its more defined type. */ -class TiXmlNode : public TiXmlBase +class EXPCL_PANDA TiXmlNode : public TiXmlBase { friend class TiXmlDocument; friend class TiXmlElement; @@ -776,7 +776,7 @@ private: part of the tinyXML document object model. There are other suggested ways to look at this problem. */ -class TiXmlAttribute : public TiXmlBase +class EXPCL_PANDA TiXmlAttribute : public TiXmlBase { friend class TiXmlAttributeSet; @@ -900,7 +900,7 @@ private: - I like circular lists - it demonstrates some independence from the (typical) doubly linked list. */ -class TiXmlAttributeSet +class EXPCL_PANDA TiXmlAttributeSet { public: TiXmlAttributeSet(); @@ -937,7 +937,7 @@ private: and can contain other elements, text, comments, and unknowns. Elements also contain an arbitrary number of attributes. */ -class TiXmlElement : public TiXmlNode +class EXPCL_PANDA TiXmlElement : public TiXmlNode { public: /// Construct an element. @@ -1152,7 +1152,7 @@ private: /** An XML comment. */ -class TiXmlComment : public TiXmlNode +class EXPCL_PANDA TiXmlComment : public TiXmlNode { public: /// Constructs an empty comment. @@ -1202,7 +1202,7 @@ private: you generally want to leave it alone, but you can change the output mode with SetCDATA() and query it with CDATA(). */ -class TiXmlText : public TiXmlNode +class EXPCL_PANDA TiXmlText : public TiXmlNode { friend class TiXmlElement; public: @@ -1275,7 +1275,7 @@ private: handled as special cases, not generic attributes, simply because there can only be at most 3 and they are always the same. */ -class TiXmlDeclaration : public TiXmlNode +class EXPCL_PANDA TiXmlDeclaration : public TiXmlNode { public: /// Construct an empty declaration. @@ -1344,7 +1344,7 @@ private: DTD tags get thrown into TiXmlUnknowns. */ -class TiXmlUnknown : public TiXmlNode +class EXPCL_PANDA TiXmlUnknown : public TiXmlNode { public: TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {} @@ -1383,7 +1383,7 @@ private: XML pieces. It can be saved, loaded, and printed to the screen. The 'value' of a document node is the xml file name. */ -class TiXmlDocument : public TiXmlNode +class EXPCL_PANDA TiXmlDocument : public TiXmlNode { public: /// Create an empty document, that has no name. @@ -1628,7 +1628,7 @@ private: } @endverbatim */ -class TiXmlHandle +class EXPCL_PANDA TiXmlHandle { public: /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. @@ -1727,7 +1727,7 @@ private: fprintf( stdout, "%s", printer.CStr() ); @endverbatim */ -class TiXmlPrinter : public TiXmlVisitor +class EXPCL_PANDA TiXmlPrinter : public TiXmlVisitor { public: TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), diff --git a/panda/src/egg/eggGroupNode_ext.cxx b/panda/src/egg/eggGroupNode_ext.cxx index e554bb243c..92b343b972 100644 --- a/panda/src/egg/eggGroupNode_ext.cxx +++ b/panda/src/egg/eggGroupNode_ext.cxx @@ -17,7 +17,7 @@ #ifdef HAVE_PYTHON #ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject Dtool_EggNode; +extern struct Dtool_PyTypedObject Dtool_EggNode; #endif //////////////////////////////////////////////////////////////////// @@ -37,7 +37,7 @@ get_children() const { } // Fill in the list. - int i = 0; + size_t i = 0; for (it = _this->begin(); it != _this->end() && i < len; ++it) { EggNode *node = *it; node->ref(); diff --git a/panda/src/egg/eggVertex.cxx b/panda/src/egg/eggVertex.cxx index 774c66ade8..d0d82502d3 100644 --- a/panda/src/egg/eggVertex.cxx +++ b/panda/src/egg/eggVertex.cxx @@ -398,6 +398,125 @@ clear_aux(const string &name) { _aux_map.erase(name); } +//////////////////////////////////////////////////////////////////// +// Function: EggVertex::make_average +// Access: Published, Static +// Description: Creates a new vertex that lies in between the two +// given vertices. The attributes for the UV sets +// they have in common are averaged. +// +// Both vertices need to be either in no pool, or in +// the same pool. In the latter case, the new vertex +// will be placed in that pool. +/////////////////////////////////////////////////////////////////// +PT(EggVertex) EggVertex:: +make_average(const EggVertex *first, const EggVertex *second) { + PT(EggVertexPool) pool = first->get_pool(); + nassertr(pool == second->get_pool(), NULL); + + // If both vertices are in a pool, the new vertex will be part of + // the pool as well. + PT(EggVertex) middle; + if (pool == NULL) { + middle = new EggVertex; + } else { + middle = pool->make_new_vertex(); + } + + middle->set_pos4((first->get_pos4() + second->get_pos4()) / 2); + + if (first->has_normal() && second->has_normal()) { + LNormald normal = (first->get_normal() + second->get_normal()) / 2; + normal.normalize(); + middle->set_normal(normal); + } + if (first->has_color() && second->has_color()) { + middle->set_color((first->get_color() + second->get_color()) / 2); + } + + // Average out the EggVertexUV objects, but only for the UV sets + // that they have in common. + const_uv_iterator it; + for (it = first->uv_begin(); it != first->uv_end(); ++it) { + const EggVertexUV *first_uv = it->second; + const EggVertexUV *second_uv = second->get_uv_obj(it->first); + + if (first_uv != NULL && second_uv != NULL) { + middle->set_uv_obj(EggVertexUV::make_average(first_uv, second_uv)); + } + } + + // Same for EggVertexAux. + const_aux_iterator ai; + for (ai = first->aux_begin(); ai != first->aux_end(); ++ai) { + const EggVertexAux *first_aux = ai->second; + const EggVertexAux *second_aux = second->get_aux_obj(ai->first); + + if (first_aux != NULL && second_aux != NULL) { + middle->set_aux_obj(EggVertexAux::make_average(first_aux, second_aux)); + } + } + + // Now process the morph targets. + EggMorphVertexList::const_iterator vi, vi2; + for (vi = first->_dxyzs.begin(); vi != first->_dxyzs.end(); ++vi) { + for (vi2 = second->_dxyzs.begin(); vi2 != second->_dxyzs.end(); ++vi2) { + if (vi->get_name() == vi2->get_name()) { + middle->_dxyzs.insert(EggMorphVertex(vi->get_name(), + (vi->get_offset() + vi2->get_offset()) / 2)); + break; + } + } + } + + EggMorphNormalList::const_iterator ni, ni2; + for (ni = first->_dxyzs.begin(); ni != first->_dxyzs.end(); ++ni) { + for (ni2 = second->_dxyzs.begin(); ni2 != second->_dxyzs.end(); ++ni2) { + if (ni->get_name() == ni2->get_name()) { + middle->_dnormals.insert(EggMorphNormal(ni->get_name(), + (ni->get_offset() + ni2->get_offset()) / 2)); + break; + } + } + } + + EggMorphColorList::const_iterator ci, ci2; + for (ci = first->_drgbas.begin(); ci != first->_drgbas.end(); ++ci) { + for (ci2 = second->_drgbas.begin(); ci2 != second->_drgbas.end(); ++ci2) { + if (ci->get_name() == ci2->get_name()) { + middle->_drgbas.insert(EggMorphColor(ci->get_name(), + (ci->get_offset() + ci2->get_offset()) / 2)); + break; + } + } + } + + // Now merge the vertex memberships. + GroupRef::iterator gi; + for (gi = first->_gref.begin(); gi != first->_gref.end(); ++gi) { + EggGroup *group = *gi; + if (second->_gref.count(group)) { + group->set_vertex_membership(middle, + (group->get_vertex_membership(first) + + group->get_vertex_membership(second)) / 2.); + } else { + // Hmm, unfortunate, only one of the vertices is member of this + // group, so we can't make an average. We'll have to assign the + // only group membership we have. + group->set_vertex_membership(middle, group->get_vertex_membership(first)); + } + } + // Also assign memberships to the grefs in the second vertex that + // aren't part of the first vertex. + for (gi = second->_gref.begin(); gi != second->_gref.end(); ++gi) { + EggGroup *group = *gi; + if (second->_gref.count(group) == 0) { + group->set_vertex_membership(middle, group->get_vertex_membership(second)); + } + } + + return middle; +} /////////////////////////////////////////////////////////////////// // Class : GroupRefEntry diff --git a/panda/src/egg/eggVertex.h b/panda/src/egg/eggVertex.h index 88c434c997..e56036fec4 100644 --- a/panda/src/egg/eggVertex.h +++ b/panda/src/egg/eggVertex.h @@ -109,6 +109,9 @@ PUBLISHED: void set_aux_obj(EggVertexAux *vertex_aux); void clear_aux(const string &name); + static PT(EggVertex) make_average(const EggVertex *first, + const EggVertex *second); + public: INLINE const_uv_iterator uv_begin() const; INLINE const_uv_iterator uv_end() const; diff --git a/panda/src/egg/eggVertexAux.cxx b/panda/src/egg/eggVertexAux.cxx index 15d5e748d7..9c6d91cc1b 100644 --- a/panda/src/egg/eggVertexAux.cxx +++ b/panda/src/egg/eggVertexAux.cxx @@ -22,7 +22,7 @@ TypeHandle EggVertexAux::_type_handle; //////////////////////////////////////////////////////////////////// // Function: EggVertexAux::Constructor // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// EggVertexAux:: EggVertexAux(const string &name, const LVecBase4d &aux) : @@ -34,7 +34,7 @@ EggVertexAux(const string &name, const LVecBase4d &aux) : //////////////////////////////////////////////////////////////////// // Function: EggVertexAux::Copy Constructor // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// EggVertexAux:: EggVertexAux(const EggVertexAux ©) : @@ -46,7 +46,7 @@ EggVertexAux(const EggVertexAux ©) : //////////////////////////////////////////////////////////////////// // Function: EggVertexAux::Copy Assignment Operator // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// EggVertexAux &EggVertexAux:: operator = (const EggVertexAux ©) { @@ -59,16 +59,31 @@ operator = (const EggVertexAux ©) { //////////////////////////////////////////////////////////////////// // Function: EggVertexAux::Destructor // Access: Published, Virtual -// Description: +// Description: //////////////////////////////////////////////////////////////////// EggVertexAux:: ~EggVertexAux() { } +//////////////////////////////////////////////////////////////////// +// Function: EggVertexAux::make_average +// Access: Published, Static +// Description: Creates a new EggVertexAux that contains the +// averaged values of the two given objects. It is +// an error if they don't have the same name. +/////////////////////////////////////////////////////////////////// +PT(EggVertexAux) EggVertexAux:: +make_average(const EggVertexAux *first, const EggVertexAux *second) { + nassertr(first->get_name() == second->get_name(), NULL); + + LVecBase4d aux = (first->_aux + second->_aux) / 2; + return new EggVertexAux(first->get_name(), aux); +} + //////////////////////////////////////////////////////////////////// // Function: EggVertexAux::write // Access: Public -// Description: +// Description: //////////////////////////////////////////////////////////////////// void EggVertexAux:: write(ostream &out, int indent_level) const { diff --git a/panda/src/egg/eggVertexAux.h b/panda/src/egg/eggVertexAux.h index 082795c86b..7d3aac7483 100644 --- a/panda/src/egg/eggVertexAux.h +++ b/panda/src/egg/eggVertexAux.h @@ -42,6 +42,9 @@ PUBLISHED: INLINE const LVecBase4d &get_aux() const; INLINE void set_aux(const LVecBase4d &aux); + static PT(EggVertexAux) make_average(const EggVertexAux *first, + const EggVertexAux *second); + void write(ostream &out, int indent_level) const; int compare_to(const EggVertexAux &other) const; diff --git a/panda/src/egg/eggVertexUV.cxx b/panda/src/egg/eggVertexUV.cxx index 387ba33f13..cb0a6961cc 100755 --- a/panda/src/egg/eggVertexUV.cxx +++ b/panda/src/egg/eggVertexUV.cxx @@ -22,7 +22,7 @@ TypeHandle EggVertexUV::_type_handle; //////////////////////////////////////////////////////////////////// // Function: EggVertexUV::Constructor // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// EggVertexUV:: EggVertexUV(const string &name, const LTexCoordd &uv) : @@ -38,7 +38,7 @@ EggVertexUV(const string &name, const LTexCoordd &uv) : //////////////////////////////////////////////////////////////////// // Function: EggVertexUV::Constructor // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// EggVertexUV:: EggVertexUV(const string &name, const LTexCoord3d &uvw) : @@ -54,7 +54,7 @@ EggVertexUV(const string &name, const LTexCoord3d &uvw) : //////////////////////////////////////////////////////////////////// // Function: EggVertexUV::Copy Constructor // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// EggVertexUV:: EggVertexUV(const EggVertexUV ©) : @@ -70,7 +70,7 @@ EggVertexUV(const EggVertexUV ©) : //////////////////////////////////////////////////////////////////// // Function: EggVertexUV::Copy Assignment Operator // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// EggVertexUV &EggVertexUV:: operator = (const EggVertexUV ©) { @@ -87,12 +87,37 @@ operator = (const EggVertexUV ©) { //////////////////////////////////////////////////////////////////// // Function: EggVertexUV::Destructor // Access: Published, Virtual -// Description: +// Description: //////////////////////////////////////////////////////////////////// EggVertexUV:: ~EggVertexUV() { } +//////////////////////////////////////////////////////////////////// +// Function: EggVertexUV::make_average +// Access: Published, Static +// Description: Creates a new EggVertexUV that contains the +// averaged values of the two given objects. It is +// an error if they don't have the same name. +/////////////////////////////////////////////////////////////////// +PT(EggVertexUV) EggVertexUV:: +make_average(const EggVertexUV *first, const EggVertexUV *second) { + nassertr(first->get_name() == second->get_name(), NULL); + int flags = first->_flags & second->_flags; + + LTexCoord3d uvw = (first->_uvw + second->_uvw) / 2; + + PT(EggVertexUV) new_obj = new EggVertexUV(first->get_name(), uvw); + new_obj->_flags = flags; + new_obj->_tangent = (first->_tangent + second->_tangent) / 2; + new_obj->_binormal = (first->_binormal + second->_binormal) / 2; + + // Normalize because we're polite. + new_obj->_tangent.normalize(); + new_obj->_binormal.normalize(); + return new_obj; +} + //////////////////////////////////////////////////////////////////// // Function: EggVertexUV::transform // Access: Published, Virtual @@ -115,7 +140,7 @@ transform(const LMatrix4d &mat) { //////////////////////////////////////////////////////////////////// // Function: EggVertexUV::write // Access: Public -// Description: +// Description: //////////////////////////////////////////////////////////////////// void EggVertexUV:: write(ostream &out, int indent_level) const { diff --git a/panda/src/egg/eggVertexUV.h b/panda/src/egg/eggVertexUV.h index ddb6cc3576..d250e9f58e 100755 --- a/panda/src/egg/eggVertexUV.h +++ b/panda/src/egg/eggVertexUV.h @@ -57,6 +57,9 @@ PUBLISHED: INLINE void set_binormal(const LNormald &binormal); INLINE void clear_binormal(); + static PT(EggVertexUV) make_average(const EggVertexUV *first, + const EggVertexUV *second); + void transform(const LMatrix4d &mat); void write(ostream &out, int indent_level) const; diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index a88792cfb2..8cafc8dced 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -2855,9 +2855,8 @@ make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, // This box is used by make_collision_box. //////////////////////////////////////////////////////////////////// bool EggLoader:: -make_box(EggGroup *egg_group, EggGroup::CollideFlags flags, - LPoint3 &min_p, LPoint3 &max_p, LColor &color) { - bool success = false; +make_box(EggGroup *egg_group, EggGroup::CollideFlags flags, + LPoint3 &min_p, LPoint3 &max_p, LColor &color) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); if (geom_group != (EggGroup *)NULL) { // Collect all of the vertices. @@ -2875,36 +2874,38 @@ make_box(EggGroup *egg_group, EggGroup::CollideFlags flags, } // Now find the min/max points - int num_vertices = 0; - bool first = true; pset::const_iterator vi; - for (vi = vertices.begin(); vi != vertices.end(); ++vi) { - EggVertex *vtx = (*vi); - LVertex pos = LCAST(PN_stdfloat, vtx->get_pos3()); + vi = vertices.begin(); - if (first) { - min_p.set(pos[0], pos[1], pos[2]); - max_p.set(pos[0], pos[1], pos[2]); - first = false; - } else { - min_p.set(min(min_p[0], pos[0]), - min(min_p[1], pos[1]), - min(min_p[2], pos[2])); - max_p.set(max(max_p[0], pos[0]), - max(max_p[1], pos[1]), - max(max_p[2], pos[2])); - } - num_vertices++; + if (vi == vertices.end()) { + // No vertices, no bounding box. + min_p.set(0, 0, 0); + max_p.set(0, 0, 0); + return false; } - if (num_vertices > 1) { - vi = vertices.begin(); - EggVertex *clr_vtx = (*vi); - color = clr_vtx->get_color(); - success = true; + EggVertex *vertex = (*vi); + LVertexd min_pd = vertex->get_pos3(); + LVertexd max_pd = min_pd; + color = vertex->get_color(); + + for (++vi; vi != vertices.end(); ++vi) { + vertex = (*vi); + const LVertexd &pos = vertex->get_pos3(); + min_pd.set(min(min_pd[0], pos[0]), + min(min_pd[1], pos[1]), + min(min_pd[2], pos[2])); + max_pd.set(max(max_pd[0], pos[0]), + max(max_pd[1], pos[1]), + max(max_pd[2], pos[2])); } + + LMatrix4d mat = egg_group->get_vertex_to_node(); + min_p = LCAST(PN_stdfloat, min_pd * mat); + max_p = LCAST(PN_stdfloat, max_pd * mat); + return (min_pd != max_pd); } - return success; + return false; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/event/Sources.pp b/panda/src/event/Sources.pp index bd3e322d5d..22bf575414 100644 --- a/panda/src/event/Sources.pp +++ b/panda/src/event/Sources.pp @@ -20,7 +20,7 @@ genericAsyncTask.h genericAsyncTask.I \ pointerEvent.I pointerEvent.h \ pointerEventList.I pointerEventList.h \ - pythonTask.h pythonTask.I \ + pythonTask.h pythonTask.I pythonTask.cxx \ event.I event.h eventHandler.h eventHandler.I \ eventParameter.I eventParameter.h \ eventQueue.I eventQueue.h eventReceiver.h \ @@ -38,7 +38,6 @@ genericAsyncTask.cxx \ pointerEvent.cxx \ pointerEventList.cxx \ - pythonTask.cxx \ config_event.cxx event.cxx eventHandler.cxx \ eventParameter.cxx eventQueue.cxx eventReceiver.cxx \ pt_Event.cxx diff --git a/panda/src/event/config_event.cxx b/panda/src/event/config_event.cxx index 1ceaf7572a..aee490825a 100644 --- a/panda/src/event/config_event.cxx +++ b/panda/src/event/config_event.cxx @@ -24,7 +24,6 @@ #include "eventParameter.h" #include "genericAsyncTask.h" #include "pointerEventList.h" -#include "pythonTask.h" #include "dconfig.h" @@ -45,9 +44,6 @@ ConfigureFn(config_event) { EventStoreInt::init_type("EventStoreInt"); EventStoreDouble::init_type("EventStoreDouble"); GenericAsyncTask::init_type(); -#ifdef HAVE_PYTHON - PythonTask::init_type(); -#endif ButtonEventList::register_with_read_factory(); EventStoreInt::register_with_read_factory(); diff --git a/panda/src/event/p3event_composite1.cxx b/panda/src/event/p3event_composite1.cxx index 08165b1800..57cc83159c 100644 --- a/panda/src/event/p3event_composite1.cxx +++ b/panda/src/event/p3event_composite1.cxx @@ -9,4 +9,3 @@ #include "genericAsyncTask.cxx" #include "pointerEvent.cxx" #include "pointerEventList.cxx" -#include "pythonTask.cxx" diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index f9061f21cb..3a4573585f 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -17,12 +17,17 @@ #include "config_event.h" #ifdef HAVE_PYTHON -#include "py_panda.h" +#include "py_panda.h" TypeHandle PythonTask::_type_handle; +Configure(config_pythonTask); +ConfigureFn(config_pythonTask) { + PythonTask::init_type(); +} + #ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject Dtool_TypedReferenceCount; +extern struct Dtool_PyTypedObject Dtool_TypedReferenceCount; #endif //////////////////////////////////////////////////////////////////// diff --git a/panda/src/event/pythonTask.h b/panda/src/event/pythonTask.h index 258fbc6f8d..d9990e92a4 100644 --- a/panda/src/event/pythonTask.h +++ b/panda/src/event/pythonTask.h @@ -25,7 +25,7 @@ // Description : This class exists to allow association of a Python // function with the AsyncTaskManager. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_PIPELINE PythonTask : public AsyncTask { +class PythonTask : public AsyncTask { PUBLISHED: PythonTask(PyObject *function = Py_None, const string &name = string()); virtual ~PythonTask(); diff --git a/panda/src/express/dcast.cxx b/panda/src/express/dcast.cxx index ecdedb6506..34517ff28c 100644 --- a/panda/src/express/dcast.cxx +++ b/panda/src/express/dcast.cxx @@ -16,11 +16,12 @@ #include "config_express.h" #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include // for IsBadWritePtr() #endif - #ifdef DO_DCAST //////////////////////////////////////////////////////////////////// // Function: _dcast_verify diff --git a/panda/src/express/multifile.I b/panda/src/express/multifile.I index 35de9b9cc6..f2ddf6b060 100644 --- a/panda/src/express/multifile.I +++ b/panda/src/express/multifile.I @@ -534,51 +534,3 @@ get_last_byte_pos() const { return max(_index_start + (streampos)_index_length, _data_start + (streampos)_data_length) - (streampos)1; } - -#ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::CertRecord::Constructor -// Access: Public -// Description: Ownership of the X509 object is passed into the -// CertRecord; it will be freed when the CertRecord -// destructs. -//////////////////////////////////////////////////////////////////// -INLINE Multifile::CertRecord:: -CertRecord(X509 *cert) : - _cert(cert) -{ -} - -//////////////////////////////////////////////////////////////////// -// Function: Multifile::CertRecord::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE Multifile::CertRecord:: -CertRecord(const Multifile::CertRecord ©) : - _cert(X509_dup(copy._cert)) -{ -} - -//////////////////////////////////////////////////////////////////// -// Function: Multifile::CertRecord::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE Multifile::CertRecord:: -~CertRecord() { - X509_free(_cert); -} - -//////////////////////////////////////////////////////////////////// -// Function: Multifile::CertRecord::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void Multifile::CertRecord:: -operator = (const Multifile::CertRecord &other) { - X509_free(_cert); - _cert = X509_dup(other._cert); -} -#endif - diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 79ad6a4d16..b693e8e5c6 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -604,6 +604,53 @@ update_subfile(const string &subfile_name, const Filename &filename, return name; } +#ifdef HAVE_OPENSSL +//////////////////////////////////////////////////////////////////// +// Function: Multifile::CertRecord::Constructor +// Access: Public +// Description: Ownership of the X509 object is passed into the +// CertRecord; it will be freed when the CertRecord +// destructs. +//////////////////////////////////////////////////////////////////// +Multifile::CertRecord:: +CertRecord(X509 *cert) : + _cert(cert) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: Multifile::CertRecord::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +Multifile::CertRecord:: +CertRecord(const Multifile::CertRecord ©) : + _cert(X509_dup(copy._cert)) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: Multifile::CertRecord::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +Multifile::CertRecord:: +~CertRecord() { + X509_free(_cert); +} + +//////////////////////////////////////////////////////////////////// +// Function: Multifile::CertRecord::Copy Assignment +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void Multifile::CertRecord:: +operator = (const Multifile::CertRecord &other) { + X509_free(_cert); + _cert = X509_dup(other._cert); +} +#endif // HAVE_OPENSSL + #ifdef HAVE_OPENSSL //////////////////////////////////////////////////////////////////// // Function: Multifile::add_signature diff --git a/panda/src/express/ordered_vector.I b/panda/src/express/ordered_vector.I index c7a4714ebd..ec0f23bfb6 100644 --- a/panda/src/express/ordered_vector.I +++ b/panda/src/express/ordered_vector.I @@ -18,8 +18,8 @@ // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ordered_vector:: +template +INLINE ordered_vector:: ordered_vector(TypeHandle type_handle) : _compare(Compare()), _vector(type_handle) @@ -31,8 +31,8 @@ ordered_vector(TypeHandle type_handle) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ordered_vector:: +template +INLINE ordered_vector:: ordered_vector(const Compare &compare, TypeHandle type_handle) : _compare(compare), _vector(type_handle) @@ -44,9 +44,9 @@ ordered_vector(const Compare &compare, TypeHandle type_handle) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ordered_vector:: -ordered_vector(const ordered_vector ©) : +template +INLINE ordered_vector:: +ordered_vector(const ordered_vector ©) : _compare(copy._compare), _vector(copy._vector) { @@ -57,9 +57,9 @@ ordered_vector(const ordered_vector ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ordered_vector &ordered_vector:: -operator = (const ordered_vector ©) { +template +INLINE ordered_vector &ordered_vector:: +operator = (const ordered_vector ©) { _compare = copy._compare; _vector = copy._vector; return *this; @@ -70,8 +70,8 @@ operator = (const ordered_vector ©) { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ordered_vector:: +template +INLINE ordered_vector:: ~ordered_vector() { } @@ -81,8 +81,8 @@ INLINE ordered_vector:: // Description: Returns the iterator that marks the first element in // the ordered vector. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: begin() { return _vector.begin(); } @@ -93,8 +93,8 @@ begin() { // Description: Returns the iterator that marks the end of the // ordered vector. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: end() { return _vector.end(); } @@ -105,8 +105,8 @@ end() { // Description: Returns the iterator that marks the first element in // the ordered vector, when viewed in reverse order. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: +template +INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: rbegin() { return _vector.rbegin(); } @@ -117,8 +117,8 @@ rbegin() { // Description: Returns the iterator that marks the end of the // ordered vector, when viewed in reverse order. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: +template +INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: rend() { return _vector.rend(); } @@ -129,8 +129,8 @@ rend() { // Description: Returns the iterator that marks the first element in // the ordered vector. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +template +INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: begin() const { return _vector.begin(); } @@ -141,8 +141,8 @@ begin() const { // Description: Returns the iterator that marks the end of the // ordered vector. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +template +INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: end() const { return _vector.end(); } @@ -153,8 +153,8 @@ end() const { // Description: Returns the iterator that marks the first element in // the ordered vector, when viewed in reverse order. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +template +INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: rbegin() const { return _vector.rbegin(); } @@ -165,8 +165,8 @@ rbegin() const { // Description: Returns the iterator that marks the end of the // ordered vector, when viewed in reverse order. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +template +INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: rend() const { return _vector.rend(); } @@ -176,9 +176,9 @@ rend() const { // Access: Public // Description: Returns the nth element. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::REFERENCE ordered_vector:: -operator [] (TYPENAME ordered_vector::SIZE_TYPE n) { +template +INLINE TYPENAME ordered_vector::REFERENCE ordered_vector:: +operator [] (TYPENAME ordered_vector::SIZE_TYPE n) { return _vector[n]; } @@ -187,9 +187,9 @@ operator [] (TYPENAME ordered_vector::SIZE_TYPE n) { // Access: Public // Description: Returns the nth element. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::CONST_REFERENCE ordered_vector:: -operator [] (TYPENAME ordered_vector::SIZE_TYPE n) const { +template +INLINE TYPENAME ordered_vector::CONST_REFERENCE ordered_vector:: +operator [] (TYPENAME ordered_vector::SIZE_TYPE n) const { return _vector[n]; } @@ -198,8 +198,8 @@ operator [] (TYPENAME ordered_vector::SIZE_TYPE n) const { // Access: Public // Description: Returns the number of elements in the ordered vector. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +template +INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: size() const { return _vector.size(); } @@ -210,8 +210,8 @@ size() const { // Description: Returns the maximum number of elements that can // possibly be stored in an ordered vector. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +template +INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: max_size() const { return _vector.max_size(); } @@ -222,8 +222,8 @@ max_size() const { // Description: Returns true if the ordered vector is empty, false // otherwise. //////////////////////////////////////////////////////////////////// -template -INLINE bool ordered_vector:: +template +INLINE bool ordered_vector:: empty() const { return _vector.empty(); } @@ -234,9 +234,9 @@ empty() const { // Description: Returns true if the two ordered vectors are // memberwise equivalent, false otherwise. //////////////////////////////////////////////////////////////////// -template -INLINE bool ordered_vector:: -operator == (const ordered_vector &other) const { +template +INLINE bool ordered_vector:: +operator == (const ordered_vector &other) const { return _vector == other._vector; } @@ -246,9 +246,9 @@ operator == (const ordered_vector &other) const { // Description: Returns true if the two ordered vectors are not // memberwise equivalent, false if they are. //////////////////////////////////////////////////////////////////// -template -INLINE bool ordered_vector:: -operator != (const ordered_vector &other) const { +template +INLINE bool ordered_vector:: +operator != (const ordered_vector &other) const { return _vector != other._vector; } @@ -259,9 +259,9 @@ operator != (const ordered_vector &other) const { // lexicographically before the other one, false // otherwise. //////////////////////////////////////////////////////////////////// -template -INLINE bool ordered_vector:: -operator < (const ordered_vector &other) const { +template +INLINE bool ordered_vector:: +operator < (const ordered_vector &other) const { return _vector < other._vector; } @@ -272,9 +272,9 @@ operator < (const ordered_vector &other) const { // lexicographically after the other one, false // otherwise. //////////////////////////////////////////////////////////////////// -template -INLINE bool ordered_vector:: -operator > (const ordered_vector &other) const { +template +INLINE bool ordered_vector:: +operator > (const ordered_vector &other) const { return _vector > other._vector; } @@ -285,9 +285,9 @@ operator > (const ordered_vector &other) const { // lexicographically before the other one or is // equivalent, false otherwise. //////////////////////////////////////////////////////////////////// -template -INLINE bool ordered_vector:: -operator <= (const ordered_vector &other) const { +template +INLINE bool ordered_vector:: +operator <= (const ordered_vector &other) const { return _vector <= other._vector; } @@ -298,9 +298,9 @@ operator <= (const ordered_vector &other) const { // lexicographically after the other one or is // equivalent, false otherwise. //////////////////////////////////////////////////////////////////// -template -INLINE bool ordered_vector:: -operator >= (const ordered_vector &other) const { +template +INLINE bool ordered_vector:: +operator >= (const ordered_vector &other) const { return _vector >= other._vector; } @@ -318,9 +318,9 @@ operator >= (const ordered_vector &other) const { // original element), and the second componet is true if // the insert operation has taken place. //////////////////////////////////////////////////////////////////// -template -INLINE pair::ITERATOR, bool> ordered_vector:: -insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &key) { +template +INLINE pair::ITERATOR, bool> ordered_vector:: +insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unique(const value_type &)", " ", TAU_USER); ITERATOR position = find_insert_position(begin(), end(), key); #ifdef NDEBUG @@ -351,9 +351,9 @@ insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &key) { // The return value is the iterator referencing the new // element. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE &key) { +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_nonunique(const value_type &)", " ", TAU_USER); ITERATOR position = find_insert_position(begin(), end(), key); nassertr(position >= begin() && position <= end(), end()); @@ -371,10 +371,10 @@ insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE &key) { // already verified that this is the correct sorting // position; no checks are made. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_unverified(TYPENAME ordered_vector::ITERATOR position, - const TYPENAME ordered_vector::VALUE_TYPE &key) { +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +insert_unverified(TYPENAME ordered_vector::ITERATOR position, + const TYPENAME ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unverified(iterator, const value_type &)", " ", TAU_USER); ITERATOR result = _vector.insert(position, key); return result; @@ -386,9 +386,9 @@ insert_unverified(TYPENAME ordered_vector::ITERATOR position, // Description: Removes the element indicated by the given iterator, // and returns the next sequential iterator. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -erase(TYPENAME ordered_vector::ITERATOR position) { +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +erase(TYPENAME ordered_vector::ITERATOR position) { TAU_PROFILE("ordered_vector::erase(iterator)", " ", TAU_USER); SIZE_TYPE count = position - begin(); _vector.erase(position); @@ -401,9 +401,9 @@ erase(TYPENAME ordered_vector::ITERATOR position) { // Description: Removes all elements matching the indicated key; // returns the number of elements removed. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: -erase(const TYPENAME ordered_vector::KEY_TYPE &key) { +template +INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +erase(const TYPENAME ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::erase(const key_type &)", " ", TAU_USER); pair result = equal_range(key); SIZE_TYPE count = result.second - result.first; @@ -417,10 +417,10 @@ erase(const TYPENAME ordered_vector::KEY_TYPE &key) { // Description: Removes all elements indicated by the given iterator // range. //////////////////////////////////////////////////////////////////// -template -INLINE void ordered_vector:: -erase(TYPENAME ordered_vector::ITERATOR first, - TYPENAME ordered_vector::ITERATOR last) { +template +INLINE void ordered_vector:: +erase(TYPENAME ordered_vector::ITERATOR first, + TYPENAME ordered_vector::ITERATOR last) { TAU_PROFILE("ordered_vector::erase(iterator, iterator)", " ", TAU_USER); _vector.erase(first, last); } @@ -430,8 +430,8 @@ erase(TYPENAME ordered_vector::ITERATOR first, // Access: Public // Description: Removes all elements from the ordered vector. //////////////////////////////////////////////////////////////////// -template -INLINE void ordered_vector:: +template +INLINE void ordered_vector:: clear() { TAU_PROFILE("ordered_vector::clear()", " ", TAU_USER); _vector.erase(_vector.begin(), _vector.end()); @@ -445,9 +445,9 @@ clear() { // is not. If there are multiple elements matching the // key, the particular iterator returned is not defined. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -find(const TYPENAME ordered_vector::KEY_TYPE &key) { +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +find(const TYPENAME ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::find(const key_type &)", " ", TAU_USER); return nci(r_find(begin(), end(), end(), key)); } @@ -460,9 +460,9 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) { // is not. If there are multiple elements matching the // key, the particular iterator returned is not defined. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -find(const TYPENAME ordered_vector::KEY_TYPE &key) const { +template +INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +find(const TYPENAME ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::find(const key_type &)", " ", TAU_USER); return r_find(begin(), end(), end(), key); } @@ -483,9 +483,9 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) const { // The assumption is that == implies !Compare(a, b) and // !Compare(b, a), but not necessarily the converse. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) { +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::find_particular(const key_type &)", " ", TAU_USER); return nci(r_find_particular(begin(), end(), end(), key)); } @@ -503,9 +503,9 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) { // multiple matches exist within the vector, the // particular iterator returned is not defined./ //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) const { +template +INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::find_particular(const key_type &)", " ", TAU_USER); return r_find_particular(begin(), end(), end(), key); } @@ -516,8 +516,8 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) cons // Description: Returns the number of elements that sort equivalent // to the key that are in the vector. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +template +INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: count(const key_type &key) const { TAU_PROFILE("ordered_vector::count(const key_type &)", " ", TAU_USER); return r_count(begin(), end(), key); @@ -529,9 +529,9 @@ count(const key_type &key) const { // Description: Returns the iterator for the first element not less // than key, or end() if all elements are less than key. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::lower_bound(const key_type &)", " ", TAU_USER); return nci(r_lower_bound(begin(), end(), key)); } @@ -542,9 +542,9 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { // Description: Returns the iterator for the first element not less // than key, or end() if all elements are less than key. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { +template +INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::lower_bound(const key_type &)", " ", TAU_USER); return r_lower_bound(begin(), end(), key); } @@ -556,9 +556,9 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { // than key, or end() if no element is greater than // key. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::upper_bound(const key_type &)", " ", TAU_USER); return nci(r_upper_bound(begin(), end(), key)); } @@ -570,9 +570,9 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { // than key, or end() if no element is greater than // key. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { +template +INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::upper_bound(const key_type &)", " ", TAU_USER); return r_upper_bound(begin(), end(), key); } @@ -582,13 +582,13 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { // Access: Public // Description: Returns the pair (lower_bound(key), upper_bound(key)). //////////////////////////////////////////////////////////////////// -template -INLINE pair::ITERATOR, TYPENAME ordered_vector::ITERATOR> ordered_vector:: -equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) { +template +INLINE pair::ITERATOR, TYPENAME ordered_vector::ITERATOR> ordered_vector:: +equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); - pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> result; + pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> result; result = r_equal_range(begin(), end(), key); - return pair::ITERATOR, TYPENAME ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); + return pair::ITERATOR, TYPENAME ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); } //////////////////////////////////////////////////////////////////// @@ -596,9 +596,9 @@ equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) { // Access: Public // Description: Returns the pair (lower_bound(key), upper_bound(key)). //////////////////////////////////////////////////////////////////// -template -INLINE pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: -equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) const { +template +INLINE pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: +equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); return r_equal_range(begin(), end(), key); } @@ -609,9 +609,9 @@ equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) const { // Description: Exchanges the contents of this vector and the other // vector, in constant time (e.g., with a pointer swap). //////////////////////////////////////////////////////////////////// -template -INLINE void ordered_vector:: -swap(ordered_vector ©) { +template +INLINE void ordered_vector:: +swap(ordered_vector ©) { TAU_PROFILE("ordered_vector::swap(ordered_vector &)", " ", TAU_USER); _vector.swap(copy._vector); } @@ -623,9 +623,9 @@ swap(ordered_vector ©) { // ensures that the capacity of the vector is greater // than or equal to n. //////////////////////////////////////////////////////////////////// -template -INLINE void ordered_vector:: -reserve(TYPENAME ordered_vector::SIZE_TYPE n) { +template +INLINE void ordered_vector:: +reserve(TYPENAME ordered_vector::SIZE_TYPE n) { TAU_PROFILE("ordered_vector::reserve(size_type)", " ", TAU_USER); _vector.reserve(n); } @@ -642,8 +642,8 @@ reserve(TYPENAME ordered_vector::SIZE_TYPE n) { // This flavor of sort also eliminates repeated // elements. //////////////////////////////////////////////////////////////////// -template -INLINE void ordered_vector:: +template +INLINE void ordered_vector:: sort_unique() { TAU_PROFILE("ordered_vector::sort_unique()", " ", TAU_USER); sort(begin(), end(), _compare); @@ -660,8 +660,8 @@ sort_unique() { // written to the vector using the non-const iterators // or has called push_back(). //////////////////////////////////////////////////////////////////// -template -INLINE void ordered_vector:: +template +INLINE void ordered_vector:: sort_nonunique() { TAU_PROFILE("ordered_vector::sort_nonunique()", " ", TAU_USER); stable_sort(begin(), end(), _compare); @@ -675,8 +675,8 @@ sort_nonunique() { // except to populate the vector the first time; be sure // to call sort() after you have added all the elements. //////////////////////////////////////////////////////////////////// -template -INLINE void ordered_vector:: +template +INLINE void ordered_vector:: push_back(const value_type &key) { TAU_PROFILE("ordered_vector::push_back()", " ", TAU_USER); _vector.push_back(key); @@ -687,8 +687,8 @@ push_back(const value_type &key) { // Access: Public // Description: Removes the last element at the end of the vector. //////////////////////////////////////////////////////////////////// -template -INLINE void ordered_vector:: +template +INLINE void ordered_vector:: pop_back() { TAU_PROFILE("ordered_vector::pop_back()", " ", TAU_USER); _vector.pop_back(); @@ -702,9 +702,9 @@ pop_back() { // easy definition of const vs. non-const flavors of // some of these methods. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -nci(TYPENAME ordered_vector::CONST_ITERATOR i) { +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +nci(TYPENAME ordered_vector::CONST_ITERATOR i) { return begin() + (i - begin()); } @@ -715,11 +715,11 @@ nci(TYPENAME ordered_vector::CONST_ITERATOR i) { // vector to insert the indicated key, and returns the // corresponding iterator. //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -find_insert_position(TYPENAME ordered_vector::ITERATOR first, - TYPENAME ordered_vector::ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) { +template +INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +find_insert_position(TYPENAME ordered_vector::ITERATOR first, + TYPENAME ordered_vector::ITERATOR last, + const TYPENAME ordered_vector::KEY_TYPE &key) { ITERATOR result = r_find_insert_position(first, last, key); return result; } @@ -729,10 +729,10 @@ find_insert_position(TYPENAME ordered_vector::ITERATOR first, // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ov_set:: +template +INLINE ov_set:: ov_set(TypeHandle type_handle) : - ordered_vector(type_handle) + ordered_vector(type_handle) { } @@ -741,10 +741,10 @@ ov_set(TypeHandle type_handle) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ov_set:: +template +INLINE ov_set:: ov_set(const Compare &compare, TypeHandle type_handle) : - ordered_vector(compare, type_handle) + ordered_vector(compare, type_handle) { } @@ -753,10 +753,10 @@ ov_set(const Compare &compare, TypeHandle type_handle) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ov_set:: -ov_set(const ov_set ©) : - ordered_vector(copy) +template +INLINE ov_set:: +ov_set(const ov_set ©) : + ordered_vector(copy) { } @@ -765,10 +765,10 @@ ov_set(const ov_set ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ov_set &ov_set:: -operator = (const ov_set ©) { - ordered_vector::operator = (copy); +template +INLINE ov_set &ov_set:: +operator = (const ov_set ©) { + ordered_vector::operator = (copy); return *this; } @@ -777,11 +777,11 @@ operator = (const ov_set ©) { // Access: Public // Description: Maps to insert_unique(). //////////////////////////////////////////////////////////////////// -template -TYPENAME ov_set::ITERATOR ov_set:: -insert(TYPENAME ov_set::ITERATOR position, - const TYPENAME ov_set::VALUE_TYPE &key) { - return ordered_vector::insert_unique(position, key); +template +TYPENAME ov_set::ITERATOR ov_set:: +insert(TYPENAME ov_set::ITERATOR position, + const TYPENAME ov_set::VALUE_TYPE &key) { + return ordered_vector::insert_unique(position, key); } //////////////////////////////////////////////////////////////////// @@ -789,10 +789,10 @@ insert(TYPENAME ov_set::ITERATOR position, // Access: Public // Description: Maps to insert_unique(). //////////////////////////////////////////////////////////////////// -template -INLINE pair::ITERATOR, bool> ov_set:: -insert(const TYPENAME ov_set::VALUE_TYPE &key) { - return ordered_vector::insert_unique(key); +template +INLINE pair::ITERATOR, bool> ov_set:: +insert(const TYPENAME ov_set::VALUE_TYPE &key) { + return ordered_vector::insert_unique(key); } //////////////////////////////////////////////////////////////////// @@ -800,10 +800,10 @@ insert(const TYPENAME ov_set::VALUE_TYPE &key) { // Access: Public // Description: Maps to sort_unique(). //////////////////////////////////////////////////////////////////// -template -INLINE void ov_set:: +template +INLINE void ov_set:: sort() { - ordered_vector::sort_unique(); + ordered_vector::sort_unique(); } //////////////////////////////////////////////////////////////////// @@ -811,10 +811,10 @@ sort() { // Access: Public // Description: Maps to verify_list_unique(). //////////////////////////////////////////////////////////////////// -template -INLINE bool ov_set:: +template +INLINE bool ov_set:: verify_list() const { - return ordered_vector::verify_list_unique(); + return ordered_vector::verify_list_unique(); } //////////////////////////////////////////////////////////////////// @@ -822,10 +822,10 @@ verify_list() const { // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ov_multiset:: +template +INLINE ov_multiset:: ov_multiset(TypeHandle type_handle) : - ordered_vector(type_handle) + ordered_vector(type_handle) { } @@ -834,10 +834,10 @@ ov_multiset(TypeHandle type_handle) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ov_multiset:: +template +INLINE ov_multiset:: ov_multiset(const Compare &compare, TypeHandle type_handle) : - ordered_vector(compare, type_handle) + ordered_vector(compare, type_handle) { } @@ -846,10 +846,10 @@ ov_multiset(const Compare &compare, TypeHandle type_handle) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ov_multiset:: -ov_multiset(const ov_multiset ©) : - ordered_vector(copy) +template +INLINE ov_multiset:: +ov_multiset(const ov_multiset ©) : + ordered_vector(copy) { } @@ -858,10 +858,10 @@ ov_multiset(const ov_multiset ©) : // Access: Public // Description: //////////////////////////////////////////////////////////////////// -template -INLINE ov_multiset &ov_multiset:: -operator = (const ov_multiset ©) { - ordered_vector::operator = (copy); +template +INLINE ov_multiset &ov_multiset:: +operator = (const ov_multiset ©) { + ordered_vector::operator = (copy); return *this; } @@ -870,11 +870,11 @@ operator = (const ov_multiset ©) { // Access: Public // Description: Maps to insert_nonunique(). //////////////////////////////////////////////////////////////////// -template -TYPENAME ov_multiset::ITERATOR ov_multiset:: -insert(TYPENAME ov_multiset::ITERATOR position, - const TYPENAME ov_multiset::VALUE_TYPE &key) { - return ordered_vector::insert_nonunique(position, key); +template +TYPENAME ov_multiset::ITERATOR ov_multiset:: +insert(TYPENAME ov_multiset::ITERATOR position, + const TYPENAME ov_multiset::VALUE_TYPE &key) { + return ordered_vector::insert_nonunique(position, key); } //////////////////////////////////////////////////////////////////// @@ -882,10 +882,10 @@ insert(TYPENAME ov_multiset::ITERATOR position, // Access: Public // Description: Maps to insert_nonunique(). //////////////////////////////////////////////////////////////////// -template -INLINE TYPENAME ov_multiset::ITERATOR ov_multiset:: -insert(const TYPENAME ov_multiset::VALUE_TYPE &key) { - return ordered_vector::insert_nonunique(key); +template +INLINE TYPENAME ov_multiset::ITERATOR ov_multiset:: +insert(const TYPENAME ov_multiset::VALUE_TYPE &key) { + return ordered_vector::insert_nonunique(key); } //////////////////////////////////////////////////////////////////// @@ -893,10 +893,10 @@ insert(const TYPENAME ov_multiset::VALUE_TYPE &key) { // Access: Public // Description: Maps to sort_nonunique(). //////////////////////////////////////////////////////////////////// -template -INLINE void ov_multiset:: +template +INLINE void ov_multiset:: sort() { - ordered_vector::sort_nonunique(); + ordered_vector::sort_nonunique(); } //////////////////////////////////////////////////////////////////// @@ -904,8 +904,8 @@ sort() { // Access: Public // Description: Maps to verify_list_nonunique(). //////////////////////////////////////////////////////////////////// -template -INLINE bool ov_multiset:: +template +INLINE bool ov_multiset:: verify_list() const { - return ordered_vector::verify_list_nonunique(); + return ordered_vector::verify_list_nonunique(); } diff --git a/panda/src/express/ordered_vector.T b/panda/src/express/ordered_vector.T index ad0e24b5a5..6a7100f90f 100644 --- a/panda/src/express/ordered_vector.T +++ b/panda/src/express/ordered_vector.T @@ -27,10 +27,10 @@ // already present, it is not inserted, and the iterator // referencing the original value is returned. //////////////////////////////////////////////////////////////////// -template -TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_unique(TYPENAME ordered_vector::ITERATOR position, - const TYPENAME ordered_vector::VALUE_TYPE &key) { +template +TYPENAME ordered_vector::ITERATOR ordered_vector:: +insert_unique(TYPENAME ordered_vector::ITERATOR position, + const TYPENAME ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unique(iterator, const value_type &)", " ", TAU_USER); if (position != end()) { // If we're not inserting at the end, the element we're @@ -74,10 +74,10 @@ insert_unique(TYPENAME ordered_vector::ITERATOR position, // This flavor of insert allows multiple copies of the // same key to be inserted. //////////////////////////////////////////////////////////////////// -template -TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_nonunique(TYPENAME ordered_vector::ITERATOR position, - const TYPENAME ordered_vector::VALUE_TYPE &key) { +template +TYPENAME ordered_vector::ITERATOR ordered_vector:: +insert_nonunique(TYPENAME ordered_vector::ITERATOR position, + const TYPENAME ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_nonunique(iterator, const value_type &)", " ", TAU_USER); if (position != end()) { // If we're not inserting at the end, the element we're @@ -107,8 +107,8 @@ insert_nonunique(TYPENAME ordered_vector::ITERATOR position, // sorted correctly. Returns true if this is the case; // otherwise, returns false. //////////////////////////////////////////////////////////////////// -template -bool ordered_vector:: +template +bool ordered_vector:: verify_list_unique() const { TAU_PROFILE("ordered_vector::verify_list_unique()", " ", TAU_USER); if (!empty()) { @@ -134,8 +134,8 @@ verify_list_unique() const { // sorted correctly. Returns true if this is the case; // otherwise, returns false. //////////////////////////////////////////////////////////////////// -template -bool ordered_vector:: +template +bool ordered_vector:: verify_list_nonunique() const { TAU_PROFILE("ordered_vector::verify_list_nonunique()", " ", TAU_USER); if (!empty()) { @@ -161,11 +161,11 @@ verify_list_nonunique() const { // Description: The recursive implementation of // find_insert_position(). //////////////////////////////////////////////////////////////////// -template -TYPENAME ordered_vector::ITERATOR ordered_vector:: -r_find_insert_position(TYPENAME ordered_vector::ITERATOR first, - TYPENAME ordered_vector::ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) { +template +TYPENAME ordered_vector::ITERATOR ordered_vector:: +r_find_insert_position(TYPENAME ordered_vector::ITERATOR first, + TYPENAME ordered_vector::ITERATOR last, + const TYPENAME ordered_vector::KEY_TYPE &key) { if (first == last) { // The list is empty; the insert position is the last of the list. return last; @@ -189,12 +189,12 @@ r_find_insert_position(TYPENAME ordered_vector::ITERATOR first, // Access: Private // Description: The recursive implementation of find(). //////////////////////////////////////////////////////////////////// -template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_find(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - TYPENAME ordered_vector::CONST_ITERATOR not_found, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +template +TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +r_find(TYPENAME ordered_vector::CONST_ITERATOR first, + TYPENAME ordered_vector::CONST_ITERATOR last, + TYPENAME ordered_vector::CONST_ITERATOR not_found, + const TYPENAME ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return not_found; @@ -222,12 +222,12 @@ r_find(TYPENAME ordered_vector::CONST_ITERATOR first, // Access: Private // Description: The recursive implementation of find_particular(). //////////////////////////////////////////////////////////////////// -template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_find_particular(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - TYPENAME ordered_vector::CONST_ITERATOR not_found, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +template +TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +r_find_particular(TYPENAME ordered_vector::CONST_ITERATOR first, + TYPENAME ordered_vector::CONST_ITERATOR last, + TYPENAME ordered_vector::CONST_ITERATOR not_found, + const TYPENAME ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return not_found; @@ -275,12 +275,12 @@ r_find_particular(TYPENAME ordered_vector::CONST_ITERATOR first, // Access: Private // Description: The recursive implementation of count(). //////////////////////////////////////////////////////////////////// -template -TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: -r_count(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { - typedef pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> pair_type; +template +TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +r_count(TYPENAME ordered_vector::CONST_ITERATOR first, + TYPENAME ordered_vector::CONST_ITERATOR last, + const TYPENAME ordered_vector::KEY_TYPE &key) const { + typedef pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> pair_type; if (first == last) { // The list is empty; the key is not on the list. @@ -311,11 +311,11 @@ r_count(TYPENAME ordered_vector::CONST_ITERATOR first, // Access: Private // Description: The recursive implementation of lower_bound(). //////////////////////////////////////////////////////////////////// -template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_lower_bound(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +template +TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +r_lower_bound(TYPENAME ordered_vector::CONST_ITERATOR first, + TYPENAME ordered_vector::CONST_ITERATOR last, + const TYPENAME ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return last; @@ -344,11 +344,11 @@ r_lower_bound(TYPENAME ordered_vector::CONST_ITERATOR first, // Access: Private // Description: The recursive implementation of upper_bound(). //////////////////////////////////////////////////////////////////// -template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_upper_bound(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +template +TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +r_upper_bound(TYPENAME ordered_vector::CONST_ITERATOR first, + TYPENAME ordered_vector::CONST_ITERATOR last, + const TYPENAME ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return last; @@ -377,12 +377,12 @@ r_upper_bound(TYPENAME ordered_vector::CONST_ITERATOR first, // Access: Private // Description: The recursive implementation of equal_range(). //////////////////////////////////////////////////////////////////// -template -pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: -r_equal_range(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { - typedef pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> pair_type; +template +pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: +r_equal_range(TYPENAME ordered_vector::CONST_ITERATOR first, + TYPENAME ordered_vector::CONST_ITERATOR last, + const TYPENAME ordered_vector::KEY_TYPE &key) const { + typedef pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> pair_type; if (first == last) { // The list is empty; the key is not on the list. diff --git a/panda/src/express/ordered_vector.h b/panda/src/express/ordered_vector.h index a481a43b37..705212b98d 100644 --- a/panda/src/express/ordered_vector.h +++ b/panda/src/express/ordered_vector.h @@ -21,15 +21,15 @@ // on pc cygwin from 3 minutes to 17 seconds ?? really need to explore interigate to figure out what is // going on .. // -template > class ov_multiset +template, class Vector = pvector > class ov_multiset { }; -template > class ov_set +template, class Vector = pvector > class ov_set { }; -template > class ordered_vector +template, class Vector = pvector > class ordered_vector { }; @@ -105,11 +105,8 @@ template > class ordered_vector // (4) Random access into the set is easy with the [] // operator. //////////////////////////////////////////////////////////////////// -template > +template, class Vector = pvector > class ordered_vector { -private: - typedef pvector Vector; - public: // Typedefs typedef Key KEY_TYPE; @@ -152,8 +149,8 @@ public: INLINE ordered_vector(TypeHandle type_handle = ov_set_type_handle); INLINE ordered_vector(const Compare &compare, TypeHandle type_handle = ov_set_type_handle); - INLINE ordered_vector(const ordered_vector ©); - INLINE ordered_vector &operator = (const ordered_vector ©); + INLINE ordered_vector(const ordered_vector ©); + INLINE ordered_vector &operator = (const ordered_vector ©); INLINE ~ordered_vector(); // Iterator access. @@ -177,13 +174,13 @@ public: INLINE bool empty() const; // Equivalence and lexicographical comparisons. - INLINE bool operator == (const ordered_vector &other) const; - INLINE bool operator != (const ordered_vector &other) const; + INLINE bool operator == (const ordered_vector &other) const; + INLINE bool operator != (const ordered_vector &other) const; - INLINE bool operator < (const ordered_vector &other) const; - INLINE bool operator > (const ordered_vector &other) const; - INLINE bool operator <= (const ordered_vector &other) const; - INLINE bool operator >= (const ordered_vector &other) const; + INLINE bool operator < (const ordered_vector &other) const; + INLINE bool operator > (const ordered_vector &other) const; + INLINE bool operator <= (const ordered_vector &other) const; + INLINE bool operator >= (const ordered_vector &other) const; // Insert operations. ITERATOR insert_unique(ITERATOR position, const VALUE_TYPE &key); @@ -213,7 +210,7 @@ public: INLINE pair equal_range(const KEY_TYPE &key) const; // Special operations. - INLINE void swap(ordered_vector &other); + INLINE void swap(ordered_vector &other); INLINE void reserve(SIZE_TYPE n); INLINE void sort_unique(); INLINE void sort_nonunique(); @@ -273,17 +270,17 @@ private: // standard STL set: one copy of each element is // allowed. //////////////////////////////////////////////////////////////////// -template > -class ov_set : public ordered_vector { +template, class Vector = pvector > +class ov_set : public ordered_vector { public: - typedef TYPENAME ordered_vector::ITERATOR ITERATOR; - typedef TYPENAME ordered_vector::VALUE_TYPE VALUE_TYPE; + typedef TYPENAME ordered_vector::ITERATOR ITERATOR; + typedef TYPENAME ordered_vector::VALUE_TYPE VALUE_TYPE; INLINE ov_set(TypeHandle type_handle = ov_set_type_handle); INLINE ov_set(const Compare &compare, TypeHandle type_handle = ov_set_type_handle); - INLINE ov_set(const ov_set ©); - INLINE ov_set &operator = (const ov_set ©); + INLINE ov_set(const ov_set ©); + INLINE ov_set &operator = (const ov_set ©); INLINE ITERATOR insert(ITERATOR position, const VALUE_TYPE &key0); INLINE pair insert(const VALUE_TYPE &key0); @@ -298,17 +295,17 @@ public: // standard STL set: many copies of each element are // allowed. //////////////////////////////////////////////////////////////////// -template > -class ov_multiset : public ordered_vector { +template, class Vector = pvector > +class ov_multiset : public ordered_vector { public: - typedef TYPENAME ordered_vector::ITERATOR ITERATOR; - typedef TYPENAME ordered_vector::VALUE_TYPE VALUE_TYPE; + typedef TYPENAME ordered_vector::ITERATOR ITERATOR; + typedef TYPENAME ordered_vector::VALUE_TYPE VALUE_TYPE; INLINE ov_multiset(TypeHandle type_handle = ov_set_type_handle); INLINE ov_multiset(const Compare &compare, TypeHandle type_handle = ov_set_type_handle); - INLINE ov_multiset(const ov_multiset ©); - INLINE ov_multiset &operator = (const ov_multiset ©); + INLINE ov_multiset(const ov_multiset ©); + INLINE ov_multiset &operator = (const ov_multiset ©); INLINE ITERATOR insert(ITERATOR position, const VALUE_TYPE &key); INLINE ITERATOR insert(const VALUE_TYPE &key); diff --git a/panda/src/express/password_hash.h b/panda/src/express/password_hash.h index 1b07bc93bb..dbaa39fe15 100644 --- a/panda/src/express/password_hash.h +++ b/panda/src/express/password_hash.h @@ -23,8 +23,9 @@ BEGIN_PUBLISH -string password_hash(const string &password, const string &salt, - int iters, int keylen); +EXPCL_PANDAEXPRESS string password_hash(const string &password, + const string &salt, + int iters, int keylen); END_PUBLISH diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index 8196ffef07..c833954570 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -39,7 +39,7 @@ PointerToArray(TypeHandle type_handle) : // Description: Return an empty array of size n //////////////////////////////////////////////////////////////////// template -INLINE PointerToArray +INLINE PointerToArray PointerToArray::empty_array(size_type n, TypeHandle type_handle) { PointerToArray temp(type_handle); temp.reassign(new ReferenceCountedVector(type_handle)); @@ -77,129 +77,6 @@ PointerToArray(const PointerToArray ©) : { } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Constructor -// Access: Published -// Description: This special constructor accepts a Python list of -// elements, or a Python string (or a bytes object, -// in Python 3), or any object that supports the -// Python buffer protocol. -//////////////////////////////////////////////////////////////////// -template -PointerToArray:: -PointerToArray(PyObject *self, PyObject *source) : - PointerToArrayBase((ReferenceCountedVector *)NULL), - _type_handle(get_type_handle(Element)) -{ - // We have to pre-initialize self's "this" pointer when we receive - // self in the constructor--the caller can't initialize this for us. - ((Dtool_PyInstDef *)self)->_ptr_to_object = this; - -#if PY_VERSION_HEX >= 0x02060000 - if (PyObject_CheckBuffer(source)) { - // User passed a buffer object. - Py_buffer view; - if (PyObject_GetBuffer(source, &view, PyBUF_CONTIG_RO) == -1) { - PyErr_SetString(PyExc_TypeError, "PointerToArray constructor requires a contiguous buffer"); - return; - } - - if (view.itemsize != 1 && view.itemsize != sizeof(Element)) { - PyErr_SetString(PyExc_TypeError, "buffer.itemsize does not match PointerToArray element size"); - return; - } - - int num_elements = view.len / sizeof(Element); - insert(begin(), num_elements, Element()); - - if (view.len > 0) { - memcpy(p(), view.buf, view.len); - } - - PyBuffer_Release(&view); - return; - } -#endif - - if (!PySequence_Check(source)) { - // If passed with a non-sequence, this isn't the right constructor. - PyErr_SetString(PyExc_TypeError, "PointerToArray constructor requires a sequence or buffer object"); - return; - } - - // If we were passed a Python string, then instead of storing it - // character-at-a-time, just load the whole string as a data - // buffer. -#if PY_MAJOR_VERSION >= 3 - if (PyBytes_Check(source)) { - int size = PyBytes_Size(source); - if (size % sizeof(Element) != 0) { - ostringstream stream; - stream << "Buffer not a multiple of " << sizeof(Element) << " bytes"; - string str = stream.str(); - PyErr_SetString(PyExc_ValueError, str.c_str()); - return; - } - - int num_elements = size / sizeof(Element); - insert(begin(), num_elements, Element()); - - // Hope there aren't any constructors or destructors involved - // here. - if (size != 0) { - const char *data = PyBytes_AsString(source); - memcpy(p(), data, size); - } - return; - } -#else - if (PyString_CheckExact(source)) { - int size = PyString_Size(source); - if (size % sizeof(Element) != 0) { - ostringstream stream; - stream << "Buffer not a multiple of " << sizeof(Element) << " bytes"; - string str = stream.str(); - PyErr_SetString(PyExc_ValueError, str.c_str()); - return; - } - - int num_elements = size / sizeof(Element); - insert(begin(), num_elements, Element()); - - // Hope there aren't any constructors or destructors involved - // here. - if (size != 0) { - const char *data = PyString_AsString(source); - memcpy(p(), data, size); - } - return; - } -#endif - - // Now construct the internal list by copying the elements - // one-at-a-time from Python. - int size = PySequence_Size(source); - for (int i = 0; i < size; ++i) { - PyObject *item = PySequence_GetItem(source, i); - if (item == NULL) { - return; - } - PyObject *result = PyObject_CallMethod(self, (char *)"push_back", (char *)"O", item); - Py_DECREF(item); - if (result == NULL) { - // Unable to add item--probably it wasn't of the appropriate type. - ostringstream stream; - stream << "Element " << i << " in sequence passed to PointerToArray constructor could not be added"; - string str = stream.str(); - PyErr_SetString(PyExc_TypeError, str.c_str()); - return; - } - Py_DECREF(result); - } -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: PointerToArray::begin // Access: Public @@ -593,31 +470,6 @@ set_element(size_type n, const Element &value) { (*this)[n] = value; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::__getitem__ -// Access: Published -// Description: Same as get_element(), this returns the nth element -// of the array. -//////////////////////////////////////////////////////////////////// -template -INLINE const Element &PointerToArray:: -__getitem__(size_type n) const { - return (*this)[n]; -} - -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::__setitem__ -// Access: Published -// Description: Same as set_element(), this replaces the nth element -// of the array. -//////////////////////////////////////////////////////////////////// -template -INLINE void PointerToArray:: -__setitem__(size_type n, const Element &value) { - nassertv(n < ((To *)(this->_void_ptr))->size()); - (*this)[n] = value; -} - //////////////////////////////////////////////////////////////////// // Function: PointerToArray::get_data // Access: Published @@ -884,23 +736,6 @@ ConstPointerToArray(const ConstPointerToArray ©) : { } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Constructor -// Access: Public -// Description: This special constructor accepts a Python list of -// elements, or a Python string (or a bytes object, -// in Python 3). -//////////////////////////////////////////////////////////////////// -template -INLINE ConstPointerToArray:: -ConstPointerToArray(PyObject *self, PyObject *source) : - PointerToArrayBase(PointerToArray(self, source)), - _type_handle(get_type_handle(Element)) -{ -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: ConstPointerToArray::begin // Access: Public @@ -1158,18 +993,6 @@ get_element(size_type n) const { return (*this)[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::__getitem__ -// Access: Published -// Description: Same as get_element(), this returns the nth element -// of the array. -//////////////////////////////////////////////////////////////////// -template -INLINE const Element &ConstPointerToArray:: -__getitem__(size_type n) const { - return (*this)[n]; -} - //////////////////////////////////////////////////////////////////// // Function: ConstPointerToArray::get_data // Access: Published @@ -1331,150 +1154,4 @@ clear() { ((ConstPointerToArray *)this)->reassign((ReferenceCountedVector *)NULL); } -#ifdef HAVE_PYTHON -#if PY_VERSION_HEX >= 0x02060000 -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::__getbuffer__ -// Access: Published -// Description: This is used to implement the buffer protocol, in -// order to allow efficient access to the array data -// through a Python multiview object. -//////////////////////////////////////////////////////////////////// -template -INLINE int PointerToArray:: -__getbuffer__(PyObject *self, Py_buffer *view, int flags) { - - const char *format = get_format_code(Element); - if (format == NULL) { - // Not supported. - return -1; - } - - if (self != NULL) { - Py_INCREF(self); - } - view->obj = self; - view->buf = (void*) p(); - view->len = size() * sizeof(Element); - view->readonly = 0; - view->itemsize = sizeof(Element); - view->format = NULL; - if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { - view->format = (char*) format; - } - view->ndim = 1; - view->shape = NULL; - if ((flags & PyBUF_ND) == PyBUF_ND) { - // This leaks, which sucks, but __releasebuffer__ doesn't give us - // the same pointer, so we would need to store it elsewhere if we - // wanted to delete it there. Eh, it's just an int, who cares. - view->shape = new Py_ssize_t(size()); - } - view->strides = NULL; - if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { - view->strides = &(view->itemsize); - } - view->suboffsets = NULL; - - // Store a reference to ourselves on the Py_buffer object - // as a reminder that we have increased our refcount. - ref(); - view->internal = (void*) this; - - return 0; -} - -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::__releasebuffer__ -// Access: Published -// Description: Releases the buffer allocated by __getbuffer__. -//////////////////////////////////////////////////////////////////// -template -INLINE void PointerToArray:: -__releasebuffer__(PyObject *self, Py_buffer *view) const { - // Note: PyBuffer_Release automatically decrements view->obj. - - if (view->internal != NULL) { - // Oh, right, let's not forget to unref this. - ((const PointerToArray *) view->internal)->unref(); - view->internal = NULL; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::__getbuffer__ -// Access: Published -// Description: This is used to implement the buffer protocol, in -// order to allow efficient access to the array data -// through a Python multiview object. -//////////////////////////////////////////////////////////////////// -template -INLINE int ConstPointerToArray:: -__getbuffer__(PyObject *self, Py_buffer *view, int flags) const { - - if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) { - PyErr_SetString(PyExc_BufferError, - "Object is not writable."); - return -1; - } - - const char *format = get_format_code(Element); - if (format == NULL) { - // Not supported. - return -1; - } - - if (self != NULL) { - Py_INCREF(self); - } - view->obj = self; - view->buf = (void*) p(); - view->len = size() * sizeof(Element); - view->readonly = 1; - view->itemsize = sizeof(Element); - view->format = NULL; - if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { - view->format = (char*) format; - } - view->ndim = 1; - view->shape = NULL; - if ((flags & PyBUF_ND) == PyBUF_ND) { - // This leaks, which sucks, but __releasebuffer__ doesn't give us - // the same pointer, so we would need to store it elsewhere if we - // wanted to delete it there. Eh, it's just an int, who cares. - view->shape = new Py_ssize_t(size()); - } - view->strides = NULL; - if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { - view->strides = &(view->itemsize); - } - view->suboffsets = NULL; - - // Store a reference to ourselves on the Py_buffer object - // as a reminder that we have increased our refcount. - ref(); - view->internal = (void*) this; - - return 0; -} - -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::__releasebuffer__ -// Access: Published -// Description: Releases the buffer allocated by __getbuffer__. -//////////////////////////////////////////////////////////////////// -template -INLINE void ConstPointerToArray:: -__releasebuffer__(PyObject *self, Py_buffer *view) const { - // Note: PyBuffer_Release automatically decrements obj->view. - - if (view->internal != NULL) { - // Oh, right, let's not forget to unref this. - ((const PointerToArray *) view->internal)->unref(); - view->internal = NULL; - } -} -#endif // PY_VERSION_HEX -#endif // HAVE_PYTHON - #endif // CPPPARSER diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index c5f545fbd3..78b504d202 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -67,9 +67,6 @@ #include "pandabase.h" #include "pointerToArrayBase.h" -#ifdef HAVE_PYTHON -#include "py_panda.h" -#endif #if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(__INTEL_COMPILER) // disable mysterious MSVC warning for static inline PTA::empty_array method @@ -112,17 +109,15 @@ PUBLISHED: INLINE static PointerToArray empty_array(size_type n, TypeHandle type_handle = get_type_handle(Element)); INLINE PointerToArray(const PointerToArray ©); -#ifdef HAVE_PYTHON - PointerToArray(PyObject *self, PyObject *source); -#endif + EXTENSION(PointerToArray(PyObject *self, PyObject *source)); INLINE size_type size() const; INLINE void push_back(const Element &x); INLINE void pop_back(); INLINE const Element &get_element(size_type n) const; INLINE void set_element(size_type n, const Element &value); - INLINE const Element &__getitem__(size_type n) const; - INLINE void __setitem__(size_type n, const Element &value); + EXTENSION(const Element &__getitem__(size_type n) const); + EXTENSION(void __setitem__(size_type n, const Element &value)); INLINE string get_data() const; INLINE void set_data(const string &data); INLINE string get_subdata(size_type n, size_type count) const; @@ -132,8 +127,8 @@ PUBLISHED: #ifdef HAVE_PYTHON #if PY_VERSION_HEX >= 0x02060000 - int __getbuffer__(PyObject *self, Py_buffer *view, int flags); - void __releasebuffer__(PyObject *self, Py_buffer *view) const; + EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags)); + EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const); #endif #endif @@ -156,10 +151,6 @@ public: INLINE PointerToArray(size_type n, const Element &value, TypeHandle type_handle = get_type_handle(Element)); INLINE PointerToArray(const PointerToArray ©); -#ifdef HAVE_PYTHON - PointerToArray(PyObject *self, PyObject *source); -#endif - public: // Duplicating the interface of vector. The following member // functions are all const, because they do not reassign the @@ -213,8 +204,6 @@ public: // Methods to help out Python and other high-level languages. INLINE const Element &get_element(size_type n) const; INLINE void set_element(size_type n, const Element &value); - INLINE const Element &__getitem__(size_type n) const; - INLINE void __setitem__(size_type n, const Element &value); INLINE string get_data() const; INLINE void set_data(const string &data); INLINE string get_subdata(size_type n, size_type count) const; @@ -237,13 +226,6 @@ public: INLINE void node_ref() const; INLINE bool node_unref() const; -#ifdef HAVE_PYTHON -#if PY_VERSION_HEX >= 0x02060000 - int __getbuffer__(PyObject *self, Py_buffer *view, int flags); - void __releasebuffer__(PyObject *self, Py_buffer *view) const; -#endif -#endif - // Reassignment is by pointer, not memberwise as with a vector. INLINE PointerToArray & operator = (ReferenceCountedVector *ptr); @@ -283,14 +265,12 @@ PUBLISHED: INLINE ConstPointerToArray(const PointerToArray ©); INLINE ConstPointerToArray(const ConstPointerToArray ©); -#ifdef HAVE_PYTHON - INLINE ConstPointerToArray(PyObject *self, PyObject *source); -#endif + EXTENSION(ConstPointerToArray(PyObject *self, PyObject *source)); typedef TYPENAME pvector::size_type size_type; INLINE size_type size() const; INLINE const Element &get_element(size_type n) const; - INLINE const Element &__getitem__(size_type n) const; + EXTENSION(const Element &__getitem__(size_type n) const); INLINE string get_data() const; INLINE string get_subdata(size_type n, size_type count) const; INLINE int get_ref_count() const; @@ -298,8 +278,8 @@ PUBLISHED: #ifdef HAVE_PYTHON #if PY_VERSION_HEX >= 0x02060000 - int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const; - void __releasebuffer__(PyObject *self, Py_buffer *view) const; + EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const); + EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const); #endif #endif @@ -325,10 +305,6 @@ PUBLISHED: INLINE ConstPointerToArray(const PointerToArray ©); INLINE ConstPointerToArray(const ConstPointerToArray ©); -#ifdef HAVE_PYTHON - INLINE ConstPointerToArray(PyObject *self, PyObject *source); -#endif - // Duplicating the interface of vector. INLINE iterator begin() const; @@ -361,7 +337,6 @@ PUBLISHED: // Methods to help out Python and other high-level languages. INLINE const Element &get_element(size_type n) const; - INLINE const Element &__getitem__(size_type n) const; INLINE string get_data() const; INLINE string get_subdata(size_type n, size_type count) const; @@ -373,13 +348,6 @@ PUBLISHED: INLINE void node_ref() const; INLINE bool node_unref() const; -#ifdef HAVE_PYTHON -#if PY_VERSION_HEX >= 0x02060000 - int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const; - void __releasebuffer__(PyObject *self, Py_buffer *view) const; -#endif -#endif - // Reassignment is by pointer, not memberwise as with a vector. INLINE ConstPointerToArray & operator = (ReferenceCountedVector *ptr); @@ -408,36 +376,6 @@ private: #define PTA(type) PointerToArray< type > #define CPTA(type) ConstPointerToArray< type > -#ifdef HAVE_PYTHON -// This macro is used to map a data type to a format code -// as used in the Python 'struct' and 'array' modules. -#define get_format_code(type) _get_format_code((const type *)0) -#define define_format_code(code, type) template<> \ - INLINE const char *_get_format_code(const type *) { \ - return code; \ - } - -template -INLINE const char *_get_format_code(const T *) { - return NULL; -} - -define_format_code("c", char); -define_format_code("b", signed char); -define_format_code("B", unsigned char); -define_format_code("h", short); -define_format_code("H", unsigned short); -define_format_code("i", int); -define_format_code("I", unsigned int); -define_format_code("l", long); -define_format_code("L", unsigned long); -define_format_code("q", long long); -define_format_code("Q", unsigned long long); -define_format_code("f", float); -define_format_code("d", double); - -#endif // HAVE_PYTHON - #include "pointerToArray.I" #endif // HAVE_POINTERTOARRAY_H diff --git a/panda/src/express/pointerToArray_ext.I b/panda/src/express/pointerToArray_ext.I new file mode 100644 index 0000000000..c53b0c3ee0 --- /dev/null +++ b/panda/src/express/pointerToArray_ext.I @@ -0,0 +1,321 @@ +// Filename: pointerToArray_ext.I +// Created by: rdb (08Feb15) +// +//////////////////////////////////////////////////////////////////// +// +// 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." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: PointerToArray::__init__ +// Access: Published +// Description: This special constructor accepts a Python list of +// elements, or a Python string (or a bytes object, +// in Python 3), or any object that supports the +// Python buffer protocol. +//////////////////////////////////////////////////////////////////// +template +void Extension >:: +__init__(PyObject *self, PyObject *source) { +#if PY_VERSION_HEX >= 0x02060000 + if (PyObject_CheckBuffer(source)) { + // User passed a buffer object. + Py_buffer view; + if (PyObject_GetBuffer(source, &view, PyBUF_CONTIG_RO) == -1) { + PyErr_SetString(PyExc_TypeError, "PointerToArray constructor requires a contiguous buffer"); + return; + } + + if (view.itemsize != 1 && view.itemsize != sizeof(Element)) { + PyErr_SetString(PyExc_TypeError, "buffer.itemsize does not match PointerToArray element size"); + return; + } + + int num_elements = view.len / sizeof(Element); + this->_this->insert(this->_this->begin(), num_elements, Element()); + + if (view.len > 0) { + memcpy(this->_this->p(), view.buf, view.len); + } + + PyBuffer_Release(&view); + return; + } +#endif + + if (!PySequence_Check(source)) { + // If passed with a non-sequence, this isn't the right constructor. + PyErr_SetString(PyExc_TypeError, "PointerToArray constructor requires a sequence or buffer object"); + return; + } + + // If we were passed a Python string, then instead of storing it + // character-at-a-time, just load the whole string as a data + // buffer. +#if PY_MAJOR_VERSION >= 3 + if (PyBytes_Check(source)) { + int size = PyBytes_Size(source); + if (size % sizeof(Element) != 0) { + ostringstream stream; + stream << "Buffer not a multiple of " << sizeof(Element) << " bytes"; + string str = stream.str(); + PyErr_SetString(PyExc_ValueError, str.c_str()); + return; + } + + int num_elements = size / sizeof(Element); + this->_this->insert(this->_this->begin(), num_elements, Element()); + + // Hope there aren't any constructors or destructors involved + // here. + if (size != 0) { + const char *data = PyBytes_AsString(source); + memcpy(this->_this->p(), data, size); + } + return; + } +#else + if (PyString_CheckExact(source)) { + int size = PyString_Size(source); + if (size % sizeof(Element) != 0) { + ostringstream stream; + stream << "Buffer not a multiple of " << sizeof(Element) << " bytes"; + string str = stream.str(); + PyErr_SetString(PyExc_ValueError, str.c_str()); + return; + } + + int num_elements = size / sizeof(Element); + this->_this->insert(this->_this->begin(), num_elements, Element()); + + // Hope there aren't any constructors or destructors involved + // here. + if (size != 0) { + const char *data = PyString_AsString(source); + memcpy(this->_this->p(), data, size); + } + return; + } +#endif + + // Now construct the internal list by copying the elements + // one-at-a-time from Python. + int size = PySequence_Size(source); + for (int i = 0; i < size; ++i) { + PyObject *item = PySequence_GetItem(source, i); + if (item == NULL) { + return; + } + PyObject *result = PyObject_CallMethod(self, (char *)"push_back", (char *)"O", item); + Py_DECREF(item); + if (result == NULL) { + // Unable to add item--probably it wasn't of the appropriate type. + ostringstream stream; + stream << "Element " << i << " in sequence passed to PointerToArray constructor could not be added"; + string str = stream.str(); + PyErr_SetString(PyExc_TypeError, str.c_str()); + return; + } + Py_DECREF(result); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: PointerToArray::__getitem__ +// Access: Published +// Description: Same as get_element(), this returns the nth element +// of the array. +//////////////////////////////////////////////////////////////////// +template +INLINE const Element &Extension >:: +__getitem__(size_t n) const { + return this->_this->get_element(n); +} + +//////////////////////////////////////////////////////////////////// +// Function: PointerToArray::__setitem__ +// Access: Published +// Description: Same as set_element(), this replaces the nth element +// of the array. +//////////////////////////////////////////////////////////////////// +template +INLINE void Extension >:: +__setitem__(size_t n, const Element &value) { + this->_this->set_element(n, value); +} + +//////////////////////////////////////////////////////////////////// +// Function: ConstPointerToArray::__init__ +// Access: Public +// Description: This special constructor accepts a Python list of +// elements, or a Python string (or a bytes object, +// in Python 3). +//////////////////////////////////////////////////////////////////// +template +INLINE void Extension >:: +__init__(PyObject *self, PyObject *source) { + new (this->_this) ConstPointerToArray(get_type_handle(Element)); +} + +//////////////////////////////////////////////////////////////////// +// Function: ConstPointerToArray::__getitem__ +// Access: Published +// Description: Same as get_element(), this returns the nth element +// of the array. +//////////////////////////////////////////////////////////////////// +template +INLINE const Element &Extension >:: +__getitem__(size_t n) const { + return (*this->_this)[n]; +} + +#if PY_VERSION_HEX >= 0x02060000 +//////////////////////////////////////////////////////////////////// +// Function: PointerToArray::__getbuffer__ +// Access: Published +// Description: This is used to implement the buffer protocol, in +// order to allow efficient access to the array data +// through a Python multiview object. +//////////////////////////////////////////////////////////////////// +template +INLINE int Extension >:: +__getbuffer__(PyObject *self, Py_buffer *view, int flags) { + + const char *format = get_format_code(Element); + if (format == NULL) { + // Not supported. + return -1; + } + + if (self != NULL) { + Py_INCREF(self); + } + view->obj = self; + view->buf = (void*) this->_this->p(); + view->len = this->_this->size() * sizeof(Element); + view->readonly = 0; + view->itemsize = sizeof(Element); + view->format = NULL; + if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { + view->format = (char*) format; + } + view->ndim = 1; + view->shape = NULL; + if ((flags & PyBUF_ND) == PyBUF_ND) { + // This leaks, which sucks, but __releasebuffer__ doesn't give us + // the same pointer, so we would need to store it elsewhere if we + // wanted to delete it there. Eh, it's just an int, who cares. + view->shape = new Py_ssize_t(this->_this->size()); + } + view->strides = NULL; + if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { + view->strides = &(view->itemsize); + } + view->suboffsets = NULL; + + // Store a reference to ourselves on the Py_buffer object + // as a reminder that we have increased our refcount. + this->_this->ref(); + view->internal = (void*) this->_this; + + return 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: PointerToArray::__releasebuffer__ +// Access: Published +// Description: Releases the buffer allocated by __getbuffer__. +//////////////////////////////////////////////////////////////////// +template +INLINE void Extension >:: +__releasebuffer__(PyObject *self, Py_buffer *view) const { + // Note: PyBuffer_Release automatically decrements view->obj. + + if (view->internal != NULL) { + // Oh, right, let's not forget to unref this. + ((const PointerToArray *) view->internal)->unref(); + view->internal = NULL; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: ConstPointerToArray::__getbuffer__ +// Access: Published +// Description: This is used to implement the buffer protocol, in +// order to allow efficient access to the array data +// through a Python multiview object. +//////////////////////////////////////////////////////////////////// +template +INLINE int Extension >:: +__getbuffer__(PyObject *self, Py_buffer *view, int flags) const { + + if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) { + PyErr_SetString(PyExc_BufferError, + "Object is not writable."); + return -1; + } + + const char *format = get_format_code(Element); + if (format == NULL) { + // Not supported. + return -1; + } + + if (self != NULL) { + Py_INCREF(self); + } + view->obj = self; + view->buf = (void*) this->_this->p(); + view->len = this->_this->size() * sizeof(Element); + view->readonly = 1; + view->itemsize = sizeof(Element); + view->format = NULL; + if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { + view->format = (char*) format; + } + view->ndim = 1; + view->shape = NULL; + if ((flags & PyBUF_ND) == PyBUF_ND) { + // This leaks, which sucks, but __releasebuffer__ doesn't give us + // the same pointer, so we would need to store it elsewhere if we + // wanted to delete it there. Eh, it's just an int, who cares. + view->shape = new Py_ssize_t(this->_this->size()); + } + view->strides = NULL; + if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { + view->strides = &(view->itemsize); + } + view->suboffsets = NULL; + + // Store a reference to ourselves on the Py_buffer object + // as a reminder that we have increased our refcount. + this->_this->ref(); + view->internal = (void*) this->_this; + + return 0; +} + +//////////////////////////////////////////////////////////////////// +// Function: ConstPointerToArray::__releasebuffer__ +// Access: Published +// Description: Releases the buffer allocated by __getbuffer__. +//////////////////////////////////////////////////////////////////// +template +INLINE void Extension >:: +__releasebuffer__(PyObject *self, Py_buffer *view) const { + // Note: PyBuffer_Release automatically decrements obj->view. + + if (view->internal != NULL) { + // Oh, right, let's not forget to unref this. + ((const PointerToArray *) view->internal)->unref(); + view->internal = NULL; + } +} +#endif // PY_VERSION_HEX diff --git a/panda/src/express/pointerToArray_ext.h b/panda/src/express/pointerToArray_ext.h new file mode 100644 index 0000000000..b403ed4dc6 --- /dev/null +++ b/panda/src/express/pointerToArray_ext.h @@ -0,0 +1,100 @@ +// Filename: pointerToArray_ext.h +// Created by: rdb (08Feb15) +// +//////////////////////////////////////////////////////////////////// +// +// 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 POINTERTOARRAY_EXT_H +#define POINTERTOARRAY_EXT_H + +#ifndef CPPPARSER + +#include "extension.h" +#include "py_panda.h" +#include "pointerToArray.h" + +//////////////////////////////////////////////////////////////////// +// Class : Extension +// Description : This class defines the extension methods for +// PointerToArray, which are called instead of +// any C++ methods with the same prototype. +// +// This is a little bit awkward because of the nested +// templating, but it does the job. +//////////////////////////////////////////////////////////////////// +template +class Extension > : public ExtensionBase > { +public: + INLINE void __init__(PyObject *self, PyObject *source); + + INLINE const Element &__getitem__(size_t n) const; + INLINE void __setitem__(size_t n, const Element &value); + +#if PY_VERSION_HEX >= 0x02060000 + INLINE int __getbuffer__(PyObject *self, Py_buffer *view, int flags); + INLINE void __releasebuffer__(PyObject *self, Py_buffer *view) const; +#endif +}; + +//////////////////////////////////////////////////////////////////// +// Class : Extension +// Description : This class defines the extension methods for +// ConstPointerToArray, which are called instead of +// any C++ methods with the same prototype. +// +// This is a little bit awkward because of the nested +// templating, but it does the job. +//////////////////////////////////////////////////////////////////// +template +class Extension > : public ExtensionBase > { +public: + INLINE void __init__(PyObject *self, PyObject *source); + + INLINE const Element &__getitem__(size_t n) const; + +#if PY_VERSION_HEX >= 0x02060000 + INLINE int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const; + INLINE void __releasebuffer__(PyObject *self, Py_buffer *view) const; +#endif +}; + +// This macro is used to map a data type to a format code +// as used in the Python 'struct' and 'array' modules. +#define get_format_code(type) _get_format_code((const type *)0) +#define define_format_code(code, type) template<> \ + INLINE const char *_get_format_code(const type *) { \ + return code; \ + } + +template +INLINE const char *_get_format_code(const T *) { + return NULL; +} + +define_format_code("c", char); +define_format_code("b", signed char); +define_format_code("B", unsigned char); +define_format_code("h", short); +define_format_code("H", unsigned short); +define_format_code("i", int); +define_format_code("I", unsigned int); +define_format_code("l", long); +define_format_code("L", unsigned long); +define_format_code("q", long long); +define_format_code("Q", unsigned long long); +define_format_code("f", float); +define_format_code("d", double); + +#include "pointerToArray_ext.I" + +#endif // CPPPARSER + +#endif // HAVE_POINTERTOARRAY_EXT_H diff --git a/panda/src/express/trueClock.cxx b/panda/src/express/trueClock.cxx index e6d9a73125..aeb2a28e56 100644 --- a/panda/src/express/trueClock.cxx +++ b/panda/src/express/trueClock.cxx @@ -30,7 +30,9 @@ TrueClock *TrueClock::_global_ptr = NULL; //////////////////////////////////////////////////////////////////// #include -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include static const double _0001 = 1.0 / 1000.0; diff --git a/panda/src/express/virtualFileSystem_ext.cxx b/panda/src/express/virtualFileSystem_ext.cxx index 3f1c3f40f8..9de1786987 100644 --- a/panda/src/express/virtualFileSystem_ext.cxx +++ b/panda/src/express/virtualFileSystem_ext.cxx @@ -13,6 +13,7 @@ //////////////////////////////////////////////////////////////////// #include "virtualFileSystem_ext.h" +#include "vector_uchar.h" #ifdef HAVE_PYTHON @@ -30,7 +31,7 @@ //////////////////////////////////////////////////////////////////// PyObject *Extension:: read_file(const Filename &filename, bool auto_unwrap) const { - pvector pv; + vector_uchar pv; bool okflag = _this->read_file(filename, pv, auto_unwrap); nassertr(okflag, NULL); diff --git a/panda/src/express/windowsRegistry.cxx b/panda/src/express/windowsRegistry.cxx index f186476dd1..60865ddfad 100755 --- a/panda/src/express/windowsRegistry.cxx +++ b/panda/src/express/windowsRegistry.cxx @@ -17,7 +17,9 @@ #include "textEncoder.h" #if defined(WIN32_VC) -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include //////////////////////////////////////////////////////////////////// diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index cb7d50678e..85b18b6f9d 100755 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -215,72 +215,132 @@ issue_parameters(int altered) { switch (ptr_data->_type) { case Shader::SPT_float: switch(_ptr._info._class) { - case Shader::SAC_scalar: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue; + case Shader::SAC_scalar: + cgSetParameter1fv(p, (float*)ptr_data->_ptr); + continue; + case Shader::SAC_vector: switch (_ptr._info._type) { - case Shader::SAT_vec1: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue; - case Shader::SAT_vec2: cgSetParameter2fv(p,(float*)ptr_data->_ptr); continue; - case Shader::SAT_vec3: cgSetParameter3fv(p,(float*)ptr_data->_ptr); continue; - case Shader::SAT_vec4: cgSetParameter4fv(p,(float*)ptr_data->_ptr); continue; - default: nassertd(false) continue; + case Shader::SAT_vec1: + cgSetParameter1fv(p, (float*)ptr_data->_ptr); + continue; + case Shader::SAT_vec2: + cgSetParameter2fv(p, (float*)ptr_data->_ptr); + continue; + case Shader::SAT_vec3: + cgSetParameter3fv(p, (float*)ptr_data->_ptr); + continue; + case Shader::SAT_vec4: + cgSetParameter4fv(p, (float*)ptr_data->_ptr); + continue; + default: + nassertd(false) continue; } - case Shader::SAC_matrix: cgGLSetMatrixParameterfc(p,(float*)ptr_data->_ptr); continue; - case Shader::SAC_array: { + continue; + + case Shader::SAC_matrix: + cgGLSetMatrixParameterfc(p, (float*)ptr_data->_ptr); + continue; + + case Shader::SAC_array: switch (_ptr._info._subclass) { case Shader::SAC_scalar: - cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; + cgGLSetParameterArray1f(p, 0, _ptr._dim[0], (float*)ptr_data->_ptr); + continue; case Shader::SAC_vector: switch (_ptr._dim[2]) { - case 1: cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; - case 2: cgGLSetParameterArray2f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; - case 3: cgGLSetParameterArray3f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; - case 4: cgGLSetParameterArray4f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; + case 1: cgGLSetParameterArray1f(p, 0, _ptr._dim[0], (float*)ptr_data->_ptr); continue; + case 2: cgGLSetParameterArray2f(p, 0, _ptr._dim[0], (float*)ptr_data->_ptr); continue; + case 3: cgGLSetParameterArray3f(p, 0, _ptr._dim[0], (float*)ptr_data->_ptr); continue; + case 4: cgGLSetParameterArray4f(p, 0, _ptr._dim[0], (float*)ptr_data->_ptr); continue; + default: + nassertd(_ptr._dim[2] > 0 && _ptr._dim[2] <= 4) continue; } + continue; case Shader::SAC_matrix: - cgGLSetMatrixParameterArrayfc(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; + cgGLSetMatrixParameterArrayfc(p, 0, _ptr._dim[0], (float*)ptr_data->_ptr); + continue; + default: + nassertd(false) continue; } + default: + nassertd(false) continue; } - } + case Shader::SPT_double: switch(_ptr._info._class) { - case Shader::SAC_scalar: cgSetParameter1dv(p,(double*)ptr_data->_ptr); continue; + case Shader::SAC_scalar: + cgSetParameter1dv(p, (double*)ptr_data->_ptr); + continue; + case Shader::SAC_vector: - switch(_ptr._info._type) { - case Shader::SAT_vec1: cgSetParameter1dv(p,(double*)ptr_data->_ptr); continue; - case Shader::SAT_vec2: cgSetParameter2dv(p,(double*)ptr_data->_ptr); continue; - case Shader::SAT_vec3: cgSetParameter3dv(p,(double*)ptr_data->_ptr); continue; - case Shader::SAT_vec4: cgSetParameter4dv(p,(double*)ptr_data->_ptr); continue; - default: nassertd(false) continue; + switch (_ptr._info._type) { + case Shader::SAT_vec1: + cgSetParameter1dv(p, (double*)ptr_data->_ptr); + continue; + case Shader::SAT_vec2: + cgSetParameter2dv(p, (double*)ptr_data->_ptr); + continue; + case Shader::SAT_vec3: + cgSetParameter3dv(p, (double*)ptr_data->_ptr); + continue; + case Shader::SAT_vec4: + cgSetParameter4dv(p, (double*)ptr_data->_ptr); + continue; + default: + nassertd(false) continue; } - case Shader::SAC_matrix: cgGLSetMatrixParameterdc(p,(double*)ptr_data->_ptr); continue; - case Shader::SAC_array: { - switch(_ptr._info._subclass) { + continue; + + case Shader::SAC_matrix: + cgGLSetMatrixParameterdc(p, (double*)ptr_data->_ptr); + continue; + + case Shader::SAC_array: + switch (_ptr._info._subclass) { case Shader::SAC_scalar: - cgGLSetParameterArray1d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; + cgGLSetParameterArray1d(p, 0, _ptr._dim[0], (double*)ptr_data->_ptr); + continue; case Shader::SAC_vector: - switch(_ptr._dim[2]) { - case 1: cgGLSetParameterArray1d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; - case 2: cgGLSetParameterArray2d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; - case 3: cgGLSetParameterArray3d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; - case 4: cgGLSetParameterArray4d(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; + switch (_ptr._dim[2]) { + case 1: cgGLSetParameterArray1d(p, 0, _ptr._dim[0], (double*)ptr_data->_ptr); continue; + case 2: cgGLSetParameterArray2d(p, 0, _ptr._dim[0], (double*)ptr_data->_ptr); continue; + case 3: cgGLSetParameterArray3d(p, 0, _ptr._dim[0], (double*)ptr_data->_ptr); continue; + case 4: cgGLSetParameterArray4d(p, 0, _ptr._dim[0], (double*)ptr_data->_ptr); continue; + default: + nassertd(_ptr._dim[2] > 0 && _ptr._dim[2] <= 4) continue; } + continue; case Shader::SAC_matrix: - cgGLSetMatrixParameterArraydc(p,0,_ptr._dim[0],(double*)ptr_data->_ptr); continue; + cgGLSetMatrixParameterArraydc(p, 0, _ptr._dim[0], (double*)ptr_data->_ptr); + continue; + default: + nassertd(false) continue; } + default: + nassertd(false) continue; } - } + continue; + case Shader::SPT_int: switch(_ptr._info._class) { - case Shader::SAC_scalar: cgSetParameter1iv(p,(int*)ptr_data->_ptr); continue; + case Shader::SAC_scalar: + cgSetParameter1iv(p, (int*)ptr_data->_ptr); + continue; case Shader::SAC_vector: switch(_ptr._info._type) { - case Shader::SAT_vec1: cgSetParameter1iv(p,(int*)ptr_data->_ptr); continue; - case Shader::SAT_vec2: cgSetParameter2iv(p,(int*)ptr_data->_ptr); continue; - case Shader::SAT_vec3: cgSetParameter3iv(p,(int*)ptr_data->_ptr); continue; - case Shader::SAT_vec4: cgSetParameter4iv(p,(int*)ptr_data->_ptr); continue; + case Shader::SAT_vec1: cgSetParameter1iv(p, (int*)ptr_data->_ptr); continue; + case Shader::SAT_vec2: cgSetParameter2iv(p, (int*)ptr_data->_ptr); continue; + case Shader::SAT_vec3: cgSetParameter3iv(p, (int*)ptr_data->_ptr); continue; + case Shader::SAT_vec4: cgSetParameter4iv(p, (int*)ptr_data->_ptr); continue; + default: + nassertd(false) continue; } + default: + nassertd(false) continue; } - default: GLCAT.error() << _ptr._id._name << ":" << "unrecognized parameter type\n"; + default: + GLCAT.error() << _ptr._id._name << ":" << "unrecognized parameter type\n"; release_resources(); return; } diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 36f1264f51..0d0c019b65 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -8811,6 +8811,11 @@ set_state_and_transform(const RenderState *target, //PStatGPUTimer timer(this, _draw_set_state_clip_plane_pcollector); do_issue_clip_plane(); _state_mask.set_bit(clip_plane_slot); +#ifndef OPENGLES_1 + if (_current_shader_context) { + _current_shader_context->issue_parameters(Shader::SSD_clip_planes); + } +#endif } int color_slot = ColorAttrib::get_class_slot(); diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 399d583aab..e6a0d4551e 100755 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -412,6 +412,25 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext s->_mat_spec.push_back(bind); continue; } + if (noprefix == "ClipPlane") { + for (int i = 0; i < param_size; ++i) { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._id._seqno = seqno++; + bind._piece = Shader::SMP_row3; + bind._func = Shader::SMF_first; + bind._index = i; + bind._part[0] = Shader::SMO_apiview_clipplane_i; + bind._arg[0] = NULL; + bind._dep[0] = Shader::SSD_general | Shader::SSD_clip_planes; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + s->_mat_spec.push_back(bind); + _glsl_parameter_map.push_back(p + i); + } + continue; + } if (noprefix == "LightModel.ambient") { Shader::ShaderMatSpec bind; bind._id = arg_id; diff --git a/panda/src/gobj/Sources.pp b/panda/src/gobj/Sources.pp index 8b71bfac5a..7ac03ff431 100644 --- a/panda/src/gobj/Sources.pp +++ b/panda/src/gobj/Sources.pp @@ -8,7 +8,8 @@ #define LOCAL_LIBS \ p3pstatclient p3event p3linmath p3mathutil p3pnmimage p3gsgbase p3putil - #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx + #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx \ + $[TARGET]_ext_composite.cxx #define SOURCES \ adaptiveLru.I adaptiveLru.h \ @@ -30,7 +31,7 @@ geomLinestrips.h \ geomPoints.h \ geomVertexArrayData.h geomVertexArrayData.I \ - geomVertexArrayData_ext.h geomVertexArrayData_ext.cxx \ + geomVertexArrayData_ext.h \ geomVertexArrayFormat.h geomVertexArrayFormat.I \ geomCacheEntry.h geomCacheEntry.I \ geomCacheManager.h geomCacheManager.I \ @@ -43,7 +44,7 @@ geomVertexWriter.h geomVertexWriter.I \ indexBufferContext.I indexBufferContext.h \ internalName.I internalName.h \ - internalName_ext.h internalName_ext.cxx \ + internalName_ext.h \ lens.h lens.I \ material.I material.h materialPool.I materialPool.h \ matrixLens.I matrixLens.h \ @@ -82,7 +83,7 @@ vertexSlider.I vertexSlider.h \ vertexTransform.I vertexTransform.h \ videoTexture.I videoTexture.h - + #define INCLUDED_SOURCES \ adaptiveLru.cxx \ animateVerticesRequest.cxx \ @@ -103,6 +104,7 @@ geomLinestrips.cxx \ geomPoints.cxx \ geomVertexArrayData.cxx \ + geomVertexArrayData_ext.cxx \ geomVertexArrayFormat.cxx \ geomCacheEntry.cxx \ geomCacheManager.cxx \ @@ -116,6 +118,7 @@ indexBufferContext.cxx \ material.cxx \ internalName.cxx \ + internalName_ext.cxx \ lens.cxx \ materialPool.cxx matrixLens.cxx \ occlusionQueryContext.cxx \ @@ -131,6 +134,7 @@ sliderTable.cxx \ texture.cxx \ textureCollection.cxx \ + textureCollection_ext.cxx \ textureContext.cxx \ texturePeeker.cxx \ texturePool.cxx \ diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 2fb8783333..7a265b66a0 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -369,7 +369,7 @@ unclean_set_format(const GeomVertexFormat *format) { // Assign the new format. cdataw->_format = format; - for (int ai = 0; ai < cdataw->_arrays.size(); ++ai) { + for (size_t ai = 0; ai < cdataw->_arrays.size(); ++ai) { PT(GeomVertexArrayData) array_obj = cdataw->_arrays[ai].get_write_pointer(); array_obj->_array_format = format->get_array(ai); } diff --git a/panda/src/gobj/p3gobj_ext_composite.cxx b/panda/src/gobj/p3gobj_ext_composite.cxx new file mode 100644 index 0000000000..33584e701b --- /dev/null +++ b/panda/src/gobj/p3gobj_ext_composite.cxx @@ -0,0 +1,3 @@ +#include "internalName_ext.cxx" +#include "geomVertexArrayData_ext.cxx" +#include "textureCollection_ext.cxx" diff --git a/panda/src/gobj/shader.I b/panda/src/gobj/shader.I index 56549c863d..e101a07dfc 100755 --- a/panda/src/gobj/shader.I +++ b/panda/src/gobj/shader.I @@ -866,7 +866,7 @@ get_filename_from_index(int index, ShaderType type) const { return fn; } } else if (glsl_preprocess && index > 2048 && - (index - 2048) < _included_files.size()) { + (index - 2048) < (int)_included_files.size()) { return _included_files[index - 2048]; } // Must be a mistake. Quietly put back the integer. diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index c74c694bdd..ced776921d 100755 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -27,10 +27,13 @@ TypeHandle Shader::_type_handle; Shader::ShaderTable Shader::_load_table; Shader::ShaderTable Shader::_make_table; Shader::ShaderCaps Shader::_default_caps; -CGcontext Shader::_cg_context = 0; int Shader::_shaders_generated; ShaderUtilization Shader::_shader_utilization = SUT_unspecified; +#ifdef HAVE_CG +CGcontext Shader::_cg_context = 0; +#endif + //////////////////////////////////////////////////////////////////// // Function: Shader::cp_report_error // Access: Public @@ -424,7 +427,6 @@ cp_dependency(ShaderMatInput inp) { (inp == SMO_mat_constant_x) || (inp == SMO_vec_constant_x) || (inp == SMO_vec_constant_x_attrib) || - (inp == SMO_clipplane_x) || (inp == SMO_view_x_to_view) || (inp == SMO_view_to_view_x) || (inp == SMO_apiview_x_to_view) || @@ -444,6 +446,10 @@ cp_dependency(ShaderMatInput inp) { (inp == SMO_light_product_i_specular)) { dep |= (SSD_light | SSD_material); } + if ((inp == SMO_clipplane_x) || + (inp == SMO_apiview_clipplane_i)) { + dep |= SSD_clip_planes; + } return dep; } @@ -643,7 +649,7 @@ compile_parameter(const ShaderArgId &arg_id, } bind._name = InternalName::get_root(); - for (int i = 1; i < pieces.size(); ++i) { + for (size_t i = 1; i < pieces.size(); ++i) { bind._name = bind._name->append(pieces[i]); } _var_spec.push_back(bind); diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 9ed5411c84..805e2ea4f6 100755 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -183,6 +183,9 @@ public: SMO_light_product_i_diffuse, SMO_light_product_i_specular, + // SMO_clipplane_x is world coords, GLSL needs eye coords + SMO_apiview_clipplane_i, + SMO_INVALID }; @@ -261,6 +264,7 @@ public: SSD_shaderinputs = 0x020, SSD_fog = 0x040, SSD_light = 0x080, + SSD_clip_planes = 0x100, }; enum ShaderBug { @@ -307,7 +311,7 @@ public: void *_ptr; ShaderPtrType _type; bool _updated; - int _size; //number of elements vec3[4]=12 + size_t _size; //number of elements vec3[4]=12 public: INLINE ShaderPtrData(); diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 53f32dd336..d44903e921 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -3325,7 +3325,7 @@ do_load_one(CData *cdata, const PfmFile &pfm, const string &name, int z, int n, //////////////////////////////////////////////////////////////////// bool Texture:: do_load_sub_image(CData *cdata, const PNMImage &image, int x, int y, int z, int n) { - nassertr(n >= 0 && n < cdata->_ram_images.size(), false); + nassertr(n >= 0 && (size_t)n < cdata->_ram_images.size(), false); int tex_x_size = do_get_expected_mipmap_x_size(cdata, n); int tex_y_size = do_get_expected_mipmap_y_size(cdata, n); @@ -4378,11 +4378,11 @@ do_make_ram_mipmap_image(CData *cdata, int n) { if (cdata->_has_clear_color) { // Fill the image with the clear color. unsigned char pixel[16]; - const int pixel_size = do_get_clear_data(cdata, pixel); + const size_t pixel_size = (size_t)do_get_clear_data(cdata, pixel); nassertr(pixel_size > 0, cdata->_ram_images[n]._image); unsigned char *image_data = cdata->_ram_images[n]._image; - for (int i = 0; i < image_size; i += pixel_size) { + for (size_t i = 0; i < image_size; i += pixel_size) { memcpy(image_data + i, pixel, pixel_size); } } diff --git a/panda/src/gobj/textureCollection.cxx b/panda/src/gobj/textureCollection.cxx index 6bddb5f199..40e8651edb 100644 --- a/panda/src/gobj/textureCollection.cxx +++ b/panda/src/gobj/textureCollection.cxx @@ -49,79 +49,6 @@ operator = (const TextureCollection ©) { _textures = copy._textures; } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::Constructor -// Access: Published -// Description: This special constructor accepts a Python list of -// Textures. Since this constructor accepts a generic -// PyObject *, it should be the last constructor listed -// in the class record. -//////////////////////////////////////////////////////////////////// -TextureCollection:: -TextureCollection(PyObject *self, PyObject *sequence) { - // We have to pre-initialize self's "this" pointer when we receive - // self in the constructor--the caller can't initialize this for us. - ((Dtool_PyInstDef *)self)->_ptr_to_object = this; - - if (!PySequence_Check(sequence)) { - // If passed with a non-sequence, this isn't the right constructor. - PyErr_SetString(PyExc_TypeError, "TextureCollection constructor requires a sequence"); - return; - } - - int size = PySequence_Size(sequence); - for (int i = 0; i < size; ++i) { - PyObject *item = PySequence_GetItem(sequence, i); - if (item == NULL) { - return; - } - PyObject *result = PyObject_CallMethod(self, (char *)"add_texture", (char *)"O", item); - Py_DECREF(item); - if (result == NULL) { - // Unable to add item--probably it wasn't of the appropriate type. - ostringstream stream; - stream << "Element " << i << " in sequence passed to TextureCollection constructor could not be added"; - string str = stream.str(); - PyErr_SetString(PyExc_TypeError, str.c_str()); - return; - } - Py_DECREF(result); - } -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// -PyObject *TextureCollection:: -__reduce__(PyObject *self) const { - // Here we will return a 4-tuple: (Class, (args), None, iterator), - // where iterator is an iterator that will yield successive - // Textures. - - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. - - PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; - } - - // Since a TextureCollection is itself an iterator, we can simply - // pass it as the fourth tuple component. - PyObject *result = Py_BuildValue("(O()OO)", this_class, Py_None, self); - Py_DECREF(this_class); - return result; -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: TextureCollection::add_texture // Access: Published @@ -270,6 +197,18 @@ clear() { _textures.clear(); } +//////////////////////////////////////////////////////////////////// +// Function: TextureCollection::reserve +// Access: Published +// Description: This is a hint to Panda to allocate enough memory +// to hold the given number of NodePaths, if you know +// ahead of time how many you will be adding. +//////////////////////////////////////////////////////////////////// +void TextureCollection:: +reserve(size_t num) { + _textures.reserve(num); +} + //////////////////////////////////////////////////////////////////// // Function: TextureCollection::find_texture // Access: Published diff --git a/panda/src/gobj/textureCollection.h b/panda/src/gobj/textureCollection.h index 38d3dc6faa..9be7b78f88 100644 --- a/panda/src/gobj/textureCollection.h +++ b/panda/src/gobj/textureCollection.h @@ -32,8 +32,8 @@ PUBLISHED: INLINE ~TextureCollection(); #ifdef HAVE_PYTHON - TextureCollection(PyObject *self, PyObject *sequence); - PyObject *__reduce__(PyObject *self) const; + EXTENSION(TextureCollection(PyObject *self, PyObject *sequence)); + EXTENSION(PyObject *__reduce__(PyObject *self) const); #endif void add_texture(Texture *texture); @@ -43,6 +43,7 @@ PUBLISHED: void remove_duplicate_textures(); bool has_texture(Texture *texture) const; void clear(); + void reserve(size_t num); Texture *find_texture(const string &name) const; @@ -74,5 +75,3 @@ INLINE ostream &operator << (ostream &out, const TextureCollection &col) { #include "textureCollection.I" #endif - - diff --git a/panda/src/gobj/textureCollection_ext.cxx b/panda/src/gobj/textureCollection_ext.cxx new file mode 100644 index 0000000000..e90295430b --- /dev/null +++ b/panda/src/gobj/textureCollection_ext.cxx @@ -0,0 +1,94 @@ +// Filename: textureCollection_ext.cxx +// Created by: rdb (11Feb15) +// +//////////////////////////////////////////////////////////////////// +// +// 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 "textureCollection_ext.h" + +#ifdef HAVE_PYTHON + +#ifndef CPPPARSER +extern struct Dtool_PyTypedObject Dtool_Texture; +#endif + +//////////////////////////////////////////////////////////////////// +// Function: TextureCollection::__init__ +// Access: Published +// Description: This special constructor accepts a Python list of +// Textures. Since this constructor accepts a generic +// PyObject *, it should be the last constructor listed +// in the class record. +//////////////////////////////////////////////////////////////////// +void Extension:: +__init__(PyObject *self, PyObject *sequence) { + PyObject *fast = PySequence_Fast(sequence, "TextureCollection constructor requires a sequence"); + if (fast == NULL) { + return; + } + + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast); + _this->reserve(size); + + for (int i = 0; i < size; ++i) { + PyObject *item = PySequence_Fast_GET_ITEM(fast, i); + if (item == NULL) { + return; + } + + Texture *tex; + DTOOL_Call_ExtractThisPointerForType(item, &Dtool_Texture, (void **)&tex); + if (tex == (Texture *)NULL) { + // Unable to add item--probably it wasn't of the appropriate type. + ostringstream stream; + stream << "Element " << i << " in sequence passed to TextureCollection constructor is not a Texture"; + string str = stream.str(); + PyErr_SetString(PyExc_TypeError, str.c_str()); + Py_DECREF(fast); + return; + } else { + _this->add_texture(tex); + } + } + + Py_DECREF(fast); +} + +//////////////////////////////////////////////////////////////////// +// Function: TextureCollection::__reduce__ +// Access: Published +// Description: This special Python method is implement to provide +// support for the pickle module. +//////////////////////////////////////////////////////////////////// +PyObject *Extension:: +__reduce__(PyObject *self) const { + // Here we will return a 4-tuple: (Class, (args), None, iterator), + // where iterator is an iterator that will yield successive + // Textures. + + // We should return at least a 2-tuple, (Class, (args)): the + // necessary class object whose constructor we should call + // (e.g. this), and the arguments necessary to reconstruct this + // object. + + PyObject *this_class = PyObject_Type(self); + if (this_class == NULL) { + return NULL; + } + + // Since a TextureCollection is itself an iterator, we can simply + // pass it as the fourth tuple component. + PyObject *result = Py_BuildValue("(O()OO)", this_class, Py_None, self); + Py_DECREF(this_class); + return result; +} + +#endif // HAVE_PYTHON diff --git a/panda/src/gobj/textureCollection_ext.h b/panda/src/gobj/textureCollection_ext.h new file mode 100644 index 0000000000..2818782e6a --- /dev/null +++ b/panda/src/gobj/textureCollection_ext.h @@ -0,0 +1,42 @@ +// Filename: textureCollection_ext.h +// Created by: rdb (11Feb15) +// +//////////////////////////////////////////////////////////////////// +// +// 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 TEXTURECOLLECTION_EXT_H +#define TEXTURECOLLECTION_EXT_H + +#include "dtoolbase.h" + +#ifdef HAVE_PYTHON + +#include "extension.h" +#include "textureCollection.h" +#include "py_panda.h" + +//////////////////////////////////////////////////////////////////// +// Class : Extension +// Description : This class defines the extension methods for +// TextureCollection, which are called instead of +// any C++ methods with the same prototype. +//////////////////////////////////////////////////////////////////// +template<> +class Extension : public ExtensionBase { +public: + void __init__(PyObject *self, PyObject *sequence); + + PyObject *__reduce__(PyObject *self) const; +}; + +#endif // HAVE_PYTHON + +#endif // TEXTURECOLLECTION_EXT_H diff --git a/panda/src/gobj/transformBlend.cxx b/panda/src/gobj/transformBlend.cxx index d450392fe2..d26c43c24f 100644 --- a/panda/src/gobj/transformBlend.cxx +++ b/panda/src/gobj/transformBlend.cxx @@ -109,7 +109,7 @@ limit_transforms(int max_transforms) { return; } - while (_entries.size() > max_transforms) { + while ((int)_entries.size() > max_transforms) { // Repeatedly find and remove the least-important transform. nassertv(!_entries.empty()); Entries::iterator ei_least = _entries.begin(); diff --git a/panda/src/gobj/vertexDataPage.h b/panda/src/gobj/vertexDataPage.h index a6a6e4eafb..7553cdd9f1 100644 --- a/panda/src/gobj/vertexDataPage.h +++ b/panda/src/gobj/vertexDataPage.h @@ -114,7 +114,7 @@ private: typedef pdeque PendingPages; class PageThreadManager; - class PageThread : public Thread { + class EXPCL_PANDA_GOBJ PageThread : public Thread { public: PageThread(PageThreadManager *manager, const string &name); @@ -132,7 +132,7 @@ private: }; typedef pvector PageThreads; - class PageThreadManager : public ReferenceCount { + class EXPCL_PANDA_GOBJ PageThreadManager : public ReferenceCount { public: PageThreadManager(int num_threads); void add_page(VertexDataPage *page, RamClass ram_class); @@ -176,7 +176,7 @@ private: // We build up a temporary linked list of these while deflating // (compressing) the vertex data in-memory. - class DeflatePage { + class EXPCL_PANDA_GOBJ DeflatePage { public: DeflatePage() { _used_size = 0; diff --git a/panda/src/gobj/vertexDataSaveFile.h b/panda/src/gobj/vertexDataSaveFile.h index 948d8a7ba8..be943ff179 100644 --- a/panda/src/gobj/vertexDataSaveFile.h +++ b/panda/src/gobj/vertexDataSaveFile.h @@ -21,7 +21,9 @@ #include "pmutex.h" #if defined(_WIN32) -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include #endif diff --git a/panda/src/linmath/lpoint2_ext_src.I b/panda/src/linmath/lpoint2_ext_src.I index d6deaa3a8b..3b66477d6d 100644 --- a/panda/src/linmath/lpoint2_ext_src.I +++ b/panda/src/linmath/lpoint2_ext_src.I @@ -12,12 +12,6 @@ // //////////////////////////////////////////////////////////////////// -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint4); -#endif - #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 #define PY_FROM_FLOATTYPE PyLong_FromLong @@ -47,6 +41,12 @@ python_repr(ostream &out, const string &class_name) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: __getattr__(const string &attr_name) const { +#ifndef CPPPARSER + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint4); +#endif + // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { diff --git a/panda/src/linmath/lpoint3_ext_src.I b/panda/src/linmath/lpoint3_ext_src.I index 583c4ff55a..2eaca34737 100644 --- a/panda/src/linmath/lpoint3_ext_src.I +++ b/panda/src/linmath/lpoint3_ext_src.I @@ -12,12 +12,6 @@ // //////////////////////////////////////////////////////////////////// -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint4); -#endif - #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 #define PY_FROM_FLOATTYPE PyLong_FromLong @@ -48,6 +42,12 @@ python_repr(ostream &out, const string &class_name) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: __getattr__(const string &attr_name) const { +#ifndef CPPPARSER + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint4); +#endif + // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { diff --git a/panda/src/linmath/lpoint4_ext_src.I b/panda/src/linmath/lpoint4_ext_src.I index c34af5986e..9a89e56a0a 100644 --- a/panda/src/linmath/lpoint4_ext_src.I +++ b/panda/src/linmath/lpoint4_ext_src.I @@ -12,12 +12,6 @@ // //////////////////////////////////////////////////////////////////// -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint4); -#endif - #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 #define PY_FROM_FLOATTYPE PyLong_FromLong @@ -49,6 +43,12 @@ python_repr(ostream &out, const string &class_name) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: __getattr__(const string &attr_name) const { +#ifndef CPPPARSER + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint4); +#endif + // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { diff --git a/panda/src/linmath/lvecBase2_ext_src.I b/panda/src/linmath/lvecBase2_ext_src.I index 5c0141031a..1498b8a32b 100644 --- a/panda/src/linmath/lvecBase2_ext_src.I +++ b/panda/src/linmath/lvecBase2_ext_src.I @@ -12,13 +12,6 @@ // //////////////////////////////////////////////////////////////////// - -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4); -#endif - #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 #define PYNUMBER_FLOATTYPE PyNumber_Long @@ -86,6 +79,12 @@ __reduce__(PyObject *self) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: __getattr__(const string &attr_name) const { +#ifndef CPPPARSER + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4); +#endif + // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { diff --git a/panda/src/linmath/lvecBase3_ext_src.I b/panda/src/linmath/lvecBase3_ext_src.I index d0916f6d80..2aa1f0420a 100644 --- a/panda/src/linmath/lvecBase3_ext_src.I +++ b/panda/src/linmath/lvecBase3_ext_src.I @@ -12,13 +12,6 @@ // //////////////////////////////////////////////////////////////////// - -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4); -#endif - #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 #define PYNUMBER_FLOATTYPE PyNumber_Long @@ -87,6 +80,12 @@ __reduce__(PyObject *self) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: __getattr__(const string &attr_name) const { +#ifndef CPPPARSER + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4); +#endif + // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { diff --git a/panda/src/linmath/lvecBase4_ext_src.I b/panda/src/linmath/lvecBase4_ext_src.I index 55db76ee4b..b1e624dc6f 100644 --- a/panda/src/linmath/lvecBase4_ext_src.I +++ b/panda/src/linmath/lvecBase4_ext_src.I @@ -12,13 +12,6 @@ // //////////////////////////////////////////////////////////////////// - -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4); -#endif - #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 #define PYNUMBER_FLOATTYPE PyNumber_Long @@ -88,6 +81,12 @@ __reduce__(PyObject *self) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: __getattr__(const string &attr_name) const { +#ifndef CPPPARSER + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase4); +#endif + // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { diff --git a/panda/src/linmath/lvector2_ext_src.I b/panda/src/linmath/lvector2_ext_src.I index 3fb1284ddd..42db030bce 100644 --- a/panda/src/linmath/lvector2_ext_src.I +++ b/panda/src/linmath/lvector2_ext_src.I @@ -12,12 +12,6 @@ // //////////////////////////////////////////////////////////////////// -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4); -#endif - #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 #define PY_FROM_FLOATTYPE PyLong_FromLong @@ -47,6 +41,12 @@ python_repr(ostream &out, const string &class_name) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: __getattr__(const string &attr_name) const { +#ifndef CPPPARSER + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4); +#endif + // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { diff --git a/panda/src/linmath/lvector3_ext_src.I b/panda/src/linmath/lvector3_ext_src.I index 183e633a76..6aa0897546 100644 --- a/panda/src/linmath/lvector3_ext_src.I +++ b/panda/src/linmath/lvector3_ext_src.I @@ -12,12 +12,6 @@ // //////////////////////////////////////////////////////////////////// -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4); -#endif - #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 #define PY_FROM_FLOATTYPE PyLong_FromLong @@ -48,6 +42,12 @@ python_repr(ostream &out, const string &class_name) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: __getattr__(const string &attr_name) const { +#ifndef CPPPARSER + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4); +#endif + // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { diff --git a/panda/src/linmath/lvector4_ext_src.I b/panda/src/linmath/lvector4_ext_src.I index f22510fc49..fa96998001 100644 --- a/panda/src/linmath/lvector4_ext_src.I +++ b/panda/src/linmath/lvector4_ext_src.I @@ -12,12 +12,6 @@ // //////////////////////////////////////////////////////////////////// -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); -IMPORT_THIS struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4); -#endif - #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 #define PY_FROM_FLOATTYPE PyLong_FromLong @@ -49,6 +43,12 @@ python_repr(ostream &out, const string &class_name) const { //////////////////////////////////////////////////////////////////// INLINE_LINMATH PyObject *Extension:: __getattr__(const string &attr_name) const { +#ifndef CPPPARSER + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); + extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector4); +#endif + // Validate the attribute name. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { diff --git a/panda/src/mathutil/config_mathutil.N b/panda/src/mathutil/config_mathutil.N index 69ef462e6c..94c5de0123 100644 --- a/panda/src/mathutil/config_mathutil.N +++ b/panda/src/mathutil/config_mathutil.N @@ -66,3 +66,5 @@ forcetype PointerToBase > forcetype PointerToArrayBase forcetype PointerToArray forcetype ConstPointerToArray + +forceinclude "pointerToArray_ext.h" diff --git a/panda/src/mathutil/triangulator.cxx b/panda/src/mathutil/triangulator.cxx index d0a40ebc83..74fb752708 100644 --- a/panda/src/mathutil/triangulator.cxx +++ b/panda/src/mathutil/triangulator.cxx @@ -287,7 +287,7 @@ cleanup_polygon_indices(vector_int &polygon) { // First, check for index bounds. size_t pi = 0; while (pi < polygon.size()) { - if (polygon[pi] >= 0 && polygon[pi] < _vertices.size()) { + if (polygon[pi] >= 0 && (size_t)polygon[pi] < _vertices.size()) { // This vertex is OK. ++pi; } else { diff --git a/panda/src/movies/microphoneAudioDS.cxx b/panda/src/movies/microphoneAudioDS.cxx index be8a55b658..7215e29365 100644 --- a/panda/src/movies/microphoneAudioDS.cxx +++ b/panda/src/movies/microphoneAudioDS.cxx @@ -22,7 +22,9 @@ #ifdef HAVE_DIRECTCAM -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #undef Configure @@ -33,9 +35,7 @@ // Class : MicrophoneAudioDS // Description : The directshow implementation of microphones. //////////////////////////////////////////////////////////////////// - -class MicrophoneAudioDS : public MicrophoneAudio -{ +class MicrophoneAudioDS : public MicrophoneAudio { public: static void find_all_microphones_ds(); friend void find_all_microphones_ds(); @@ -56,7 +56,7 @@ private: typedef pvector AudioBuffers; static void delete_buffers(AudioBuffers &buffers); - + friend class MicrophoneAudioCursorDS; public: @@ -90,7 +90,7 @@ public: typedef MicrophoneAudioDS::AudioBuffers AudioBuffers; MicrophoneAudioCursorDS(MicrophoneAudioDS *src, AudioBuffers &bufs, HWAVEIN hwav); virtual ~MicrophoneAudioCursorDS(); - + AudioBuffers _buffers; HWAVEIN _hwavein; int _samples_per_buffer; @@ -105,7 +105,7 @@ public: HWAVEIN _handle; int _next; // Which buffer is the next one to read from. int _offset; // How many samples to skip in the buffer. - + public: static TypeHandle get_class_type() { return _type_handle; @@ -129,7 +129,7 @@ TypeHandle MicrophoneAudioCursorDS::_type_handle; //////////////////////////////////////////////////////////////////// // Function: MicrophoneAudioDS::find_all_microphones_ds // Access: Public, Static -// Description: Finds all DirectShow microphones and adds them to +// Description: Finds all DirectShow microphones and adds them to // the global list _all_microphones. //////////////////////////////////////////////////////////////////// void MicrophoneAudioDS:: @@ -205,7 +205,7 @@ delete_buffers(AudioBuffers &buffers) { //////////////////////////////////////////////////////////////////// PT(MovieAudioCursor) MicrophoneAudioDS:: open() { - + // Allocate the buffers. 64 buffers, not quite 1/20 sec each. int samples; switch (_rate) { @@ -248,7 +248,7 @@ open() { nassert_raise("Could not allocate audio input buffers."); return NULL; } - + WAVEFORMATEX format; format.wFormatTag = WAVE_FORMAT_PCM; format.nChannels = _channels; @@ -260,7 +260,7 @@ open() { HWAVEIN hwav; MMRESULT stat = waveInOpen(&hwav, _device_id, &format, NULL, NULL, CALLBACK_NULL); - + if (stat != MMSYSERR_NOERROR) { delete_buffers(buffers); nassert_raise("Could not open audio input device."); @@ -284,7 +284,7 @@ open() { waveInClose(hwav); delete_buffers(buffers); nassert_raise("Could not start recording on input device."); - return NULL; + return NULL; } return new MicrophoneAudioCursorDS(this, buffers, hwav); } @@ -292,7 +292,7 @@ open() { //////////////////////////////////////////////////////////////////// // Function: MicrophoneAudioCursorDS::Constructor // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// MicrophoneAudioCursorDS:: MicrophoneAudioCursorDS(MicrophoneAudioDS *src, AudioBuffers &bufs, HWAVEIN hwav) : @@ -314,7 +314,7 @@ MicrophoneAudioCursorDS(MicrophoneAudioDS *src, AudioBuffers &bufs, HWAVEIN hwav //////////////////////////////////////////////////////////////////// // Function: MicrophoneAudioCursorDS::cleanup // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// void MicrophoneAudioCursorDS:: cleanup() { @@ -330,7 +330,7 @@ cleanup() { //////////////////////////////////////////////////////////////////// // Function: MicrophoneAudioCursorDS::Destructor // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// MicrophoneAudioCursorDS:: ~MicrophoneAudioCursorDS() { @@ -340,7 +340,7 @@ MicrophoneAudioCursorDS:: //////////////////////////////////////////////////////////////////// // Function: MicrophoneAudioCursorDS::read_samples // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// void MicrophoneAudioCursorDS:: read_samples(int n, PN_int16 *data) { @@ -351,19 +351,19 @@ read_samples(int n, PN_int16 *data) { if ((_buffers[index]._header->dwFlags & WHDR_DONE)==0) { break; } - + // Find start of data in buffer. PN_int16 *src = (PN_int16*)(_buffers[index]._storage); src += (_offset * _audio_channels); - + // Decide how many samples to extract from this buffer. int samples = _samples_per_buffer; samples -= _offset; if (samples > n) samples = n; - + // Copy data to output buffer. memcpy(data, src, samples * 2 * _audio_channels); - + // Advance pointers. data += samples * _audio_channels; n -= samples; @@ -397,7 +397,7 @@ read_samples(int n, PN_int16 *data) { //////////////////////////////////////////////////////////////////// // Function: MicrophoneAudioCursorDS::ready // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// int MicrophoneAudioCursorDS:: ready() const { diff --git a/panda/src/nativenet/buffered_datagramconnection.h b/panda/src/nativenet/buffered_datagramconnection.h index 2bc949cbcc..2ea996d7e5 100755 --- a/panda/src/nativenet/buffered_datagramconnection.h +++ b/panda/src/nativenet/buffered_datagramconnection.h @@ -11,6 +11,7 @@ // 3. Handle Framing and Unframing properly .. // //////////////////////////////////////////////////////////////////// + #include "pandabase.h" #include "socket_base.h" #include "datagram.h" @@ -19,9 +20,12 @@ #include "buffered_datagramwriter.h" #include "config_nativenet.h" +#ifdef HAVE_PYTHON +#include "py_panda.h" +#endif //////////////////////////////////////////////////////////////// -// there are 3 states +// there are 3 states // // 1. Socket not even assigned,,,, // 2. Socket Assigned and trying to get a active connect open diff --git a/panda/src/net/connectionManager.h b/panda/src/net/connectionManager.h index 7021842e9e..8a9878a335 100644 --- a/panda/src/net/connectionManager.h +++ b/panda/src/net/connectionManager.h @@ -67,7 +67,7 @@ PUBLISHED: static string get_host_name(); - class Interface { + class EXPCL_PANDA_NET Interface { PUBLISHED: const string &get_name() const { return _name; } const string &get_mac_address() const { return _mac_address; } diff --git a/panda/src/ode/odeGeom_ext.cxx b/panda/src/ode/odeGeom_ext.cxx index c9b2cd5320..6e248f6404 100644 --- a/panda/src/ode/odeGeom_ext.cxx +++ b/panda/src/ode/odeGeom_ext.cxx @@ -31,19 +31,19 @@ #ifdef HAVE_PYTHON #ifndef CPPPARSER -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeBoxGeom; -//extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeConvexGeom; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeGeom; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeHashSpace; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeCappedCylinderGeom; -//extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeHeightfieldGeom; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdePlaneGeom; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeQuadTreeSpace; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeRayGeom; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeSimpleSpace; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeSpace; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeSphereGeom; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeTriMeshGeom; +extern Dtool_PyTypedObject Dtool_OdeBoxGeom; +//extern Dtool_PyTypedObject Dtool_OdeConvexGeom; +extern Dtool_PyTypedObject Dtool_OdeGeom; +extern Dtool_PyTypedObject Dtool_OdeHashSpace; +extern Dtool_PyTypedObject Dtool_OdeCappedCylinderGeom; +//extern Dtool_PyTypedObject Dtool_OdeHeightfieldGeom; +extern Dtool_PyTypedObject Dtool_OdePlaneGeom; +extern Dtool_PyTypedObject Dtool_OdeQuadTreeSpace; +extern Dtool_PyTypedObject Dtool_OdeRayGeom; +extern Dtool_PyTypedObject Dtool_OdeSimpleSpace; +extern Dtool_PyTypedObject Dtool_OdeSpace; +extern Dtool_PyTypedObject Dtool_OdeSphereGeom; +extern Dtool_PyTypedObject Dtool_OdeTriMeshGeom; #endif //////////////////////////////////////////////////////////////////// diff --git a/panda/src/ode/odeJoint_ext.cxx b/panda/src/ode/odeJoint_ext.cxx index 871eb09c78..93253fec3e 100644 --- a/panda/src/ode/odeJoint_ext.cxx +++ b/panda/src/ode/odeJoint_ext.cxx @@ -30,18 +30,18 @@ #include "odePlane2dJoint.h" #ifndef CPPPARSER -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeBallJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeHingeJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeSliderJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeContactJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeUniversalJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeHinge2Joint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeFixedJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeNullJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeAMotorJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeLMotorJoint; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdePlane2dJoint; +extern Dtool_PyTypedObject Dtool_OdeJoint; +extern Dtool_PyTypedObject Dtool_OdeBallJoint; +extern Dtool_PyTypedObject Dtool_OdeHingeJoint; +extern Dtool_PyTypedObject Dtool_OdeSliderJoint; +extern Dtool_PyTypedObject Dtool_OdeContactJoint; +extern Dtool_PyTypedObject Dtool_OdeUniversalJoint; +extern Dtool_PyTypedObject Dtool_OdeHinge2Joint; +extern Dtool_PyTypedObject Dtool_OdeFixedJoint; +extern Dtool_PyTypedObject Dtool_OdeNullJoint; +extern Dtool_PyTypedObject Dtool_OdeAMotorJoint; +extern Dtool_PyTypedObject Dtool_OdeLMotorJoint; +extern Dtool_PyTypedObject Dtool_OdePlane2dJoint; #endif //////////////////////////////////////////////////////////////////// diff --git a/panda/src/ode/odeSpace_ext.cxx b/panda/src/ode/odeSpace_ext.cxx index 8baa7aabb1..78c52a06bf 100644 --- a/panda/src/ode/odeSpace_ext.cxx +++ b/panda/src/ode/odeSpace_ext.cxx @@ -24,10 +24,10 @@ #include "odeQuadTreeSpace.h" #ifndef CPPPARSER -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeHashSpace; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeSimpleSpace; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeSpace; -extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeQuadTreeSpace; +extern Dtool_PyTypedObject Dtool_OdeHashSpace; +extern Dtool_PyTypedObject Dtool_OdeSimpleSpace; +extern Dtool_PyTypedObject Dtool_OdeSpace; +extern Dtool_PyTypedObject Dtool_OdeQuadTreeSpace; #endif PyObject *Extension::_python_callback = NULL; diff --git a/panda/src/ode/odeTriMeshData.h b/panda/src/ode/odeTriMeshData.h index 70b6eaa4dd..e126fcb8c5 100755 --- a/panda/src/ode/odeTriMeshData.h +++ b/panda/src/ode/odeTriMeshData.h @@ -28,9 +28,11 @@ #include "geomTriangles.h" #include "geomTristrips.h" +#include "config_ode.h" + //////////////////////////////////////////////////////////////////// // Class : OdeTriMeshData -// Description : +// Description : //////////////////////////////////////////////////////////////////// class EXPCL_PANDAODE OdeTriMeshData : public TypedReferenceCount { public: @@ -54,7 +56,7 @@ PUBLISHED: virtual ~OdeTriMeshData(); void destroy(); - + // INLINE void set(int data_id, void* in_data); // INLINE void* get(int data_id); // INLINE void get_buffer(unsigned char** buf, int* buf_len) const; @@ -63,7 +65,7 @@ PUBLISHED: virtual void write(ostream &out = cout, unsigned int indent=0) const; void write_faces(ostream &out) const; -public: +public: INLINE void build_single(const void* vertices, int vertex_stride, int vertex_count, \ const void* indices, int index_count, int tri_stride); INLINE void build_single1(const void* vertices, int vertex_stride, int vertex_count, \ @@ -96,7 +98,7 @@ private: void process_model(const NodePath& model, bool &use_normals); void process_geom_node(const GeomNode *geomNode); void process_geom(const Geom *geom); - void process_primitive(const GeomPrimitive *primitive, + void process_primitive(const GeomPrimitive *primitive, CPT(GeomVertexData) vData); void analyze(const GeomNode *geomNode); void analyze(const Geom *geom); @@ -104,15 +106,15 @@ private: OdeTriMeshData(const OdeTriMeshData &other); void operator = (const OdeTriMeshData &other); - + protected: - struct StridedVertex{ + struct StridedVertex { dReal Vertex[3]; - }; - struct StridedTri{ + }; + struct StridedTri { int Indices[3]; }; - struct FaceNormal{ + struct FaceNormal { dVector3 Normal; }; diff --git a/panda/src/parametrics/curveFitter.h b/panda/src/parametrics/curveFitter.h index c5c67138f3..bf6a21c43d 100644 --- a/panda/src/parametrics/curveFitter.h +++ b/panda/src/parametrics/curveFitter.h @@ -32,7 +32,7 @@ class NurbsCurve; // Class : CurveFitter // Description : //////////////////////////////////////////////////////////////////// -class CurveFitter { +class EXPCL_PANDA_GOBJ CurveFitter { PUBLISHED: CurveFitter(); ~CurveFitter(); diff --git a/panda/src/parametrics/hermiteCurve.h b/panda/src/parametrics/hermiteCurve.h index 124913fb23..ea45316f87 100644 --- a/panda/src/parametrics/hermiteCurve.h +++ b/panda/src/parametrics/hermiteCurve.h @@ -49,7 +49,7 @@ END_PUBLISH //] // Description : A single CV of a Hermite curve. Hermite curve CV's // include an in and out tangent, as well as a position. //////////////////////////////////////////////////////////////////// -class HermiteCurveCV { +class EXPCL_PANDA_PARAMETRICS HermiteCurveCV { public: HermiteCurveCV(); HermiteCurveCV(const HermiteCurveCV &c); @@ -85,7 +85,7 @@ public: // list of the CV's that are used to define the curve // (since the CubicCurveseg class doesn't retain these). //////////////////////////////////////////////////////////////////// -class HermiteCurve : public PiecewiseCurve { +class EXPCL_PANDA_PARAMETRICS HermiteCurve : public PiecewiseCurve { PUBLISHED: HermiteCurve(); HermiteCurve(const ParametricCurve &pc); diff --git a/panda/src/pgraph/Sources.pp b/panda/src/pgraph/Sources.pp index 55e210ea99..51e0bdb0fa 100644 --- a/panda/src/pgraph/Sources.pp +++ b/panda/src/pgraph/Sources.pp @@ -73,7 +73,7 @@ nodePath.I nodePath.h nodePath.cxx \ nodePath_ext.I nodePath_ext.h \ nodePathCollection.I nodePathCollection.h \ - nodePathCollection_ext.I nodePathCollection_ext.h \ + nodePathCollection_ext.h \ nodePathComponent.I nodePathComponent.h \ occluderEffect.I occluderEffect.h \ occluderNode.I occluderNode.h \ @@ -112,7 +112,7 @@ weakNodePath.I weakNodePath.h \ workingNodePath.I workingNodePath.h \ nodePath_ext.h nodePath_ext.I \ - nodePathCollection_ext.h nodePathCollection_ext.I \ + nodePathCollection_ext.h \ pandaNode_ext.h \ renderState_ext.h \ transformState_ext.h diff --git a/panda/src/pgraph/cullBinManager.h b/panda/src/pgraph/cullBinManager.h index 9502667182..4e6adf0821 100644 --- a/panda/src/pgraph/cullBinManager.h +++ b/panda/src/pgraph/cullBinManager.h @@ -97,17 +97,17 @@ private: class EXPCL_PANDA_PGRAPH BinDefinition { public: +#ifndef NDEBUG + LColorf _flash_color; + bool _flash_active; +#endif bool _in_use; string _name; BinType _type; int _sort; bool _active; -#ifndef NDEBUG - bool _flash_active; - LColorf _flash_color; -#endif }; - typedef pvector BinDefinitions; + typedef epvector BinDefinitions; BinDefinitions _bin_definitions; class SortBins { diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index bd3ddfbcc6..c704543838 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -20,10 +20,6 @@ #include "colorAttrib.h" #include "indent.h" -#ifdef HAVE_PYTHON -#include "py_panda.h" -#endif - //////////////////////////////////////////////////////////////////// // Function: NodePathCollection::Constructor // Access: Published @@ -54,48 +50,6 @@ operator = (const NodePathCollection ©) { _node_paths = copy._node_paths; } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::Constructor -// Access: Published -// Description: This special constructor accepts a Python list of -// NodePaths. Since this constructor accepts a generic -// PyObject *, it should be the last constructor listed -// in the class record. -//////////////////////////////////////////////////////////////////// -NodePathCollection:: -NodePathCollection(PyObject *self, PyObject *sequence) { - // We have to pre-initialize self's "this" pointer when we receive - // self in the constructor--the caller can't initialize this for us. - ((Dtool_PyInstDef *)self)->_ptr_to_object = this; - - if (!PySequence_Check(sequence)) { - // If passed with a non-sequence, this isn't the right constructor. - PyErr_SetString(PyExc_TypeError, "NodePathCollection constructor requires a sequence"); - return; - } - - int size = PySequence_Size(sequence); - for (int i = 0; i < size; ++i) { - PyObject *item = PySequence_GetItem(sequence, i); - if (item == NULL) { - return; - } - PyObject *result = PyObject_CallMethod(self, (char *)"addPath", (char *)"O", item); - Py_DECREF(item); - if (result == NULL) { - // Unable to add item--probably it wasn't of the appropriate type. - ostringstream stream; - stream << "Element " << i << " in sequence passed to NodePathCollection constructor could not be added"; - string str = stream.str(); - PyErr_SetString(PyExc_TypeError, str.c_str()); - return; - } - Py_DECREF(result); - } -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: NodePathCollection::add_path // Access: Published @@ -244,6 +198,18 @@ clear() { _node_paths.clear(); } +//////////////////////////////////////////////////////////////////// +// Function: NodePathCollection::reserve +// Access: Published +// Description: This is a hint to Panda to allocate enough memory +// to hold the given number of NodePaths, if you know +// ahead of time how many you will be adding. +//////////////////////////////////////////////////////////////////// +void NodePathCollection:: +reserve(size_t num) { + _node_paths.reserve(num); +} + //////////////////////////////////////////////////////////////////// // Function: NodePathCollection::is_empty // Access: Published @@ -335,7 +301,7 @@ find_all_matches(const string &path) const { if (!is_empty()) { FindApproxLevelEntry *level = NULL; for (int i = 0; i < get_num_paths(); i++) { - FindApproxLevelEntry *start = + FindApproxLevelEntry *start = new FindApproxLevelEntry(get_path(i), approx_path); start->_next = level; level = start; diff --git a/panda/src/pgraph/nodePathCollection.h b/panda/src/pgraph/nodePathCollection.h index 6265f85d16..8527db5b5d 100644 --- a/panda/src/pgraph/nodePathCollection.h +++ b/panda/src/pgraph/nodePathCollection.h @@ -34,7 +34,7 @@ PUBLISHED: INLINE ~NodePathCollection(); #ifdef HAVE_PYTHON - NodePathCollection(PyObject *self, PyObject *sequence); + EXTENSION(NodePathCollection(PyObject *self, PyObject *sequence)); EXTENSION(PyObject *__reduce__(PyObject *self) const); #endif @@ -45,6 +45,7 @@ PUBLISHED: void remove_duplicate_paths(); bool has_path(const NodePath &path) const; void clear(); + void reserve(size_t num); bool is_empty() const; int get_num_paths() const; diff --git a/panda/src/pgraph/nodePathCollection_ext.I b/panda/src/pgraph/nodePathCollection_ext.I deleted file mode 100644 index d88ba08295..0000000000 --- a/panda/src/pgraph/nodePathCollection_ext.I +++ /dev/null @@ -1,51 +0,0 @@ -// Filename: nodePathCollection_ext.I -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// 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 CPPPARSER -#ifdef STDFLOAT_DOUBLE -IMPORT_THIS struct Dtool_PyTypedObject Dtool_LPoint3d; -#else -IMPORT_THIS struct Dtool_PyTypedObject Dtool_LPoint3f; -#endif -#endif - -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_tight_bounds -// Access: Published -// Description: Returns the tight bounds as a 2-tuple of LPoint3 -// objects. This is a convenience function for Python -// users, among which the use of calc_tight_bounds -// may be confusing. -// Returns None if calc_tight_bounds returned false. -//////////////////////////////////////////////////////////////////// -INLINE PyObject *Extension:: -get_tight_bounds() const { - LPoint3 *min_point = new LPoint3; - LPoint3 *max_point = new LPoint3; - - if (_this->calc_tight_bounds(*min_point, *max_point)) { -#ifdef STDFLOAT_DOUBLE - PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3d, true, false); - PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3d, true, false); -#else - PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3f, true, false); - PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3f, true, false); -#endif - return Py_BuildValue("NN", min_inst, max_inst); - - } else { - Py_INCREF(Py_None); - return Py_None; - } -} diff --git a/panda/src/pgraph/nodePathCollection_ext.cxx b/panda/src/pgraph/nodePathCollection_ext.cxx index 324e746d47..48898fb547 100644 --- a/panda/src/pgraph/nodePathCollection_ext.cxx +++ b/panda/src/pgraph/nodePathCollection_ext.cxx @@ -16,6 +16,57 @@ #ifdef HAVE_PYTHON +#ifndef CPPPARSER +extern struct Dtool_PyTypedObject Dtool_NodePath; +#ifdef STDFLOAT_DOUBLE +extern struct Dtool_PyTypedObject Dtool_LPoint3d; +#else +extern struct Dtool_PyTypedObject Dtool_LPoint3f; +#endif +#endif + +//////////////////////////////////////////////////////////////////// +// Function: NodePathCollection::__init__ +// Access: Published +// Description: This special constructor accepts a Python list of +// NodePaths. Since this constructor accepts a generic +// PyObject *, it should be the last constructor listed +// in the class record. +//////////////////////////////////////////////////////////////////// +void Extension:: +__init__(PyObject *self, PyObject *sequence) { + PyObject *fast = PySequence_Fast(sequence, "NodePathCollection constructor requires a sequence"); + if (fast == NULL) { + return; + } + + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast); + _this->reserve(size); + + for (int i = 0; i < size; ++i) { + PyObject *item = PySequence_Fast_GET_ITEM(fast, i); + if (item == NULL) { + return; + } + + NodePath *path; + DTOOL_Call_ExtractThisPointerForType(item, &Dtool_NodePath, (void **)&path); + if (path == (NodePath *)NULL) { + // Unable to add item--probably it wasn't of the appropriate type. + ostringstream stream; + stream << "Element " << i << " in sequence passed to NodePathCollection constructor is not a NodePath"; + string str = stream.str(); + PyErr_SetString(PyExc_TypeError, str.c_str()); + Py_DECREF(fast); + return; + } else { + _this->add_path(*path); + } + } + + Py_DECREF(fast); +} + //////////////////////////////////////////////////////////////////// // Function: NodePathCollection::__reduce__ // Access: Published @@ -45,4 +96,34 @@ __reduce__(PyObject *self) const { return result; } +//////////////////////////////////////////////////////////////////// +// Function: Extension::get_tight_bounds +// Access: Published +// Description: Returns the tight bounds as a 2-tuple of LPoint3 +// objects. This is a convenience function for Python +// users, among which the use of calc_tight_bounds +// may be confusing. +// Returns None if calc_tight_bounds returned false. +//////////////////////////////////////////////////////////////////// +PyObject *Extension:: +get_tight_bounds() const { + LPoint3 *min_point = new LPoint3; + LPoint3 *max_point = new LPoint3; + + if (_this->calc_tight_bounds(*min_point, *max_point)) { +#ifdef STDFLOAT_DOUBLE + PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3d, true, false); + PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3d, true, false); +#else + PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3f, true, false); + PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3f, true, false); #endif + return Py_BuildValue("NN", min_inst, max_inst); + + } else { + Py_INCREF(Py_None); + return Py_None; + } +} + +#endif // HAVE_PYTHON diff --git a/panda/src/pgraph/nodePathCollection_ext.h b/panda/src/pgraph/nodePathCollection_ext.h index 96dc6f9e19..60aa2203ec 100644 --- a/panda/src/pgraph/nodePathCollection_ext.h +++ b/panda/src/pgraph/nodePathCollection_ext.h @@ -32,13 +32,13 @@ template<> class Extension : public ExtensionBase { public: + void __init__(PyObject *self, PyObject *sequence); + PyObject *__reduce__(PyObject *self) const; - INLINE PyObject *get_tight_bounds() const; + PyObject *get_tight_bounds() const; }; -#include "nodePathCollection_ext.I" - #endif // HAVE_PYTHON #endif // NODEPATHCOLLECTION_EXT_H diff --git a/panda/src/pgraph/nodePath_ext.I b/panda/src/pgraph/nodePath_ext.I index 3888d6f8f2..f40acd26d8 100644 --- a/panda/src/pgraph/nodePath_ext.I +++ b/panda/src/pgraph/nodePath_ext.I @@ -14,14 +14,6 @@ #include "pandaNode_ext.h" -#ifndef CPPPARSER -#ifdef STDFLOAT_DOUBLE -IMPORT_THIS struct Dtool_PyTypedObject Dtool_LPoint3d; -#else -IMPORT_THIS struct Dtool_PyTypedObject Dtool_LPoint3f; -#endif -#endif - //////////////////////////////////////////////////////////////////// // Function: Extension::get_python_tag_keys // Access: Published @@ -167,33 +159,3 @@ INLINE bool Extension:: has_net_python_tag(const string &key) const { return !find_net_python_tag(key).is_empty(); } - -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_tight_bounds -// Access: Published -// Description: Returns the tight bounds as a 2-tuple of LPoint3 -// objects. This is a convenience function for Python -// users, among which the use of calc_tight_bounds -// may be confusing. -// Returns None if calc_tight_bounds returned false. -//////////////////////////////////////////////////////////////////// -INLINE PyObject *Extension:: -get_tight_bounds() const { - LPoint3 *min_point = new LPoint3; - LPoint3 *max_point = new LPoint3; - - if (_this->calc_tight_bounds(*min_point, *max_point)) { -#ifdef STDFLOAT_DOUBLE - PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3d, true, false); - PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3d, true, false); -#else - PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3f, true, false); - PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3f, true, false); -#endif - return Py_BuildValue("NN", min_inst, max_inst); - - } else { - Py_INCREF(Py_None); - return Py_None; - } -} diff --git a/panda/src/pgraph/nodePath_ext.cxx b/panda/src/pgraph/nodePath_ext.cxx index 4192675f1b..b5cc7dbd51 100644 --- a/panda/src/pgraph/nodePath_ext.cxx +++ b/panda/src/pgraph/nodePath_ext.cxx @@ -18,8 +18,13 @@ #ifdef HAVE_PYTHON #ifndef CPPPARSER -extern EXPCL_PANDA_PUTIL Dtool_PyTypedObject Dtool_BamWriter; -extern EXPCL_PANDA_PUTIL Dtool_PyTypedObject Dtool_BamReader; +extern struct Dtool_PyTypedObject Dtool_BamWriter; +extern struct Dtool_PyTypedObject Dtool_BamReader; +#ifdef STDFLOAT_DOUBLE +extern struct Dtool_PyTypedObject Dtool_LPoint3d; +#else +extern struct Dtool_PyTypedObject Dtool_LPoint3f; +#endif #endif // CPPPARSER //////////////////////////////////////////////////////////////////// @@ -53,7 +58,7 @@ __copy__() const { //////////////////////////////////////////////////////////////////// PyObject *Extension:: __deepcopy__(PyObject *self, PyObject *memo) const { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_NodePath; + extern struct Dtool_PyTypedObject Dtool_NodePath; // Borrowed reference. PyObject *dupe = PyDict_GetItem(memo, self); @@ -228,5 +233,34 @@ py_decode_NodePath_from_bam_stream_persist(PyObject *unpickler, const string &da return NodePath::decode_from_bam_stream(data, reader); } -#endif // HAVE_PYTHON +//////////////////////////////////////////////////////////////////// +// Function: Extension::get_tight_bounds +// Access: Published +// Description: Returns the tight bounds as a 2-tuple of LPoint3 +// objects. This is a convenience function for Python +// users, among which the use of calc_tight_bounds +// may be confusing. +// Returns None if calc_tight_bounds returned false. +//////////////////////////////////////////////////////////////////// +PyObject *Extension:: +get_tight_bounds() const { + LPoint3 *min_point = new LPoint3; + LPoint3 *max_point = new LPoint3; + if (_this->calc_tight_bounds(*min_point, *max_point)) { +#ifdef STDFLOAT_DOUBLE + PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3d, true, false); + PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3d, true, false); +#else + PyObject *min_inst = DTool_CreatePyInstance((void*) min_point, Dtool_LPoint3f, true, false); + PyObject *max_inst = DTool_CreatePyInstance((void*) max_point, Dtool_LPoint3f, true, false); +#endif + return Py_BuildValue("NN", min_inst, max_inst); + + } else { + Py_INCREF(Py_None); + return Py_None; + } +} + +#endif // HAVE_PYTHON diff --git a/panda/src/pgraph/nodePath_ext.h b/panda/src/pgraph/nodePath_ext.h index c91a462bff..00983a9de1 100644 --- a/panda/src/pgraph/nodePath_ext.h +++ b/panda/src/pgraph/nodePath_ext.h @@ -48,7 +48,7 @@ public: INLINE bool has_net_python_tag(const string &key) const; NodePath find_net_python_tag(const string &key) const; - INLINE PyObject *get_tight_bounds() const; + PyObject *get_tight_bounds() const; }; BEGIN_PUBLISH diff --git a/panda/src/pgraph/pandaNode_ext.cxx b/panda/src/pgraph/pandaNode_ext.cxx index 515b704574..df251cba44 100644 --- a/panda/src/pgraph/pandaNode_ext.cxx +++ b/panda/src/pgraph/pandaNode_ext.cxx @@ -53,7 +53,7 @@ __copy__() const { //////////////////////////////////////////////////////////////////// PyObject *Extension:: __deepcopy__(PyObject *self, PyObject *memo) const { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_PandaNode; + extern struct Dtool_PyTypedObject Dtool_PandaNode; // Borrowed reference. PyObject *dupe = PyDict_GetItem(memo, self); diff --git a/panda/src/pgraph/renderState_ext.cxx b/panda/src/pgraph/renderState_ext.cxx index 70b214fbb3..3238677bd0 100644 --- a/panda/src/pgraph/renderState_ext.cxx +++ b/panda/src/pgraph/renderState_ext.cxx @@ -32,7 +32,7 @@ //////////////////////////////////////////////////////////////////// PyObject *Extension:: get_composition_cache() const { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_RenderState; + extern struct Dtool_PyTypedObject Dtool_RenderState; LightReMutexHolder holder(*RenderState::_states_lock); size_t cache_size = _this->_composition_cache.get_size(); PyObject *list = PyList_New(cache_size); @@ -90,7 +90,7 @@ get_composition_cache() const { //////////////////////////////////////////////////////////////////// PyObject *Extension:: get_invert_composition_cache() const { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_RenderState; + extern struct Dtool_PyTypedObject Dtool_RenderState; LightReMutexHolder holder(*RenderState::_states_lock); size_t cache_size = _this->_invert_composition_cache.get_size(); PyObject *list = PyList_New(cache_size); @@ -141,7 +141,7 @@ get_invert_composition_cache() const { //////////////////////////////////////////////////////////////////// PyObject *Extension:: get_states() { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_RenderState; + extern struct Dtool_PyTypedObject Dtool_RenderState; if (RenderState::_states == (RenderState::States *)NULL) { return PyList_New(0); } diff --git a/panda/src/pgraph/textureAttrib.h b/panda/src/pgraph/textureAttrib.h index 6a0b48928c..0c27a018eb 100644 --- a/panda/src/pgraph/textureAttrib.h +++ b/panda/src/pgraph/textureAttrib.h @@ -23,6 +23,7 @@ #include "updateSeq.h" #include "ordered_vector.h" #include "vector_int.h" +#include "epvector.h" //////////////////////////////////////////////////////////////////// // Class : TextureAttrib @@ -109,9 +110,9 @@ private: unsigned int implicit_sort = 0, int override = 0); + SamplerState _sampler; PT(TextureStage) _stage; PT(Texture) _texture; - SamplerState _sampler; bool _has_sampler; int _ff_tc_index; unsigned int _implicit_sort; @@ -133,7 +134,7 @@ private: INLINE bool operator () (const TextureAttrib::StageNode &a, const TextureAttrib::StageNode &b) const; }; - typedef ov_set Stages; + typedef ov_set > Stages; Stages _on_stages; // set of all "on" stages, indexed by pointer. typedef pvector RenderStages; diff --git a/panda/src/pgraph/transformState_ext.cxx b/panda/src/pgraph/transformState_ext.cxx index c66fd87943..a657df7fae 100644 --- a/panda/src/pgraph/transformState_ext.cxx +++ b/panda/src/pgraph/transformState_ext.cxx @@ -32,7 +32,7 @@ //////////////////////////////////////////////////////////////////// PyObject *Extension:: get_composition_cache() const { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_TransformState; + extern struct Dtool_PyTypedObject Dtool_TransformState; LightReMutexHolder holder(*_this->_states_lock); size_t num_states = _this->_composition_cache.get_num_entries(); @@ -94,7 +94,7 @@ get_composition_cache() const { //////////////////////////////////////////////////////////////////// PyObject *Extension:: get_invert_composition_cache() const { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_TransformState; + extern struct Dtool_PyTypedObject Dtool_TransformState; LightReMutexHolder holder(*_this->_states_lock); size_t num_states = _this->_invert_composition_cache.get_num_entries(); @@ -149,7 +149,7 @@ get_invert_composition_cache() const { //////////////////////////////////////////////////////////////////// PyObject *Extension:: get_states() { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_TransformState; + extern struct Dtool_PyTypedObject Dtool_TransformState; if (TransformState::_states == (TransformState::States *)NULL) { return PyList_New(0); } @@ -186,7 +186,7 @@ get_states() { //////////////////////////////////////////////////////////////////// PyObject *Extension:: get_unused_states() { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_TransformState; + extern struct Dtool_PyTypedObject Dtool_TransformState; if (TransformState::_states == (TransformState::States *)NULL) { return PyList_New(0); } diff --git a/panda/src/pgraphnodes/computeNode.I b/panda/src/pgraphnodes/computeNode.I index 726193e8b1..156657be3c 100644 --- a/panda/src/pgraphnodes/computeNode.I +++ b/panda/src/pgraphnodes/computeNode.I @@ -73,7 +73,7 @@ get_num_dispatches() const { INLINE const LVecBase3i &ComputeNode:: get_dispatch(int n) const { Dispatcher::CDReader cdata(_dispatcher->_cycler); - nassertr(n >= 0 && n < cdata->_dispatches.size(), LVecBase3i::zero()); + nassertr(n >= 0 && (size_t)n < cdata->_dispatches.size(), LVecBase3i::zero()); return cdata->_dispatches[n]; } diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 2e49eb0f01..9e76063177 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -86,35 +86,35 @@ reset_register_allocator() { // Access: Protected // Description: Allocate a vreg. //////////////////////////////////////////////////////////////////// -INLINE char *ShaderGenerator:: +const char *ShaderGenerator:: alloc_vreg() { switch (_vtregs_used) { - case 0: _vtregs_used += 1; return (char*)"TEXCOORD0"; - case 1: _vtregs_used += 1; return (char*)"TEXCOORD1"; - case 2: _vtregs_used += 1; return (char*)"TEXCOORD2"; - case 3: _vtregs_used += 1; return (char*)"TEXCOORD3"; - case 4: _vtregs_used += 1; return (char*)"TEXCOORD4"; - case 5: _vtregs_used += 1; return (char*)"TEXCOORD5"; - case 6: _vtregs_used += 1; return (char*)"TEXCOORD6"; - case 7: _vtregs_used += 1; return (char*)"TEXCOORD7"; + case 0: _vtregs_used += 1; return "TEXCOORD0"; + case 1: _vtregs_used += 1; return "TEXCOORD1"; + case 2: _vtregs_used += 1; return "TEXCOORD2"; + case 3: _vtregs_used += 1; return "TEXCOORD3"; + case 4: _vtregs_used += 1; return "TEXCOORD4"; + case 5: _vtregs_used += 1; return "TEXCOORD5"; + case 6: _vtregs_used += 1; return "TEXCOORD6"; + case 7: _vtregs_used += 1; return "TEXCOORD7"; } switch (_vcregs_used) { - case 0: _vcregs_used += 1; return (char*)"COLOR0"; - case 1: _vcregs_used += 1; return (char*)"COLOR1"; + case 0: _vcregs_used += 1; return "COLOR0"; + case 1: _vcregs_used += 1; return "COLOR1"; } // These don't exist in arbvp1, though they're reportedly // supported by other profiles. switch (_vtregs_used) { - case 8: _vtregs_used += 1; return (char*)"TEXCOORD8"; - case 9: _vtregs_used += 1; return (char*)"TEXCOORD9"; - case 10: _vtregs_used += 1; return (char*)"TEXCOORD10"; - case 11: _vtregs_used += 1; return (char*)"TEXCOORD11"; - case 12: _vtregs_used += 1; return (char*)"TEXCOORD12"; - case 13: _vtregs_used += 1; return (char*)"TEXCOORD13"; - case 14: _vtregs_used += 1; return (char*)"TEXCOORD14"; - case 15: _vtregs_used += 1; return (char*)"TEXCOORD15"; + case 8: _vtregs_used += 1; return "TEXCOORD8"; + case 9: _vtregs_used += 1; return "TEXCOORD9"; + case 10: _vtregs_used += 1; return "TEXCOORD10"; + case 11: _vtregs_used += 1; return "TEXCOORD11"; + case 12: _vtregs_used += 1; return "TEXCOORD12"; + case 13: _vtregs_used += 1; return "TEXCOORD13"; + case 14: _vtregs_used += 1; return "TEXCOORD14"; + case 15: _vtregs_used += 1; return "TEXCOORD15"; } - return (char*)"UNKNOWN"; + return "UNKNOWN"; } //////////////////////////////////////////////////////////////////// @@ -122,37 +122,37 @@ alloc_vreg() { // Access: Protected // Description: Allocate a freg. //////////////////////////////////////////////////////////////////// -INLINE char *ShaderGenerator:: +const char *ShaderGenerator:: alloc_freg() { switch (_ftregs_used) { - case 0: _ftregs_used += 1; return (char*)"TEXCOORD0"; - case 1: _ftregs_used += 1; return (char*)"TEXCOORD1"; - case 2: _ftregs_used += 1; return (char*)"TEXCOORD2"; - case 3: _ftregs_used += 1; return (char*)"TEXCOORD3"; - case 4: _ftregs_used += 1; return (char*)"TEXCOORD4"; - case 5: _ftregs_used += 1; return (char*)"TEXCOORD5"; - case 6: _ftregs_used += 1; return (char*)"TEXCOORD6"; - case 7: _ftregs_used += 1; return (char*)"TEXCOORD7"; + case 0: _ftregs_used += 1; return "TEXCOORD0"; + case 1: _ftregs_used += 1; return "TEXCOORD1"; + case 2: _ftregs_used += 1; return "TEXCOORD2"; + case 3: _ftregs_used += 1; return "TEXCOORD3"; + case 4: _ftregs_used += 1; return "TEXCOORD4"; + case 5: _ftregs_used += 1; return "TEXCOORD5"; + case 6: _ftregs_used += 1; return "TEXCOORD6"; + case 7: _ftregs_used += 1; return "TEXCOORD7"; } // We really shouldn't rely on COLOR fregs, // since the clamping can have unexpected side-effects. //switch (_fcregs_used) { - //case 0: _fcregs_used += 1; return (char*)"COLOR0"; - //case 1: _fcregs_used += 1; return (char*)"COLOR1"; + //case 0: _fcregs_used += 1; return "COLOR0"; + //case 1: _fcregs_used += 1; return "COLOR1"; //} // These don't exist in arbvp1/arbfp1, though they're // reportedly supported by other profiles. switch (_ftregs_used) { - case 8: _ftregs_used += 1; return (char*)"TEXCOORD8"; - case 9: _ftregs_used += 1; return (char*)"TEXCOORD9"; - case 10: _ftregs_used += 1; return (char*)"TEXCOORD10"; - case 11: _ftregs_used += 1; return (char*)"TEXCOORD11"; - case 12: _ftregs_used += 1; return (char*)"TEXCOORD12"; - case 13: _ftregs_used += 1; return (char*)"TEXCOORD13"; - case 14: _ftregs_used += 1; return (char*)"TEXCOORD14"; - case 15: _ftregs_used += 1; return (char*)"TEXCOORD15"; + case 8: _ftregs_used += 1; return "TEXCOORD8"; + case 9: _ftregs_used += 1; return "TEXCOORD9"; + case 10: _ftregs_used += 1; return "TEXCOORD10"; + case 11: _ftregs_used += 1; return "TEXCOORD11"; + case 12: _ftregs_used += 1; return "TEXCOORD12"; + case 13: _ftregs_used += 1; return "TEXCOORD13"; + case 14: _ftregs_used += 1; return "TEXCOORD14"; + case 15: _ftregs_used += 1; return "TEXCOORD15"; } - return (char*)"UNKNOWN"; + return "UNKNOWN"; } //////////////////////////////////////////////////////////////////// @@ -624,18 +624,18 @@ synthesize_shader(const RenderState *rs) { // These variables will hold the results of register allocation. - char *tangent_freg = 0; - char *binormal_freg = 0; + const char *tangent_freg = 0; + const char *binormal_freg = 0; string tangent_input; string binormal_input; - pmap texcoord_fregs; - pvector dlightcoord_fregs; - pvector slightcoord_fregs; - char *world_position_freg = 0; - char *world_normal_freg = 0; - char *eye_position_freg = 0; - char *eye_normal_freg = 0; - char *hpos_freg = 0; + pmap texcoord_fregs; + pvector dlightcoord_fregs; + pvector slightcoord_fregs; + const char *world_position_freg = 0; + const char *world_normal_freg = 0; + const char *eye_position_freg = 0; + const char *eye_normal_freg = 0; + const char *hpos_freg = 0; if (_vertex_colors) { // Reserve COLOR0 @@ -662,7 +662,7 @@ synthesize_shader(const RenderState *rs) { const InternalName *texcoord_name = stage->get_texcoord_name(); if (texcoord_fregs.count(texcoord_name) == 0) { - char *freg = alloc_freg(); + const char *freg = alloc_freg(); string tcname = texcoord_name->join("_"); texcoord_fregs[texcoord_name] = freg; @@ -774,7 +774,7 @@ synthesize_shader(const RenderState *rs) { text << "\t l_eye_normal.xyz = mul((float3x3)tpose_view_to_model, vtx_normal);\n"; text << "\t l_eye_normal.w = 0;\n"; } - pmap::const_iterator it; + pmap::const_iterator it; for (it = texcoord_fregs.begin(); it != texcoord_fregs.end(); ++it) { // Pass through all texcoord inputs as-is. string tcname = it->first->join("_"); diff --git a/panda/src/pgraphnodes/shaderGenerator.h b/panda/src/pgraphnodes/shaderGenerator.h index 9028149e92..9a4aa05857 100644 --- a/panda/src/pgraphnodes/shaderGenerator.h +++ b/panda/src/pgraphnodes/shaderGenerator.h @@ -85,8 +85,8 @@ protected: int _vtregs_used; int _ftregs_used; void reset_register_allocator(); - char *alloc_vreg(); - char *alloc_freg(); + const char *alloc_vreg(); + const char *alloc_freg(); // RenderState analysis information. Created by analyze_renderstate: diff --git a/panda/src/pipeline/threadDummyImpl.h b/panda/src/pipeline/threadDummyImpl.h index 4084f2f181..689e6386e6 100644 --- a/panda/src/pipeline/threadDummyImpl.h +++ b/panda/src/pipeline/threadDummyImpl.h @@ -26,7 +26,9 @@ class Thread; #ifdef WIN32 -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include // For Sleep(). #endif diff --git a/panda/src/pipeline/threadSimpleManager.h b/panda/src/pipeline/threadSimpleManager.h index e839ac2f5a..34314907f5 100644 --- a/panda/src/pipeline/threadSimpleManager.h +++ b/panda/src/pipeline/threadSimpleManager.h @@ -31,7 +31,9 @@ #include // for pthread_t, below #endif #ifdef WIN32 -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include // for DWORD, below #endif diff --git a/panda/src/pnmimage/pfmFile_ext.cxx b/panda/src/pnmimage/pfmFile_ext.cxx index c28ed79b57..29b5949f75 100644 --- a/panda/src/pnmimage/pfmFile_ext.cxx +++ b/panda/src/pnmimage/pfmFile_ext.cxx @@ -17,9 +17,9 @@ #ifdef HAVE_PYTHON #ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject Dtool_LPoint2f; -IMPORT_THIS struct Dtool_PyTypedObject Dtool_LPoint3f; -IMPORT_THIS struct Dtool_PyTypedObject Dtool_LPoint4f; +extern struct Dtool_PyTypedObject Dtool_LPoint2f; +extern struct Dtool_PyTypedObject Dtool_LPoint3f; +extern struct Dtool_PyTypedObject Dtool_LPoint4f; #endif //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pnmimage/pnmImageHeader.h b/panda/src/pnmimage/pnmImageHeader.h index 7ae5920a82..d5e6db3b9c 100644 --- a/panda/src/pnmimage/pnmImageHeader.h +++ b/panda/src/pnmimage/pnmImageHeader.h @@ -106,7 +106,7 @@ PUBLISHED: // Contains a single pixel specification used in compute_histogram() // and make_histogram(). Note that pixels are stored by integer // value, not by floating-point scaled value. - class PixelSpec { + class EXPCL_PANDA_PNMIMAGE PixelSpec { PUBLISHED: INLINE PixelSpec(xelval gray_value); INLINE PixelSpec(xelval gray_value, xelval alpha); @@ -143,7 +143,7 @@ PUBLISHED: // Associates a pixel specification with an appearance count, for // use in Histogram, below. - class PixelSpecCount { + class EXPCL_PANDA_PNMIMAGE PixelSpecCount { public: INLINE PixelSpecCount(const PixelSpec &pixel, int count); INLINE bool operator < (const PixelSpecCount &other) const; @@ -157,7 +157,7 @@ PUBLISHED: typedef pvector Palette; // Used to return a pixel histogram in PNMImage::get_histogram(). - class Histogram { + class EXPCL_PANDA_PNMIMAGE Histogram { PUBLISHED: INLINE Histogram(); diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPG.h b/panda/src/pnmimagetypes/pnmFileTypeJPG.h index 8dfa27af9f..936e349568 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPG.h +++ b/panda/src/pnmimagetypes/pnmFileTypeJPG.h @@ -24,7 +24,9 @@ #include "pnmWriter.h" #if defined(_WIN32) -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include // we need to include this before jpeglib. #endif diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx index 45f1888371..8a080fc953 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx @@ -136,8 +136,8 @@ pm_allocarray(int const cols, int const rows, int const size ) { /* We couldn't get the whole heap in one block, so try fragmented format. */ - unsigned int row; - + int row; + rowIndex[rows] = NULL; /* Declare it fragmented format */ for (row = 0; row < rows; ++row) { @@ -149,7 +149,7 @@ pm_allocarray(int const cols, int const rows, int const size ) { } } else { /* It's unfragmented format */ - unsigned int row; + int row; rowIndex[rows] = rowheap; /* Declare it unfragmented format */ for (row = 0; row < rows; ++row) @@ -159,17 +159,18 @@ pm_allocarray(int const cols, int const rows, int const size ) { } void -pm_freearray(char ** const rowIndex, +pm_freearray(char ** const rowIndex, int const rows) { void * const rowheap = rowIndex[rows]; - if (rowheap != NULL) + if (rowheap != NULL) { PANDA_FREE_ARRAY(rowheap); - else { - unsigned int row; - for (row = 0; row < rows; ++row) + } else { + int row; + for (row = 0; row < rows; ++row) { pm_freerow(rowIndex[row]); + } } PANDA_FREE_ARRAY(rowIndex); } @@ -191,7 +192,7 @@ pm_getuint(istream * const ifP) { -----------------------------------------------------------------------------*/ char ch; unsigned int i; - + // skip whitespace do { ch = ifP->get(); @@ -400,7 +401,7 @@ pgm_readpgmrow(istream* const file, gray* const grayrow, } } break; - + case PBM_FORMAT: case RPBM_FORMAT: { @@ -414,22 +415,22 @@ pgm_readpgmrow(istream* const file, gray* const grayrow, pbm_freerow(bitrow); } break; - + default: pm_error( "can't happen" ); } } static void -ppm_readppmrow(istream* const fileP, - pixel* const pixelrow, - int const cols, - pixval const maxval, +ppm_readppmrow(istream* const fileP, + pixel* const pixelrow, + int const cols, + pixval const maxval, int const format) { switch (format) { case PPM_FORMAT: { - unsigned int col; + int col; for (col = 0; col < cols; ++col) { pixval const r = pm_getuint(fileP); pixval const g = pm_getuint(fileP); @@ -440,7 +441,7 @@ ppm_readppmrow(istream* const fileP, break; case RPPM_FORMAT: { - unsigned int col; + int col; for (col = 0; col < cols; ++col) { pixval const r = pgm_getrawsample(fileP, maxval); pixval const g = pgm_getrawsample(fileP, maxval); @@ -453,7 +454,7 @@ ppm_readppmrow(istream* const fileP, case PGM_FORMAT: case RPGM_FORMAT: { gray * const grayrow = pgm_allocrow(cols); - unsigned int col; + int col; pgm_readpgmrow(fileP, grayrow, cols, maxval, format); for (col = 0; col < cols; ++col) { @@ -467,7 +468,7 @@ ppm_readppmrow(istream* const fileP, case PBM_FORMAT: case RPBM_FORMAT: { bit * const bitrow = pbm_allocrow(cols); - unsigned int col; + int col; pbm_readpbmrow(fileP, bitrow, cols, format); for (col = 0; col < cols; ++col) { @@ -626,7 +627,7 @@ packBitsGeneric(ostream * const fileP, Don't use any special CPU facilities to do the packing. -----------------------------------------------------------------------------*/ - unsigned int col; + int col; #define iszero(x) ((x) == 0 ? 0 : 1) @@ -653,7 +654,7 @@ writePackedRawRow(ostream * const fileP, fileP->write((const char *)packed_bits, pbm_packed_bytes(cols)); if (fileP->fail()) pm_error("I/O error writing packed row to raw PBM file."); -} +} static void writePbmRowRaw(ostream * const fileP, @@ -900,24 +901,24 @@ ppm_writeppmrow(ostream * const fileP, } static void -pnm_writepnmrow(ostream * const fileP, - xel * const xelrow, - int const cols, - xelval const maxval, - int const format, +pnm_writepnmrow(ostream * const fileP, + xel * const xelrow, + int const cols, + xelval const maxval, + int const format, int const forceplain) { bool const plainFormat = forceplain || pm_plain_output; - + switch (PNM_FORMAT_TYPE(format)) { case PPM_TYPE: - ppm_writeppmrow(fileP, (pixel*) xelrow, cols, (pixval) maxval, + ppm_writeppmrow(fileP, (pixel*) xelrow, cols, (pixval) maxval, plainFormat); break; case PGM_TYPE: { gray* grayrow; - unsigned int col; + int col; grayrow = pgm_allocrow(cols); @@ -932,7 +933,7 @@ pnm_writepnmrow(ostream * const fileP, case PBM_TYPE: { bit* bitrow; - unsigned int col; + int col; bitrow = pbm_allocrow(cols); @@ -942,12 +943,12 @@ pnm_writepnmrow(ostream * const fileP, pbm_writepbmrow(fileP, bitrow, cols, plainFormat); pbm_freerow(bitrow); - } + } break; - + default: pm_error("invalid format argument received by pnm_writepnmrow(): %d" - "PNM_FORMAT_TYPE(format) must be %d, %d, or %d", + "PNM_FORMAT_TYPE(format) must be %d, %d, or %d", format, PBM_TYPE, PGM_TYPE, PPM_TYPE); } } diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx index 1461ed2f98..e16b857d61 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx @@ -589,7 +589,7 @@ PNMFileTypeTIFF::Reader:: //////////////////////////////////////////////////////////////////// bool PNMFileTypeTIFF::Reader:: is_floating_point() { - return sample_format = SAMPLEFORMAT_IEEEFP; + return (sample_format == SAMPLEFORMAT_IEEEFP); } //////////////////////////////////////////////////////////////////// @@ -988,7 +988,7 @@ write_pfm(const PfmFile &pfm) { const vector_float &table = pfm.get_table(); for (int yi = 0; yi < y_size; ++yi) { const float *row = &table[(yi * x_size) * _num_channels]; - + if (TIFFWriteScanline(tif, (tdata_t)row, yi, 0 ) < 0) { pnmimage_tiff_cat.error() << "failed a scanline write on row " << yi << "\n"; diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index 7a78988cdd..680368a49d 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -60,6 +60,7 @@ pbitops.I pbitops.h \ portalMask.h \ pta_ushort.h \ + pythonCallbackObject.cxx \ pythonCallbackObject.h pythonCallbackObject.I \ simpleHashMap.I simpleHashMap.h \ sparseArray.I sparseArray.h \ @@ -110,7 +111,6 @@ paramValue.cxx \ pbitops.cxx \ pta_ushort.cxx \ - pythonCallbackObject.cxx \ simpleHashMap.cxx \ sparseArray.cxx \ timedCycle.cxx typedWritable.cxx \ diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index c7b8b7e1c9..64fcdedff0 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -160,8 +160,12 @@ INLINE ostream &operator << (ostream &out, const BitMask &bitmask) // We need to define this temporary macro so we can pass a parameter // containing a comma through the macro. +#define BITMASK16_DEF BitMask #define BITMASK32_DEF BitMask +#define BITMASK64_DEF BitMask +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, BITMASK16_DEF); EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, BITMASK32_DEF); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, BITMASK64_DEF); typedef BitMask BitMask16; typedef BitMask BitMask32; diff --git a/panda/src/putil/config_util.N b/panda/src/putil/config_util.N index a177d46e73..4bcc299b1e 100644 --- a/panda/src/putil/config_util.N +++ b/panda/src/putil/config_util.N @@ -17,3 +17,6 @@ forcetype PointerToBase > forcetype PointerToArrayBase forcetype PointerToArray forcetype ConstPointerToArray + +# This is so the extensions for PTA_ushort are made available. +forceinclude "pointerToArray_ext.h" diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_util.cxx index a6ef2bcb70..ea690e423b 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_util.cxx @@ -35,7 +35,6 @@ #include "namable.h" #include "nodeCachedReferenceCount.h" #include "paramValue.h" -#include "pythonCallbackObject.h" #include "referenceCount.h" #include "sparseArray.h" #include "typedObject.h" @@ -216,9 +215,6 @@ init_libputil() { ParamVecBase4d::init_type("ParamVecBase4d"); ParamVecBase4i::init_type("ParamVecBase4i"); ParamWstring::init_type("ParamWstring"); -#ifdef HAVE_PYTHON - PythonCallbackObject::init_type(); -#endif QuadBitMaskNative::init_type(); ReferenceCount::init_type(); SparseArray::init_type(); diff --git a/panda/src/putil/doubleBitMask.h b/panda/src/putil/doubleBitMask.h index b8933efd4f..4d4dfcf3b8 100644 --- a/panda/src/putil/doubleBitMask.h +++ b/panda/src/putil/doubleBitMask.h @@ -142,7 +142,10 @@ INLINE ostream &operator << (ostream &out, const DoubleBitMask &doubleBi return out; } +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, DoubleBitMask); typedef DoubleBitMask DoubleBitMaskNative; + +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, DoubleBitMask); typedef DoubleBitMask QuadBitMaskNative; // Tell GCC that we'll take care of the instantiation explicitly here. diff --git a/panda/src/putil/p3putil_composite2.cxx b/panda/src/putil/p3putil_composite2.cxx index eacfff40b4..1f3b46718d 100644 --- a/panda/src/putil/p3putil_composite2.cxx +++ b/panda/src/putil/p3putil_composite2.cxx @@ -13,7 +13,6 @@ #include "paramValue.cxx" #include "pbitops.cxx" #include "pta_ushort.cxx" -#include "pythonCallbackObject.cxx" #include "simpleHashMap.cxx" #include "sparseArray.cxx" #include "timedCycle.cxx" diff --git a/panda/src/putil/pythonCallbackObject.cxx b/panda/src/putil/pythonCallbackObject.cxx index 1160877901..48b0bbbbe3 100644 --- a/panda/src/putil/pythonCallbackObject.cxx +++ b/panda/src/putil/pythonCallbackObject.cxx @@ -15,15 +15,21 @@ #include "pythonCallbackObject.h" #ifdef HAVE_PYTHON -#include "py_panda.h" + +#include "py_panda.h" #include "thread.h" #include "callbackData.h" #include "config_util.h" TypeHandle PythonCallbackObject::_type_handle; +Configure(config_pythonCallbackObject); +ConfigureFn(config_pythonCallbackObject) { + PythonCallbackObject::init_type(); +} + #ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject Dtool_TypedObject; +extern struct Dtool_PyTypedObject Dtool_TypedObject; #endif //////////////////////////////////////////////////////////////////// @@ -126,13 +132,13 @@ do_python_callback(CallbackData *cbdata) { // Wrap the cbdata up in a Python object, then put it in a tuple, // for the argument list. - PyObject *pycbdata = + PyObject *pycbdata = DTool_CreatePyInstanceTyped(cbdata, Dtool_TypedObject, false, false, cbdata->get_type_index()); PyObject *args = Py_BuildValue("(O)", pycbdata); Py_DECREF(pycbdata); - PyObject *result = + PyObject *result = Thread::get_current_thread()->call_python_func(_function, args); Py_DECREF(args); diff --git a/panda/src/putil/pythonCallbackObject.h b/panda/src/putil/pythonCallbackObject.h index 4e1c03889f..44e45ab19d 100644 --- a/panda/src/putil/pythonCallbackObject.h +++ b/panda/src/putil/pythonCallbackObject.h @@ -28,7 +28,7 @@ // a callback to directly call an arbitarary Python // function. Powerful! But use with caution. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDA_PUTIL PythonCallbackObject : public CallbackObject { +class PythonCallbackObject : public CallbackObject { PUBLISHED: PythonCallbackObject(PyObject *function = Py_None); virtual ~PythonCallbackObject(); diff --git a/panda/src/putil/typedWritable_ext.cxx b/panda/src/putil/typedWritable_ext.cxx index 1cf11e0852..80e3ea2d47 100644 --- a/panda/src/putil/typedWritable_ext.cxx +++ b/panda/src/putil/typedWritable_ext.cxx @@ -17,7 +17,7 @@ #ifdef HAVE_PYTHON #ifndef CPPPARSER -extern EXPCL_PANDA_PUTIL Dtool_PyTypedObject Dtool_BamWriter; +extern Dtool_PyTypedObject Dtool_BamWriter; #endif // CPPPARSER //////////////////////////////////////////////////////////////////// diff --git a/panda/src/rocket/rocketInputHandler.cxx b/panda/src/rocket/rocketInputHandler.cxx index 4abb0366d2..58408ae08e 100644 --- a/panda/src/rocket/rocketInputHandler.cxx +++ b/panda/src/rocket/rocketInputHandler.cxx @@ -259,6 +259,15 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, case ButtonEvent::T_move: break; + + case ButtonEvent::T_candidate: + break; + + case ButtonEvent::T_raw_down: + break; + + case ButtonEvent::T_raw_up: + break; } } } diff --git a/panda/src/rocket/rocketSystemInterface.cxx b/panda/src/rocket/rocketSystemInterface.cxx index c417c60339..2f0d3acce6 100644 --- a/panda/src/rocket/rocketSystemInterface.cxx +++ b/panda/src/rocket/rocketSystemInterface.cxx @@ -51,6 +51,10 @@ LogMessage(Rocket::Core::Log::Type type, const Rocket::Core::String& message) { return true; case Rocket::Core::Log::LT_DEBUG: rocket_cat->debug() << message.CString() << "\n"; + return true; + case Rocket::Core::Log::LT_MAX: + // Not really sent; just to keep compiler happy + break; } return true; } diff --git a/panda/src/text/config_text.h b/panda/src/text/config_text.h index fb0a0f674c..279f05d083 100644 --- a/panda/src/text/config_text.h +++ b/panda/src/text/config_text.h @@ -36,9 +36,9 @@ extern ConfigVariableInt text_texture_margin; extern ConfigVariableDouble text_poly_margin; extern ConfigVariableInt text_page_size; extern ConfigVariableBool text_small_caps; -extern ConfigVariableDouble text_small_caps_scale; +extern EXPCL_PANDA_TEXT ConfigVariableDouble text_small_caps_scale; extern ConfigVariableFilename text_default_font; -extern ConfigVariableDouble text_tab_width; +extern EXPCL_PANDA_TEXT ConfigVariableDouble text_tab_width; extern ConfigVariableInt text_push_properties_key; extern ConfigVariableInt text_pop_properties_key; extern ConfigVariableInt text_soft_hyphen_key; @@ -48,7 +48,7 @@ extern wstring get_text_soft_hyphen_output(); extern ConfigVariableDouble text_hyphen_ratio; extern wstring get_text_never_break_before(); extern ConfigVariableInt text_max_never_break; -extern ConfigVariableDouble text_default_underscore_height; +extern EXPCL_PANDA_TEXT ConfigVariableDouble text_default_underscore_height; extern ConfigVariableEnum text_minfilter; extern ConfigVariableEnum text_magfilter; diff --git a/panda/src/tinydisplay/zgl.h b/panda/src/tinydisplay/zgl.h index 05aec50ce1..c18cafa8b7 100644 --- a/panda/src/tinydisplay/zgl.h +++ b/panda/src/tinydisplay/zgl.h @@ -1,6 +1,8 @@ #ifndef _tgl_zgl_h_ #define _tgl_zgl_h_ +#include "dtoolbase.h" + #include #include #include diff --git a/panda/src/vision/webcamVideoDS.cxx b/panda/src/vision/webcamVideoDS.cxx index 66743387e0..bdbdc8d798 100644 --- a/panda/src/vision/webcamVideoDS.cxx +++ b/panda/src/vision/webcamVideoDS.cxx @@ -31,7 +31,9 @@ #if defined(HAVE_DIRECTCAM) && !defined(CPPPARSER) -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #undef Configure diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.h b/panda/src/wgldisplay/wglGraphicsBuffer.h index 72aac1247b..6e4fb286e8 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.h +++ b/panda/src/wgldisplay/wglGraphicsBuffer.h @@ -22,7 +22,9 @@ // This must be included after we have included glgsg.h (which // includes gl.h). #include "wglext.h" -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include //////////////////////////////////////////////////////////////////// diff --git a/panda/src/windisplay/winDetectDx9.cxx b/panda/src/windisplay/winDetectDx9.cxx index 3689451cce..3a592331ed 100644 --- a/panda/src/windisplay/winDetectDx9.cxx +++ b/panda/src/windisplay/winDetectDx9.cxx @@ -16,7 +16,9 @@ #ifdef HAVE_DX9 -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include #include "graphicsStateGuardian.h" #include "graphicsPipe.h" diff --git a/panda/src/windisplay/winGraphicsPipe.cxx b/panda/src/windisplay/winGraphicsPipe.cxx index 90a17ab557..1fd25e52e1 100644 --- a/panda/src/windisplay/winGraphicsPipe.cxx +++ b/panda/src/windisplay/winGraphicsPipe.cxx @@ -25,21 +25,20 @@ #include #endif - TypeHandle WinGraphicsPipe::_type_handle; +#ifndef MAXIMUM_PROCESSORS #define MAXIMUM_PROCESSORS 32 +#endif -typedef struct _PROCESSOR_POWER_INFORMATION -{ - ULONG Number; - ULONG MaxMhz; - ULONG CurrentMhz; - ULONG MhzLimit; - ULONG MaxIdleState; +typedef struct _PROCESSOR_POWER_INFORMATION { + ULONG Number; + ULONG MaxMhz; + ULONG CurrentMhz; + ULONG MhzLimit; + ULONG MaxIdleState; ULONG CurrentIdleState; -} -PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION; +} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION; typedef BOOL (WINAPI *GetProcessMemoryInfoType) (HANDLE Process, PROCESS_MEMORY_COUNTERS *ppsmemCounters, DWORD cb); typedef BOOL (WINAPI *GlobalMemoryStatusExType) (LPMEMORYSTATUSEX lpBuffer); diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 592b404218..7f090ecd5c 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -47,6 +47,7 @@ static int xcursor_read(XcursorFile *file, unsigned char *buf, int len) { static int xcursor_write(XcursorFile *file, unsigned char *buf, int len) { // Not implemented, we don't need it. nassertr_always(false, 0); + return 0; } static int xcursor_seek(XcursorFile *file, long offset, int whence) { diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx index 57dc424449..4790c3bfc2 100755 --- a/pandatool/src/daeegg/daeMaterials.cxx +++ b/pandatool/src/daeegg/daeMaterials.cxx @@ -158,7 +158,7 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co string uvset_semantic (FROM_FSTRING(uvset->GetSemantic())); // Only set the UV name if this UV set actually exists. - for (int i = 0; i < _materials[semantic]->_uvsets.size(); ++i) { + for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) { if (_materials[semantic]->_uvsets[i]->_semantic == uvset_semantic) { egg_texture->set_uv_name(uvset_semantic); break; @@ -273,7 +273,7 @@ get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semanti if (input_set == -1 && _materials[semantic]->_uvsets.size() == 1) { return _materials[semantic]->_uvsets[0]->_semantic; } else { - for (int i = 0; i < _materials[semantic]->_uvsets.size(); ++i) { + for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) { if (_materials[semantic]->_uvsets[i]->_input_set == input_set && _materials[semantic]->_uvsets[i]->_input_semantic == input_semantic) { return _materials[semantic]->_uvsets[i]->_semantic; @@ -283,7 +283,7 @@ get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semanti // input_semantic this time. The reason for this is that some tools // export textangents and texbinormals bound to a uvset with input // semantic TEXCOORD. - for (int i = 0; i < _materials[semantic]->_uvsets.size(); ++i) { + for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) { if (_materials[semantic]->_uvsets[i]->_input_set == input_set) { daeegg_cat.debug() << "Using uv set with non-matching input semantic " << _materials[semantic]->_uvsets[i]->_semantic << "\n"; return _materials[semantic]->_uvsets[i]->_semantic; diff --git a/pandatool/src/palettizer/paletteImage.cxx b/pandatool/src/palettizer/paletteImage.cxx index 8676ec1409..247948c947 100644 --- a/pandatool/src/palettizer/paletteImage.cxx +++ b/pandatool/src/palettizer/paletteImage.cxx @@ -322,7 +322,7 @@ place(TexturePlacement *placement) { // [gjeon] create swappedImages TexturePlacement::TextureSwaps::iterator tsi; for (tsi = placement->_textureSwaps.begin(); tsi != placement->_textureSwaps.end(); ++tsi) { - if ((tsi - placement->_textureSwaps.begin()) >= _swappedImages.size()) { + if ((tsi - placement->_textureSwaps.begin()) >= (int)_swappedImages.size()) { PaletteImage *swappedImage = new PaletteImage(_page, _swappedImages.size(), tsi - placement->_textureSwaps.begin() + 1); swappedImage->_masterPlacements = &_placements; _swappedImages.push_back(swappedImage); @@ -1010,10 +1010,11 @@ get_swapped_image(int index) { Placements::iterator pi; for (pi = _masterPlacements->begin(); pi != _masterPlacements->end(); ++pi) { TexturePlacement *placement = (*pi); - if (placement->_textureSwaps.size() > index) + if ((int)placement->_textureSwaps.size() > index) { placement->fill_swapped_image(_image, index); - else + } else { placement->fill_image(_image); + } } } diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index e1417b023e..94bcb0e13b 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -200,7 +200,7 @@ show_text(const string &prefix, int indent_width, string text) { void ProgramBase:: write_man_page(ostream &out) { string prog = _program_name.get_basename_wo_extension(); - out << ".\\\" Automatically generated by " << prog << " -write-bam\n"; + out << ".\\\" Automatically generated by " << prog << " -write-man\n"; // Format the man page title as the uppercase version of the program name, // as per the UNIX manual conventions.