From 3cc88cd3046796687bc8b99d9839c6fc81916d00 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 11 Jun 2018 13:39:45 +0200 Subject: [PATCH 001/360] interrogate: clean up py_panda.h a bit more Inching towards reducing code in py_panda and eventually having no Python-specific code in interrogatedb anymore. --- .../interfaceMakerPythonNative.cxx | 42 +++--- dtool/src/interrogatedb/dtool_super_base.cxx | 6 +- dtool/src/interrogatedb/py_compat.cxx | 2 - dtool/src/interrogatedb/py_compat.h | 41 ++++- dtool/src/interrogatedb/py_panda.I | 31 ++++ dtool/src/interrogatedb/py_panda.cxx | 142 +----------------- dtool/src/interrogatedb/py_panda.h | 23 +-- dtool/src/pystub/pystub.cxx | 2 + 8 files changed, 105 insertions(+), 184 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 27151b8cbe..041b677d39 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -2536,7 +2536,7 @@ write_module_class(ostream &out, Object *obj) { } } - if (NeedsARichCompareFunction(obj->_itype)) { + if (NeedsARichCompareFunction(obj->_itype) || slots.count("tp_compare")) { out << "//////////////////\n"; out << "// A rich comparison function\n"; out << "// " << ClassName << "\n"; @@ -2547,7 +2547,6 @@ write_module_class(ostream &out, Object *obj) { out << " return nullptr;\n"; out << " }\n\n"; - out << " switch (op) {\n"; for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { std::set remaps; Function *func = (*fi); @@ -2564,21 +2563,28 @@ write_module_class(ostream &out, Object *obj) { } } const string &fname = func->_ifunc.get_name(); + const char *op_type; if (fname == "operator <") { - out << " case Py_LT:\n"; + op_type = "Py_LT"; } else if (fname == "operator <=") { - out << " case Py_LE:\n"; + op_type = "Py_LE"; } else if (fname == "operator ==") { - out << " case Py_EQ:\n"; + op_type = "Py_EQ"; } else if (fname == "operator !=") { - out << " case Py_NE:\n"; + op_type = "Py_NE"; } else if (fname == "operator >") { - out << " case Py_GT:\n"; + op_type = "Py_GT"; } else if (fname == "operator >=") { - out << " case Py_GE:\n"; + op_type = "Py_GE"; } else { continue; } + if (!has_local_richcompare) { + out << " switch (op) {\n"; + has_local_richcompare = true; + } + out << " case " << op_type << ":\n"; + out << " {\n"; string expected_params; @@ -2587,14 +2593,15 @@ write_module_class(ostream &out, Object *obj) { out << " break;\n"; out << " }\n"; - has_local_richcompare = true; } - out << " }\n\n"; - - out << " if (_PyErr_OCCURRED()) {\n"; - out << " PyErr_Clear();\n"; - out << " }\n\n"; + if (has_local_richcompare) { + // End of switch block + out << " }\n\n"; + out << " if (_PyErr_OCCURRED()) {\n"; + out << " PyErr_Clear();\n"; + out << " }\n\n"; + } if (slots.count("tp_compare")) { // A lot of Panda code depends on comparisons being done via the @@ -2624,6 +2631,7 @@ write_module_class(ostream &out, Object *obj) { out << " case Py_GE:\n"; out << " return PyBool_FromLong(cmpval >= 0);\n"; out << " }\n"; + has_local_richcompare = true; } out << " Py_INCREF(Py_NotImplemented);\n"; @@ -2850,7 +2858,7 @@ write_module_class(ostream &out, Object *obj) { out << "#else\n"; if (has_hash_compare) { write_function_slot(out, 4, slots, "tp_compare", - "&DTOOL_PyObject_ComparePointers"); + "&DtoolInstance_ComparePointers"); } else { out << " nullptr, // tp_compare\n"; } @@ -2880,7 +2888,7 @@ write_module_class(ostream &out, Object *obj) { // hashfunc tp_hash; if (has_hash_compare) { - write_function_slot(out, 4, slots, "tp_hash", "&DTOOL_PyObject_HashPointer"); + write_function_slot(out, 4, slots, "tp_hash", "&DtoolInstance_HashPointer"); } else { out << " nullptr, // tp_hash\n"; } @@ -2951,7 +2959,7 @@ write_module_class(ostream &out, Object *obj) { } else if (has_hash_compare) { // All hashable types need to be comparable. out << "#if PY_MAJOR_VERSION >= 3\n"; - out << " &DTOOL_PyObject_RichCompare,\n"; + out << " &DtoolInstance_RichComparePointers,\n"; out << "#else\n"; out << " nullptr, // tp_richcompare\n"; out << "#endif\n"; diff --git a/dtool/src/interrogatedb/dtool_super_base.cxx b/dtool/src/interrogatedb/dtool_super_base.cxx index d5197b3c76..9170af9d4f 100644 --- a/dtool/src/interrogatedb/dtool_super_base.cxx +++ b/dtool/src/interrogatedb/dtool_super_base.cxx @@ -79,13 +79,13 @@ EXPORT_THIS Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE = { #if PY_MAJOR_VERSION >= 3 nullptr, // tp_compare #else - &DTOOL_PyObject_ComparePointers, + &DtoolInstance_ComparePointers, #endif nullptr, // tp_repr nullptr, // tp_as_number nullptr, // tp_as_sequence nullptr, // tp_as_mapping - &DTOOL_PyObject_HashPointer, + &DtoolInstance_HashPointer, nullptr, // tp_call nullptr, // tp_str PyObject_GenericGetAttr, @@ -96,7 +96,7 @@ EXPORT_THIS Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE = { nullptr, // tp_traverse nullptr, // tp_clear #if PY_MAJOR_VERSION >= 3 - &DTOOL_PyObject_RichCompare, + &DtoolInstance_RichComparePointers, #else nullptr, // tp_richcompare #endif diff --git a/dtool/src/interrogatedb/py_compat.cxx b/dtool/src/interrogatedb/py_compat.cxx index f0dd42cf73..0c1383f983 100644 --- a/dtool/src/interrogatedb/py_compat.cxx +++ b/dtool/src/interrogatedb/py_compat.cxx @@ -16,8 +16,6 @@ #ifdef HAVE_PYTHON -PyTupleObject Dtool_EmptyTuple = {PyVarObject_HEAD_INIT(nullptr, 0)}; - #if PY_MAJOR_VERSION < 3 /** * Given a long or int, returns a size_t, or raises an OverflowError if it is diff --git a/dtool/src/interrogatedb/py_compat.h b/dtool/src/interrogatedb/py_compat.h index 46537114aa..f87c73cf3d 100644 --- a/dtool/src/interrogatedb/py_compat.h +++ b/dtool/src/interrogatedb/py_compat.h @@ -138,11 +138,29 @@ typedef long Py_hash_t; /* Python 3.6 */ -// Used to implement _PyObject_CallNoArg -extern EXPCL_INTERROGATEDB PyTupleObject Dtool_EmptyTuple; - #ifndef _PyObject_CallNoArg -# define _PyObject_CallNoArg(func) PyObject_Call((func), (PyObject *)&Dtool_EmptyTuple, nullptr) +INLINE PyObject *_PyObject_CallNoArg(PyObject *func) { + static PyTupleObject empty_tuple = {PyVarObject_HEAD_INIT(nullptr, 0)}; +#ifdef Py_TRACE_REFS + _Py_AddToAllObjects((PyObject *)&empty_tuple, 0); +#endif + return PyObject_Call(func, (PyObject *)&empty_tuple, nullptr); +} +# define _PyObject_CallNoArg _PyObject_CallNoArg +#endif + +#ifndef _PyObject_FastCall +INLINE PyObject *_PyObject_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs) { + PyObject *tuple = PyTuple_New(nargs); + for (Py_ssize_t i = 0; i < nargs; ++i) { + PyTuple_SET_ITEM(tuple, i, args[i]); + Py_INCREF(args[i]); + } + PyObject *result = PyObject_Call(func, tuple, nullptr); + Py_DECREF(tuple); + return result; +} +# define _PyObject_FastCall _PyObject_FastCall #endif // Python versions before 3.6 didn't require longlong support to be enabled. @@ -161,6 +179,21 @@ extern EXPCL_INTERROGATEDB PyTupleObject Dtool_EmptyTuple; # define PyDict_GET_SIZE(mp) (((PyDictObject *)mp)->ma_used) #endif +#ifndef Py_RETURN_RICHCOMPARE +# define Py_RETURN_RICHCOMPARE(val1, val2, op) \ + do { \ + switch (op) { \ + NODEFAULT \ + case Py_EQ: if ((val1) == (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_NE: if ((val1) != (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_LT: if ((val1) < (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_GT: if ((val1) > (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_LE: if ((val1) <= (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + case Py_GE: if ((val1) >= (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ + } \ + } while (0) +#endif + /* Other Python implementations */ // _PyErr_OCCURRED is an undocumented macro version of PyErr_Occurred. diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index 7ddf8bec9b..8f889768ea 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -62,6 +62,37 @@ DtoolInstance_GetPointer(PyObject *self, T *&into, Dtool_PyTypedObject &target_c return false; } +/** + * Function to create a hash from a wrapped Python object. + */ +INLINE Py_hash_t DtoolInstance_HashPointer(PyObject *self) { + if (self != nullptr && DtoolInstance_Check(self)) { + return (Py_hash_t)(intptr_t)DtoolInstance_VOID_PTR(self); + } + return -1; +} + +/** + * Python 2-style comparison function that compares objects by pointer. + */ +INLINE int DtoolInstance_ComparePointers(PyObject *v1, PyObject *v2) { + void *v1_this = DtoolInstance_Check(v1) ? DtoolInstance_VOID_PTR(v1) : nullptr; + void *v2_this = DtoolInstance_Check(v2) ? DtoolInstance_VOID_PTR(v2) : nullptr; + if (v1_this != nullptr && v2_this != nullptr) { + return (v1_this > v2_this) - (v1_this < v2_this); + } else { + return (v1 > v2) - (v1 < v2); + } +} + +/** + * Rich comparison function that compares objects by pointer. + */ +INLINE PyObject *DtoolInstance_RichComparePointers(PyObject *v1, PyObject *v2, int op) { + int cmpval = DtoolInstance_ComparePointers(v1, v2); + Py_RETURN_RICHCOMPARE(cmpval, 0, op); +} + /** * These functions wrap a pointer for a class that defines get_type_handle(). */ diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 236c9a5197..becbedfa78 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -143,13 +143,6 @@ DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, return nullptr; } -void *DTOOL_Call_GetPointerThis(PyObject *self) { - if (self != nullptr && DtoolInstance_Check(self)) { - return DtoolInstance_VOID_PTR(self); - } - return nullptr; -} - /** * This is similar to a PyErr_Occurred() check, except that it also checks * Notify to see if an assertion has occurred. If that is the case, then it @@ -588,10 +581,6 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { return Dtool_Raise_TypeError("PyType_Ready(Dtool_StaticProperty_Type)"); } -#ifdef Py_TRACE_REFS - _Py_AddToAllObjects((PyObject *)&Dtool_EmptyTuple, 0); -#endif - // Initialize the base class of everything. Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(nullptr); } @@ -734,127 +723,6 @@ PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { return Py_None; } -Py_hash_t DTOOL_PyObject_HashPointer(PyObject *self) { - if (self != nullptr && DtoolInstance_Check(self)) { - return (Py_hash_t)(intptr_t)DtoolInstance_VOID_PTR(self); - } - return -1; -} - -/* Compare v to w. Return - -1 if v < w or exception (PyErr_Occurred() true in latter case). - 0 if v == w. - 1 if v > w. - XXX The docs (C API manual) say the return value is undefined in case - XXX of error. -*/ - -int DTOOL_PyObject_ComparePointers(PyObject *v1, PyObject *v2) { - // try this compare - void *v1_this = DTOOL_Call_GetPointerThis(v1); - void *v2_this = DTOOL_Call_GetPointerThis(v2); - if (v1_this != nullptr && v2_this != nullptr) { // both are our types... - if (v1_this < v2_this) { - return -1; - } - if (v1_this > v2_this) { - return 1; - } - return 0; - } - - // ok self compare... - if (v1 < v2) { - return -1; - } - if (v1 > v2) { - return 1; - } - return 0; -} - -int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2) { - // First try compareTo function.. - PyObject * func = PyObject_GetAttrString(v1, "compare_to"); - if (func == nullptr) { - PyErr_Clear(); - } else { -#if PY_VERSION_HEX >= 0x03060000 - PyObject *res = _PyObject_FastCall(func, &v2, 1); -#else - PyObject *res = nullptr; - PyObject *args = PyTuple_Pack(1, v2); - if (args != nullptr) { - res = PyObject_Call(func, args, nullptr); - Py_DECREF(args); - } -#endif - Py_DECREF(func); - PyErr_Clear(); // just in case the function threw an error - // only use if the function returns an INT... hmm - if (res != nullptr) { - if (PyLong_Check(res)) { - long answer = PyLong_AsLong(res); - Py_DECREF(res); - - // Python really wants us to return strictly -1, 0, or 1. - if (answer < 0) { - return -1; - } else if (answer > 0) { - return 1; - } else { - return 0; - } - } -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(res)) { - long answer = PyInt_AsLong(res); - Py_DECREF(res); - - // Python really wants us to return strictly -1, 0, or 1. - if (answer < 0) { - return -1; - } else if (answer > 0) { - return 1; - } else { - return 0; - } - } -#endif - Py_DECREF(res); - } - } - - return DTOOL_PyObject_ComparePointers(v1, v2); -} - -PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op) { - int cmpval = DTOOL_PyObject_Compare(v1, v2); - bool result; - switch (op) { - NODEFAULT - case Py_LT: - result = (cmpval < 0); - break; - case Py_LE: - result = (cmpval <= 0); - break; - case Py_EQ: - result = (cmpval == 0); - break; - case Py_NE: - result = (cmpval != 0); - break; - case Py_GT: - result = (cmpval > 0); - break; - case Py_GE: - result = (cmpval >= 0); - break; - } - return PyBool_FromLong(result); -} - /** * This is a support function for a synthesized __copy__() method from a C++ * make_copy() method. @@ -875,15 +743,7 @@ PyObject *copy_from_make_copy(PyObject *self, PyObject *noargs) { */ PyObject *copy_from_copy_constructor(PyObject *self, PyObject *noargs) { PyObject *callable = (PyObject *)Py_TYPE(self); - -#if PY_VERSION_HEX >= 0x03060000 - PyObject *result = _PyObject_FastCall(callable, &self, 1); -#else - PyObject *args = PyTuple_Pack(1, self); - PyObject *result = PyObject_Call(callable, args, nullptr); - Py_DECREF(args); -#endif - return result; + return _PyObject_FastCall(callable, &self, 1); } /** diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index ed6d063e03..6feb2d6f70 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -195,8 +195,6 @@ EXPCL_INTERROGATEDB void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dt EXPCL_INTERROGATEDB void *DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const std::string &function_name, bool const_ok, bool report_errors); -EXPCL_INTERROGATEDB void *DTOOL_Call_GetPointerThis(PyObject *self); - EXPCL_INTERROGATEDB bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef, void **answer); EXPCL_INTERROGATEDB bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject &classdef, @@ -205,6 +203,10 @@ EXPCL_INTERROGATEDB bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, template INLINE bool DtoolInstance_GetPointer(PyObject *self, T *&into); template INLINE bool DtoolInstance_GetPointer(PyObject *self, T *&into, Dtool_PyTypedObject &classdef); +INLINE Py_hash_t DtoolInstance_HashPointer(PyObject *self); +INLINE int DtoolInstance_ComparePointers(PyObject *v1, PyObject *v2); +INLINE PyObject *DtoolInstance_RichComparePointers(PyObject *v1, PyObject *v2, int op); + // Functions related to error reporting. EXPCL_INTERROGATEDB bool _Dtool_CheckErrorOccurred(); @@ -331,21 +333,8 @@ EXPCL_INTERROGATEDB PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject // some point.. EXPCL_INTERROGATEDB PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args); - -EXPCL_INTERROGATEDB Py_hash_t DTOOL_PyObject_HashPointer(PyObject *obj); - -/* Compare v to w. Return - -1 if v < w or exception (PyErr_Occurred() true in latter case). - 0 if v == w. - 1 if v > w. - XXX The docs (C API manual) say the return value is undefined in case - XXX of error. -*/ - -EXPCL_INTERROGATEDB int DTOOL_PyObject_ComparePointers(PyObject *v1, PyObject *v2); -EXPCL_INTERROGATEDB int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2); - -EXPCL_INTERROGATEDB PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op); +#define DTOOL_PyObject_HashPointer DtoolInstance_HashPointer +#define DTOOL_PyObject_ComparePointers DtoolInstance_ComparePointers EXPCL_INTERROGATEDB PyObject * copy_from_make_copy(PyObject *self, PyObject *noargs); diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index 91cad58115..cf617cd6f7 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -192,6 +192,7 @@ extern "C" { EXPCL_PYSTUB int _PyArg_Parse_SizeT(...); EXPCL_PYSTUB int _PyErr_BadInternalCall(...); EXPCL_PYSTUB int _PyLong_AsByteArray(...); + EXPCL_PYSTUB int _PyLong_Sign(...); EXPCL_PYSTUB int _PyObject_CallFunction_SizeT(...); EXPCL_PYSTUB int _PyObject_CallMethod_SizeT(...); EXPCL_PYSTUB int _PyObject_DebugFree(...); @@ -421,6 +422,7 @@ int _PyArg_ParseTupleAndKeywords_SizeT(...) { return 0; }; int _PyArg_Parse_SizeT(...) { return 0; }; int _PyErr_BadInternalCall(...) { return 0; }; int _PyLong_AsByteArray(...) { return 0; }; +int _PyLong_Sign(...) { return 0; }; int _PyObject_CallFunction_SizeT(...) { return 0; }; int _PyObject_CallMethod_SizeT(...) { return 0; }; int _PyObject_DebugFree(...) { return 0; }; From 1c476203fc1d74449fd1f2c78a0ed4ab2ad51a2d Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 11 Jun 2018 13:43:30 +0200 Subject: [PATCH 002/360] interrogate: remove Dtool_AddToDictionary (let me know if anyone uses this) If any code is relying on this, please let me know and I will add it back. It appears to be redundant, though, since one can access DtoolClassDict directly. Symbol kept around temporarily in order to keep ABI compatibility for a short while as people may not update their interrogate and Panda in sync, but it can soon be removed. --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 2 +- dtool/src/interrogatedb/py_panda.cxx | 2 +- dtool/src/interrogatedb/py_panda.h | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 041b677d39..e1867508c7 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -1459,7 +1459,7 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { if (force_base_functions) { out << " // Support Function For Dtool_types ... for now in each module ??\n"; out << " {\"Dtool_BorrowThisReference\", &Dtool_BorrowThisReference, METH_VARARGS, \"Used to borrow 'this' pointer (to, from)\\nAssumes no ownership.\"},\n"; - out << " {\"Dtool_AddToDictionary\", &Dtool_AddToDictionary, METH_VARARGS, \"Used to add items into a tp_dict\"},\n"; + //out << " {\"Dtool_AddToDictionary\", &Dtool_AddToDictionary, METH_VARARGS, \"Used to add items into a tp_dict\"},\n"; } out << " {nullptr, nullptr, 0, nullptr}\n" << "};\n\n"; diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index becbedfa78..ee2966789f 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -704,7 +704,7 @@ PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args) { // We do expose a dictionay for dtool classes .. this should be removed at // some point.. -PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { +EXPCL_INTERROGATEDB PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { PyObject *self; PyObject *subject; PyObject *key; diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 6feb2d6f70..4025b965d5 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -329,10 +329,6 @@ EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const // historical inharatence in the for of "is this instance of".. EXPCL_INTERROGATEDB PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args); -// We do expose a dictionay for dtool classes .. this should be removed at -// some point.. -EXPCL_INTERROGATEDB PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args); - #define DTOOL_PyObject_HashPointer DtoolInstance_HashPointer #define DTOOL_PyObject_ComparePointers DtoolInstance_ComparePointers From 494ba40c5edc6b333f2ff629f06e404a545e9e44 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 11 Jun 2018 14:35:37 +0200 Subject: [PATCH 003/360] Fix compilation error on Android --- panda/src/express/virtualFileMountAndroidAsset.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/panda/src/express/virtualFileMountAndroidAsset.cxx b/panda/src/express/virtualFileMountAndroidAsset.cxx index b14edabb36..fa5fccece3 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.cxx +++ b/panda/src/express/virtualFileMountAndroidAsset.cxx @@ -290,10 +290,10 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { int whence; switch (dir) { - case ios_base::beg: + case std::ios_base::beg: whence = SEEK_SET; break; - case ios_base::cur: + case std::ios_base::cur: if (off == 0) { // Just requesting the current position, no need to void the buffer. return AAsset_seek(_asset, 0, SEEK_CUR) - n; @@ -305,7 +305,7 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { } whence = SEEK_CUR; break; - case ios_base::end: + case std::ios_base::end: whence = SEEK_END; break; default: From ac4b8d1e1d3443ca16cc223799a5b13d44893c71 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 11 Jun 2018 14:53:25 +0200 Subject: [PATCH 004/360] Fix various compilation warnings --- contrib/src/rplight/iesDataset.cxx | 2 ++ contrib/src/rplight/pssmCameraRig.cxx | 2 ++ contrib/src/rplight/rpSpotLight.cxx | 2 ++ dtool/src/parser-inc/stdlib.h | 2 ++ pandatool/src/mayaprogs/mayaSavePview.cxx | 4 ++-- pandatool/src/mayaprogs/mayapath.cxx | 2 ++ 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/contrib/src/rplight/iesDataset.cxx b/contrib/src/rplight/iesDataset.cxx index 2975268138..34f5a8608e 100644 --- a/contrib/src/rplight/iesDataset.cxx +++ b/contrib/src/rplight/iesDataset.cxx @@ -27,7 +27,9 @@ #include "iesDataset.h" +#ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES +#endif #include NotifyCategoryDef(iesdataset, "") diff --git a/contrib/src/rplight/pssmCameraRig.cxx b/contrib/src/rplight/pssmCameraRig.cxx index b9560a80d2..8b8c22fd20 100644 --- a/contrib/src/rplight/pssmCameraRig.cxx +++ b/contrib/src/rplight/pssmCameraRig.cxx @@ -27,7 +27,9 @@ #include "pssmCameraRig.h" +#ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES +#endif #include #include "orthographicLens.h" diff --git a/contrib/src/rplight/rpSpotLight.cxx b/contrib/src/rplight/rpSpotLight.cxx index 649e0b1beb..3fd677a34c 100644 --- a/contrib/src/rplight/rpSpotLight.cxx +++ b/contrib/src/rplight/rpSpotLight.cxx @@ -27,7 +27,9 @@ #include "rpSpotLight.h" +#ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES +#endif #include diff --git a/dtool/src/parser-inc/stdlib.h b/dtool/src/parser-inc/stdlib.h index 5009b522b8..cb05992816 100644 --- a/dtool/src/parser-inc/stdlib.h +++ b/dtool/src/parser-inc/stdlib.h @@ -1,3 +1,5 @@ +#pragma once + #include #define EXIT_SUCCESS 0 diff --git a/pandatool/src/mayaprogs/mayaSavePview.cxx b/pandatool/src/mayaprogs/mayaSavePview.cxx index 423c7f09da..1537d95ce8 100644 --- a/pandatool/src/mayaprogs/mayaSavePview.cxx +++ b/pandatool/src/mayaprogs/mayaSavePview.cxx @@ -72,8 +72,8 @@ doIt(const MArgList &args) { #ifdef WIN32_VC // On Windows, we use the spawn function to run pview asynchronously. MString quoted = MString("\"") + filename + MString("\""); - int retval = _spawnlp(_P_DETACH, "pview", - "pview", pview_args.asChar(), quoted.asChar(), nullptr); + intptr_t retval = _spawnlp(_P_DETACH, "pview", + "pview", pview_args.asChar(), quoted.asChar(), nullptr); if (retval == -1) { return MS::kFailure; } diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index a82411efe9..cac021eebe 100644 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -43,7 +43,9 @@ #include #if defined(_WIN32) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include #else #include From 4fe7fe4c88aaf5f69fa0f9f7e1ecc3a31eece760 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 12 Jun 2018 11:08:02 +0200 Subject: [PATCH 005/360] interrogate: fix int8_t / signed char range checking on Android --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index e1867508c7..6c652bb806 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -5046,7 +5046,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, "value %ld out of range for unsigned byte", param_name); } else { - extra_convert << "if (" << param_name << " < CHAR_MIN || " << param_name << " > CHAR_MAX) {\n"; + extra_convert << "if (" << param_name << " < SCHAR_MIN || " << param_name << " > SCHAR_MAX) {\n"; error_raise_return(extra_convert, 2, return_flags, "OverflowError", "value %ld out of range for signed byte", param_name); From fa23c199eca853836b093d46272d70c872d1624c Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 12 Jun 2018 11:08:52 +0200 Subject: [PATCH 006/360] makepanda: fix faulty error when immediately pressing Ctrl+C --- makepanda/makepanda.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 1b49826a8f..df25c49f39 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -15,9 +15,11 @@ try: import queue else: import Queue as queue +except KeyboardInterrupt: + raise except: print("You are either using an incomplete or an old version of Python!") - print("Please install the development package of Python 2.x and try again.") + print("Please install the development package of Python and try again.") exit(1) from makepandacore import * From b88bd9970464ebda498e96bab08f7403757da7fa Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 12 Jun 2018 11:09:26 +0200 Subject: [PATCH 007/360] Various compiler warning fixes --- .../interfaceMakerPythonNative.cxx | 20 ------------------- panda/src/char/characterSlider.h | 1 + panda/src/display/nativeWindowHandle.h | 2 +- panda/src/egg/eggCompositePrimitive.cxx | 8 ++++---- panda/src/egg/eggPrimitive.cxx | 8 +++----- panda/src/egg/eggTriangleFan.cxx | 2 +- panda/src/egg2pg/eggSaver.cxx | 4 ++-- panda/src/event/asyncTaskSequence.I | 2 +- panda/src/event/asyncTaskSequence.h | 4 ++-- .../glstuff/glGraphicsStateGuardian_src.cxx | 2 +- .../src/glstuff/glGraphicsStateGuardian_src.h | 2 +- panda/src/grutil/meshDrawer.cxx | 2 +- panda/src/grutil/movieTexture.cxx | 11 ++++++++++ panda/src/grutil/movieTexture.h | 3 +++ panda/src/movies/dr_flac.h | 2 ++ panda/src/pgraph/geomTransformer.cxx | 2 +- panda/src/pgraph/nodePathCollection.cxx | 6 +++--- panda/src/pgraph/nodePathCollection.h | 4 ++-- panda/src/pgraphnodes/shaderGenerator.cxx | 5 +++++ panda/src/text/textAssembler.cxx | 4 ++-- panda/src/tinydisplay/ztriangle.h | 2 +- panda/src/tinydisplay/ztriangle_two.h | 14 ++++++------- 22 files changed, 55 insertions(+), 55 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 6c652bb806..c040f0dc6c 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -103,11 +103,6 @@ RenameSet methodRenameDictionary[] = { { nullptr, nullptr, -1 } }; -RenameSet classRenameDictionary[] = { - // No longer used, now empty. - { nullptr, nullptr, -1 } -}; - const char *pythonKeywords[] = { "and", "as", @@ -193,12 +188,6 @@ classNameFromCppName(const std::string &cppName, bool mangle) { } } - for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) { - if (cppName == classRenameDictionary[x]._from) { - className = classRenameDictionary[x]._to; - } - } - if (className.empty()) { std::string text = "** ERROR ** Renaming class: " + cppName + " to empty string"; printf("%s", text.c_str()); @@ -253,15 +242,6 @@ methodNameFromCppName(const std::string &cppName, const std::string &className, } } - if (className.size() > 0) { - string lookup_name = className + '.' + cppName; - for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) { - if (lookup_name == methodRenameDictionary[x]._from) { - methodName = methodRenameDictionary[x]._to; - } - } - } - // # Mangle names that happen to be python keywords so they are not anymore methodName = checkKeyword(methodName); return methodName; diff --git a/panda/src/char/characterSlider.h b/panda/src/char/characterSlider.h index 3c347af12b..9871095afd 100644 --- a/panda/src/char/characterSlider.h +++ b/panda/src/char/characterSlider.h @@ -34,6 +34,7 @@ PUBLISHED: explicit CharacterSlider(PartGroup *parent, const std::string &name); virtual ~CharacterSlider(); +public: virtual PartGroup *make_copy() const; virtual bool update_internals(PartBundle *root, PartGroup *parent, diff --git a/panda/src/display/nativeWindowHandle.h b/panda/src/display/nativeWindowHandle.h index 1ee6fec43a..14bab98815 100644 --- a/panda/src/display/nativeWindowHandle.h +++ b/panda/src/display/nativeWindowHandle.h @@ -33,7 +33,7 @@ * This class exists for name scoping only. Don't use the constructor * directly; use one of the make_* methods. */ -class EXPCL_PANDA_DISPLAY NativeWindowHandle : public WindowHandle { +class EXPCL_PANDA_DISPLAY NativeWindowHandle final : public WindowHandle { private: INLINE NativeWindowHandle(); INLINE NativeWindowHandle(const NativeWindowHandle ©); diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index b42cb080c9..94c4b1d625 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -57,7 +57,7 @@ get_shading() const { if (!first_component->has_normal()) { first_component = this; } - for (int i = 1; i < get_num_components(); i++) { + for (size_t i = 1; i < get_num_components(); ++i) { const EggAttributes *component = get_component(i); if (!component->has_normal()) { component = this; @@ -74,7 +74,7 @@ get_shading() const { if (!first_component->has_color()) { first_component = this; } - for (int i = 1; i < get_num_components(); i++) { + for (size_t i = 1; i < get_num_components(); ++i) { const EggAttributes *component = get_component(i); if (!component->has_color()) { component = this; @@ -295,7 +295,7 @@ apply_last_attribute() { // The first component gets applied to the third vertex, and so on from // there. int num_lead_vertices = get_num_lead_vertices(); - for (int i = 0; i < get_num_components(); i++) { + for (size_t i = 0; i < get_num_components(); ++i) { EggAttributes *component = get_component(i); do_apply_flat_attribute(i + num_lead_vertices, component); } @@ -313,7 +313,7 @@ void EggCompositePrimitive:: apply_first_attribute() { // The first component gets applied to the first vertex, and so on from // there. - for (int i = 0; i < get_num_components(); i++) { + for (size_t i = 0; i < get_num_components(); ++i) { EggAttributes *component = get_component(i); do_apply_flat_attribute(i, component); } diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index ad0b464c30..ee35080416 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -227,7 +227,7 @@ get_shading() const { if (!first_vertex->has_normal()) { first_vertex = this; } - for (int i = 1; i < get_num_vertices(); i++) { + for (size_t i = 1; i < get_num_vertices(); ++i) { const EggAttributes *vertex = get_vertex(i); if (!vertex->has_normal()) { vertex = this; @@ -244,7 +244,7 @@ get_shading() const { if (!first_vertex->has_color()) { first_vertex = this; } - for (int i = 1; i < get_num_vertices(); i++) { + for (size_t i = 1; i < get_num_vertices(); ++i) { const EggAttributes *vertex = get_vertex(i); if (!vertex->has_color()) { vertex = this; @@ -461,9 +461,7 @@ apply_first_attribute() { void EggPrimitive:: post_apply_flat_attribute() { if (!empty()) { - for (int i = 0; i < (int)size(); i++) { - EggVertex *vertex = get_vertex(i); - + for (EggVertex *vertex : _vertices) { // Use set_normal() instead of copy_normal(), to avoid getting the // morphs--we don't want them here, since we're just putting a bogus // value on the normal anyway. diff --git a/panda/src/egg/eggTriangleFan.cxx b/panda/src/egg/eggTriangleFan.cxx index 30d441286a..6ad3b4f5ae 100644 --- a/panda/src/egg/eggTriangleFan.cxx +++ b/panda/src/egg/eggTriangleFan.cxx @@ -57,7 +57,7 @@ apply_first_attribute() { // In the case of a triangle fan, the first vertex of the fan is the common // vertex, so we consider the second vertex to be the key vertex of the // first triangle, and move from there. - for (int i = 0; i < get_num_components(); i++) { + for (size_t i = 0; i < get_num_components(); ++i) { EggAttributes *component = get_component(i); do_apply_flat_attribute(i + 1, component); } diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index b54b6df744..af70617e36 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -560,7 +560,7 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, // Get an arbitrary vector on the plane by taking the cross product // with any vector, as long as it is different. LVector3 vec1; - if (abs(normal[2]) > abs(normal[1])) { + if (std::fabs(normal[2]) > std::fabs(normal[1])) { vec1 = normal.cross(LVector3(0, 1, 0)); } else { vec1 = normal.cross(LVector3(0, 0, 1)); @@ -626,7 +626,7 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, // Also get an arbitrary vector perpendicular to the tube. LVector3 axis = point_b - point_a; LVector3 sideways; - if (abs(axis[2]) > abs(axis[1])) { + if (std::fabs(axis[2]) > std::fabs(axis[1])) { sideways = axis.cross(LVector3(0, 1, 0)); } else { sideways = axis.cross(LVector3(0, 0, 1)); diff --git a/panda/src/event/asyncTaskSequence.I b/panda/src/event/asyncTaskSequence.I index 28d94f2f75..332303df7a 100644 --- a/panda/src/event/asyncTaskSequence.I +++ b/panda/src/event/asyncTaskSequence.I @@ -34,7 +34,7 @@ get_repeat_count() const { * Returns the index of the task within the sequence that is currently being * executed (or that will be executed at the next epoch). */ -INLINE int AsyncTaskSequence:: +INLINE size_t AsyncTaskSequence:: get_current_task_index() const { return _task_index; } diff --git a/panda/src/event/asyncTaskSequence.h b/panda/src/event/asyncTaskSequence.h index 3d1c4cc450..096d1f6b88 100644 --- a/panda/src/event/asyncTaskSequence.h +++ b/panda/src/event/asyncTaskSequence.h @@ -39,7 +39,7 @@ PUBLISHED: INLINE void set_repeat_count(int repeat_count); INLINE int get_repeat_count() const; - INLINE int get_current_task_index() const; + INLINE size_t get_current_task_index() const; protected: virtual bool is_runnable(); @@ -51,7 +51,7 @@ private: void set_current_task(AsyncTask *task, bool clean_exit); int _repeat_count; - int _task_index; + size_t _task_index; PT(AsyncTask) _current_task; public: diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 6c06ae0b6b..1e4c2bb530 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -3007,7 +3007,7 @@ reset() { #ifndef OPENGLES_1 _enabled_vertex_attrib_arrays.clear(); - memset(_vertex_attrib_divisors, 0, sizeof(GLint) * 32); + memset(_vertex_attrib_divisors, 0, sizeof(GLuint) * 32); #endif // Dither is on by default in GL; let's turn it off diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 5c29d4bcad..c0f75a21d5 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -661,7 +661,7 @@ protected: #ifndef OPENGLES_1 BitMask32 _enabled_vertex_attrib_arrays; - GLint _vertex_attrib_divisors[32]; + GLuint _vertex_attrib_divisors[32]; PT(Shader) _current_shader; ShaderContext *_current_shader_context; diff --git a/panda/src/grutil/meshDrawer.cxx b/panda/src/grutil/meshDrawer.cxx index a727c15ced..b87380d3b8 100644 --- a/panda/src/grutil/meshDrawer.cxx +++ b/panda/src/grutil/meshDrawer.cxx @@ -374,7 +374,7 @@ void MeshDrawer::geometry(NodePath draw_node) { CPT(GeomVertexData) v_data = geom->get_vertex_data(); GeomVertexReader *prim_vertex_reader = new GeomVertexReader(v_data, "vertex"); GeomVertexReader *prim_uv_reader = new GeomVertexReader(v_data, "texcoord"); - for(int k=0; k get_num_primitives(); k++) { + for (size_t k = 0; k < geom->get_num_primitives(); ++k) { CPT(GeomPrimitive) prim1 = geom->get_primitive(k); CPT(GeomPrimitive) _prim = prim1->decompose(); diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index c62eb23715..44f3d541d4 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -288,6 +288,17 @@ do_load_one(Texture::CData *cdata_tex, return false; } +/** + * Loading a static image into a MovieTexture is an error. + */ +bool MovieTexture:: +do_load_one(Texture::CData *cdata_tex, + const PfmFile &pfm, const std::string &name, int z, int n, + const LoaderOptions &options) { + grutil_cat.error() << "You cannot load a static image into a MovieTexture\n"; + return false; +} + /** * Called internally by do_reconsider_z_size() to allocate new memory in * _ram_images[0] for the new number of pages. diff --git a/panda/src/grutil/movieTexture.h b/panda/src/grutil/movieTexture.h index c1721f4320..1a49c885b1 100644 --- a/panda/src/grutil/movieTexture.h +++ b/panda/src/grutil/movieTexture.h @@ -102,6 +102,9 @@ protected: virtual bool do_load_one(Texture::CData *cdata, const PNMImage &pnmimage, const std::string &name, int z, int n, const LoaderOptions &options); + virtual bool do_load_one(Texture::CData *cdata, + const PfmFile &pfm, const std::string &name, + int z, int n, const LoaderOptions &options); bool do_load_one(Texture::CData *cdata, PT(MovieVideoCursor) color, PT(MovieVideoCursor) alpha, int z, const LoaderOptions &options); diff --git a/panda/src/movies/dr_flac.h b/panda/src/movies/dr_flac.h index fdac6a2f79..3d0b1cdd91 100644 --- a/panda/src/movies/dr_flac.h +++ b/panda/src/movies/dr_flac.h @@ -328,7 +328,9 @@ static drflac* drflac_open_memory(const void* data, size_t dataSize); #endif #ifdef __linux__ +#ifndef _BSD_SOURCE #define _BSD_SOURCE +#endif #include #endif diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index c77fc35e28..e21327b304 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -1242,7 +1242,7 @@ apply_collect_changes() { */ void GeomTransformer::NewCollectedData:: append_vdata(const GeomVertexData *vdata, int vertex_offset) { - for (int i = 0; i < vdata->get_num_arrays(); ++i) { + for (size_t i = 0; i < vdata->get_num_arrays(); ++i) { PT(GeomVertexArrayDataHandle) new_handle = _new_data->modify_array_handle(i); CPT(GeomVertexArrayDataHandle) old_handle = vdata->get_array_handle(i); size_t stride = (size_t)_new_format->get_array(i)->get_stride(); diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index 68977a8b4b..8f29f07f22 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -188,8 +188,8 @@ get_path(int index) const { * get_path(), but it may be a more convenient way to access it. */ NodePath NodePathCollection:: -operator [] (int index) const { - nassertr(index >= 0 && index < (int)_node_paths.size(), NodePath()); +operator [] (size_t index) const { + nassertr(index < _node_paths.size(), NodePath()); return _node_paths[index]; } @@ -198,7 +198,7 @@ operator [] (int index) const { * Returns the number of paths in the collection. This is the same thing as * get_num_paths(). */ -int NodePathCollection:: +size_t NodePathCollection:: size() const { return _node_paths.size(); } diff --git a/panda/src/pgraph/nodePathCollection.h b/panda/src/pgraph/nodePathCollection.h index 64a16d63c3..6dd4e76b12 100644 --- a/panda/src/pgraph/nodePathCollection.h +++ b/panda/src/pgraph/nodePathCollection.h @@ -45,8 +45,8 @@ PUBLISHED: int get_num_paths() const; NodePath get_path(int index) const; MAKE_SEQ(get_paths, get_num_paths, get_path); - NodePath operator [] (int index) const; - int size() const; + NodePath operator [] (size_t index) const; + size_t size() const; INLINE void operator += (const NodePathCollection &other); INLINE NodePathCollection operator + (const NodePathCollection &other) const; diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index af4410aea2..bdca5406ce 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -404,6 +404,9 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { info._flags |= ShaderKey::TF_uses_last_saved_result; } break; + + default: + break; } // In fact, perhaps this stage should be disabled altogether? @@ -438,6 +441,8 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { skip = true; } break; + default: + break; } // We can't just drop a disabled slot from the list, since then the // indices for the texture stages will no longer match up. So we keep it, diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index c427be8c79..e59b83a100 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -2381,7 +2381,7 @@ assign_append_to(GeomCollectorMap &geom_collector_map, PT(Geom) geom = _glyph->get_geom(GeomEnums::UH_static); - int p, sp, s, e, i; + int sp, s, e, i; const GeomVertexData *vdata = geom->get_vertex_data(); CPT(RenderState) rs = _glyph->get_state()->compose(state); @@ -2398,7 +2398,7 @@ assign_append_to(GeomCollectorMap &geom_collector_map, // that we don't needlessly duplicate vertices into our output vertex data. VertexIndexMap vimap; - for (p = 0; p < geom->get_num_primitives(); p++) { + for (size_t p = 0; p < geom->get_num_primitives(); ++p) { CPT(GeomPrimitive) primitive = geom->get_primitive(p)->decompose(); // Get a new GeomPrimitive of the corresponding type. diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index 9b2db10f2d..daa035dc75 100644 --- a/panda/src/tinydisplay/ztriangle.h +++ b/panda/src/tinydisplay/ztriangle.h @@ -14,7 +14,7 @@ int error, derror; int x1, dxdy_min, dxdy_max; /* warning: x2 is multiplied by 2^16 */ - int x2, dx2dy2; + UNUSED int x2, dx2dy2; #ifdef INTERP_Z int z1 = 0, dzdx = 0, dzdy = 0, dzdl_min = 0, dzdl_max = 0; diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index b8baba23c2..49c4550b4a 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -32,7 +32,7 @@ FNAME(flat_untextured) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { UNUSED int color; - int or0, og0, ob0, oa0; + UNUSED int or0, og0, ob0, oa0; #define INTERP_Z @@ -160,7 +160,7 @@ FNAME(flat_textured) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { ZTextureDef *texture_def; - int or0, og0, ob0, oa0; + UNUSED int or0, og0, ob0, oa0; #define INTERP_Z #define INTERP_ST @@ -399,7 +399,7 @@ FNAME(flat_perspective) (ZBuffer *zb, { ZTextureDef *texture_def; PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx; - int or0, og0, ob0, oa0; + UNUSED int or0, og0, ob0, oa0; #define INTERP_Z #define INTERP_STZ @@ -456,7 +456,7 @@ FNAME(flat_perspective) (ZBuffer *zb, PIXEL *pp; \ int s,t,z,zz; \ int n,dsdx,dtdx; \ - int or1,og1,ob1,oa1; \ + UNUSED int or1,og1,ob1,oa1; \ PN_stdfloat sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ fz=(PN_stdfloat)z1; \ @@ -596,7 +596,7 @@ FNAME(smooth_perspective) (ZBuffer *zb, PIXEL *pp; \ int s,t,z,zz; \ int n,dsdx,dtdx; \ - int or1,og1,ob1,oa1; \ + UNUSED int or1,og1,ob1,oa1; \ PN_stdfloat sz,tz,fz,zinv; \ n=(x2>>16)-x1; \ fz=(PN_stdfloat)z1; \ @@ -727,7 +727,7 @@ FNAME(smooth_multitex2) (ZBuffer *zb, PIXEL *pp; \ int s,t,sa,ta,z,zz; \ int n,dsdx,dtdx,dsadx,dtadx; \ - int or1,og1,ob1,oa1; \ + UNUSED int or1,og1,ob1,oa1; \ PN_stdfloat sz,tz,sza,tza,fz,zinv; \ n=(x2>>16)-x1; \ fz=(PN_stdfloat)z1; \ @@ -888,7 +888,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, PIXEL *pp; \ int s,t,sa,ta,sb,tb,z,zz; \ int n,dsdx,dtdx,dsadx,dtadx,dsbdx,dtbdx; \ - int or1,og1,ob1,oa1; \ + UNUSED int or1,og1,ob1,oa1; \ PN_stdfloat sz,tz,sza,tza,szb,tzb,fz,zinv; \ n=(x2>>16)-x1; \ fz=(PN_stdfloat)z1; \ From 65217a258d63830f374145f928444a81e47f5a69 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 12 Jun 2018 12:45:48 +0200 Subject: [PATCH 008/360] tform: allow calling MouseWatcher::add_region with same region twice Previously, this was an error. Now, it will simply silently be ignored, making it behave more like a set. --- panda/src/tform/mouseWatcherBase.cxx | 65 ++++++++++++++-------------- panda/src/tform/mouseWatcherBase.h | 9 ++-- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/panda/src/tform/mouseWatcherBase.cxx b/panda/src/tform/mouseWatcherBase.cxx index 820fb81d90..2a167e57c5 100644 --- a/panda/src/tform/mouseWatcherBase.cxx +++ b/panda/src/tform/mouseWatcherBase.cxx @@ -40,34 +40,31 @@ MouseWatcherBase:: } /** - * Adds the indicated region to the set of regions in the group. It is an - * error to add the same region to the set more than once. + * Adds the indicated region to the set of regions in the group. It is no + * longer an error to call this for the same region more than once. */ void MouseWatcherBase:: -add_region(MouseWatcherRegion *region) { - PT(MouseWatcherRegion) pt = region; - +add_region(PT(MouseWatcherRegion) region) { LightMutexHolder holder(_lock); - // We will only bother to check for duplicates in the region list if we are - // building a development Panda. The overhead for doing this may be too - // high if we have many regions. -#ifdef _DEBUG - // See if the region is in the setvector already - Regions::const_iterator ri = - find(_regions.begin(), _regions.end(), pt); - nassertv(ri == _regions.end()); -#endif // _DEBUG - #ifndef NDEBUG // Also add it to the vizzes if we have them. - if (_show_regions) { - nassertv(_vizzes.size() == _regions.size()); - _vizzes.push_back(make_viz_region(pt)); + if (UNLIKELY(_show_regions)) { + // We need to check whether it is already in the set, so that we don't + // create a duplicate viz. + Regions::const_iterator ri = + std::find(_regions.begin(), _regions.end(), region); + + if (ri == _regions.end()) { + nassertv(_vizzes.size() == _regions.size()); + _vizzes.push_back(make_viz_region(region)); + } else { + return; + } } #endif // NDEBUG - _regions.push_back(pt); + _regions.push_back(std::move(region)); _sorted = false; } @@ -111,9 +108,7 @@ MouseWatcherRegion *MouseWatcherBase:: find_region(const string &name) const { LightMutexHolder holder(_lock); - Regions::const_iterator ri; - for (ri = _regions.begin(); ri != _regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + for (MouseWatcherRegion *region : _regions) { if (region->get_name() == name) { return region; } @@ -162,10 +157,13 @@ is_sorted() const { /** * Returns the number of regions in the group. */ -int MouseWatcherBase:: +size_t MouseWatcherBase:: get_num_regions() const { LightMutexHolder holder(_lock); - + if (!_sorted) { + // Remove potential duplicates to get an accurate count. + ((MouseWatcherBase *)this)->do_sort_regions(); + } return _regions.size(); } @@ -175,9 +173,12 @@ get_num_regions() const { * removed the nth region before you called this method. */ MouseWatcherRegion *MouseWatcherBase:: -get_region(int n) const { +get_region(size_t n) const { LightMutexHolder holder(_lock); - if (n >= 0 && n < (int)_regions.size()) { + if (!_sorted) { + ((MouseWatcherBase *)this)->do_sort_regions(); + } + if (n < _regions.size()) { return _regions[n]; } return nullptr; @@ -198,9 +199,7 @@ void MouseWatcherBase:: write(ostream &out, int indent_level) const { LightMutexHolder holder(_lock); - Regions::const_iterator ri; - for (ri = _regions.begin(); ri != _regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + for (MouseWatcherRegion *region : _regions) { region->write(out, indent_level); } } @@ -345,13 +344,15 @@ do_update_regions() { nassertv(_lock.debug_is_locked()); if (_show_regions) { + // Make sure we have no duplicates. + do_sort_regions(); + _show_regions_root.node()->remove_all_children(); _vizzes.clear(); _vizzes.reserve(_regions.size()); - Regions::const_iterator ri; - for (ri = _regions.begin(); ri != _regions.end(); ++ri) { - _vizzes.push_back(make_viz_region(*ri)); + for (MouseWatcherRegion *region : _regions) { + _vizzes.push_back(make_viz_region(region)); } } } diff --git a/panda/src/tform/mouseWatcherBase.h b/panda/src/tform/mouseWatcherBase.h index f3b53c2ec2..f20bca0cc5 100644 --- a/panda/src/tform/mouseWatcherBase.h +++ b/panda/src/tform/mouseWatcherBase.h @@ -21,6 +21,7 @@ #include "pvector.h" #include "nodePath.h" #include "lightMutex.h" +#include "ordered_vector.h" /** * This represents a collection of MouseWatcherRegions that may be managed as @@ -34,7 +35,7 @@ public: virtual ~MouseWatcherBase(); PUBLISHED: - void add_region(MouseWatcherRegion *region); + void add_region(PT(MouseWatcherRegion) region); bool has_region(MouseWatcherRegion *region) const; bool remove_region(MouseWatcherRegion *region); MouseWatcherRegion *find_region(const std::string &name) const; @@ -44,8 +45,8 @@ PUBLISHED: bool is_sorted() const; MAKE_PROPERTY(sorted, is_sorted); - int get_num_regions() const; - MouseWatcherRegion *get_region(int n) const; + size_t get_num_regions() const; + MouseWatcherRegion *get_region(size_t n) const; MAKE_SEQ(get_regions, get_num_regions, get_region); MAKE_SEQ_PROPERTY(regions, get_num_regions, get_region); @@ -73,7 +74,7 @@ protected: #endif // NDEBUG protected: - typedef pvector< PT(MouseWatcherRegion) > Regions; + typedef ov_set< PT(MouseWatcherRegion) > Regions; Regions _regions; bool _sorted; From eab8b1c7a354e85e0b669e7f32d3ed795fbe2627 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 12 Jun 2018 13:42:14 +0200 Subject: [PATCH 009/360] tform: MouseWatcher sort should uniquify duplicates Also change the code to use range-for when appropriate, which improves code readability. --- panda/src/tform/mouseWatcher.cxx | 118 +++++++++++++-------------- panda/src/tform/mouseWatcherBase.I | 32 ++++++++ panda/src/tform/mouseWatcherBase.cxx | 21 +---- panda/src/tform/mouseWatcherBase.h | 6 +- tests/tform/test_mousewatcher.py | 18 ++++ 5 files changed, 112 insertions(+), 83 deletions(-) create mode 100644 panda/src/tform/mouseWatcherBase.I create mode 100644 tests/tform/test_mousewatcher.py diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index eac710d414..67dbee8591 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -491,11 +491,13 @@ output(ostream &out) const { LightMutexHolder holder(_lock); DataNode::output(out); - int count = _regions.size(); - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); - count += group->_regions.size(); + if (!_sorted) { + ((MouseWatcher *)this)->do_sort_regions(); + } + + size_t count = _regions.size(); + for (MouseWatcherGroup *group : _groups) { + count += group->get_num_regions(); } out << " (" << count << " regions)"; @@ -511,14 +513,10 @@ write(ostream &out, int indent_level) const { MouseWatcherBase::write(out, indent_level + 2); LightMutexHolder holder(_lock); - if (!_groups.empty()) { - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); - indent(out, indent_level + 2) - << "Subgroup:\n"; - group->write(out, indent_level + 4); - } + for (MouseWatcherGroup *group : _groups) { + indent(out, indent_level + 2) + << "Subgroup:\n"; + group->write(out, indent_level + 4); } } @@ -540,9 +538,12 @@ get_over_regions(MouseWatcher::Regions ®ions, const LPoint2 &pos) const { // Ensure the vector is empty before we begin. regions.clear(); - Regions::const_iterator ri; - for (ri = _regions.begin(); ri != _regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + // Make sure there are no duplicates in the regions vector. + if (!_sorted) { + ((MouseWatcher *)this)->do_sort_regions(); + } + + for (MouseWatcherRegion *region : _regions) { const LVecBase4 &frame = region->get_frame(); if (region->get_active() && @@ -554,11 +555,10 @@ get_over_regions(MouseWatcher::Regions ®ions, const LPoint2 &pos) const { } // Also check all of our sub-groups. - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); - for (ri = group->_regions.begin(); ri != group->_regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + for (MouseWatcherGroup *group : _groups) { + group->sort_regions(); + + for (MouseWatcherRegion *region : group->_regions) { const LVecBase4 &frame = region->get_frame(); if (region->get_active() && @@ -750,9 +750,7 @@ do_show_regions(const NodePath &render2d, const string &bin_name, _show_regions_bin_name = bin_name; _show_regions_draw_order = draw_order; - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); + for (MouseWatcherGroup *group : _groups) { group->show_regions(render2d, bin_name, draw_order); } } @@ -770,9 +768,7 @@ do_hide_regions() { _show_regions_bin_name = string(); _show_regions_draw_order = 0; - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); + for (MouseWatcherGroup *group : _groups) { group->hide_regions(); } } @@ -1026,15 +1022,17 @@ keystroke(int keycode) { param.set_modifier_buttons(_mods); param.set_mouse(_mouse); + // Make sure there are no duplicates in the regions vector. + if (!_sorted) { + ((MouseWatcher *)this)->do_sort_regions(); + } + // Keystrokes go to all those regions that want keyboard events, regardless // of which is the "preferred" region (that is, without respect to the mouse // position). However, we do set the outside flag according to whether the // given region is the preferred region or not. - Regions::const_iterator ri; - for (ri = _regions.begin(); ri != _regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); - + for (MouseWatcherRegion *region : _regions) { if (region->get_keyboard()) { param.set_outside(region != _preferred_region); region->keystroke(param); @@ -1043,12 +1041,10 @@ keystroke(int keycode) { } // Also check all of our sub-groups. - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); - for (ri = group->_regions.begin(); ri != group->_regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + for (MouseWatcherGroup *group : _groups) { + group->sort_regions(); + for (MouseWatcherRegion *region : group->_regions) { if (region->get_keyboard()) { param.set_outside(region != _preferred_region); region->keystroke(param); @@ -1072,13 +1068,15 @@ candidate(const wstring &candidate_string, size_t highlight_start, param.set_modifier_buttons(_mods); param.set_mouse(_mouse); + // Make sure there are no duplicates in the regions vector. + if (!_sorted) { + ((MouseWatcher *)this)->do_sort_regions(); + } + // Candidate strings go to all those regions that want keyboard events, // exactly like keystrokes, above. - Regions::const_iterator ri; - for (ri = _regions.begin(); ri != _regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); - + for (MouseWatcherRegion *region : _regions) { if (region->get_keyboard()) { param.set_outside(region != _preferred_region); region->candidate(param); @@ -1086,12 +1084,10 @@ candidate(const wstring &candidate_string, size_t highlight_start, } // Also check all of our sub-groups. - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); - for (ri = group->_regions.begin(); ri != group->_regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + for (MouseWatcherGroup *group : _groups) { + group->sort_regions(); + for (MouseWatcherRegion *region : group->_regions) { if (region->get_keyboard()) { param.set_outside(region != _preferred_region); region->candidate(param); @@ -1109,10 +1105,12 @@ void MouseWatcher:: global_keyboard_press(const MouseWatcherParameter ¶m) { nassertv(_lock.debug_is_locked()); - Regions::const_iterator ri; - for (ri = _regions.begin(); ri != _regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + // Make sure there are no duplicates in the regions vector. + if (!_sorted) { + ((MouseWatcher *)this)->do_sort_regions(); + } + for (MouseWatcherRegion *region : _regions) { if (region != _preferred_region && region->get_keyboard()) { region->press(param); consider_keyboard_suppress(region); @@ -1120,12 +1118,10 @@ global_keyboard_press(const MouseWatcherParameter ¶m) { } // Also check all of our sub-groups. - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); - for (ri = group->_regions.begin(); ri != group->_regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + for (MouseWatcherGroup *group : _groups) { + group->sort_regions(); + for (MouseWatcherRegion *region : group->_regions) { if (region != _preferred_region && region->get_keyboard()) { region->press(param); consider_keyboard_suppress(region); @@ -1142,22 +1138,22 @@ void MouseWatcher:: global_keyboard_release(const MouseWatcherParameter ¶m) { nassertv(_lock.debug_is_locked()); - Regions::const_iterator ri; - for (ri = _regions.begin(); ri != _regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + // Make sure there are no duplicates in the regions vector. + if (!_sorted) { + ((MouseWatcher *)this)->do_sort_regions(); + } + for (MouseWatcherRegion *region : _regions) { if (region != _preferred_region && region->get_keyboard()) { region->release(param); } } // Also check all of our sub-groups. - Groups::const_iterator gi; - for (gi = _groups.begin(); gi != _groups.end(); ++gi) { - MouseWatcherGroup *group = (*gi); - for (ri = group->_regions.begin(); ri != group->_regions.end(); ++ri) { - MouseWatcherRegion *region = (*ri); + for (MouseWatcherGroup *group : _groups) { + group->sort_regions(); + for (MouseWatcherRegion *region : group->_regions) { if (region != _preferred_region && region->get_keyboard()) { region->release(param); } diff --git a/panda/src/tform/mouseWatcherBase.I b/panda/src/tform/mouseWatcherBase.I new file mode 100644 index 0000000000..e5739d1de5 --- /dev/null +++ b/panda/src/tform/mouseWatcherBase.I @@ -0,0 +1,32 @@ +/** + * 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." + * + * @file mouseWatcherBase.I + * @author rdb + * @date 2018-06-12 + */ + +/** + * Sorts all the regions in this group into pointer order. + */ +INLINE void MouseWatcherBase:: +sort_regions() { + LightMutexHolder holder(_lock); + if (!_sorted) { + do_sort_regions(); + } +} + +/** + * Returns true if the group has already been sorted, false otherwise. + */ +INLINE bool MouseWatcherBase:: +is_sorted() const { + LightMutexHolder holder(_lock); + return _sorted; +} diff --git a/panda/src/tform/mouseWatcherBase.cxx b/panda/src/tform/mouseWatcherBase.cxx index 2a167e57c5..46c1ae9743 100644 --- a/panda/src/tform/mouseWatcherBase.cxx +++ b/panda/src/tform/mouseWatcherBase.cxx @@ -135,25 +135,6 @@ clear_regions() { #endif // NDEBUG } -/** - * Sorts all the regions in this group into pointer order. - */ -void MouseWatcherBase:: -sort_regions() { - LightMutexHolder holder(_lock); - do_sort_regions(); -} - -/** - * Returns true if the group has already been sorted, false otherwise. - */ -bool MouseWatcherBase:: -is_sorted() const { - LightMutexHolder holder(_lock); - - return _sorted; -} - /** * Returns the number of regions in the group. */ @@ -261,7 +242,7 @@ update_regions() { void MouseWatcherBase:: do_sort_regions() { if (!_sorted) { - sort(_regions.begin(), _regions.end()); + _regions.sort_unique(); _sorted = true; } } diff --git a/panda/src/tform/mouseWatcherBase.h b/panda/src/tform/mouseWatcherBase.h index f20bca0cc5..b7de361653 100644 --- a/panda/src/tform/mouseWatcherBase.h +++ b/panda/src/tform/mouseWatcherBase.h @@ -41,8 +41,8 @@ PUBLISHED: MouseWatcherRegion *find_region(const std::string &name) const; void clear_regions(); - void sort_regions(); - bool is_sorted() const; + INLINE void sort_regions(); + INLINE bool is_sorted() const; MAKE_PROPERTY(sorted, is_sorted); size_t get_num_regions() const; @@ -110,4 +110,6 @@ private: friend class BlobWatcher; }; +#include "mouseWatcherBase.I" + #endif diff --git a/tests/tform/test_mousewatcher.py b/tests/tform/test_mousewatcher.py new file mode 100644 index 0000000000..a4eccbd47b --- /dev/null +++ b/tests/tform/test_mousewatcher.py @@ -0,0 +1,18 @@ +from panda3d.core import MouseWatcher, MouseWatcherRegion + + +def test_mousewatcher_region_add(): + region1 = MouseWatcherRegion("1", 0, 1, 0, 1) + region2 = MouseWatcherRegion("2", 0, 1, 0, 1) + + mw = MouseWatcher() + assert len(mw.regions) == 0 + + mw.add_region(region1) + assert len(mw.regions) == 1 + + mw.add_region(region2) + assert len(mw.regions) == 2 + + mw.add_region(region1) + assert len(mw.regions) == 2 From 7e61891c09d2b1ae0f64e17e5582d2bafb2f202f Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 10 Jun 2018 17:41:51 -0600 Subject: [PATCH 010/360] general: Fix more DLL linkage and EXPCL_PANDA_ macros --- panda/src/gobj/shader.h | 2 +- panda/src/pgraph/cullBin.h | 2 +- panda/src/pgraphnodes/lodNode.h | 2 +- panda/src/pgraphnodes/lodNodeType.h | 4 ++-- panda/src/pgraphnodes/uvScrollNode.h | 2 +- panda/src/pnmimage/config_pnmimage.h | 10 +++++----- panda/src/pnmimage/ppmcmap.h | 12 ++++++------ panda/src/pnmimagetypes/pnmFileTypePfm.h | 2 +- panda/src/pstatclient/pStatClient.h | 2 +- panda/src/pstatclient/pStatTimer.h | 2 +- panda/src/putil/bamReader.cxx | 7 ------- panda/src/putil/bamReader.h | 2 +- panda/src/text/config_text.h | 4 ++-- 13 files changed, 23 insertions(+), 30 deletions(-) diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 98734dfe50..8e65c005e9 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -436,7 +436,7 @@ public: ShaderPtrType _type; }; - class ShaderCaps { + class EXPCL_PANDA_GOBJ ShaderCaps { public: void clear(); INLINE bool operator == (const ShaderCaps &other) const; diff --git a/panda/src/pgraph/cullBin.h b/panda/src/pgraph/cullBin.h index e3a2ccca55..7a104d1f3b 100644 --- a/panda/src/pgraph/cullBin.h +++ b/panda/src/pgraph/cullBin.h @@ -74,7 +74,7 @@ protected: GraphicsStateGuardianBase *_gsg; // Used in make_result_graph() and fill_result_graph(). - class ResultGraphBuilder { + class EXPCL_PANDA_PGRAPH ResultGraphBuilder { public: ResultGraphBuilder(PandaNode *root_node); void add_object(CullableObject *object); diff --git a/panda/src/pgraphnodes/lodNode.h b/panda/src/pgraphnodes/lodNode.h index c82e066ffc..b7b58dca85 100644 --- a/panda/src/pgraphnodes/lodNode.h +++ b/panda/src/pgraphnodes/lodNode.h @@ -161,7 +161,7 @@ protected: typedef pvector SwitchVector; private: - class EXPCL_PANDA_PGRAPH CData : public CycleData { + class EXPCL_PANDA_PGRAPHNODES CData : public CycleData { public: INLINE CData(); INLINE CData(const CData ©); diff --git a/panda/src/pgraphnodes/lodNodeType.h b/panda/src/pgraphnodes/lodNodeType.h index 507ade03cf..ec1dec820b 100644 --- a/panda/src/pgraphnodes/lodNodeType.h +++ b/panda/src/pgraphnodes/lodNodeType.h @@ -25,7 +25,7 @@ enum LODNodeType { END_PUBLISH -EXPCL_PANDA_PGRAPH std::ostream &operator << (std::ostream &out, LODNodeType lnt); -EXPCL_PANDA_PGRAPH std::istream &operator >> (std::istream &in, LODNodeType &cs); +EXPCL_PANDA_PGRAPHNODES std::ostream &operator << (std::ostream &out, LODNodeType lnt); +EXPCL_PANDA_PGRAPHNODES std::istream &operator >> (std::istream &in, LODNodeType &cs); #endif diff --git a/panda/src/pgraphnodes/uvScrollNode.h b/panda/src/pgraphnodes/uvScrollNode.h index ac4c29b643..51ab828130 100644 --- a/panda/src/pgraphnodes/uvScrollNode.h +++ b/panda/src/pgraphnodes/uvScrollNode.h @@ -23,7 +23,7 @@ /** * This node is placed at key points within the scene graph to animate uvs. */ -class EXPCL_PANDA_PGRAPH UvScrollNode : public PandaNode { +class EXPCL_PANDA_PGRAPHNODES UvScrollNode : public PandaNode { PUBLISHED: INLINE explicit UvScrollNode(const std::string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_stdfloat w_speed, PN_stdfloat r_speed); INLINE explicit UvScrollNode(const std::string &name); diff --git a/panda/src/pnmimage/config_pnmimage.h b/panda/src/pnmimage/config_pnmimage.h index 9ff40dd5a0..f5f6c029bb 100644 --- a/panda/src/pnmimage/config_pnmimage.h +++ b/panda/src/pnmimage/config_pnmimage.h @@ -21,11 +21,11 @@ NotifyCategoryDecl(pnmimage, EXPCL_PANDA_PNMIMAGE, EXPTP_PANDA_PNMIMAGE); -extern ConfigVariableBool pfm_force_littleendian; -extern ConfigVariableBool pfm_reverse_dimensions; -extern ConfigVariableBool pfm_resize_gaussian; -extern ConfigVariableBool pfm_resize_quick; -extern ConfigVariableDouble pfm_resize_radius; +extern EXPCL_PANDA_PNMIMAGE ConfigVariableBool pfm_force_littleendian; +extern EXPCL_PANDA_PNMIMAGE ConfigVariableBool pfm_reverse_dimensions; +extern EXPCL_PANDA_PNMIMAGE ConfigVariableBool pfm_resize_gaussian; +extern EXPCL_PANDA_PNMIMAGE ConfigVariableBool pfm_resize_quick; +extern EXPCL_PANDA_PNMIMAGE ConfigVariableDouble pfm_resize_radius; extern EXPCL_PANDA_PNMIMAGE void init_libpnmimage(); diff --git a/panda/src/pnmimage/ppmcmap.h b/panda/src/pnmimage/ppmcmap.h index f8b9966818..5466de04e7 100644 --- a/panda/src/pnmimage/ppmcmap.h +++ b/panda/src/pnmimage/ppmcmap.h @@ -26,7 +26,7 @@ struct colorhist_list_item EXPCL_PANDA_PNMIMAGE colorhist_vector ppm_computecolorhist( pixel** pixels, int cols, int rows, int maxcolors, int* colorsP ); /* Returns a colorhist *colorsP long (with space allocated for maxcolors. */ -void ppm_addtocolorhist ( colorhist_vector chv, int* colorsP, int maxcolors, pixel* colorP, int value, int position ); +EXPCL_PANDA_PNMIMAGE void ppm_addtocolorhist ( colorhist_vector chv, int* colorsP, int maxcolors, pixel* colorP, int value, int position ); EXPCL_PANDA_PNMIMAGE void ppm_freecolorhist( colorhist_vector chv ); @@ -35,19 +35,19 @@ EXPCL_PANDA_PNMIMAGE void ppm_freecolorhist( colorhist_vector chv ); typedef colorhist_list* colorhash_table; -colorhash_table ppm_computecolorhash ( pixel** pixels, int cols, int rows, int maxcolors, int* colorsP ); +EXPCL_PANDA_PNMIMAGE colorhash_table ppm_computecolorhash ( pixel** pixels, int cols, int rows, int maxcolors, int* colorsP ); EXPCL_PANDA_PNMIMAGE int ppm_lookupcolor( colorhash_table cht, pixel* colorP ); -colorhist_vector ppm_colorhashtocolorhist ( colorhash_table cht, int maxcolors ); +EXPCL_PANDA_PNMIMAGE colorhist_vector ppm_colorhashtocolorhist ( colorhash_table cht, int maxcolors ); EXPCL_PANDA_PNMIMAGE colorhash_table ppm_colorhisttocolorhash( colorhist_vector chv, int colors ); -int ppm_addtocolorhash ( colorhash_table cht, pixel* colorP, int value ); +EXPCL_PANDA_PNMIMAGE int ppm_addtocolorhash ( colorhash_table cht, pixel* colorP, int value ); /* Returns -1 on failure. */ -colorhash_table ppm_alloccolorhash ( void ); +EXPCL_PANDA_PNMIMAGE colorhash_table ppm_alloccolorhash ( void ); -void ppm_freecolorhash( colorhash_table cht ); +EXPCL_PANDA_PNMIMAGE void ppm_freecolorhash( colorhash_table cht ); #endif diff --git a/panda/src/pnmimagetypes/pnmFileTypePfm.h b/panda/src/pnmimagetypes/pnmFileTypePfm.h index aa41adb1df..ab18685084 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePfm.h +++ b/panda/src/pnmimagetypes/pnmFileTypePfm.h @@ -25,7 +25,7 @@ * For reading and writing PFM files using the basic PNMImage interface, as if * they were basic RGB files. */ -class EXPCL_PANDA_PNMIMAGE PNMFileTypePfm : public PNMFileType { +class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypePfm : public PNMFileType { public: PNMFileTypePfm(); diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index 8ee255613b..bdcdb4eb20 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -169,7 +169,7 @@ private: // This is where the meat of the Collector data is stored. (All the stuff // in PStatCollector and PStatCollectorDef is just fluff.) - class Collector { + class EXPCL_PANDA_PSTATCLIENT Collector { public: INLINE Collector(int parent_index, const std::string &name); INLINE int get_parent_index() const; diff --git a/panda/src/pstatclient/pStatTimer.h b/panda/src/pstatclient/pStatTimer.h index b7a32f27e2..4cfca5a7d2 100644 --- a/panda/src/pstatclient/pStatTimer.h +++ b/panda/src/pstatclient/pStatTimer.h @@ -27,7 +27,7 @@ class Thread; * and when the PStatTimer variable goes out of scope (for instance, at the * end of the function), it will automatically stop the Collector. */ -class EXPCL_PANDA_PSTATCLIENT PStatTimer { +class PStatTimer { public: #ifdef DO_PSTATS INLINE PStatTimer(PStatCollector &collector); diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index e6cc5683d6..a1b6641148 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -1544,10 +1544,3 @@ finalize() { } } } - -/** - * - */ -BamReader::AuxData:: -~AuxData() { -} diff --git a/panda/src/putil/bamReader.h b/panda/src/putil/bamReader.h index 84312ac4a6..69c901f0fa 100644 --- a/panda/src/putil/bamReader.h +++ b/panda/src/putil/bamReader.h @@ -228,7 +228,7 @@ public: class AuxData : public ReferenceCount { public: INLINE AuxData(); - virtual ~AuxData(); + virtual ~AuxData() = default; }; private: diff --git a/panda/src/text/config_text.h b/panda/src/text/config_text.h index 131b95809d..cf58c5c811 100644 --- a/panda/src/text/config_text.h +++ b/panda/src/text/config_text.h @@ -40,8 +40,8 @@ extern ConfigVariableBool text_small_caps; extern EXPCL_PANDA_TEXT ConfigVariableDouble text_small_caps_scale; extern ConfigVariableFilename text_default_font; extern EXPCL_PANDA_TEXT ConfigVariableDouble text_tab_width; -extern ConfigVariableInt text_push_properties_key; -extern ConfigVariableInt text_pop_properties_key; +extern EXPCL_PANDA_TEXT ConfigVariableInt text_push_properties_key; +extern EXPCL_PANDA_TEXT ConfigVariableInt text_pop_properties_key; extern ConfigVariableInt text_soft_hyphen_key; extern ConfigVariableInt text_soft_break_key; extern ConfigVariableInt text_embed_graphic_key; From e73c25d15e9b710d9bedb3d81fb14d0d2fababd7 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 10 Jun 2018 19:19:24 -0600 Subject: [PATCH 011/360] general: Break apart BUILDING_PANDAPHYSICS --- panda/src/pandabase/pandasymbols.h | 22 +++++++++++++++++++ panda/src/particlesystem/arcEmitter.h | 2 +- panda/src/particlesystem/baseParticle.h | 2 +- .../src/particlesystem/baseParticleEmitter.h | 2 +- .../src/particlesystem/baseParticleFactory.h | 2 +- .../src/particlesystem/baseParticleRenderer.h | 2 +- panda/src/particlesystem/boxEmitter.h | 2 +- .../colorInterpolationManager.h | 14 ++++++------ .../particlesystem/config_particlesystem.cxx | 4 ++-- .../particlesystem/config_particlesystem.h | 6 ++--- panda/src/particlesystem/discEmitter.h | 2 +- .../src/particlesystem/geomParticleRenderer.h | 2 +- panda/src/particlesystem/lineEmitter.h | 2 +- .../src/particlesystem/lineParticleRenderer.h | 2 +- panda/src/particlesystem/orientedParticle.h | 2 +- .../particlesystem/orientedParticleFactory.h | 2 +- panda/src/particlesystem/particleSystem.h | 2 +- .../particlesystem/particleSystemManager.h | 2 +- panda/src/particlesystem/pointEmitter.h | 2 +- panda/src/particlesystem/pointParticle.h | 2 +- .../src/particlesystem/pointParticleFactory.h | 2 +- .../particlesystem/pointParticleRenderer.h | 2 +- panda/src/particlesystem/rectangleEmitter.h | 2 +- panda/src/particlesystem/ringEmitter.h | 2 +- .../particlesystem/sparkleParticleRenderer.h | 2 +- .../src/particlesystem/sphereSurfaceEmitter.h | 2 +- .../src/particlesystem/sphereVolumeEmitter.h | 2 +- .../particlesystem/spriteParticleRenderer.h | 2 +- panda/src/particlesystem/tangentRingEmitter.h | 2 +- panda/src/particlesystem/zSpinParticle.h | 2 +- .../src/particlesystem/zSpinParticleFactory.h | 2 +- panda/src/physics/actorNode.h | 2 +- panda/src/physics/angularEulerIntegrator.h | 2 +- panda/src/physics/angularForce.h | 2 +- panda/src/physics/angularIntegrator.h | 2 +- panda/src/physics/angularVectorForce.h | 2 +- panda/src/physics/baseForce.h | 2 +- panda/src/physics/baseIntegrator.h | 2 +- panda/src/physics/config_physics.cxx | 4 ++-- panda/src/physics/config_physics.h | 6 ++--- panda/src/physics/forceNode.h | 2 +- panda/src/physics/linearControlForce.h | 2 +- panda/src/physics/linearCylinderVortexForce.h | 2 +- panda/src/physics/linearDistanceForce.h | 2 +- panda/src/physics/linearEulerIntegrator.h | 2 +- panda/src/physics/linearForce.h | 2 +- panda/src/physics/linearFrictionForce.h | 2 +- panda/src/physics/linearIntegrator.h | 2 +- panda/src/physics/linearJitterForce.h | 2 +- panda/src/physics/linearNoiseForce.h | 2 +- panda/src/physics/linearRandomForce.h | 2 +- panda/src/physics/linearSinkForce.h | 2 +- panda/src/physics/linearSourceForce.h | 2 +- panda/src/physics/linearUserDefinedForce.h | 2 +- panda/src/physics/linearVectorForce.h | 2 +- panda/src/physics/physical.h | 2 +- panda/src/physics/physicalNode.h | 2 +- panda/src/physics/physicsCollisionHandler.h | 2 +- panda/src/physics/physicsManager.h | 2 +- panda/src/physics/physicsObject.h | 2 +- panda/src/physics/physicsObjectCollection.h | 2 +- 61 files changed, 94 insertions(+), 72 deletions(-) diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index a1b17ffb86..d0f7fd19f0 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -111,6 +111,12 @@ #define BUILDING_PANDA_EXPRESS #endif +/* BUILDING_PANDAPHYSICS for these: */ +#ifdef BUILDING_PANDAPHYSICS + #define BUILDING_PANDA_PARTICLESYSTEM + #define BUILDING_PANDA_PHYSICS +#endif + #ifdef BUILDING_LIBPANDA #define EXPCL_LIBPANDA EXPORT_CLASS #define EXPTP_LIBPANDA EXPORT_TEMPL @@ -287,6 +293,14 @@ #define EXPTP_PANDA_PARAMETRICS IMPORT_TEMPL #endif +#ifdef BUILDING_PANDA_PARTICLESYSTEM + #define EXPCL_PANDA_PARTICLESYSTEM EXPORT_CLASS + #define EXPTP_PANDA_PARTICLESYSTEM EXPORT_TEMPL +#else + #define EXPCL_PANDA_PARTICLESYSTEM IMPORT_CLASS + #define EXPTP_PANDA_PARTICLESYSTEM IMPORT_TEMPL +#endif + #ifdef BUILDING_PANDA_PGRAPH #define EXPCL_PANDA_PGRAPH EXPORT_CLASS #define EXPTP_PANDA_PGRAPH EXPORT_TEMPL @@ -311,6 +325,14 @@ #define EXPTP_PANDA_PGUI IMPORT_TEMPL #endif +#ifdef BUILDING_PANDA_PHYSICS + #define EXPCL_PANDA_PHYSICS EXPORT_CLASS + #define EXPTP_PANDA_PHYSICS EXPORT_TEMPL +#else + #define EXPCL_PANDA_PHYSICS IMPORT_CLASS + #define EXPTP_PANDA_PHYSICS IMPORT_TEMPL +#endif + #ifdef BUILDING_PANDA_PIPELINE #define EXPCL_PANDA_PIPELINE EXPORT_CLASS #define EXPTP_PANDA_PIPELINE EXPORT_TEMPL diff --git a/panda/src/particlesystem/arcEmitter.h b/panda/src/particlesystem/arcEmitter.h index ce95891b3e..3d8dc3988e 100644 --- a/panda/src/particlesystem/arcEmitter.h +++ b/panda/src/particlesystem/arcEmitter.h @@ -19,7 +19,7 @@ /** * Describes a planar ring region in which particles are generated. */ -class EXPCL_PANDAPHYSICS ArcEmitter : public RingEmitter { +class EXPCL_PANDA_PARTICLESYSTEM ArcEmitter : public RingEmitter { PUBLISHED: ArcEmitter(); ArcEmitter(const ArcEmitter ©); diff --git a/panda/src/particlesystem/baseParticle.h b/panda/src/particlesystem/baseParticle.h index edc14ca0f1..487f9ba476 100644 --- a/panda/src/particlesystem/baseParticle.h +++ b/panda/src/particlesystem/baseParticle.h @@ -20,7 +20,7 @@ /** * An individual, physically-modelable particle abstract base class. */ -class EXPCL_PANDAPHYSICS BaseParticle : public PhysicsObject { +class EXPCL_PANDA_PARTICLESYSTEM BaseParticle : public PhysicsObject { public: // local methods INLINE void set_age(PN_stdfloat age); diff --git a/panda/src/particlesystem/baseParticleEmitter.h b/panda/src/particlesystem/baseParticleEmitter.h index aad4d1ad17..f1c6665679 100644 --- a/panda/src/particlesystem/baseParticleEmitter.h +++ b/panda/src/particlesystem/baseParticleEmitter.h @@ -22,7 +22,7 @@ #include "mathNumbers.h" -class EXPCL_PANDAPHYSICS BaseParticleEmitter : public ReferenceCount { +class EXPCL_PANDA_PARTICLESYSTEM BaseParticleEmitter : public ReferenceCount { PUBLISHED: enum emissionType { ET_EXPLICIT, // all particles are emitted in parallel along the same vector diff --git a/panda/src/particlesystem/baseParticleFactory.h b/panda/src/particlesystem/baseParticleFactory.h index 47073862f2..0271ef91eb 100644 --- a/panda/src/particlesystem/baseParticleFactory.h +++ b/panda/src/particlesystem/baseParticleFactory.h @@ -25,7 +25,7 @@ /** * Pure Virtual base class for creating particles */ -class EXPCL_PANDAPHYSICS BaseParticleFactory : public ReferenceCount { +class EXPCL_PANDA_PARTICLESYSTEM BaseParticleFactory : public ReferenceCount { PUBLISHED: virtual ~BaseParticleFactory(); diff --git a/panda/src/particlesystem/baseParticleRenderer.h b/panda/src/particlesystem/baseParticleRenderer.h index bab215567a..8dd8a0a081 100644 --- a/panda/src/particlesystem/baseParticleRenderer.h +++ b/panda/src/particlesystem/baseParticleRenderer.h @@ -29,7 +29,7 @@ /** * Pure virtual particle renderer base class */ -class EXPCL_PANDAPHYSICS BaseParticleRenderer : public ReferenceCount { +class EXPCL_PANDA_PARTICLESYSTEM BaseParticleRenderer : public ReferenceCount { PUBLISHED: enum ParticleRendererAlphaMode { PR_ALPHA_NONE, diff --git a/panda/src/particlesystem/boxEmitter.h b/panda/src/particlesystem/boxEmitter.h index 830e7827af..9899a04978 100644 --- a/panda/src/particlesystem/boxEmitter.h +++ b/panda/src/particlesystem/boxEmitter.h @@ -19,7 +19,7 @@ /** * Describes a voluminous box region in which particles are generated. */ -class EXPCL_PANDAPHYSICS BoxEmitter : public BaseParticleEmitter { +class EXPCL_PANDA_PARTICLESYSTEM BoxEmitter : public BaseParticleEmitter { PUBLISHED: BoxEmitter(); BoxEmitter(const BoxEmitter ©); diff --git a/panda/src/particlesystem/colorInterpolationManager.h b/panda/src/particlesystem/colorInterpolationManager.h index 917694bee7..441ec4de7a 100644 --- a/panda/src/particlesystem/colorInterpolationManager.h +++ b/panda/src/particlesystem/colorInterpolationManager.h @@ -24,7 +24,7 @@ * virtual interpolate() function. */ -class EXPCL_PANDAPHYSICS ColorInterpolationFunction : public TypedReferenceCount { +class EXPCL_PANDA_PARTICLESYSTEM ColorInterpolationFunction : public TypedReferenceCount { PUBLISHED: // virtual string get_type(); @@ -57,7 +57,7 @@ private: * Defines a constant color over the lifetime of the segment. */ -class EXPCL_PANDAPHYSICS ColorInterpolationFunctionConstant : public ColorInterpolationFunction { +class EXPCL_PANDA_PARTICLESYSTEM ColorInterpolationFunctionConstant : public ColorInterpolationFunction { PUBLISHED: INLINE LColor get_color_a() const; @@ -96,7 +96,7 @@ private: * Defines a linear interpolation over the lifetime of the segment. */ -class EXPCL_PANDAPHYSICS ColorInterpolationFunctionLinear : public ColorInterpolationFunctionConstant { +class EXPCL_PANDA_PARTICLESYSTEM ColorInterpolationFunctionLinear : public ColorInterpolationFunctionConstant { PUBLISHED: INLINE LColor get_color_b() const; @@ -138,7 +138,7 @@ private: * repeats until the end of the segment. */ -class EXPCL_PANDAPHYSICS ColorInterpolationFunctionStepwave : public ColorInterpolationFunctionLinear { +class EXPCL_PANDA_PARTICLESYSTEM ColorInterpolationFunctionStepwave : public ColorInterpolationFunctionLinear { PUBLISHED: INLINE PN_stdfloat get_width_a() const; INLINE PN_stdfloat get_width_b() const; @@ -183,7 +183,7 @@ private: * result in a higher frequency cycle. */ -class EXPCL_PANDAPHYSICS ColorInterpolationFunctionSinusoid : public ColorInterpolationFunctionLinear { +class EXPCL_PANDA_PARTICLESYSTEM ColorInterpolationFunctionSinusoid : public ColorInterpolationFunctionLinear { PUBLISHED: INLINE PN_stdfloat get_period() const; @@ -224,7 +224,7 @@ private: * segment also has a function associated with it. */ -class EXPCL_PANDAPHYSICS ColorInterpolationSegment : public ReferenceCount { +class EXPCL_PANDA_PARTICLESYSTEM ColorInterpolationSegment : public ReferenceCount { public: ColorInterpolationSegment(ColorInterpolationFunction* function, const PN_stdfloat &time_begin, const PN_stdfloat &time_end, const bool is_modulated, const int id); @@ -266,7 +266,7 @@ protected: * Access to these segments is provided but not necessary general use. */ -class EXPCL_PANDAPHYSICS ColorInterpolationManager : public ReferenceCount { +class EXPCL_PANDA_PARTICLESYSTEM ColorInterpolationManager : public ReferenceCount { PUBLISHED: ColorInterpolationManager(); ColorInterpolationManager(const LColor &c); diff --git a/panda/src/particlesystem/config_particlesystem.cxx b/panda/src/particlesystem/config_particlesystem.cxx index 0eba6c33f1..61f1224ea4 100644 --- a/panda/src/particlesystem/config_particlesystem.cxx +++ b/panda/src/particlesystem/config_particlesystem.cxx @@ -16,8 +16,8 @@ #include "geomParticleRenderer.h" #include "geomNode.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAPHYSICS) - #error Buildsystem error: BUILDING_PANDAPHYSICS not defined +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PARTICLESYSTEM) + #error Buildsystem error: BUILDING_PANDA_PARTICLESYSTEM not defined #endif ConfigureDef(config_particlesystem); diff --git a/panda/src/particlesystem/config_particlesystem.h b/panda/src/particlesystem/config_particlesystem.h index 16382b274c..56beffeaf0 100644 --- a/panda/src/particlesystem/config_particlesystem.h +++ b/panda/src/particlesystem/config_particlesystem.h @@ -18,10 +18,10 @@ #include "notifyCategoryProxy.h" #include "dconfig.h" -ConfigureDecl(config_particlesystem, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); -NotifyCategoryDecl(particlesystem, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); +ConfigureDecl(config_particlesystem, EXPCL_PANDA_PARTICLESYSTEM, EXPTP_PANDA_PARTICLESYSTEM); +NotifyCategoryDecl(particlesystem, EXPCL_PANDA_PARTICLESYSTEM, EXPTP_PANDA_PARTICLESYSTEM); -extern EXPCL_PANDAPHYSICS void init_libparticlesystem(); +extern EXPCL_PANDA_PARTICLESYSTEM void init_libparticlesystem(); #ifndef NDEBUG //[ // Non-release build: diff --git a/panda/src/particlesystem/discEmitter.h b/panda/src/particlesystem/discEmitter.h index 0ce8bf9d70..fcfcf9b94a 100644 --- a/panda/src/particlesystem/discEmitter.h +++ b/panda/src/particlesystem/discEmitter.h @@ -19,7 +19,7 @@ /** * Describes a planar disc region from which particles are generated */ -class EXPCL_PANDAPHYSICS DiscEmitter : public BaseParticleEmitter { +class EXPCL_PANDA_PARTICLESYSTEM DiscEmitter : public BaseParticleEmitter { PUBLISHED: DiscEmitter(); DiscEmitter(const DiscEmitter ©); diff --git a/panda/src/particlesystem/geomParticleRenderer.h b/panda/src/particlesystem/geomParticleRenderer.h index f80322a5bd..a9fd906dd4 100644 --- a/panda/src/particlesystem/geomParticleRenderer.h +++ b/panda/src/particlesystem/geomParticleRenderer.h @@ -23,7 +23,7 @@ #include "pvector.h" #include "pStatCollector.h" -class EXPCL_PANDAPHYSICS GeomParticleRenderer : public BaseParticleRenderer { +class EXPCL_PANDA_PARTICLESYSTEM GeomParticleRenderer : public BaseParticleRenderer { PUBLISHED: explicit GeomParticleRenderer(ParticleRendererAlphaMode am = PR_ALPHA_NONE, PandaNode *geom_node = nullptr); diff --git a/panda/src/particlesystem/lineEmitter.h b/panda/src/particlesystem/lineEmitter.h index 0b5a832563..80422654fb 100644 --- a/panda/src/particlesystem/lineEmitter.h +++ b/panda/src/particlesystem/lineEmitter.h @@ -19,7 +19,7 @@ /** * Describes a linear region in which particles are generated. */ -class EXPCL_PANDAPHYSICS LineEmitter : public BaseParticleEmitter { +class EXPCL_PANDA_PARTICLESYSTEM LineEmitter : public BaseParticleEmitter { PUBLISHED: LineEmitter(); LineEmitter(const LineEmitter ©); diff --git a/panda/src/particlesystem/lineParticleRenderer.h b/panda/src/particlesystem/lineParticleRenderer.h index 86dcc5973c..ecec62fc8e 100644 --- a/panda/src/particlesystem/lineParticleRenderer.h +++ b/panda/src/particlesystem/lineParticleRenderer.h @@ -28,7 +28,7 @@ * sparks, etc. */ -class EXPCL_PANDAPHYSICS LineParticleRenderer : public BaseParticleRenderer { +class EXPCL_PANDA_PARTICLESYSTEM LineParticleRenderer : public BaseParticleRenderer { PUBLISHED: LineParticleRenderer(); LineParticleRenderer(const LineParticleRenderer& copy); diff --git a/panda/src/particlesystem/orientedParticle.h b/panda/src/particlesystem/orientedParticle.h index 0f021fed8d..740b8e03d6 100644 --- a/panda/src/particlesystem/orientedParticle.h +++ b/panda/src/particlesystem/orientedParticle.h @@ -20,7 +20,7 @@ * Describes a particle that has angular characteristics (velocity, * orientation). */ -class EXPCL_PANDAPHYSICS OrientedParticle : public BaseParticle { +class EXPCL_PANDA_PARTICLESYSTEM OrientedParticle : public BaseParticle { public: OrientedParticle(int lifespan = 0, bool alive = false); OrientedParticle(const OrientedParticle ©); diff --git a/panda/src/particlesystem/orientedParticleFactory.h b/panda/src/particlesystem/orientedParticleFactory.h index a38d5e2ec0..d33f18009b 100644 --- a/panda/src/particlesystem/orientedParticleFactory.h +++ b/panda/src/particlesystem/orientedParticleFactory.h @@ -21,7 +21,7 @@ /** * Creates particles that are affected by angular forces. */ -class EXPCL_PANDAPHYSICS OrientedParticleFactory : public BaseParticleFactory { +class EXPCL_PANDA_PARTICLESYSTEM OrientedParticleFactory : public BaseParticleFactory { PUBLISHED: OrientedParticleFactory(); OrientedParticleFactory(const OrientedParticleFactory ©); diff --git a/panda/src/particlesystem/particleSystem.h b/panda/src/particlesystem/particleSystem.h index 9c453b1b50..a7b4af64ef 100644 --- a/panda/src/particlesystem/particleSystem.h +++ b/panda/src/particlesystem/particleSystem.h @@ -37,7 +37,7 @@ class ParticleSystemManager; /** * Contains and manages a particle system. */ -class EXPCL_PANDAPHYSICS ParticleSystem : public Physical { +class EXPCL_PANDA_PARTICLESYSTEM ParticleSystem : public Physical { PUBLISHED: // constructordestructor diff --git a/panda/src/particlesystem/particleSystemManager.h b/panda/src/particlesystem/particleSystemManager.h index b083076e8a..5bfbe09ec7 100644 --- a/panda/src/particlesystem/particleSystemManager.h +++ b/panda/src/particlesystem/particleSystemManager.h @@ -24,7 +24,7 @@ * one doesn't have to be updated and rendered every frame See Also : * particleSystemManager.cxx */ -class EXPCL_PANDAPHYSICS ParticleSystemManager { +class EXPCL_PANDA_PARTICLESYSTEM ParticleSystemManager { PUBLISHED: explicit ParticleSystemManager(int every_nth_frame = 1); virtual ~ParticleSystemManager(); diff --git a/panda/src/particlesystem/pointEmitter.h b/panda/src/particlesystem/pointEmitter.h index fd59ea1aea..90af2a899a 100644 --- a/panda/src/particlesystem/pointEmitter.h +++ b/panda/src/particlesystem/pointEmitter.h @@ -19,7 +19,7 @@ /** * Describes a planar ring region in which particles are generated. */ -class EXPCL_PANDAPHYSICS PointEmitter : public BaseParticleEmitter { +class EXPCL_PANDA_PARTICLESYSTEM PointEmitter : public BaseParticleEmitter { PUBLISHED: PointEmitter(); PointEmitter(const PointEmitter ©); diff --git a/panda/src/particlesystem/pointParticle.h b/panda/src/particlesystem/pointParticle.h index 44e067edaf..bf7b70a98b 100644 --- a/panda/src/particlesystem/pointParticle.h +++ b/panda/src/particlesystem/pointParticle.h @@ -20,7 +20,7 @@ * Describes a particle that requires representation by a point (pixel, * sparkle, billboard) */ -class EXPCL_PANDAPHYSICS PointParticle : public BaseParticle { +class EXPCL_PANDA_PARTICLESYSTEM PointParticle : public BaseParticle { public: PointParticle(PN_stdfloat lifespan = 0.0f, bool alive = false); PointParticle(const PointParticle ©); diff --git a/panda/src/particlesystem/pointParticleFactory.h b/panda/src/particlesystem/pointParticleFactory.h index acaccf835e..3c2df92ff7 100644 --- a/panda/src/particlesystem/pointParticleFactory.h +++ b/panda/src/particlesystem/pointParticleFactory.h @@ -20,7 +20,7 @@ * Creates point particles to user specs */ -class EXPCL_PANDAPHYSICS PointParticleFactory : public BaseParticleFactory { +class EXPCL_PANDA_PARTICLESYSTEM PointParticleFactory : public BaseParticleFactory { PUBLISHED: PointParticleFactory(); PointParticleFactory(const PointParticleFactory ©); diff --git a/panda/src/particlesystem/pointParticleRenderer.h b/panda/src/particlesystem/pointParticleRenderer.h index 114cbb0e93..ff2f7b3f98 100644 --- a/panda/src/particlesystem/pointParticleRenderer.h +++ b/panda/src/particlesystem/pointParticleRenderer.h @@ -30,7 +30,7 @@ * BillboardParticleRenderer for that. */ -class EXPCL_PANDAPHYSICS PointParticleRenderer : public BaseParticleRenderer { +class EXPCL_PANDA_PARTICLESYSTEM PointParticleRenderer : public BaseParticleRenderer { PUBLISHED: enum PointParticleBlendType { PP_ONE_COLOR, diff --git a/panda/src/particlesystem/rectangleEmitter.h b/panda/src/particlesystem/rectangleEmitter.h index 7805d3b619..d425c70618 100644 --- a/panda/src/particlesystem/rectangleEmitter.h +++ b/panda/src/particlesystem/rectangleEmitter.h @@ -19,7 +19,7 @@ /** * Describes a planar square region in which particles are generated. */ -class EXPCL_PANDAPHYSICS RectangleEmitter : public BaseParticleEmitter { +class EXPCL_PANDA_PARTICLESYSTEM RectangleEmitter : public BaseParticleEmitter { PUBLISHED: RectangleEmitter(); RectangleEmitter(const RectangleEmitter ©); diff --git a/panda/src/particlesystem/ringEmitter.h b/panda/src/particlesystem/ringEmitter.h index 7bc9516148..cdd3d484f7 100644 --- a/panda/src/particlesystem/ringEmitter.h +++ b/panda/src/particlesystem/ringEmitter.h @@ -19,7 +19,7 @@ /** * Describes a planar ring region in which particles are generated. */ -class EXPCL_PANDAPHYSICS RingEmitter : public BaseParticleEmitter { +class EXPCL_PANDA_PARTICLESYSTEM RingEmitter : public BaseParticleEmitter { PUBLISHED: RingEmitter(); RingEmitter(const RingEmitter ©); diff --git a/panda/src/particlesystem/sparkleParticleRenderer.h b/panda/src/particlesystem/sparkleParticleRenderer.h index 040d4a5315..6b81e07cc5 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.h +++ b/panda/src/particlesystem/sparkleParticleRenderer.h @@ -31,7 +31,7 @@ enum SparkleParticleLifeScale { /** * pretty sparkly things. */ -class EXPCL_PANDAPHYSICS SparkleParticleRenderer : public BaseParticleRenderer { +class EXPCL_PANDA_PARTICLESYSTEM SparkleParticleRenderer : public BaseParticleRenderer { PUBLISHED: enum SparkleParticleLifeScale { SP_NO_SCALE, diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.h b/panda/src/particlesystem/sphereSurfaceEmitter.h index e5f9cebaae..f2ee42488c 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.h +++ b/panda/src/particlesystem/sphereSurfaceEmitter.h @@ -19,7 +19,7 @@ /** * Describes a curved space in which particles are generated. */ -class EXPCL_PANDAPHYSICS SphereSurfaceEmitter : public BaseParticleEmitter { +class EXPCL_PANDA_PARTICLESYSTEM SphereSurfaceEmitter : public BaseParticleEmitter { PUBLISHED: SphereSurfaceEmitter(); SphereSurfaceEmitter(const SphereSurfaceEmitter ©); diff --git a/panda/src/particlesystem/sphereVolumeEmitter.h b/panda/src/particlesystem/sphereVolumeEmitter.h index 14981b1b50..9907bbd3cf 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.h +++ b/panda/src/particlesystem/sphereVolumeEmitter.h @@ -19,7 +19,7 @@ /** * Describes a voluminous spherical region in which particles are generated. */ -class EXPCL_PANDAPHYSICS SphereVolumeEmitter : public BaseParticleEmitter { +class EXPCL_PANDA_PARTICLESYSTEM SphereVolumeEmitter : public BaseParticleEmitter { PUBLISHED: SphereVolumeEmitter(); SphereVolumeEmitter(const SphereVolumeEmitter ©); diff --git a/panda/src/particlesystem/spriteParticleRenderer.h b/panda/src/particlesystem/spriteParticleRenderer.h index c26f0ee7c1..0de03533d6 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.h +++ b/panda/src/particlesystem/spriteParticleRenderer.h @@ -151,7 +151,7 @@ private: /** * Renders a particle system with high-speed nasty trick sprites. */ -class EXPCL_PANDAPHYSICS SpriteParticleRenderer : public BaseParticleRenderer { +class EXPCL_PANDA_PARTICLESYSTEM SpriteParticleRenderer : public BaseParticleRenderer { PUBLISHED: explicit SpriteParticleRenderer(Texture *tex = nullptr); SpriteParticleRenderer(const SpriteParticleRenderer ©); diff --git a/panda/src/particlesystem/tangentRingEmitter.h b/panda/src/particlesystem/tangentRingEmitter.h index 7100b7ee80..51bd8112b3 100644 --- a/panda/src/particlesystem/tangentRingEmitter.h +++ b/panda/src/particlesystem/tangentRingEmitter.h @@ -20,7 +20,7 @@ * Describes a planar ring region in which tangent particles are generated, * and particles fly off tangential to the ring. */ -class EXPCL_PANDAPHYSICS TangentRingEmitter : public BaseParticleEmitter { +class EXPCL_PANDA_PARTICLESYSTEM TangentRingEmitter : public BaseParticleEmitter { PUBLISHED: TangentRingEmitter(); TangentRingEmitter(const TangentRingEmitter ©); diff --git a/panda/src/particlesystem/zSpinParticle.h b/panda/src/particlesystem/zSpinParticle.h index ad867d7269..da5d39197b 100644 --- a/panda/src/particlesystem/zSpinParticle.h +++ b/panda/src/particlesystem/zSpinParticle.h @@ -22,7 +22,7 @@ * your sprites to spin without having them be full-blown oriented (i.e. * angry quat math), use this. */ -class EXPCL_PANDAPHYSICS ZSpinParticle : public BaseParticle { +class EXPCL_PANDA_PARTICLESYSTEM ZSpinParticle : public BaseParticle { public: ZSpinParticle(); ZSpinParticle(const ZSpinParticle ©); diff --git a/panda/src/particlesystem/zSpinParticleFactory.h b/panda/src/particlesystem/zSpinParticleFactory.h index 2ef6819069..491b1bf65f 100644 --- a/panda/src/particlesystem/zSpinParticleFactory.h +++ b/panda/src/particlesystem/zSpinParticleFactory.h @@ -19,7 +19,7 @@ /** * */ -class EXPCL_PANDAPHYSICS ZSpinParticleFactory : public BaseParticleFactory { +class EXPCL_PANDA_PARTICLESYSTEM ZSpinParticleFactory : public BaseParticleFactory { PUBLISHED: ZSpinParticleFactory(); ZSpinParticleFactory(const ZSpinParticleFactory ©); diff --git a/panda/src/physics/actorNode.h b/panda/src/physics/actorNode.h index 17e704a3ce..719b6b16f9 100644 --- a/panda/src/physics/actorNode.h +++ b/panda/src/physics/actorNode.h @@ -23,7 +23,7 @@ * will be reflected as transforms. This relation goes both ways; changes in * the transform will update the object's position (shoves). */ -class EXPCL_PANDAPHYSICS ActorNode : public PhysicalNode { +class EXPCL_PANDA_PHYSICS ActorNode : public PhysicalNode { PUBLISHED: explicit ActorNode(const std::string &name = ""); ActorNode(const ActorNode ©); diff --git a/panda/src/physics/angularEulerIntegrator.h b/panda/src/physics/angularEulerIntegrator.h index aa9cc71a78..1710d0841f 100644 --- a/panda/src/physics/angularEulerIntegrator.h +++ b/panda/src/physics/angularEulerIntegrator.h @@ -20,7 +20,7 @@ * Performs Euler integration on a vector of physically modelable objects * given a quantum dt. */ -class EXPCL_PANDAPHYSICS AngularEulerIntegrator : public AngularIntegrator { +class EXPCL_PANDA_PHYSICS AngularEulerIntegrator : public AngularIntegrator { PUBLISHED: AngularEulerIntegrator(); virtual ~AngularEulerIntegrator(); diff --git a/panda/src/physics/angularForce.h b/panda/src/physics/angularForce.h index 85d6b09a1a..e090095295 100644 --- a/panda/src/physics/angularForce.h +++ b/panda/src/physics/angularForce.h @@ -19,7 +19,7 @@ /** * pure virtual parent of all quat-based forces. */ -class EXPCL_PANDAPHYSICS AngularForce : public BaseForce { +class EXPCL_PANDA_PHYSICS AngularForce : public BaseForce { PUBLISHED: virtual ~AngularForce(); diff --git a/panda/src/physics/angularIntegrator.h b/panda/src/physics/angularIntegrator.h index 0accd60014..43f65c9581 100644 --- a/panda/src/physics/angularIntegrator.h +++ b/panda/src/physics/angularIntegrator.h @@ -22,7 +22,7 @@ * Pure virtual base class for physical modeling. Takes physically modelable * objects and applies forces to them. */ -class EXPCL_PANDAPHYSICS AngularIntegrator : public BaseIntegrator { +class EXPCL_PANDA_PHYSICS AngularIntegrator : public BaseIntegrator { PUBLISHED: virtual ~AngularIntegrator(); public: diff --git a/panda/src/physics/angularVectorForce.h b/panda/src/physics/angularVectorForce.h index 3560f67db0..2c45f5d43c 100644 --- a/panda/src/physics/angularVectorForce.h +++ b/panda/src/physics/angularVectorForce.h @@ -20,7 +20,7 @@ * a simple directed torque force, the angular equivalent of simple vector * force. */ -class EXPCL_PANDAPHYSICS AngularVectorForce : public AngularForce { +class EXPCL_PANDA_PHYSICS AngularVectorForce : public AngularForce { PUBLISHED: explicit AngularVectorForce(const LRotation& quat); explicit AngularVectorForce(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); diff --git a/panda/src/physics/baseForce.h b/panda/src/physics/baseForce.h index 9d046596a3..ffe8f58295 100644 --- a/panda/src/physics/baseForce.h +++ b/panda/src/physics/baseForce.h @@ -26,7 +26,7 @@ class ForceNode; /** * pure virtual base class for all forces that could POSSIBLY exist. */ -class EXPCL_PANDAPHYSICS BaseForce : public TypedReferenceCount { +class EXPCL_PANDA_PHYSICS BaseForce : public TypedReferenceCount { PUBLISHED: virtual ~BaseForce(); diff --git a/panda/src/physics/baseIntegrator.h b/panda/src/physics/baseIntegrator.h index 528f882021..5921b6e019 100644 --- a/panda/src/physics/baseIntegrator.h +++ b/panda/src/physics/baseIntegrator.h @@ -31,7 +31,7 @@ class Physical; * pure virtual integrator class that holds cached matrix information that * really should be common to any possible child implementation. */ -class EXPCL_PANDAPHYSICS BaseIntegrator : public ReferenceCount { +class EXPCL_PANDA_PHYSICS BaseIntegrator : public ReferenceCount { public: typedef epvector MatrixVector; typedef pvector LinearForceVector; diff --git a/panda/src/physics/config_physics.cxx b/panda/src/physics/config_physics.cxx index 5ce5c905f0..b4ad867f66 100644 --- a/panda/src/physics/config_physics.cxx +++ b/panda/src/physics/config_physics.cxx @@ -26,8 +26,8 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAPHYSICS) - #error Buildsystem error: BUILDING_PANDAPHYSICS not defined +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PHYSICS) + #error Buildsystem error: BUILDING_PANDA_PHYSICS not defined #endif ConfigureDef(config_physics); diff --git a/panda/src/physics/config_physics.h b/panda/src/physics/config_physics.h index cfbbe5146b..1c1b768e83 100644 --- a/panda/src/physics/config_physics.h +++ b/panda/src/physics/config_physics.h @@ -18,10 +18,10 @@ #include "notifyCategoryProxy.h" #include "dconfig.h" -ConfigureDecl(config_physics, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); -NotifyCategoryDecl(physics, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); +ConfigureDecl(config_physics, EXPCL_PANDA_PHYSICS, EXPTP_PANDA_PHYSICS); +NotifyCategoryDecl(physics, EXPCL_PANDA_PHYSICS, EXPTP_PANDA_PHYSICS); -extern EXPCL_PANDAPHYSICS void init_libphysics(); +extern EXPCL_PANDA_PHYSICS void init_libphysics(); // These macros get stripped out in a non-debug build (like asserts). Use them // like cout but with paranthesis aroud the cout input. e.g. foo_debug("The diff --git a/panda/src/physics/forceNode.h b/panda/src/physics/forceNode.h index 851b54259b..0f7758199d 100644 --- a/panda/src/physics/forceNode.h +++ b/panda/src/physics/forceNode.h @@ -24,7 +24,7 @@ * coordinate systems. An example of this would be simulating gravity in a * rotating space station. or something. */ -class EXPCL_PANDAPHYSICS ForceNode : public PandaNode { +class EXPCL_PANDA_PHYSICS ForceNode : public PandaNode { PUBLISHED: explicit ForceNode(const std::string &name); INLINE void clear(); diff --git a/panda/src/physics/linearControlForce.h b/panda/src/physics/linearControlForce.h index e769abbaa8..30c255b769 100644 --- a/panda/src/physics/linearControlForce.h +++ b/panda/src/physics/linearControlForce.h @@ -22,7 +22,7 @@ * not make sense for a physics simulation, but it's very handy for a game. * I.e. this is the force applied by user on the selected object. */ -class EXPCL_PANDAPHYSICS LinearControlForce : public LinearForce { +class EXPCL_PANDA_PHYSICS LinearControlForce : public LinearForce { PUBLISHED: explicit LinearControlForce(const PhysicsObject *po = 0, PN_stdfloat a = 1.0f, bool mass = false); diff --git a/panda/src/physics/linearCylinderVortexForce.h b/panda/src/physics/linearCylinderVortexForce.h index d41b4b638a..41c7a554f1 100644 --- a/panda/src/physics/linearCylinderVortexForce.h +++ b/panda/src/physics/linearCylinderVortexForce.h @@ -23,7 +23,7 @@ * warned- this will suck anything that it can reach directly into orbit and * will NOT let go. */ -class EXPCL_PANDAPHYSICS LinearCylinderVortexForce : public LinearForce { +class EXPCL_PANDA_PHYSICS LinearCylinderVortexForce : public LinearForce { PUBLISHED: explicit LinearCylinderVortexForce(PN_stdfloat radius = 1.0f, PN_stdfloat length = 0.0f, diff --git a/panda/src/physics/linearDistanceForce.h b/panda/src/physics/linearDistanceForce.h index 52f30411d4..fa245db104 100644 --- a/panda/src/physics/linearDistanceForce.h +++ b/panda/src/physics/linearDistanceForce.h @@ -21,7 +21,7 @@ class BamReader; /** * Pure virtual class for sinks and sources */ -class EXPCL_PANDAPHYSICS LinearDistanceForce : public LinearForce { +class EXPCL_PANDA_PHYSICS LinearDistanceForce : public LinearForce { PUBLISHED: enum FalloffType { FT_ONE_OVER_R, diff --git a/panda/src/physics/linearEulerIntegrator.h b/panda/src/physics/linearEulerIntegrator.h index 69c6d67649..09430d863d 100644 --- a/panda/src/physics/linearEulerIntegrator.h +++ b/panda/src/physics/linearEulerIntegrator.h @@ -20,7 +20,7 @@ * Performs Euler integration on a vector of physically modelable objects * given a quantum dt. */ -class EXPCL_PANDAPHYSICS LinearEulerIntegrator : public LinearIntegrator { +class EXPCL_PANDA_PHYSICS LinearEulerIntegrator : public LinearIntegrator { PUBLISHED: LinearEulerIntegrator(); virtual ~LinearEulerIntegrator(); diff --git a/panda/src/physics/linearForce.h b/panda/src/physics/linearForce.h index a3208d6e90..b555c99ca8 100644 --- a/panda/src/physics/linearForce.h +++ b/panda/src/physics/linearForce.h @@ -20,7 +20,7 @@ * A force that acts on a PhysicsObject by way of an Integrator. This is a * pure virtual base class. */ -class EXPCL_PANDAPHYSICS LinearForce : public BaseForce { +class EXPCL_PANDA_PHYSICS LinearForce : public BaseForce { PUBLISHED: ~LinearForce(); diff --git a/panda/src/physics/linearFrictionForce.h b/panda/src/physics/linearFrictionForce.h index 7a3dd86bef..cc098c4cce 100644 --- a/panda/src/physics/linearFrictionForce.h +++ b/panda/src/physics/linearFrictionForce.h @@ -19,7 +19,7 @@ /** * Friction-based drag force */ -class EXPCL_PANDAPHYSICS LinearFrictionForce : public LinearForce { +class EXPCL_PANDA_PHYSICS LinearFrictionForce : public LinearForce { PUBLISHED: explicit LinearFrictionForce(PN_stdfloat coef = 1.0f, PN_stdfloat a = 1.0f, bool m = false); LinearFrictionForce(const LinearFrictionForce ©); diff --git a/panda/src/physics/linearIntegrator.h b/panda/src/physics/linearIntegrator.h index 4d0eca841b..4737ae7014 100644 --- a/panda/src/physics/linearIntegrator.h +++ b/panda/src/physics/linearIntegrator.h @@ -23,7 +23,7 @@ * Pure virtual base class for physical modeling. Takes physically modelable * objects and applies forces to them. */ -class EXPCL_PANDAPHYSICS LinearIntegrator : public BaseIntegrator { +class EXPCL_PANDA_PHYSICS LinearIntegrator : public BaseIntegrator { PUBLISHED: virtual ~LinearIntegrator(); public: diff --git a/panda/src/physics/linearJitterForce.h b/panda/src/physics/linearJitterForce.h index 79dd49be85..32433a3f66 100644 --- a/panda/src/physics/linearJitterForce.h +++ b/panda/src/physics/linearJitterForce.h @@ -20,7 +20,7 @@ * Completely random noise force vector. Not repeatable, reliable, or * predictable. */ -class EXPCL_PANDAPHYSICS LinearJitterForce : public LinearRandomForce { +class EXPCL_PANDA_PHYSICS LinearJitterForce : public LinearRandomForce { PUBLISHED: explicit LinearJitterForce(PN_stdfloat a = 1.0f, bool m = false); LinearJitterForce(const LinearJitterForce ©); diff --git a/panda/src/physics/linearNoiseForce.h b/panda/src/physics/linearNoiseForce.h index 1fae5f1217..cfe63183bc 100644 --- a/panda/src/physics/linearNoiseForce.h +++ b/panda/src/physics/linearNoiseForce.h @@ -21,7 +21,7 @@ /** * Repeating noise force vector. */ -class EXPCL_PANDAPHYSICS LinearNoiseForce : public LinearRandomForce { +class EXPCL_PANDA_PHYSICS LinearNoiseForce : public LinearRandomForce { PUBLISHED: explicit LinearNoiseForce(PN_stdfloat a = 1.0f, bool m = false); LinearNoiseForce(const LinearNoiseForce ©); diff --git a/panda/src/physics/linearRandomForce.h b/panda/src/physics/linearRandomForce.h index 7f097ca53a..c637f4a794 100644 --- a/panda/src/physics/linearRandomForce.h +++ b/panda/src/physics/linearRandomForce.h @@ -22,7 +22,7 @@ /** * Pure virtual, parent to noiseForce and jitterForce */ -class EXPCL_PANDAPHYSICS LinearRandomForce : public LinearForce { +class EXPCL_PANDA_PHYSICS LinearRandomForce : public LinearForce { PUBLISHED: virtual ~LinearRandomForce(); diff --git a/panda/src/physics/linearSinkForce.h b/panda/src/physics/linearSinkForce.h index 235085b253..9268e0cdd9 100644 --- a/panda/src/physics/linearSinkForce.h +++ b/panda/src/physics/linearSinkForce.h @@ -19,7 +19,7 @@ /** * Attractor force. Think black hole. */ -class EXPCL_PANDAPHYSICS LinearSinkForce : public LinearDistanceForce { +class EXPCL_PANDA_PHYSICS LinearSinkForce : public LinearDistanceForce { PUBLISHED: explicit LinearSinkForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a = 1.0f, bool m = true); diff --git a/panda/src/physics/linearSourceForce.h b/panda/src/physics/linearSourceForce.h index 52af5ee9c6..70e764a468 100644 --- a/panda/src/physics/linearSourceForce.h +++ b/panda/src/physics/linearSourceForce.h @@ -19,7 +19,7 @@ /** * Repellant force. */ -class EXPCL_PANDAPHYSICS LinearSourceForce : public LinearDistanceForce { +class EXPCL_PANDA_PHYSICS LinearSourceForce : public LinearDistanceForce { PUBLISHED: explicit LinearSourceForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a = 1.0f, bool mass = true); diff --git a/panda/src/physics/linearUserDefinedForce.h b/panda/src/physics/linearUserDefinedForce.h index 2908313095..e7be671950 100644 --- a/panda/src/physics/linearUserDefinedForce.h +++ b/panda/src/physics/linearUserDefinedForce.h @@ -19,7 +19,7 @@ /** * A programmable force that takes an evaluator function. */ -class EXPCL_PANDAPHYSICS LinearUserDefinedForce : public LinearForce { +class EXPCL_PANDA_PHYSICS LinearUserDefinedForce : public LinearForce { PUBLISHED: explicit LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *) = nullptr, PN_stdfloat a = 1.0f, bool md = false); diff --git a/panda/src/physics/linearVectorForce.h b/panda/src/physics/linearVectorForce.h index 75d624cb64..e68f4599da 100644 --- a/panda/src/physics/linearVectorForce.h +++ b/panda/src/physics/linearVectorForce.h @@ -20,7 +20,7 @@ * Simple directed vector force. Suitable for gravity, non-turbulent wind, * etc... */ -class EXPCL_PANDAPHYSICS LinearVectorForce : public LinearForce { +class EXPCL_PANDA_PHYSICS LinearVectorForce : public LinearForce { PUBLISHED: explicit LinearVectorForce(const LVector3& vec, PN_stdfloat a = 1.0f, bool mass = false); explicit LinearVectorForce(PN_stdfloat x = 0.0f, PN_stdfloat y = 0.0f, PN_stdfloat z = 0.0f, diff --git a/panda/src/physics/physical.h b/panda/src/physics/physical.h index 3ab30e9ee4..fd3b9c343a 100644 --- a/panda/src/physics/physical.h +++ b/panda/src/physics/physical.h @@ -34,7 +34,7 @@ class PhysicsManager; * Defines a set of physically modeled attributes. If you want physics * applied to your class, derive it from this. */ -class EXPCL_PANDAPHYSICS Physical : public TypedReferenceCount { +class EXPCL_PANDA_PHYSICS Physical : public TypedReferenceCount { public: // typedef pvector PhysicsObjectVector; typedef pvector LinearForceVector; diff --git a/panda/src/physics/physicalNode.h b/panda/src/physics/physicalNode.h index 57ea5026f6..f88d79dda6 100644 --- a/panda/src/physics/physicalNode.h +++ b/panda/src/physics/physicalNode.h @@ -25,7 +25,7 @@ /** * Graph node that encapsulated a series of physical objects */ -class EXPCL_PANDAPHYSICS PhysicalNode : public PandaNode { +class EXPCL_PANDA_PHYSICS PhysicalNode : public PandaNode { PUBLISHED: explicit PhysicalNode(const std::string &name); INLINE void clear(); diff --git a/panda/src/physics/physicsCollisionHandler.h b/panda/src/physics/physicsCollisionHandler.h index 8811a88756..febcede789 100644 --- a/panda/src/physics/physicsCollisionHandler.h +++ b/panda/src/physics/physicsCollisionHandler.h @@ -23,7 +23,7 @@ * that attempt to move into solid walls. This also puts forces onto the * physics objects */ -class EXPCL_PANDAPHYSICS PhysicsCollisionHandler : +class EXPCL_PANDA_PHYSICS PhysicsCollisionHandler : public CollisionHandlerPusher { PUBLISHED: PhysicsCollisionHandler(); diff --git a/panda/src/physics/physicsManager.h b/panda/src/physics/physicsManager.h index 0dc3ef2c51..b9ca9adf49 100644 --- a/panda/src/physics/physicsManager.h +++ b/panda/src/physics/physicsManager.h @@ -33,7 +33,7 @@ * Physics don't get much higher-level than this. Attach as many Physicals * (particle systems, etc..) as you want, pick an integrator and go. */ -class EXPCL_PANDAPHYSICS PhysicsManager { +class EXPCL_PANDA_PHYSICS PhysicsManager { public: // NOTE that the physicals container is NOT reference counted. this does // indeed mean that you are NOT supposed to use this as a primary storage diff --git a/panda/src/physics/physicsObject.h b/panda/src/physics/physicsObject.h index c2a0dc24bd..a36eb2660f 100644 --- a/panda/src/physics/physicsObject.h +++ b/panda/src/physics/physicsObject.h @@ -24,7 +24,7 @@ * motion to your class, do NOT derive from this. Derive from Physical * instead. */ -class EXPCL_PANDAPHYSICS PhysicsObject : public TypedReferenceCount { +class EXPCL_PANDA_PHYSICS PhysicsObject : public TypedReferenceCount { public: typedef pvector Vector; diff --git a/panda/src/physics/physicsObjectCollection.h b/panda/src/physics/physicsObjectCollection.h index b41f5e6cc2..8a69d49073 100644 --- a/panda/src/physics/physicsObjectCollection.h +++ b/panda/src/physics/physicsObjectCollection.h @@ -22,7 +22,7 @@ * This is a set of zero or more PhysicsObjects. It's handy for returning * from functions that need to return multiple PhysicsObjects. */ -class EXPCL_PANDAPHYSICS PhysicsObjectCollection { +class EXPCL_PANDA_PHYSICS PhysicsObjectCollection { PUBLISHED: PhysicsObjectCollection(); PhysicsObjectCollection(const PhysicsObjectCollection ©); From 768f78306a3341515e5aab442554a6bf51876cec Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 10 Jun 2018 19:24:53 -0600 Subject: [PATCH 012/360] general: Break apart BUILDING_PANDAEGG --- panda/src/egg/config_egg.cxx | 4 +- panda/src/egg/config_egg.h | 32 +++++++-------- panda/src/egg/eggAnimData.h | 2 +- panda/src/egg/eggAnimPreload.h | 2 +- panda/src/egg/eggAttributes.h | 2 +- panda/src/egg/eggBin.h | 2 +- panda/src/egg/eggBinMaker.h | 4 +- panda/src/egg/eggComment.h | 2 +- panda/src/egg/eggCompositePrimitive.h | 2 +- panda/src/egg/eggCoordinateSystem.h | 2 +- panda/src/egg/eggCurve.h | 2 +- panda/src/egg/eggData.h | 2 +- panda/src/egg/eggExternalReference.h | 2 +- panda/src/egg/eggFilenameNode.h | 2 +- panda/src/egg/eggGroup.h | 2 +- panda/src/egg/eggGroupNode.h | 2 +- panda/src/egg/eggGroupUniquifier.h | 2 +- panda/src/egg/eggLine.h | 2 +- panda/src/egg/eggMaterial.h | 4 +- panda/src/egg/eggMaterialCollection.h | 2 +- panda/src/egg/eggMorph.h | 4 +- panda/src/egg/eggMorphList.cxx | 12 +++--- panda/src/egg/eggNameUniquifier.h | 2 +- panda/src/egg/eggNamedObject.h | 2 +- panda/src/egg/eggNode.h | 2 +- panda/src/egg/eggNurbsCurve.h | 2 +- panda/src/egg/eggNurbsSurface.h | 2 +- panda/src/egg/eggObject.h | 2 +- panda/src/egg/eggParameters.h | 4 +- panda/src/egg/eggPatch.h | 2 +- panda/src/egg/eggPoint.h | 2 +- panda/src/egg/eggPolygon.h | 2 +- panda/src/egg/eggPolysetMaker.h | 2 +- panda/src/egg/eggPoolUniquifier.h | 2 +- panda/src/egg/eggPrimitive.h | 2 +- panda/src/egg/eggRenderMode.h | 12 +++--- panda/src/egg/eggSAnimData.h | 2 +- panda/src/egg/eggSurface.h | 2 +- panda/src/egg/eggSwitchCondition.h | 4 +- panda/src/egg/eggTable.h | 2 +- panda/src/egg/eggTexture.h | 28 ++++++------- panda/src/egg/eggTextureCollection.h | 2 +- panda/src/egg/eggTransform.h | 2 +- panda/src/egg/eggTriangleFan.h | 2 +- panda/src/egg/eggTriangleStrip.h | 2 +- panda/src/egg/eggUserData.h | 2 +- panda/src/egg/eggVertex.h | 4 +- panda/src/egg/eggVertexAux.h | 2 +- panda/src/egg/eggVertexPool.h | 2 +- panda/src/egg/eggVertexUV.h | 2 +- panda/src/egg/eggXfmAnimData.h | 2 +- panda/src/egg/eggXfmSAnim.h | 2 +- panda/src/egg/parserDefs.h | 2 +- panda/src/egg/pt_EggMaterial.h | 6 +-- panda/src/egg/pt_EggTexture.h | 6 +-- panda/src/egg/pt_EggVertex.h | 6 +-- panda/src/egg/vector_PT_EggMaterial.h | 4 +- panda/src/egg/vector_PT_EggTexture.h | 4 +- panda/src/egg/vector_PT_EggVertex.cxx | 4 +- panda/src/egg/vector_PT_EggVertex.h | 4 +- panda/src/egg2pg/animBundleMaker.h | 2 +- panda/src/egg2pg/characterMaker.h | 2 +- panda/src/egg2pg/config_egg2pg.cxx | 4 +- panda/src/egg2pg/config_egg2pg.h | 58 +++++++++++++-------------- panda/src/egg2pg/egg_parametrics.h | 4 +- panda/src/egg2pg/load_egg_file.h | 4 +- panda/src/egg2pg/loaderFileTypeEgg.h | 2 +- panda/src/egg2pg/save_egg_file.h | 4 +- panda/src/pandabase/pandasymbols.h | 22 ++++++++++ 69 files changed, 177 insertions(+), 155 deletions(-) diff --git a/panda/src/egg/config_egg.cxx b/panda/src/egg/config_egg.cxx index 65e08efcbc..ec0009819f 100644 --- a/panda/src/egg/config_egg.cxx +++ b/panda/src/egg/config_egg.cxx @@ -58,8 +58,8 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAEGG) - #error Buildsystem error: BUILDING_PANDAEGG not defined +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EGG) + #error Buildsystem error: BUILDING_PANDA_EGG not defined #endif Configure(config_egg); diff --git a/panda/src/egg/config_egg.h b/panda/src/egg/config_egg.h index 1df45a4359..a9d67f8460 100644 --- a/panda/src/egg/config_egg.h +++ b/panda/src/egg/config_egg.h @@ -22,26 +22,26 @@ #include "configVariableDouble.h" #include "configVariableInt.h" -NotifyCategoryDecl(egg, EXPCL_PANDAEGG, EXPTP_PANDAEGG); +NotifyCategoryDecl(egg, EXPCL_PANDA_EGG, EXPTP_PANDA_EGG); extern ConfigVariableBool egg_support_old_anims; -extern EXPCL_PANDAEGG ConfigVariableBool egg_mesh; -extern EXPCL_PANDAEGG ConfigVariableBool egg_retesselate_coplanar; -extern EXPCL_PANDAEGG ConfigVariableBool egg_unroll_fans; -extern EXPCL_PANDAEGG ConfigVariableBool egg_show_tstrips; -extern EXPCL_PANDAEGG ConfigVariableBool egg_show_qsheets; -extern EXPCL_PANDAEGG ConfigVariableBool egg_show_quads; +extern EXPCL_PANDA_EGG ConfigVariableBool egg_mesh; +extern EXPCL_PANDA_EGG ConfigVariableBool egg_retesselate_coplanar; +extern EXPCL_PANDA_EGG ConfigVariableBool egg_unroll_fans; +extern EXPCL_PANDA_EGG ConfigVariableBool egg_show_tstrips; +extern EXPCL_PANDA_EGG ConfigVariableBool egg_show_qsheets; +extern EXPCL_PANDA_EGG ConfigVariableBool egg_show_quads; #define egg_false_color (egg_show_tstrips | egg_show_qsheets | egg_show_quads) -extern EXPCL_PANDAEGG ConfigVariableBool egg_subdivide_polys; -extern EXPCL_PANDAEGG ConfigVariableBool egg_consider_fans; -extern EXPCL_PANDAEGG ConfigVariableDouble egg_max_tfan_angle; -extern EXPCL_PANDAEGG ConfigVariableInt egg_min_tfan_tris; -extern EXPCL_PANDAEGG ConfigVariableDouble egg_coplanar_threshold; -extern EXPCL_PANDAEGG ConfigVariableInt egg_test_vref_integrity; -extern EXPCL_PANDAEGG ConfigVariableInt egg_recursion_limit; -extern EXPCL_PANDAEGG ConfigVariableInt egg_precision; +extern EXPCL_PANDA_EGG ConfigVariableBool egg_subdivide_polys; +extern EXPCL_PANDA_EGG ConfigVariableBool egg_consider_fans; +extern EXPCL_PANDA_EGG ConfigVariableDouble egg_max_tfan_angle; +extern EXPCL_PANDA_EGG ConfigVariableInt egg_min_tfan_tris; +extern EXPCL_PANDA_EGG ConfigVariableDouble egg_coplanar_threshold; +extern EXPCL_PANDA_EGG ConfigVariableInt egg_test_vref_integrity; +extern EXPCL_PANDA_EGG ConfigVariableInt egg_recursion_limit; +extern EXPCL_PANDA_EGG ConfigVariableInt egg_precision; -extern EXPCL_PANDAEGG void init_libegg(); +extern EXPCL_PANDA_EGG void init_libegg(); #endif diff --git a/panda/src/egg/eggAnimData.h b/panda/src/egg/eggAnimData.h index 05bdc3669a..9bcb68030b 100644 --- a/panda/src/egg/eggAnimData.h +++ b/panda/src/egg/eggAnimData.h @@ -27,7 +27,7 @@ * A base class for EggSAnimData and EggXfmAnimData, which contain rows and * columns of numbers. */ -class EXPCL_PANDAEGG EggAnimData : public EggNode { +class EXPCL_PANDA_EGG EggAnimData : public EggNode { PUBLISHED: INLINE explicit EggAnimData(const std::string &name = ""); INLINE EggAnimData(const EggAnimData ©); diff --git a/panda/src/egg/eggAnimPreload.h b/panda/src/egg/eggAnimPreload.h index 577901cac5..e2b52a5c64 100644 --- a/panda/src/egg/eggAnimPreload.h +++ b/panda/src/egg/eggAnimPreload.h @@ -21,7 +21,7 @@ /** * This corresponds to an entry. */ -class EXPCL_PANDAEGG EggAnimPreload : public EggNode { +class EXPCL_PANDA_EGG EggAnimPreload : public EggNode { PUBLISHED: INLINE explicit EggAnimPreload(const std::string &name = ""); INLINE EggAnimPreload(const EggAnimPreload ©); diff --git a/panda/src/egg/eggAttributes.h b/panda/src/egg/eggAttributes.h index 1ff0833d7e..d0fa35dfd3 100644 --- a/panda/src/egg/eggAttributes.h +++ b/panda/src/egg/eggAttributes.h @@ -30,7 +30,7 @@ * EggPolygon level with multiple appearances of the EggObject base class. * And making EggObject a virtual base class is just no fun. */ -class EXPCL_PANDAEGG EggAttributes : public MemoryBase { +class EXPCL_PANDA_EGG EggAttributes : public MemoryBase { PUBLISHED: EggAttributes(); EggAttributes(const EggAttributes ©); diff --git a/panda/src/egg/eggBin.h b/panda/src/egg/eggBin.h index e069a44af1..d6b09dde22 100644 --- a/panda/src/egg/eggBin.h +++ b/panda/src/egg/eggBin.h @@ -23,7 +23,7 @@ * of node that will never be read in from an egg file, but can only exist in * the egg scene graph if it is created via the use of an EggBinMaker. */ -class EXPCL_PANDAEGG EggBin : public EggGroup { +class EXPCL_PANDA_EGG EggBin : public EggGroup { PUBLISHED: explicit EggBin(const std::string &name = ""); EggBin(const EggGroup ©); diff --git a/panda/src/egg/eggBinMaker.h b/panda/src/egg/eggBinMaker.h index 06590cd0c4..02f3dbb43f 100644 --- a/panda/src/egg/eggBinMaker.h +++ b/panda/src/egg/eggBinMaker.h @@ -139,7 +139,7 @@ class EggBinMaker; * This is just an STL function object, used to sort nodes within EggBinMaker. * It's part of the private interface; ignore it. */ -class EXPCL_PANDAEGG EggBinMakerCompareNodes { +class EXPCL_PANDA_EGG EggBinMakerCompareNodes { public: EggBinMakerCompareNodes() { // We need to have a default constructor to compile, but it should never @@ -158,7 +158,7 @@ public: * abstract class; to use it you must subclass off of it. See the somewhat * lengthy comment above. */ -class EXPCL_PANDAEGG EggBinMaker : public EggObject { +class EXPCL_PANDA_EGG EggBinMaker : public EggObject { PUBLISHED: EggBinMaker(); ~EggBinMaker(); diff --git a/panda/src/egg/eggComment.h b/panda/src/egg/eggComment.h index 491ecdf6ba..17611ed5d5 100644 --- a/panda/src/egg/eggComment.h +++ b/panda/src/egg/eggComment.h @@ -21,7 +21,7 @@ /** * A comment that appears in an egg file within a entry. */ -class EXPCL_PANDAEGG EggComment : public EggNode { +class EXPCL_PANDA_EGG EggComment : public EggNode { PUBLISHED: INLINE explicit EggComment(const std::string &node_name, const std::string &comment); INLINE EggComment(const EggComment ©); diff --git a/panda/src/egg/eggCompositePrimitive.h b/panda/src/egg/eggCompositePrimitive.h index 4cde1084bf..d7e169624b 100644 --- a/panda/src/egg/eggCompositePrimitive.h +++ b/panda/src/egg/eggCompositePrimitive.h @@ -23,7 +23,7 @@ * which include several component triangles, each of which might have its own * color and/or normal. */ -class EXPCL_PANDAEGG EggCompositePrimitive : public EggPrimitive { +class EXPCL_PANDA_EGG EggCompositePrimitive : public EggPrimitive { PUBLISHED: INLINE explicit EggCompositePrimitive(const std::string &name = ""); INLINE EggCompositePrimitive(const EggCompositePrimitive ©); diff --git a/panda/src/egg/eggCoordinateSystem.h b/panda/src/egg/eggCoordinateSystem.h index 0d4575a708..54a76e6f78 100644 --- a/panda/src/egg/eggCoordinateSystem.h +++ b/panda/src/egg/eggCoordinateSystem.h @@ -26,7 +26,7 @@ * with the enum EggData::CoordinateSystem, which is the value contained by * this entry. */ -class EXPCL_PANDAEGG EggCoordinateSystem : public EggNode { +class EXPCL_PANDA_EGG EggCoordinateSystem : public EggNode { PUBLISHED: INLINE EggCoordinateSystem(CoordinateSystem value = CS_default); INLINE EggCoordinateSystem(const EggCoordinateSystem ©); diff --git a/panda/src/egg/eggCurve.h b/panda/src/egg/eggCurve.h index 6bbcb64ea5..736869fbdb 100644 --- a/panda/src/egg/eggCurve.h +++ b/panda/src/egg/eggCurve.h @@ -21,7 +21,7 @@ /** * A parametric curve of some kind. See EggNurbsCurve. */ -class EXPCL_PANDAEGG EggCurve : public EggPrimitive { +class EXPCL_PANDA_EGG EggCurve : public EggPrimitive { PUBLISHED: INLINE explicit EggCurve(const std::string &name = ""); INLINE EggCurve(const EggCurve ©); diff --git a/panda/src/egg/eggData.h b/panda/src/egg/eggData.h index 4b49ba5f90..ad5d3a9917 100644 --- a/panda/src/egg/eggData.h +++ b/panda/src/egg/eggData.h @@ -34,7 +34,7 @@ class BamCacheRecord; * begin() and end() calls. The children of the EggData class are the * toplevel nodes in the egg file. */ -class EXPCL_PANDAEGG EggData : public EggGroupNode { +class EXPCL_PANDA_EGG EggData : public EggGroupNode { PUBLISHED: INLINE EggData(); INLINE EggData(const EggData ©); diff --git a/panda/src/egg/eggExternalReference.h b/panda/src/egg/eggExternalReference.h index ff4f332740..d19879397d 100644 --- a/panda/src/egg/eggExternalReference.h +++ b/panda/src/egg/eggExternalReference.h @@ -22,7 +22,7 @@ * Defines a reference to another egg file which should be inserted at this * point. */ -class EXPCL_PANDAEGG EggExternalReference : public EggFilenameNode { +class EXPCL_PANDA_EGG EggExternalReference : public EggFilenameNode { PUBLISHED: explicit EggExternalReference(const std::string &node_name, const std::string &filename); EggExternalReference(const EggExternalReference ©); diff --git a/panda/src/egg/eggFilenameNode.h b/panda/src/egg/eggFilenameNode.h index 3eda6ace36..ee98f8d091 100644 --- a/panda/src/egg/eggFilenameNode.h +++ b/panda/src/egg/eggFilenameNode.h @@ -24,7 +24,7 @@ * file relative to the directory the egg file was loaded in. It is a base * class for EggTexture and EggExternalReference. */ -class EXPCL_PANDAEGG EggFilenameNode : public EggNode { +class EXPCL_PANDA_EGG EggFilenameNode : public EggNode { PUBLISHED: INLINE EggFilenameNode(); INLINE explicit EggFilenameNode(const std::string &node_name, const Filename &filename); diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index bc4d095150..14485dcc24 100644 --- a/panda/src/egg/eggGroup.h +++ b/panda/src/egg/eggGroup.h @@ -31,7 +31,7 @@ * The main glue of the egg hierarchy, this corresponds to the , * , and type nodes. */ -class EXPCL_PANDAEGG EggGroup : public EggGroupNode, public EggRenderMode, public EggTransform { +class EXPCL_PANDA_EGG EggGroup : public EggGroupNode, public EggRenderMode, public EggTransform { PUBLISHED: typedef pmap VertexRef; typedef pmap TagData; diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index b8e361e97e..346c2ed817 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/panda/src/egg/eggGroupNode.h @@ -43,7 +43,7 @@ class DSearchPath; * to manipulate the list. The list may also be operated on (read-only) via * iterators and begin()/end(). */ -class EXPCL_PANDAEGG EggGroupNode : public EggNode { +class EXPCL_PANDA_EGG EggGroupNode : public EggNode { // This is a bit of private interface stuff that must be here as a forward // reference. This allows us to define the EggGroupNode as an STL diff --git a/panda/src/egg/eggGroupUniquifier.h b/panda/src/egg/eggGroupUniquifier.h index cacabcb06e..4c8c142d1a 100644 --- a/panda/src/egg/eggGroupUniquifier.h +++ b/panda/src/egg/eggGroupUniquifier.h @@ -23,7 +23,7 @@ * EggGroup nodes. It's not called automatically; you must invoke it yourself * if you want it. */ -class EXPCL_PANDAEGG EggGroupUniquifier : public EggNameUniquifier { +class EXPCL_PANDA_EGG EggGroupUniquifier : public EggNameUniquifier { PUBLISHED: explicit EggGroupUniquifier(bool filter_names = true); diff --git a/panda/src/egg/eggLine.h b/panda/src/egg/eggLine.h index 09ce5a22c8..e4c67ff279 100644 --- a/panda/src/egg/eggLine.h +++ b/panda/src/egg/eggLine.h @@ -22,7 +22,7 @@ * A line segment, or a series of connected line segments, defined by a * entry. */ -class EXPCL_PANDAEGG EggLine : public EggCompositePrimitive { +class EXPCL_PANDA_EGG EggLine : public EggCompositePrimitive { PUBLISHED: INLINE explicit EggLine(const std::string &name = ""); INLINE EggLine(const EggLine ©); diff --git a/panda/src/egg/eggMaterial.h b/panda/src/egg/eggMaterial.h index 19dc055185..6d9f979848 100644 --- a/panda/src/egg/eggMaterial.h +++ b/panda/src/egg/eggMaterial.h @@ -23,7 +23,7 @@ /** * */ -class EXPCL_PANDAEGG EggMaterial : public EggNode { +class EXPCL_PANDA_EGG EggMaterial : public EggNode { PUBLISHED: explicit EggMaterial(const std::string &mref_name); EggMaterial(const EggMaterial ©); @@ -151,7 +151,7 @@ private: * Returns true if the two referenced EggMaterial pointers are in sorted * order, false otherwise. */ -class EXPCL_PANDAEGG UniqueEggMaterials { +class EXPCL_PANDA_EGG UniqueEggMaterials { public: INLINE UniqueEggMaterials(int eq = ~0); INLINE bool operator ()(const EggMaterial *t1, const EggMaterial *t2) const; diff --git a/panda/src/egg/eggMaterialCollection.h b/panda/src/egg/eggMaterialCollection.h index bc712704a8..9f4d196b62 100644 --- a/panda/src/egg/eggMaterialCollection.h +++ b/panda/src/egg/eggMaterialCollection.h @@ -27,7 +27,7 @@ * materials from an egg file and sort them all together; it can also manage * the creation of unique materials and the assignment of unique MRef names. */ -class EXPCL_PANDAEGG EggMaterialCollection { +class EXPCL_PANDA_EGG EggMaterialCollection { // This is a bit of private interface stuff that must be here as a forward // reference. This allows us to define the EggMaterialCollection as an STL diff --git a/panda/src/egg/eggMorph.h b/panda/src/egg/eggMorph.h index 482b612a6e..29c42cecab 100644 --- a/panda/src/egg/eggMorph.h +++ b/panda/src/egg/eggMorph.h @@ -49,8 +49,8 @@ private: // I'd love to export these, but it produces a strange linker issue with Mac // OS X's version of GCC. We'll do it only on Windows, then. #ifdef _MSC_VER -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, EggMorph); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, EggMorph); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, EggMorph); +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, EggMorph); #endif typedef EggMorph EggMorphVertex; diff --git a/panda/src/egg/eggMorphList.cxx b/panda/src/egg/eggMorphList.cxx index eb5a12a9b1..01172b9f17 100644 --- a/panda/src/egg/eggMorphList.cxx +++ b/panda/src/egg/eggMorphList.cxx @@ -15,20 +15,20 @@ // Continue all of the vector import definitions. -#define EXPCL EXPCL_PANDAEGG -#define EXPTP EXPTP_PANDAEGG +#define EXPCL EXPCL_PANDA_EGG +#define EXPTP EXPTP_PANDA_EGG #define TYPE LVector3d #define NAME vector_LVector3d #include "vector_src.cxx" -#define EXPCL EXPCL_PANDAEGG -#define EXPTP EXPTP_PANDAEGG +#define EXPCL EXPCL_PANDA_EGG +#define EXPTP EXPTP_PANDA_EGG #define TYPE LVector2d #define NAME vector_LVector2d #include "vector_src.cxx" -#define EXPCL EXPCL_PANDAEGG -#define EXPTP EXPTP_PANDAEGG +#define EXPCL EXPCL_PANDA_EGG +#define EXPTP EXPTP_PANDA_EGG #define TYPE LVector4 #define NAME vector_LVector4 #include "vector_src.cxx" diff --git a/panda/src/egg/eggNameUniquifier.h b/panda/src/egg/eggNameUniquifier.h index ff0c17c00f..4b1f0f48d0 100644 --- a/panda/src/egg/eggNameUniquifier.h +++ b/panda/src/egg/eggNameUniquifier.h @@ -56,7 +56,7 @@ class EggNode; * hierarchy. It is an abstract class; to use it you must subclass off of it. * See the comment above. */ -class EXPCL_PANDAEGG EggNameUniquifier : public EggObject { +class EXPCL_PANDA_EGG EggNameUniquifier : public EggObject { PUBLISHED: EggNameUniquifier(); ~EggNameUniquifier(); diff --git a/panda/src/egg/eggNamedObject.h b/panda/src/egg/eggNamedObject.h index 0b3588d87b..880dd0ca2d 100644 --- a/panda/src/egg/eggNamedObject.h +++ b/panda/src/egg/eggNamedObject.h @@ -23,7 +23,7 @@ /** * This is a fairly low-level base class--any egg object that has a name. */ -class EXPCL_PANDAEGG EggNamedObject : public EggObject, public Namable { +class EXPCL_PANDA_EGG EggNamedObject : public EggObject, public Namable { PUBLISHED: INLINE explicit EggNamedObject(const std::string &name = ""); INLINE EggNamedObject(const EggNamedObject ©); diff --git a/panda/src/egg/eggNode.h b/panda/src/egg/eggNode.h index 05191dabc5..c2d811859e 100644 --- a/panda/src/egg/eggNode.h +++ b/panda/src/egg/eggNode.h @@ -32,7 +32,7 @@ class EggTextureCollection; * This includes groups, joints, polygons, vertex pools, etc., but does not * include things like vertices. */ -class EXPCL_PANDAEGG EggNode : public EggNamedObject { +class EXPCL_PANDA_EGG EggNode : public EggNamedObject { PUBLISHED: INLINE explicit EggNode(const std::string &name = ""); INLINE EggNode(const EggNode ©); diff --git a/panda/src/egg/eggNurbsCurve.h b/panda/src/egg/eggNurbsCurve.h index dd62f6c5ab..33eeaaae26 100644 --- a/panda/src/egg/eggNurbsCurve.h +++ b/panda/src/egg/eggNurbsCurve.h @@ -23,7 +23,7 @@ /** * A parametric NURBS curve. */ -class EXPCL_PANDAEGG EggNurbsCurve : public EggCurve { +class EXPCL_PANDA_EGG EggNurbsCurve : public EggCurve { PUBLISHED: INLINE explicit EggNurbsCurve(const std::string &name = ""); INLINE EggNurbsCurve(const EggNurbsCurve ©); diff --git a/panda/src/egg/eggNurbsSurface.h b/panda/src/egg/eggNurbsSurface.h index 46d9c86357..329c50920c 100644 --- a/panda/src/egg/eggNurbsSurface.h +++ b/panda/src/egg/eggNurbsSurface.h @@ -24,7 +24,7 @@ /** * A parametric NURBS surface. */ -class EXPCL_PANDAEGG EggNurbsSurface : public EggSurface { +class EXPCL_PANDA_EGG EggNurbsSurface : public EggSurface { PUBLISHED: typedef plist< PT(EggNurbsCurve) > Curves; typedef Curves Loop; diff --git a/panda/src/egg/eggObject.h b/panda/src/egg/eggObject.h index f293b19503..71c68e51db 100644 --- a/panda/src/egg/eggObject.h +++ b/panda/src/egg/eggObject.h @@ -26,7 +26,7 @@ class EggTransform; * The highest-level base class in the egg directory. (Almost) all things egg * inherit from this. */ -class EXPCL_PANDAEGG EggObject : public TypedReferenceCount { +class EXPCL_PANDA_EGG EggObject : public TypedReferenceCount { PUBLISHED: EggObject(); EggObject(const EggObject ©); diff --git a/panda/src/egg/eggParameters.h b/panda/src/egg/eggParameters.h index 93b1aff8b0..600de3c17a 100644 --- a/panda/src/egg/eggParameters.h +++ b/panda/src/egg/eggParameters.h @@ -29,7 +29,7 @@ * process it, and write the egg file out again before resetting the * parameters again. */ -class EXPCL_PANDAEGG EggParameters { +class EXPCL_PANDA_EGG EggParameters { public: constexpr EggParameters() = default; @@ -54,6 +54,6 @@ public: double _table_threshold = 0.0001; }; -extern EXPCL_PANDAEGG EggParameters *egg_parameters; +extern EXPCL_PANDA_EGG EggParameters *egg_parameters; #endif diff --git a/panda/src/egg/eggPatch.h b/panda/src/egg/eggPatch.h index 67c94c100a..72530df4cb 100644 --- a/panda/src/egg/eggPatch.h +++ b/panda/src/egg/eggPatch.h @@ -22,7 +22,7 @@ * A single "patch", a special primitive to be rendered only with a * tessellation shader. */ -class EXPCL_PANDAEGG EggPatch : public EggPrimitive { +class EXPCL_PANDA_EGG EggPatch : public EggPrimitive { PUBLISHED: INLINE explicit EggPatch(const std::string &name = ""); INLINE EggPatch(const EggPatch ©); diff --git a/panda/src/egg/eggPoint.h b/panda/src/egg/eggPoint.h index fc1ed8d24c..5c113280c5 100644 --- a/panda/src/egg/eggPoint.h +++ b/panda/src/egg/eggPoint.h @@ -22,7 +22,7 @@ * A single point, or a collection of points as defined by a single * entry. */ -class EXPCL_PANDAEGG EggPoint : public EggPrimitive { +class EXPCL_PANDA_EGG EggPoint : public EggPrimitive { PUBLISHED: INLINE explicit EggPoint(const std::string &name = ""); INLINE EggPoint(const EggPoint ©); diff --git a/panda/src/egg/eggPolygon.h b/panda/src/egg/eggPolygon.h index 3629537814..ec3c236644 100644 --- a/panda/src/egg/eggPolygon.h +++ b/panda/src/egg/eggPolygon.h @@ -21,7 +21,7 @@ /** * A single polygon. */ -class EXPCL_PANDAEGG EggPolygon : public EggPrimitive { +class EXPCL_PANDA_EGG EggPolygon : public EggPrimitive { PUBLISHED: INLINE explicit EggPolygon(const std::string &name = ""); INLINE EggPolygon(const EggPolygon ©); diff --git a/panda/src/egg/eggPolysetMaker.h b/panda/src/egg/eggPolysetMaker.h index 5fa5eebc94..a104a41477 100644 --- a/panda/src/egg/eggPolysetMaker.h +++ b/panda/src/egg/eggPolysetMaker.h @@ -29,7 +29,7 @@ * these are not sufficient, you can always rederive your own further * specialization of this class. */ -class EXPCL_PANDAEGG EggPolysetMaker : public EggBinMaker { +class EXPCL_PANDA_EGG EggPolysetMaker : public EggBinMaker { PUBLISHED: // The BinNumber serves to identify why a particular EggBin was created. enum BinNumber { diff --git a/panda/src/egg/eggPoolUniquifier.h b/panda/src/egg/eggPoolUniquifier.h index 8fa0c328d0..a5d48f0813 100644 --- a/panda/src/egg/eggPoolUniquifier.h +++ b/panda/src/egg/eggPoolUniquifier.h @@ -23,7 +23,7 @@ * textures, materials, and vertex pools prior to writing out an egg file. * It's automatically called by EggData prior to writing out an egg file. */ -class EXPCL_PANDAEGG EggPoolUniquifier : public EggNameUniquifier { +class EXPCL_PANDA_EGG EggPoolUniquifier : public EggNameUniquifier { PUBLISHED: EggPoolUniquifier(); diff --git a/panda/src/egg/eggPrimitive.h b/panda/src/egg/eggPrimitive.h index d461762382..4b8a035952 100644 --- a/panda/src/egg/eggPrimitive.h +++ b/panda/src/egg/eggPrimitive.h @@ -44,7 +44,7 @@ class EggVertexPool; * can. However, it is necessary that all vertices belong to the same vertex * pool. */ -class EXPCL_PANDAEGG EggPrimitive : public EggNode, public EggAttributes, +class EXPCL_PANDA_EGG EggPrimitive : public EggNode, public EggAttributes, public EggRenderMode { diff --git a/panda/src/egg/eggRenderMode.h b/panda/src/egg/eggRenderMode.h index db18e5d47d..3730cde3da 100644 --- a/panda/src/egg/eggRenderMode.h +++ b/panda/src/egg/eggRenderMode.h @@ -28,7 +28,7 @@ * EggPolygon level with multiple appearances of the EggObject base class. * And making EggObject a virtual base class is just no fun. */ -class EXPCL_PANDAEGG EggRenderMode { +class EXPCL_PANDA_EGG EggRenderMode { PUBLISHED: EggRenderMode(); INLINE EggRenderMode(const EggRenderMode ©); @@ -122,12 +122,12 @@ private: static TypeHandle _type_handle; }; -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggRenderMode::AlphaMode mode); -EXPCL_PANDAEGG std::istream &operator >> (std::istream &in, EggRenderMode::AlphaMode &mode); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggRenderMode::AlphaMode mode); +EXPCL_PANDA_EGG std::istream &operator >> (std::istream &in, EggRenderMode::AlphaMode &mode); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggRenderMode::DepthWriteMode mode); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggRenderMode::DepthTestMode mode); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggRenderMode::VisibilityMode mode); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggRenderMode::DepthWriteMode mode); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggRenderMode::DepthTestMode mode); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggRenderMode::VisibilityMode mode); #include "eggRenderMode.I" diff --git a/panda/src/egg/eggSAnimData.h b/panda/src/egg/eggSAnimData.h index 681716f6b0..c1c28eb2c5 100644 --- a/panda/src/egg/eggSAnimData.h +++ b/panda/src/egg/eggSAnimData.h @@ -22,7 +22,7 @@ * Corresponding to an entry, this stores a single column of numbers, * for instance for a morph target, or as one column in an EggXfmSAnim. */ -class EXPCL_PANDAEGG EggSAnimData : public EggAnimData { +class EXPCL_PANDA_EGG EggSAnimData : public EggAnimData { PUBLISHED: INLINE explicit EggSAnimData(const std::string &name = ""); INLINE EggSAnimData(const EggSAnimData ©); diff --git a/panda/src/egg/eggSurface.h b/panda/src/egg/eggSurface.h index ca6994f7ba..19ee6cb907 100644 --- a/panda/src/egg/eggSurface.h +++ b/panda/src/egg/eggSurface.h @@ -21,7 +21,7 @@ /** * A parametric surface of some kind. See EggNurbsSurface. */ -class EXPCL_PANDAEGG EggSurface : public EggPrimitive { +class EXPCL_PANDA_EGG EggSurface : public EggPrimitive { PUBLISHED: INLINE explicit EggSurface(const std::string &name = ""); INLINE EggSurface(const EggSurface ©); diff --git a/panda/src/egg/eggSwitchCondition.h b/panda/src/egg/eggSwitchCondition.h index 35d1c16cc3..ceb15cca51 100644 --- a/panda/src/egg/eggSwitchCondition.h +++ b/panda/src/egg/eggSwitchCondition.h @@ -26,7 +26,7 @@ * different kinds of switching conditions; presently, only a type * is actually supported. */ -class EXPCL_PANDAEGG EggSwitchCondition : public EggObject { +class EXPCL_PANDA_EGG EggSwitchCondition : public EggObject { PUBLISHED: virtual EggSwitchCondition *make_copy() const=0; virtual void write(std::ostream &out, int indent_level) const=0; @@ -58,7 +58,7 @@ private: * A SwitchCondition that switches the levels-of-detail based on distance from * the camera's eyepoint. */ -class EXPCL_PANDAEGG EggSwitchConditionDistance : public EggSwitchCondition { +class EXPCL_PANDA_EGG EggSwitchConditionDistance : public EggSwitchCondition { PUBLISHED: explicit EggSwitchConditionDistance(double switch_in, double switch_out, const LPoint3d ¢er, double fade = 0.0); diff --git a/panda/src/egg/eggTable.h b/panda/src/egg/eggTable.h index a2f627f555..59d76e9a08 100644 --- a/panda/src/egg/eggTable.h +++ b/panda/src/egg/eggTable.h @@ -24,7 +24,7 @@ * EggSAnimData or an EggXfmAnimData, which do. It may also be a parent to * another or , establishing a hierarchy of tables. */ -class EXPCL_PANDAEGG EggTable : public EggGroupNode { +class EXPCL_PANDA_EGG EggTable : public EggGroupNode { PUBLISHED: enum TableType { TT_invalid, diff --git a/panda/src/egg/eggTexture.h b/panda/src/egg/eggTexture.h index e20c19b9cc..55f56f4b3d 100644 --- a/panda/src/egg/eggTexture.h +++ b/panda/src/egg/eggTexture.h @@ -27,7 +27,7 @@ /** * Defines a texture map that may be applied to geometry. */ -class EXPCL_PANDAEGG EggTexture : public EggFilenameNode, public EggRenderMode, public EggTransform { +class EXPCL_PANDA_EGG EggTexture : public EggFilenameNode, public EggRenderMode, public EggTransform { PUBLISHED: explicit EggTexture(const std::string &tref_name, const Filename &filename); EggTexture(const EggTexture ©); @@ -458,7 +458,7 @@ private: * Returns true if the two referenced EggTexture pointers are in sorted order, * false otherwise. */ -class EXPCL_PANDAEGG UniqueEggTextures { +class EXPCL_PANDA_EGG UniqueEggTextures { public: INLINE UniqueEggTextures(int eq = ~0); INLINE bool operator ()(const EggTexture *t1, const EggTexture *t2) const; @@ -470,18 +470,18 @@ INLINE std::ostream &operator << (std::ostream &out, const EggTexture &n) { return out << n.get_filename(); } -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::TextureType texture_type); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::Format format); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CompressionMode mode); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::WrapMode mode); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::FilterType type); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::EnvType type); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CombineMode cm); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CombineChannel cc); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CombineSource cs); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CombineOperand co); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::TexGen tex_gen); -EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::QualityLevel quality_level); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::TextureType texture_type); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::Format format); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::CompressionMode mode); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::WrapMode mode); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::FilterType type); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::EnvType type); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::CombineMode cm); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::CombineChannel cc); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::CombineSource cs); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::CombineOperand co); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::TexGen tex_gen); +EXPCL_PANDA_EGG std::ostream &operator << (std::ostream &out, EggTexture::QualityLevel quality_level); #include "eggTexture.I" diff --git a/panda/src/egg/eggTextureCollection.h b/panda/src/egg/eggTextureCollection.h index db9f64ae93..040a8e0da8 100644 --- a/panda/src/egg/eggTextureCollection.h +++ b/panda/src/egg/eggTextureCollection.h @@ -27,7 +27,7 @@ * from an egg file and sort them all together; it can also manage the * creation of unique textures and the assignment of unique TRef names. */ -class EXPCL_PANDAEGG EggTextureCollection { +class EXPCL_PANDA_EGG EggTextureCollection { // This is a bit of private interface stuff that must be here as a forward // reference. This allows us to define the EggTextureCollection as an STL diff --git a/panda/src/egg/eggTransform.h b/panda/src/egg/eggTransform.h index 9a6b95b434..671a3b1155 100644 --- a/panda/src/egg/eggTransform.h +++ b/panda/src/egg/eggTransform.h @@ -26,7 +26,7 @@ * This may be either a 3-d transform, and therefore described by a 4x4 * matrix, or a 2-d transform, described by a 3x3 matrix. */ -class EXPCL_PANDAEGG EggTransform { +class EXPCL_PANDA_EGG EggTransform { PUBLISHED: EggTransform(); EggTransform(const EggTransform ©); diff --git a/panda/src/egg/eggTriangleFan.h b/panda/src/egg/eggTriangleFan.h index d8a1c7807f..29485b2f5f 100644 --- a/panda/src/egg/eggTriangleFan.h +++ b/panda/src/egg/eggTriangleFan.h @@ -22,7 +22,7 @@ * A connected fan of triangles. This does not normally appear in an egg * file; it is typically generated as a result of meshing. */ -class EXPCL_PANDAEGG EggTriangleFan : public EggCompositePrimitive { +class EXPCL_PANDA_EGG EggTriangleFan : public EggCompositePrimitive { PUBLISHED: INLINE explicit EggTriangleFan(const std::string &name = ""); INLINE EggTriangleFan(const EggTriangleFan ©); diff --git a/panda/src/egg/eggTriangleStrip.h b/panda/src/egg/eggTriangleStrip.h index 728b6e2e30..052d174232 100644 --- a/panda/src/egg/eggTriangleStrip.h +++ b/panda/src/egg/eggTriangleStrip.h @@ -22,7 +22,7 @@ * A connected strip of triangles. This does not normally appear in an egg * file; it is typically generated as a result of meshing. */ -class EXPCL_PANDAEGG EggTriangleStrip : public EggCompositePrimitive { +class EXPCL_PANDA_EGG EggTriangleStrip : public EggCompositePrimitive { PUBLISHED: INLINE explicit EggTriangleStrip(const std::string &name = ""); INLINE EggTriangleStrip(const EggTriangleStrip ©); diff --git a/panda/src/egg/eggUserData.h b/panda/src/egg/eggUserData.h index cec2587946..477bebc7c6 100644 --- a/panda/src/egg/eggUserData.h +++ b/panda/src/egg/eggUserData.h @@ -26,7 +26,7 @@ * However, this data will not be written out to the disk when the egg file is * written; it is an in-memory object only. */ -class EXPCL_PANDAEGG EggUserData : public TypedReferenceCount { +class EXPCL_PANDA_EGG EggUserData : public TypedReferenceCount { PUBLISHED: INLINE EggUserData(); INLINE EggUserData(const EggUserData ©); diff --git a/panda/src/egg/eggVertex.h b/panda/src/egg/eggVertex.h index 4c2cc2e36d..55dbc8a3d3 100644 --- a/panda/src/egg/eggVertex.h +++ b/panda/src/egg/eggVertex.h @@ -36,7 +36,7 @@ class EggPrimitive; * Any one-, two-, three-, or four-component vertex, possibly with attributes * such as a normal. */ -class EXPCL_PANDAEGG EggVertex : public EggObject, public EggAttributes { +class EXPCL_PANDA_EGG EggVertex : public EggObject, public EggAttributes { public: typedef pset GroupRef; typedef pmultiset PrimitiveRef; @@ -211,7 +211,7 @@ INLINE std::ostream &operator << (std::ostream &out, const EggVertex &vert) { * Returns true if the two referenced EggVertex pointers are in sorted order, * false otherwise. */ -class EXPCL_PANDAEGG UniqueEggVertices { +class EXPCL_PANDA_EGG UniqueEggVertices { public: INLINE bool operator ()(const EggVertex *v1, const EggVertex *v2) const; }; diff --git a/panda/src/egg/eggVertexAux.h b/panda/src/egg/eggVertexAux.h index 20c80dd531..db8bb67ccc 100644 --- a/panda/src/egg/eggVertexAux.h +++ b/panda/src/egg/eggVertexAux.h @@ -27,7 +27,7 @@ * the vertex data, but will not otherwise interpret it. Presumably, a shader * will process the data later. */ -class EXPCL_PANDAEGG EggVertexAux : public EggNamedObject { +class EXPCL_PANDA_EGG EggVertexAux : public EggNamedObject { PUBLISHED: explicit EggVertexAux(const std::string &name, const LVecBase4d &aux); EggVertexAux(const EggVertexAux ©); diff --git a/panda/src/egg/eggVertexPool.h b/panda/src/egg/eggVertexPool.h index dd8672abb4..8ee26fa35b 100644 --- a/panda/src/egg/eggVertexPool.h +++ b/panda/src/egg/eggVertexPool.h @@ -38,7 +38,7 @@ * list. The list may also be operated on (read-only) via iterators and * begin()/end(). */ -class EXPCL_PANDAEGG EggVertexPool : public EggNode { +class EXPCL_PANDA_EGG EggVertexPool : public EggNode { // This is a bit of private interface stuff that must be here as a forward // reference. This allows us to define the EggVertexPool as an STL diff --git a/panda/src/egg/eggVertexUV.h b/panda/src/egg/eggVertexUV.h index 2483432aa9..2ab0447639 100644 --- a/panda/src/egg/eggVertexUV.h +++ b/panda/src/egg/eggVertexUV.h @@ -26,7 +26,7 @@ * multitexturing, there may be multiple sets of UV's on a particular vertex, * each with its own name. */ -class EXPCL_PANDAEGG EggVertexUV : public EggNamedObject { +class EXPCL_PANDA_EGG EggVertexUV : public EggNamedObject { PUBLISHED: explicit EggVertexUV(const std::string &name, const LTexCoordd &uv); explicit EggVertexUV(const std::string &name, const LTexCoord3d &uvw); diff --git a/panda/src/egg/eggXfmAnimData.h b/panda/src/egg/eggXfmAnimData.h index 412b586b73..1fdaec39fe 100644 --- a/panda/src/egg/eggXfmAnimData.h +++ b/panda/src/egg/eggXfmAnimData.h @@ -26,7 +26,7 @@ * is an older syntax of egg anim table, not often used currently--it's * replaced by EggXfmSAnim. */ -class EXPCL_PANDAEGG EggXfmAnimData : public EggAnimData { +class EXPCL_PANDA_EGG EggXfmAnimData : public EggAnimData { PUBLISHED: INLINE explicit EggXfmAnimData(const std::string &name = "", CoordinateSystem cs = CS_default); diff --git a/panda/src/egg/eggXfmSAnim.h b/panda/src/egg/eggXfmSAnim.h index 508f0cd67d..1fd37c51ad 100644 --- a/panda/src/egg/eggXfmSAnim.h +++ b/panda/src/egg/eggXfmSAnim.h @@ -25,7 +25,7 @@ class EggXfmAnimData; * It's implemented as a group that can contain any number of EggSAnimData * children. */ -class EXPCL_PANDAEGG EggXfmSAnim : public EggGroupNode { +class EXPCL_PANDA_EGG EggXfmSAnim : public EggGroupNode { PUBLISHED: INLINE explicit EggXfmSAnim(const std::string &name = "", CoordinateSystem cs = CS_default); diff --git a/panda/src/egg/parserDefs.h b/panda/src/egg/parserDefs.h index df91568015..b20cba96db 100644 --- a/panda/src/egg/parserDefs.h +++ b/panda/src/egg/parserDefs.h @@ -40,7 +40,7 @@ void egg_cleanup_parser(); // that has member functions in a union), so we'll use a class instead. That // means we need to declare it externally, here. -class EXPCL_PANDAEGG EggTokenType { +class EXPCL_PANDA_EGG EggTokenType { public: double _number; unsigned long _ulong; diff --git a/panda/src/egg/pt_EggMaterial.h b/panda/src/egg/pt_EggMaterial.h index 7c5e5f083e..6427434da9 100644 --- a/panda/src/egg/pt_EggMaterial.h +++ b/panda/src/egg/pt_EggMaterial.h @@ -24,9 +24,9 @@ * the template class. It's not strictly necessary, but it doesn't hurt. */ -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerTo) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerTo) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, PointerToBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, PointerTo) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, ConstPointerTo) typedef PointerTo PT_EggMaterial; typedef ConstPointerTo CPT_EggMaterial; diff --git a/panda/src/egg/pt_EggTexture.h b/panda/src/egg/pt_EggTexture.h index bc61025fb6..5138a7f25b 100644 --- a/panda/src/egg/pt_EggTexture.h +++ b/panda/src/egg/pt_EggTexture.h @@ -24,9 +24,9 @@ * template class. It's not strictly necessary, but it doesn't hurt. */ -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerTo) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerTo) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, PointerToBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, PointerTo) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, ConstPointerTo) typedef PointerTo PT_EggTexture; typedef ConstPointerTo CPT_EggTexture; diff --git a/panda/src/egg/pt_EggVertex.h b/panda/src/egg/pt_EggVertex.h index 5c2922b51d..8ff72c3a96 100644 --- a/panda/src/egg/pt_EggVertex.h +++ b/panda/src/egg/pt_EggVertex.h @@ -24,9 +24,9 @@ * template class. It's not strictly necessary, but it doesn't hurt. */ -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerTo) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerTo) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, PointerToBase) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, PointerTo) +EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EGG, EXPTP_PANDA_EGG, ConstPointerTo) typedef PointerTo PT_EggVertex; typedef ConstPointerTo CPT_EggVertex; diff --git a/panda/src/egg/vector_PT_EggMaterial.h b/panda/src/egg/vector_PT_EggMaterial.h index 0878ba71c0..d1bb90ada9 100644 --- a/panda/src/egg/vector_PT_EggMaterial.h +++ b/panda/src/egg/vector_PT_EggMaterial.h @@ -28,8 +28,8 @@ * file, rather than defining the vector again. */ -#define EXPCL EXPCL_PANDAEGG -#define EXPTP EXPTP_PANDAEGG +#define EXPCL EXPCL_PANDA_EGG +#define EXPTP EXPTP_PANDA_EGG #define TYPE PT_EggMaterial #define NAME vector_PT_EggMaterial diff --git a/panda/src/egg/vector_PT_EggTexture.h b/panda/src/egg/vector_PT_EggTexture.h index 12d5f91212..062d24347c 100644 --- a/panda/src/egg/vector_PT_EggTexture.h +++ b/panda/src/egg/vector_PT_EggTexture.h @@ -28,8 +28,8 @@ * file, rather than defining the vector again. */ -#define EXPCL EXPCL_PANDAEGG -#define EXPTP EXPTP_PANDAEGG +#define EXPCL EXPCL_PANDA_EGG +#define EXPTP EXPTP_PANDA_EGG #define TYPE PT_EggTexture #define NAME vector_PT_EggTexture diff --git a/panda/src/egg/vector_PT_EggVertex.cxx b/panda/src/egg/vector_PT_EggVertex.cxx index 61deffdeac..e02586491c 100644 --- a/panda/src/egg/vector_PT_EggVertex.cxx +++ b/panda/src/egg/vector_PT_EggVertex.cxx @@ -13,8 +13,8 @@ #include "vector_PT_EggVertex.h" -#define EXPCL EXPCL_PANDAEGG -#define EXPTP EXPTP_PANDAEGG +#define EXPCL EXPCL_PANDA_EGG +#define EXPTP EXPTP_PANDA_EGG #define TYPE PT_EggVertex #define NAME vector_PT_EggVertex diff --git a/panda/src/egg/vector_PT_EggVertex.h b/panda/src/egg/vector_PT_EggVertex.h index 8d04bccc17..b8e8290179 100644 --- a/panda/src/egg/vector_PT_EggVertex.h +++ b/panda/src/egg/vector_PT_EggVertex.h @@ -28,8 +28,8 @@ * rather than defining the vector again. */ -#define EXPCL EXPCL_PANDAEGG -#define EXPTP EXPTP_PANDAEGG +#define EXPCL EXPCL_PANDA_EGG +#define EXPTP EXPTP_PANDA_EGG #define TYPE PT_EggVertex #define NAME vector_PT_EggVertex diff --git a/panda/src/egg2pg/animBundleMaker.h b/panda/src/egg2pg/animBundleMaker.h index 62a8e1f7bf..5f19d92f8d 100644 --- a/panda/src/egg2pg/animBundleMaker.h +++ b/panda/src/egg2pg/animBundleMaker.h @@ -32,7 +32,7 @@ class AnimChannelMatrixXfmTable; * Converts an EggTable hierarchy, beginning with a entry, into an * AnimBundle hierarchy. */ -class EXPCL_PANDAEGG AnimBundleMaker { +class EXPCL_PANDA_EGG2PG AnimBundleMaker { public: explicit AnimBundleMaker(EggTable *root); diff --git a/panda/src/egg2pg/characterMaker.h b/panda/src/egg2pg/characterMaker.h index 466f890f36..21163010a9 100644 --- a/panda/src/egg2pg/characterMaker.h +++ b/panda/src/egg2pg/characterMaker.h @@ -42,7 +42,7 @@ class PandaNode; * Converts an EggGroup hierarchy, beginning with a group with set, to * a character node with joints. */ -class EXPCL_PANDAEGG CharacterMaker { +class EXPCL_PANDA_EGG2PG CharacterMaker { public: CharacterMaker(EggGroup *root, EggLoader &loader, bool structured = false); diff --git a/panda/src/egg2pg/config_egg2pg.cxx b/panda/src/egg2pg/config_egg2pg.cxx index f864a8f4d8..36247ad2c4 100644 --- a/panda/src/egg2pg/config_egg2pg.cxx +++ b/panda/src/egg2pg/config_egg2pg.cxx @@ -20,8 +20,8 @@ #include "configVariableCore.h" #include "eggRenderState.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAEGG) - #error Buildsystem error: BUILDING_PANDAEGG not defined +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EGG2PG) + #error Buildsystem error: BUILDING_PANDA_EGG2PG not defined #endif ConfigureDef(config_egg2pg); diff --git a/panda/src/egg2pg/config_egg2pg.h b/panda/src/egg2pg/config_egg2pg.h index 874d413319..e9e0e202d6 100644 --- a/panda/src/egg2pg/config_egg2pg.h +++ b/panda/src/egg2pg/config_egg2pg.h @@ -25,36 +25,36 @@ #include "configVariableInt.h" #include "dconfig.h" -ConfigureDecl(config_egg2pg, EXPCL_PANDAEGG, EXPTP_PANDAEGG); -NotifyCategoryDecl(egg2pg, EXPCL_PANDAEGG, EXPTP_PANDAEGG); +ConfigureDecl(config_egg2pg, EXPCL_PANDA_EGG2PG, EXPTP_PANDA_EGG2PG); +NotifyCategoryDecl(egg2pg, EXPCL_PANDA_EGG2PG, EXPTP_PANDA_EGG2PG); -extern EXPCL_PANDAEGG ConfigVariableDouble egg_normal_scale; -extern EXPCL_PANDAEGG ConfigVariableBool egg_show_normals; -extern EXPCL_PANDAEGG ConfigVariableEnum egg_coordinate_system; -extern EXPCL_PANDAEGG ConfigVariableBool egg_ignore_mipmaps; -extern EXPCL_PANDAEGG ConfigVariableBool egg_ignore_filters; -extern EXPCL_PANDAEGG ConfigVariableBool egg_ignore_clamp; -extern EXPCL_PANDAEGG ConfigVariableBool egg_ignore_decals; -extern EXPCL_PANDAEGG ConfigVariableBool egg_flatten; -extern EXPCL_PANDAEGG ConfigVariableDouble egg_flatten_radius; -extern EXPCL_PANDAEGG ConfigVariableBool egg_unify; -extern EXPCL_PANDAEGG ConfigVariableBool egg_combine_geoms; -extern EXPCL_PANDAEGG ConfigVariableBool egg_rigid_geometry; -extern EXPCL_PANDAEGG ConfigVariableBool egg_flat_shading; -extern EXPCL_PANDAEGG ConfigVariableBool egg_flat_colors; -extern EXPCL_PANDAEGG ConfigVariableBool egg_load_old_curves; -extern EXPCL_PANDAEGG ConfigVariableBool egg_load_classic_nurbs_curves; -extern EXPCL_PANDAEGG ConfigVariableBool egg_accept_errors; -extern EXPCL_PANDAEGG ConfigVariableBool egg_suppress_hidden; -extern EXPCL_PANDAEGG ConfigVariableEnum egg_alpha_mode; -extern EXPCL_PANDAEGG ConfigVariableInt egg_max_vertices; -extern EXPCL_PANDAEGG ConfigVariableInt egg_max_indices; -extern EXPCL_PANDAEGG ConfigVariableBool egg_emulate_bface; -extern EXPCL_PANDAEGG ConfigVariableBool egg_preload_simple_textures; -extern EXPCL_PANDAEGG ConfigVariableDouble egg_vertex_membership_quantize; -extern EXPCL_PANDAEGG ConfigVariableInt egg_vertex_max_num_joints; -extern EXPCL_PANDAEGG ConfigVariableBool egg_implicit_alpha_binary; +extern EXPCL_PANDA_EGG2PG ConfigVariableDouble egg_normal_scale; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_show_normals; +extern EXPCL_PANDA_EGG2PG ConfigVariableEnum egg_coordinate_system; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_ignore_mipmaps; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_ignore_filters; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_ignore_clamp; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_ignore_decals; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_flatten; +extern EXPCL_PANDA_EGG2PG ConfigVariableDouble egg_flatten_radius; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_unify; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_combine_geoms; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_rigid_geometry; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_flat_shading; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_flat_colors; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_load_old_curves; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_load_classic_nurbs_curves; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_accept_errors; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_suppress_hidden; +extern EXPCL_PANDA_EGG2PG ConfigVariableEnum egg_alpha_mode; +extern EXPCL_PANDA_EGG2PG ConfigVariableInt egg_max_vertices; +extern EXPCL_PANDA_EGG2PG ConfigVariableInt egg_max_indices; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_emulate_bface; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_preload_simple_textures; +extern EXPCL_PANDA_EGG2PG ConfigVariableDouble egg_vertex_membership_quantize; +extern EXPCL_PANDA_EGG2PG ConfigVariableInt egg_vertex_max_num_joints; +extern EXPCL_PANDA_EGG2PG ConfigVariableBool egg_implicit_alpha_binary; -extern EXPCL_PANDAEGG void init_libegg2pg(); +extern EXPCL_PANDA_EGG2PG void init_libegg2pg(); #endif diff --git a/panda/src/egg2pg/egg_parametrics.h b/panda/src/egg2pg/egg_parametrics.h index 639561dc0e..a18ab4db61 100644 --- a/panda/src/egg2pg/egg_parametrics.h +++ b/panda/src/egg2pg/egg_parametrics.h @@ -29,7 +29,7 @@ BEGIN_PUBLISH * the object is invalid. If there is vertex color, it will be applied to * values 0 - 3 of the extended vertex values. */ -EXPCL_PANDAEGG PT(NurbsSurfaceEvaluator) +EXPCL_PANDA_EGG2PG PT(NurbsSurfaceEvaluator) make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat); /** @@ -38,7 +38,7 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat); * object is invalid. If there is vertex color, it will be applied to values * 0 - 3 of the extended vertex values. */ -EXPCL_PANDAEGG PT(NurbsCurveEvaluator) +EXPCL_PANDA_EGG2PG PT(NurbsCurveEvaluator) make_nurbs_curve(EggNurbsCurve *egg_curve, const LMatrix4d &mat); END_PUBLISH diff --git a/panda/src/egg2pg/load_egg_file.h b/panda/src/egg2pg/load_egg_file.h index 45ea636f94..9bfafbbcc5 100644 --- a/panda/src/egg2pg/load_egg_file.h +++ b/panda/src/egg2pg/load_egg_file.h @@ -31,7 +31,7 @@ BEGIN_PUBLISH * Also see the EggLoader class, which can exercise a bit more manual control * over the loading process. */ -EXPCL_PANDAEGG PT(PandaNode) +EXPCL_PANDA_EGG2PG PT(PandaNode) load_egg_file(const Filename &filename, CoordinateSystem cs = CS_default, BamCacheRecord *record = nullptr); @@ -40,7 +40,7 @@ load_egg_file(const Filename &filename, CoordinateSystem cs = CS_default, * already-filled EggData structure. The structure is destroyed in the * loading. */ -EXPCL_PANDAEGG PT(PandaNode) +EXPCL_PANDA_EGG2PG PT(PandaNode) load_egg_data(EggData *data, CoordinateSystem cs = CS_default); END_PUBLISH diff --git a/panda/src/egg2pg/loaderFileTypeEgg.h b/panda/src/egg2pg/loaderFileTypeEgg.h index a0ca9474ed..a719fc0323 100644 --- a/panda/src/egg2pg/loaderFileTypeEgg.h +++ b/panda/src/egg2pg/loaderFileTypeEgg.h @@ -21,7 +21,7 @@ /** * This defines the Loader interface to read Egg files. */ -class EXPCL_PANDAEGG LoaderFileTypeEgg : public LoaderFileType { +class EXPCL_PANDA_EGG2PG LoaderFileTypeEgg : public LoaderFileType { public: LoaderFileTypeEgg(); diff --git a/panda/src/egg2pg/save_egg_file.h b/panda/src/egg2pg/save_egg_file.h index 0c522cffa0..0804cfc01a 100644 --- a/panda/src/egg2pg/save_egg_file.h +++ b/panda/src/egg2pg/save_egg_file.h @@ -25,7 +25,7 @@ BEGIN_PUBLISH * A convenience function; converts the indicated scene graph to an egg file * and writes it to disk. */ -EXPCL_PANDAEGG bool +EXPCL_PANDA_EGG2PG bool save_egg_file(const Filename &filename, PandaNode *node, CoordinateSystem cs = CS_default); @@ -33,7 +33,7 @@ save_egg_file(const Filename &filename, PandaNode *node, * Another convenience function; works like save_egg_file() but populates an * EggData instead of writing the results to disk. */ -EXPCL_PANDAEGG bool +EXPCL_PANDA_EGG2PG bool save_egg_data(EggData *data, PandaNode *node); END_PUBLISH diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index d0f7fd19f0..5d5d78ef75 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -105,6 +105,12 @@ #define BUILDING_PANDA_TFORM #endif +/* BUILDING_PANDAEGG for these: */ +#ifdef BUILDING_PANDAEGG + #define BUILDING_PANDA_EGG + #define BUILDING_PANDA_EGG2PG +#endif + /* BUILDING_PANDAEXPRESS for these: */ #ifdef BUILDING_PANDAEXPRESS #define BUILDING_PANDA_DOWNLOADER @@ -205,6 +211,22 @@ #define EXPTP_PANDA_DXML IMPORT_TEMPL #endif +#ifdef BUILDING_PANDA_EGG + #define EXPCL_PANDA_EGG EXPORT_CLASS + #define EXPTP_PANDA_EGG EXPORT_TEMPL +#else + #define EXPCL_PANDA_EGG IMPORT_CLASS + #define EXPTP_PANDA_EGG IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_EGG2PG + #define EXPCL_PANDA_EGG2PG EXPORT_CLASS + #define EXPTP_PANDA_EGG2PG EXPORT_TEMPL +#else + #define EXPCL_PANDA_EGG2PG IMPORT_CLASS + #define EXPTP_PANDA_EGG2PG IMPORT_TEMPL +#endif + #ifdef BUILDING_PANDA_EVENT #define EXPCL_PANDA_EVENT EXPORT_CLASS #define EXPTP_PANDA_EVENT EXPORT_TEMPL From a971bc1dfcf5e07f74be4b28c19ee276c39056d8 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 10 Jun 2018 20:27:23 -0600 Subject: [PATCH 013/360] general: Break apart BUILDING_PANDAGL --- panda/src/cocoadisplay/config_cocoadisplay.h | 4 +- panda/src/cocoadisplay/config_cocoadisplay.mm | 4 +- panda/src/framework/pandaFramework.cxx | 2 +- panda/src/glgsg/config_glgsg.cxx | 4 +- panda/src/glgsg/config_glgsg.h | 6 +- panda/src/glgsg/glgsg.h | 4 +- panda/src/glstuff/glmisc_src.h | 6 +- panda/src/glxdisplay/config_glxdisplay.cxx | 4 +- panda/src/glxdisplay/config_glxdisplay.h | 4 +- panda/src/osxdisplay/config_osxdisplay.cxx | 4 +- panda/src/osxdisplay/config_osxdisplay.h | 4 +- panda/src/osxdisplay/osxGraphicsPipe.h | 2 +- panda/src/pandabase/pandasymbols.h | 65 ++++++++++++++++--- panda/src/wgldisplay/config_wgldisplay.cxx | 4 +- panda/src/wgldisplay/config_wgldisplay.h | 4 +- panda/src/wgldisplay/wglGraphicsBuffer.h | 2 +- panda/src/wgldisplay/wglGraphicsPipe.h | 2 +- panda/src/wgldisplay/wglGraphicsWindow.h | 2 +- 18 files changed, 88 insertions(+), 39 deletions(-) diff --git a/panda/src/cocoadisplay/config_cocoadisplay.h b/panda/src/cocoadisplay/config_cocoadisplay.h index a5ed970b8f..43a0e057c3 100644 --- a/panda/src/cocoadisplay/config_cocoadisplay.h +++ b/panda/src/cocoadisplay/config_cocoadisplay.h @@ -18,8 +18,8 @@ #include "notifyCategoryProxy.h" #include "configVariableBool.h" -NotifyCategoryDecl(cocoadisplay, EXPCL_PANDAGL, EXPTP_PANDAGL); +NotifyCategoryDecl(cocoadisplay, EXPCL_PANDA_COCOADISPLAY, EXPTP_PANDA_COCOADISPLAY); -extern EXPCL_PANDAGL void init_libcocoadisplay(); +extern EXPCL_PANDA_COCOADISPLAY void init_libcocoadisplay(); #endif diff --git a/panda/src/cocoadisplay/config_cocoadisplay.mm b/panda/src/cocoadisplay/config_cocoadisplay.mm index c88177cf66..a41e5bc579 100644 --- a/panda/src/cocoadisplay/config_cocoadisplay.mm +++ b/panda/src/cocoadisplay/config_cocoadisplay.mm @@ -20,8 +20,8 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) - #error Buildsystem error: BUILDING_PANDAGL not defined +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_COCOADISPLAY) + #error Buildsystem error: BUILDING_PANDA_COCOADISPLAY not defined #endif Configure(config_cocoadisplay); diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 26f5f2d3ce..9179aa02f4 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -91,7 +91,7 @@ open_framework(int &argc, char **&argv) { // If we're statically linking, we need to explicitly link with at least one // of the available renderers. #if defined(HAVE_GL) - extern EXPCL_PANDAGL void init_libpandagl(); + extern void init_libpandagl(); init_libpandagl(); #elif defined(HAVE_DX9) extern EXPCL_PANDADX void init_libpandadx9(); diff --git a/panda/src/glgsg/config_glgsg.cxx b/panda/src/glgsg/config_glgsg.cxx index 6e60169acc..1c7ddcbfd5 100644 --- a/panda/src/glgsg/config_glgsg.cxx +++ b/panda/src/glgsg/config_glgsg.cxx @@ -16,8 +16,8 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) - #error Buildsystem error: BUILDING_PANDAGL not defined +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GLGSG) + #error Buildsystem error: BUILDING_PANDA_GLGSG not defined #endif ConfigureDef(config_glgsg); diff --git a/panda/src/glgsg/config_glgsg.h b/panda/src/glgsg/config_glgsg.h index 87220333ed..e2beef8e52 100644 --- a/panda/src/glgsg/config_glgsg.h +++ b/panda/src/glgsg/config_glgsg.h @@ -18,9 +18,9 @@ #include "notifyCategoryProxy.h" #include "dconfig.h" -ConfigureDecl(config_glgsg, EXPCL_PANDAGL, EXPTP_PANDAGL); -NotifyCategoryDecl(glgsg, EXPCL_PANDAGL, EXPTP_PANDAGL); +ConfigureDecl(config_glgsg, EXPCL_PANDA_GLGSG, EXPTP_PANDA_GLGSG); +NotifyCategoryDecl(glgsg, EXPCL_PANDA_GLGSG, EXPTP_PANDA_GLGSG); -extern EXPCL_PANDAGL void init_libglgsg(); +extern EXPCL_PANDA_GLGSG void init_libglgsg(); #endif diff --git a/panda/src/glgsg/glgsg.h b/panda/src/glgsg/glgsg.h index 713ce9e862..b225466ab0 100644 --- a/panda/src/glgsg/glgsg.h +++ b/panda/src/glgsg/glgsg.h @@ -37,8 +37,8 @@ #define GLSYSTEM_NAME "OpenGL" #define CONFIGOBJ config_glgsg #define GLCAT glgsg_cat -#define EXPCL_GL EXPCL_PANDAGL -#define EXPTP_GL EXPTP_PANDAGL +#define EXPCL_GL EXPCL_PANDA_GLGSG +#define EXPTP_GL EXPTP_PANDA_GLGSG #if MIN_GL_VERSION_MAJOR > 1 || (MIN_GL_VERSION_MAJOR == 1 && MIN_GL_VERSION_MINOR >= 2) #define EXPECT_GL_VERSION_1_2 diff --git a/panda/src/glstuff/glmisc_src.h b/panda/src/glstuff/glmisc_src.h index 5ba0b35d20..3c6dd81e7b 100644 --- a/panda/src/glstuff/glmisc_src.h +++ b/panda/src/glstuff/glmisc_src.h @@ -40,8 +40,8 @@ // #define GSG_VERBOSE 1 -extern ConfigVariableInt gl_version; -extern EXPCL_PANDAGL ConfigVariableBool gl_support_fbo; +extern EXPCL_GL ConfigVariableInt gl_version; +extern EXPCL_GL ConfigVariableBool gl_support_fbo; extern ConfigVariableBool gl_cheap_textures; extern ConfigVariableBool gl_ignore_clamp; extern ConfigVariableBool gl_support_clamp_to_border; @@ -58,7 +58,7 @@ extern ConfigVariableBool gl_interleaved_arrays; extern ConfigVariableBool gl_parallel_arrays; extern ConfigVariableInt gl_max_errors; extern ConfigVariableEnum gl_min_buffer_usage_hint; -extern ConfigVariableBool gl_debug; +extern EXPCL_GL ConfigVariableBool gl_debug; extern ConfigVariableBool gl_debug_synchronous; extern ConfigVariableEnum gl_debug_abort_level; extern ConfigVariableBool gl_debug_object_labels; diff --git a/panda/src/glxdisplay/config_glxdisplay.cxx b/panda/src/glxdisplay/config_glxdisplay.cxx index fffcd2c264..23b8aef8fa 100644 --- a/panda/src/glxdisplay/config_glxdisplay.cxx +++ b/panda/src/glxdisplay/config_glxdisplay.cxx @@ -23,8 +23,8 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) - #error Buildsystem error: BUILDING_PANDAGL not defined +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GLXDISPLAY) + #error Buildsystem error: BUILDING_PANDA_GLXDISPLAY not defined #endif Configure(config_glxdisplay); diff --git a/panda/src/glxdisplay/config_glxdisplay.h b/panda/src/glxdisplay/config_glxdisplay.h index 7c8aadc3b9..9cabb2de39 100644 --- a/panda/src/glxdisplay/config_glxdisplay.h +++ b/panda/src/glxdisplay/config_glxdisplay.h @@ -20,9 +20,9 @@ #include "configVariableBool.h" #include "configVariableInt.h" -NotifyCategoryDecl(glxdisplay, EXPCL_PANDAGL, EXPTP_PANDAGL); +NotifyCategoryDecl(glxdisplay, EXPCL_PANDA_GLXDISPLAY, EXPTP_PANDA_GLXDISPLAY); -extern EXPCL_PANDAGL void init_libglxdisplay(); +extern EXPCL_PANDA_GLXDISPLAY void init_libglxdisplay(); extern ConfigVariableBool glx_get_proc_address; extern ConfigVariableBool glx_get_os_address; diff --git a/panda/src/osxdisplay/config_osxdisplay.cxx b/panda/src/osxdisplay/config_osxdisplay.cxx index 4ac68f5e58..43f897b862 100644 --- a/panda/src/osxdisplay/config_osxdisplay.cxx +++ b/panda/src/osxdisplay/config_osxdisplay.cxx @@ -20,8 +20,8 @@ #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) - #error Buildsystem error: BUILDING_PANDAGL not defined +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_OSXDISPLAY) + #error Buildsystem error: BUILDING_PANDA_OSXDISPLAY not defined #endif Configure(config_osxdisplay); diff --git a/panda/src/osxdisplay/config_osxdisplay.h b/panda/src/osxdisplay/config_osxdisplay.h index cedaff1e3e..5eadc80a7e 100644 --- a/panda/src/osxdisplay/config_osxdisplay.h +++ b/panda/src/osxdisplay/config_osxdisplay.h @@ -17,9 +17,9 @@ #include "configVariableBool.h" #include "configVariableInt.h" -NotifyCategoryDecl( osxdisplay , EXPCL_PANDAGL, EXPTP_PANDAGL); +NotifyCategoryDecl( osxdisplay , EXPCL_PANDA_OSXDISPLAY, EXPTP_PANDA_OSXDISPLAY); -extern EXPCL_PANDAGL void init_libosxdisplay(); +extern EXPCL_PANDA_OSXDISPLAY void init_libosxdisplay(); extern ConfigVariableBool show_resize_box; extern ConfigVariableBool osx_support_gl_buffer; diff --git a/panda/src/osxdisplay/osxGraphicsPipe.h b/panda/src/osxdisplay/osxGraphicsPipe.h index 02cc60576c..75094778d6 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.h +++ b/panda/src/osxdisplay/osxGraphicsPipe.h @@ -24,7 +24,7 @@ class PNMImage; * This graphics pipe represents the interface for creating OpenGL graphics * windows on the various OSX's. */ -class EXPCL_PANDAGL osxGraphicsPipe : public GraphicsPipe { +class EXPCL_PANDA_OSXDISPLAY osxGraphicsPipe : public GraphicsPipe { public: osxGraphicsPipe(); virtual ~osxGraphicsPipe(); diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index 5d5d78ef75..ef83b4314e 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -117,6 +117,15 @@ #define BUILDING_PANDA_EXPRESS #endif +/* BUILDING_PANDAGL for these: */ +#ifdef BUILDING_PANDAGL + #define BUILDING_PANDA_COCOADISPLAY + #define BUILDING_PANDA_GLGSG + #define BUILDING_PANDA_GLXDISPLAY + #define BUILDING_PANDA_OSXDISPLAY + #define BUILDING_PANDA_WGLDISPLAY +#endif + /* BUILDING_PANDAPHYSICS for these: */ #ifdef BUILDING_PANDAPHYSICS #define BUILDING_PANDA_PARTICLESYSTEM @@ -155,6 +164,14 @@ #define EXPTP_PANDA_CHAR IMPORT_TEMPL #endif +#ifdef BUILDING_PANDA_COCOADISPLAY + #define EXPCL_PANDA_COCOADISPLAY EXPORT_CLASS + #define EXPTP_PANDA_COCOADISPLAY EXPORT_TEMPL +#else + #define EXPCL_PANDA_COCOADISPLAY IMPORT_CLASS + #define EXPTP_PANDA_COCOADISPLAY IMPORT_TEMPL +#endif + #ifdef BUILDING_PANDA_COLLIDE #define EXPCL_PANDA_COLLIDE EXPORT_CLASS #define EXPTP_PANDA_COLLIDE EXPORT_TEMPL @@ -243,6 +260,22 @@ #define EXPTP_PANDA_EXPRESS IMPORT_TEMPL #endif +#ifdef BUILDING_PANDA_GLGSG + #define EXPCL_PANDA_GLGSG EXPORT_CLASS + #define EXPTP_PANDA_GLGSG EXPORT_TEMPL +#else + #define EXPCL_PANDA_GLGSG IMPORT_CLASS + #define EXPTP_PANDA_GLGSG IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_GLXDISPLAY + #define EXPCL_PANDA_GLXDISPLAY EXPORT_CLASS + #define EXPTP_PANDA_GLXDISPLAY EXPORT_TEMPL +#else + #define EXPCL_PANDA_GLXDISPLAY IMPORT_CLASS + #define EXPTP_PANDA_GLXDISPLAY IMPORT_TEMPL +#endif + #ifdef BUILDING_PANDA_GOBJ #define EXPCL_PANDA_GOBJ EXPORT_CLASS #define EXPTP_PANDA_GOBJ EXPORT_TEMPL @@ -307,6 +340,14 @@ #define EXPTP_PANDA_NET IMPORT_TEMPL #endif +#ifdef BUILDING_PANDA_OSXDISPLAY + #define EXPCL_PANDA_OSXDISPLAY EXPORT_CLASS + #define EXPTP_PANDA_OSXDISPLAY EXPORT_TEMPL +#else + #define EXPCL_PANDA_OSXDISPLAY IMPORT_CLASS + #define EXPTP_PANDA_OSXDISPLAY IMPORT_TEMPL +#endif + #ifdef BUILDING_PANDA_PARAMETRICS #define EXPCL_PANDA_PARAMETRICS EXPORT_CLASS #define EXPTP_PANDA_PARAMETRICS EXPORT_TEMPL @@ -427,6 +468,14 @@ #define EXPTP_PANDA_TFORM IMPORT_TEMPL #endif +#ifdef BUILDING_PANDA_WGLDISPLAY + #define EXPCL_PANDA_WGLDISPLAY EXPORT_CLASS + #define EXPTP_PANDA_WGLDISPLAY EXPORT_TEMPL +#else + #define EXPCL_PANDA_WGLDISPLAY IMPORT_CLASS + #define EXPTP_PANDA_WGLDISPLAY IMPORT_TEMPL +#endif + #ifdef BUILDING_PANDAAWESOMIUM #define EXPCL_PANDAAWESOMIUM EXPORT_CLASS #define EXPTP_PANDAAWESOMIUM EXPORT_TEMPL @@ -435,6 +484,14 @@ #define EXPTP_PANDAAWESOMIUM IMPORT_TEMPL #endif +#ifdef BUILDING_PANDAGL + #define EXPCL_PANDAGL EXPORT_CLASS + #define EXPTP_PANDAGL EXPORT_TEMPL +#else + #define EXPCL_PANDAGL IMPORT_CLASS + #define EXPTP_PANDAGL IMPORT_TEMPL +#endif + #ifdef BUILDING_PANDABULLET #define EXPCL_PANDABULLET EXPORT_CLASS #define EXPTP_PANDABULLET EXPORT_TEMPL @@ -467,14 +524,6 @@ #define EXPTP_PANDAFX IMPORT_TEMPL #endif -#ifdef BUILDING_PANDAGL - #define EXPCL_PANDAGL EXPORT_CLASS - #define EXPTP_PANDAGL EXPORT_TEMPL -#else - #define EXPCL_PANDAGL IMPORT_CLASS - #define EXPTP_PANDAGL IMPORT_TEMPL -#endif - #ifdef BUILDING_PANDAGLES #define EXPCL_PANDAGLES EXPORT_CLASS #define EXPTP_PANDAGLES EXPORT_TEMPL diff --git a/panda/src/wgldisplay/config_wgldisplay.cxx b/panda/src/wgldisplay/config_wgldisplay.cxx index 93dc2ad36c..fa04606dca 100644 --- a/panda/src/wgldisplay/config_wgldisplay.cxx +++ b/panda/src/wgldisplay/config_wgldisplay.cxx @@ -20,8 +20,8 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) - #error Buildsystem error: BUILDING_PANDAGL not defined +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_WGLDISPLAY) + #error Buildsystem error: BUILDING_PANDA_WGLDISPLAY not defined #endif Configure(config_wgldisplay); diff --git a/panda/src/wgldisplay/config_wgldisplay.h b/panda/src/wgldisplay/config_wgldisplay.h index 400b565bbd..e4c2096b5e 100644 --- a/panda/src/wgldisplay/config_wgldisplay.h +++ b/panda/src/wgldisplay/config_wgldisplay.h @@ -19,12 +19,12 @@ #include "configVariableInt.h" #include "configVariableBool.h" -NotifyCategoryDecl(wgldisplay, EXPCL_PANDAGL, EXPTP_PANDAGL); +NotifyCategoryDecl(wgldisplay, EXPCL_PANDA_WGLDISPLAY, EXPTP_PANDA_WGLDISPLAY); extern ConfigVariableInt gl_force_pixfmt; extern ConfigVariableBool gl_force_invalid; extern ConfigVariableBool gl_do_vidmemsize_check; -extern EXPCL_PANDAGL void init_libwgldisplay(); +extern EXPCL_PANDA_WGLDISPLAY void init_libwgldisplay(); #endif diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.h b/panda/src/wgldisplay/wglGraphicsBuffer.h index 594adc921d..3560d3f4b5 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.h +++ b/panda/src/wgldisplay/wglGraphicsBuffer.h @@ -32,7 +32,7 @@ * we can use, and thus makes it difficult to support one GSG rendering into * an offscreen buffer and also into a window. */ -class EXPCL_PANDAGL wglGraphicsBuffer : public GraphicsBuffer { +class EXPCL_PANDA_WGLDISPLAY wglGraphicsBuffer : public GraphicsBuffer { public: wglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const std::string &name, diff --git a/panda/src/wgldisplay/wglGraphicsPipe.h b/panda/src/wgldisplay/wglGraphicsPipe.h index 892a8f8884..176483f92c 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.h +++ b/panda/src/wgldisplay/wglGraphicsPipe.h @@ -23,7 +23,7 @@ class wglGraphicsStateGuardian; * This graphics pipe represents the interface for creating OpenGL graphics * windows on the various Windows OSes. */ -class EXPCL_PANDAGL wglGraphicsPipe : public WinGraphicsPipe { +class EXPCL_PANDA_WGLDISPLAY wglGraphicsPipe : public WinGraphicsPipe { public: wglGraphicsPipe(); virtual ~wglGraphicsPipe(); diff --git a/panda/src/wgldisplay/wglGraphicsWindow.h b/panda/src/wgldisplay/wglGraphicsWindow.h index 0db8f9cc73..06a74aa501 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.h +++ b/panda/src/wgldisplay/wglGraphicsWindow.h @@ -20,7 +20,7 @@ /** * A single graphics window for rendering OpenGL under Microsoft Windows. */ -class EXPCL_PANDAGL wglGraphicsWindow : public WinGraphicsWindow { +class EXPCL_PANDA_WGLDISPLAY wglGraphicsWindow : public WinGraphicsWindow { public: wglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const std::string &name, From 69d5fcf3b0af0f81aab1533c3685d78a73d5b481 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 12 Jun 2018 16:13:52 -0600 Subject: [PATCH 014/360] pgraph: Fix use of incomplete GeomNode in PT(GeomNode) --- panda/src/pgraph/cullBin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/pgraph/cullBin.h b/panda/src/pgraph/cullBin.h index 7a104d1f3b..05e0fbb19e 100644 --- a/panda/src/pgraph/cullBin.h +++ b/panda/src/pgraph/cullBin.h @@ -20,6 +20,7 @@ #include "pStatCollector.h" #include "pointerTo.h" #include "luse.h" +#include "geomNode.h" class CullableObject; class GraphicsStateGuardianBase; @@ -27,7 +28,6 @@ class SceneSetup; class TransformState; class RenderState; class PandaNode; -class GeomNode; /** * A collection of Geoms and their associated state, for a particular scene. From d22da73a4ce677a50c5fed45dc0c044576172731 Mon Sep 17 00:00:00 2001 From: Younguk Kim Date: Thu, 14 Jun 2018 09:33:19 +0900 Subject: [PATCH 015/360] Fix macro redefinition warning --- panda/src/express/checksumHashGenerator.I | 2 ++ 1 file changed, 2 insertions(+) diff --git a/panda/src/express/checksumHashGenerator.I b/panda/src/express/checksumHashGenerator.I index ade42717b0..640b02e415 100644 --- a/panda/src/express/checksumHashGenerator.I +++ b/panda/src/express/checksumHashGenerator.I @@ -13,7 +13,9 @@ #ifdef _WIN32 // Needed for PtrToLong, below +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 +#endif #include #endif From 9231694f8f83d580b254fdea47ea6c675e95e4a8 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 14 Jun 2018 14:10:35 +0200 Subject: [PATCH 016/360] gobj: fix Python 3 support for GVADHandle::get_(sub)data/set_(sub)data That said, you should really be using the buffer protocol; you can create a memoryview() directly around the GeomVertexArrayData. --- panda/src/gobj/geomVertexArrayData.I | 10 ++++++---- panda/src/gobj/geomVertexArrayData.cxx | 4 ++-- panda/src/gobj/geomVertexArrayData.h | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index d573489ba6..cfe12f9013 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -518,10 +518,11 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, * a string. This is primarily for the benefit of high-level languages such * as Python. */ -INLINE std::string GeomVertexArrayDataHandle:: +INLINE vector_uchar GeomVertexArrayDataHandle:: get_data() const { mark_used(); - return std::string((const char *)_cdata->_buffer.get_read_pointer(true), _cdata->_buffer.get_size()); + const unsigned char *ptr = _cdata->_buffer.get_read_pointer(true); + return vector_uchar(ptr, ptr + _cdata->_buffer.get_size()); } /** @@ -529,12 +530,13 @@ get_data() const { * formatted as a string. This is primarily for the benefit of high-level * languages such as Python. */ -INLINE std::string GeomVertexArrayDataHandle:: +INLINE vector_uchar GeomVertexArrayDataHandle:: get_subdata(size_t start, size_t size) const { mark_used(); start = std::min(start, _cdata->_buffer.get_size()); size = std::min(size, _cdata->_buffer.get_size() - start); - return std::string((const char *)_cdata->_buffer.get_read_pointer(true) + start, size); + const unsigned char *ptr = _cdata->_buffer.get_read_pointer(true) + start; + return vector_uchar(ptr, ptr + size); } /** diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index 9b4803d3bf..b868fc87e0 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -842,7 +842,7 @@ copy_subdata_from(size_t to_start, size_t to_size, * Python. */ void GeomVertexArrayDataHandle:: -set_data(const string &data) { +set_data(const vector_uchar &data) { nassertv(_writable); mark_used(); @@ -864,7 +864,7 @@ set_data(const string &data) { * This is primarily for the benefit of high-level languages like Python. */ void GeomVertexArrayDataHandle:: -set_subdata(size_t start, size_t size, const string &data) { +set_subdata(size_t start, size_t size, const vector_uchar &data) { nassertv(_writable); mark_used(); diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index 40935563e5..917b27c71a 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -316,10 +316,10 @@ PUBLISHED: PyObject *buffer, size_t from_start, size_t from_size)); - INLINE std::string get_data() const; - void set_data(const std::string &data); - INLINE std::string get_subdata(size_t start, size_t size) const; - void set_subdata(size_t start, size_t size, const std::string &data); + INLINE vector_uchar get_data() const; + void set_data(const vector_uchar &data); + INLINE vector_uchar get_subdata(size_t start, size_t size) const; + void set_subdata(size_t start, size_t size, const vector_uchar &data); INLINE void mark_used() const; From d284cedbea5337a18b5ecb2cdaa94aed79117c47 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 14 Jun 2018 14:19:54 +0200 Subject: [PATCH 017/360] movies/ffmpeg: support grayscale and grayscale-alpha videos Fixes #352 --- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 26 ++++++-- panda/src/grutil/movieTexture.cxx | 7 +- panda/src/movies/movieVideoCursor.cxx | 90 ++++++++++++++++++++------ 3 files changed, 93 insertions(+), 30 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index b7b67a8ecf..2536f85e3c 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -112,13 +112,25 @@ init_from(FfmpegVideo *source) { // Check if we got an alpha format. Please note that some video codecs // (eg. libvpx) change the pix_fmt after decoding the first frame, which is // why we didn't do this earlier. - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(_video_ctx->pix_fmt); - if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA) != 0) { - _num_components = 4; - _pixel_format = (int)AV_PIX_FMT_BGRA; - } else { - _num_components = 3; - _pixel_format = (int)AV_PIX_FMT_BGR24; + switch (_video_ctx->pix_fmt) { + case AV_PIX_FMT_GRAY8: + _num_components = 1; + _pixel_format = (int)AV_PIX_FMT_GRAY8; + break; + case AV_PIX_FMT_YA8: + _num_components = 2; + _pixel_format = (int)AV_PIX_FMT_YA8; + break; + default: + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(_video_ctx->pix_fmt); + if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA) != 0) { + _num_components = 4; + _pixel_format = (int)AV_PIX_FMT_BGRA; + } else { + _num_components = 3; + _pixel_format = (int)AV_PIX_FMT_BGR24; + } + break; } #ifdef HAVE_SWSCALE diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index 44f3d541d4..ab8cb390ef 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -141,6 +141,7 @@ void MovieTexture:: do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const LoaderOptions &options) { int x_max = 1; int y_max = 1; + bool rgb = false; bool alpha = false; double len = 0.0; @@ -150,7 +151,8 @@ do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const L if (t->size_x() > x_max) x_max = t->size_x(); if (t->size_y() > y_max) y_max = t->size_y(); if (t->length() > len) len = t->length(); - if (t->get_num_components() == 4) alpha=true; + if (t->get_num_components() >= 3) rgb=true; + if (t->get_num_components() == 4 || t->get_num_components() == 2) alpha=true; } t = cdata->_pages[i]._alpha; if (t) { @@ -167,7 +169,8 @@ do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const L do_adjust_this_size(cdata_tex, x_max, y_max, get_name(), true); - do_reconsider_image_properties(cdata_tex, x_max, y_max, alpha?4:3, + int num_components = (rgb ? 3 : 1) + alpha; + do_reconsider_image_properties(cdata_tex, x_max, y_max, num_components, T_unsigned_byte, cdata->_pages.size(), options); cdata_tex->_orig_file_x_size = cdata->_video_width; diff --git a/panda/src/movies/movieVideoCursor.cxx b/panda/src/movies/movieVideoCursor.cxx index 761e7e2fa6..96ead8c8f0 100644 --- a/panda/src/movies/movieVideoCursor.cxx +++ b/panda/src/movies/movieVideoCursor.cxx @@ -60,7 +60,21 @@ setup_texture(Texture *tex) const { int fullx = size_x(); int fully = size_y(); tex->adjust_this_size(fullx, fully, tex->get_name(), true); - Texture::Format fmt = (get_num_components() == 4) ? Texture::F_rgba : Texture::F_rgb; + Texture::Format fmt; + switch (get_num_components()) { + case 1: + fmt = Texture::F_luminance; + break; + case 2: + fmt = Texture::F_luminance_alpha; + break; + default: + fmt = Texture::F_rgb; + break; + case 4: + fmt = Texture::F_rgba; + break; + } tex->setup_texture(Texture::TT_2d_texture, fullx, fully, 1, Texture::T_unsigned_byte, fmt); tex->set_pad_size(fullx - size_x(), fully - size_y()); } @@ -113,7 +127,9 @@ apply_to_texture(const Buffer *buffer, Texture *t, int page) { nassertv(t->get_x_size() >= size_x()); nassertv(t->get_y_size() >= size_y()); - nassertv((t->get_num_components() == 3) || (t->get_num_components() == 4)); + nassertv((t->get_num_components() == 3) || (t->get_num_components() == 4) || + (t->get_num_components() == 1 && get_num_components() == 1) || + (t->get_num_components() == 2 && get_num_components() == 2)); nassertv(t->get_component_width() == 1); nassertv(page < t->get_num_pages()); @@ -132,17 +148,19 @@ apply_to_texture(const Buffer *buffer, Texture *t, int page) { } else { unsigned char *p = buffer->_block; - if (t->get_num_components() == get_num_components()) { - int src_stride = size_x() * get_num_components(); - int dst_stride = t->get_x_size() * t->get_num_components(); + int src_width = get_num_components(); + int dst_width = t->get_num_components(); + if (src_width == dst_width) { + int src_stride = src_width * size_x(); + int dst_stride = dst_width * t->get_x_size(); for (int y=0; yget_num_components(); + nassertv(src_width >= 3); + nassertv(dst_width >= 3); for (int y = 0; y < size_y(); ++y) { for (int x = 0; x < size_x(); ++x) { data[0] = p[0]; @@ -168,9 +186,20 @@ apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src PStatTimer timer(_copy_pcollector); + // Is this a grayscale texture? + if (get_num_components() < 3) { + if (get_num_components() == 1 || alpha_src < 2 || alpha_src == 3) { + // There's only one "RGB" channel to take from. + alpha_src = 1; + } else { + // Alpha is actually in the second channel for grayscale-alpha. + alpha_src = 2; + } + } + nassertv(t->get_x_size() >= size_x()); nassertv(t->get_y_size() >= size_y()); - nassertv(t->get_num_components() == 4); + nassertv(t->get_num_components() == 4 || t->get_num_components() == 2); nassertv(t->get_component_width() == 1); nassertv(page < t->get_z_size()); nassertv((alpha_src >= 0) && (alpha_src <= get_num_components())); @@ -186,14 +215,16 @@ apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src PStatTimer timer2(_copy_pcollector_copy); int src_width = get_num_components(); + int dst_width = t->get_num_components(); int src_stride = size_x() * src_width; - int dst_stride = t->get_x_size() * 4; + int dst_stride = t->get_x_size() * dst_width; unsigned char *p = buffer->_block; if (alpha_src == 0) { + nassertv(src_width >= 3); for (int y=0; yget_x_size() >= size_x()); nassertv(t->get_y_size() >= size_y()); - nassertv(t->get_num_components() == 4); + nassertv(t->get_num_components() == 4 || t->get_num_components() == 2); nassertv(t->get_component_width() == 1); nassertv(page < t->get_z_size()); @@ -238,18 +269,35 @@ apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page) { unsigned char *data = img.p() + page * t->get_expected_ram_page_size(); PStatTimer timer2(_copy_pcollector_copy); - int src_stride = size_x() * get_num_components(); int src_width = get_num_components(); - int dst_stride = t->get_x_size() * 4; + int dst_width = t->get_num_components(); + int src_stride = size_x() * src_width; + int dst_stride = t->get_x_size() * dst_width; unsigned char *p = buffer->_block; - for (int y=0; y= 3) { + // It has RGB values. + nassertv(dst_width >= 3); + for (int y = 0; y < size_y(); ++y) { + for (int x = 0; x < size_x(); ++x) { + data[x * dst_width + 0] = p[x * src_width + 0]; + data[x * dst_width + 1] = p[x * src_width + 1]; + data[x * dst_width + 2] = p[x * src_width + 2]; + } + data += dst_stride; + p += src_stride; + } + } else if (dst_width == 4) { + // It has only grayscale. + for (int y = 0; y < size_y(); ++y) { + for (int x = 0; x < size_x(); ++x) { + unsigned char gray = p[x * src_width]; + data[x * dst_width + 0] = gray; + data[x * dst_width + 1] = gray; + data[x * dst_width + 2] = gray; + } + data += dst_stride; + p += src_stride; } - data += dst_stride; - p += src_stride; } } From b2bfb31114a70188928818299aa6fefc70bbed7d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 14 Jun 2018 14:28:08 +0200 Subject: [PATCH 018/360] general: Remove `using std::*` from headers Also remove most `using namespace std;` statements. The only one that remains is in py_panda.h. Closes #350 Closes #335 --- contrib/src/ai/aiBehaviors.cxx | 4 ++ contrib/src/ai/aiCharacter.cxx | 2 +- contrib/src/ai/aiPathFinder.cxx | 2 +- contrib/src/ai/aiWorld.cxx | 10 ++-- contrib/src/ai/arrival.cxx | 2 +- contrib/src/ai/pathFind.cxx | 10 ++-- contrib/src/ai/pathFollow.cxx | 2 +- contrib/src/rplight/gpuCommand.cxx | 8 +-- contrib/src/rplight/iesDataset.cxx | 4 +- contrib/src/rplight/internalLightManager.cxx | 6 ++- contrib/src/rplight/shadowAtlas.cxx | 6 +-- contrib/src/rplight/tagStateManager.cxx | 4 +- direct/src/dcparse/dcparse.cxx | 3 ++ direct/src/dcparser/dcArrayParameter.cxx | 6 ++- direct/src/dcparser/dcAtomicField.cxx | 8 +-- direct/src/dcparser/dcClass.cxx | 10 ++-- direct/src/dcparser/dcClassParameter.cxx | 4 +- direct/src/dcparser/dcDeclaration.cxx | 4 +- direct/src/dcparser/dcField.cxx | 10 ++-- direct/src/dcparser/dcFile.cxx | 9 ++-- direct/src/dcparser/dcKeyword.cxx | 8 +-- direct/src/dcparser/dcKeywordList.cxx | 6 +-- direct/src/dcparser/dcLexer.cxx.prebuilt | 28 +++++----- direct/src/dcparser/dcLexer.lxx | 28 +++++----- direct/src/dcparser/dcMolecularField.cxx | 6 +-- direct/src/dcparser/dcPacker.cxx | 10 +++- direct/src/dcparser/dcPackerCatalog.cxx | 2 + direct/src/dcparser/dcPackerInterface.cxx | 4 +- direct/src/dcparser/dcParameter.cxx | 3 ++ direct/src/dcparser/dcParser.cxx.prebuilt | 4 ++ direct/src/dcparser/dcParser.yxx | 4 ++ direct/src/dcparser/dcSimpleParameter.cxx | 4 +- direct/src/dcparser/dcSubatomicType.cxx | 4 +- direct/src/dcparser/dcSwitch.cxx | 3 ++ direct/src/dcparser/dcSwitchParameter.cxx | 6 ++- direct/src/dcparser/dcTypedef.cxx | 8 +-- direct/src/dcparser/dcindent.cxx | 4 +- direct/src/dcparser/hashGenerator.cxx | 4 +- direct/src/deadrec/smoothMover.cxx | 10 ++-- direct/src/directd/directd.cxx | 7 ++- direct/src/directdServer/directdClient.cxx | 6 +++ direct/src/directdServer/directdServer.cxx | 8 ++- .../src/distributed/cConnectionRepository.cxx | 7 ++- .../cDistributedSmoothNodeBase.cxx | 8 +-- direct/src/interval/cConstrainHprInterval.cxx | 4 +- .../src/interval/cConstrainPosHprInterval.cxx | 4 +- direct/src/interval/cConstrainPosInterval.cxx | 4 +- .../interval/cConstrainTransformInterval.cxx | 4 +- direct/src/interval/cConstraintInterval.cxx | 2 +- direct/src/interval/cInterval.cxx | 5 +- direct/src/interval/cIntervalManager.cxx | 6 +-- .../src/interval/cLerpAnimEffectInterval.cxx | 2 +- direct/src/interval/cLerpInterval.cxx | 4 +- direct/src/interval/cLerpNodePathInterval.cxx | 4 +- direct/src/interval/cMetaInterval.cxx | 10 ++-- direct/src/interval/hideInterval.cxx | 4 +- direct/src/interval/showInterval.cxx | 4 +- direct/src/plugin/binaryXml.cxx | 5 ++ direct/src/plugin/binaryXml.h | 2 - direct/src/plugin/fileSpec.cxx | 9 +++- direct/src/plugin/fileSpec.h | 1 - direct/src/plugin/find_root_dir.cxx | 4 ++ direct/src/plugin/find_root_dir.h | 1 - direct/src/plugin/find_root_dir_assist.mm | 2 +- direct/src/plugin/handleStreamBuf.cxx | 4 ++ direct/src/plugin/handleStreamBuf.h | 2 - direct/src/plugin/load_plugin.cxx | 10 ++-- direct/src/plugin/load_plugin.h | 1 - direct/src/plugin/mkdir_complete.cxx | 4 ++ direct/src/plugin/mkdir_complete.h | 1 - direct/src/plugin/p3dAuthSession.cxx | 8 +-- direct/src/plugin/p3dBoolObject.cxx | 2 +- direct/src/plugin/p3dCert.cxx | 4 ++ direct/src/plugin/p3dCert.h | 1 - direct/src/plugin/p3dCert_wx.cxx | 12 +++-- direct/src/plugin/p3dCert_wx.h | 1 - direct/src/plugin/p3dConcreteSequence.cxx | 8 +-- direct/src/plugin/p3dConcreteStruct.cxx | 6 ++- direct/src/plugin/p3dDownload.cxx | 4 +- direct/src/plugin/p3dFileDownload.cxx | 8 +-- direct/src/plugin/p3dFileParams.cxx | 2 + direct/src/plugin/p3dFloatObject.cxx | 4 +- direct/src/plugin/p3dHost.cxx | 17 ++++--- direct/src/plugin/p3dInstance.cxx | 12 ++++- direct/src/plugin/p3dInstanceManager.cxx | 16 +++--- direct/src/plugin/p3dIntObject.cxx | 4 +- direct/src/plugin/p3dMainObject.cxx | 13 +++-- direct/src/plugin/p3dMultifileReader.cxx | 15 ++++-- direct/src/plugin/p3dNoneObject.cxx | 2 +- direct/src/plugin/p3dObject.cxx | 6 ++- direct/src/plugin/p3dOsxSplashWindow.cxx | 4 +- direct/src/plugin/p3dPackage.cxx | 16 ++++-- direct/src/plugin/p3dPatchFinder.cxx | 4 +- direct/src/plugin/p3dPatchfileReader.cxx | 17 ++++--- direct/src/plugin/p3dPythonMain.cxx | 17 +++---- direct/src/plugin/p3dPythonObject.cxx | 6 ++- direct/src/plugin/p3dPythonRun.cxx | 8 +-- direct/src/plugin/p3dPythonRun.h | 2 - direct/src/plugin/p3dSession.cxx | 15 +++--- direct/src/plugin/p3dSplashWindow.cxx | 4 ++ direct/src/plugin/p3dStringObject.cxx | 8 +-- direct/src/plugin/p3dTemporaryFile.cxx | 2 +- direct/src/plugin/p3dUndefinedObject.cxx | 2 +- direct/src/plugin/p3dWinSplashWindow.cxx | 8 +-- direct/src/plugin/p3dWindowParams.cxx | 2 +- direct/src/plugin/p3dX11SplashWindow.cxx | 9 ++-- direct/src/plugin/p3d_plugin.cxx | 2 +- direct/src/plugin/p3d_plugin_common.h | 2 - direct/src/plugin/parse_color.cxx | 2 +- direct/src/plugin/parse_color.h | 1 - direct/src/plugin/wstring_encode.cxx | 5 +- direct/src/plugin/wstring_encode.h | 1 - direct/src/plugin/xml_helpers.cxx | 2 +- direct/src/plugin_npapi/nppanda3d_common.h | 2 - direct/src/plugin_npapi/ppBrowserObject.cxx | 4 +- direct/src/plugin_npapi/ppInstance.cxx | 14 +++-- direct/src/plugin_npapi/ppPandaObject.cxx | 4 +- direct/src/plugin_npapi/startup.cxx | 14 ++--- direct/src/plugin_standalone/p3dEmbed.cxx | 9 ++-- direct/src/plugin_standalone/panda3d.cxx | 14 +++-- direct/src/plugin_standalone/panda3dBase.cxx | 5 +- direct/src/plugin_standalone/panda3dMac.cxx | 3 +- .../src/plugin_standalone/panda3dWinMain.cxx | 6 +-- direct/src/showbase/showBase.cxx | 7 ++- direct/src/showbase/showBase_assist.mm | 2 +- dtool/src/cppparser/cppArrayType.cxx | 12 ++--- dtool/src/cppparser/cppBison.cxx.prebuilt | 3 ++ dtool/src/cppparser/cppBison.yxx | 3 ++ dtool/src/cppparser/cppBisonDefs.h | 2 - .../cppparser/cppClassTemplateParameter.cxx | 2 +- dtool/src/cppparser/cppClosureType.cxx | 8 +-- dtool/src/cppparser/cppConstType.cxx | 8 +-- dtool/src/cppparser/cppDeclaration.cxx | 4 +- dtool/src/cppparser/cppDeclaration.h | 2 - dtool/src/cppparser/cppEnumType.cxx | 4 +- dtool/src/cppparser/cppExpression.cxx | 11 ++-- dtool/src/cppparser/cppExpressionParser.cxx | 10 ++-- dtool/src/cppparser/cppExtensionType.cxx | 12 ++--- dtool/src/cppparser/cppFile.cxx | 2 + dtool/src/cppparser/cppFunctionGroup.cxx | 4 +- dtool/src/cppparser/cppFunctionType.cxx | 4 ++ dtool/src/cppparser/cppGlobals.cxx | 2 +- dtool/src/cppparser/cppIdentifier.cxx | 8 +-- dtool/src/cppparser/cppInstance.cxx | 6 ++- dtool/src/cppparser/cppInstanceIdentifier.cxx | 10 ++-- dtool/src/cppparser/cppInstanceIdentifier.h | 2 - dtool/src/cppparser/cppMakeProperty.cxx | 8 +-- dtool/src/cppparser/cppMakeSeq.cxx | 8 +-- dtool/src/cppparser/cppManifest.cxx | 4 +- dtool/src/cppparser/cppNameComponent.cxx | 6 ++- dtool/src/cppparser/cppNameComponent.h | 2 - dtool/src/cppparser/cppNamespace.cxx | 8 +-- dtool/src/cppparser/cppParameterList.cxx | 2 +- dtool/src/cppparser/cppParser.cxx | 6 +-- dtool/src/cppparser/cppPointerType.cxx | 10 ++-- dtool/src/cppparser/cppPreprocessor.cxx | 9 ++-- dtool/src/cppparser/cppReferenceType.cxx | 8 +-- dtool/src/cppparser/cppScope.cxx | 5 ++ dtool/src/cppparser/cppScope.h | 2 - dtool/src/cppparser/cppSimpleType.cxx | 4 +- dtool/src/cppparser/cppStructType.cxx | 6 +-- dtool/src/cppparser/cppTBDType.cxx | 8 +-- .../cppparser/cppTemplateParameterList.cxx | 8 +-- dtool/src/cppparser/cppTemplateScope.cxx | 4 +- dtool/src/cppparser/cppToken.cxx | 6 +-- dtool/src/cppparser/cppType.cxx | 10 ++-- dtool/src/cppparser/cppTypeDeclaration.cxx | 2 +- dtool/src/cppparser/cppTypeParser.cxx | 10 ++-- dtool/src/cppparser/cppTypeProxy.cxx | 6 ++- dtool/src/cppparser/cppTypedefType.cxx | 4 +- dtool/src/cppparser/cppUsing.cxx | 2 +- dtool/src/cppparser/cppVisibility.cxx | 4 +- dtool/src/dconfig/test_config.cxx | 3 ++ dtool/src/dconfig/test_expand.cxx | 3 ++ dtool/src/dconfig/test_pfstream.cxx | 4 +- dtool/src/dconfig/test_searchpath.cxx | 3 ++ dtool/src/dtoolbase/deletedBufferChain.cxx | 2 +- dtool/src/dtoolbase/dtoolbase_cc.h | 30 ----------- dtool/src/dtoolbase/indent.cxx | 4 +- dtool/src/dtoolbase/memoryHook.cxx | 4 +- dtool/src/dtoolbase/neverFreeMemory.cxx | 2 +- dtool/src/dtoolbase/pallocator.h | 2 - dtool/src/dtoolbase/pdeque.h | 2 - dtool/src/dtoolbase/plist.h | 2 - dtool/src/dtoolbase/pmap.h | 3 -- dtool/src/dtoolbase/pset.h | 3 -- dtool/src/dtoolbase/pvector.h | 2 - dtool/src/dtoolbase/test_strtod.cxx | 4 +- dtool/src/dtoolbase/typeHandle.cxx | 8 +-- dtool/src/dtoolbase/typeRegistry.cxx | 5 ++ dtool/src/dtoolbase/typeRegistryNode.cxx | 12 ++--- dtool/src/dtoolbase/typedObject.cxx | 2 +- dtool/src/dtoolutil/dSearchPath.cxx | 3 ++ dtool/src/dtoolutil/executionEnvironment.cxx | 9 ++-- dtool/src/dtoolutil/filename.cxx | 11 ++-- dtool/src/dtoolutil/filename_assist.mm | 2 + dtool/src/dtoolutil/filename_ext.cxx | 3 ++ dtool/src/dtoolutil/globPattern.cxx | 2 + dtool/src/dtoolutil/lineStreamBuf.cxx | 6 ++- dtool/src/dtoolutil/load_dso.cxx | 6 ++- dtool/src/dtoolutil/pandaFileStreamBuf.cxx | 12 ++++- dtool/src/dtoolutil/pandaSystem.cxx | 10 ++-- dtool/src/dtoolutil/panda_getopt_impl.cxx | 3 +- dtool/src/dtoolutil/pfstreamBuf.cxx | 10 ++-- dtool/src/dtoolutil/stringDecoder.cxx | 8 +-- dtool/src/dtoolutil/string_utils.cxx | 3 ++ dtool/src/dtoolutil/test_pfstream.cxx | 8 +-- dtool/src/dtoolutil/test_touch.cxx | 2 +- dtool/src/dtoolutil/textEncoder.cxx | 5 ++ dtool/src/dtoolutil/win32ArgParser.cxx | 6 ++- dtool/src/interrogate/functionRemap.cxx | 9 +++- dtool/src/interrogate/functionWriter.cxx | 8 +-- .../functionWriterPtrFromPython.cxx | 4 +- .../interrogate/functionWriterPtrToPython.cxx | 6 +-- dtool/src/interrogate/functionWriters.cxx | 6 +-- dtool/src/interrogate/interfaceMaker.cxx | 4 ++ dtool/src/interrogate/interfaceMakerC.cxx | 8 +-- .../src/interrogate/interfaceMakerPython.cxx | 4 +- .../interfaceMakerPythonNative.cxx | 30 +++++++---- .../interrogate/interfaceMakerPythonObj.cxx | 3 ++ .../interfaceMakerPythonSimple.cxx | 3 ++ dtool/src/interrogate/interrogate.cxx | 3 ++ dtool/src/interrogate/interrogateBuilder.cxx | 9 +++- dtool/src/interrogate/interrogate_module.cxx | 11 ++-- dtool/src/interrogate/parameterRemap.cxx | 6 ++- .../parameterRemapBasicStringPtrToString.cxx | 6 ++- .../parameterRemapBasicStringRefToString.cxx | 6 ++- .../parameterRemapBasicStringToString.cxx | 3 ++ .../parameterRemapConcreteToPointer.cxx | 6 +-- .../parameterRemapConstToNonConst.cxx | 6 +-- .../interrogate/parameterRemapEnumToInt.cxx | 6 +-- .../interrogate/parameterRemapHandleToInt.cxx | 6 +-- .../interrogate/parameterRemapPTToPointer.cxx | 4 +- .../parameterRemapReferenceToConcrete.cxx | 6 +-- .../parameterRemapReferenceToPointer.cxx | 6 +-- dtool/src/interrogate/parameterRemapThis.cxx | 6 +-- .../interrogate/parameterRemapToString.cxx | 6 ++- dtool/src/interrogate/parse_file.cxx | 5 ++ dtool/src/interrogate/typeManager.cxx | 4 +- .../interrogatedb/interrogateComponent.cxx | 8 +-- .../src/interrogatedb/interrogateDatabase.cxx | 9 ++-- .../src/interrogatedb/interrogateElement.cxx | 4 +- .../src/interrogatedb/interrogateFunction.cxx | 4 +- .../interrogateFunctionWrapper.cxx | 3 ++ .../src/interrogatedb/interrogateMakeSeq.cxx | 4 +- .../src/interrogatedb/interrogateManifest.cxx | 4 +- dtool/src/interrogatedb/interrogateType.cxx | 3 ++ .../interrogatedb/interrogate_datafile.cxx | 4 ++ .../interrogatedb/interrogate_interface.cxx | 2 + dtool/src/interrogatedb/py_panda.cxx | 8 +-- dtool/src/interrogatedb/py_wrappers.cxx | 2 +- dtool/src/prc/androidLogStream.cxx | 8 +-- dtool/src/prc/configDeclaration.cxx | 6 ++- dtool/src/prc/configFlags.cxx | 4 +- dtool/src/prc/configPage.cxx | 6 ++- dtool/src/prc/configPageManager.cxx | 10 ++-- dtool/src/prc/configVariableBase.cxx | 4 +- dtool/src/prc/configVariableCore.cxx | 10 ++-- dtool/src/prc/configVariableList.cxx | 4 +- dtool/src/prc/configVariableManager.cxx | 8 +-- dtool/src/prc/configVariableSearchPath.cxx | 2 +- dtool/src/prc/encryptStreamBuf.cxx | 6 +-- dtool/src/prc/notify.cxx | 14 +++-- dtool/src/prc/notifyCategory.cxx | 8 +-- dtool/src/prc/notifySeverity.cxx | 4 ++ dtool/src/prc/streamReader.cxx | 2 + dtool/src/prc/streamReader_ext.cxx | 4 +- dtool/src/prc/streamWrapper.cxx | 8 +-- dtool/src/prckeys/makePrcKey.cxx | 11 ++-- dtool/src/prckeys/signPrcFile_src.cxx | 15 +++--- .../src/test_interrogate/test_interrogate.cxx | 5 ++ dtool/src/test_interrogate/test_lib.cxx | 2 +- panda/src/android/android_main.cxx | 6 ++- panda/src/android/config_android.cxx | 2 +- panda/src/android/pnmFileTypeAndroid.cxx | 8 +-- .../src/android/pnmFileTypeAndroidReader.cxx | 8 +-- .../src/android/pnmFileTypeAndroidWriter.cxx | 2 +- panda/src/android/python_main.cxx | 4 +- .../androiddisplay/androidGraphicsPipe.cxx | 4 +- .../androidGraphicsStateGuardian.cxx | 2 +- .../androiddisplay/androidGraphicsWindow.cxx | 2 +- .../androiddisplay/config_androiddisplay.cxx | 2 +- panda/src/audio/audioManager.cxx | 6 ++- panda/src/audio/audioSound.cxx | 2 + panda/src/audio/config_audio.cxx | 4 ++ panda/src/audio/nullAudioManager.cxx | 4 +- panda/src/audio/nullAudioSound.cxx | 2 + panda/src/audio/test_audio.cxx | 4 +- panda/src/audiotraits/fmodAudioManager.cxx | 4 +- panda/src/audiotraits/fmodAudioSound.cxx | 3 ++ panda/src/audiotraits/globalMilesManager.cxx | 9 ++-- panda/src/audiotraits/milesAudioManager.cxx | 10 ++-- panda/src/audiotraits/milesAudioSample.cxx | 8 +-- panda/src/audiotraits/milesAudioSequence.cxx | 8 +-- panda/src/audiotraits/milesAudioSound.cxx | 2 + panda/src/audiotraits/milesAudioStream.cxx | 8 +-- panda/src/audiotraits/openalAudioManager.cxx | 3 ++ panda/src/audiotraits/openalAudioSound.cxx | 6 +-- panda/src/awesomium/AwMouseAndKeyboard.cxx | 4 +- panda/src/awesomium/WebBrowserTexture.cxx | 2 +- panda/src/awesomium/awWebView.cxx | 2 +- panda/src/bullet/bulletBodyNode.cxx | 6 +-- panda/src/bullet/bulletCapsuleShape.cxx | 6 +-- .../bullet/bulletCharacterControllerNode.cxx | 2 +- panda/src/bullet/bulletConeShape.cxx | 6 +-- panda/src/bullet/bulletCylinderShape.cxx | 2 + panda/src/bullet/bulletDebugNode.cxx | 10 ++-- panda/src/bullet/bulletHeightfieldShape.cxx | 2 +- panda/src/bullet/bulletMultiSphereShape.cxx | 2 +- panda/src/bullet/bulletRigidBodyNode.cxx | 2 +- panda/src/bullet/bulletSoftBodyNode.cxx | 2 +- panda/src/bullet/bulletTriangleMesh.cxx | 10 ++-- panda/src/bullet/bulletTriangleMeshShape.cxx | 4 +- panda/src/bullet/bulletVehicle.cxx | 2 +- panda/src/bullet/bulletWorld.cxx | 7 ++- panda/src/bullet/config_bullet.cxx | 2 +- panda/src/chan/animBundle.cxx | 2 +- panda/src/chan/animChannel.cxx | 2 +- panda/src/chan/animChannelMatrixDynamic.cxx | 2 +- panda/src/chan/animChannelMatrixFixed.cxx | 4 +- panda/src/chan/animChannelMatrixXfmTable.cxx | 8 +-- panda/src/chan/animChannelScalarDynamic.cxx | 2 +- panda/src/chan/animChannelScalarTable.cxx | 4 +- panda/src/chan/animControl.cxx | 8 +-- panda/src/chan/animControlCollection.cxx | 6 ++- panda/src/chan/animGroup.cxx | 10 ++-- panda/src/chan/animPreloadTable.cxx | 8 +-- panda/src/chan/auto_bind.cxx | 2 + panda/src/chan/bindAnimRequest.cxx | 2 +- panda/src/chan/movingPartBase.cxx | 6 +-- panda/src/chan/partBundle.cxx | 4 ++ panda/src/chan/partGroup.cxx | 8 +-- panda/src/chan/partSubset.cxx | 6 +-- panda/src/char/character.cxx | 12 ++--- panda/src/char/characterJoint.cxx | 2 +- panda/src/char/characterJointBundle.cxx | 2 +- panda/src/char/characterJointEffect.cxx | 2 +- panda/src/char/characterSlider.cxx | 2 +- panda/src/char/jointVertexTransform.cxx | 2 +- panda/src/cocoadisplay/cocoaGraphicsBuffer.mm | 2 +- panda/src/cocoadisplay/cocoaGraphicsPipe.mm | 4 +- .../cocoaGraphicsStateGuardian.mm | 2 +- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 6 +-- panda/src/collada/colladaBindMaterial.cxx | 2 +- panda/src/collada/colladaInput.cxx | 6 +-- panda/src/collada/colladaLoader.cxx | 4 +- panda/src/collada/loaderFileTypeDae.cxx | 6 +-- panda/src/collide/collisionBox.cxx | 5 +- panda/src/collide/collisionEntry.cxx | 4 +- panda/src/collide/collisionFloorMesh.cxx | 8 ++- panda/src/collide/collisionGeom.cxx | 2 +- panda/src/collide/collisionHandlerEvent.cxx | 2 + panda/src/collide/collisionHandlerFloor.cxx | 5 +- panda/src/collide/collisionHandlerGravity.cxx | 7 ++- panda/src/collide/collisionHandlerQueue.cxx | 4 +- panda/src/collide/collisionInvSphere.cxx | 8 +-- panda/src/collide/collisionLine.cxx | 2 +- panda/src/collide/collisionNode.cxx | 4 +- panda/src/collide/collisionParabola.cxx | 6 +-- panda/src/collide/collisionPlane.cxx | 4 +- panda/src/collide/collisionPolygon.cxx | 7 ++- panda/src/collide/collisionRay.cxx | 2 +- panda/src/collide/collisionRecorder.cxx | 2 +- panda/src/collide/collisionSegment.cxx | 2 +- panda/src/collide/collisionSolid.cxx | 4 +- panda/src/collide/collisionSphere.cxx | 5 +- panda/src/collide/collisionTraverser.cxx | 10 ++-- panda/src/collide/collisionTube.cxx | 6 +-- panda/src/collide/collisionVisualizer.cxx | 10 ++-- panda/src/cull/cullBinBackToFront.cxx | 2 +- panda/src/cull/cullBinFixed.cxx | 2 +- panda/src/cull/cullBinFrontToBack.cxx | 2 +- panda/src/cull/cullBinStateSorted.cxx | 2 +- panda/src/cull/cullBinUnsorted.cxx | 2 +- panda/src/device/analogNode.cxx | 4 +- panda/src/device/buttonNode.cxx | 6 +-- panda/src/device/clientAnalogDevice.cxx | 4 +- panda/src/device/clientBase.cxx | 6 +-- panda/src/device/clientButtonDevice.cxx | 4 +- panda/src/device/clientDevice.cxx | 6 +-- panda/src/device/dialNode.cxx | 2 +- panda/src/device/mouseAndKeyboard.cxx | 2 +- panda/src/device/trackerNode.cxx | 2 +- panda/src/device/virtualMouse.cxx | 2 +- panda/src/dgraph/dataNode.cxx | 8 +-- panda/src/display/callbackGraphicsWindow.cxx | 4 +- panda/src/display/displayInformation.cxx | 6 +-- panda/src/display/displayRegion.cxx | 8 +-- .../display/displayRegionCullCallbackData.cxx | 2 +- .../display/displayRegionDrawCallbackData.cxx | 2 +- panda/src/display/frameBufferProperties.cxx | 6 +-- panda/src/display/graphicsBuffer.cxx | 2 +- panda/src/display/graphicsEngine.cxx | 6 ++- panda/src/display/graphicsOutput.cxx | 8 +-- panda/src/display/graphicsPipe.cxx | 6 +-- panda/src/display/graphicsPipeSelection.cxx | 8 +-- panda/src/display/graphicsStateGuardian.cxx | 12 +++-- panda/src/display/graphicsThreadingModel.cxx | 2 + panda/src/display/graphicsWindow.cxx | 2 + .../src/display/graphicsWindowInputDevice.cxx | 4 +- .../graphicsWindowProcCallbackData.cxx | 2 +- panda/src/display/nativeWindowHandle.cxx | 2 + panda/src/display/parasiteBuffer.cxx | 8 +-- panda/src/display/stereoDisplayRegion.cxx | 2 +- panda/src/display/subprocessWindow.cxx | 2 + panda/src/display/subprocessWindowBuffer.cxx | 3 ++ panda/src/display/windowHandle.cxx | 4 +- panda/src/display/windowProperties.cxx | 4 ++ panda/src/distort/nonlinearImager.cxx | 2 +- panda/src/distort/projectionScreen.cxx | 6 +-- panda/src/downloader/bioPtr.cxx | 2 + panda/src/downloader/chunkedStreamBuf.cxx | 8 +-- panda/src/downloader/decompressor.cxx | 12 ++--- panda/src/downloader/documentSpec.cxx | 10 ++-- panda/src/downloader/downloadDb.cxx | 7 +++ panda/src/downloader/download_utils.cxx | 6 ++- panda/src/downloader/extractor.cxx | 4 +- panda/src/downloader/httpAuthorization.cxx | 2 + .../src/downloader/httpBasicAuthorization.cxx | 2 + panda/src/downloader/httpChannel.cxx | 14 +++-- panda/src/downloader/httpClient.cxx | 10 ++-- panda/src/downloader/httpCookie.cxx | 4 +- panda/src/downloader/httpDate.cxx | 10 ++-- .../downloader/httpDigestAuthorization.cxx | 6 ++- panda/src/downloader/httpEntityTag.cxx | 4 +- panda/src/downloader/httpEnum.cxx | 4 +- panda/src/downloader/identityStreamBuf.cxx | 2 +- panda/src/downloader/multiplexStreamBuf.cxx | 8 +-- panda/src/downloader/socketStream.cxx | 10 ++-- panda/src/downloader/stringStreamBuf.cxx | 8 ++- panda/src/downloader/urlSpec.cxx | 11 +++- panda/src/downloader/virtualFileHTTP.cxx | 8 ++- panda/src/downloader/virtualFileMountHTTP.cxx | 12 +++-- panda/src/downloadertools/apply_patch.cxx | 3 ++ panda/src/downloadertools/build_patch.cxx | 3 ++ panda/src/downloadertools/check_adler.cxx | 4 +- panda/src/downloadertools/check_crc.cxx | 4 +- panda/src/downloadertools/check_md5.cxx | 9 ++-- panda/src/downloadertools/multify.cxx | 7 ++- panda/src/downloadertools/pdecrypt.cxx | 5 +- panda/src/downloadertools/pencrypt.cxx | 7 ++- panda/src/downloadertools/punzip.cxx | 5 ++ panda/src/downloadertools/pzip.cxx | 5 ++ panda/src/downloadertools/show_ddb.cxx | 4 +- panda/src/dxgsg9/dxGeomMunger9.cxx | 4 +- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 12 +++-- panda/src/dxgsg9/dxInput9.cxx | 2 + panda/src/dxgsg9/dxShaderContext9.cxx | 4 +- panda/src/dxgsg9/dxTextureContext9.cxx | 6 ++- panda/src/dxgsg9/wdxGraphicsBuffer9.cxx | 7 ++- panda/src/dxgsg9/wdxGraphicsPipe9.cxx | 6 ++- panda/src/dxgsg9/wdxGraphicsWindow9.cxx | 8 +-- panda/src/dxml/config_dxml.cxx | 6 +-- panda/src/egg/eggAnimPreload.cxx | 2 +- panda/src/egg/eggAttributes.cxx | 2 +- panda/src/egg/eggBin.cxx | 2 +- panda/src/egg/eggBinMaker.cxx | 8 +-- panda/src/egg/eggComment.cxx | 2 +- panda/src/egg/eggCompositePrimitive.cxx | 8 +-- panda/src/egg/eggCoordinateSystem.cxx | 2 +- panda/src/egg/eggCurve.cxx | 4 +- panda/src/egg/eggData.cxx | 9 ++-- panda/src/egg/eggExternalReference.cxx | 8 +-- panda/src/egg/eggFilenameNode.cxx | 4 +- panda/src/egg/eggGroup.cxx | 3 ++ panda/src/egg/eggGroupNode.cxx | 6 ++- panda/src/egg/eggGroupUniquifier.cxx | 4 +- panda/src/egg/eggLine.cxx | 2 +- panda/src/egg/eggMaterial.cxx | 4 +- panda/src/egg/eggMaterialCollection.cxx | 4 +- panda/src/egg/eggMesher.cxx | 6 +-- panda/src/egg/eggMesherEdge.cxx | 2 +- panda/src/egg/eggMesherFanMaker.cxx | 2 +- panda/src/egg/eggMesherStrip.cxx | 4 +- panda/src/egg/eggMiscFuncs.cxx | 3 ++ panda/src/egg/eggNameUniquifier.cxx | 4 +- panda/src/egg/eggNamedObject.cxx | 4 +- panda/src/egg/eggNode.cxx | 8 +-- panda/src/egg/eggNurbsCurve.cxx | 2 +- panda/src/egg/eggNurbsSurface.cxx | 2 +- panda/src/egg/eggPatch.cxx | 2 +- panda/src/egg/eggPoint.cxx | 2 +- panda/src/egg/eggPolygon.cxx | 2 +- panda/src/egg/eggPolysetMaker.cxx | 2 +- panda/src/egg/eggPoolUniquifier.cxx | 4 +- panda/src/egg/eggPrimitive.cxx | 4 +- panda/src/egg/eggRenderMode.cxx | 4 ++ panda/src/egg/eggSAnimData.cxx | 2 +- panda/src/egg/eggSwitchCondition.cxx | 2 +- panda/src/egg/eggTable.cxx | 6 +-- panda/src/egg/eggTexture.cxx | 3 ++ panda/src/egg/eggTextureCollection.cxx | 4 +- panda/src/egg/eggTransform.cxx | 2 +- panda/src/egg/eggTriangleFan.cxx | 2 +- panda/src/egg/eggTriangleStrip.cxx | 2 +- panda/src/egg/eggVertex.cxx | 3 ++ panda/src/egg/eggVertexAux.cxx | 6 +-- panda/src/egg/eggVertexPool.cxx | 10 ++-- panda/src/egg/eggVertexUV.cxx | 8 +-- panda/src/egg/eggXfmAnimData.cxx | 2 +- panda/src/egg/eggXfmSAnim.cxx | 6 ++- panda/src/egg/lexer.cxx.prebuilt | 14 +++-- panda/src/egg/lexer.lxx | 12 +++-- panda/src/egg/parser.cxx.prebuilt | 4 ++ panda/src/egg/parser.yxx | 4 ++ panda/src/egg/test_egg.cxx | 2 +- panda/src/egg2pg/animBundleMaker.cxx | 8 +-- panda/src/egg2pg/characterMaker.cxx | 2 + panda/src/egg2pg/eggBinner.cxx | 4 +- panda/src/egg2pg/eggLoader.cxx | 6 ++- panda/src/egg2pg/eggRenderState.cxx | 4 +- panda/src/egg2pg/eggSaver.cxx | 7 ++- panda/src/egg2pg/load_egg_file.cxx | 2 +- panda/src/egg2pg/loaderFileTypeEgg.cxx | 4 +- panda/src/egldisplay/config_egldisplay.cxx | 2 +- panda/src/egldisplay/eglGraphicsBuffer.cxx | 2 +- panda/src/egldisplay/eglGraphicsPipe.cxx | 6 +-- panda/src/egldisplay/eglGraphicsPixmap.cxx | 2 +- .../egldisplay/eglGraphicsStateGuardian.cxx | 4 +- panda/src/egldisplay/eglGraphicsWindow.cxx | 2 +- panda/src/event/asyncFuture.cxx | 6 +-- panda/src/event/asyncFuture_ext.cxx | 2 +- panda/src/event/asyncTask.cxx | 8 +-- panda/src/event/asyncTaskChain.cxx | 5 ++ panda/src/event/asyncTaskCollection.cxx | 6 +-- panda/src/event/asyncTaskManager.cxx | 10 ++-- panda/src/event/asyncTaskSequence.cxx | 2 +- panda/src/event/buttonEvent.cxx | 2 +- panda/src/event/buttonEventList.cxx | 4 +- panda/src/event/event.cxx | 4 +- panda/src/event/eventHandler.cxx | 12 +++-- panda/src/event/eventParameter.cxx | 2 +- panda/src/event/genericAsyncTask.cxx | 4 +- panda/src/event/pointerEvent.cxx | 2 +- panda/src/event/pointerEventList.cxx | 14 ++--- panda/src/event/pythonTask.cxx | 6 +-- panda/src/event/test_task.cxx | 12 +++-- panda/src/express/checksumHashGenerator.cxx | 4 +- panda/src/express/compress_string.cxx | 6 +++ panda/src/express/copy_stream.cxx | 2 +- panda/src/express/datagram.cxx | 10 ++-- panda/src/express/datagramGenerator.cxx | 2 +- panda/src/express/datagramIterator.cxx | 7 ++- panda/src/express/datagramSink.cxx | 2 +- panda/src/express/encrypt_string.cxx | 6 +++ panda/src/express/error_utils.cxx | 8 +-- panda/src/express/hashVal.cxx | 10 +++- panda/src/express/make_ca_bundle.cxx | 14 +++-- panda/src/express/memoryUsage.cxx | 4 +- .../src/express/memoryUsagePointerCounts.cxx | 4 +- panda/src/express/memoryUsagePointers.cxx | 4 +- panda/src/express/multifile.cxx | 15 +++++- panda/src/express/openSSLWrapper.cxx | 4 +- panda/src/express/password_hash.cxx | 2 + panda/src/express/patchfile.cxx | 8 +++ panda/src/express/profileTimer.cxx | 7 ++- panda/src/express/ramfile.cxx | 6 +-- panda/src/express/ramfile_ext.cxx | 8 +-- panda/src/express/subStreamBuf.cxx | 5 ++ panda/src/express/subfileInfo.cxx | 2 +- panda/src/express/test_ordered_vector.cxx | 4 +- panda/src/express/test_types.cxx | 3 ++ panda/src/express/test_zstream.cxx | 8 ++- panda/src/express/trueClock.cxx | 7 ++- panda/src/express/virtualFile.cxx | 13 +++-- panda/src/express/virtualFileComposite.cxx | 2 +- panda/src/express/virtualFileMount.cxx | 7 ++- .../express/virtualFileMountAndroidAsset.cxx | 10 ++-- .../src/express/virtualFileMountMultifile.cxx | 12 ++--- panda/src/express/virtualFileMountRamdisk.cxx | 13 +++-- panda/src/express/virtualFileMountSystem.cxx | 11 +++- panda/src/express/virtualFileSimple.cxx | 9 +++- panda/src/express/virtualFileSystem.cxx | 5 ++ panda/src/express/windowsRegistry.cxx | 6 ++- panda/src/express/zStreamBuf.cxx | 10 ++-- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 4 +- panda/src/ffmpeg/ffmpegVirtualFile.cxx | 13 +++-- panda/src/framework/pandaFramework.cxx | 14 ++--- panda/src/framework/windowFramework.cxx | 10 ++-- panda/src/glstuff/glCgShaderContext_src.cxx | 8 +-- panda/src/glstuff/glGraphicsBuffer_src.cxx | 15 +++--- .../glstuff/glGraphicsStateGuardian_src.cxx | 13 +++-- panda/src/glstuff/glShaderContext_src.cxx | 10 +++- panda/src/glxdisplay/glxGraphicsBuffer.cxx | 2 +- panda/src/glxdisplay/glxGraphicsPipe.cxx | 2 + panda/src/glxdisplay/glxGraphicsPixmap.cxx | 2 +- .../glxdisplay/glxGraphicsStateGuardian.cxx | 2 + panda/src/glxdisplay/glxGraphicsWindow.cxx | 2 +- panda/src/gobj/adaptiveLru.cxx | 7 ++- panda/src/gobj/bufferContextChain.cxx | 2 +- panda/src/gobj/bufferResidencyTracker.cxx | 4 +- panda/src/gobj/geom.cxx | 15 +++--- panda/src/gobj/geomCacheEntry.cxx | 2 +- panda/src/gobj/geomEnums.cxx | 4 ++ panda/src/gobj/geomLines.cxx | 4 +- panda/src/gobj/geomLinestrips.cxx | 2 + panda/src/gobj/geomMunger.cxx | 4 +- panda/src/gobj/geomPrimitive.cxx | 9 ++-- panda/src/gobj/geomTriangles.cxx | 6 ++- panda/src/gobj/geomTristrips.cxx | 4 +- panda/src/gobj/geomVertexAnimationSpec.cxx | 2 +- panda/src/gobj/geomVertexArrayData.cxx | 7 ++- panda/src/gobj/geomVertexArrayData_ext.cxx | 6 +-- panda/src/gobj/geomVertexArrayFormat.cxx | 14 +++-- panda/src/gobj/geomVertexColumn.cxx | 5 +- panda/src/gobj/geomVertexData.cxx | 14 ++--- panda/src/gobj/geomVertexFormat.cxx | 10 ++-- panda/src/gobj/geomVertexReader.cxx | 3 +- panda/src/gobj/geomVertexRewriter.cxx | 2 +- panda/src/gobj/geomVertexWriter.cxx | 3 +- panda/src/gobj/indexBufferContext.cxx | 4 +- panda/src/gobj/internalName.cxx | 4 +- panda/src/gobj/internalName_ext.cxx | 2 + panda/src/gobj/lens.cxx | 7 ++- panda/src/gobj/material.cxx | 4 +- panda/src/gobj/materialPool.cxx | 4 +- panda/src/gobj/matrixLens.cxx | 2 +- panda/src/gobj/orthographicLens.cxx | 2 +- panda/src/gobj/paramTexture.cxx | 4 +- panda/src/gobj/preparedGraphicsObjects.cxx | 12 ++--- panda/src/gobj/samplerContext.cxx | 4 +- panda/src/gobj/samplerState.cxx | 6 ++- panda/src/gobj/savedContext.cxx | 4 +- panda/src/gobj/shader.cxx | 18 ++++--- panda/src/gobj/shaderBuffer.cxx | 2 +- panda/src/gobj/simpleAllocator.cxx | 6 +-- panda/src/gobj/simpleLru.cxx | 4 +- panda/src/gobj/sliderTable.cxx | 2 +- panda/src/gobj/test_gobj.cxx | 2 +- panda/src/gobj/texture.cxx | 18 +++++-- panda/src/gobj/textureCollection.cxx | 6 +-- panda/src/gobj/textureCollection_ext.cxx | 4 +- panda/src/gobj/textureContext.cxx | 4 +- panda/src/gobj/texturePeeker.cxx | 2 +- panda/src/gobj/texturePool.cxx | 12 +++-- panda/src/gobj/texturePoolFilter.cxx | 2 +- panda/src/gobj/textureStage.cxx | 4 +- panda/src/gobj/textureStagePool.cxx | 4 ++ panda/src/gobj/texture_ext.cxx | 8 +-- panda/src/gobj/transformBlend.cxx | 8 +-- panda/src/gobj/transformBlendTable.cxx | 8 +-- panda/src/gobj/transformTable.cxx | 2 +- panda/src/gobj/userVertexSlider.cxx | 2 +- panda/src/gobj/userVertexTransform.cxx | 4 +- panda/src/gobj/vertexBufferContext.cxx | 4 +- panda/src/gobj/vertexDataBuffer.cxx | 2 +- panda/src/gobj/vertexDataPage.cxx | 10 ++-- panda/src/gobj/vertexDataSaveFile.cxx | 13 +++-- panda/src/gobj/vertexSlider.cxx | 4 +- panda/src/gobj/vertexTransform.cxx | 4 +- panda/src/gobj/videoTexture.cxx | 8 +-- panda/src/grutil/fisheyeMaker.cxx | 4 +- panda/src/grutil/frameRateMeter.cxx | 2 +- panda/src/grutil/geoMipTerrain.cxx | 5 +- panda/src/grutil/lineSegs.cxx | 2 +- panda/src/grutil/movieTexture.cxx | 12 ++--- panda/src/grutil/multitexReducer.cxx | 7 ++- panda/src/grutil/nodeVertexTransform.cxx | 2 +- panda/src/grutil/pfmVizzer.cxx | 5 +- panda/src/grutil/rigidBodyCombiner.cxx | 2 +- panda/src/grutil/sceneGraphAnalyzerMeter.cxx | 2 +- panda/src/grutil/shaderTerrainMesh.cxx | 6 ++- panda/src/iphone/iphone_runappmf_src.mm | 1 - panda/src/iphonedisplay/iPhoneGraphicsPipe.mm | 2 +- panda/src/linmath/coordinateSystem.cxx | 5 ++ panda/src/linmath/lmatrix3_src.cxx | 4 +- panda/src/linmath/lmatrix4_src.cxx | 4 +- panda/src/linmath/test_math.cxx | 4 ++ panda/src/mathutil/boundingBox.cxx | 5 +- panda/src/mathutil/boundingHexahedron.cxx | 7 ++- panda/src/mathutil/boundingLine.cxx | 2 +- panda/src/mathutil/boundingPlane.cxx | 2 +- panda/src/mathutil/boundingSphere.cxx | 5 +- panda/src/mathutil/boundingVolume.cxx | 4 ++ .../mathutil/intersectionBoundingVolume.cxx | 4 +- panda/src/mathutil/omniBoundingVolume.cxx | 2 +- panda/src/mathutil/parabola_src.cxx | 4 +- panda/src/mathutil/plane_src.cxx | 4 +- panda/src/mathutil/test_tri.cxx | 2 +- panda/src/mathutil/unionBoundingVolume.cxx | 4 +- panda/src/movies/flacAudio.cxx | 2 +- panda/src/movies/flacAudioCursor.cxx | 10 ++-- panda/src/movies/microphoneAudioDS.cxx | 2 +- panda/src/movies/movieAudio.cxx | 2 +- panda/src/movies/movieAudioCursor.cxx | 4 +- panda/src/movies/movieTypeRegistry.cxx | 3 ++ panda/src/movies/movieVideo.cxx | 2 +- panda/src/movies/opusAudio.cxx | 2 +- panda/src/movies/opusAudioCursor.cxx | 10 ++-- panda/src/movies/userDataAudio.cxx | 2 +- panda/src/movies/vorbisAudio.cxx | 2 +- panda/src/movies/vorbisAudioCursor.cxx | 10 ++-- panda/src/movies/wavAudio.cxx | 2 +- panda/src/movies/wavAudioCursor.cxx | 10 ++-- panda/src/net/config_net.cxx | 6 +-- panda/src/net/connection.cxx | 10 ++-- panda/src/net/connectionListener.cxx | 6 +-- panda/src/net/connectionManager.cxx | 13 +++-- panda/src/net/connectionReader.cxx | 8 +-- panda/src/net/connectionWriter.cxx | 6 +-- panda/src/net/datagramTCPHeader.cxx | 2 +- panda/src/net/datagramUDPHeader.cxx | 2 +- panda/src/net/datagram_ui.cxx | 3 ++ panda/src/net/fake_http_server.cxx | 4 +- panda/src/net/netAddress.cxx | 6 +-- panda/src/net/queuedConnectionReader.cxx | 2 +- panda/src/net/test_datagram.cxx | 3 ++ panda/src/net/test_raw_server.cxx | 2 +- panda/src/net/test_spam_client.cxx | 6 +-- panda/src/net/test_tcp_client.cxx | 5 +- panda/src/net/test_udp.cxx | 5 +- panda/src/ode/odeBody.cxx | 2 +- panda/src/ode/odeGeom.cxx | 2 +- panda/src/ode/odeJoint.cxx | 6 +-- panda/src/ode/odeMass.cxx | 2 +- panda/src/ode/odeSpace.cxx | 2 +- panda/src/ode/odeTriMeshData.cxx | 4 +- panda/src/ode/odeUtil.cxx | 2 +- panda/src/osxdisplay/osxGraphicsBuffer.cxx | 2 +- panda/src/osxdisplay/osxGraphicsPipe.cxx | 4 +- .../osxdisplay/osxGraphicsStateGuardian.cxx | 6 +-- panda/src/parametrics/cubicCurveseg.cxx | 4 +- panda/src/parametrics/curveFitter.cxx | 8 +-- panda/src/parametrics/hermiteCurve.cxx | 9 ++-- panda/src/parametrics/nurbsCurve.cxx | 4 +- panda/src/parametrics/nurbsCurveEvaluator.cxx | 2 +- panda/src/parametrics/nurbsCurveInterface.cxx | 6 +-- .../src/parametrics/nurbsSurfaceEvaluator.cxx | 2 +- panda/src/parametrics/parametricCurve.cxx | 8 +-- .../parametrics/parametricCurveCollection.cxx | 12 ++--- panda/src/parametrics/piecewiseCurve.cxx | 2 + panda/src/parametrics/ropeNode.cxx | 6 +-- panda/src/parametrics/sheetNode.cxx | 6 +-- panda/src/particlesystem/arcEmitter.cxx | 4 +- panda/src/particlesystem/baseParticle.cxx | 4 +- .../particlesystem/baseParticleEmitter.cxx | 4 +- .../particlesystem/baseParticleFactory.cxx | 4 +- .../particlesystem/baseParticleRenderer.cxx | 4 +- panda/src/particlesystem/boxEmitter.cxx | 4 +- .../colorInterpolationManager.cxx | 3 ++ panda/src/particlesystem/discEmitter.cxx | 4 +- .../particlesystem/geomParticleRenderer.cxx | 8 +-- panda/src/particlesystem/lineEmitter.cxx | 4 +- .../particlesystem/lineParticleRenderer.cxx | 6 +-- panda/src/particlesystem/orientedParticle.cxx | 4 +- .../orientedParticleFactory.cxx | 4 +- panda/src/particlesystem/particleSystem.cxx | 6 ++- .../particlesystem/particleSystemManager.cxx | 6 +-- panda/src/particlesystem/pointEmitter.cxx | 4 +- panda/src/particlesystem/pointParticle.cxx | 4 +- .../particlesystem/pointParticleFactory.cxx | 4 +- .../particlesystem/pointParticleRenderer.cxx | 6 +-- panda/src/particlesystem/rectangleEmitter.cxx | 4 +- panda/src/particlesystem/ringEmitter.cxx | 4 +- .../sparkleParticleRenderer.cxx | 6 +-- .../particlesystem/sphereSurfaceEmitter.cxx | 4 +- .../particlesystem/sphereVolumeEmitter.cxx | 4 +- .../particlesystem/spriteParticleRenderer.cxx | 11 ++-- .../src/particlesystem/tangentRingEmitter.cxx | 4 +- panda/src/particlesystem/zSpinParticle.cxx | 4 +- .../particlesystem/zSpinParticleFactory.cxx | 4 +- panda/src/pgraph/accumulatedAttribs.cxx | 2 +- panda/src/pgraph/alphaTestAttrib.cxx | 2 +- panda/src/pgraph/antialiasAttrib.cxx | 2 +- panda/src/pgraph/attribNodeRegistry.cxx | 12 ++--- panda/src/pgraph/audioVolumeAttrib.cxx | 2 +- panda/src/pgraph/auxBitplaneAttrib.cxx | 2 +- panda/src/pgraph/auxSceneData.cxx | 4 +- panda/src/pgraph/bamFile.cxx | 6 ++- panda/src/pgraph/billboardEffect.cxx | 2 +- panda/src/pgraph/cacheStats.cxx | 2 +- panda/src/pgraph/camera.cxx | 4 +- panda/src/pgraph/clipPlaneAttrib.cxx | 4 +- panda/src/pgraph/colorAttrib.cxx | 2 +- panda/src/pgraph/colorBlendAttrib.cxx | 2 + panda/src/pgraph/colorScaleAttrib.cxx | 2 +- panda/src/pgraph/colorWriteAttrib.cxx | 2 +- panda/src/pgraph/compassEffect.cxx | 2 +- panda/src/pgraph/cullBinAttrib.cxx | 4 +- panda/src/pgraph/cullBinManager.cxx | 8 +-- panda/src/pgraph/cullFaceAttrib.cxx | 2 +- panda/src/pgraph/cullPlanes.cxx | 9 ++-- panda/src/pgraph/cullResult.cxx | 2 +- panda/src/pgraph/cullTraverser.cxx | 4 +- panda/src/pgraph/cullTraverserData.cxx | 8 +-- panda/src/pgraph/cullableObject.cxx | 10 ++-- panda/src/pgraph/depthOffsetAttrib.cxx | 2 +- panda/src/pgraph/depthTestAttrib.cxx | 2 +- panda/src/pgraph/depthWriteAttrib.cxx | 2 +- panda/src/pgraph/findApproxLevelEntry.cxx | 4 +- panda/src/pgraph/findApproxPath.cxx | 3 ++ panda/src/pgraph/fog.cxx | 8 +-- panda/src/pgraph/fogAttrib.cxx | 2 +- panda/src/pgraph/geomDrawCallbackData.cxx | 2 +- panda/src/pgraph/geomNode.cxx | 10 ++-- panda/src/pgraph/geomTransformer.cxx | 2 +- panda/src/pgraph/internalNameCollection.cxx | 4 +- panda/src/pgraph/lensNode.cxx | 6 +-- panda/src/pgraph/lightAttrib.cxx | 6 +-- panda/src/pgraph/lightRampAttrib.cxx | 2 +- panda/src/pgraph/loader.cxx | 12 +++-- panda/src/pgraph/loaderFileType.cxx | 4 +- panda/src/pgraph/loaderFileTypeBam.cxx | 4 +- panda/src/pgraph/loaderFileTypeRegistry.cxx | 12 +++-- panda/src/pgraph/logicOpAttrib.cxx | 6 +-- panda/src/pgraph/materialAttrib.cxx | 2 +- panda/src/pgraph/materialCollection.cxx | 6 +-- panda/src/pgraph/modelLoadRequest.cxx | 2 +- panda/src/pgraph/modelPool.cxx | 4 +- panda/src/pgraph/modelSaveRequest.cxx | 2 +- panda/src/pgraph/nodePath.cxx | 6 +++ panda/src/pgraph/nodePathCollection.cxx | 11 ++-- panda/src/pgraph/nodePathCollection_ext.cxx | 4 +- panda/src/pgraph/nodePathComponent.cxx | 2 +- panda/src/pgraph/nodePath_ext.cxx | 8 +-- panda/src/pgraph/occluderEffect.cxx | 2 +- panda/src/pgraph/occluderNode.cxx | 4 +- panda/src/pgraph/pandaNode.cxx | 6 ++- panda/src/pgraph/paramNodePath.cxx | 2 +- panda/src/pgraph/planeNode.cxx | 4 +- panda/src/pgraph/polylightEffect.cxx | 8 +-- panda/src/pgraph/polylightNode.cxx | 10 ++-- panda/src/pgraph/portalClipper.cxx | 4 ++ panda/src/pgraph/portalNode.cxx | 8 +-- panda/src/pgraph/renderAttrib.cxx | 8 +-- panda/src/pgraph/renderEffect.cxx | 8 +-- panda/src/pgraph/renderEffects.cxx | 8 +-- panda/src/pgraph/renderModeAttrib.cxx | 2 +- panda/src/pgraph/renderState.cxx | 14 ++--- panda/src/pgraph/rescaleNormalAttrib.cxx | 4 ++ panda/src/pgraph/sceneGraphReducer.cxx | 8 +-- panda/src/pgraph/scissorAttrib.cxx | 5 +- panda/src/pgraph/scissorEffect.cxx | 5 +- panda/src/pgraph/shadeModelAttrib.cxx | 2 +- panda/src/pgraph/shaderAttrib.cxx | 11 ++-- panda/src/pgraph/shaderAttrib_ext.cxx | 6 +-- panda/src/pgraph/shaderInput.cxx | 6 +-- panda/src/pgraph/shaderInput_ext.cxx | 2 +- panda/src/pgraph/shaderPool.cxx | 6 +-- panda/src/pgraph/stencilAttrib.cxx | 2 +- panda/src/pgraph/test_pgraph.cxx | 6 ++- panda/src/pgraph/texGenAttrib.cxx | 2 +- panda/src/pgraph/texMatrixAttrib.cxx | 2 +- panda/src/pgraph/texProjectorEffect.cxx | 2 +- panda/src/pgraph/textureAttrib.cxx | 4 +- panda/src/pgraph/textureStageCollection.cxx | 6 +-- panda/src/pgraph/transformState.cxx | 10 ++-- panda/src/pgraph/transparencyAttrib.cxx | 2 +- panda/src/pgraph/weakNodePath.cxx | 2 +- panda/src/pgraph/workingNodePath.cxx | 2 +- panda/src/pgraphnodes/ambientLight.cxx | 4 +- panda/src/pgraphnodes/callbackNode.cxx | 4 +- panda/src/pgraphnodes/computeNode.cxx | 4 +- panda/src/pgraphnodes/directionalLight.cxx | 4 +- panda/src/pgraphnodes/fadeLodNode.cxx | 6 +-- panda/src/pgraphnodes/fadeLodNodeData.cxx | 2 +- panda/src/pgraphnodes/lightLensNode.cxx | 6 +-- panda/src/pgraphnodes/lightNode.cxx | 6 +-- panda/src/pgraphnodes/lodNode.cxx | 10 ++-- panda/src/pgraphnodes/lodNodeType.cxx | 4 ++ .../src/pgraphnodes/nodeCullCallbackData.cxx | 2 +- panda/src/pgraphnodes/pointLight.cxx | 4 +- panda/src/pgraphnodes/rectangleLight.cxx | 4 +- panda/src/pgraphnodes/sceneGraphAnalyzer.cxx | 4 +- panda/src/pgraphnodes/sequenceNode.cxx | 2 +- panda/src/pgraphnodes/shaderGenerator.cxx | 8 +-- panda/src/pgraphnodes/sphereLight.cxx | 4 +- panda/src/pgraphnodes/spotlight.cxx | 4 +- panda/src/pgui/pgButton.cxx | 6 +-- panda/src/pgui/pgEntry.cxx | 5 ++ panda/src/pgui/pgFrameStyle.cxx | 9 ++-- panda/src/pgui/pgItem.cxx | 4 ++ panda/src/pgui/pgMouseWatcherParameter.cxx | 2 +- panda/src/pgui/pgScrollFrame.cxx | 2 +- panda/src/pgui/pgSliderBar.cxx | 7 ++- panda/src/pgui/pgTop.cxx | 2 +- panda/src/pgui/pgVirtualFrame.cxx | 2 +- panda/src/pgui/pgWaitBar.cxx | 4 +- panda/src/physics/actorNode.cxx | 4 +- panda/src/physics/angularEulerIntegrator.cxx | 4 +- panda/src/physics/angularForce.cxx | 4 +- panda/src/physics/angularIntegrator.cxx | 4 +- panda/src/physics/angularVectorForce.cxx | 4 +- panda/src/physics/baseForce.cxx | 4 +- panda/src/physics/baseIntegrator.cxx | 2 + panda/src/physics/forceNode.cxx | 8 +-- panda/src/physics/linearControlForce.cxx | 4 +- .../src/physics/linearCylinderVortexForce.cxx | 4 +- panda/src/physics/linearDistanceForce.cxx | 4 +- panda/src/physics/linearEulerIntegrator.cxx | 4 +- panda/src/physics/linearForce.cxx | 4 +- panda/src/physics/linearFrictionForce.cxx | 4 +- panda/src/physics/linearIntegrator.cxx | 4 +- panda/src/physics/linearJitterForce.cxx | 4 +- panda/src/physics/linearNoiseForce.cxx | 4 +- panda/src/physics/linearRandomForce.cxx | 4 +- panda/src/physics/linearSinkForce.cxx | 4 +- panda/src/physics/linearSourceForce.cxx | 4 +- panda/src/physics/linearUserDefinedForce.cxx | 4 +- panda/src/physics/linearVectorForce.cxx | 4 +- panda/src/physics/physical.cxx | 2 + panda/src/physics/physicalNode.cxx | 4 +- panda/src/physics/physicsCollisionHandler.cxx | 3 ++ panda/src/physics/physicsManager.cxx | 2 + panda/src/physics/physicsObject.cxx | 4 +- panda/src/physics/physicsObjectCollection.cxx | 4 +- panda/src/physics/test_physics.cxx | 3 ++ panda/src/physx/physxContactPair.cxx | 4 +- panda/src/physx/physxDebugGeomNode.cxx | 2 +- panda/src/physx/physxEnums.cxx | 7 ++- panda/src/physx/physxGroupsMask.cxx | 4 +- .../physx/physxLinearInterpolationValues.cxx | 8 +-- panda/src/physx/physxManager.cxx | 4 +- panda/src/physx/physxMask.cxx | 4 +- panda/src/physx/physxMeshPool.cxx | 8 +-- panda/src/pipeline/conditionVarDebug.cxx | 3 ++ panda/src/pipeline/conditionVarDirect.cxx | 2 +- panda/src/pipeline/conditionVarFullDebug.cxx | 3 ++ panda/src/pipeline/conditionVarFullDirect.cxx | 2 +- panda/src/pipeline/cycleData.cxx | 2 +- panda/src/pipeline/externalThread.cxx | 2 +- panda/src/pipeline/genericThread.cxx | 4 +- panda/src/pipeline/lightMutexDirect.cxx | 2 +- panda/src/pipeline/lightReMutexDirect.cxx | 2 +- panda/src/pipeline/mutexDebug.cxx | 7 ++- panda/src/pipeline/mutexDirect.cxx | 2 +- panda/src/pipeline/pipeline.cxx | 2 +- panda/src/pipeline/pipelineCyclerTrueImpl.cxx | 2 +- panda/src/pipeline/psemaphore.cxx | 2 +- panda/src/pipeline/pythonThread.cxx | 2 +- panda/src/pipeline/reMutexDirect.cxx | 4 +- panda/src/pipeline/test_atomic.cxx | 4 +- panda/src/pipeline/test_concurrency.cxx | 4 +- panda/src/pipeline/test_delete.cxx | 6 +-- panda/src/pipeline/test_diners.cxx | 6 ++- panda/src/pipeline/test_mutex.cxx | 6 +-- panda/src/pipeline/test_setjmp.cxx | 2 + panda/src/pipeline/test_threaddata.cxx | 8 +-- panda/src/pipeline/thread.cxx | 10 ++-- panda/src/pipeline/threadDummyImpl.cxx | 4 +- panda/src/pipeline/threadPosixImpl.cxx | 6 +-- panda/src/pipeline/threadPriority.cxx | 4 ++ panda/src/pipeline/threadSimpleImpl.cxx | 4 +- panda/src/pipeline/threadSimpleManager.cxx | 4 +- panda/src/pipeline/threadWin32Impl.cxx | 4 +- panda/src/pnmimage/pfmFile.cxx | 5 ++ panda/src/pnmimage/pnm-image-filter.cxx | 3 ++ panda/src/pnmimage/pnmBrush.cxx | 3 ++ panda/src/pnmimage/pnmFileType.cxx | 6 ++- panda/src/pnmimage/pnmFileTypeRegistry.cxx | 6 ++- panda/src/pnmimage/pnmImage.cxx | 9 ++-- panda/src/pnmimage/pnmImageHeader.cxx | 8 ++- panda/src/pnmimage/pnmReader.cxx | 2 +- panda/src/pnmimage/pnmbitio.cxx | 4 ++ panda/src/pnmimage/pnmimage_base.cxx | 3 ++ .../pnmimagetypes/config_pnmimagetypes.cxx | 4 ++ panda/src/pnmimagetypes/pnmFileTypeBMP.cxx | 6 ++- .../pnmimagetypes/pnmFileTypeBMPReader.cxx | 3 ++ .../pnmimagetypes/pnmFileTypeBMPWriter.cxx | 2 + panda/src/pnmimagetypes/pnmFileTypeEXR.cxx | 4 ++ panda/src/pnmimagetypes/pnmFileTypeIMG.cxx | 4 ++ panda/src/pnmimagetypes/pnmFileTypeJPG.cxx | 6 ++- .../pnmimagetypes/pnmFileTypeJPGReader.cxx | 12 ++--- .../pnmimagetypes/pnmFileTypeJPGWriter.cxx | 6 +-- panda/src/pnmimagetypes/pnmFileTypePNG.cxx | 4 ++ panda/src/pnmimagetypes/pnmFileTypePNM.cxx | 4 ++ panda/src/pnmimagetypes/pnmFileTypePfm.cxx | 4 ++ panda/src/pnmimagetypes/pnmFileTypeSGI.cxx | 6 ++- .../pnmimagetypes/pnmFileTypeSGIReader.cxx | 5 +- .../pnmimagetypes/pnmFileTypeSGIWriter.cxx | 2 + .../pnmimagetypes/pnmFileTypeSoftImage.cxx | 6 ++- .../src/pnmimagetypes/pnmFileTypeStbImage.cxx | 8 ++- panda/src/pnmimagetypes/pnmFileTypeTGA.cxx | 4 ++ panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx | 9 +++- panda/src/pnmtext/freetypeFont.cxx | 8 ++- panda/src/pnmtext/pnmTextGlyph.cxx | 3 ++ panda/src/pnmtext/pnmTextMaker.cxx | 2 + panda/src/pstatclient/pStatClient.cxx | 4 +- panda/src/pstatclient/pStatClientImpl.cxx | 4 +- panda/src/pstatclient/pStatCollectorDef.cxx | 2 +- panda/src/pstatclient/pStatProperties.cxx | 2 + panda/src/pstatclient/test_client.cxx | 2 +- panda/src/putil/animInterface.cxx | 7 ++- panda/src/putil/autoTextureScale.cxx | 4 ++ panda/src/putil/bamCache.cxx | 7 ++- panda/src/putil/bamCacheIndex.cxx | 8 +-- panda/src/putil/bamCacheRecord.cxx | 8 +-- panda/src/putil/bamEnums.cxx | 4 ++ panda/src/putil/bamReader.cxx | 10 ++-- panda/src/putil/bitArray.cxx | 4 ++ panda/src/putil/buttonHandle.cxx | 4 +- panda/src/putil/buttonMap.cxx | 6 +-- panda/src/putil/buttonRegistry.cxx | 8 +-- panda/src/putil/callbackData.cxx | 2 +- panda/src/putil/callbackObject.cxx | 2 +- panda/src/putil/clockObject.cxx | 8 ++- panda/src/putil/colorSpace.cxx | 5 ++ panda/src/putil/datagramBuffer.cxx | 6 +-- panda/src/putil/datagramInputFile.cxx | 17 ++++--- panda/src/putil/datagramOutputFile.cxx | 10 ++-- panda/src/putil/factoryBase.cxx | 2 +- panda/src/putil/globalPointerRegistry.cxx | 2 +- panda/src/putil/keyboardButton.cxx | 2 +- panda/src/putil/load_prc_file.cxx | 8 +-- panda/src/putil/loaderOptions.cxx | 8 +-- panda/src/putil/modifierButtons.cxx | 8 +-- panda/src/putil/mouseData.cxx | 2 +- panda/src/putil/nameUniquifier.cxx | 2 + panda/src/putil/paramValue.cxx | 2 +- panda/src/putil/sparseArray.cxx | 8 +-- panda/src/putil/test_bam.cxx | 2 + panda/src/putil/test_bamRead.cxx | 8 +-- panda/src/putil/test_bamWrite.cxx | 2 +- panda/src/putil/test_glob.cxx | 6 +-- panda/src/putil/test_uniqueIdAllocator.cxx | 4 +- panda/src/putil/typedWritable.cxx | 4 +- .../src/putil/typedWritableReferenceCount.cxx | 2 +- panda/src/putil/typedWritable_ext.cxx | 8 +-- panda/src/putil/uniqueIdAllocator.cxx | 6 ++- panda/src/recorder/mouseRecorder.cxx | 6 +-- panda/src/recorder/recorderController.cxx | 2 +- panda/src/recorder/recorderTable.cxx | 4 +- panda/src/recorder/socketStreamRecorder.cxx | 2 +- panda/src/rocket/rocketFileInterface.cxx | 8 +-- panda/src/rocket/rocketInputHandler.cxx | 2 +- panda/src/rocket/rocketRegion.cxx | 2 +- panda/src/speedtree/loaderFileTypeSrt.cxx | 4 +- panda/src/speedtree/loaderFileTypeStf.cxx | 4 +- panda/src/speedtree/speedTreeNode.cxx | 12 +++-- panda/src/speedtree/stBasicTerrain.cxx | 8 ++- panda/src/speedtree/stTerrain.cxx | 4 +- panda/src/speedtree/stTransform.cxx | 2 +- panda/src/speedtree/stTree.cxx | 4 +- panda/src/testbed/pgrid.cxx | 4 +- panda/src/testbed/pview.cxx | 11 ++-- panda/src/testbed/test_map.cxx | 8 ++- panda/src/testbed/test_texmem.cxx | 4 +- panda/src/text/config_text.cxx | 2 + panda/src/text/dynamicTextFont.cxx | 6 +-- panda/src/text/dynamicTextPage.cxx | 5 +- panda/src/text/fontPool.cxx | 8 +-- panda/src/text/geomTextGlyph.cxx | 4 +- panda/src/text/staticTextFont.cxx | 4 +- panda/src/text/textAssembler.cxx | 13 +++-- panda/src/text/textFont.cxx | 4 ++ panda/src/text/textGlyph.cxx | 5 +- panda/src/text/textNode.cxx | 12 +++-- panda/src/text/textProperties.cxx | 12 ++--- panda/src/text/textPropertiesManager.cxx | 4 +- panda/src/tform/buttonThrower.cxx | 6 ++- panda/src/tform/driveInterface.cxx | 5 +- panda/src/tform/mouseInterfaceNode.cxx | 2 +- panda/src/tform/mouseSubregion.cxx | 2 +- panda/src/tform/mouseWatcher.cxx | 12 +++-- panda/src/tform/mouseWatcherBase.cxx | 10 ++-- panda/src/tform/mouseWatcherParameter.cxx | 2 +- panda/src/tform/mouseWatcherRegion.cxx | 4 +- panda/src/tform/trackball.cxx | 2 +- panda/src/tform/transform2sg.cxx | 2 +- panda/src/tinydisplay/clip.cxx | 2 + panda/src/tinydisplay/store_pixel.cxx | 2 +- panda/src/tinydisplay/tinyGraphicsBuffer.cxx | 2 +- .../tinydisplay/tinyGraphicsStateGuardian.cxx | 15 +++--- .../tinydisplay/tinyOffscreenGraphicsPipe.cxx | 4 +- panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx | 4 +- panda/src/tinydisplay/tinySDLGraphicsPipe.cxx | 4 +- .../src/tinydisplay/tinySDLGraphicsWindow.cxx | 2 +- panda/src/tinydisplay/tinyWinGraphicsPipe.cxx | 4 +- .../src/tinydisplay/tinyWinGraphicsWindow.cxx | 2 +- panda/src/tinydisplay/tinyXGraphicsPipe.cxx | 6 +-- panda/src/tinydisplay/tinyXGraphicsWindow.cxx | 4 +- panda/src/tinydisplay/zbuffer.cxx | 3 ++ panda/src/vision/arToolKit.cxx | 4 +- panda/src/vision/openCVTexture.cxx | 10 ++-- panda/src/vision/webcamVideoCursorV4L.cxx | 2 +- panda/src/vision/webcamVideoDS.cxx | 3 ++ panda/src/vision/webcamVideoOpenCV.cxx | 2 +- panda/src/vision/webcamVideoV4L.cxx | 4 +- panda/src/vrpn/vrpnAnalog.cxx | 6 +-- panda/src/vrpn/vrpnAnalogDevice.cxx | 2 +- panda/src/vrpn/vrpnButton.cxx | 6 +-- panda/src/vrpn/vrpnButtonDevice.cxx | 2 +- panda/src/vrpn/vrpnClient.cxx | 4 +- panda/src/vrpn/vrpnDial.cxx | 6 +-- panda/src/vrpn/vrpnDialDevice.cxx | 2 +- panda/src/vrpn/vrpnTracker.cxx | 6 +-- panda/src/vrpn/vrpnTrackerDevice.cxx | 2 +- panda/src/wgldisplay/wglGraphicsBuffer.cxx | 2 +- panda/src/wgldisplay/wglGraphicsPipe.cxx | 10 ++-- .../wgldisplay/wglGraphicsStateGuardian.cxx | 6 +-- panda/src/wgldisplay/wglGraphicsWindow.cxx | 10 ++-- panda/src/windisplay/winGraphicsWindow.cxx | 15 +++--- panda/src/x11display/x11GraphicsPipe.cxx | 4 +- panda/src/x11display/x11GraphicsWindow.cxx | 6 ++- pandatool/src/assimp/assimpLoader.cxx | 4 ++ pandatool/src/assimp/loaderFileTypeAssimp.cxx | 2 + pandatool/src/assimp/pandaIOStream.cxx | 7 +-- pandatool/src/assimp/pandaIOSystem.cxx | 2 +- pandatool/src/bam/bamInfo.cxx | 4 +- pandatool/src/bam/eggToBam.cxx | 4 +- pandatool/src/bam/ptsToBam.cxx | 6 ++- .../src/converter/eggToSomethingConverter.cxx | 4 +- .../src/converter/somethingToEggConverter.cxx | 4 +- pandatool/src/cvscopy/cvsCopy.cxx | 2 + pandatool/src/cvscopy/cvsSourceDirectory.cxx | 2 + pandatool/src/cvscopy/cvsSourceTree.cxx | 4 +- pandatool/src/daeegg/daeCharacter.cxx | 6 +-- pandatool/src/daeegg/daeMaterials.cxx | 3 ++ pandatool/src/daeegg/daeToEggConverter.cxx | 3 ++ pandatool/src/daeegg/pre_fcollada_include.h | 4 ++ pandatool/src/daeprogs/daeToEgg.cxx | 2 +- pandatool/src/daeprogs/eggToDAE.cxx | 2 + pandatool/src/dxf/dxfFile.cxx | 4 ++ pandatool/src/dxf/dxfLayer.cxx | 2 +- pandatool/src/dxf/dxfLayerMap.cxx | 2 +- pandatool/src/dxfegg/dxfToEggConverter.cxx | 6 +-- pandatool/src/dxfegg/dxfToEggLayer.cxx | 2 +- pandatool/src/dxfprogs/eggToDXF.cxx | 6 +-- pandatool/src/dxfprogs/eggToDXFLayer.cxx | 2 + pandatool/src/egg-mkfont/eggMakeFont.cxx | 4 +- pandatool/src/egg-mkfont/rangeDescription.cxx | 4 +- pandatool/src/egg-optchar/eggOptchar.cxx | 4 ++ pandatool/src/egg-palettize/eggPalettize.cxx | 8 +-- pandatool/src/egg-palettize/txaFileFilter.cxx | 4 +- pandatool/src/egg-qtess/eggQtess.cxx | 10 ++-- pandatool/src/egg-qtess/isoPlacer.cxx | 2 +- pandatool/src/egg-qtess/qtessInputEntry.cxx | 8 +-- pandatool/src/egg-qtess/qtessInputFile.cxx | 4 +- pandatool/src/egg-qtess/qtessSurface.cxx | 5 +- pandatool/src/eggbase/eggBase.cxx | 2 + pandatool/src/eggbase/eggConverter.cxx | 4 +- pandatool/src/eggbase/eggMultiFilter.cxx | 2 +- pandatool/src/eggbase/eggReader.cxx | 2 +- pandatool/src/eggbase/eggToSomething.cxx | 6 +-- pandatool/src/eggbase/eggWriter.cxx | 2 +- pandatool/src/eggbase/somethingToEgg.cxx | 6 +-- pandatool/src/eggcharbase/eggBackPointer.cxx | 2 +- .../eggcharbase/eggCharacterCollection.cxx | 6 ++- .../src/eggcharbase/eggCharacterData.cxx | 12 ++--- .../src/eggcharbase/eggComponentData.cxx | 4 +- pandatool/src/eggcharbase/eggJointData.cxx | 6 ++- .../src/eggcharbase/eggJointNodePointer.cxx | 4 +- pandatool/src/eggcharbase/eggJointPointer.cxx | 4 +- .../src/eggcharbase/eggMatrixTablePointer.cxx | 2 + .../src/eggcharbase/eggScalarTablePointer.cxx | 2 +- pandatool/src/eggcharbase/eggSliderData.cxx | 2 +- pandatool/src/eggprogs/eggListTextures.cxx | 4 +- pandatool/src/eggprogs/eggRetargetAnim.cxx | 6 +-- pandatool/src/eggprogs/eggTextureCards.cxx | 2 + pandatool/src/eggprogs/eggToC.cxx | 3 ++ pandatool/src/eggprogs/eggTopstrip.cxx | 6 +-- pandatool/src/flt/fltBeadID.cxx | 6 +-- pandatool/src/flt/fltError.cxx | 4 +- pandatool/src/flt/fltExternalReference.cxx | 8 +-- pandatool/src/flt/fltHeader.cxx | 16 +++--- pandatool/src/flt/fltInstanceRef.cxx | 2 +- pandatool/src/flt/fltMeshPrimitive.cxx | 2 +- pandatool/src/flt/fltOpcode.cxx | 4 +- pandatool/src/flt/fltPackedColor.cxx | 2 +- pandatool/src/flt/fltRecord.cxx | 12 ++--- pandatool/src/flt/fltRecordReader.cxx | 2 +- pandatool/src/flt/fltRecordWriter.cxx | 6 +-- pandatool/src/flt/fltTexture.cxx | 8 +-- pandatool/src/flt/fltUnsupportedRecord.cxx | 2 +- pandatool/src/flt/fltVertexList.cxx | 2 +- pandatool/src/fltegg/fltToEggConverter.cxx | 2 + pandatool/src/fltegg/fltToEggLevelState.cxx | 2 +- pandatool/src/fltprogs/eggToFlt.cxx | 8 +-- pandatool/src/fltprogs/fltInfo.cxx | 2 +- pandatool/src/gtk-stats/gtkStats.cxx | 8 +-- pandatool/src/gtk-stats/gtkStatsChartMenu.cxx | 6 +-- pandatool/src/gtk-stats/gtkStatsGraph.cxx | 4 +- pandatool/src/gtk-stats/gtkStatsMonitor.cxx | 8 +-- pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx | 6 +-- .../src/gtk-stats/gtkStatsStripChart.cxx | 6 +-- pandatool/src/imagebase/imageWriter.cxx | 2 +- pandatool/src/imageprogs/imageResize.cxx | 4 +- pandatool/src/imageprogs/imageTrans.cxx | 2 +- .../src/imageprogs/imageTransformColors.cxx | 4 ++ pandatool/src/lwo/iffChunk.cxx | 4 +- pandatool/src/lwo/iffGenericChunk.cxx | 2 +- pandatool/src/lwo/iffId.cxx | 8 +-- pandatool/src/lwo/iffInputFile.cxx | 8 +-- pandatool/src/lwo/lwoBoundingBox.cxx | 2 +- pandatool/src/lwo/lwoClip.cxx | 2 +- .../src/lwo/lwoDiscontinuousVertexMap.cxx | 4 +- pandatool/src/lwo/lwoGroupChunk.cxx | 2 +- pandatool/src/lwo/lwoHeader.cxx | 2 +- pandatool/src/lwo/lwoInputFile.cxx | 2 + pandatool/src/lwo/lwoLayer.cxx | 4 +- pandatool/src/lwo/lwoPoints.cxx | 2 +- pandatool/src/lwo/lwoPolygonTags.cxx | 2 +- pandatool/src/lwo/lwoPolygons.cxx | 2 +- pandatool/src/lwo/lwoStillImage.cxx | 2 +- pandatool/src/lwo/lwoSurface.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlock.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockAxis.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockChannel.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockHeader.cxx | 10 ++-- pandatool/src/lwo/lwoSurfaceBlockImage.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx | 2 +- .../src/lwo/lwoSurfaceBlockProjection.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockTMap.cxx | 2 +- .../src/lwo/lwoSurfaceBlockTransform.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlockWrap.cxx | 2 +- pandatool/src/lwo/lwoSurfaceColor.cxx | 2 +- pandatool/src/lwo/lwoSurfaceParameter.cxx | 2 +- pandatool/src/lwo/lwoSurfaceSidedness.cxx | 2 +- .../src/lwo/lwoSurfaceSmoothingAngle.cxx | 2 +- pandatool/src/lwo/lwoTags.cxx | 8 +-- pandatool/src/lwo/lwoVertexMap.cxx | 2 +- pandatool/src/lwoegg/cLwoPoints.cxx | 6 +-- pandatool/src/lwoegg/cLwoPolygons.cxx | 2 + pandatool/src/lwoegg/cLwoSurface.cxx | 2 +- pandatool/src/lwoegg/lwoToEggConverter.cxx | 6 +-- pandatool/src/lwoprogs/lwoScan.cxx | 2 +- pandatool/src/maxegg/maxEggLoader.cxx | 10 ++-- pandatool/src/maxegg/maxToEggConverter.cxx | 8 +-- pandatool/src/maxprogs/maxEggImport.cxx | 2 +- pandatool/src/maya/mayaApi.cxx | 6 ++- pandatool/src/maya/mayaShader.cxx | 7 ++- pandatool/src/maya/mayaShaderColorDef.cxx | 5 +- pandatool/src/maya/mayaShaders.cxx | 2 + pandatool/src/maya/maya_funcs.cxx | 3 ++ pandatool/src/mayaegg/mayaBlendDesc.cxx | 2 +- pandatool/src/mayaegg/mayaEggLoader.cxx | 8 ++- pandatool/src/mayaegg/mayaNodeDesc.cxx | 8 +-- pandatool/src/mayaegg/mayaNodeTree.cxx | 4 +- pandatool/src/mayaegg/mayaToEggConverter.cxx | 5 +- pandatool/src/mayaprogs/blend_test.cxx | 4 +- pandatool/src/mayaprogs/mayaCopy.cxx | 3 ++ pandatool/src/mayaprogs/mayaEggImport.cxx | 2 +- pandatool/src/mayaprogs/mayaPview.cxx | 6 +-- pandatool/src/mayaprogs/mayaToEgg.cxx | 2 +- pandatool/src/mayaprogs/mayaToEgg_client.cxx | 2 +- pandatool/src/mayaprogs/mayaToEgg_server.cxx | 8 +-- pandatool/src/mayaprogs/mayapath.cxx | 4 ++ pandatool/src/mayaprogs/normal_test.cxx | 3 +- pandatool/src/miscprogs/binToC.cxx | 12 ++--- pandatool/src/objegg/eggToObjConverter.cxx | 3 ++ pandatool/src/objegg/objToEggConverter.cxx | 10 ++-- pandatool/src/palettizer/destTextureImage.cxx | 4 +- pandatool/src/palettizer/eggFile.cxx | 8 +-- pandatool/src/palettizer/imageFile.cxx | 4 +- pandatool/src/palettizer/omitReason.cxx | 4 +- pandatool/src/palettizer/pal_string_utils.cxx | 2 + pandatool/src/palettizer/paletteGroup.cxx | 4 +- pandatool/src/palettizer/paletteGroups.cxx | 4 +- pandatool/src/palettizer/paletteImage.cxx | 8 +-- pandatool/src/palettizer/palettePage.cxx | 2 +- pandatool/src/palettizer/palettizer.cxx | 11 ++-- pandatool/src/palettizer/textureImage.cxx | 8 +-- .../src/palettizer/textureMemoryCounter.cxx | 12 ++--- pandatool/src/palettizer/texturePlacement.cxx | 7 ++- .../src/palettizer/textureProperties.cxx | 4 +- pandatool/src/palettizer/textureReference.cxx | 8 ++- pandatool/src/palettizer/txaFile.cxx | 8 +-- pandatool/src/palettizer/txaLine.cxx | 8 +-- .../src/pandatoolbase/animationConvert.cxx | 8 +-- pandatool/src/pandatoolbase/distanceUnit.cxx | 4 ++ pandatool/src/pandatoolbase/pathReplace.cxx | 6 +-- pandatool/src/pandatoolbase/pathStore.cxx | 8 +-- pandatool/src/pfmprogs/pfmBba.cxx | 2 +- pandatool/src/pfmprogs/pfmTrans.cxx | 2 + pandatool/src/progbase/programBase.cxx | 12 +++-- pandatool/src/progbase/withOutputFile.cxx | 4 +- pandatool/src/progbase/wordWrapStream.cxx | 2 +- pandatool/src/progbase/wordWrapStreamBuf.cxx | 10 ++-- pandatool/src/pstatserver/pStatClientData.cxx | 2 + pandatool/src/pstatserver/pStatGraph.cxx | 2 + pandatool/src/pstatserver/pStatMonitor.cxx | 2 + pandatool/src/pstatserver/pStatReader.cxx | 4 +- pandatool/src/pstatserver/pStatStripChart.cxx | 7 ++- .../src/ptloader/loaderFileTypePandatool.cxx | 6 +-- pandatool/src/softegg/softNodeDesc.cxx | 6 ++- pandatool/src/softegg/softNodeTree.cxx | 8 +-- pandatool/src/softegg/softToEggConverter.cxx | 3 ++ pandatool/src/softprogs/softCVS.cxx | 6 ++- pandatool/src/softprogs/softFilename.cxx | 2 + pandatool/src/text-stats/textMonitor.cxx | 4 +- pandatool/src/vrml/parse_vrml.cxx | 10 ++-- pandatool/src/vrml/vrmlLexer.cxx.prebuilt | 45 ++++++++-------- pandatool/src/vrml/vrmlLexer.lxx | 45 ++++++++-------- pandatool/src/vrml/vrmlNode.cxx | 8 +-- pandatool/src/vrml/vrmlNodeType.cxx | 6 ++- pandatool/src/vrml/vrmlParser.cxx.prebuilt | 16 +++--- pandatool/src/vrml/vrmlParser.yxx | 18 +++---- pandatool/src/vrmlegg/indexedFaceSet.cxx | 2 + pandatool/src/vrmlegg/vrmlToEggConverter.cxx | 10 ++-- pandatool/src/win-stats/winStats.cxx | 8 +-- pandatool/src/win-stats/winStatsChartMenu.cxx | 6 +-- pandatool/src/win-stats/winStatsGraph.cxx | 6 +-- .../src/win-stats/winStatsLabelStack.cxx | 4 +- pandatool/src/win-stats/winStatsMonitor.cxx | 6 +-- pandatool/src/win-stats/winStatsPianoRoll.cxx | 6 +-- .../src/win-stats/winStatsStripChart.cxx | 2 + pandatool/src/xfile/windowsGuid.cxx | 4 +- pandatool/src/xfile/xFile.cxx | 5 ++ pandatool/src/xfile/xFileArrayDef.cxx | 2 +- pandatool/src/xfile/xFileDataDef.cxx | 4 +- pandatool/src/xfile/xFileDataNode.cxx | 6 +-- .../src/xfile/xFileDataNodeReference.cxx | 4 +- pandatool/src/xfile/xFileDataNodeTemplate.cxx | 6 ++- pandatool/src/xfile/xFileDataObject.cxx | 6 ++- pandatool/src/xfile/xFileDataObjectArray.cxx | 2 +- pandatool/src/xfile/xFileDataObjectDouble.cxx | 6 +-- .../src/xfile/xFileDataObjectInteger.cxx | 6 +-- pandatool/src/xfile/xFileDataObjectString.cxx | 8 +-- pandatool/src/xfile/xFileNode.cxx | 4 +- pandatool/src/xfile/xFileParseData.cxx | 2 +- pandatool/src/xfile/xFileTemplate.cxx | 4 +- pandatool/src/xfile/xLexer.cxx.prebuilt | 51 +++++++++---------- pandatool/src/xfile/xLexer.lxx | 51 +++++++++---------- pandatool/src/xfile/xParser.cxx.prebuilt | 4 +- pandatool/src/xfile/xParser.yxx | 4 +- pandatool/src/xfileegg/xFileAnimationSet.cxx | 6 +-- pandatool/src/xfileegg/xFileMaker.cxx | 2 +- pandatool/src/xfileegg/xFileMaterial.cxx | 2 +- pandatool/src/xfileegg/xFileMesh.cxx | 9 ++-- .../src/xfileegg/xFileToEggConverter.cxx | 2 + 1325 files changed, 4190 insertions(+), 2743 deletions(-) diff --git a/contrib/src/ai/aiBehaviors.cxx b/contrib/src/ai/aiBehaviors.cxx index 38d32b1026..1ace436e5b 100644 --- a/contrib/src/ai/aiBehaviors.cxx +++ b/contrib/src/ai/aiBehaviors.cxx @@ -13,6 +13,10 @@ #include "aiBehaviors.h" +using std::cout; +using std::endl; +using std::string; + static const float _PI = 3.14; AIBehaviors::AIBehaviors() { diff --git a/contrib/src/ai/aiCharacter.cxx b/contrib/src/ai/aiCharacter.cxx index 240f1a4ea3..58485081c3 100644 --- a/contrib/src/ai/aiCharacter.cxx +++ b/contrib/src/ai/aiCharacter.cxx @@ -13,7 +13,7 @@ #include "aiCharacter.h" -AICharacter::AICharacter(string model_name, NodePath model_np, double mass, double movt_force, double max_force) { +AICharacter::AICharacter(std::string model_name, NodePath model_np, double mass, double movt_force, double max_force) { _name = model_name; _ai_char_np = model_np; diff --git a/contrib/src/ai/aiPathFinder.cxx b/contrib/src/ai/aiPathFinder.cxx index 8167a6e42e..be2b2dd56a 100644 --- a/contrib/src/ai/aiPathFinder.cxx +++ b/contrib/src/ai/aiPathFinder.cxx @@ -74,7 +74,7 @@ void PathFinder::generate_path() { add_to_clist(nxt_node); } } - cout<<"DESTINATION NOT REACHABLE MATE!"<_world = this; } -void AIWorld::remove_ai_char(string name) { +void AIWorld::remove_ai_char(std::string name) { AICharPool::iterator it; for (it = _ai_char_pool.begin(); it != _ai_char_pool.end(); ++it) { AICharacter *ai_char = *it; @@ -38,10 +38,10 @@ void AIWorld::remove_ai_char(string name) { } } - remove_ai_char_from_flock(move(name)); + remove_ai_char_from_flock(std::move(name)); } -void AIWorld::remove_ai_char_from_flock(string name) { +void AIWorld::remove_ai_char_from_flock(std::string name) { for (AICharacter *ai_char : _ai_char_pool) { for (Flock *flock : _flock_pool) { if (ai_char->_ai_char_flock_id == flock->get_id()) { @@ -62,7 +62,7 @@ void AIWorld::remove_ai_char_from_flock(string name) { */ void AIWorld::print_list() { for (AICharacter *ai_char : _ai_char_pool) { - cout << ai_char->_name << endl; + std::cout << ai_char->_name << std::endl; } } diff --git a/contrib/src/ai/arrival.cxx b/contrib/src/ai/arrival.cxx index af7400d170..966a6b2611 100644 --- a/contrib/src/ai/arrival.cxx +++ b/contrib/src/ai/arrival.cxx @@ -77,7 +77,7 @@ LVecBase3 Arrival::do_arrival() { return(desired_force); } - cout<<"Arrival works only with seek and pursue"< 0) { diff --git a/contrib/src/rplight/gpuCommand.cxx b/contrib/src/rplight/gpuCommand.cxx index 2bd468c902..0b977bc5bb 100644 --- a/contrib/src/rplight/gpuCommand.cxx +++ b/contrib/src/rplight/gpuCommand.cxx @@ -57,13 +57,13 @@ GPUCommand::GPUCommand(CommandType command_type) { * in mind that integers might be shown in their binary float representation, * depending on the setting in the GPUCommand::convert_int_to_float method. */ -void GPUCommand::write(ostream &out) const { - out << "GPUCommand(type=" << _command_type << ", size=" << _current_index << ", data = {" << endl; +void GPUCommand::write(std::ostream &out) const { + out << "GPUCommand(type=" << _command_type << ", size=" << _current_index << ", data = {" << std::endl; for (size_t k = 0; k < GPU_COMMAND_ENTRIES; ++k) { out << std::setw(12) << std::fixed << std::setprecision(5) << _data[k] << " "; - if (k % 6 == 5 || k == GPU_COMMAND_ENTRIES - 1) out << endl; + if (k % 6 == 5 || k == GPU_COMMAND_ENTRIES - 1) out << std::endl; } - out << "})" << endl; + out << "})" << std::endl; } /** diff --git a/contrib/src/rplight/iesDataset.cxx b/contrib/src/rplight/iesDataset.cxx index 34f5a8608e..9aafbf2f86 100644 --- a/contrib/src/rplight/iesDataset.cxx +++ b/contrib/src/rplight/iesDataset.cxx @@ -141,7 +141,7 @@ float IESDataset::get_candela_value(float vertical_angle, float horizontal_angle iesdataset_cat.error() << "Invalid horizontal lerp: " << lerp << ", requested angle was " << horizontal_angle << ", prev = " << prev_angle << ", cur = " << curr_angle - << endl; + << std::endl; } return curr_value * lerp + prev_value * (1-lerp); @@ -192,7 +192,7 @@ float IESDataset::get_vertical_candela_value(size_t horizontal_angle_idx, float iesdataset_cat.error() << "ERROR: Invalid vertical lerp: " << lerp << ", requested angle was " << vertical_angle << ", prev = " << prev_angle << ", cur = " << curr_angle - << endl; + << std::endl; } return curr_value * lerp + prev_value * (1-lerp); diff --git a/contrib/src/rplight/internalLightManager.cxx b/contrib/src/rplight/internalLightManager.cxx index ea45c518fd..3d80294f82 100644 --- a/contrib/src/rplight/internalLightManager.cxx +++ b/contrib/src/rplight/internalLightManager.cxx @@ -29,6 +29,8 @@ #include +using std::endl; + NotifyCategoryDef(lightmgr, ""); @@ -355,7 +357,7 @@ bool InternalLightManager::compare_shadow_sources(const ShadowSource* a, const S void InternalLightManager::update_shadow_sources() { // Find all dirty shadow sources and make a list of them - vector sources_to_update; + std::vector sources_to_update; for (auto iter = _shadow_sources.begin(); iter != _shadow_sources.end(); ++iter) { ShadowSource* source = *iter; if (source) { @@ -393,7 +395,7 @@ void InternalLightManager::update_shadow_sources() { // Free the regions of all sources which will get updated. We have to take into // account that only a limited amount of sources can get updated per frame. - size_t update_slots = min(sources_to_update.size(), + size_t update_slots = std::min(sources_to_update.size(), _shadow_manager->get_num_update_slots_left()); for(size_t i = 0; i < update_slots; ++i) { if (sources_to_update[i]->has_region()) { diff --git a/contrib/src/rplight/shadowAtlas.cxx b/contrib/src/rplight/shadowAtlas.cxx index 15d4ea1bd0..fa2b2d3076 100644 --- a/contrib/src/rplight/shadowAtlas.cxx +++ b/contrib/src/rplight/shadowAtlas.cxx @@ -131,13 +131,13 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h // Check for empty region if (tile_width < 1 || tile_height < 1) { - shadowatlas_cat.error() << "Called find_and_reserve_region with null-region!" << endl; + shadowatlas_cat.error() << "Called find_and_reserve_region with null-region!" << std::endl; return LVecBase4i(-1); } // Check for region bigger than the shadow atlas if (tile_width > _num_tiles || tile_height > _num_tiles) { - shadowatlas_cat.error() << "Requested region exceeds shadow atlas size!" << endl; + shadowatlas_cat.error() << "Requested region exceeds shadow atlas size!" << std::endl; return LVecBase4i(-1); } @@ -155,7 +155,7 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h // When we reached this part, we couldn't find a free region, so the atlas // seems to be full. shadowatlas_cat.error() << "Failed to find a free region of size " << tile_width - << " x " << tile_height << "!" << endl; + << " x " << tile_height << "!" << std::endl; return LVecBase4i(-1); } diff --git a/contrib/src/rplight/tagStateManager.cxx b/contrib/src/rplight/tagStateManager.cxx index ddc996f9a4..30653d1f79 100644 --- a/contrib/src/rplight/tagStateManager.cxx +++ b/contrib/src/rplight/tagStateManager.cxx @@ -27,6 +27,8 @@ #include "tagStateManager.h" +using std::endl; + NotifyCategoryDef(tagstatemgr, ""); @@ -77,7 +79,7 @@ TagStateManager:: */ void TagStateManager:: apply_state(StateContainer& container, NodePath np, Shader* shader, - const string &name, int sort) { + const std::string &name, int sort) { if (tagstatemgr_cat.is_spam()) { tagstatemgr_cat.spam() << "Constructing new state " << name << " with shader " << shader << endl; diff --git a/direct/src/dcparse/dcparse.cxx b/direct/src/dcparse/dcparse.cxx index 9fbd4ef063..b12323bb4a 100644 --- a/direct/src/dcparse/dcparse.cxx +++ b/direct/src/dcparse/dcparse.cxx @@ -19,6 +19,9 @@ #include "indent.h" #include "panda_getopt.h" +using std::cerr; +using std::cout; + void usage() { cerr << diff --git a/direct/src/dcparser/dcArrayParameter.cxx b/direct/src/dcparser/dcArrayParameter.cxx index b8101128bd..2f2ea69932 100644 --- a/direct/src/dcparser/dcArrayParameter.cxx +++ b/direct/src/dcparser/dcArrayParameter.cxx @@ -16,6 +16,8 @@ #include "dcClassParameter.h" #include "hashGenerator.h" +using std::string; + /** * */ @@ -201,13 +203,13 @@ validate_num_nested_fields(int num_nested_fields) const { * identifier. */ void DCArrayParameter:: -output_instance(ostream &out, bool brief, const string &prename, +output_instance(std::ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { - ostringstream strm; + std::ostringstream strm; strm << "["; _array_size_range.output(strm); diff --git a/direct/src/dcparser/dcAtomicField.cxx b/direct/src/dcparser/dcAtomicField.cxx index c3f0dc365b..3efebfa2d6 100644 --- a/direct/src/dcparser/dcAtomicField.cxx +++ b/direct/src/dcparser/dcAtomicField.cxx @@ -19,6 +19,8 @@ #include +using std::string; + /** * */ @@ -151,7 +153,7 @@ get_element_divisor(int n) const { * */ void DCAtomicField:: -output(ostream &out, bool brief) const { +output(std::ostream &out, bool brief) const { out << _name << "("; if (!_elements.empty()) { @@ -174,7 +176,7 @@ output(ostream &out, bool brief) const { * stream. */ void DCAtomicField:: -write(ostream &out, bool brief, int indent_level) const { +write(std::ostream &out, bool brief, int indent_level) const { indent(out, indent_level); output(out, brief); out << ";"; @@ -270,7 +272,7 @@ do_check_match_atomic_field(const DCAtomicField *other) const { * */ void DCAtomicField:: -output_element(ostream &out, bool brief, DCParameter *element) const { +output_element(std::ostream &out, bool brief, DCParameter *element) const { element->output(out, brief); if (!brief && element->has_default_value()) { diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 3d311e6506..4c428db595 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -25,6 +25,10 @@ #include "py_panda.h" #endif +using std::ostream; +using std::ostringstream; +using std::string; + #ifdef WITHIN_PANDA #include "pStatTimer.h" @@ -177,9 +181,9 @@ DCField *DCClass:: get_field(int n) const { #ifndef NDEBUG //[ if (n < 0 || n >= (int)_fields.size()) { - cerr << *this << " " + std::cerr << *this << " " << "n:" << n << " _fields.size():" - << (int)_fields.size() << endl; + << (int)_fields.size() << std::endl; // __asm { int 3 } } #endif //] @@ -749,7 +753,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj, if (result == nullptr) { // We don't set this as an exception, since presumably the Python method // itself has already triggered a Python exception. - cerr << "Error when calling " << getter_name << "\n"; + std::cerr << "Error when calling " << getter_name << "\n"; return false; } diff --git a/direct/src/dcparser/dcClassParameter.cxx b/direct/src/dcparser/dcClassParameter.cxx index 379dbb5961..a3bc68d5eb 100644 --- a/direct/src/dcparser/dcClassParameter.cxx +++ b/direct/src/dcparser/dcClassParameter.cxx @@ -128,8 +128,8 @@ get_nested_field(int n) const { * identifier. */ void DCClassParameter:: -output_instance(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const { +output_instance(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const { if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); diff --git a/direct/src/dcparser/dcDeclaration.cxx b/direct/src/dcparser/dcDeclaration.cxx index 7da467a44a..bf8830f046 100644 --- a/direct/src/dcparser/dcDeclaration.cxx +++ b/direct/src/dcparser/dcDeclaration.cxx @@ -57,7 +57,7 @@ as_switch() const { * Write a string representation of this instance to . */ void DCDeclaration:: -output(ostream &out) const { +output(std::ostream &out) const { output(out, true); } @@ -65,6 +65,6 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void DCDeclaration:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write(out, false, indent_level); } diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index eeace485c6..4f255dea7d 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -26,6 +26,8 @@ #include "pStatTimer.h" #endif +using std::string; + /** * */ @@ -232,7 +234,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const { } if (!Notify::ptr()->has_assert_failed()) { - ostringstream strm; + std::ostringstream strm; PyObject *exc_type = PyExc_Exception; if (as_parameter() != nullptr) { @@ -303,7 +305,7 @@ unpack_args(DCPacker &packer) const { } if (!Notify::ptr()->has_assert_failed()) { - ostringstream strm; + std::ostringstream strm; PyObject *exc_type = PyExc_Exception; if (packer.had_pack_error()) { @@ -315,7 +317,7 @@ unpack_args(DCPacker &packer) const { dg.dump_hex(strm); size_t error_byte = packer.get_num_unpacked_bytes() - start_byte; strm << "Error detected on byte " << error_byte - << " (" << hex << error_byte << dec << " hex)"; + << " (" << std::hex << error_byte << std::dec << " hex)"; exc_type = PyExc_RuntimeError; } else { @@ -562,7 +564,7 @@ refresh_default_value() { packer.begin_pack(this); packer.pack_default_value(); if (!packer.end_pack()) { - cerr << "Error while packing default value for " << get_name() << "\n"; + std::cerr << "Error while packing default value for " << get_name() << "\n"; } else { _default_value.assign(packer.get_data(), packer.get_length()); } diff --git a/direct/src/dcparser/dcFile.cxx b/direct/src/dcparser/dcFile.cxx index 43301e4615..be69b4b18c 100644 --- a/direct/src/dcparser/dcFile.cxx +++ b/direct/src/dcparser/dcFile.cxx @@ -28,6 +28,9 @@ #include "configVariableList.h" #endif +using std::cerr; +using std::string; + /** * @@ -122,7 +125,7 @@ read(Filename filename) { #ifdef WITHIN_PANDA filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *in = vfs->open_read_file(filename, true); + std::istream *in = vfs->open_read_file(filename, true); if (in == nullptr) { cerr << "Cannot open " << filename << " for reading.\n"; return false; @@ -163,7 +166,7 @@ read(Filename filename) { * (in which case the file might have been partially read). */ bool DCFile:: -read(istream &in, const string &filename) { +read(std::istream &in, const string &filename) { cerr << "DCFile::read of " << filename << "\n"; dc_init_parser(in, filename, *this); dcyyparse(); @@ -203,7 +206,7 @@ write(Filename filename, bool brief) const { * Returns true if the description is successfully written, false otherwise. */ bool DCFile:: -write(ostream &out, bool brief) const { +write(std::ostream &out, bool brief) const { if (!_imports.empty()) { Imports::const_iterator ii; for (ii = _imports.begin(); ii != _imports.end(); ++ii) { diff --git a/direct/src/dcparser/dcKeyword.cxx b/direct/src/dcparser/dcKeyword.cxx index 17dcab8df2..ef9c497b7d 100644 --- a/direct/src/dcparser/dcKeyword.cxx +++ b/direct/src/dcparser/dcKeyword.cxx @@ -19,7 +19,7 @@ * */ DCKeyword:: -DCKeyword(const string &name, int historical_flag) : +DCKeyword(const std::string &name, int historical_flag) : _name(name), _historical_flag(historical_flag) { @@ -35,7 +35,7 @@ DCKeyword:: /** * Returns the name of this keyword. */ -const string &DCKeyword:: +const std::string &DCKeyword:: get_name() const { return _name; } @@ -64,7 +64,7 @@ clear_historical_flag() { * Write a string representation of this instance to . */ void DCKeyword:: -output(ostream &out, bool brief) const { +output(std::ostream &out, bool brief) const { out << "keyword " << _name; } @@ -72,7 +72,7 @@ output(ostream &out, bool brief) const { * */ void DCKeyword:: -write(ostream &out, bool, int indent_level) const { +write(std::ostream &out, bool, int indent_level) const { indent(out, indent_level) << "keyword " << _name << ";\n"; } diff --git a/direct/src/dcparser/dcKeywordList.cxx b/direct/src/dcparser/dcKeywordList.cxx index c2cba110b6..cdfdd4f7f5 100644 --- a/direct/src/dcparser/dcKeywordList.cxx +++ b/direct/src/dcparser/dcKeywordList.cxx @@ -57,7 +57,7 @@ DCKeywordList:: * Returns true if this list includes the indicated keyword, false otherwise. */ bool DCKeywordList:: -has_keyword(const string &name) const { +has_keyword(const std::string &name) const { return (_keywords_by_name.find(name) != _keywords_by_name.end()); } @@ -92,7 +92,7 @@ get_keyword(int n) const { * is no keyword in the list with that name. */ const DCKeyword *DCKeywordList:: -get_keyword_by_name(const string &name) const { +get_keyword_by_name(const std::string &name) const { KeywordsByName::const_iterator ni; ni = _keywords_by_name.find(name); if (ni != _keywords_by_name.end()) { @@ -148,7 +148,7 @@ clear_keywords() { * */ void DCKeywordList:: -output_keywords(ostream &out) const { +output_keywords(std::ostream &out) const { Keywords::const_iterator ki; for (ki = _keywords.begin(); ki != _keywords.end(); ++ki) { out << " " << (*ki)->get_name(); diff --git a/direct/src/dcparser/dcLexer.cxx.prebuilt b/direct/src/dcparser/dcLexer.cxx.prebuilt index f99b920f81..70333927fe 100644 --- a/direct/src/dcparser/dcLexer.cxx.prebuilt +++ b/direct/src/dcparser/dcLexer.cxx.prebuilt @@ -610,11 +610,11 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static std::istream *input_p = nullptr; // This is the name of the dc file we're parsing. We keep it so we // can print it out for error messages. -static string dc_filename; +static std::string dc_filename; // This is the initial token state returned by the lexer. It allows // the yacc grammar to start from initial points. @@ -626,7 +626,7 @@ static int initial_token; //////////////////////////////////////////////////////////////////// void -dc_init_lexer(istream &in, const string &filename) { +dc_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ dc_filename = filename; line_number = 0; @@ -671,7 +671,9 @@ dcyywrap(void) { } void -dcyyerror(const string &msg) { +dcyyerror(const std::string &msg) { + using std::cerr; + cerr << "\nError"; if (!dc_filename.empty()) { cerr << " in " << dc_filename; @@ -686,7 +688,9 @@ dcyyerror(const string &msg) { } void -dcyywarning(const string &msg) { +dcyywarning(const std::string &msg) { + using std::cerr; + cerr << "\nWarning"; if (!dc_filename.empty()) { cerr << " in " << dc_filename; @@ -762,9 +766,9 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string +static std::string scan_quoted_string(char quote_mark) { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -884,9 +888,9 @@ scan_quoted_string(char quote_mark) { // scan_hex_string reads a string of hexadecimal digits delimited by // angle brackets and returns the representative string. -static string +static std::string scan_hex_string() { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -916,7 +920,7 @@ scan_hex_string() { line_number = line; col_number = col; dcyyerror("Invalid hex digit."); - return string(); + return std::string(); } odd = !odd; @@ -930,10 +934,10 @@ scan_hex_string() { if (c == EOF) { dcyyerror("This hex string is unterminated."); - return string(); + return std::string(); } else if (odd) { dcyyerror("Odd number of hex digits."); - return string(); + return std::string(); } line_number = line; diff --git a/direct/src/dcparser/dcLexer.lxx b/direct/src/dcparser/dcLexer.lxx index b2d83dad47..423bfe9a99 100644 --- a/direct/src/dcparser/dcLexer.lxx +++ b/direct/src/dcparser/dcLexer.lxx @@ -35,11 +35,11 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = nullptr; +static std::istream *input_p = nullptr; // This is the name of the dc file we're parsing. We keep it so we // can print it out for error messages. -static string dc_filename; +static std::string dc_filename; // This is the initial token state returned by the lexer. It allows // the yacc grammar to start from initial points. @@ -51,7 +51,7 @@ static int initial_token; //////////////////////////////////////////////////////////////////// void -dc_init_lexer(istream &in, const string &filename) { +dc_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ dc_filename = filename; line_number = 0; @@ -96,7 +96,9 @@ dcyywrap(void) { } void -dcyyerror(const string &msg) { +dcyyerror(const std::string &msg) { + using std::cerr; + cerr << "\nError"; if (!dc_filename.empty()) { cerr << " in " << dc_filename; @@ -111,7 +113,9 @@ dcyyerror(const string &msg) { } void -dcyywarning(const string &msg) { +dcyywarning(const std::string &msg) { + using std::cerr; + cerr << "\nWarning"; if (!dc_filename.empty()) { cerr << " in " << dc_filename; @@ -187,9 +191,9 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string +static std::string scan_quoted_string(char quote_mark) { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -309,9 +313,9 @@ scan_quoted_string(char quote_mark) { // scan_hex_string reads a string of hexadecimal digits delimited by // angle brackets and returns the representative string. -static string +static std::string scan_hex_string() { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -341,7 +345,7 @@ scan_hex_string() { line_number = line; col_number = col; dcyyerror("Invalid hex digit."); - return string(); + return std::string(); } odd = !odd; @@ -355,10 +359,10 @@ scan_hex_string() { if (c == EOF) { dcyyerror("This hex string is unterminated."); - return string(); + return std::string(); } else if (odd) { dcyyerror("Odd number of hex digits."); - return string(); + return std::string(); } line_number = line; diff --git a/direct/src/dcparser/dcMolecularField.cxx b/direct/src/dcparser/dcMolecularField.cxx index 178c86ad2e..b5e18094a9 100644 --- a/direct/src/dcparser/dcMolecularField.cxx +++ b/direct/src/dcparser/dcMolecularField.cxx @@ -22,7 +22,7 @@ * */ DCMolecularField:: -DCMolecularField(const string &name, DCClass *dclass) : DCField(name, dclass) { +DCMolecularField(const std::string &name, DCClass *dclass) : DCField(name, dclass) { _got_keywords = false; } @@ -109,7 +109,7 @@ add_atomic(DCAtomicField *atomic) { * */ void DCMolecularField:: -output(ostream &out, bool brief) const { +output(std::ostream &out, bool brief) const { out << _name; if (!_fields.empty()) { @@ -130,7 +130,7 @@ output(ostream &out, bool brief) const { * stream. */ void DCMolecularField:: -write(ostream &out, bool brief, int indent_level) const { +write(std::ostream &out, bool brief, int indent_level) const { indent(out, indent_level); output(out, brief); if (!brief) { diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index 119add847e..ebab348f6f 100644 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -23,6 +23,12 @@ #include "py_panda.h" #endif +using std::istream; +using std::istringstream; +using std::ostream; +using std::ostringstream; +using std::string; + DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = nullptr; int DCPacker::StackElement::_num_ever_allocated = 0; @@ -786,7 +792,7 @@ pack_object(PyObject *object) { pack_object(element); Py_DECREF(element); } else { - cerr << "Unable to extract item " << i << " from sequence.\n"; + std::cerr << "Unable to extract item " << i << " from sequence.\n"; } } pop(); @@ -903,7 +909,7 @@ unpack_object() { // constructor, create the class object instead of just a tuple. object = unpack_class_object(dclass); if (object == nullptr) { - cerr << "Unable to construct object of class " + std::cerr << "Unable to construct object of class " << dclass->get_name() << "\n"; } else { break; diff --git a/direct/src/dcparser/dcPackerCatalog.cxx b/direct/src/dcparser/dcPackerCatalog.cxx index 0eda4197b6..594c7b6742 100644 --- a/direct/src/dcparser/dcPackerCatalog.cxx +++ b/direct/src/dcparser/dcPackerCatalog.cxx @@ -16,6 +16,8 @@ #include "dcPacker.h" #include "dcSwitchParameter.h" +using std::string; + /** * The catalog is created only by DCPackerInterface::get_catalog(). */ diff --git a/direct/src/dcparser/dcPackerInterface.cxx b/direct/src/dcparser/dcPackerInterface.cxx index dd6e4ae482..d17ff1f7b7 100644 --- a/direct/src/dcparser/dcPackerInterface.cxx +++ b/direct/src/dcparser/dcPackerInterface.cxx @@ -17,6 +17,8 @@ #include "dcParserDefs.h" #include "dcLexerDefs.h" +using std::string; + /** * */ @@ -139,7 +141,7 @@ bool DCPackerInterface:: check_match(const string &description, DCFile *dcfile) const { bool match = false; - istringstream strm(description); + std::istringstream strm(description); dc_init_parser_parameter_description(strm, "check_match", dcfile); dcyyparse(); dc_cleanup_parser(); diff --git a/direct/src/dcparser/dcParameter.cxx b/direct/src/dcparser/dcParameter.cxx index ef1c50997f..61b13ff04a 100644 --- a/direct/src/dcparser/dcParameter.cxx +++ b/direct/src/dcparser/dcParameter.cxx @@ -17,6 +17,9 @@ #include "dcindent.h" #include "dcTypedef.h" +using std::ostream; +using std::string; + /** * */ diff --git a/direct/src/dcparser/dcParser.cxx.prebuilt b/direct/src/dcparser/dcParser.cxx.prebuilt index a7f911e452..80df4b2b09 100644 --- a/direct/src/dcparser/dcParser.cxx.prebuilt +++ b/direct/src/dcparser/dcParser.cxx.prebuilt @@ -101,6 +101,10 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 +using std::istream; +using std::ostringstream; +using std::string; + DCFile *dc_file = (DCFile *)NULL; static DCClass *current_class = (DCClass *)NULL; static DCSwitch *current_switch = (DCSwitch *)NULL; diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index 8b9c7e40ad..0a5c3d6aa0 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -29,6 +29,10 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 +using std::istream; +using std::ostringstream; +using std::string; + DCFile *dc_file = nullptr; static DCClass *current_class = nullptr; static DCSwitch *current_switch = nullptr; diff --git a/direct/src/dcparser/dcSimpleParameter.cxx b/direct/src/dcparser/dcSimpleParameter.cxx index 34f4e7e402..bd2cb05534 100644 --- a/direct/src/dcparser/dcSimpleParameter.cxx +++ b/direct/src/dcparser/dcSimpleParameter.cxx @@ -20,6 +20,8 @@ #include "hashGenerator.h" #include +using std::string; + DCSimpleParameter::NestedFieldMap DCSimpleParameter::_nested_field_map; DCClassParameter *DCSimpleParameter::_uint32uint8_type = nullptr; @@ -2171,7 +2173,7 @@ unpack_skip(const char *data, size_t length, size_t &p, * identifier. */ void DCSimpleParameter:: -output_instance(ostream &out, bool brief, const string &prename, +output_instance(std::ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); diff --git a/direct/src/dcparser/dcSubatomicType.cxx b/direct/src/dcparser/dcSubatomicType.cxx index 1489fe3a3f..841edf7155 100644 --- a/direct/src/dcparser/dcSubatomicType.cxx +++ b/direct/src/dcparser/dcSubatomicType.cxx @@ -13,8 +13,8 @@ #include "dcSubatomicType.h" -ostream & -operator << (ostream &out, DCSubatomicType type) { +std::ostream & +operator << (std::ostream &out, DCSubatomicType type) { switch (type) { case ST_int8: return out << "int8"; diff --git a/direct/src/dcparser/dcSwitch.cxx b/direct/src/dcparser/dcSwitch.cxx index ee3c70f7c5..5b23505209 100644 --- a/direct/src/dcparser/dcSwitch.cxx +++ b/direct/src/dcparser/dcSwitch.cxx @@ -18,6 +18,9 @@ #include "dcindent.h" #include "dcPacker.h" +using std::ostream; +using std::string; + /** * The key_parameter must be recently allocated via new; it will be deleted * via delete when the switch destructs. diff --git a/direct/src/dcparser/dcSwitchParameter.cxx b/direct/src/dcparser/dcSwitchParameter.cxx index 8f3b7ccf00..d4f2c10394 100644 --- a/direct/src/dcparser/dcSwitchParameter.cxx +++ b/direct/src/dcparser/dcSwitchParameter.cxx @@ -15,6 +15,8 @@ #include "dcSwitch.h" #include "hashGenerator.h" +using std::string; + /** * */ @@ -153,7 +155,7 @@ apply_switch(const char *value_data, size_t length) const { * identifier. */ void DCSwitchParameter:: -output_instance(ostream &out, bool brief, const string &prename, +output_instance(std::ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); @@ -168,7 +170,7 @@ output_instance(ostream &out, bool brief, const string &prename, * identifier. */ void DCSwitchParameter:: -write_instance(ostream &out, bool brief, int indent_level, +write_instance(std::ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const { if (get_typedef() != nullptr) { diff --git a/direct/src/dcparser/dcTypedef.cxx b/direct/src/dcparser/dcTypedef.cxx index cc45f74d49..a83f68e895 100644 --- a/direct/src/dcparser/dcTypedef.cxx +++ b/direct/src/dcparser/dcTypedef.cxx @@ -16,6 +16,8 @@ #include "dcSimpleParameter.h" #include "dcindent.h" +using std::string; + /** * The DCTypedef object becomes the owner of the supplied parameter pointer * and will delete it upon destruction. @@ -72,7 +74,7 @@ get_name() const { */ string DCTypedef:: get_description() const { - ostringstream strm; + std::ostringstream strm; _parameter->output(strm, true); return strm.str(); } @@ -122,7 +124,7 @@ set_number(int number) { * Write a string representation of this instance to . */ void DCTypedef:: -output(ostream &out, bool brief) const { +output(std::ostream &out, bool brief) const { out << "typedef "; _parameter->output(out, false); } @@ -131,7 +133,7 @@ output(ostream &out, bool brief) const { * */ void DCTypedef:: -write(ostream &out, bool brief, int indent_level) const { +write(std::ostream &out, bool brief, int indent_level) const { indent(out, indent_level) << "typedef "; diff --git a/direct/src/dcparser/dcindent.cxx b/direct/src/dcparser/dcindent.cxx index ae466667ac..b7b9f20793 100644 --- a/direct/src/dcparser/dcindent.cxx +++ b/direct/src/dcparser/dcindent.cxx @@ -18,8 +18,8 @@ /** * */ -ostream & -indent(ostream &out, int indent_level) { +std::ostream & +indent(std::ostream &out, int indent_level) { for (int i = 0; i < indent_level; i++) { out << ' '; } diff --git a/direct/src/dcparser/hashGenerator.cxx b/direct/src/dcparser/hashGenerator.cxx index b5a092f95c..900fd4bf42 100644 --- a/direct/src/dcparser/hashGenerator.cxx +++ b/direct/src/dcparser/hashGenerator.cxx @@ -48,9 +48,9 @@ add_int(int num) { * Adds a string to the hash, by breaking it down into a sequence of integers. */ void HashGenerator:: -add_string(const string &str) { +add_string(const std::string &str) { add_int(str.length()); - string::const_iterator si; + std::string::const_iterator si; for (si = str.begin(); si != str.end(); ++si) { add_int(*si); } diff --git a/direct/src/deadrec/smoothMover.cxx b/direct/src/deadrec/smoothMover.cxx index 727f10f9b3..d15ad745c6 100644 --- a/direct/src/deadrec/smoothMover.cxx +++ b/direct/src/deadrec/smoothMover.cxx @@ -95,7 +95,7 @@ mark_position() { LVector3 pos_delta = _sample._pos - _smooth_pos; LVecBase3 hpr_delta = _sample._hpr - _smooth_hpr; double age = timestamp - _smooth_timestamp; - age = min(age, _max_position_age); + age = std::min(age, _max_position_age); set_smooth_pos(_sample._pos, _sample._hpr, timestamp); if (age != 0.0) { @@ -272,13 +272,13 @@ compute_smooth_position(double timestamp) { // Find the newest of the points before the indicated time. Assume that // this will be no older than _last_point_before. - i = max(0, _last_point_before); + i = std::max(0, _last_point_before); while (i < num_points && _points[i]._timestamp < timestamp) { point_before = i; timestamp_before = _points[i]._timestamp; ++i; } - point_way_before = max(point_before - 1, -1); + point_way_before = std::max(point_before - 1, -1); // Now the next point is presumably the oldest point after the indicated // time. @@ -527,7 +527,7 @@ get_latest_position() { * */ void SmoothMover:: -output(ostream &out) const { +output(std::ostream &out) const { out << "SmoothMover, " << _points.size() << " sample points."; } @@ -535,7 +535,7 @@ output(ostream &out) const { * */ void SmoothMover:: -write(ostream &out) const { +write(std::ostream &out) const { out << "SmoothMover, " << _points.size() << " sample points:\n"; int num_points = _points.size(); for (int i = 0; i < num_points; i++) { diff --git a/direct/src/directd/directd.cxx b/direct/src/directd/directd.cxx index 027236579d..817706acb5 100644 --- a/direct/src/directd/directd.cxx +++ b/direct/src/directd/directd.cxx @@ -34,6 +34,11 @@ #error Buildsystem error: BUILDING_DIRECT_DIRECTD not defined #endif +using std::cerr; +using std::cout; +using std::endl; +using std::string; + namespace { // ...This section is part of the old stuff from the original // implementation. The new stuff that uses job objects doesn't need this @@ -148,7 +153,7 @@ DirectD::~DirectD() { int DirectD::client_ready(const string& server_host, int port, const string& cmd) { - stringstream ss; + std::stringstream ss; ss<<"!"<= 0x03030000 PyObject *exc_type = PyExc_ConnectionError; @@ -884,7 +887,7 @@ handle_update_field_owner() { * description on the indicated output stream. */ void CConnectionRepository:: -describe_message(ostream &out, const string &prefix, +describe_message(std::ostream &out, const string &prefix, const Datagram &dg) const { DCPacker packer; diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.cxx b/direct/src/distributed/cDistributedSmoothNodeBase.cxx index 37c69daaca..67e273644f 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.cxx +++ b/direct/src/distributed/cDistributedSmoothNodeBase.cxx @@ -268,7 +268,7 @@ broadcast_pos_hpr_xy() { * indicated field name, up until the arguments. */ void CDistributedSmoothNodeBase:: -begin_send_update(DCPacker &packer, const string &field_name) { +begin_send_update(DCPacker &packer, const std::string &field_name) { DCField *field = _dclass->get_field_by_name(field_name); nassertv(field != nullptr); @@ -325,14 +325,14 @@ finish_send_update(DCPacker &packer) { } else { #ifndef NDEBUG if (packer.had_range_error()) { - ostringstream error; + std::ostringstream error; error << "Node position out of range for DC file: " << _node_path << " pos = " << _store_xyz << " hpr = " << _store_hpr << " zoneId = " << _currL[0]; #ifdef HAVE_PYTHON - string message = error.str(); + std::string message = error.str(); distributed_cat.warning() << message << "\n"; PyErr_SetString(PyExc_ValueError, message.c_str()); @@ -364,5 +364,5 @@ set_curr_l(uint64_t l) { void CDistributedSmoothNodeBase:: print_curr_l() { - cout << "printCurrL: sent l: " << _currL[1] << " last set l: " << _currL[0] << "\n"; + std::cout << "printCurrL: sent l: " << _currL[1] << " last set l: " << _currL[0] << "\n"; } diff --git a/direct/src/interval/cConstrainHprInterval.cxx b/direct/src/interval/cConstrainHprInterval.cxx index bfd6f6d86d..0cd3e26a35 100644 --- a/direct/src/interval/cConstrainHprInterval.cxx +++ b/direct/src/interval/cConstrainHprInterval.cxx @@ -26,7 +26,7 @@ TypeHandle CConstrainHprInterval::_type_handle; * node's local orientation will be copied unaltered. */ CConstrainHprInterval:: -CConstrainHprInterval(const string &name, double duration, +CConstrainHprInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt, const LVecBase3 hprOffset) : CConstraintInterval(name, duration), @@ -69,7 +69,7 @@ priv_step(double t) { * */ void CConstrainHprInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; out << " dur " << get_duration(); } diff --git a/direct/src/interval/cConstrainPosHprInterval.cxx b/direct/src/interval/cConstrainPosHprInterval.cxx index 7b0944c3e4..4e30d9f56e 100644 --- a/direct/src/interval/cConstrainPosHprInterval.cxx +++ b/direct/src/interval/cConstrainPosHprInterval.cxx @@ -27,7 +27,7 @@ TypeHandle CConstrainPosHprInterval::_type_handle; * unaltered. */ CConstrainPosHprInterval:: -CConstrainPosHprInterval(const string &name, double duration, +CConstrainPosHprInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt, const LVecBase3 posOffset, const LVecBase3 hprOffset) : @@ -72,7 +72,7 @@ priv_step(double t) { * */ void CConstrainPosHprInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; out << " dur " << get_duration(); } diff --git a/direct/src/interval/cConstrainPosInterval.cxx b/direct/src/interval/cConstrainPosInterval.cxx index fe8f235654..1cc967617c 100644 --- a/direct/src/interval/cConstrainPosInterval.cxx +++ b/direct/src/interval/cConstrainPosInterval.cxx @@ -26,7 +26,7 @@ TypeHandle CConstrainPosInterval::_type_handle; * node's local position will be copied unaltered. */ CConstrainPosInterval:: -CConstrainPosInterval(const string &name, double duration, +CConstrainPosInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt, const LVecBase3 posOffset) : CConstraintInterval(name, duration), @@ -73,7 +73,7 @@ priv_step(double t) { * */ void CConstrainPosInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; out << " dur " << get_duration(); } diff --git a/direct/src/interval/cConstrainTransformInterval.cxx b/direct/src/interval/cConstrainTransformInterval.cxx index f816f3bbc1..a21c109bde 100644 --- a/direct/src/interval/cConstrainTransformInterval.cxx +++ b/direct/src/interval/cConstrainTransformInterval.cxx @@ -27,7 +27,7 @@ TypeHandle CConstrainTransformInterval::_type_handle; * local transform will be copied unaltered. */ CConstrainTransformInterval:: -CConstrainTransformInterval(const string &name, double duration, +CConstrainTransformInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt) : CConstraintInterval(name, duration), @@ -72,7 +72,7 @@ priv_step(double t) { * */ void CConstrainTransformInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; out << " dur " << get_duration(); } diff --git a/direct/src/interval/cConstraintInterval.cxx b/direct/src/interval/cConstraintInterval.cxx index 708caed9fa..71ac457cb4 100644 --- a/direct/src/interval/cConstraintInterval.cxx +++ b/direct/src/interval/cConstraintInterval.cxx @@ -19,7 +19,7 @@ TypeHandle CConstraintInterval::_type_handle; * */ CConstraintInterval:: -CConstraintInterval(const string &name, double duration) : +CConstraintInterval(const std::string &name, double duration) : CInterval(name, duration, true) { } diff --git a/direct/src/interval/cInterval.cxx b/direct/src/interval/cInterval.cxx index 84325720ab..0e7dba1554 100644 --- a/direct/src/interval/cInterval.cxx +++ b/direct/src/interval/cInterval.cxx @@ -19,6 +19,9 @@ #include "eventQueue.h" #include "pStatTimer.h" +using std::ostream; +using std::string; + PStatCollector CInterval::_root_pcollector("App:Show code:ivalLoop"); TypeHandle CInterval::_type_handle; @@ -41,7 +44,7 @@ CInterval(const string &name, double duration, bool open_ended) : _curr_t(0.0), _name(name), _pname(get_pstats_name(name)), - _duration(max(duration, 0.0)), + _duration(std::max(duration, 0.0)), _open_ended(open_ended), _dirty(false), _ival_pcollector(_root_pcollector, _pname) diff --git a/direct/src/interval/cIntervalManager.cxx b/direct/src/interval/cIntervalManager.cxx index 104c9e0953..137f30c0ff 100644 --- a/direct/src/interval/cIntervalManager.cxx +++ b/direct/src/interval/cIntervalManager.cxx @@ -108,7 +108,7 @@ add_c_interval(CInterval *interval, bool external) { * interval, or -1 if there is not. */ int CIntervalManager:: -find_c_interval(const string &name) const { +find_c_interval(const std::string &name) const { MutexHolder holder(_lock); NameIndex::const_iterator ni = _name_index.find(name); @@ -351,7 +351,7 @@ get_next_removal() { * */ void CIntervalManager:: -output(ostream &out) const { +output(std::ostream &out) const { MutexHolder holder(_lock); out << "CIntervalManager, " << (int)_name_index.size() << " intervals."; @@ -361,7 +361,7 @@ output(ostream &out) const { * */ void CIntervalManager:: -write(ostream &out) const { +write(std::ostream &out) const { MutexHolder holder(_lock); // We need to write this line so that it's clear what's going on when there diff --git a/direct/src/interval/cLerpAnimEffectInterval.cxx b/direct/src/interval/cLerpAnimEffectInterval.cxx index d91bf8612e..4f7986a7c4 100644 --- a/direct/src/interval/cLerpAnimEffectInterval.cxx +++ b/direct/src/interval/cLerpAnimEffectInterval.cxx @@ -43,7 +43,7 @@ priv_step(double t) { * */ void CLerpAnimEffectInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ": "; if (_controls.empty()) { diff --git a/direct/src/interval/cLerpInterval.cxx b/direct/src/interval/cLerpInterval.cxx index b1eec3a135..43a291f94e 100644 --- a/direct/src/interval/cLerpInterval.cxx +++ b/direct/src/interval/cLerpInterval.cxx @@ -21,7 +21,7 @@ TypeHandle CLerpInterval::_type_handle; * string, or BT_invalid if the string doesn't match anything. */ CLerpInterval::BlendType CLerpInterval:: -string_blend_type(const string &blend_type) { +string_blend_type(const std::string &blend_type) { if (blend_type == "easeIn") { return BT_ease_in; } else if (blend_type == "easeOut") { @@ -49,7 +49,7 @@ compute_delta(double t) const { return 1.0; } t /= duration; - t = min(max(t, 0.0), 1.0); + t = std::min(std::max(t, 0.0), 1.0); switch (_blend_type) { case BT_ease_in: diff --git a/direct/src/interval/cLerpNodePathInterval.cxx b/direct/src/interval/cLerpNodePathInterval.cxx index 12286ce3d8..2fbc8a7e75 100644 --- a/direct/src/interval/cLerpNodePathInterval.cxx +++ b/direct/src/interval/cLerpNodePathInterval.cxx @@ -47,7 +47,7 @@ TypeHandle CLerpNodePathInterval::_type_handle; * otherwise, it is reset. */ CLerpNodePathInterval:: -CLerpNodePathInterval(const string &name, double duration, +CLerpNodePathInterval(const std::string &name, double duration, CLerpInterval::BlendType blend_type, bool bake_in_start, bool fluid, const NodePath &node, const NodePath &other) : @@ -544,7 +544,7 @@ priv_reverse_instant() { * */ void CLerpNodePathInterval:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ":"; if ((_flags & F_end_pos) != 0) { diff --git a/direct/src/interval/cMetaInterval.cxx b/direct/src/interval/cMetaInterval.cxx index 2b764187bc..d43ea9cebf 100644 --- a/direct/src/interval/cMetaInterval.cxx +++ b/direct/src/interval/cMetaInterval.cxx @@ -21,6 +21,8 @@ #include // for log10() #include // for sprintf() +using std::string; + TypeHandle CMetaInterval::_type_handle; /** @@ -669,7 +671,7 @@ pop_event() { * */ void CMetaInterval:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { recompute(); // How many digits of precision should we output for time? @@ -698,7 +700,7 @@ write(ostream &out, int indent_level) const { * Outputs a list of all events in the order in which they occur. */ void CMetaInterval:: -timeline(ostream &out) const { +timeline(std::ostream &out) const { recompute(); // How many digits of precision should we output for time? @@ -1124,7 +1126,7 @@ recompute_level(int n, int level_begin, int &level_end) { previous_begin = begin_time; previous_end = end_time; - level_end = max(level_end, end_time); + level_end = std::max(level_end, end_time); n++; } @@ -1169,7 +1171,7 @@ get_begin_time(const CMetaInterval::IntervalDef &def, int level_begin, * Formats an event for output, for write() or timeline(). */ void CMetaInterval:: -write_event_desc(ostream &out, const CMetaInterval::IntervalDef &def, +write_event_desc(std::ostream &out, const CMetaInterval::IntervalDef &def, int &extra_indent_level) const { switch (def._type) { case DT_c_interval: diff --git a/direct/src/interval/hideInterval.cxx b/direct/src/interval/hideInterval.cxx index ed335dc307..46498800e0 100644 --- a/direct/src/interval/hideInterval.cxx +++ b/direct/src/interval/hideInterval.cxx @@ -20,13 +20,13 @@ TypeHandle HideInterval::_type_handle; * */ HideInterval:: -HideInterval(const NodePath &node, const string &name) : +HideInterval(const NodePath &node, const std::string &name) : CInterval(name, 0.0, true), _node(node) { nassertv(!node.is_empty()); if (_name.empty()) { - ostringstream name_strm; + std::ostringstream name_strm; name_strm << "HideInterval-" << node.node()->get_name() << "-" << ++_unique_index; _name = name_strm.str(); diff --git a/direct/src/interval/showInterval.cxx b/direct/src/interval/showInterval.cxx index 53bc7d2346..b014100f2f 100644 --- a/direct/src/interval/showInterval.cxx +++ b/direct/src/interval/showInterval.cxx @@ -20,13 +20,13 @@ TypeHandle ShowInterval::_type_handle; * */ ShowInterval:: -ShowInterval(const NodePath &node, const string &name) : +ShowInterval(const NodePath &node, const std::string &name) : CInterval(name, 0.0, true), _node(node) { nassertv(!node.is_empty()); if (_name.empty()) { - ostringstream name_strm; + std::ostringstream name_strm; name_strm << "ShowInterval-" << node.node()->get_name() << "-" << ++_unique_index; _name = name_strm.str(); diff --git a/direct/src/plugin/binaryXml.cxx b/direct/src/plugin/binaryXml.cxx index 4840a2c1e2..7dc4a60268 100644 --- a/direct/src/plugin/binaryXml.cxx +++ b/direct/src/plugin/binaryXml.cxx @@ -15,6 +15,11 @@ #include "p3d_lock.h" #include +using std::istream; +using std::ostream; +using std::ostringstream; +using std::string; + static const bool debug_xml_output = false; static LOCK xml_lock; diff --git a/direct/src/plugin/binaryXml.h b/direct/src/plugin/binaryXml.h index 664c7fb5e6..477c51e83f 100644 --- a/direct/src/plugin/binaryXml.h +++ b/direct/src/plugin/binaryXml.h @@ -18,8 +18,6 @@ #include "handleStream.h" #include -using namespace std; - // A pair of functions to input and output the TinyXml constructs on the // indicated streams. We could, of course, use the TinyXml output operators, // but this is a smidge more efficient and gives us more control. diff --git a/direct/src/plugin/fileSpec.cxx b/direct/src/plugin/fileSpec.cxx index 29f22e9899..c291bfc14a 100644 --- a/direct/src/plugin/fileSpec.cxx +++ b/direct/src/plugin/fileSpec.cxx @@ -33,6 +33,11 @@ #endif +using std::istream; +using std::ostream; +using std::string; +using std::wstring; + /** * */ @@ -325,10 +330,10 @@ read_hash(const string &pathname) { #ifdef _WIN32 wstring pathname_w; if (string_to_wstring(pathname_w, pathname)) { - stream.open(pathname_w.c_str(), ios::in | ios::binary); + stream.open(pathname_w.c_str(), std::ios::in | std::ios::binary); } #else // _WIN32 - stream.open(pathname.c_str(), ios::in | ios::binary); + stream.open(pathname.c_str(), std::ios::in | std::ios::binary); #endif // _WIN32 if (!stream) { diff --git a/direct/src/plugin/fileSpec.h b/direct/src/plugin/fileSpec.h index e393b680fa..3a661ab603 100644 --- a/direct/src/plugin/fileSpec.h +++ b/direct/src/plugin/fileSpec.h @@ -16,7 +16,6 @@ #include "get_tinyxml.h" #include -using namespace std; /** * This simple class is used both within the core API in this module, as well diff --git a/direct/src/plugin/find_root_dir.cxx b/direct/src/plugin/find_root_dir.cxx index d15362bfd0..7d20461aa9 100644 --- a/direct/src/plugin/find_root_dir.cxx +++ b/direct/src/plugin/find_root_dir.cxx @@ -27,6 +27,10 @@ #include #endif +using std::cerr; +using std::string; +using std::wstring; + #ifdef _WIN32 // From KnownFolders.h (part of Vista SDK): #define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ diff --git a/direct/src/plugin/find_root_dir.h b/direct/src/plugin/find_root_dir.h index 977a64cc37..e76be59af3 100644 --- a/direct/src/plugin/find_root_dir.h +++ b/direct/src/plugin/find_root_dir.h @@ -16,7 +16,6 @@ #include #include -using namespace std; std::string find_root_dir(); diff --git a/direct/src/plugin/find_root_dir_assist.mm b/direct/src/plugin/find_root_dir_assist.mm index e4eed157a6..f27693d147 100644 --- a/direct/src/plugin/find_root_dir_assist.mm +++ b/direct/src/plugin/find_root_dir_assist.mm @@ -70,7 +70,7 @@ get_osx_home_directory() { /** * */ -string +std::string find_osx_root_dir() { string result = call_NSSearchPathForDirectories(NSCachesDirectory, NSUserDomainMask); if (!result.empty()) { diff --git a/direct/src/plugin/handleStreamBuf.cxx b/direct/src/plugin/handleStreamBuf.cxx index c2adbd2f62..55e74977b5 100644 --- a/direct/src/plugin/handleStreamBuf.cxx +++ b/direct/src/plugin/handleStreamBuf.cxx @@ -28,6 +28,10 @@ #include #endif // !_WIN32 && !__APPLE__ && !__FreeBSD__ +using std::cerr; +using std::dec; +using std::hex; + static const size_t handle_buffer_size = 4096; /** diff --git a/direct/src/plugin/handleStreamBuf.h b/direct/src/plugin/handleStreamBuf.h index 19610a0c45..da3448d4d3 100644 --- a/direct/src/plugin/handleStreamBuf.h +++ b/direct/src/plugin/handleStreamBuf.h @@ -18,8 +18,6 @@ #include "p3d_lock.h" #include -using namespace std; - /** * */ diff --git a/direct/src/plugin/load_plugin.cxx b/direct/src/plugin/load_plugin.cxx index f46cb7355d..75def4fc10 100644 --- a/direct/src/plugin/load_plugin.cxx +++ b/direct/src/plugin/load_plugin.cxx @@ -24,6 +24,8 @@ #include #endif +using std::string; + #ifdef _WIN32 static const string dll_ext = ".dll"; #elif defined(__APPLE__) @@ -132,7 +134,7 @@ load_plugin(const string &p3d_plugin_filename, const string &log_directory, const string &log_basename, bool trusted_environment, bool console_environment, const string &root_dir, const string &host_dir, - const string &start_dir, ostream &logfile) { + const string &start_dir, std::ostream &logfile) { if (plugin_loaded) { return true; } @@ -161,7 +163,7 @@ load_plugin(const string &p3d_plugin_filename, } SetErrorMode(0); - wstring filename_w; + std::wstring filename_w; if (string_to_wstring(filename_w, filename)) { module = LoadLibraryW(filename_w.c_str()); } @@ -273,7 +275,7 @@ init_plugin(const string &contents_filename, const string &host_url, const string &log_directory, const string &log_basename, bool trusted_environment, bool console_environment, const string &root_dir, const string &host_dir, - const string &start_dir, ostream &logfile) { + const string &start_dir, std::ostream &logfile) { // Ensure that all of the function pointers have been found. if (P3D_initialize_ptr == nullptr || @@ -392,7 +394,7 @@ init_plugin(const string &contents_filename, const string &host_url, * the pointers. */ void -unload_plugin(ostream &logfile) { +unload_plugin(std::ostream &logfile) { if (!plugin_loaded) { return; } diff --git a/direct/src/plugin/load_plugin.h b/direct/src/plugin/load_plugin.h index 58f160ef7d..2e462ed9cd 100644 --- a/direct/src/plugin/load_plugin.h +++ b/direct/src/plugin/load_plugin.h @@ -17,7 +17,6 @@ #include "p3d_plugin.h" #include -using namespace std; extern P3D_initialize_func *P3D_initialize_ptr; extern P3D_finalize_func *P3D_finalize_ptr; diff --git a/direct/src/plugin/mkdir_complete.cxx b/direct/src/plugin/mkdir_complete.cxx index 8b721f1fa8..6689584198 100644 --- a/direct/src/plugin/mkdir_complete.cxx +++ b/direct/src/plugin/mkdir_complete.cxx @@ -26,6 +26,10 @@ #include #endif +using std::ostream; +using std::string; +using std::wstring; + /** * Returns the directory component of the indicated pathname, or the empty * string if there is no directory prefix. diff --git a/direct/src/plugin/mkdir_complete.h b/direct/src/plugin/mkdir_complete.h index 5ba165e6be..be79cf7e8e 100644 --- a/direct/src/plugin/mkdir_complete.h +++ b/direct/src/plugin/mkdir_complete.h @@ -16,7 +16,6 @@ #include #include -using namespace std; bool mkdir_complete(const std::string &dirname, std::ostream &logfile); bool mkfile_complete(const std::string &dirname, std::ostream &logfile); diff --git a/direct/src/plugin/p3dAuthSession.cxx b/direct/src/plugin/p3dAuthSession.cxx index 15363647f9..e76bbe0a07 100644 --- a/direct/src/plugin/p3dAuthSession.cxx +++ b/direct/src/plugin/p3dAuthSession.cxx @@ -30,6 +30,8 @@ #include #endif +using std::string; + /** * */ @@ -178,7 +180,7 @@ start_p3dcert() { nullptr }; - wstring env_w; + std::wstring env_w; for (int ki = 0; keep[ki] != nullptr; ++ki) { wchar_t *value = _wgetenv(keep[ki]); @@ -369,7 +371,7 @@ win_create_process() { // Construct the command-line string, containing the quoted command-line // arguments. - ostringstream stream; + std::ostringstream stream; stream << "\"" << _p3dcert_exe << "\" \"" << _cert_filename->get_filename() << "\" \"" << _cert_dir << "\""; @@ -432,7 +434,7 @@ posix_create_process() { } // build up an array of char strings for the environment. - vector ptrs; + std::vector ptrs; size_t p = 0; size_t zero = _env.find('\0', p); while (zero != string::npos) { diff --git a/direct/src/plugin/p3dBoolObject.cxx b/direct/src/plugin/p3dBoolObject.cxx index 87736ba216..7740c2f669 100644 --- a/direct/src/plugin/p3dBoolObject.cxx +++ b/direct/src/plugin/p3dBoolObject.cxx @@ -59,7 +59,7 @@ get_int() { * to a string. */ void P3DBoolObject:: -make_string(string &value) { +make_string(std::string &value) { if (_value) { value = "True"; } else { diff --git a/direct/src/plugin/p3dCert.cxx b/direct/src/plugin/p3dCert.cxx index f47723d466..e6868bdb80 100644 --- a/direct/src/plugin/p3dCert.cxx +++ b/direct/src/plugin/p3dCert.cxx @@ -46,6 +46,10 @@ #include #endif +using std::cerr; +using std::string; +using std::wstring; + static LanguageIndex li = LI_default; #if defined(_WIN32) diff --git a/direct/src/plugin/p3dCert.h b/direct/src/plugin/p3dCert.h index 1583727565..3c856c6ec3 100644 --- a/direct/src/plugin/p3dCert.h +++ b/direct/src/plugin/p3dCert.h @@ -25,7 +25,6 @@ #include #include #include -using namespace std; class ViewCertDialog; diff --git a/direct/src/plugin/p3dCert_wx.cxx b/direct/src/plugin/p3dCert_wx.cxx index d2e5a78801..125732adda 100644 --- a/direct/src/plugin/p3dCert_wx.cxx +++ b/direct/src/plugin/p3dCert_wx.cxx @@ -20,6 +20,8 @@ #include "ca_bundle_data_src.c" +using std::cerr; + static const wxString self_signed_cert_text = _T("This Panda3D application uses a self-signed certificate. ") @@ -132,7 +134,7 @@ END_EVENT_TABLE() * */ AuthDialog:: -AuthDialog(const string &cert_filename, const string &cert_dir) : +AuthDialog(const std::string &cert_filename, const std::string &cert_dir) : // I hate stay-on-top dialogs, but if we don't set this flag, it doesn't // come to the foreground on OSX, and might be lost behind the browser // window. @@ -216,7 +218,7 @@ approve_cert() { size_t buf_length = _cert_dir.length() + 100; char *buf = new char[buf_length]; #ifdef _WIN32 - wstring buf_w; + std::wstring buf_w; #endif // _WIN32 while (true) { @@ -262,10 +264,10 @@ approve_cert() { * line into _cert and _stack. */ void AuthDialog:: -read_cert_file(const string &cert_filename) { +read_cert_file(const std::string &cert_filename) { FILE *fp = nullptr; #ifdef _WIN32 - wstring cert_filename_w; + std::wstring cert_filename_w; if (string_to_wstring(cert_filename_w, cert_filename)) { fp = _wfopen(cert_filename_w.c_str(), L"r"); } @@ -612,5 +614,5 @@ layout() { // Make sure the resulting window is at least a certain size. int width, height; GetSize(&width, &height); - SetSize(max(width, 600), max(height, 400)); + SetSize(std::max(width, 600), std::max(height, 400)); } diff --git a/direct/src/plugin/p3dCert_wx.h b/direct/src/plugin/p3dCert_wx.h index bced0ec91f..1ea8765a17 100644 --- a/direct/src/plugin/p3dCert_wx.h +++ b/direct/src/plugin/p3dCert_wx.h @@ -24,7 +24,6 @@ #include #include #include -using namespace std; class ViewCertDialog; diff --git a/direct/src/plugin/p3dConcreteSequence.cxx b/direct/src/plugin/p3dConcreteSequence.cxx index 2dd6dbf29e..ec4291cb7b 100644 --- a/direct/src/plugin/p3dConcreteSequence.cxx +++ b/direct/src/plugin/p3dConcreteSequence.cxx @@ -62,8 +62,8 @@ get_bool() { * to a string. */ void P3DConcreteSequence:: -make_string(string &value) { - ostringstream strm; +make_string(std::string &value) { + std::ostringstream strm; strm << "["; if (!_elements.empty()) { strm << *_elements[0]; @@ -81,7 +81,7 @@ make_string(string &value) { * new-reference P3D_object, or NULL on error. */ P3D_object *P3DConcreteSequence:: -get_property(const string &property) { +get_property(const std::string &property) { // We only understand integer "property" names. char *endptr; int index = strtoul(property.c_str(), &endptr, 10); @@ -97,7 +97,7 @@ get_property(const string &property) { * object. Returns true on success, false on failure. */ bool P3DConcreteSequence:: -set_property(const string &property, P3D_object *value) { +set_property(const std::string &property, P3D_object *value) { // We only understand integer "property" names. char *endptr; int index = strtoul(property.c_str(), &endptr, 10); diff --git a/direct/src/plugin/p3dConcreteStruct.cxx b/direct/src/plugin/p3dConcreteStruct.cxx index 753bcb2b83..fa9917d955 100644 --- a/direct/src/plugin/p3dConcreteStruct.cxx +++ b/direct/src/plugin/p3dConcreteStruct.cxx @@ -13,6 +13,8 @@ #include "p3dConcreteStruct.h" +using std::string; + /** * */ @@ -53,7 +55,7 @@ get_bool() { */ void P3DConcreteStruct:: make_string(string &value) { - ostringstream strm; + std::ostringstream strm; strm << "{"; if (!_elements.empty()) { Elements::iterator ei; @@ -105,7 +107,7 @@ set_property(const string &property, P3D_object *value) { } else { // Replace or insert an element. P3D_OBJECT_INCREF(value); - pair result = _elements.insert(Elements::value_type(property, value)); + std::pair result = _elements.insert(Elements::value_type(property, value)); if (!result.second) { // Replacing an element. Elements::iterator ei = result.first; diff --git a/direct/src/plugin/p3dDownload.cxx b/direct/src/plugin/p3dDownload.cxx index 6423b4d9a7..3b6a6cca7a 100644 --- a/direct/src/plugin/p3dDownload.cxx +++ b/direct/src/plugin/p3dDownload.cxx @@ -60,7 +60,7 @@ P3DDownload:: * Supplies the source URL for the download. */ void P3DDownload:: -set_url(const string &url) { +set_url(const std::string &url) { _url = url; } @@ -119,7 +119,7 @@ feed_url_stream(P3D_result_code result_code, _total_data += this_data_size; } - total_expected_data = max(total_expected_data, _total_data); + total_expected_data = std::max(total_expected_data, _total_data); if (total_expected_data > _total_expected_data) { // If the expected data grows during the download, we don't really know // how much we're getting. diff --git a/direct/src/plugin/p3dFileDownload.cxx b/direct/src/plugin/p3dFileDownload.cxx index 2d1a85497e..a978c3640e 100644 --- a/direct/src/plugin/p3dFileDownload.cxx +++ b/direct/src/plugin/p3dFileDownload.cxx @@ -38,7 +38,7 @@ P3DFileDownload(const P3DFileDownload ©) : * success, false on failure. */ bool P3DFileDownload:: -set_filename(const string &filename) { +set_filename(const std::string &filename) { _filename = filename; return open_file(); @@ -57,12 +57,12 @@ open_file() { _file.clear(); #ifdef _WIN32 - wstring filename_w; + std::wstring filename_w; if (string_to_wstring(filename_w, _filename)) { - _file.open(filename_w.c_str(), ios::out | ios::trunc | ios::binary); + _file.open(filename_w.c_str(), std::ios::out | std::ios::trunc | std::ios::binary); } #else // _WIN32 - _file.open(_filename.c_str(), ios::out | ios::trunc | ios::binary); + _file.open(_filename.c_str(), std::ios::out | std::ios::trunc | std::ios::binary); #endif // _WIN32 if (!_file) { nout << "Failed to open " << _filename << " in write mode\n"; diff --git a/direct/src/plugin/p3dFileParams.cxx b/direct/src/plugin/p3dFileParams.cxx index 1be229e3bb..a32ede4b95 100644 --- a/direct/src/plugin/p3dFileParams.cxx +++ b/direct/src/plugin/p3dFileParams.cxx @@ -14,6 +14,8 @@ #include "p3dFileParams.h" #include +using std::string; + /** * */ diff --git a/direct/src/plugin/p3dFloatObject.cxx b/direct/src/plugin/p3dFloatObject.cxx index 2581c44282..3262d45a54 100644 --- a/direct/src/plugin/p3dFloatObject.cxx +++ b/direct/src/plugin/p3dFloatObject.cxx @@ -67,8 +67,8 @@ get_float() { * to a string. */ void P3DFloatObject:: -make_string(string &value) { - ostringstream strm; +make_string(std::string &value) { + std::ostringstream strm; strm << _value; value = strm.str(); } diff --git a/direct/src/plugin/p3dHost.cxx b/direct/src/plugin/p3dHost.cxx index 028af6bef0..991a66df3e 100644 --- a/direct/src/plugin/p3dHost.cxx +++ b/direct/src/plugin/p3dHost.cxx @@ -25,6 +25,11 @@ #include #endif +using std::ios; +using std::ostringstream; +using std::string; +using std::wstring; + /** * Use P3DInstanceManager::get_host() to construct a new P3DHost. */ @@ -200,11 +205,11 @@ read_contents_file(const string &contents_filename, bool fresh_download) { _contents_spec.read_hash(contents_filename); } - _contents_expiration = min(_contents_expiration, (time_t)expiration); + _contents_expiration = std::min(_contents_expiration, (time_t)expiration); } nout << "read contents.xml, max_age = " << max_age - << ", expires in " << max(_contents_expiration, now) - now + << ", expires in " << std::max(_contents_expiration, now) - now << " s\n"; TiXmlElement *xhost = _xcontents->FirstChildElement("host"); @@ -631,10 +636,10 @@ migrate_package_host(P3DPackage *package, const string &alt_host, P3DHost *new_h * elements in the list, adds only as many mirrors as we can get. */ void P3DHost:: -choose_random_mirrors(vector &result, int num_mirrors) { - vector selected; +choose_random_mirrors(std::vector &result, int num_mirrors) { + std::vector selected; - size_t num_to_select = min(_mirrors.size(), (size_t)num_mirrors); + size_t num_to_select = std::min(_mirrors.size(), (size_t)num_mirrors); while (num_to_select > 0) { size_t i = (size_t)(((double)rand() / (double)RAND_MAX) * _mirrors.size()); while (find(selected.begin(), selected.end(), i) != selected.end()) { @@ -846,7 +851,7 @@ copy_file(const string &from_filename, const string &to_filename) { char buffer[buffer_size]; in.read(buffer, buffer_size); - streamsize count = in.gcount(); + std::streamsize count = in.gcount(); while (count != 0) { out.write(buffer, count); if (out.fail()) { diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index 21e608d5a5..220e28c667 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -34,6 +34,14 @@ #include #include +using std::max; +using std::min; +using std::ostream; +using std::ostringstream; +using std::stringstream; +using std::string; +using std::vector; + // Lifted from NSEvent.h (which is Objective-C). enum { NSAlphaShiftKeyMask = 1 << 16, @@ -1472,7 +1480,7 @@ uninstall_host() { uninstall_packages(); // Collect the set of hosts referenced by this instance. - set hosts; + std::set hosts; Packages::const_iterator pi; for (pi = _packages.begin(); pi != _packages.end(); ++pi) { P3DPackage *package = (*pi); @@ -1484,7 +1492,7 @@ uninstall_host() { nout << "Uninstalling " << hosts.size() << " hosts\n"; // Uninstall all of them. - set::iterator hi; + std::set::iterator hi; for (hi = hosts.begin(); hi != hosts.end(); ++hi) { P3DHost *host = (*hi); host->uninstall(); diff --git a/direct/src/plugin/p3dInstanceManager.cxx b/direct/src/plugin/p3dInstanceManager.cxx index 3b8c52ba15..93e2ffcfc2 100644 --- a/direct/src/plugin/p3dInstanceManager.cxx +++ b/direct/src/plugin/p3dInstanceManager.cxx @@ -50,8 +50,12 @@ #include +using std::string; +using std::vector; +using std::wstring; + static ofstream logfile; -ostream *nout_stream = &logfile; +std::ostream *nout_stream = &logfile; P3DInstanceManager *P3DInstanceManager::_global_ptr; @@ -285,7 +289,7 @@ initialize(int api_version, const string &contents_filename, if (root_dir.empty()) { _root_dir = find_root_dir(); if (_root_dir.empty()) { - cerr << "Could not find root directory.\n"; + std::cerr << "Could not find root directory.\n"; return false; } } else { @@ -1306,19 +1310,19 @@ append_safe_dir(string &root, const string &basename) { */ void P3DInstanceManager:: create_runtime_environment() { - mkdir_complete(_log_directory, cerr); + mkdir_complete(_log_directory, std::cerr); logfile.close(); logfile.clear(); #ifdef _WIN32 wstring log_pathname_w; string_to_wstring(log_pathname_w, _log_pathname); - logfile.open(log_pathname_w.c_str(), ios::out | ios::trunc); + logfile.open(log_pathname_w.c_str(), std::ios::out | std::ios::trunc); #else - logfile.open(_log_pathname.c_str(), ios::out | ios::trunc); + logfile.open(_log_pathname.c_str(), std::ios::out | std::ios::trunc); #endif // _WIN32 if (logfile) { - logfile.setf(ios::unitbuf); + logfile.setf(std::ios::unitbuf); nout_stream = &logfile; } diff --git a/direct/src/plugin/p3dIntObject.cxx b/direct/src/plugin/p3dIntObject.cxx index 4fa4b14aaf..05ad970128 100644 --- a/direct/src/plugin/p3dIntObject.cxx +++ b/direct/src/plugin/p3dIntObject.cxx @@ -59,8 +59,8 @@ get_int() { * to a string. */ void P3DIntObject:: -make_string(string &value) { - ostringstream strm; +make_string(std::string &value) { + std::ostringstream strm; strm << _value; value = strm.str(); } diff --git a/direct/src/plugin/p3dMainObject.cxx b/direct/src/plugin/p3dMainObject.cxx index adda6129d6..2fd8dba33d 100644 --- a/direct/src/plugin/p3dMainObject.cxx +++ b/direct/src/plugin/p3dMainObject.cxx @@ -18,6 +18,11 @@ #include "p3dStringObject.h" #include "p3dInstanceManager.h" +using std::ios; +using std::max; +using std::streamsize; +using std::string; + /** * */ @@ -231,7 +236,7 @@ call(const string &method_name, bool needs_response, * This is intended for developer assistance. */ void P3DMainObject:: -output(ostream &out) { +output(std::ostream &out) { out << "P3DMainObject"; } @@ -459,7 +464,7 @@ P3D_object *P3DMainObject:: read_log(const string &log_pathname, P3D_object *params[], int num_params) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); string log_directory = inst_mgr->get_log_directory(); - ostringstream log_data; + std::ostringstream log_data; // Check the first parameter, if any--if given, it specifies the last n // bytes to retrieve. @@ -512,7 +517,7 @@ read_log(const string &log_pathname, P3D_object *params[], int num_params) { } // Read matching files - vector all_logs; + std::vector all_logs; int log_matches_found = 0; string log_matching_pathname; inst_mgr->scan_directory(log_directory, all_logs); @@ -544,7 +549,7 @@ read_log(const string &log_pathname, P3D_object *params[], int num_params) { void P3DMainObject:: read_log_file(const string &log_pathname, size_t tail_bytes, size_t head_bytes, - ostringstream &log_data) { + std::ostringstream &log_data) { // Get leaf name string log_leafname = log_pathname; diff --git a/direct/src/plugin/p3dMultifileReader.cxx b/direct/src/plugin/p3dMultifileReader.cxx index dfaf4d8a2d..e47400bdb6 100644 --- a/direct/src/plugin/p3dMultifileReader.cxx +++ b/direct/src/plugin/p3dMultifileReader.cxx @@ -23,6 +23,13 @@ #include #endif +using std::ios; +using std::max; +using std::min; +using std::streampos; +using std::streamsize; +using std::string; + // This sequence of bytes begins each Multifile to identify it as a Multifile. const char P3DMultifileReader::_header[] = "pmf\0\n\r"; const size_t P3DMultifileReader::_header_size = 6; @@ -99,7 +106,7 @@ extract_all(const string &to_dir, P3DPackage *package, ofstream out; #ifdef _WIN32 - wstring output_pathname_w; + std::wstring output_pathname_w; if (string_to_wstring(output_pathname_w, output_pathname)) { out.open(output_pathname_w.c_str(), ios::out | ios::binary); } @@ -140,7 +147,7 @@ extract_all(const string &to_dir, P3DPackage *package, * stream. Returns true on success, false on failure. */ bool P3DMultifileReader:: -extract_one(ostream &out, const string &filename) { +extract_one(std::ostream &out, const string &filename) { assert(_is_open); if (_in.fail()) { return false; @@ -202,7 +209,7 @@ read_header(const string &pathname) { _signatures.clear(); #ifdef _WIN32 - wstring pathname_w; + std::wstring pathname_w; if (string_to_wstring(pathname_w, pathname)) { _in.open(pathname_w.c_str(), ios::in | ios::binary); } @@ -341,7 +348,7 @@ read_index() { * Returns true on success, false on failure. */ bool P3DMultifileReader:: -extract_subfile(ostream &out, const Subfile &s) { +extract_subfile(std::ostream &out, const Subfile &s) { _in.seekg(s._data_start + _read_offset); static const streamsize buffer_size = 4096; diff --git a/direct/src/plugin/p3dNoneObject.cxx b/direct/src/plugin/p3dNoneObject.cxx index 0245b61174..2a1653a2b8 100644 --- a/direct/src/plugin/p3dNoneObject.cxx +++ b/direct/src/plugin/p3dNoneObject.cxx @@ -41,6 +41,6 @@ get_bool() { * to a string. */ void P3DNoneObject:: -make_string(string &value) { +make_string(std::string &value) { value = "None"; } diff --git a/direct/src/plugin/p3dObject.cxx b/direct/src/plugin/p3dObject.cxx index a8393a6c11..f34f2d6d2d 100644 --- a/direct/src/plugin/p3dObject.cxx +++ b/direct/src/plugin/p3dObject.cxx @@ -19,6 +19,8 @@ #include "p3dInstanceManager.h" #include // strncpy +using std::string; + // The following functions are C-style wrappers around the below P3DObject // virtual methods; they are defined to allow us to create the C-style // P3D_class_definition method table to store in the P3D_object structure. @@ -231,7 +233,7 @@ get_string(char *buffer, int buffer_length) { */ int P3DObject:: get_repr(char *buffer, int buffer_length) { - ostringstream strm; + std::ostringstream strm; output(strm); string result = strm.str(); strncpy(buffer, result.c_str(), buffer_length); @@ -292,7 +294,7 @@ eval(const string &expression) { * This is intended for developer assistance. */ void P3DObject:: -output(ostream &out) { +output(std::ostream &out) { string value; make_string(value); out << value; diff --git a/direct/src/plugin/p3dOsxSplashWindow.cxx b/direct/src/plugin/p3dOsxSplashWindow.cxx index d504d58671..4139a9629d 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.cxx +++ b/direct/src/plugin/p3dOsxSplashWindow.cxx @@ -26,6 +26,8 @@ #endif #endif +using std::string; + /** * */ @@ -580,7 +582,7 @@ paint_image(CGContextRef context, const OsxImageData &image) { // The bitmap is larger than the window; scale it down. double x_scale = (double)_win_width / (double)image._width; double y_scale = (double)_win_height / (double)image._height; - double scale = min(x_scale, y_scale); + double scale = std::min(x_scale, y_scale); int sc_width = (int)(image._width * scale); int sc_height = (int)(image._height * scale); diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 1efead479b..fad2dd97f2 100644 --- a/direct/src/plugin/p3dPackage.cxx +++ b/direct/src/plugin/p3dPackage.cxx @@ -29,6 +29,12 @@ #include // chmod() #endif +using std::ios; +using std::ostream; +using std::ostringstream; +using std::string; +using std::vector; + // Weight factors for computing download progress. This attempts to reflect // the relative time-per-byte of each of these operations. const double P3DPackage::_download_factor = 1.0; @@ -1147,7 +1153,7 @@ void P3DPackage:: report_progress(P3DPackage::InstallStep *step) { if (_computed_plan_size) { double size = _total_plan_completed + _current_step_effort * step->get_progress(); - _download_progress = min(size / _total_plan_size, 1.0); + _download_progress = std::min(size / _total_plan_size, 1.0); Instances::iterator ii; for (ii = _instances.begin(); ii != _instances.end(); ++ii) { @@ -1780,7 +1786,7 @@ thread_step() { ifstream source; #ifdef _WIN32 - wstring source_pathname_w; + std::wstring source_pathname_w; if (string_to_wstring(source_pathname_w, source_pathname)) { source.open(source_pathname_w.c_str(), ios::in | ios::binary); } @@ -1798,7 +1804,7 @@ thread_step() { ofstream target; #ifdef _WIN32 - wstring target_pathname_w; + std::wstring target_pathname_w; if (string_to_wstring(target_pathname_w, target_pathname)) { target.open(target_pathname_w.c_str(), ios::out | ios::binary); } @@ -1829,7 +1835,7 @@ thread_step() { int flush = 0; source.read(decompress_buffer, decompress_buffer_size); - streamsize read_count = source.gcount(); + std::streamsize read_count = source.gcount(); eof = (read_count == 0 || source.eof() || source.fail()); z.next_in = (Bytef *)decompress_buffer; @@ -1844,7 +1850,7 @@ thread_step() { while (true) { if (z.avail_in == 0 && !eof) { source.read(decompress_buffer, decompress_buffer_size); - streamsize read_count = source.gcount(); + std::streamsize read_count = source.gcount(); eof = (read_count == 0 || source.eof() || source.fail()); z.next_in = (Bytef *)decompress_buffer; diff --git a/direct/src/plugin/p3dPatchFinder.cxx b/direct/src/plugin/p3dPatchFinder.cxx index 044953b3af..fbc109fe8c 100644 --- a/direct/src/plugin/p3dPatchFinder.cxx +++ b/direct/src/plugin/p3dPatchFinder.cxx @@ -13,6 +13,8 @@ #include "p3dPatchFinder.h" +using std::string; + /** * */ @@ -116,7 +118,7 @@ operator < (const PackageVersionKey &other) const { * */ void P3DPatchFinder::PackageVersionKey:: -output(ostream &out) const { +output(std::ostream &out) const { out << "(" << _package_name << ", " << _platform << ", " << _version << ", " << _host_url << ", "; _file.output_hash(out); diff --git a/direct/src/plugin/p3dPatchfileReader.cxx b/direct/src/plugin/p3dPatchfileReader.cxx index 255bed8477..14ede5e9f9 100644 --- a/direct/src/plugin/p3dPatchfileReader.cxx +++ b/direct/src/plugin/p3dPatchfileReader.cxx @@ -14,6 +14,9 @@ #include "p3dPatchfileReader.h" #include "wstring_encode.h" +using std::ios; +using std::string; + /** * */ @@ -55,7 +58,7 @@ open_read() { string patch_pathname = _patchfile.get_pathname(_package_dir); _patch_in.clear(); #ifdef _WIN32 - wstring patch_pathname_w; + std::wstring patch_pathname_w; if (string_to_wstring(patch_pathname_w, patch_pathname)) { _patch_in.open(patch_pathname_w.c_str(), ios::in | ios::binary); } @@ -66,7 +69,7 @@ open_read() { string source_pathname = _source.get_pathname(_package_dir); _source_in.clear(); #ifdef _WIN32 - wstring source_pathname_w; + std::wstring source_pathname_w; if (string_to_wstring(source_pathname_w, source_pathname)) { _source_in.open(source_pathname_w.c_str(), ios::in | ios::binary); } @@ -77,7 +80,7 @@ open_read() { mkfile_complete(_output_pathname, nout); _target_out.clear(); #ifdef _WIN32 - wstring output_pathname_w; + std::wstring output_pathname_w; if (string_to_wstring(output_pathname_w, _output_pathname)) { _target_out.open(output_pathname_w.c_str(), ios::in | ios::binary); } @@ -247,13 +250,13 @@ close() { * have enough bytes. */ bool P3DPatchfileReader:: -copy_bytes(istream &in, size_t copy_byte_count) { +copy_bytes(std::istream &in, size_t copy_byte_count) { static const size_t buffer_size = 8192; char buffer[buffer_size]; - streamsize read_size = min(copy_byte_count, buffer_size); + std::streamsize read_size = std::min(copy_byte_count, buffer_size); in.read(buffer, read_size); - streamsize count = in.gcount(); + std::streamsize count = in.gcount(); while (count != 0) { _target_out.write(buffer, count); _bytes_written += (size_t)count; @@ -267,7 +270,7 @@ copy_bytes(istream &in, size_t copy_byte_count) { copy_byte_count -= (size_t)count; count = 0; if (copy_byte_count != 0) { - read_size = min(copy_byte_count, buffer_size); + read_size = std::min(copy_byte_count, buffer_size); in.read(buffer, read_size); count = in.gcount(); } diff --git a/direct/src/plugin/p3dPythonMain.cxx b/direct/src/plugin/p3dPythonMain.cxx index 3d8bbdc9e8..b5d11e6052 100644 --- a/direct/src/plugin/p3dPythonMain.cxx +++ b/direct/src/plugin/p3dPythonMain.cxx @@ -18,7 +18,6 @@ #include #include #include // strrchr -using namespace std; #if defined(_WIN32) && defined(NON_CONSOLE) // On Windows, we may need to build p3dpythonw.exe, a non-console version of @@ -34,7 +33,7 @@ static char * parse_quoted_arg(char *&p) { char quote = *p; ++p; - string result; + std::string result; while (*p != '\0' && *p != quote) { // TODO: handle escape characters? Not sure if we need to. @@ -51,7 +50,7 @@ parse_quoted_arg(char *&p) { // beginning at p. Advances p to the first whitespace following the argument. static char * parse_unquoted_arg(char *&p) { - string result; + std::string result; while (*p != '\0' && !isspace(*p)) { result += *p; ++p; @@ -63,7 +62,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { char *command_line = GetCommandLine(); - vector argv; + std::vector argv; char *p = command_line; while (*p != '\0') { @@ -113,13 +112,13 @@ main(int argc, char *argv[]) { } if (archive_file == nullptr || *archive_file == '\0') { - cerr << "No archive filename specified on command line.\n"; + std::cerr << "No archive filename specified on command line.\n"; return 1; } FHandle input_handle = invalid_fhandle; if (input_handle_str != nullptr && *input_handle_str) { - stringstream stream(input_handle_str); + std::stringstream stream(input_handle_str); stream >> input_handle; if (!stream) { input_handle = invalid_fhandle; @@ -128,7 +127,7 @@ main(int argc, char *argv[]) { FHandle output_handle = invalid_fhandle; if (output_handle_str != nullptr && *output_handle_str) { - stringstream stream(output_handle_str); + std::stringstream stream(output_handle_str); stream >> output_handle; if (!stream) { output_handle = invalid_fhandle; @@ -137,7 +136,7 @@ main(int argc, char *argv[]) { bool interactive_console = false; if (interactive_console_str != nullptr && *interactive_console_str) { - stringstream stream(interactive_console_str); + std::stringstream stream(interactive_console_str); int flag; stream >> flag; if (!stream.fail()) { @@ -148,7 +147,7 @@ main(int argc, char *argv[]) { int status = run_p3dpython(program_name, archive_file, input_handle, output_handle, nullptr, interactive_console); if (status != 0) { - cerr << "Failure on startup.\n"; + std::cerr << "Failure on startup.\n"; } return status; } diff --git a/direct/src/plugin/p3dPythonObject.cxx b/direct/src/plugin/p3dPythonObject.cxx index fb52163b71..58a2d0348f 100644 --- a/direct/src/plugin/p3dPythonObject.cxx +++ b/direct/src/plugin/p3dPythonObject.cxx @@ -13,6 +13,8 @@ #include "p3dPythonObject.h" +using std::string; + /** * */ @@ -178,7 +180,7 @@ set_property_insecure(const string &property, bool needs_response, bool P3DPythonObject:: has_method(const string &method_name) { // First, check the cache. - pair cresult = _has_method.insert(HasMethod::value_type(method_name, false)); + std::pair cresult = _has_method.insert(HasMethod::value_type(method_name, false)); HasMethod::iterator hi = cresult.first; if (!cresult.second) { // Already cached. @@ -281,7 +283,7 @@ call_insecure(const string &method_name, bool needs_response, * This is intended for developer assistance. */ void P3DPythonObject:: -output(ostream &out) { +output(std::ostream &out) { P3D_object *result = call("__repr__", true, nullptr, 0); out << "Python " << _object_id; if (result != nullptr) { diff --git a/direct/src/plugin/p3dPythonRun.cxx b/direct/src/plugin/p3dPythonRun.cxx index 3d657597fe..b9e4c5655e 100644 --- a/direct/src/plugin/p3dPythonRun.cxx +++ b/direct/src/plugin/p3dPythonRun.cxx @@ -20,6 +20,8 @@ #include "py_panda.h" +using std::string; + extern "C" { // This has been compiled-in by the build system, if all is well. extern struct _frozen _PyImport_FrozenModules[]; @@ -118,7 +120,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, f.set_text(); if (f.open_write(_error_log)) { // Set up the indicated error log as the Notify output. - _error_log.setf(ios::unitbuf); + _error_log.setf(std::ios::unitbuf); Notify::ptr()->set_ostream_ptr(&_error_log, false); } } @@ -155,7 +157,7 @@ P3DPythonRun:: // Restore the notify stream in case it tries to write to anything else // after our shutdown. - Notify::ptr()->set_ostream_ptr(&cerr, false); + Notify::ptr()->set_ostream_ptr(&std::cerr, false); } /** @@ -1439,7 +1441,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { const char *parent_cstr = xwparams->Attribute("parent_xwindow"); if (parent_cstr != nullptr) { long window; - istringstream strm(parent_cstr); + std::istringstream strm(parent_cstr); strm >> window; parent_window_handle = NativeWindowHandle::make_x11((X11_Window)window); } diff --git a/direct/src/plugin/p3dPythonRun.h b/direct/src/plugin/p3dPythonRun.h index e478670cca..ee3fbc3d00 100644 --- a/direct/src/plugin/p3dPythonRun.h +++ b/direct/src/plugin/p3dPythonRun.h @@ -41,8 +41,6 @@ typedef int Py_ssize_t; #define PY_SSIZE_T_MIN INT_MIN #endif -using namespace std; - /** * This class is used to run, and communicate with, embedded Python in a sub- * process. It is compiled and launched as a separate executable from the diff --git a/direct/src/plugin/p3dSession.cxx b/direct/src/plugin/p3dSession.cxx index cb0fb58d78..4a769ec9e1 100644 --- a/direct/src/plugin/p3dSession.cxx +++ b/direct/src/plugin/p3dSession.cxx @@ -43,6 +43,9 @@ #include #endif +using std::string; +using std::wstring; + /** * Creates a new session, corresponding to a new subprocess with its own copy * of Python. The initial parameters for the session are taken from the @@ -1047,7 +1050,7 @@ start_p3dpython(P3DInstance *inst) { // Check if we want to keep copies of recent logs on disk. if (!log_basename.empty()) { // Get a list of all logs on disk - vector all_logs; + std::vector all_logs; string log_directory = inst_mgr->get_log_directory(); inst_mgr->scan_directory(log_directory, all_logs); @@ -1067,7 +1070,7 @@ start_p3dpython(P3DInstance *inst) { // Remove all but the most recent log_history timestamped logs string log_basename_dash = (log_basename + string("-")); string log_matching_pathname; - vector matching_logs; + std::vector matching_logs; for (int i=0; i<(int)all_logs.size(); ++i) { if ((all_logs[i].size() > 4) && (all_logs[i].find(log_basename_dash) == 0) && @@ -1457,7 +1460,7 @@ win_create_process() { // Construct the command-line string, containing the quoted command-line // arguments. - ostringstream stream; + std::ostringstream stream; stream << "\"" << _p3dpython_exe << "\" \"" << _mf_filename << "\" \"" << _input_handle << "\" \"" << _output_handle << "\" \"" << _interactive_console << "\""; @@ -1569,7 +1572,7 @@ posix_create_process() { } // build up an array of char strings for the environment. - vector ptrs; + std::vector ptrs; size_t p = 0; size_t zero = _env.find('\0', p); while (zero != string::npos) { @@ -1579,11 +1582,11 @@ posix_create_process() { } ptrs.push_back(nullptr); - stringstream input_handle_stream; + std::stringstream input_handle_stream; input_handle_stream << _input_handle; string input_handle_str = input_handle_stream.str(); - stringstream output_handle_stream; + std::stringstream output_handle_stream; output_handle_stream << _output_handle; string output_handle_str = output_handle_stream.str(); diff --git a/direct/src/plugin/p3dSplashWindow.cxx b/direct/src/plugin/p3dSplashWindow.cxx index 2660cb2b3e..13bcc09ff2 100644 --- a/direct/src/plugin/p3dSplashWindow.cxx +++ b/direct/src/plugin/p3dSplashWindow.cxx @@ -20,6 +20,10 @@ #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" +using std::max; +using std::min; +using std::string; + // The number of pixels to move the block per byte downloaded, when we don't // know the actual file size we're downloading. const double P3DSplashWindow::_unknown_progress_rate = 1.0 / 4096; diff --git a/direct/src/plugin/p3dStringObject.cxx b/direct/src/plugin/p3dStringObject.cxx index d0188a65af..8d87a2dc8c 100644 --- a/direct/src/plugin/p3dStringObject.cxx +++ b/direct/src/plugin/p3dStringObject.cxx @@ -17,7 +17,7 @@ * */ P3DStringObject:: -P3DStringObject(const string &value) : _value(value) { +P3DStringObject(const std::string &value) : _value(value) { } /** @@ -65,7 +65,7 @@ get_bool() { * to a string. */ void P3DStringObject:: -make_string(string &value) { +make_string(std::string &value) { value = _value; } @@ -74,9 +74,9 @@ make_string(string &value) { * This is intended for developer assistance. */ void P3DStringObject:: -output(ostream &out) { +output(std::ostream &out) { out << '"'; - for (string::const_iterator si = _value.begin(); si != _value.end(); ++si) { + for (std::string::const_iterator si = _value.begin(); si != _value.end(); ++si) { if (isprint(*si)) { switch (*si) { case '"': diff --git a/direct/src/plugin/p3dTemporaryFile.cxx b/direct/src/plugin/p3dTemporaryFile.cxx index ca7abe701a..bb7c8ca7a1 100644 --- a/direct/src/plugin/p3dTemporaryFile.cxx +++ b/direct/src/plugin/p3dTemporaryFile.cxx @@ -18,7 +18,7 @@ * Constructs a new, unique temporary filename. */ P3DTemporaryFile:: -P3DTemporaryFile(const string &extension) { +P3DTemporaryFile(const std::string &extension) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); _filename = inst_mgr->make_temp_filename(extension); } diff --git a/direct/src/plugin/p3dUndefinedObject.cxx b/direct/src/plugin/p3dUndefinedObject.cxx index 80cbb5897d..0ed227573f 100644 --- a/direct/src/plugin/p3dUndefinedObject.cxx +++ b/direct/src/plugin/p3dUndefinedObject.cxx @@ -41,6 +41,6 @@ get_bool() { * to a string. */ void P3DUndefinedObject:: -make_string(string &value) { +make_string(std::string &value) { value = "Undefined"; } diff --git a/direct/src/plugin/p3dWinSplashWindow.cxx b/direct/src/plugin/p3dWinSplashWindow.cxx index 5cc189b31c..256acb5eb8 100644 --- a/direct/src/plugin/p3dWinSplashWindow.cxx +++ b/direct/src/plugin/p3dWinSplashWindow.cxx @@ -95,7 +95,7 @@ set_visible(bool visible) { * the splash window. */ void P3DWinSplashWindow:: -set_image_filename(const string &image_filename, ImagePlacement image_placement) { +set_image_filename(const std::string &image_filename, ImagePlacement image_placement) { nout << "image_filename = " << image_filename << ", thread_id = " << _thread_id << "\n"; WinImageData *image = nullptr; switch (image_placement) { @@ -141,7 +141,7 @@ set_image_filename(const string &image_filename, ImagePlacement image_placement) * Specifies the text that is displayed above the install progress bar. */ void P3DWinSplashWindow:: -set_install_label(const string &install_label) { +set_install_label(const std::string &install_label) { ACQUIRE_LOCK(_install_lock); if (_install_label != install_label) { _install_label = install_label; @@ -493,7 +493,7 @@ update_image(WinImageData &image) { InvalidateRect(_hwnd, nullptr, TRUE); // Go read the image. - string data; + std::string data; if (!read_image_data(image, data, image._filename)) { return; } @@ -715,7 +715,7 @@ paint_image(HDC dc, const WinImageData &image, bool use_alpha) { // The bitmap is larger than the window; scale it down. double x_scale = (double)_win_width / (double)image._width; double y_scale = (double)_win_height / (double)image._height; - double scale = min(x_scale, y_scale); + double scale = std::min(x_scale, y_scale); int sc_width = (int)(image._width * scale); int sc_height = (int)(image._height * scale); diff --git a/direct/src/plugin/p3dWindowParams.cxx b/direct/src/plugin/p3dWindowParams.cxx index e6e9b750e4..29ed954823 100644 --- a/direct/src/plugin/p3dWindowParams.cxx +++ b/direct/src/plugin/p3dWindowParams.cxx @@ -78,7 +78,7 @@ make_xml(P3DInstance *inst) { // TinyXml doesn't support a "long" attribute. We'll use stringstream to // do it ourselves. { - ostringstream strm; + std::ostringstream strm; assert(_parent_window._window_handle_type == P3D_WHT_x11_window); strm << _parent_window._handle._x11_window._xwindow; xwparams->SetAttribute("parent_xwindow", strm.str()); diff --git a/direct/src/plugin/p3dX11SplashWindow.cxx b/direct/src/plugin/p3dX11SplashWindow.cxx index 2e1bbcb66e..07e5fc4d99 100644 --- a/direct/src/plugin/p3dX11SplashWindow.cxx +++ b/direct/src/plugin/p3dX11SplashWindow.cxx @@ -24,6 +24,9 @@ #include #include +using std::string; +using std::vector; + /** * */ @@ -1284,7 +1287,7 @@ scale_image(vector &image0, int &image0_width, int &image0_height } else { // Yuck, the bad case - we need to scale it down. - double scale = min((double)_win_width / (double)image._width, + double scale = std::min((double)_win_width / (double)image._width, (double)_win_height / (double)image._height); image0_width = (int)(image._width * scale); image0_height = (int)(image._height * scale); @@ -1335,8 +1338,8 @@ compose_two_images(vector &image0, int &image0_width, int &image0 const vector &image1, int image1_width, int image1_height, const vector &image2, int image2_width, int image2_height) { // First, the resulting image size is the larger of the two. - image0_width = max(image1_width, image2_width); - image0_height = max(image1_height, image2_height); + image0_width = std::max(image1_width, image2_width); + image0_height = std::max(image1_height, image2_height); int new_row_stride = image0_width * 4; int new_data_length = image0_height * new_row_stride; diff --git a/direct/src/plugin/p3d_plugin.cxx b/direct/src/plugin/p3d_plugin.cxx index 5cddf55b31..7e6c01108b 100644 --- a/direct/src/plugin/p3d_plugin.cxx +++ b/direct/src/plugin/p3d_plugin.cxx @@ -448,7 +448,7 @@ P3D_new_string_object(const char *str, int length) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); ACQUIRE_LOCK(_api_lock); - P3D_object *result = new P3DStringObject(string(str, length)); + P3D_object *result = new P3DStringObject(std::string(str, length)); RELEASE_LOCK(_api_lock); return result; diff --git a/direct/src/plugin/p3d_plugin_common.h b/direct/src/plugin/p3d_plugin_common.h index 748005c48d..6ddd0e057c 100644 --- a/direct/src/plugin/p3d_plugin_common.h +++ b/direct/src/plugin/p3d_plugin_common.h @@ -34,8 +34,6 @@ #include #include -using namespace std; - // Appears in p3dInstanceManager.cxx. extern std::ostream *nout_stream; #define nout (*nout_stream) diff --git a/direct/src/plugin/parse_color.cxx b/direct/src/plugin/parse_color.cxx index e3094e9d40..4a5f12b587 100644 --- a/direct/src/plugin/parse_color.cxx +++ b/direct/src/plugin/parse_color.cxx @@ -22,7 +22,7 @@ static bool parse_hexdigit(int &result, char digit); * in the range 0..255. On failure, r, g, b are undefined. */ bool -parse_color(int &r, int &g, int &b, const string &color) { +parse_color(int &r, int &g, int &b, const std::string &color) { if (color.empty() || color[0] != '#') { return false; } diff --git a/direct/src/plugin/parse_color.h b/direct/src/plugin/parse_color.h index ba5dd152a8..794abf2055 100644 --- a/direct/src/plugin/parse_color.h +++ b/direct/src/plugin/parse_color.h @@ -15,7 +15,6 @@ #define PARSE_COLOR_H #include -using namespace std; bool parse_color(int &r, int &g, int &b, const std::string &color); diff --git a/direct/src/plugin/wstring_encode.cxx b/direct/src/plugin/wstring_encode.cxx index 3766e7dc10..e844d643bd 100644 --- a/direct/src/plugin/wstring_encode.cxx +++ b/direct/src/plugin/wstring_encode.cxx @@ -21,13 +21,12 @@ #include #endif // _WIN32 - #ifdef _WIN32 /** * Encodes std::wstring to std::string using UTF-8. */ bool -wstring_to_string(string &result, const wstring &source) { +wstring_to_string(std::string &result, const std::wstring &source) { bool success = false; int size = WideCharToMultiByte(CP_UTF8, 0, source.data(), source.length(), nullptr, 0, nullptr, nullptr); @@ -51,7 +50,7 @@ wstring_to_string(string &result, const wstring &source) { * Decodes std::string to std::wstring using UTF-8. */ bool -string_to_wstring(wstring &result, const string &source) { +string_to_wstring(std::wstring &result, const std::string &source) { bool success = false; int size = MultiByteToWideChar(CP_UTF8, 0, source.data(), source.length(), nullptr, 0); diff --git a/direct/src/plugin/wstring_encode.h b/direct/src/plugin/wstring_encode.h index 5d5ebab4de..b9641bd43d 100644 --- a/direct/src/plugin/wstring_encode.h +++ b/direct/src/plugin/wstring_encode.h @@ -15,7 +15,6 @@ #define WSTRING_ENCODE_H #include -using namespace std; // Presently, these two functions are implemented only for Windows, which is // the only place they are needed. (Only Windows requires wstrings for diff --git a/direct/src/plugin/xml_helpers.cxx b/direct/src/plugin/xml_helpers.cxx index 20da4ce7ca..9a997189da 100644 --- a/direct/src/plugin/xml_helpers.cxx +++ b/direct/src/plugin/xml_helpers.cxx @@ -21,7 +21,7 @@ * empty. */ bool -parse_bool_attrib(TiXmlElement *xelem, const string &attrib, +parse_bool_attrib(TiXmlElement *xelem, const std::string &attrib, bool default_value) { const char *value = xelem->Attribute(attrib.c_str()); if (value == nullptr || *value == '\0') { diff --git a/direct/src/plugin_npapi/nppanda3d_common.h b/direct/src/plugin_npapi/nppanda3d_common.h index a3bb8f0191..c1b7cd61af 100644 --- a/direct/src/plugin_npapi/nppanda3d_common.h +++ b/direct/src/plugin_npapi/nppanda3d_common.h @@ -30,8 +30,6 @@ #include #include -using namespace std; - // Appears in startup.cxx. extern std::ostream *nout_stream; #define nout (*nout_stream) diff --git a/direct/src/plugin_npapi/ppBrowserObject.cxx b/direct/src/plugin_npapi/ppBrowserObject.cxx index 9655295141..17104b9e6c 100644 --- a/direct/src/plugin_npapi/ppBrowserObject.cxx +++ b/direct/src/plugin_npapi/ppBrowserObject.cxx @@ -16,6 +16,8 @@ #include #include // strncpy +using std::string; + // The following functions are C-style wrappers around the above // PPBrowserObject methods; they are defined to allow us to create the C-style // P3D_class_definition method table to store in the P3D_object structure. @@ -105,7 +107,7 @@ PPBrowserObject:: */ int PPBrowserObject:: get_repr(char *buffer, int buffer_length) const { - ostringstream strm; + std::ostringstream strm; strm << "NPObject " << _npobj; string result = strm.str(); strncpy(buffer, result.c_str(), buffer_length); diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index 8e3281c405..6a3d961e32 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -41,6 +41,12 @@ #include #endif // HAVE_X11 +using std::ios; +using std::ostream; +using std::ostringstream; +using std::string; +using std::vector; + PPInstance::FileDatas PPInstance::_file_datas; @@ -1154,7 +1160,7 @@ void PPInstance:: choose_random_mirrors(vector &result, int num_mirrors) { vector selected; - size_t num_to_select = min(_mirrors.size(), (size_t)num_mirrors); + size_t num_to_select = std::min(_mirrors.size(), (size_t)num_mirrors); while (num_to_select > 0) { size_t i = (size_t)(((double)rand() / (double)RAND_MAX) * _mirrors.size()); while (find(selected.begin(), selected.end(), i) != selected.end()) { @@ -1313,11 +1319,11 @@ read_contents_file(const string &contents_filename, bool fresh_download) { xorig->Attribute("expiration", &expiration); } - _contents_expiration = min(_contents_expiration, (time_t)expiration); + _contents_expiration = std::min(_contents_expiration, (time_t)expiration); } nout << "read contents.xml, max_age = " << max_age - << ", expires in " << max(_contents_expiration, now) - now + << ", expires in " << std::max(_contents_expiration, now) - now << " s\n"; // Look for the entry; it might point us at a different download @@ -2411,7 +2417,7 @@ copy_cocoa_event(P3DCocoaEvent *p3d_event, NPCocoaEvent *np_event, * returns result.c_str(). */ const wchar_t *PPInstance:: -make_ansi_string(wstring &result, NPNSString *ns_string) { +make_ansi_string(std::wstring &result, NPNSString *ns_string) { result.clear(); if (ns_string != nullptr) { diff --git a/direct/src/plugin_npapi/ppPandaObject.cxx b/direct/src/plugin_npapi/ppPandaObject.cxx index f85ef43407..e4e4854c3f 100644 --- a/direct/src/plugin_npapi/ppPandaObject.cxx +++ b/direct/src/plugin_npapi/ppPandaObject.cxx @@ -13,6 +13,8 @@ #include "ppPandaObject.h" +using std::string; + NPClass PPPandaObject::_object_class = { NP_CLASS_STRUCT_VERSION, &PPPandaObject::NPAllocate, @@ -304,7 +306,7 @@ identifier_to_string(NPIdentifier ident) { // Firefox does, but Safari doesn't appear to use integer identifiers and // just sends everything as a string identifier. So to make things // consistent internally, we also send everything as a string. - ostringstream strm; + std::ostringstream strm; strm << browser->intfromidentifier(ident); return strm.str(); } diff --git a/direct/src/plugin_npapi/startup.cxx b/direct/src/plugin_npapi/startup.cxx index 0c6a99c258..315a21f8cc 100644 --- a/direct/src/plugin_npapi/startup.cxx +++ b/direct/src/plugin_npapi/startup.cxx @@ -23,8 +23,10 @@ #include #endif +using std::string; + static ofstream logfile; -ostream *nout_stream = &logfile; +std::ostream *nout_stream = &logfile; string global_root_dir; bool has_plugin_thread_async_call; @@ -62,7 +64,7 @@ open_logfile() { if (log_directory.empty()) { log_directory = global_root_dir + "/log"; } - mkdir_complete(log_directory, cerr); + mkdir_complete(log_directory, std::cerr); // Ensure that the log directory ends with a slash. if (!log_directory.empty() && log_directory[log_directory.size() - 1] != '/') { @@ -92,13 +94,13 @@ open_logfile() { logfile.close(); logfile.clear(); #ifdef _WIN32 - wstring log_pathname_w; + std::wstring log_pathname_w; string_to_wstring(log_pathname_w, log_pathname); - logfile.open(log_pathname_w.c_str(), ios::out | ios::trunc); + logfile.open(log_pathname_w.c_str(), std::ios::out | std::ios::trunc); #else - logfile.open(log_pathname.c_str(), ios::out | ios::trunc); + logfile.open(log_pathname.c_str(), std::ios::out | std::ios::trunc); #endif // _WIN32 - logfile.setf(ios::unitbuf); + logfile.setf(std::ios::unitbuf); } // If we didn't have a logfile name compiled in, we throw away log output diff --git a/direct/src/plugin_standalone/p3dEmbed.cxx b/direct/src/plugin_standalone/p3dEmbed.cxx index 14903aa600..1d191e9c22 100644 --- a/direct/src/plugin_standalone/p3dEmbed.cxx +++ b/direct/src/plugin_standalone/p3dEmbed.cxx @@ -17,6 +17,9 @@ #include "load_plugin.h" #include "find_root_dir.h" +using std::cerr; +using std::string; + /** * */ @@ -36,7 +39,7 @@ P3DEmbed(bool console_environment) : Panda3DBase(console_environment) { * offset. */ int P3DEmbed:: -run_embedded(streampos read_offset, int argc, char *argv[]) { +run_embedded(std::streampos read_offset, int argc, char *argv[]) { // Check to see if we've actually got an application embedded. If we do, // read_offset will have been modified to contain a different value than the // one we compiled in, above. We test against read_offset + 1, because any @@ -46,8 +49,8 @@ run_embedded(streampos read_offset, int argc, char *argv[]) { // We also have to store this computation in a member variable, to work // around a compiler optimization that might otherwise remove the + 1 from // the test. - _read_offset_check = read_offset + (streampos)1; - if (_read_offset_check == (streampos)0xFF3D3D01) { + _read_offset_check = read_offset + (std::streampos)1; + if (_read_offset_check == (std::streampos)0xFF3D3D01) { cerr << "This program is not intended to be run directly.\nIt is used " "by pdeploy to construct an embedded Panda3D application.\n"; return 1; diff --git a/direct/src/plugin_standalone/panda3d.cxx b/direct/src/plugin_standalone/panda3d.cxx index 8710d92696..d21933a441 100644 --- a/direct/src/plugin_standalone/panda3d.cxx +++ b/direct/src/plugin_standalone/panda3d.cxx @@ -29,6 +29,10 @@ #include #endif +using std::cerr; +using std::cout; +using std::string; + /** * */ @@ -410,7 +414,7 @@ download_contents_file(const Filename &contents_filename) { if (!success) { // Go download contents.xml from the actual host. - ostringstream strm; + std::ostringstream strm; strm << _host_url_prefix << "contents.xml"; // Append a uniquifying query string to the URL to force the download to // go all the way through any caches. We use the time in seconds; that's @@ -498,7 +502,7 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { xorig->Attribute("expiration", &expiration); } - _contents_expiration = min(_contents_expiration, (time_t)expiration); + _contents_expiration = std::min(_contents_expiration, (time_t)expiration); } // Look for the entry; it might point us at a different download @@ -670,7 +674,7 @@ void Panda3D:: choose_random_mirrors(vector_string &result, int num_mirrors) { pvector selected; - size_t num_to_select = min(_mirrors.size(), (size_t)num_mirrors); + size_t num_to_select = std::min(_mirrors.size(), (size_t)num_mirrors); while (num_to_select > 0) { size_t i = (size_t)(((double)rand() / (double)RAND_MAX) * _mirrors.size()); while (find(selected.begin(), selected.end(), i) != selected.end()) { @@ -740,7 +744,7 @@ get_core_api() { #endif // Format the coreapi_timestamp as a string, for passing as a parameter. - ostringstream stream; + std::ostringstream stream; stream << _coreapi_dll.get_timestamp(); string coreapi_timestamp = stream.str(); @@ -765,7 +769,7 @@ download_core_api() { // Our last act of desperation: hit the original host, with a query // uniquifier, to break through any caches. - ostringstream strm; + std::ostringstream strm; strm << _download_url_prefix << _coreapi_dll.get_filename() << "?" << time(nullptr); url = strm.str(); diff --git a/direct/src/plugin_standalone/panda3dBase.cxx b/direct/src/plugin_standalone/panda3dBase.cxx index 07f86fb18a..cfdaeb1350 100644 --- a/direct/src/plugin_standalone/panda3dBase.cxx +++ b/direct/src/plugin_standalone/panda3dBase.cxx @@ -35,6 +35,9 @@ #include #include +using std::cerr; +using std::string; + // The amount of time in seconds to wait for new messages. static const double wait_cycle = 0.2; @@ -436,7 +439,7 @@ read_p3d_info(const Filename &p3d_filename, int p3d_offset) { string p3d_info; mf->read_subfile(si, p3d_info); - istringstream strm(p3d_info); + std::istringstream strm(p3d_info); TiXmlDocument doc; strm >> doc; if (strm.fail() && !strm.eof()) { diff --git a/direct/src/plugin_standalone/panda3dMac.cxx b/direct/src/plugin_standalone/panda3dMac.cxx index 06877b9af0..5a87c60d3e 100644 --- a/direct/src/plugin_standalone/panda3dMac.cxx +++ b/direct/src/plugin_standalone/panda3dMac.cxx @@ -16,7 +16,6 @@ #include #include -using namespace std; // Having a global Panda3DMac object just makes things easier. static Panda3DMac *this_prog; @@ -48,7 +47,7 @@ open_p3d_file(FSRef *ref) { UInt8 filename[buffer_size]; err = FSRefMakePath(ref, filename, buffer_size); if (err) { - cerr << "Couldn't get filename\n"; + std::cerr << "Couldn't get filename\n"; return; } diff --git a/direct/src/plugin_standalone/panda3dWinMain.cxx b/direct/src/plugin_standalone/panda3dWinMain.cxx index dbf951da4c..ec7b8e630c 100644 --- a/direct/src/plugin_standalone/panda3dWinMain.cxx +++ b/direct/src/plugin_standalone/panda3dWinMain.cxx @@ -22,7 +22,7 @@ static char * parse_quoted_arg(char *&p) { char quote = *p; ++p; - string result; + std::string result; while (*p != '\0' && *p != quote) { // TODO: handle escape characters? Not sure if we need to. @@ -39,7 +39,7 @@ parse_quoted_arg(char *&p) { // beginning at p. Advances p to the first whitespace following the argument. static char * parse_unquoted_arg(char *&p) { - string result; + std::string result; while (*p != '\0' && !isspace(*p)) { result += *p; ++p; @@ -51,7 +51,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { char *command_line = GetCommandLine(); - vector argv; + std::vector argv; char *p = command_line; while (*p != '\0') { diff --git a/direct/src/showbase/showBase.cxx b/direct/src/showbase/showBase.cxx index 12aa08d4bd..f14d9610a4 100644 --- a/direct/src/showbase/showBase.cxx +++ b/direct/src/showbase/showBase.cxx @@ -34,6 +34,9 @@ TOGGLEKEYS g_StartupToggleKeys = {sizeof(TOGGLEKEYS), 0}; FILTERKEYS g_StartupFilterKeys = {sizeof(FILTERKEYS), 0}; #endif +using std::max; +using std::min; + #if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_SHOWBASE) #error Buildsystem error: BUILDING_DIRECT_SHOWBASE not defined #endif @@ -201,7 +204,7 @@ add_grid_zone(unsigned int x, // zoneBase is the first zone in the grid (e.g. the upper left) // zoneResolution is the number of cells on each axsis. returns the next // available zoneBase (i.e. zoneBase+xZoneResolution*yZoneResolution) - cerr<<"adding grid zone with a zoneBase of "< 1.0 || y < 0.0 || y > 1.0) { return 0; } - cerr<<"resolution="<output(out, indent_level, scope, complete); out << "["; @@ -180,16 +180,16 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * have special exceptions. */ void CPPArrayType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const { - ostringstream brackets; +output_instance(std::ostream &out, int indent_level, CPPScope *scope, + bool complete, const std::string &prename, + const std::string &name) const { + std::ostringstream brackets; brackets << "["; if (_bounds != nullptr) { brackets << *_bounds; } brackets << "]"; - string bracketsstr = brackets.str(); + std::string bracketsstr = brackets.str(); _element_type->output_instance(out, indent_level, scope, complete, prename, name + bracketsstr); diff --git a/dtool/src/cppparser/cppBison.cxx.prebuilt b/dtool/src/cppparser/cppBison.cxx.prebuilt index f1985d488e..4bff774461 100644 --- a/dtool/src/cppparser/cppBison.cxx.prebuilt +++ b/dtool/src/cppparser/cppBison.cxx.prebuilt @@ -97,6 +97,9 @@ #include "cppNamespace.h" #include "cppUsing.h" +using std::stringstream; +using std::string; + //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index d132677763..5c2721eea7 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -32,6 +32,9 @@ #include "cppNamespace.h" #include "cppUsing.h" +using std::stringstream; +using std::string; + //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/cppparser/cppBisonDefs.h b/dtool/src/cppparser/cppBisonDefs.h index 1c7be65b85..9e8f71f9b1 100644 --- a/dtool/src/cppparser/cppBisonDefs.h +++ b/dtool/src/cppparser/cppBisonDefs.h @@ -27,8 +27,6 @@ #include "cppExtensionType.h" #include "cppFile.h" -using namespace std; - class CPPParser; class CPPExpression; class CPPPreprocessor; diff --git a/dtool/src/cppparser/cppClassTemplateParameter.cxx b/dtool/src/cppparser/cppClassTemplateParameter.cxx index 46fb525b8b..7c85eb6c24 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.cxx +++ b/dtool/src/cppparser/cppClassTemplateParameter.cxx @@ -40,7 +40,7 @@ is_fully_specified() const { * */ void CPPClassTemplateParameter:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (complete) { out << "class"; if (_packed) { diff --git a/dtool/src/cppparser/cppClosureType.cxx b/dtool/src/cppparser/cppClosureType.cxx index 974742e5df..1d12602c3b 100644 --- a/dtool/src/cppparser/cppClosureType.cxx +++ b/dtool/src/cppparser/cppClosureType.cxx @@ -49,7 +49,7 @@ operator = (const CPPClosureType ©) { * Adds a new capture to the beginning of the capture list. */ void CPPClosureType:: -add_capture(string name, CaptureType type, CPPExpression *initializer) { +add_capture(std::string name, CaptureType type, CPPExpression *initializer) { if (type == CT_none) { if (name == "this") { type = CT_by_reference; @@ -58,8 +58,8 @@ add_capture(string name, CaptureType type, CPPExpression *initializer) { } } - Capture capture = {move(name), type, initializer}; - _captures.insert(_captures.begin(), move(capture)); + Capture capture = {std::move(name), type, initializer}; + _captures.insert(_captures.begin(), std::move(capture)); } /** @@ -100,7 +100,7 @@ is_destructible() const { * */ void CPPClosureType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { out.put('['); bool have_capture = false; diff --git a/dtool/src/cppparser/cppConstType.cxx b/dtool/src/cppparser/cppConstType.cxx index f7eb198782..139a25dc5c 100644 --- a/dtool/src/cppparser/cppConstType.cxx +++ b/dtool/src/cppparser/cppConstType.cxx @@ -171,7 +171,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPConstType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { _wrapped_around->output(out, indent_level, scope, complete); out << " const"; } @@ -182,9 +182,9 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * have special exceptions. */ void CPPConstType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const { +output_instance(std::ostream &out, int indent_level, CPPScope *scope, + bool complete, const std::string &prename, + const std::string &name) const { _wrapped_around->output_instance(out, indent_level, scope, complete, "const " + prename, name); } diff --git a/dtool/src/cppparser/cppDeclaration.cxx b/dtool/src/cppparser/cppDeclaration.cxx index 444801ceea..0125ed4289 100644 --- a/dtool/src/cppparser/cppDeclaration.cxx +++ b/dtool/src/cppparser/cppDeclaration.cxx @@ -338,8 +338,8 @@ is_less(const CPPDeclaration *other) const { } -ostream & -operator << (ostream &out, const CPPDeclaration::SubstDecl &subst) { +std::ostream & +operator << (std::ostream &out, const CPPDeclaration::SubstDecl &subst) { CPPDeclaration::SubstDecl::const_iterator it; for (it = subst.begin(); it != subst.end(); ++it) { out << " "; diff --git a/dtool/src/cppparser/cppDeclaration.h b/dtool/src/cppparser/cppDeclaration.h index d472c277fd..967dc6b6ec 100644 --- a/dtool/src/cppparser/cppDeclaration.h +++ b/dtool/src/cppparser/cppDeclaration.h @@ -25,8 +25,6 @@ #include #include -using namespace std; - class CPPInstance; class CPPTemplateParameterList; class CPPTypedefType; diff --git a/dtool/src/cppparser/cppEnumType.cxx b/dtool/src/cppparser/cppEnumType.cxx index ffbce64a7d..11fcd5da3e 100644 --- a/dtool/src/cppparser/cppEnumType.cxx +++ b/dtool/src/cppparser/cppEnumType.cxx @@ -89,7 +89,7 @@ get_underlying_type() { * */ CPPInstance *CPPEnumType:: -add_element(const string &name, CPPExpression *value, CPPPreprocessor *preprocessor, const cppyyltype &pos) { +add_element(const std::string &name, CPPExpression *value, CPPPreprocessor *preprocessor, const cppyyltype &pos) { CPPIdentifier *ident = new CPPIdentifier(name); ident->_native_scope = _parent_scope; @@ -262,7 +262,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPEnumType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (!complete && _ident != nullptr) { // If we have a name, use it. if (cppparser_output_class_keyword) { diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index ed36275af9..2b2cc0bd50 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -31,6 +31,9 @@ #include +using std::cerr; +using std::string; + /** * */ @@ -161,7 +164,7 @@ as_boolean() const { * */ void CPPExpression::Result:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_type) { case RT_integer: out << _u._integer; @@ -1551,7 +1554,7 @@ is_tbd() const { * */ void CPPExpression:: -output(ostream &out, int indent_level, CPPScope *scope, bool) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool) const { switch (_type) { case T_nullptr: out << "nullptr"; @@ -1630,8 +1633,8 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { if (isprint(*si)) { out << *si; } else { - out << '\\' << oct << setw(3) << setfill('0') << (int)(*si) - << dec << setw(0); + out << '\\' << std::oct << std::setw(3) << std::setfill('0') << (int)(*si) + << std::dec << std::setw(0); } } } diff --git a/dtool/src/cppparser/cppExpressionParser.cxx b/dtool/src/cppparser/cppExpressionParser.cxx index c0821712fc..ef5785eb5a 100644 --- a/dtool/src/cppparser/cppExpressionParser.cxx +++ b/dtool/src/cppparser/cppExpressionParser.cxx @@ -36,9 +36,9 @@ CPPExpressionParser:: * */ bool CPPExpressionParser:: -parse_expr(const string &expr) { +parse_expr(const std::string &expr) { if (!init_const_expr(expr)) { - cerr << "Unable to parse expression\n"; + std::cerr << "Unable to parse expression\n"; return false; } @@ -51,9 +51,9 @@ parse_expr(const string &expr) { * */ bool CPPExpressionParser:: -parse_expr(const string &expr, const CPPPreprocessor &filepos) { +parse_expr(const std::string &expr, const CPPPreprocessor &filepos) { if (!init_const_expr(expr)) { - cerr << "Unable to parse expression\n"; + std::cerr << "Unable to parse expression\n"; return false; } @@ -68,7 +68,7 @@ parse_expr(const string &expr, const CPPPreprocessor &filepos) { * */ void CPPExpressionParser:: -output(ostream &out) const { +output(std::ostream &out) const { if (_expr == nullptr) { out << "(null expr)"; } else { diff --git a/dtool/src/cppparser/cppExtensionType.cxx b/dtool/src/cppparser/cppExtensionType.cxx index ef5168334b..b7d23cb667 100644 --- a/dtool/src/cppparser/cppExtensionType.cxx +++ b/dtool/src/cppparser/cppExtensionType.cxx @@ -36,7 +36,7 @@ CPPExtensionType(CPPExtensionType::Type type, /** * */ -string CPPExtensionType:: +std::string CPPExtensionType:: get_simple_name() const { if (_ident == nullptr) { return ""; @@ -47,7 +47,7 @@ get_simple_name() const { /** * */ -string CPPExtensionType:: +std::string CPPExtensionType:: get_local_name(CPPScope *scope) const { if (_ident == nullptr) { return ""; @@ -58,7 +58,7 @@ get_local_name(CPPScope *scope) const { /** * */ -string CPPExtensionType:: +std::string CPPExtensionType:: get_fully_scoped_name() const { if (_ident == nullptr) { return ""; @@ -209,7 +209,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPExtensionType:: -output(ostream &out, int, CPPScope *scope, bool complete) const { +output(std::ostream &out, int, CPPScope *scope, bool complete) const { if (_ident != nullptr) { // If we have a name, use it. if (complete || cppparser_output_class_keyword) { @@ -242,8 +242,8 @@ as_extension_type() { return this; } -ostream & -operator << (ostream &out, CPPExtensionType::Type type) { +std::ostream & +operator << (std::ostream &out, CPPExtensionType::Type type) { switch (type) { case CPPExtensionType::T_enum: return out << "enum"; diff --git a/dtool/src/cppparser/cppFile.cxx b/dtool/src/cppparser/cppFile.cxx index a42602013f..ce9a61ffc5 100644 --- a/dtool/src/cppparser/cppFile.cxx +++ b/dtool/src/cppparser/cppFile.cxx @@ -15,6 +15,8 @@ #include +using std::string; + /** * */ diff --git a/dtool/src/cppparser/cppFunctionGroup.cxx b/dtool/src/cppparser/cppFunctionGroup.cxx index fdec00184d..7904663d08 100644 --- a/dtool/src/cppparser/cppFunctionGroup.cxx +++ b/dtool/src/cppparser/cppFunctionGroup.cxx @@ -20,7 +20,7 @@ * */ CPPFunctionGroup:: -CPPFunctionGroup(const string &name) : +CPPFunctionGroup(const std::string &name) : CPPDeclaration(CPPFile()), _name(name) { @@ -61,7 +61,7 @@ get_return_type() const { * */ void CPPFunctionGroup:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (!_instances.empty()) { Instances::const_iterator ii = _instances.begin(); (*ii)->output(out, indent_level, scope, complete); diff --git a/dtool/src/cppparser/cppFunctionType.cxx b/dtool/src/cppparser/cppFunctionType.cxx index 221297061d..27699d711b 100644 --- a/dtool/src/cppparser/cppFunctionType.cxx +++ b/dtool/src/cppparser/cppFunctionType.cxx @@ -16,6 +16,10 @@ #include "cppSimpleType.h" #include "cppInstance.h" +using std::ostream; +using std::ostringstream; +using std::string; + /** * */ diff --git a/dtool/src/cppparser/cppGlobals.cxx b/dtool/src/cppparser/cppGlobals.cxx index a435227203..f537ce8c42 100644 --- a/dtool/src/cppparser/cppGlobals.cxx +++ b/dtool/src/cppparser/cppGlobals.cxx @@ -13,4 +13,4 @@ #include "cppGlobals.h" -string cpp_longlong_keyword; +std::string cpp_longlong_keyword; diff --git a/dtool/src/cppparser/cppIdentifier.cxx b/dtool/src/cppparser/cppIdentifier.cxx index 9fd7b500c8..43c937177b 100644 --- a/dtool/src/cppparser/cppIdentifier.cxx +++ b/dtool/src/cppparser/cppIdentifier.cxx @@ -19,6 +19,8 @@ #include "cppTBDType.h" #include "cppStructType.h" +using std::string; + /** * @@ -546,7 +548,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPIdentifier:: -output(ostream &out, CPPScope *scope) const { +output(std::ostream &out, CPPScope *scope) const { if (scope == nullptr) { output_fully_scoped_name(out); } else { @@ -559,7 +561,7 @@ output(ostream &out, CPPScope *scope) const { * */ void CPPIdentifier:: -output_local_name(ostream &out, CPPScope *scope) const { +output_local_name(std::ostream &out, CPPScope *scope) const { assert(!_names.empty()); if (scope == nullptr || (_native_scope == nullptr && _names.size() == 1)) { @@ -583,7 +585,7 @@ output_local_name(ostream &out, CPPScope *scope) const { * */ void CPPIdentifier:: -output_fully_scoped_name(ostream &out) const { +output_fully_scoped_name(std::ostream &out) const { if (_native_scope != nullptr) { _native_scope->output(out, nullptr); out << "::"; diff --git a/dtool/src/cppparser/cppInstance.cxx b/dtool/src/cppparser/cppInstance.cxx index eb71e47315..cb59e9a048 100644 --- a/dtool/src/cppparser/cppInstance.cxx +++ b/dtool/src/cppparser/cppInstance.cxx @@ -26,6 +26,8 @@ #include +using std::string; + /** * */ @@ -506,7 +508,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPInstance:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { output(out, indent_level, scope, complete, -1); } @@ -515,7 +517,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * function prototype. See CPPFunctionType::output(). */ void CPPInstance:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete, +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete, int num_default_parameters) const { assert(_type != nullptr); diff --git a/dtool/src/cppparser/cppInstanceIdentifier.cxx b/dtool/src/cppparser/cppInstanceIdentifier.cxx index b75dfc6424..878d751285 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.cxx +++ b/dtool/src/cppparser/cppInstanceIdentifier.cxx @@ -119,8 +119,8 @@ add_func_modifier(CPPParameterList *params, int flags, CPPType *trailing_return_ if (_ident != nullptr && _ident->get_simple_name().substr(0, 9) == "operator ") { - if (_ident->get_simple_name() != string("operator ()") && - _ident->get_simple_name() != string("operator []")) { + if (_ident->get_simple_name() != std::string("operator ()") && + _ident->get_simple_name() != std::string("operator []")) { if (params->_parameters.empty()) { flags |= CPPFunctionType::F_unary_op; } @@ -184,7 +184,7 @@ add_trailing_return_type(CPPType *type) { return; } } - cerr << "trailing return type can only be added to a function\n"; + std::cerr << "trailing return type can only be added to a function\n"; } /** @@ -296,7 +296,7 @@ r_unroll_type(CPPType *start_type, if (simple_type != nullptr && simple_type->_type == CPPSimpleType::T_auto) { return_type = mod._trailing_return_type; } else { - cerr << "function with trailing return type needs auto\n"; + std::cerr << "function with trailing return type needs auto\n"; } } result = new CPPFunctionType(return_type, mod._func_params, @@ -312,7 +312,7 @@ r_unroll_type(CPPType *start_type, break; default: - cerr << "Internal error--invalid CPPInstanceIdentifier\n"; + std::cerr << "Internal error--invalid CPPInstanceIdentifier\n"; abort(); } diff --git a/dtool/src/cppparser/cppInstanceIdentifier.h b/dtool/src/cppparser/cppInstanceIdentifier.h index 795677513e..6a2951d9cb 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.h +++ b/dtool/src/cppparser/cppInstanceIdentifier.h @@ -19,8 +19,6 @@ #include #include -using namespace std; - class CPPIdentifier; class CPPParameterList; class CPPType; diff --git a/dtool/src/cppparser/cppMakeProperty.cxx b/dtool/src/cppparser/cppMakeProperty.cxx index e75cfb5676..1846092eaa 100644 --- a/dtool/src/cppparser/cppMakeProperty.cxx +++ b/dtool/src/cppparser/cppMakeProperty.cxx @@ -38,7 +38,7 @@ CPPMakeProperty(CPPIdentifier *ident, Type type, /** * */ -string CPPMakeProperty:: +std::string CPPMakeProperty:: get_simple_name() const { return _ident->get_simple_name(); } @@ -46,7 +46,7 @@ get_simple_name() const { /** * */ -string CPPMakeProperty:: +std::string CPPMakeProperty:: get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } @@ -54,7 +54,7 @@ get_local_name(CPPScope *scope) const { /** * */ -string CPPMakeProperty:: +std::string CPPMakeProperty:: get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } @@ -63,7 +63,7 @@ get_fully_scoped_name() const { * */ void CPPMakeProperty:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_length_function != nullptr) { out << "__make_seq_property"; } else { diff --git a/dtool/src/cppparser/cppMakeSeq.cxx b/dtool/src/cppparser/cppMakeSeq.cxx index d9b5ac7fcd..b032d367bb 100644 --- a/dtool/src/cppparser/cppMakeSeq.cxx +++ b/dtool/src/cppparser/cppMakeSeq.cxx @@ -32,7 +32,7 @@ CPPMakeSeq(CPPIdentifier *ident, /** * */ -string CPPMakeSeq:: +std::string CPPMakeSeq:: get_simple_name() const { return _ident->get_simple_name(); } @@ -40,7 +40,7 @@ get_simple_name() const { /** * */ -string CPPMakeSeq:: +std::string CPPMakeSeq:: get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } @@ -48,7 +48,7 @@ get_local_name(CPPScope *scope) const { /** * */ -string CPPMakeSeq:: +std::string CPPMakeSeq:: get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } @@ -57,7 +57,7 @@ get_fully_scoped_name() const { * */ void CPPMakeSeq:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { out << "__make_seq(" << _ident->get_local_name(scope) << ", " << _length_getter->_name << ", " << _element_getter->_name diff --git a/dtool/src/cppparser/cppManifest.cxx b/dtool/src/cppparser/cppManifest.cxx index faaaced2d8..2fc85783a7 100644 --- a/dtool/src/cppparser/cppManifest.cxx +++ b/dtool/src/cppparser/cppManifest.cxx @@ -16,6 +16,8 @@ #include +using std::string; + /** * */ @@ -252,7 +254,7 @@ determine_type() const { * */ void CPPManifest:: -output(ostream &out) const { +output(std::ostream &out) const { out << _name; if (_has_parameters) { diff --git a/dtool/src/cppparser/cppNameComponent.cxx b/dtool/src/cppparser/cppNameComponent.cxx index b5c7f825aa..1c8e4df88b 100644 --- a/dtool/src/cppparser/cppNameComponent.cxx +++ b/dtool/src/cppparser/cppNameComponent.cxx @@ -14,6 +14,8 @@ #include "cppNameComponent.h" #include "cppTemplateParameterList.h" +using std::string; + /** * */ @@ -83,7 +85,7 @@ get_name() const { */ string CPPNameComponent:: get_name_with_templ(CPPScope *scope) const { - ostringstream strm; + std::ostringstream strm; strm << _name; if (_templ != nullptr) { strm << "< "; @@ -157,7 +159,7 @@ set_templ(CPPTemplateParameterList *templ) { * */ void CPPNameComponent:: -output(ostream &out) const { +output(std::ostream &out) const { out << _name; if (_templ != nullptr) { out << "< " << *_templ << " >"; diff --git a/dtool/src/cppparser/cppNameComponent.h b/dtool/src/cppparser/cppNameComponent.h index cdeb293fca..a33de22a39 100644 --- a/dtool/src/cppparser/cppNameComponent.h +++ b/dtool/src/cppparser/cppNameComponent.h @@ -19,8 +19,6 @@ #include -using namespace std; - class CPPTemplateParameterList; class CPPScope; diff --git a/dtool/src/cppparser/cppNamespace.cxx b/dtool/src/cppparser/cppNamespace.cxx index c8e84a3725..9a6f608f49 100644 --- a/dtool/src/cppparser/cppNamespace.cxx +++ b/dtool/src/cppparser/cppNamespace.cxx @@ -31,7 +31,7 @@ CPPNamespace(CPPIdentifier *ident, CPPScope *scope, const CPPFile &file) : /** * */ -string CPPNamespace:: +std::string CPPNamespace:: get_simple_name() const { if (_ident == nullptr) { return ""; @@ -42,7 +42,7 @@ get_simple_name() const { /** * */ -string CPPNamespace:: +std::string CPPNamespace:: get_local_name(CPPScope *scope) const { if (_ident == nullptr) { return ""; @@ -53,7 +53,7 @@ get_local_name(CPPScope *scope) const { /** * */ -string CPPNamespace:: +std::string CPPNamespace:: get_fully_scoped_name() const { if (_ident == nullptr) { return ""; @@ -73,7 +73,7 @@ get_scope() const { * */ void CPPNamespace:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_is_inline) { out << "inline "; } diff --git a/dtool/src/cppparser/cppParameterList.cxx b/dtool/src/cppparser/cppParameterList.cxx index 6ecdbc665d..4fc5198b6e 100644 --- a/dtool/src/cppparser/cppParameterList.cxx +++ b/dtool/src/cppparser/cppParameterList.cxx @@ -198,7 +198,7 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { * shown. */ void CPPParameterList:: -output(ostream &out, CPPScope *scope, bool parameter_names, +output(std::ostream &out, CPPScope *scope, bool parameter_names, int num_default_parameters) const { if (!_parameters.empty()) { for (int i = 0; i < (int)_parameters.size(); ++i) { diff --git a/dtool/src/cppparser/cppParser.cxx b/dtool/src/cppparser/cppParser.cxx index 6b13d95dec..f236a238c9 100644 --- a/dtool/src/cppparser/cppParser.cxx +++ b/dtool/src/cppparser/cppParser.cxx @@ -59,7 +59,7 @@ parse_file(const Filename &filename) { } if (!init_cpp(file)) { - cerr << "Unable to read " << filename << "\n"; + std::cerr << "Unable to read " << filename << "\n"; return false; } parse_cpp(this); @@ -72,7 +72,7 @@ parse_file(const Filename &filename) { * an expression. Returns NULL if the string is not a valid expression. */ CPPExpression *CPPParser:: -parse_expr(const string &expr) { +parse_expr(const std::string &expr) { YYLTYPE loc = {}; return CPPPreprocessor::parse_expr(expr, this, this, loc); } @@ -82,7 +82,7 @@ parse_expr(const string &expr) { * CPPType. Returns NULL if the string is not a valid type. */ CPPType *CPPParser:: -parse_type(const string &type) { +parse_type(const std::string &type) { CPPTypeParser ep(this, this); ep._verbose = 0; if (ep.parse_type(type, *this)) { diff --git a/dtool/src/cppparser/cppPointerType.cxx b/dtool/src/cppparser/cppPointerType.cxx index 9185455350..bba2a82333 100644 --- a/dtool/src/cppparser/cppPointerType.cxx +++ b/dtool/src/cppparser/cppPointerType.cxx @@ -205,7 +205,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPPointerType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { /* CPPFunctionType *ftype = _pointing_at->as_function_type(); if (ftype != (CPPFunctionType *)NULL) { @@ -235,10 +235,10 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * have special exceptions. */ void CPPPointerType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const { - string star = "*"; +output_instance(std::ostream &out, int indent_level, CPPScope *scope, + bool complete, const std::string &prename, + const std::string &name) const { + std::string star = "*"; CPPFunctionType *ftype = _pointing_at->as_function_type(); if (ftype != nullptr && diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 2a6c3270bc..24784a98c8 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -35,6 +35,9 @@ #include #include +using std::cerr; +using std::string; + // We manage our own visibility counter, in addition to that managed by // cppBison.y. We do this just so we can define manifests with the correct // visibility when they are declared. (Asking the parser for the current @@ -137,7 +140,7 @@ connect_input(const string &input) { assert(_in == nullptr); _input = input; - _in = new istringstream(_input); + _in = new std::istringstream(_input); return !_in->fail(); } @@ -1491,7 +1494,7 @@ handle_define_directive(const string &args, const YYLTYPE &loc) { } } - pair result = + std::pair result = _manifests.insert(Manifests::value_type(manifest->_name, manifest)); if (!result.second) { @@ -1555,7 +1558,7 @@ handle_if_directive(const string &args, const YYLTYPE &loc) { if (ep.parse_expr(expr, *this)) { CPPExpression::Result result = ep._expr->evaluate(); if (result._type == CPPExpression::RT_error) { - ostringstream strm; + std::ostringstream strm; strm << *ep._expr; warning("Ignoring invalid expression " + strm.str(), loc); } else { diff --git a/dtool/src/cppparser/cppReferenceType.cxx b/dtool/src/cppparser/cppReferenceType.cxx index 0b351c830e..42526789a3 100644 --- a/dtool/src/cppparser/cppReferenceType.cxx +++ b/dtool/src/cppparser/cppReferenceType.cxx @@ -210,7 +210,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPReferenceType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { /* _pointing_at->output(out, indent_level, scope, complete); out << " &"; @@ -224,9 +224,9 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { * have special exceptions. */ void CPPReferenceType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const { +output_instance(std::ostream &out, int indent_level, CPPScope *scope, + bool complete, const std::string &prename, + const std::string &name) const { if (_value_category == VC_rvalue) { _pointing_at->output_instance(out, indent_level, scope, complete, diff --git a/dtool/src/cppparser/cppScope.cxx b/dtool/src/cppparser/cppScope.cxx index 878daa8812..af6404e4dd 100644 --- a/dtool/src/cppparser/cppScope.cxx +++ b/dtool/src/cppparser/cppScope.cxx @@ -33,6 +33,11 @@ #include "cppBisonDefs.h" #include "indent.h" +using std::ostream; +using std::ostringstream; +using std::pair; +using std::string; + /** * */ diff --git a/dtool/src/cppparser/cppScope.h b/dtool/src/cppparser/cppScope.h index 44fcc25fef..2631d6097a 100644 --- a/dtool/src/cppparser/cppScope.h +++ b/dtool/src/cppparser/cppScope.h @@ -25,8 +25,6 @@ #include #include -using namespace std; - class CPPType; class CPPDeclaration; class CPPExtensionType; diff --git a/dtool/src/cppparser/cppSimpleType.cxx b/dtool/src/cppparser/cppSimpleType.cxx index 321e76c3cd..1ed364a175 100644 --- a/dtool/src/cppparser/cppSimpleType.cxx +++ b/dtool/src/cppparser/cppSimpleType.cxx @@ -133,7 +133,7 @@ is_parameter_expr() const { /** * */ -string CPPSimpleType:: +std::string CPPSimpleType:: get_preferred_name() const { // Simple types always prefer to use their native types. return get_local_name(); @@ -143,7 +143,7 @@ get_preferred_name() const { * */ void CPPSimpleType:: -output(ostream &out, int, CPPScope *, bool) const { +output(std::ostream &out, int, CPPScope *, bool) const { if (_flags & F_unsigned) { out << "unsigned "; } diff --git a/dtool/src/cppparser/cppStructType.cxx b/dtool/src/cppparser/cppStructType.cxx index 25337642a0..aba4bdbb60 100644 --- a/dtool/src/cppparser/cppStructType.cxx +++ b/dtool/src/cppparser/cppStructType.cxx @@ -28,7 +28,7 @@ * */ void CPPStructType::Base:: -output(ostream &out) const { +output(std::ostream &out) const { if (_is_virtual) { out << "virtual "; } @@ -1240,7 +1240,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPStructType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (!complete && _ident != nullptr) { // If we have a name, use it. if (cppparser_output_class_keyword) { @@ -1351,7 +1351,7 @@ get_virtual_funcs(VFunctions &funcs) const { } else { // Non-destructors we can try to match up by name. - string fname = inst->get_local_name(); + std::string fname = inst->get_local_name(); CPPScope::Functions::const_iterator fi; fi = _scope->_functions.find(fname); diff --git a/dtool/src/cppparser/cppTBDType.cxx b/dtool/src/cppparser/cppTBDType.cxx index 664787cbe6..5c583453ca 100644 --- a/dtool/src/cppparser/cppTBDType.cxx +++ b/dtool/src/cppparser/cppTBDType.cxx @@ -56,7 +56,7 @@ is_tbd() const { * include any scoping operators or template parameters, so it may not be a * compilable reference to the type. */ -string CPPTBDType:: +std::string CPPTBDType:: get_simple_name() const { return _ident->get_simple_name(); } @@ -65,7 +65,7 @@ get_simple_name() const { * Returns the compilable, correct name for this type within the indicated * scope. If the scope is NULL, within the scope the type is declared in. */ -string CPPTBDType:: +std::string CPPTBDType:: get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } @@ -74,7 +74,7 @@ get_local_name(CPPScope *scope) const { * Returns the compilable, correct name for the type, with completely explicit * scoping. */ -string CPPTBDType:: +std::string CPPTBDType:: get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } @@ -128,7 +128,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPTBDType:: -output(ostream &out, int, CPPScope *, bool) const { +output(std::ostream &out, int, CPPScope *, bool) const { out /* << "typename " */ << *_ident; } diff --git a/dtool/src/cppparser/cppTemplateParameterList.cxx b/dtool/src/cppparser/cppTemplateParameterList.cxx index 24ee70e9e4..fd12967711 100644 --- a/dtool/src/cppparser/cppTemplateParameterList.cxx +++ b/dtool/src/cppparser/cppTemplateParameterList.cxx @@ -26,9 +26,9 @@ CPPTemplateParameterList() { /** * */ -string CPPTemplateParameterList:: +std::string CPPTemplateParameterList:: get_string() const { - ostringstream strname; + std::ostringstream strname; strname << "< " << *this << " >"; return strname.str(); } @@ -197,7 +197,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPTemplateParameterList:: -output(ostream &out, CPPScope *scope) const { +output(std::ostream &out, CPPScope *scope) const { if (!_parameters.empty()) { Parameters::const_iterator pi = _parameters.begin(); (*pi)->output(out, 0, scope, false); @@ -217,7 +217,7 @@ output(ostream &out, CPPScope *scope) const { * trailing newline. */ void CPPTemplateParameterList:: -write_formal(ostream &out, CPPScope *scope) const { +write_formal(std::ostream &out, CPPScope *scope) const { out << "template<"; if (!_parameters.empty()) { Parameters::const_iterator pi = _parameters.begin(); diff --git a/dtool/src/cppparser/cppTemplateScope.cxx b/dtool/src/cppparser/cppTemplateScope.cxx index 34482ad64b..a71c176005 100644 --- a/dtool/src/cppparser/cppTemplateScope.cxx +++ b/dtool/src/cppparser/cppTemplateScope.cxx @@ -17,6 +17,8 @@ #include "cppIdentifier.h" #include "cppTypedefType.h" +using std::string; + /** * */ @@ -154,7 +156,7 @@ get_fully_scoped_name() const { * */ void CPPTemplateScope:: -output(ostream &out, CPPScope *scope) const { +output(std::ostream &out, CPPScope *scope) const { CPPScope::output(out, scope); out << "< "; _parameters.output(out, scope); diff --git a/dtool/src/cppparser/cppToken.cxx b/dtool/src/cppparser/cppToken.cxx index 8504150bbd..5649d4a612 100644 --- a/dtool/src/cppparser/cppToken.cxx +++ b/dtool/src/cppparser/cppToken.cxx @@ -23,7 +23,7 @@ */ CPPToken:: CPPToken(int token, int line_number, int col_number, - const CPPFile &file, const string &str, + const CPPFile &file, const std::string &str, const YYSTYPE &lval) : _token(token), _lval(lval) { @@ -39,7 +39,7 @@ CPPToken(int token, int line_number, int col_number, * */ CPPToken:: -CPPToken(int token, const YYLTYPE &loc, const string &str, const YYSTYPE &val) : +CPPToken(int token, const YYLTYPE &loc, const std::string &str, const YYSTYPE &val) : _token(token), _lval(val), _lloc(loc) { _lval.str = str; @@ -90,7 +90,7 @@ is_eof() const { * */ void CPPToken:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_token) { case REAL: out << "REAL " << _lval.u.real; diff --git a/dtool/src/cppparser/cppType.cxx b/dtool/src/cppparser/cppType.cxx index 26581c7205..eea6f47bf6 100644 --- a/dtool/src/cppparser/cppType.cxx +++ b/dtool/src/cppparser/cppType.cxx @@ -20,6 +20,8 @@ #include "cppExtensionType.h" #include +using std::string; + CPPType::Types CPPType::_types; CPPType::PreferredNames CPPType::_preferred_names; CPPType::AltNames CPPType::_alt_names; @@ -306,7 +308,7 @@ get_simple_name() const { */ string CPPType:: get_local_name(CPPScope *scope) const { - ostringstream ostrm; + std::ostringstream ostrm; output(ostrm, 0, scope, false); return ostrm.str(); } @@ -419,7 +421,7 @@ is_convertible_to(const CPPType *other) const { * have special exceptions. */ void CPPType:: -output_instance(ostream &out, const string &name, CPPScope *scope) const { +output_instance(std::ostream &out, const string &name, CPPScope *scope) const { output_instance(out, 0, scope, false, "", name); } @@ -429,7 +431,7 @@ output_instance(ostream &out, const string &name, CPPScope *scope) const { * have special exceptions. */ void CPPType:: -output_instance(ostream &out, int indent_level, CPPScope *scope, +output_instance(std::ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, const string &name) const { output(out, indent_level, scope, complete); @@ -454,7 +456,7 @@ as_type() { */ CPPType *CPPType:: new_type(CPPType *type) { - pair result = _types.insert(type); + std::pair result = _types.insert(type); if (result.second) { // The insertion has taken place; thus, this is the first time this type // has been declared. diff --git a/dtool/src/cppparser/cppTypeDeclaration.cxx b/dtool/src/cppparser/cppTypeDeclaration.cxx index 23c72cd2d0..84b6075172 100644 --- a/dtool/src/cppparser/cppTypeDeclaration.cxx +++ b/dtool/src/cppparser/cppTypeDeclaration.cxx @@ -46,7 +46,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, * */ void CPPTypeDeclaration:: -output(ostream &out, int indent_level, CPPScope *scope, bool) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool) const { _type->output(out, indent_level, scope, true); } diff --git a/dtool/src/cppparser/cppTypeParser.cxx b/dtool/src/cppparser/cppTypeParser.cxx index b88a1a079d..cdaa1d0288 100644 --- a/dtool/src/cppparser/cppTypeParser.cxx +++ b/dtool/src/cppparser/cppTypeParser.cxx @@ -36,9 +36,9 @@ CPPTypeParser:: * */ bool CPPTypeParser:: -parse_type(const string &type) { +parse_type(const std::string &type) { if (!init_type(type)) { - cerr << "Unable to parse type\n"; + std::cerr << "Unable to parse type\n"; return false; } @@ -51,9 +51,9 @@ parse_type(const string &type) { * */ bool CPPTypeParser:: -parse_type(const string &type, const CPPPreprocessor &filepos) { +parse_type(const std::string &type, const CPPPreprocessor &filepos) { if (!init_type(type)) { - cerr << "Unable to parse type\n"; + std::cerr << "Unable to parse type\n"; return false; } @@ -68,7 +68,7 @@ parse_type(const string &type, const CPPPreprocessor &filepos) { * */ void CPPTypeParser:: -output(ostream &out) const { +output(std::ostream &out) const { if (_type == nullptr) { out << "(null type)"; } else { diff --git a/dtool/src/cppparser/cppTypeProxy.cxx b/dtool/src/cppparser/cppTypeProxy.cxx index fe6bfb7c05..4843ac5b34 100644 --- a/dtool/src/cppparser/cppTypeProxy.cxx +++ b/dtool/src/cppparser/cppTypeProxy.cxx @@ -14,6 +14,8 @@ #include "cppTypeProxy.h" #include "cppFile.h" +using std::string; + /** * */ @@ -144,7 +146,7 @@ is_incomplete() const { * have special exceptions. */ void CPPTypeProxy:: -output_instance(ostream &out, int indent_level, CPPScope *scope, +output_instance(std::ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, const string &name) const { if (_actual_type == nullptr) { @@ -159,7 +161,7 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, * */ void CPPTypeProxy:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_actual_type == nullptr) { out << "unknown"; return; diff --git a/dtool/src/cppparser/cppTypedefType.cxx b/dtool/src/cppparser/cppTypedefType.cxx index 32d4c55865..6924fca4a0 100644 --- a/dtool/src/cppparser/cppTypedefType.cxx +++ b/dtool/src/cppparser/cppTypedefType.cxx @@ -17,6 +17,8 @@ #include "cppTemplateScope.h" #include "indent.h" +using std::string; + /** * */ @@ -373,7 +375,7 @@ is_equivalent(const CPPType &other) const { * */ void CPPTypedefType:: -output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { +output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const { string name; if (_ident != nullptr) { name = _ident->get_local_name(scope); diff --git a/dtool/src/cppparser/cppUsing.cxx b/dtool/src/cppparser/cppUsing.cxx index 3611450de6..146f8f3f48 100644 --- a/dtool/src/cppparser/cppUsing.cxx +++ b/dtool/src/cppparser/cppUsing.cxx @@ -28,7 +28,7 @@ CPPUsing(CPPIdentifier *ident, bool full_namespace, const CPPFile &file) : * */ void CPPUsing:: -output(ostream &out, int, CPPScope *, bool) const { +output(std::ostream &out, int, CPPScope *, bool) const { out << "using "; if (_full_namespace) { out << "namespace "; diff --git a/dtool/src/cppparser/cppVisibility.cxx b/dtool/src/cppparser/cppVisibility.cxx index 6cee2a70f3..92273c00a3 100644 --- a/dtool/src/cppparser/cppVisibility.cxx +++ b/dtool/src/cppparser/cppVisibility.cxx @@ -13,8 +13,8 @@ #include "cppVisibility.h" -ostream & -operator << (ostream &out, CPPVisibility vis) { +std::ostream & +operator << (std::ostream &out, CPPVisibility vis) { switch (vis) { case V_published: return out << "__published"; diff --git a/dtool/src/dconfig/test_config.cxx b/dtool/src/dconfig/test_config.cxx index 40f27e7197..2374bd775e 100644 --- a/dtool/src/dconfig/test_config.cxx +++ b/dtool/src/dconfig/test_config.cxx @@ -13,6 +13,9 @@ #include "dconfig.h" +using std::cout; +using std::endl; + #define SNARF Configure(test); diff --git a/dtool/src/dconfig/test_expand.cxx b/dtool/src/dconfig/test_expand.cxx index 281e8b02ba..334bf2593d 100644 --- a/dtool/src/dconfig/test_expand.cxx +++ b/dtool/src/dconfig/test_expand.cxx @@ -14,6 +14,9 @@ #include "expand.h" #include +using std::cout; +using std::endl; + void TestExpandFunction() { std::string line; diff --git a/dtool/src/dconfig/test_pfstream.cxx b/dtool/src/dconfig/test_pfstream.cxx index 29874a97ac..9b211c2381 100644 --- a/dtool/src/dconfig/test_pfstream.cxx +++ b/dtool/src/dconfig/test_pfstream.cxx @@ -14,13 +14,13 @@ #include "pfstream.h" #include -void ReadIt(istream& ifs) { +void ReadIt(std::istream& ifs) { std::string line; while (!ifs.eof()) { std::getline(ifs, line); if (line.length() != 0) - cout << line << endl; + std::cout << line << std::endl; } } diff --git a/dtool/src/dconfig/test_searchpath.cxx b/dtool/src/dconfig/test_searchpath.cxx index edcb8a13cd..4abf1f71bd 100644 --- a/dtool/src/dconfig/test_searchpath.cxx +++ b/dtool/src/dconfig/test_searchpath.cxx @@ -15,6 +15,9 @@ // #include "expand.h" #include +using std::cout; +using std::endl; + void TestSearch() { std::string line, path; diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index 303c9f1223..d009510ad3 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -24,7 +24,7 @@ DeletedBufferChain(size_t buffer_size) { _buffer_size = buffer_size; // We must allocate at least this much space for bookkeeping reasons. - _buffer_size = max(_buffer_size, sizeof(ObjectNode)); + _buffer_size = std::max(_buffer_size, sizeof(ObjectNode)); } /** diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index db12cc8737..b4ce1d597c 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -158,36 +158,6 @@ namespace std { #endif // CPPPARSER -// This was previously `using namespace std`, but we don't want to pull in the -// entire namespace, so we enumerate the things we are using without std:: -// prefix in the Panda headers. It is intended that this list will shrink. -using std::cerr; -using std::cin; -using std::cout; -using std::dec; -using std::endl; -using std::hex; -using std::ios; -using std::iostream; -using std::istream; -using std::istringstream; -using std::max; -using std::min; -using std::move; -using std::ostream; -using std::ostringstream; -using std::pair; -using std::setfill; -using std::setw; -using std::streambuf; -using std::streamoff; -using std::streampos; -using std::streamsize; -using std::string; -using std::stringstream; -using std::swap; -using std::wstring; - // The ReferenceCount class is defined later, within Panda, but we need to // pass around forward references to it here at the very low level. class ReferenceCount; diff --git a/dtool/src/dtoolbase/indent.cxx b/dtool/src/dtoolbase/indent.cxx index bf33828d03..df66a47197 100644 --- a/dtool/src/dtoolbase/indent.cxx +++ b/dtool/src/dtoolbase/indent.cxx @@ -16,8 +16,8 @@ /** * */ -ostream & -indent(ostream &out, int indent_level) { +std::ostream & +indent(std::ostream &out, int indent_level) { for (int i = 0; i < indent_level; i++) { out << ' '; } diff --git a/dtool/src/dtoolbase/memoryHook.cxx b/dtool/src/dtoolbase/memoryHook.cxx index 82ee8dc037..24d5f11a11 100644 --- a/dtool/src/dtoolbase/memoryHook.cxx +++ b/dtool/src/dtoolbase/memoryHook.cxx @@ -37,6 +37,8 @@ #endif // WIN32 +using std::cerr; + // Ensure we made the right decisions about the alignment size. static_assert(MEMORY_HOOK_ALIGNMENT >= sizeof(size_t), "MEMORY_HOOK_ALIGNMENT should at least be sizeof(size_t)"); @@ -423,7 +425,7 @@ heap_realloc_array(void *ptr, size_t size) { size_t orig_delta = (char *)ptr - (char *)alloc; size_t new_delta = (char *)ptr1 - (char *)alloc1; if (orig_delta != new_delta) { - memmove((char *)alloc1 + new_delta, (char *)alloc1 + orig_delta, min(size, orig_size)); + memmove((char *)alloc1 + new_delta, (char *)alloc1 + orig_delta, std::min(size, orig_size)); } root[-2] = size; diff --git a/dtool/src/dtoolbase/neverFreeMemory.cxx b/dtool/src/dtoolbase/neverFreeMemory.cxx index b933007dd5..bd7c1c1481 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.cxx +++ b/dtool/src/dtoolbase/neverFreeMemory.cxx @@ -61,7 +61,7 @@ ns_alloc(size_t size) { // We have to allocate a new page. Allocate at least min_page_size bytes, // and then round that up to the next _page_size bytes. - size_t needed_size = max(size, min_page_size); + size_t needed_size = std::max(size, min_page_size); needed_size = memory_hook->round_up_to_page_size(needed_size); void *start = memory_hook->mmap_alloc(needed_size, false); _total_alloc += needed_size; diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index b5158810df..d61ca64ceb 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -20,8 +20,6 @@ #include "deletedChain.h" #include "typeHandle.h" -using std::allocator; - /** * This is our own Panda specialization on the default STL allocator. Its * main purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index b4c71c81eb..e7e9f96c28 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -27,8 +27,6 @@ #else -using std::deque; - /** * This is our own Panda specialization on the default STL deque. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index 0ddef3c9f1..12d29880f3 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -26,8 +26,6 @@ #else -using std::list; - /** * This is our own Panda specialization on the default STL list. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pmap.h b/dtool/src/dtoolbase/pmap.h index 0f960ac9d5..6ddb38edee 100644 --- a/dtool/src/dtoolbase/pmap.h +++ b/dtool/src/dtoolbase/pmap.h @@ -40,9 +40,6 @@ #else // USE_STL_ALLOCATOR -using std::map; -using std::multimap; - /** * This is our own Panda specialization on the default STL map. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pset.h b/dtool/src/dtoolbase/pset.h index 7b51cf787d..ff54486dfe 100644 --- a/dtool/src/dtoolbase/pset.h +++ b/dtool/src/dtoolbase/pset.h @@ -40,9 +40,6 @@ #else // USE_STL_ALLOCATOR -using std::set; -using std::multiset; - /** * This is our own Panda specialization on the default STL set. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index f88b625bca..4199506d13 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -33,8 +33,6 @@ class pvector : public std::vector { #else -using std::vector; - /** * This is our own Panda specialization on the default STL vector. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/test_strtod.cxx b/dtool/src/dtoolbase/test_strtod.cxx index 169e90bfcf..1071a89273 100644 --- a/dtool/src/dtoolbase/test_strtod.cxx +++ b/dtool/src/dtoolbase/test_strtod.cxx @@ -26,9 +26,9 @@ main(int argc, char *argv[]) { for (int i = 1; i < argc; ++i) { char *endptr = nullptr; double result = pstrtod(argv[i], &endptr); - cerr << "pstrtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; + std::cerr << "pstrtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; result = strtod(argv[i], &endptr); - cerr << "strtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; + std::cerr << "strtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; } return 0; diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index c3cad42e8c..1b96352723 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -55,7 +55,7 @@ inc_memory_usage(MemoryClass memory_class, size_t size) { // cerr << *this << ".inc(" << memory_class << ", " << size << ") -> " << // rnode->_memory_usage[memory_class] << "\n"; if (rnode->_memory_usage[memory_class] < 0) { - cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; + std::cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; abort(); } } @@ -102,7 +102,7 @@ allocate_array(size_t size) { assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[MC_array], (AtomicAdjust::Integer)alloc_size); if (rnode->_memory_usage[MC_array] < 0) { - cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; + std::cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; abort(); } } @@ -175,8 +175,8 @@ get_best_parent_from_Set(const std::set< int > &legal_vals) const { return -1; } -ostream & -operator << (ostream &out, TypeHandle::MemoryClass mem_class) { +std::ostream & +operator << (std::ostream &out, TypeHandle::MemoryClass mem_class) { switch (mem_class) { case TypeHandle::MC_singleton: return out << "singleton"; diff --git a/dtool/src/dtoolbase/typeRegistry.cxx b/dtool/src/dtoolbase/typeRegistry.cxx index d7077727e1..23cdb5ebfb 100644 --- a/dtool/src/dtoolbase/typeRegistry.cxx +++ b/dtool/src/dtoolbase/typeRegistry.cxx @@ -20,6 +20,11 @@ #include +using std::cerr; +using std::ostream; +using std::ostringstream; +using std::string; + MutexImpl *TypeRegistry::_lock = nullptr; TypeRegistry *TypeRegistry::_global_pointer = nullptr; diff --git a/dtool/src/dtoolbase/typeRegistryNode.cxx b/dtool/src/dtoolbase/typeRegistryNode.cxx index 6d8d85ffc5..f809ddcc0b 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.cxx +++ b/dtool/src/dtoolbase/typeRegistryNode.cxx @@ -22,7 +22,7 @@ bool TypeRegistryNode::_paranoid_inheritance = false; * */ TypeRegistryNode:: -TypeRegistryNode(TypeHandle handle, const string &name, TypeHandle &ref) : +TypeRegistryNode(TypeHandle handle, const std::string &name, TypeHandle &ref) : _handle(handle), _name(name), _ref(ref) { clear_subtree(); @@ -54,19 +54,19 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { if (_paranoid_inheritance) { bool paranoid_derives = check_derived_from(child, base); if (derives != paranoid_derives) { - cerr + std::cerr << "Inheritance test for " << child->_name << " from " << base->_name << " failed!\n" << "Result: " << derives << " should have been: " << paranoid_derives << "\n" << "Classes are in the same single inheritance subtree, children of " << child->_inherit._top->_name << "\n" - << hex + << std::hex << child->_name << " has mask " << child->_inherit._mask << " and bits " << child->_inherit._bits << "\n" << base->_name << " has mask " << base->_inherit._mask << " and bits " << base->_inherit._bits << "\n" - << dec; + << std::dec; return paranoid_derives; } } @@ -118,7 +118,7 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { if (_paranoid_inheritance) { bool paranoid_derives = check_derived_from(child, base); if (derives != paranoid_derives) { - cerr + std::cerr << "Inheritance test for " << child->_name << " from " << base->_name << " failed!\n" << "Result: " << derives << " should have been: " @@ -280,7 +280,7 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, // We need at least one bit, even if there is only one child, so we can // differentiate parent from child. - more_bits = max(more_bits, 1); + more_bits = std::max(more_bits, 1); assert(more_bits < (int)(sizeof(SubtreeMaskType) * 8)); diff --git a/dtool/src/dtoolbase/typedObject.cxx b/dtool/src/dtoolbase/typedObject.cxx index a397ef843e..73a2cfc9c2 100644 --- a/dtool/src/dtoolbase/typedObject.cxx +++ b/dtool/src/dtoolbase/typedObject.cxx @@ -31,7 +31,7 @@ get_type() const { // Normally, this function should never be called, because it is a pure // virtual function. If it is called, you probably called get_type() on a // recently-destructed object. - cerr + std::cerr << "TypedObject::get_type() called!\n"; return _type_handle; } diff --git a/dtool/src/dtoolutil/dSearchPath.cxx b/dtool/src/dtoolutil/dSearchPath.cxx index f30f2156fc..4a094f1d98 100644 --- a/dtool/src/dtoolutil/dSearchPath.cxx +++ b/dtool/src/dtoolutil/dSearchPath.cxx @@ -17,6 +17,9 @@ #include #include +using std::ostream; +using std::string; + /** * */ diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index a2baf28343..4152a8c356 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -18,6 +18,9 @@ #include #include // for perror +using std::cerr; +using std::string; + #ifdef __APPLE__ #include // for realpath #endif // __APPLE__ @@ -554,7 +557,7 @@ read_args() { wchar_t buffer[buffer_size]; DWORD size = GetModuleFileNameW(dllhandle, buffer, buffer_size); if (size != 0) { - Filename tmp = Filename::from_os_specific_w(wstring(buffer, size)); + Filename tmp = Filename::from_os_specific_w(std::wstring(buffer, size)); tmp.make_true_case(); _dtool_name = tmp; } @@ -654,7 +657,7 @@ read_args() { wchar_t buffer[buffer_size]; DWORD size = GetModuleFileNameW(nullptr, buffer, buffer_size); if (size != 0) { - Filename tmp = Filename::from_os_specific_w(wstring(buffer, size)); + Filename tmp = Filename::from_os_specific_w(std::wstring(buffer, size)); tmp.make_true_case(); _binary_name = tmp; } @@ -727,7 +730,7 @@ read_args() { encoder.set_encoding(Filename::get_filesystem_encoding()); for (int i = 0; i < argc; ++i) { - wstring wtext(wargv[i]); + std::wstring wtext(wargv[i]); encoder.set_wtext(wtext); if (i == 0) { diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index 61816e7a44..da5657dd9d 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -53,6 +53,11 @@ #include #endif +using std::cerr; +using std::ios; +using std::string; +using std::wstring; + TextEncoder::Encoding Filename::_filesystem_encoding = TextEncoder::E_utf8; TVOLATILE AtomicAdjust::Pointer Filename::_home_directory; @@ -832,9 +837,9 @@ get_filename_index(int index) const { Filename file(*this); if (_hash_end != _hash_start) { - ostringstream strm; + std::ostringstream strm; strm << _filename.substr(0, _hash_start) - << setw((int)(_hash_end - _hash_start)) << setfill('0') << index + << std::setw((int)(_hash_end - _hash_start)) << std::setfill('0') << index << _filename.substr(_hash_end); file.set_fullpath(strm.str()); } @@ -1542,7 +1547,7 @@ get_access_timestamp() const { /** * Returns the size of the file in bytes, or 0 if there is an error. */ -streamsize Filename:: +std::streamsize Filename:: get_file_size() const { #ifdef WIN32_VC wstring os_specific = get_filename_index(0).to_os_specific_w(); diff --git a/dtool/src/dtoolutil/filename_assist.mm b/dtool/src/dtoolutil/filename_assist.mm index e27c4d1ece..3192fc58e2 100644 --- a/dtool/src/dtoolutil/filename_assist.mm +++ b/dtool/src/dtoolutil/filename_assist.mm @@ -22,6 +22,8 @@ #include #endif +using std::string; + /** * Copy the Objective-C string to a C++ string. */ diff --git a/dtool/src/dtoolutil/filename_ext.cxx b/dtool/src/dtoolutil/filename_ext.cxx index 196492d23f..e60bf83a90 100644 --- a/dtool/src/dtoolutil/filename_ext.cxx +++ b/dtool/src/dtoolutil/filename_ext.cxx @@ -13,6 +13,9 @@ #include "filename_ext.h" +using std::string; +using std::wstring; + #ifdef HAVE_PYTHON #ifndef CPPPARSER diff --git a/dtool/src/dtoolutil/globPattern.cxx b/dtool/src/dtoolutil/globPattern.cxx index 57a6afdb57..982fe3bb1d 100644 --- a/dtool/src/dtoolutil/globPattern.cxx +++ b/dtool/src/dtoolutil/globPattern.cxx @@ -14,6 +14,8 @@ #include "globPattern.h" #include +using std::string; + /** * Returns true if the pattern includes any special globbing characters, or * false if it is just a literal string. diff --git a/dtool/src/dtoolutil/lineStreamBuf.cxx b/dtool/src/dtoolutil/lineStreamBuf.cxx index 4e9f990540..8ac3ed74f2 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.cxx +++ b/dtool/src/dtoolutil/lineStreamBuf.cxx @@ -13,6 +13,8 @@ #include "lineStreamBuf.h" +using std::string; + /** * */ @@ -65,7 +67,7 @@ get_line() { */ int LineStreamBuf:: sync() { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); write_chars(pbase(), n); pbump(-(int)n); // Reset pptr(). return 0; // EOF to indicate write full. @@ -77,7 +79,7 @@ sync() { */ int LineStreamBuf:: overflow(int ch) { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0 && sync() != 0) { return EOF; diff --git a/dtool/src/dtoolutil/load_dso.cxx b/dtool/src/dtoolutil/load_dso.cxx index a54763afb1..79d821b5fa 100644 --- a/dtool/src/dtoolutil/load_dso.cxx +++ b/dtool/src/dtoolutil/load_dso.cxx @@ -14,6 +14,8 @@ #include "load_dso.h" #include "executionEnvironment.h" +using std::string; + static Filename resolve_dso(const DSearchPath &path, const Filename &filename) { if (filename.is_local()) { if ((path.get_num_directories()==1)&&(path.get_directory(0)=="")) { @@ -47,7 +49,7 @@ load_dso(const DSearchPath &path, const Filename &filename) { if (!abspath.is_regular_file()) { return nullptr; } - wstring os_specific_w = abspath.to_os_specific_w(); + std::wstring os_specific_w = abspath.to_os_specific_w(); // Try using LoadLibraryEx, if possible. typedef HMODULE (WINAPI *tLoadLibraryEx)(LPCWSTR, HANDLE, DWORD); @@ -104,7 +106,7 @@ load_dso_error() { } // Some unknown error code. - ostringstream errmsg; + std::ostringstream errmsg; errmsg << "Unknown error " << last_error; return errmsg.str(); } diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx index 2e2c0ec035..676f17e0e6 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx @@ -25,6 +25,16 @@ #include #endif // _WIN32 +using std::cerr; +using std::dec; +using std::hex; +using std::ios; +using std::istream; +using std::ostream; +using std::streamoff; +using std::streampos; +using std::string; + PandaFileStreamBuf::NewlineMode PandaFileStreamBuf::_newline_mode = NM_native; static const size_t file_buffer_size = 4096; @@ -130,7 +140,7 @@ open(const char *filename, ios::openmode mode) { TextEncoder encoder; encoder.set_encoding(Filename::get_filesystem_encoding()); encoder.set_text(_filename); - wstring wfilename = encoder.get_wtext(); + std::wstring wfilename = encoder.get_wtext(); _handle = CreateFileW(wfilename.c_str(), access, share_mode, nullptr, creation_disposition, flags, nullptr); if (_handle != INVALID_HANDLE_VALUE) { diff --git a/dtool/src/dtoolutil/pandaSystem.cxx b/dtool/src/dtoolutil/pandaSystem.cxx index 5e7cc4b913..d09fecb663 100644 --- a/dtool/src/dtoolutil/pandaSystem.cxx +++ b/dtool/src/dtoolutil/pandaSystem.cxx @@ -15,6 +15,8 @@ #include "pandaVersion.h" #include "dtool_platform.h" +using std::string; + PandaSystem *PandaSystem::_global_ptr = nullptr; TypeHandle PandaSystem::_type_handle; @@ -220,7 +222,7 @@ string PandaSystem:: get_compiler() { #if defined(_MSC_VER) // MSVC defines this macro. It's an integer; we need to format it. - ostringstream strm; + std::ostringstream strm; strm << "MSC v." << _MSC_VER; // We also get this suite of macros that tells us what the build platform @@ -368,7 +370,7 @@ add_system(const string &system) { void PandaSystem:: set_system_tag(const string &system, const string &tag, const string &value) { - pair result; + std::pair result; result = _systems.insert(Systems::value_type(system, SystemTags(get_class_type()))); if (result.second) { _system_names_dirty = true; @@ -399,7 +401,7 @@ heap_trim(size_t pad) { * */ void PandaSystem:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Panda version " << get_version_string(); } @@ -407,7 +409,7 @@ output(ostream &out) const { * */ void PandaSystem:: -write(ostream &out) const { +write(std::ostream &out) const { out << *this << "\n" << "compiled on " << get_build_date() << " by " << get_distributor() << "\n" diff --git a/dtool/src/dtoolutil/panda_getopt_impl.cxx b/dtool/src/dtoolutil/panda_getopt_impl.cxx index 9a216bbda0..030641a357 100644 --- a/dtool/src/dtoolutil/panda_getopt_impl.cxx +++ b/dtool/src/dtoolutil/panda_getopt_impl.cxx @@ -22,6 +22,7 @@ // If the system does lack one or the other of these functions, then we'll go // ahead and provide it instead. +using std::string; char *optarg = nullptr; int optind = 0; @@ -226,7 +227,7 @@ process(int opterr, int *longindex, char *&optarg, int &optind, int &optopt) { if (param._opt_index == 0 && opterr) { // This was an invalid character. optopt = param._short_option; - cerr << "Illegal option: -" << param._short_option << "\n"; + std::cerr << "Illegal option: -" << param._short_option << "\n"; return '?'; } diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index 591d2847e0..a5585ee3cd 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -14,6 +14,10 @@ #include "pfstreamBuf.h" #include +using std::cerr; +using std::endl; +using std::string; + PipeStreamBuf::PipeStreamBuf(PipeStreamBuf::Direction dir) : _dir(dir) { @@ -56,7 +60,7 @@ void PipeStreamBuf::command(const string cmd) { int PipeStreamBuf::overflow(int c) { assert(is_open()); assert(_dir == Output); - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0) { write_chars(pbase(), n, false); pbump(-n); // reset pptr() @@ -72,11 +76,11 @@ int PipeStreamBuf::overflow(int c) { int PipeStreamBuf::sync(void) { assert(is_open()); if (_dir == Output) { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); write_chars(pbase(), n, false); pbump(-n); } else { - streamsize n = egptr() - gptr(); + std::streamsize n = egptr() - gptr(); if (n != 0) { gbump(n); // flush all our stored input away #ifndef NDEBUG diff --git a/dtool/src/dtoolutil/stringDecoder.cxx b/dtool/src/dtoolutil/stringDecoder.cxx index 847d8559bd..e77e0c5e13 100644 --- a/dtool/src/dtoolutil/stringDecoder.cxx +++ b/dtool/src/dtoolutil/stringDecoder.cxx @@ -14,7 +14,7 @@ #include "stringDecoder.h" #include "config_dtoolutil.h" -ostream *StringDecoder::_notify_ptr = &cerr; +std::ostream *StringDecoder::_notify_ptr = &std::cerr; /** * @@ -41,7 +41,7 @@ get_next_character() { * notify. */ void StringDecoder:: -set_notify_ptr(ostream *notify_ptr) { +set_notify_ptr(std::ostream *notify_ptr) { _notify_ptr = notify_ptr; } @@ -49,7 +49,7 @@ set_notify_ptr(ostream *notify_ptr) { * Returns the ostream that is used to write error messages to. See * set_notify_ptr(). */ -ostream *StringDecoder:: +std::ostream *StringDecoder:: get_notify_ptr() { return _notify_ptr; } @@ -131,7 +131,7 @@ get_next_character() { // utf-8 bytes--we have an error. if (_notify_ptr != nullptr) { (*_notify_ptr) - << "Non utf-8 byte in string: 0x" << hex << result << dec + << "Non utf-8 byte in string: 0x" << std::hex << result << std::dec << ", string is '" << _input << "'\n"; } return -1; diff --git a/dtool/src/dtoolutil/string_utils.cxx b/dtool/src/dtoolutil/string_utils.cxx index 600b07e7ed..50d5d53802 100644 --- a/dtool/src/dtoolutil/string_utils.cxx +++ b/dtool/src/dtoolutil/string_utils.cxx @@ -17,6 +17,9 @@ #include +using std::string; +using std::wstring; + // Case-insensitive string comparison, from Stroustrup's C++ third edition. // Works like strcmp(). int diff --git a/dtool/src/dtoolutil/test_pfstream.cxx b/dtool/src/dtoolutil/test_pfstream.cxx index b088079723..93bebd6236 100644 --- a/dtool/src/dtoolutil/test_pfstream.cxx +++ b/dtool/src/dtoolutil/test_pfstream.cxx @@ -17,26 +17,26 @@ int main(int argc, char *argv[]) { if (argc < 2) { - cout << "test_pfstream command-line\n"; + std::cout << "test_pfstream command-line\n"; return (1); } // Build one command out of the arguments. - string cmd; + std::string cmd; cmd = argv[1]; for (int i = 2; i < argc; i++) { cmd += " "; cmd += argv[i]; } - cout << "Executing command:\n" << cmd << "\n"; + std::cout << "Executing command:\n" << cmd << "\n"; IPipeStream in(cmd); char c; c = in.get(); while (in && !in.fail() && !in.eof()) { - cout.put(toupper(c)); + std::cout.put(toupper(c)); c = in.get(); } diff --git a/dtool/src/dtoolutil/test_touch.cxx b/dtool/src/dtoolutil/test_touch.cxx index 722a94a85e..94a7d2782c 100644 --- a/dtool/src/dtoolutil/test_touch.cxx +++ b/dtool/src/dtoolutil/test_touch.cxx @@ -17,7 +17,7 @@ int main(int argc, char *argv[]) { if (argc < 2) { - cout << "test_touch filename [filename ... ]\n"; + std::cout << "test_touch filename [filename ... ]\n"; return (1); } diff --git a/dtool/src/dtoolutil/textEncoder.cxx b/dtool/src/dtoolutil/textEncoder.cxx index 90ce30d395..1e1cd4bc61 100644 --- a/dtool/src/dtoolutil/textEncoder.cxx +++ b/dtool/src/dtoolutil/textEncoder.cxx @@ -16,6 +16,11 @@ #include "unicodeLatinMap.h" #include "config_dtoolutil.h" +using std::istream; +using std::ostream; +using std::string; +using std::wstring; + TextEncoder::Encoding TextEncoder::_default_encoding = TextEncoder::E_iso8859; /** diff --git a/dtool/src/dtoolutil/win32ArgParser.cxx b/dtool/src/dtoolutil/win32ArgParser.cxx index 231b4af12b..4faf6bff95 100644 --- a/dtool/src/dtoolutil/win32ArgParser.cxx +++ b/dtool/src/dtoolutil/win32ArgParser.cxx @@ -24,6 +24,8 @@ #include #include +using std::string; + /** * */ @@ -97,7 +99,7 @@ set_command_line(const string &command_line) { * starts parsing this into argc, argv. */ void Win32ArgParser:: -set_command_line(const wstring &command_line) { +set_command_line(const std::wstring &command_line) { TextEncoder encoder; encoder.set_encoding(Filename::get_filesystem_encoding()); encoder.set_wtext(command_line); @@ -146,7 +148,7 @@ do_glob() { // means to do it. string envvar = ExecutionEnvironment::get_environment_variable("PANDA_GLOB"); if (!envvar.empty()) { - istringstream strm(envvar); + std::istringstream strm(envvar); int value; strm >> value; if (!strm.fail()) { diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index 745d084b72..e7a2f828d9 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -32,6 +32,10 @@ #include "interrogateType.h" #include "pnotify.h" +using std::ostream; +using std::ostringstream; +using std::string; + /** * */ @@ -439,7 +443,10 @@ get_call_str(const string &container, const vector_string &pexprs) const { call << ")." << _cppfunc->get_local_name(); } else { - call << _cppfunc->get_local_name(&parser); + if (_cpptype != nullptr) { + call << _cpptype->get_local_name(&parser); + } + call << "::" << _cppfunc->get_local_name(); } } call << "("; diff --git a/dtool/src/interrogate/functionWriter.cxx b/dtool/src/interrogate/functionWriter.cxx index 6a5c3e4e34..58937d3f3d 100644 --- a/dtool/src/interrogate/functionWriter.cxx +++ b/dtool/src/interrogate/functionWriter.cxx @@ -30,7 +30,7 @@ FunctionWriter:: /** * */ -const string &FunctionWriter:: +const std::string &FunctionWriter:: get_name() const { return _name; } @@ -42,7 +42,7 @@ int FunctionWriter:: compare_to(const FunctionWriter &other) const { // Lexicographical string comparison. - string::const_iterator n1, n2; + std::string::const_iterator n1, n2; n1 = _name.begin(); n2 = other._name.begin(); while (n1 != _name.end() && n2 != other._name.end()) { @@ -65,12 +65,12 @@ compare_to(const FunctionWriter &other) const { * Outputs the prototype for the function. */ void FunctionWriter:: -write_prototype(ostream &) { +write_prototype(std::ostream &) { } /** * Outputs the code for the function. */ void FunctionWriter:: -write_code(ostream &) { +write_code(std::ostream &) { } diff --git a/dtool/src/interrogate/functionWriterPtrFromPython.cxx b/dtool/src/interrogate/functionWriterPtrFromPython.cxx index c27ef1efe5..016d79cff7 100644 --- a/dtool/src/interrogate/functionWriterPtrFromPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrFromPython.cxx @@ -43,7 +43,7 @@ FunctionWriterPtrFromPython:: * Outputs the prototype for the function. */ void FunctionWriterPtrFromPython:: -write_prototype(ostream &out) { +write_prototype(std::ostream &out) { CPPType *ppointer = new CPPPointerType(_pointer_type); out << "static int " << _name << "(PyObject *obj, "; @@ -57,7 +57,7 @@ write_prototype(ostream &out) { * Outputs the code for the function. */ void FunctionWriterPtrFromPython:: -write_code(ostream &out) { +write_code(std::ostream &out) { CPPType *ppointer = new CPPPointerType(_pointer_type); out << "static int\n" diff --git a/dtool/src/interrogate/functionWriterPtrToPython.cxx b/dtool/src/interrogate/functionWriterPtrToPython.cxx index aac2984dbc..e2486dae7c 100644 --- a/dtool/src/interrogate/functionWriterPtrToPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrToPython.cxx @@ -44,7 +44,7 @@ FunctionWriterPtrToPython:: * Outputs the prototype for the function. */ void FunctionWriterPtrToPython:: -write_prototype(ostream &out) { +write_prototype(std::ostream &out) { out << "static PyObject *" << _name << "("; _pointer_type->output_instance(out, "addr", &parser); out << ", int caller_manages);\n"; @@ -54,8 +54,8 @@ write_prototype(ostream &out) { * Outputs the code for the function. */ void FunctionWriterPtrToPython:: -write_code(ostream &out) { - string classobj_func = InterfaceMakerPythonObj::get_builder_name(_type); +write_code(std::ostream &out) { + std::string classobj_func = InterfaceMakerPythonObj::get_builder_name(_type); out << "static PyObject *\n" << _name << "("; _pointer_type->output_instance(out, "addr", &parser); diff --git a/dtool/src/interrogate/functionWriters.cxx b/dtool/src/interrogate/functionWriters.cxx index 93ee5945fc..2d1d167b2d 100644 --- a/dtool/src/interrogate/functionWriters.cxx +++ b/dtool/src/interrogate/functionWriters.cxx @@ -41,7 +41,7 @@ FunctionWriters:: */ FunctionWriter *FunctionWriters:: add_writer(FunctionWriter *writer) { - pair result = _writers.insert(writer); + std::pair result = _writers.insert(writer); if (!result.second) { // Already there; delete the pointer. delete writer; @@ -55,7 +55,7 @@ add_writer(FunctionWriter *writer) { * Generates prototypes for all of the functions. */ void FunctionWriters:: -write_prototypes(ostream &out) { +write_prototypes(std::ostream &out) { Writers::iterator wi; for (wi = _writers.begin(); wi != _writers.end(); ++wi) { FunctionWriter *writer = (*wi); @@ -67,7 +67,7 @@ write_prototypes(ostream &out) { * Generates all of the functions. */ void FunctionWriters:: -write_code(ostream &out) { +write_code(std::ostream &out) { Writers::iterator wi; for (wi = _writers.begin(); wi != _writers.end(); ++wi) { FunctionWriter *writer = (*wi); diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index 69ab181286..0d4d56dfc1 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -39,6 +39,10 @@ #include "cppStructType.h" #include "pnotify.h" +using std::ostream; +using std::ostringstream; +using std::string; + InterrogateType dummy_type; /** diff --git a/dtool/src/interrogate/interfaceMakerC.cxx b/dtool/src/interrogate/interfaceMakerC.cxx index 966e9c058d..64b36fc366 100644 --- a/dtool/src/interrogate/interfaceMakerC.cxx +++ b/dtool/src/interrogate/interfaceMakerC.cxx @@ -24,6 +24,8 @@ #include "interrogateFunction.h" #include "cppFunctionType.h" +using std::ostream; + /** * */ @@ -115,7 +117,7 @@ synthesize_this_parameter() { /** * Returns the prefix string used to generate wrapper function names. */ -string InterfaceMakerC:: +std::string InterfaceMakerC:: get_wrapper_prefix() { return "_inC"; } @@ -124,7 +126,7 @@ get_wrapper_prefix() { * Returns the prefix string used to generate unique symbolic names, which are * not necessarily C-callable function names. */ -string InterfaceMakerC:: +std::string InterfaceMakerC:: get_unique_prefix() { return "c"; } @@ -206,7 +208,7 @@ write_function_instance(ostream &out, InterfaceMaker::Function *func, write_spam_message(out, remap); } - string return_expr = + std::string return_expr = remap->call_function(out, 2, true, "param0"); return_expr = manage_return_value(out, 2, remap, return_expr); if (!return_expr.empty()) { diff --git a/dtool/src/interrogate/interfaceMakerPython.cxx b/dtool/src/interrogate/interfaceMakerPython.cxx index 31f59c0785..cfd82edf19 100644 --- a/dtool/src/interrogate/interfaceMakerPython.cxx +++ b/dtool/src/interrogate/interfaceMakerPython.cxx @@ -28,7 +28,7 @@ InterfaceMakerPython(InterrogateModuleDef *def) : * particular interface to the indicated output stream. */ void InterfaceMakerPython:: -write_includes(ostream &out) { +write_includes(std::ostream &out) { InterfaceMaker::write_includes(out); out << "#undef _POSIX_C_SOURCE\n" << "#undef _XOPEN_SOURCE\n" @@ -45,7 +45,7 @@ write_includes(ostream &out) { * was executing, and report this failure back to Python. */ void InterfaceMakerPython:: -test_assert(ostream &out, int indent_level) const { +test_assert(std::ostream &out, int indent_level) const { if (watch_asserts) { out << "#ifndef NDEBUG\n"; indent(out, indent_level) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index c040f0dc6c..6a47257eda 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -39,7 +39,17 @@ #include #include -extern InterrogateType dummy_type; +using std::dec; +using std::hex; +using std::max; +using std::min; +using std::oct; +using std::ostream; +using std::ostringstream; +using std::set; +using std::string; + +extern InterrogateType dummy_type; extern std::string EXPORT_IMPORT_PREFIX; #define CLASS_PREFIX "Dtool_" @@ -702,7 +712,7 @@ get_valid_child_classes(std::map &answer, CPPStructTyp void InterfaceMakerPythonNative:: write_python_instance(ostream &out, int indent_level, const string &return_expr, bool owns_memory, const InterrogateType &itype, bool is_const) { - out << boolalpha; + out << std::boolalpha; if (!isExportThisRun(itype._cpptype)) { _external_imports.insert(TypeManager::resolve_type(itype._cpptype)); @@ -1049,10 +1059,10 @@ write_class_details(ostream &out, Object *obj) { write_make_seq(out, obj, ClassName, cClassName, *msi); } else { if (!is_function_legal((*msi)->_length_getter)) { - cerr << "illegal length function for MAKE_SEQ: " << (*msi)->_length_getter->_name << "\n"; + std::cerr << "illegal length function for MAKE_SEQ: " << (*msi)->_length_getter->_name << "\n"; } if (!is_function_legal((*msi)->_element_getter)) { - cerr << "illegal element function for MAKE_SEQ: " << (*msi)->_element_getter->_name << "\n"; + std::cerr << "illegal element function for MAKE_SEQ: " << (*msi)->_element_getter->_name << "\n"; } } } @@ -2447,7 +2457,7 @@ write_module_class(ostream &out, Object *obj) { // Nothing special about the wrapper function: just write it normally. string fname = "static PyObject *" + def._wrapper_name + "(PyObject *self, PyObject *args, PyObject *kwds)\n"; - vector remaps; + std::vector remaps; remaps.insert(remaps.end(), def._remaps.begin(), def._remaps.end()); string expected_params; write_function_for_name(out, obj, remaps, fname, expected_params, true, AT_keyword_args, RF_pyobject | RF_err_null); @@ -2473,7 +2483,7 @@ write_module_class(ostream &out, Object *obj) { out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return nullptr;\n"; out << " }\n\n"; - out << " ostringstream os;\n"; + out << " std::ostringstream os;\n"; if (need_repr == 3) { out << " invoke_extension(local_this).python_repr(os, \"" << classNameFromCppName(ClassName, false) << "\");\n"; @@ -2503,7 +2513,7 @@ write_module_class(ostream &out, Object *obj) { out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return nullptr;\n"; out << " }\n\n"; - out << " ostringstream os;\n"; + out << " std::ostringstream os;\n"; if (need_str == 2) { out << " local_this->write(os, 0);\n"; } else { @@ -3050,7 +3060,7 @@ write_module_class(ostream &out, Object *obj) { out << " // Dependent objects\n"; if (bases.size() > 0) { string baseargs; - for (vector::iterator bi = bases.begin(); bi != bases.end(); ++bi) { + for (std::vector::iterator bi = bases.begin(); bi != bases.end(); ++bi) { string safe_name = make_safe_name((*bi)->get_local_name(&parser)); if (isExportThisRun(*bi)) { @@ -5571,7 +5581,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, << ", *Dtool_Ptr_" << make_safe_name(class_name) << ");\n"; } else { - extra_convert << boolalpha + extra_convert << std::boolalpha << " = (" << class_name << " *)" << "DTOOL_Call_GetPointerThisClass(" << param_name << ", Dtool_Ptr_" << make_safe_name(class_name) @@ -7873,7 +7883,7 @@ output_quoted(ostream &out, int indent_level, const std::string &str, default: if (!isprint(*si)) { - out << "\\" << oct << setw(3) << setfill('0') << (unsigned int)(*si) + out << "\\" << oct << std::setw(3) << std::setfill('0') << (unsigned int)(*si) << dec; } else { out << *si; diff --git a/dtool/src/interrogate/interfaceMakerPythonObj.cxx b/dtool/src/interrogate/interfaceMakerPythonObj.cxx index 3f11acb855..fa0e35eaea 100644 --- a/dtool/src/interrogate/interfaceMakerPythonObj.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonObj.cxx @@ -25,6 +25,9 @@ #include "interrogateFunction.h" #include "cppFunctionType.h" +using std::ostream; +using std::string; + /** * */ diff --git a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx index 8ee9552250..c0f1be390a 100644 --- a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx @@ -23,6 +23,9 @@ #include "interrogateFunction.h" #include "cppFunctionType.h" +using std::ostream; +using std::string; + /** * */ diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index 39b69e2c1d..d11bd22ff6 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -22,6 +22,9 @@ #include "pystub.h" #include +using std::cerr; +using std::string; + CPPParser parser; Filename output_code_filename; diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index f320a66943..f579f1586d 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -50,6 +50,13 @@ #include #include +using std::cerr; +using std::istream; +using std::map; +using std::ostream; +using std::ostringstream; +using std::string; + InterrogateBuilder builder; std::string EXPORT_IMPORT_PREFIX; @@ -1699,7 +1706,7 @@ get_function(CPPInstance *function, string description, ifunction._flags |= flags; // Also, make sure this particular signature is defined. - pair result = + std::pair result = ifunction._instances->insert(InterrogateFunction::Instances::value_type(function_signature, function)); InterrogateFunction::Instances::iterator ii = result.first; diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 0fe4534890..5c5cc9d9ab 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -27,6 +27,9 @@ #include +using std::cerr; +using std::string; + Filename output_code_filename; string module_name; string library_name; @@ -149,7 +152,7 @@ static bool print_dependent_types(const string &lib1, const string &lib2) { return false; } -int write_python_table_native(ostream &out) { +int write_python_table_native(std::ostream &out) { out << "\n#include \"dtoolbase.h\"\n" << "#include \"interrogate_request.h\"\n\n" << "#include \"py_panda.h\"\n\n"; @@ -192,7 +195,7 @@ int write_python_table_native(ostream &out) { interrogate_type_has_library_name(basetype)) { string baselib = interrogate_type_library_name(basetype); if (baselib != library_name) { - deps.insert(move(baselib)); + deps.insert(std::move(baselib)); } } } @@ -203,7 +206,7 @@ int write_python_table_native(ostream &out) { interrogate_type_has_library_name(wrapped)) { string wrappedlib = interrogate_type_library_name(wrapped); if (wrappedlib != library_name) { - deps.insert(move(wrappedlib)); + deps.insert(std::move(wrappedlib)); } } } @@ -420,7 +423,7 @@ int write_python_table_native(ostream &out) { return count; } -int write_python_table(ostream &out) { +int write_python_table(std::ostream &out) { out << "\n#include \"dtoolbase.h\"\n" << "#include \"interrogate_request.h\"\n\n" << "#undef _POSIX_C_SOURCE\n" diff --git a/dtool/src/interrogate/parameterRemap.cxx b/dtool/src/interrogate/parameterRemap.cxx index 19c6bb4251..4794c7c16d 100644 --- a/dtool/src/interrogate/parameterRemap.cxx +++ b/dtool/src/interrogate/parameterRemap.cxx @@ -13,6 +13,8 @@ #include "parameterRemap.h" +using std::string; + /** * @@ -26,7 +28,7 @@ ParameterRemap:: * original type to the new type, for passing into the actual C++ function. */ void ParameterRemap:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << variable_name; } @@ -37,7 +39,7 @@ pass_parameter(ostream &out, const string &variable_name) { * return the modified expression. */ string ParameterRemap:: -prepare_return_expr(ostream &, int, const string &expression) { +prepare_return_expr(std::ostream &, int, const string &expression) { return expression; } diff --git a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx index d2ea916fff..07dad4694a 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx @@ -14,6 +14,8 @@ #include "parameterRemapBasicStringPtrToString.h" #include "interrogate.h" +using std::string; + /** * */ @@ -34,7 +36,7 @@ ParameterRemapBasicStringPtrToString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapBasicStringPtrToString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << "&std::string(" << variable_name << ")"; } @@ -67,7 +69,7 @@ ParameterRemapBasicWStringPtrToWString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapBasicWStringPtrToWString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << "&std::wstring(" << variable_name << ")"; } diff --git a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx index 0e5bac31ff..90cd3d7e45 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx @@ -14,6 +14,8 @@ #include "parameterRemapBasicStringRefToString.h" #include "interrogate.h" +using std::string; + /** * */ @@ -34,7 +36,7 @@ ParameterRemapBasicStringRefToString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapBasicStringRefToString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << "std::string(" << variable_name << ")"; } @@ -67,7 +69,7 @@ ParameterRemapBasicWStringRefToWString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapBasicWStringRefToWString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << "std::wstring(" << variable_name << ")"; } diff --git a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx index d2ed1f0406..21faabfaac 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx @@ -15,6 +15,9 @@ #include "interfaceMaker.h" #include "interrogate.h" +using std::ostream; +using std::string; + /** * */ diff --git a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx index 05f0eda533..f5e7c35b39 100644 --- a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx @@ -36,7 +36,7 @@ ParameterRemapConcreteToPointer(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapConcreteToPointer:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { if (variable_name.size() > 1 && variable_name[0] == '&') { // Prevent generating something like *¶m Also, if this is really some // local type, we can presumably just move it? @@ -50,8 +50,8 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapConcreteToPointer:: -get_return_expr(const string &expression) { +std::string ParameterRemapConcreteToPointer:: +get_return_expr(const std::string &expression) { return "new " + _orig_type->get_local_name(&parser) + "(" + expression + ")"; diff --git a/dtool/src/interrogate/parameterRemapConstToNonConst.cxx b/dtool/src/interrogate/parameterRemapConstToNonConst.cxx index c031350e70..2fb23e90bc 100644 --- a/dtool/src/interrogate/parameterRemapConstToNonConst.cxx +++ b/dtool/src/interrogate/parameterRemapConstToNonConst.cxx @@ -31,7 +31,7 @@ ParameterRemapConstToNonConst(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapConstToNonConst:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { out << variable_name; } @@ -39,7 +39,7 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapConstToNonConst:: -get_return_expr(const string &expression) { +std::string ParameterRemapConstToNonConst:: +get_return_expr(const std::string &expression) { return expression; } diff --git a/dtool/src/interrogate/parameterRemapEnumToInt.cxx b/dtool/src/interrogate/parameterRemapEnumToInt.cxx index 40283dd364..59fb6019fc 100644 --- a/dtool/src/interrogate/parameterRemapEnumToInt.cxx +++ b/dtool/src/interrogate/parameterRemapEnumToInt.cxx @@ -35,7 +35,7 @@ ParameterRemapEnumToInt(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapEnumToInt:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { out << "(" << _enum_type->get_local_name(&parser) << ")" << variable_name; } @@ -43,8 +43,8 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapEnumToInt:: -get_return_expr(const string &expression) { +std::string ParameterRemapEnumToInt:: +get_return_expr(const std::string &expression) { return "(int)(" + expression + ")"; } diff --git a/dtool/src/interrogate/parameterRemapHandleToInt.cxx b/dtool/src/interrogate/parameterRemapHandleToInt.cxx index b22052c7c3..4594ca45c8 100644 --- a/dtool/src/interrogate/parameterRemapHandleToInt.cxx +++ b/dtool/src/interrogate/parameterRemapHandleToInt.cxx @@ -36,7 +36,7 @@ ParameterRemapHandleToInt(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapHandleToInt:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { CPPType *unwrapped = TypeManager::unwrap_const(_orig_type); if (unwrapped->get_local_name(&parser) == "TypeHandle") { @@ -50,7 +50,7 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapHandleToInt:: -get_return_expr(const string &expression) { +std::string ParameterRemapHandleToInt:: +get_return_expr(const std::string &expression) { return "(" + expression + ").get_index()"; } diff --git a/dtool/src/interrogate/parameterRemapPTToPointer.cxx b/dtool/src/interrogate/parameterRemapPTToPointer.cxx index d4aefb71d2..243b907260 100644 --- a/dtool/src/interrogate/parameterRemapPTToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapPTToPointer.cxx @@ -21,6 +21,8 @@ #include "cppDeclaration.h" #include "pnotify.h" +using std::string; + /** * */ @@ -64,7 +66,7 @@ ParameterRemapPTToPointer(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapPTToPointer:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << variable_name; } diff --git a/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx b/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx index c4a4e77451..bdb613cef6 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx +++ b/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx @@ -35,7 +35,7 @@ ParameterRemapReferenceToConcrete(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapReferenceToConcrete:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { out << variable_name; } @@ -43,7 +43,7 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapReferenceToConcrete:: -get_return_expr(const string &expression) { +std::string ParameterRemapReferenceToConcrete:: +get_return_expr(const std::string &expression) { return expression; } diff --git a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx index 3199017eea..6c8e8b05a9 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx @@ -35,7 +35,7 @@ ParameterRemapReferenceToPointer(CPPType *orig_type) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapReferenceToPointer:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { if (variable_name.size() > 1 && variable_name[0] == '&') { // Prevent generating something like *¶m Also, if this is really some // local type, we can presumably just move it? This is only relevant if @@ -52,7 +52,7 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapReferenceToPointer:: -get_return_expr(const string &expression) { +std::string ParameterRemapReferenceToPointer:: +get_return_expr(const std::string &expression) { return "&(" + expression + ")"; } diff --git a/dtool/src/interrogate/parameterRemapThis.cxx b/dtool/src/interrogate/parameterRemapThis.cxx index e0ef867931..7fd8be4243 100644 --- a/dtool/src/interrogate/parameterRemapThis.cxx +++ b/dtool/src/interrogate/parameterRemapThis.cxx @@ -39,7 +39,7 @@ ParameterRemapThis(CPPType *type, bool is_const) : * type to the original type, for passing into the actual C++ function. */ void ParameterRemapThis:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const std::string &variable_name) { out << "(*" << variable_name << ")"; } @@ -47,8 +47,8 @@ pass_parameter(ostream &out, const string &variable_name) { * Returns an expression that evalutes to the appropriate value type for * returning from the function, given an expression of the original type. */ -string ParameterRemapThis:: -get_return_expr(const string &) { +std::string ParameterRemapThis:: +get_return_expr(const std::string &) { return "**invalid**"; } diff --git a/dtool/src/interrogate/parameterRemapToString.cxx b/dtool/src/interrogate/parameterRemapToString.cxx index 0a3abe4559..9771a2db1b 100644 --- a/dtool/src/interrogate/parameterRemapToString.cxx +++ b/dtool/src/interrogate/parameterRemapToString.cxx @@ -15,6 +15,8 @@ #include "interrogate.h" #include "typeManager.h" +using std::string; + /** * */ @@ -44,7 +46,7 @@ ParameterRemapToString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapToString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << variable_name; } @@ -88,7 +90,7 @@ ParameterRemapToWString(CPPType *orig_type) : * original type to the new type, for passing into the actual C++ function. */ void ParameterRemapToWString:: -pass_parameter(ostream &out, const string &variable_name) { +pass_parameter(std::ostream &out, const string &variable_name) { out << variable_name; } diff --git a/dtool/src/interrogate/parse_file.cxx b/dtool/src/interrogate/parse_file.cxx index 9eb45fcc5b..aa903407d1 100644 --- a/dtool/src/interrogate/parse_file.cxx +++ b/dtool/src/interrogate/parse_file.cxx @@ -25,6 +25,11 @@ #include "pystub.h" #include +using std::cerr; +using std::cin; +using std::cout; +using std::string; + CPPParser parser; void diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index 85161eb69e..b7b744aa86 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -30,6 +30,8 @@ #include "cppTypedefType.h" #include "pnotify.h" +using std::string; + /** * A horrible hack around a CPPParser bug. We don't trust the CPPType pointer * we were given; instead, we ask CPPParser to parse a new type of the same @@ -2251,7 +2253,7 @@ get_function_signature(CPPInstance *function, CPPFunctionType *ftype = function->_type->as_function_type(); assert(ftype != nullptr); - ostringstream out; + std::ostringstream out; // It's tempting to mark static methods with a different function signature // than non-static, because a static method doesn't have an implicit 'this' diff --git a/dtool/src/interrogatedb/interrogateComponent.cxx b/dtool/src/interrogatedb/interrogateComponent.cxx index c5a8e15df0..61398f686f 100644 --- a/dtool/src/interrogatedb/interrogateComponent.cxx +++ b/dtool/src/interrogatedb/interrogateComponent.cxx @@ -16,13 +16,13 @@ // This static string is just kept around as a handy bogus return value for // functions that must return a const string reference. -string InterrogateComponent::_empty_string; +std::string InterrogateComponent::_empty_string; /** * Formats the component for output to a data file. */ void InterrogateComponent:: -output(ostream &out) const { +output(std::ostream &out) const { idf_output_string(out, _name); out << _alt_names.size() << " "; @@ -36,14 +36,14 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateComponent:: -input(istream &in) { +input(std::istream &in) { idf_input_string(in, _name); int num_alt_names; in >> num_alt_names; _alt_names.reserve(num_alt_names); for (int i = 0; i < num_alt_names; ++i) { - string alt_name; + std::string alt_name; idf_input_string(in, alt_name); _alt_names.push_back(alt_name); } diff --git a/dtool/src/interrogatedb/interrogateDatabase.cxx b/dtool/src/interrogatedb/interrogateDatabase.cxx index 8781e5c2bd..a8e7b37a6c 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.cxx +++ b/dtool/src/interrogatedb/interrogateDatabase.cxx @@ -16,6 +16,9 @@ #include "indexRemapper.h" #include "interrogate_datafile.h" +using std::map; +using std::string; + InterrogateDatabase *InterrogateDatabase::_global_ptr = nullptr; int InterrogateDatabase::_file_major_version = 0; int InterrogateDatabase::_file_minor_version = 0; @@ -734,7 +737,7 @@ remap_indices(int first_index, IndexRemapper &remap) { * Writes the database to the indicated stream for later reading. */ void InterrogateDatabase:: -write(ostream &out, InterrogateModuleDef *def) const { +write(std::ostream &out, InterrogateModuleDef *def) const { // Write out the file header. out << def->file_identifier << "\n" << _current_major_version << " " << _current_minor_version << "\n"; @@ -793,7 +796,7 @@ write(ostream &out, InterrogateModuleDef *def) const { * Returns true if the file is read successfully, false if there is an error. */ bool InterrogateDatabase:: -read(istream &in, InterrogateModuleDef *def) { +read(std::istream &in, InterrogateModuleDef *def) { InterrogateDatabase temp; if (!temp.read_new(in, def)) { return false; @@ -899,7 +902,7 @@ load_latest() { * already has some data in it. */ bool InterrogateDatabase:: -read_new(istream &in, InterrogateModuleDef *def) { +read_new(std::istream &in, InterrogateModuleDef *def) { // We've already read the header. Read the module definition. idf_input_string(in, def->library_name); idf_input_string(in, def->library_hash_name); diff --git a/dtool/src/interrogatedb/interrogateElement.cxx b/dtool/src/interrogatedb/interrogateElement.cxx index 38c7c8f4ec..4b6b3d948f 100644 --- a/dtool/src/interrogatedb/interrogateElement.cxx +++ b/dtool/src/interrogatedb/interrogateElement.cxx @@ -20,7 +20,7 @@ * Formats the InterrogateElement data for output to a data file. */ void InterrogateElement:: -output(ostream &out) const { +output(std::ostream &out) const { InterrogateComponent::output(out); out << _flags << " " << _type << " " @@ -40,7 +40,7 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateElement:: -input(istream &in) { +input(std::istream &in) { InterrogateComponent::input(in); in >> _flags >> _type >> _getter >> _setter; if (InterrogateDatabase::get_file_minor_version() >= 1) { diff --git a/dtool/src/interrogatedb/interrogateFunction.cxx b/dtool/src/interrogatedb/interrogateFunction.cxx index a9a60264da..db70cc0b9c 100644 --- a/dtool/src/interrogatedb/interrogateFunction.cxx +++ b/dtool/src/interrogatedb/interrogateFunction.cxx @@ -58,7 +58,7 @@ operator = (const InterrogateFunction ©) { * Formats the InterrogateFunction data for output to a data file. */ void InterrogateFunction:: -output(ostream &out) const { +output(std::ostream &out) const { InterrogateComponent::output(out); out << _flags << " " << _class << " "; @@ -73,7 +73,7 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateFunction:: -input(istream &in) { +input(std::istream &in) { InterrogateComponent::input(in); in >> _flags >> _class; idf_input_string(in, _scoped_name); diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx b/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx index 3cb143a2f3..9cad10ef4e 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx @@ -17,6 +17,9 @@ #include +using std::istream; +using std::ostream; + /** * */ diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.cxx b/dtool/src/interrogatedb/interrogateMakeSeq.cxx index 68f3f5999e..d875a91809 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.cxx +++ b/dtool/src/interrogatedb/interrogateMakeSeq.cxx @@ -19,7 +19,7 @@ * Formats the InterrogateMakeSeq data for output to a data file. */ void InterrogateMakeSeq:: -output(ostream &out) const { +output(std::ostream &out) const { InterrogateComponent::output(out); out << _length_getter << " " << _element_getter << " "; @@ -31,7 +31,7 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateMakeSeq:: -input(istream &in) { +input(std::istream &in) { InterrogateComponent::input(in); in >> _length_getter >> _element_getter; diff --git a/dtool/src/interrogatedb/interrogateManifest.cxx b/dtool/src/interrogatedb/interrogateManifest.cxx index 5257b85aaf..a078e868f4 100644 --- a/dtool/src/interrogatedb/interrogateManifest.cxx +++ b/dtool/src/interrogatedb/interrogateManifest.cxx @@ -19,7 +19,7 @@ * Formats the InterrogateManifest data for output to a data file. */ void InterrogateManifest:: -output(ostream &out) const { +output(std::ostream &out) const { InterrogateComponent::output(out); out << _flags << " " << _int_value << " " @@ -32,7 +32,7 @@ output(ostream &out) const { * Reads the data file as previously formatted by output(). */ void InterrogateManifest:: -input(istream &in) { +input(std::istream &in) { InterrogateComponent::input(in); in >> _flags >> _int_value >> _type >> _getter; idf_input_string(in, _definition); diff --git a/dtool/src/interrogatedb/interrogateType.cxx b/dtool/src/interrogatedb/interrogateType.cxx index 41839ffbf7..a9b9404cd4 100644 --- a/dtool/src/interrogatedb/interrogateType.cxx +++ b/dtool/src/interrogatedb/interrogateType.cxx @@ -18,6 +18,9 @@ #include +using std::istream; +using std::ostream; + /** * */ diff --git a/dtool/src/interrogatedb/interrogate_datafile.cxx b/dtool/src/interrogatedb/interrogate_datafile.cxx index 65cc3f3fef..a61defb368 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.cxx +++ b/dtool/src/interrogatedb/interrogate_datafile.cxx @@ -13,6 +13,10 @@ #include "interrogate_datafile.h" +using std::istream; +using std::ostream; +using std::string; + /** * Writes the indicated string to the output file. Uses the given whitespace diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index 5f72f967e0..2cd08d4adf 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -17,6 +17,8 @@ #include "interrogateFunction.h" #include "config_interrogatedb.h" +using std::string; + // This function adds one more directory to the list of directories search for // interrogate (*.in) files. In the past, this list has been defined the // environment variable ETC_PATH, but now it is passed in by the code diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index ee2966789f..7e867aacad 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -17,6 +17,8 @@ #ifdef HAVE_PYTHON +using std::string; + PyMemberDef standard_type_members[] = { {(char *)"this", (sizeof(void*) == sizeof(int)) ? T_UINT : T_ULONGLONG, offsetof(Dtool_PyInstDef, _ptr_to_object), READONLY, (char *)"C++ 'this' pointer, if any"}, {(char *)"this_ownership", T_BOOL, offsetof(Dtool_PyInstDef, _memory_rules), READONLY, (char *)"C++ 'this' ownership rules"}, @@ -425,7 +427,7 @@ void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) { // are uniquly defined by an integer. void RegisterNamedClass(const string &name, Dtool_PyTypedObject &otype) { - pair result = + std::pair result = named_type_map.insert(NamedTypeMap::value_type(name, &otype)); if (!result.second) { @@ -450,7 +452,7 @@ RegisterRuntimeTypedClass(Dtool_PyTypedObject &otype) { << " has an illegal TypeHandle value; check that init_type() is called.\n"; } else { - pair result = + std::pair result = runtime_type_map.insert(RuntimeTypeMap::value_type(type_index, &otype)); if (!result.second) { // There was already an entry in the dictionary for type_index. @@ -531,7 +533,7 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { version[2] != '0' + PY_MINOR_VERSION) { // Raise a helpful error message. We can safely do this because the // signature and behavior for PyErr_SetString has remained consistent. - ostringstream errs; + std::ostringstream errs; errs << "this module was compiled for Python " << PY_MAJOR_VERSION << "." << PY_MINOR_VERSION << ", which is " << "incompatible with Python " << version.substr(0, 3); diff --git a/dtool/src/interrogatedb/py_wrappers.cxx b/dtool/src/interrogatedb/py_wrappers.cxx index f03d727bd3..c09df0d5ab 100644 --- a/dtool/src/interrogatedb/py_wrappers.cxx +++ b/dtool/src/interrogatedb/py_wrappers.cxx @@ -377,7 +377,7 @@ static PyObject *Dtool_MutableSequenceWrapper_insert(PyObject *self, PyObject *a return PyErr_Format(PyExc_TypeError, "%s.insert() does not support negative indices", wrap->_base._name); } } - return wrap->_insert_func(wrap->_base._self, (ssize_t)max(index, (Py_ssize_t)0), PyTuple_GET_ITEM(args, 1)); + return wrap->_insert_func(wrap->_base._self, (ssize_t)std::max(index, (Py_ssize_t)0), PyTuple_GET_ITEM(args, 1)); } /** diff --git a/dtool/src/prc/androidLogStream.cxx b/dtool/src/prc/androidLogStream.cxx index 2dd32f7c5b..ef05db96ee 100644 --- a/dtool/src/prc/androidLogStream.cxx +++ b/dtool/src/prc/androidLogStream.cxx @@ -56,7 +56,7 @@ AndroidLogStream::AndroidLogStreamBuf:: */ int AndroidLogStream::AndroidLogStreamBuf:: sync() { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); // Write the characters that remain in the buffer. for (char *p = pbase(); p < pptr(); ++p) { @@ -73,7 +73,7 @@ sync() { */ int AndroidLogStream::AndroidLogStreamBuf:: overflow(int ch) { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0 && sync() != 0) { return EOF; @@ -107,7 +107,7 @@ write_char(char c) { */ AndroidLogStream:: AndroidLogStream(int priority) : - ostream(new AndroidLogStreamBuf(priority)) { + std::ostream(new AndroidLogStreamBuf(priority)) { } /** @@ -122,7 +122,7 @@ AndroidLogStream:: * Returns an AndroidLogStream suitable for writing log messages with the * indicated severity. */ -ostream &AndroidLogStream:: +std::ostream &AndroidLogStream:: out(NotifySeverity severity) { static AndroidLogStream* streams[NS_fatal + 1] = {nullptr}; diff --git a/dtool/src/prc/configDeclaration.cxx b/dtool/src/prc/configDeclaration.cxx index d692bec013..7cbfa5ba6e 100644 --- a/dtool/src/prc/configDeclaration.cxx +++ b/dtool/src/prc/configDeclaration.cxx @@ -17,6 +17,8 @@ #include "pstrtod.h" #include "string_utils.h" +using std::string; + /** * Use the ConfigPage::make_declaration() interface to create a new * declaration. @@ -133,7 +135,7 @@ set_double_word(size_t n, double value) { * */ void ConfigDeclaration:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_variable()->get_name() << " " << get_string_value(); } @@ -141,7 +143,7 @@ output(ostream &out) const { * */ void ConfigDeclaration:: -write(ostream &out) const { +write(std::ostream &out) const { out << get_variable()->get_name() << " " << get_string_value(); // if (!get_variable()->is_used()) { out << " (not used)"; } out << "\n"; diff --git a/dtool/src/prc/configFlags.cxx b/dtool/src/prc/configFlags.cxx index 7d9fb90eec..4613dc4615 100644 --- a/dtool/src/prc/configFlags.cxx +++ b/dtool/src/prc/configFlags.cxx @@ -18,8 +18,8 @@ TVOLATILE AtomicAdjust::Integer ConfigFlags::_global_modified; /** * */ -ostream & -operator << (ostream &out, ConfigFlags::ValueType type) { +std::ostream & +operator << (std::ostream &out, ConfigFlags::ValueType type) { switch (type) { case ConfigFlags::VT_undefined: return out << "undefined"; diff --git a/dtool/src/prc/configPage.cxx b/dtool/src/prc/configPage.cxx index ce515529c2..b7f1d06bd9 100644 --- a/dtool/src/prc/configPage.cxx +++ b/dtool/src/prc/configPage.cxx @@ -25,6 +25,10 @@ #include "openssl/evp.h" #endif +using std::istream; +using std::ostream; +using std::string; + ConfigPage *ConfigPage::_default_page = nullptr; ConfigPage *ConfigPage::_local_page = nullptr; @@ -340,7 +344,7 @@ output(ostream &out) const { */ void ConfigPage:: output_brief_signature(ostream &out) const { - size_t num_bytes = min(_signature.size(), (size_t)8); + size_t num_bytes = std::min(_signature.size(), (size_t)8); for (size_t p = 0; p < num_bytes; ++p) { unsigned int byte = _signature[p]; diff --git a/dtool/src/prc/configPageManager.cxx b/dtool/src/prc/configPageManager.cxx index fafaa6fa07..18f8b12784 100644 --- a/dtool/src/prc/configPageManager.cxx +++ b/dtool/src/prc/configPageManager.cxx @@ -38,6 +38,8 @@ #include #include +using std::string; + ConfigPageManager *ConfigPageManager::_global_ptr = nullptr; /** @@ -241,7 +243,7 @@ reload_implicit_pages() { // Use a set to ensure that we only visit each directory once, even if it // appears multiple times (under different aliases!) in the path. - set unique_dirnames; + std::set unique_dirnames; // We walk through the list of directories in forward order, so that the // most important directories are visited first. @@ -447,7 +449,7 @@ delete_explicit_page(ConfigPage *page) { * */ void ConfigPageManager:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ConfigPageManager, " << _explicit_pages.size() + _implicit_pages.size() << " pages."; @@ -457,7 +459,7 @@ output(ostream &out) const { * */ void ConfigPageManager:: -write(ostream &out) const { +write(std::ostream &out) const { check_sort_pages(); out << _explicit_pages.size() << " explicit pages:\n"; @@ -558,7 +560,7 @@ scan_auto_prc_dir(Filename &prc_dir) const { } // Didn't find it; too bad. - cerr << "Warning: unable to auto-locate config files in directory named by \"" + std::cerr << "Warning: unable to auto-locate config files in directory named by \"" << prc_dir << "\".\n"; return false; } diff --git a/dtool/src/prc/configVariableBase.cxx b/dtool/src/prc/configVariableBase.cxx index 55643704b7..0b4e728b94 100644 --- a/dtool/src/prc/configVariableBase.cxx +++ b/dtool/src/prc/configVariableBase.cxx @@ -21,9 +21,9 @@ ConfigVariableBase::Unconstructed *ConfigVariableBase::_unconstructed; * ConfigVariableFoo derived class. */ ConfigVariableBase:: -ConfigVariableBase(const string &name, +ConfigVariableBase(const std::string &name, ConfigVariableBase::ValueType value_type, - const string &description, int flags) : + const std::string &description, int flags) : _core(ConfigVariableManager::get_global_ptr()->make_variable(name)) { #ifndef NDEBUG diff --git a/dtool/src/prc/configVariableCore.cxx b/dtool/src/prc/configVariableCore.cxx index b2ab7d277a..8ae104efd8 100644 --- a/dtool/src/prc/configVariableCore.cxx +++ b/dtool/src/prc/configVariableCore.cxx @@ -23,6 +23,8 @@ #include +using std::string; + /** * Use the ConfigVariableManager::make_variable() interface to create a new @@ -126,9 +128,9 @@ set_flags(int flags) { if ((bits_changed & ~(F_trust_level_mask | F_dconfig)) != 0) { prc_cat->warning() << "changing flags for ConfigVariable " - << get_name() << " from " << hex + << get_name() << " from " << std::hex << (_flags & ~F_trust_level_mask) << " to " - << (flags & ~F_trust_level_mask) << dec << ".\n"; + << (flags & ~F_trust_level_mask) << std::dec << ".\n"; } } @@ -325,7 +327,7 @@ get_declaration(size_t n) const { * */ void ConfigVariableCore:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_declaration(0)->get_string_value(); } @@ -333,7 +335,7 @@ output(ostream &out) const { * */ void ConfigVariableCore:: -write(ostream &out) const { +write(std::ostream &out) const { out << "ConfigVariable " << get_name() << ":\n"; check_sort_declarations(); diff --git a/dtool/src/prc/configVariableList.cxx b/dtool/src/prc/configVariableList.cxx index 7ecd861837..f663ac5adc 100644 --- a/dtool/src/prc/configVariableList.cxx +++ b/dtool/src/prc/configVariableList.cxx @@ -17,7 +17,7 @@ * */ void ConfigVariableList:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_num_values() << " values."; } @@ -25,7 +25,7 @@ output(ostream &out) const { * */ void ConfigVariableList:: -write(ostream &out) const { +write(std::ostream &out) const { size_t num_values = get_num_values(); for (size_t i = 0; i < num_values; ++i) { out << get_string_value(i) << "\n"; diff --git a/dtool/src/prc/configVariableManager.cxx b/dtool/src/prc/configVariableManager.cxx index 52f7269f6b..774dc19f6b 100644 --- a/dtool/src/prc/configVariableManager.cxx +++ b/dtool/src/prc/configVariableManager.cxx @@ -17,6 +17,8 @@ #include "configPage.h" #include "config_prc.h" +using std::string; + ConfigVariableManager *ConfigVariableManager::_global_ptr = nullptr; /** @@ -180,7 +182,7 @@ is_variable_used(size_t n) const { * */ void ConfigVariableManager:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ConfigVariableManager, " << _variables.size() << " variables."; } @@ -188,7 +190,7 @@ output(ostream &out) const { * */ void ConfigVariableManager:: -write(ostream &out) const { +write(std::ostream &out) const { VariablesByName::const_iterator ni; for (ni = _variables_by_name.begin(); ni != _variables_by_name.end(); @@ -211,7 +213,7 @@ write(ostream &out) const { * state. */ void ConfigVariableManager:: -write_prc_variables(ostream &out) const { +write_prc_variables(std::ostream &out) const { VariablesByName::const_iterator ni; for (ni = _variables_by_name.begin(); ni != _variables_by_name.end(); diff --git a/dtool/src/prc/configVariableSearchPath.cxx b/dtool/src/prc/configVariableSearchPath.cxx index 984ba435c7..2231626a7a 100644 --- a/dtool/src/prc/configVariableSearchPath.cxx +++ b/dtool/src/prc/configVariableSearchPath.cxx @@ -32,7 +32,7 @@ reload_search_path() { Filename page_filename(page->get_name()); Filename page_dirname = page_filename.get_dirname(); ExecutionEnvironment::shadow_environment_variable("THIS_PRC_DIR", page_dirname.to_os_specific()); - string expanded = ExecutionEnvironment::expand_string(decl->get_string_value()); + std::string expanded = ExecutionEnvironment::expand_string(decl->get_string_value()); ExecutionEnvironment::clear_shadow("THIS_PRC_DIR"); if (!expanded.empty()) { Filename dir = Filename::from_os_specific(expanded); diff --git a/dtool/src/prc/encryptStreamBuf.cxx b/dtool/src/prc/encryptStreamBuf.cxx index 1fd5cc72b5..192c1181c6 100644 --- a/dtool/src/prc/encryptStreamBuf.cxx +++ b/dtool/src/prc/encryptStreamBuf.cxx @@ -101,7 +101,7 @@ EncryptStreamBuf:: * */ void EncryptStreamBuf:: -open_read(istream *source, bool owns_source, const string &password) { +open_read(std::istream *source, bool owns_source, const std::string &password) { OpenSSL_add_all_algorithms(); _source = source; @@ -208,7 +208,7 @@ close_read() { * */ void EncryptStreamBuf:: -open_write(ostream *dest, bool owns_dest, const string &password) { +open_write(std::ostream *dest, bool owns_dest, const std::string &password) { OpenSSL_add_all_algorithms(); close_write(); @@ -408,7 +408,7 @@ read_chars(char *start, size_t length) { if (_in_read_overflow_buffer != 0) { // Take from the overflow buffer. - length = min(length, _in_read_overflow_buffer); + length = std::min(length, _in_read_overflow_buffer); memcpy(start, _read_overflow_buffer, length); _in_read_overflow_buffer -= length; memcpy(_read_overflow_buffer + length, _read_overflow_buffer, _in_read_overflow_buffer); diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index 0d91f5b444..f9c39135e8 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -29,6 +29,12 @@ #include #endif +using std::cerr; +using std::cout; +using std::ostream; +using std::ostringstream; +using std::string; + Notify *Notify::_global_ptr = nullptr; /** @@ -101,7 +107,7 @@ get_literal_flag() { if (!got_flag) { #ifndef PHAVE_IOSTREAM - flag = ios::bitalloc(); + flag = std::ios::bitalloc(); #else // We lost bitalloc in the new iostream? Ok, this feature will just be // disabled for now. No big deal. @@ -187,7 +193,7 @@ get_category(const string &basename, NotifyCategory *parent_category) { } } - pair result = + std::pair result = _categories.insert(Categories::value_type(fullname, nullptr)); bool inserted = result.second; @@ -430,7 +436,7 @@ config_initialized() { if (!notify_output.empty()) { if (notify_output == "stdout") { - cout.setf(ios::unitbuf); + cout.setf(std::ios::unitbuf); set_ostream_ptr(&cout, false); } else if (notify_output == "stderr") { @@ -459,7 +465,7 @@ config_initialized() { nout << "Unable to open file " << filename << " for output.\n"; delete out; } else { - out->setf(ios::unitbuf); + out->setf(std::ios::unitbuf); set_ostream_ptr(out, true); } #endif // BUILD_IPHONE diff --git a/dtool/src/prc/notifyCategory.cxx b/dtool/src/prc/notifyCategory.cxx index 8faa89bdd0..11a3c52587 100644 --- a/dtool/src/prc/notifyCategory.cxx +++ b/dtool/src/prc/notifyCategory.cxx @@ -31,7 +31,7 @@ long NotifyCategory::_server_delta = 0; * */ NotifyCategory:: -NotifyCategory(const string &fullname, const string &basename, +NotifyCategory(const std::string &fullname, const std::string &basename, NotifyCategory *parent) : _fullname(fullname), _basename(basename), @@ -55,7 +55,7 @@ NotifyCategory(const string &fullname, const string &basename, * the Notify::out() stream and returns that. If the severity level is * disabled, this returns Notify::null(). */ -ostream &NotifyCategory:: +std::ostream &NotifyCategory:: out(NotifySeverity severity, bool prefix) const { if (is_on(severity)) { @@ -151,9 +151,9 @@ set_server_delta(long delta) { * Returns the name of the config variable that controls this category. This * is called at construction time. */ -string NotifyCategory:: +std::string NotifyCategory:: get_config_name() const { - string config_name; + std::string config_name; if (_fullname.empty()) { config_name = "notify-level"; diff --git a/dtool/src/prc/notifySeverity.cxx b/dtool/src/prc/notifySeverity.cxx index 0ee750e879..d6547e8de1 100644 --- a/dtool/src/prc/notifySeverity.cxx +++ b/dtool/src/prc/notifySeverity.cxx @@ -14,6 +14,10 @@ #include "notifySeverity.h" #include "pnotify.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, NotifySeverity severity) { switch (severity) { diff --git a/dtool/src/prc/streamReader.cxx b/dtool/src/prc/streamReader.cxx index e9fa173ad1..74f278e220 100644 --- a/dtool/src/prc/streamReader.cxx +++ b/dtool/src/prc/streamReader.cxx @@ -14,6 +14,8 @@ #include "streamReader.h" #include "memoryHook.h" +using std::string; + /** * Extracts a variable-length string. diff --git a/dtool/src/prc/streamReader_ext.cxx b/dtool/src/prc/streamReader_ext.cxx index 53a4570872..94c346e370 100644 --- a/dtool/src/prc/streamReader_ext.cxx +++ b/dtool/src/prc/streamReader_ext.cxx @@ -41,9 +41,9 @@ extract_bytes(size_t size) { */ PyObject *Extension:: readline() { - istream *in = _this->get_istream(); + std::istream *in = _this->get_istream(); - string line; + std::string line; int ch = in->get(); while (!in->eof() && !in->fail()) { line += ch; diff --git a/dtool/src/prc/streamWrapper.cxx b/dtool/src/prc/streamWrapper.cxx index 68f8e47abb..3c59fb3a90 100644 --- a/dtool/src/prc/streamWrapper.cxx +++ b/dtool/src/prc/streamWrapper.cxx @@ -13,6 +13,8 @@ #include "streamWrapper.h" +using std::streamsize; + /** * */ @@ -121,7 +123,7 @@ streamsize IStreamWrapper:: seek_gpos_eof() { streamsize pos; acquire(); - _istream->seekg(0, ios::end); + _istream->seekg(0, std::ios::end); pos = _istream->tellg(); release(); @@ -204,7 +206,7 @@ void OStreamWrapper:: seek_eof_write(const char *buffer, streamsize num_bytes, bool &fail) { acquire(); _ostream->clear(); - _ostream->seekp(0, ios::end); + _ostream->seekp(0, std::ios::end); #ifdef WIN32_VC if (_ostream->fail() && _stringstream_hack) { @@ -228,7 +230,7 @@ streamsize OStreamWrapper:: seek_ppos_eof() { streamsize pos; acquire(); - _ostream->seekp(0, ios::end); + _ostream->seekp(0, std::ios::end); #ifdef WIN32_VC if (_ostream->fail() && _stringstream_hack) { diff --git a/dtool/src/prckeys/makePrcKey.cxx b/dtool/src/prckeys/makePrcKey.cxx index 48b8f62d9c..a6ee834b04 100644 --- a/dtool/src/prckeys/makePrcKey.cxx +++ b/dtool/src/prckeys/makePrcKey.cxx @@ -30,6 +30,9 @@ #include "openssl/rand.h" #include "openssl/bio.h" +using std::cerr; +using std::string; + class KeyNumber { public: int _number; @@ -69,7 +72,7 @@ output_ssl_errors() { * string. */ void -output_c_string(ostream &out, const string &string_name, +output_c_string(std::ostream &out, const string &string_name, size_t index, BIO *mbio) { char *data_ptr; size_t data_size = BIO_get_mem_data(mbio, &data_ptr); @@ -94,8 +97,8 @@ output_c_string(ostream &out, const string &string_name, out << data_ptr[i]; } else { - out << "\\x" << hex << setw(2) << setfill('0') - << (unsigned int)(unsigned char)data_ptr[i] << dec; + out << "\\x" << std::hex << std::setw(2) << std::setfill('0') + << (unsigned int)(unsigned char)data_ptr[i] << std::dec; } } } @@ -456,7 +459,7 @@ main(int argc, char **argv) { EVP_PKEY *pkey = generate_key(); PrcKeyRegistry::get_global_ptr()->set_key(n, pkey, now); - ostringstream strm; + std::ostringstream strm; if (got_hash || n != 1) { // If we got an explicit hash mark, we always output the number. If we // did not get an explicit hash mark, we output the number only if it is diff --git a/dtool/src/prckeys/signPrcFile_src.cxx b/dtool/src/prckeys/signPrcFile_src.cxx index f122283c55..5e9d04a1b4 100644 --- a/dtool/src/prckeys/signPrcFile_src.cxx +++ b/dtool/src/prckeys/signPrcFile_src.cxx @@ -30,6 +30,9 @@ #include "openssl/bio.h" #include "openssl/evp.h" +using std::cerr; +using std::string; + string progname = PROGNAME; /** @@ -77,7 +80,7 @@ read_prc_line(const string &line, string &data) { * indicated string. */ void -read_file(istream &in, string &data) { +read_file(std::istream &in, string &data) { // We avoid getline() here because of its notorious problem with last lines // that lack a trailing newline character. static const size_t buffer_size = 1024; @@ -129,7 +132,7 @@ read_file(istream &in, string &data) { * Outputs the indicated data stream as a series of hex digits. */ void -output_hex(ostream &out, const unsigned char *data, size_t size) { +output_hex(std::ostream &out, const unsigned char *data, size_t size) { } /** @@ -155,7 +158,7 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { } // Append the comments before the signature (these get signed too). - ostringstream strm; + std::ostringstream strm; strm << "##!\n"; if (!no_comments) { time_t now = time(nullptr); @@ -203,7 +206,7 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { } cerr << "Rewriting " << filename << "\n"; - out << data << hex << setfill('0'); + out << data << std::hex << std::setfill('0'); static const size_t row_width = 32; for (size_t p = 0; p < sig_size; p += row_width) { out << "##!sig "; @@ -214,11 +217,11 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { end = p+row_width; for (size_t q = p; q < end; q++) { - out << setw(2) << (unsigned int)sig_data[q]; + out << std::setw(2) << (unsigned int)sig_data[q]; } out << "\n"; } - out << dec; + out << std::dec; delete[] sig_data; } diff --git a/dtool/src/test_interrogate/test_interrogate.cxx b/dtool/src/test_interrogate/test_interrogate.cxx index 9a5c6dfc16..590b8ac873 100644 --- a/dtool/src/test_interrogate/test_interrogate.cxx +++ b/dtool/src/test_interrogate/test_interrogate.cxx @@ -23,6 +23,11 @@ #include +using std::cerr; +using std::cout; +using std::ostream; +using std::string; + static ostream & indent(ostream &out, int indent_level) { for (int i = 0; i < indent_level; i++) { diff --git a/dtool/src/test_interrogate/test_lib.cxx b/dtool/src/test_interrogate/test_lib.cxx index cab224118c..89ccafccfc 100644 --- a/dtool/src/test_interrogate/test_lib.cxx +++ b/dtool/src/test_interrogate/test_lib.cxx @@ -34,7 +34,7 @@ int stupid_global; Configure(test_lib); ConfigureFn(test_lib) { - cerr << "In test_lib configure function!" << endl; + std::cerr << "In test_lib configure function!" << std::endl; } ConfigureLibSym; diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index 865936e2ed..626111ed83 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -26,6 +26,8 @@ #include #include +using std::string; + // struct android_app* panda_android_app = NULL; extern int main(int argc, const char **argv); @@ -197,7 +199,7 @@ void android_main(struct android_app* app) { get_model_path().append_directory(asset_dir); // Now load the configuration files. - vector pages; + std::vector pages; ConfigPageManager *cp_mgr; AAssetDir *etc = AAssetManager_openDir(app->activity->assetManager, "etc"); if (etc != nullptr) { @@ -209,7 +211,7 @@ void android_main(struct android_app* app) { GlobPattern pattern = cp_mgr->get_prc_pattern(i); if (pattern.matches(filename)) { Filename prc_fn("etc", filename); - istream *in = asset_mount->open_read_file(prc_fn); + std::istream *in = asset_mount->open_read_file(prc_fn); if (in != nullptr) { ConfigPage *page = cp_mgr->make_explicit_page(Filename("/android_asset", prc_fn)); page->read_prc(*in); diff --git a/panda/src/android/config_android.cxx b/panda/src/android/config_android.cxx index aa527cefc3..083cd7c192 100644 --- a/panda/src/android/config_android.cxx +++ b/panda/src/android/config_android.cxx @@ -139,7 +139,7 @@ void JNI_OnUnload(JavaVM *jvm, void *reserved) { * Shows a toast notification at the bottom of the activity. The duration * should be 0 for short and 1 for long. */ -void android_show_toast(ANativeActivity *activity, const string &message, int duration) { +void android_show_toast(ANativeActivity *activity, const std::string &message, int duration) { Thread *thread = Thread::get_current_thread(); JNIEnv *env = thread->get_jni_env(); nassertv(env != nullptr); diff --git a/panda/src/android/pnmFileTypeAndroid.cxx b/panda/src/android/pnmFileTypeAndroid.cxx index aa25b2c777..535cc30563 100644 --- a/panda/src/android/pnmFileTypeAndroid.cxx +++ b/panda/src/android/pnmFileTypeAndroid.cxx @@ -27,7 +27,7 @@ PNMFileTypeAndroid(CompressFormat format) : _format(format) { /** * Returns a few words describing the file type. */ -string PNMFileTypeAndroid:: +std::string PNMFileTypeAndroid:: get_name() const { return "Android Bitmap"; } @@ -54,7 +54,7 @@ get_num_extensions() const { * Returns the nth possible filename extension associated with this particular * file type, without a leading dot. */ -string PNMFileTypeAndroid:: +std::string PNMFileTypeAndroid:: get_extension(int n) const { static const char *const jpeg_extensions[] = {"jpg", "jpeg", "jpe"}; switch (_format) { @@ -84,7 +84,7 @@ has_magic_number() const { * returns NULL. */ PNMReader *PNMFileTypeAndroid:: -make_reader(istream *file, bool owns_file, const string &magic_number) { +make_reader(std::istream *file, bool owns_file, const std::string &magic_number) { return new Reader(this, file, owns_file, magic_number); } @@ -94,7 +94,7 @@ make_reader(istream *file, bool owns_file, const string &magic_number) { * NULL. */ PNMWriter *PNMFileTypeAndroid:: -make_writer(ostream *file, bool owns_file) { +make_writer(std::ostream *file, bool owns_file) { return new Writer(this, file, owns_file, _format); } diff --git a/panda/src/android/pnmFileTypeAndroidReader.cxx b/panda/src/android/pnmFileTypeAndroidReader.cxx index 797571a311..7feceffa1c 100644 --- a/panda/src/android/pnmFileTypeAndroidReader.cxx +++ b/panda/src/android/pnmFileTypeAndroidReader.cxx @@ -60,11 +60,11 @@ static void conv_rgba4444(uint16_t in, xel &rgb, xelval &alpha) { * */ PNMFileTypeAndroid::Reader:: -Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : +Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number) : PNMReader(type, file, owns_file), _bitmap(nullptr) { // Hope we can putback() more than one character. - for (string::reverse_iterator mi = magic_number.rbegin(); + for (std::string::reverse_iterator mi = magic_number.rbegin(); mi != magic_number.rend(); ++mi) { _file->putback(*mi); }; @@ -75,7 +75,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : return; } - streampos pos = _file->tellg(); + std::streampos pos = _file->tellg(); Thread *current_thread = Thread::get_current_thread(); _env = current_thread->get_jni_env(); @@ -143,7 +143,7 @@ prepare_read() { int x_reduction = _orig_x_size / _read_x_size; int y_reduction = _orig_y_size / _read_y_size; - _sample_size = max(min(x_reduction, y_reduction), 1); + _sample_size = std::max(std::min(x_reduction, y_reduction), 1); } _bitmap = _env->CallStaticObjectMethod(jni_PandaActivity, diff --git a/panda/src/android/pnmFileTypeAndroidWriter.cxx b/panda/src/android/pnmFileTypeAndroidWriter.cxx index 4677a25cbd..3157733115 100644 --- a/panda/src/android/pnmFileTypeAndroidWriter.cxx +++ b/panda/src/android/pnmFileTypeAndroidWriter.cxx @@ -34,7 +34,7 @@ enum class BitmapConfig : jint { * */ PNMFileTypeAndroid::Writer:: -Writer(PNMFileType *type, ostream *file, bool owns_file, +Writer(PNMFileType *type, std::ostream *file, bool owns_file, CompressFormat format) : PNMWriter(type, file, owns_file), _format(format) diff --git a/panda/src/android/python_main.cxx b/panda/src/android/python_main.cxx index c1fc0a39fe..0e4059c61c 100644 --- a/panda/src/android/python_main.cxx +++ b/panda/src/android/python_main.cxx @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) { Py_SetProgramName(Py_DecodeLocale("ppython", nullptr)); // Set PYTHONHOME to the location of the .apk file. - string apk_path = ExecutionEnvironment::get_binary_name(); + std::string apk_path = ExecutionEnvironment::get_binary_name(); Py_SetPythonHome(Py_DecodeLocale(apk_path.c_str(), nullptr)); // We need to make zlib available to zipimport, but I don't know how @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { // This is used by the import hook to locate the module libraries. Filename dtool_name = ExecutionEnvironment::get_dtool_name(); - string native_dir = dtool_name.get_dirname(); + std::string native_dir = dtool_name.get_dirname(); PyObject *py_native_dir = PyUnicode_FromStringAndSize(native_dir.c_str(), native_dir.size()); PySys_SetObject("_native_library_dir", py_native_dir); Py_DECREF(py_native_dir); diff --git a/panda/src/androiddisplay/androidGraphicsPipe.cxx b/panda/src/androiddisplay/androidGraphicsPipe.cxx index 673a03e5a2..53f0f72310 100644 --- a/panda/src/androiddisplay/androidGraphicsPipe.cxx +++ b/panda/src/androiddisplay/androidGraphicsPipe.cxx @@ -68,7 +68,7 @@ AndroidGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string AndroidGraphicsPipe:: +std::string AndroidGraphicsPipe:: get_interface_name() const { return "OpenGL ES"; } @@ -99,7 +99,7 @@ AndroidGraphicsPipe::get_preferred_window_thread() const { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) AndroidGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx index 3d5b949633..e5c8177d9e 100644 --- a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx +++ b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx @@ -275,7 +275,7 @@ reset() { #endif // If "PixelFlinger" is present, assume software. - if (_gl_renderer.find("PixelFlinger") != string::npos) { + if (_gl_renderer.find("PixelFlinger") != std::string::npos) { _fbprops.set_force_software(1); _fbprops.set_force_hardware(0); } else { diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index 62755cdd2c..431f9419b7 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -38,7 +38,7 @@ TypeHandle AndroidGraphicsWindow::_type_handle; */ AndroidGraphicsWindow:: AndroidGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/androiddisplay/config_androiddisplay.cxx b/panda/src/androiddisplay/config_androiddisplay.cxx index 6b344b6c9d..42b0fb8120 100644 --- a/panda/src/androiddisplay/config_androiddisplay.cxx +++ b/panda/src/androiddisplay/config_androiddisplay.cxx @@ -64,7 +64,7 @@ init_libandroiddisplay() { /** * Returns the given EGL error as string. */ -const string get_egl_error_string(int error) { +const std::string get_egl_error_string(int error) { switch (error) { case 0x3000: return "EGL_SUCCESS"; break; case 0x3001: return "EGL_NOT_INITIALIZED"; break; diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index 77d4c1a076..39d16156ef 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -25,6 +25,8 @@ #include // For GetSystemDirectory() #endif +using std::string; + TypeHandle AudioManager::_type_handle; @@ -312,7 +314,7 @@ get_dls_pathname() { * */ void AudioManager:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -320,7 +322,7 @@ output(ostream &out) const { * */ void AudioManager:: -write(ostream &out) const { +write(std::ostream &out) const { out << (*this) << "\n"; } diff --git a/panda/src/audio/audioSound.cxx b/panda/src/audio/audioSound.cxx index 9d121e06b0..19cc27f030 100644 --- a/panda/src/audio/audioSound.cxx +++ b/panda/src/audio/audioSound.cxx @@ -14,6 +14,8 @@ #include "audioSound.h" +using std::ostream; + TypeHandle AudioSound::_type_handle; /** diff --git a/panda/src/audio/config_audio.cxx b/panda/src/audio/config_audio.cxx index 0f58e56a32..1ea8053eb6 100644 --- a/panda/src/audio/config_audio.cxx +++ b/panda/src/audio/config_audio.cxx @@ -25,6 +25,10 @@ #error Buildsystem error: BUILDING_PANDA_AUDIO not defined #endif +using std::istream; +using std::ostream; +using std::string; + Configure(config_audio); NotifyCategoryDef(audio, ""); diff --git a/panda/src/audio/nullAudioManager.cxx b/panda/src/audio/nullAudioManager.cxx index f7126e9b7b..dabeb8c825 100644 --- a/panda/src/audio/nullAudioManager.cxx +++ b/panda/src/audio/nullAudioManager.cxx @@ -49,7 +49,7 @@ is_valid() { * */ PT(AudioSound) NullAudioManager:: -get_sound(const string&, bool positional, int mode) { +get_sound(const std::string&, bool positional, int mode) { return get_null_sound(); } @@ -65,7 +65,7 @@ get_sound(MovieAudio *sound, bool positional, int mode) { * */ void NullAudioManager:: -uncache_sound(const string&) { +uncache_sound(const std::string&) { // intentionally blank. } diff --git a/panda/src/audio/nullAudioSound.cxx b/panda/src/audio/nullAudioSound.cxx index 980083b468..0fbdf14672 100644 --- a/panda/src/audio/nullAudioSound.cxx +++ b/panda/src/audio/nullAudioSound.cxx @@ -14,6 +14,8 @@ #include "nullAudioSound.h" +using std::string; + TypeHandle NullAudioSound::_type_handle; namespace { diff --git a/panda/src/audio/test_audio.cxx b/panda/src/audio/test_audio.cxx index a2a7ac06fb..612ad1bcb5 100644 --- a/panda/src/audio/test_audio.cxx +++ b/panda/src/audio/test_audio.cxx @@ -26,9 +26,9 @@ main(int argc, char* argv[]) { PT(AudioSound) tester = AudioPool::load_sound(argv[1]); AudioManager::play(tester); AudioPool::release_all_sounds(); - cerr << "all sounds but 1 released" << endl; + std::cerr << "all sounds but 1 released" << std::endl; } - cerr << "all sounds released" << endl; + std::cerr << "all sounds released" << std::endl; } /* diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 529f6facb0..1f7ed7cd22 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -409,7 +409,7 @@ configure_filters(FilterProperties *config) { * This is what creates a sound instance. */ PT(AudioSound) FmodAudioManager:: -get_sound(const string &file_name, bool positional, int) { +get_sound(const std::string &file_name, bool positional, int) { ReMutexHolder holder(_lock); // Needed so People use Panda's Generic UNIX Style Paths for Filename. // path.to_os_specific() converts it back to the proper OS version later on. @@ -768,7 +768,7 @@ reduce_sounds_playing_to(unsigned int count) { * NOT USED FOR FMOD-EX!!! Clears a sound out of the sound cache. */ void FmodAudioManager:: -uncache_sound(const string& file_name) { +uncache_sound(const std::string& file_name) { audio_debug("FmodAudioManager::uncache_sound(\""< #endif +using std::istream; +using std::string; + GlobalMilesManager *GlobalMilesManager::_global_ptr; /** @@ -414,15 +417,15 @@ seek_callback(UINTa file_handle, S32 offset, U32 type) { strm->clear(); switch (type) { case AIL_FILE_SEEK_BEGIN: - strm->seekg(offset, ios::beg); + strm->seekg(offset, std::ios::beg); break; case AIL_FILE_SEEK_CURRENT: - strm->seekg(offset, ios::cur); + strm->seekg(offset, std::ios::cur); break; case AIL_FILE_SEEK_END: - strm->seekg(offset, ios::end); + strm->seekg(offset, std::ios::end); break; } diff --git a/panda/src/audiotraits/milesAudioManager.cxx b/panda/src/audiotraits/milesAudioManager.cxx index 24ed73d448..2aed1ce44b 100644 --- a/panda/src/audiotraits/milesAudioManager.cxx +++ b/panda/src/audiotraits/milesAudioManager.cxx @@ -31,6 +31,8 @@ #include +using std::string; + TypeHandle MilesAudioManager::_type_handle; @@ -153,7 +155,7 @@ get_sound(const string &file_name, bool, int) { } // Put it in the pool: The following is roughly like: _sounds[path] = // sd; But, it gives us an iterator into the map. - pair ib + std::pair ib = _sounds.insert(SoundMap::value_type(path, sd)); if (!ib.second) { // The insert failed. @@ -673,7 +675,7 @@ cleanup() { * */ void MilesAudioManager:: -output(ostream &out) const { +output(std::ostream &out) const { LightReMutexHolder holder(_lock); out << get_type() << ": " << _sounds_playing.size() << " / " << _sounds_on_loan.size() << " sounds playing / total"; @@ -683,7 +685,7 @@ output(ostream &out) const { * */ void MilesAudioManager:: -write(ostream &out) const { +write(std::ostream &out) const { LightReMutexHolder holder(_lock); out << (*this) << "\n"; @@ -899,7 +901,7 @@ load(const Filename &file_name) { bool is_midi_file = (downcase(extension) == "mid"); - if ((miles_audio_preload_threshold == -1 || file->get_file_size() < (streamsize)miles_audio_preload_threshold) || + if ((miles_audio_preload_threshold == -1 || file->get_file_size() < (std::streamsize)miles_audio_preload_threshold) || is_midi_file) { // If the file is sufficiently small, we'll preload it into memory. MIDI // files cannot be streamed, so we always preload them, regardless of diff --git a/panda/src/audiotraits/milesAudioSample.cxx b/panda/src/audiotraits/milesAudioSample.cxx index e953e77dad..8eb0ab2d26 100644 --- a/panda/src/audiotraits/milesAudioSample.cxx +++ b/panda/src/audiotraits/milesAudioSample.cxx @@ -34,7 +34,7 @@ TypeHandle MilesAudioSample::_type_handle; */ MilesAudioSample:: MilesAudioSample(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, - const string &file_name) : + const std::string &file_name) : MilesAudioSound(manager, file_name), _sd(sd) { @@ -176,8 +176,8 @@ set_volume(PN_stdfloat volume) { // Change to Miles volume, range 0 to 1.0: F32 milesVolume = volume; - milesVolume = min(milesVolume, 1.0f); - milesVolume = max(milesVolume, 0.0f); + milesVolume = std::min(milesVolume, 1.0f); + milesVolume = std::max(milesVolume, 0.0f); // Convert balance of -1.0..1.0 to 0-1.0: F32 milesBalance = (F32)((_balance + 1.0f) * 0.5f); @@ -269,7 +269,7 @@ cleanup() { * */ void MilesAudioSample:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name() << " " << status(); if (!_sd.is_null()) { out << " " << (_sd->_raw_data.size() + 1023) / 1024 << "K"; diff --git a/panda/src/audiotraits/milesAudioSequence.cxx b/panda/src/audiotraits/milesAudioSequence.cxx index 9f16c0dd3d..b214644e54 100644 --- a/panda/src/audiotraits/milesAudioSequence.cxx +++ b/panda/src/audiotraits/milesAudioSequence.cxx @@ -34,7 +34,7 @@ TypeHandle MilesAudioSequence::_type_handle; */ MilesAudioSequence:: MilesAudioSequence(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, - const string &file_name) : + const std::string &file_name) : MilesAudioSound(manager, file_name), _sd(sd) { @@ -166,8 +166,8 @@ set_volume(PN_stdfloat volume) { // Change to Miles volume, range 0 to 127: S32 milesVolume = (S32)(volume * 127.0f); - milesVolume = min(milesVolume, 127); - milesVolume = max(milesVolume, 0); + milesVolume = std::min(milesVolume, 127); + milesVolume = std::max(milesVolume, 0); AIL_set_sequence_volume(_sequence, milesVolume, 0); } @@ -296,7 +296,7 @@ do_set_time(PN_stdfloat time) { // Ensure we don't inadvertently run off the end of the sound. S32 length_ms; AIL_sequence_ms_position(_sequence, &length_ms, nullptr); - time_ms = min(time_ms, length_ms); + time_ms = std::min(time_ms, length_ms); AIL_set_sequence_ms_position(_sequence, time_ms); } diff --git a/panda/src/audiotraits/milesAudioSound.cxx b/panda/src/audiotraits/milesAudioSound.cxx index de9d0edcff..75ca1d012b 100644 --- a/panda/src/audiotraits/milesAudioSound.cxx +++ b/panda/src/audiotraits/milesAudioSound.cxx @@ -16,6 +16,8 @@ #include "milesAudioManager.h" +using std::string; + TypeHandle MilesAudioSound::_type_handle; #undef miles_audio_debug diff --git a/panda/src/audiotraits/milesAudioStream.cxx b/panda/src/audiotraits/milesAudioStream.cxx index debf8dd08a..480d35c81c 100644 --- a/panda/src/audiotraits/milesAudioStream.cxx +++ b/panda/src/audiotraits/milesAudioStream.cxx @@ -32,7 +32,7 @@ TypeHandle MilesAudioStream::_type_handle; * */ MilesAudioStream:: -MilesAudioStream(MilesAudioManager *manager, const string &file_name, +MilesAudioStream(MilesAudioManager *manager, const std::string &file_name, const Filename &path) : MilesAudioSound(manager, file_name), _path(path) @@ -173,8 +173,8 @@ set_volume(PN_stdfloat volume) { // Change to Miles volume, range 0 to 1.0: F32 milesVolume = volume; - milesVolume = min(milesVolume, 1.0f); - milesVolume = max(milesVolume, 0.0f); + milesVolume = std::min(milesVolume, 1.0f); + milesVolume = std::max(milesVolume, 0.0f); // Convert balance of -1.0..1.0 to 0-1.0: F32 milesBalance = (F32)((_balance + 1.0f) * 0.5f); @@ -301,7 +301,7 @@ do_set_time(PN_stdfloat time) { // Ensure we don't inadvertently run off the end of the sound. S32 length_ms; AIL_stream_ms_position(_stream, &length_ms, nullptr); - time_ms = min(time_ms, length_ms); + time_ms = std::min(time_ms, length_ms); AIL_set_stream_ms_position(_stream, time_ms); } diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index f6b7caa22b..feee7a62aa 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -33,6 +33,9 @@ #define ALC_ALL_DEVICES_SPECIFIER 0x1013 #endif +using std::endl; +using std::string; + TypeHandle OpenALAudioManager::_type_handle; ReMutex OpenALAudioManager::_lock; diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index 2a697a642b..8d41a61fa3 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -836,14 +836,14 @@ get_active() const { * */ void OpenALAudioSound:: -set_finished_event(const string& event) { +set_finished_event(const std::string& event) { _finished_event = event; } /** * */ -const string& OpenALAudioSound:: +const std::string& OpenALAudioSound:: get_finished_event() const { return _finished_event; } @@ -851,7 +851,7 @@ get_finished_event() const { /** * Get name of sound file */ -const string& OpenALAudioSound:: +const std::string& OpenALAudioSound:: get_name() const { return _basename; } diff --git a/panda/src/awesomium/AwMouseAndKeyboard.cxx b/panda/src/awesomium/AwMouseAndKeyboard.cxx index 2ee5728584..9948c0d49d 100644 --- a/panda/src/awesomium/AwMouseAndKeyboard.cxx +++ b/panda/src/awesomium/AwMouseAndKeyboard.cxx @@ -17,7 +17,7 @@ TypeHandle AwMouseAndKeyboard::_type_handle; -AwMouseAndKeyboard::AwMouseAndKeyboard(const string &name): +AwMouseAndKeyboard::AwMouseAndKeyboard(const std::string &name): DataNode(name) { _button_events_input = define_input("button_events", ButtonEventList::get_class_type()); @@ -34,7 +34,7 @@ void AwMouseAndKeyboard::do_transmit_data(DataGraphTraverser *trav, const DataNo int num_events = button_events->get_num_events(); for (int i = 0; i < num_events; i++) { const ButtonEvent &be = button_events->get_event(i); - string event_name = be._button.get_name(); + std::string event_name = be._button.get_name(); printf("Button Event! : %s with code %i and index %i ", event_name.c_str(), be._keycode, be._button.get_index()); if(be._type == ButtonEvent::T_down) printf("down"); if(be._type == ButtonEvent::T_repeat) printf("repeat"); diff --git a/panda/src/awesomium/WebBrowserTexture.cxx b/panda/src/awesomium/WebBrowserTexture.cxx index 04908f4abc..1051a33e36 100644 --- a/panda/src/awesomium/WebBrowserTexture.cxx +++ b/panda/src/awesomium/WebBrowserTexture.cxx @@ -33,7 +33,7 @@ Texture(copy) /** * This initializes a web browser texture with the given AwWebView class. */ -WebBrowserTexture::WebBrowserTexture(const string &name, AwWebView* aw_web_view): +WebBrowserTexture::WebBrowserTexture(const std::string &name, AwWebView* aw_web_view): Texture(name), _update_active(true), _flip_texture_active(false) diff --git a/panda/src/awesomium/awWebView.cxx b/panda/src/awesomium/awWebView.cxx index 5ef0b95181..ebc3a63f89 100644 --- a/panda/src/awesomium/awWebView.cxx +++ b/panda/src/awesomium/awWebView.cxx @@ -28,7 +28,7 @@ AwWebView:: void AwWebView:: -loadURL2(const string& url, const string& frameName , const string& username , const string& password ) +loadURL2(const std::string& url, const std::string& frameName , const std::string& username , const std::string& password ) { _myWebView->loadURL2(url, frameName, username, password); diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 565cfa35a2..9c2553c892 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -150,7 +150,7 @@ safe_to_flatten_below() const { * */ void BulletBodyNode:: -do_output(ostream &out) const { +do_output(std::ostream &out) const { PandaNode::output(out); @@ -166,7 +166,7 @@ do_output(ostream &out) const { * */ void BulletBodyNode:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(BulletWorld::get_global_lock()); do_output(out); @@ -427,7 +427,7 @@ remove_shape(BulletShape *shape) { found = find(_shapes.begin(), _shapes.end(), ptshape); if (found == _shapes.end()) { - bullet_cat.warning() << "shape not attached" << endl; + bullet_cat.warning() << "shape not attached" << std::endl; } else { _shapes.erase(found); diff --git a/panda/src/bullet/bulletCapsuleShape.cxx b/panda/src/bullet/bulletCapsuleShape.cxx index 44fbc3e501..85171d9b46 100644 --- a/panda/src/bullet/bulletCapsuleShape.cxx +++ b/panda/src/bullet/bulletCapsuleShape.cxx @@ -35,7 +35,7 @@ BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : _shape = new btCapsuleShapeZ(radius, height); break; default: - bullet_cat.error() << "invalid up-axis:" << up << endl; + bullet_cat.error() << "invalid up-axis:" << up << std::endl; break; } @@ -65,7 +65,7 @@ BulletCapsuleShape(const BulletCapsuleShape ©) { _shape = new btCapsuleShapeZ(_radius, _height); break; default: - bullet_cat.error() << "invalid up-axis:" << _up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << std::endl; break; } @@ -150,7 +150,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btCapsuleShapeZ(_radius, _height); break; default: - bullet_cat.error() << "invalid up-axis:" << _up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << std::endl; break; } diff --git a/panda/src/bullet/bulletCharacterControllerNode.cxx b/panda/src/bullet/bulletCharacterControllerNode.cxx index d65948a824..e9652de7e5 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.cxx +++ b/panda/src/bullet/bulletCharacterControllerNode.cxx @@ -34,7 +34,7 @@ BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height, const // Get convex shape (for ghost object) if (!shape->is_convex()) { - bullet_cat.error() << "a convex shape is required!" << endl; + bullet_cat.error() << "a convex shape is required!" << std::endl; return; } diff --git a/panda/src/bullet/bulletConeShape.cxx b/panda/src/bullet/bulletConeShape.cxx index 84c1fc4157..c4c554ba2f 100644 --- a/panda/src/bullet/bulletConeShape.cxx +++ b/panda/src/bullet/bulletConeShape.cxx @@ -35,7 +35,7 @@ BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : _shape = new btConeShapeZ((btScalar)radius, (btScalar)height); break; default: - bullet_cat.error() << "invalid up-axis:" << up << endl; + bullet_cat.error() << "invalid up-axis:" << up << std::endl; break; } @@ -65,7 +65,7 @@ BulletConeShape(const BulletConeShape ©) { _shape = new btConeShapeZ((btScalar)_radius, (btScalar)_height); break; default: - bullet_cat.error() << "invalid up-axis:" << _up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << std::endl; break; } @@ -150,7 +150,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btConeShapeZ((btScalar)_radius, (btScalar)_height); break; default: - bullet_cat.error() << "invalid up-axis:" << _up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << std::endl; break; } diff --git a/panda/src/bullet/bulletCylinderShape.cxx b/panda/src/bullet/bulletCylinderShape.cxx index 6d107bff7a..976daac96e 100644 --- a/panda/src/bullet/bulletCylinderShape.cxx +++ b/panda/src/bullet/bulletCylinderShape.cxx @@ -13,6 +13,8 @@ #include "bulletCylinderShape.h" +using std::endl; + TypeHandle BulletCylinderShape::_type_handle; /** diff --git a/panda/src/bullet/bulletDebugNode.cxx b/panda/src/bullet/bulletDebugNode.cxx index 743b5163ff..ce0c044758 100644 --- a/panda/src/bullet/bulletDebugNode.cxx +++ b/panda/src/bullet/bulletDebugNode.cxx @@ -256,12 +256,12 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { trav->_geoms_pcollector.add_level(2); { CullableObject *object = - new CullableObject(move(debug_lines), RenderState::make_empty(), trav->get_scene()->get_cs_world_transform()); + new CullableObject(std::move(debug_lines), RenderState::make_empty(), trav->get_scene()->get_cs_world_transform()); trav->get_cull_handler()->record_object(object, trav); } { CullableObject *object = - new CullableObject(move(debug_triangles), RenderState::make_empty(), trav->get_scene()->get_cs_world_transform()); + new CullableObject(std::move(debug_triangles), RenderState::make_empty(), trav->get_scene()->get_cs_world_transform()); trav->get_cull_handler()->record_object(object, trav); } } @@ -300,7 +300,7 @@ getDebugMode() const { void BulletDebugNode::DebugDraw:: reportErrorWarning(const char *warning) { - bullet_cat.error() << warning << endl; + bullet_cat.error() << warning << std::endl; } /** @@ -381,7 +381,7 @@ drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, cons void BulletDebugNode::DebugDraw:: drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, const btVector3 &n0, const btVector3 &n1, const btVector3 &n2, const btVector3 &color, btScalar alpha) { - bullet_cat.debug() << "drawTriangle(2) - not yet implemented!" << endl; + bullet_cat.debug() << "drawTriangle(2) - not yet implemented!" << std::endl; } /** @@ -402,7 +402,7 @@ drawContactPoint(const btVector3 &point, const btVector3 &normal, btScalar dista void BulletDebugNode::DebugDraw:: draw3dText(const btVector3 &location, const char *text) { - bullet_cat.debug() << "draw3dText - not yet implemented!" << endl; + bullet_cat.debug() << "draw3dText - not yet implemented!" << std::endl; } /** diff --git a/panda/src/bullet/bulletHeightfieldShape.cxx b/panda/src/bullet/bulletHeightfieldShape.cxx index 6f5f0529e3..15e8d6f75f 100644 --- a/panda/src/bullet/bulletHeightfieldShape.cxx +++ b/panda/src/bullet/bulletHeightfieldShape.cxx @@ -89,7 +89,7 @@ BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up) : for (int row=0; row < _num_rows; row++) { for (int column=0; column < _num_cols; column++) { if (!peeker->lookup_bilinear(sample, row * step_x, column * step_y)) { - bullet_cat.error() << "Could not sample texture." << endl; + bullet_cat.error() << "Could not sample texture." << std::endl; } // Transpose _data[_num_rows * column + row] = max_height * sample.get_x(); diff --git a/panda/src/bullet/bulletMultiSphereShape.cxx b/panda/src/bullet/bulletMultiSphereShape.cxx index ffaed8bafb..52d1edc42f 100644 --- a/panda/src/bullet/bulletMultiSphereShape.cxx +++ b/panda/src/bullet/bulletMultiSphereShape.cxx @@ -23,7 +23,7 @@ TypeHandle BulletMultiSphereShape::_type_handle; BulletMultiSphereShape:: BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii) { - int num_spheres = min(points.size(), radii.size()); + int num_spheres = std::min(points.size(), radii.size()); // Convert points btVector3 *bt_points = new btVector3[num_spheres]; diff --git a/panda/src/bullet/bulletRigidBodyNode.cxx b/panda/src/bullet/bulletRigidBodyNode.cxx index ab8c4327f9..b0d36f705e 100644 --- a/panda/src/bullet/bulletRigidBodyNode.cxx +++ b/panda/src/bullet/bulletRigidBodyNode.cxx @@ -74,7 +74,7 @@ make_copy() const { * */ void BulletRigidBodyNode:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(BulletWorld::get_global_lock()); BulletBodyNode::do_output(out); diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index 546a73f311..4664ab75c5 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -207,7 +207,7 @@ transform_changed() { _soft->scale(new_scale); } - _sync = move(ts); + _sync = std::move(ts); } } diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 9286a2d010..34372e5130 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -17,6 +17,8 @@ #include "geomVertexData.h" #include "geomVertexReader.h" +using std::endl; + TypeHandle BulletTriangleMesh::_type_handle; /** @@ -237,7 +239,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState CPT(GeomVertexArrayData) vertices = prim->get_vertices(); if (vertices != nullptr) { - GeomVertexReader index(move(vertices), 0); + GeomVertexReader index(std::move(vertices), 0); while (!index.is_at_end()) { _indices.push_back(index_offset + index.get_data1i()); } @@ -280,7 +282,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState CPT(GeomVertexArrayData) vertices = prim->get_vertices(); if (vertices != nullptr) { - GeomVertexReader index(move(vertices), 0); + GeomVertexReader index(std::move(vertices), 0); while (!index.is_at_end()) { _indices.push_back(find_or_add_vertex(points[index.get_data1i()])); } @@ -351,7 +353,7 @@ add_array(const PTA_LVecBase3 &points, const PTA_int &indices, bool remove_dupli * */ void BulletTriangleMesh:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(BulletWorld::get_global_lock()); out << get_type() << ", " << _indices.size() / 3 << " triangles"; @@ -361,7 +363,7 @@ output(ostream &out) const { * */ void BulletTriangleMesh:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":" << endl; const IndexedMeshArray &array = _mesh.getIndexedMeshArray(); diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index ca9f7288cc..8416c52cbc 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -46,13 +46,13 @@ BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, b // Assert that mesh is not NULL if (!mesh) { - bullet_cat.warning() << "mesh is NULL! creating new mesh." << endl; + bullet_cat.warning() << "mesh is NULL! creating new mesh." << std::endl; mesh = new BulletTriangleMesh(); } // Assert that mesh has at least one triangle if (mesh->do_get_num_triangles() == 0) { - bullet_cat.warning() << "mesh has zero triangles! adding degenerated triangle." << endl; + bullet_cat.warning() << "mesh has zero triangles! adding degenerated triangle." << std::endl; mesh->add_triangle(LPoint3::zero(), LPoint3::zero(), LPoint3::zero()); } diff --git a/panda/src/bullet/bulletVehicle.cxx b/panda/src/bullet/bulletVehicle.cxx index 8d0f479dee..5575d6ff22 100644 --- a/panda/src/bullet/bulletVehicle.cxx +++ b/panda/src/bullet/bulletVehicle.cxx @@ -52,7 +52,7 @@ set_coordinate_system(BulletUpAxis up) { _vehicle->setCoordinateSystem(0, 2, 1); break; default: - bullet_cat.error() << "invalid up axis:" << up << endl; + bullet_cat.error() << "invalid up axis:" << up << std::endl; break; } } diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 6827140e93..e4c395267c 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -19,7 +19,12 @@ #include "collideMask.h" #include "lightMutexHolder.h" -#define clamp(x, x_min, x_max) max(min(x, x_max), x_min) +#define clamp(x, x_min, x_max) std::max(std::min(x, x_max), x_min) + +using std::endl; +using std::istream; +using std::ostream; +using std::string; TypeHandle BulletWorld::_type_handle; diff --git a/panda/src/bullet/config_bullet.cxx b/panda/src/bullet/config_bullet.cxx index 4e228427b9..5997bf575b 100644 --- a/panda/src/bullet/config_bullet.cxx +++ b/panda/src/bullet/config_bullet.cxx @@ -207,7 +207,7 @@ init_libbullet() { // Initialize notification category bullet_cat.init(); - bullet_cat.debug() << "initialize module" << endl; + bullet_cat.debug() << "initialize module" << std::endl; // Register the Bullet system PandaSystem *ps = PandaSystem::get_global_ptr(); diff --git a/panda/src/chan/animBundle.cxx b/panda/src/chan/animBundle.cxx index 312483b3be..8313516485 100644 --- a/panda/src/chan/animBundle.cxx +++ b/panda/src/chan/animBundle.cxx @@ -51,7 +51,7 @@ copy_bundle() const { * Writes a one-line description of the bundle. */ void AnimBundle:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name() << ", " << get_num_frames() << " frames at " << get_base_frame_rate() << " fps"; } diff --git a/panda/src/chan/animChannel.cxx b/panda/src/chan/animChannel.cxx index dfaf152b7b..d34d364068 100644 --- a/panda/src/chan/animChannel.cxx +++ b/panda/src/chan/animChannel.cxx @@ -22,7 +22,7 @@ template class AnimChannel; * Outputs a very brief description of a matrix. */ void ACMatrixSwitchType:: -output_value(ostream &out, const ACMatrixSwitchType::ValueType &value) { +output_value(std::ostream &out, const ACMatrixSwitchType::ValueType &value) { LVecBase3 scale, shear, hpr, translate; if (decompose_matrix(value, scale, shear, hpr, translate)) { if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { diff --git a/panda/src/chan/animChannelMatrixDynamic.cxx b/panda/src/chan/animChannelMatrixDynamic.cxx index 1fa762e782..53b2771685 100644 --- a/panda/src/chan/animChannelMatrixDynamic.cxx +++ b/panda/src/chan/animChannelMatrixDynamic.cxx @@ -49,7 +49,7 @@ AnimChannelMatrixDynamic(AnimGroup *parent, const AnimChannelMatrixDynamic © * */ AnimChannelMatrixDynamic:: -AnimChannelMatrixDynamic(const string &name) +AnimChannelMatrixDynamic(const std::string &name) : AnimChannelMatrix(name) { _value = TransformState::make_identity(); diff --git a/panda/src/chan/animChannelMatrixFixed.cxx b/panda/src/chan/animChannelMatrixFixed.cxx index cf79e7ea5a..d5f0ef3d84 100644 --- a/panda/src/chan/animChannelMatrixFixed.cxx +++ b/panda/src/chan/animChannelMatrixFixed.cxx @@ -34,7 +34,7 @@ AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©) : * */ AnimChannelMatrixFixed:: -AnimChannelMatrixFixed(const string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) : +AnimChannelMatrixFixed(const std::string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) : AnimChannel(name), _pos(pos), _hpr(hpr), _scale(scale) { @@ -116,7 +116,7 @@ get_shear(int, LVecBase3 &shear) { * */ void AnimChannelMatrixFixed:: -output(ostream &out) const { +output(std::ostream &out) const { AnimChannel::output(out); out << ": pos " << _pos << " hpr " << _hpr << " scale " << _scale; } diff --git a/panda/src/chan/animChannelMatrixXfmTable.cxx b/panda/src/chan/animChannelMatrixXfmTable.cxx index ec9564ee88..c6c27b8b7a 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.cxx +++ b/panda/src/chan/animChannelMatrixXfmTable.cxx @@ -54,7 +54,7 @@ AnimChannelMatrixXfmTable(AnimGroup *parent, const AnimChannelMatrixXfmTable &co * */ AnimChannelMatrixXfmTable:: -AnimChannelMatrixXfmTable(AnimGroup *parent, const string &name) +AnimChannelMatrixXfmTable(AnimGroup *parent, const std::string &name) : AnimChannelMatrix(parent, name) { for (int i = 0; i < num_matrix_components; i++) { @@ -267,7 +267,7 @@ clear_all_tables() { * Writes a brief description of the table and all of its descendants. */ void AnimChannelMatrixXfmTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " " << get_name() << " "; @@ -369,7 +369,7 @@ write_datagram(BamWriter *manager, Datagram &me) { // Now, write out the joint angles. For these we need to build up a HPR // array. pvector hprs; - int hprs_length = max(max(_tables[6].size(), _tables[7].size()), _tables[8].size()); + int hprs_length = std::max(std::max(_tables[6].size(), _tables[7].size()), _tables[8].size()); hprs.reserve(hprs_length); for (i = 0; i < hprs_length; i++) { PN_stdfloat h = _tables[6].empty() ? 0.0f : _tables[6][i % _tables[6].size()]; @@ -419,7 +419,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { if (!new_hpr) { // Convert between the old HPR form and the new HPR form. - size_t num_hprs = max(max(_tables[6].size(), _tables[7].size()), + size_t num_hprs = std::max(std::max(_tables[6].size(), _tables[7].size()), _tables[8].size()); LVecBase3 default_hpr(0.0, 0.0, 0.0); diff --git a/panda/src/chan/animChannelScalarDynamic.cxx b/panda/src/chan/animChannelScalarDynamic.cxx index a5597110ba..8a9835a550 100644 --- a/panda/src/chan/animChannelScalarDynamic.cxx +++ b/panda/src/chan/animChannelScalarDynamic.cxx @@ -51,7 +51,7 @@ AnimChannelScalarDynamic(AnimGroup *parent, const AnimChannelScalarDynamic © * */ AnimChannelScalarDynamic:: -AnimChannelScalarDynamic(const string &name) +AnimChannelScalarDynamic(const std::string &name) : AnimChannelScalar(name) { _last_value = _value = TransformState::make_identity(); diff --git a/panda/src/chan/animChannelScalarTable.cxx b/panda/src/chan/animChannelScalarTable.cxx index 195258b9c7..54953164e7 100644 --- a/panda/src/chan/animChannelScalarTable.cxx +++ b/panda/src/chan/animChannelScalarTable.cxx @@ -47,7 +47,7 @@ AnimChannelScalarTable(AnimGroup *parent, const AnimChannelScalarTable ©) : * */ AnimChannelScalarTable:: -AnimChannelScalarTable(AnimGroup *parent, const string &name) : +AnimChannelScalarTable(AnimGroup *parent, const std::string &name) : AnimChannelScalar(parent, name), _table(get_class_type()) { @@ -115,7 +115,7 @@ set_table(const CPTA_stdfloat &table) { * Writes a brief description of the table and all of its descendants. */ void AnimChannelScalarTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " " << get_name() << " " << _table.size(); diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index 34fd94646e..aa47ea7486 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -27,7 +27,7 @@ TypeHandle AnimControl::_type_handle; * being loaded during an asynchronous load-and-bind operation. */ AnimControl:: -AnimControl(const string &name, PartBundle *part, +AnimControl(const std::string &name, PartBundle *part, double frame_rate, int num_frames) : Namable(name), _pending_lock(name), @@ -131,7 +131,7 @@ wait_pending() { * binding, the event will be thrown immediately. */ void AnimControl:: -set_pending_done_event(const string &done_event) { +set_pending_done_event(const std::string &done_event) { MutexHolder holder(_pending_lock); _pending_done_event = done_event; if (!_pending) { @@ -143,7 +143,7 @@ set_pending_done_event(const string &done_event) { * Returns the event name that will be thrown when the AnimControl is finished * binding asynchronously. */ -string AnimControl:: +std::string AnimControl:: get_pending_done_event() const { MutexHolder holder(_pending_lock); return _pending_done_event; @@ -161,7 +161,7 @@ get_part() const { * */ void AnimControl:: -output(ostream &out) const { +output(std::ostream &out) const { out << "AnimControl(" << get_name() << ", " << get_part()->get_name() << ": "; AnimInterface::output(out); diff --git a/panda/src/chan/animControlCollection.cxx b/panda/src/chan/animControlCollection.cxx index 50783b5305..f8e6ed7b17 100644 --- a/panda/src/chan/animControlCollection.cxx +++ b/panda/src/chan/animControlCollection.cxx @@ -13,6 +13,8 @@ #include "animControlCollection.h" +using std::string; + /** * Returns the AnimControl associated with the given name, or NULL if no such @@ -252,7 +254,7 @@ which_anim_playing() const { * */ void AnimControlCollection:: -output(ostream &out) const { +output(std::ostream &out) const { out << _controls.size() << " anims."; } @@ -260,7 +262,7 @@ output(ostream &out) const { * */ void AnimControlCollection:: -write(ostream &out) const { +write(std::ostream &out) const { ControlsByName::const_iterator ci; for (ci = _controls_by_name.begin(); ci != _controls_by_name.end(); diff --git a/panda/src/chan/animGroup.cxx b/panda/src/chan/animGroup.cxx index 4c23b36110..17a83f1f20 100644 --- a/panda/src/chan/animGroup.cxx +++ b/panda/src/chan/animGroup.cxx @@ -24,6 +24,8 @@ #include +using std::string; + TypeHandle AnimGroup::_type_handle; @@ -179,7 +181,7 @@ get_value_type() const { * Writes a one-line description of the group. */ void AnimGroup:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name(); } @@ -187,7 +189,7 @@ output(ostream &out) const { * Writes a brief description of the group and all of its descendants. */ void AnimGroup:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this; if (!_children.empty()) { out << " {\n"; @@ -201,7 +203,7 @@ write(ostream &out, int indent_level) const { * Writes a brief description of all of the group's descendants. */ void AnimGroup:: -write_descendants(ostream &out, int indent_level) const { +write_descendants(std::ostream &out, int indent_level) const { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -277,7 +279,7 @@ complete_pointers(TypedWritable **p_list, BamReader *) { for (int i = 1; i < _num_children+1; i++) { if (p_list[i] == TypedWritable::Null) { chan_cat->warning() << get_type().get_name() - << " Ignoring null child" << endl; + << " Ignoring null child" << std::endl; } else { _children.push_back(DCAST(AnimGroup, p_list[i])); } diff --git a/panda/src/chan/animPreloadTable.cxx b/panda/src/chan/animPreloadTable.cxx index 9303c11490..43958482b3 100644 --- a/panda/src/chan/animPreloadTable.cxx +++ b/panda/src/chan/animPreloadTable.cxx @@ -60,7 +60,7 @@ get_num_anims() const { * Filename::get_basename_wo_extension(). */ int AnimPreloadTable:: -find_anim(const string &basename) const { +find_anim(const std::string &basename) const { consider_sort(); AnimRecord record; record._basename = basename; @@ -96,7 +96,7 @@ remove_anim(int n) { * See find_anim(). This will invalidate existing index numbers. */ void AnimPreloadTable:: -add_anim(const string &basename, PN_stdfloat base_frame_rate, int num_frames) { +add_anim(const std::string &basename, PN_stdfloat base_frame_rate, int num_frames) { AnimRecord record; record._basename = basename; record._base_frame_rate = base_frame_rate; @@ -124,7 +124,7 @@ add_anims_from(const AnimPreloadTable *other) { * */ void AnimPreloadTable:: -output(ostream &out) const { +output(std::ostream &out) const { consider_sort(); out << "AnimPreloadTable, " << _anims.size() << " animation records."; } @@ -133,7 +133,7 @@ output(ostream &out) const { * */ void AnimPreloadTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { consider_sort(); indent(out, indent_level) << "AnimPreloadTable, " << _anims.size() << " animation records:\n"; diff --git a/panda/src/chan/auto_bind.cxx b/panda/src/chan/auto_bind.cxx index e9e827b319..993201a8ef 100644 --- a/panda/src/chan/auto_bind.cxx +++ b/panda/src/chan/auto_bind.cxx @@ -18,6 +18,8 @@ #include "string_utils.h" #include "partGroup.h" +using std::string; + typedef pset AnimBundles; typedef pmap Anims; diff --git a/panda/src/chan/bindAnimRequest.cxx b/panda/src/chan/bindAnimRequest.cxx index c1b34038ff..637f44831d 100644 --- a/panda/src/chan/bindAnimRequest.cxx +++ b/panda/src/chan/bindAnimRequest.cxx @@ -22,7 +22,7 @@ TypeHandle BindAnimRequest::_type_handle; * */ BindAnimRequest:: -BindAnimRequest(const string &name, +BindAnimRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, Loader *loader, AnimControl *control, int hierarchy_match_flags, diff --git a/panda/src/chan/movingPartBase.cxx b/panda/src/chan/movingPartBase.cxx index cc60dabe3c..e4016edd2c 100644 --- a/panda/src/chan/movingPartBase.cxx +++ b/panda/src/chan/movingPartBase.cxx @@ -26,7 +26,7 @@ TypeHandle MovingPartBase::_type_handle; * */ MovingPartBase:: -MovingPartBase(PartGroup *parent, const string &name) : +MovingPartBase(PartGroup *parent, const std::string &name) : PartGroup(parent, name), _num_effective_channels(0), _effective_control(nullptr) @@ -70,7 +70,7 @@ get_forced_channel() const { * Writes a brief description of the channel and all of its descendants. */ void MovingPartBase:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_value_type() << " " << get_name(); if (_children.empty()) { out << "\n"; @@ -86,7 +86,7 @@ write(ostream &out, int indent_level) const { * with their values. */ void MovingPartBase:: -write_with_value(ostream &out, int indent_level) const { +write_with_value(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_value_type() << " " << get_name() << "\n"; indent(out, indent_level); output_value(out); diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index d2aa343774..dffed55d50 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -31,6 +31,10 @@ #include +using std::istream; +using std::ostream; +using std::string; + TypeHandle PartBundle::_type_handle; diff --git a/panda/src/chan/partGroup.cxx b/panda/src/chan/partGroup.cxx index ad501ca24c..52cee4ce19 100644 --- a/panda/src/chan/partGroup.cxx +++ b/panda/src/chan/partGroup.cxx @@ -25,6 +25,8 @@ #include +using std::ostream; + TypeHandle PartGroup::_type_handle; /** @@ -32,7 +34,7 @@ TypeHandle PartGroup::_type_handle; * to delete it subsequently is to delete the entire hierarchy. */ PartGroup:: -PartGroup(PartGroup *parent, const string &name) : +PartGroup(PartGroup *parent, const std::string &name) : Namable(name), _children(get_class_type()) { @@ -113,7 +115,7 @@ get_child(int n) const { * find_child(). */ PartGroup *PartGroup:: -get_child_named(const string &name) const { +get_child_named(const std::string &name) const { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { PartGroup *child = (*ci); @@ -131,7 +133,7 @@ get_child_named(const string &name) const { * this PartGroup; see also get_child_named(). */ PartGroup *PartGroup:: -find_child(const string &name) const { +find_child(const std::string &name) const { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { PartGroup *child = (*ci); diff --git a/panda/src/chan/partSubset.cxx b/panda/src/chan/partSubset.cxx index 6e88cce020..5e2a6c5831 100644 --- a/panda/src/chan/partSubset.cxx +++ b/panda/src/chan/partSubset.cxx @@ -89,7 +89,7 @@ append(const PartSubset &other) { * */ void PartSubset:: -output(ostream &out) const { +output(std::ostream &out) const { if (_include_joints.empty() && _exclude_joints.empty()) { out << "PartSubset, empty"; } else { @@ -120,7 +120,7 @@ is_include_empty() const { * false otherwise. */ bool PartSubset:: -matches_include(const string &joint_name) const { +matches_include(const std::string &joint_name) const { Joints::const_iterator ji; for (ji = _include_joints.begin(); ji != _include_joints.end(); ++ji) { if ((*ji).matches(joint_name)) { @@ -137,7 +137,7 @@ matches_include(const string &joint_name) const { * false otherwise. */ bool PartSubset:: -matches_exclude(const string &joint_name) const { +matches_exclude(const std::string &joint_name) const { Joints::const_iterator ji; for (ji = _exclude_joints.begin(); ji != _exclude_joints.end(); ++ji) { if ((*ji).matches(joint_name)) { diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index 8b5bac116a..0e2655de54 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -73,7 +73,7 @@ Character(const Character ©, bool copy_bundles) : * */ Character:: -Character(const string &name) : +Character(const std::string &name) : PartBundleNode(name, new CharacterJointBundle(name)), _joints_pcollector(PStatCollector(_animation_pcollector, name), "Joints"), _skinning_pcollector(PStatCollector(_animation_pcollector, name), "Vertices") @@ -355,7 +355,7 @@ clear_lod_animation() { * to a slider. */ CharacterJoint *Character:: -find_joint(const string &name) const { +find_joint(const std::string &name) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { PartGroup *part = get_bundle(i)->find_child(name); @@ -373,7 +373,7 @@ find_joint(const string &name) const { * to a joint. */ CharacterSlider *Character:: -find_slider(const string &name) const { +find_slider(const std::string &name) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { PartGroup *part = get_bundle(i)->find_child(name); @@ -391,7 +391,7 @@ find_slider(const string &name) const { * structure, to the indicated output stream. */ void Character:: -write_parts(ostream &out) const { +write_parts(std::ostream &out) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { get_bundle(i)->write(out, 0); @@ -404,7 +404,7 @@ write_parts(ostream &out) const { * stream. */ void Character:: -write_part_values(ostream &out) const { +write_part_values(std::ostream &out) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { get_bundle(i)->write_with_value(out, 0); @@ -671,7 +671,7 @@ r_merge_bundles(Character::JointMap &joint_map, int new_num_children = new_group->get_num_children(); PartGroup::Children new_children(PartGroup::get_class_type()); - new_children.reserve(max(old_num_children, new_num_children)); + new_children.reserve(std::max(old_num_children, new_num_children)); while (i < old_num_children && j < new_num_children) { PartGroup *pc = old_group->get_child(i); diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index 8a424d91c1..7e3e1c9b9a 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -50,7 +50,7 @@ CharacterJoint(const CharacterJoint ©) : */ CharacterJoint:: CharacterJoint(Character *character, - PartBundle *root, PartGroup *parent, const string &name, + PartBundle *root, PartGroup *parent, const std::string &name, const LMatrix4 &default_value) : MovingPartMatrix(parent, name, default_value), _character(character) diff --git a/panda/src/char/characterJointBundle.cxx b/panda/src/char/characterJointBundle.cxx index 980e9058dc..86a43f7e13 100644 --- a/panda/src/char/characterJointBundle.cxx +++ b/panda/src/char/characterJointBundle.cxx @@ -24,7 +24,7 @@ TypeHandle CharacterJointBundle::_type_handle; * Character node will automatically create one for itself. */ CharacterJointBundle:: -CharacterJointBundle(const string &name) : PartBundle(name) { +CharacterJointBundle(const std::string &name) : PartBundle(name) { } /** diff --git a/panda/src/char/characterJointEffect.cxx b/panda/src/char/characterJointEffect.cxx index 50b1a878e8..b4bc263c20 100644 --- a/panda/src/char/characterJointEffect.cxx +++ b/panda/src/char/characterJointEffect.cxx @@ -87,7 +87,7 @@ safe_to_combine() const { * */ void CharacterJointEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); PT(Character) character = get_character(); if (character != nullptr) { diff --git a/panda/src/char/characterSlider.cxx b/panda/src/char/characterSlider.cxx index 824b7e2737..b4ced5e782 100644 --- a/panda/src/char/characterSlider.cxx +++ b/panda/src/char/characterSlider.cxx @@ -40,7 +40,7 @@ CharacterSlider(const CharacterSlider ©) : * */ CharacterSlider:: -CharacterSlider(PartGroup *parent, const string &name) +CharacterSlider(PartGroup *parent, const std::string &name) : MovingPartScalar(parent, name) { } diff --git a/panda/src/char/jointVertexTransform.cxx b/panda/src/char/jointVertexTransform.cxx index 5212aa6cd9..5f60777ff1 100644 --- a/panda/src/char/jointVertexTransform.cxx +++ b/panda/src/char/jointVertexTransform.cxx @@ -83,7 +83,7 @@ accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { * */ void JointVertexTransform:: -output(ostream &out) const { +output(std::ostream &out) const { out << _joint->get_name(); } diff --git a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm index 07f44b6c94..f45837ed87 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm @@ -25,7 +25,7 @@ TypeHandle CocoaGraphicsBuffer::_type_handle; */ CocoaGraphicsBuffer:: CocoaGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm index dd554e2a77..91bd0fbbb9 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm @@ -169,7 +169,7 @@ CocoaGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string CocoaGraphicsPipe:: +std::string CocoaGraphicsPipe:: get_interface_name() const { return "OpenGL"; } @@ -199,7 +199,7 @@ CocoaGraphicsPipe::get_preferred_window_thread() const { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) CocoaGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index ec25b94486..26d4dbdf71 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm @@ -190,7 +190,7 @@ choose_pixel_format(const FrameBufferProperties &properties, // make it grab one with 8 bits, though. Dirty hack. Needs more research. if (properties.get_alpha_bits() > 0) { attribs.push_back(NSOpenGLPFAAlphaSize); - attribs.push_back(max(8, properties.get_alpha_bits())); + attribs.push_back(std::max(8, properties.get_alpha_bits())); } if (properties.get_multisamples() > 0) { diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index df12a69985..7d461817f1 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -50,7 +50,7 @@ TypeHandle CocoaGraphicsWindow::_type_handle; */ CocoaGraphicsWindow:: CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -1293,7 +1293,7 @@ load_image(const Filename &filename) { if (vfile == NULL) { return nil; } - istream *str = vfile->open_read_file(true); + std::istream *str = vfile->open_read_file(true); if (str == NULL) { cocoadisplay_cat.error() << "Could not open file " << filename << " for reading\n"; @@ -1449,7 +1449,7 @@ handle_foreground_event(bool foreground) { */ bool CocoaGraphicsWindow:: handle_close_request() { - string close_request_event = get_close_request_event(); + std::string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { // In this case, the app has indicated a desire to intercept the request // and process it directly. diff --git a/panda/src/collada/colladaBindMaterial.cxx b/panda/src/collada/colladaBindMaterial.cxx index 2ef46e4a99..90ea8a21cf 100644 --- a/panda/src/collada/colladaBindMaterial.cxx +++ b/panda/src/collada/colladaBindMaterial.cxx @@ -48,7 +48,7 @@ get_material(const ColladaPrimitive *prim) const { * found. */ CPT(RenderState) ColladaBindMaterial:: -get_material(const string &symbol) const { +get_material(const std::string &symbol) const { if (_states.count(symbol) == 0) { return nullptr; } diff --git a/panda/src/collada/colladaInput.cxx b/panda/src/collada/colladaInput.cxx index be6522b23f..09ce788655 100644 --- a/panda/src/collada/colladaInput.cxx +++ b/panda/src/collada/colladaInput.cxx @@ -37,7 +37,7 @@ * Pretty obvious what this does. */ ColladaInput:: -ColladaInput(const string &semantic) : +ColladaInput(const std::string &semantic) : _column_name (nullptr), _semantic (semantic), _offset (0), @@ -69,14 +69,14 @@ ColladaInput(const string &semantic) : * Pretty obvious what this does. */ ColladaInput:: -ColladaInput(const string &semantic, unsigned int set) : +ColladaInput(const std::string &semantic, unsigned int set) : _column_name (nullptr), _semantic (semantic), _offset (0), _have_set (true), _set (set) { - ostringstream setstr; + std::ostringstream setstr; setstr << _set; if (semantic == "POSITION") { diff --git a/panda/src/collada/colladaLoader.cxx b/panda/src/collada/colladaLoader.cxx index 7414af0a7f..1347d492a1 100644 --- a/panda/src/collada/colladaLoader.cxx +++ b/panda/src/collada/colladaLoader.cxx @@ -76,7 +76,7 @@ bool ColladaLoader:: read(const Filename &filename) { _filename = filename; - string data; + std::string data; VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); if (!vfs->read_file(_filename, data, true)) { @@ -299,7 +299,7 @@ load_tags(domExtra &extra, PandaNode *node) { daeElement &child = *children[c]; if (cmp_nocase(child.getElementName(), "tag") == 0) { - const string &name = child.getAttribute("name"); + const std::string &name = child.getAttribute("name"); if (name.size() > 0) { node->set_tag(name, child.getCharData()); } else { diff --git a/panda/src/collada/loaderFileTypeDae.cxx b/panda/src/collada/loaderFileTypeDae.cxx index 9fc5785514..a35223f30c 100644 --- a/panda/src/collada/loaderFileTypeDae.cxx +++ b/panda/src/collada/loaderFileTypeDae.cxx @@ -26,7 +26,7 @@ LoaderFileTypeDae() { /** * */ -string LoaderFileTypeDae:: +std::string LoaderFileTypeDae:: get_name() const { #if PANDA_COLLADA_VERSION == 14 return "COLLADA 1.4"; @@ -40,7 +40,7 @@ get_name() const { /** * */ -string LoaderFileTypeDae:: +std::string LoaderFileTypeDae:: get_extension() const { return "dae"; } @@ -49,7 +49,7 @@ get_extension() const { * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this loader. */ -string LoaderFileTypeDae:: +std::string LoaderFileTypeDae:: get_additional_extensions() const { return "zae"; } diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index ad025f8682..46666722e2 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -35,6 +35,9 @@ #include +using std::max; +using std::min; + PStatCollector CollisionBox::_volume_pcollector("Collision Volumes:CollisionBox"); PStatCollector CollisionBox::_test_pcollector("Collision Tests:CollisionBox"); TypeHandle CollisionBox::_type_handle; @@ -181,7 +184,7 @@ get_test_pcollector() { * */ void CollisionBox:: -output(ostream &out) const { +output(std::ostream &out) const { } /** diff --git a/panda/src/collide/collisionEntry.cxx b/panda/src/collide/collisionEntry.cxx index 237c725579..2a8c97fa2c 100644 --- a/panda/src/collide/collisionEntry.cxx +++ b/panda/src/collide/collisionEntry.cxx @@ -209,7 +209,7 @@ get_all_contact_info(const NodePath &space, LPoint3 &contact_pos, * */ void CollisionEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << _from_node_path; if (!_into_node_path.is_empty()) { out << " into " << _into_node_path; @@ -223,7 +223,7 @@ output(ostream &out) const { * */ void CollisionEntry:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "CollisionEntry:\n"; if (!_from_node_path.is_empty()) { diff --git a/panda/src/collide/collisionFloorMesh.cxx b/panda/src/collide/collisionFloorMesh.cxx index fa7ac93949..5f0ab0cabc 100644 --- a/panda/src/collide/collisionFloorMesh.cxx +++ b/panda/src/collide/collisionFloorMesh.cxx @@ -33,6 +33,10 @@ #include "geomLinestrips.h" #include "geomVertexWriter.h" #include + +using std::max; +using std::min; + PStatCollector CollisionFloorMesh::_volume_pcollector("Collision Volumes:CollisionFloorMesh"); PStatCollector CollisionFloorMesh::_test_pcollector("Collision Tests:CollisionFloorMesh"); TypeHandle CollisionFloorMesh::_type_handle; @@ -86,7 +90,7 @@ get_collision_origin() const { * */ void CollisionFloorMesh:: -output(ostream &out) const { +output(std::ostream &out) const { out << "cfloor"; } @@ -406,7 +410,7 @@ register_with_read_factory() { * */ void CollisionFloorMesh:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; } diff --git a/panda/src/collide/collisionGeom.cxx b/panda/src/collide/collisionGeom.cxx index 15211b9598..b90bebe38b 100644 --- a/panda/src/collide/collisionGeom.cxx +++ b/panda/src/collide/collisionGeom.cxx @@ -47,6 +47,6 @@ get_test_pcollector() { * */ void CollisionGeom:: -output(ostream &out) const { +output(std::ostream &out) const { out << "cgeom"; } diff --git a/panda/src/collide/collisionHandlerEvent.cxx b/panda/src/collide/collisionHandlerEvent.cxx index 872044bb22..0fd949074e 100644 --- a/panda/src/collide/collisionHandlerEvent.cxx +++ b/panda/src/collide/collisionHandlerEvent.cxx @@ -17,6 +17,8 @@ #include "eventParameter.h" #include "throw_event.h" +using std::string; + TypeHandle CollisionHandlerEvent::_type_handle; diff --git a/panda/src/collide/collisionHandlerFloor.cxx b/panda/src/collide/collisionHandlerFloor.cxx index 3c8c8e80bf..506101cb41 100644 --- a/panda/src/collide/collisionHandlerFloor.cxx +++ b/panda/src/collide/collisionHandlerFloor.cxx @@ -18,6 +18,9 @@ #include "clockObject.h" +using std::cout; +using std::endl; + TypeHandle CollisionHandlerFloor::_type_handle; /** @@ -204,7 +207,7 @@ handle_entries() { if (adjust < 0.0f && _max_velocity != 0.0f) { PN_stdfloat max_adjust = _max_velocity * ClockObject::get_global_clock()->get_dt(); - adjust = max(adjust, -max_adjust); + adjust = std::max(adjust, -max_adjust); } CPT(TransformState) trans = def._target.get_transform(); diff --git a/panda/src/collide/collisionHandlerGravity.cxx b/panda/src/collide/collisionHandlerGravity.cxx index 42a52a54b6..023d220cd4 100644 --- a/panda/src/collide/collisionHandlerGravity.cxx +++ b/panda/src/collide/collisionHandlerGravity.cxx @@ -18,6 +18,9 @@ #include "collisionPlane.h" #include "clockObject.h" +using std::cout; +using std::endl; + TypeHandle CollisionHandlerGravity::_type_handle; /** @@ -254,10 +257,10 @@ handle_entries() { // ...the node is under the floor, so it has landed. Keep the // adjust to bring us up to the ground and then add the // gravity_adjust to get us airborne: - adjust += max((PN_stdfloat)0.0, gravity_adjust); + adjust += std::max((PN_stdfloat)0.0, gravity_adjust); } else { // ...the node is above the floor, so it is airborne. - adjust = max(adjust, gravity_adjust); + adjust = std::max(adjust, gravity_adjust); } _current_velocity -= _gravity * dt; // Record the airborne height in case someone else needs it: diff --git a/panda/src/collide/collisionHandlerQueue.cxx b/panda/src/collide/collisionHandlerQueue.cxx index 7a2fefd271..75761362bd 100644 --- a/panda/src/collide/collisionHandlerQueue.cxx +++ b/panda/src/collide/collisionHandlerQueue.cxx @@ -126,7 +126,7 @@ get_entry(int n) const { * */ void CollisionHandlerQueue:: -output(ostream &out) const { +output(std::ostream &out) const { out << "CollisionHandlerQueue, " << _entries.size() << " entries"; } @@ -134,7 +134,7 @@ output(ostream &out) const { * */ void CollisionHandlerQueue:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "CollisionHandlerQueue, " << _entries.size() << " entries:\n"; diff --git a/panda/src/collide/collisionInvSphere.cxx b/panda/src/collide/collisionInvSphere.cxx index 2074fb9522..8a75135e55 100644 --- a/panda/src/collide/collisionInvSphere.cxx +++ b/panda/src/collide/collisionInvSphere.cxx @@ -72,7 +72,7 @@ get_test_pcollector() { * */ void CollisionInvSphere:: -output(ostream &out) const { +output(std::ostream &out) const { out << "invsphere, c (" << get_center() << "), r " << get_radius(); } @@ -198,7 +198,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { t1 = t2 = 0.0; } - t2 = max(t2, 0.0); + t2 = std::max(t2, 0.0); if (collide_cat.is_debug()) { collide_cat.debug() @@ -254,11 +254,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } else if (t2 <= 1.0) { // The bottom edge of the segment intersects the shell. - t = min(t2, 1.0); + t = std::min(t2, 1.0); } else if (t1 >= 0.0) { // The top edge of the segment intersects the shell. - t = max(t1, 0.0); + t = std::max(t1, 0.0); } else { // Neither edge of the segment intersects the shell. It follows that both diff --git a/panda/src/collide/collisionLine.cxx b/panda/src/collide/collisionLine.cxx index 5e98087145..27b066b3c9 100644 --- a/panda/src/collide/collisionLine.cxx +++ b/panda/src/collide/collisionLine.cxx @@ -51,7 +51,7 @@ test_intersection(const CollisionEntry &entry) const { * */ void CollisionLine:: -output(ostream &out) const { +output(std::ostream &out) const { out << "line, o (" << get_origin() << "), d (" << get_direction() << ")"; } diff --git a/panda/src/collide/collisionNode.cxx b/panda/src/collide/collisionNode.cxx index 803a5f058d..ce037f917f 100644 --- a/panda/src/collide/collisionNode.cxx +++ b/panda/src/collide/collisionNode.cxx @@ -37,7 +37,7 @@ TypeHandle CollisionNode::_type_handle; * */ CollisionNode:: -CollisionNode(const string &name) : +CollisionNode(const std::string &name) : PandaNode(name), _from_collide_mask(get_default_collide_mask()), _collider_sort(0) @@ -252,7 +252,7 @@ is_collision_node() const { * classes to include some information relevant to the class. */ void CollisionNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out << " (" << _solids.size() << " solids)"; } diff --git a/panda/src/collide/collisionParabola.cxx b/panda/src/collide/collisionParabola.cxx index 734647b16c..b439440228 100644 --- a/panda/src/collide/collisionParabola.cxx +++ b/panda/src/collide/collisionParabola.cxx @@ -90,7 +90,7 @@ get_test_pcollector() { * */ void CollisionParabola:: -output(ostream &out) const { +output(std::ostream &out) const { out << _parabola << ", t1 = " << _t1 << ", t2 = " << _t2; } @@ -145,8 +145,8 @@ compute_internal_bounds() const { for (int i = 0; i < num_points; ++i) { double t = (double)(i + 1) / (double)(num_points + 1); LPoint3 p = psp.calc_point(get_t1() + t * (get_t2() - get_t1())); - min_z = min(min_z, p[2]); - max_z = max(max_z, p[2]); + min_z = std::min(min_z, p[2]); + max_z = std::max(max_z, p[2]); } // That gives us a simple bounding volume in parabola space. diff --git a/panda/src/collide/collisionPlane.cxx b/panda/src/collide/collisionPlane.cxx index f869f6c2d1..8a325ea082 100644 --- a/panda/src/collide/collisionPlane.cxx +++ b/panda/src/collide/collisionPlane.cxx @@ -89,7 +89,7 @@ get_test_pcollector() { * */ void CollisionPlane:: -output(ostream &out) const { +output(std::ostream &out) const { out << "cplane, (" << _plane << ")"; } @@ -397,7 +397,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { if (t2 >= parabola->get_t1() && t2 <= parabola->get_t2()) { // Both intersection points are within our segment of the parabola. // Choose the first of the two. - t = min(t1, t2); + t = std::min(t1, t2); } else { // Only t1 is within our segment. t = t1; diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index 2e907c0695..25dc01d272 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -41,6 +41,9 @@ #include +using std::max; +using std::min; + PStatCollector CollisionPolygon::_volume_pcollector("Collision Volumes:CollisionPolygon"); PStatCollector CollisionPolygon::_test_pcollector("Collision Tests:CollisionPolygon"); TypeHandle CollisionPolygon::_type_handle; @@ -296,7 +299,7 @@ get_test_pcollector() { * */ void CollisionPolygon:: -output(ostream &out) const { +output(std::ostream &out) const { out << "cpolygon, (" << get_plane() << "), " << _points.size() << " vertices"; } @@ -305,7 +308,7 @@ output(ostream &out) const { * */ void CollisionPolygon:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; Points::const_iterator pi; for (pi = _points.begin(); pi != _points.end(); ++pi) { diff --git a/panda/src/collide/collisionRay.cxx b/panda/src/collide/collisionRay.cxx index 05aa445aa1..9cbf9223fe 100644 --- a/panda/src/collide/collisionRay.cxx +++ b/panda/src/collide/collisionRay.cxx @@ -72,7 +72,7 @@ get_collision_origin() const { * */ void CollisionRay:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ray, o (" << get_origin() << "), d (" << get_direction() << ")"; } diff --git a/panda/src/collide/collisionRecorder.cxx b/panda/src/collide/collisionRecorder.cxx index 45580e97f1..9abd0814a7 100644 --- a/panda/src/collide/collisionRecorder.cxx +++ b/panda/src/collide/collisionRecorder.cxx @@ -42,7 +42,7 @@ CollisionRecorder:: * */ void CollisionRecorder:: -output(ostream &out) const { +output(std::ostream &out) const { out << "tested " << _num_missed + _num_detected << ", detected " << _num_detected << "\n"; } diff --git a/panda/src/collide/collisionSegment.cxx b/panda/src/collide/collisionSegment.cxx index 3fa0fe0524..802259b338 100644 --- a/panda/src/collide/collisionSegment.cxx +++ b/panda/src/collide/collisionSegment.cxx @@ -75,7 +75,7 @@ get_collision_origin() const { * */ void CollisionSegment:: -output(ostream &out) const { +output(std::ostream &out) const { out << "segment, a (" << _a << "), b (" << _b << ")"; } diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index f812c836f2..0e83c647de 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -174,7 +174,7 @@ get_test_pcollector() { * */ void CollisionSolid:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -182,7 +182,7 @@ output(ostream &out) const { * */ void CollisionSolid:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; } diff --git a/panda/src/collide/collisionSphere.cxx b/panda/src/collide/collisionSphere.cxx index 898fbd86c6..a07b1fbcbc 100644 --- a/panda/src/collide/collisionSphere.cxx +++ b/panda/src/collide/collisionSphere.cxx @@ -33,6 +33,9 @@ #include "geomTristrips.h" #include "geomVertexWriter.h" +using std::max; +using std::min; + PStatCollector CollisionSphere::_volume_pcollector( "Collision Volumes:CollisionSphere"); PStatCollector CollisionSphere::_test_pcollector( @@ -102,7 +105,7 @@ get_test_pcollector() { * */ void CollisionSphere:: -output(ostream &out) const { +output(std::ostream &out) const { out << "sphere, c (" << get_center() << "), r " << get_radius(); } diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index 65f33cba31..6e8a01d68f 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -38,6 +38,8 @@ #include +using std::min; + PStatCollector CollisionTraverser::_collisions_pcollector("App:Collisions"); PStatCollector CollisionTraverser::_cnode_volume_pcollector("Collision Volumes:CollisionNode"); @@ -67,7 +69,7 @@ public: * */ CollisionTraverser:: -CollisionTraverser(const string &name) : +CollisionTraverser(const std::string &name) : Namable(name), _this_pcollector(_collisions_pcollector, name) { @@ -421,7 +423,7 @@ hide_collisions() { * */ void CollisionTraverser:: -output(ostream &out) const { +output(std::ostream &out) const { out << "CollisionTraverser, " << _colliders.size() << " colliders and " << _handlers.size() << " handlers.\n"; } @@ -430,7 +432,7 @@ output(ostream &out) const { * */ void CollisionTraverser:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "CollisionTraverser, " << _colliders.size() << " colliders and " << _handlers.size() << " handlers:\n"; @@ -1389,7 +1391,7 @@ PStatCollector &CollisionTraverser:: get_pass_collector(int pass) { nassertr(pass >= 0, _this_pcollector); while ((int)_pass_collectors.size() <= pass) { - ostringstream name; + std::ostringstream name; name << "pass" << (_pass_collectors.size() + 1); PStatCollector col(_this_pcollector, name.str()); _pass_collectors.push_back(col); diff --git a/panda/src/collide/collisionTube.cxx b/panda/src/collide/collisionTube.cxx index b84e308395..174935368e 100644 --- a/panda/src/collide/collisionTube.cxx +++ b/panda/src/collide/collisionTube.cxx @@ -104,7 +104,7 @@ get_test_pcollector() { * */ void CollisionTube:: -output(ostream &out) const { +output(std::ostream &out) const { out << "tube, a (" << _a << "), b (" << _b << "), r " << _radius; } @@ -183,7 +183,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } // doubles, not floats, to satisfy min and max templates. - actual_t = min(1.0, max(0.0, t1)); + actual_t = std::min(1.0, std::max(0.0, t1)); contact_point = from_a + actual_t * (from_b - from_a); if (collide_cat.is_debug()) { @@ -824,7 +824,7 @@ intersects_parabola(double &t, const LParabola ¶bola, return false; } - t = max(t1a, 0.0); + t = std::max(t1a, 0.0); return true; } diff --git a/panda/src/collide/collisionVisualizer.cxx b/panda/src/collide/collisionVisualizer.cxx index 0c7861b5eb..0cebbeffdf 100644 --- a/panda/src/collide/collisionVisualizer.cxx +++ b/panda/src/collide/collisionVisualizer.cxx @@ -41,7 +41,7 @@ TypeHandle CollisionVisualizer::_type_handle; * */ CollisionVisualizer:: -CollisionVisualizer(const string &name) : PandaNode(name), _lock("CollisionVisualizer") { +CollisionVisualizer(const std::string &name) : PandaNode(name), _lock("CollisionVisualizer") { set_cull_callback(); // We always want to render the CollisionVisualizer node itself (even if it @@ -263,7 +263,7 @@ is_renderable() const { * classes to include some information relevant to the class. */ void CollisionVisualizer:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out << " "; CollisionRecorder::output(out); @@ -296,9 +296,9 @@ collision_tested(const CollisionEntry &entry, bool detected) { nassertv(!solid.is_null()); LightMutexHolder holder(_lock); - VizInfo &viz_info = _data[move(net_transform)]; + VizInfo &viz_info = _data[std::move(net_transform)]; if (detected) { - viz_info._solids[move(solid)]._detected_count++; + viz_info._solids[std::move(solid)]._detected_count++; if (entry.has_surface_point()) { CollisionPoint p; @@ -308,7 +308,7 @@ collision_tested(const CollisionEntry &entry, bool detected) { } } else { - viz_info._solids[move(solid)]._missed_count++; + viz_info._solids[std::move(solid)]._missed_count++; } } diff --git a/panda/src/cull/cullBinBackToFront.cxx b/panda/src/cull/cullBinBackToFront.cxx index 99da6cf5ac..00c6ba7c32 100644 --- a/panda/src/cull/cullBinBackToFront.cxx +++ b/panda/src/cull/cullBinBackToFront.cxx @@ -39,7 +39,7 @@ CullBinBackToFront:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinBackToFront:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinBackToFront(name, gsg, draw_region_pcollector); } diff --git a/panda/src/cull/cullBinFixed.cxx b/panda/src/cull/cullBinFixed.cxx index e3e5637ad9..557b3435a3 100644 --- a/panda/src/cull/cullBinFixed.cxx +++ b/panda/src/cull/cullBinFixed.cxx @@ -39,7 +39,7 @@ CullBinFixed:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinFixed:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinFixed(name, gsg, draw_region_pcollector); } diff --git a/panda/src/cull/cullBinFrontToBack.cxx b/panda/src/cull/cullBinFrontToBack.cxx index 4d297d1c94..4337b42d7c 100644 --- a/panda/src/cull/cullBinFrontToBack.cxx +++ b/panda/src/cull/cullBinFrontToBack.cxx @@ -39,7 +39,7 @@ CullBinFrontToBack:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinFrontToBack:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinFrontToBack(name, gsg, draw_region_pcollector); } diff --git a/panda/src/cull/cullBinStateSorted.cxx b/panda/src/cull/cullBinStateSorted.cxx index 04890af48c..ad4d26cd12 100644 --- a/panda/src/cull/cullBinStateSorted.cxx +++ b/panda/src/cull/cullBinStateSorted.cxx @@ -38,7 +38,7 @@ CullBinStateSorted:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinStateSorted:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinStateSorted(name, gsg, draw_region_pcollector); } diff --git a/panda/src/cull/cullBinUnsorted.cxx b/panda/src/cull/cullBinUnsorted.cxx index 4ef8c35ae6..14766f9bbd 100644 --- a/panda/src/cull/cullBinUnsorted.cxx +++ b/panda/src/cull/cullBinUnsorted.cxx @@ -35,7 +35,7 @@ CullBinUnsorted:: * Factory constructor for passing to the CullBinManager. */ CullBin *CullBinUnsorted:: -make_bin(const string &name, GraphicsStateGuardianBase *gsg, +make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinUnsorted(name, gsg, draw_region_pcollector); } diff --git a/panda/src/device/analogNode.cxx b/panda/src/device/analogNode.cxx index 4f331c7bae..59e57f4179 100644 --- a/panda/src/device/analogNode.cxx +++ b/panda/src/device/analogNode.cxx @@ -23,7 +23,7 @@ TypeHandle AnalogNode::_type_handle; * */ AnalogNode:: -AnalogNode(ClientBase *client, const string &device_name) : +AnalogNode(ClientBase *client, const std::string &device_name) : DataNode(device_name) { _xy_output = define_output("xy", EventStoreVec2::get_class_type()); @@ -63,7 +63,7 @@ AnalogNode:: * */ void AnalogNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { DataNode::write(out, indent_level); if (_analog != nullptr) { diff --git a/panda/src/device/buttonNode.cxx b/panda/src/device/buttonNode.cxx index e2bb18eeee..67803cf658 100644 --- a/panda/src/device/buttonNode.cxx +++ b/panda/src/device/buttonNode.cxx @@ -23,7 +23,7 @@ TypeHandle ButtonNode::_type_handle; * */ ButtonNode:: -ButtonNode(ClientBase *client, const string &device_name) : +ButtonNode(ClientBase *client, const std::string &device_name) : DataNode(device_name) { _button_events_output = define_output("button_events", ButtonEventList::get_class_type()); @@ -63,7 +63,7 @@ ButtonNode:: * */ void ButtonNode:: -output(ostream &out) const { +output(std::ostream &out) const { DataNode::output(out); if (_button != nullptr) { @@ -79,7 +79,7 @@ output(ostream &out) const { * */ void ButtonNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { DataNode::write(out, indent_level); if (_button != nullptr) { diff --git a/panda/src/device/clientAnalogDevice.cxx b/panda/src/device/clientAnalogDevice.cxx index 47ddde620b..eb9c72ee06 100644 --- a/panda/src/device/clientAnalogDevice.cxx +++ b/panda/src/device/clientAnalogDevice.cxx @@ -37,7 +37,7 @@ ensure_control_index(int index) { * */ void ClientAnalogDevice:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " " << get_device_name() << ":\n"; write_controls(out, indent_level + 2); } @@ -46,7 +46,7 @@ write(ostream &out, int indent_level) const { * Writes a multi-line description of the current analog control states. */ void ClientAnalogDevice:: -write_controls(ostream &out, int indent_level) const { +write_controls(std::ostream &out, int indent_level) const { bool any_controls = false; Controls::const_iterator ai; for (ai = _controls.begin(); ai != _controls.end(); ++ai) { diff --git a/panda/src/device/clientBase.cxx b/panda/src/device/clientBase.cxx index 2ad270b81b..b7c6c3347c 100644 --- a/panda/src/device/clientBase.cxx +++ b/panda/src/device/clientBase.cxx @@ -85,7 +85,7 @@ fork_asynchronous_thread(double poll_time) { if (device_cat.is_debug()) { device_cat.debug() << "fork_asynchronous_thread() - forking client thread" - << endl; + << std::endl; } return true; } @@ -113,7 +113,7 @@ fork_asynchronous_thread(double poll_time) { * NULL is returned. */ PT(ClientDevice) ClientBase:: -get_device(TypeHandle device_type, const string &device_name) { +get_device(TypeHandle device_type, const std::string &device_name) { DevicesByName &dbn = _devices[device_type]; DevicesByName::iterator dbni; @@ -143,7 +143,7 @@ get_device(TypeHandle device_type, const string &device_name) { * unknown (e.g. it was disconnected previously). */ bool ClientBase:: -disconnect_device(TypeHandle device_type, const string &device_name, +disconnect_device(TypeHandle device_type, const std::string &device_name, ClientDevice *device) { DevicesByName &dbn = _devices[device_type]; diff --git a/panda/src/device/clientButtonDevice.cxx b/panda/src/device/clientButtonDevice.cxx index 60952f6a2c..27451c2887 100644 --- a/panda/src/device/clientButtonDevice.cxx +++ b/panda/src/device/clientButtonDevice.cxx @@ -15,13 +15,15 @@ #include "indent.h" +using std::ostream; + TypeHandle ClientButtonDevice::_type_handle; /** * */ ClientButtonDevice:: -ClientButtonDevice(ClientBase *client, const string &device_name): +ClientButtonDevice(ClientBase *client, const std::string &device_name): ClientDevice(client, get_class_type(), device_name) { _button_events = new ButtonEventList(); diff --git a/panda/src/device/clientDevice.cxx b/panda/src/device/clientDevice.cxx index f6bca213e5..6da404eca4 100644 --- a/panda/src/device/clientDevice.cxx +++ b/panda/src/device/clientDevice.cxx @@ -23,7 +23,7 @@ TypeHandle ClientDevice::_type_handle; */ ClientDevice:: ClientDevice(ClientBase *client, TypeHandle device_type, - const string &device_name) : + const std::string &device_name) : _client(client), _device_type(device_type), _device_name(device_name) @@ -87,7 +87,7 @@ poll() { * */ void ClientDevice:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_device_name(); } @@ -95,6 +95,6 @@ output(ostream &out) const { * */ void ClientDevice:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/device/dialNode.cxx b/panda/src/device/dialNode.cxx index 86fa011908..04f46a7805 100644 --- a/panda/src/device/dialNode.cxx +++ b/panda/src/device/dialNode.cxx @@ -22,7 +22,7 @@ TypeHandle DialNode::_type_handle; * */ DialNode:: -DialNode(ClientBase *client, const string &device_name) : +DialNode(ClientBase *client, const std::string &device_name) : DataNode(device_name) { nassertv(client != nullptr); diff --git a/panda/src/device/mouseAndKeyboard.cxx b/panda/src/device/mouseAndKeyboard.cxx index 4a431c5e5e..4a8e599afe 100644 --- a/panda/src/device/mouseAndKeyboard.cxx +++ b/panda/src/device/mouseAndKeyboard.cxx @@ -24,7 +24,7 @@ TypeHandle MouseAndKeyboard::_type_handle; * */ MouseAndKeyboard:: -MouseAndKeyboard(GraphicsWindow *window, int device, const string &name) : +MouseAndKeyboard(GraphicsWindow *window, int device, const std::string &name) : DataNode(name), _window(window), _device(device) diff --git a/panda/src/device/trackerNode.cxx b/panda/src/device/trackerNode.cxx index cf4a8d0f01..0ec33af92f 100644 --- a/panda/src/device/trackerNode.cxx +++ b/panda/src/device/trackerNode.cxx @@ -21,7 +21,7 @@ TypeHandle TrackerNode::_type_handle; * */ TrackerNode:: -TrackerNode(ClientBase *client, const string &device_name) : +TrackerNode(ClientBase *client, const std::string &device_name) : DataNode(device_name) { _transform_output = define_output("transform", TransformState::get_class_type()); diff --git a/panda/src/device/virtualMouse.cxx b/panda/src/device/virtualMouse.cxx index fc0782828b..cdbf5aa678 100644 --- a/panda/src/device/virtualMouse.cxx +++ b/panda/src/device/virtualMouse.cxx @@ -20,7 +20,7 @@ TypeHandle VirtualMouse::_type_handle; * */ VirtualMouse:: -VirtualMouse(const string &name) : +VirtualMouse(const std::string &name) : DataNode(name) { _pixel_xy_output = define_output("pixel_xy", EventStoreVec2::get_class_type()); diff --git a/panda/src/dgraph/dataNode.cxx b/panda/src/dgraph/dataNode.cxx index 564a19f45d..a67c0b0c0d 100644 --- a/panda/src/dgraph/dataNode.cxx +++ b/panda/src/dgraph/dataNode.cxx @@ -16,6 +16,8 @@ #include "config_dgraph.h" #include "dcast.h" +using std::string; + TypeHandle DataNode::_type_handle; /** @@ -100,7 +102,7 @@ transmit_data(DataGraphTraverser *trav, * might expect to receive. */ void DataNode:: -write_inputs(ostream &out) const { +write_inputs(std::ostream &out) const { Wires::const_iterator wi; for (wi = _input_wires.begin(); wi != _input_wires.end(); ++wi) { const string &name = (*wi).first; @@ -114,7 +116,7 @@ write_inputs(ostream &out) const { * might generate. */ void DataNode:: -write_outputs(ostream &out) const { +write_outputs(std::ostream &out) const { Wires::const_iterator wi; for (wi = _output_wires.begin(); wi != _output_wires.end(); ++wi) { const string &name = (*wi).first; @@ -128,7 +130,7 @@ write_outputs(ostream &out) const { * showing between this DataNode and its parent(s). */ void DataNode:: -write_connections(ostream &out) const { +write_connections(std::ostream &out) const { DataConnections::const_iterator ci; for (ci = _data_connections.begin(); ci != _data_connections.end(); ++ci) { const DataConnection &connect = (*ci); diff --git a/panda/src/display/callbackGraphicsWindow.cxx b/panda/src/display/callbackGraphicsWindow.cxx index 7774b149c2..ebe2442d17 100644 --- a/panda/src/display/callbackGraphicsWindow.cxx +++ b/panda/src/display/callbackGraphicsWindow.cxx @@ -24,7 +24,7 @@ TypeHandle CallbackGraphicsWindow::RenderCallbackData::_type_handle; */ CallbackGraphicsWindow:: CallbackGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -65,7 +65,7 @@ get_input_device(int device) { * Returns the index of the new device. */ int CallbackGraphicsWindow:: -create_input_device(const string &name) { +create_input_device(const std::string &name) { GraphicsWindowInputDevice device = GraphicsWindowInputDevice::pointer_and_keyboard(this, name); return add_input_device(device); diff --git a/panda/src/display/displayInformation.cxx b/panda/src/display/displayInformation.cxx index df1cec1420..337da59699 100644 --- a/panda/src/display/displayInformation.cxx +++ b/panda/src/display/displayInformation.cxx @@ -46,7 +46,7 @@ operator != (const DisplayMode &other) const { * */ void DisplayMode:: -output(ostream &out) const { +output(std::ostream &out) const { out << width << 'x' << height; if (bits_per_pixel > 0) { out << ' ' << bits_per_pixel << "bpp"; @@ -489,7 +489,7 @@ get_driver_date_year() { /** * */ -const string &DisplayInformation:: +const std::string &DisplayInformation:: get_cpu_vendor_string() const { return _cpu_vendor_string; } @@ -497,7 +497,7 @@ get_cpu_vendor_string() const { /** * */ -const string &DisplayInformation:: +const std::string &DisplayInformation:: get_cpu_brand_string() const { return _cpu_brand_string; } diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index b1d99df839..e32b0f5a50 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -23,6 +23,8 @@ #include +using std::string; + TypeHandle DisplayRegion::_type_handle; TypeHandle DisplayRegionPipelineReader::_type_handle; @@ -339,7 +341,7 @@ set_target_tex_page(int page) { * */ void DisplayRegion:: -output(ostream &out) const { +output(std::ostream &out) const { CDReader cdata(_cycler); out << "DisplayRegion(" << cdata->_regions[0]._dimensions << ")=pixels(" << cdata->_regions[0]._pixels << ")"; @@ -363,7 +365,7 @@ make_screenshot_filename(const string &prefix) { static const int buffer_size = 1024; char buffer[buffer_size]; - ostringstream filename_strm; + std::ostringstream filename_strm; size_t i = 0; while (i < screenshot_filename.length()) { @@ -668,7 +670,7 @@ do_compute_pixels(int i, int x_size, int y_size, CData *cdata) { void DisplayRegion:: set_active_index(int index) { #ifdef DO_PSTATS - ostringstream strm; + std::ostringstream strm; strm << "dr_" << index; string name = strm.str(); diff --git a/panda/src/display/displayRegionCullCallbackData.cxx b/panda/src/display/displayRegionCullCallbackData.cxx index 39268fbabe..822ecdce7b 100644 --- a/panda/src/display/displayRegionCullCallbackData.cxx +++ b/panda/src/display/displayRegionCullCallbackData.cxx @@ -33,7 +33,7 @@ DisplayRegionCullCallbackData(CullHandler *cull_handler, SceneSetup *scene_setup * */ void DisplayRegionCullCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << (void *)_cull_handler << ", " << (void *)_scene_setup << ")"; } diff --git a/panda/src/display/displayRegionDrawCallbackData.cxx b/panda/src/display/displayRegionDrawCallbackData.cxx index 194aa6bbef..b95a3086e2 100644 --- a/panda/src/display/displayRegionDrawCallbackData.cxx +++ b/panda/src/display/displayRegionDrawCallbackData.cxx @@ -37,7 +37,7 @@ DisplayRegionDrawCallbackData(CullResult *cull_result, SceneSetup *scene_setup) * */ void DisplayRegionDrawCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << (void *)_cull_result << ", " << (void *)_scene_setup << ")"; } diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx index 81d12a98ba..cb6d14da3f 100644 --- a/panda/src/display/frameBufferProperties.cxx +++ b/panda/src/display/frameBufferProperties.cxx @@ -213,7 +213,7 @@ add_properties(const FrameBufferProperties &other) { * Generates a string representation. */ void FrameBufferProperties:: -output(ostream &out) const { +output(std::ostream &out) const { if ((_flags & FBF_float_depth) != 0) { out << "float_depth "; } @@ -542,7 +542,7 @@ get_quality(const FrameBufferProperties &reqs) const { for (int prop = FBP_aux_rgba; prop <= FBP_aux_float; ++prop) { int extra = _property[prop] > reqs._property[prop]; if (extra > 0) { - extra = min(extra, 3); + extra = std::min(extra, 3); quality -= extra*50; } } @@ -601,7 +601,7 @@ get_quality(const FrameBufferProperties &reqs) const { * false. */ bool FrameBufferProperties:: -verify_hardware_software(const FrameBufferProperties &props, const string &renderer) const { +verify_hardware_software(const FrameBufferProperties &props, const std::string &renderer) const { if (get_force_hardware() < props.get_force_hardware()) { display_cat.error() diff --git a/panda/src/display/graphicsBuffer.cxx b/panda/src/display/graphicsBuffer.cxx index bb0b086309..6955305a96 100644 --- a/panda/src/display/graphicsBuffer.cxx +++ b/panda/src/display/graphicsBuffer.cxx @@ -21,7 +21,7 @@ TypeHandle GraphicsBuffer::_type_handle; */ GraphicsBuffer:: GraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg, diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index b27eaa5c39..0b4e8448b1 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -57,6 +57,8 @@ #include #endif +using std::string; + PT(GraphicsEngine) GraphicsEngine::_global_ptr; PStatCollector GraphicsEngine::_wait_pcollector("Wait:Thread sync"); @@ -1511,7 +1513,7 @@ cull_to_bins(GraphicsEngine::Windows wlist, Thread *current_thread) { key._lens_index = dr_reader.get_lens_index(); } - AlreadyCulled::iterator aci = already_culled.insert(AlreadyCulled::value_type(move(key), nullptr)).first; + AlreadyCulled::iterator aci = already_culled.insert(AlreadyCulled::value_type(std::move(key), nullptr)).first; if ((*aci).second == nullptr) { // We have not used this camera already in this thread. Perform // the cull operation. @@ -1537,7 +1539,7 @@ cull_to_bins(GraphicsEngine::Windows wlist, Thread *current_thread) { } // Save the results for next frame. - dr->set_cull_result(move(cull_result), MOVE(scene_setup), current_thread); + dr->set_cull_result(std::move(cull_result), MOVE(scene_setup), current_thread); } } } diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 1f3141e9fc..7c6cef51cb 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -34,6 +34,8 @@ #include "throw_event.h" #include "config_gobj.h" +using std::string; + TypeHandle GraphicsOutput::_type_handle; PStatCollector GraphicsOutput::_make_current_pcollector("Draw:Make current"); @@ -895,7 +897,7 @@ make_cube_map(const string &name, int size, NodePath &camera_rig, return nullptr; } if (max_dimension > 0) { - size = min(max_dimension, size); + size = std::min(max_dimension, size); } } @@ -1629,8 +1631,8 @@ make_copy() const { /** * */ -ostream & -operator << (ostream &out, GraphicsOutput::FrameMode fm) { +std::ostream & +operator << (std::ostream &out, GraphicsOutput::FrameMode fm) { switch (fm) { case GraphicsOutput::FM_render: return out << "render"; diff --git a/panda/src/display/graphicsPipe.cxx b/panda/src/display/graphicsPipe.cxx index 62a8ec5ad0..937987f567 100644 --- a/panda/src/display/graphicsPipe.cxx +++ b/panda/src/display/graphicsPipe.cxx @@ -134,8 +134,8 @@ GraphicsPipe() : if (max_cpuid >= 1) { get_cpuid(0, info); - swap(info.ecx, info.edx); - _display_information->_cpu_vendor_string = string(info.str + 4, 12); + std::swap(info.ecx, info.edx); + _display_information->_cpu_vendor_string = std::string(info.str + 4, 12); get_cpuid(1, info); _display_information->_cpu_version_information = info.eax; @@ -260,7 +260,7 @@ close_gsg(GraphicsStateGuardian *gsg) { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) GraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index d2b145da39..9c4f52ff63 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -23,6 +23,8 @@ #include +using std::string; + GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = nullptr; /** @@ -121,7 +123,7 @@ print_pipe_types() const { load_default_module(); LightMutexHolder holder(_lock); - nout << "Known pipe types:" << endl; + nout << "Known pipe types:" << std::endl; PipeTypes::const_iterator pi; for (pi = _pipe_types.begin(); pi != _pipe_types.end(); ++pi) { const PipeType &pipe_type = (*pi); @@ -406,11 +408,11 @@ load_named_module(const string &name) { // We have not yet loaded this module. Load it now. Filename dlname = Filename::dso_filename("lib" + name + ".so"); display_cat.info() - << "loading display module: " << dlname.to_os_specific() << endl; + << "loading display module: " << dlname.to_os_specific() << std::endl; void *handle = load_dso(get_plugin_path().get_value(), dlname); if (handle == nullptr) { display_cat.warning() - << "Unable to load: " << load_dso_error() << endl; + << "Unable to load: " << load_dso_error() << std::endl; return TypeHandle::none(); } diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index d0353717c9..94330cfa11 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -63,6 +63,8 @@ #include #include +using std::string; + PStatCollector GraphicsStateGuardian::_vertex_buffer_switch_pcollector("Buffer switch:Vertex"); PStatCollector GraphicsStateGuardian::_index_buffer_switch_pcollector("Buffer switch:Index"); PStatCollector GraphicsStateGuardian::_shader_buffer_switch_pcollector("Buffer switch:Shader"); @@ -2194,7 +2196,7 @@ flush_timer_queries() { if (_last_num_queried > 0) { // We know how many queries were available last frame, and this usually // stays fairly constant, so use this as a starting point. - int i = min(_last_num_queried, count) - 1; + int i = std::min(_last_num_queried, count) - 1; if (_pending_timer_queries[i]->is_answer_ready()) { first = count; @@ -2763,7 +2765,7 @@ do_issue_light() { // LightAttrib guarantees that the on lights are sorted, and that // non-ambient lights come before ambient lights. any_on_lights = target_light->has_any_on_light(); - size_t filtered_lights = min((size_t)_max_lights, target_light->get_num_non_ambient_lights()); + size_t filtered_lights = std::min((size_t)_max_lights, target_light->get_num_non_ambient_lights()); for (size_t li = 0; li < filtered_lights; ++li) { NodePath light = target_light->get_on_light(li); nassertv(!light.is_empty()); @@ -3241,7 +3243,7 @@ async_reload_texture(TextureContext *tc) { ((TextureReloadRequest *)task)->get_texture() == tc->get_texture()) { // This texture is already queued to be reloaded. Don't queue it again, // just make sure the priority is updated, and return. - task->set_priority(max(task->get_priority(), priority)); + task->set_priority(std::max(task->get_priority(), priority)); return (AsyncFuture *)task; } } @@ -3498,8 +3500,8 @@ get_driver_shader_version_minor() { return -1; } -ostream & -operator << (ostream &out, GraphicsStateGuardian::ShaderModel sm) { +std::ostream & +operator << (std::ostream &out, GraphicsStateGuardian::ShaderModel sm) { static const char *sm_strings[] = {"none", "1.1", "2.0", "2.x", "3.0", "4.0", "5.0", "5.1"}; nassertr(sm >= 0 && sm <= GraphicsStateGuardian::SM_51, out); out << sm_strings[sm]; diff --git a/panda/src/display/graphicsThreadingModel.cxx b/panda/src/display/graphicsThreadingModel.cxx index 113352ecba..22357206da 100644 --- a/panda/src/display/graphicsThreadingModel.cxx +++ b/panda/src/display/graphicsThreadingModel.cxx @@ -13,6 +13,8 @@ #include "graphicsThreadingModel.h" +using std::string; + /** * The threading model accepts a string representing the names of the two * threads that will process cull and draw for the given window, separated by diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index c3dadfa08c..8d618f3d9b 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -21,6 +21,8 @@ #include "throw_event.h" #include "string_utils.h" +using std::string; + TypeHandle GraphicsWindow::_type_handle; /** diff --git a/panda/src/display/graphicsWindowInputDevice.cxx b/panda/src/display/graphicsWindowInputDevice.cxx index f2af1e9df1..377f3986e4 100644 --- a/panda/src/display/graphicsWindowInputDevice.cxx +++ b/panda/src/display/graphicsWindowInputDevice.cxx @@ -23,6 +23,8 @@ #include "vector_src.cxx" +using std::string; + /** * Defines a new InputDevice for the window. Most windows will have exactly * one InputDevice: a keyboard/mouse pair. Some may also add joystick data, @@ -281,7 +283,7 @@ keystroke(int keycode, double time) { * especially Chinese/Japanese/Korean. */ void GraphicsWindowInputDevice:: -candidate(const wstring &candidate_string, size_t highlight_start, +candidate(const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) { LightMutexHolder holder(_lock); _button_events.push_back(ButtonEvent(candidate_string, diff --git a/panda/src/display/graphicsWindowProcCallbackData.cxx b/panda/src/display/graphicsWindowProcCallbackData.cxx index 8bf1da03af..82e57ef382 100644 --- a/panda/src/display/graphicsWindowProcCallbackData.cxx +++ b/panda/src/display/graphicsWindowProcCallbackData.cxx @@ -20,7 +20,7 @@ TypeHandle GraphicsWindowProcCallbackData::_type_handle; * */ void GraphicsWindowProcCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { #ifdef WIN32 out << get_type() << "(" << (void*)_graphicsWindow << ", " << _hwnd << ", " << _msg << ", " << _wparam << ", " << _lparam << ")"; diff --git a/panda/src/display/nativeWindowHandle.cxx b/panda/src/display/nativeWindowHandle.cxx index 7616471172..2ae1973a6f 100644 --- a/panda/src/display/nativeWindowHandle.cxx +++ b/panda/src/display/nativeWindowHandle.cxx @@ -13,6 +13,8 @@ #include "nativeWindowHandle.h" +using std::ostream; + TypeHandle NativeWindowHandle::_type_handle; TypeHandle NativeWindowHandle::IntHandle::_type_handle; TypeHandle NativeWindowHandle::SubprocessHandle::_type_handle; diff --git a/panda/src/display/parasiteBuffer.cxx b/panda/src/display/parasiteBuffer.cxx index c03d799f4c..1b23fdb653 100644 --- a/panda/src/display/parasiteBuffer.cxx +++ b/panda/src/display/parasiteBuffer.cxx @@ -21,7 +21,7 @@ TypeHandle ParasiteBuffer::_type_handle; * created instead via the GraphicsEngine::make_parasite() function. */ ParasiteBuffer:: -ParasiteBuffer(GraphicsOutput *host, const string &name, +ParasiteBuffer(GraphicsOutput *host, const std::string &name, int x_size, int y_size, int flags) : GraphicsOutput(host->get_engine(), host->get_pipe(), name, host->get_fb_properties(), @@ -95,7 +95,7 @@ set_size_and_recalc(int x, int y) { y = Texture::down_to_power_2(y); } if (_creation_flags & GraphicsPipe::BF_size_square) { - x = y = min(x, y); + x = y = std::min(x, y); } } @@ -180,8 +180,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { } else { if (_host->get_x_size() < get_x_size() || _host->get_y_size() < get_y_size()) { - set_size_and_recalc(min(get_x_size(), _host->get_x_size()), - min(get_y_size(), _host->get_y_size())); + set_size_and_recalc(std::min(get_x_size(), _host->get_x_size()), + std::min(get_y_size(), _host->get_y_size())); } } diff --git a/panda/src/display/stereoDisplayRegion.cxx b/panda/src/display/stereoDisplayRegion.cxx index 3b3a7cf9f8..5151920cab 100644 --- a/panda/src/display/stereoDisplayRegion.cxx +++ b/panda/src/display/stereoDisplayRegion.cxx @@ -262,7 +262,7 @@ set_target_tex_page(int page) { * */ void StereoDisplayRegion:: -output(ostream &out) const { +output(std::ostream &out) const { out << "StereoDisplayRegion(" << *_left_eye << ")"; } diff --git a/panda/src/display/subprocessWindow.cxx b/panda/src/display/subprocessWindow.cxx index 261c7f161a..fe4b2eff5d 100644 --- a/panda/src/display/subprocessWindow.cxx +++ b/panda/src/display/subprocessWindow.cxx @@ -19,6 +19,8 @@ #include "config_display.h" #include "nativeWindowHandle.h" +using std::string; + TypeHandle SubprocessWindow::_type_handle; /** diff --git a/panda/src/display/subprocessWindowBuffer.cxx b/panda/src/display/subprocessWindowBuffer.cxx index f2f7eea2cb..168e7f0758 100644 --- a/panda/src/display/subprocessWindowBuffer.cxx +++ b/panda/src/display/subprocessWindowBuffer.cxx @@ -19,6 +19,9 @@ #include +using std::cerr; +using std::string; + const char SubprocessWindowBuffer:: _magic_number[SubprocessWindowBuffer::magic_number_length] = "pNdaSWB"; diff --git a/panda/src/display/windowHandle.cxx b/panda/src/display/windowHandle.cxx index c114da8adf..0bfec17af7 100644 --- a/panda/src/display/windowHandle.cxx +++ b/panda/src/display/windowHandle.cxx @@ -52,7 +52,7 @@ get_int_handle() const { * */ void WindowHandle:: -output(ostream &out) const { +output(std::ostream &out) const { if (_os_handle == nullptr) { out << "(null)"; } else { @@ -117,6 +117,6 @@ get_int_handle() const { * */ void WindowHandle::OSHandle:: -output(ostream &out) const { +output(std::ostream &out) const { out << "(no type)"; } diff --git a/panda/src/display/windowProperties.cxx b/panda/src/display/windowProperties.cxx index fec24e4faf..93cd0a7144 100644 --- a/panda/src/display/windowProperties.cxx +++ b/panda/src/display/windowProperties.cxx @@ -15,6 +15,10 @@ #include "config_display.h" #include "nativeWindowHandle.h" +using std::istream; +using std::ostream; +using std::string; + WindowProperties *WindowProperties::_default_properties = nullptr; /** diff --git a/panda/src/distort/nonlinearImager.cxx b/panda/src/distort/nonlinearImager.cxx index 551caac4d1..e0f86670a2 100644 --- a/panda/src/distort/nonlinearImager.cxx +++ b/panda/src/distort/nonlinearImager.cxx @@ -71,7 +71,7 @@ add_screen(ProjectionScreen *screen) { * The return value is the index number of the new screen. */ int NonlinearImager:: -add_screen(const NodePath &screen, const string &name) { +add_screen(const NodePath &screen, const std::string &name) { nassertr(!screen.is_empty() && screen.node()->is_of_type(ProjectionScreen::get_class_type()), -1); diff --git a/panda/src/distort/projectionScreen.cxx b/panda/src/distort/projectionScreen.cxx index 0ac8fd9edf..e3bed91e27 100644 --- a/panda/src/distort/projectionScreen.cxx +++ b/panda/src/distort/projectionScreen.cxx @@ -30,7 +30,7 @@ TypeHandle ProjectionScreen::_type_handle; * */ ProjectionScreen:: -ProjectionScreen(const string &name) : PandaNode(name) +ProjectionScreen(const std::string &name) : PandaNode(name) { set_cull_callback(); @@ -151,7 +151,7 @@ set_projector(const NodePath &projector) { * fraction, and make the screen smaller by the inverse fraction. */ PT(GeomNode) ProjectionScreen:: -generate_screen(const NodePath &projector, const string &screen_name, +generate_screen(const NodePath &projector, const std::string &screen_name, int num_x_verts, int num_y_verts, PN_stdfloat distance, PN_stdfloat fill_ratio) { nassertr(!projector.is_empty() && @@ -237,7 +237,7 @@ generate_screen(const NodePath &projector, const string &screen_name, * generated child returned by generate_screen(). */ void ProjectionScreen:: -regenerate_screen(const NodePath &projector, const string &screen_name, +regenerate_screen(const NodePath &projector, const std::string &screen_name, int num_x_verts, int num_y_verts, PN_stdfloat distance, PN_stdfloat fill_ratio) { // First, remove all existing children. diff --git a/panda/src/downloader/bioPtr.cxx b/panda/src/downloader/bioPtr.cxx index 8c5c76f636..eb12b2bd8b 100644 --- a/panda/src/downloader/bioPtr.cxx +++ b/panda/src/downloader/bioPtr.cxx @@ -31,6 +31,8 @@ #include #endif +using std::string; + #ifdef _WIN32 static string format_error() { PVOID buffer; diff --git a/panda/src/downloader/chunkedStreamBuf.cxx b/panda/src/downloader/chunkedStreamBuf.cxx index f6ddd39713..f9580b8e91 100644 --- a/panda/src/downloader/chunkedStreamBuf.cxx +++ b/panda/src/downloader/chunkedStreamBuf.cxx @@ -131,7 +131,7 @@ read_chars(char *start, size_t length) { if (_chunk_remaining != 0) { // Extract some of the bytes remaining in the chunk. - length = min(length, _chunk_remaining); + length = std::min(length, _chunk_remaining); (*_source)->read(start, length); size_t read_count = (*_source)->gcount(); if (!_wanted_nonblocking) { @@ -153,7 +153,7 @@ read_chars(char *start, size_t length) { } // Read the next chunk. - string line; + std::string line; bool got_line = http_getline(line); while (got_line && line.empty()) { // Skip blank lines. There really should be exactly one blank line, but @@ -212,7 +212,7 @@ read_chars(char *start, size_t length) { * received or if the connection has been closed. */ bool ChunkedStreamBuf:: -http_getline(string &str) { +http_getline(std::string &str) { nassertr(!_source.is_null(), false); int ch = (*_source)->get(); while (!(*_source)->eof() && !(*_source)->fail()) { @@ -220,7 +220,7 @@ http_getline(string &str) { case '\n': // end-of-line character, we're done. str = _working_getline; - _working_getline = string(); + _working_getline = std::string(); { // Trim trailing whitespace. We're not required to do this per the // HTTP spec, but let's be generous. diff --git a/panda/src/downloader/decompressor.cxx b/panda/src/downloader/decompressor.cxx index b6bc542e60..272279047d 100644 --- a/panda/src/downloader/decompressor.cxx +++ b/panda/src/downloader/decompressor.cxx @@ -54,7 +54,7 @@ Decompressor:: */ int Decompressor:: initiate(const Filename &source_file) { - string extension = source_file.get_extension(); + std::string extension = source_file.get_extension(); if (extension == "pz" || extension == "gz") { Filename dest_file = source_file; dest_file = source_file.get_fullpath_wo_extension(); @@ -64,7 +64,7 @@ initiate(const Filename &source_file) { if (downloader_cat.is_debug()) { downloader_cat.debug() << "Unknown file extension for decompressor: ." - << extension << endl; + << extension << std::endl; } return EU_error_abort; } @@ -90,14 +90,14 @@ initiate(const Filename &source_file, const Filename &dest_file) { } // Determine source file length - source_pfstream->seekg(0, ios::end); + source_pfstream->seekg(0, std::ios::end); _source_length = source_pfstream->tellg(); if (_source_length == 0) { downloader_cat.warning() << "Zero length file: " << source_file << "\n"; return EU_error_file_empty; } - source_pfstream->seekg(0, ios::beg); + source_pfstream->seekg(0, std::ios::beg); // Open destination file Filename dest_filename(dest_file); @@ -201,8 +201,8 @@ decompress(const Filename &source_file) { */ bool Decompressor:: decompress(Ramfile &source_and_dest_file) { - istringstream source(source_and_dest_file._data); - ostringstream dest; + std::istringstream source(source_and_dest_file._data); + std::ostringstream dest; IDecompressStream decompress(&source, false); diff --git a/panda/src/downloader/documentSpec.cxx b/panda/src/downloader/documentSpec.cxx index b9ccc7097d..6ca2a9b260 100644 --- a/panda/src/downloader/documentSpec.cxx +++ b/panda/src/downloader/documentSpec.cxx @@ -51,7 +51,7 @@ compare_to(const DocumentSpec &other) const { * output() or write(). Returns true on success, false on failure. */ bool DocumentSpec:: -input(istream &in) { +input(std::istream &in) { // First, clear the spec. (*this) = DocumentSpec(); @@ -64,7 +64,7 @@ input(istream &in) { in >> ch; if (ch == '(') { // Scan the tag, up to but not including the closing paren. - string tag; + std::string tag; in >> ch; while (!in.fail() && !in.eof() && ch != ')') { tag += ch; @@ -80,7 +80,7 @@ input(istream &in) { // Scan the date, up to but not including the closing bracket. if (ch != ']') { - string date; + std::string date; while (!in.fail() && !in.eof() && ch != ']') { date += ch; ch = in.get(); @@ -99,7 +99,7 @@ input(istream &in) { * */ void DocumentSpec:: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ " << get_url(); if (has_tag()) { out << " (" << get_tag() << ")"; @@ -114,7 +114,7 @@ output(ostream &out) const { * */ void DocumentSpec:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "[ " << get_url(); if (has_tag()) { diff --git a/panda/src/downloader/downloadDb.cxx b/panda/src/downloader/downloadDb.cxx index d532009e2b..0679614c8b 100644 --- a/panda/src/downloader/downloadDb.cxx +++ b/panda/src/downloader/downloadDb.cxx @@ -20,6 +20,13 @@ #include +using std::endl; +using std::istream; +using std::istringstream; +using std::move; +using std::ostream; +using std::string; + // Defines // Written at the top of the file so we know this is a downloadDb diff --git a/panda/src/downloader/download_utils.cxx b/panda/src/downloader/download_utils.cxx index e090627362..ebeec3a97c 100644 --- a/panda/src/downloader/download_utils.cxx +++ b/panda/src/downloader/download_utils.cxx @@ -19,13 +19,15 @@ #include "config_downloader.h" #include +using std::ios; + unsigned long check_crc(Filename name) { pifstream read_stream; name.set_binary(); if (!name.open_read(read_stream)) { downloader_cat.error() - << "check_crc() - Failed to open input file: " << name << endl; + << "check_crc() - Failed to open input file: " << name << std::endl; return 0; } @@ -51,7 +53,7 @@ check_adler(Filename name) { name.set_binary(); if (!name.open_read(read_stream)) { downloader_cat.error() - << "check_adler() - Failed to open input file: " << name << endl; + << "check_adler() - Failed to open input file: " << name << std::endl; return 0; } diff --git a/panda/src/downloader/extractor.cxx b/panda/src/downloader/extractor.cxx index 81568ae951..a78e9a340d 100644 --- a/panda/src/downloader/extractor.cxx +++ b/panda/src/downloader/extractor.cxx @@ -192,7 +192,7 @@ step() { static const size_t buffer_size = 1024; char buffer[buffer_size]; - size_t max_bytes = min(buffer_size, _subfile_length - _subfile_pos); + size_t max_bytes = std::min(buffer_size, _subfile_length - _subfile_pos); _read->read(buffer, max_bytes); size_t count = _read->gcount(); while (count != 0) { @@ -217,7 +217,7 @@ step() { return EU_ok; } - max_bytes = min(buffer_size, _subfile_length - _subfile_pos); + max_bytes = std::min(buffer_size, _subfile_length - _subfile_pos); _read->read(buffer, max_bytes); count = _read->gcount(); } diff --git a/panda/src/downloader/httpAuthorization.cxx b/panda/src/downloader/httpAuthorization.cxx index d067b96d97..081f16532d 100644 --- a/panda/src/downloader/httpAuthorization.cxx +++ b/panda/src/downloader/httpAuthorization.cxx @@ -17,6 +17,8 @@ #ifdef HAVE_OPENSSL +using std::string; + static const char base64_table[64] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', diff --git a/panda/src/downloader/httpBasicAuthorization.cxx b/panda/src/downloader/httpBasicAuthorization.cxx index 8e86c25a94..a8abd67979 100644 --- a/panda/src/downloader/httpBasicAuthorization.cxx +++ b/panda/src/downloader/httpBasicAuthorization.cxx @@ -15,6 +15,8 @@ #ifdef HAVE_OPENSSL +using std::string; + const string HTTPBasicAuthorization::_mechanism = "basic"; /** diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 990c89d4e6..17c12d806a 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -35,6 +35,12 @@ #undef X509_NAME #endif // WIN32_VC +using std::istream; +using std::min; +using std::ostream; +using std::ostringstream; +using std::string; + TypeHandle HTTPChannel::_type_handle; #define _NOTIFY_HTTP_CHANNEL_ID "[" << this << "] " @@ -250,7 +256,7 @@ will_close_connection() const { * requests which can change their minds midstream about how much data they're * sending you. */ -streamsize HTTPChannel:: +std::streamsize HTTPChannel:: get_file_size() const { if (_got_file_size) { return _file_size; @@ -2678,7 +2684,7 @@ open_download_file() { // Windows doesn't complain if you try to seek past the end of file--it // happily appends enough zero bytes to make the difference. Blecch. // That means we need to get the file size first to check it ourselves. - _download_to_stream->seekp(0, ios::end); + _download_to_stream->seekp(0, std::ios::end); if (_first_byte_delivered > (size_t)_download_to_stream->tellp()) { downloader_cat.info() << _NOTIFY_HTTP_CHANNEL_ID @@ -2716,7 +2722,7 @@ open_download_file() { // Windows doesn't complain if you try to seek past the end of file--it // happily appends enough zero bytes to make the difference. Blecch. // That means we need to get the file size first to check it ourselves. - _download_to_stream->seekp(0, ios::end); + _download_to_stream->seekp(0, std::ios::end); if (_first_byte_delivered > (size_t)_download_to_stream->tellp()) { downloader_cat.info() << _NOTIFY_HTTP_CHANNEL_ID @@ -3711,7 +3717,7 @@ reset_url(const URLSpec &old_url, const URLSpec &new_url) { */ void HTTPChannel:: store_header_field(const string &field_name, const string &field_value) { - pair insert_result = + std::pair insert_result = _headers.insert(Headers::value_type(field_name, field_value)); if (!insert_result.second) { diff --git a/panda/src/downloader/httpClient.cxx b/panda/src/downloader/httpClient.cxx index 7183b36ddf..1f80bf61fd 100644 --- a/panda/src/downloader/httpClient.cxx +++ b/panda/src/downloader/httpClient.cxx @@ -26,6 +26,8 @@ #include "openSSLWrapper.h" +using std::string; + PT(HTTPClient) HTTPClient::_global_ptr; /** @@ -78,7 +80,7 @@ tokenize(const string &str, vector_string &words, const string &delimiters) { static void ssl_msg_callback(int write_p, int version, int content_type, const void *, size_t len, SSL *, void *) { - ostringstream describe; + std::ostringstream describe; if (write_p) { describe << "sent "; } else { @@ -701,7 +703,7 @@ set_cookie(const HTTPCookie &cookie) { clear_cookie(cookie); } else { - pair result = _cookies.insert(cookie); + std::pair result = _cookies.insert(cookie); if (!result.second) { // We already had a cookie matching the supplied domainpathname, so // replace it. @@ -778,7 +780,7 @@ copy_cookies_from(const HTTPClient &other) { * host). */ void HTTPClient:: -write_cookies(ostream &out) const { +write_cookies(std::ostream &out) const { Cookies::const_iterator ci; for (ci = _cookies.begin(); ci != _cookies.end(); ++ci) { out << *ci << "\n"; @@ -791,7 +793,7 @@ write_cookies(ostream &out) const { * also removes expired cookies. */ void HTTPClient:: -send_cookies(ostream &out, const URLSpec &url) { +send_cookies(std::ostream &out, const URLSpec &url) { HTTPDate now = HTTPDate::now(); bool any_expired = false; bool first_cookie = true; diff --git a/panda/src/downloader/httpCookie.cxx b/panda/src/downloader/httpCookie.cxx index cbe095cd8d..d09f12b856 100644 --- a/panda/src/downloader/httpCookie.cxx +++ b/panda/src/downloader/httpCookie.cxx @@ -18,6 +18,8 @@ #include "ctype.h" #include "httpChannel.h" +using std::string; + /** * The sorting operator allows the cookies to be stored in a single * dictionary; it returns nonequal only if the cookies are different in name, @@ -139,7 +141,7 @@ matches_url(const URLSpec &url) const { * */ void HTTPCookie:: -output(ostream &out) const { +output(std::ostream &out) const { out << _name << "=" << _value << "; path=" << _path << "; domain=" << _domain; diff --git a/panda/src/downloader/httpDate.cxx b/panda/src/downloader/httpDate.cxx index f8877a65c8..a651b50f89 100644 --- a/panda/src/downloader/httpDate.cxx +++ b/panda/src/downloader/httpDate.cxx @@ -15,6 +15,10 @@ #include +using std::setfill; +using std::setw; +using std::string; + static const int num_weekdays = 7; static const char * const weekdays[num_weekdays] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" @@ -245,7 +249,7 @@ get_string() const { struct tm *tp = gmtime(&_time); - ostringstream result; + std::ostringstream result; result << weekdays[tp->tm_wday] << ", " << setw(2) << setfill('0') << tp->tm_mday << " " @@ -263,7 +267,7 @@ get_string() const { * */ bool HTTPDate:: -input(istream &in) { +input(std::istream &in) { (*this) = HTTPDate(); // Extract out the quoted date string. @@ -294,7 +298,7 @@ input(istream &in) { * */ void HTTPDate:: -output(ostream &out) const { +output(std::ostream &out) const { // We put quotes around the string on output, so we can reliably detect the // end of the date string on input, above. out << '"' << get_string() << '"'; diff --git a/panda/src/downloader/httpDigestAuthorization.cxx b/panda/src/downloader/httpDigestAuthorization.cxx index 8bb2804bcf..1e59ea560c 100644 --- a/panda/src/downloader/httpDigestAuthorization.cxx +++ b/panda/src/downloader/httpDigestAuthorization.cxx @@ -21,6 +21,10 @@ #include "openssl/md5.h" #include +using std::ostream; +using std::ostringstream; +using std::string; + const string HTTPDigestAuthorization::_mechanism = "digest"; /** @@ -277,7 +281,7 @@ get_a2(HTTPEnum::Method method, const string &request_path, string HTTPDigestAuthorization:: get_hex_nonce_count() const { ostringstream strm; - strm << hex << setfill('0') << setw(8) << _nonce_count; + strm << std::hex << std::setfill('0') << std::setw(8) << _nonce_count; return strm.str(); } diff --git a/panda/src/downloader/httpEntityTag.cxx b/panda/src/downloader/httpEntityTag.cxx index 9c756024ee..1d4b79922a 100644 --- a/panda/src/downloader/httpEntityTag.cxx +++ b/panda/src/downloader/httpEntityTag.cxx @@ -13,6 +13,8 @@ #include "httpEntityTag.h" +using std::string; + /** * This constructor accepts a string as formatted from an HTTP server (e.g. @@ -52,7 +54,7 @@ HTTPEntityTag(const string &text) { */ string HTTPEntityTag:: get_string() const { - ostringstream result; + std::ostringstream result; if (_weak) { result << "W/"; } diff --git a/panda/src/downloader/httpEnum.cxx b/panda/src/downloader/httpEnum.cxx index 1ef09de254..ebe7914110 100644 --- a/panda/src/downloader/httpEnum.cxx +++ b/panda/src/downloader/httpEnum.cxx @@ -18,8 +18,8 @@ /** * */ -ostream & -operator << (ostream &out, HTTPEnum::Method method) { +std::ostream & +operator << (std::ostream &out, HTTPEnum::Method method) { switch (method) { case HTTPEnum::M_options: out << "OPTIONS"; diff --git a/panda/src/downloader/identityStreamBuf.cxx b/panda/src/downloader/identityStreamBuf.cxx index 4d98540423..852c252f32 100644 --- a/panda/src/downloader/identityStreamBuf.cxx +++ b/panda/src/downloader/identityStreamBuf.cxx @@ -140,7 +140,7 @@ read_chars(char *start, size_t length) { // content_length restriction. if (_bytes_remaining != 0) { - length = min(length, _bytes_remaining); + length = std::min(length, _bytes_remaining); (*_source)->read(start, length); read_count = (*_source)->gcount(); if (!_wanted_nonblocking) { diff --git a/panda/src/downloader/multiplexStreamBuf.cxx b/panda/src/downloader/multiplexStreamBuf.cxx index 3b6b0a8b10..aa42d33f9e 100644 --- a/panda/src/downloader/multiplexStreamBuf.cxx +++ b/panda/src/downloader/multiplexStreamBuf.cxx @@ -24,6 +24,8 @@ // recursion. #include +using std::string; + /** * Closes or deletes the relevant pointers, if _owns_obj is true. */ @@ -107,7 +109,7 @@ MultiplexStreamBuf:: void MultiplexStreamBuf:: add_output(MultiplexStreamBuf::BufferType buffer_type, MultiplexStreamBuf::OutputType output_type, - ostream *out, FILE *fout, bool owns_obj) { + std::ostream *out, FILE *fout, bool owns_obj) { Output o; o._buffer_type = buffer_type; @@ -141,7 +143,7 @@ int MultiplexStreamBuf:: overflow(int ch) { _lock.lock(); - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0) { write_chars(pbase(), n, false); @@ -166,7 +168,7 @@ int MultiplexStreamBuf:: sync() { _lock.lock(); - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); // We pass in false for the flush value, even though our transmitting // ostream said to sync. This allows us to get better line buffering, since diff --git a/panda/src/downloader/socketStream.cxx b/panda/src/downloader/socketStream.cxx index 4d52a82cb5..eec65d1857 100644 --- a/panda/src/downloader/socketStream.cxx +++ b/panda/src/downloader/socketStream.cxx @@ -23,7 +23,7 @@ * */ SSReader:: -SSReader(istream *stream) : _istream(stream) { +SSReader(std::istream *stream) : _istream(stream) { _data_expected = 0; _tcp_header_size = tcp_header_size; @@ -84,13 +84,13 @@ do_receive_datagram(Datagram &dg) { static const size_t buffer_size = 1024; char buffer[buffer_size]; - size_t read_count = min(_data_expected - _data_so_far.size(), buffer_size); + size_t read_count = std::min(_data_expected - _data_so_far.size(), buffer_size); _istream->read(buffer, read_count); size_t count = _istream->gcount(); while (count != 0) { _data_so_far.insert(_data_so_far.end(), buffer, buffer + count); - read_count = min(_data_expected - _data_so_far.size(), + read_count = std::min(_data_expected - _data_so_far.size(), buffer_size); _istream->read(buffer, read_count); count = _istream->gcount(); @@ -126,7 +126,7 @@ do_receive_datagram(Datagram &dg) { void SSReader:: start_delay(double min_delay, double max_delay) { _min_delay = min_delay; - _delay_variance = max(max_delay - min_delay, 0.0); + _delay_variance = std::max(max_delay - min_delay, 0.0); _delay_active = true; } #endif // SIMULATE_NETWORK_DELAY @@ -194,7 +194,7 @@ get_delayed(Datagram &datagram) { * */ SSWriter:: -SSWriter(ostream *stream) : _ostream(stream) { +SSWriter(std::ostream *stream) : _ostream(stream) { _collect_tcp = collect_tcp; _collect_tcp_interval = collect_tcp_interval; _queued_data_start = 0.0; diff --git a/panda/src/downloader/stringStreamBuf.cxx b/panda/src/downloader/stringStreamBuf.cxx index 4067ca1acb..f9a6cc99f9 100644 --- a/panda/src/downloader/stringStreamBuf.cxx +++ b/panda/src/downloader/stringStreamBuf.cxx @@ -15,6 +15,10 @@ #include "pnotify.h" #include "config_express.h" +using std::ios; +using std::streamoff; +using std::streampos; + /** * */ @@ -82,7 +86,7 @@ read_chars(char *start, size_t length) { return 0; } - length = min(length, _data.size() - _gpos); + length = std::min(length, _data.size() - _gpos); memcpy(start, &_data[_gpos], length); _gpos += length; return length; @@ -102,7 +106,7 @@ write_chars(const char *start, size_t length) { if (_data.size() > _ppos) { // We are overwriting some data. size_t remaining_length = _data.size() - _ppos; - size_t overwrite_length = min(remaining_length, length); + size_t overwrite_length = std::min(remaining_length, length); memcpy(&_data[_ppos], start, overwrite_length); length -= overwrite_length; _ppos += overwrite_length; diff --git a/panda/src/downloader/urlSpec.cxx b/panda/src/downloader/urlSpec.cxx index 09769f3693..1925c6a775 100644 --- a/panda/src/downloader/urlSpec.cxx +++ b/panda/src/downloader/urlSpec.cxx @@ -17,6 +17,13 @@ #include +using std::istream; +using std::ostream; +using std::ostringstream; +using std::setfill; +using std::setw; +using std::string; + /** * */ @@ -711,7 +718,7 @@ output(ostream &out) const { string URLSpec:: quote(const string &source, const string &safe) { ostringstream result; - result << hex << setfill('0'); + result << std::hex << setfill('0'); for (string::const_iterator si = source.begin(); si != source.end(); ++si) { char ch = (*si); @@ -750,7 +757,7 @@ quote(const string &source, const string &safe) { string URLSpec:: quote_plus(const string &source, const string &safe) { ostringstream result; - result << hex << setfill('0'); + result << std::hex << setfill('0'); for (string::const_iterator si = source.begin(); si != source.end(); ++si) { char ch = (*si); diff --git a/panda/src/downloader/virtualFileHTTP.cxx b/panda/src/downloader/virtualFileHTTP.cxx index 27f33c644a..527e9c619b 100644 --- a/panda/src/downloader/virtualFileHTTP.cxx +++ b/panda/src/downloader/virtualFileHTTP.cxx @@ -18,6 +18,10 @@ #ifdef HAVE_OPENSSL +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFileHTTP::_type_handle; @@ -205,7 +209,7 @@ was_read_successful() const { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileHTTP:: +std::streamsize VirtualFileHTTP:: get_file_size(istream *stream) const { return _channel->get_file_size(); } @@ -214,7 +218,7 @@ get_file_size(istream *stream) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileHTTP:: +std::streamsize VirtualFileHTTP:: get_file_size() const { return _channel->get_file_size(); } diff --git a/panda/src/downloader/virtualFileMountHTTP.cxx b/panda/src/downloader/virtualFileMountHTTP.cxx index c9cc4759a0..25e9dc99ea 100644 --- a/panda/src/downloader/virtualFileMountHTTP.cxx +++ b/panda/src/downloader/virtualFileMountHTTP.cxx @@ -17,6 +17,8 @@ #ifdef HAVE_OPENSSL +using std::string; + TypeHandle VirtualFileMountHTTP::_type_handle; @@ -174,7 +176,7 @@ make_virtual_file(const Filename &local_filename, * istream on success (which you should eventually delete when you are done * reading). Returns NULL on failure. */ -istream *VirtualFileMountHTTP:: +std::istream *VirtualFileMountHTTP:: open_read_file(const Filename &) const { return nullptr; } @@ -184,8 +186,8 @@ open_read_file(const Filename &) const { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileMountHTTP:: -get_file_size(const Filename &, istream *) const { +std::streamsize VirtualFileMountHTTP:: +get_file_size(const Filename &, std::istream *) const { return 0; } @@ -193,7 +195,7 @@ get_file_size(const Filename &, istream *) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileMountHTTP:: +std::streamsize VirtualFileMountHTTP:: get_file_size(const Filename &) const { return 0; } @@ -227,7 +229,7 @@ scan_directory(vector_string &, const Filename &) const { * */ void VirtualFileMountHTTP:: -output(ostream &out) const { +output(std::ostream &out) const { out << _root; } diff --git a/panda/src/downloadertools/apply_patch.cxx b/panda/src/downloadertools/apply_patch.cxx index 908f3c8189..502d67c89b 100644 --- a/panda/src/downloadertools/apply_patch.cxx +++ b/panda/src/downloadertools/apply_patch.cxx @@ -15,6 +15,9 @@ #include "patchfile.h" #include "filename.h" +using std::cerr; +using std::endl; + int main(int argc, char **argv) { preprocess_argv(argc, argv); diff --git a/panda/src/downloadertools/build_patch.cxx b/panda/src/downloadertools/build_patch.cxx index d14e27db9f..5c705bb38d 100644 --- a/panda/src/downloadertools/build_patch.cxx +++ b/panda/src/downloadertools/build_patch.cxx @@ -15,6 +15,9 @@ #include "patchfile.h" #include "filename.h" +using std::cerr; +using std::endl; + void usage() { cerr << "Usage: build_patch [opts] " << endl; diff --git a/panda/src/downloadertools/check_adler.cxx b/panda/src/downloadertools/check_adler.cxx index b53eb2839f..dbea94f8b7 100644 --- a/panda/src/downloadertools/check_adler.cxx +++ b/panda/src/downloadertools/check_adler.cxx @@ -14,13 +14,13 @@ int main(int argc, char *argv[]) { if (argc < 2) { - cerr << "Usage: check_adler " << endl; + std::cerr << "Usage: check_adler " << std::endl; return 1; } Filename source_file = argv[1]; - cout << check_adler(source_file); + std::cout << check_adler(source_file); return 0; } diff --git a/panda/src/downloadertools/check_crc.cxx b/panda/src/downloadertools/check_crc.cxx index 9afadd4fb2..e98de20b57 100644 --- a/panda/src/downloadertools/check_crc.cxx +++ b/panda/src/downloadertools/check_crc.cxx @@ -14,13 +14,13 @@ int main(int argc, char *argv[]) { if (argc < 2) { - cerr << "Usage: check_crc " << endl; + std::cerr << "Usage: check_crc " << std::endl; return 1; } Filename source_file = argv[1]; - cout << check_crc(source_file); + std::cout << check_crc(source_file); return 0; } diff --git a/panda/src/downloadertools/check_md5.cxx b/panda/src/downloadertools/check_md5.cxx index 5b386c7c1e..2cc3ce508e 100644 --- a/panda/src/downloadertools/check_md5.cxx +++ b/panda/src/downloadertools/check_md5.cxx @@ -15,6 +15,9 @@ #include "panda_getopt.h" #include "preprocess_argv.h" +using std::cerr; +using std::cout; + bool output_decimal = false; bool suppress_filename = false; pofstream binary_output; @@ -45,7 +48,7 @@ help() { } void -output_hash(const string &filename, const HashVal &hash) { +output_hash(const std::string &filename, const HashVal &hash) { if (!suppress_filename && !filename.empty()) { cout << filename << " "; } @@ -69,7 +72,7 @@ main(int argc, char **argv) { const char *optstr = "i:db:qh"; bool got_input_string = false; - string input_string; + std::string input_string; Filename binary_output_filename; preprocess_argv(argc, argv); @@ -87,7 +90,7 @@ main(int argc, char **argv) { break; case 'b': - binary_output_filename = Filename::binary_filename(string(optarg)); + binary_output_filename = Filename::binary_filename(std::string(optarg)); break; case 'q': diff --git a/panda/src/downloadertools/multify.cxx b/panda/src/downloadertools/multify.cxx index 3b58ca0d23..bea4c5bedd 100644 --- a/panda/src/downloadertools/multify.cxx +++ b/panda/src/downloadertools/multify.cxx @@ -21,6 +21,11 @@ #include #include +using std::cerr; +using std::cout; +using std::endl; +using std::string; + bool create = false; // -c bool append = false; // -r @@ -634,7 +639,7 @@ list_files(const vector_string ¶ms) { // We happen to know that we can read the index without doing a seek. // So this is the only place where we accept a .pz/.gz compressed .mf. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *istr = vfs->open_read_file(multifile_name, true); + std::istream *istr = vfs->open_read_file(multifile_name, true); if (istr == nullptr) { cerr << "Unable to open " << multifile_name << " for reading.\n"; return false; diff --git a/panda/src/downloadertools/pdecrypt.cxx b/panda/src/downloadertools/pdecrypt.cxx index 9ce3445bf0..7763286b09 100644 --- a/panda/src/downloadertools/pdecrypt.cxx +++ b/panda/src/downloadertools/pdecrypt.cxx @@ -17,7 +17,10 @@ #include "panda_getopt.h" #include "preprocess_argv.h" -string password; +using std::cerr; +using std::endl; + +std::string password; bool got_password = false; void diff --git a/panda/src/downloadertools/pencrypt.cxx b/panda/src/downloadertools/pencrypt.cxx index 3d61651348..e40fbaba2c 100644 --- a/panda/src/downloadertools/pencrypt.cxx +++ b/panda/src/downloadertools/pencrypt.cxx @@ -17,9 +17,12 @@ #include "panda_getopt.h" #include "preprocess_argv.h" -string password; +using std::cerr; +using std::endl; + +std::string password; bool got_password = false; -string algorithm; +std::string algorithm; bool got_algorithm = false; int key_length = -1; bool got_key_length = false; diff --git a/panda/src/downloadertools/punzip.cxx b/panda/src/downloadertools/punzip.cxx index 5753f7b6ec..84a593c795 100644 --- a/panda/src/downloadertools/punzip.cxx +++ b/panda/src/downloadertools/punzip.cxx @@ -15,6 +15,11 @@ #include "panda_getopt.h" #include "preprocess_argv.h" +using std::cerr; +using std::cin; +using std::cout; +using std::endl; + void usage() { cerr diff --git a/panda/src/downloadertools/pzip.cxx b/panda/src/downloadertools/pzip.cxx index 6364be0130..37c80e7f9f 100644 --- a/panda/src/downloadertools/pzip.cxx +++ b/panda/src/downloadertools/pzip.cxx @@ -15,6 +15,11 @@ #include "panda_getopt.h" #include "preprocess_argv.h" +using std::cerr; +using std::cin; +using std::cout; +using std::endl; + void usage() { cerr diff --git a/panda/src/downloadertools/show_ddb.cxx b/panda/src/downloadertools/show_ddb.cxx index d19c3be9cd..1b1a4abce4 100644 --- a/panda/src/downloadertools/show_ddb.cxx +++ b/panda/src/downloadertools/show_ddb.cxx @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { if (argc != 3) { - cerr << "Usage: show_ddb server.ddb client.ddb\n"; + std::cerr << "Usage: show_ddb server.ddb client.ddb\n"; return 1; } @@ -26,7 +26,7 @@ main(int argc, char *argv[]) { Filename client_ddb = Filename::from_os_specific(argv[2]); DownloadDb db(server_ddb, client_ddb); - db.write(cout); + db.write(std::cout); return 0; } diff --git a/panda/src/dxgsg9/dxGeomMunger9.cxx b/panda/src/dxgsg9/dxGeomMunger9.cxx index cce0f2e6f0..8aa539c11f 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.cxx +++ b/panda/src/dxgsg9/dxGeomMunger9.cxx @@ -140,7 +140,7 @@ munge_format_impl(const GeomVertexFormat *orig, int tc_index = _filtered_texture->get_ff_tc_index(si); nassertr(tc_index < num_stages, orig); ff_tc_index[tc_index] = si; - max_tc_index = max(tc_index, max_tc_index); + max_tc_index = std::max(tc_index, max_tc_index); } // Now walk through the texture coordinates in the order they will appear @@ -243,7 +243,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { int tc_index = _filtered_texture->get_ff_tc_index(si); nassertr(tc_index < num_stages, orig); ff_tc_index[tc_index] = si; - max_tc_index = max(tc_index, max_tc_index); + max_tc_index = std::max(tc_index, max_tc_index); } // Now walk through the texture coordinates in the order they will appear diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 389baa4dca..0e5687d490 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -77,6 +77,10 @@ #define SDK_VERSION(major,minor) tostring(major) << "." << tostring(minor) #define DIRECTX_SDK_VERSION SDK_VERSION (_DXSDK_PRODUCT_MAJOR, _DXSDK_PRODUCT_MINOR) << "." << SDK_VERSION (_DXSDK_BUILD_MAJOR, _DXSDK_BUILD_MINOR) +using std::endl; +using std::max; +using std::min; + TypeHandle DXGraphicsStateGuardian9::_type_handle; D3DMATRIX DXGraphicsStateGuardian9::_d3d_ident_mat; @@ -3312,7 +3316,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { static PStatCollector _draw_set_state_light_bind_directional_pcollector("Draw:Set State:Light:Bind:Directional"); // PStatTimer timer(_draw_set_state_light_bind_directional_pcollector); - pair lookup = _dlights.insert(DirectionalLights::value_type(light, D3DLIGHT9())); + std::pair lookup = _dlights.insert(DirectionalLights::value_type(light, D3DLIGHT9())); D3DLIGHT9 &fdata = (*lookup.first).second; if (lookup.second) { // Get the light in "world coordinates" (actually, view coordinates). @@ -4548,7 +4552,7 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, // release graphics buffer surfaces { wdxGraphicsBuffer9 *graphics_buffer; - list ::iterator graphics_buffer_iterator; + std::list ::iterator graphics_buffer_iterator; for (graphics_buffer_iterator = _graphics_buffer_list.begin( ); graphics_buffer_iterator != _graphics_buffer_list.end( ); graphics_buffer_iterator++) { @@ -5372,7 +5376,7 @@ atexit_function(void) { * Profile. */ bool DXGraphicsStateGuardian9:: -get_supports_cg_profile(const string &name) const { +get_supports_cg_profile(const std::string &name) const { #ifndef HAVE_CG return false; #else @@ -5400,7 +5404,7 @@ set_cg_device(LPDIRECT3DDEVICE9 cg_device) { #endif // HAVE_CG } -typedef string KEY; +typedef std::string KEY; typedef struct _KEY_ELEMENT { diff --git a/panda/src/dxgsg9/dxInput9.cxx b/panda/src/dxgsg9/dxInput9.cxx index d0556d44c7..17d5b2f88e 100644 --- a/panda/src/dxgsg9/dxInput9.cxx +++ b/panda/src/dxgsg9/dxInput9.cxx @@ -17,6 +17,8 @@ #define AXIS_RESOLUTION 2000 // use this many levels of resolution by default (could be more if needed and device supported it) #define AXIS_RANGE_CENTERED // if defined, axis range is centered on 0, instead of starting on 0 +using std::endl; + BOOL CALLBACK EnumGameCtrlsCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) { DI_DeviceInfos *pDevInfos = (DI_DeviceInfos *)pContext; diff --git a/panda/src/dxgsg9/dxShaderContext9.cxx b/panda/src/dxgsg9/dxShaderContext9.cxx index c3b1970bd9..6513ce8a89 100644 --- a/panda/src/dxgsg9/dxShaderContext9.cxx +++ b/panda/src/dxgsg9/dxShaderContext9.cxx @@ -207,7 +207,7 @@ issue_parameters(GSG *gsg, int altered) { // Calculate how many elements to transfer; no more than it expects, // but certainly no more than we have. - int input_size = min(abs(spec._dim[0] * spec._dim[1] * spec._dim[2]), (int)ptr_data->_size); + int input_size = std::min(abs(spec._dim[0] * spec._dim[1] * spec._dim[2]), (int)ptr_data->_size); CGparameter p = _cg_parameter_map[spec._id._seqno]; switch (ptr_data->_type) { @@ -313,7 +313,7 @@ issue_parameters(GSG *gsg, int altered) { } if (FAILED(hr)) { - string name = "unnamed"; + std::string name = "unnamed"; if (spec._arg[0]) { name = spec._arg[0]->get_basename(); diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index 12ad6dfdfe..70c9db7803 100644 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -24,6 +24,10 @@ #define DEBUG_SURFACES false #define DEBUG_TEXTURES true +using std::endl; +using std::max; +using std::min; + TypeHandle DXTextureContext9::_type_handle; static const DWORD g_LowByteMask = 0x000000FF; @@ -686,7 +690,7 @@ create_texture(DXScreenData &scrn) { << "NumColorChannels: " << num_color_channels << "; NumAlphaBits: " << num_alpha_bits << "; targetbpp: " <::iterator graphics_buffer_iterator; + std::list ::iterator graphics_buffer_iterator; graphics_buffer_iterator = _shared_depth_buffer_list.begin( ); while (graphics_buffer_iterator != _shared_depth_buffer_list.end( )) { diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index 7ff6f28e5d..cbfada1b41 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -17,6 +17,8 @@ #include "wdxGraphicsBuffer9.h" #include "config_dxgsg9.h" +using std::endl; + TypeHandle wdxGraphicsPipe9::_type_handle; static bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName) { @@ -60,7 +62,7 @@ wdxGraphicsPipe9:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string wdxGraphicsPipe9:: +std::string wdxGraphicsPipe9:: get_interface_name() const { return "DirectX9"; } @@ -78,7 +80,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) wdxGraphicsPipe9:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index d173881ac0..3136d75fd0 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -26,6 +26,8 @@ #include #include +using std::endl; + TypeHandle wdxGraphicsWindow9::_type_handle; /** @@ -33,7 +35,7 @@ TypeHandle wdxGraphicsWindow9::_type_handle; */ wdxGraphicsWindow9:: wdxGraphicsWindow9(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -880,10 +882,10 @@ choose_device() { << ", Driver: " << adapter_info.Driver << ", DriverVersion: (" << HIWORD(DrvVer->HighPart) << "." << LOWORD(DrvVer->HighPart) << "." << HIWORD(DrvVer->LowPart) << "." << LOWORD(DrvVer->LowPart) - << ")\nVendorID: 0x" << hex << adapter_info.VendorId + << ")\nVendorID: 0x" << std::hex << adapter_info.VendorId << " DeviceID: 0x" << adapter_info.DeviceId << " SubsysID: 0x" << adapter_info.SubSysId - << " Revision: 0x" << adapter_info.Revision << dec << endl; + << " Revision: 0x" << adapter_info.Revision << std::dec << endl; HMONITOR _monitor = dxpipe->__d3d9->GetAdapterMonitor(i); if (_monitor == nullptr) { diff --git a/panda/src/dxml/config_dxml.cxx b/panda/src/dxml/config_dxml.cxx index 9c9a65533b..0441f1fdc5 100644 --- a/panda/src/dxml/config_dxml.cxx +++ b/panda/src/dxml/config_dxml.cxx @@ -54,7 +54,7 @@ BEGIN_PUBLISH // Returns the document, or NULL on error. //////////////////////////////////////////////////////////////////// TiXmlDocument * -read_xml_stream(istream &in) { +read_xml_stream(std::istream &in) { TiXmlDocument *doc = new TiXmlDocument; in >> *doc; if (in.fail() && !in.eof()) { @@ -72,7 +72,7 @@ BEGIN_PUBLISH // Description: Writes an XML document to the indicated stream. //////////////////////////////////////////////////////////////////// void -write_xml_stream(ostream &out, TiXmlDocument *doc) { +write_xml_stream(std::ostream &out, TiXmlDocument *doc) { out << *doc; } END_PUBLISH @@ -97,7 +97,7 @@ BEGIN_PUBLISH //////////////////////////////////////////////////////////////////// void print_xml_to_file(const Filename &filename, TiXmlNode *xnode) { - string os_name = filename.to_os_specific(); + std::string os_name = filename.to_os_specific(); #ifdef _WIN32 FILE *file; if (fopen_s(&file, os_name.c_str(), "w") != 0) { diff --git a/panda/src/egg/eggAnimPreload.cxx b/panda/src/egg/eggAnimPreload.cxx index ff05b12a3c..894df329ce 100644 --- a/panda/src/egg/eggAnimPreload.cxx +++ b/panda/src/egg/eggAnimPreload.cxx @@ -23,7 +23,7 @@ TypeHandle EggAnimPreload::_type_handle; * Egg format. */ void EggAnimPreload:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { test_under_integrity(); write_header(out, indent_level, ""); diff --git a/panda/src/egg/eggAttributes.cxx b/panda/src/egg/eggAttributes.cxx index 4f27c5a8b3..26fe007524 100644 --- a/panda/src/egg/eggAttributes.cxx +++ b/panda/src/egg/eggAttributes.cxx @@ -62,7 +62,7 @@ EggAttributes:: * Writes the attributes to the indicated output stream in Egg format. */ void EggAttributes:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (has_normal()) { if (_dnormals.empty()) { indent(out, indent_level) diff --git a/panda/src/egg/eggBin.cxx b/panda/src/egg/eggBin.cxx index 789eaffb21..95a8bdc0a9 100644 --- a/panda/src/egg/eggBin.cxx +++ b/panda/src/egg/eggBin.cxx @@ -21,7 +21,7 @@ TypeHandle EggBin::_type_handle; * */ EggBin:: -EggBin(const string &name) : EggGroup(name) { +EggBin(const std::string &name) : EggGroup(name) { _bin_number = 0; } diff --git a/panda/src/egg/eggBinMaker.cxx b/panda/src/egg/eggBinMaker.cxx index 9200afde6b..4c0214eb92 100644 --- a/panda/src/egg/eggBinMaker.cxx +++ b/panda/src/egg/eggBinMaker.cxx @@ -112,9 +112,9 @@ collapse_group(const EggGroup *, int) { * May be overridden in derived classes to define a name for each new bin, * based on its bin number, and a sample child. */ -string EggBinMaker:: +std::string EggBinMaker:: get_bin_name(int, const EggNode *) { - return string(); + return std::string(); } /** @@ -162,7 +162,7 @@ collect_nodes(EggGroupNode *group) { // If this is the first time this group has been encountered, we need // to create a new entry in _group_nodes for it. - pair result; + std::pair result; result = _group_nodes.insert (GroupNodes::value_type (group, SortedNodes(EggBinMakerCompareNodes(this)))); @@ -286,7 +286,7 @@ setup_bin(EggBin *bin, const Nodes &nodes) { int bin_number = get_bin_number(nodes.front()); bin->set_bin_number(bin_number); - string bin_name = get_bin_name(bin_number, nodes.front()); + std::string bin_name = get_bin_name(bin_number, nodes.front()); if (!bin_name.empty()) { bin->set_name(bin_name); } diff --git a/panda/src/egg/eggComment.cxx b/panda/src/egg/eggComment.cxx index a55dd0787c..1379623c03 100644 --- a/panda/src/egg/eggComment.cxx +++ b/panda/src/egg/eggComment.cxx @@ -24,7 +24,7 @@ TypeHandle EggComment::_type_handle; * Writes the comment definition to the indicated output stream in Egg format. */ void EggComment:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); enquote_string(out, get_comment(), indent_level + 2) << "\n"; indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index 94c4b1d625..f390fb67c2 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -330,7 +330,7 @@ post_apply_flat_attribute() { int num_lead_vertices = get_num_lead_vertices(); for (int i = 0; i < (int)size(); i++) { EggVertex *vertex = get_vertex(i); - EggAttributes *component = get_component(max(i - num_lead_vertices, 0)); + EggAttributes *component = get_component(std::max(i - num_lead_vertices, 0)); // Use set_normal() instead of copy_normal(), to avoid getting the // morphs--we don't want them here, since we're just putting a bogus @@ -376,7 +376,7 @@ prepare_add_vertex(EggVertex *vertex, int i, int n) { int num_lead_vertices = get_num_lead_vertices(); if (n >= num_lead_vertices + 1) { - i = max(i - num_lead_vertices, 0); + i = std::max(i - num_lead_vertices, 0); nassertv(i <= (int)_components.size()); _components.insert(_components.begin() + i, new EggAttributes(*this)); } @@ -400,7 +400,7 @@ prepare_remove_vertex(EggVertex *vertex, int i, int n) { int num_lead_vertices = get_num_lead_vertices(); if (n >= num_lead_vertices + 1) { - i = max(i - num_lead_vertices, 0); + i = std::max(i - num_lead_vertices, 0); nassertv(i < (int)_components.size()); delete _components[i]; _components.erase(_components.begin() + i); @@ -428,7 +428,7 @@ do_triangulate(EggGroupNode *container) const { * indicated output stream in Egg format. */ void EggCompositePrimitive:: -write_body(ostream &out, int indent_level) const { +write_body(std::ostream &out, int indent_level) const { EggPrimitive::write_body(out, indent_level); for (int i = 0; i < get_num_components(); i++) { diff --git a/panda/src/egg/eggCoordinateSystem.cxx b/panda/src/egg/eggCoordinateSystem.cxx index 9ef0ce14f9..a646de21c7 100644 --- a/panda/src/egg/eggCoordinateSystem.cxx +++ b/panda/src/egg/eggCoordinateSystem.cxx @@ -23,7 +23,7 @@ TypeHandle EggCoordinateSystem::_type_handle; * Egg format. */ void EggCoordinateSystem:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (get_value() != CS_default && get_value() != CS_invalid) { indent(out, indent_level) diff --git a/panda/src/egg/eggCurve.cxx b/panda/src/egg/eggCurve.cxx index 932e4a6c9d..1c18a9ac5e 100644 --- a/panda/src/egg/eggCurve.cxx +++ b/panda/src/egg/eggCurve.cxx @@ -25,7 +25,7 @@ TypeHandle EggCurve::_type_handle; * CurveType value. */ EggCurve::CurveType EggCurve:: -string_curve_type(const string &string) { +string_curve_type(const std::string &string) { if (cmp_nocase_uh(string, "xyz") == 0) { return CT_xyz; } else if (cmp_nocase_uh(string, "hpr") == 0) { @@ -40,7 +40,7 @@ string_curve_type(const string &string) { /** * */ -ostream &operator << (ostream &out, EggCurve::CurveType t) { +std::ostream &operator << (std::ostream &out, EggCurve::CurveType t) { switch (t) { case EggCurve::CT_none: return out << "none"; diff --git a/panda/src/egg/eggData.cxx b/panda/src/egg/eggData.cxx index 84fe2cde3c..75c9ad68d0 100644 --- a/panda/src/egg/eggData.cxx +++ b/panda/src/egg/eggData.cxx @@ -26,6 +26,9 @@ #include "lightMutexHolder.h" #include "zStream.h" +using std::istream; +using std::ostream; + extern int eggyyparse(); #include "parserDefs.h" #include "lexerDefs.h" @@ -59,7 +62,7 @@ resolve_egg_filename(Filename &egg_filename, const DSearchPath &searchpath) { * error is the output stream to which to write error messages. */ bool EggData:: -read(Filename filename, string display_name) { +read(Filename filename, std::string display_name) { filename.set_text(); set_egg_filename(filename); @@ -230,8 +233,8 @@ write_egg(ostream &out) { if (egg_precision > 0) { // Change the egg precision as requested. - streamsize orig_precision = out.precision(); - out.precision((streamsize)egg_precision); + std::streamsize orig_precision = out.precision(); + out.precision((std::streamsize)egg_precision); write(out, 0); out.precision(orig_precision); } else { diff --git a/panda/src/egg/eggExternalReference.cxx b/panda/src/egg/eggExternalReference.cxx index d70a5003db..e124e05238 100644 --- a/panda/src/egg/eggExternalReference.cxx +++ b/panda/src/egg/eggExternalReference.cxx @@ -24,7 +24,7 @@ TypeHandle EggExternalReference::_type_handle; * */ EggExternalReference:: -EggExternalReference(const string &node_name, const string &filename) +EggExternalReference(const std::string &node_name, const std::string &filename) : EggFilenameNode(node_name, filename) { } @@ -49,7 +49,7 @@ operator = (const EggExternalReference ©) { * Writes the reference to the indicated output stream in Egg format. */ void EggExternalReference:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); enquote_string(out, get_filename(), indent_level + 2) << "\n"; indent(out, indent_level) << "}\n"; @@ -58,7 +58,7 @@ write(ostream &out, int indent_level) const { /** * Returns the default extension for this filename type. */ -string EggExternalReference:: +std::string EggExternalReference:: get_default_extension() const { - return string("egg"); + return std::string("egg"); } diff --git a/panda/src/egg/eggFilenameNode.cxx b/panda/src/egg/eggFilenameNode.cxx index b0a257c9a4..83e26aff5f 100644 --- a/panda/src/egg/eggFilenameNode.cxx +++ b/panda/src/egg/eggFilenameNode.cxx @@ -18,7 +18,7 @@ TypeHandle EggFilenameNode::_type_handle; /** * Returns the default extension for this filename type. */ -string EggFilenameNode:: +std::string EggFilenameNode:: get_default_extension() const { - return string(); + return std::string(); } diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index b67d079cce..a5ff1dee06 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -22,6 +22,9 @@ #include "lmatrix.h" #include "dcast.h" +using std::ostream; +using std::string; + TypeHandle EggGroup::_type_handle; diff --git a/panda/src/egg/eggGroupNode.cxx b/panda/src/egg/eggGroupNode.cxx index ef31289424..851eba7f48 100644 --- a/panda/src/egg/eggGroupNode.cxx +++ b/panda/src/egg/eggGroupNode.cxx @@ -39,6 +39,8 @@ #include +using std::string; + TypeHandle EggGroupNode::_type_handle; @@ -79,7 +81,7 @@ EggGroupNode:: * Egg format. */ void EggGroupNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { iterator i; // Since joints tend to reference vertex pools, which sometimes appear later @@ -738,7 +740,7 @@ triangulate_polygons(int flags) { } } - num_produced += max(0, (int)(_children.size() - children_copy.size())); + num_produced += std::max(0, (int)(_children.size() - children_copy.size())); return num_produced; } diff --git a/panda/src/egg/eggGroupUniquifier.cxx b/panda/src/egg/eggGroupUniquifier.cxx index f19b15e10d..b43529a092 100644 --- a/panda/src/egg/eggGroupUniquifier.cxx +++ b/panda/src/egg/eggGroupUniquifier.cxx @@ -18,6 +18,8 @@ #include +using std::string; + TypeHandle EggGroupUniquifier::_type_handle; @@ -95,7 +97,7 @@ filter_name(EggNode *node) { */ string EggGroupUniquifier:: generate_name(EggNode *node, const string &category, int index) { - ostringstream str; + std::ostringstream str; str << node->get_name() << "_group" << index; return str.str(); } diff --git a/panda/src/egg/eggLine.cxx b/panda/src/egg/eggLine.cxx index fca1efd7f1..6ba445a5c8 100644 --- a/panda/src/egg/eggLine.cxx +++ b/panda/src/egg/eggLine.cxx @@ -37,7 +37,7 @@ make_copy() const { * Writes the point to the indicated output stream in Egg format. */ void EggLine:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_thick()) { diff --git a/panda/src/egg/eggMaterial.cxx b/panda/src/egg/eggMaterial.cxx index 8a77c9c0cc..3d543645a1 100644 --- a/panda/src/egg/eggMaterial.cxx +++ b/panda/src/egg/eggMaterial.cxx @@ -22,7 +22,7 @@ TypeHandle EggMaterial::_type_handle; * */ EggMaterial:: -EggMaterial(const string &mref_name) +EggMaterial(const std::string &mref_name) : EggNode(mref_name) { _flags = 0; @@ -54,7 +54,7 @@ EggMaterial(const EggMaterial ©) * format. */ void EggMaterial:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_base()) { diff --git a/panda/src/egg/eggMaterialCollection.cxx b/panda/src/egg/eggMaterialCollection.cxx index 3ccc9c330f..527bd7a0a6 100644 --- a/panda/src/egg/eggMaterialCollection.cxx +++ b/panda/src/egg/eggMaterialCollection.cxx @@ -221,7 +221,7 @@ collapse_equivalent_materials(int eq, EggMaterialCollection::MaterialReplacement ++oti) { EggMaterial *tex = (*oti); - pair result = collapser.insert(tex); + std::pair result = collapser.insert(tex); if (!result.second) { // This material is non-unique; another one was already there. EggMaterial *first = *(result.first); @@ -383,7 +383,7 @@ create_unique_material(const EggMaterial ©, int eq) { * matches. */ EggMaterial *EggMaterialCollection:: -find_mref(const string &mref_name) const { +find_mref(const std::string &mref_name) const { // This requires a complete linear traversal, not terribly efficient. OrderedMaterials::const_iterator oti; for (oti = _ordered_materials.begin(); diff --git a/panda/src/egg/eggMesher.cxx b/panda/src/egg/eggMesher.cxx index 89261d9855..da2334cfaa 100644 --- a/panda/src/egg/eggMesher.cxx +++ b/panda/src/egg/eggMesher.cxx @@ -113,7 +113,7 @@ mesh(EggGroupNode *group, bool flat_shaded) { * */ void EggMesher:: -write(ostream &out) const { +write(std::ostream &out) const { /* out << _edges.size() << " edges:\n"; copy(_edges.begin(), _edges.end(), ostream_iterator(out, "\n")); @@ -704,8 +704,8 @@ make_quads() { // and pair them up right away. The others we'll get to later. This way, // the uncertain matches won't pollute the quad alignment for everyone else. - typedef pair Pair; - typedef pair Matched; + typedef std::pair Pair; + typedef std::pair Matched; typedef pvector SoulMates; SoulMates soulmates; diff --git a/panda/src/egg/eggMesherEdge.cxx b/panda/src/egg/eggMesherEdge.cxx index 1b24891b4e..f270b30de8 100644 --- a/panda/src/egg/eggMesherEdge.cxx +++ b/panda/src/egg/eggMesherEdge.cxx @@ -52,7 +52,7 @@ change_strip(EggMesherStrip *from, EggMesherStrip *to) { * Formats the edge for output in some sensible way. */ void EggMesherEdge:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Edge [" << _vi_a << " to " << _vi_b << "], " << _strips.size() << " strips:"; diff --git a/panda/src/egg/eggMesherFanMaker.cxx b/panda/src/egg/eggMesherFanMaker.cxx index 51396dd32e..09f91e0f0f 100644 --- a/panda/src/egg/eggMesherFanMaker.cxx +++ b/panda/src/egg/eggMesherFanMaker.cxx @@ -326,7 +326,7 @@ unroll(Strips::iterator strip_begin, Strips::iterator strip_end, * */ void EggMesherFanMaker:: -output(ostream &out) const { +output(std::ostream &out) const { out << _vertex << ":["; if (!_edges.empty()) { Edges::const_iterator ei; diff --git a/panda/src/egg/eggMesherStrip.cxx b/panda/src/egg/eggMesherStrip.cxx index cec01dfe36..27260b96b0 100644 --- a/panda/src/egg/eggMesherStrip.cxx +++ b/panda/src/egg/eggMesherStrip.cxx @@ -849,7 +849,7 @@ count_neighbors() const { * Writes all the neighbor indexes to the ostream. */ void EggMesherStrip:: -output_neighbors(ostream &out) const { +output_neighbors(std::ostream &out) const { Edges::const_iterator ei; EggMesherEdge::Strips::const_iterator si; @@ -1350,7 +1350,7 @@ pick_sheet_mate(const EggMesherStrip &a_strip, * Formats the vertex for output in some sensible way. */ void EggMesherStrip:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_status) { case MS_alive: break; diff --git a/panda/src/egg/eggMiscFuncs.cxx b/panda/src/egg/eggMiscFuncs.cxx index 2181622df5..11d684a185 100644 --- a/panda/src/egg/eggMiscFuncs.cxx +++ b/panda/src/egg/eggMiscFuncs.cxx @@ -17,6 +17,9 @@ #include +using std::ostream; +using std::string; + /** * Writes the string to the indicated output stream. If the string contains diff --git a/panda/src/egg/eggNameUniquifier.cxx b/panda/src/egg/eggNameUniquifier.cxx index 34a7123d48..239a2b692b 100644 --- a/panda/src/egg/eggNameUniquifier.cxx +++ b/panda/src/egg/eggNameUniquifier.cxx @@ -19,6 +19,8 @@ #include "pnotify.h" +using std::string; + TypeHandle EggNameUniquifier::_type_handle; @@ -173,7 +175,7 @@ string EggNameUniquifier:: generate_name(EggNode *node, const string &category, int index) { string name = filter_name(node); - ostringstream str; + std::ostringstream str; if (name.empty()) { str << category << index; } else { diff --git a/panda/src/egg/eggNamedObject.cxx b/panda/src/egg/eggNamedObject.cxx index 663cfc3ed6..d397e26f91 100644 --- a/panda/src/egg/eggNamedObject.cxx +++ b/panda/src/egg/eggNamedObject.cxx @@ -22,7 +22,7 @@ TypeHandle EggNamedObject::_type_handle; * */ void EggNamedObject:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); if (has_name()) { out << " " << get_name(); @@ -36,7 +36,7 @@ output(ostream &out) const { * "". */ void EggNamedObject:: -write_header(ostream &out, int indent_level, const char *egg_keyword) const { +write_header(std::ostream &out, int indent_level, const char *egg_keyword) const { indent(out, indent_level) << egg_keyword << " "; if (has_name()) { diff --git a/panda/src/egg/eggNode.cxx b/panda/src/egg/eggNode.cxx index 531f57f2c0..efca0825c7 100644 --- a/panda/src/egg/eggNode.cxx +++ b/panda/src/egg/eggNode.cxx @@ -34,9 +34,9 @@ int EggNode:: rename_node(vector_string strip_prefix) { int num_renamed = 0; for (unsigned int ni = 0; ni < strip_prefix.size(); ++ni) { - string axe_name = strip_prefix[ni]; + std::string axe_name = strip_prefix[ni]; if (this->get_name().substr(0, axe_name.size()) == axe_name) { - string new_name = this->get_name().substr(axe_name.size()); + std::string new_name = this->get_name().substr(axe_name.size()); // cout << "renaming " << this->get_name() << "->" << new_name << endl; this->set_name(new_name); num_renamed += 1; @@ -221,13 +221,13 @@ determine_decal() { * error or if the object does not support this functionality. */ bool EggNode:: -parse_egg(const string &egg_syntax) { +parse_egg(const std::string &egg_syntax) { EggGroupNode *group = get_parent(); if (is_of_type(EggGroupNode::get_class_type())) { DCAST_INTO_R(group, this, false); } - istringstream in(egg_syntax); + std::istringstream in(egg_syntax); LightMutexHolder holder(egg_lock); diff --git a/panda/src/egg/eggNurbsCurve.cxx b/panda/src/egg/eggNurbsCurve.cxx index 79b1d5011b..f0f18a41b5 100644 --- a/panda/src/egg/eggNurbsCurve.cxx +++ b/panda/src/egg/eggNurbsCurve.cxx @@ -118,7 +118,7 @@ is_closed() const { * Writes the nurbsCurve to the indicated output stream in Egg format. */ void EggNurbsCurve:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (get_curve_type() != CT_none) { diff --git a/panda/src/egg/eggNurbsSurface.cxx b/panda/src/egg/eggNurbsSurface.cxx index c89ebfe157..8dc19be6fb 100644 --- a/panda/src/egg/eggNurbsSurface.cxx +++ b/panda/src/egg/eggNurbsSurface.cxx @@ -168,7 +168,7 @@ is_closed_v() const { * Writes the nurbsSurface to the indicated output stream in Egg format. */ void EggNurbsSurface:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); Trims::const_iterator ti; diff --git a/panda/src/egg/eggPatch.cxx b/panda/src/egg/eggPatch.cxx index 0bed947622..f3bbd30444 100644 --- a/panda/src/egg/eggPatch.cxx +++ b/panda/src/egg/eggPatch.cxx @@ -33,7 +33,7 @@ make_copy() const { * Writes the patch to the indicated output stream in Egg format. */ void EggPatch:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); write_body(out, indent_level+2); indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggPoint.cxx b/panda/src/egg/eggPoint.cxx index a344ee59cd..1545b6649d 100644 --- a/panda/src/egg/eggPoint.cxx +++ b/panda/src/egg/eggPoint.cxx @@ -41,7 +41,7 @@ cleanup() { * Writes the point to the indicated output stream in Egg format. */ void EggPoint:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_thick()) { diff --git a/panda/src/egg/eggPolygon.cxx b/panda/src/egg/eggPolygon.cxx index cb783925e1..5863d988e5 100644 --- a/panda/src/egg/eggPolygon.cxx +++ b/panda/src/egg/eggPolygon.cxx @@ -159,7 +159,7 @@ triangulate_in_place(bool convex_also) { * Writes the polygon to the indicated output stream in Egg format. */ void EggPolygon:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); write_body(out, indent_level+2); indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggPolysetMaker.cxx b/panda/src/egg/eggPolysetMaker.cxx index ddd2200df6..83d0de6d89 100644 --- a/panda/src/egg/eggPolysetMaker.cxx +++ b/panda/src/egg/eggPolysetMaker.cxx @@ -66,7 +66,7 @@ sorts_less(int bin_number, const EggNode *a, const EggNode *b) { } } if ((_properties & (P_texture)) != 0) { - int num_textures = min(pa->get_num_textures(), pb->get_num_textures()); + int num_textures = std::min(pa->get_num_textures(), pb->get_num_textures()); for (int i = 0; i < num_textures; i++) { EggTexture *a_texture = pa->get_texture(i); EggTexture *b_texture = pb->get_texture(i); diff --git a/panda/src/egg/eggPoolUniquifier.cxx b/panda/src/egg/eggPoolUniquifier.cxx index 859bd0aff0..86f8eea1e3 100644 --- a/panda/src/egg/eggPoolUniquifier.cxx +++ b/panda/src/egg/eggPoolUniquifier.cxx @@ -33,7 +33,7 @@ EggPoolUniquifier() { * Returns the category name into which the given node should be collected, or * the empty string if the node's name should be left alone. */ -string EggPoolUniquifier:: +std::string EggPoolUniquifier:: get_category(EggNode *node) { if (node->is_of_type(EggTexture::get_class_type())) { return "tex"; @@ -43,5 +43,5 @@ get_category(EggNode *node) { return "vpool"; } - return string(); + return std::string(); } diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index ee35080416..f4985dfc90 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -821,7 +821,7 @@ prepare_remove_vertex(EggVertex *vertex, int i, int n) { * indicated output stream in Egg format. */ void EggPrimitive:: -write_body(ostream &out, int indent_level) const { +write_body(std::ostream &out, int indent_level) const { test_vref_integrity(); EggAttributes::write(out, indent_level); @@ -977,7 +977,7 @@ r_apply_texmats(EggTextureCollection &textures) { EggTexture *unique = textures.create_unique_texture(new_texture, ~0); new_textures.push_back(unique); - string uv_name = unique->get_uv_name(); + std::string uv_name = unique->get_uv_name(); // Now apply the matrix to the vertex UV's. Create new vertices as // necessary. diff --git a/panda/src/egg/eggRenderMode.cxx b/panda/src/egg/eggRenderMode.cxx index 7c7e478a6d..5ac4b05844 100644 --- a/panda/src/egg/eggRenderMode.cxx +++ b/panda/src/egg/eggRenderMode.cxx @@ -16,6 +16,10 @@ #include "string_utils.h" #include "pnotify.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle EggRenderMode::_type_handle; /** diff --git a/panda/src/egg/eggSAnimData.cxx b/panda/src/egg/eggSAnimData.cxx index 27d3a88ed6..2dd63d24a1 100644 --- a/panda/src/egg/eggSAnimData.cxx +++ b/panda/src/egg/eggSAnimData.cxx @@ -48,7 +48,7 @@ optimize() { * Writes the data to the indicated output stream in Egg format. */ void EggSAnimData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (get_num_rows() <= 1) { // We get a lot of these little tiny tables. For brevity, we'll write // these all on one line, because we can. This just makes it easier for a diff --git a/panda/src/egg/eggSwitchCondition.cxx b/panda/src/egg/eggSwitchCondition.cxx index d461c406f7..1515563d50 100644 --- a/panda/src/egg/eggSwitchCondition.cxx +++ b/panda/src/egg/eggSwitchCondition.cxx @@ -45,7 +45,7 @@ make_copy() const { * */ void EggSwitchConditionDistance:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << " {\n"; indent(out, indent_level+2) << " { " << _switch_in << " " << _switch_out; diff --git a/panda/src/egg/eggTable.cxx b/panda/src/egg/eggTable.cxx index b8372e41af..234c40c5f8 100644 --- a/panda/src/egg/eggTable.cxx +++ b/panda/src/egg/eggTable.cxx @@ -41,7 +41,7 @@ has_transform() const { * Egg format. */ void EggTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { test_under_integrity(); switch (get_table_type()) { @@ -69,7 +69,7 @@ write(ostream &out, int indent_level) const { * TableType value. */ EggTable::TableType EggTable:: -string_table_type(const string &string) { +string_table_type(const std::string &string) { if (cmp_nocase_uh(string, "table") == 0) { return TT_table; } else if (cmp_nocase_uh(string, "bundle") == 0) { @@ -137,7 +137,7 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv, /** * */ -ostream &operator << (ostream &out, EggTable::TableType t) { +std::ostream &operator << (std::ostream &out, EggTable::TableType t) { switch (t) { case EggTable::TT_invalid: return out << "invalid table"; diff --git a/panda/src/egg/eggTexture.cxx b/panda/src/egg/eggTexture.cxx index 85327cb915..eb2cfa7342 100644 --- a/panda/src/egg/eggTexture.cxx +++ b/panda/src/egg/eggTexture.cxx @@ -18,6 +18,9 @@ #include "indent.h" #include "string_utils.h" +using std::ostream; +using std::string; + TypeHandle EggTexture::_type_handle; diff --git a/panda/src/egg/eggTextureCollection.cxx b/panda/src/egg/eggTextureCollection.cxx index 38ee134048..0c1b46eea7 100644 --- a/panda/src/egg/eggTextureCollection.cxx +++ b/panda/src/egg/eggTextureCollection.cxx @@ -271,7 +271,7 @@ collapse_equivalent_textures(int eq, EggTextureCollection::TextureReplacement &r ++oti) { EggTexture *tex = (*oti); - pair result = collapser.insert(tex); + std::pair result = collapser.insert(tex); if (!result.second) { // This texture is non-unique; another one was already there. EggTexture *first = *(result.first); @@ -453,7 +453,7 @@ create_unique_texture(const EggTexture ©, int eq) { * matches. */ EggTexture *EggTextureCollection:: -find_tref(const string &tref_name) const { +find_tref(const std::string &tref_name) const { // This requires a complete linear traversal, not terribly efficient. OrderedTextures::const_iterator oti; for (oti = _ordered_textures.begin(); diff --git a/panda/src/egg/eggTransform.cxx b/panda/src/egg/eggTransform.cxx index 67ce77e1bc..65ba63c3e7 100644 --- a/panda/src/egg/eggTransform.cxx +++ b/panda/src/egg/eggTransform.cxx @@ -186,7 +186,7 @@ add_uniform_scale(double scale) { * Writes the transform to the indicated stream in Egg format. */ void EggTransform:: -write(ostream &out, int indent_level, const string &label) const { +write(std::ostream &out, int indent_level, const std::string &label) const { indent(out, indent_level) << label << " {\n"; int num_components = get_num_components(); diff --git a/panda/src/egg/eggTriangleFan.cxx b/panda/src/egg/eggTriangleFan.cxx index 6ad3b4f5ae..5287d1c8e9 100644 --- a/panda/src/egg/eggTriangleFan.cxx +++ b/panda/src/egg/eggTriangleFan.cxx @@ -38,7 +38,7 @@ make_copy() const { * Writes the triangle fan to the indicated output stream in Egg format. */ void EggTriangleFan:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); write_body(out, indent_level+2); indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggTriangleStrip.cxx b/panda/src/egg/eggTriangleStrip.cxx index 5882471c9e..a0aa83b144 100644 --- a/panda/src/egg/eggTriangleStrip.cxx +++ b/panda/src/egg/eggTriangleStrip.cxx @@ -38,7 +38,7 @@ make_copy() const { * Writes the triangle strip to the indicated output stream in Egg format. */ void EggTriangleStrip:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); write_body(out, indent_level+2); indent(out, indent_level) << "}\n"; diff --git a/panda/src/egg/eggVertex.cxx b/panda/src/egg/eggVertex.cxx index 5272a9f034..cebf9608e7 100644 --- a/panda/src/egg/eggVertex.cxx +++ b/panda/src/egg/eggVertex.cxx @@ -26,6 +26,9 @@ #include #include +using std::ostream; +using std::string; + TypeHandle EggVertex::_type_handle; diff --git a/panda/src/egg/eggVertexAux.cxx b/panda/src/egg/eggVertexAux.cxx index 6b12ee538b..b421c527f6 100644 --- a/panda/src/egg/eggVertexAux.cxx +++ b/panda/src/egg/eggVertexAux.cxx @@ -22,7 +22,7 @@ TypeHandle EggVertexAux::_type_handle; * */ EggVertexAux:: -EggVertexAux(const string &name, const LVecBase4d &aux) : +EggVertexAux(const std::string &name, const LVecBase4d &aux) : EggNamedObject(name), _aux(aux) { @@ -72,8 +72,8 @@ make_average(const EggVertexAux *first, const EggVertexAux *second) { * */ void EggVertexAux:: -write(ostream &out, int indent_level) const { - string inline_name = get_name(); +write(std::ostream &out, int indent_level) const { + std::string inline_name = get_name(); if (!inline_name.empty()) { inline_name += ' '; } diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index e3b3cad248..8fa3b5e637 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -20,6 +20,8 @@ #include +using std::string; + TypeHandle EggVertexPool::_type_handle; /** @@ -176,7 +178,7 @@ get_num_dimensions() const { IndexVertices::const_iterator ivi; for (ivi = _index_vertices.begin(); ivi != _index_vertices.end(); ++ivi) { EggVertex *vertex = (*ivi).second; - num_dimensions = max(num_dimensions, vertex->get_num_dimensions()); + num_dimensions = std::max(num_dimensions, vertex->get_num_dimensions()); } return num_dimensions; @@ -438,7 +440,7 @@ add_vertex(EggVertex *vertex, int index) { !vertex->is_forward_reference()) { (*orig_vertex) = (*vertex); orig_vertex->_forward_reference = false; - _highest_index = max(_highest_index, index); + _highest_index = std::max(_highest_index, index); return orig_vertex; } @@ -450,7 +452,7 @@ add_vertex(EggVertex *vertex, int index) { _index_vertices[index] = vertex; if (!vertex->is_forward_reference()) { - _highest_index = max(_highest_index, index); + _highest_index = std::max(_highest_index, index); } vertex->_pool = this; @@ -761,7 +763,7 @@ sort_by_external_index() { * Writes the vertex pool to the indicated output stream in Egg format. */ void EggVertexPool:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); iterator i; diff --git a/panda/src/egg/eggVertexUV.cxx b/panda/src/egg/eggVertexUV.cxx index 4ba501d4c3..49a3c39ace 100644 --- a/panda/src/egg/eggVertexUV.cxx +++ b/panda/src/egg/eggVertexUV.cxx @@ -22,7 +22,7 @@ TypeHandle EggVertexUV::_type_handle; * */ EggVertexUV:: -EggVertexUV(const string &name, const LTexCoordd &uv) : +EggVertexUV(const std::string &name, const LTexCoordd &uv) : EggNamedObject(name), _flags(0), _uvw(uv[0], uv[1], 0.0) @@ -36,7 +36,7 @@ EggVertexUV(const string &name, const LTexCoordd &uv) : * */ EggVertexUV:: -EggVertexUV(const string &name, const LTexCoord3d &uvw) : +EggVertexUV(const std::string &name, const LTexCoord3d &uvw) : EggNamedObject(name), _flags(F_has_w), _uvw(uvw) @@ -124,8 +124,8 @@ transform(const LMatrix4d &mat) { * */ void EggVertexUV:: -write(ostream &out, int indent_level) const { - string inline_name = get_name(); +write(std::ostream &out, int indent_level) const { + std::string inline_name = get_name(); if (!inline_name.empty()) { inline_name += ' '; } diff --git a/panda/src/egg/eggXfmAnimData.cxx b/panda/src/egg/eggXfmAnimData.cxx index 62ed89f1c3..73a7128036 100644 --- a/panda/src/egg/eggXfmAnimData.cxx +++ b/panda/src/egg/eggXfmAnimData.cxx @@ -164,7 +164,7 @@ is_anim_matrix() const { * Writes the data to the indicated output stream in Egg format. */ void EggXfmAnimData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_fps()) { diff --git a/panda/src/egg/eggXfmSAnim.cxx b/panda/src/egg/eggXfmSAnim.cxx index c28d8c6c4e..43a784b33f 100644 --- a/panda/src/egg/eggXfmSAnim.cxx +++ b/panda/src/egg/eggXfmSAnim.cxx @@ -23,6 +23,8 @@ #include +using std::string; + TypeHandle EggXfmSAnim::_type_handle; const string EggXfmSAnim::_standard_order = "srpht"; @@ -138,7 +140,7 @@ is_anim_matrix() const { * Writes the data to the indicated output stream in Egg format. */ void EggXfmSAnim:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { test_under_integrity(); write_header(out, indent_level, ""); @@ -271,7 +273,7 @@ get_num_rows() const { min_rows = sanim->get_num_rows(); } else { - min_rows = min(min_rows, sanim->get_num_rows()); + min_rows = std::min(min_rows, sanim->get_num_rows()); } } } diff --git a/panda/src/egg/lexer.cxx.prebuilt b/panda/src/egg/lexer.cxx.prebuilt index ef8160d2c2..c736ac335e 100644 --- a/panda/src/egg/lexer.cxx.prebuilt +++ b/panda/src/egg/lexer.cxx.prebuilt @@ -963,6 +963,10 @@ char *eggyytext; #include +using std::istream; +using std::ostream; +using std::string; + extern "C" int eggyywrap(void); // declared below. static int yyinput(void); // declared by flex. @@ -1072,7 +1076,7 @@ eggyyerror(const string &msg) { } void -eggyyerror(ostringstream &strm) { +eggyyerror(std::ostringstream &strm) { string s = strm.str(); eggyyerror(s); } @@ -1098,8 +1102,8 @@ eggyywarning(const string &msg) { } void -eggyywarning(ostringstream &strm) { - string s = strm.str(); +eggyywarning(std::ostringstream &strm) { + std::string s = strm.str(); eggyywarning(s); } @@ -1117,7 +1121,7 @@ input_chars(char *buffer, int &result, int max_size) { // from the stream, copy it into the current_line array. This // is because the \n.* rule below, which fills current_line // normally, doesn't catch the first line. - int length = min(max_error_width, result); + int length = std::min(max_error_width, result); strncpy(current_line, buffer, length); current_line[length] = '\0'; line_number++; @@ -1212,7 +1216,7 @@ eat_c_comment() { c = read_char(line, col); while (c != EOF && !(last_c == '*' && c == '/')) { if (last_c == '/' && c == '*') { - ostringstream errmsg; + std::ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " << line << ", column " << col-1 << "--possibly unclosed?" << std::ends; diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index 468a393418..1c07166635 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -18,6 +18,10 @@ #include +using std::istream; +using std::ostream; +using std::string; + extern "C" int eggyywrap(void); // declared below. static int yyinput(void); // declared by flex. @@ -127,7 +131,7 @@ eggyyerror(const string &msg) { } void -eggyyerror(ostringstream &strm) { +eggyyerror(std::ostringstream &strm) { string s = strm.str(); eggyyerror(s); } @@ -153,7 +157,7 @@ eggyywarning(const string &msg) { } void -eggyywarning(ostringstream &strm) { +eggyywarning(std::ostringstream &strm) { string s = strm.str(); eggyywarning(s); } @@ -172,7 +176,7 @@ input_chars(char *buffer, int &result, int max_size) { // from the stream, copy it into the current_line array. This // is because the \n.* rule below, which fills current_line // normally, doesn't catch the first line. - int length = min(max_error_width, result); + int length = std::min(max_error_width, result); strncpy(current_line, buffer, length); current_line[length] = '\0'; line_number++; @@ -267,7 +271,7 @@ eat_c_comment() { c = read_char(line, col); while (c != EOF && !(last_c == '*' && c == '/')) { if (last_c == '/' && c == '*') { - ostringstream errmsg; + std::ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " << line << ", column " << col-1 << "--possibly unclosed?" << std::ends; diff --git a/panda/src/egg/parser.cxx.prebuilt b/panda/src/egg/parser.cxx.prebuilt index b25f0abf32..f9a81a30a5 100644 --- a/panda/src/egg/parser.cxx.prebuilt +++ b/panda/src/egg/parser.cxx.prebuilt @@ -129,6 +129,10 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 +using std::istream; +using std::ostringstream; +using std::string; + // We need a stack of EggObject pointers. Each time we encounter a // nested EggObject of some kind, we'll allocate a new one of these // and push it onto the stack. At any given time, the top of the diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index 8bdd6ee39d..1ffaa3a078 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -57,6 +57,10 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 +using std::istream; +using std::ostringstream; +using std::string; + // We need a stack of EggObject pointers. Each time we encounter a // nested EggObject of some kind, we'll allocate a new one of these // and push it onto the stack. At any given time, the top of the diff --git a/panda/src/egg/test_egg.cxx b/panda/src/egg/test_egg.cxx index ae91d3548d..8023145331 100644 --- a/panda/src/egg/test_egg.cxx +++ b/panda/src/egg/test_egg.cxx @@ -28,7 +28,7 @@ main(int argc, char *argv[]) { if (data.read(egg_filename)) { data.load_externals(DSearchPath(Filename(""))); - data.write_egg(cout); + data.write_egg(std::cout); } else { nout << "Errors.\n"; } diff --git a/panda/src/egg2pg/animBundleMaker.cxx b/panda/src/egg2pg/animBundleMaker.cxx index b32f6d79a5..ea5ac4285f 100644 --- a/panda/src/egg2pg/animBundleMaker.cxx +++ b/panda/src/egg2pg/animBundleMaker.cxx @@ -25,6 +25,8 @@ #include "animChannelMatrixXfmTable.h" #include "animChannelScalarTable.h" +using std::min; + /** * */ @@ -212,7 +214,7 @@ build_hierarchy(EggTable *egg_table, AnimGroup *parent) { * structure. */ AnimChannelScalarTable *AnimBundleMaker:: -create_s_channel(EggSAnimData *egg_anim, const string &name, +create_s_channel(EggSAnimData *egg_anim, const std::string &name, AnimGroup *parent) { AnimChannelScalarTable *table = new AnimChannelScalarTable(parent, name); @@ -236,7 +238,7 @@ create_s_channel(EggSAnimData *egg_anim, const string &name, * structure, if possible. */ AnimChannelMatrixXfmTable *AnimBundleMaker:: -create_xfm_channel(EggNode *egg_node, const string &name, +create_xfm_channel(EggNode *egg_node, const std::string &name, AnimGroup *parent) { if (egg_node->is_of_type(EggXfmAnimData::get_class_type())) { EggXfmAnimData *egg_anim = DCAST(EggXfmAnimData, egg_node); @@ -260,7 +262,7 @@ create_xfm_channel(EggNode *egg_node, const string &name, * structure. */ AnimChannelMatrixXfmTable *AnimBundleMaker:: -create_xfm_channel(EggXfmSAnim *egg_anim, const string &name, +create_xfm_channel(EggXfmSAnim *egg_anim, const std::string &name, AnimGroup *parent) { // Ensure that the anim table is optimal and that it is standard order. egg_anim->optimize_to_standard_order(); diff --git a/panda/src/egg2pg/characterMaker.cxx b/panda/src/egg2pg/characterMaker.cxx index 11c3a4e9b4..f087ebf88e 100644 --- a/panda/src/egg2pg/characterMaker.cxx +++ b/panda/src/egg2pg/characterMaker.cxx @@ -34,6 +34,8 @@ #include "eggAnimPreload.h" #include "animPreloadTable.h" +using std::string; + diff --git a/panda/src/egg2pg/eggBinner.cxx b/panda/src/egg2pg/eggBinner.cxx index 66471661f8..9d24341f91 100644 --- a/panda/src/egg2pg/eggBinner.cxx +++ b/panda/src/egg2pg/eggBinner.cxx @@ -76,13 +76,13 @@ get_bin_number(const EggNode *node) { * May be overridden in derived classes to define a name for each new bin, * based on its bin number, and a sample child. */ -string EggBinner:: +std::string EggBinner:: get_bin_name(int bin_number, const EggNode *child) { if (bin_number == BN_polyset || bin_number == BN_patches) { return DCAST(EggPrimitive, child)->get_sort_name(); } - return string(); + return std::string(); } /** diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index ae2c30a8c3..e26a4120b9 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -100,6 +100,10 @@ #include #include +using std::max; +using std::min; +using std::string; + // This class is used in make_node(EggBin *) to sort LOD instances in order by // switching distance. class LODInstance { @@ -2584,7 +2588,7 @@ make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, // Insert the primitive into the set, but if we already have a primitive of // that type, reset the pointer to that one instead. PrimitiveUnifier pu(primitive); - pair result = + std::pair result = unique_primitives.insert(UniquePrimitives::value_type(pu, primitive)); if (result.second) { diff --git a/panda/src/egg2pg/eggRenderState.cxx b/panda/src/egg2pg/eggRenderState.cxx index 5612826ec0..4c5baf6e3a 100644 --- a/panda/src/egg2pg/eggRenderState.cxx +++ b/panda/src/egg2pg/eggRenderState.cxx @@ -59,7 +59,7 @@ fill_state(EggPrimitive *egg_prim) { bool has_depth_offset = false; int depth_offset = 0; bool has_bin = false; - string bin; + std::string bin; EggRenderMode *render_mode; render_mode = egg_prim->determine_alpha_mode(); @@ -151,7 +151,7 @@ fill_state(EggPrimitive *egg_prim) { // of textures that share this same set of UV's per each unique texture // matrix. Whew!) CPT(InternalName) uv_name; - if (egg_tex->has_uv_name() && egg_tex->get_uv_name() != string("default")) { + if (egg_tex->has_uv_name() && egg_tex->get_uv_name() != std::string("default")) { uv_name = InternalName::get_texcoord_name(egg_tex->get_uv_name()); } else { uv_name = InternalName::get_texcoord(); diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index af70617e36..fb6bb3a59b 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -75,6 +75,9 @@ #include "eggTable.h" #include "dcast.h" +using std::pair; +using std::string; + /** * */ @@ -191,7 +194,7 @@ convert_lod_node(LODNode *node, const WorkingNodePath &node_path, int num_children = node->get_num_children(); int num_switches = node->get_num_switches(); - num_children = min(num_children, num_switches); + num_children = std::min(num_children, num_switches); for (int i = 0; i < num_children; i++) { PandaNode *child = node->get_child(i); @@ -1148,7 +1151,7 @@ apply_state_properties(EggRenderMode *egg_render_mode, const RenderState *state) */ bool EggSaver:: apply_tags(EggGroup *egg_group, PandaNode *node) { - ostringstream strm; + std::ostringstream strm; char delimiter = '\n'; string delimiter_str(1, delimiter); node->list_tags(strm, delimiter_str); diff --git a/panda/src/egg2pg/load_egg_file.cxx b/panda/src/egg2pg/load_egg_file.cxx index bee738af4b..f6f3fa8f8b 100644 --- a/panda/src/egg2pg/load_egg_file.cxx +++ b/panda/src/egg2pg/load_egg_file.cxx @@ -94,7 +94,7 @@ load_egg_file(const Filename &filename, CoordinateSystem cs, loader._data->set_egg_timestamp(vfile->get_timestamp()); bool okflag; - istream *istr = vfile->open_read_file(true); + std::istream *istr = vfile->open_read_file(true); if (istr == nullptr) { egg2pg_cat.error() << "Couldn't read " << egg_filename << "\n"; diff --git a/panda/src/egg2pg/loaderFileTypeEgg.cxx b/panda/src/egg2pg/loaderFileTypeEgg.cxx index a5bbd96210..281e2ca51f 100644 --- a/panda/src/egg2pg/loaderFileTypeEgg.cxx +++ b/panda/src/egg2pg/loaderFileTypeEgg.cxx @@ -29,7 +29,7 @@ LoaderFileTypeEgg() { /** * */ -string LoaderFileTypeEgg:: +std::string LoaderFileTypeEgg:: get_name() const { return "Egg"; } @@ -37,7 +37,7 @@ get_name() const { /** * */ -string LoaderFileTypeEgg:: +std::string LoaderFileTypeEgg:: get_extension() const { return "egg"; } diff --git a/panda/src/egldisplay/config_egldisplay.cxx b/panda/src/egldisplay/config_egldisplay.cxx index 9f9bf13770..f76b1b9d1f 100644 --- a/panda/src/egldisplay/config_egldisplay.cxx +++ b/panda/src/egldisplay/config_egldisplay.cxx @@ -63,7 +63,7 @@ init_libegldisplay() { /** * Returns the given EGL error as string. */ -const string get_egl_error_string(int error) { +const std::string get_egl_error_string(int error) { switch (error) { case 0x3000: return "EGL_SUCCESS"; break; case 0x3001: return "EGL_NOT_INITIALIZED"; break; diff --git a/panda/src/egldisplay/eglGraphicsBuffer.cxx b/panda/src/egldisplay/eglGraphicsBuffer.cxx index 07057818ab..a0cf71f1fa 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.cxx +++ b/panda/src/egldisplay/eglGraphicsBuffer.cxx @@ -26,7 +26,7 @@ TypeHandle eglGraphicsBuffer::_type_handle; */ eglGraphicsBuffer:: eglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/egldisplay/eglGraphicsPipe.cxx b/panda/src/egldisplay/eglGraphicsPipe.cxx index 93ddb7f92c..17594f799e 100644 --- a/panda/src/egldisplay/eglGraphicsPipe.cxx +++ b/panda/src/egldisplay/eglGraphicsPipe.cxx @@ -25,7 +25,7 @@ TypeHandle eglGraphicsPipe::_type_handle; * */ eglGraphicsPipe:: -eglGraphicsPipe(const string &display) : x11GraphicsPipe(display) { +eglGraphicsPipe(const std::string &display) : x11GraphicsPipe(display) { _egl_display = eglGetDisplay((NativeDisplayType) _display); if (!eglInitialize(_egl_display, nullptr, nullptr)) { egldisplay_cat.error() @@ -59,7 +59,7 @@ eglGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string eglGraphicsPipe:: +std::string eglGraphicsPipe:: get_interface_name() const { return "OpenGL ES"; } @@ -77,7 +77,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) eglGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/egldisplay/eglGraphicsPixmap.cxx b/panda/src/egldisplay/eglGraphicsPixmap.cxx index ec34b460a3..5933416f5c 100644 --- a/panda/src/egldisplay/eglGraphicsPixmap.cxx +++ b/panda/src/egldisplay/eglGraphicsPixmap.cxx @@ -27,7 +27,7 @@ TypeHandle eglGraphicsPixmap::_type_handle; */ eglGraphicsPixmap:: eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx index 0d9a70e910..31c1069d46 100644 --- a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx +++ b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx @@ -258,8 +258,8 @@ reset() { // If "Mesa" is present, assume software. However, if "Mesa DRI" is found, // it's actually a Mesa-based OpenGL layer running over a hardware driver. if (_gl_renderer == "Software Rasterizer" || - (_gl_renderer.find("Mesa") != string::npos && - _gl_renderer.find("Mesa DRI") == string::npos)) { + (_gl_renderer.find("Mesa") != std::string::npos && + _gl_renderer.find("Mesa DRI") == std::string::npos)) { // It's Mesa, therefore probably a software context. _fbprops.set_force_software(1); _fbprops.set_force_hardware(0); diff --git a/panda/src/egldisplay/eglGraphicsWindow.cxx b/panda/src/egldisplay/eglGraphicsWindow.cxx index 094d4ae547..29f7ffbf49 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.cxx +++ b/panda/src/egldisplay/eglGraphicsWindow.cxx @@ -34,7 +34,7 @@ TypeHandle eglGraphicsWindow::_type_handle; */ eglGraphicsWindow:: eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/event/asyncFuture.cxx b/panda/src/event/asyncFuture.cxx index d97173d54d..16540954ed 100644 --- a/panda/src/event/asyncFuture.cxx +++ b/panda/src/event/asyncFuture.cxx @@ -55,7 +55,7 @@ cancel() { * */ void AsyncFuture:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); FutureState state = (FutureState)AtomicAdjust::get(_future_state); switch (state) { @@ -159,7 +159,7 @@ notify_done(bool clean_exit) { if (clean_exit && !_done_event.empty()) { PT_Event event = new Event(_done_event); event->add_parameter(EventParameter(this)); - throw_event(move(event)); + throw_event(std::move(event)); } } @@ -308,7 +308,7 @@ wake_task(AsyncTask *task) { */ AsyncGatheringFuture:: AsyncGatheringFuture(AsyncFuture::Futures futures) : - _futures(move(futures)), + _futures(std::move(futures)), _num_pending(0) { bool any_pending = false; diff --git a/panda/src/event/asyncFuture_ext.cxx b/panda/src/event/asyncFuture_ext.cxx index 3150c09d7d..00ee3516b1 100644 --- a/panda/src/event/asyncFuture_ext.cxx +++ b/panda/src/event/asyncFuture_ext.cxx @@ -306,7 +306,7 @@ gather(PyObject *args) { return Dtool_Raise_ArgTypeError(item, i, "gather", "coroutine, task or future"); } - AsyncFuture *future = AsyncFuture::gather(move(futures)); + AsyncFuture *future = AsyncFuture::gather(std::move(futures)); if (future != nullptr) { future->ref(); return DTool_CreatePyInstanceTyped((void *)future, Dtool_AsyncFuture, true, false, future->get_type_index()); diff --git a/panda/src/event/asyncTask.cxx b/panda/src/event/asyncTask.cxx index f5a796643c..806d8e87af 100644 --- a/panda/src/event/asyncTask.cxx +++ b/panda/src/event/asyncTask.cxx @@ -18,6 +18,8 @@ #include "throw_event.h" #include "eventParameter.h" +using std::string; + AtomicAdjust::Integer AsyncTask::_next_task_id; PStatCollector AsyncTask::_show_code_pcollector("App:Show code"); TypeHandle AsyncTask::_type_handle; @@ -187,7 +189,7 @@ set_name(const string &name) { size_t end = name.size(); size_t colon = name.find(':'); if (colon != string::npos) { - end = min(end, colon); + end = std::min(end, colon); } // If the name ends with a hyphen followed by a string of digits, we strip @@ -364,7 +366,7 @@ set_priority(int priority) { * */ void AsyncTask:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); if (has_name()) { out << " " << get_name(); @@ -427,7 +429,7 @@ unlock_and_do_task() { _manager->_lock.lock(); _dt = end - start; - _max_dt = max(_dt, _max_dt); + _max_dt = std::max(_dt, _max_dt); _total_dt += _dt; _chain->_time_in_frame += _dt; diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index eb00a5b08d..34e458691e 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -23,6 +23,11 @@ #include #include // For sprintf/snprintf +using std::max; +using std::ostream; +using std::ostringstream; +using std::string; + TypeHandle AsyncTaskChain::_type_handle; PStatCollector AsyncTaskChain::_task_pcollector("Task"); diff --git a/panda/src/event/asyncTaskCollection.cxx b/panda/src/event/asyncTaskCollection.cxx index af5b1bc2f5..b6fd56fece 100644 --- a/panda/src/event/asyncTaskCollection.cxx +++ b/panda/src/event/asyncTaskCollection.cxx @@ -174,7 +174,7 @@ clear() { * if no task has that name. */ AsyncTask *AsyncTaskCollection:: -find_task(const string &name) const { +find_task(const std::string &name) const { size_t num_tasks = get_num_tasks(); for (size_t i = 0; i < num_tasks; ++i) { AsyncTask *task = get_task(i); @@ -246,7 +246,7 @@ size() const { * indicated output stream. */ void AsyncTaskCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_tasks() == 1) { out << "1 AsyncTask"; } else { @@ -259,7 +259,7 @@ output(ostream &out) const { * indicated output stream. */ void AsyncTaskCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (size_t i = 0; i < get_num_tasks(); i++) { indent(out, indent_level) << *get_task(i) << "\n"; } diff --git a/panda/src/event/asyncTaskManager.cxx b/panda/src/event/asyncTaskManager.cxx index a9bab44898..b80908ddc5 100644 --- a/panda/src/event/asyncTaskManager.cxx +++ b/panda/src/event/asyncTaskManager.cxx @@ -22,6 +22,8 @@ #include "config_event.h" #include +using std::string; + AsyncTaskManager *AsyncTaskManager::_global_ptr = nullptr; TypeHandle AsyncTaskManager::_type_handle; @@ -508,7 +510,7 @@ get_next_wake_time() const { got_any = true; next_wake_time = time; } else { - next_wake_time = min(time, next_wake_time); + next_wake_time = std::min(time, next_wake_time); } } } @@ -520,7 +522,7 @@ get_next_wake_time() const { * */ void AsyncTaskManager:: -output(ostream &out) const { +output(std::ostream &out) const { MutexHolder holder(_lock); do_output(out); } @@ -529,7 +531,7 @@ output(ostream &out) const { * */ void AsyncTaskManager:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { MutexHolder holder(_lock); indent(out, indent_level) << get_type() << " " << get_name() << "\n"; @@ -629,7 +631,7 @@ do_has_task(AsyncTask *task) const { * */ void AsyncTaskManager:: -do_output(ostream &out) const { +do_output(std::ostream &out) const { out << get_type() << " " << get_name() << "; " << _num_tasks << " tasks"; } diff --git a/panda/src/event/asyncTaskSequence.cxx b/panda/src/event/asyncTaskSequence.cxx index b84a968386..82541ec8da 100644 --- a/panda/src/event/asyncTaskSequence.cxx +++ b/panda/src/event/asyncTaskSequence.cxx @@ -20,7 +20,7 @@ TypeHandle AsyncTaskSequence::_type_handle; * */ AsyncTaskSequence:: -AsyncTaskSequence(const string &name) : +AsyncTaskSequence(const std::string &name) : AsyncTask(name), _repeat_count(0), _task_index(0) diff --git a/panda/src/event/buttonEvent.cxx b/panda/src/event/buttonEvent.cxx index 38dbbffb6a..170812958b 100644 --- a/panda/src/event/buttonEvent.cxx +++ b/panda/src/event/buttonEvent.cxx @@ -21,7 +21,7 @@ * */ void ButtonEvent:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_type) { case T_down: out << "button " << _button << " down"; diff --git a/panda/src/event/buttonEventList.cxx b/panda/src/event/buttonEventList.cxx index 633329a5a1..21c9d45981 100644 --- a/panda/src/event/buttonEventList.cxx +++ b/panda/src/event/buttonEventList.cxx @@ -45,7 +45,7 @@ update_mods(ModifierButtons &mods) const { * */ void ButtonEventList:: -output(ostream &out) const { +output(std::ostream &out) const { if (_events.empty()) { out << "(no buttons)"; } else { @@ -65,7 +65,7 @@ output(ostream &out) const { * */ void ButtonEventList:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _events.size() << " events:\n"; Events::const_iterator ei; for (ei = _events.begin(); ei != _events.end(); ++ei) { diff --git a/panda/src/event/event.cxx b/panda/src/event/event.cxx index 4453b890f3..8a46d2586f 100644 --- a/panda/src/event/event.cxx +++ b/panda/src/event/event.cxx @@ -20,7 +20,7 @@ TypeHandle Event::_type_handle; * */ Event:: -Event(const string &event_name, EventReceiver *receiver) : +Event(const std::string &event_name, EventReceiver *receiver) : _name(event_name) { _receiver = receiver; @@ -117,7 +117,7 @@ clear_receiver() { * */ void Event:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name(); out << "("; diff --git a/panda/src/event/eventHandler.cxx b/panda/src/event/eventHandler.cxx index 998946e92b..f74bd8c519 100644 --- a/panda/src/event/eventHandler.cxx +++ b/panda/src/event/eventHandler.cxx @@ -15,6 +15,8 @@ #include "eventQueue.h" #include "config_event.h" +using std::string; + TypeHandle EventHandler::_type_handle; EventHandler *EventHandler::_global_event_handler = nullptr; @@ -82,7 +84,7 @@ dispatch_event(const Event *event) { event_cat->spam() << "calling callback 0x" << (void*)(*fi) << " for event '" << event->get_name() << "'" - << endl; + << std::endl; } (*fi)(event); } @@ -120,7 +122,7 @@ dispatch_event(const Event *event) { * */ void EventHandler:: -write(ostream &out) const { +write(std::ostream &out) const { Hooks::const_iterator hi; hi = _hooks.begin(); @@ -165,7 +167,7 @@ add_hook(const string &event_name, EventFunction *function) { if (event_cat.is_debug()) { event_cat.debug() << "adding hook for event '" << event_name - << "' with function 0x" << (void*)function << endl; + << "' with function 0x" << (void*)function << std::endl; } assert(!event_name.empty()); assert(function); @@ -357,7 +359,7 @@ make_global_event_handler() { * */ void EventHandler:: -write_hook(ostream &out, const EventHandler::Hooks::value_type &hook) const { +write_hook(std::ostream &out, const EventHandler::Hooks::value_type &hook) const { if (!hook.second.empty()) { out << hook.first << " has " << hook.second.size() << " functions.\n"; } @@ -367,7 +369,7 @@ write_hook(ostream &out, const EventHandler::Hooks::value_type &hook) const { * */ void EventHandler:: -write_cbhook(ostream &out, const EventHandler::CallbackHooks::value_type &hook) const { +write_cbhook(std::ostream &out, const EventHandler::CallbackHooks::value_type &hook) const { if (!hook.second.empty()) { out << hook.first << " has " << hook.second.size() << " callback functions.\n"; } diff --git a/panda/src/event/eventParameter.cxx b/panda/src/event/eventParameter.cxx index 40122908cd..37f6690dae 100644 --- a/panda/src/event/eventParameter.cxx +++ b/panda/src/event/eventParameter.cxx @@ -21,7 +21,7 @@ template class ParamValue; * */ void EventParameter:: -output(ostream &out) const { +output(std::ostream &out) const { if (_ptr == nullptr) { out << "(empty)"; diff --git a/panda/src/event/genericAsyncTask.cxx b/panda/src/event/genericAsyncTask.cxx index c0d68fa3ff..f78fddecc3 100644 --- a/panda/src/event/genericAsyncTask.cxx +++ b/panda/src/event/genericAsyncTask.cxx @@ -20,7 +20,7 @@ TypeHandle GenericAsyncTask::_type_handle; * */ GenericAsyncTask:: -GenericAsyncTask(const string &name) : +GenericAsyncTask(const std::string &name) : AsyncTask(name) { _function = nullptr; @@ -33,7 +33,7 @@ GenericAsyncTask(const string &name) : * */ GenericAsyncTask:: -GenericAsyncTask(const string &name, GenericAsyncTask::TaskFunc *function, void *user_data) : +GenericAsyncTask(const std::string &name, GenericAsyncTask::TaskFunc *function, void *user_data) : AsyncTask(name), _function(function), _user_data(user_data) diff --git a/panda/src/event/pointerEvent.cxx b/panda/src/event/pointerEvent.cxx index 8e64a3c58b..7ee7d3621c 100644 --- a/panda/src/event/pointerEvent.cxx +++ b/panda/src/event/pointerEvent.cxx @@ -19,7 +19,7 @@ * */ void PointerEvent:: -output(ostream &out) const { +output(std::ostream &out) const { out << (_in_window ? "In@" : "Out@") << _xpos << "," << _ypos << " "; } diff --git a/panda/src/event/pointerEventList.cxx b/panda/src/event/pointerEventList.cxx index fc376bc886..4c9d8472c2 100644 --- a/panda/src/event/pointerEventList.cxx +++ b/panda/src/event/pointerEventList.cxx @@ -48,7 +48,7 @@ INLINE double normalize_angle(double angle) { * */ void PointerEventList:: -output(ostream &out) const { +output(std::ostream &out) const { if (_events.empty()) { out << "(no pointers)"; } else { @@ -68,7 +68,7 @@ output(ostream &out) const { * */ void PointerEventList:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _events.size() << " events:\n"; Events::const_iterator ei; for (ei = _events.begin(); ei != _events.end(); ++ei) { @@ -172,7 +172,7 @@ total_turns(double sec) const { * to be in order to be considered significant. */ double PointerEventList:: -match_pattern(const string &ascpat, double rot, double seglen) { +match_pattern(const std::string &ascpat, double rot, double seglen) { // Convert the pattern from ascii to a more usable form. vector_double pattern; parse_pattern(ascpat, pattern); @@ -189,7 +189,7 @@ match_pattern(const string &ascpat, double rot, double seglen) { * Parses a pattern as used by match_pattern. */ void PointerEventList:: -parse_pattern(const string &ascpat, vector_double &pattern) { +parse_pattern(const std::string &ascpat, vector_double &pattern) { int chars = 0; double dir = 180.0; for (size_t i=0; i= 3 PyObject *str = PyObject_ASCII(result); if (str == nullptr) { @@ -742,7 +742,7 @@ do_python_task() { #endif Py_DECREF(str); Py_DECREF(result); - string message = strm.str(); + std::string message = strm.str(); nassert_raise(message); return DS_interrupt; diff --git a/panda/src/event/test_task.cxx b/panda/src/event/test_task.cxx index 958742f747..e8cc5cb5ef 100644 --- a/panda/src/event/test_task.cxx +++ b/panda/src/event/test_task.cxx @@ -16,9 +16,11 @@ #include "asyncTaskManager.h" #include "perlinNoise2.h" +using std::cerr; + class MyTask : public AsyncTask { public: - MyTask(const string &name, double length, int repeat_count) : + MyTask(const std::string &name, double length, int repeat_count) : AsyncTask(name), _length(length), _repeat_count(repeat_count) @@ -62,12 +64,12 @@ main(int argc, char *argv[]) { cerr << "Making tasks.\n"; for (int yi = 0; yi < grid_size; ++yi) { for (int xi = 0; xi < grid_size; ++xi) { - ostringstream namestrm; + std::ostringstream namestrm; namestrm << "task_" << xi << "_" << yi; - double length = max(length_noise.noise(xi, yi) + 1.0, 0.0); - double delay = max(delay_noise.noise(xi, yi), 0.0) * 3.0; - int repeat_count = (int)floor(max(repeat_count_noise.noise(xi, yi) + 1.0, 0.0) * 1.5); + double length = std::max(length_noise.noise(xi, yi) + 1.0, 0.0); + double delay = std::max(delay_noise.noise(xi, yi), 0.0) * 3.0; + int repeat_count = (int)floor(std::max(repeat_count_noise.noise(xi, yi) + 1.0, 0.0) * 1.5); int sort = (int)floor(sort_noise.noise(xi, yi) * 2.0); int priority = (int)floor(priority_noise.noise(xi, yi) * 5.0); diff --git a/panda/src/express/checksumHashGenerator.cxx b/panda/src/express/checksumHashGenerator.cxx index fbcf1b7563..0de99789fd 100644 --- a/panda/src/express/checksumHashGenerator.cxx +++ b/panda/src/express/checksumHashGenerator.cxx @@ -17,9 +17,9 @@ * Adds a string to the hash, by breaking it down into a sequence of integers. */ void ChecksumHashGenerator:: -add_string(const string &str) { +add_string(const std::string &str) { add_int(str.length()); - string::const_iterator si; + std::string::const_iterator si; for (si = str.begin(); si != str.end(); ++si) { add_int(*si); } diff --git a/panda/src/express/compress_string.cxx b/panda/src/express/compress_string.cxx index 4d1069e34c..d4c08ddb39 100644 --- a/panda/src/express/compress_string.cxx +++ b/panda/src/express/compress_string.cxx @@ -18,6 +18,12 @@ #include "virtualFileSystem.h" #include "config_express.h" +using std::istream; +using std::istringstream; +using std::ostream; +using std::ostringstream; +using std::string; + /** * Compress the indicated source string at the given compression level (1 * through 9). Returns the compressed string. diff --git a/panda/src/express/copy_stream.cxx b/panda/src/express/copy_stream.cxx index 77d0e78364..e04e681772 100644 --- a/panda/src/express/copy_stream.cxx +++ b/panda/src/express/copy_stream.cxx @@ -19,7 +19,7 @@ * true on success, false on failure. */ bool -copy_stream(istream &source, ostream &dest) { +copy_stream(std::istream &source, std::ostream &dest) { static const size_t buffer_size = 4096; char buffer[buffer_size]; diff --git a/panda/src/express/datagram.cxx b/panda/src/express/datagram.cxx index 826a261f93..de7d4089dc 100644 --- a/panda/src/express/datagram.cxx +++ b/panda/src/express/datagram.cxx @@ -41,7 +41,7 @@ clear() { * hex (and ASCII) values. */ void Datagram:: -dump_hex(ostream &out, unsigned int indent) const { +dump_hex(std::ostream &out, unsigned int indent) const { const char *message = (const char *)get_data(); size_t num_bytes = get_length(); for (size_t line = 0; line < num_bytes; line += 16) { @@ -80,13 +80,13 @@ dump_hex(ostream &out, unsigned int indent) const { * Adds a variable-length wstring to the datagram. */ void Datagram:: -add_wstring(const wstring &str) { +add_wstring(const std::wstring &str) { // By convention, wstrings are marked with 32-bit lengths. add_uint32((uint32_t)str.length()); // Now append each character in the string. We store each code little- // endian, for no real good reason. - wstring::const_iterator ci; + std::wstring::const_iterator ci; for (ci = str.begin(); ci != str.end(); ++ci) { add_uint16((uint16_t)*ci); } @@ -168,7 +168,7 @@ assign(const void *data, size_t size) { * Write a string representation of this instance to . */ void Datagram:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<""<<"Datagram"; #endif //] NDEBUG @@ -178,7 +178,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void Datagram:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"Datagram:\n"; diff --git a/panda/src/express/datagramGenerator.cxx b/panda/src/express/datagramGenerator.cxx index 08d792bd70..275a050e88 100644 --- a/panda/src/express/datagramGenerator.cxx +++ b/panda/src/express/datagramGenerator.cxx @@ -86,7 +86,7 @@ get_vfile() { * pointing to the first byte following the datagram returned after a call to * get_datagram(). */ -streampos DatagramGenerator:: +std::streampos DatagramGenerator:: get_file_pos() { return 0; } diff --git a/panda/src/express/datagramIterator.cxx b/panda/src/express/datagramIterator.cxx index 4006ec1eea..680ead3a66 100644 --- a/panda/src/express/datagramIterator.cxx +++ b/panda/src/express/datagramIterator.cxx @@ -14,6 +14,9 @@ #include "datagramIterator.h" #include "pnotify.h" +using std::string; +using std::wstring; + TypeHandle DatagramIterator::_type_handle; /** @@ -156,7 +159,7 @@ extract_bytes(unsigned char *into, size_t size) { * Write a string representation of this instance to . */ void DatagramIterator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<""<<"DatagramIterator"; #endif //] NDEBUG @@ -166,7 +169,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void DatagramIterator:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"DatagramIterator:\n"; out.width(indent+2); out<<""<<"_current_index "<<_current_index; diff --git a/panda/src/express/datagramSink.cxx b/panda/src/express/datagramSink.cxx index 5b451d3bb2..bdf2be596c 100644 --- a/panda/src/express/datagramSink.cxx +++ b/panda/src/express/datagramSink.cxx @@ -80,7 +80,7 @@ get_file() { * pointing to the first byte following the datagram returned after a call to * put_datagram(). */ -streampos DatagramSink:: +std::streampos DatagramSink:: get_file_pos() { return 0; } diff --git a/panda/src/express/encrypt_string.cxx b/panda/src/express/encrypt_string.cxx index be2100cee8..6c400d77f7 100644 --- a/panda/src/express/encrypt_string.cxx +++ b/panda/src/express/encrypt_string.cxx @@ -18,6 +18,12 @@ #include "virtualFileSystem.h" #include "config_express.h" +using std::istream; +using std::istringstream; +using std::ostream; +using std::ostringstream; +using std::string; + /** * Encrypts the indicated source string using the given password, and the * algorithm specified by encryption-algorithm. Returns the encrypted string. diff --git a/panda/src/express/error_utils.cxx b/panda/src/express/error_utils.cxx index 8a1ec79331..8509856f18 100644 --- a/panda/src/express/error_utils.cxx +++ b/panda/src/express/error_utils.cxx @@ -21,6 +21,8 @@ #include #endif +using std::string; + /** * */ @@ -229,7 +231,7 @@ string handle_socket_error() { errmsg = strerror(errno); default: if (express_cat.is_debug()) - express_cat.debug() << "handle_socket_error - unknown error: " << err << endl; + express_cat.debug() << "handle_socket_error - unknown error: " << err << std::endl; errmsg = "Unknown WSA error"; } @@ -282,12 +284,12 @@ get_network_error() { if (express_cat.is_debug()) express_cat.debug() << "get_network_error() - WSA error = 0 - error : " - << strerror(errno) << endl; + << strerror(errno) << std::endl; return EU_error_abort; default: if (express_cat.is_debug()) express_cat.debug() - << "get_network_error() - unknown error: " << err << endl; + << "get_network_error() - unknown error: " << err << std::endl; return EU_error_abort; } #endif diff --git a/panda/src/express/hashVal.cxx b/panda/src/express/hashVal.cxx index 797ead2ed2..3d2e6f42f5 100644 --- a/panda/src/express/hashVal.cxx +++ b/panda/src/express/hashVal.cxx @@ -20,6 +20,12 @@ #include "openssl/md5.h" #endif // HAVE_OPENSSL +using std::istream; +using std::istringstream; +using std::ostream; +using std::ostringstream; +using std::string; + /** * Outputs the HashVal as a 32-digit hexadecimal number. @@ -53,7 +59,7 @@ input_hex(istream &in) { } if (i != 32) { - in.clear(ios::failbit|in.rdstate()); + in.clear(std::ios::failbit|in.rdstate()); return; } @@ -203,7 +209,7 @@ hash_stream(istream &stream) { char buffer[buffer_size]; // Seek the stream to the beginning in case it wasn't there already. - stream.seekg(0, ios::beg); + stream.seekg(0, std::ios::beg); stream.read(buffer, buffer_size); size_t count = stream.gcount(); diff --git a/panda/src/express/make_ca_bundle.cxx b/panda/src/express/make_ca_bundle.cxx index a619a0a9f1..0773bb88ec 100644 --- a/panda/src/express/make_ca_bundle.cxx +++ b/panda/src/express/make_ca_bundle.cxx @@ -15,6 +15,10 @@ #include "openSSLWrapper.h" #include +using std::cerr; +using std::stringstream; +using std::string; + static const char *source_filename = "ca-bundle.crt"; static const char *target_filename = "ca_bundle_data_src.c"; @@ -45,7 +49,7 @@ main(int argc, char *argv[]) { << " entries.\n"; // Now convert the certificates to DER form. - stringstream der_stream; + std::stringstream der_stream; int cert_count = 0; int num_entries = sk_X509_INFO_num(inf); @@ -78,7 +82,7 @@ main(int argc, char *argv[]) { } der_stream.seekg(0); - istream &in = der_stream; + std::istream &in = der_stream; string table_type = "const unsigned char "; string length_type = "const int "; @@ -99,7 +103,7 @@ main(int argc, char *argv[]) { << " * in DER form, for compiling into OpenSSLWrapper.\n" << " */\n\n" << static_keyword << table_type << table_name << "[] = {"; - out << hex << setfill('0'); + out << std::hex << std::setfill('0'); int count = 0; int col = 0; unsigned int ch; @@ -113,14 +117,14 @@ main(int argc, char *argv[]) { } else { out << ", "; } - out << "0x" << setw(2) << ch; + out << "0x" << std::setw(2) << ch; col++; count++; ch = in.get(); } out << "\n};\n\n" << static_keyword << length_type << table_name << "_len = " - << dec << count << ";\n\n"; + << std::dec << count << ";\n\n"; cerr << "Wrote " << cert_count << " certificates to " << target_filename << "\n"; diff --git a/panda/src/express/memoryUsage.cxx b/panda/src/express/memoryUsage.cxx index d38ac0c77e..b76ae0ed3e 100644 --- a/panda/src/express/memoryUsage.cxx +++ b/panda/src/express/memoryUsage.cxx @@ -27,6 +27,8 @@ #include #include +using std::pair; + MemoryUsage *MemoryUsage::_global_ptr; // This flag is used to protect the operator newdelete handlers against @@ -79,7 +81,7 @@ show() const { #ifdef DO_MEMORY_USAGE // First, copy the relevant information to a vector so we can sort by // counts. Don't use a pvector. - typedef vector CountSorter; + typedef std::vector CountSorter; CountSorter count_sorter; Counts::const_iterator ci; for (ci = _counts.begin(); ci != _counts.end(); ++ci) { diff --git a/panda/src/express/memoryUsagePointerCounts.cxx b/panda/src/express/memoryUsagePointerCounts.cxx index b91be61bcc..8ce69872d6 100644 --- a/panda/src/express/memoryUsagePointerCounts.cxx +++ b/panda/src/express/memoryUsagePointerCounts.cxx @@ -34,7 +34,7 @@ add_info(MemoryInfo *info) { * */ void MemoryUsagePointerCounts:: -output(ostream &out) const { +output(std::ostream &out) const { #ifdef DO_MEMORY_USAGE out << _count << " pointers"; if (_unknown_size_count < _count) { @@ -56,7 +56,7 @@ output(ostream &out) const { * units. */ void MemoryUsagePointerCounts:: -output_bytes(ostream &out, size_t size) { +output_bytes(std::ostream &out, size_t size) { #ifdef DO_MEMORY_USAGE if (size < 4 * 1024) { out << size << " bytes"; diff --git a/panda/src/express/memoryUsagePointers.cxx b/panda/src/express/memoryUsagePointers.cxx index dd412958da..065519bc0c 100644 --- a/panda/src/express/memoryUsagePointers.cxx +++ b/panda/src/express/memoryUsagePointers.cxx @@ -111,7 +111,7 @@ get_type(size_t n) const { /** * Returns the type name of the nth pointer, if it is known. */ -string MemoryUsagePointers:: +std::string MemoryUsagePointers:: get_type_name(size_t n) const { #ifdef DO_MEMORY_USAGE nassertr(n < get_num_pointers(), ""); @@ -150,7 +150,7 @@ clear() { * */ void MemoryUsagePointers:: -output(ostream &out) const { +output(std::ostream &out) const { #ifdef DO_MEMORY_USAGE out << _entries.size() << " pointers."; #endif diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 064262747a..e625861f87 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -28,6 +28,19 @@ #include "openSSLWrapper.h" +using std::ios; +using std::iostream; +using std::istream; +using std::max; +using std::min; +using std::ostream; +using std::ostringstream; +using std::streamoff; +using std::streampos; +using std::streamsize; +using std::stringstream; +using std::string; + // This sequence of bytes begins each Multifile to identify it as a Multifile. const char Multifile::_header[] = "pmf\0\n\r"; const size_t Multifile::_header_size = 6; @@ -1997,7 +2010,7 @@ add_new_subfile(Subfile *subfile, int compression_level) { _needs_repack = true; } - pair insert_result = _subfiles.insert(subfile); + std::pair insert_result = _subfiles.insert(subfile); if (!insert_result.second) { // Hmm, unable to insert. There must already be a subfile by that name. // Remove the old one. diff --git a/panda/src/express/openSSLWrapper.cxx b/panda/src/express/openSSLWrapper.cxx index 97fe936d21..d71818e130 100644 --- a/panda/src/express/openSSLWrapper.cxx +++ b/panda/src/express/openSSLWrapper.cxx @@ -63,7 +63,7 @@ OpenSSLWrapper() { int num_certs = ssl_certificates.get_num_unique_values(); for (int ci = 0; ci < num_certs; ci++) { - string cert_file = ssl_certificates.get_unique_value(ci); + std::string cert_file = ssl_certificates.get_unique_value(ci); Filename filename = Filename::expand_from(cert_file); load_certificates(filename); } @@ -108,7 +108,7 @@ load_certificates(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); // First, read the complete file into memory. - string data; + std::string data; if (!vfs->read_file(filename, data, true)) { // Could not find or read file. express_cat.info() diff --git a/panda/src/express/password_hash.cxx b/panda/src/express/password_hash.cxx index a3385013df..b061904965 100644 --- a/panda/src/express/password_hash.cxx +++ b/panda/src/express/password_hash.cxx @@ -21,6 +21,8 @@ #include "openssl/evp.h" #include "memoryHook.h" +using std::string; + /** * Generates a non-reversible hash of a particular length based on an * arbitrary password and a random salt. This is much stronger than the diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index 9c0ebc9481..4c6d9984f4 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -35,6 +35,14 @@ istream *Patchfile::_tar_istream = nullptr; #endif // HAVE_TAR +using std::endl; +using std::ios; +using std::istream; +using std::min; +using std::ostream; +using std::streampos; +using std::string; + // this actually slows things down... #define // USE_MD5_FOR_HASHTABLE_INDEX_VALUES diff --git a/panda/src/express/profileTimer.cxx b/panda/src/express/profileTimer.cxx index 78df0afbd4..dfad4b03b4 100644 --- a/panda/src/express/profileTimer.cxx +++ b/panda/src/express/profileTimer.cxx @@ -13,6 +13,9 @@ #include "pmap.h" +using std::ostream; +using std::string; + // See ProfileTimer.h for documentation. @@ -127,7 +130,7 @@ consolidateTo(ostream &out) const { << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total << " seconds]\n" << "-------------------------------------------------------------------\n"; - out << endl; + out << std::endl; } void ProfileTimer:: @@ -156,7 +159,7 @@ printTo(ostream &out) const { << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total << " seconds]\n" << "-------------------------------------------------------------------\n"; - out << endl; + out << std::endl; } ProfileTimer::AutoTimer::AutoTimer(ProfileTimer& profile, const char* tag) : diff --git a/panda/src/express/ramfile.cxx b/panda/src/express/ramfile.cxx index cc12e239c7..c1994df34c 100644 --- a/panda/src/express/ramfile.cxx +++ b/panda/src/express/ramfile.cxx @@ -21,10 +21,10 @@ * The interface here is intentionally designed to be similar to that for * Python's file.read() function. */ -string Ramfile:: +std::string Ramfile:: read(size_t length) { size_t orig_pos = _pos; - _pos = min(_pos + length, _data.length()); + _pos = std::min(_pos + length, _data.length()); return _data.substr(orig_pos, length); } @@ -36,7 +36,7 @@ read(size_t length) { * The interface here is intentionally designed to be similar to that for * Python's file.readline() function. */ -string Ramfile:: +std::string Ramfile:: readline() { size_t start = _pos; while (_pos < _data.length() && _data[_pos] != '\n') { diff --git a/panda/src/express/ramfile_ext.cxx b/panda/src/express/ramfile_ext.cxx index c52641abca..fc1047487c 100644 --- a/panda/src/express/ramfile_ext.cxx +++ b/panda/src/express/ramfile_ext.cxx @@ -23,8 +23,8 @@ PyObject *Extension:: read(size_t length) { size_t data_length = _this->get_data_size(); const char *data = _this->_data.data() + _this->_pos; - length = min(length, data_length - _this->_pos); - _this->_pos = min(_this->_pos + length, data_length); + length = std::min(length, data_length - _this->_pos); + _this->_pos = std::min(_this->_pos + length, data_length); #if PY_MAJOR_VERSION >= 3 return PyBytes_FromStringAndSize((char *)data, length); @@ -43,7 +43,7 @@ read(size_t length) { */ PyObject *Extension:: readline() { - string line = _this->readline(); + std::string line = _this->readline(); #if PY_MAJOR_VERSION >= 3 return PyBytes_FromStringAndSize(line.data(), line.size()); #else @@ -62,7 +62,7 @@ readlines() { return nullptr; } - string line = _this->readline(); + std::string line = _this->readline(); while (!line.empty()) { #if PY_MAJOR_VERSION >= 3 PyObject *py_line = PyBytes_FromStringAndSize(line.data(), line.size()); diff --git a/panda/src/express/subStreamBuf.cxx b/panda/src/express/subStreamBuf.cxx index 0a3f44da9e..4d773e359f 100644 --- a/panda/src/express/subStreamBuf.cxx +++ b/panda/src/express/subStreamBuf.cxx @@ -15,6 +15,11 @@ #include "pnotify.h" #include "memoryHook.h" +using std::ios; +using std::streamoff; +using std::streampos; +using std::streamsize; + static const size_t substream_buffer_size = 4096; /** diff --git a/panda/src/express/subfileInfo.cxx b/panda/src/express/subfileInfo.cxx index 07ab4fc7f8..55631b25af 100644 --- a/panda/src/express/subfileInfo.cxx +++ b/panda/src/express/subfileInfo.cxx @@ -17,6 +17,6 @@ * */ void SubfileInfo:: -output(ostream &out) const { +output(std::ostream &out) const { out << "SubfileInfo(" << get_filename() << ", " << _start << ", " << _size << ")"; } diff --git a/panda/src/express/test_ordered_vector.cxx b/panda/src/express/test_ordered_vector.cxx index 1ed3ba9c96..18c0ab6d1d 100644 --- a/panda/src/express/test_ordered_vector.cxx +++ b/panda/src/express/test_ordered_vector.cxx @@ -13,11 +13,13 @@ #include "ordered_vector.h" +using std::cerr; + typedef ov_multiset myvec; void search(myvec &v, int element) { - pair result; + std::pair result; result = v.equal_range(element); size_t count = v.count(element); diff --git a/panda/src/express/test_types.cxx b/panda/src/express/test_types.cxx index 7cc5cf6e61..1bc9bfefd7 100644 --- a/panda/src/express/test_types.cxx +++ b/panda/src/express/test_types.cxx @@ -19,6 +19,9 @@ #include "pnotify.h" +using std::cerr; +using std::string; + class ThatThingie : public TypedObject, public ReferenceCount { public: ThatThingie(const string &name) : _name(name) { diff --git a/panda/src/express/test_zstream.cxx b/panda/src/express/test_zstream.cxx index 34212eb2df..6040aa3ca7 100644 --- a/panda/src/express/test_zstream.cxx +++ b/panda/src/express/test_zstream.cxx @@ -17,6 +17,10 @@ #include +using std::cerr; +using std::cout; +using std::istream; + void stream_decompress(istream &source) { IDecompressStream zstream(&source, false); @@ -42,7 +46,7 @@ stream_compress(istream &source) { void zlib_decompress(istream &source) { // First, read the entire contents into a buffer. - string data; + std::string data; int ch = source.get(); while (!source.eof() && !source.fail()) { @@ -82,7 +86,7 @@ zlib_decompress(istream &source) { void zlib_compress(istream &source) { // First, read the entire contents into a buffer. - string data; + std::string data; int ch = source.get(); while (!source.eof() && !source.fail()) { diff --git a/panda/src/express/trueClock.cxx b/panda/src/express/trueClock.cxx index ea60c5bb1e..f60ddc22dc 100644 --- a/panda/src/express/trueClock.cxx +++ b/panda/src/express/trueClock.cxx @@ -17,6 +17,9 @@ #include // for fabs() +using std::max; +using std::min; + TrueClock *TrueClock::_global_ptr = nullptr; #if defined(WIN32_VC) || defined(WIN64_VC) @@ -169,7 +172,7 @@ TrueClock() { if (_has_high_res) { if (int_frequency <= 0) { clock_cat.error() - << "TrueClock::get_real_time() - frequency is negative!" << endl; + << "TrueClock::get_real_time() - frequency is negative!" << std::endl; _has_high_res = false; } else { @@ -198,7 +201,7 @@ TrueClock() { if (!_has_high_res) { clock_cat.warning() - << "No high resolution clock available." << endl; + << "No high resolution clock available." << std::endl; } } diff --git a/panda/src/express/virtualFile.cxx b/panda/src/express/virtualFile.cxx index 37068adcab..e388d7c704 100644 --- a/panda/src/express/virtualFile.cxx +++ b/panda/src/express/virtualFile.cxx @@ -18,6 +18,11 @@ #include "pvector.h" #include +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFile::_type_handle; /** @@ -284,7 +289,7 @@ close_read_write_file(iostream *stream) { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFile:: +std::streamsize VirtualFile:: get_file_size(istream *stream) const { return get_file_size(); } @@ -293,7 +298,7 @@ get_file_size(istream *stream) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFile:: +std::streamsize VirtualFile:: get_file_size() const { return 0; } @@ -412,14 +417,14 @@ simple_read_file(istream *in, vector_uchar &result, size_t max_bytes) { static const size_t buffer_size = 4096; char buffer[buffer_size]; - in->read(buffer, min(buffer_size, max_bytes)); + in->read(buffer, std::min(buffer_size, max_bytes)); size_t count = in->gcount(); while (count != 0) { thread_consider_yield(); nassertr(count <= max_bytes, false); result.insert(result.end(), buffer, buffer + count); max_bytes -= count; - in->read(buffer, min(buffer_size, max_bytes)); + in->read(buffer, std::min(buffer_size, max_bytes)); count = in->gcount(); } diff --git a/panda/src/express/virtualFileComposite.cxx b/panda/src/express/virtualFileComposite.cxx index 30a5cbb0d9..63c4f8d569 100644 --- a/panda/src/express/virtualFileComposite.cxx +++ b/panda/src/express/virtualFileComposite.cxx @@ -57,7 +57,7 @@ is_directory() const { */ bool VirtualFileComposite:: scan_local_directory(VirtualFileList *file_list, - const ov_set &mount_points) const { + const ov_set &mount_points) const { bool any_ok = false; Components::const_iterator ci; for (ci = _components.begin(); ci != _components.end(); ++ci) { diff --git a/panda/src/express/virtualFileMount.cxx b/panda/src/express/virtualFileMount.cxx index 6f8a46afda..37e3554ac2 100644 --- a/panda/src/express/virtualFileMount.cxx +++ b/panda/src/express/virtualFileMount.cxx @@ -16,6 +16,11 @@ #include "virtualFileSystem.h" #include "zStream.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFileMount::_type_handle; @@ -134,7 +139,7 @@ read_file(const Filename &file, bool do_uncompress, return false; } - streamsize file_size = get_file_size(file, in); + std::streamsize file_size = get_file_size(file, in); if (file_size > 0) { result.reserve((size_t)file_size); } diff --git a/panda/src/express/virtualFileMountAndroidAsset.cxx b/panda/src/express/virtualFileMountAndroidAsset.cxx index fa5fccece3..c9074fe97a 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.cxx +++ b/panda/src/express/virtualFileMountAndroidAsset.cxx @@ -20,6 +20,10 @@ #include #endif +using std::streamoff; +using std::streampos; +using std::streamsize; + TypeHandle VirtualFileMountAndroidAsset::_type_handle; /** @@ -140,7 +144,7 @@ read_file(const Filename &file, bool do_uncompress, * istream on success (which you should eventually delete when you are done * reading). Returns NULL on failure. */ -istream *VirtualFileMountAndroidAsset:: +std::istream *VirtualFileMountAndroidAsset:: open_read_file(const Filename &file) const { AAsset* asset; asset = AAssetManager_open(_asset_mgr, file.c_str(), AASSET_MODE_UNKNOWN); @@ -149,7 +153,7 @@ open_read_file(const Filename &file) const { } AssetStream *stream = new AssetStream(asset); - return (istream *) stream; + return (std::istream *) stream; } /** @@ -158,7 +162,7 @@ open_read_file(const Filename &file) const { * implementations may require this stream to determine the size. */ streamsize VirtualFileMountAndroidAsset:: -get_file_size(const Filename &file, istream *in) const { +get_file_size(const Filename &file, std::istream *in) const { // If it's already open, get the AAsset pointer from the streambuf. const AssetStreamBuf *buf = (const AssetStreamBuf *) in->rdbuf(); off_t length = AAsset_getLength(buf->_asset); diff --git a/panda/src/express/virtualFileMountMultifile.cxx b/panda/src/express/virtualFileMountMultifile.cxx index 1ecd5b7b5e..1c9a0782ba 100644 --- a/panda/src/express/virtualFileMountMultifile.cxx +++ b/panda/src/express/virtualFileMountMultifile.cxx @@ -85,7 +85,7 @@ read_file(const Filename &file, bool do_uncompress, * istream on success (which you should eventually delete when you are done * reading). Returns NULL on failure. */ -istream *VirtualFileMountMultifile:: +std::istream *VirtualFileMountMultifile:: open_read_file(const Filename &file) const { int subfile_index = _multifile->find_subfile(file); if (subfile_index < 0) { @@ -104,8 +104,8 @@ open_read_file(const Filename &file) const { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileMountMultifile:: -get_file_size(const Filename &file, istream *) const { +std::streamsize VirtualFileMountMultifile:: +get_file_size(const Filename &file, std::istream *) const { int subfile_index = _multifile->find_subfile(file); if (subfile_index < 0) { return 0; @@ -117,7 +117,7 @@ get_file_size(const Filename &file, istream *) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileMountMultifile:: +std::streamsize VirtualFileMountMultifile:: get_file_size(const Filename &file) const { int subfile_index = _multifile->find_subfile(file); if (subfile_index < 0) { @@ -167,7 +167,7 @@ get_system_info(const Filename &file, SubfileInfo &info) { return false; } - streampos start = _multifile->get_subfile_internal_start(subfile_index); + std::streampos start = _multifile->get_subfile_internal_start(subfile_index); size_t length = _multifile->get_subfile_internal_length(subfile_index); info = SubfileInfo(multifile_name, start, length); @@ -189,6 +189,6 @@ scan_directory(vector_string &contents, const Filename &dir) const { * */ void VirtualFileMountMultifile:: -output(ostream &out) const { +output(std::ostream &out) const { out << _multifile->get_multifile_name(); } diff --git a/panda/src/express/virtualFileMountRamdisk.cxx b/panda/src/express/virtualFileMountRamdisk.cxx index 2f1f481b3d..feda85d1f6 100644 --- a/panda/src/express/virtualFileMountRamdisk.cxx +++ b/panda/src/express/virtualFileMountRamdisk.cxx @@ -15,6 +15,11 @@ #include "subStream.h" #include "dcast.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFileMountRamdisk::_type_handle; TypeHandle VirtualFileMountRamdisk::FileBase::_type_handle; TypeHandle VirtualFileMountRamdisk::File::_type_handle; @@ -241,7 +246,7 @@ open_write_file(const Filename &file, bool truncate) { // second, since the timer only has a one second precision. The proper // solution to fix this would be to switch to a higher precision // timer everywhere. - f->_timestamp = max(f->_timestamp + 1, time(nullptr)); + f->_timestamp = std::max(f->_timestamp + 1, time(nullptr)); } return new OSubStream(&f->_wrapper, 0, 0); @@ -283,7 +288,7 @@ open_read_write_file(const Filename &file, bool truncate) { f->_data.str(string()); // See open_write_file - f->_timestamp = max(f->_timestamp + 1, time(nullptr)); + f->_timestamp = std::max(f->_timestamp + 1, time(nullptr)); } return new SubStream(&f->_wrapper, 0, 0); @@ -312,7 +317,7 @@ open_read_append_file(const Filename &file) { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileMountRamdisk:: +std::streamsize VirtualFileMountRamdisk:: get_file_size(const Filename &file, istream *stream) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); @@ -329,7 +334,7 @@ get_file_size(const Filename &file, istream *stream) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileMountRamdisk:: +std::streamsize VirtualFileMountRamdisk:: get_file_size(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); diff --git a/panda/src/express/virtualFileMountSystem.cxx b/panda/src/express/virtualFileMountSystem.cxx index 4ef0d32ab1..ebf5fa6645 100644 --- a/panda/src/express/virtualFileMountSystem.cxx +++ b/panda/src/express/virtualFileMountSystem.cxx @@ -14,6 +14,13 @@ #include "virtualFileMountSystem.h" #include "virtualFileSystem.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::streampos; +using std::streamsize; +using std::string; + TypeHandle VirtualFileMountSystem::_type_handle; @@ -297,7 +304,7 @@ get_file_size(const Filename &file, istream *stream) const { streampos orig = stream->tellg(); // Seek to the end and get the stream position there. - stream->seekg(0, ios::end); + stream->seekg(0, std::ios::end); if (stream->fail()) { // Seeking not supported. stream->clear(); @@ -306,7 +313,7 @@ get_file_size(const Filename &file, istream *stream) const { streampos size = stream->tellg(); // Then return to the original point. - stream->seekg(orig, ios::beg); + stream->seekg(orig, std::ios::beg); // Make sure there are no error flags set as a result of the seek. stream->clear(); diff --git a/panda/src/express/virtualFileSimple.cxx b/panda/src/express/virtualFileSimple.cxx index c5810934f9..11ee94cce9 100644 --- a/panda/src/express/virtualFileSimple.cxx +++ b/panda/src/express/virtualFileSimple.cxx @@ -16,6 +16,11 @@ #include "virtualFileList.h" #include "dcast.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + TypeHandle VirtualFileSimple::_type_handle; @@ -308,7 +313,7 @@ close_read_write_file(iostream *stream) { * file. Pass in the stream that was returned by open_read_file(); some * implementations may require this stream to determine the size. */ -streamsize VirtualFileSimple:: +std::streamsize VirtualFileSimple:: get_file_size(istream *stream) const { return _mount->get_file_size(_local_filename, stream); } @@ -317,7 +322,7 @@ get_file_size(istream *stream) const { * Returns the current size on disk (or wherever it is) of the file before it * has been opened. */ -streamsize VirtualFileSimple:: +std::streamsize VirtualFileSimple:: get_file_size() const { return _mount->get_file_size(_local_filename); } diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index 0262392216..eb915b566c 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -25,6 +25,11 @@ #include "executionEnvironment.h" #include "pset.h" +using std::iostream; +using std::istream; +using std::ostream; +using std::string; + VirtualFileSystem *VirtualFileSystem::_global_ptr = nullptr; diff --git a/panda/src/express/windowsRegistry.cxx b/panda/src/express/windowsRegistry.cxx index 29255a5e74..b96091c299 100644 --- a/panda/src/express/windowsRegistry.cxx +++ b/panda/src/express/windowsRegistry.cxx @@ -21,6 +21,8 @@ #endif #include +using std::string; + /** * Sets the registry key to the indicated value as a string. The supplied * string value is automatically converted from whatever encoding is set by @@ -32,7 +34,7 @@ set_string_value(const string &key, const string &name, const string &value, WindowsRegistry::RegLevel rl) { TextEncoder encoder; - wstring wvalue = encoder.decode_text(value); + std::wstring wvalue = encoder.decode_text(value); // Now convert the string to Windows' idea of the correct wide-char // encoding, so we can store it in the registry. This might well be the @@ -152,7 +154,7 @@ get_string_value(const string &key, const string &name, data.data(), data.length(), wide_result, wide_result_len); - wstring wdata(wide_result, wide_result_len); + std::wstring wdata(wide_result, wide_result_len); TextEncoder encoder; string result = encoder.encode_wtext(wdata); diff --git a/panda/src/express/zStreamBuf.cxx b/panda/src/express/zStreamBuf.cxx index c037252895..877254918d 100644 --- a/panda/src/express/zStreamBuf.cxx +++ b/panda/src/express/zStreamBuf.cxx @@ -18,6 +18,10 @@ #include "pnotify.h" #include "config_express.h" +using std::ios; +using std::streamoff; +using std::streampos; + #if !defined(USE_MEMORY_NOWRAPPERS) && !defined(CPPPARSER) // Define functions that hook zlib into panda's memory allocation system. static void * @@ -69,7 +73,7 @@ ZStreamBuf:: * */ void ZStreamBuf:: -open_read(istream *source, bool owns_source) { +open_read(std::istream *source, bool owns_source) { _source = source; _owns_source = owns_source; @@ -120,7 +124,7 @@ close_read() { * */ void ZStreamBuf:: -open_write(ostream *dest, bool owns_dest, int compression_level) { +open_write(std::ostream *dest, bool owns_dest, int compression_level) { _dest = dest; _owns_dest = owns_dest; @@ -392,7 +396,7 @@ write_chars(const char *start, size_t length, int flush) { */ void ZStreamBuf:: show_zlib_error(const char *function, int error_code, z_stream &z) { - stringstream error_line; + std::stringstream error_line; error_line << "zlib error in " << function << ": "; diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 2536f85e3c..8746540af2 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -259,7 +259,7 @@ start_thread() { if (_thread_status == TS_stopped && _max_readahead_frames > 0) { // Get a unique name for the thread's sync name. - ostringstream strm; + std::ostringstream strm; strm << (void *)this; _sync_name = strm.str(); @@ -337,7 +337,7 @@ set_time(double timestamp, int loop_count) { } // No point in trying to position before the first frame. - frame = max(frame, _initial_dts); + frame = std::max(frame, _initial_dts); if (ffmpeg_cat.is_spam() && frame != _current_frame) { ffmpeg_cat.spam() diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index 6acf6debcd..3fd88f640f 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -17,6 +17,9 @@ #include "ffmpegVirtualFile.h" #include "virtualFileSystem.h" +using std::streampos; +using std::streamsize; + extern "C" { #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" @@ -202,7 +205,7 @@ int FfmpegVirtualFile:: read_packet(void *opaque, uint8_t *buf, int size) { streampos ssize = (streampos)size; FfmpegVirtualFile *self = (FfmpegVirtualFile *) opaque; - istream *in = self->_in; + std::istream *in = self->_in; // Since we may be simulating a subset of the opened stream, don't allow it // to read past the "end". @@ -228,21 +231,21 @@ read_packet(void *opaque, uint8_t *buf, int size) { int64_t FfmpegVirtualFile:: seek(void *opaque, int64_t pos, int whence) { FfmpegVirtualFile *self = (FfmpegVirtualFile *) opaque; - istream *in = self->_in; + std::istream *in = self->_in; switch (whence) { case SEEK_SET: - in->seekg(self->_start + (streampos)pos, ios::beg); + in->seekg(self->_start + (streampos)pos, std::ios::beg); break; case SEEK_CUR: - in->seekg(pos, ios::cur); + in->seekg(pos, std::ios::cur); break; case SEEK_END: // For seeks relative to the end, we actually compute the end based on // _start + _size, and then use ios::beg. - in->seekg(self->_start + (streampos)self->_size + (streampos)pos, ios::beg); + in->seekg(self->_start + (streampos)self->_size + (streampos)pos, std::ios::beg); break; case AVSEEK_SIZE: diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 9179aa02f4..4dfbaee572 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -37,6 +37,8 @@ #endif #endif +using std::string; + LoaderOptions PandaFramework::_loader_options; /** @@ -535,7 +537,7 @@ get_models() { * Reports the currently measured average frame rate to the indicated ostream. */ void PandaFramework:: -report_frame_rate(ostream &out) const { +report_frame_rate(std::ostream &out) const { double now = ClockObject::get_global_clock()->get_frame_time(); double delta = now - _start_time; @@ -1175,10 +1177,10 @@ event_arrow_right(const Event *, void *data) { void PandaFramework:: event_S(const Event *, void *) { #ifdef DO_PSTATS - nout << "Connecting to stats host" << endl; + nout << "Connecting to stats host" << std::endl; PStatClient::connect(); #else - nout << "Stats host not supported." << endl; + nout << "Stats host not supported." << std::endl; #endif } @@ -1219,7 +1221,7 @@ event_f9(const Event *event, void *data) { self->_screenshot_text.set_scale(0.06); self->_screenshot_text.set_pos(0.0, 0.0, -0.7); self->_screenshot_text.reparent_to(wf->get_aspect_2d()); - cout << "Screenshot saved: " + output_text + "\n"; + std::cout << "Screenshot saved: " + output_text + "\n"; // Set a do-later to remove the text in 3 seconds. self->_task_mgr.remove(self->_task_mgr.find_tasks("clear_text")); @@ -1273,7 +1275,7 @@ event_question(const Event *event, void *data) { } else { // Build up a string to display. - ostringstream help; + std::ostringstream help; KeyDefinitions::const_iterator ki; for (ki = self->_key_definitions.begin(); ki != self->_key_definitions.end(); @@ -1294,7 +1296,7 @@ event_question(const Event *event, void *data) { LVecBase4 frame = text_node->get_frame_actual(); PN_stdfloat height = frame[3] - frame[2]; - PN_stdfloat scale = min(0.06, 1.8 / height); + PN_stdfloat scale = std::min(0.06, 1.8 / height); self->_help_text.set_scale(scale); PN_stdfloat pos_scale = scale / -2.0; diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 3b1cb1807c..1a6c8b1d77 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -62,6 +62,10 @@ // shuttle_controls.bam_src.c. #include "shuttle_controls.bam_src.c" +using std::istringstream; +using std::ostringstream; +using std::string; + // This number is chosen arbitrarily to override any settings in model files. static const int override_priority = 100; @@ -514,15 +518,15 @@ center_trackball(const NodePath &object) { if (lens != nullptr) { LVecBase2 fov = lens->get_fov(); - distance = radius / ctan(deg_2_rad(min(fov[0], fov[1]) / 2.0f)); + distance = radius / ctan(deg_2_rad(std::min(fov[0], fov[1]) / 2.0f)); // Ensure the far plane is far enough back to see the entire object. PN_stdfloat ideal_far_plane = distance + radius * 1.5; - lens->set_far(max(lens->get_default_far(), ideal_far_plane)); + lens->set_far(std::max(lens->get_default_far(), ideal_far_plane)); // And that the near plane is far enough forward. PN_stdfloat ideal_near_plane = distance - radius; - lens->set_near(min(lens->get_default_near(), ideal_near_plane)); + lens->set_near(std::min(lens->get_default_near(), ideal_near_plane)); } _trackball->set_origin(center); diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index d70b2a4a1a..353c68dc46 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -508,7 +508,7 @@ issue_parameters(int altered) { if (GLCAT.is_spam()) { GLCAT.spam() << "Setting uniforms for " << _shader->get_filename() - << " (altered 0x" << hex << altered << dec << ")\n"; + << " (altered 0x" << std::hex << altered << std::dec << ")\n"; } // We have no way to track modifications to PTAs, so we assume that they are @@ -737,7 +737,7 @@ update_transform_table(const TransformTable *table) { int i = 0; if (table != nullptr) { - int num_transforms = min(_transform_table_size, (long)table->get_num_transforms()); + int num_transforms = std::min(_transform_table_size, (long)table->get_num_transforms()); for (; i < num_transforms; ++i) { #ifdef STDFLOAT_DOUBLE LMatrix4 matrix; @@ -765,7 +765,7 @@ update_slider_table(const SliderTable *table) { memset(sliders, 0, _slider_table_size * 4); if (table != nullptr) { - int num_sliders = min(_slider_table_size, (long)table->get_num_sliders()); + int num_sliders = std::min(_slider_table_size, (long)table->get_num_sliders()); for (int i = 0; i < num_sliders; ++i) { sliders[i] = table->get_slider(i)->get_slider(); } @@ -880,7 +880,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // limited in the options we can set. GLenum type = _glgsg->get_numeric_type(numeric_type); if (p >= 0) { - max_p = max(max_p, (GLuint)p + 1); + max_p = std::max(max_p, (GLuint)p + 1); _glgsg->enable_vertex_attrib_array(p); diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 8d77e56086..cba097ad34 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -13,6 +13,9 @@ #include "depthWriteAttrib.h" +using std::max; +using std::min; + TypeHandle CLP(GraphicsBuffer)::_type_handle; /** @@ -20,7 +23,7 @@ TypeHandle CLP(GraphicsBuffer)::_type_handle; */ CLP(GraphicsBuffer):: CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -67,7 +70,7 @@ CLP(GraphicsBuffer):: // unshare all buffers that are sharing this object's depth buffer { CLP(GraphicsBuffer) *graphics_buffer; - list ::iterator graphics_buffer_iterator; + std::list ::iterator graphics_buffer_iterator; graphics_buffer_iterator = _shared_depth_buffer_list.begin(); while (graphics_buffer_iterator != _shared_depth_buffer_list.end()) { @@ -495,7 +498,7 @@ rebuild_bitplanes() { } else if (attach[RTP_depth_stencil] != nullptr && attach[RTP_depth] == nullptr) { // The depth stencil slot was assigned a texture, but we don't support it. // Downgrade to a regular depth texture. - swap(attach[RTP_depth], attach[RTP_depth_stencil]); + std::swap(attach[RTP_depth], attach[RTP_depth_stencil]); } // Knowing this, we can already be a tiny bit more accurate about the @@ -537,9 +540,9 @@ rebuild_bitplanes() { if (glgsg->_use_object_labels) { // Assign a label for OpenGL to use when displaying debug messages. if (num_fbos > 1) { - ostringstream strm; + std::ostringstream strm; strm << _name << '[' << layer << ']'; - string name = strm.str(); + std::string name = strm.str(); glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], name.size(), name.data()); } else { glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], _name.size(), _name.data()); @@ -1775,7 +1778,7 @@ resolve_multisamples() { if (_shared_depth_buffer) { CLP(GraphicsBuffer) *graphics_buffer = nullptr; //CLP(GraphicsBuffer) *highest_sort_graphics_buffer = NULL; - list ::iterator graphics_buffer_iterator; + std::list ::iterator graphics_buffer_iterator; int max_sort_order = 0; for (graphics_buffer_iterator = _shared_depth_buffer_list.begin(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 1e4c2bb530..b6790e4931 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -73,6 +73,13 @@ #include +using std::dec; +using std::endl; +using std::hex; +using std::max; +using std::min; +using std::string; + TypeHandle CLP(GraphicsStateGuardian)::_type_handle; PStatCollector CLP(GraphicsStateGuardian)::_load_display_list_pcollector("Draw:Transfer data:Display lists"); @@ -7836,7 +7843,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { // State:Light:Bind:Directional"); PStatGPUTimer timer(this, // _draw_set_state_light_bind_directional_pcollector); - pair lookup = _dlights.insert(DirectionalLights::value_type(light, DirectionalLightFrameData())); + std::pair lookup = _dlights.insert(DirectionalLights::value_type(light, DirectionalLightFrameData())); DirectionalLightFrameData &fdata = (*lookup.first).second; if (lookup.second) { // The light was not computed yet this frame. Compute it now. @@ -8100,7 +8107,7 @@ get_error_string(GLenum error_code) { } // Other error, somehow? Just display the error code then. - ostringstream strm; + std::ostringstream strm; strm << "GL error " << (int)error_code; return strm.str(); @@ -8307,7 +8314,7 @@ get_extra_extensions() { void CLP(GraphicsStateGuardian):: report_extensions() const { if (GLCAT.is_debug()) { - ostream &out = GLCAT.debug(); + std::ostream &out = GLCAT.debug(); out << "GL Extensions:\n"; pset::const_iterator ei; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 203cccb727..77c111ad75 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -27,6 +27,12 @@ #include "clipPlaneAttrib.h" #include "bamCache.h" +using std::dec; +using std::hex; +using std::max; +using std::min; +using std::string; + TypeHandle CLP(ShaderContext)::_type_handle; /** @@ -2799,7 +2805,7 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) { // Parse the errors so that we can substitute in actual file locations // instead of source indices. - istringstream log(info_log); + std::istringstream log(info_log); string line; while (std::getline(log, line)) { int fileno, lineno, colno; @@ -3114,7 +3120,7 @@ glsl_compile_and_link() { sprintf(filename, "glsl_program%d.dump", gl_dump_count++); pofstream s; - s.open(filename, ios::out | ios::binary | ios::trunc); + s.open(filename, std::ios::out | std::ios::binary | std::ios::trunc); s.write(binary, num_bytes); s.close(); diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.cxx b/panda/src/glxdisplay/glxGraphicsBuffer.cxx index 835adeed97..d777f7a239 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.cxx +++ b/panda/src/glxdisplay/glxGraphicsBuffer.cxx @@ -27,7 +27,7 @@ TypeHandle glxGraphicsBuffer::_type_handle; */ glxGraphicsBuffer:: glxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/glxdisplay/glxGraphicsPipe.cxx b/panda/src/glxdisplay/glxGraphicsPipe.cxx index 06266e6e96..e4ec8380fb 100644 --- a/panda/src/glxdisplay/glxGraphicsPipe.cxx +++ b/panda/src/glxdisplay/glxGraphicsPipe.cxx @@ -20,6 +20,8 @@ #include "config_glxdisplay.h" #include "frameBufferProperties.h" +using std::string; + TypeHandle glxGraphicsPipe::_type_handle; /** diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.cxx b/panda/src/glxdisplay/glxGraphicsPixmap.cxx index 8c9c317b2c..7f551b8d4f 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.cxx +++ b/panda/src/glxdisplay/glxGraphicsPixmap.cxx @@ -28,7 +28,7 @@ TypeHandle glxGraphicsPixmap::_type_handle; */ glxGraphicsPixmap:: glxGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 2b877b2168..76c66d817e 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -18,6 +18,8 @@ #include +using std::string; + TypeHandle glxGraphicsStateGuardian::_type_handle; diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 28f4652266..a7a2472a84 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -36,7 +36,7 @@ TypeHandle glxGraphicsWindow::_type_handle; */ glxGraphicsWindow:: glxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index 85bb3ab36c..54ed81a3c8 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -16,6 +16,9 @@ #include "clockObject.h" #include "indent.h" +using std::cerr; +using std::ostream; + static const int HIGH_PRIORITY_SCALE = 4; static const int LOW_PRIORITY_RANGE = 25; @@ -23,7 +26,7 @@ static const int LOW_PRIORITY_RANGE = 25; * */ AdaptiveLru:: -AdaptiveLru(const string &name, size_t max_size) : +AdaptiveLru(const std::string &name, size_t max_size) : Namable(name) { _total_size = 0; @@ -156,7 +159,7 @@ update_page(AdaptiveLruPage *page) { } if (target_priority != page->_priority) { - page->_priority = min(max(target_priority, 0), LPP_TotalPriorities - 1); + page->_priority = std::min(std::max(target_priority, 0), LPP_TotalPriorities - 1); ((AdaptiveLruPageDynamicList *)page)->remove_from_list(); ((AdaptiveLruPageDynamicList *)page)->insert_before(&_page_array[page->_priority]); } diff --git a/panda/src/gobj/bufferContextChain.cxx b/panda/src/gobj/bufferContextChain.cxx index 9a94ff2919..4f27c90c88 100644 --- a/panda/src/gobj/bufferContextChain.cxx +++ b/panda/src/gobj/bufferContextChain.cxx @@ -54,7 +54,7 @@ take_from(BufferContextChain &other) { * */ void BufferContextChain:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _count << " objects, consuming " << _total_size << " bytes:\n"; diff --git a/panda/src/gobj/bufferResidencyTracker.cxx b/panda/src/gobj/bufferResidencyTracker.cxx index abb51610e6..9ac4fef735 100644 --- a/panda/src/gobj/bufferResidencyTracker.cxx +++ b/panda/src/gobj/bufferResidencyTracker.cxx @@ -22,7 +22,7 @@ PStatCollector BufferResidencyTracker::_gmem_collector("Graphics memory"); * */ BufferResidencyTracker:: -BufferResidencyTracker(const string &pgo_name, const string &type_name) : +BufferResidencyTracker(const std::string &pgo_name, const std::string &type_name) : _pgo_collector(_gmem_collector, pgo_name), _active_resident_collector(PStatCollector(_pgo_collector, "Active"), type_name), _active_nonresident_collector(PStatCollector(_pgo_collector, "Thrashing"), type_name), @@ -90,7 +90,7 @@ set_levels() { * */ void BufferResidencyTracker:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (_chains[S_inactive_nonresident].get_count() != 0) { indent(out, indent_level) << "Inactive nonresident:\n"; _chains[S_inactive_nonresident].write(out, indent_level + 2); diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 0c627d6e5b..5cf18838d8 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -25,6 +25,9 @@ #include "lightMutexHolder.h" #include "config_mathutil.h" +using std::max; +using std::min; + UpdateSeq Geom::_next_modified; PStatCollector Geom::_draw_primitive_setup_pcollector("Draw:Primitive:Setup"); @@ -625,7 +628,7 @@ unify_in_place(int max_indices, bool preserve_order) { } else { // We have already encountered another primitive of this type. Combine // them. - combine_primitives((*npi).second, move(primitive), current_thread); + combine_primitives((*npi).second, std::move(primitive), current_thread); } } @@ -1060,7 +1063,7 @@ get_nested_vertices(Thread *current_thread) const { * */ void Geom:: -output(ostream &out) const { +output(std::ostream &out) const { CDReader cdata(_cycler); // Get a list of the primitive types contained within this object. @@ -1087,7 +1090,7 @@ output(ostream &out) const { * */ void Geom:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { CDReader cdata(_cycler); // Get a list of the primitive types contained within this object. @@ -1552,9 +1555,9 @@ combine_primitives(GeomPrimitive *a_prim, CPT(GeomPrimitive) b_prim, } PT(GeomVertexArrayDataHandle) a_handle = - new GeomVertexArrayDataHandle(move(a_vertices), current_thread); + new GeomVertexArrayDataHandle(std::move(a_vertices), current_thread); CPT(GeomVertexArrayDataHandle) b_handle = - new GeomVertexArrayDataHandle(move(b_vertices), current_thread); + new GeomVertexArrayDataHandle(std::move(b_vertices), current_thread); size_t orig_a_vertices = a_handle->get_num_rows(); @@ -1672,7 +1675,7 @@ evict_callback() { * */ void Geom::CacheEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << "geom " << (void *)_source << ", " << (const void *)_key._modifier; } diff --git a/panda/src/gobj/geomCacheEntry.cxx b/panda/src/gobj/geomCacheEntry.cxx index 608ebbdac4..8ddb12b042 100644 --- a/panda/src/gobj/geomCacheEntry.cxx +++ b/panda/src/gobj/geomCacheEntry.cxx @@ -133,6 +133,6 @@ evict_callback() { * */ void GeomCacheEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ unknown ]"; } diff --git a/panda/src/gobj/geomEnums.cxx b/panda/src/gobj/geomEnums.cxx index e63260a144..0899fd3679 100644 --- a/panda/src/gobj/geomEnums.cxx +++ b/panda/src/gobj/geomEnums.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "config_gobj.h" +using std::istream; +using std::ostream; +using std::string; + /** * diff --git a/panda/src/gobj/geomLines.cxx b/panda/src/gobj/geomLines.cxx index dee3c89ccf..2d38fc8838 100644 --- a/panda/src/gobj/geomLines.cxx +++ b/panda/src/gobj/geomLines.cxx @@ -20,6 +20,8 @@ #include "geomVertexWriter.h" #include "geomLinesAdjacency.h" +using std::map; + TypeHandle GeomLines::_type_handle; /** @@ -125,7 +127,7 @@ make_adjacency() const { nassertr(to.is_at_end(), nullptr); } - adj->set_vertices(move(new_vertices)); + adj->set_vertices(std::move(new_vertices)); return adj.p(); } diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index 0b54de3410..f6550a0de3 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -20,6 +20,8 @@ #include "graphicsStateGuardianBase.h" #include "geomLinestripsAdjacency.h" +using std::map; + TypeHandle GeomLinestrips::_type_handle; /** diff --git a/panda/src/gobj/geomMunger.cxx b/panda/src/gobj/geomMunger.cxx index 83d57467c1..40a183edfa 100644 --- a/panda/src/gobj/geomMunger.cxx +++ b/panda/src/gobj/geomMunger.cxx @@ -148,7 +148,7 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, if (entry == nullptr) { // Create a new entry for the result. // We don't need the key anymore, move the pointers into the CacheEntry. - entry = new Geom::CacheEntry(orig_geom, move(key)); + entry = new Geom::CacheEntry(orig_geom, std::move(key)); { LightMutexHolder holder(orig_geom->_cache_lock); @@ -378,7 +378,7 @@ do_unregister() { * */ void GeomMunger::CacheEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << "munger " << _munger; } diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index db939d3bef..f52e06663a 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -31,6 +31,9 @@ #include "indent.h" #include "pStatTimer.h" +using std::max; +using std::min; + TypeHandle GeomPrimitive::_type_handle; TypeHandle GeomPrimitive::CData::_type_handle; TypeHandle GeomPrimitivePipelineReader::_type_handle; @@ -581,7 +584,7 @@ pack_vertices(GeomVertexData *dest, const GeomVertexData *source) { // Try to add the relation { v : size() }. If that succeeds, great; if // it doesn't, look up whatever we previously added for v. - pair result = + std::pair result = copied_indices.insert(CopiedIndices::value_type(v, (int)copied_indices.size())); int v2 = (*result.first).second + dest_start; index.add_data1i(v2); @@ -1079,7 +1082,7 @@ request_resident(Thread *current_thread) const { * */ void GeomPrimitive:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ", " << get_num_primitives() << ", " << get_num_vertices(); } @@ -1088,7 +1091,7 @@ output(ostream &out) const { * */ void GeomPrimitive:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type(); if (is_indexed()) { diff --git a/panda/src/gobj/geomTriangles.cxx b/panda/src/gobj/geomTriangles.cxx index 494f59be74..809b9199c0 100644 --- a/panda/src/gobj/geomTriangles.cxx +++ b/panda/src/gobj/geomTriangles.cxx @@ -19,6 +19,8 @@ #include "graphicsStateGuardianBase.h" #include "geomTrianglesAdjacency.h" +using std::map; + TypeHandle GeomTriangles::_type_handle; /** @@ -85,7 +87,7 @@ make_adjacency() const { new_vertices->set_num_rows(num_vertices * 2); // First, build a map of each triangle's halfedges to its opposing vertices. - map, int> edge_map; + map, int> edge_map; for (int i = 0; i < num_vertices; i += 3) { int v0 = from.get_vertex(i); int v1 = from.get_vertex(i + 1); @@ -135,7 +137,7 @@ make_adjacency() const { nassertr(to.is_at_end(), nullptr); } - adj->set_vertices(move(new_vertices)); + adj->set_vertices(std::move(new_vertices)); return adj.p(); } diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index 7c8eff61f9..0b88bcf8f1 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -20,6 +20,8 @@ #include "graphicsStateGuardianBase.h" #include "geomTristripsAdjacency.h" +using std::map; + TypeHandle GeomTristrips::_type_handle; /** @@ -98,7 +100,7 @@ make_adjacency() const { const int num_unused = 2; // First, build a map of each triangle's halfedges to its opposing vertices. - map, int> edge_map; + map, int> edge_map; int vi = -num_unused; int li = 0; diff --git a/panda/src/gobj/geomVertexAnimationSpec.cxx b/panda/src/gobj/geomVertexAnimationSpec.cxx index be4dc6903a..f4560b7980 100644 --- a/panda/src/gobj/geomVertexAnimationSpec.cxx +++ b/panda/src/gobj/geomVertexAnimationSpec.cxx @@ -19,7 +19,7 @@ * */ void GeomVertexAnimationSpec:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_animation_type) { case AT_none: out << "none"; diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index b868fc87e0..998ca1ad14 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -25,6 +25,9 @@ #include "vertexDataBuffer.h" #include "texture.h" +using std::max; +using std::min; + ConfigVariableInt max_independent_vertex_data ("max-independent-vertex-data", -1, PRC_DESC("Specifies the maximum number of bytes of all vertex data " @@ -176,7 +179,7 @@ set_usage_hint(GeomVertexArrayData::UsageHint usage_hint) { * */ void GeomVertexArrayData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_num_rows() << " rows: " << *get_array_format(); } @@ -184,7 +187,7 @@ output(ostream &out) const { * */ void GeomVertexArrayData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { _array_format->write_with_data(out, indent_level, this); } diff --git a/panda/src/gobj/geomVertexArrayData_ext.cxx b/panda/src/gobj/geomVertexArrayData_ext.cxx index f35d96ae3a..73c795f0b5 100644 --- a/panda/src/gobj/geomVertexArrayData_ext.cxx +++ b/panda/src/gobj/geomVertexArrayData_ext.cxx @@ -19,7 +19,7 @@ struct InternalBufferData { CPT(GeomVertexArrayDataHandle) _handle; Py_ssize_t _num_rows; Py_ssize_t _stride; - string _format; + std::string _format; }; /** @@ -251,8 +251,8 @@ copy_subdata_from(size_t to_start, size_t to_size, } size_t from_buffer_orig_size = (size_t) view.len; - from_start = min(from_start, from_buffer_orig_size); - from_size = min(from_size, from_buffer_orig_size - from_start); + from_start = std::min(from_start, from_buffer_orig_size); + from_size = std::min(from_size, from_buffer_orig_size - from_start); _this->copy_subdata_from(to_start, to_size, (const unsigned char *) view.buf, diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index 9e0d35cccd..2a82eef81f 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -21,6 +21,10 @@ #include "indirectLess.h" #include "lightMutexHolder.h" +using std::max; +using std::min; +using std::move; + GeomVertexArrayFormat::Registry *GeomVertexArrayFormat::_registry = nullptr; TypeHandle GeomVertexArrayFormat::_type_handle; @@ -460,7 +464,7 @@ count_unused_space() const { * */ void GeomVertexArrayFormat:: -output(ostream &out) const { +output(std::ostream &out) const { Columns::const_iterator ci; int last_pos = 0; out << "["; @@ -484,7 +488,7 @@ output(ostream &out) const { * */ void GeomVertexArrayFormat:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Array format (stride = " << get_stride() << "):\n"; consider_sort_columns(); @@ -503,7 +507,7 @@ write(ostream &out, int indent_level) const { * */ void GeomVertexArrayFormat:: -write_with_data(ostream &out, int indent_level, +write_with_data(std::ostream &out, int indent_level, const GeomVertexArrayData *array_data) const { consider_sort_columns(); int num_rows = array_data->get_num_rows(); @@ -536,7 +540,7 @@ write_with_data(ostream &out, int indent_level, * the columns in memory, as understood by Python's struct module. If pad is * true, extra padding bytes are added to the end as 'x' characters as needed. */ -string GeomVertexArrayFormat:: +std::string GeomVertexArrayFormat:: get_format_string(bool pad) const { consider_sort_columns(); @@ -616,7 +620,7 @@ get_format_string(bool pad) const { memset((void*) (fmt + fi), 'x', pad); } - string fmt_string (fmt); + std::string fmt_string (fmt); free(fmt); return fmt_string; } diff --git a/panda/src/gobj/geomVertexColumn.cxx b/panda/src/gobj/geomVertexColumn.cxx index b43930d3b5..d04b69a307 100644 --- a/panda/src/gobj/geomVertexColumn.cxx +++ b/panda/src/gobj/geomVertexColumn.cxx @@ -16,6 +16,9 @@ #include "bamReader.h" #include "bamWriter.h" +using std::max; +using std::min; + /** * */ @@ -97,7 +100,7 @@ set_column_alignment(int column_alignment) { * */ void GeomVertexColumn:: -output(ostream &out) const { +output(std::ostream &out) const { out << *get_name() << "(" << get_num_components(); switch (get_numeric_type()) { case NT_uint8: diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index f2597614ef..e87e573552 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -22,6 +22,8 @@ #include "pset.h" #include "indent.h" +using std::ostream; + TypeHandle GeomVertexData::_type_handle; TypeHandle GeomVertexData::CDataCache::_type_handle; TypeHandle GeomVertexData::CacheEntry::_type_handle; @@ -60,7 +62,7 @@ make_cow_copy() { * */ GeomVertexData:: -GeomVertexData(const string &name, +GeomVertexData(const std::string &name, const GeomVertexFormat *format, GeomVertexData::UsageHint usage_hint) : _name(name), @@ -210,7 +212,7 @@ compare_to(const GeomVertexData &other) const { * graph for vertex computations. */ void GeomVertexData:: -set_name(const string &name) { +set_name(const std::string &name) { _name = name; _char_pcollector = PStatCollector(_animation_pcollector, name); _skinning_pcollector = PStatCollector(_char_pcollector, "Skinning"); @@ -761,7 +763,7 @@ convert_to(const GeomVertexFormat *new_format) const { if (entry == nullptr) { // Create a new entry for the result. // We don't need the key anymore, move the pointers into the CacheEntry. - entry = new CacheEntry((GeomVertexData *)this, move(key)); + entry = new CacheEntry((GeomVertexData *)this, std::move(key)); { LightMutexHolder holder(_cache_lock); @@ -969,7 +971,7 @@ animate_vertices(bool force, Thread *current_thread) const { if (!cdata->_transform_blend_table.is_null()) { if (cdata->_slider_table != nullptr) { modified = - max(cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread), + std::max(cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread), cdata->_slider_table->get_modified(current_thread)); } else { modified = cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread); @@ -1316,7 +1318,7 @@ describe_vertex(ostream &out, int row) const { const GeomVertexColumn *column = format->get_column(ci); reader.set_column(ai, column); - int num_values = min(column->get_num_values(), 4); + int num_values = std::min(column->get_num_values(), 4); const LVecBase4 &d = reader.get_data4(); out << " " << *column->get_name(); @@ -1470,7 +1472,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { new_format = orig_format->get_post_animated_format(); cdata->_animated_vertices = new GeomVertexData(get_name(), new_format, - min(get_usage_hint(), UH_dynamic)); + std::min(get_usage_hint(), UH_dynamic)); } PT(GeomVertexData) new_data = cdata->_animated_vertices; diff --git a/panda/src/gobj/geomVertexFormat.cxx b/panda/src/gobj/geomVertexFormat.cxx index 05814c5bd8..2b3479cc4f 100644 --- a/panda/src/gobj/geomVertexFormat.cxx +++ b/panda/src/gobj/geomVertexFormat.cxx @@ -173,7 +173,7 @@ get_union_format(const GeomVertexFormat *other) const { // D, E) in array 1. In general, a column will appear in the result in the // first array it appears in either of the inputs. - size_t num_arrays = max(_arrays.size(), other->_arrays.size()); + size_t num_arrays = std::max(_arrays.size(), other->_arrays.size()); for (size_t ai = 0; ai < num_arrays; ++ai) { PT(GeomVertexArrayFormat) new_array = new GeomVertexArrayFormat; @@ -565,7 +565,7 @@ maybe_align_columns_for_animation() { * */ void GeomVertexFormat:: -output(ostream &out) const { +output(std::ostream &out) const { if (_arrays.empty()) { out << "(empty)"; @@ -589,7 +589,7 @@ output(ostream &out) const { * */ void GeomVertexFormat:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (size_t i = 0; i < _arrays.size(); i++) { indent(out, indent_level) << "Array " << i << ":\n"; @@ -606,7 +606,7 @@ write(ostream &out, int indent_level) const { * */ void GeomVertexFormat:: -write_with_data(ostream &out, int indent_level, +write_with_data(std::ostream &out, int indent_level, const GeomVertexData *data) const { indent(out, indent_level) << data->get_num_rows() << " rows.\n"; @@ -716,7 +716,7 @@ do_register() { int num_columns = array_format->get_num_columns(); for (int i = 0; i < num_columns; i++) { const GeomVertexColumn *column = array_format->get_column(i); - pair result; + std::pair result; result = _columns_by_name.insert(DataTypesByName::value_type(column->get_name(), DataTypeRecord())); if (!result.second) { gobj_cat.warning() diff --git a/panda/src/gobj/geomVertexReader.cxx b/panda/src/gobj/geomVertexReader.cxx index b803095915..00bd42a33f 100644 --- a/panda/src/gobj/geomVertexReader.cxx +++ b/panda/src/gobj/geomVertexReader.cxx @@ -13,7 +13,6 @@ #include "geomVertexReader.h" - #ifndef NDEBUG // This is defined just for the benefit of having something non-NULL to // return from a nassertr() call. @@ -60,7 +59,7 @@ set_column(int array, const GeomVertexColumn *column) { * */ void GeomVertexReader:: -output(ostream &out) const { +output(std::ostream &out) const { const GeomVertexColumn *column = get_column(); if (column == nullptr) { out << "GeomVertexReader()"; diff --git a/panda/src/gobj/geomVertexRewriter.cxx b/panda/src/gobj/geomVertexRewriter.cxx index e1743ca39d..1bad4afd9d 100644 --- a/panda/src/gobj/geomVertexRewriter.cxx +++ b/panda/src/gobj/geomVertexRewriter.cxx @@ -17,7 +17,7 @@ * */ void GeomVertexRewriter:: -output(ostream &out) const { +output(std::ostream &out) const { const GeomVertexColumn *column = get_column(); if (column == nullptr) { out << "GeomVertexRewriter()"; diff --git a/panda/src/gobj/geomVertexWriter.cxx b/panda/src/gobj/geomVertexWriter.cxx index 51e8b91bf5..a433bef9e2 100644 --- a/panda/src/gobj/geomVertexWriter.cxx +++ b/panda/src/gobj/geomVertexWriter.cxx @@ -13,7 +13,6 @@ #include "geomVertexWriter.h" - #ifdef _DEBUG // This is defined just for the benefit of having something non-NULL to // return from a nassertr() call. @@ -92,7 +91,7 @@ reserve_num_rows(int num_rows) { * */ void GeomVertexWriter:: -output(ostream &out) const { +output(std::ostream &out) const { const GeomVertexColumn *column = get_column(); if (column == nullptr) { out << "GeomVertexWriter()"; diff --git a/panda/src/gobj/indexBufferContext.cxx b/panda/src/gobj/indexBufferContext.cxx index ebb65ea89f..2c3e68ba0b 100644 --- a/panda/src/gobj/indexBufferContext.cxx +++ b/panda/src/gobj/indexBufferContext.cxx @@ -19,7 +19,7 @@ TypeHandle IndexBufferContext::_type_handle; * */ void IndexBufferContext:: -output(ostream &out) const { +output(std::ostream &out) const { out << *get_data() << ", " << get_data_size_bytes(); } @@ -27,6 +27,6 @@ output(ostream &out) const { * */ void IndexBufferContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SavedContext::write(out, indent_level); } diff --git a/panda/src/gobj/internalName.cxx b/panda/src/gobj/internalName.cxx index 828b6db97a..6803f9bab8 100644 --- a/panda/src/gobj/internalName.cxx +++ b/panda/src/gobj/internalName.cxx @@ -18,6 +18,8 @@ #include "bamReader.h" #include "preparedGraphicsObjects.h" +using std::string; + PT(InternalName) InternalName::_root; PT(InternalName) InternalName::_error; PT(InternalName) InternalName::_default; @@ -248,7 +250,7 @@ get_net_basename(int n) const { * */ void InternalName:: -output(ostream &out) const { +output(std::ostream &out) const { if (_parent == get_root()) { out << _basename; diff --git a/panda/src/gobj/internalName_ext.cxx b/panda/src/gobj/internalName_ext.cxx index a03651dbf5..4967b330b5 100644 --- a/panda/src/gobj/internalName_ext.cxx +++ b/panda/src/gobj/internalName_ext.cxx @@ -13,6 +13,8 @@ #include "internalName_ext.h" +using std::string; + #ifdef HAVE_PYTHON /** diff --git a/panda/src/gobj/lens.cxx b/panda/src/gobj/lens.cxx index cb7a496e97..470b64447a 100644 --- a/panda/src/gobj/lens.cxx +++ b/panda/src/gobj/lens.cxx @@ -23,6 +23,9 @@ #include "config_gobj.h" #include "plane.h" +using std::max; +using std::min; + TypeHandle Lens::_type_handle; TypeHandle Lens::CData::_type_handle; @@ -676,7 +679,7 @@ make_bounds() const { * */ void Lens:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -684,7 +687,7 @@ output(ostream &out) const { * */ void Lens:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " fov = " << get_fov() << "\n"; } diff --git a/panda/src/gobj/material.cxx b/panda/src/gobj/material.cxx index 12d4f15365..1952066649 100644 --- a/panda/src/gobj/material.cxx +++ b/panda/src/gobj/material.cxx @@ -395,7 +395,7 @@ compare_to(const Material &other) const { * */ void Material:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Material " << get_name(); if (has_base_color()) { out << " c(" << get_base_color() << ")"; @@ -432,7 +432,7 @@ output(ostream &out) const { * */ void Material:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Material " << get_name() << "\n"; if (has_base_color()) { indent(out, indent_level + 2) << "base_color = " << get_ambient() << "\n"; diff --git a/panda/src/gobj/materialPool.cxx b/panda/src/gobj/materialPool.cxx index 58fec6dcbc..a2dd6c9064 100644 --- a/panda/src/gobj/materialPool.cxx +++ b/panda/src/gobj/materialPool.cxx @@ -22,7 +22,7 @@ MaterialPool *MaterialPool::_global_ptr = nullptr; * Lists the contents of the material pool to the indicated output stream. */ void MaterialPool:: -write(ostream &out) { +write(std::ostream &out) { get_global_ptr()->ns_list_contents(out); } @@ -100,7 +100,7 @@ ns_garbage_collect() { * The nonstatic implementation of list_contents(). */ void MaterialPool:: -ns_list_contents(ostream &out) const { +ns_list_contents(std::ostream &out) const { LightMutexHolder holder(_lock); out << _materials.size() << " materials:\n"; diff --git a/panda/src/gobj/matrixLens.cxx b/panda/src/gobj/matrixLens.cxx index 147870a954..db647516c7 100644 --- a/panda/src/gobj/matrixLens.cxx +++ b/panda/src/gobj/matrixLens.cxx @@ -41,7 +41,7 @@ is_linear() const { * */ void MatrixLens:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":\n"; get_projection_mat().write(out, indent_level + 2); } diff --git a/panda/src/gobj/orthographicLens.cxx b/panda/src/gobj/orthographicLens.cxx index 86c8fe0ef5..131903935a 100644 --- a/panda/src/gobj/orthographicLens.cxx +++ b/panda/src/gobj/orthographicLens.cxx @@ -49,7 +49,7 @@ is_orthographic() const { * */ void OrthographicLens:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " film size = " << get_film_size() << "\n"; } diff --git a/panda/src/gobj/paramTexture.cxx b/panda/src/gobj/paramTexture.cxx index 7250cab5ec..892fe157c9 100644 --- a/panda/src/gobj/paramTexture.cxx +++ b/panda/src/gobj/paramTexture.cxx @@ -21,7 +21,7 @@ TypeHandle ParamTextureImage::_type_handle; * */ void ParamTextureSampler:: -output(ostream &out) const { +output(std::ostream &out) const { out << "texture "; if (_texture != nullptr) { @@ -96,7 +96,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ void ParamTextureImage:: -output(ostream &out) const { +output(std::ostream &out) const { out << "texture "; if (_texture != nullptr) { diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index a77a8837d7..4f6ecea1ed 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -162,7 +162,7 @@ set_graphics_memory_limit(size_t limit) { * vertex buffers are allocated in the LRU. */ void PreparedGraphicsObjects:: -show_graphics_memory_lru(ostream &out) const { +show_graphics_memory_lru(std::ostream &out) const { _graphics_memory_lru.write(out, 0); } @@ -171,7 +171,7 @@ show_graphics_memory_lru(ostream &out) const { * vertex buffers are allocated in the LRU. */ void PreparedGraphicsObjects:: -show_residency_trackers(ostream &out) const { +show_residency_trackers(std::ostream &out) const { out << "Textures:\n"; _texture_residency.write(out, 2); @@ -204,7 +204,7 @@ PT(PreparedGraphicsObjects::EnqueuedObject) PreparedGraphicsObjects:: enqueue_texture_future(Texture *tex) { ReMutexHolder holder(_lock); - pair result = + std::pair result = _enqueued_textures.insert(EnqueuedTextures::value_type(tex, nullptr)); if (result.first->second == nullptr) { result.first->second = new EnqueuedObject(this, tex); @@ -713,7 +713,7 @@ PT(PreparedGraphicsObjects::EnqueuedObject) PreparedGraphicsObjects:: enqueue_shader_future(Shader *shader) { ReMutexHolder holder(_lock); - pair result = + std::pair result = _enqueued_shaders.insert(EnqueuedShaders::value_type(shader, nullptr)); if (result.first->second == nullptr) { result.first->second = new EnqueuedObject(this, shader); @@ -1668,10 +1668,10 @@ end_frame(Thread *current_thread) { /** * Returns a new, unique name for a newly-constructed object. */ -string PreparedGraphicsObjects:: +std::string PreparedGraphicsObjects:: init_name() { ++_name_index; - ostringstream strm; + std::ostringstream strm; strm << "context" << _name_index; return strm.str(); } diff --git a/panda/src/gobj/samplerContext.cxx b/panda/src/gobj/samplerContext.cxx index aad143c2fc..5b8d9b3322 100644 --- a/panda/src/gobj/samplerContext.cxx +++ b/panda/src/gobj/samplerContext.cxx @@ -19,7 +19,7 @@ TypeHandle SamplerContext::_type_handle; * */ void SamplerContext:: -output(ostream &out) const { +output(std::ostream &out) const { SavedContext::output(out); } @@ -27,6 +27,6 @@ output(ostream &out) const { * */ void SamplerContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SavedContext::write(out, indent_level); } diff --git a/panda/src/gobj/samplerState.cxx b/panda/src/gobj/samplerState.cxx index be8bd7b23d..9f1a5766bc 100644 --- a/panda/src/gobj/samplerState.cxx +++ b/panda/src/gobj/samplerState.cxx @@ -20,6 +20,8 @@ #include "samplerContext.h" #include "preparedGraphicsObjects.h" +using std::string; + TypeHandle SamplerState::_type_handle; SamplerState SamplerState::_default; @@ -283,7 +285,7 @@ compare_to(const SamplerState &other) const { * */ void SamplerState:: -output(ostream &out) const { +output(std::ostream &out) const { out << "sampler" << " wrap(u=" << _wrap_u << ", v=" << _wrap_v << ", w=" << _wrap_w @@ -298,7 +300,7 @@ output(ostream &out) const { * */ void SamplerState:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "SamplerState\n"; indent(out, indent_level) << " wrap_u = " << _wrap_u << "\n"; indent(out, indent_level) << " wrap_v = " << _wrap_v << "\n"; diff --git a/panda/src/gobj/savedContext.cxx b/panda/src/gobj/savedContext.cxx index 2b93299121..92a1af46ca 100644 --- a/panda/src/gobj/savedContext.cxx +++ b/panda/src/gobj/savedContext.cxx @@ -20,7 +20,7 @@ TypeHandle SavedContext::_type_handle; * */ void SavedContext:: -output(ostream &out) const { +output(std::ostream &out) const { out << "SavedContext " << this; } @@ -28,6 +28,6 @@ output(ostream &out) const { * */ void SavedContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 4f41cf57f1..b5e9e78489 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -27,6 +27,12 @@ #include #endif +using std::istream; +using std::move; +using std::ostream; +using std::ostringstream; +using std::string; + TypeHandle Shader::_type_handle; Shader::ShaderTable Shader::_load_table; Shader::ShaderTable Shader::_make_table; @@ -2455,7 +2461,7 @@ bool Shader:: do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { if (_language == SL_GLSL && glsl_preprocess) { // Preprocess the GLSL file as we read it. - set open_files; + std::set open_files; ostringstream sstr; if (!r_preprocess_source(sstr, fn, Filename(), open_files, record)) { return false; @@ -2482,7 +2488,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { if (record != nullptr) { record->add_dependent_file(vf); } - _last_modified = max(_last_modified, vf->get_timestamp()); + _last_modified = std::max(_last_modified, vf->get_timestamp()); _source_files.push_back(vf->get_filename()); } @@ -2504,7 +2510,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { bool Shader:: r_preprocess_source(ostream &out, const Filename &fn, const Filename &source_dir, - set &once_files, + std::set &once_files, BamCacheRecord *record, int depth) { if (depth > glsl_include_recursion_limit) { @@ -2543,7 +2549,7 @@ r_preprocess_source(ostream &out, const Filename &fn, if (record != nullptr) { record->add_dependent_file(vf); } - _last_modified = max(_last_modified, vf->get_timestamp()); + _last_modified = std::max(_last_modified, vf->get_timestamp()); _source_files.push_back(full_fn); // We give each file an unique index. This is so that we can identify a @@ -3168,7 +3174,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { // It makes little sense to cache the shader before compilation, so we keep // the record for when we have the compiled the shader. - swap(shader->_record, record); + std::swap(shader->_record, record); shader->_cache_compiled_shader = BamCache::get_global_ptr()->get_cache_compiled_shaders(); shader->_fullpath = shader->_source_files[0]; return shader; @@ -3233,7 +3239,7 @@ make(string body, ShaderLanguage lang) { shader_cat.warning() << "Dumping shader: " << fn << "\n"; pofstream s; - s.open(fn.c_str(), ios::out | ios::trunc); + s.open(fn.c_str(), std::ios::out | std::ios::trunc); s << shader->get_text(); s.close(); } diff --git a/panda/src/gobj/shaderBuffer.cxx b/panda/src/gobj/shaderBuffer.cxx index da9dc37d4d..971787f0e6 100644 --- a/panda/src/gobj/shaderBuffer.cxx +++ b/panda/src/gobj/shaderBuffer.cxx @@ -28,7 +28,7 @@ ShaderBuffer:: * */ void ShaderBuffer:: -output(ostream &out) const { +output(std::ostream &out) const { out << "buffer " << get_name() << ", " << _data_size_bytes << "B, " << _usage_hint; } diff --git a/panda/src/gobj/simpleAllocator.cxx b/panda/src/gobj/simpleAllocator.cxx index 5790f35428..0cc087e2d7 100644 --- a/panda/src/gobj/simpleAllocator.cxx +++ b/panda/src/gobj/simpleAllocator.cxx @@ -32,7 +32,7 @@ SimpleAllocator:: * */ void SimpleAllocator:: -output(ostream &out) const { +output(std::ostream &out) const { MutexHolder holder(_lock); out << "SimpleAllocator, " << _total_size << " of " << _max_size << " allocated"; @@ -42,7 +42,7 @@ output(ostream &out) const { * */ void SimpleAllocator:: -write(ostream &out) const { +write(std::ostream &out) const { MutexHolder holder(_lock); out << "SimpleAllocator, " << _total_size << " of " << _max_size << " allocated"; @@ -168,7 +168,7 @@ changed_contiguous() { * */ void SimpleAllocatorBlock:: -output(ostream &out) const { +output(std::ostream &out) const { if (_allocator == nullptr) { out << "free block\n"; } else { diff --git a/panda/src/gobj/simpleLru.cxx b/panda/src/gobj/simpleLru.cxx index b24b48146c..dfdb9113da 100644 --- a/panda/src/gobj/simpleLru.cxx +++ b/panda/src/gobj/simpleLru.cxx @@ -14,6 +14,8 @@ #include "simpleLru.h" #include "indent.h" +using std::ostream; + // We define this as a reference to an allocated object, instead of as a // concrete object, so that it won't get destructed when the program exits. // (If it did, there would be an ordering issue between it and the various @@ -24,7 +26,7 @@ LightMutex &SimpleLru::_global_lock = *new LightMutex; * */ SimpleLru:: -SimpleLru(const string &name, size_t max_size) : +SimpleLru(const std::string &name, size_t max_size) : LinkedListNode(true), Namable(name) { diff --git a/panda/src/gobj/sliderTable.cxx b/panda/src/gobj/sliderTable.cxx index 169f023e3f..52ccdacc1c 100644 --- a/panda/src/gobj/sliderTable.cxx +++ b/panda/src/gobj/sliderTable.cxx @@ -124,7 +124,7 @@ add_slider(const VertexSlider *slider, const SparseArray &rows) { * */ void SliderTable:: -write(ostream &out) const { +write(std::ostream &out) const { for (size_t i = 0; i < _sliders.size(); ++i) { out << i << ". " << *_sliders[i]._slider << " " << _sliders[i]._rows << "\n"; diff --git a/panda/src/gobj/test_gobj.cxx b/panda/src/gobj/test_gobj.cxx index 74b408ec97..0bbe93e907 100644 --- a/panda/src/gobj/test_gobj.cxx +++ b/panda/src/gobj/test_gobj.cxx @@ -15,7 +15,7 @@ #include "perspectiveProjection.h" int main() { - nout << "running test_gobj" << endl; + nout << "running test_gobj" << std::endl; PT(GeomTri) triangle = new GeomTri; Frustumf frust; PT(PerspectiveProjection) proj = new PerspectiveProjection(frust); diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 2479105093..1ebeec18db 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -49,6 +49,14 @@ #include +using std::endl; +using std::istream; +using std::max; +using std::min; +using std::ostream; +using std::string; +using std::swap; + ConfigVariableEnum texture_quality_level ("texture-quality-level", Texture::QL_normal, PRC_DESC("This specifies a global quality level for all textures. You " @@ -3960,7 +3968,7 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) default: gobj_cat.error() << filename << ": unsupported texture compression (FourCC: 0x" - << hex << header.pf.four_cc << dec << ").\n"; + << std::hex << header.pf.four_cc << std::dec << ").\n"; return false; } @@ -4432,8 +4440,8 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) if (base_format != gl_base_format) { gobj_cat.error() << filename << " has internal format that is incompatible with base " - "format (0x" << hex << gl_base_format << ", expected 0x" - << base_format << dec << ")\n"; + "format (0x" << std::hex << gl_base_format << ", expected 0x" + << base_format << std::dec << ")\n"; return false; } @@ -4895,14 +4903,14 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } } - do_set_ram_mipmap_image(cdata, (int)n, move(image), + do_set_ram_mipmap_image(cdata, (int)n, std::move(image), row_size * do_get_expected_mipmap_y_size(cdata, (int)n)); } else { // Compressed image. We'll trust that the file has the right size. image = PTA_uchar::empty_array(image_size); ktx.extract_bytes(image.p(), image_size); - do_set_ram_mipmap_image(cdata, (int)n, move(image), image_size / depth); + do_set_ram_mipmap_image(cdata, (int)n, std::move(image), image_size / depth); } ktx.skip_bytes(3 - ((image_size + 3) & 3)); diff --git a/panda/src/gobj/textureCollection.cxx b/panda/src/gobj/textureCollection.cxx index 16c6a908f6..57f91a8ef8 100644 --- a/panda/src/gobj/textureCollection.cxx +++ b/panda/src/gobj/textureCollection.cxx @@ -181,7 +181,7 @@ reserve(size_t num) { * NULL if no texture has that name. */ Texture *TextureCollection:: -find_texture(const string &name) const { +find_texture(const std::string &name) const { int num_textures = get_num_textures(); for (int i = 0; i < num_textures; i++) { Texture *texture = get_texture(i); @@ -235,7 +235,7 @@ size() const { * indicated output stream. */ void TextureCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_textures() == 1) { out << "1 Texture"; } else { @@ -248,7 +248,7 @@ output(ostream &out) const { * indicated output stream. */ void TextureCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_textures(); i++) { indent(out, indent_level) << *get_texture(i) << "\n"; } diff --git a/panda/src/gobj/textureCollection_ext.cxx b/panda/src/gobj/textureCollection_ext.cxx index 233249ee6f..127bba9ac5 100644 --- a/panda/src/gobj/textureCollection_ext.cxx +++ b/panda/src/gobj/textureCollection_ext.cxx @@ -44,9 +44,9 @@ __init__(PyObject *self, PyObject *sequence) { DTOOL_Call_ExtractThisPointerForType(item, &Dtool_Texture, (void **)&tex); if (tex == nullptr) { // Unable to add item--probably it wasn't of the appropriate type. - ostringstream stream; + std::ostringstream stream; stream << "Element " << i << " in sequence passed to TextureCollection constructor is not a Texture"; - string str = stream.str(); + std::string str = stream.str(); PyErr_SetString(PyExc_TypeError, str.c_str()); Py_DECREF(fast); return; diff --git a/panda/src/gobj/textureContext.cxx b/panda/src/gobj/textureContext.cxx index 32224a7bde..7a83a17a01 100644 --- a/panda/src/gobj/textureContext.cxx +++ b/panda/src/gobj/textureContext.cxx @@ -40,7 +40,7 @@ get_native_buffer_id() const { * */ void TextureContext:: -output(ostream &out) const { +output(std::ostream &out) const { out << *get_texture() << ", " << get_data_size_bytes(); } @@ -48,6 +48,6 @@ output(ostream &out) const { * */ void TextureContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SavedContext::write(out, indent_level); } diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index b4e1be9224..5dc3368909 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -178,7 +178,7 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { default: // Not supported. gobj_cat.error() << "Unsupported texture peeker format: " - << Texture::format_format(_format) << endl; + << Texture::format_format(_format) << std::endl; _image.clear(); return; } diff --git a/panda/src/gobj/texturePool.cxx b/panda/src/gobj/texturePool.cxx index 1b39a24273..d62b68b377 100644 --- a/panda/src/gobj/texturePool.cxx +++ b/panda/src/gobj/texturePool.cxx @@ -28,6 +28,10 @@ #include "mutexHolder.h" #include "dcast.h" +using std::istream; +using std::ostream; +using std::string; + TexturePool *TexturePool::_global_ptr; /** @@ -128,7 +132,7 @@ write_texture_types(ostream &out, int indent_level) const { PT(Texture) tex = func(); string name = tex->get_type().get_name(); indent(out, indent_level) << name; - indent(out, max(30 - (int)name.length(), 0)) + indent(out, std::max(30 - (int)name.length(), 0)) << " ." << extension << "\n"; } } @@ -389,7 +393,7 @@ ns_load_texture(const Filename &orig_filename, // needs to be loaded from its source image(s). gobj_cat.info() << "Loading texture " << filename << " and alpha component " - << alpha_filename << endl; + << alpha_filename << std::endl; tex = ns_make_texture(filename.get_extension()); if (!tex->read(filename, alpha_filename, primary_file_num_channels, alpha_file_channel, 0, 0, false, read_mipmaps, nullptr, @@ -1245,11 +1249,11 @@ load_filters() { Filename dlname = Filename::dso_filename("lib" + name + ".so"); gobj_cat->info() - << "loading texture filter: " << dlname.to_os_specific() << endl; + << "loading texture filter: " << dlname.to_os_specific() << std::endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == nullptr) { gobj_cat.info() - << "Unable to load: " << load_dso_error() << endl; + << "Unable to load: " << load_dso_error() << std::endl; } } } diff --git a/panda/src/gobj/texturePoolFilter.cxx b/panda/src/gobj/texturePoolFilter.cxx index f0b98c877e..c63803860c 100644 --- a/panda/src/gobj/texturePoolFilter.cxx +++ b/panda/src/gobj/texturePoolFilter.cxx @@ -51,6 +51,6 @@ post_load(Texture *tex) { * */ void TexturePoolFilter:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } diff --git a/panda/src/gobj/textureStage.cxx b/panda/src/gobj/textureStage.cxx index 120bb4feb3..4fecd20999 100644 --- a/panda/src/gobj/textureStage.cxx +++ b/panda/src/gobj/textureStage.cxx @@ -16,6 +16,8 @@ #include "bamReader.h" #include "bamWriter.h" +using std::ostream; + PT(TextureStage) TextureStage::_default_stage; UpdateSeq TextureStage::_sort_seq; @@ -25,7 +27,7 @@ TypeHandle TextureStage::_type_handle; * Initialize the texture stage at construction */ TextureStage:: -TextureStage(const string &name) : _used_by_auto_shader(false) { +TextureStage(const std::string &name) : _used_by_auto_shader(false) { _name = name; _sort = 0; _priority = 0; diff --git a/panda/src/gobj/textureStagePool.cxx b/panda/src/gobj/textureStagePool.cxx index f47addd52b..01e009ef7c 100644 --- a/panda/src/gobj/textureStagePool.cxx +++ b/panda/src/gobj/textureStagePool.cxx @@ -17,6 +17,10 @@ #include "configVariableEnum.h" #include "string_utils.h" +using std::istream; +using std::ostream; +using std::string; + TextureStagePool *TextureStagePool::_global_ptr = nullptr; diff --git a/panda/src/gobj/texture_ext.cxx b/panda/src/gobj/texture_ext.cxx index 3cd291843f..9af792be08 100644 --- a/panda/src/gobj/texture_ext.cxx +++ b/panda/src/gobj/texture_ext.cxx @@ -77,7 +77,7 @@ set_ram_image(PyObject *image, Texture::CompressionMode compression, PTA_uchar data = PTA_uchar::empty_array(view.len, Texture::get_class_type()); memcpy(data.p(), view.buf, view.len); - _this->set_ram_image(move(data), compression, page_size); + _this->set_ram_image(std::move(data), compression, page_size); PyBuffer_Release(&view); return; @@ -102,7 +102,7 @@ set_ram_image(PyObject *image, Texture::CompressionMode compression, PTA_uchar data = PTA_uchar::empty_array(buffer_len, Texture::get_class_type()); memcpy(data.p(), buffer, buffer_len); - _this->set_ram_image(move(data), compression, page_size); + _this->set_ram_image(std::move(data), compression, page_size); return; } #endif @@ -117,7 +117,7 @@ set_ram_image(PyObject *image, Texture::CompressionMode compression, * support compressed image data or sub-pages; use set_ram_image() for that. */ void Extension:: -set_ram_image_as(PyObject *image, const string &provided_format) { +set_ram_image_as(PyObject *image, const std::string &provided_format) { // Check if perhaps a PointerToArray object was passed in. if (DtoolInstance_Check(image)) { if (DtoolInstance_TYPE(image) == &Dtool_ConstPointerToArray_unsigned_char) { @@ -155,7 +155,7 @@ set_ram_image_as(PyObject *image, const string &provided_format) { PTA_uchar data = PTA_uchar::empty_array(view.len, Texture::get_class_type()); memcpy(data.p(), view.buf, view.len); - _this->set_ram_image_as(move(data), provided_format); + _this->set_ram_image_as(std::move(data), provided_format); PyBuffer_Release(&view); return; diff --git a/panda/src/gobj/transformBlend.cxx b/panda/src/gobj/transformBlend.cxx index 656a691a95..9ca70390e2 100644 --- a/panda/src/gobj/transformBlend.cxx +++ b/panda/src/gobj/transformBlend.cxx @@ -54,7 +54,7 @@ add_transform(const VertexTransform *transform, PN_stdfloat weight) { TransformEntry entry; entry._transform = transform; entry._weight = weight; - pair result = _entries.insert(entry); + std::pair result = _entries.insert(entry); if (!result.second) { // If the new value was not inserted, it was already there; increment // the existing weight factor. @@ -168,7 +168,7 @@ get_weight(const VertexTransform *transform) const { * */ void TransformBlend:: -output(ostream &out) const { +output(std::ostream &out) const { if (_entries.empty()) { out << "empty"; } else { @@ -186,7 +186,7 @@ output(ostream &out) const { * */ void TransformBlend:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Thread *current_thread = Thread::get_current_thread(); Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { @@ -218,7 +218,7 @@ recompute_result(CData *cdata, Thread *current_thread) { UpdateSeq seq; Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { - seq = max(seq, (*ei)._transform->get_modified(current_thread)); + seq = std::max(seq, (*ei)._transform->get_modified(current_thread)); } if (cdata->_modified != seq) { diff --git a/panda/src/gobj/transformBlendTable.cxx b/panda/src/gobj/transformBlendTable.cxx index da76d38626..266da16c3b 100644 --- a/panda/src/gobj/transformBlendTable.cxx +++ b/panda/src/gobj/transformBlendTable.cxx @@ -107,7 +107,7 @@ add_blend(const TransformBlend &blend) { // latest. const TransformBlend &added_blend = _blends[new_position]; _blend_index[&added_blend] = new_position; - _max_simultaneous_transforms = max(_max_simultaneous_transforms, + _max_simultaneous_transforms = std::max(_max_simultaneous_transforms, (int)blend.get_num_transforms()); // We can't compute this one as we go, so set it to a special value to @@ -122,7 +122,7 @@ add_blend(const TransformBlend &blend) { * */ void TransformBlendTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (size_t i = 0; i < _blends.size(); ++i) { indent(out, indent_level) << i << ". " << _blends[i] << "\n"; @@ -158,7 +158,7 @@ rebuild_index() { for (size_t ti = 0; ti < blend.get_num_transforms(); ++ti) { transforms.insert(blend.get_transform(ti)); } - _max_simultaneous_transforms = max((size_t)_max_simultaneous_transforms, + _max_simultaneous_transforms = std::max((size_t)_max_simultaneous_transforms, blend.get_num_transforms()); } @@ -179,7 +179,7 @@ recompute_modified(TransformBlendTable::CData *cdata, Thread *current_thread) { UpdateSeq seq; Blends::const_iterator bi; for (bi = _blends.begin(); bi != _blends.end(); ++bi) { - seq = max(seq, (*bi).get_modified(current_thread)); + seq = std::max(seq, (*bi).get_modified(current_thread)); } cdata->_modified = seq; diff --git a/panda/src/gobj/transformTable.cxx b/panda/src/gobj/transformTable.cxx index df66f7a696..3ddadca33a 100644 --- a/panda/src/gobj/transformTable.cxx +++ b/panda/src/gobj/transformTable.cxx @@ -111,7 +111,7 @@ add_transform(const VertexTransform *transform) { * */ void TransformTable:: -write(ostream &out) const { +write(std::ostream &out) const { for (size_t i = 0; i < _transforms.size(); ++i) { out << i << ". " << *_transforms[i] << "\n"; } diff --git a/panda/src/gobj/userVertexSlider.cxx b/panda/src/gobj/userVertexSlider.cxx index d6363082a8..a868be2058 100644 --- a/panda/src/gobj/userVertexSlider.cxx +++ b/panda/src/gobj/userVertexSlider.cxx @@ -21,7 +21,7 @@ TypeHandle UserVertexSlider::_type_handle; * */ UserVertexSlider:: -UserVertexSlider(const string &name) : +UserVertexSlider(const std::string &name) : VertexSlider(InternalName::make(name)) { } diff --git a/panda/src/gobj/userVertexTransform.cxx b/panda/src/gobj/userVertexTransform.cxx index d83aeb4c8a..c27cb38d61 100644 --- a/panda/src/gobj/userVertexTransform.cxx +++ b/panda/src/gobj/userVertexTransform.cxx @@ -21,7 +21,7 @@ TypeHandle UserVertexTransform::_type_handle; * */ UserVertexTransform:: -UserVertexTransform(const string &name) : +UserVertexTransform(const std::string &name) : _name(name) { } @@ -39,7 +39,7 @@ get_matrix(LMatrix4 &matrix) const { * */ void UserVertexTransform:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name(); } diff --git a/panda/src/gobj/vertexBufferContext.cxx b/panda/src/gobj/vertexBufferContext.cxx index cde6ec023a..b0eab66a74 100644 --- a/panda/src/gobj/vertexBufferContext.cxx +++ b/panda/src/gobj/vertexBufferContext.cxx @@ -20,7 +20,7 @@ TypeHandle VertexBufferContext::_type_handle; * */ void VertexBufferContext:: -output(ostream &out) const { +output(std::ostream &out) const { out << *get_data() << ", " << get_data_size_bytes(); } @@ -28,6 +28,6 @@ output(ostream &out) const { * */ void VertexBufferContext:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SavedContext::write(out, indent_level); } diff --git a/panda/src/gobj/vertexDataBuffer.cxx b/panda/src/gobj/vertexDataBuffer.cxx index a891811091..e1d3ad5c56 100644 --- a/panda/src/gobj/vertexDataBuffer.cxx +++ b/panda/src/gobj/vertexDataBuffer.cxx @@ -102,7 +102,7 @@ do_clean_realloc(size_t reserved_size) { _reserved_size = reserved_size; } - _size = min(_size, _reserved_size); + _size = std::min(_size, _reserved_size); } /** diff --git a/panda/src/gobj/vertexDataPage.cxx b/panda/src/gobj/vertexDataPage.cxx index e7adb80d33..74e58edb58 100644 --- a/panda/src/gobj/vertexDataPage.cxx +++ b/panda/src/gobj/vertexDataPage.cxx @@ -211,7 +211,7 @@ flush_threads() { * */ void VertexDataPage:: -output(ostream &out) const { +output(std::ostream &out) const { SimpleAllocator::output(out); } @@ -219,7 +219,7 @@ output(ostream &out) const { * */ void VertexDataPage:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { SimpleAllocator::write(out); } @@ -391,7 +391,7 @@ make_resident() { while (result != Z_STREAM_END) { unsigned char *start_out = (unsigned char *)z_source.next_out; nassertv(start_out < end_data); - z_source.avail_out = min((size_t)(end_data - start_out), (size_t)inflate_page_size); + z_source.avail_out = std::min((size_t)(end_data - start_out), (size_t)inflate_page_size); nassertv(z_source.avail_out != 0); result = inflate(&z_source, flush); if (result < 0 && result != Z_BUF_ERROR) { @@ -884,7 +884,7 @@ start_threads(int num_threads) { _threads.reserve(num_threads); for (int i = 0; i < num_threads; ++i) { - ostringstream name_strm; + std::ostringstream name_strm; name_strm << "VertexDataPage" << _threads.size(); PT(PageThread) thread = new PageThread(this, name_strm.str()); thread->start(TP_low, true); @@ -919,7 +919,7 @@ stop_threads() { * */ VertexDataPage::PageThread:: -PageThread(PageThreadManager *manager, const string &name) : +PageThread(PageThreadManager *manager, const std::string &name) : Thread(name, name), _manager(manager), _working_cvar(_tlock) diff --git a/panda/src/gobj/vertexDataSaveFile.cxx b/panda/src/gobj/vertexDataSaveFile.cxx index 97a77688a8..37839099dc 100644 --- a/panda/src/gobj/vertexDataSaveFile.cxx +++ b/panda/src/gobj/vertexDataSaveFile.cxx @@ -28,11 +28,14 @@ #include #endif +using std::dec; +using std::hex; + /** * */ VertexDataSaveFile:: -VertexDataSaveFile(const Filename &directory, const string &prefix, +VertexDataSaveFile(const Filename &directory, const std::string &prefix, size_t max_size) : SimpleAllocator(max_size, _lock) { @@ -50,12 +53,12 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, int index = 0; while (true) { ++index; - ostringstream strm; + std::ostringstream strm; strm << prefix << "_" << index << ".dat"; - string basename = strm.str(); + std::string basename = strm.str(); _filename = Filename(dir, basename); - string os_specific = _filename.to_os_specific(); + std::string os_specific = _filename.to_os_specific(); if (gobj_cat.is_debug()) { gobj_cat.debug() @@ -201,7 +204,7 @@ write_data(const unsigned char *data, size_t size, bool compressed) { PT(VertexDataSaveBlock) block = (VertexDataSaveBlock *)SimpleAllocator::do_alloc(size); if (block != nullptr) { - _total_file_size = max(_total_file_size, block->get_start() + size); + _total_file_size = std::max(_total_file_size, block->get_start() + size); block->set_compressed(compressed); #ifdef _WIN32 diff --git a/panda/src/gobj/vertexSlider.cxx b/panda/src/gobj/vertexSlider.cxx index 86d841ad53..bc05232eb2 100644 --- a/panda/src/gobj/vertexSlider.cxx +++ b/panda/src/gobj/vertexSlider.cxx @@ -40,7 +40,7 @@ VertexSlider:: * */ void VertexSlider:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << *get_name(); } @@ -48,7 +48,7 @@ output(ostream &out) const { * */ void VertexSlider:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << " = " << get_slider() << "\n"; } diff --git a/panda/src/gobj/vertexTransform.cxx b/panda/src/gobj/vertexTransform.cxx index 35a60bd25a..972584b527 100644 --- a/panda/src/gobj/vertexTransform.cxx +++ b/panda/src/gobj/vertexTransform.cxx @@ -68,7 +68,7 @@ accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { * */ void VertexTransform:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -76,7 +76,7 @@ output(ostream &out) const { * */ void VertexTransform:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; LMatrix4 mat; diff --git a/panda/src/gobj/videoTexture.cxx b/panda/src/gobj/videoTexture.cxx index 0cde2d98f6..a3b5e2c72b 100644 --- a/panda/src/gobj/videoTexture.cxx +++ b/panda/src/gobj/videoTexture.cxx @@ -23,7 +23,7 @@ TypeHandle VideoTexture::_type_handle; * */ VideoTexture:: -VideoTexture(const string &name) : +VideoTexture(const std::string &name) : Texture(name) { // We don't want to try to compress each frame as it's loaded. @@ -104,8 +104,8 @@ set_video_size(int video_width, int video_height) { Texture::CDWriter cdata(Texture::_cycler, true); do_set_pad_size(cdata, - max(cdata->_x_size - _video_width, 0), - max(cdata->_y_size - _video_height, 0), + std::max(cdata->_x_size - _video_width, 0), + std::max(cdata->_y_size - _video_height, 0), 0); } @@ -181,7 +181,7 @@ do_can_reload(const Texture::CData *cdata) const { */ bool VideoTexture:: do_adjust_this_size(const Texture::CData *cdata_tex, - int &x_size, int &y_size, const string &name, + int &x_size, int &y_size, const std::string &name, bool for_padding) const { AutoTextureScale ats = do_get_auto_texture_scale(cdata_tex); if (ats != ATS_none) { diff --git a/panda/src/grutil/fisheyeMaker.cxx b/panda/src/grutil/fisheyeMaker.cxx index f245242aec..ad7a8a90ef 100644 --- a/panda/src/grutil/fisheyeMaker.cxx +++ b/panda/src/grutil/fisheyeMaker.cxx @@ -177,7 +177,7 @@ generate() { int piece_size = max_vertices_per_primitive / 2 - 1; int vi = 0; while (vi < ring_size) { - int piece_end = min(ring_size + 1, piece_size + 1 + vi); + int piece_end = std::min(ring_size + 1, piece_size + 1 + vi); for (int pi = vi; pi < piece_end; ++pi) { tristrips->add_vertex(last_ring_vertex + pi % last_ring_size); tristrips->add_vertex(ring_vertex + pi % ring_size); @@ -284,7 +284,7 @@ generate() { int piece_size = max_vertices_per_primitive / 2 - 1; int vi = 0; while (vi < ring_size) { - int piece_end = min(ring_size + 1, piece_size + 1 + vi); + int piece_end = std::min(ring_size + 1, piece_size + 1 + vi); for (int pi = vi; pi < piece_end; ++pi) { tristrips->add_vertex(last_ring_vertex + pi % last_ring_size); tristrips->add_vertex(ring_vertex + pi % ring_size); diff --git a/panda/src/grutil/frameRateMeter.cxx b/panda/src/grutil/frameRateMeter.cxx index 0b9fc9d1bb..f015e0ab55 100644 --- a/panda/src/grutil/frameRateMeter.cxx +++ b/panda/src/grutil/frameRateMeter.cxx @@ -31,7 +31,7 @@ TypeHandle FrameRateMeter::_type_handle; * */ FrameRateMeter:: -FrameRateMeter(const string &name) : +FrameRateMeter(const std::string &name) : TextNode(name), _last_aspect_ratio(-1) { diff --git a/panda/src/grutil/geoMipTerrain.cxx b/panda/src/grutil/geoMipTerrain.cxx index a627ac11f7..457e55d901 100644 --- a/panda/src/grutil/geoMipTerrain.cxx +++ b/panda/src/grutil/geoMipTerrain.cxx @@ -29,6 +29,9 @@ #include "collideMask.h" +using std::max; +using std::min; + static ConfigVariableBool geomipterrain_incorrect_normals ("geomipterrain-incorrect-normals", false, PRC_DESC("If true, uses the incorrect normal vector calculation that " @@ -256,7 +259,7 @@ generate_block(unsigned short mx, geom->add_primitive(prim); geom->set_bounds_type(BoundingVolume::BT_box); - ostringstream sname; + std::ostringstream sname; sname << "gmm" << mx << "x" << my; PT(GeomNode) node = new GeomNode(sname.str()); node->add_geom(geom); diff --git a/panda/src/grutil/lineSegs.cxx b/panda/src/grutil/lineSegs.cxx index 7e53416855..534c1f5700 100644 --- a/panda/src/grutil/lineSegs.cxx +++ b/panda/src/grutil/lineSegs.cxx @@ -29,7 +29,7 @@ * which will render the described path. */ LineSegs:: -LineSegs(const string &name) : Namable(name) { +LineSegs(const std::string &name) : Namable(name) { _color.set(1.0f, 1.0f, 1.0f, 1.0f); _thick = 1.0f; } diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index ab8cb390ef..280079948d 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -35,7 +35,7 @@ TypeHandle MovieTexture::_type_handle; * do_load_one. */ MovieTexture:: -MovieTexture(const string &name) : +MovieTexture(const std::string &name) : Texture(name) { } @@ -177,8 +177,8 @@ do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const L cdata_tex->_orig_file_y_size = cdata->_video_height; do_set_pad_size(cdata_tex, - max(cdata_tex->_x_size - cdata_tex->_orig_file_x_size, 0), - max(cdata_tex->_y_size - cdata_tex->_orig_file_y_size, 0), + std::max(cdata_tex->_x_size - cdata_tex->_orig_file_x_size, 0), + std::max(cdata_tex->_y_size - cdata_tex->_orig_file_y_size, 0), 0); } @@ -188,7 +188,7 @@ do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const L */ bool MovieTexture:: do_adjust_this_size(const Texture::CData *cdata_tex, - int &x_size, int &y_size, const string &name, + int &x_size, int &y_size, const std::string &name, bool for_padding) const { AutoTextureScale ats = do_get_auto_texture_scale(cdata_tex); if (ats != ATS_none) { @@ -285,7 +285,7 @@ do_load_one(Texture::CData *cdata_tex, */ bool MovieTexture:: do_load_one(Texture::CData *cdata_tex, - const PNMImage &pnmimage, const string &name, int z, int n, + const PNMImage &pnmimage, const std::string &name, int z, int n, const LoaderOptions &options) { grutil_cat.error() << "You cannot load a static image into a MovieTexture\n"; return false; @@ -534,7 +534,7 @@ play() { void MovieTexture:: set_time(double t) { CDWriter cdata(_cycler); - t = min(cdata->_video_length, max(0.0, t)); + t = std::min(cdata->_video_length, std::max(0.0, t)); if (cdata->_playing) { double now = ClockObject::get_global_clock()->get_frame_time(); cdata->_clock = t - (now * cdata->_play_rate); diff --git a/panda/src/grutil/multitexReducer.cxx b/panda/src/grutil/multitexReducer.cxx index 5d76ade23a..fdad25bb48 100644 --- a/panda/src/grutil/multitexReducer.cxx +++ b/panda/src/grutil/multitexReducer.cxx @@ -37,6 +37,9 @@ #include "geomVertexWriter.h" #include "geomVertexReader.h" +using std::max; +using std::min; + /** * */ @@ -236,7 +239,7 @@ flatten(GraphicsOutput *window) { window); static int multitex_id = 1; - ostringstream multitex_name_strm; + std::ostringstream multitex_name_strm; multitex_name_strm << "multitex" << multitex_id; multitex_id++; @@ -437,7 +440,7 @@ scan_geom_node(GeomNode *node, const RenderState *state, if (grutil_cat.is_debug()) { grutil_cat.debug() << "geom " << gi << " net_state =\n"; - geom_net_state->write(cerr, 2); + geom_net_state->write(std::cerr, 2); } // Get out the net TextureAttrib and TexMatrixAttrib from the state. diff --git a/panda/src/grutil/nodeVertexTransform.cxx b/panda/src/grutil/nodeVertexTransform.cxx index 5fb44d6cc1..7d4cb2deac 100644 --- a/panda/src/grutil/nodeVertexTransform.cxx +++ b/panda/src/grutil/nodeVertexTransform.cxx @@ -46,7 +46,7 @@ get_matrix(LMatrix4 &matrix) const { * */ void NodeVertexTransform:: -output(ostream &out) const { +output(std::ostream &out) const { if (_prev != nullptr) { _prev->output(out); out << " * "; diff --git a/panda/src/grutil/pfmVizzer.cxx b/panda/src/grutil/pfmVizzer.cxx index 4d1a65d416..f3d60787a8 100644 --- a/panda/src/grutil/pfmVizzer.cxx +++ b/panda/src/grutil/pfmVizzer.cxx @@ -23,6 +23,9 @@ #include "pnmImage.h" #include "config_grutil.h" +using std::max; +using std::min; + /** * The PfmVizzer constructor receives a reference to a PfmFile which it will * operate on. It does not keep ownership of this reference; it is your @@ -777,7 +780,7 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { num_vertices = x_size * y_size; max_indices = (x_size - 1) * (y_size - 1) * 6; - ostringstream mesh_name; + std::ostringstream mesh_name; mesh_name << "mesh_" << xci << "_" << yci; PT(GeomVertexData) vdata = new GeomVertexData (mesh_name.str(), format, Geom::UH_static); diff --git a/panda/src/grutil/rigidBodyCombiner.cxx b/panda/src/grutil/rigidBodyCombiner.cxx index 44f2971aa5..fb2c3959ab 100644 --- a/panda/src/grutil/rigidBodyCombiner.cxx +++ b/panda/src/grutil/rigidBodyCombiner.cxx @@ -30,7 +30,7 @@ TypeHandle RigidBodyCombiner::_type_handle; * */ RigidBodyCombiner:: -RigidBodyCombiner(const string &name) : PandaNode(name) { +RigidBodyCombiner(const std::string &name) : PandaNode(name) { set_cull_callback(); _internal_root = new PandaNode(name); diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx index 9881575f62..02d6ed3709 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx @@ -29,7 +29,7 @@ TypeHandle SceneGraphAnalyzerMeter::_type_handle; * */ SceneGraphAnalyzerMeter:: -SceneGraphAnalyzerMeter(const string &name, PandaNode *node) : TextNode(name) { +SceneGraphAnalyzerMeter(const std::string &name, PandaNode *node) : TextNode(name) { set_cull_callback(); Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/grutil/shaderTerrainMesh.cxx b/panda/src/grutil/shaderTerrainMesh.cxx index d5ecdf21e2..44c8397279 100644 --- a/panda/src/grutil/shaderTerrainMesh.cxx +++ b/panda/src/grutil/shaderTerrainMesh.cxx @@ -34,6 +34,10 @@ #include "config_grutil.h" #include "typeHandle.h" +using std::endl; +using std::max; +using std::min; + ConfigVariableBool stm_use_hexagonal_layout ("stm-use-hexagonal-layout", false, PRC_DESC("Set this to true to use a hexagonal vertex layout. This approximates " @@ -542,7 +546,7 @@ void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &dat state = state->set_attrib(current_shader_attrib, 10000); // Emit chunk - CullableObject *object = new CullableObject(_chunk_geom, move(state), move(modelview_transform)); + CullableObject *object = new CullableObject(_chunk_geom, std::move(state), std::move(modelview_transform)); trav->get_cull_handler()->record_object(object, trav); // After rendering, increment the view index diff --git a/panda/src/iphone/iphone_runappmf_src.mm b/panda/src/iphone/iphone_runappmf_src.mm index 40479f894f..56d97e8364 100644 --- a/panda/src/iphone/iphone_runappmf_src.mm +++ b/panda/src/iphone/iphone_runappmf_src.mm @@ -15,7 +15,6 @@ #include #include #include -using namespace std; #include "pnotify.h" diff --git a/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm b/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm index dba09cbcc9..82e92f4b70 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm +++ b/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm @@ -51,7 +51,7 @@ IPhoneGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string IPhoneGraphicsPipe:: +std::string IPhoneGraphicsPipe:: get_interface_name() const { return "OpenGL ES"; } diff --git a/panda/src/linmath/coordinateSystem.cxx b/panda/src/linmath/coordinateSystem.cxx index 6eb81077ca..b94b0ec4ff 100644 --- a/panda/src/linmath/coordinateSystem.cxx +++ b/panda/src/linmath/coordinateSystem.cxx @@ -21,6 +21,11 @@ #include +using std::istream; +using std::ostream; +using std::ostringstream; +using std::string; + static ConfigVariableEnum default_cs ("coordinate-system", CS_zup_right, PRC_DESC("The default coordinate system to use throughout Panda for " diff --git a/panda/src/linmath/lmatrix3_src.cxx b/panda/src/linmath/lmatrix3_src.cxx index e21160b2fd..e654b3accd 100644 --- a/panda/src/linmath/lmatrix3_src.cxx +++ b/panda/src/linmath/lmatrix3_src.cxx @@ -326,7 +326,7 @@ almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const { * */ void FLOATNAME(LMatrix3):: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ " << MAYBE_ZERO(_m(0, 0)) << " " << MAYBE_ZERO(_m(0, 1)) << " " @@ -346,7 +346,7 @@ output(ostream &out) const { * */ void FLOATNAME(LMatrix3):: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << MAYBE_ZERO(_m(0, 0)) << " " << MAYBE_ZERO(_m(0, 1)) << " " diff --git a/panda/src/linmath/lmatrix4_src.cxx b/panda/src/linmath/lmatrix4_src.cxx index 427841965f..0a1d5a6a0e 100644 --- a/panda/src/linmath/lmatrix4_src.cxx +++ b/panda/src/linmath/lmatrix4_src.cxx @@ -306,7 +306,7 @@ almost_equal(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const { * */ void FLOATNAME(LMatrix4):: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ " << MAYBE_ZERO(_m(0, 0)) << " " << MAYBE_ZERO(_m(0, 1)) << " " @@ -334,7 +334,7 @@ output(ostream &out) const { * */ void FLOATNAME(LMatrix4):: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << MAYBE_ZERO(_m(0, 0)) << " " << MAYBE_ZERO(_m(0, 1)) << " " diff --git a/panda/src/linmath/test_math.cxx b/panda/src/linmath/test_math.cxx index 41d1d15431..5a92f433d2 100644 --- a/panda/src/linmath/test_math.cxx +++ b/panda/src/linmath/test_math.cxx @@ -19,6 +19,10 @@ #include "pnotify.h" #include +using std::cerr; +using std::cout; +using std::endl; + void test() { LMatrix4f x = LMatrix4f::ident_mat(); LMatrix4f y = LMatrix4f::ident_mat(); diff --git a/panda/src/mathutil/boundingBox.cxx b/panda/src/mathutil/boundingBox.cxx index e2ce9c6c6a..1f0a1b7758 100644 --- a/panda/src/mathutil/boundingBox.cxx +++ b/panda/src/mathutil/boundingBox.cxx @@ -22,6 +22,9 @@ #include #include +using std::max; +using std::min; + const int BoundingBox::plane_def[6][3] = { { 0, 4, 5 }, { 4, 6, 7 }, @@ -111,7 +114,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingBox:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bbox, empty"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/boundingHexahedron.cxx b/panda/src/mathutil/boundingHexahedron.cxx index b765f043b0..1e500cb64c 100644 --- a/panda/src/mathutil/boundingHexahedron.cxx +++ b/panda/src/mathutil/boundingHexahedron.cxx @@ -19,6 +19,9 @@ #include #include +using std::max; +using std::min; + TypeHandle BoundingHexahedron::_type_handle; /** @@ -151,7 +154,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingHexahedron:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bhexahedron, empty"; } else if (is_infinite()) { @@ -165,7 +168,7 @@ output(ostream &out) const { * */ void BoundingHexahedron:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (is_empty()) { indent(out, indent_level) << "bhexahedron, empty\n"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/boundingLine.cxx b/panda/src/mathutil/boundingLine.cxx index 38dd4704a5..93de2f6d5e 100644 --- a/panda/src/mathutil/boundingLine.cxx +++ b/panda/src/mathutil/boundingLine.cxx @@ -60,7 +60,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingLine:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bline, empty"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/boundingPlane.cxx b/panda/src/mathutil/boundingPlane.cxx index b0a36ab3e3..9690bb8dae 100644 --- a/panda/src/mathutil/boundingPlane.cxx +++ b/panda/src/mathutil/boundingPlane.cxx @@ -53,7 +53,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingPlane:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bplane, empty"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/boundingSphere.cxx b/panda/src/mathutil/boundingSphere.cxx index a0754b9b55..32e48adad9 100644 --- a/panda/src/mathutil/boundingSphere.cxx +++ b/panda/src/mathutil/boundingSphere.cxx @@ -22,6 +22,9 @@ #include +using std::max; +using std::min; + TypeHandle BoundingSphere::_type_handle; /** @@ -116,7 +119,7 @@ xform(const LMatrix4 &mat) { * */ void BoundingSphere:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "bsphere, empty"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/boundingVolume.cxx b/panda/src/mathutil/boundingVolume.cxx index d81f905e25..a806dc819b 100644 --- a/panda/src/mathutil/boundingVolume.cxx +++ b/panda/src/mathutil/boundingVolume.cxx @@ -24,6 +24,10 @@ #include "indent.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle BoundingVolume::_type_handle; diff --git a/panda/src/mathutil/intersectionBoundingVolume.cxx b/panda/src/mathutil/intersectionBoundingVolume.cxx index a8af2d2b97..334cb428fe 100644 --- a/panda/src/mathutil/intersectionBoundingVolume.cxx +++ b/panda/src/mathutil/intersectionBoundingVolume.cxx @@ -74,7 +74,7 @@ xform(const LMatrix4 &mat) { * */ void IntersectionBoundingVolume:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "intersection, empty"; } else if (is_infinite()) { @@ -94,7 +94,7 @@ output(ostream &out) const { * */ void IntersectionBoundingVolume:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (is_empty()) { indent(out, indent_level) << "intersection, empty\n"; } else if (is_infinite()) { diff --git a/panda/src/mathutil/omniBoundingVolume.cxx b/panda/src/mathutil/omniBoundingVolume.cxx index 65e556b767..687374c1be 100644 --- a/panda/src/mathutil/omniBoundingVolume.cxx +++ b/panda/src/mathutil/omniBoundingVolume.cxx @@ -46,7 +46,7 @@ xform(const LMatrix4 &) { * */ void OmniBoundingVolume:: -output(ostream &out) const { +output(std::ostream &out) const { out << "omni"; } diff --git a/panda/src/mathutil/parabola_src.cxx b/panda/src/mathutil/parabola_src.cxx index a695a89c31..437ab012e5 100644 --- a/panda/src/mathutil/parabola_src.cxx +++ b/panda/src/mathutil/parabola_src.cxx @@ -27,7 +27,7 @@ xform(const FLOATNAME(LMatrix4) &mat) { * */ void FLOATNAME(LParabola):: -output(ostream &out) const { +output(std::ostream &out) const { out << "LParabola(" << _a << ", " << _b << ", " << _c << ")"; } @@ -35,7 +35,7 @@ output(ostream &out) const { * */ void FLOATNAME(LParabola):: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/mathutil/plane_src.cxx b/panda/src/mathutil/plane_src.cxx index 3a3baff375..7ba18701c6 100644 --- a/panda/src/mathutil/plane_src.cxx +++ b/panda/src/mathutil/plane_src.cxx @@ -145,7 +145,7 @@ intersects_parabola(FLOATTYPE &t1, FLOATTYPE &t2, * */ void FLOATNAME(LPlane):: -output(ostream &out) const { +output(std::ostream &out) const { out << "LPlane("; FLOATNAME(LVecBase4)::output(out); out << ")"; @@ -155,6 +155,6 @@ output(ostream &out) const { * */ void FLOATNAME(LPlane):: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/mathutil/test_tri.cxx b/panda/src/mathutil/test_tri.cxx index 57852b3773..e09b86fc21 100644 --- a/panda/src/mathutil/test_tri.cxx +++ b/panda/src/mathutil/test_tri.cxx @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) { t.triangulate(); for (int i = 0; i < t.get_num_triangles(); ++i) { - cerr << "tri: " << t.get_triangle_v0(i) << " " + std::cerr << "tri: " << t.get_triangle_v0(i) << " " << t.get_triangle_v1(i) << " " << t.get_triangle_v2(i) << "\n"; } diff --git a/panda/src/mathutil/unionBoundingVolume.cxx b/panda/src/mathutil/unionBoundingVolume.cxx index ed575b518b..2c4d7c41a9 100644 --- a/panda/src/mathutil/unionBoundingVolume.cxx +++ b/panda/src/mathutil/unionBoundingVolume.cxx @@ -74,7 +74,7 @@ xform(const LMatrix4 &mat) { * */ void UnionBoundingVolume:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_empty()) { out << "union, empty"; } else if (is_infinite()) { @@ -94,7 +94,7 @@ output(ostream &out) const { * */ void UnionBoundingVolume:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (is_empty()) { indent(out, indent_level) << "union, empty\n"; } else if (is_infinite()) { diff --git a/panda/src/movies/flacAudio.cxx b/panda/src/movies/flacAudio.cxx index b7c205b25b..07f41ca350 100644 --- a/panda/src/movies/flacAudio.cxx +++ b/panda/src/movies/flacAudio.cxx @@ -41,7 +41,7 @@ FlacAudio:: PT(MovieAudioCursor) FlacAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *stream = vfs->open_read_file(_filename, true); + std::istream *stream = vfs->open_read_file(_filename, true); if (stream == nullptr) { return nullptr; diff --git a/panda/src/movies/flacAudioCursor.cxx b/panda/src/movies/flacAudioCursor.cxx index e30fbfba8f..19eb71cbc9 100644 --- a/panda/src/movies/flacAudioCursor.cxx +++ b/panda/src/movies/flacAudioCursor.cxx @@ -25,7 +25,7 @@ extern "C" { * Callback passed to dr_flac to implement file I/O via the VirtualFileSystem. */ static size_t cb_read_proc(void *user, void *buffer, size_t size) { - istream *stream = (istream *)user; + std::istream *stream = (std::istream *)user; nassertr(stream != nullptr, false); stream->read((char *)buffer, size); @@ -42,10 +42,10 @@ static size_t cb_read_proc(void *user, void *buffer, size_t size) { * Callback passed to dr_flac to implement file I/O via the VirtualFileSystem. */ static bool cb_seek_proc(void *user, int offset) { - istream *stream = (istream *)user; + std::istream *stream = (std::istream *)user; nassertr(stream != nullptr, false); - stream->seekg(offset, ios::cur); + stream->seekg(offset, std::ios::cur); return !stream->fail(); } @@ -56,7 +56,7 @@ TypeHandle FlacAudioCursor::_type_handle; * pointer positioned at the start of the data. */ FlacAudioCursor:: -FlacAudioCursor(FlacAudio *src, istream *stream) : +FlacAudioCursor(FlacAudio *src, std::istream *stream) : MovieAudioCursor(src), _is_valid(false), _drflac(nullptr) @@ -99,7 +99,7 @@ FlacAudioCursor:: */ void FlacAudioCursor:: seek(double t) { - t = max(t, 0.0); + t = std::max(t, 0.0); uint64_t sample = t * _drflac->sampleRate; diff --git a/panda/src/movies/microphoneAudioDS.cxx b/panda/src/movies/microphoneAudioDS.cxx index cea9c65f60..1ce78b0209 100644 --- a/panda/src/movies/microphoneAudioDS.cxx +++ b/panda/src/movies/microphoneAudioDS.cxx @@ -149,7 +149,7 @@ find_all_microphones_ds() { stat = waveInOpen(nullptr, i, &format, 0, 0, WAVE_FORMAT_QUERY); if (stat == MMSYSERR_NOERROR) { PT(MicrophoneAudioDS) p = new MicrophoneAudioDS(); - ostringstream name; + std::ostringstream name; name << "WaveIn: " << caps.szPname << " Chan:" << chan << " HZ:" << freq; p->set_name(name.str()); p->_device_id = i; diff --git a/panda/src/movies/movieAudio.cxx b/panda/src/movies/movieAudio.cxx index 0dee90e805..6843984ac3 100644 --- a/panda/src/movies/movieAudio.cxx +++ b/panda/src/movies/movieAudio.cxx @@ -24,7 +24,7 @@ TypeHandle MovieAudio::_type_handle; * construct a subclass of this class. */ MovieAudio:: -MovieAudio(const string &name) : +MovieAudio(const std::string &name) : Namable(name) { } diff --git a/panda/src/movies/movieAudioCursor.cxx b/panda/src/movies/movieAudioCursor.cxx index f386401103..33acc0e10c 100644 --- a/panda/src/movies/movieAudioCursor.cxx +++ b/panda/src/movies/movieAudioCursor.cxx @@ -92,9 +92,9 @@ read_samples(int n, Datagram *dg) { * This is not particularly efficient, but it may be a convenient way to * manipulate samples in python. */ -string MovieAudioCursor:: +std::string MovieAudioCursor:: read_samples(int n) { - ostringstream result; + std::ostringstream result; int16_t tmp[4096]; while (n > 0) { int blocksize = (4096 / _audio_channels); diff --git a/panda/src/movies/movieTypeRegistry.cxx b/panda/src/movies/movieTypeRegistry.cxx index 024cf53634..012deff1cd 100644 --- a/panda/src/movies/movieTypeRegistry.cxx +++ b/panda/src/movies/movieTypeRegistry.cxx @@ -17,6 +17,9 @@ #include "config_putil.h" #include "load_dso.h" +using std::endl; +using std::string; + MovieTypeRegistry *MovieTypeRegistry::_global_ptr = nullptr; /** diff --git a/panda/src/movies/movieVideo.cxx b/panda/src/movies/movieVideo.cxx index cdeb797213..57b755a453 100644 --- a/panda/src/movies/movieVideo.cxx +++ b/panda/src/movies/movieVideo.cxx @@ -26,7 +26,7 @@ TypeHandle MovieVideo::_type_handle; * need to construct a subclass of this class. */ MovieVideo:: -MovieVideo(const string &name) : +MovieVideo(const std::string &name) : Namable(name) { } diff --git a/panda/src/movies/opusAudio.cxx b/panda/src/movies/opusAudio.cxx index 024560156a..54be404cd2 100644 --- a/panda/src/movies/opusAudio.cxx +++ b/panda/src/movies/opusAudio.cxx @@ -43,7 +43,7 @@ OpusAudio:: PT(MovieAudioCursor) OpusAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *stream = vfs->open_read_file(_filename, true); + std::istream *stream = vfs->open_read_file(_filename, true); if (stream == nullptr) { return nullptr; diff --git a/panda/src/movies/opusAudioCursor.cxx b/panda/src/movies/opusAudioCursor.cxx index 698648c5cb..2b1591e971 100644 --- a/panda/src/movies/opusAudioCursor.cxx +++ b/panda/src/movies/opusAudioCursor.cxx @@ -18,6 +18,8 @@ #include +using std::istream; + /** * Callbacks passed to libopusfile to implement file I/O via the * VirtualFileSystem. @@ -46,15 +48,15 @@ int cb_seek(void *stream, opus_int64 offset, int whence) { switch (whence) { case SEEK_SET: - in->seekg(offset, ios::beg); + in->seekg(offset, std::ios::beg); break; case SEEK_CUR: - in->seekg(offset, ios::cur); + in->seekg(offset, std::ios::cur); break; case SEEK_END: - in->seekg(offset, ios::end); + in->seekg(offset, std::ios::end); break; default: @@ -165,7 +167,7 @@ seek(double t) { return; } - t = max(t, 0.0); + t = std::max(t, 0.0); // Use op_time_seek_lap if cross-lapping is enabled. int error = op_pcm_seek(_op, (ogg_int64_t)(t * 48000.0)); diff --git a/panda/src/movies/userDataAudio.cxx b/panda/src/movies/userDataAudio.cxx index 81865e3b8b..f02726d10b 100644 --- a/panda/src/movies/userDataAudio.cxx +++ b/panda/src/movies/userDataAudio.cxx @@ -107,7 +107,7 @@ append(DatagramIterator *src, int n) { * but it may be convenient to deal with samples in python. */ void UserDataAudio:: -append(const string &str) { +append(const std::string &str) { nassertv(!_aborted); int samples = str.size() / (2 * _desired_channels); int words = samples * _desired_channels; diff --git a/panda/src/movies/vorbisAudio.cxx b/panda/src/movies/vorbisAudio.cxx index b3e32c84f4..db4c70b000 100644 --- a/panda/src/movies/vorbisAudio.cxx +++ b/panda/src/movies/vorbisAudio.cxx @@ -43,7 +43,7 @@ VorbisAudio:: PT(MovieAudioCursor) VorbisAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *stream = vfs->open_read_file(_filename, true); + std::istream *stream = vfs->open_read_file(_filename, true); if (stream == nullptr) { return nullptr; diff --git a/panda/src/movies/vorbisAudioCursor.cxx b/panda/src/movies/vorbisAudioCursor.cxx index 6f6002158f..d4478c9f07 100644 --- a/panda/src/movies/vorbisAudioCursor.cxx +++ b/panda/src/movies/vorbisAudioCursor.cxx @@ -16,6 +16,8 @@ #ifdef HAVE_VORBIS +using std::istream; + TypeHandle VorbisAudioCursor::_type_handle; /** @@ -82,7 +84,7 @@ seek(double t) { return; } - t = max(t, 0.0); + t = std::max(t, 0.0); // Use ov_time_seek_lap if cross-lapping is enabled. if (vorbis_seek_lap) { @@ -189,15 +191,15 @@ cb_seek_func(void *datasource, ogg_int64_t offset, int whence) { switch (whence) { case SEEK_SET: - stream->seekg(offset, ios::beg); + stream->seekg(offset, std::ios::beg); break; case SEEK_CUR: - stream->seekg(offset, ios::cur); + stream->seekg(offset, std::ios::cur); break; case SEEK_END: - stream->seekg(offset, ios::end); + stream->seekg(offset, std::ios::end); break; default: diff --git a/panda/src/movies/wavAudio.cxx b/panda/src/movies/wavAudio.cxx index 685a0a7d68..854d2aef5c 100644 --- a/panda/src/movies/wavAudio.cxx +++ b/panda/src/movies/wavAudio.cxx @@ -41,7 +41,7 @@ WavAudio:: PT(MovieAudioCursor) WavAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *stream = vfs->open_read_file(_filename, true); + std::istream *stream = vfs->open_read_file(_filename, true); if (stream == nullptr) { return nullptr; diff --git a/panda/src/movies/wavAudioCursor.cxx b/panda/src/movies/wavAudioCursor.cxx index 5f6cf05047..381ce2d81b 100644 --- a/panda/src/movies/wavAudioCursor.cxx +++ b/panda/src/movies/wavAudioCursor.cxx @@ -94,7 +94,7 @@ TypeHandle WavAudioCursor::_type_handle; * pointer positioned at the start of the data. */ WavAudioCursor:: -WavAudioCursor(WavAudio *src, istream *stream) : +WavAudioCursor(WavAudio *src, std::istream *stream) : MovieAudioCursor(src), _is_valid(false), _stream(stream), @@ -291,8 +291,8 @@ WavAudioCursor:: */ void WavAudioCursor:: seek(double t) { - t = max(t, 0.0); - streampos pos = _data_start + (streampos) min((size_t) (t * _byte_rate), _data_size); + t = std::max(t, 0.0); + std::streampos pos = _data_start + (std::streampos) std::min((size_t) (t * _byte_rate), _data_size); if (_can_seek_fast) { _stream->seekg(pos); @@ -303,7 +303,7 @@ seek(double t) { } if (!_can_seek_fast) { - streampos current = _stream->tellg(); + std::streampos current = _stream->tellg(); if (pos > current) { // It is ahead of our current position. Skip ahead. @@ -327,7 +327,7 @@ seek(double t) { void WavAudioCursor:: read_samples(int n, int16_t *data) { int desired = n * _audio_channels; - int read_samples = min(desired, ((int) (_data_size - _data_pos)) / _bytes_per_sample); + int read_samples = std::min(desired, ((int) (_data_size - _data_pos)) / _bytes_per_sample); if (read_samples <= 0) { return; diff --git a/panda/src/net/config_net.cxx b/panda/src/net/config_net.cxx index 9fcbdcbe91..80af80147a 100644 --- a/panda/src/net/config_net.cxx +++ b/panda/src/net/config_net.cxx @@ -119,9 +119,9 @@ get_net_max_block() { // This function is used in the ReaderThread and WriterThread constructors to // make a simple name for each thread. -string -make_thread_name(const string &thread_name, int thread_index) { - ostringstream stream; +std::string +make_thread_name(const std::string &thread_name, int thread_index) { + std::ostringstream stream; stream << thread_name << "_" << thread_index; return stream.str(); } diff --git a/panda/src/net/connection.cxx b/panda/src/net/connection.cxx index 1e96a758de..aecfc111ac 100644 --- a/panda/src/net/connection.cxx +++ b/panda/src/net/connection.cxx @@ -303,7 +303,7 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { LightReMutexHolder holder(_write_mutex); DatagramUDPHeader header(datagram); - string data; + std::string data; data += header.get_header(); data += datagram.get_message(); @@ -374,7 +374,7 @@ send_raw_datagram(const NetDatagram &datagram) { Socket_UDP *udp; DCAST_INTO_R(udp, _socket, false); - string data = datagram.get_message(); + std::string data = datagram.get_message(); LightReMutexHolder holder(_write_mutex); Socket_Address addr = datagram.get_address().get_addr(); @@ -430,7 +430,7 @@ do_flush() { Socket_TCP *tcp; DCAST_INTO_R(tcp, _socket, false); - string sending_data; + std::string sending_data; _queued_data.swap(sending_data); _queued_count = 0; @@ -438,7 +438,7 @@ do_flush() { #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) int max_send = net_max_write_per_epoch; - int data_sent = tcp->SendData(sending_data.data(), min((size_t)max_send, sending_data.size())); + int data_sent = tcp->SendData(sending_data.data(), std::min((size_t)max_send, sending_data.size())); bool okflag = (data_sent == (int)sending_data.size()); if (!okflag) { int total_sent = 0; @@ -453,7 +453,7 @@ do_flush() { } else { Thread::consider_yield(); } - data_sent = tcp->SendData(sending_data.data() + total_sent, min((size_t)max_send, sending_data.size() - total_sent)); + data_sent = tcp->SendData(sending_data.data() + total_sent, std::min((size_t)max_send, sending_data.size() - total_sent)); if (data_sent > 0) { total_sent += data_sent; } diff --git a/panda/src/net/connectionListener.cxx b/panda/src/net/connectionListener.cxx index a48791b24d..2ab8b33ef7 100644 --- a/panda/src/net/connectionListener.cxx +++ b/panda/src/net/connectionListener.cxx @@ -19,8 +19,8 @@ #include "config_net.h" #include "socket_tcp_listen.h" -static string -listener_thread_name(const string &thread_name) { +static std::string +listener_thread_name(const std::string &thread_name) { if (!thread_name.empty()) { return thread_name; } @@ -32,7 +32,7 @@ listener_thread_name(const string &thread_name) { */ ConnectionListener:: ConnectionListener(ConnectionManager *manager, int num_threads, - const string &thread_name) : + const std::string &thread_name) : ConnectionReader(manager, num_threads, listener_thread_name(thread_name)) { } diff --git a/panda/src/net/connectionManager.cxx b/panda/src/net/connectionManager.cxx index 0d7da68000..f125356f50 100644 --- a/panda/src/net/connectionManager.cxx +++ b/panda/src/net/connectionManager.cxx @@ -33,6 +33,9 @@ #include #endif +using std::stringstream; +using std::string; + /** * */ @@ -412,7 +415,7 @@ wait_for_readers(double timeout) { double wait_timeout = get_net_max_block(); if (!block_forever) { - wait_timeout = min(wait_timeout, stop - now); + wait_timeout = std::min(wait_timeout, stop - now); } uint32_t wait_timeout_ms = (uint32_t)(wait_timeout * 1000.0); @@ -489,7 +492,7 @@ scan_interfaces() { // p->AdapterName appears to be a GUID. Not sure if this is actually // useful to anyone; we'll store the "friendly name" instead. TextEncoder encoder; - encoder.set_wtext(wstring(p->FriendlyName)); + encoder.set_wtext(std::wstring(p->FriendlyName)); string friendly_name = encoder.get_text(); Interface iface; @@ -716,12 +719,12 @@ remove_writer(ConnectionWriter *writer) { */ string ConnectionManager:: format_mac_address(const unsigned char *data, size_t data_size) { - stringstream strm; + std::stringstream strm; for (size_t di = 0; di < data_size; ++di) { if (di != 0) { strm << "-"; } - strm << hex << setw(2) << setfill('0') << (unsigned int)data[di]; + strm << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)data[di]; } return strm.str(); @@ -731,7 +734,7 @@ format_mac_address(const unsigned char *data, size_t data_size) { * */ void ConnectionManager::Interface:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << " ["; if (has_ip()) { out << " " << get_ip().get_ip_string(); diff --git a/panda/src/net/connectionReader.cxx b/panda/src/net/connectionReader.cxx index 4f9a31dca5..9fbab3e1dc 100644 --- a/panda/src/net/connectionReader.cxx +++ b/panda/src/net/connectionReader.cxx @@ -27,6 +27,8 @@ #include "atomicAdjust.h" #include "config_downloader.h" +using std::min; + static const int read_buffer_size = maximum_udp_datagram + datagram_udp_header_size; /** @@ -60,7 +62,7 @@ get_socket() const { * */ ConnectionReader::ReaderThread:: -ReaderThread(ConnectionReader *reader, const string &thread_name, +ReaderThread(ConnectionReader *reader, const std::string &thread_name, int thread_index) : Thread(make_thread_name(thread_name, thread_index), make_thread_name(thread_name, thread_index)), @@ -85,7 +87,7 @@ thread_main() { */ ConnectionReader:: ConnectionReader(ConnectionManager *manager, int num_threads, - const string &thread_name) : + const std::string &thread_name) : _manager(manager) { if (!Thread::is_threading_supported()) { @@ -111,7 +113,7 @@ ConnectionReader(ConnectionManager *manager, int num_threads, _currently_polling_thread = -1; - string reader_thread_name = thread_name; + std::string reader_thread_name = thread_name; if (thread_name.empty()) { reader_thread_name = "ReaderThread"; } diff --git a/panda/src/net/connectionWriter.cxx b/panda/src/net/connectionWriter.cxx index 554f8118c1..47cde6c35d 100644 --- a/panda/src/net/connectionWriter.cxx +++ b/panda/src/net/connectionWriter.cxx @@ -24,7 +24,7 @@ * */ ConnectionWriter::WriterThread:: -WriterThread(ConnectionWriter *writer, const string &thread_name, +WriterThread(ConnectionWriter *writer, const std::string &thread_name, int thread_index) : Thread(make_thread_name(thread_name, thread_index), make_thread_name(thread_name, thread_index)), @@ -50,7 +50,7 @@ thread_main() { */ ConnectionWriter:: ConnectionWriter(ConnectionManager *manager, int num_threads, - const string &thread_name) : + const std::string &thread_name) : _manager(manager) { if (!Thread::is_threading_supported()) { @@ -70,7 +70,7 @@ ConnectionWriter(ConnectionManager *manager, int num_threads, _immediate = (num_threads <= 0); _shutdown = false; - string writer_thread_name = thread_name; + std::string writer_thread_name = thread_name; if (thread_name.empty()) { writer_thread_name = "WriterThread"; } diff --git a/panda/src/net/datagramTCPHeader.cxx b/panda/src/net/datagramTCPHeader.cxx index bd013f0c33..44db216b3d 100644 --- a/panda/src/net/datagramTCPHeader.cxx +++ b/panda/src/net/datagramTCPHeader.cxx @@ -107,7 +107,7 @@ verify_datagram(const NetDatagram &datagram, int header_size) const { // We write the hex dump into a ostringstream first, to guarantee an // atomic write to the output stream in case we're threaded. - ostringstream hex; + std::ostringstream hex; datagram.dump_hex(hex); hex << "\n"; net_cat.debug() << hex.str(); diff --git a/panda/src/net/datagramUDPHeader.cxx b/panda/src/net/datagramUDPHeader.cxx index 2191c0241a..7c58205e8d 100644 --- a/panda/src/net/datagramUDPHeader.cxx +++ b/panda/src/net/datagramUDPHeader.cxx @@ -73,7 +73,7 @@ verify_datagram(const NetDatagram &datagram) const { // We write the hex dump into a ostringstream first, to guarantee an // atomic write to the output stream in case we're threaded. - ostringstream hex; + std::ostringstream hex; datagram.dump_hex(hex); hex << "\n"; net_cat.debug(false) << hex.str(); diff --git a/panda/src/net/datagram_ui.cxx b/panda/src/net/datagram_ui.cxx index fa9879bf86..d5f0bdea1b 100644 --- a/panda/src/net/datagram_ui.cxx +++ b/panda/src/net/datagram_ui.cxx @@ -19,6 +19,9 @@ #include #include +using std::istream; +using std::ostream; + enum DatagramElement { DE_int32, DE_float64, diff --git a/panda/src/net/fake_http_server.cxx b/panda/src/net/fake_http_server.cxx index 718b6db824..bc29e9806a 100644 --- a/panda/src/net/fake_http_server.cxx +++ b/panda/src/net/fake_http_server.cxx @@ -24,6 +24,8 @@ #include +using std::string; + QueuedConnectionManager cm; QueuedConnectionReader reader(&cm, 10); ConnectionWriter writer(&cm, 10); @@ -65,7 +67,7 @@ receive_data(const Datagram &data) { void ClientState:: receive_line(string line) { - cerr << "received: " << line << "\n"; + std::cerr << "received: " << line << "\n"; // trim trailing whitespace. size_t size = line.size(); while (size > 0 && isspace(line[size - 1])) { diff --git a/panda/src/net/netAddress.cxx b/panda/src/net/netAddress.cxx index 0f0404dc45..9d49623252 100644 --- a/panda/src/net/netAddress.cxx +++ b/panda/src/net/netAddress.cxx @@ -63,7 +63,7 @@ set_broadcast(int port) { * Returns true if the hostname is known, false otherwise. */ bool NetAddress:: -set_host(const string &hostname, int port) { +set_host(const std::string &hostname, int port) { return _addr.set_host(hostname, port); } @@ -102,7 +102,7 @@ is_any() const { /** * Returns the IP address to which this address refers, formatted as a string. */ -string NetAddress:: +std::string NetAddress:: get_ip_string() const { return _addr.get_ip(); } @@ -143,7 +143,7 @@ get_addr() const { * */ void NetAddress:: -output(ostream &out) const { +output(std::ostream &out) const { out << _addr.get_ip_port(); } diff --git a/panda/src/net/queuedConnectionReader.cxx b/panda/src/net/queuedConnectionReader.cxx index bdc562bd22..807b69337c 100644 --- a/panda/src/net/queuedConnectionReader.cxx +++ b/panda/src/net/queuedConnectionReader.cxx @@ -123,7 +123,7 @@ void QueuedConnectionReader:: start_delay(double min_delay, double max_delay) { LightMutexHolder holder(_dd_mutex); _min_delay = min_delay; - _delay_variance = max(max_delay - min_delay, 0.0); + _delay_variance = std::max(max_delay - min_delay, 0.0); _delay_active = true; } diff --git a/panda/src/net/test_datagram.cxx b/panda/src/net/test_datagram.cxx index db2f3fd305..93da4b6c87 100644 --- a/panda/src/net/test_datagram.cxx +++ b/panda/src/net/test_datagram.cxx @@ -14,6 +14,9 @@ #include "netDatagram.h" #include "datagramIterator.h" +using std::cout; +using std::endl; + int main() { NetDatagram dg; diff --git a/panda/src/net/test_raw_server.cxx b/panda/src/net/test_raw_server.cxx index aeec9b0aee..444d65756c 100644 --- a/panda/src/net/test_raw_server.cxx +++ b/panda/src/net/test_raw_server.cxx @@ -82,7 +82,7 @@ main(int argc, char *argv[]) { while (reader.data_available()) { NetDatagram datagram; if (reader.get_data(datagram)) { - string data = datagram.get_message(); + std::string data = datagram.get_message(); nout.write(data.data(), data.length()); nout << std::flush; diff --git a/panda/src/net/test_spam_client.cxx b/panda/src/net/test_spam_client.cxx index e76643e5c2..5488cec357 100644 --- a/panda/src/net/test_spam_client.cxx +++ b/panda/src/net/test_spam_client.cxx @@ -28,7 +28,7 @@ main(int argc, char *argv[]) { exit(1); } - string hostname = argv[1]; + std::string hostname = argv[1]; int port = atoi(argv[2]); NetAddress host; @@ -54,8 +54,8 @@ main(int argc, char *argv[]) { bool lost_connection = false; NetDatagram datagram; - cout << "Enter a datagram.\n"; - cin >> datagram; + std::cout << "Enter a datagram.\n"; + std::cin >> datagram; nout << "Read datagram " << datagram << "\n"; datagram.dump_hex(nout); diff --git a/panda/src/net/test_tcp_client.cxx b/panda/src/net/test_tcp_client.cxx index 4c5b15fa17..c88821149c 100644 --- a/panda/src/net/test_tcp_client.cxx +++ b/panda/src/net/test_tcp_client.cxx @@ -20,6 +20,9 @@ #include "datagram_ui.h" +using std::cin; +using std::cout; + int main(int argc, char *argv[]) { if (argc != 3) { @@ -27,7 +30,7 @@ main(int argc, char *argv[]) { exit(1); } - string hostname = argv[1]; + std::string hostname = argv[1]; int port = atoi(argv[2]); NetAddress host; diff --git a/panda/src/net/test_udp.cxx b/panda/src/net/test_udp.cxx index f069523f48..4aec3ecc76 100644 --- a/panda/src/net/test_udp.cxx +++ b/panda/src/net/test_udp.cxx @@ -20,6 +20,9 @@ #include "datagram_ui.h" +using std::cin; +using std::cout; + int main(int argc, char *argv[]) { if (argc != 3) { @@ -27,7 +30,7 @@ main(int argc, char *argv[]) { exit(1); } - string hostname = argv[1]; + std::string hostname = argv[1]; int port = atoi(argv[2]); NetAddress host; diff --git a/panda/src/ode/odeBody.cxx b/panda/src/ode/odeBody.cxx index 412759f8e7..70ad46169d 100644 --- a/panda/src/ode/odeBody.cxx +++ b/panda/src/ode/odeBody.cxx @@ -69,7 +69,7 @@ get_joint(int index) const { } void OdeBody:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << "" << get_type() \ << "(id = " << _id \ << ")"; diff --git a/panda/src/ode/odeGeom.cxx b/panda/src/ode/odeGeom.cxx index c291025912..e25c6c45b6 100644 --- a/panda/src/ode/odeGeom.cxx +++ b/panda/src/ode/odeGeom.cxx @@ -107,7 +107,7 @@ get_space() const { void OdeGeom:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << get_type() << "(id = " << _id << ")"; } diff --git a/panda/src/ode/odeJoint.cxx b/panda/src/ode/odeJoint.cxx index a089a7b303..dd10c57f0a 100644 --- a/panda/src/ode/odeJoint.cxx +++ b/panda/src/ode/odeJoint.cxx @@ -31,14 +31,14 @@ TypeHandle OdeJoint::_type_handle; OdeJoint:: OdeJoint() : _id(nullptr) { - ostream &out = odejoint_cat.debug(); + std::ostream &out = odejoint_cat.debug(); out << get_type() << "(" << _id << ")\n"; } OdeJoint:: OdeJoint(dJointID id) : _id(id) { - ostream &out = odejoint_cat.debug(); + std::ostream &out = odejoint_cat.debug(); out << get_type() << "(" << _id << ")\n"; } @@ -95,7 +95,7 @@ get_body(int index) const { } void OdeJoint:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << "" << get_type() \ << "(id = " << _id \ << ", body1 = "; diff --git a/panda/src/ode/odeMass.cxx b/panda/src/ode/odeMass.cxx index de9d52567a..76c3d360e8 100644 --- a/panda/src/ode/odeMass.cxx +++ b/panda/src/ode/odeMass.cxx @@ -51,7 +51,7 @@ operator = (const OdeMass ©) { void OdeMass:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << get_type() \ << "(mag = " << get_magnitude() \ diff --git a/panda/src/ode/odeSpace.cxx b/panda/src/ode/odeSpace.cxx index a07342b82f..f2beca8efb 100644 --- a/panda/src/ode/odeSpace.cxx +++ b/panda/src/ode/odeSpace.cxx @@ -95,7 +95,7 @@ get_geom(int i) { void OdeSpace:: -write(ostream &out, unsigned int indent) const { +write(std::ostream &out, unsigned int indent) const { out.width(indent); out << "" << get_type() << "(id = " << _id << ")"; } diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx index 07d265a41d..4ca05ea17a 100644 --- a/panda/src/ode/odeTriMeshData.cxx +++ b/panda/src/ode/odeTriMeshData.cxx @@ -13,6 +13,8 @@ #include "odeTriMeshData.h" +using std::ostream; + TypeHandle OdeTriMeshData::_type_handle; OdeTriMeshData::TriMeshDataMap *OdeTriMeshData::_tri_mesh_data_map = nullptr; @@ -43,7 +45,7 @@ unlink_data(dGeomID id) { } void OdeTriMeshData:: -print_data(const string &marker) { +print_data(const std::string &marker) { odetrimeshdata_cat.debug() << get_class_type() << "::print_data(" << marker << ")\n"; const TriMeshDataMap &data_map = get_tri_mesh_data_map(); TriMeshDataMap::const_iterator iter = data_map.begin(); diff --git a/panda/src/ode/odeUtil.cxx b/panda/src/ode/odeUtil.cxx index 0e38b45558..2ae8d281d4 100644 --- a/panda/src/ode/odeUtil.cxx +++ b/panda/src/ode/odeUtil.cxx @@ -28,7 +28,7 @@ get_connecting_joint(const OdeBody &body1, const OdeBody &body2) { */ OdeJointCollection OdeUtil:: get_connecting_joint_list(const OdeBody &body1, const OdeBody &body2) { - const int max_possible_joints = min(body1.get_num_joints(), body1.get_num_joints()); + const int max_possible_joints = std::min(body1.get_num_joints(), body1.get_num_joints()); dJointID *joint_list = (dJointID *)PANDA_MALLOC_ARRAY(max_possible_joints * sizeof(dJointID)); int num_joints = dConnectingJointList(body1.get_id(), body2.get_id(), diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.cxx b/panda/src/osxdisplay/osxGraphicsBuffer.cxx index d98b5d956a..03bfa46d79 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.cxx +++ b/panda/src/osxdisplay/osxGraphicsBuffer.cxx @@ -25,7 +25,7 @@ TypeHandle osxGraphicsBuffer::_type_handle; */ osxGraphicsBuffer:: osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/osxdisplay/osxGraphicsPipe.cxx b/panda/src/osxdisplay/osxGraphicsPipe.cxx index 9211c52515..5a56a6259d 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.cxx +++ b/panda/src/osxdisplay/osxGraphicsPipe.cxx @@ -202,7 +202,7 @@ osxGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string osxGraphicsPipe:: +std::string osxGraphicsPipe:: get_interface_name() const { return "OpenGL"; } @@ -344,7 +344,7 @@ release_data(void *info, const void *data, size_t size) { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) osxGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx index 0ae735b055..2fb60d2d74 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx @@ -35,7 +35,7 @@ TypeHandle osxGraphicsStateGuardian::_type_handle; */ void *osxGraphicsStateGuardian:: do_get_extension_func(const char *name) { - string fullname = "_" + string(name); + std::string fullname = "_" + std::string(name); NSSymbol symbol = nullptr; if (NSIsSymbolNameDefined(fullname.c_str())) { @@ -113,8 +113,8 @@ draw_resize_box() { // Get the default texture to apply to the resize box; it's compiled into // the code. - string resize_box_string((const char *)resize_box, resize_box_len); - istringstream resize_box_strm(resize_box_string); + std::string resize_box_string((const char *)resize_box, resize_box_len); + std::istringstream resize_box_strm(resize_box_string); PNMImage resize_box_pnm; if (resize_box_pnm.read(resize_box_strm, "resize_box.rgb")) { PT(Texture) tex = new Texture; diff --git a/panda/src/parametrics/cubicCurveseg.cxx b/panda/src/parametrics/cubicCurveseg.cxx index 6bd2dcef6f..dcb5905cfa 100644 --- a/panda/src/parametrics/cubicCurveseg.cxx +++ b/panda/src/parametrics/cubicCurveseg.cxx @@ -234,7 +234,7 @@ compute_nurbs_basis(int order, if (mink==maxk) { // Huh. What were you thinking? This is a trivial NURBS. parametrics_cat->warning() - << "Trivial NURBS curve specified." << endl; + << "Trivial NURBS curve specified." << std::endl; memset((void *)&basis, 0, sizeof(LMatrix4)); return; } @@ -409,7 +409,7 @@ compute_seg_col(int c, break; default: - cerr << "Invalid rebuild type in compute_seg\n"; + std::cerr << "Invalid rebuild type in compute_seg\n"; return false; } diff --git a/panda/src/parametrics/curveFitter.cxx b/panda/src/parametrics/curveFitter.cxx index e929ebd21e..275a270a4b 100644 --- a/panda/src/parametrics/curveFitter.cxx +++ b/panda/src/parametrics/curveFitter.cxx @@ -137,8 +137,8 @@ get_sample_tangent(int n) const { */ void CurveFitter:: remove_samples(int begin, int end) { - begin = max(0, min((int)_data.size(), begin)); - end = max(0, min((int)_data.size(), end)); + begin = std::max(0, std::min((int)_data.size(), begin)); + end = std::max(0, std::min((int)_data.size(), end)); nassertv(begin <= end); @@ -411,7 +411,7 @@ make_nurbs() const { * */ void CurveFitter:: -output(ostream &out) const { +output(std::ostream &out) const { out << "CurveFitter, " << _data.size() << " samples.\n"; } @@ -419,7 +419,7 @@ output(ostream &out) const { * */ void CurveFitter:: -write(ostream &out) const { +write(std::ostream &out) const { out << "CurveFitter, " << _data.size() << " samples:\n"; Data::const_iterator di; for (di = _data.begin(); di != _data.end(); ++di) { diff --git a/panda/src/parametrics/hermiteCurve.cxx b/panda/src/parametrics/hermiteCurve.cxx index 73931ab001..7bb2399368 100644 --- a/panda/src/parametrics/hermiteCurve.cxx +++ b/panda/src/parametrics/hermiteCurve.cxx @@ -24,6 +24,9 @@ #include +using std::ostream; +using std::string; + TypeHandle HermiteCurve::_type_handle; static const LVecBase3 zerovec_3 = LVecBase3(0.0f, 0.0f, 0.0f); @@ -246,7 +249,7 @@ HermiteCurve(const ParametricCurve &nc) { if (!nc.convert_to_hermite(this)) { parametrics_cat->warning() << "Cannot make a Hermite from the indicated curve." - << endl; + << std::endl; } } @@ -291,7 +294,7 @@ insert_cv(PN_stdfloat t) { return n; } - t = min(max(t, (PN_stdfloat)0.0), get_max_t()); + t = std::min(std::max(t, (PN_stdfloat)0.0), get_max_t()); int n = find_cv(t); nassertr(n+1= 0 && n < get_num_cvs()); out << "CV " << n << ": " << get_cv_point(n) << ", weight " @@ -55,7 +55,7 @@ write_cv(ostream &out, int n) const { * */ void NurbsCurveInterface:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level); PN_stdfloat min_t = 0.0f; @@ -93,7 +93,7 @@ write(ostream &out, int indent_level) const { * Formats the Nurbs curve for output to an Egg file. */ bool NurbsCurveInterface:: -format_egg(ostream &out, const string &name, const string &curve_type, +format_egg(std::ostream &out, const std::string &name, const std::string &curve_type, int indent_level) const { indent(out, indent_level) << " " << name << ".pool {\n"; diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.cxx b/panda/src/parametrics/nurbsSurfaceEvaluator.cxx index 12ed399a9d..33d1ce0a81 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.cxx +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.cxx @@ -212,7 +212,7 @@ evaluate(const NodePath &rel_to) const { * */ void NurbsSurfaceEvaluator:: -output(ostream &out) const { +output(std::ostream &out) const { out << "NurbsSurface, (" << get_num_u_knots() << ", " << get_num_v_knots() << ") knots."; } diff --git a/panda/src/parametrics/parametricCurve.cxx b/panda/src/parametrics/parametricCurve.cxx index 5d3d014722..9893c65604 100644 --- a/panda/src/parametrics/parametricCurve.cxx +++ b/panda/src/parametrics/parametricCurve.cxx @@ -321,8 +321,8 @@ write_egg(Filename filename, CoordinateSystem cs) { * stream. Returns true if the file is successfully written. */ bool ParametricCurve:: -write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { - string curve_type; +write_egg(std::ostream &out, const Filename &filename, CoordinateSystem cs) { + std::string curve_type; switch (get_curve_type()) { case PCT_XYZ: curve_type = "xyz"; @@ -339,7 +339,7 @@ write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { if (!has_name()) { // If we don't have a name, come up with one. - string name = filename.get_basename_wo_extension(); + std::string name = filename.get_basename_wo_extension(); if (!curve_type.empty()) { name += "_"; @@ -602,7 +602,7 @@ invalidate_all() { * Returns true on success, false on failure. */ bool ParametricCurve:: -format_egg(ostream &, const string &, const string &, int) const { +format_egg(std::ostream &, const std::string &, const std::string &, int) const { return false; } diff --git a/panda/src/parametrics/parametricCurveCollection.cxx b/panda/src/parametrics/parametricCurveCollection.cxx index 9e3d8b4a1b..96ce9bd503 100644 --- a/panda/src/parametrics/parametricCurveCollection.cxx +++ b/panda/src/parametrics/parametricCurveCollection.cxx @@ -44,7 +44,7 @@ add_curve(ParametricCurve *curve) { void ParametricCurveCollection:: insert_curve(size_t index, ParametricCurve *curve) { prepare_add_curve(curve); - index = min(index, _curves.size()); + index = std::min(index, _curves.size()); _curves.insert(_curves.begin() + index, curve); redraw(); } @@ -307,7 +307,7 @@ make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { // the same length as all the others. CurveFitter fitter; - int num_segments = max(1, (int)cfloor(segments_per_unit * xyz_curve->get_max_t() + 0.5f)); + int num_segments = std::max(1, (int)cfloor(segments_per_unit * xyz_curve->get_max_t() + 0.5f)); if (parametrics_cat.is_debug()) { parametrics_cat.debug() @@ -657,7 +657,7 @@ stitch(const ParametricCurveCollection *a, * indicated output stream. */ void ParametricCurveCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_curves() == 1) { out << "1 ParametricCurve"; } else { @@ -670,7 +670,7 @@ output(ostream &out) const { * to the indicated output stream. */ void ParametricCurveCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { ParametricCurves::const_iterator ci; for (ci = _curves.begin(); ci != _curves.end(); ++ci) { ParametricCurve *curve = (*ci); @@ -700,7 +700,7 @@ write_egg(Filename filename, CoordinateSystem cs) { * specified output stream. Returns true if the file is successfully written. */ bool ParametricCurveCollection:: -write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { +write_egg(std::ostream &out, const Filename &filename, CoordinateSystem cs) { if (cs == CS_default) { cs = get_default_coordinate_system(); } @@ -740,7 +740,7 @@ write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { if (!curve->has_name()) { // If we don't have a name, come up with one. - string name = filename.get_basename_wo_extension(); + std::string name = filename.get_basename_wo_extension(); switch (curve->get_curve_type()) { case PCT_XYZ: diff --git a/panda/src/parametrics/piecewiseCurve.cxx b/panda/src/parametrics/piecewiseCurve.cxx index d69b4f7025..f5e2fadad9 100644 --- a/panda/src/parametrics/piecewiseCurve.cxx +++ b/panda/src/parametrics/piecewiseCurve.cxx @@ -20,6 +20,8 @@ #include "bamWriter.h" #include "bamReader.h" +using std::cerr; + TypeHandle PiecewiseCurve::_type_handle; /** diff --git a/panda/src/parametrics/ropeNode.cxx b/panda/src/parametrics/ropeNode.cxx index 5837bfd361..ffb2c83119 100644 --- a/panda/src/parametrics/ropeNode.cxx +++ b/panda/src/parametrics/ropeNode.cxx @@ -67,7 +67,7 @@ fillin(DatagramIterator &scan, BamReader *reader) { * */ RopeNode:: -RopeNode(const string &name) : +RopeNode(const std::string &name) : PandaNode(name) { set_cull_callback(); @@ -177,7 +177,7 @@ is_renderable() const { * */ void RopeNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); NurbsCurveEvaluator *curve = get_curve(); if (curve != nullptr) { @@ -191,7 +191,7 @@ output(ostream &out) const { * */ void RopeNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); indent(out, indent_level) << *get_curve() << "\n"; } diff --git a/panda/src/parametrics/sheetNode.cxx b/panda/src/parametrics/sheetNode.cxx index 294c3a7ff4..eec44c0cda 100644 --- a/panda/src/parametrics/sheetNode.cxx +++ b/panda/src/parametrics/sheetNode.cxx @@ -66,7 +66,7 @@ fillin(DatagramIterator &scan, BamReader *reader) { * */ SheetNode:: -SheetNode(const string &name) : +SheetNode(const std::string &name) : PandaNode(name) { set_cull_callback(); @@ -155,7 +155,7 @@ is_renderable() const { * */ void SheetNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); NurbsSurfaceEvaluator *surface = get_surface(); if (surface != nullptr) { @@ -169,7 +169,7 @@ output(ostream &out) const { * */ void SheetNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); NurbsSurfaceEvaluator *surface = get_surface(); if (surface != nullptr) { diff --git a/panda/src/particlesystem/arcEmitter.cxx b/panda/src/particlesystem/arcEmitter.cxx index cc56b3130e..a87c7376db 100644 --- a/panda/src/particlesystem/arcEmitter.cxx +++ b/panda/src/particlesystem/arcEmitter.cxx @@ -74,7 +74,7 @@ assign_initial_position(LPoint3& pos) { * Write a starc representation of this instance to . */ void ArcEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"ArcEmitter"; #endif //] NDEBUG @@ -84,7 +84,7 @@ output(ostream &out) const { * Write a starc representation of this instance to . */ void ArcEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ArcEmitter:\n"; out.width(indent+2); out<<""; out<<"_start_angle "<. */ void BaseParticle:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BaseParticle"; #endif //] NDEBUG @@ -61,7 +61,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseParticle:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseParticle:\n"; out.width(indent+2); out<<""; out<<"_age "<<_age<<"\n"; diff --git a/panda/src/particlesystem/baseParticleEmitter.cxx b/panda/src/particlesystem/baseParticleEmitter.cxx index 20ef762aa9..c18584b461 100644 --- a/panda/src/particlesystem/baseParticleEmitter.cxx +++ b/panda/src/particlesystem/baseParticleEmitter.cxx @@ -79,7 +79,7 @@ generate(LPoint3& pos, LVector3& vel) { * Write a string representation of this instance to . */ void BaseParticleEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BaseParticleEmitter"; #endif //] NDEBUG @@ -89,7 +89,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseParticleEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseParticleEmitter:\n"; out.width(indent+2); out<<""; out<<"_emission_type "<<_emission_type<<"\n"; diff --git a/panda/src/particlesystem/baseParticleFactory.cxx b/panda/src/particlesystem/baseParticleFactory.cxx index 162b4df88e..0f0169f99b 100644 --- a/panda/src/particlesystem/baseParticleFactory.cxx +++ b/panda/src/particlesystem/baseParticleFactory.cxx @@ -69,7 +69,7 @@ populate_particle(BaseParticle *bp) { * Write a string representation of this instance to . */ void BaseParticleFactory:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BaseParticleFactory"; #endif //] NDEBUG @@ -79,7 +79,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseParticleFactory:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseParticleFactory:\n"; out.width(indent+2); out<<""; out<<"_lifespan_base "<<_lifespan_base<<"\n"; diff --git a/panda/src/particlesystem/baseParticleRenderer.cxx b/panda/src/particlesystem/baseParticleRenderer.cxx index 2a2072c2a1..f7f33c41ac 100644 --- a/panda/src/particlesystem/baseParticleRenderer.cxx +++ b/panda/src/particlesystem/baseParticleRenderer.cxx @@ -79,7 +79,7 @@ set_ignore_scale(bool ignore_scale) { * Write a string representation of this instance to . */ void BaseParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BaseParticleRenderer"; #endif //] NDEBUG @@ -89,7 +89,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseParticleRenderer:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseParticleRenderer:\n"; out.width(indent+2); out<<""; out<<"_render_node "<<_render_node_path<<"\n"; diff --git a/panda/src/particlesystem/boxEmitter.cxx b/panda/src/particlesystem/boxEmitter.cxx index 52035e62c7..3b84932dd7 100644 --- a/panda/src/particlesystem/boxEmitter.cxx +++ b/panda/src/particlesystem/boxEmitter.cxx @@ -78,7 +78,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void BoxEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"BoxEmitter"; #endif //] NDEBUG @@ -88,7 +88,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BoxEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BoxEmitter:\n"; out.width(indent+2); out<<""; out<<"_vmin "<<_vmin<<"\n"; diff --git a/panda/src/particlesystem/colorInterpolationManager.cxx b/panda/src/particlesystem/colorInterpolationManager.cxx index 27268c2ef8..b2e68ba66d 100644 --- a/panda/src/particlesystem/colorInterpolationManager.cxx +++ b/panda/src/particlesystem/colorInterpolationManager.cxx @@ -14,6 +14,9 @@ #include "colorInterpolationManager.h" #include "mathNumbers.h" +using std::max; +using std::min; + TypeHandle ColorInterpolationFunction::_type_handle; TypeHandle ColorInterpolationFunctionConstant::_type_handle; TypeHandle ColorInterpolationFunctionLinear::_type_handle; diff --git a/panda/src/particlesystem/discEmitter.cxx b/panda/src/particlesystem/discEmitter.cxx index 3b018a2dfe..e07f933bdf 100644 --- a/panda/src/particlesystem/discEmitter.cxx +++ b/panda/src/particlesystem/discEmitter.cxx @@ -115,7 +115,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void DiscEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"DiscEmitter"; #endif //] NDEBUG @@ -125,7 +125,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void DiscEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"DiscEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/geomParticleRenderer.cxx b/panda/src/particlesystem/geomParticleRenderer.cxx index 74df181f2e..8db733c58d 100644 --- a/panda/src/particlesystem/geomParticleRenderer.cxx +++ b/panda/src/particlesystem/geomParticleRenderer.cxx @@ -200,7 +200,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (_alpha_mode == PR_ALPHA_OUT) alpha_scalar = 1.0f - alpha_scalar; else if (_alpha_mode == PR_ALPHA_IN_OUT) - alpha_scalar = 2.0f * min(alpha_scalar, 1.0f - alpha_scalar); + alpha_scalar = 2.0f * std::min(alpha_scalar, 1.0f - alpha_scalar); alpha_scalar *= get_user_alpha(); } @@ -252,7 +252,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void GeomParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"GeomParticleRenderer"; #endif //] NDEBUG @@ -262,7 +262,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void GeomParticleRenderer:: -write_linear_forces(ostream &out, int indent) const { +write_linear_forces(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_node_vector ("<<_node_vector.size()<<" forces)\n"; @@ -278,7 +278,7 @@ write_linear_forces(ostream &out, int indent) const { * Write a string representation of this instance to . */ void GeomParticleRenderer:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"GeomParticleRenderer:\n"; out.width(indent+2); out<<""; out<<"_geom_node "<<_geom_node<<"\n"; diff --git a/panda/src/particlesystem/lineEmitter.cxx b/panda/src/particlesystem/lineEmitter.cxx index 5a236c03e1..6855fc3aeb 100644 --- a/panda/src/particlesystem/lineEmitter.cxx +++ b/panda/src/particlesystem/lineEmitter.cxx @@ -76,7 +76,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void LineEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LineEmitter"; #endif //] NDEBUG @@ -86,7 +86,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LineEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LineEmitter:\n"; out.width(indent+2); out<<""; out<<"_endpoint1 "<<_endpoint1<<"\n"; diff --git a/panda/src/particlesystem/lineParticleRenderer.cxx b/panda/src/particlesystem/lineParticleRenderer.cxx index e139e6f2e8..5a2240cfb6 100644 --- a/panda/src/particlesystem/lineParticleRenderer.cxx +++ b/panda/src/particlesystem/lineParticleRenderer.cxx @@ -195,7 +195,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (_alpha_mode == PR_ALPHA_OUT) alpha = 1.0f - alpha; else if (_alpha_mode == PR_ALPHA_IN_OUT) - alpha = 2.0f * min(alpha, 1.0f - alpha); + alpha = 2.0f * std::min(alpha, 1.0f - alpha); } head_color[3] = alpha; @@ -232,7 +232,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void LineParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LineParticleRenderer"; #endif //] NDEBUG @@ -242,7 +242,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LineParticleRenderer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "LineParticleRenderer:\n"; indent(out, indent_level + 2) << "_head_color "<<_head_color<<"\n"; indent(out, indent_level + 2) << "_tail_color "<<_tail_color<<"\n"; diff --git a/panda/src/particlesystem/orientedParticle.cxx b/panda/src/particlesystem/orientedParticle.cxx index bf828f165c..640c244aa7 100644 --- a/panda/src/particlesystem/orientedParticle.cxx +++ b/panda/src/particlesystem/orientedParticle.cxx @@ -71,7 +71,7 @@ update() { * Write a string representation of this instance to . */ void OrientedParticle:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"OrientedParticle"; #endif //] NDEBUG @@ -81,7 +81,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void OrientedParticle:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"OrientedParticle:\n"; BaseParticle::write(out, indent+2); diff --git a/panda/src/particlesystem/orientedParticleFactory.cxx b/panda/src/particlesystem/orientedParticleFactory.cxx index 2889a16727..7276d9c2b9 100644 --- a/panda/src/particlesystem/orientedParticleFactory.cxx +++ b/panda/src/particlesystem/orientedParticleFactory.cxx @@ -59,7 +59,7 @@ alloc_particle() const { * Write a string representation of this instance to . */ void OrientedParticleFactory:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"OrientedParticleFactory"; #endif //] NDEBUG @@ -69,7 +69,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void OrientedParticleFactory:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"OrientedParticleFactory:\n"; BaseParticleFactory::write(out, indent+2); diff --git a/panda/src/particlesystem/particleSystem.cxx b/panda/src/particlesystem/particleSystem.cxx index 7e22ac9180..32a9480fc0 100644 --- a/panda/src/particlesystem/particleSystem.cxx +++ b/panda/src/particlesystem/particleSystem.cxx @@ -30,6 +30,10 @@ #include "sphereSurfaceEmitter.h" #include "pStatTimer.h" +using std::cout; +using std::endl; +using std::ostream; + TypeHandle ParticleSystem::_type_handle; PStatCollector ParticleSystem::_update_collector("App:Particles:Update"); @@ -594,7 +598,7 @@ sanity_check() { #endif result++; } - pool_size = min(_particle_pool_size, _physics_objects.size()); + pool_size = std::min(_particle_pool_size, _physics_objects.size()); // find out how many particles are REALLY alive and dead int real_live_particle_count = 0; diff --git a/panda/src/particlesystem/particleSystemManager.cxx b/panda/src/particlesystem/particleSystemManager.cxx index e6dbf53fef..b96c7d6105 100644 --- a/panda/src/particlesystem/particleSystemManager.cxx +++ b/panda/src/particlesystem/particleSystemManager.cxx @@ -145,7 +145,7 @@ do_particles(PN_stdfloat dt, ParticleSystem *ps, bool do_render) { * Write a string representation of this instance to . */ void ParticleSystemManager:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"ParticleSystemManager"; #endif //] NDEBUG @@ -155,7 +155,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ParticleSystemManager:: -write_ps_list(ostream &out, int indent) const { +write_ps_list(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_ps_list ("<<_ps_list.size()<<" systems)\n"; @@ -171,7 +171,7 @@ write_ps_list(ostream &out, int indent) const { * Write a string representation of this instance to . */ void ParticleSystemManager:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ParticleSystemManager:\n"; out.width(indent+2); out<<""; out<<"_nth_frame "<<_nth_frame<<"\n"; diff --git a/panda/src/particlesystem/pointEmitter.cxx b/panda/src/particlesystem/pointEmitter.cxx index 9c3664e7c7..376cec9a82 100644 --- a/panda/src/particlesystem/pointEmitter.cxx +++ b/panda/src/particlesystem/pointEmitter.cxx @@ -66,7 +66,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void PointEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PointEmitter"; #endif //] NDEBUG @@ -76,7 +76,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PointEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PointEmitter:\n"; out.width(indent+2); out<<""; out<<"_location "<<_location<<"\n"; diff --git a/panda/src/particlesystem/pointParticle.cxx b/panda/src/particlesystem/pointParticle.cxx index 32e1dbf0b2..fac3c5edf2 100644 --- a/panda/src/particlesystem/pointParticle.cxx +++ b/panda/src/particlesystem/pointParticle.cxx @@ -71,7 +71,7 @@ update() { * Write a string representation of this instance to . */ void PointParticle:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PointParticle"; #endif //] NDEBUG @@ -81,7 +81,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PointParticle:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PointParticle:\n"; BaseParticle::write(out, indent+2); diff --git a/panda/src/particlesystem/pointParticleFactory.cxx b/panda/src/particlesystem/pointParticleFactory.cxx index 71a06d763e..2e1b645d88 100644 --- a/panda/src/particlesystem/pointParticleFactory.cxx +++ b/panda/src/particlesystem/pointParticleFactory.cxx @@ -59,7 +59,7 @@ alloc_particle() const { * Write a string representation of this instance to . */ void PointParticleFactory:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PointParticleFactory"; #endif //] NDEBUG @@ -69,7 +69,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PointParticleFactory:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PointParticleFactory:\n"; BaseParticleFactory::write(out, indent+2); diff --git a/panda/src/particlesystem/pointParticleRenderer.cxx b/panda/src/particlesystem/pointParticleRenderer.cxx index 2a5d345d37..04374bf536 100644 --- a/panda/src/particlesystem/pointParticleRenderer.cxx +++ b/panda/src/particlesystem/pointParticleRenderer.cxx @@ -167,7 +167,7 @@ create_color(const BaseParticle *p) { if (_alpha_mode == PR_ALPHA_OUT) { parameterized_age = 1.0f - parameterized_age; } else if (_alpha_mode == PR_ALPHA_IN_OUT) { - parameterized_age = 2.0f * min(parameterized_age, + parameterized_age = 2.0f * std::min(parameterized_age, 1.0f - parameterized_age); } } @@ -257,7 +257,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void PointParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PointParticleRenderer"; #endif //] NDEBUG @@ -267,7 +267,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PointParticleRenderer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "PointParticleRenderer:\n"; indent(out, indent_level + 2) << "_start_color "<<_start_color<<"\n"; indent(out, indent_level + 2) << "_end_color "<<_end_color<<"\n"; diff --git a/panda/src/particlesystem/rectangleEmitter.cxx b/panda/src/particlesystem/rectangleEmitter.cxx index f261662486..d23de128e3 100644 --- a/panda/src/particlesystem/rectangleEmitter.cxx +++ b/panda/src/particlesystem/rectangleEmitter.cxx @@ -76,7 +76,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void RectangleEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"RectangleEmitter"; #endif //] NDEBUG @@ -86,7 +86,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void RectangleEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"RectangleEmitter:\n"; out.width(indent+2); out<<""; out<<"_vmin "<<_vmin<<"\n"; diff --git a/panda/src/particlesystem/ringEmitter.cxx b/panda/src/particlesystem/ringEmitter.cxx index c9f7009807..1c4e4ee5fd 100644 --- a/panda/src/particlesystem/ringEmitter.cxx +++ b/panda/src/particlesystem/ringEmitter.cxx @@ -105,7 +105,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void RingEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"RingEmitter"; #endif //] NDEBUG @@ -115,7 +115,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void RingEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"RingEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/sparkleParticleRenderer.cxx b/panda/src/particlesystem/sparkleParticleRenderer.cxx index 5dc2d0772b..63a7124b59 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.cxx +++ b/panda/src/particlesystem/sparkleParticleRenderer.cxx @@ -192,7 +192,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (_alpha_mode == PR_ALPHA_OUT) alpha = 1.0f - alpha; else if (_alpha_mode == PR_ALPHA_IN_OUT) - alpha = 2.0f * min(alpha, 1.0f - alpha); + alpha = 2.0f * std::min(alpha, 1.0f - alpha); alpha *= get_user_alpha(); } @@ -262,7 +262,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void SparkleParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"SparkleParticleRenderer"; #endif //] NDEBUG @@ -272,7 +272,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void SparkleParticleRenderer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "SparkleParticleRenderer:\n"; indent(out, indent_level + 2) << "_center_color "<<_center_color<<"\n"; indent(out, indent_level + 2) << "_edge_color "<<_edge_color<<"\n"; diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.cxx b/panda/src/particlesystem/sphereSurfaceEmitter.cxx index 37b6a274fb..9fc67113a8 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.cxx +++ b/panda/src/particlesystem/sphereSurfaceEmitter.cxx @@ -71,7 +71,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void SphereSurfaceEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"SphereSurfaceEmitter"; #endif //] NDEBUG @@ -81,7 +81,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void SphereSurfaceEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"SphereSurfaceEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/sphereVolumeEmitter.cxx b/panda/src/particlesystem/sphereVolumeEmitter.cxx index 5b541ce220..985b96c21d 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.cxx +++ b/panda/src/particlesystem/sphereVolumeEmitter.cxx @@ -85,7 +85,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void SphereVolumeEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"SphereVolumeEmitter"; #endif //] NDEBUG @@ -95,7 +95,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void SphereVolumeEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"SphereVolumeEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/spriteParticleRenderer.cxx b/panda/src/particlesystem/spriteParticleRenderer.cxx index 58cec0e50a..9aa9c77e52 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.cxx +++ b/panda/src/particlesystem/spriteParticleRenderer.cxx @@ -30,6 +30,9 @@ #include "config_particlesystem.h" #include "pStatTimer.h" +using std::max; +using std::min; + PStatCollector SpriteParticleRenderer::_render_collector("App:Particles:Sprite:Render"); /** @@ -189,7 +192,7 @@ extract_textures_from_node(const NodePath &node_path, NodePathCollection &np_col * match the new geometry. */ void SpriteParticleRenderer:: -set_from_node(const NodePath &node_path, const string &model, const string &node, bool size_from_texels) { +set_from_node(const NodePath &node_path, const std::string &model, const std::string &node, bool size_from_texels) { // Clear all texture information _anims.clear(); add_from_node(node_path,model,node,size_from_texels,true); @@ -241,7 +244,7 @@ set_from_node(const NodePath &node_path, bool size_from_texels) { * now on. (Default is false) */ void SpriteParticleRenderer:: -add_from_node(const NodePath &node_path, const string &model, const string &node, bool size_from_texels, bool resize) { +add_from_node(const NodePath &node_path, const std::string &model, const std::string &node, bool size_from_texels, bool resize) { int anim_count = _anims.size(); if (anim_count == 0) resize = true; @@ -744,7 +747,7 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { * Write a string representation of this instance to . */ void SpriteParticleRenderer:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"SpriteParticleRenderer"; #endif //] NDEBUG @@ -754,7 +757,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void SpriteParticleRenderer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "SpriteParticleRenderer:\n"; // indent(out, indent_level + 2) << "_sprite_primitive // "<<_sprite_primitive<<"\n"; diff --git a/panda/src/particlesystem/tangentRingEmitter.cxx b/panda/src/particlesystem/tangentRingEmitter.cxx index 5c77c5491e..13bbf6f8bc 100644 --- a/panda/src/particlesystem/tangentRingEmitter.cxx +++ b/panda/src/particlesystem/tangentRingEmitter.cxx @@ -73,7 +73,7 @@ assign_initial_velocity(LVector3& vel) { * Write a string representation of this instance to . */ void TangentRingEmitter:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"TangentRingEmitter"; #endif //] NDEBUG @@ -83,7 +83,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void TangentRingEmitter:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"TangentRingEmitter:\n"; out.width(indent+2); out<<""; out<<"_radius "<<_radius<<"\n"; diff --git a/panda/src/particlesystem/zSpinParticle.cxx b/panda/src/particlesystem/zSpinParticle.cxx index 560fa12a72..7808c2833e 100644 --- a/panda/src/particlesystem/zSpinParticle.cxx +++ b/panda/src/particlesystem/zSpinParticle.cxx @@ -108,7 +108,7 @@ get_theta() const { * Write a string representation of this instance to . */ void ZSpinParticle:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"ZSpinParticle"; #endif //] NDEBUG @@ -118,7 +118,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ZSpinParticle:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ZSpinParticle:\n"; out.width(indent+2); out<<""; out<<"_initial_angle "<<_initial_angle<<"\n"; diff --git a/panda/src/particlesystem/zSpinParticleFactory.cxx b/panda/src/particlesystem/zSpinParticleFactory.cxx index f8c21efccb..5f260714d7 100644 --- a/panda/src/particlesystem/zSpinParticleFactory.cxx +++ b/panda/src/particlesystem/zSpinParticleFactory.cxx @@ -76,7 +76,7 @@ populate_child_particle(BaseParticle *bp) const { * Write a string representation of this instance to . */ void ZSpinParticleFactory:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"ZSpinParticleFactory"; #endif //] NDEBUG @@ -86,7 +86,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ZSpinParticleFactory:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ZSpinParticleFactory:\n"; out.width(indent+2); out<<""; out<<"_initial_angle "<<_initial_angle<<"\n"; diff --git a/panda/src/pgraph/accumulatedAttribs.cxx b/panda/src/pgraph/accumulatedAttribs.cxx index f82ec15d03..94faa3072a 100644 --- a/panda/src/pgraph/accumulatedAttribs.cxx +++ b/panda/src/pgraph/accumulatedAttribs.cxx @@ -85,7 +85,7 @@ operator = (const AccumulatedAttribs ©) { * */ void AccumulatedAttribs:: -write(ostream &out, int attrib_types, int indent_level) const { +write(std::ostream &out, int attrib_types, int indent_level) const { if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { _transform->write(out, indent_level); } diff --git a/panda/src/pgraph/alphaTestAttrib.cxx b/panda/src/pgraph/alphaTestAttrib.cxx index a302026623..331b709478 100644 --- a/panda/src/pgraph/alphaTestAttrib.cxx +++ b/panda/src/pgraph/alphaTestAttrib.cxx @@ -46,7 +46,7 @@ make_default() { * */ void AlphaTestAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; output_comparefunc(out,_mode); out << "," << _reference_alpha; diff --git a/panda/src/pgraph/antialiasAttrib.cxx b/panda/src/pgraph/antialiasAttrib.cxx index ef35490753..260b4fdef1 100644 --- a/panda/src/pgraph/antialiasAttrib.cxx +++ b/panda/src/pgraph/antialiasAttrib.cxx @@ -69,7 +69,7 @@ make_default() { * */ void AntialiasAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; int type = get_mode_type(); diff --git a/panda/src/pgraph/attribNodeRegistry.cxx b/panda/src/pgraph/attribNodeRegistry.cxx index 995fe2b63c..721feb5572 100644 --- a/panda/src/pgraph/attribNodeRegistry.cxx +++ b/panda/src/pgraph/attribNodeRegistry.cxx @@ -41,7 +41,7 @@ add_node(const NodePath &attrib_node) { nassertv(!attrib_node.is_empty()); LightMutexHolder holder(_lock); - pair result = _entries.insert(Entry(attrib_node)); + std::pair result = _entries.insert(Entry(attrib_node)); if (!result.second) { // Replace an existing node. (*result.first)._node = attrib_node; @@ -119,10 +119,10 @@ get_node_type(int n) const { * be the node name as it was at the time the node was recorded; if the node * has changed names since then, this will still return the original name. */ -string AttribNodeRegistry:: +std::string AttribNodeRegistry:: get_node_name(int n) const { LightMutexHolder holder(_lock); - nassertr(n >= 0 && n < (int)_entries.size(), string()); + nassertr(n >= 0 && n < (int)_entries.size(), std::string()); return _entries[n]._name; } @@ -148,7 +148,7 @@ find_node(const NodePath &attrib_node) const { * the registry, or -1 if there is no such node in the registry. */ int AttribNodeRegistry:: -find_node(TypeHandle type, const string &name) const { +find_node(TypeHandle type, const std::string &name) const { LightMutexHolder holder(_lock); Entries::const_iterator ei = _entries.find(Entry(type, name)); if (ei != _entries.end()) { @@ -180,7 +180,7 @@ clear() { * */ void AttribNodeRegistry:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(_lock); typedef pmap Counts; @@ -211,7 +211,7 @@ output(ostream &out) const { * */ void AttribNodeRegistry:: -write(ostream &out) const { +write(std::ostream &out) const { LightMutexHolder holder(_lock); Entries::const_iterator ei; diff --git a/panda/src/pgraph/audioVolumeAttrib.cxx b/panda/src/pgraph/audioVolumeAttrib.cxx index 52d12156d0..23c6a4d7d8 100644 --- a/panda/src/pgraph/audioVolumeAttrib.cxx +++ b/panda/src/pgraph/audioVolumeAttrib.cxx @@ -99,7 +99,7 @@ set_volume(PN_stdfloat volume) const { * */ void AudioVolumeAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_off()) { out << "off"; diff --git a/panda/src/pgraph/auxBitplaneAttrib.cxx b/panda/src/pgraph/auxBitplaneAttrib.cxx index 662ae36b19..16f87b03f2 100644 --- a/panda/src/pgraph/auxBitplaneAttrib.cxx +++ b/panda/src/pgraph/auxBitplaneAttrib.cxx @@ -57,7 +57,7 @@ make_default() { * */ void AuxBitplaneAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << _outputs << ")"; } diff --git a/panda/src/pgraph/auxSceneData.cxx b/panda/src/pgraph/auxSceneData.cxx index b0a50cb1c0..2ef626c270 100644 --- a/panda/src/pgraph/auxSceneData.cxx +++ b/panda/src/pgraph/auxSceneData.cxx @@ -20,7 +20,7 @@ TypeHandle AuxSceneData::_type_handle; * */ void AuxSceneData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " expires " << get_expiration_time(); } @@ -28,6 +28,6 @@ output(ostream &out) const { * */ void AuxSceneData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/pgraph/bamFile.cxx b/panda/src/pgraph/bamFile.cxx index fa8ae7f4c0..5bf0d5af88 100644 --- a/panda/src/pgraph/bamFile.cxx +++ b/panda/src/pgraph/bamFile.cxx @@ -24,6 +24,8 @@ #include "virtualFileSystem.h" #include "dcast.h" +using std::string; + /** * */ @@ -61,7 +63,7 @@ open_read(const Filename &bam_filename, bool report_errors) { * for information purposes only. Returns true if successful, false on error. */ bool BamFile:: -open_read(istream &in, const string &bam_filename, bool report_errors) { +open_read(std::istream &in, const string &bam_filename, bool report_errors) { close(); if (!_din.open(in)) { @@ -205,7 +207,7 @@ open_write(const Filename &bam_filename, bool report_errors) { * for information purposes only. Returns true if successful, false on error. */ bool BamFile:: -open_write(ostream &out, const string &bam_filename, bool report_errors) { +open_write(std::ostream &out, const string &bam_filename, bool report_errors) { close(); if (!_dout.open(out)) { diff --git a/panda/src/pgraph/billboardEffect.cxx b/panda/src/pgraph/billboardEffect.cxx index 737b370c42..c5843bb667 100644 --- a/panda/src/pgraph/billboardEffect.cxx +++ b/panda/src/pgraph/billboardEffect.cxx @@ -66,7 +66,7 @@ prepare_flatten_transform(const TransformState *net_transform) const { * */ void BillboardEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_off()) { out << "(off)"; diff --git a/panda/src/pgraph/cacheStats.cxx b/panda/src/pgraph/cacheStats.cxx index e16c14801e..4721171e86 100644 --- a/panda/src/pgraph/cacheStats.cxx +++ b/panda/src/pgraph/cacheStats.cxx @@ -49,7 +49,7 @@ reset(double now) { * */ void CacheStats:: -write(ostream &out, const char *name) const { +write(std::ostream &out, const char *name) const { #ifndef NDEBUG out << name << " cache: " << _cache_hits << " hits, " << _cache_misses << " misses\n" diff --git a/panda/src/pgraph/camera.cxx b/panda/src/pgraph/camera.cxx index 4ab1039d05..5a10d6145e 100644 --- a/panda/src/pgraph/camera.cxx +++ b/panda/src/pgraph/camera.cxx @@ -16,6 +16,8 @@ #include "lens.h" #include "throw_event.h" +using std::string; + TypeHandle Camera::_type_handle; /** @@ -195,7 +197,7 @@ get_aux_scene_data(const NodePath &node_path) const { * Outputs all of the NodePaths and AuxSceneDatas in use. */ void Camera:: -list_aux_scene_data(ostream &out) const { +list_aux_scene_data(std::ostream &out) const { out << _aux_data.size() << " data objects held:\n"; AuxData::const_iterator ai; for (ai = _aux_data.begin(); ai != _aux_data.end(); ++ai) { diff --git a/panda/src/pgraph/clipPlaneAttrib.cxx b/panda/src/pgraph/clipPlaneAttrib.cxx index f833d2dd94..de3f1183c9 100644 --- a/panda/src/pgraph/clipPlaneAttrib.cxx +++ b/panda/src/pgraph/clipPlaneAttrib.cxx @@ -375,7 +375,7 @@ add_on_plane(const NodePath &plane) const { attrib->_on_planes.insert(plane); attrib->_off_planes.erase(plane); - pair insert_result = + std::pair insert_result = attrib->_on_planes.insert(Planes::value_type(plane)); if (insert_result.second) { // Also ensure it is removed from the off_planes list. @@ -552,7 +552,7 @@ compose_off(const RenderAttrib *other) const { * */ void ClipPlaneAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_off_planes.empty()) { if (_on_planes.empty()) { diff --git a/panda/src/pgraph/colorAttrib.cxx b/panda/src/pgraph/colorAttrib.cxx index 5af6ace015..7bfbecee79 100644 --- a/panda/src/pgraph/colorAttrib.cxx +++ b/panda/src/pgraph/colorAttrib.cxx @@ -75,7 +75,7 @@ make_default() { * */ void ColorAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_color_type()) { case T_vertex: diff --git a/panda/src/pgraph/colorBlendAttrib.cxx b/panda/src/pgraph/colorBlendAttrib.cxx index 9341f2d808..f9a24d96bf 100644 --- a/panda/src/pgraph/colorBlendAttrib.cxx +++ b/panda/src/pgraph/colorBlendAttrib.cxx @@ -19,6 +19,8 @@ #include "datagram.h" #include "datagramIterator.h" +using std::ostream; + TypeHandle ColorBlendAttrib::_type_handle; int ColorBlendAttrib::_attrib_slot; diff --git a/panda/src/pgraph/colorScaleAttrib.cxx b/panda/src/pgraph/colorScaleAttrib.cxx index 572f3e0e14..088c3142ef 100644 --- a/panda/src/pgraph/colorScaleAttrib.cxx +++ b/panda/src/pgraph/colorScaleAttrib.cxx @@ -129,7 +129,7 @@ lower_attrib_can_override() const { * */ void ColorScaleAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_off()) { out << "off"; diff --git a/panda/src/pgraph/colorWriteAttrib.cxx b/panda/src/pgraph/colorWriteAttrib.cxx index 98c889a0de..671fa82629 100644 --- a/panda/src/pgraph/colorWriteAttrib.cxx +++ b/panda/src/pgraph/colorWriteAttrib.cxx @@ -44,7 +44,7 @@ make_default() { * */ void ColorWriteAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_channels == 0) { out << "off"; diff --git a/panda/src/pgraph/compassEffect.cxx b/panda/src/pgraph/compassEffect.cxx index d972e7f45a..41bd9af880 100644 --- a/panda/src/pgraph/compassEffect.cxx +++ b/panda/src/pgraph/compassEffect.cxx @@ -50,7 +50,7 @@ safe_to_transform() const { * */ void CompassEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_properties == 0) { out << " none"; diff --git a/panda/src/pgraph/cullBinAttrib.cxx b/panda/src/pgraph/cullBinAttrib.cxx index f8eb40626d..27238c9c31 100644 --- a/panda/src/pgraph/cullBinAttrib.cxx +++ b/panda/src/pgraph/cullBinAttrib.cxx @@ -28,7 +28,7 @@ int CullBinAttrib::_attrib_slot; * only to certain kinds of bins (in particular CullBinFixed type bins). */ CPT(RenderAttrib) CullBinAttrib:: -make(const string &bin_name, int draw_order) { +make(const std::string &bin_name, int draw_order) { CullBinAttrib *attrib = new CullBinAttrib; attrib->_bin_name = bin_name; attrib->_draw_order = draw_order; @@ -48,7 +48,7 @@ make_default() { * */ void CullBinAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_bin_name.empty()) { out << "(default)"; diff --git a/panda/src/pgraph/cullBinManager.cxx b/panda/src/pgraph/cullBinManager.cxx index 56aed8c730..5826905c89 100644 --- a/panda/src/pgraph/cullBinManager.cxx +++ b/panda/src/pgraph/cullBinManager.cxx @@ -18,6 +18,8 @@ #include "string_utils.h" #include "configVariableColor.h" +using std::string; + CullBinManager *CullBinManager::_global_ptr = nullptr; /** @@ -165,7 +167,7 @@ find_bin(const string &name) const { * */ void CullBinManager:: -write(ostream &out) const { +write(std::ostream &out) const { if (!_bins_are_sorted) { ((CullBinManager *)this)->do_sort_bins(); } @@ -316,8 +318,8 @@ parse_bin_type(const string &bin_type) { /** * */ -ostream & -operator << (ostream &out, CullBinManager::BinType bin_type) { +std::ostream & +operator << (std::ostream &out, CullBinManager::BinType bin_type) { switch (bin_type) { case CullBinManager::BT_invalid: return out << "invalid"; diff --git a/panda/src/pgraph/cullFaceAttrib.cxx b/panda/src/pgraph/cullFaceAttrib.cxx index db3527a653..054d8061b3 100644 --- a/panda/src/pgraph/cullFaceAttrib.cxx +++ b/panda/src/pgraph/cullFaceAttrib.cxx @@ -99,7 +99,7 @@ get_effective_mode() const { * */ void CullFaceAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_actual_mode()) { case M_cull_none: diff --git a/panda/src/pgraph/cullPlanes.cxx b/panda/src/pgraph/cullPlanes.cxx index fcb7a0c532..fafbae6cfa 100644 --- a/panda/src/pgraph/cullPlanes.cxx +++ b/panda/src/pgraph/cullPlanes.cxx @@ -18,6 +18,9 @@ #include "occluderEffect.h" #include "boundingBox.h" +using std::max; +using std::min; + /** * Returns a pointer to an empty CullPlanes object. */ @@ -200,8 +203,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, if (plane.get_normal().dot(LVector3::forward()) >= 0.0) { if (occluder_node->is_double_sided()) { - swap(points_near[0], points_near[3]); - swap(points_near[1], points_near[2]); + std::swap(points_near[0], points_near[3]); + std::swap(points_near[1], points_near[2]); plane = LPlane(points_near[0], points_near[1], points_near[2]); } else { // This occluder is facing the wrong direction. Ignore it. @@ -429,7 +432,7 @@ remove_occluder(const NodePath &occluder) const { * */ void CullPlanes:: -write(ostream &out) const { +write(std::ostream &out) const { out << "CullPlanes (" << _planes.size() << " planes and " << _occluders.size() << " occluders):\n"; Planes::const_iterator pi; diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index 8f3e8dc19a..faee06ee53 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -359,7 +359,7 @@ make_new_bin(int bin_index) { nassertr(bin_index >= 0 && bin_index < (int)_bins.size(), nullptr); // Prevent unnecessary refunref by swapping the PointerTos. - swap(_bins[bin_index], bin); + std::swap(_bins[bin_index], bin); } return bin_ptr; diff --git a/panda/src/pgraph/cullTraverser.cxx b/panda/src/pgraph/cullTraverser.cxx index 50726c2ee7..0ecf27666a 100644 --- a/panda/src/pgraph/cullTraverser.cxx +++ b/panda/src/pgraph/cullTraverser.cxx @@ -237,7 +237,7 @@ draw_bounding_volume(const BoundingVolume *vol, _cull_handler->record_object(outer_viz, this); CullableObject *inner_viz = - new CullableObject(move(bounds_viz), get_bounds_inner_viz_state(), + new CullableObject(std::move(bounds_viz), get_bounds_inner_viz_state(), internal_transform); _cull_handler->record_object(inner_viz, this); } @@ -267,7 +267,7 @@ show_bounds(CullTraverserData &data, bool tight) { if (bounds_viz != nullptr) { _geoms_pcollector.add_level(1); CullableObject *outer_viz = - new CullableObject(move(bounds_viz), get_bounds_outer_viz_state(), + new CullableObject(std::move(bounds_viz), get_bounds_outer_viz_state(), internal_transform); _cull_handler->record_object(outer_viz, this); } diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index e0aed703e9..8d54308af8 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -41,7 +41,7 @@ apply_transform_and_state(CullTraverser *trav) { // camera. This indicates some special state transition for this node, // which is unique to this camera. const Camera *camera = trav->get_scene()->get_camera_node(); - string tag_state = _node_reader.get_tag(trav->get_tag_state_key()); + std::string tag_state = _node_reader.get_tag(trav->get_tag_state_key()); node_state = node_state->compose(camera->get_tag_state(tag_state)); } _node_reader.compose_draw_mask(_draw_mask); @@ -154,7 +154,7 @@ is_in_view_impl() { if (pgraph_cat.is_spam()) { pgraph_cat.spam() - << get_node_path() << " cull result = " << hex << result << dec << "\n"; + << get_node_path() << " cull result = " << std::hex << result << std::dec << "\n"; } if (result == BoundingVolume::IF_no_intersection) { @@ -202,8 +202,8 @@ is_in_view_impl() { if (pgraph_cat.is_spam()) { pgraph_cat.spam() - << get_node_path() << " cull planes cull result = " << hex - << result << dec << "\n"; + << get_node_path() << " cull planes cull result = " << std::hex + << result << std::dec << "\n"; _cull_planes->write(pgraph_cat.spam(false)); } diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index 3e6db8453c..dae73b00ed 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -114,8 +114,8 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "munge_points_to_quads() for geometry with bits: " - << hex << geom_rendering << ", unsupported: " - << (unsupported_bits & Geom::GR_point_bits) << dec << "\n"; + << std::hex << geom_rendering << ", unsupported: " + << (unsupported_bits & Geom::GR_point_bits) << std::dec << "\n"; } if (!munge_points_to_quads(traverser, force)) { return false; @@ -161,7 +161,7 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, _munged_data->animate_vertices(force, current_thread); if (animated_vertices != _munged_data) { cpu_animated = true; - swap(_munged_data, animated_vertices); + std::swap(_munged_data, animated_vertices); } #ifndef NDEBUG @@ -187,7 +187,7 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, * */ void CullableObject:: -output(ostream &out) const { +output(std::ostream &out) const { if (_geom != nullptr) { out << *_geom; } else { @@ -583,7 +583,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { } _geom = new_geom.p(); - _munged_data = move(new_data); + _munged_data = std::move(new_data); return true; } diff --git a/panda/src/pgraph/depthOffsetAttrib.cxx b/panda/src/pgraph/depthOffsetAttrib.cxx index a04e72bffb..5516dd52ff 100644 --- a/panda/src/pgraph/depthOffsetAttrib.cxx +++ b/panda/src/pgraph/depthOffsetAttrib.cxx @@ -60,7 +60,7 @@ make_default() { * */ void DepthOffsetAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":(" << get_offset() << ", " << get_min_value() << ", " << get_max_value() << ")"; } diff --git a/panda/src/pgraph/depthTestAttrib.cxx b/panda/src/pgraph/depthTestAttrib.cxx index b75f63b436..eb4093b168 100644 --- a/panda/src/pgraph/depthTestAttrib.cxx +++ b/panda/src/pgraph/depthTestAttrib.cxx @@ -44,7 +44,7 @@ make_default() { * */ void DepthTestAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; output_comparefunc(out,_mode); } diff --git a/panda/src/pgraph/depthWriteAttrib.cxx b/panda/src/pgraph/depthWriteAttrib.cxx index eef6264d47..b12d0c30b8 100644 --- a/panda/src/pgraph/depthWriteAttrib.cxx +++ b/panda/src/pgraph/depthWriteAttrib.cxx @@ -44,7 +44,7 @@ make_default() { * */ void DepthWriteAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_mode()) { case M_off: diff --git a/panda/src/pgraph/findApproxLevelEntry.cxx b/panda/src/pgraph/findApproxLevelEntry.cxx index 2ea72cd889..07c8f1f931 100644 --- a/panda/src/pgraph/findApproxLevelEntry.cxx +++ b/panda/src/pgraph/findApproxLevelEntry.cxx @@ -22,7 +22,7 @@ TypeHandle FindApproxLevelEntry::_type_handle; * Formats the entry for meaningful output. For debugging only. */ void FindApproxLevelEntry:: -output(ostream &out) const { +output(std::ostream &out) const { out << "(" << _node_path << "):"; if (is_solution(0)) { out << " solution!"; @@ -38,7 +38,7 @@ output(ostream &out) const { * For debugging only. */ void FindApproxLevelEntry:: -write_level(ostream &out, int indent_level) const { +write_level(std::ostream &out, int indent_level) const { for (const FindApproxLevelEntry *entry = this; entry != nullptr; entry = entry->_next) { diff --git a/panda/src/pgraph/findApproxPath.cxx b/panda/src/pgraph/findApproxPath.cxx index 0b8d035580..093a160f32 100644 --- a/panda/src/pgraph/findApproxPath.cxx +++ b/panda/src/pgraph/findApproxPath.cxx @@ -17,6 +17,9 @@ #include "string_utils.h" #include "pandaNode.h" +using std::ostream; +using std::string; + /** * Returns true if the indicated node matches this component, false otherwise. diff --git a/panda/src/pgraph/fog.cxx b/panda/src/pgraph/fog.cxx index 654c6fd613..dc45af63ee 100644 --- a/panda/src/pgraph/fog.cxx +++ b/panda/src/pgraph/fog.cxx @@ -27,8 +27,8 @@ TypeHandle Fog::_type_handle; -ostream & -operator << (ostream &out, Fog::Mode mode) { +std::ostream & +operator << (std::ostream &out, Fog::Mode mode) { switch (mode) { case Fog::M_linear: return out << "linear"; @@ -47,7 +47,7 @@ operator << (ostream &out, Fog::Mode mode) { * */ Fog:: -Fog(const string &name) : +Fog(const std::string &name) : PandaNode(name) { _mode = M_linear; @@ -112,7 +112,7 @@ xform(const LMatrix4 &mat) { * */ void Fog:: -output(ostream &out) const { +output(std::ostream &out) const { out << "fog: " << _mode; switch (_mode) { case M_linear: diff --git a/panda/src/pgraph/fogAttrib.cxx b/panda/src/pgraph/fogAttrib.cxx index 17016cd7b0..3a511f7d19 100644 --- a/panda/src/pgraph/fogAttrib.cxx +++ b/panda/src/pgraph/fogAttrib.cxx @@ -54,7 +54,7 @@ make_off() { * */ void FogAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_off()) { out << "(off)"; diff --git a/panda/src/pgraph/geomDrawCallbackData.cxx b/panda/src/pgraph/geomDrawCallbackData.cxx index 1b6dc76082..b8bdae2d78 100644 --- a/panda/src/pgraph/geomDrawCallbackData.cxx +++ b/panda/src/pgraph/geomDrawCallbackData.cxx @@ -21,7 +21,7 @@ TypeHandle GeomDrawCallbackData::_type_handle; * */ void GeomDrawCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << (void *)_obj << ", " << (void *)_gsg << ", " << _force << ")"; } diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index cbbb7bb609..328870364a 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -51,7 +51,7 @@ TypeHandle GeomNode::_type_handle; * */ GeomNode:: -GeomNode(const string &name) : +GeomNode(const std::string &name) : PandaNode(name) { _preserved = preserve_geom_nodes; @@ -559,7 +559,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { } CullableObject *object = - new CullableObject(move(geom), move(state), internal_transform); + new CullableObject(std::move(geom), std::move(state), internal_transform); trav->get_cull_handler()->record_object(object, trav); } } @@ -782,7 +782,7 @@ unify(int max_indices, bool preserve_order) { * Writes a short description of all the Geoms in the node. */ void GeomNode:: -write_geoms(ostream &out, int indent_level) const { +write_geoms(std::ostream &out, int indent_level) const { CDReader cdata(_cycler); write(out, indent_level); GeomList::const_iterator gi; @@ -798,7 +798,7 @@ write_geoms(ostream &out, int indent_level) const { * Writes a detailed description of all the Geoms in the node. */ void GeomNode:: -write_verbose(ostream &out, int indent_level) const { +write_verbose(std::ostream &out, int indent_level) const { CDReader cdata(_cycler); write(out, indent_level); GeomList::const_iterator gi; @@ -816,7 +816,7 @@ write_verbose(ostream &out, int indent_level) const { * */ void GeomNode:: -output(ostream &out) const { +output(std::ostream &out) const { // Accumulate the total set of RenderAttrib types that are applied to any of // our Geoms, so we can output them too. The result will be the list of // attrib types that might be applied to some Geoms, but not necessarily to diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index e21327b304..6e4d30955e 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -151,7 +151,7 @@ transform_vertices(GeomNode *node, const LMatrix4 &mat) { GeomNode::GeomEntry &entry = (*gi); PT(Geom) new_geom = entry._geom.get_read_pointer()->make_copy(); if (transform_vertices(new_geom, mat)) { - entry._geom = move(new_geom); + entry._geom = std::move(new_geom); any_changed = true; } } diff --git a/panda/src/pgraph/internalNameCollection.cxx b/panda/src/pgraph/internalNameCollection.cxx index 93b92e3518..9c3779c88e 100644 --- a/panda/src/pgraph/internalNameCollection.cxx +++ b/panda/src/pgraph/internalNameCollection.cxx @@ -211,7 +211,7 @@ size() const { * indicated output stream. */ void InternalNameCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_names() == 1) { out << "1 InternalName"; } else { @@ -224,7 +224,7 @@ output(ostream &out) const { * the indicated output stream. */ void InternalNameCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_names(); i++) { indent(out, indent_level) << *get_name(i) << "\n"; } diff --git a/panda/src/pgraph/lensNode.cxx b/panda/src/pgraph/lensNode.cxx index 60307c2ce0..1b428d9e98 100644 --- a/panda/src/pgraph/lensNode.cxx +++ b/panda/src/pgraph/lensNode.cxx @@ -26,7 +26,7 @@ TypeHandle LensNode::_type_handle; * */ LensNode:: -LensNode(const string &name, Lens *lens) : +LensNode(const std::string &name, Lens *lens) : PandaNode(name) { if (lens == nullptr) { @@ -171,7 +171,7 @@ hide_frustum() { * */ void LensNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out << " ("; @@ -190,7 +190,7 @@ output(ostream &out) const { * */ void LensNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); for (Lenses::const_iterator li = _lenses.begin(); diff --git a/panda/src/pgraph/lightAttrib.cxx b/panda/src/pgraph/lightAttrib.cxx index 1ad177b1b4..1d6fce8cf7 100644 --- a/panda/src/pgraph/lightAttrib.cxx +++ b/panda/src/pgraph/lightAttrib.cxx @@ -420,7 +420,7 @@ add_on_light(const NodePath &light) const { LightAttrib *attrib = new LightAttrib(*this); - pair insert_result = + std::pair insert_result = attrib->_on_lights.insert(Lights::value_type(light)); if (insert_result.second) { lobj->attrib_ref(); @@ -523,7 +523,7 @@ get_ambient_contribution() const { * */ void LightAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_off_lights.empty()) { if (_on_lights.empty()) { @@ -572,7 +572,7 @@ output(ostream &out) const { * */ void LightAttrib:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":"; if (_off_lights.empty()) { if (_on_lights.empty()) { diff --git a/panda/src/pgraph/lightRampAttrib.cxx b/panda/src/pgraph/lightRampAttrib.cxx index 93adfc305b..3f5caee8d9 100644 --- a/panda/src/pgraph/lightRampAttrib.cxx +++ b/panda/src/pgraph/lightRampAttrib.cxx @@ -176,7 +176,7 @@ make_hdr2() { * */ void LightRampAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (_mode) { case LRT_default: diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 866f3c2f14..03ae0e0587 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -32,6 +32,8 @@ #include "configVariableInt.h" #include "configVariableEnum.h" +using std::string; + bool Loader::_file_types_loaded = false; PT(Loader) Loader::_global_ptr; TypeHandle Loader::_type_handle; @@ -96,7 +98,7 @@ make_async_save_request(const Filename &filename, const LoaderOptions &options, * graph defined there. */ PT(PandaNode) Loader:: -load_bam_stream(istream &in) { +load_bam_stream(std::istream &in) { BamFile bam_file; if (!bam_file.open_read(in)) { return nullptr; @@ -109,7 +111,7 @@ load_bam_stream(istream &in) { * */ void Loader:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name(); int num_tasks = _task_manager->make_task_chain(_task_chain)->get_num_tasks(); @@ -473,15 +475,15 @@ load_file_types() { string name = words[0]; Filename dlname = Filename::dso_filename("lib" + name + ".so"); loader_cat.info() - << "loading file type module: " << name << endl; + << "loading file type module: " << name << std::endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == nullptr) { loader_cat.warning() << "Unable to load " << dlname.to_os_specific() - << ": " << load_dso_error() << endl; + << ": " << load_dso_error() << std::endl; } else if (loader_cat.is_debug()) { loader_cat.debug() - << "done loading file type module: " << name << endl; + << "done loading file type module: " << name << std::endl; } } else if (words.size() > 1) { diff --git a/panda/src/pgraph/loaderFileType.cxx b/panda/src/pgraph/loaderFileType.cxx index a7189526ed..262da5859f 100644 --- a/panda/src/pgraph/loaderFileType.cxx +++ b/panda/src/pgraph/loaderFileType.cxx @@ -41,9 +41,9 @@ LoaderFileType:: * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this loader. */ -string LoaderFileType:: +std::string LoaderFileType:: get_additional_extensions() const { - return string(); + return std::string(); } /** diff --git a/panda/src/pgraph/loaderFileTypeBam.cxx b/panda/src/pgraph/loaderFileTypeBam.cxx index 985ffb706a..7d2f6fd2cd 100644 --- a/panda/src/pgraph/loaderFileTypeBam.cxx +++ b/panda/src/pgraph/loaderFileTypeBam.cxx @@ -32,7 +32,7 @@ LoaderFileTypeBam() { /** * */ -string LoaderFileTypeBam:: +std::string LoaderFileTypeBam:: get_name() const { return "Bam"; } @@ -40,7 +40,7 @@ get_name() const { /** * */ -string LoaderFileTypeBam:: +std::string LoaderFileTypeBam:: get_extension() const { return "bam"; } diff --git a/panda/src/pgraph/loaderFileTypeRegistry.cxx b/panda/src/pgraph/loaderFileTypeRegistry.cxx index 6f5f6fed44..c7df6731eb 100644 --- a/panda/src/pgraph/loaderFileTypeRegistry.cxx +++ b/panda/src/pgraph/loaderFileTypeRegistry.cxx @@ -21,6 +21,8 @@ #include +using std::string; + LoaderFileTypeRegistry *LoaderFileTypeRegistry::_global_ptr; /** @@ -152,16 +154,16 @@ get_type_from_extension(const string &extension) { _deferred_types.erase(di); loader_cat->info() - << "loading file type module: " << name << endl; + << "loading file type module: " << name << std::endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == nullptr) { loader_cat->warning() << "Unable to load " << dlname.to_os_specific() << ": " - << load_dso_error() << endl; + << load_dso_error() << std::endl; return nullptr; } else if (loader_cat.is_debug()) { loader_cat.debug() - << "done loading file type module: " << name << endl; + << "done loading file type module: " << name << std::endl; } // Now try again to find the LoaderFileType. @@ -183,7 +185,7 @@ get_type_from_extension(const string &extension) { * per line. */ void LoaderFileTypeRegistry:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (_types.empty()) { indent(out, indent_level) << "(No file types are known).\n"; } else { @@ -192,7 +194,7 @@ write(ostream &out, int indent_level) const { LoaderFileType *type = (*ti); string name = type->get_name(); indent(out, indent_level) << name; - indent(out, max(30 - (int)name.length(), 0)) << " "; + indent(out, std::max(30 - (int)name.length(), 0)) << " "; bool comma = false; if (!type->get_extension().empty()) { diff --git a/panda/src/pgraph/logicOpAttrib.cxx b/panda/src/pgraph/logicOpAttrib.cxx index 28381dfc5b..75aff15fce 100644 --- a/panda/src/pgraph/logicOpAttrib.cxx +++ b/panda/src/pgraph/logicOpAttrib.cxx @@ -53,7 +53,7 @@ make_default() { * */ void LogicOpAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":" << get_operation(); } @@ -138,8 +138,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { /** * */ -ostream & -operator << (ostream &out, LogicOpAttrib::Operation op) { +std::ostream & +operator << (std::ostream &out, LogicOpAttrib::Operation op) { switch (op) { case LogicOpAttrib::O_none: return out << "none"; diff --git a/panda/src/pgraph/materialAttrib.cxx b/panda/src/pgraph/materialAttrib.cxx index baeac4dc38..2ff453b8c6 100644 --- a/panda/src/pgraph/materialAttrib.cxx +++ b/panda/src/pgraph/materialAttrib.cxx @@ -56,7 +56,7 @@ make_default() { * */ void MaterialAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_material != nullptr) { out << *_material; diff --git a/panda/src/pgraph/materialCollection.cxx b/panda/src/pgraph/materialCollection.cxx index 386758f1c5..37fbd79c80 100644 --- a/panda/src/pgraph/materialCollection.cxx +++ b/panda/src/pgraph/materialCollection.cxx @@ -173,7 +173,7 @@ clear() { * NULL if no material has that name. */ Material *MaterialCollection:: -find_material(const string &name) const { +find_material(const std::string &name) const { int num_materials = get_num_materials(); for (int i = 0; i < num_materials; i++) { Material *material = get_material(i); @@ -227,7 +227,7 @@ size() const { * indicated output stream. */ void MaterialCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_materials() == 1) { out << "1 Material"; } else { @@ -240,7 +240,7 @@ output(ostream &out) const { * indicated output stream. */ void MaterialCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_materials(); i++) { indent(out, indent_level) << *get_material(i) << "\n"; } diff --git a/panda/src/pgraph/modelLoadRequest.cxx b/panda/src/pgraph/modelLoadRequest.cxx index 4feba702ef..0bbec06161 100644 --- a/panda/src/pgraph/modelLoadRequest.cxx +++ b/panda/src/pgraph/modelLoadRequest.cxx @@ -22,7 +22,7 @@ TypeHandle ModelLoadRequest::_type_handle; * to begin an asynchronous load. */ ModelLoadRequest:: -ModelLoadRequest(const string &name, +ModelLoadRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, Loader *loader) : AsyncTask(name), diff --git a/panda/src/pgraph/modelPool.cxx b/panda/src/pgraph/modelPool.cxx index b5722f2271..c53e2b867f 100644 --- a/panda/src/pgraph/modelPool.cxx +++ b/panda/src/pgraph/modelPool.cxx @@ -25,7 +25,7 @@ ModelPool *ModelPool::_global_ptr = nullptr; * with debugging. */ void ModelPool:: -write(ostream &out) { +write(std::ostream &out) { get_ptr()->ns_list_contents(out); } @@ -259,7 +259,7 @@ ns_garbage_collect() { * The nonstatic implementation of list_contents(). */ void ModelPool:: -ns_list_contents(ostream &out) const { +ns_list_contents(std::ostream &out) const { LightMutexHolder holder(_lock); out << "model pool contents:\n"; diff --git a/panda/src/pgraph/modelSaveRequest.cxx b/panda/src/pgraph/modelSaveRequest.cxx index 31c50cfdf6..eefca944d4 100644 --- a/panda/src/pgraph/modelSaveRequest.cxx +++ b/panda/src/pgraph/modelSaveRequest.cxx @@ -22,7 +22,7 @@ TypeHandle ModelSaveRequest::_type_handle; * to begin an asynchronous save. */ ModelSaveRequest:: -ModelSaveRequest(const string &name, +ModelSaveRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, PandaNode *node, Loader *loader) : AsyncTask(name), diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 065bef7424..9123a951b5 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -73,6 +73,12 @@ #include "datagramBuffer.h" #include "weakNodePath.h" +using std::max; +using std::move; +using std::ostream; +using std::ostringstream; +using std::string; + // stack seems to overflow on Intel C++ at 7000. If we need more than 7000, // need to increase stack size. int NodePath::_max_search_depth = 7000; diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index 8f29f07f22..545691d0fc 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -19,6 +19,9 @@ #include "colorAttrib.h" #include "indent.h" +using std::max; +using std::min; + /** * Adds a new NodePath to the collection. */ @@ -208,7 +211,7 @@ size() const { * hierarchically. */ void NodePathCollection:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_paths(); i++) { NodePath path = get_path(i); indent(out, indent_level) << path << "\n"; @@ -223,7 +226,7 @@ ls(ostream &out, int indent_level) const { * listed first. */ NodePathCollection NodePathCollection:: -find_all_matches(const string &path) const { +find_all_matches(const std::string &path) const { NodePathCollection result; FindApproxPath approx_path; @@ -557,7 +560,7 @@ set_attrib(const RenderAttrib *attrib, int priority) { * indicated output stream. */ void NodePathCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_paths() == 1) { out << "1 NodePath"; } else { @@ -570,7 +573,7 @@ output(ostream &out) const { * indicated output stream. */ void NodePathCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_paths(); i++) { indent(out, indent_level) << get_path(i) << "\n"; } diff --git a/panda/src/pgraph/nodePathCollection_ext.cxx b/panda/src/pgraph/nodePathCollection_ext.cxx index 1e2b13fe1e..836e2959e0 100644 --- a/panda/src/pgraph/nodePathCollection_ext.cxx +++ b/panda/src/pgraph/nodePathCollection_ext.cxx @@ -48,9 +48,9 @@ __init__(PyObject *self, PyObject *sequence) { NodePath *path; if (!DtoolInstance_GetPointer(item, path, Dtool_NodePath)) { // Unable to add item--probably it wasn't of the appropriate type. - ostringstream stream; + std::ostringstream stream; stream << "Element " << i << " in sequence passed to NodePathCollection constructor is not a NodePath"; - string str = stream.str(); + std::string str = stream.str(); PyErr_SetString(PyExc_TypeError, str.c_str()); Py_DECREF(fast); return; diff --git a/panda/src/pgraph/nodePathComponent.cxx b/panda/src/pgraph/nodePathComponent.cxx index dd767cf172..fa578ba53f 100644 --- a/panda/src/pgraph/nodePathComponent.cxx +++ b/panda/src/pgraph/nodePathComponent.cxx @@ -121,7 +121,7 @@ fix_length(int pipeline_stage, Thread *current_thread) { * the end of the linked list and then outputting from there. */ void NodePathComponent:: -output(ostream &out) const { +output(std::ostream &out) const { Thread *current_thread = Thread::get_current_thread(); int pipeline_stage = current_thread->get_pipeline_stage(); diff --git a/panda/src/pgraph/nodePath_ext.cxx b/panda/src/pgraph/nodePath_ext.cxx index f167d0c57a..4be58f3201 100644 --- a/panda/src/pgraph/nodePath_ext.cxx +++ b/panda/src/pgraph/nodePath_ext.cxx @@ -16,6 +16,8 @@ #include "shaderInput_ext.h" #include "shaderAttrib.h" +using std::move; + #ifdef HAVE_PYTHON #ifndef CPPPARSER @@ -123,9 +125,9 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { vector_uchar bam_stream; if (!_this->encode_to_bam_stream(bam_stream, writer)) { - ostringstream stream; + std::ostringstream stream; stream << "Could not bamify " << _this; - string message = stream.str(); + std::string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); return nullptr; } @@ -294,7 +296,7 @@ set_shader_inputs(PyObject *args, PyObject *kwargs) { return; } - CPT_InternalName name(string(buffer, length)); + CPT_InternalName name(std::string(buffer, length)); ShaderInput &input = attrib->_inputs[name]; invoke_extension(&input).__init__(move(name), value); } diff --git a/panda/src/pgraph/occluderEffect.cxx b/panda/src/pgraph/occluderEffect.cxx index 9e81d4e52d..eceb1afd6e 100644 --- a/panda/src/pgraph/occluderEffect.cxx +++ b/panda/src/pgraph/occluderEffect.cxx @@ -66,7 +66,7 @@ remove_on_occluder(const NodePath &occluder) const { * */ void OccluderEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (_on_occluders.empty()) { out << "identity"; diff --git a/panda/src/pgraph/occluderNode.cxx b/panda/src/pgraph/occluderNode.cxx index 3fc81bc944..09f8bbd038 100644 --- a/panda/src/pgraph/occluderNode.cxx +++ b/panda/src/pgraph/occluderNode.cxx @@ -51,7 +51,7 @@ PT(Texture) OccluderNode::_viz_tex; * vertices with set_vertices(). */ OccluderNode:: -OccluderNode(const string &name) : +OccluderNode(const std::string &name) : PandaNode(name) { set_cull_callback(); @@ -174,7 +174,7 @@ is_renderable() const { * classes to include some information relevant to the class. */ void OccluderNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index c6cc323d2a..6994e643f8 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -28,6 +28,10 @@ #include "lightReMutexHolder.h" #include "graphicsStateGuardianBase.h" +using std::ostream; +using std::ostringstream; +using std::string; + // This category is just temporary for debugging convenience. NotifyCategoryDecl(drawmask, EXPCL_PANDA_PGRAPH, EXPTP_PANDA_PGRAPH); NotifyCategoryDef(drawmask, ""); @@ -2118,7 +2122,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { TypedWritable *object; ReferenceCount *ref_ptr; - if (TypedWritable::decode_raw_from_bam_stream(object, ref_ptr, move(data), reader)) { + if (TypedWritable::decode_raw_from_bam_stream(object, ref_ptr, std::move(data), reader)) { return DCAST(PandaNode, object); } else { return nullptr; diff --git a/panda/src/pgraph/paramNodePath.cxx b/panda/src/pgraph/paramNodePath.cxx index 32d5aeb585..72a3563b22 100644 --- a/panda/src/pgraph/paramNodePath.cxx +++ b/panda/src/pgraph/paramNodePath.cxx @@ -21,7 +21,7 @@ TypeHandle ParamNodePath::_type_handle; * */ void ParamNodePath:: -output(ostream &out) const { +output(std::ostream &out) const { out << "node path " << _node_path; } diff --git a/panda/src/pgraph/planeNode.cxx b/panda/src/pgraph/planeNode.cxx index 2af7609809..9513b23509 100644 --- a/panda/src/pgraph/planeNode.cxx +++ b/panda/src/pgraph/planeNode.cxx @@ -59,7 +59,7 @@ fillin(DatagramIterator &scan, BamReader *) { * */ PlaneNode:: -PlaneNode(const string &name, const LPlane &plane) : +PlaneNode(const std::string &name, const LPlane &plane) : PandaNode(name), _priority(0), _clip_effect(~0) @@ -88,7 +88,7 @@ PlaneNode(const PlaneNode ©) : * */ void PlaneNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out << " " << get_plane(); } diff --git a/panda/src/pgraph/polylightEffect.cxx b/panda/src/pgraph/polylightEffect.cxx index acbd41b18f..f940a62c8c 100644 --- a/panda/src/pgraph/polylightEffect.cxx +++ b/panda/src/pgraph/polylightEffect.cxx @@ -22,6 +22,8 @@ #include +using std::endl; + TypeHandle PolylightEffect::_type_handle; /** @@ -334,7 +336,7 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran * */ void PolylightEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; LightGroup::const_iterator li; @@ -461,8 +463,8 @@ has_light(const NodePath &light) const { return (li != _lightgroup.end()); } -ostream & -operator << (ostream &out, PolylightEffect::ContribType ct) { +std::ostream & +operator << (std::ostream &out, PolylightEffect::ContribType ct) { switch (ct) { case PolylightEffect::CT_proximal: return out << "proximal"; diff --git a/panda/src/pgraph/polylightNode.cxx b/panda/src/pgraph/polylightNode.cxx index e7b857367b..73242aab04 100644 --- a/panda/src/pgraph/polylightNode.cxx +++ b/panda/src/pgraph/polylightNode.cxx @@ -29,7 +29,7 @@ TypeHandle PolylightNode::_type_handle; * Use PolylightNode() to construct a new PolylightNode object. */ PolylightNode:: -PolylightNode(const string &name) : +PolylightNode(const std::string &name) : PandaNode(name) { _enabled = true; @@ -100,12 +100,12 @@ LColor PolylightNode::flicker() const { variation = (rand()%100); // a value between 0-99 variation /= 100.0; if (polylight_info) - pgraph_cat.info() << "Random Variation: " << variation << endl; + pgraph_cat.info() << "Random Variation: " << variation << std::endl; } else if (_flicker_type == FSIN) { double now = ClockObject::get_global_clock()->get_frame_time(); variation = sinf(now*_sin_freq); if (polylight_info) - pgraph_cat.info() << "Variation: " << variation << endl; + pgraph_cat.info() << "Variation: " << variation << std::endl; // can't use negative variation, so make it positive if (variation < 0.0) variation *= -1.0; @@ -134,7 +134,7 @@ LColor PolylightNode::flicker() const { b = color[2]; } */ - pgraph_cat.debug() << "Color R:" << r << "; G:" << g << "; B:" << b << endl; + pgraph_cat.debug() << "Color R:" << r << "; G:" << g << "; B:" << b << std::endl; return LColor(r,g,b,1.0); } @@ -277,7 +277,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ void PolylightNode:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; // out << "Position: " << get_x() << " " << get_y() << " " << get_z() << // "\n"; out << "Color: " << get_r() << " " << get_g() << " " << get_b() << diff --git a/panda/src/pgraph/portalClipper.cxx b/panda/src/pgraph/portalClipper.cxx index c0fe73f73f..d9d1af727d 100644 --- a/panda/src/pgraph/portalClipper.cxx +++ b/panda/src/pgraph/portalClipper.cxx @@ -30,6 +30,10 @@ #include "geomLinestrips.h" #include "geomPoints.h" +using std::endl; +using std::max; +using std::min; + TypeHandle PortalClipper::_type_handle; /** diff --git a/panda/src/pgraph/portalNode.cxx b/panda/src/pgraph/portalNode.cxx index 8ddb409f09..c7ad0444fe 100644 --- a/panda/src/pgraph/portalNode.cxx +++ b/panda/src/pgraph/portalNode.cxx @@ -30,6 +30,8 @@ #include "plane.h" +using std::endl; + TypeHandle PortalNode::_type_handle; @@ -39,7 +41,7 @@ TypeHandle PortalNode::_type_handle; * Then you can set the vertices yourself, with addVertex. */ PortalNode:: -PortalNode(const string &name) : +PortalNode(const std::string &name) : PandaNode(name), _from_portal_mask(PortalMask::all_on()), _into_portal_mask(PortalMask::all_on()), @@ -58,7 +60,7 @@ PortalNode(const string &name) : * portal and setup from Python */ PortalNode:: -PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale) : +PortalNode(const std::string &name, LPoint3 pos, PN_stdfloat scale) : PandaNode(name), _from_portal_mask(PortalMask::all_on()), _into_portal_mask(PortalMask::all_on()), @@ -323,7 +325,7 @@ is_renderable() const { * classes to include some information relevant to the class. */ void PortalNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 66c507c1c8..73b1e4b392 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -18,6 +18,8 @@ #include "lightReMutexHolder.h" #include "pStatTimer.h" +using std::ostream; + LightReMutex *RenderAttrib::_attribs_lock = nullptr; RenderAttrib::Attribs *RenderAttrib::_attribs = nullptr; TypeHandle RenderAttrib::_type_handle; @@ -198,7 +200,7 @@ garbage_collect() { // How many elements to process this pass? size_t size = orig_size; - size_t num_this_pass = max(0, int(size * garbage_collect_states_rate)); + size_t num_this_pass = std::max(0, int(size * garbage_collect_states_rate)); if (num_this_pass <= 0) { return 0; } @@ -208,7 +210,7 @@ garbage_collect() { si = 0; } - num_this_pass = min(num_this_pass, size); + num_this_pass = std::min(num_this_pass, size); size_t stop_at_element = (_garbage_index + num_this_pass) % size; do { @@ -266,7 +268,7 @@ validate_attribs() { for (size_t si = 0; si < size; ++si) { const RenderAttrib *attrib = _attribs->get_key(si); //cerr << si << ": " << attrib << "\n"; - attrib->write(cerr, 2); + attrib->write(std::cerr, 2); } return false; diff --git a/panda/src/pgraph/renderEffect.cxx b/panda/src/pgraph/renderEffect.cxx index 583c04d812..da052c0073 100644 --- a/panda/src/pgraph/renderEffect.cxx +++ b/panda/src/pgraph/renderEffect.cxx @@ -151,7 +151,7 @@ adjust_transform(CPT(TransformState) &, CPT(TransformState) &, * */ void RenderEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -159,7 +159,7 @@ output(ostream &out) const { * */ void RenderEffect:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } @@ -181,7 +181,7 @@ get_num_effects() { * prepared. */ void RenderEffect:: -list_effects(ostream &out) { +list_effects(std::ostream &out) { out << _effects->size() << " effects:\n"; Effects::const_iterator si; for (si = _effects->begin(); si != _effects->end(); ++si) { @@ -247,7 +247,7 @@ return_new(RenderEffect *effect) { // of this function if no one else uses it. CPT(RenderEffect) pt_effect = effect; - pair result = _effects->insert(effect); + std::pair result = _effects->insert(effect); if (result.second) { // The effect was inserted; save the iterator and return the input effect. effect->_saved_entry = result.first; diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index 4ef038625d..3c1b1066bb 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -351,7 +351,7 @@ unref() const { * */ void RenderEffects:: -output(ostream &out) const { +output(std::ostream &out) const { out << "E:"; if (_effects.empty()) { out << "(empty)"; @@ -372,7 +372,7 @@ output(ostream &out) const { * */ void RenderEffects:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _effects.size() << " effects:\n"; Effects::const_iterator ai; for (ai = _effects.begin(); ai != _effects.end(); ++ai) { @@ -400,7 +400,7 @@ get_num_states() { * prepared. */ void RenderEffects:: -list_states(ostream &out) { +list_states(std::ostream &out) { out << _states->size() << " states:\n"; States::const_iterator si; for (si = _states->begin(); si != _states->end(); ++si) { @@ -538,7 +538,7 @@ return_new(RenderEffects *state) { // of this function if no one else uses it. CPT(RenderEffects) pt_state = state; - pair result = _states->insert(state); + std::pair result = _states->insert(state); if (result.second) { // The state was inserted; save the iterator and return the input state. state->_saved_entry = result.first; diff --git a/panda/src/pgraph/renderModeAttrib.cxx b/panda/src/pgraph/renderModeAttrib.cxx index efdf3e7434..1b2b41c9ad 100644 --- a/panda/src/pgraph/renderModeAttrib.cxx +++ b/panda/src/pgraph/renderModeAttrib.cxx @@ -60,7 +60,7 @@ make_default() { * */ void RenderModeAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_mode()) { case M_unchanged: diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 1a8a3f0a56..927d1e7073 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -36,6 +36,8 @@ #include "thread.h" #include "renderAttribRegistry.h" +using std::ostream; + LightReMutex *RenderState::_states_lock = nullptr; RenderState::States *RenderState::_states = nullptr; const RenderState *RenderState::_empty_state = nullptr; @@ -590,7 +592,7 @@ adjust_all_priorities(int adjustment) const { while (slot >= 0) { Attribute &attrib = new_state->_attributes[slot]; nassertr(attrib._attrib != nullptr, this); - attrib._override = max(attrib._override + adjustment, 0); + attrib._override = std::max(attrib._override + adjustment, 0); mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); @@ -756,7 +758,7 @@ get_num_unused_states() { const RenderState *result = state->_composition_cache.get_data(i)._result; if (result != nullptr && result != state) { // Here's a RenderState that's recorded in the cache. Count it. - pair ir = + std::pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { // If the above insert operation fails, then it's already in the @@ -769,7 +771,7 @@ get_num_unused_states() { for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_invert_composition_cache.get_data(i)._result; if (result != nullptr && result != state) { - pair ir = + std::pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { (*(ir.first)).second++; @@ -904,7 +906,7 @@ garbage_collect() { // How many elements to process this pass? size_t size = orig_size; - size_t num_this_pass = max(0, int(size * garbage_collect_states_rate)); + size_t num_this_pass = std::max(0, int(size * garbage_collect_states_rate)); if (num_this_pass <= 0) { return num_attribs; } @@ -916,7 +918,7 @@ garbage_collect() { si = 0; } - num_this_pass = min(num_this_pass, size); + num_this_pass = std::min(num_this_pass, size); size_t stop_at_element = (si + num_this_pass) % size; do { @@ -1733,7 +1735,7 @@ determine_bin_index() { return; } - string bin_name; + std::string bin_name; _draw_order = 0; const CullBinAttrib *bin; diff --git a/panda/src/pgraph/rescaleNormalAttrib.cxx b/panda/src/pgraph/rescaleNormalAttrib.cxx index fbc4d59274..0b93da7a23 100644 --- a/panda/src/pgraph/rescaleNormalAttrib.cxx +++ b/panda/src/pgraph/rescaleNormalAttrib.cxx @@ -22,6 +22,10 @@ #include "configVariableEnum.h" #include "config_pgraph.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle RescaleNormalAttrib::_type_handle; int RescaleNormalAttrib::_attrib_slot; CPT(RenderAttrib) RescaleNormalAttrib::_attribs[RescaleNormalAttrib::M_auto + 1]; diff --git a/panda/src/pgraph/sceneGraphReducer.cxx b/panda/src/pgraph/sceneGraphReducer.cxx index 3b1e075a90..03179d38dd 100644 --- a/panda/src/pgraph/sceneGraphReducer.cxx +++ b/panda/src/pgraph/sceneGraphReducer.cxx @@ -51,7 +51,7 @@ set_gsg(GraphicsStateGuardianBase *gsg) { int max_vertices = max_collect_vertices; if (_gsg != nullptr) { - max_vertices = min(max_vertices, _gsg->get_max_vertices_per_array()); + max_vertices = std::min(max_vertices, _gsg->get_max_vertices_per_array()); } _transformer.set_max_collect_vertices(max_vertices); @@ -181,7 +181,7 @@ unify(PandaNode *root, bool preserve_order) { int max_indices = max_collect_indices; if (_gsg != nullptr) { - max_indices = min(max_indices, _gsg->get_max_vertices_per_primitive()); + max_indices = std::min(max_indices, _gsg->get_max_vertices_per_primitive()); } r_unify(root, max_indices, preserve_order); } @@ -376,7 +376,7 @@ r_flatten(PandaNode *grandparent_node, PandaNode *parent_node, if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "SceneGraphReducer::r_flatten(" << *grandparent_node << ", " - << *parent_node << ", " << hex << combine_siblings_bits << dec + << *parent_node << ", " << std::hex << combine_siblings_bits << std::dec << ")\n"; } @@ -730,7 +730,7 @@ collapse_nodes(PandaNode *node1, PandaNode *node2, bool siblings) { */ void SceneGraphReducer:: choose_name(PandaNode *preserve, PandaNode *source1, PandaNode *source2) { - string name; + std::string name; bool got_name = false; name = source1->get_name(); diff --git a/panda/src/pgraph/scissorAttrib.cxx b/panda/src/pgraph/scissorAttrib.cxx index f6281cd083..4e137eec5b 100644 --- a/panda/src/pgraph/scissorAttrib.cxx +++ b/panda/src/pgraph/scissorAttrib.cxx @@ -19,6 +19,9 @@ #include "datagram.h" #include "datagramIterator.h" +using std::max; +using std::min; + TypeHandle ScissorAttrib::_type_handle; int ScissorAttrib::_attrib_slot; CPT(RenderAttrib) ScissorAttrib::_off_attrib; @@ -78,7 +81,7 @@ make_default() { * */ void ScissorAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":[" << _frame << "]"; } diff --git a/panda/src/pgraph/scissorEffect.cxx b/panda/src/pgraph/scissorEffect.cxx index 8e0d47ca9e..dbfa96cf9e 100644 --- a/panda/src/pgraph/scissorEffect.cxx +++ b/panda/src/pgraph/scissorEffect.cxx @@ -23,6 +23,9 @@ #include "boundingHexahedron.h" #include "lens.h" +using std::max; +using std::min; + TypeHandle ScissorEffect::_type_handle; /** @@ -155,7 +158,7 @@ xform(const LMatrix4 &mat) const { * */ void ScissorEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; if (is_screen()) { out << "screen [" << _frame << "]"; diff --git a/panda/src/pgraph/shadeModelAttrib.cxx b/panda/src/pgraph/shadeModelAttrib.cxx index dea61a8521..26fac679b4 100644 --- a/panda/src/pgraph/shadeModelAttrib.cxx +++ b/panda/src/pgraph/shadeModelAttrib.cxx @@ -45,7 +45,7 @@ make_default() { * */ void ShadeModelAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_mode()) { case M_flat: diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index 982497497e..e519289b28 100644 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -29,6 +29,9 @@ #include "paramTexture.h" #include "shaderBuffer.h" +using std::ostream; +using std::ostringstream; + TypeHandle ShaderAttrib::_type_handle; int ShaderAttrib::_attrib_slot; @@ -214,9 +217,9 @@ set_shader_input(ShaderInput &&input) const { ShaderAttrib *result = new ShaderAttrib(*this); Inputs::iterator i = result->_inputs.find(input.get_name()); if (i == result->_inputs.end()) { - result->_inputs.insert(Inputs::value_type(input.get_name(), move(input))); + result->_inputs.insert(Inputs::value_type(input.get_name(), std::move(input))); } else { - i->second = move(input); + i->second = std::move(input); } return return_new(result); } @@ -247,7 +250,7 @@ clear_shader_input(const InternalName *id) const { * */ CPT(RenderAttrib) ShaderAttrib:: -clear_shader_input(const string &id) const { +clear_shader_input(const std::string &id) const { return clear_shader_input(InternalName::make(id)); } @@ -280,7 +283,7 @@ get_shader_input(const InternalName *id) const { * function does not return NULL --- it returns the "blank" ShaderInput. */ const ShaderInput &ShaderAttrib:: -get_shader_input(const string &id) const { +get_shader_input(const std::string &id) const { return get_shader_input(InternalName::make(id)); } diff --git a/panda/src/pgraph/shaderAttrib_ext.cxx b/panda/src/pgraph/shaderAttrib_ext.cxx index b98badf71b..54acefe0ec 100644 --- a/panda/src/pgraph/shaderAttrib_ext.cxx +++ b/panda/src/pgraph/shaderAttrib_ext.cxx @@ -24,7 +24,7 @@ set_shader_input(CPT_InternalName name, PyObject *value, int priority) const { ShaderAttrib *attrib = new ShaderAttrib(*_this); ShaderInput &input = attrib->_inputs[name]; - invoke_extension(&input).__init__(move(name), value); + invoke_extension(&input).__init__(std::move(name), value); return ShaderAttrib::return_new(attrib); } @@ -60,9 +60,9 @@ set_shader_inputs(PyObject *args, PyObject *kwargs) const { return nullptr; } - CPT_InternalName name(string(buffer, length)); + CPT_InternalName name(std::string(buffer, length)); ShaderInput &input = attrib->_inputs[name]; - invoke_extension(&input).__init__(move(name), value); + invoke_extension(&input).__init__(std::move(name), value); } return ShaderAttrib::return_new(attrib); diff --git a/panda/src/pgraph/shaderInput.cxx b/panda/src/pgraph/shaderInput.cxx index a1d698cce7..b017045b22 100644 --- a/panda/src/pgraph/shaderInput.cxx +++ b/panda/src/pgraph/shaderInput.cxx @@ -30,7 +30,7 @@ get_blank() { */ ShaderInput:: ShaderInput(CPT_InternalName name, const NodePath &np, int priority) : - _name(move(name)), + _name(std::move(name)), _type(M_nodepath), _priority(priority), _value(new ParamNodePath(np)) @@ -42,7 +42,7 @@ ShaderInput(CPT_InternalName name, const NodePath &np, int priority) : */ ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, int n, int priority) : - _name(move(name)), + _name(std::move(name)), _type(M_texture_image), _priority(priority), _value(new ParamTextureImage(tex, read, write, z, n)) @@ -54,7 +54,7 @@ ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, i */ ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority) : - _name(move(name)), + _name(std::move(name)), _type(M_texture_sampler), _priority(priority), _value(new ParamTextureSampler(tex, sampler)) diff --git a/panda/src/pgraph/shaderInput_ext.cxx b/panda/src/pgraph/shaderInput_ext.cxx index d09a971b46..72a4d74de3 100644 --- a/panda/src/pgraph/shaderInput_ext.cxx +++ b/panda/src/pgraph/shaderInput_ext.cxx @@ -58,7 +58,7 @@ extern struct Dtool_PyTypedObject Dtool_ParamValueBase; */ void Extension:: __init__(CPT_InternalName name, PyObject *value, int priority) { - _this->_name = move(name); + _this->_name = std::move(name); _this->_priority = priority; if (PyTuple_CheckExact(value) && PyTuple_GET_SIZE(value) <= 4) { diff --git a/panda/src/pgraph/shaderPool.cxx b/panda/src/pgraph/shaderPool.cxx index 87823b9e50..0806b5ed32 100644 --- a/panda/src/pgraph/shaderPool.cxx +++ b/panda/src/pgraph/shaderPool.cxx @@ -25,7 +25,7 @@ ShaderPool *ShaderPool::_global_ptr = nullptr; * Lists the contents of the shader pool to the indicated output stream. */ void ShaderPool:: -write(ostream &out) { +write(std::ostream &out) { get_ptr()->ns_list_contents(out); } @@ -77,7 +77,7 @@ ns_load_shader(const Filename &orig_filename) { // the file extension. This is really just guesswork - there are no // standardized extensions for shaders, especially for GLSL. These are the // ones that appear to be closest to "standard". - string ext = downcase(filename.get_extension()); + std::string ext = downcase(filename.get_extension()); if (ext == "cg" || ext == "sha") { // "sha" is for historical reasons. lang = Shader::SL_Cg; @@ -182,7 +182,7 @@ ns_garbage_collect() { * The nonstatic implementation of list_contents(). */ void ShaderPool:: -ns_list_contents(ostream &out) const { +ns_list_contents(std::ostream &out) const { LightMutexHolder holder(_lock); out << _shaders.size() << " shaders:\n"; diff --git a/panda/src/pgraph/stencilAttrib.cxx b/panda/src/pgraph/stencilAttrib.cxx index 13a00165ed..52b047652b 100644 --- a/panda/src/pgraph/stencilAttrib.cxx +++ b/panda/src/pgraph/stencilAttrib.cxx @@ -264,7 +264,7 @@ make_2_sided_with_clear( * */ void StencilAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { int index; for (index = 0; index < SRS_total; index++) { diff --git a/panda/src/pgraph/test_pgraph.cxx b/panda/src/pgraph/test_pgraph.cxx index 45df2fe578..cb2e3a4dde 100644 --- a/panda/src/pgraph/test_pgraph.cxx +++ b/panda/src/pgraph/test_pgraph.cxx @@ -17,13 +17,15 @@ #include "findApproxLevelEntry.h" #include "clockObject.h" +using std::cerr; + NodePath -build_tree(const string &name, int depth) { +build_tree(const std::string &name, int depth) { NodePath node(name); if (depth > 1) { for (int i = 0; i < 3; i++) { char letter = 'a' + i; - string child_name = name + string(1, letter); + std::string child_name = name + std::string(1, letter); NodePath child = build_tree(child_name, depth - 1); child.reparent_to(node); } diff --git a/panda/src/pgraph/texGenAttrib.cxx b/panda/src/pgraph/texGenAttrib.cxx index 9842d1158f..32216dab88 100644 --- a/panda/src/pgraph/texGenAttrib.cxx +++ b/panda/src/pgraph/texGenAttrib.cxx @@ -190,7 +190,7 @@ get_constant_value(TextureStage *stage) const { * */ void TexGenAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; Stages::const_iterator mi; diff --git a/panda/src/pgraph/texMatrixAttrib.cxx b/panda/src/pgraph/texMatrixAttrib.cxx index a228b79072..f32e0a8b97 100644 --- a/panda/src/pgraph/texMatrixAttrib.cxx +++ b/panda/src/pgraph/texMatrixAttrib.cxx @@ -179,7 +179,7 @@ get_transform(TextureStage *stage) const { * */ void TexMatrixAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; Stages::const_iterator mi; diff --git a/panda/src/pgraph/texProjectorEffect.cxx b/panda/src/pgraph/texProjectorEffect.cxx index 5d850ab0f5..456c6556e2 100644 --- a/panda/src/pgraph/texProjectorEffect.cxx +++ b/panda/src/pgraph/texProjectorEffect.cxx @@ -142,7 +142,7 @@ get_lens_index(TextureStage *stage) const { * */ void TexProjectorEffect:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; Stages::const_iterator mi; diff --git a/panda/src/pgraph/textureAttrib.cxx b/panda/src/pgraph/textureAttrib.cxx index 49bf20f5b9..7f9c6ff8b8 100644 --- a/panda/src/pgraph/textureAttrib.cxx +++ b/panda/src/pgraph/textureAttrib.cxx @@ -345,7 +345,7 @@ lower_attrib_can_override() const { * */ void TextureAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { check_sorted(); out << get_type() << ":"; @@ -891,7 +891,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { override = scan.get_int32(); } - _next_implicit_sort = max(_next_implicit_sort, implicit_sort + 1); + _next_implicit_sort = std::max(_next_implicit_sort, implicit_sort + 1); Stages::iterator si = _on_stages.insert_nonunique(StageNode(nullptr, _next_implicit_sort, override)); ++_next_implicit_sort; diff --git a/panda/src/pgraph/textureStageCollection.cxx b/panda/src/pgraph/textureStageCollection.cxx index 33e3ce00a6..b7fe96d885 100644 --- a/panda/src/pgraph/textureStageCollection.cxx +++ b/panda/src/pgraph/textureStageCollection.cxx @@ -176,7 +176,7 @@ clear() { * any, or NULL if no texture_stage has that name. */ TextureStage *TextureStageCollection:: -find_texture_stage(const string &name) const { +find_texture_stage(const std::string &name) const { int num_texture_stages = get_num_texture_stages(); for (int i = 0; i < num_texture_stages; i++) { TextureStage *texture_stage = get_texture_stage(i); @@ -240,7 +240,7 @@ sort() { * indicated output stream. */ void TextureStageCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_texture_stages() == 1) { out << "1 TextureStage"; } else { @@ -253,7 +253,7 @@ output(ostream &out) const { * the indicated output stream. */ void TextureStageCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_texture_stages(); i++) { indent(out, indent_level) << *get_texture_stage(i) << "\n"; } diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index a58bd78510..453fb505b4 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -24,6 +24,8 @@ #include "lightMutexHolder.h" #include "thread.h" +using std::ostream; + LightReMutex *TransformState::_states_lock = nullptr; TransformState::States *TransformState::_states = nullptr; CPT(TransformState) TransformState::_identity_state; @@ -1025,7 +1027,7 @@ get_num_unused_states() { const TransformState *result = state->_composition_cache.get_data(i)._result; if (result != nullptr && result != state) { // Here's a TransformState that's recorded in the cache. Count it. - pair ir = + std::pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { // If the above insert operation fails, then it's already in the @@ -1038,7 +1040,7 @@ get_num_unused_states() { for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_invert_composition_cache.get_data(i)._result; if (result != nullptr && result != state) { - pair ir = + std::pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { (*(ir.first)).second++; @@ -1170,7 +1172,7 @@ garbage_collect() { // How many elements to process this pass? size_t size = orig_size; - size_t num_this_pass = max(0, int(size * garbage_collect_states_rate)); + size_t num_this_pass = std::max(0, int(size * garbage_collect_states_rate)); if (num_this_pass <= 0) { return 0; } @@ -1182,7 +1184,7 @@ garbage_collect() { si = 0; } - num_this_pass = min(num_this_pass, size); + num_this_pass = std::min(num_this_pass, size); size_t stop_at_element = (si + num_this_pass) % size; do { diff --git a/panda/src/pgraph/transparencyAttrib.cxx b/panda/src/pgraph/transparencyAttrib.cxx index ad105f3214..146e0aa5b4 100644 --- a/panda/src/pgraph/transparencyAttrib.cxx +++ b/panda/src/pgraph/transparencyAttrib.cxx @@ -44,7 +44,7 @@ make_default() { * */ void TransparencyAttrib:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << ":"; switch (get_mode()) { case M_none: diff --git a/panda/src/pgraph/weakNodePath.cxx b/panda/src/pgraph/weakNodePath.cxx index a83d797cc9..c4d75aad5e 100644 --- a/panda/src/pgraph/weakNodePath.cxx +++ b/panda/src/pgraph/weakNodePath.cxx @@ -17,7 +17,7 @@ * */ void WeakNodePath:: -output(ostream &out) const { +output(std::ostream &out) const { if (was_deleted()) { out << "deleted"; } else { diff --git a/panda/src/pgraph/workingNodePath.cxx b/panda/src/pgraph/workingNodePath.cxx index af9a1fb8e8..0431a1fb85 100644 --- a/panda/src/pgraph/workingNodePath.cxx +++ b/panda/src/pgraph/workingNodePath.cxx @@ -71,7 +71,7 @@ get_node(int index) const { * */ void WorkingNodePath:: -output(ostream &out) const { +output(std::ostream &out) const { // Cheesy and slow, but when you're outputting the thing, presumably you're // not in a hurry. get_node_path().output(out); diff --git a/panda/src/pgraphnodes/ambientLight.cxx b/panda/src/pgraphnodes/ambientLight.cxx index d3aae3fb54..deb6eed6cc 100644 --- a/panda/src/pgraphnodes/ambientLight.cxx +++ b/panda/src/pgraphnodes/ambientLight.cxx @@ -23,7 +23,7 @@ TypeHandle AmbientLight::_type_handle; * */ AmbientLight:: -AmbientLight(const string &name) : +AmbientLight(const std::string &name) : LightNode(name) { } @@ -63,7 +63,7 @@ make_copy() const { * */ void AmbientLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) << "color " << get_color() << "\n"; diff --git a/panda/src/pgraphnodes/callbackNode.cxx b/panda/src/pgraphnodes/callbackNode.cxx index 12018de8da..bf0a233f3c 100644 --- a/panda/src/pgraphnodes/callbackNode.cxx +++ b/panda/src/pgraphnodes/callbackNode.cxx @@ -26,7 +26,7 @@ TypeHandle CallbackNode::_type_handle; * */ CallbackNode:: -CallbackNode(const string &name) : +CallbackNode(const std::string &name) : PandaNode(name) { PandaNode::set_cull_callback(); @@ -145,7 +145,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { * classes to include some information relevant to the class. */ void CallbackNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } diff --git a/panda/src/pgraphnodes/computeNode.cxx b/panda/src/pgraphnodes/computeNode.cxx index 0a55d988ef..560e1a8365 100644 --- a/panda/src/pgraphnodes/computeNode.cxx +++ b/panda/src/pgraphnodes/computeNode.cxx @@ -27,7 +27,7 @@ TypeHandle ComputeNode::_type_handle; * assign a shader using a ShaderAttrib. */ ComputeNode:: -ComputeNode(const string &name) : +ComputeNode(const std::string &name) : PandaNode(name), _dispatcher(new ComputeNode::Dispatcher) { @@ -105,7 +105,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { * classes to include some information relevant to the class. */ void ComputeNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } diff --git a/panda/src/pgraphnodes/directionalLight.cxx b/panda/src/pgraphnodes/directionalLight.cxx index 9d198fac6f..062d2d364d 100644 --- a/panda/src/pgraphnodes/directionalLight.cxx +++ b/panda/src/pgraphnodes/directionalLight.cxx @@ -55,7 +55,7 @@ fillin(DatagramIterator &scan, BamReader *) { * */ DirectionalLight:: -DirectionalLight(const string &name) : +DirectionalLight(const std::string &name) : LightLensNode(name, new OrthographicLens()) { _lenses[0]._lens->set_interocular_distance(0); } @@ -98,7 +98,7 @@ xform(const LMatrix4 &mat) { * */ void DirectionalLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) << "color " << get_color() << "\n"; diff --git a/panda/src/pgraphnodes/fadeLodNode.cxx b/panda/src/pgraphnodes/fadeLodNode.cxx index 92141d7f2d..f523d01795 100644 --- a/panda/src/pgraphnodes/fadeLodNode.cxx +++ b/panda/src/pgraphnodes/fadeLodNode.cxx @@ -28,7 +28,7 @@ TypeHandle FadeLODNode::_type_handle; * */ FadeLODNode:: -FadeLODNode(const string &name) : +FadeLODNode(const std::string &name) : LODNode(name) { set_cull_callback(); @@ -241,7 +241,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { * */ void FadeLODNode:: -output(ostream &out) const { +output(std::ostream &out) const { LODNode::output(out); out << " fade time: " << _fade_time; } @@ -251,7 +251,7 @@ output(ostream &out) const { * of the geometry during a transition. */ void FadeLODNode:: -set_fade_bin(const string &name, int draw_order) { +set_fade_bin(const std::string &name, int draw_order) { _fade_bin_name = name; _fade_bin_draw_order = draw_order; _fade_1_new_state.clear(); diff --git a/panda/src/pgraphnodes/fadeLodNodeData.cxx b/panda/src/pgraphnodes/fadeLodNodeData.cxx index d0f0d09987..5e15112fd3 100644 --- a/panda/src/pgraphnodes/fadeLodNodeData.cxx +++ b/panda/src/pgraphnodes/fadeLodNodeData.cxx @@ -20,7 +20,7 @@ TypeHandle FadeLODNodeData::_type_handle; * */ void FadeLODNodeData:: -output(ostream &out) const { +output(std::ostream &out) const { AuxSceneData::output(out); if (_fade_mode != FM_solid) { out << " fading " << _fade_out << " to " << _fade_in << " since " diff --git a/panda/src/pgraphnodes/lightLensNode.cxx b/panda/src/pgraphnodes/lightLensNode.cxx index b79b5e8dc0..87f9a5bca8 100644 --- a/panda/src/pgraphnodes/lightLensNode.cxx +++ b/panda/src/pgraphnodes/lightLensNode.cxx @@ -26,7 +26,7 @@ TypeHandle LightLensNode::_type_handle; * */ LightLensNode:: -LightLensNode(const string &name, Lens *lens) : +LightLensNode(const std::string &name, Lens *lens) : Camera(name, lens), _has_specular_color(false), _attrib_count(0) @@ -158,7 +158,7 @@ as_light() { * */ void LightLensNode:: -output(ostream &out) const { +output(std::ostream &out) const { LensNode::output(out); } @@ -166,7 +166,7 @@ output(ostream &out) const { * */ void LightLensNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { LensNode::write(out, indent_level); } diff --git a/panda/src/pgraphnodes/lightNode.cxx b/panda/src/pgraphnodes/lightNode.cxx index 13eae68d6d..cffcb05a2f 100644 --- a/panda/src/pgraphnodes/lightNode.cxx +++ b/panda/src/pgraphnodes/lightNode.cxx @@ -23,7 +23,7 @@ TypeHandle LightNode::_type_handle; * */ LightNode:: -LightNode(const string &name) : +LightNode(const std::string &name) : PandaNode(name) { } @@ -59,7 +59,7 @@ as_light() { * */ void LightNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); } @@ -67,7 +67,7 @@ output(ostream &out) const { * */ void LightNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); } diff --git a/panda/src/pgraphnodes/lodNode.cxx b/panda/src/pgraphnodes/lodNode.cxx index e39f0d0c97..060adac699 100644 --- a/panda/src/pgraphnodes/lodNode.cxx +++ b/panda/src/pgraphnodes/lodNode.cxx @@ -45,7 +45,7 @@ TypeHandle LODNode::_type_handle; * variable. */ PT(LODNode) LODNode:: -make_default_lod(const string &name) { +make_default_lod(const std::string &name) { switch (default_lod_type.get_value()) { case LNT_pop: return new LODNode(name); @@ -146,7 +146,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { LPoint3 center = cdata->_center * rel_transform->get_mat(); PN_stdfloat dist2 = center.dot(center); - int num_children = min(get_num_children(), (int)cdata->_switch_vector.size()); + int num_children = std::min(get_num_children(), (int)cdata->_switch_vector.size()); for (int index = 0; index < num_children; ++index) { const Switch &sw = cdata->_switch_vector[index]; bool in_range; @@ -176,7 +176,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { * */ void LODNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); CDReader cdata(_cycler); out << " center(" << cdata->_center << ") "; @@ -593,7 +593,7 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, // should definitely fit entirely within a bounding sphere that contains // all the points of the child. LPoint3 box_center = (min_point + max_point) / 2.0f; - PN_stdfloat box_radius = min(min(max_point[0] - box_center[0], + PN_stdfloat box_radius = std::min(std::min(max_point[0] - box_center[0], max_point[1] - box_center[1]), max_point[2] - box_center[2]); @@ -642,7 +642,7 @@ do_auto_verify_lods(CullTraverser *trav, CullTraverserData &data) { PN_stdfloat suggested_radius; if (!do_verify_child_bounds(cdata, index, suggested_radius)) { const Switch &sw = cdata->_switch_vector[index]; - ostringstream strm; + std::ostringstream strm; strm << "Level " << index << " geometry of " << data.get_node_path() << " is larger than its switch radius; suggest radius of " diff --git a/panda/src/pgraphnodes/lodNodeType.cxx b/panda/src/pgraphnodes/lodNodeType.cxx index 2798cdd0f4..5c37066cf5 100644 --- a/panda/src/pgraphnodes/lodNodeType.cxx +++ b/panda/src/pgraphnodes/lodNodeType.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "config_pgraph.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, LODNodeType lnt) { switch (lnt) { diff --git a/panda/src/pgraphnodes/nodeCullCallbackData.cxx b/panda/src/pgraphnodes/nodeCullCallbackData.cxx index e4ee2acdb1..5a9dbc9e0a 100644 --- a/panda/src/pgraphnodes/nodeCullCallbackData.cxx +++ b/panda/src/pgraphnodes/nodeCullCallbackData.cxx @@ -24,7 +24,7 @@ TypeHandle NodeCullCallbackData::_type_handle; * */ void NodeCullCallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << "(" << (void *)_trav << ", " << (void *)&_data << ")"; } diff --git a/panda/src/pgraphnodes/pointLight.cxx b/panda/src/pgraphnodes/pointLight.cxx index 02cc33fda9..8a132515aa 100644 --- a/panda/src/pgraphnodes/pointLight.cxx +++ b/panda/src/pgraphnodes/pointLight.cxx @@ -61,7 +61,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ PointLight:: -PointLight(const string &name) : +PointLight(const std::string &name) : LightLensNode(name) { PT(Lens) lens; lens = new PerspectiveLens(90, 90); @@ -127,7 +127,7 @@ xform(const LMatrix4 &mat) { * */ void PointLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) << "color " << get_color() << "\n"; diff --git a/panda/src/pgraphnodes/rectangleLight.cxx b/panda/src/pgraphnodes/rectangleLight.cxx index 187d35cd2d..1af641788c 100644 --- a/panda/src/pgraphnodes/rectangleLight.cxx +++ b/panda/src/pgraphnodes/rectangleLight.cxx @@ -50,7 +50,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ RectangleLight:: -RectangleLight(const string &name) : +RectangleLight(const std::string &name) : LightLensNode(name) { } @@ -80,7 +80,7 @@ make_copy() const { * */ void RectangleLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { LightLensNode::write(out, indent_level); indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx index 7e374721f6..915845af86 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx @@ -111,7 +111,7 @@ add_node(PandaNode *node) { * Describes all the data collected. */ void SceneGraphAnalyzer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _num_nodes << " total nodes (including " << _num_instances << " instances); " << _num_lod_nodes << " LODNodes.\n"; @@ -366,7 +366,7 @@ collect_statistics(GeomNode *geom_node) { void SceneGraphAnalyzer:: collect_statistics(const Geom *geom) { CPT(GeomVertexData) vdata = geom->get_vertex_data(); - pair result = _vdatas.insert(VDatas::value_type(vdata, VDataTracker())); + std::pair result = _vdatas.insert(VDatas::value_type(vdata, VDataTracker())); if (result.second) { // This is the first time we've encountered this vertex data. ++_num_geom_vertex_datas; diff --git a/panda/src/pgraphnodes/sequenceNode.cxx b/panda/src/pgraphnodes/sequenceNode.cxx index b8f3ffb8e0..06f0019e6d 100644 --- a/panda/src/pgraphnodes/sequenceNode.cxx +++ b/panda/src/pgraphnodes/sequenceNode.cxx @@ -134,7 +134,7 @@ get_visible_child() const { * */ void SequenceNode:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name() << ": "; AnimInterface::output(out); } diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index bdca5406ce..dceb4abf4b 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -47,6 +47,8 @@ #include "config_pgraphnodes.h" #include "pStatTimer.h" +using std::string; + TypeHandle ShaderGenerator::_type_handle; #ifdef HAVE_CG @@ -703,7 +705,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { // Generate the shader's text. - ostringstream text; + std::ostringstream text; text << "//Cg\n"; @@ -1622,7 +1624,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { */ string ShaderGenerator:: combine_mode_as_string(const ShaderKey::TextureInfo &info, TextureStage::CombineMode c_mode, bool alpha, short texindex) { - ostringstream text; + std::ostringstream text; switch (c_mode) { case TextureStage::CM_modulate: text << combine_source_as_string(info, 0, alpha, texindex); @@ -1688,7 +1690,7 @@ combine_source_as_string(const ShaderKey::TextureInfo &info, short num, bool alp c_src = UNPACK_COMBINE_SRC(info._combine_alpha, num); c_op = UNPACK_COMBINE_OP(info._combine_alpha, num); } - ostringstream csource; + std::ostringstream csource; if (c_op == TextureStage::CO_one_minus_src_color || c_op == TextureStage::CO_one_minus_src_alpha) { csource << "saturate(1.0f - "; diff --git a/panda/src/pgraphnodes/sphereLight.cxx b/panda/src/pgraphnodes/sphereLight.cxx index c4cf01be5a..6cd70c2fbb 100644 --- a/panda/src/pgraphnodes/sphereLight.cxx +++ b/panda/src/pgraphnodes/sphereLight.cxx @@ -50,7 +50,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ SphereLight:: -SphereLight(const string &name) : +SphereLight(const std::string &name) : PointLight(name) { } @@ -92,7 +92,7 @@ xform(const LMatrix4 &mat) { * */ void SphereLight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PointLight::write(out, indent_level); indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) diff --git a/panda/src/pgraphnodes/spotlight.cxx b/panda/src/pgraphnodes/spotlight.cxx index 5935485ceb..a7d334e721 100644 --- a/panda/src/pgraphnodes/spotlight.cxx +++ b/panda/src/pgraphnodes/spotlight.cxx @@ -64,7 +64,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { * */ Spotlight:: -Spotlight(const string &name) : +Spotlight(const std::string &name) : LightLensNode(name) { _lenses[0]._lens->set_interocular_distance(0); } @@ -104,7 +104,7 @@ xform(const LMatrix4 &mat) { * */ void Spotlight:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; indent(out, indent_level + 2) << "color " << get_color() << "\n"; diff --git a/panda/src/pgui/pgButton.cxx b/panda/src/pgui/pgButton.cxx index 14821b017e..d1eba186c0 100644 --- a/panda/src/pgui/pgButton.cxx +++ b/panda/src/pgui/pgButton.cxx @@ -26,7 +26,7 @@ TypeHandle PGButton::_type_handle; * */ PGButton:: -PGButton(const string &name) : PGItem(name) +PGButton(const std::string &name) : PGItem(name) { _button_down = false; _click_buttons.insert(MouseButton::one()); @@ -134,7 +134,7 @@ void PGButton:: click(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); - string event = get_click_event(param.get_button()); + std::string event = get_click_event(param.get_button()); play_sound(event); throw_event(event, EventParameter(ep)); @@ -150,7 +150,7 @@ click(const MouseWatcherParameter ¶m) { * to the size of the text. */ void PGButton:: -setup(const string &label, PN_stdfloat bevel) { +setup(const std::string &label, PN_stdfloat bevel) { LightReMutexHolder holder(_lock); clear_state_def(S_ready); clear_state_def(S_depressed); diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index bc8fb204c7..b6a86754d7 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -27,6 +27,11 @@ #include +using std::max; +using std::min; +using std::string; +using std::wstring; + TypeHandle PGEntry::_type_handle; /** diff --git a/panda/src/pgui/pgFrameStyle.cxx b/panda/src/pgui/pgFrameStyle.cxx index 0f0458265c..b4590bf8f0 100644 --- a/panda/src/pgui/pgFrameStyle.cxx +++ b/panda/src/pgui/pgFrameStyle.cxx @@ -25,13 +25,16 @@ #include "geomTristrips.h" #include "geomVertexWriter.h" +using std::max; +using std::min; + // Specifies the UV range of textures applied to the frame. Maybe we'll have // a reason to make this a parameter of the frame style one day, but for now // it's hardcoded to fit the entire texture over the rectangular frame. static const LVecBase4 uv_range = LVecBase4(0.0f, 1.0f, 0.0f, 1.0f); -ostream & -operator << (ostream &out, PGFrameStyle::Type type) { +std::ostream & +operator << (std::ostream &out, PGFrameStyle::Type type) { switch (type) { case PGFrameStyle::T_none: return out << "none"; @@ -92,7 +95,7 @@ get_internal_frame(const LVecBase4 &frame) const { * */ void PGFrameStyle:: -output(ostream &out) const { +output(std::ostream &out) const { out << _type << " color = " << _color << " width = " << _width; if (_visible_scale != LVecBase2(1.0f, 1.0f)) { out << "visible_scale = " << get_visible_scale(); diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index da3dfe86ba..582c12985b 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -35,6 +35,10 @@ #include "audioSound.h" #endif +using std::max; +using std::min; +using std::string; + TypeHandle PGItem::_type_handle; PT(TextNode) PGItem::_text_node; PGItem *PGItem::_focus_item = nullptr; diff --git a/panda/src/pgui/pgMouseWatcherParameter.cxx b/panda/src/pgui/pgMouseWatcherParameter.cxx index 52844f5e23..732d5f01a4 100644 --- a/panda/src/pgui/pgMouseWatcherParameter.cxx +++ b/panda/src/pgui/pgMouseWatcherParameter.cxx @@ -26,6 +26,6 @@ PGMouseWatcherParameter:: * */ void PGMouseWatcherParameter:: -output(ostream &out) const { +output(std::ostream &out) const { MouseWatcherParameter::output(out); } diff --git a/panda/src/pgui/pgScrollFrame.cxx b/panda/src/pgui/pgScrollFrame.cxx index c35ea7b395..a41916d3c9 100644 --- a/panda/src/pgui/pgScrollFrame.cxx +++ b/panda/src/pgui/pgScrollFrame.cxx @@ -19,7 +19,7 @@ TypeHandle PGScrollFrame::_type_handle; * */ PGScrollFrame:: -PGScrollFrame(const string &name) : PGVirtualFrame(name) +PGScrollFrame(const std::string &name) : PGVirtualFrame(name) { set_cull_callback(); diff --git a/panda/src/pgui/pgSliderBar.cxx b/panda/src/pgui/pgSliderBar.cxx index ae7720140a..e085f0f91d 100644 --- a/panda/src/pgui/pgSliderBar.cxx +++ b/panda/src/pgui/pgSliderBar.cxx @@ -20,13 +20,16 @@ #include "transformState.h" #include "mouseButton.h" +using std::max; +using std::min; + TypeHandle PGSliderBar::_type_handle; /** * */ PGSliderBar:: -PGSliderBar(const string &name) +PGSliderBar(const std::string &name) : PGItem(name) { set_cull_callback(); @@ -224,7 +227,7 @@ xform(const LMatrix4 &mat) { void PGSliderBar:: adjust() { LightReMutexHolder holder(_lock); - string event = get_adjust_event(); + std::string event = get_adjust_event(); play_sound(event); throw_event(event); diff --git a/panda/src/pgui/pgTop.cxx b/panda/src/pgui/pgTop.cxx index 172f62123c..3c0948ebda 100644 --- a/panda/src/pgui/pgTop.cxx +++ b/panda/src/pgui/pgTop.cxx @@ -24,7 +24,7 @@ TypeHandle PGTop::_type_handle; * */ PGTop:: -PGTop(const string &name) : +PGTop(const std::string &name) : PandaNode(name) { set_cull_callback(); diff --git a/panda/src/pgui/pgVirtualFrame.cxx b/panda/src/pgui/pgVirtualFrame.cxx index b6a6d195b0..01013fd87f 100644 --- a/panda/src/pgui/pgVirtualFrame.cxx +++ b/panda/src/pgui/pgVirtualFrame.cxx @@ -21,7 +21,7 @@ TypeHandle PGVirtualFrame::_type_handle; * */ PGVirtualFrame:: -PGVirtualFrame(const string &name) : PGItem(name) +PGVirtualFrame(const std::string &name) : PGItem(name) { _has_clip_frame = false; _clip_frame.set(0.0f, 0.0f, 0.0f, 0.0f); diff --git a/panda/src/pgui/pgWaitBar.cxx b/panda/src/pgui/pgWaitBar.cxx index 2f6f50a557..8348b692dc 100644 --- a/panda/src/pgui/pgWaitBar.cxx +++ b/panda/src/pgui/pgWaitBar.cxx @@ -22,7 +22,7 @@ TypeHandle PGWaitBar::_type_handle; * */ PGWaitBar:: -PGWaitBar(const string &name) : PGItem(name) +PGWaitBar(const std::string &name) : PGItem(name) { set_cull_callback(); @@ -147,7 +147,7 @@ update() { // And scale the bar according to our value. PN_stdfloat frac = _value / _range; - frac = max(min(frac, (PN_stdfloat)1.0), (PN_stdfloat)0.0); + frac = std::max(std::min(frac, (PN_stdfloat)1.0), (PN_stdfloat)0.0); bar_frame[1] = bar_frame[0] + frac * (bar_frame[1] - bar_frame[0]); _bar = _bar_style.generate_into(root, bar_frame, 1); diff --git a/panda/src/physics/actorNode.cxx b/panda/src/physics/actorNode.cxx index b216036009..ac9a03a69d 100644 --- a/panda/src/physics/actorNode.cxx +++ b/panda/src/physics/actorNode.cxx @@ -23,7 +23,7 @@ TypeHandle ActorNode::_type_handle; * Constructor */ ActorNode:: -ActorNode(const string &name) : +ActorNode(const std::string &name) : PhysicalNode(name) { _contact_vector = LVector3::zero(); add_physical(new Physical(1, true)); @@ -120,7 +120,7 @@ transform_changed() { * Write a string representation of this instance to . */ void ActorNode:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ActorNode:\n"; out.width(indent+2); out<<""; out<<"_ok_to_callback "<<_ok_to_callback<<"\n"; diff --git a/panda/src/physics/angularEulerIntegrator.cxx b/panda/src/physics/angularEulerIntegrator.cxx index 1ca581eaf6..642c2c6b8b 100644 --- a/panda/src/physics/angularEulerIntegrator.cxx +++ b/panda/src/physics/angularEulerIntegrator.cxx @@ -142,7 +142,7 @@ child_integrate(Physical *physical, * Write a string representation of this instance to . */ void AngularEulerIntegrator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"AngularEulerIntegrator (id "<. */ void AngularEulerIntegrator:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularEulerIntegrator:\n"; AngularIntegrator::write(out, indent+2); diff --git a/panda/src/physics/angularForce.cxx b/panda/src/physics/angularForce.cxx index 06c71289ae..3be7eafff5 100644 --- a/panda/src/physics/angularForce.cxx +++ b/panda/src/physics/angularForce.cxx @@ -59,7 +59,7 @@ is_linear() const { * Write a string representation of this instance to . */ void AngularForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"AngularForce (id "<. */ void AngularForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularForce (id "<. */ void AngularIntegrator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"AngularIntegrator"; #endif //] NDEBUG @@ -59,7 +59,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularIntegrator:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularIntegrator:\n"; out.width(indent+2); out<<""; out<<"_max_angular_dt "<<_max_angular_dt<<" (class const)\n"; diff --git a/panda/src/physics/angularVectorForce.cxx b/panda/src/physics/angularVectorForce.cxx index 736deec04f..f917eaaba7 100644 --- a/panda/src/physics/angularVectorForce.cxx +++ b/panda/src/physics/angularVectorForce.cxx @@ -68,7 +68,7 @@ get_child_quat(const PhysicsObject *) { * Write a string representation of this instance to . */ void AngularVectorForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"AngularVectorForce"; #endif //] NDEBUG @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularVectorForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularVectorForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/baseForce.cxx b/panda/src/physics/baseForce.cxx index c06ba12180..18bc3ef5e1 100644 --- a/panda/src/physics/baseForce.cxx +++ b/panda/src/physics/baseForce.cxx @@ -48,7 +48,7 @@ BaseForce:: * Write a string representation of this instance to . */ void BaseForce:: -output(ostream &out) const { +output(std::ostream &out) const { out << "BaseForce (id " << this << ")"; } @@ -56,7 +56,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseForce:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "BaseForce (id " << this << "):\n"; diff --git a/panda/src/physics/baseIntegrator.cxx b/panda/src/physics/baseIntegrator.cxx index ca5ec4faad..33bc0b72cb 100644 --- a/panda/src/physics/baseIntegrator.cxx +++ b/panda/src/physics/baseIntegrator.cxx @@ -16,6 +16,8 @@ #include "forceNode.h" #include "nodePath.h" +using std::ostream; + /** * constructor */ diff --git a/panda/src/physics/forceNode.cxx b/panda/src/physics/forceNode.cxx index 326962b7c1..c8f744f777 100644 --- a/panda/src/physics/forceNode.cxx +++ b/panda/src/physics/forceNode.cxx @@ -20,7 +20,7 @@ TypeHandle ForceNode::_type_handle; * default constructor */ ForceNode:: -ForceNode(const string &name) : +ForceNode(const std::string &name) : PandaNode(name) { } @@ -124,7 +124,7 @@ remove_force(size_t index) { * Write a string representation of this instance to . */ void ForceNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); out<<" ("<<_forces.size()<<" forces)"; } @@ -133,7 +133,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ForceNode:: -write_forces(ostream &out, int indent) const { +write_forces(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_forces ("<<_forces.size()<<" forces)"<<"\n"; for (ForceVector::const_iterator i=_forces.begin(); @@ -149,7 +149,7 @@ write_forces(ostream &out, int indent) const { * Write a string representation of this instance to . */ void ForceNode:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ForceNode (id "<. */ void LinearControlForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearControlForce"; #endif //] NDEBUG @@ -81,7 +81,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearControlForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearControlForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/linearCylinderVortexForce.cxx b/panda/src/physics/linearCylinderVortexForce.cxx index ab91296af0..c1abcc6c4d 100644 --- a/panda/src/physics/linearCylinderVortexForce.cxx +++ b/panda/src/physics/linearCylinderVortexForce.cxx @@ -117,7 +117,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearCylinderVortexForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearCylinderVortexForce"; #endif //] NDEBUG @@ -127,7 +127,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearCylinderVortexForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearCylinderVortexForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearDistanceForce.cxx b/panda/src/physics/linearDistanceForce.cxx index b48907feeb..3a7349f094 100644 --- a/panda/src/physics/linearDistanceForce.cxx +++ b/panda/src/physics/linearDistanceForce.cxx @@ -47,7 +47,7 @@ LinearDistanceForce:: * Write a string representation of this instance to . */ void LinearDistanceForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearDistanceForce"; #endif //] NDEBUG @@ -57,7 +57,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearDistanceForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearDistanceForce:\n"; out.width(indent+2); out<<""; out<<"_force_center "<<_force_center<<"\n"; diff --git a/panda/src/physics/linearEulerIntegrator.cxx b/panda/src/physics/linearEulerIntegrator.cxx index 5095937a48..f9801e3405 100644 --- a/panda/src/physics/linearEulerIntegrator.cxx +++ b/panda/src/physics/linearEulerIntegrator.cxx @@ -189,7 +189,7 @@ child_integrate(Physical *physical, * Write a string representation of this instance to . */ void LinearEulerIntegrator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearEulerIntegrator"; #endif //] NDEBUG @@ -199,7 +199,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearEulerIntegrator:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearEulerIntegrator:\n"; diff --git a/panda/src/physics/linearForce.cxx b/panda/src/physics/linearForce.cxx index e7481a2703..cef7f1e543 100644 --- a/panda/src/physics/linearForce.cxx +++ b/panda/src/physics/linearForce.cxx @@ -82,7 +82,7 @@ is_linear() const { * Write a string representation of this instance to . */ void LinearForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearForce (id "<. */ void LinearForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearForce (id "<. */ void LinearFrictionForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearFrictionForce"; #endif //] NDEBUG @@ -83,7 +83,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearFrictionForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearFrictionForce:\n"; out.width(indent+2); out<<""; out<<"_coef "<<_coef<<":\n"; diff --git a/panda/src/physics/linearIntegrator.cxx b/panda/src/physics/linearIntegrator.cxx index 9efd0a3c1b..d8841cee9c 100644 --- a/panda/src/physics/linearIntegrator.cxx +++ b/panda/src/physics/linearIntegrator.cxx @@ -68,7 +68,7 @@ integrate(Physical *physical, LinearForceVector &forces, * Write a string representation of this instance to . */ void LinearIntegrator:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearIntegrator"; #endif //] NDEBUG @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearIntegrator:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearIntegrator:\n"; out.width(indent+2); out<<""; out<<"_max_linear_dt "<<_max_linear_dt<<" (class static)\n"; diff --git a/panda/src/physics/linearJitterForce.cxx b/panda/src/physics/linearJitterForce.cxx index 80809a0f28..397092a807 100644 --- a/panda/src/physics/linearJitterForce.cxx +++ b/panda/src/physics/linearJitterForce.cxx @@ -58,7 +58,7 @@ get_child_vector(const PhysicsObject *) { * Write a string representation of this instance to . */ void LinearJitterForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearJitterForce"; #endif //] NDEBUG @@ -68,7 +68,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearJitterForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearJitterForce:\n"; LinearRandomForce::write(out, indent+2); diff --git a/panda/src/physics/linearNoiseForce.cxx b/panda/src/physics/linearNoiseForce.cxx index b86754b8fe..9873494480 100644 --- a/panda/src/physics/linearNoiseForce.cxx +++ b/panda/src/physics/linearNoiseForce.cxx @@ -136,7 +136,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearNoiseForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<""<<"LinearNoiseForce"; #endif //] NDEBUG @@ -146,7 +146,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearNoiseForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearNoiseForce:"; diff --git a/panda/src/physics/linearRandomForce.cxx b/panda/src/physics/linearRandomForce.cxx index f961fdba4e..f234b174bd 100644 --- a/panda/src/physics/linearRandomForce.cxx +++ b/panda/src/physics/linearRandomForce.cxx @@ -50,7 +50,7 @@ bounded_rand() { * Write a string representation of this instance to . */ void LinearRandomForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearRandomForce"; #endif //] NDEBUG @@ -60,7 +60,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearRandomForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearRandomForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearSinkForce.cxx b/panda/src/physics/linearSinkForce.cxx index 066fc64bef..ab1268cd5c 100644 --- a/panda/src/physics/linearSinkForce.cxx +++ b/panda/src/physics/linearSinkForce.cxx @@ -68,7 +68,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearSinkForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearSinkForce"; #endif //] NDEBUG @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearSinkForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearSinkForce:\n"; LinearDistanceForce::write(out, indent+2); diff --git a/panda/src/physics/linearSourceForce.cxx b/panda/src/physics/linearSourceForce.cxx index 87e8d4e6ef..4bb674dbad 100644 --- a/panda/src/physics/linearSourceForce.cxx +++ b/panda/src/physics/linearSourceForce.cxx @@ -68,7 +68,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearSourceForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearSourceForce"; #endif //] NDEBUG @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearSourceForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearSourceForce:\n"; LinearDistanceForce::write(out, indent+2); diff --git a/panda/src/physics/linearUserDefinedForce.cxx b/panda/src/physics/linearUserDefinedForce.cxx index 8e009aa6d9..2bab34805a 100644 --- a/panda/src/physics/linearUserDefinedForce.cxx +++ b/panda/src/physics/linearUserDefinedForce.cxx @@ -62,7 +62,7 @@ get_child_vector(const PhysicsObject *po) { * Write a string representation of this instance to . */ void LinearUserDefinedForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearUserDefinedForce"; #endif //] NDEBUG @@ -72,7 +72,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearUserDefinedForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearUserDefinedForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearVectorForce.cxx b/panda/src/physics/linearVectorForce.cxx index ed2012dccf..3247bb5ad5 100644 --- a/panda/src/physics/linearVectorForce.cxx +++ b/panda/src/physics/linearVectorForce.cxx @@ -74,7 +74,7 @@ get_child_vector(const PhysicsObject *) { * Write a string representation of this instance to . */ void LinearVectorForce:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"LinearVectorForce"; #endif //] NDEBUG @@ -84,7 +84,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearVectorForce:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearVectorForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/physical.cxx b/panda/src/physics/physical.cxx index 1cad199507..afd158ec14 100644 --- a/panda/src/physics/physical.cxx +++ b/panda/src/physics/physical.cxx @@ -16,6 +16,8 @@ #include "physical.h" #include "physicsManager.h" +using std::ostream; + TypeHandle Physical::_type_handle; /** diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index 0166b81ade..0fcabeeb8a 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -21,7 +21,7 @@ TypeHandle PhysicalNode::_type_handle; * default constructor */ PhysicalNode:: -PhysicalNode(const string &name) : +PhysicalNode(const std::string &name) : PandaNode(name) { } @@ -133,7 +133,7 @@ remove_physical(size_t index) { * Write a string representation of this instance to . */ void PhysicalNode:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PhysicalNode:\n"; // PandaNode::write(out, indent+2); diff --git a/panda/src/physics/physicsCollisionHandler.cxx b/panda/src/physics/physicsCollisionHandler.cxx index f3be69e927..7fe69cd997 100644 --- a/panda/src/physics/physicsCollisionHandler.cxx +++ b/panda/src/physics/physicsCollisionHandler.cxx @@ -20,6 +20,9 @@ #include "actorNode.h" #include "dcast.h" +using std::cerr; +using std::endl; + TypeHandle PhysicsCollisionHandler::_type_handle; /** diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index 510d61abce..3286e73539 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -17,6 +17,8 @@ #include #include "pvector.h" +using std::ostream; + ConfigVariableInt PhysicsManager::_random_seed ("physics_manager_random_seed", 139); diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index 96651949d5..79c1829374 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -150,7 +150,7 @@ get_inertial_tensor() const { * Write a string representation of this instance to . */ void PhysicsObject:: -output(ostream &out) const { +output(std::ostream &out) const { #ifndef NDEBUG //[ out<<"PhysicsObject"; #endif //] NDEBUG @@ -160,7 +160,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PhysicsObject:: -write(ostream &out, int indent) const { +write(std::ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsObject "<<_name<<"\n"; diff --git a/panda/src/physics/physicsObjectCollection.cxx b/panda/src/physics/physicsObjectCollection.cxx index 17ce51158d..2b810ef8be 100644 --- a/panda/src/physics/physicsObjectCollection.cxx +++ b/panda/src/physics/physicsObjectCollection.cxx @@ -221,7 +221,7 @@ size() const { * indicated output stream. */ void PhysicsObjectCollection:: -output(ostream &out) const { +output(std::ostream &out) const { if (get_num_physics_objects() == 1) { out << "1 PhysicsObject"; } else { @@ -234,7 +234,7 @@ output(ostream &out) const { * the indicated output stream. */ void PhysicsObjectCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { for (int i = 0; i < get_num_physics_objects(); i++) { indent(out, indent_level) << get_physics_object(i) << "\n"; } diff --git a/panda/src/physics/test_physics.cxx b/panda/src/physics/test_physics.cxx index cb2e2f0c9d..21d248575f 100644 --- a/panda/src/physics/test_physics.cxx +++ b/panda/src/physics/test_physics.cxx @@ -16,6 +16,9 @@ #include "physicsManager.h" #include "forces.h" +using std::cout; +using std::endl; + class Baseball : public Physical { public: int ttl_balls; diff --git a/panda/src/physx/physxContactPair.cxx b/panda/src/physx/physxContactPair.cxx index 3e8d69e34f..fdaf22889c 100644 --- a/panda/src/physx/physxContactPair.cxx +++ b/panda/src/physx/physxContactPair.cxx @@ -25,7 +25,7 @@ PhysxActor *PhysxContactPair:: get_actor_a() const { if (_pair.isDeletedActor[0]) { - physx_cat.warning() << "actor A has been deleted" << endl; + physx_cat.warning() << "actor A has been deleted" << std::endl; return nullptr; } @@ -40,7 +40,7 @@ PhysxActor *PhysxContactPair:: get_actor_b() const { if (_pair.isDeletedActor[1]) { - physx_cat.warning() << "actor B has been deleted" << endl; + physx_cat.warning() << "actor B has been deleted" << std::endl; return nullptr; } diff --git a/panda/src/physx/physxDebugGeomNode.cxx b/panda/src/physx/physxDebugGeomNode.cxx index a609fb2f3c..8b3bd2a1ca 100644 --- a/panda/src/physx/physxDebugGeomNode.cxx +++ b/panda/src/physx/physxDebugGeomNode.cxx @@ -31,7 +31,7 @@ update(NxScene *scenePtr) { const NxDebugRenderable *renderable = scenePtr->getDebugRenderable(); if (!renderable) { remove_all_geoms(); - physx_cat.warning() << "Could no get debug renderable." << endl; + physx_cat.warning() << "Could no get debug renderable." << std::endl; return; } diff --git a/panda/src/physx/physxEnums.cxx b/panda/src/physx/physxEnums.cxx index 172e6013b3..73bf0a8534 100644 --- a/panda/src/physx/physxEnums.cxx +++ b/panda/src/physx/physxEnums.cxx @@ -16,8 +16,13 @@ #include "string_utils.h" #include "config_putil.h" +using std::istream; +using std::ostream; + ostream & operator << (ostream &out, PhysxEnums::PhysxUpAxis axis) { +std::ostream & +operator << (std::ostream &out, PhysxEnums::PhysxUpAxis axis) { switch (axis) { case PhysxEnums::X_up: @@ -36,7 +41,7 @@ operator << (ostream &out, PhysxEnums::PhysxUpAxis axis) { istream & operator >> (istream &in, PhysxEnums::PhysxUpAxis &axis) { - string word; + std::string word; in >> word; if (cmp_nocase(word, "x") == 0) { diff --git a/panda/src/physx/physxGroupsMask.cxx b/panda/src/physx/physxGroupsMask.cxx index e16497350e..6591ab2583 100644 --- a/panda/src/physx/physxGroupsMask.cxx +++ b/panda/src/physx/physxGroupsMask.cxx @@ -13,6 +13,8 @@ #include "physxGroupsMask.h" +using std::string; + /** * Returns a PhysxGroupsMask whose bits are all on. */ @@ -120,7 +122,7 @@ get_bit(unsigned int idx) const { * Writes the PhysxGroupsMask out as a list of ones and zeros. */ void PhysxGroupsMask:: -output(ostream &out) const { +output(std::ostream &out) const { string name0; string name1; diff --git a/panda/src/physx/physxLinearInterpolationValues.cxx b/panda/src/physx/physxLinearInterpolationValues.cxx index 346d30508f..45cd603c64 100644 --- a/panda/src/physx/physxLinearInterpolationValues.cxx +++ b/panda/src/physx/physxLinearInterpolationValues.cxx @@ -32,8 +32,8 @@ insert(float index, float value) { _min = _max = index; } else { - _min = min(_min, index); - _max = max(_max, index); + _min = std::min(_min, index); + _max = std::max(_max, index); } _map[index] = value; } @@ -106,11 +106,11 @@ get_value_at_index(int index) const { * */ void PhysxLinearInterpolationValues:: -output(ostream &out) const { +output(std::ostream &out) const { MapType::const_iterator it = _map.begin(); for (; it != _map.end(); ++it) { - cout << it->first << " -> " << it->second << "\n"; + std::cout << it->first << " -> " << it->second << "\n"; } } diff --git a/panda/src/physx/physxManager.cxx b/panda/src/physx/physxManager.cxx index 56f63149c8..1bba65c280 100644 --- a/panda/src/physx/physxManager.cxx +++ b/panda/src/physx/physxManager.cxx @@ -15,6 +15,8 @@ #include "physxScene.h" #include "physxSceneDesc.h" +using std::endl; + PhysxManager *PhysxManager::_global_ptr; PhysxManager::PhysxOutputStream PhysxManager::_outputStream; @@ -364,7 +366,7 @@ get_internal_version() { v = _sdk->getInternalVersion(apiRev, descRev, branchId); - stringstream version; + std::stringstream version; version << "version:" << (unsigned int)v << " apiRef:" << (unsigned int)apiRev << " descRev:" << (unsigned int)descRev diff --git a/panda/src/physx/physxMask.cxx b/panda/src/physx/physxMask.cxx index f1e31437ea..b9f3437634 100644 --- a/panda/src/physx/physxMask.cxx +++ b/panda/src/physx/physxMask.cxx @@ -70,9 +70,9 @@ get_bit(unsigned int idx) const { * Writes the PhysxMask out as a list of ones and zeros. */ void PhysxMask:: -output(ostream &out) const { +output(std::ostream &out) const { - string name; + std::string name; for (int i=0; i<32; i++) { name += (_mask & (1 << i)) ? '1' : '0'; diff --git a/panda/src/physx/physxMeshPool.cxx b/panda/src/physx/physxMeshPool.cxx index 4bf65576e2..155707cccb 100644 --- a/panda/src/physx/physxMeshPool.cxx +++ b/panda/src/physx/physxMeshPool.cxx @@ -32,12 +32,12 @@ bool PhysxMeshPool:: check_filename(const Filename &fn) { if (!(VirtualFileSystem::get_global_ptr()->exists(fn))) { - physx_cat.error() << "File does not exists: " << fn << endl; + physx_cat.error() << "File does not exists: " << fn << std::endl; return false; } if (!(VirtualFileSystem::get_global_ptr()->is_regular_file(fn))) { - physx_cat.error() << "Not a regular file: " << fn << endl; + physx_cat.error() << "Not a regular file: " << fn << std::endl; return false; } @@ -272,7 +272,7 @@ list_contents() { * */ void PhysxMeshPool:: -list_contents(ostream &out) { +list_contents(std::ostream &out) { out << "PhysX mesh pool contents:\n"; @@ -285,7 +285,7 @@ list_contents(ostream &out) { out << " " << fn.get_fullpath() << " (convex mesh, " << mesh->ptr()->getReferenceCount() - << " references)" << endl; + << " references)" << std::endl; } } diff --git a/panda/src/pipeline/conditionVarDebug.cxx b/panda/src/pipeline/conditionVarDebug.cxx index fb67e7d3c9..bbf9ce0d22 100644 --- a/panda/src/pipeline/conditionVarDebug.cxx +++ b/panda/src/pipeline/conditionVarDebug.cxx @@ -17,6 +17,9 @@ #ifdef DEBUG_THREADS +using std::ostream; +using std::ostringstream; + /** * You must pass in a Mutex to the condition variable constructor. This mutex * may be shared by other condition variables, if desired. It is the caller's diff --git a/panda/src/pipeline/conditionVarDirect.cxx b/panda/src/pipeline/conditionVarDirect.cxx index b3f18f1c0c..c9337e8d9c 100644 --- a/panda/src/pipeline/conditionVarDirect.cxx +++ b/panda/src/pipeline/conditionVarDirect.cxx @@ -20,7 +20,7 @@ * ConditionVarDirect. */ void ConditionVarDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ConditionVar " << (void *)this << " on " << _mutex; } diff --git a/panda/src/pipeline/conditionVarFullDebug.cxx b/panda/src/pipeline/conditionVarFullDebug.cxx index 24f9d1cdc3..746991e79c 100644 --- a/panda/src/pipeline/conditionVarFullDebug.cxx +++ b/panda/src/pipeline/conditionVarFullDebug.cxx @@ -17,6 +17,9 @@ #ifdef DEBUG_THREADS +using std::ostream; +using std::ostringstream; + /** * You must pass in a Mutex to the condition variable constructor. This mutex * may be shared by other condition variables, if desired. It is the caller's diff --git a/panda/src/pipeline/conditionVarFullDirect.cxx b/panda/src/pipeline/conditionVarFullDirect.cxx index 10c30d57c9..04f9c647ed 100644 --- a/panda/src/pipeline/conditionVarFullDirect.cxx +++ b/panda/src/pipeline/conditionVarFullDirect.cxx @@ -20,7 +20,7 @@ * in ConditionVarFullDirect. */ void ConditionVarFullDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ConditionVarFull " << (void *)this << " on " << _mutex; } diff --git a/panda/src/pipeline/cycleData.cxx b/panda/src/pipeline/cycleData.cxx index 7570aabbf8..62359cd451 100644 --- a/panda/src/pipeline/cycleData.cxx +++ b/panda/src/pipeline/cycleData.cxx @@ -79,6 +79,6 @@ get_parent_type() const { * This is useful mainly for debugging. */ void CycleData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_parent_type() << "::CData"; } diff --git a/panda/src/pipeline/externalThread.cxx b/panda/src/pipeline/externalThread.cxx index 411c4f2062..d77fc194ea 100644 --- a/panda/src/pipeline/externalThread.cxx +++ b/panda/src/pipeline/externalThread.cxx @@ -31,7 +31,7 @@ ExternalThread() : Thread("External", "External") { * external thread that is bound via Thread::bind_thread(). */ ExternalThread:: -ExternalThread(const string &name, const string &sync_name) : +ExternalThread(const std::string &name, const std::string &sync_name) : Thread(name, sync_name) { _started = true; diff --git a/panda/src/pipeline/genericThread.cxx b/panda/src/pipeline/genericThread.cxx index b91819f61f..64eb0b4814 100644 --- a/panda/src/pipeline/genericThread.cxx +++ b/panda/src/pipeline/genericThread.cxx @@ -20,7 +20,7 @@ TypeHandle GenericThread::_type_handle; * */ GenericThread:: -GenericThread(const string &name, const string &sync_name) : +GenericThread(const std::string &name, const std::string &sync_name) : Thread(name, sync_name) { _function = nullptr; @@ -31,7 +31,7 @@ GenericThread(const string &name, const string &sync_name) : * */ GenericThread:: -GenericThread(const string &name, const string &sync_name, GenericThread::ThreadFunc *function, void *user_data) : +GenericThread(const std::string &name, const std::string &sync_name, GenericThread::ThreadFunc *function, void *user_data) : Thread(name, sync_name), _function(function), _user_data(user_data) diff --git a/panda/src/pipeline/lightMutexDirect.cxx b/panda/src/pipeline/lightMutexDirect.cxx index ed5d1a30ff..522d361032 100644 --- a/panda/src/pipeline/lightMutexDirect.cxx +++ b/panda/src/pipeline/lightMutexDirect.cxx @@ -20,7 +20,7 @@ * LightMutexDirect. */ void LightMutexDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "LightMutex " << (void *)this; } diff --git a/panda/src/pipeline/lightReMutexDirect.cxx b/panda/src/pipeline/lightReMutexDirect.cxx index fdfcc71cd2..9166f87867 100644 --- a/panda/src/pipeline/lightReMutexDirect.cxx +++ b/panda/src/pipeline/lightReMutexDirect.cxx @@ -21,7 +21,7 @@ * LightReMutexDirect. */ void LightReMutexDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "LightReMutex " << (void *)this; } diff --git a/panda/src/pipeline/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx index a73e1257bc..d1e0194e6f 100644 --- a/panda/src/pipeline/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -17,6 +17,9 @@ #ifdef DEBUG_THREADS +using std::ostream; +using std::ostringstream; + int MutexDebug::_pstats_count = 0; MutexTrueImpl *MutexDebug::_global_lock; @@ -24,7 +27,7 @@ MutexTrueImpl *MutexDebug::_global_lock; * */ MutexDebug:: -MutexDebug(const string &name, bool allow_recursion, bool lightweight) : +MutexDebug(const std::string &name, bool allow_recursion, bool lightweight) : Namable(name), _allow_recursion(allow_recursion), _lightweight(lightweight), @@ -53,7 +56,7 @@ MutexDebug:: if (name_deleted_mutexes) { ostringstream strm; strm << *this; - string name = strm.str(); + std::string name = strm.str(); _deleted_name = strdup((char *)name.c_str()); } diff --git a/panda/src/pipeline/mutexDirect.cxx b/panda/src/pipeline/mutexDirect.cxx index 5f74c67c93..29c0beb9b4 100644 --- a/panda/src/pipeline/mutexDirect.cxx +++ b/panda/src/pipeline/mutexDirect.cxx @@ -20,7 +20,7 @@ * MutexDirect. */ void MutexDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Mutex " << (void *)this; } diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index c12e72114b..763dc3a8d6 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -22,7 +22,7 @@ Pipeline *Pipeline::_render_pipeline = nullptr; * */ Pipeline:: -Pipeline(const string &name, int num_stages) : +Pipeline(const std::string &name, int num_stages) : Namable(name), #ifdef THREADED_PIPELINE _num_stages(num_stages), diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx index fb31088501..714e61c0e4 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx @@ -324,7 +324,7 @@ set_num_stages(int num_stages) { * */ void PipelineCyclerTrueImpl::CyclerMutex:: -output(ostream &out) const { +output(std::ostream &out) const { out << "CyclerMutex "; _cycler->cheat()->output(out); } diff --git a/panda/src/pipeline/psemaphore.cxx b/panda/src/pipeline/psemaphore.cxx index 1142930e3a..9a1e453819 100644 --- a/panda/src/pipeline/psemaphore.cxx +++ b/panda/src/pipeline/psemaphore.cxx @@ -17,7 +17,7 @@ * */ void Semaphore:: -output(ostream &out) const { +output(std::ostream &out) const { MutexHolder holder(_lock); out << "Semaphore, count = " << _count; } diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index ae64aba2a4..ab41070fb8 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -24,7 +24,7 @@ TypeHandle PythonThread::_type_handle; */ PythonThread:: PythonThread(PyObject *function, PyObject *args, - const string &name, const string &sync_name) : + const std::string &name, const std::string &sync_name) : Thread(name, sync_name) { _function = function; diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index b83a2f30a6..7bfdcb8f8d 100644 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -21,7 +21,7 @@ * ReMutexDirect. */ void ReMutexDirect:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ReMutex " << (void *)this; } @@ -146,7 +146,7 @@ do_unlock() { #ifdef _DEBUG if (_locking_thread != Thread::get_current_thread()) { - ostringstream ostr; + std::ostringstream ostr; ostr << *_locking_thread << " attempted to release " << *this << " which it does not own"; nassert_raise(ostr.str()); diff --git a/panda/src/pipeline/test_atomic.cxx b/panda/src/pipeline/test_atomic.cxx index ae371114e4..66ab6c5a14 100644 --- a/panda/src/pipeline/test_atomic.cxx +++ b/panda/src/pipeline/test_atomic.cxx @@ -35,7 +35,7 @@ AtomicAdjust::Integer _num_net_count_incremented = 0; class MyThread : public Thread { public: - MyThread(const string &name) : Thread(name, name) + MyThread(const std::string &name) : Thread(name, name) { } @@ -73,7 +73,7 @@ main(int argc, char *argv[]) { for (int i = 1; i < number_of_threads; ++i) { char name = 'a' + i; - PT(MyThread) thread = new MyThread(string(1, name)); + PT(MyThread) thread = new MyThread(std::string(1, name)); threads.push_back(thread); thread->start(TP_normal, true); } diff --git a/panda/src/pipeline/test_concurrency.cxx b/panda/src/pipeline/test_concurrency.cxx index 9d092d08c8..6f59a025b1 100644 --- a/panda/src/pipeline/test_concurrency.cxx +++ b/panda/src/pipeline/test_concurrency.cxx @@ -50,7 +50,7 @@ volatile MemBlock memblock[number_of_threads]; class MyThread : public Thread { public: - MyThread(const string &name, int index) : + MyThread(const std::string &name, int index) : Thread(name, name), _index(index) { @@ -101,7 +101,7 @@ main(int argc, char *argv[]) { for (int i = 1; i < number_of_threads; ++i) { char name = 'a' + i; Thread::sleep(delay_between_threads); - PT(MyThread) thread = new MyThread(string(1, name), i); + PT(MyThread) thread = new MyThread(std::string(1, name), i); threads.push_back(thread); thread->start(TP_normal, true); } diff --git a/panda/src/pipeline/test_delete.cxx b/panda/src/pipeline/test_delete.cxx index f49606a6f1..3ea431f77b 100644 --- a/panda/src/pipeline/test_delete.cxx +++ b/panda/src/pipeline/test_delete.cxx @@ -80,7 +80,7 @@ TypeHandle Doober::_type_handle; class MyThread : public Thread { public: - MyThread(const string &name) : Thread(name, name) + MyThread(const std::string &name) : Thread(name, name) { } @@ -106,7 +106,7 @@ public: doobers.push_back(new Doober(++counter)); } int num_del = (int)random_f(max_doobers_per_chunk); - num_del = min(num_del, (int)doobers.size()); + num_del = std::min(num_del, (int)doobers.size()); for (int j = 0; j < num_del; ++j) { assert(!doobers.empty()); @@ -137,7 +137,7 @@ main(int argc, char *argv[]) { for (int i = 1; i < number_of_threads; ++i) { char name = 'a' + i; - PT(MyThread) thread = new MyThread(string(1, name)); + PT(MyThread) thread = new MyThread(std::string(1, name)); threads.push_back(thread); thread->start(TP_normal, true); } diff --git a/panda/src/pipeline/test_diners.cxx b/panda/src/pipeline/test_diners.cxx index 27976e3ea5..a5ff82e446 100644 --- a/panda/src/pipeline/test_diners.cxx +++ b/panda/src/pipeline/test_diners.cxx @@ -24,6 +24,8 @@ #include "trueClock.h" #include "pstrtod.h" +using std::cerr; + #ifdef WIN32_VC // Under Windows, the rand() function seems to return a sequence per-thread, // so we use this trick to set each thread to a different seed. @@ -50,7 +52,7 @@ static double random_f(double max) class ChopstickMutex : public Mutex { public: - void output(ostream &out) const { + void output(std::ostream &out) const { out << "chopstick " << _n; } int _n; @@ -121,7 +123,7 @@ public: _id = id; } - virtual void output(ostream &out) const { + virtual void output(std::ostream &out) const { out << "philosopher " << _id; } }; diff --git a/panda/src/pipeline/test_mutex.cxx b/panda/src/pipeline/test_mutex.cxx index f02ccd1434..a0a4dd49c6 100644 --- a/panda/src/pipeline/test_mutex.cxx +++ b/panda/src/pipeline/test_mutex.cxx @@ -22,7 +22,7 @@ static const double thread_duration = 5.0; class MyThread : public Thread { public: - MyThread(const string &name, MutexImpl &m1, double period) : + MyThread(const std::string &name, MutexImpl &m1, double period) : Thread(name, name), _m1(m1), _period(period) { @@ -50,11 +50,11 @@ main(int argc, char *argv[]) { _m1.lock(); _m1.unlock(); - cerr << "Making threads.\n"; + std::cerr << "Making threads.\n"; MyThread *a = new MyThread("a", _m1, 1.0); MyThread *b = new MyThread("b", _m1, 0.9); - cerr << "Starting threads.\n"; + std::cerr << "Starting threads.\n"; a->start(TP_normal, true); b->start(TP_normal, true); diff --git a/panda/src/pipeline/test_setjmp.cxx b/panda/src/pipeline/test_setjmp.cxx index 3ce1bcf075..4803ff3fee 100644 --- a/panda/src/pipeline/test_setjmp.cxx +++ b/panda/src/pipeline/test_setjmp.cxx @@ -15,6 +15,8 @@ #include +using std::cerr; + int main(int argc, char *argv[]) { diff --git a/panda/src/pipeline/test_threaddata.cxx b/panda/src/pipeline/test_threaddata.cxx index 2e347823c9..b3d919a827 100644 --- a/panda/src/pipeline/test_threaddata.cxx +++ b/panda/src/pipeline/test_threaddata.cxx @@ -17,12 +17,14 @@ #include "mutexHolder.h" #include "pointerTo.h" +using std::cout; + Mutex *cout_mutex = nullptr; // Test forking a thread with some private data. class ThreadWithData : public Thread { public: - ThreadWithData(const string &name, int parameter); + ThreadWithData(const std::string &name, int parameter); virtual void thread_main(); @@ -32,7 +34,7 @@ private: ThreadWithData:: -ThreadWithData(const string &name, int parameter) : +ThreadWithData(const std::string &name, int parameter) : Thread(name, name), _parameter(parameter) { @@ -60,7 +62,7 @@ int main() { cout << "main beginning.\n"; for (int i = 0; i < 10; i++) { - string name = string("thread_") + (char)(i + 'a'); + std::string name = std::string("thread_") + (char)(i + 'a'); PT(Thread) thread = new ThreadWithData(name, i); if (!thread->start(TP_low, true)) { MutexHolder holder(cout_mutex); diff --git a/panda/src/pipeline/thread.cxx b/panda/src/pipeline/thread.cxx index 3dc5994282..351e316033 100644 --- a/panda/src/pipeline/thread.cxx +++ b/panda/src/pipeline/thread.cxx @@ -36,7 +36,7 @@ TypeHandle Thread::_type_handle; * given the same sync_name, for the benefit of PStats. */ Thread:: -Thread(const string &name, const string &sync_name) : +Thread(const std::string &name, const std::string &sync_name) : Namable(name), _sync_name(sync_name), _impl(this) @@ -87,7 +87,7 @@ Thread:: * case the same pointer will be returned each time). */ PT(Thread) Thread:: -bind_thread(const string &name, const string &sync_name) { +bind_thread(const std::string &name, const std::string &sync_name) { Thread *current_thread = get_current_thread(); if (current_thread != get_external_thread()) { // This thread already has an associated thread. @@ -129,7 +129,7 @@ set_pipeline_stage(int pipeline_stage) { * */ void Thread:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type() << " " << get_name(); } @@ -139,7 +139,7 @@ output(ostream &out) const { * DEBUG_THREADS mode. */ void Thread:: -output_blocker(ostream &out) const { +output_blocker(std::ostream &out) const { #ifdef DEBUG_THREADS if (_blocked_on_mutex != nullptr) { _blocked_on_mutex->output_with_holder(out); @@ -155,7 +155,7 @@ output_blocker(ostream &out) const { * */ void Thread:: -write_status(ostream &out) { +write_status(std::ostream &out) { #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) ThreadImpl::write_status(out); #endif diff --git a/panda/src/pipeline/threadDummyImpl.cxx b/panda/src/pipeline/threadDummyImpl.cxx index 419744a4b5..2d30630d98 100644 --- a/panda/src/pipeline/threadDummyImpl.cxx +++ b/panda/src/pipeline/threadDummyImpl.cxx @@ -28,10 +28,10 @@ /** * */ -string ThreadDummyImpl:: +std::string ThreadDummyImpl:: get_unique_id() const { // In a single-threaded application, this is just the unique process ID. - ostringstream strm; + std::ostringstream strm; #ifdef WIN32 strm << GetCurrentProcessId(); #else diff --git a/panda/src/pipeline/threadPosixImpl.cxx b/panda/src/pipeline/threadPosixImpl.cxx index dcae44e721..0d88c5ebe8 100644 --- a/panda/src/pipeline/threadPosixImpl.cxx +++ b/panda/src/pipeline/threadPosixImpl.cxx @@ -177,9 +177,9 @@ join() { /** * */ -string ThreadPosixImpl:: +std::string ThreadPosixImpl:: get_unique_id() const { - ostringstream strm; + std::ostringstream strm; strm << getpid() << "." << _thread; return strm.str(); @@ -193,7 +193,7 @@ get_unique_id() const { bool ThreadPosixImpl:: attach_java_vm() { JNIEnv *env; - string thread_name = _parent_obj->get_name(); + std::string thread_name = _parent_obj->get_name(); JavaVMAttachArgs args; args.version = JNI_VERSION_1_2; args.name = thread_name.c_str(); diff --git a/panda/src/pipeline/threadPriority.cxx b/panda/src/pipeline/threadPriority.cxx index 0402273099..3d9c55fe21 100644 --- a/panda/src/pipeline/threadPriority.cxx +++ b/panda/src/pipeline/threadPriority.cxx @@ -15,6 +15,10 @@ #include "pnotify.h" // nassertr #include "pipeline.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, ThreadPriority pri) { switch (pri) { diff --git a/panda/src/pipeline/threadSimpleImpl.cxx b/panda/src/pipeline/threadSimpleImpl.cxx index 1bde4c7ca0..a631421503 100644 --- a/panda/src/pipeline/threadSimpleImpl.cxx +++ b/panda/src/pipeline/threadSimpleImpl.cxx @@ -178,9 +178,9 @@ preempt() { /** * */ -string ThreadSimpleImpl:: +std::string ThreadSimpleImpl:: get_unique_id() const { - ostringstream strm; + std::ostringstream strm; #ifdef WIN32 strm << GetCurrentProcessId(); #else diff --git a/panda/src/pipeline/threadSimpleManager.cxx b/panda/src/pipeline/threadSimpleManager.cxx index 8b58579642..4d9890dfd4 100644 --- a/panda/src/pipeline/threadSimpleManager.cxx +++ b/panda/src/pipeline/threadSimpleManager.cxx @@ -377,7 +377,7 @@ system_sleep(double seconds) { * Writes a list of threads running and threads blocked. */ void ThreadSimpleManager:: -write_status(ostream &out) const { +write_status(std::ostream &out) const { out << "Currently running: " << *_current_thread->_parent_obj << "\n"; out << "Ready:"; @@ -663,7 +663,7 @@ do_timeslice_accounting(ThreadSimpleImpl *thread, double now) { // Clamp the elapsed time at 0. (If it's less than 0, the clock is running // backwards, ick.) - elapsed = max(elapsed, 0.0); + elapsed = std::max(elapsed, 0.0); unsigned int ticks = (unsigned int)(elapsed * _tick_scale + 0.5); thread->_run_ticks += ticks; diff --git a/panda/src/pipeline/threadWin32Impl.cxx b/panda/src/pipeline/threadWin32Impl.cxx index 998dc44b8c..4671787918 100644 --- a/panda/src/pipeline/threadWin32Impl.cxx +++ b/panda/src/pipeline/threadWin32Impl.cxx @@ -125,9 +125,9 @@ join() { /** * */ -string ThreadWin32Impl:: +std::string ThreadWin32Impl:: get_unique_id() const { - ostringstream strm; + std::ostringstream strm; strm << GetCurrentProcessId() << "." << _thread_id; return strm.str(); diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index 97a151f324..abe2845add 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -24,6 +24,11 @@ #include "string_utils.h" #include "look_at.h" +using std::istream; +using std::max; +using std::min; +using std::ostream; + /** * */ diff --git a/panda/src/pnmimage/pnm-image-filter.cxx b/panda/src/pnmimage/pnm-image-filter.cxx index 63398ad3c1..6ca6a145d6 100644 --- a/panda/src/pnmimage/pnm-image-filter.cxx +++ b/panda/src/pnmimage/pnm-image-filter.cxx @@ -37,6 +37,9 @@ #include "pnmImage.h" #include "pfmFile.h" +using std::max; +using std::min; + // WorkType is an abstraction that allows the filtering process to be // recompiled to use either floating-point or integer arithmetic. On SGI // machines, there doesn't seem to be much of a performance difference-- if diff --git a/panda/src/pnmimage/pnmBrush.cxx b/panda/src/pnmimage/pnmBrush.cxx index 64dffab3cb..94d1799fe7 100644 --- a/panda/src/pnmimage/pnmBrush.cxx +++ b/panda/src/pnmimage/pnmBrush.cxx @@ -16,6 +16,9 @@ #include "config_pnmimage.h" #include "cmath.h" +using std::max; +using std::min; + // A PNMTransparentBrush doesn't draw or fill anything. class EXPCL_PANDA_PNMIMAGE PNMTransparentBrush : public PNMBrush { public: diff --git a/panda/src/pnmimage/pnmFileType.cxx b/panda/src/pnmimage/pnmFileType.cxx index 80fae2784a..c400db9d53 100644 --- a/panda/src/pnmimage/pnmFileType.cxx +++ b/panda/src/pnmimage/pnmFileType.cxx @@ -18,6 +18,8 @@ #include "bamReader.h" #include "bamWriter.h" +using std::string; + bool PNMFileType::_did_init_pnm = false; TypeHandle PNMFileType::_type_handle; @@ -91,7 +93,7 @@ matches_magic_number(const string &) const { * returns NULL. */ PNMReader *PNMFileType:: -make_reader(istream *, bool, const string &) { +make_reader(std::istream *, bool, const string &) { return nullptr; } @@ -101,7 +103,7 @@ make_reader(istream *, bool, const string &) { * NULL. */ PNMWriter *PNMFileType:: -make_writer(ostream *, bool) { +make_writer(std::ostream *, bool) { return nullptr; } diff --git a/panda/src/pnmimage/pnmFileTypeRegistry.cxx b/panda/src/pnmimage/pnmFileTypeRegistry.cxx index c1dd16f211..d290f52bdc 100644 --- a/panda/src/pnmimage/pnmFileTypeRegistry.cxx +++ b/panda/src/pnmimage/pnmFileTypeRegistry.cxx @@ -21,6 +21,8 @@ #include +using std::string; + PNMFileTypeRegistry *PNMFileTypeRegistry::_global_ptr; /** @@ -243,7 +245,7 @@ get_type_by_handle(TypeHandle handle) const { * one per line. */ void PNMFileTypeRegistry:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (_types.empty()) { indent(out, indent_level) << "(No image types are known).\n"; } else { @@ -252,7 +254,7 @@ write(ostream &out, int indent_level) const { PNMFileType *type = (*ti); string name = type->get_name(); indent(out, indent_level) << name; - indent(out, max(30 - (int)name.length(), 0)) << " "; + indent(out, std::max(30 - (int)name.length(), 0)) << " "; int num_extensions = type->get_num_extensions(); if (num_extensions == 1) { diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index ce9871d6f0..9c6c3a68d9 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -21,6 +21,9 @@ #include "stackedPerlinNoise2.h" #include +using std::max; +using std::min; + /** * */ @@ -295,10 +298,10 @@ read(const Filename &filename, PNMFileType *type, bool report_unknown_type) { * Returns true if successful, false on error. */ bool PNMImage:: -read(istream &data, const string &filename, PNMFileType *type, +read(std::istream &data, const std::string &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = PNMImageHeader::make_reader - (&data, false, filename, string(), type, report_unknown_type); + (&data, false, filename, std::string(), type, report_unknown_type); if (reader == nullptr) { clear(); return false; @@ -402,7 +405,7 @@ write(const Filename &filename, PNMFileType *type) const { * write. */ bool PNMImage:: -write(ostream &data, const string &filename, PNMFileType *type) const { +write(std::ostream &data, const std::string &filename, PNMFileType *type) const { if (!is_valid()) { return false; } diff --git a/panda/src/pnmimage/pnmImageHeader.cxx b/panda/src/pnmimage/pnmImageHeader.cxx index b51e2d8c4d..c7a6129bd7 100644 --- a/panda/src/pnmimage/pnmImageHeader.cxx +++ b/panda/src/pnmimage/pnmImageHeader.cxx @@ -20,6 +20,10 @@ #include "virtualFileSystem.h" #include "zStream.h" +using std::istream; +using std::ostream; +using std::string; + /** * Opens up the image file and tries to read its header information to * determine its size, number of channels, etc. If successful, updates the @@ -84,7 +88,7 @@ make_reader(const Filename &filename, PNMFileType *type, if (filename == "-") { owns_file = false; - file = &cin; + file = &std::cin; if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() @@ -251,7 +255,7 @@ make_writer(const Filename &filename, PNMFileType *type) const { if (filename == "-") { owns_file = false; - file = &cout; + file = &std::cout; if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() diff --git a/panda/src/pnmimage/pnmReader.cxx b/panda/src/pnmimage/pnmReader.cxx index b40bf3ce40..938648e0a1 100644 --- a/panda/src/pnmimage/pnmReader.cxx +++ b/panda/src/pnmimage/pnmReader.cxx @@ -249,7 +249,7 @@ get_reduction_shift(int orig_size, int new_size) { return 0; } - int reduction = max(orig_size / new_size, 1); + int reduction = std::max(orig_size / new_size, 1); int shift = 0; diff --git a/panda/src/pnmimage/pnmbitio.cxx b/panda/src/pnmimage/pnmbitio.cxx index 2dcbfbfacc..fbd9bff5d4 100644 --- a/panda/src/pnmimage/pnmbitio.cxx +++ b/panda/src/pnmimage/pnmbitio.cxx @@ -15,6 +15,10 @@ #include "pnmbitio.h" #include + +using std::istream; +using std::ostream; + struct bitstream { istream *inf; diff --git a/panda/src/pnmimage/pnmimage_base.cxx b/panda/src/pnmimage/pnmimage_base.cxx index 075b45dcd2..0fb9bedfc6 100644 --- a/panda/src/pnmimage/pnmimage_base.cxx +++ b/panda/src/pnmimage/pnmimage_base.cxx @@ -19,6 +19,9 @@ #include #include // for sprintf() +using std::istream; +using std::ostream; + /** * Outputs the given printf-style message to the user and returns. diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index 7661696980..551c351c43 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -36,6 +36,10 @@ #error Buildsystem error: BUILDING_PANDA_PNMIMAGETYPES not defined #endif +using std::istream; +using std::ostream; +using std::string; + Configure(config_pnmimagetypes); NotifyCategoryDefName(pnmimage_sgi, "sgi", pnmimage_cat); NotifyCategoryDefName(pnmimage_tga, "tga", pnmimage_cat); diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx index 9ff4240ecf..688275edf7 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx @@ -20,6 +20,8 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::string; + static const char * const extensions_bmp[] = { "bmp" }; @@ -96,7 +98,7 @@ matches_magic_number(const string &magic_number) const { * returns NULL. */ PNMReader *PNMFileTypeBMP:: -make_reader(istream *file, bool owns_file, const string &magic_number) { +make_reader(std::istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } @@ -107,7 +109,7 @@ make_reader(istream *file, bool owns_file, const string &magic_number) { * NULL. */ PNMWriter *PNMFileTypeBMP:: -make_writer(ostream *file, bool owns_file) { +make_writer(std::ostream *file, bool owns_file) { init_pnm(); return new Writer(this, file, owns_file); } diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx index 394445f257..7b2fc6e18c 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx @@ -19,6 +19,9 @@ #include "bmp.h" #include "pnmbitio.h" +using std::istream; +using std::string; + // Much code in this file is borrowed from Netpbm, specifically bmptoppm.c. /* * bmptoppm.c - Converts from a Microsoft Windows or OS/2 .BMP file to a diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx index b624314b6b..2c592afa9d 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx @@ -45,6 +45,8 @@ #define MAXCOLORS 256 +using std::ostream; + /* * Utilities */ diff --git a/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx b/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx index 157bd716be..83d7cf5bb4 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx @@ -30,6 +30,10 @@ #define IMATH_NAMESPACE Imath #endif +using std::istream; +using std::ostream; +using std::string; + TypeHandle PNMFileTypeEXR::_type_handle; static const char * const extensions_exr[] = { diff --git a/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx b/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx index 477f921bd2..3e20f41a87 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx @@ -25,6 +25,10 @@ // than this, it must be bogus. #define INSANE_SIZE 20000 +using std::istream; +using std::ostream; +using std::string; + static const char * const extensions_img[] = { "img" }; diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx index 555fe29074..d7793be7fe 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx @@ -20,6 +20,8 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::string; + static const char *const extensions_jpg[] = { "jpg", "jpeg" }; @@ -97,7 +99,7 @@ matches_magic_number(const string &magic_number) const { * returns NULL. */ PNMReader *PNMFileTypeJPG:: -make_reader(istream *file, bool owns_file, const string &magic_number) { +make_reader(std::istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } @@ -108,7 +110,7 @@ make_reader(istream *file, bool owns_file, const string &magic_number) { * NULL. */ PNMWriter *PNMFileTypeJPG:: -make_writer(ostream *file, bool owns_file) { +make_writer(std::ostream *file, bool owns_file) { init_pnm(); return new Writer(this, file, owns_file); } diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx index 4525dda22a..2789583e7f 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx @@ -49,7 +49,7 @@ extern "C" { typedef struct { struct jpeg_source_mgr pub; /* public fields */ - istream * infile; /* source stream */ + std::istream * infile; /* source stream */ JOCTET * buffer; /* start of buffer */ boolean start_of_file; /* have we gotten any data yet? */ } my_source_mgr; @@ -205,7 +205,7 @@ term_source (j_decompress_ptr cinfo) */ GLOBAL(void) -jpeg_istream_src (j_decompress_ptr cinfo, istream * infile) +jpeg_istream_src (j_decompress_ptr cinfo, std::istream * infile) { my_src_ptr src; @@ -245,11 +245,11 @@ jpeg_istream_src (j_decompress_ptr cinfo, istream * infile) * */ PNMFileTypeJPG::Reader:: -Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : +Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number) : PNMReader(type, file, owns_file) { // Hope we can putback() more than one character. - for (string::reverse_iterator mi = magic_number.rbegin(); + for (std::string::reverse_iterator mi = magic_number.rbegin(); mi != magic_number.rend(); ++mi) { _file->putback(*mi); @@ -308,7 +308,7 @@ prepare_read() { // Attempt to get the scale close to our target scale. int x_reduction = _cinfo.image_width / _read_x_size; int y_reduction = _cinfo.image_height / _read_y_size; - _cinfo.scale_denom = max(min(x_reduction, y_reduction), 1); + _cinfo.scale_denom = std::max(std::min(x_reduction, y_reduction), 1); } /* Step 7: Start decompressor */ @@ -413,7 +413,7 @@ read_data(xel *array, xelval *) { */ if (_jerr.pub.num_warnings) { pnmimage_jpg_cat.warning() - << "Jpeg data may be corrupt" << endl; + << "Jpeg data may be corrupt" << std::endl; } return _y_size; diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx index 5308a3417e..6f0285a841 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx @@ -53,7 +53,7 @@ extern "C" { typedef struct { struct jpeg_destination_mgr pub; /* public fields */ - ostream * outfile; /* target stream */ + std::ostream * outfile; /* target stream */ JOCTET * buffer; /* start of buffer */ } my_destination_mgr; @@ -156,7 +156,7 @@ term_destination (j_compress_ptr cinfo) */ GLOBAL(void) -jpeg_ostream_dest (j_compress_ptr cinfo, ostream * outfile) +jpeg_ostream_dest (j_compress_ptr cinfo, std::ostream * outfile) { my_dest_ptr dest; @@ -187,7 +187,7 @@ jpeg_ostream_dest (j_compress_ptr cinfo, ostream * outfile) * */ PNMFileTypeJPG::Writer:: -Writer(PNMFileType *type, ostream *file, bool owns_file) : +Writer(PNMFileType *type, std::ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { } diff --git a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx index 3c2bb2b1d0..799f4d1dce 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx @@ -21,6 +21,10 @@ #include "bamReader.h" #include "thread.h" +using std::istream; +using std::ostream; +using std::string; + static const char * const extensions_png[] = { "png" }; diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx index 7fd918aa73..cdc1e62f93 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx @@ -20,6 +20,10 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::istream; +using std::ostream; +using std::string; + static const char * const extensions_PNM[] = { "pbm", "pgm", "ppm", "pnm" }; diff --git a/panda/src/pnmimagetypes/pnmFileTypePfm.cxx b/panda/src/pnmimagetypes/pnmFileTypePfm.cxx index 71652689ec..89324f3c61 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePfm.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePfm.cxx @@ -18,6 +18,10 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle PNMFileTypePfm::_type_handle; /** diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx index e35880daa3..e2a99eb378 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx @@ -21,6 +21,8 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::string; + static const char * const extensions_sgi[] = { "rgb", "rgba", "sgi" }; @@ -100,7 +102,7 @@ matches_magic_number(const string &magic_number) const { * returns NULL. */ PNMReader *PNMFileTypeSGI:: -make_reader(istream *file, bool owns_file, const string &magic_number) { +make_reader(std::istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } @@ -111,7 +113,7 @@ make_reader(istream *file, bool owns_file, const string &magic_number) { * NULL. */ PNMWriter *PNMFileTypeSGI:: -make_writer(ostream *file, bool owns_file) { +make_writer(std::ostream *file, bool owns_file) { init_pnm(); return new Writer(this, file, owns_file); } diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx index 2f56552d18..fafb625fac 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx @@ -23,6 +23,9 @@ #include "pnotify.h" +using std::istream; +using std::string; + // Much code in this file is borrowed from Netpbm, specifically sgitopnm.c. /* sgitopnm.c - read an SGI image and and produce a portable anymap @@ -121,7 +124,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : _x_size = head.xsize; _y_size = head.ysize; - _num_channels = min((int)head.zsize, 4); + _num_channels = std::min((int)head.zsize, 4); bpc = head.bpc; current_row = _y_size - 1; diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx index faf45cc093..f5b143e867 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx @@ -49,6 +49,8 @@ #define MAXVAL_BYTE 255 #define MAXVAL_WORD 65535 +using std::ostream; + inline void put_byte(ostream *out_file, unsigned char b) { out_file->put(b); diff --git a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx index e2d12c3e33..d67a22fa53 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx @@ -20,6 +20,10 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" +using std::istream; +using std::ostream; +using std::string; + static const float imageVersionNumber = 3.0; static const int imageCommentLength = 80; static const char imageComment[imageCommentLength+1] = @@ -322,7 +326,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : read_float(_file); // Skip comment - _file->seekg(imageCommentLength, ios::cur); + _file->seekg(imageCommentLength, std::ios::cur); char pict_id[4]; _file->read(pict_id, 4); diff --git a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx index 93599cac83..96610157a4 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx @@ -60,6 +60,10 @@ #include "stb_image.h" +using std::ios; +using std::istream; +using std::string; + static const char *const stb_extensions[] = { // Expose the extensions that we don't already expose through other loaders. #if !defined(HAVE_JPEG) && !defined(ANDROID) @@ -300,7 +304,7 @@ read_pfm(PfmFile &pfm) { } else { // We need to reinitialize the context. _file->seekg(0, ios::beg); - if (_file->tellg() != (streampos)0) { + if (_file->tellg() != (std::streampos)0) { pnmimage_cat.error() << "Could not reposition file pointer to the beginning.\n"; return false; @@ -482,7 +486,7 @@ read_data(xel *array, xelval *alpha) { } else { // We need to reinitialize the context. _file->seekg(0, ios::beg); - if (_file->tellg() != (streampos)0) { + if (_file->tellg() != (std::streampos)0) { pnmimage_cat.error() << "Could not reposition file pointer to the beginning.\n"; return false; diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index 3be6bd1ff0..18fc389150 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -52,6 +52,10 @@ #include +using std::istream; +using std::ostream; +using std::string; + static const char * const extensions_tga[] = { "tga" }; diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx index e2d5cf0fa1..3c4634055d 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx @@ -28,6 +28,11 @@ #define int32 tiff_int32 #define uint32 tiff_uint32 +using std::ios; +using std::istream; +using std::ostream; +using std::string; + extern "C" { #include #include @@ -1046,13 +1051,13 @@ write_data(xel *array, xelval *alpha) { bytesperrow = _x_size * samplesperpixel; } else if ( grayscale ) { samplesperpixel = 1; - bitspersample = min(8, pm_maxvaltobits(_maxval)); + bitspersample = std::min(8, pm_maxvaltobits(_maxval)); photometric = PHOTOMETRIC_MINISBLACK; i = 8 / bitspersample; bytesperrow = ( _x_size + i - 1 ) / i; } else { samplesperpixel = 1; - bitspersample = min(8, pm_maxvaltobits(_maxval)); + bitspersample = std::min(8, pm_maxvaltobits(_maxval)); photometric = PHOTOMETRIC_PALETTE; bytesperrow = _x_size; } diff --git a/panda/src/pnmtext/freetypeFont.cxx b/panda/src/pnmtext/freetypeFont.cxx index 78a7455b96..f922943b7f 100644 --- a/panda/src/pnmtext/freetypeFont.cxx +++ b/panda/src/pnmtext/freetypeFont.cxx @@ -25,6 +25,10 @@ #undef interface // I don't know where this symbol is defined, but it interferes with FreeType. #include FT_OUTLINE_H +using std::istream; +using std::ostream; +using std::string; + // This constant determines how big a particular point size font appears to // be. By convention, 10 points is 1 unit (e.g. 1 foot) high. const PN_stdfloat FreetypeFont::_points_per_unit = 10.0f; @@ -461,7 +465,7 @@ render_distance_field(PNMImage &image, int outline, int min_x, int min_y) { } } else { - dist_sq = min((p - begin).length_squared(), (p - end).length_squared()); + dist_sq = std::min((p - begin).length_squared(), (p - end).length_squared()); if (begin[1] <= p[1]) { if (end[1] > p[1]) { if ((v[0] * (p[1] - begin[1]) > v[1] * (p[0] - begin[0]))) { @@ -503,7 +507,7 @@ render_distance_field(PNMImage &image, int outline, int min_x, int min_y) { } } - min_dist_sq = min(min_dist_sq, dist_sq); + min_dist_sq = std::min(min_dist_sq, dist_sq); } } // Determine the sign based on whether we're inside the contour. diff --git a/panda/src/pnmtext/pnmTextGlyph.cxx b/panda/src/pnmtext/pnmTextGlyph.cxx index 833febd98c..d52e415c02 100644 --- a/panda/src/pnmtext/pnmTextGlyph.cxx +++ b/panda/src/pnmtext/pnmTextGlyph.cxx @@ -14,6 +14,9 @@ #include "pnmTextGlyph.h" #include "indent.h" +using std::max; +using std::min; + /** * */ diff --git a/panda/src/pnmtext/pnmTextMaker.cxx b/panda/src/pnmtext/pnmTextMaker.cxx index 1cf2c92a75..8a22fff510 100644 --- a/panda/src/pnmtext/pnmTextMaker.cxx +++ b/panda/src/pnmtext/pnmTextMaker.cxx @@ -18,6 +18,8 @@ #include FT_OUTLINE_H +using std::wstring; + /** * The constructor expects the name of some font file that FreeType can read, * along with face_index, indicating which font within the file to load diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index 8a4a9fc288..c69e1ea032 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -27,6 +27,8 @@ #include "clockObject.h" #include "neverFreeMemory.h" +using std::string; + PStatCollector PStatClient::_heap_total_size_pcollector("System memory:Heap"); PStatCollector PStatClient::_heap_overhead_size_pcollector("System memory:Heap:Overhead"); PStatCollector PStatClient::_heap_single_size_pcollector("System memory:Heap:Single"); @@ -334,7 +336,7 @@ main_tick() { // Not used. break; } - ostringstream strm; + std::ostringstream strm; strm << "System memory:" << category << ":" << type; col = PStatCollector(strm.str()); } diff --git a/panda/src/pstatclient/pStatClientImpl.cxx b/panda/src/pstatclient/pStatClientImpl.cxx index d126c6c753..d607a53bd9 100644 --- a/panda/src/pstatclient/pStatClientImpl.cxx +++ b/panda/src/pstatclient/pStatClientImpl.cxx @@ -85,7 +85,7 @@ PStatClientImpl:: * Called only by PStatClient::client_connect(). */ bool PStatClientImpl:: -client_connect(string hostname, int port) { +client_connect(std::string hostname, int port) { nassertr(!_is_connected, true); if (hostname.empty()) { @@ -372,7 +372,7 @@ transmit_control_data() { /** * Returns the current machine's hostname. */ -string PStatClientImpl:: +std::string PStatClientImpl:: get_hostname() { if (_hostname.empty()) { char temp_buff[1024]; diff --git a/panda/src/pstatclient/pStatCollectorDef.cxx b/panda/src/pstatclient/pStatCollectorDef.cxx index 13070343e0..bdd0035bba 100644 --- a/panda/src/pstatclient/pStatCollectorDef.cxx +++ b/panda/src/pstatclient/pStatCollectorDef.cxx @@ -38,7 +38,7 @@ PStatCollectorDef() { * */ PStatCollectorDef:: -PStatCollectorDef(int index, const string &name) : +PStatCollectorDef(int index, const std::string &name) : _index(index), _name(name) { diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 32db833ed5..cce31e693f 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -23,6 +23,8 @@ #include +using std::string; + static const int current_pstat_major_version = 3; static const int current_pstat_minor_version = 0; // Initialized at 2.0 on 51801, when version numbers were first added. diff --git a/panda/src/pstatclient/test_client.cxx b/panda/src/pstatclient/test_client.cxx index b60aa6c625..8151b808d2 100644 --- a/panda/src/pstatclient/test_client.cxx +++ b/panda/src/pstatclient/test_client.cxx @@ -85,7 +85,7 @@ public: int main(int argc, char *argv[]) { - string hostname = "localhost"; + std::string hostname = "localhost"; int port = pstats_port; if (argc > 1) { diff --git a/panda/src/putil/animInterface.cxx b/panda/src/putil/animInterface.cxx index 4727b4f907..304e4f95af 100644 --- a/panda/src/putil/animInterface.cxx +++ b/panda/src/putil/animInterface.cxx @@ -18,6 +18,9 @@ #include "datagram.h" #include "datagramIterator.h" +using std::max; +using std::min; + TypeHandle AnimInterface::_type_handle; /** @@ -61,7 +64,7 @@ get_num_frames() const { * */ void AnimInterface:: -output(ostream &out) const { +output(std::ostream &out) const { CDReader cdata(_cycler); cdata->output(out); } @@ -375,7 +378,7 @@ is_playing() const { * */ void AnimInterface::CData:: -output(ostream &out) const { +output(std::ostream &out) const { switch (_play_mode) { case PM_pose: out << "pose, frame " << get_full_fframe(); diff --git a/panda/src/putil/autoTextureScale.cxx b/panda/src/putil/autoTextureScale.cxx index ea17b6f08b..f9c27128ce 100644 --- a/panda/src/putil/autoTextureScale.cxx +++ b/panda/src/putil/autoTextureScale.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "config_putil.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, AutoTextureScale ats) { switch (ats) { diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index 385079d7ee..4dbcf06966 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -27,6 +27,11 @@ #include "configVariableFilename.h" #include "virtualFileSystem.h" +using std::istream; +using std::ostream; +using std::ostringstream; +using std::string; + BamCache *BamCache::_global_ptr = nullptr; /** @@ -966,7 +971,7 @@ hash_filename(const string &filename) { } ostringstream strm; - strm << hex << setw(8) << setfill('0') << hash; + strm << std::hex << std::setw(8) << std::setfill('0') << hash; return strm.str(); #endif // HAVE_OPENSSL diff --git a/panda/src/putil/bamCacheIndex.cxx b/panda/src/putil/bamCacheIndex.cxx index 889bb2a8ab..4455d5362d 100644 --- a/panda/src/putil/bamCacheIndex.cxx +++ b/panda/src/putil/bamCacheIndex.cxx @@ -37,7 +37,7 @@ BamCacheIndex:: * */ void BamCacheIndex:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "BamCacheIndex, " << _records.size() << " records:\n"; @@ -45,13 +45,13 @@ write(ostream &out, int indent_level) const { for (ri = _records.begin(); ri != _records.end(); ++ri) { BamCacheRecord *record = (*ri).second; indent(out, indent_level + 2) - << setw(10) << record->_record_size << " " + << std::setw(10) << record->_record_size << " " << record->get_cache_filename() << " " << record->get_source_pathname() << "\n"; } out << "\n"; indent(out, indent_level) - << setw(12) << _cache_size << " bytes total\n"; + << std::setw(12) << _cache_size << " bytes total\n"; } /** @@ -129,7 +129,7 @@ evict_old_file() { */ bool BamCacheIndex:: add_record(BamCacheRecord *record) { - pair result = + std::pair result = _records.insert(Records::value_type(record->get_source_pathname(), record)); if (!result.second) { // We already had a record for this filename; it gets replaced. diff --git a/panda/src/putil/bamCacheRecord.cxx b/panda/src/putil/bamCacheRecord.cxx index f732dbcb9e..65a3c650f1 100644 --- a/panda/src/putil/bamCacheRecord.cxx +++ b/panda/src/putil/bamCacheRecord.cxx @@ -190,7 +190,7 @@ add_dependent_file(const VirtualFile *file) { * */ void BamCacheRecord:: -output(ostream &out) const { +output(std::ostream &out) const { out << "BamCacheRecord " << get_source_pathname(); } @@ -198,7 +198,7 @@ output(ostream &out) const { * */ void BamCacheRecord:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "BamCacheRecord " << get_source_pathname() << "\n"; indent(out, indent_level) @@ -212,7 +212,7 @@ write(ostream &out, int indent_level) const { for (fi = _files.begin(); fi != _files.end(); ++fi) { const DependentFile &dfile = (*fi); indent(out, indent_level + 2) - << setw(10) << dfile._size << " " + << std::setw(10) << dfile._size << " " << format_timestamp(dfile._timestamp) << " " << dfile._pathname << "\n"; } @@ -221,7 +221,7 @@ write(ostream &out, int indent_level) const { /** * Returns a timestamp value formatted nicely for output. */ -string BamCacheRecord:: +std::string BamCacheRecord:: format_timestamp(time_t timestamp) { static const size_t buffer_size = 512; char buffer[buffer_size]; diff --git a/panda/src/putil/bamEnums.cxx b/panda/src/putil/bamEnums.cxx index ed1b18ac58..88d21cecf8 100644 --- a/panda/src/putil/bamEnums.cxx +++ b/panda/src/putil/bamEnums.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "config_putil.h" +using std::istream; +using std::ostream; +using std::string; + ostream & operator << (ostream &out, BamEnums::BamEndian be) { switch (be) { diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index a1b6641148..db360ae249 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -20,6 +20,8 @@ #include "config_putil.h" #include "pipelineCyclerBase.h" +using std::string; + TypeHandle BamReaderAuxData::_type_handle; WritableFactory *BamReader::_factory = nullptr; @@ -1111,7 +1113,7 @@ p_read_object() { default: bam_cat.error() - << "Encountered invalid BamObjectCode 0x" << hex << (int)boc << dec << ".\n"; + << "Encountered invalid BamObjectCode 0x" << std::hex << (int)boc << std::dec << ".\n"; return 0; } @@ -1251,7 +1253,7 @@ p_read_object() { if (object == nullptr) { if (bam_cat.is_debug()) { bam_cat.debug() - << "Unable to create an object of type " << type << endl; + << "Unable to create an object of type " << type << std::endl; } } else if (object->get_type() != type) { @@ -1263,7 +1265,7 @@ p_read_object() { bam_cat.warning() << "Attempted to create a " << type.get_name() \ << " but a " << object->get_type() \ - << " was created instead." << endl; + << " was created instead." << std::endl; } } else { @@ -1272,7 +1274,7 @@ p_read_object() { bam_cat.warning() << "Attempted to create a " << type.get_name() \ << " but a " << object->get_type() \ - << " was created instead." << endl; + << " was created instead." << std::endl; } } else { diff --git a/panda/src/putil/bitArray.cxx b/panda/src/putil/bitArray.cxx index f91c16d573..42f0d47259 100644 --- a/panda/src/putil/bitArray.cxx +++ b/panda/src/putil/bitArray.cxx @@ -16,6 +16,10 @@ #include "datagram.h" #include "datagramIterator.h" +using std::max; +using std::min; +using std::ostream; + TypeHandle BitArray::_type_handle; /** diff --git a/panda/src/putil/buttonHandle.cxx b/panda/src/putil/buttonHandle.cxx index 5495b7ce18..831a3daddd 100644 --- a/panda/src/putil/buttonHandle.cxx +++ b/panda/src/putil/buttonHandle.cxx @@ -27,14 +27,14 @@ TypeHandle ButtonHandle::_type_handle; * ButtonRegistry::register_button(). */ ButtonHandle:: -ButtonHandle(const string &name) { +ButtonHandle(const std::string &name) { _index = ButtonRegistry::ptr()->get_button(name)._index; } /** * Returns the name of the button. */ -string ButtonHandle:: +std::string ButtonHandle:: get_name() const { if ((*this) == ButtonHandle::none()) { return "none"; diff --git a/panda/src/putil/buttonMap.cxx b/panda/src/putil/buttonMap.cxx index 7fcc0fa516..2e74d929ce 100644 --- a/panda/src/putil/buttonMap.cxx +++ b/panda/src/putil/buttonMap.cxx @@ -20,7 +20,7 @@ TypeHandle ButtonMap::_type_handle; * Registers a new button mapping. */ void ButtonMap:: -map_button(ButtonHandle raw_button, ButtonHandle button, const string &label) { +map_button(ButtonHandle raw_button, ButtonHandle button, const std::string &label) { int index = raw_button.get_index(); if (_button_map.find(index) != _button_map.end()) { // A button with this index was already mapped. @@ -39,7 +39,7 @@ map_button(ButtonHandle raw_button, ButtonHandle button, const string &label) { * */ void ButtonMap:: -output(ostream &out) const { +output(std::ostream &out) const { out << "ButtonMap (" << get_num_buttons() << " buttons)"; } @@ -47,7 +47,7 @@ output(ostream &out) const { * */ void ButtonMap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "ButtonMap, " << get_num_buttons() << " buttons:\n"; diff --git a/panda/src/putil/buttonRegistry.cxx b/panda/src/putil/buttonRegistry.cxx index 2537dcc0dc..1800d9e88a 100644 --- a/panda/src/putil/buttonRegistry.cxx +++ b/panda/src/putil/buttonRegistry.cxx @@ -41,7 +41,7 @@ ButtonRegistry *ButtonRegistry::_global_pointer = nullptr; * right. */ bool ButtonRegistry:: -register_button(ButtonHandle &button_handle, const string &name, +register_button(ButtonHandle &button_handle, const std::string &name, ButtonHandle alias, char ascii_equivalent) { NameRegistry::iterator ri; ri = _name_registry.find(name); @@ -109,7 +109,7 @@ register_button(ButtonHandle &button_handle, const string &name, * is no such ButtonHandle, registers a new one and returns it. */ ButtonHandle ButtonRegistry:: -get_button(const string &name) { +get_button(const std::string &name) { NameRegistry::const_iterator ri; ri = _name_registry.find(name); @@ -127,7 +127,7 @@ get_button(const string &name) { * is no such ButtonHandle, returns ButtonHandle::none(). */ ButtonHandle ButtonRegistry:: -find_button(const string &name) { +find_button(const std::string &name) { NameRegistry::const_iterator ri; ri = _name_registry.find(name); @@ -155,7 +155,7 @@ find_ascii_button(char ascii_equivalent) const { * */ void ButtonRegistry:: -write(ostream &out) const { +write(std::ostream &out) const { out << "ASCII equivalents:\n"; for (int i = 1; i < 128; i++) { if (_handle_registry[i] != nullptr) { diff --git a/panda/src/putil/callbackData.cxx b/panda/src/putil/callbackData.cxx index de7eac9678..1a3f15672b 100644 --- a/panda/src/putil/callbackData.cxx +++ b/panda/src/putil/callbackData.cxx @@ -20,7 +20,7 @@ TypeHandle CallbackData::_type_handle; * */ void CallbackData:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } diff --git a/panda/src/putil/callbackObject.cxx b/panda/src/putil/callbackObject.cxx index 9f1ce360ac..579b0299b7 100644 --- a/panda/src/putil/callbackObject.cxx +++ b/panda/src/putil/callbackObject.cxx @@ -20,7 +20,7 @@ TypeHandle CallbackObject::_type_handle; * */ void CallbackObject:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } diff --git a/panda/src/putil/clockObject.cxx b/panda/src/putil/clockObject.cxx index 341a11374a..0eb72647e4 100644 --- a/panda/src/putil/clockObject.cxx +++ b/panda/src/putil/clockObject.cxx @@ -17,6 +17,10 @@ #include "string_utils.h" #include "thread.h" +using std::istream; +using std::ostream; +using std::string; + void (*ClockObject::_start_clock_wait)() = ClockObject::dummy_clock_wait; void (*ClockObject::_start_clock_busy_wait)() = ClockObject::dummy_clock_wait; void (*ClockObject::_stop_clock_wait)() = ClockObject::dummy_clock_wait; @@ -351,7 +355,7 @@ tick(Thread *current_thread) { // In case someone munged the clock last frame and sent us backward in // time, clamp the previous time to the current time to make sure we don't // report anything strange (or wait interminably). - old_time = min(old_time, _actual_frame_time); + old_time = std::min(old_time, _actual_frame_time); ++cdata->_frame_count; @@ -375,7 +379,7 @@ tick(Thread *current_thread) { double wait_until_time = old_time + 1.0 / _user_frame_rate; wait_until(wait_until_time); cdata->_dt = _actual_frame_time - old_time; - cdata->_reported_frame_time = max(_actual_frame_time, wait_until_time); + cdata->_reported_frame_time = std::max(_actual_frame_time, wait_until_time); } break; diff --git a/panda/src/putil/colorSpace.cxx b/panda/src/putil/colorSpace.cxx index 075eb438a1..3a244a68eb 100644 --- a/panda/src/putil/colorSpace.cxx +++ b/panda/src/putil/colorSpace.cxx @@ -21,6 +21,11 @@ #include +using std::istream; +using std::ostream; +using std::ostringstream; +using std::string; + ColorSpace parse_color_space_string(const string &str) { if (cmp_nocase_uh(str, "linear") == 0 || diff --git a/panda/src/putil/datagramBuffer.cxx b/panda/src/putil/datagramBuffer.cxx index c9831a4f82..7b1acb4ba1 100644 --- a/panda/src/putil/datagramBuffer.cxx +++ b/panda/src/putil/datagramBuffer.cxx @@ -20,7 +20,7 @@ * written. */ bool DatagramBuffer:: -write_header(const string &header) { +write_header(const std::string &header) { nassertr(!_wrote_first_datagram, false); _data.insert(_data.end(), header.begin(), header.end()); @@ -78,13 +78,13 @@ flush() { * has been read. */ bool DatagramBuffer:: -read_header(string &header, size_t num_bytes) { +read_header(std::string &header, size_t num_bytes) { nassertr(!_read_first_datagram, false); if (_read_offset + num_bytes > _data.size()) { return false; } - header = string((char *)&_data[_read_offset], num_bytes); + header = std::string((char *)&_data[_read_offset], num_bytes); _read_offset += num_bytes; return true; } diff --git a/panda/src/putil/datagramInputFile.cxx b/panda/src/putil/datagramInputFile.cxx index 466d78006b..c4802ceed2 100644 --- a/panda/src/putil/datagramInputFile.cxx +++ b/panda/src/putil/datagramInputFile.cxx @@ -22,6 +22,9 @@ #include "streamReader.h" #include "thread.h" +using std::streampos; +using std::streamsize; + /** * Opens the indicated filename for reading. Returns true on success, false * on failure. @@ -54,7 +57,7 @@ open(const FileReference *file) { * you are responsible for closing or deleting it when you are done. */ bool DatagramInputFile:: -open(istream &in, const Filename &filename) { +open(std::istream &in, const Filename &filename) { close(); _in = ∈ @@ -98,7 +101,7 @@ close() { * has been read. */ bool DatagramInputFile:: -read_header(string &header, size_t num_bytes) { +read_header(std::string &header, size_t num_bytes) { nassertr(!_read_first_datagram, false); nassertr(_in != nullptr, false); @@ -110,7 +113,7 @@ read_header(string &header, size_t num_bytes) { return false; } - header = string(buffer, num_bytes); + header = std::string(buffer, num_bytes); Thread::consider_yield(); return true; } @@ -170,7 +173,7 @@ get_datagram(Datagram &data) { // standards. Let's take it 4MB at a time just in case the length is // corrupt, so we don't allocate potentially a few GBs of RAM only to // find a truncated file. - bytes_left = min(bytes_left, (size_t)4*1024*1024); + bytes_left = std::min(bytes_left, (size_t)4*1024*1024); PTA_uchar buffer = data.modify_array(); buffer.resize(buffer.size() + bytes_left); @@ -221,7 +224,7 @@ save_datagram(SubfileInfo &info) { // into this file. if (_file != nullptr) { info = SubfileInfo(_file, _in->tellg(), num_bytes); - _in->seekg(num_bytes, ios::cur); + _in->seekg(num_bytes, std::ios::cur); return true; } @@ -245,7 +248,7 @@ save_datagram(SubfileInfo &info) { static const size_t buffer_size = 4096; char buffer[buffer_size]; - _in->read(buffer, min((streamsize)buffer_size, num_remaining)); + _in->read(buffer, std::min((streamsize)buffer_size, num_remaining)); streamsize count = _in->gcount(); while (count != 0) { out.write(buffer, count); @@ -259,7 +262,7 @@ save_datagram(SubfileInfo &info) { if (num_remaining == 0) { break; } - _in->read(buffer, min((streamsize)buffer_size, num_remaining)); + _in->read(buffer, std::min((streamsize)buffer_size, num_remaining)); count = _in->gcount(); } diff --git a/panda/src/putil/datagramOutputFile.cxx b/panda/src/putil/datagramOutputFile.cxx index 24533ad8b0..407e1adfec 100644 --- a/panda/src/putil/datagramOutputFile.cxx +++ b/panda/src/putil/datagramOutputFile.cxx @@ -16,6 +16,10 @@ #include "zStream.h" #include +using std::min; +using std::streampos; +using std::streamsize; + /** * Opens the indicated filename for writing. Returns true if successful, * false on failure. @@ -47,7 +51,7 @@ open(const FileReference *file) { * are responsible for closing or deleting it when you are done. */ bool DatagramOutputFile:: -open(ostream &out, const Filename &filename) { +open(std::ostream &out, const Filename &filename) { close(); _out = &out; @@ -89,7 +93,7 @@ close() { * written. */ bool DatagramOutputFile:: -write_header(const string &header) { +write_header(const std::string &header) { nassertr(_out != nullptr, false); nassertr(!_wrote_first_datagram, false); @@ -145,7 +149,7 @@ copy_datagram(SubfileInfo &result, const Filename &filename) { if (vfile == nullptr) { return false; } - istream *in = vfile->open_read_file(true); + std::istream *in = vfile->open_read_file(true); if (in == nullptr) { return false; } diff --git a/panda/src/putil/factoryBase.cxx b/panda/src/putil/factoryBase.cxx index bfb803da39..eeba7183dc 100644 --- a/panda/src/putil/factoryBase.cxx +++ b/panda/src/putil/factoryBase.cxx @@ -212,7 +212,7 @@ get_preferred(int n) const { * output stream, one per line. */ void FactoryBase:: -write_types(ostream &out, int indent_level) const { +write_types(std::ostream &out, int indent_level) const { Creators::const_iterator ci; for (ci = _creators.begin(); ci != _creators.end(); ++ci) { indent(out, indent_level) << (*ci).first << "\n"; diff --git a/panda/src/putil/globalPointerRegistry.cxx b/panda/src/putil/globalPointerRegistry.cxx index 622a666f6e..2f6f308baf 100644 --- a/panda/src/putil/globalPointerRegistry.cxx +++ b/panda/src/putil/globalPointerRegistry.cxx @@ -57,7 +57,7 @@ ns_store_pointer(TypeHandle type, void *ptr) { clear_pointer(type); return; } - pair result = + std::pair result = _pointers.insert(Pointers::value_type(type, ptr)); if (!result.second) { diff --git a/panda/src/putil/keyboardButton.cxx b/panda/src/putil/keyboardButton.cxx index e6d7162d50..3ab8e38265 100644 --- a/panda/src/putil/keyboardButton.cxx +++ b/panda/src/putil/keyboardButton.cxx @@ -155,7 +155,7 @@ init_keyboard_buttons() { for (int i = 32; i < 127; i++) { if (isgraph(i)) { ButtonHandle key; - ButtonRegistry::ptr()->register_button(key, string(1, (char)i), + ButtonRegistry::ptr()->register_button(key, std::string(1, (char)i), ButtonHandle::none(), i); } } diff --git a/panda/src/putil/load_prc_file.cxx b/panda/src/putil/load_prc_file.cxx index 7da6526c9c..f40296b403 100644 --- a/panda/src/putil/load_prc_file.cxx +++ b/panda/src/putil/load_prc_file.cxx @@ -43,7 +43,7 @@ load_prc_file(const Filename &filename) { vfs->resolve_filename(path, cp_mgr->get_search_path()) || vfs->resolve_filename(path, get_model_path()); - istream *file = vfs->open_read_file(path, true); + std::istream *file = vfs->open_read_file(path, true); if (file == nullptr) { util_cat.error() << "Unable to open " << path << "\n"; @@ -78,8 +78,8 @@ load_prc_file(const Filename &filename) { * loaded prc files is listed. */ EXPCL_PANDA_PUTIL ConfigPage * -load_prc_file_data(const string &name, const string &data) { - istringstream strm(data); +load_prc_file_data(const std::string &name, const std::string &data) { + std::istringstream strm(data); ConfigPageManager *cp_mgr = ConfigPageManager::get_global_ptr(); @@ -121,7 +121,7 @@ unload_prc_file(ConfigPage *page) { */ void hash_prc_variables(HashVal &hash) { - ostringstream strm; + std::ostringstream strm; ConfigVariableManager *cv_mgr = ConfigVariableManager::get_global_ptr(); cv_mgr->write_prc_variables(strm); hash.hash_string(strm.str()); diff --git a/panda/src/putil/loaderOptions.cxx b/panda/src/putil/loaderOptions.cxx index 167d977cd7..508e22f23c 100644 --- a/panda/src/putil/loaderOptions.cxx +++ b/panda/src/putil/loaderOptions.cxx @@ -15,6 +15,8 @@ #include "config_putil.h" #include "indent.h" +using std::string; + /** * */ @@ -54,7 +56,7 @@ LoaderOptions(int flags) : * */ void LoaderOptions:: -output(ostream &out) const { +output(std::ostream &out) const { out << "LoaderOptions("; string sep = ""; @@ -100,7 +102,7 @@ output(ostream &out) const { * Used to implement output(). */ void LoaderOptions:: -write_flag(ostream &out, string &sep, +write_flag(std::ostream &out, string &sep, const string &flag_name, int flag) const { if ((_flags & flag) == flag) { out << sep << flag_name; @@ -112,7 +114,7 @@ write_flag(ostream &out, string &sep, * Used to implement output(). */ void LoaderOptions:: -write_texture_flag(ostream &out, string &sep, +write_texture_flag(std::ostream &out, string &sep, const string &flag_name, int flag) const { if ((_texture_flags & flag) == flag) { out << sep << flag_name; diff --git a/panda/src/putil/modifierButtons.cxx b/panda/src/putil/modifierButtons.cxx index a0c4a79146..00a75fcdd9 100644 --- a/panda/src/putil/modifierButtons.cxx +++ b/panda/src/putil/modifierButtons.cxx @@ -302,9 +302,9 @@ is_down(ButtonHandle button) const { * Returns a string which can be used to prefix any button name or event name * with the unique set of modifier buttons currently being held. */ -string ModifierButtons:: +std::string ModifierButtons:: get_prefix() const { - string prefix; + std::string prefix; for (int i = 0; i < (int)_button_list.size(); i++) { if ((_state & ((BitmaskType)1 << i)) != 0) { prefix += _button_list[i].get_name(); @@ -319,7 +319,7 @@ get_prefix() const { * Writes a one-line summary of the buttons known to be down. */ void ModifierButtons:: -output(ostream &out) const { +output(std::ostream &out) const { out << "["; for (int i = 0; i < (int)_button_list.size(); i++) { if ((_state & ((BitmaskType)1 << i)) != 0) { @@ -334,7 +334,7 @@ output(ostream &out) const { * and which ones are known to be down. */ void ModifierButtons:: -write(ostream &out) const { +write(std::ostream &out) const { out << "ModifierButtons:\n"; for (int i = 0; i < (int)_button_list.size(); i++) { out << " " << _button_list[i]; diff --git a/panda/src/putil/mouseData.cxx b/panda/src/putil/mouseData.cxx index 8149672c9b..de83bd1505 100644 --- a/panda/src/putil/mouseData.cxx +++ b/panda/src/putil/mouseData.cxx @@ -17,7 +17,7 @@ * */ void MouseData:: -output(ostream &out) const { +output(std::ostream &out) const { if (!_in_window) { out << "MouseData: Not in window"; } else { diff --git a/panda/src/putil/nameUniquifier.cxx b/panda/src/putil/nameUniquifier.cxx index 0629a58ac9..e6ab3f6917 100644 --- a/panda/src/putil/nameUniquifier.cxx +++ b/panda/src/putil/nameUniquifier.cxx @@ -17,6 +17,8 @@ #include +using std::string; + /** * Creates a new NameUniquifier. diff --git a/panda/src/putil/paramValue.cxx b/panda/src/putil/paramValue.cxx index 309f8885bd..5ffcf2807c 100644 --- a/panda/src/putil/paramValue.cxx +++ b/panda/src/putil/paramValue.cxx @@ -56,7 +56,7 @@ ParamTypedRefCount:: * */ void ParamTypedRefCount:: -output(ostream &out) const { +output(std::ostream &out) const { if (_value == nullptr) { out << "(empty)"; diff --git a/panda/src/putil/sparseArray.cxx b/panda/src/putil/sparseArray.cxx index 37940d1d10..6373e53039 100644 --- a/panda/src/putil/sparseArray.cxx +++ b/panda/src/putil/sparseArray.cxx @@ -214,7 +214,7 @@ has_bits_in_common(const SparseArray &other) const { * */ void SparseArray:: -output(ostream &out) const { +output(std::ostream &out) const { out << "[ "; if (_inverse) { out << "all except: "; @@ -442,7 +442,7 @@ do_remove_range(int begin, int end) { si = _subranges.begin() + _subranges.size() - 1; if ((*si)._end >= begin) { // The new range shortens the last element of the array on the right. - end = min(end, (*si)._begin); + end = std::min(end, (*si)._begin); (*si)._end = end; // It might also shorten it on the left; fall through. } else { @@ -465,7 +465,7 @@ do_remove_range(int begin, int end) { if ((*si2)._end >= begin) { // The new range shortens an element within the array on the right // (but does not intersect the next element). - end = min(end, (*si2)._begin); + end = std::min(end, (*si2)._begin); (*si2)._end = end; // It might also shorten it on the left; fall through. si = si2; @@ -499,7 +499,7 @@ do_remove_range(int begin, int end) { si = si2; } - (*si)._end = min((*si)._end, begin); + (*si)._end = std::min((*si)._end, begin); } /** diff --git a/panda/src/putil/test_bam.cxx b/panda/src/putil/test_bam.cxx index a6103d5c5f..bf6d862434 100644 --- a/panda/src/putil/test_bam.cxx +++ b/panda/src/putil/test_bam.cxx @@ -17,6 +17,8 @@ #include "test_bam.h" +using std::endl; + TypeHandle Person::_type_handle; TypeHandle Parent::_type_handle; diff --git a/panda/src/putil/test_bamRead.cxx b/panda/src/putil/test_bamRead.cxx index d49f49434b..50949f63eb 100644 --- a/panda/src/putil/test_bamRead.cxx +++ b/panda/src/putil/test_bamRead.cxx @@ -20,7 +20,7 @@ int main(int argc, char* argv[]) { - string test_file = "bamTest.out"; + std::string test_file = "bamTest.out"; DatagramInputFile stream; bool success = stream.open(test_file); nassertr(success, 1); @@ -37,11 +37,11 @@ int main(int argc, char* argv[]) manager.resolve(); dad->print_relationships(); - nout << endl; + nout << std::endl; mom->print_relationships(); - nout << endl; + nout << std::endl; bro->print_relationships(); - nout << endl; + nout << std::endl; sis->print_relationships(); return 0; diff --git a/panda/src/putil/test_bamWrite.cxx b/panda/src/putil/test_bamWrite.cxx index 59d56930ec..9469b8a6a3 100644 --- a/panda/src/putil/test_bamWrite.cxx +++ b/panda/src/putil/test_bamWrite.cxx @@ -19,7 +19,7 @@ int main(int argc, char* argv[]) { - string test_file("bamTest.out"); + std::string test_file("bamTest.out"); DatagramOutputFile stream; bool success = stream.open(test_file); nassertr(success, 1); diff --git a/panda/src/putil/test_glob.cxx b/panda/src/putil/test_glob.cxx index 32ba0d1927..cc5141dcdd 100644 --- a/panda/src/putil/test_glob.cxx +++ b/panda/src/putil/test_glob.cxx @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { if (argc != 2 && argc != 3) { - cerr + std::cerr << "test_glob \"pattern\" [from-directory]\n\n" << "Attempts to match the pattern against each of the files in the\n" << "indicated directory if specified, or the current directory\n" @@ -36,10 +36,10 @@ main(int argc, char *argv[]) { vector_string results; int num_matched = pattern.match_files(results, from_directory); - cerr << num_matched << " results:\n"; + std::cerr << num_matched << " results:\n"; vector_string::const_iterator si; for (si = results.begin(); si != results.end(); ++si) { - cerr << " " << *si << "\n"; + std::cerr << " " << *si << "\n"; } return (0); diff --git a/panda/src/putil/test_uniqueIdAllocator.cxx b/panda/src/putil/test_uniqueIdAllocator.cxx index be39a01450..73c3c6b498 100644 --- a/panda/src/putil/test_uniqueIdAllocator.cxx +++ b/panda/src/putil/test_uniqueIdAllocator.cxx @@ -4,7 +4,9 @@ #include #include #include -using namespace std; + +using std::cout; +using std::endl; #include "uniqueIdAllocator.h" diff --git a/panda/src/putil/typedWritable.cxx b/panda/src/putil/typedWritable.cxx index d0e5058538..8ca4081c63 100644 --- a/panda/src/putil/typedWritable.cxx +++ b/panda/src/putil/typedWritable.cxx @@ -190,11 +190,11 @@ bool TypedWritable:: decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader) { - DatagramBuffer buffer(move(data)); + DatagramBuffer buffer(std::move(data)); if (reader == nullptr) { // Create a local reader. - string head; + std::string head; if (!buffer.read_header(head, _bam_header.size())) { return false; } diff --git a/panda/src/putil/typedWritableReferenceCount.cxx b/panda/src/putil/typedWritableReferenceCount.cxx index ba4e2c49e4..3ca6d27550 100644 --- a/panda/src/putil/typedWritableReferenceCount.cxx +++ b/panda/src/putil/typedWritableReferenceCount.cxx @@ -41,7 +41,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { TypedWritable *object; ReferenceCount *ref_ptr; - if (TypedWritable::decode_raw_from_bam_stream(object, ref_ptr, move(data), reader)) { + if (TypedWritable::decode_raw_from_bam_stream(object, ref_ptr, std::move(data), reader)) { return DCAST(TypedWritableReferenceCount, object); } else { return nullptr; diff --git a/panda/src/putil/typedWritable_ext.cxx b/panda/src/putil/typedWritable_ext.cxx index c736a6fa14..3db4b086c3 100644 --- a/panda/src/putil/typedWritable_ext.cxx +++ b/panda/src/putil/typedWritable_ext.cxx @@ -52,9 +52,9 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { // can't use this interface. PyObject *method = PyObject_GetAttrString(self, "decode_from_bam_stream"); if (method == nullptr) { - ostringstream stream; + std::ostringstream stream; stream << "Cannot pickle objects of type " << _this->get_type() << "\n"; - string message = stream.str(); + std::string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); return nullptr; } @@ -75,9 +75,9 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { // First, streamify the object, if possible. vector_uchar bam_stream; if (!_this->encode_to_bam_stream(bam_stream, writer)) { - ostringstream stream; + std::ostringstream stream; stream << "Could not bamify object of type " << _this->get_type() << "\n"; - string message = stream.str(); + std::string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); return nullptr; } diff --git a/panda/src/putil/uniqueIdAllocator.cxx b/panda/src/putil/uniqueIdAllocator.cxx index 0b3307a2af..6c4edd9795 100644 --- a/panda/src/putil/uniqueIdAllocator.cxx +++ b/panda/src/putil/uniqueIdAllocator.cxx @@ -17,6 +17,8 @@ #include "uniqueIdAllocator.h" +using std::endl; + NotifyCategoryDecl(uniqueIdAllocator, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); NotifyCategoryDef(uniqueIdAllocator, ""); @@ -212,7 +214,7 @@ fraction_used() const { * ...intended for debugging only. */ void UniqueIdAllocator:: -output(ostream &out) const { +output(std::ostream &out) const { out << "UniqueIdAllocator(" << _min << ", " << _max << "), " << _free << " id's remaining of " << _size; } @@ -221,7 +223,7 @@ output(ostream &out) const { * ...intended for debugging only. */ void UniqueIdAllocator:: -write(ostream &out) const { +write(std::ostream &out) const { out << "_min: " << _min << "; _max: " << _max << ";\n_next_free: " << int32_t(_next_free) << "; _last_free: " << int32_t(_last_free) diff --git a/panda/src/recorder/mouseRecorder.cxx b/panda/src/recorder/mouseRecorder.cxx index a79c7dc49b..37a5a2a440 100644 --- a/panda/src/recorder/mouseRecorder.cxx +++ b/panda/src/recorder/mouseRecorder.cxx @@ -23,7 +23,7 @@ TypeHandle MouseRecorder::_type_handle; * */ MouseRecorder:: -MouseRecorder(const string &name) : +MouseRecorder(const std::string &name) : DataNode(name) { _pixel_xy_input = define_input("pixel_xy", EventStoreVec2::get_class_type()); @@ -88,7 +88,7 @@ play_frame(DatagramIterator &scan, BamReader *manager) { * */ void MouseRecorder:: -output(ostream &out) const { +output(std::ostream &out) const { DataNode::output(out); } @@ -96,7 +96,7 @@ output(ostream &out) const { * */ void MouseRecorder:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { DataNode::write(out, indent_level); } diff --git a/panda/src/recorder/recorderController.cxx b/panda/src/recorder/recorderController.cxx index b383402715..805ea5778a 100644 --- a/panda/src/recorder/recorderController.cxx +++ b/panda/src/recorder/recorderController.cxx @@ -113,7 +113,7 @@ begin_playback(const Filename &filename) { return false; } - string head; + std::string head; if (!_din.read_header(head, _bam_header.size()) || head != _bam_header) { recorder_cat.error() << "Unable to read " << _filename << "\n"; return false; diff --git a/panda/src/recorder/recorderTable.cxx b/panda/src/recorder/recorderTable.cxx index 27fc5ed2c8..4db629865f 100644 --- a/panda/src/recorder/recorderTable.cxx +++ b/panda/src/recorder/recorderTable.cxx @@ -18,6 +18,8 @@ #include "recorderController.h" #include "indent.h" +using std::string; + TypeHandle RecorderTable::_type_handle; /** @@ -140,7 +142,7 @@ clear_flags(short flags) { * */ void RecorderTable:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "RecorderTable:\n"; diff --git a/panda/src/recorder/socketStreamRecorder.cxx b/panda/src/recorder/socketStreamRecorder.cxx index 9c9d66b310..5ee6168d44 100644 --- a/panda/src/recorder/socketStreamRecorder.cxx +++ b/panda/src/recorder/socketStreamRecorder.cxx @@ -85,7 +85,7 @@ play_frame(DatagramIterator &scan, BamReader *manager) { size_t size = scan.get_uint16(); vector_uchar packet(size); scan.extract_bytes(&packet[0], size); - _data.push_back(Datagram(move(packet))); + _data.push_back(Datagram(std::move(packet))); } } diff --git a/panda/src/rocket/rocketFileInterface.cxx b/panda/src/rocket/rocketFileInterface.cxx index 0c3a25fc29..5a54e31c8f 100644 --- a/panda/src/rocket/rocketFileInterface.cxx +++ b/panda/src/rocket/rocketFileInterface.cxx @@ -50,7 +50,7 @@ Open(const Rocket::Core::String& path) { } } - istream *str = file->open_read_file(true); + std::istream *str = file->open_read_file(true); if (str == nullptr) { rocket_cat.error() << "Failed to open " << fn << " for reading\n"; return (Rocket::Core::FileHandle) nullptr; @@ -104,13 +104,13 @@ Seek(Rocket::Core::FileHandle file, long offset, int origin) { switch(origin) { case SEEK_SET: - handle->_stream->seekg(offset, ios::beg); + handle->_stream->seekg(offset, std::ios::beg); break; case SEEK_CUR: - handle->_stream->seekg(offset, ios::cur); + handle->_stream->seekg(offset, std::ios::cur); break; case SEEK_END: - handle->_stream->seekg(offset, ios::end); + handle->_stream->seekg(offset, std::ios::end); }; return !handle->_stream->fail(); diff --git a/panda/src/rocket/rocketInputHandler.cxx b/panda/src/rocket/rocketInputHandler.cxx index fcfa6dc2cf..6b07e3a02b 100644 --- a/panda/src/rocket/rocketInputHandler.cxx +++ b/panda/src/rocket/rocketInputHandler.cxx @@ -31,7 +31,7 @@ TypeHandle RocketInputHandler::_type_handle; * */ RocketInputHandler:: -RocketInputHandler(const string &name) : +RocketInputHandler(const std::string &name) : DataNode(name), _mouse_xy(-1), _mouse_xy_changed(false), diff --git a/panda/src/rocket/rocketRegion.cxx b/panda/src/rocket/rocketRegion.cxx index fe21d5c6c2..17fdc8f55f 100644 --- a/panda/src/rocket/rocketRegion.cxx +++ b/panda/src/rocket/rocketRegion.cxx @@ -31,7 +31,7 @@ TypeHandle RocketRegion::_type_handle; */ RocketRegion:: RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, - const string &context_name) : + const std::string &context_name) : DisplayRegion(window, dr_dimensions) { // A hack I don't like. libRocket's decorator system has a bug somewhere, diff --git a/panda/src/speedtree/loaderFileTypeSrt.cxx b/panda/src/speedtree/loaderFileTypeSrt.cxx index 0f67d2fb96..fa1f7b3a48 100644 --- a/panda/src/speedtree/loaderFileTypeSrt.cxx +++ b/panda/src/speedtree/loaderFileTypeSrt.cxx @@ -27,7 +27,7 @@ LoaderFileTypeSrt() { /** * */ -string LoaderFileTypeSrt:: +std::string LoaderFileTypeSrt:: get_name() const { return "SpeedTree compiled tree"; } @@ -35,7 +35,7 @@ get_name() const { /** * */ -string LoaderFileTypeSrt:: +std::string LoaderFileTypeSrt:: get_extension() const { return "srt"; } diff --git a/panda/src/speedtree/loaderFileTypeStf.cxx b/panda/src/speedtree/loaderFileTypeStf.cxx index 2f568fae3c..981d36b59b 100644 --- a/panda/src/speedtree/loaderFileTypeStf.cxx +++ b/panda/src/speedtree/loaderFileTypeStf.cxx @@ -26,7 +26,7 @@ LoaderFileTypeStf() { /** * */ -string LoaderFileTypeStf:: +std::string LoaderFileTypeStf:: get_name() const { return "SpeedTree compiled tree"; } @@ -34,7 +34,7 @@ get_name() const { /** * */ -string LoaderFileTypeStf:: +std::string LoaderFileTypeStf:: get_extension() const { return "stf"; } diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index da8c036d8e..48cda1204b 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -42,6 +42,10 @@ #include "dxGraphicsStateGuardian9.h" #endif +using std::istream; +using std::ostream; +using std::string; + double SpeedTreeNode::_global_time_delta = 0.0; bool SpeedTreeNode::_authorized; bool SpeedTreeNode::_done_first_init; @@ -155,7 +159,7 @@ add_tree(const STTree *tree) { if (ti == _trees.end()) { // This is the first time that this particular tree has been added. InstanceList *instance_list = new InstanceList(tree); - pair result = _trees.insert(instance_list); + std::pair result = _trees.insert(instance_list); ti = result.first; bool inserted = result.second; nassertr(inserted, *(*ti)); @@ -1245,10 +1249,10 @@ repopulate() { SpeedTree::CMap::const_iterator si; si = _population_stats.m_mMaxNumInstancesPerCellPerBase.find(tree->get_tree()); if (si != _population_stats.m_mMaxNumInstancesPerCellPerBase.end()) { - max_instances = max(max_instances, (int)si->second); + max_instances = std::max(max_instances, (int)si->second); } - max_instances_by_cell = max(max_instances_by_cell, max_instances); + max_instances_by_cell = std::max(max_instances_by_cell, max_instances); } _visible_trees.Reserve(_forest_render.GetBaseTrees(), @@ -1547,7 +1551,7 @@ setup_for_render(GraphicsStateGuardian *gsg) { SpeedTree::CMap::const_iterator si; si = _population_stats.m_mMaxNumInstancesPerCellPerBase.find(tree->get_tree()); if (si != _population_stats.m_mMaxNumInstancesPerCellPerBase.end()) { - max_instances = max(max_instances, (int)si->second); + max_instances = std::max(max_instances, (int)si->second); } // Get the speedtree-textures-dir to pass for initialization. diff --git a/panda/src/speedtree/stBasicTerrain.cxx b/panda/src/speedtree/stBasicTerrain.cxx index 2a6dba22f4..1c32cfe02f 100644 --- a/panda/src/speedtree/stBasicTerrain.cxx +++ b/panda/src/speedtree/stBasicTerrain.cxx @@ -16,6 +16,10 @@ #include "pnmImage.h" #include "indent.h" +using std::istream; +using std::ostream; +using std::string; + TypeHandle STBasicTerrain::_type_handle; // VERTEX_ATTRIB_END is defined as a macro that must be evaluated within the @@ -345,8 +349,8 @@ read_height_map() { v *= scalar; _height_data._data[pi] = v; ++pi; - _min_height = min(_min_height, v); - _max_height = max(_max_height, v); + _min_height = std::min(_min_height, v); + _max_height = std::max(_max_height, v); } } diff --git a/panda/src/speedtree/stTerrain.cxx b/panda/src/speedtree/stTerrain.cxx index fef97b9d0d..9215a5dd26 100644 --- a/panda/src/speedtree/stTerrain.cxx +++ b/panda/src/speedtree/stTerrain.cxx @@ -149,7 +149,7 @@ fill_vertices(GeomVertexData *data, * */ void STTerrain:: -output(ostream &out) const { +output(std::ostream &out) const { Namable::output(out); } @@ -157,7 +157,7 @@ output(ostream &out) const { * */ void STTerrain:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } diff --git a/panda/src/speedtree/stTransform.cxx b/panda/src/speedtree/stTransform.cxx index aab4be7e93..dfdb586a6c 100644 --- a/panda/src/speedtree/stTransform.cxx +++ b/panda/src/speedtree/stTransform.cxx @@ -44,7 +44,7 @@ STTransform(const TransformState *trans) { * */ void STTransform:: -output(ostream &out) const { +output(std::ostream &out) const { out << "STTransform(" << _pos << ", " << _rotate << ", " << _scale << ")"; } diff --git a/panda/src/speedtree/stTree.cxx b/panda/src/speedtree/stTree.cxx index 7a09205d6e..a34b36e7a4 100644 --- a/panda/src/speedtree/stTree.cxx +++ b/panda/src/speedtree/stTree.cxx @@ -48,7 +48,7 @@ STTree(const Filename &fullpath) : } */ - string os_fullpath = _fullpath.to_os_specific(); + std::string os_fullpath = _fullpath.to_os_specific(); if (!_tree.LoadTree(os_fullpath.c_str())) { speedtree_cat.warning() << "Couldn't read: " << _fullpath << "\n"; @@ -65,7 +65,7 @@ STTree(const Filename &fullpath) : * */ void STTree:: -output(ostream &out) const { +output(std::ostream &out) const { if (!is_valid()) { out << "(invalid STTree)"; } else { diff --git a/panda/src/testbed/pgrid.cxx b/panda/src/testbed/pgrid.cxx index d93cf64382..6858165bdf 100644 --- a/panda/src/testbed/pgrid.cxx +++ b/panda/src/testbed/pgrid.cxx @@ -22,6 +22,8 @@ #define RANDFRAC (rand()/(PN_stdfloat)(RAND_MAX)) +using std::string; + class GriddedFilename { public: Filename _filename; @@ -244,7 +246,7 @@ load_gridded_models(WindowFramework *window, } grid_pos_offset = -gridwidth*GRIDCELLSIZE/2.0; - wander_area_pos_offset = -max((PN_stdfloat)fabs(grid_pos_offset), MIN_WANDERAREA_DIMENSION/2.0f); + wander_area_pos_offset = -std::max((PN_stdfloat)fabs(grid_pos_offset), MIN_WANDERAREA_DIMENSION/2.0f); // Now walk through the list again, copying models into the scene graph as // we go. diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index 8d39104d64..73e71a358d 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -29,6 +29,9 @@ #include "asyncTask.h" #include "boundingSphere.h" +using std::cerr; +using std::endl; + PandaFramework framework; ConfigVariableBool pview_test_hack @@ -237,7 +240,7 @@ report_version() { // class AdjustCameraClipPlanesTask : public AsyncTask { public: - AdjustCameraClipPlanesTask(const string &name, Camera *camera) : + AdjustCameraClipPlanesTask(const std::string &name, Camera *camera) : AsyncTask(name), _camera(camera), _lens(camera->get_lens(0)), _sphere(nullptr) { NodePath np = framework.get_models(); @@ -317,12 +320,12 @@ public: // Ensure the far plane is far enough back to see the entire object. PN_stdfloat ideal_far_plane = distance + radius * 1.5; - _lens->set_far(max(_lens->get_default_far(), ideal_far_plane)); + _lens->set_far(std::max(_lens->get_default_far(), ideal_far_plane)); // And that the near plane is far enough forward, but if inside // the sphere, keep above 0. - PN_stdfloat ideal_near_plane = max(min_distance * 10, distance - radius); - _lens->set_near(min(_lens->get_default_near(), ideal_near_plane)); + PN_stdfloat ideal_near_plane = std::max(min_distance * 10, distance - radius); + _lens->set_near(std::min(_lens->get_default_near(), ideal_near_plane)); return DS_cont; } diff --git a/panda/src/testbed/test_map.cxx b/panda/src/testbed/test_map.cxx index 2c85f2c11a..97c0176a9d 100644 --- a/panda/src/testbed/test_map.cxx +++ b/panda/src/testbed/test_map.cxx @@ -16,6 +16,10 @@ #include "memoryUsage.h" #include "clockObject.h" +using std::cerr; +using std::cout; +using std::string; + class Alpha { public: Alpha(const string &str) : _str(str) { } @@ -36,7 +40,7 @@ public: string _str; }; -ostream &operator << (ostream &out, const Alpha &alpha) { +std::ostream &operator << (std::ostream &out, const Alpha &alpha) { return out << alpha._str; } @@ -113,7 +117,7 @@ test_performance() { static const int num_cycles = 10000; static const int num_reps = 3; - vector samples; + std::vector samples; samples.reserve(sample_size); for (int s = 0; s < sample_size; s++) { string key; diff --git a/panda/src/testbed/test_texmem.cxx b/panda/src/testbed/test_texmem.cxx index 977c1b0209..fd26a11508 100644 --- a/panda/src/testbed/test_texmem.cxx +++ b/panda/src/testbed/test_texmem.cxx @@ -49,7 +49,7 @@ event_T(const Event *, void *data) { static const int tex_x_size = 256; static const int tex_y_size = 256; - cerr << "Loading " << num_quads_side * num_quads_side << " textures at " + std::cerr << "Loading " << num_quads_side * num_quads_side << " textures at " << tex_x_size << ", " << tex_y_size << "\n"; PNMImage white_center(tex_x_size / 4, tex_y_size / 4); @@ -92,7 +92,7 @@ event_T(const Event *, void *data) { card.set_texture(tex); } } - cerr << "Done.\n"; + std::cerr << "Done.\n"; } int diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index 1bdcafcf09..77dd27beba 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -31,6 +31,8 @@ #error Buildsystem error: BUILDING_PANDA_TEXT not defined #endif +using std::wstring; + Configure(config_text); NotifyCategoryDef(text, ""); diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index 42c040c6ed..4eb4afc96a 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -226,7 +226,7 @@ clear() { * */ void DynamicTextFont:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { static const int max_glyph_name = 1024; char glyph_name[max_glyph_name]; @@ -972,7 +972,7 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { void DynamicTextFont:: render_wireframe_contours(TextGlyph *glyph) { PT(GeomVertexData) vdata = new GeomVertexData - (string(), GeomVertexFormat::get_v3(), + (std::string(), GeomVertexFormat::get_v3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); @@ -1003,7 +1003,7 @@ render_wireframe_contours(TextGlyph *glyph) { void DynamicTextFont:: render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { PT(GeomVertexData) vdata = new GeomVertexData - (string(), GeomVertexFormat::get_v3n3(), + (std::string(), GeomVertexFormat::get_v3n3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter normal(vdata, InternalName::get_normal()); diff --git a/panda/src/text/dynamicTextPage.cxx b/panda/src/text/dynamicTextPage.cxx index b48ba426db..7bfe582040 100644 --- a/panda/src/text/dynamicTextPage.cxx +++ b/panda/src/text/dynamicTextPage.cxx @@ -17,7 +17,6 @@ #ifdef HAVE_FREETYPE - TypeHandle DynamicTextPage::_type_handle; /** @@ -40,7 +39,7 @@ DynamicTextPage(DynamicTextFont *font, int page_number) : setup_2d_texture(_size[0], _size[1], T_unsigned_byte, font->get_tex_format()); // Assign a name to the Texture. - ostringstream strm; + std::ostringstream strm; strm << font->get_name() << "_" << page_number; set_name(strm.str()); @@ -215,7 +214,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { } next_x = overlap->_x + overlap->_x_size; - next_y = min(next_y, overlap->_y + overlap->_y_size); + next_y = std::min(next_y, overlap->_y + overlap->_y_size); nassertr(next_x > x, false); x = next_x; } diff --git a/panda/src/text/fontPool.cxx b/panda/src/text/fontPool.cxx index 6217be1bae..3f01243771 100644 --- a/panda/src/text/fontPool.cxx +++ b/panda/src/text/fontPool.cxx @@ -21,13 +21,15 @@ #include "loader.h" #include "lightMutexHolder.h" +using std::string; + FontPool *FontPool::_global_ptr = nullptr; /** * Lists the contents of the font pool to the indicated output stream. */ void FontPool:: -write(ostream &out) { +write(std::ostream &out) { get_ptr()->ns_list_contents(out); } @@ -211,7 +213,7 @@ ns_garbage_collect() { * The nonstatic implementation of list_contents(). */ void FontPool:: -ns_list_contents(ostream &out) const { +ns_list_contents(std::ostream &out) const { LightMutexHolder holder(_lock); out << _fonts.size() << " fonts:\n"; @@ -252,7 +254,7 @@ lookup_filename(const string &str, string &index_str, VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->resolve_filename(filename, get_model_path()); - ostringstream strm; + std::ostringstream strm; strm << filename << ":" << face_index; index_str = strm.str(); } diff --git a/panda/src/text/geomTextGlyph.cxx b/panda/src/text/geomTextGlyph.cxx index 6a02f2af16..ecd1a2173c 100644 --- a/panda/src/text/geomTextGlyph.cxx +++ b/panda/src/text/geomTextGlyph.cxx @@ -142,7 +142,7 @@ count_geom(const Geom *other) { * */ void GeomTextGlyph:: -output(ostream &out) const { +output(std::ostream &out) const { Geom::output(out); out << ", glyphs: ["; Glyphs::const_iterator gi; @@ -158,7 +158,7 @@ output(ostream &out) const { * */ void GeomTextGlyph:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Geom::write(out, indent_level); indent(out, indent_level) << "Glyphs: ["; diff --git a/panda/src/text/staticTextFont.cxx b/panda/src/text/staticTextFont.cxx index 2f68c2dba8..c179120a14 100644 --- a/panda/src/text/staticTextFont.cxx +++ b/panda/src/text/staticTextFont.cxx @@ -114,7 +114,7 @@ make_copy() const { * */ void StaticTextFont:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "StaticTextFont " << get_name() << "; " << _glyphs.size() << " characters available in font:\n"; @@ -280,7 +280,7 @@ find_character_gsets(PandaNode *root, CPT(Geom) &ch, CPT(Geom) &dot, void StaticTextFont:: find_characters(PandaNode *root, const RenderState *net_state) { CPT(RenderState) next_net_state = net_state->compose(root->get_state()); - string name = root->get_name(); + std::string name = root->get_name(); bool all_digits = !name.empty(); const char *p = name.c_str(); diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index e59b83a100..bb3a789504 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -40,6 +40,11 @@ #include #endif +using std::max; +using std::min; +using std::move; +using std::wstring; + // This is the factor by which CT_small scales the character down. static const PN_stdfloat small_accent_scale = 0.6f; @@ -827,7 +832,7 @@ scan_wtext(TextAssembler::TextString &output_string, // Now we have to encode the wstring into a string, for lookup in the // TextPropertiesManager. - string graphic_name = _encoder->encode_wtext(graphic_wname); + std::string graphic_name = _encoder->encode_wtext(graphic_wname); TextPropertiesManager *manager = TextPropertiesManager::get_global_ptr(); @@ -1628,7 +1633,7 @@ assemble_row(TextAssembler::TextRow &row, if (first_glyph != nullptr) { advance = first_glyph->get_advance() * advance_scale; if (!first_glyph->is_whitespace()) { - swap(placement._glyph, first_glyph); + std::swap(placement._glyph, first_glyph); placed_glyphs.push_back(placement); } } @@ -1638,7 +1643,7 @@ assemble_row(TextAssembler::TextRow &row, if (second_glyph != nullptr) { placement._xpos += advance * glyph_scale; advance += second_glyph->get_advance(); - swap(placement._glyph, second_glyph); + std::swap(placement._glyph, second_glyph); placed_glyphs.push_back(placement); } @@ -2414,7 +2419,7 @@ assign_append_to(GeomCollectorMap &geom_collector_map, int vi = primitive->get_vertex(i); // Attempt to insert number "vi" into the map. - pair added = vimap.insert(VertexIndexMap::value_type(vi, 0)); + std::pair added = vimap.insert(VertexIndexMap::value_type(vi, 0)); int new_vertex; if (added.second) { // The insert succeeded. That means this is the first time we have diff --git a/panda/src/text/textFont.cxx b/panda/src/text/textFont.cxx index 866743a5e8..bf6e9c5397 100644 --- a/panda/src/text/textFont.cxx +++ b/panda/src/text/textFont.cxx @@ -21,6 +21,10 @@ #include "geom.h" #include +using std::istream; +using std::ostream; +using std::string; + TypeHandle TextFont::_type_handle; /** diff --git a/panda/src/text/textGlyph.cxx b/panda/src/text/textGlyph.cxx index d68dce6371..bb8d998175 100644 --- a/panda/src/text/textGlyph.cxx +++ b/panda/src/text/textGlyph.cxx @@ -17,6 +17,9 @@ #include "geomVertexReader.h" #include "geomVertexWriter.h" +using std::max; +using std::min; + TypeHandle TextGlyph::_type_handle; /** @@ -252,7 +255,7 @@ make_quad_geom() { // rather than a single triangle strip, to avoid the bad vertex duplication // behavior with lots of two-triangle strips. PT(GeomVertexData) vdata = new GeomVertexData - (string(), GeomVertexFormat::get_v3t2(), Geom::UH_static); + (std::string(), GeomVertexFormat::get_v3t2(), Geom::UH_static); vdata->unclean_set_num_rows(4); PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index 7e0e687ada..19395788c3 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -49,6 +49,8 @@ #include +using std::string; + TypeHandle TextNode::_type_handle; PStatCollector TextNode::_text_generate_pcollector("*:Generate Text"); @@ -252,10 +254,10 @@ is_whitespace(wchar_t character) const { * like \1 or \3. */ PN_stdfloat TextNode:: -calc_width(const wstring &line) const { +calc_width(const std::wstring &line) const { PN_stdfloat width = 0.0f; - wstring::const_iterator si; + std::wstring::const_iterator si; for (si = line.begin(); si != line.end(); ++si) { width += calc_width(*si); } @@ -267,7 +269,7 @@ calc_width(const wstring &line) const { * */ void TextNode:: -output(ostream &out) const { +output(std::ostream &out) const { PandaNode::output(out); check_rebuild(); @@ -283,7 +285,7 @@ output(ostream &out) const { * */ void TextNode:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { PandaNode::write(out, indent_level); TextProperties::write(out, indent_level + 2); indent(out, indent_level + 2) @@ -346,7 +348,7 @@ generate() { CPT(TransformState) transform = TransformState::make_mat(mat); root->set_transform(transform); - wstring wtext = get_wtext(); + std::wstring wtext = get_wtext(); // Assemble the text. TextAssembler assembler(this); diff --git a/panda/src/text/textProperties.cxx b/panda/src/text/textProperties.cxx index dea089b612..42e7982638 100644 --- a/panda/src/text/textProperties.cxx +++ b/panda/src/text/textProperties.cxx @@ -253,7 +253,7 @@ add_properties(const TextProperties &other) { * */ void TextProperties:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { if (!is_any_specified()) { indent(out, indent_level) << "default properties\n"; @@ -408,7 +408,7 @@ get_text_state() const { state = state->add_attrib(CullBinAttrib::make(get_bin(), get_draw_order() + 2)); } - swap(_text_state, state); + std::swap(_text_state, state); return _text_state; } @@ -433,7 +433,7 @@ get_shadow_state() const { state = state->add_attrib(CullBinAttrib::make(get_bin(), get_draw_order() + 1)); } - swap(_shadow_state, state); + std::swap(_shadow_state, state); return _shadow_state; } @@ -466,16 +466,16 @@ load_default_font() { #else // The compiled-in Bam font requires creating a BamFile object to decode it. - string data((const char *)default_font_data, default_font_size); + std::string data((const char *)default_font_data, default_font_size); #ifdef HAVE_ZLIB // The font data is stored compressed; decompress it on-the-fly. - istringstream inz(data); + std::istringstream inz(data); IDecompressStream in(&inz, false); #else // The font data is stored uncompressed, so just load it. - istringstream in(data); + std::istringstream in(data); #endif // HAVE_ZLIB BamFile bam_file; diff --git a/panda/src/text/textPropertiesManager.cxx b/panda/src/text/textPropertiesManager.cxx index c057196e52..1c589499cc 100644 --- a/panda/src/text/textPropertiesManager.cxx +++ b/panda/src/text/textPropertiesManager.cxx @@ -14,6 +14,8 @@ #include "textPropertiesManager.h" #include "indent.h" +using std::string; + TextPropertiesManager *TextPropertiesManager::_global_ptr = nullptr; /** @@ -179,7 +181,7 @@ clear_graphic(const string &name) { * */ void TextPropertiesManager:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Properties::const_iterator pi; for (pi = _properties.begin(); pi != _properties.end(); ++pi) { indent(out, indent_level) diff --git a/panda/src/tform/buttonThrower.cxx b/panda/src/tform/buttonThrower.cxx index 33c7150fb1..2446c1929a 100644 --- a/panda/src/tform/buttonThrower.cxx +++ b/panda/src/tform/buttonThrower.cxx @@ -21,6 +21,8 @@ #include "indent.h" #include "dcast.h" +using std::string; + TypeHandle ButtonThrower::_type_handle; @@ -204,7 +206,7 @@ clear_throw_buttons() { * Throw all events for button events found in the data element. */ void ButtonThrower:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { DataNode::write(out, indent_level); if (_throw_buttons_active) { indent(out, indent_level) @@ -310,7 +312,7 @@ do_general_event(const ButtonEvent &button_event, const string &button_name) { break; case ButtonEvent::T_keystroke: - event->add_parameter(wstring(1, button_event._keycode)); + event->add_parameter(std::wstring(1, button_event._keycode)); break; case ButtonEvent::T_candidate: diff --git a/panda/src/tform/driveInterface.cxx b/panda/src/tform/driveInterface.cxx index e9adfd8829..eb3433c557 100644 --- a/panda/src/tform/driveInterface.cxx +++ b/panda/src/tform/driveInterface.cxx @@ -25,6 +25,9 @@ #include "dataNodeTransmit.h" #include "dataGraphTraverser.h" +using std::max; +using std::min; + TypeHandle DriveInterface::_type_handle; const PN_stdfloat DriveInterface::_hpr_quantize = 0.001; @@ -95,7 +98,7 @@ operator < (const DriveInterface::KeyHeld &other) const { * */ DriveInterface:: -DriveInterface(const string &name) : +DriveInterface(const std::string &name) : MouseInterfaceNode(name) { _xy_input = define_input("xy", EventStoreVec2::get_class_type()); diff --git a/panda/src/tform/mouseInterfaceNode.cxx b/panda/src/tform/mouseInterfaceNode.cxx index 22031c4219..63c6c6cf87 100644 --- a/panda/src/tform/mouseInterfaceNode.cxx +++ b/panda/src/tform/mouseInterfaceNode.cxx @@ -23,7 +23,7 @@ TypeHandle MouseInterfaceNode::_type_handle; * */ MouseInterfaceNode:: -MouseInterfaceNode(const string &name) : +MouseInterfaceNode(const std::string &name) : DataNode(name) { _button_events_input = define_input("button_events", ButtonEventList::get_class_type()); diff --git a/panda/src/tform/mouseSubregion.cxx b/panda/src/tform/mouseSubregion.cxx index f342db85fe..89a5fcca94 100644 --- a/panda/src/tform/mouseSubregion.cxx +++ b/panda/src/tform/mouseSubregion.cxx @@ -20,7 +20,7 @@ TypeHandle MouseSubregion::_type_handle; * */ MouseSubregion:: -MouseSubregion(const string &name) : +MouseSubregion(const std::string &name) : MouseInterfaceNode(name) { _pixel_xy_input = define_input("pixel_xy", EventStoreVec2::get_class_type()); diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 67dbee8591..c4b5c0a6e7 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -35,6 +35,8 @@ #include +using std::string; + TypeHandle MouseWatcher::_type_handle; /** @@ -487,7 +489,7 @@ note_activity() { * */ void MouseWatcher:: -output(ostream &out) const { +output(std::ostream &out) const { LightMutexHolder holder(_lock); DataNode::output(out); @@ -507,7 +509,7 @@ output(ostream &out) const { * */ void MouseWatcher:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "MouseWatcher " << get_name() << ":\n"; MouseWatcherBase::write(out, indent_level + 2); @@ -625,7 +627,7 @@ set_current_regions(MouseWatcher::Regions ®ions) { // Queue up all the new regions so we can send the within patterns all at // once, after all of the without patterns have been thrown. - vector new_regions; + std::vector new_regions; bool any_changes = false; while (new_ri != regions.end() && old_ri != _current_regions.end()) { @@ -672,7 +674,7 @@ set_current_regions(MouseWatcher::Regions ®ions) { _current_regions.swap(regions); // And don't forget to throw all of the new regions' "within" events. - vector::const_iterator ri; + std::vector::const_iterator ri; for (ri = new_regions.begin(); ri != new_regions.end(); ++ri) { MouseWatcherRegion *new_region = (*ri); within_region(new_region, param); @@ -1059,7 +1061,7 @@ keystroke(int keycode) { * IME. */ void MouseWatcher:: -candidate(const wstring &candidate_string, size_t highlight_start, +candidate(const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) { nassertv(_lock.debug_is_locked()); diff --git a/panda/src/tform/mouseWatcherBase.cxx b/panda/src/tform/mouseWatcherBase.cxx index 46c1ae9743..6137ad9b3e 100644 --- a/panda/src/tform/mouseWatcherBase.cxx +++ b/panda/src/tform/mouseWatcherBase.cxx @@ -105,7 +105,7 @@ remove_region(MouseWatcherRegion *region) { * indeterminate. */ MouseWatcherRegion *MouseWatcherBase:: -find_region(const string &name) const { +find_region(const std::string &name) const { LightMutexHolder holder(_lock); for (MouseWatcherRegion *region : _regions) { @@ -169,7 +169,7 @@ get_region(size_t n) const { * */ void MouseWatcherBase:: -output(ostream &out) const { +output(std::ostream &out) const { out << "MouseWatcherGroup (" << _regions.size() << " regions)"; } @@ -177,7 +177,7 @@ output(ostream &out) const { * */ void MouseWatcherBase:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { LightMutexHolder holder(_lock); for (MouseWatcherRegion *region : _regions) { @@ -192,7 +192,7 @@ write(ostream &out, int indent_level) const { * scene graph for the window. */ void MouseWatcherBase:: -show_regions(const NodePath &render2d, const string &bin_name, int draw_order) { +show_regions(const NodePath &render2d, const std::string &bin_name, int draw_order) { LightMutexHolder holder(_lock); do_show_regions(render2d, bin_name, draw_order); } @@ -292,7 +292,7 @@ do_remove_region(MouseWatcherRegion *region) { * already held. */ void MouseWatcherBase:: -do_show_regions(const NodePath &render2d, const string &bin_name, +do_show_regions(const NodePath &render2d, const std::string &bin_name, int draw_order) { do_hide_regions(); _show_regions = true; diff --git a/panda/src/tform/mouseWatcherParameter.cxx b/panda/src/tform/mouseWatcherParameter.cxx index c1a697375e..9cc502694a 100644 --- a/panda/src/tform/mouseWatcherParameter.cxx +++ b/panda/src/tform/mouseWatcherParameter.cxx @@ -17,7 +17,7 @@ * */ void MouseWatcherParameter:: -output(ostream &out) const { +output(std::ostream &out) const { bool output_anything = false; if (has_button()) { diff --git a/panda/src/tform/mouseWatcherRegion.cxx b/panda/src/tform/mouseWatcherRegion.cxx index b9905a4715..2b7465041c 100644 --- a/panda/src/tform/mouseWatcherRegion.cxx +++ b/panda/src/tform/mouseWatcherRegion.cxx @@ -22,7 +22,7 @@ TypeHandle MouseWatcherRegion::_type_handle; * */ void MouseWatcherRegion:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << " lrbt = " << _frame; } @@ -30,7 +30,7 @@ output(ostream &out) const { * */ void MouseWatcherRegion:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_name() << " lrbt = " << _frame << ", sort = " << _sort << "\n"; diff --git a/panda/src/tform/trackball.cxx b/panda/src/tform/trackball.cxx index 620b52950b..b56e1d47fe 100644 --- a/panda/src/tform/trackball.cxx +++ b/panda/src/tform/trackball.cxx @@ -34,7 +34,7 @@ TypeHandle Trackball::_type_handle; * */ Trackball:: -Trackball(const string &name) : +Trackball(const std::string &name) : MouseInterfaceNode(name) { _pixel_xy_input = define_input("pixel_xy", EventStoreVec2::get_class_type()); diff --git a/panda/src/tform/transform2sg.cxx b/panda/src/tform/transform2sg.cxx index 3f7137af56..61f734521f 100644 --- a/panda/src/tform/transform2sg.cxx +++ b/panda/src/tform/transform2sg.cxx @@ -23,7 +23,7 @@ TypeHandle Transform2SG::_type_handle; * */ Transform2SG:: -Transform2SG(const string &name) : +Transform2SG(const std::string &name) : DataNode(name) { _transform_input = define_input("transform", TransformState::get_class_type()); diff --git a/panda/src/tinydisplay/clip.cxx b/panda/src/tinydisplay/clip.cxx index da20a86adc..f2c6baa4ba 100644 --- a/panda/src/tinydisplay/clip.cxx +++ b/panda/src/tinydisplay/clip.cxx @@ -11,6 +11,8 @@ #define CLIP_ZMIN (1<<4) #define CLIP_ZMAX (1<<5) +using std::min; + void gl_transform_to_viewport(GLContext *c,GLVertex *v) { PN_stdfloat winv; diff --git a/panda/src/tinydisplay/store_pixel.cxx b/panda/src/tinydisplay/store_pixel.cxx index 07d5e7bdf4..4ffd8dde30 100644 --- a/panda/src/tinydisplay/store_pixel.cxx +++ b/panda/src/tinydisplay/store_pixel.cxx @@ -17,7 +17,7 @@ /* Pick up all of the generated code references to store_pixel.h. */ -#define STORE_PIX_CLAMP(x) (min((x), (unsigned int)0xffff)) +#define STORE_PIX_CLAMP(x) (std::min((x), (unsigned int)0xffff)) #include "store_pixel_table.h" #include "store_pixel_code.h" diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx index 95599e9b22..ea8e8241a6 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx @@ -25,7 +25,7 @@ TypeHandle TinyGraphicsBuffer::_type_handle; */ TinyGraphicsBuffer:: TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 782d461dc2..3717405893 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -40,6 +40,9 @@ #include "store_pixel_table.h" #include "graphicsEngine.h" +using std::max; +using std::min; + TypeHandle TinyGraphicsStateGuardian::_type_handle; PStatCollector TinyGraphicsStateGuardian::_vertices_immediate_pcollector("Vertices:Immediate mode"); @@ -1790,7 +1793,7 @@ do_issue_light() { */ void TinyGraphicsStateGuardian:: bind_light(PointLight *light_obj, const NodePath &light, int light_id) { - pair lookup = _plights.insert(Lights::value_type(light, GLLight())); + std::pair lookup = _plights.insert(Lights::value_type(light, GLLight())); GLLight *gl_light = &(*lookup.first).second; if (lookup.second) { // It's a brand new light. Define it. @@ -1842,7 +1845,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { */ void TinyGraphicsStateGuardian:: bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { - pair lookup = _dlights.insert(Lights::value_type(light, GLLight())); + std::pair lookup = _dlights.insert(Lights::value_type(light, GLLight())); GLLight *gl_light = &(*lookup.first).second; if (lookup.second) { // It's a brand new light. Define it. @@ -1901,7 +1904,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { */ void TinyGraphicsStateGuardian:: bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { - pair lookup = _plights.insert(Lights::value_type(light, GLLight())); + std::pair lookup = _plights.insert(Lights::value_type(light, GLLight())); GLLight *gl_light = &(*lookup.first).second; if (lookup.second) { // It's a brand new light. Define it. @@ -2010,7 +2013,7 @@ do_issue_render_mode() { default: tinydisplay_cat.error() - << "Unknown render mode " << (int)target_render_mode->get_mode() << endl; + << "Unknown render mode " << (int)target_render_mode->get_mode() << std::endl; } } @@ -2043,7 +2046,7 @@ do_issue_rescale_normal() { default: tinydisplay_cat.error() - << "Unknown rescale_normal mode " << (int)mode << endl; + << "Unknown rescale_normal mode " << (int)mode << std::endl; } } @@ -2089,7 +2092,7 @@ do_issue_cull_face() { break; default: tinydisplay_cat.error() - << "invalid cull face mode " << (int)mode << endl; + << "invalid cull face mode " << (int)mode << std::endl; break; } } diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx index 2e2c517fee..901d874c6d 100644 --- a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx @@ -43,7 +43,7 @@ TinyOffscreenGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinyOffscreenGraphicsPipe:: +std::string TinyOffscreenGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -61,7 +61,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) TinyOffscreenGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx index 6a55f05b94..349fad4398 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx @@ -48,7 +48,7 @@ TinyOsxGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinyOsxGraphicsPipe:: +std::string TinyOsxGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -181,7 +181,7 @@ release_data(void *info, const void *data, size_t size) { * only called from GraphicsEngine::make_output. */ PT(GraphicsOutput) TinyOsxGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx index 7afe0953a4..8a8ef6c54b 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx @@ -55,7 +55,7 @@ TinySDLGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinySDLGraphicsPipe:: +std::string TinySDLGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -73,7 +73,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) TinySDLGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx index d0fe649b79..640adf3d5d 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx @@ -30,7 +30,7 @@ TypeHandle TinySDLGraphicsWindow::_type_handle; */ TinySDLGraphicsWindow:: TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx index 6cfb2dc7c7..adc51e6c9f 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx @@ -43,7 +43,7 @@ TinyWinGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinyWinGraphicsPipe:: +std::string TinyWinGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -62,7 +62,7 @@ pipe_constructor() { * only called from GraphicsEngine::make_output. */ PT(GraphicsOutput) TinyWinGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx index 85f1776ae5..ac16d45bf2 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx @@ -31,7 +31,7 @@ TypeHandle TinyWinGraphicsWindow::_type_handle; */ TinyWinGraphicsWindow:: TinyWinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx index 7bbfbecf79..76cf30050e 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx @@ -27,7 +27,7 @@ TypeHandle TinyXGraphicsPipe::_type_handle; * */ TinyXGraphicsPipe:: -TinyXGraphicsPipe(const string &display) : x11GraphicsPipe(display) { +TinyXGraphicsPipe(const std::string &display) : x11GraphicsPipe(display) { } /** @@ -43,7 +43,7 @@ TinyXGraphicsPipe:: * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string TinyXGraphicsPipe:: +std::string TinyXGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } @@ -61,7 +61,7 @@ pipe_constructor() { * Creates a new window on the pipe, if possible. */ PT(GraphicsOutput) TinyXGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx index 64f1a7c809..e84fa4d834 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx @@ -37,7 +37,7 @@ TypeHandle TinyXGraphicsWindow::_type_handle; */ TinyXGraphicsWindow:: TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -334,7 +334,7 @@ process_events() { if ((Atom)(event.xclient.data.l[0]) == _wm_delete_window) { // This is a message from the window manager indicating that the user // has requested to close the window. - string close_request_event = get_close_request_event(); + std::string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { // In this case, the app has indicated a desire to intercept the // request and process it directly. diff --git a/panda/src/tinydisplay/zbuffer.cxx b/panda/src/tinydisplay/zbuffer.cxx index 45dbe1b0a2..ceab7790d8 100644 --- a/panda/src/tinydisplay/zbuffer.cxx +++ b/panda/src/tinydisplay/zbuffer.cxx @@ -24,6 +24,9 @@ int pixel_count_smooth_multitex2; int pixel_count_smooth_multitex3; #endif // DO_PSTATS +using std::max; +using std::min; + ZBuffer * ZB_open(int xsize, int ysize, int mode, int nb_colors, diff --git a/panda/src/vision/arToolKit.cxx b/panda/src/vision/arToolKit.cxx index 9d990cc26b..cb9a73508d 100644 --- a/panda/src/vision/arToolKit.cxx +++ b/panda/src/vision/arToolKit.cxx @@ -145,7 +145,7 @@ make(NodePath camera, const Filename ¶mfile, double marker_size) { } ARParam wparam; - string fn = paramfile.to_os_specific(); + std::string fn = paramfile.to_os_specific(); if( arParamLoad(fn.c_str(), 1, &wparam) < 0 ) { vision_cat.error() << "Cannot load ARToolKit camera config\n"; return 0; @@ -206,7 +206,7 @@ get_pattern(const Filename &filename) { return (*ptf).second; } - string fn = filename.to_os_specific(); + std::string fn = filename.to_os_specific(); int id = arLoadPatt(fn.c_str()); if (id < 0) { vision_cat.error() << "Could not load AR ToolKit Pattern: " << fn << "\n"; diff --git a/panda/src/vision/openCVTexture.cxx b/panda/src/vision/openCVTexture.cxx index e6deea17ea..702e0932af 100644 --- a/panda/src/vision/openCVTexture.cxx +++ b/panda/src/vision/openCVTexture.cxx @@ -43,7 +43,7 @@ TypeHandle OpenCVTexture::_type_handle; * Sets up the texture to read frames from a camera */ OpenCVTexture:: -OpenCVTexture(const string &name) : +OpenCVTexture(const std::string &name) : VideoTexture(name) { } @@ -70,7 +70,7 @@ consider_update() { } else { // Loop through the pages to see if there's any camera stream to update. Texture::CDWriter cdata(Texture::_cycler, false); - int max_z = max(cdata->_z_size, (int)_pages.size()); + int max_z = std::max(cdata->_z_size, (int)_pages.size()); for (int z = 0; z < max_z; ++z) { VideoPage &page = _pages[z]; if (!page._color.is_from_file() || !page._alpha.is_from_file()) { @@ -258,7 +258,7 @@ make_texture() { */ void OpenCVTexture:: do_update_frame(Texture::CData *cdata, int frame) { - int max_z = max(cdata->_z_size, (int)_pages.size()); + int max_z = std::max(cdata->_z_size, (int)_pages.size()); for (int z = 0; z < max_z; ++z) { do_update_frame(cdata, frame, z); } @@ -446,7 +446,7 @@ do_read_one(Texture::CData *cdata, */ bool OpenCVTexture:: do_load_one(Texture::CData *cdata, - const PNMImage &pnmimage, const string &name, + const PNMImage &pnmimage, const std::string &name, int z, int n, const LoaderOptions &options) { if (z <= (int)_pages.size()) { VideoPage &page = do_modify_page(cdata, z); @@ -581,7 +581,7 @@ bool OpenCVTexture::VideoStream:: read(const Filename &filename) { clear(); - string os_specific = filename.to_os_specific(); + std::string os_specific = filename.to_os_specific(); _capture = cvCaptureFromFile(os_specific.c_str()); if (_capture == nullptr) { return false; diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index 853f3e070f..95565f9428 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -30,7 +30,7 @@ extern "C" { TypeHandle WebcamVideoCursorV4L::_type_handle; -#define clamp(x) min(max(x, 0.0), 255.0) +#define clamp(x) std::min(std::max(x, 0.0), 255.0) INLINE static void yuv_to_bgr(unsigned char *dest, const unsigned char *src) { double y1 = (255 / 219.0) * (src[0] - 16); diff --git a/panda/src/vision/webcamVideoDS.cxx b/panda/src/vision/webcamVideoDS.cxx index 79510cf24d..531328b206 100644 --- a/panda/src/vision/webcamVideoDS.cxx +++ b/panda/src/vision/webcamVideoDS.cxx @@ -58,6 +58,9 @@ #include #include +using std::cerr; +using std::string; + /* * This used to work back when qedit.h still existed. The hacks served to * prevent it from including the defunct dxtrans.h. #pragma include_alias( diff --git a/panda/src/vision/webcamVideoOpenCV.cxx b/panda/src/vision/webcamVideoOpenCV.cxx index d4c68070fa..e7cadf8c69 100644 --- a/panda/src/vision/webcamVideoOpenCV.cxx +++ b/panda/src/vision/webcamVideoOpenCV.cxx @@ -46,7 +46,7 @@ WebcamVideoOpenCV:: WebcamVideoOpenCV(int camera_index) : _camera_index(camera_index) { - ostringstream strm; + std::ostringstream strm; strm << "OpenCV webcam " << _camera_index; set_name(strm.str()); } diff --git a/panda/src/vision/webcamVideoV4L.cxx b/panda/src/vision/webcamVideoV4L.cxx index 7d5636f4e0..bc6cad7a1b 100644 --- a/panda/src/vision/webcamVideoV4L.cxx +++ b/panda/src/vision/webcamVideoV4L.cxx @@ -94,7 +94,7 @@ TypeHandle WebcamVideoV4L::_type_handle; * */ void WebcamVideoV4L:: -add_options_for_size(int fd, const string &dev, const char *name, unsigned width, unsigned height, unsigned pixelformat) { +add_options_for_size(int fd, const std::string &dev, const char *name, unsigned width, unsigned height, unsigned pixelformat) { struct v4l2_frmivalenum frmivalenum; for (int k = 0;; k++) { memset(&frmivalenum, 0, sizeof frmivalenum); @@ -132,7 +132,7 @@ add_options_for_size(int fd, const string &dev, const char *name, unsigned width wc->_size_y = height; wc->_fps = fps; wc->_pformat = pixelformat; - wc->_pixel_format = string((char*) &pixelformat, 4); + wc->_pixel_format = std::string((char*) &pixelformat, 4); WebcamVideoV4L::_all_webcams.push_back(DCAST(WebcamVideo, wc)); } diff --git a/panda/src/vrpn/vrpnAnalog.cxx b/panda/src/vrpn/vrpnAnalog.cxx index 0934f7a8d8..d0d1b773ca 100644 --- a/panda/src/vrpn/vrpnAnalog.cxx +++ b/panda/src/vrpn/vrpnAnalog.cxx @@ -24,7 +24,7 @@ * */ VrpnAnalog:: -VrpnAnalog(const string &analog_name, vrpn_Connection *connection) : +VrpnAnalog(const std::string &analog_name, vrpn_Connection *connection) : _analog_name(analog_name) { _analog = new vrpn_Analog_Remote(_analog_name.c_str(), connection); @@ -74,7 +74,7 @@ unmark(VrpnAnalogDevice *device) { * */ void VrpnAnalog:: -output(ostream &out) const { +output(std::ostream &out) const { out << _analog_name; } @@ -82,7 +82,7 @@ output(ostream &out) const { * */ void VrpnAnalog:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_analog_name() << " (" << _devices.size() << " devices)\n"; diff --git a/panda/src/vrpn/vrpnAnalogDevice.cxx b/panda/src/vrpn/vrpnAnalogDevice.cxx index 00da1a2240..101f097c52 100644 --- a/panda/src/vrpn/vrpnAnalogDevice.cxx +++ b/panda/src/vrpn/vrpnAnalogDevice.cxx @@ -20,7 +20,7 @@ TypeHandle VrpnAnalogDevice::_type_handle; * */ VrpnAnalogDevice:: -VrpnAnalogDevice(VrpnClient *client, const string &device_name, +VrpnAnalogDevice(VrpnClient *client, const std::string &device_name, VrpnAnalog *vrpn_analog) : ClientAnalogDevice(client, device_name), _vrpn_analog(vrpn_analog) diff --git a/panda/src/vrpn/vrpnButton.cxx b/panda/src/vrpn/vrpnButton.cxx index cf17f6bade..71af239f88 100644 --- a/panda/src/vrpn/vrpnButton.cxx +++ b/panda/src/vrpn/vrpnButton.cxx @@ -24,7 +24,7 @@ * */ VrpnButton:: -VrpnButton(const string &button_name, vrpn_Connection *connection) : +VrpnButton(const std::string &button_name, vrpn_Connection *connection) : _button_name(button_name) { _button = new vrpn_Button_Remote(_button_name.c_str(), connection); @@ -74,7 +74,7 @@ unmark(VrpnButtonDevice *device) { * */ void VrpnButton:: -output(ostream &out) const { +output(std::ostream &out) const { out << _button_name; } @@ -82,7 +82,7 @@ output(ostream &out) const { * */ void VrpnButton:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_button_name() << " (" << _devices.size() << " devices)\n"; diff --git a/panda/src/vrpn/vrpnButtonDevice.cxx b/panda/src/vrpn/vrpnButtonDevice.cxx index a392bbce49..eb287d2f5e 100644 --- a/panda/src/vrpn/vrpnButtonDevice.cxx +++ b/panda/src/vrpn/vrpnButtonDevice.cxx @@ -20,7 +20,7 @@ TypeHandle VrpnButtonDevice::_type_handle; * */ VrpnButtonDevice:: -VrpnButtonDevice(VrpnClient *client, const string &device_name, +VrpnButtonDevice(VrpnClient *client, const std::string &device_name, VrpnButton *vrpn_button) : ClientButtonDevice(client, device_name), _vrpn_button(vrpn_button) diff --git a/panda/src/vrpn/vrpnClient.cxx b/panda/src/vrpn/vrpnClient.cxx index 068d7614a0..1fb7fcb4ff 100644 --- a/panda/src/vrpn/vrpnClient.cxx +++ b/panda/src/vrpn/vrpnClient.cxx @@ -26,6 +26,8 @@ #include "string_utils.h" #include "indent.h" +using std::string; + TypeHandle VrpnClient::_type_handle; /** @@ -63,7 +65,7 @@ VrpnClient:: * polling each frame. */ void VrpnClient:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "VrpnClient, server " << _server_name << "\n"; diff --git a/panda/src/vrpn/vrpnDial.cxx b/panda/src/vrpn/vrpnDial.cxx index 57de1bd59c..5c06f797ee 100644 --- a/panda/src/vrpn/vrpnDial.cxx +++ b/panda/src/vrpn/vrpnDial.cxx @@ -24,7 +24,7 @@ * */ VrpnDial:: -VrpnDial(const string &dial_name, vrpn_Connection *connection) : +VrpnDial(const std::string &dial_name, vrpn_Connection *connection) : _dial_name(dial_name) { _dial = new vrpn_Dial_Remote(_dial_name.c_str(), connection); @@ -74,7 +74,7 @@ unmark(VrpnDialDevice *device) { * */ void VrpnDial:: -output(ostream &out) const { +output(std::ostream &out) const { out << _dial_name; } @@ -82,7 +82,7 @@ output(ostream &out) const { * */ void VrpnDial:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_dial_name() << " (" << _devices.size() << " devices)\n"; diff --git a/panda/src/vrpn/vrpnDialDevice.cxx b/panda/src/vrpn/vrpnDialDevice.cxx index 77be871f73..6331fb8a02 100644 --- a/panda/src/vrpn/vrpnDialDevice.cxx +++ b/panda/src/vrpn/vrpnDialDevice.cxx @@ -20,7 +20,7 @@ TypeHandle VrpnDialDevice::_type_handle; * */ VrpnDialDevice:: -VrpnDialDevice(VrpnClient *client, const string &device_name, +VrpnDialDevice(VrpnClient *client, const std::string &device_name, VrpnDial *vrpn_dial) : ClientDialDevice(client, device_name), _vrpn_dial(vrpn_dial) diff --git a/panda/src/vrpn/vrpnTracker.cxx b/panda/src/vrpn/vrpnTracker.cxx index 6427c6c392..6e4e196769 100644 --- a/panda/src/vrpn/vrpnTracker.cxx +++ b/panda/src/vrpn/vrpnTracker.cxx @@ -24,7 +24,7 @@ * */ VrpnTracker:: -VrpnTracker(const string &tracker_name, vrpn_Connection *connection) : +VrpnTracker(const std::string &tracker_name, vrpn_Connection *connection) : _tracker_name(tracker_name) { _tracker = new vrpn_Tracker_Remote(_tracker_name.c_str(), connection); @@ -76,7 +76,7 @@ unmark(VrpnTrackerDevice *device) { * */ void VrpnTracker:: -output(ostream &out) const { +output(std::ostream &out) const { out << _tracker_name; } @@ -84,7 +84,7 @@ output(ostream &out) const { * */ void VrpnTracker:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_tracker_name() << " (" << _devices.size() << " devices)\n"; diff --git a/panda/src/vrpn/vrpnTrackerDevice.cxx b/panda/src/vrpn/vrpnTrackerDevice.cxx index 5484df2c23..980f9cf77c 100644 --- a/panda/src/vrpn/vrpnTrackerDevice.cxx +++ b/panda/src/vrpn/vrpnTrackerDevice.cxx @@ -20,7 +20,7 @@ TypeHandle VrpnTrackerDevice::_type_handle; * */ VrpnTrackerDevice:: -VrpnTrackerDevice(VrpnClient *client, const string &device_name, +VrpnTrackerDevice(VrpnClient *client, const std::string &device_name, int sensor, VrpnTrackerDevice::DataType data_type, VrpnTracker *vrpn_tracker) : ClientTrackerDevice(client, device_name), diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index 868ff727b2..aacedf0ae3 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -28,7 +28,7 @@ TypeHandle wglGraphicsBuffer::_type_handle; */ wglGraphicsBuffer:: wglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/wgldisplay/wglGraphicsPipe.cxx b/panda/src/wgldisplay/wglGraphicsPipe.cxx index abffe1e1ee..1a55059dbd 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.cxx +++ b/panda/src/wgldisplay/wglGraphicsPipe.cxx @@ -66,7 +66,7 @@ wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector) { * choose between several possible GraphicsPipes available on a particular * platform, so the name should be meaningful and unique for a given platform. */ -string wglGraphicsPipe:: +std::string wglGraphicsPipe:: get_interface_name() const { return "OpenGL"; } @@ -85,7 +85,7 @@ pipe_constructor() { * only called from GraphicsEngine::make_output. */ PT(GraphicsOutput) wglGraphicsPipe:: -make_output(const string &name, +make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -232,7 +232,7 @@ make_callback_gsg(GraphicsEngine *engine) { /** * Returns pfd_flags formatted as a string in a user-friendly way. */ -string wglGraphicsPipe:: +std::string wglGraphicsPipe:: format_pfd_flags(DWORD pfd_flags) { struct FlagDef { DWORD flag; @@ -255,7 +255,7 @@ format_pfd_flags(DWORD pfd_flags) { }; static const int num_flag_defs = sizeof(flag_def) / sizeof(FlagDef); - ostringstream out; + std::ostringstream out; const char *sep = ""; bool got_any = false; @@ -269,7 +269,7 @@ format_pfd_flags(DWORD pfd_flags) { } if (pfd_flags != 0 || !got_any) { - out << sep << hex << "0x" << pfd_flags << dec; + out << sep << std::hex << "0x" << pfd_flags << std::dec; } return out.str(); diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index 0d6f78ae1c..b1dc143da5 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -395,7 +395,7 @@ choose_pixel_format(const FrameBufferProperties &properties, max_pformats, pformat, (unsigned int *)&nformats)) { nformats = 0; } - nformats = min(nformats, max_pformats); + nformats = std::min(nformats, max_pformats); if (wgldisplay_cat.is_debug()) { wgldisplay_cat.debug() @@ -706,7 +706,7 @@ make_twindow() { if (!_twindow) { wgldisplay_cat.error() - << "CreateWindow() failed!" << endl; + << "CreateWindow() failed!" << std::endl; return false; } @@ -764,7 +764,7 @@ register_twindow_class() { if (!RegisterClass(&wc)) { wgldisplay_cat.error() - << "could not register window class!" << endl; + << "could not register window class!" << std::endl; return; } _twindow_class_registered = true; diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index fcba0b8bf4..d6a892ee30 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -28,7 +28,7 @@ TypeHandle wglGraphicsWindow::_type_handle; */ wglGraphicsWindow:: wglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -386,7 +386,7 @@ print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) { wgldisplay_cat.debug() << msg << ", " << OGLDrvStrings[drvtype] << " driver\n" - << "PFD flags: 0x" << hex << pfd->dwFlags << dec << " (" + << "PFD flags: 0x" << std::hex << pfd->dwFlags << std::dec << " (" << PRINT_FLAG(GENERIC_ACCELERATED) << PRINT_FLAG(GENERIC_FORMAT) << PRINT_FLAG(DOUBLEBUFFER) @@ -403,15 +403,15 @@ print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) { << PRINT_FLAG(SUPPORT_DIRECTDRAW) << ")\n" << "PFD iPixelType: " << ((pfd->iPixelType==PFD_TYPE_RGBA) ? "PFD_TYPE_RGBA":"PFD_TYPE_COLORINDEX") - << endl + << std::endl << "PFD cColorBits: " << (DWORD)pfd->cColorBits << " R: " << (DWORD)pfd->cRedBits <<" G: " << (DWORD)pfd->cGreenBits - <<" B: " << (DWORD)pfd->cBlueBits << endl + <<" B: " << (DWORD)pfd->cBlueBits << std::endl << "PFD cAlphaBits: " << (DWORD)pfd->cAlphaBits << " DepthBits: " << (DWORD)pfd->cDepthBits <<" StencilBits: " << (DWORD)pfd->cStencilBits <<" AccumBits: " << (DWORD)pfd->cAccumBits - << endl; + << std::endl; } #endif diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index bd8244e880..eee4a30365 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -37,6 +37,9 @@ // Not used on Windows XP, but we still need to define it. #define TOUCH_COORD_TO_PIXEL(l) ((l) / 100) +using std::endl; +using std::wstring; + DECLARE_HANDLE(HTOUCHINPUT); #endif @@ -82,7 +85,7 @@ static PFN_CLOSETOUCHINPUTHANDLE pCloseTouchInputHandle = 0; */ WinGraphicsWindow:: WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -257,7 +260,7 @@ set_properties_now(WindowProperties &properties) { } if (properties.has_title()) { - string title = properties.get_title(); + std::string title = properties.get_title(); _properties.set_title(title); TextEncoder encoder; wstring title_w = encoder.decode_text(title); @@ -1359,7 +1362,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { // This is a message from the system indicating that the user has // requested to close the window (e.g. alt-f4). { - string close_request_event = get_close_request_event(); + std::string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { // In this case, the app has indicated a desire to intercept the // request and process it directly. @@ -1724,8 +1727,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { size_t num_chars = result_size / sizeof(wchar_t); _input_devices[0].candidate(wstring(ime_buffer, num_chars), - min(cursor_pos, delta_start), - max(cursor_pos, delta_start), + std::min(cursor_pos, delta_start), + std::max(cursor_pos, delta_start), cursor_pos); } ImmReleaseContext(hwnd, hIMC); @@ -2829,7 +2832,7 @@ register_window_class(const WindowProperties &props) { wclass_name << L"WinGraphicsWindow" << _window_class_index; wcreg._name = wclass_name.str(); - pair found = _window_classes.insert(wcreg); + std::pair found = _window_classes.insert(wcreg); const WindowClass &wclass = (*found.first); if (!found.second) { diff --git a/panda/src/x11display/x11GraphicsPipe.cxx b/panda/src/x11display/x11GraphicsPipe.cxx index 494da180da..2348d58706 100644 --- a/panda/src/x11display/x11GraphicsPipe.cxx +++ b/panda/src/x11display/x11GraphicsPipe.cxx @@ -33,12 +33,12 @@ LightReMutex x11GraphicsPipe::_x_mutex; * */ x11GraphicsPipe:: -x11GraphicsPipe(const string &display) : +x11GraphicsPipe(const std::string &display) : _have_xrandr(false), _xcursor_size(-1), _XF86DGADirectVideo(nullptr) { - string display_spec = display; + std::string display_spec = display; if (display_spec.empty()) { display_spec = display_cfg; } diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 5fb290e315..0187139828 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -38,6 +38,10 @@ #include #endif +using std::istream; +using std::ostringstream; +using std::string; + struct _XcursorFile { void *closure; int (*read)(XcursorFile *, unsigned char *, int); @@ -1912,7 +1916,7 @@ map_button(KeySym key) const { } if (x11display_cat.is_debug()) { x11display_cat.debug() - << "Unrecognized keysym 0x" << hex << key << dec << "\n"; + << "Unrecognized keysym 0x" << std::hex << key << std::dec << "\n"; } return ButtonHandle::none(); } diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index 4694e89217..61c7514aa6 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -41,6 +41,10 @@ #include "postprocess.h" +using std::ostringstream; +using std::stringstream; +using std::string; + struct BoneWeight { CPT(JointVertexTransform) joint_vertex_xform; float weight; diff --git a/pandatool/src/assimp/loaderFileTypeAssimp.cxx b/pandatool/src/assimp/loaderFileTypeAssimp.cxx index 3f344b2674..73c27ee7d4 100644 --- a/pandatool/src/assimp/loaderFileTypeAssimp.cxx +++ b/pandatool/src/assimp/loaderFileTypeAssimp.cxx @@ -15,6 +15,8 @@ #include "config_assimp.h" #include "assimpLoader.h" +using std::string; + TypeHandle LoaderFileTypeAssimp::_type_handle; /** diff --git a/pandatool/src/assimp/pandaIOStream.cxx b/pandatool/src/assimp/pandaIOStream.cxx index e4dde48e79..ad610d608f 100644 --- a/pandatool/src/assimp/pandaIOStream.cxx +++ b/pandatool/src/assimp/pandaIOStream.cxx @@ -13,12 +13,13 @@ #include "pandaIOStream.h" +using std::ios; /** * */ PandaIOStream:: -PandaIOStream(istream &stream) : _istream(stream) { +PandaIOStream(std::istream &stream) : _istream(stream) { } /** @@ -26,9 +27,9 @@ PandaIOStream(istream &stream) : _istream(stream) { */ size_t PandaIOStream:: FileSize() const { - streampos cur = _istream.tellg(); + std::streampos cur = _istream.tellg(); _istream.seekg(0, ios::end); - streampos end = _istream.tellg(); + std::streampos end = _istream.tellg(); _istream.seekg(cur, ios::beg); return end; } diff --git a/pandatool/src/assimp/pandaIOSystem.cxx b/pandatool/src/assimp/pandaIOSystem.cxx index ff400bd285..87dea240d2 100644 --- a/pandatool/src/assimp/pandaIOSystem.cxx +++ b/pandatool/src/assimp/pandaIOSystem.cxx @@ -72,7 +72,7 @@ Open(const char *file, const char *mode) { Filename fn = Filename::from_os_specific(file); if (mode[0] == 'r') { - istream *stream = _vfs->open_read_file(file, true); + std::istream *stream = _vfs->open_read_file(file, true); if (stream == nullptr) { return nullptr; } diff --git a/pandatool/src/bam/bamInfo.cxx b/pandatool/src/bam/bamInfo.cxx index bda00908a5..a30a5066dd 100644 --- a/pandatool/src/bam/bamInfo.cxx +++ b/pandatool/src/bam/bamInfo.cxx @@ -234,7 +234,7 @@ describe_session(RecorderHeader *header, const BamInfo::Objects &objects) { strftime(time_buffer, 1024, "%c", localtime(&header->_start_time)); - pset recorders; + pset recorders; double last_timestamp = 0.0; for (size_t i = 1; i < objects.size(); i++) { @@ -256,7 +256,7 @@ describe_session(RecorderHeader *header, const BamInfo::Objects &objects) { << " secs, " << objects.size() - 1 << " frames, " << time_buffer << ".\n" << "Recorders:"; - for (pset::iterator ni = recorders.begin(); + for (pset::iterator ni = recorders.begin(); ni != recorders.end(); ++ni) { nout << " " << (*ni); diff --git a/pandatool/src/bam/eggToBam.cxx b/pandatool/src/bam/eggToBam.cxx index 7522a70cc6..a7e760d29c 100644 --- a/pandatool/src/bam/eggToBam.cxx +++ b/pandatool/src/bam/eggToBam.cxx @@ -246,7 +246,7 @@ run() { if (_ctex_quality != "default") { // Override the user's config file with the command-line parameter for // texture compression. - string prc = "texture-quality-level " + _ctex_quality; + std::string prc = "texture-quality-level " + _ctex_quality; load_prc_file_data("prc", prc); } @@ -442,7 +442,7 @@ bool EggToBam:: make_buffer() { if (!_load_display.empty()) { // Override the user's config file with the command-line parameter. - string prc = "load-display " + _load_display; + std::string prc = "load-display " + _load_display; load_prc_file_data("prc", prc); } diff --git a/pandatool/src/bam/ptsToBam.cxx b/pandatool/src/bam/ptsToBam.cxx index 538022bfbc..0059df8616 100644 --- a/pandatool/src/bam/ptsToBam.cxx +++ b/pandatool/src/bam/ptsToBam.cxx @@ -22,6 +22,8 @@ #include "string_utils.h" #include "config_egg2pg.h" +using std::string; + /** * */ @@ -71,7 +73,7 @@ run() { _num_points_expected = 0; _num_points_found = 0; _num_points_added = 0; - _decimate_factor = 1.0 / max(1.0, _decimate_divisor); + _decimate_factor = 1.0 / std::max(1.0, _decimate_divisor); _line_number = 0; _point_number = 0; _decimated_point_number = 0.0; @@ -215,7 +217,7 @@ close_vertex_data() { int num_vertices = _data->get_num_rows(); int vertices_so_far = 0; while (num_vertices > 0) { - int this_num_vertices = min(num_vertices, (int)egg_max_indices); + int this_num_vertices = std::min(num_vertices, (int)egg_max_indices); PT(GeomPrimitive) points = new GeomPoints(GeomEnums::UH_static); points->add_consecutive_vertices(vertices_so_far, this_num_vertices); geom->add_primitive(points); diff --git a/pandatool/src/converter/eggToSomethingConverter.cxx b/pandatool/src/converter/eggToSomethingConverter.cxx index 1e1629fe1b..0f357883c8 100644 --- a/pandatool/src/converter/eggToSomethingConverter.cxx +++ b/pandatool/src/converter/eggToSomethingConverter.cxx @@ -54,9 +54,9 @@ set_egg_data(EggData *egg_data) { * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this converter. */ -string EggToSomethingConverter:: +std::string EggToSomethingConverter:: get_additional_extensions() const { - return string(); + return std::string(); } /** diff --git a/pandatool/src/converter/somethingToEggConverter.cxx b/pandatool/src/converter/somethingToEggConverter.cxx index 58c914b7f5..8911021a0a 100644 --- a/pandatool/src/converter/somethingToEggConverter.cxx +++ b/pandatool/src/converter/somethingToEggConverter.cxx @@ -71,9 +71,9 @@ set_egg_data(EggData *egg_data) { * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this converter. */ -string SomethingToEggConverter:: +std::string SomethingToEggConverter:: get_additional_extensions() const { - return string(); + return std::string(); } /** diff --git a/pandatool/src/cvscopy/cvsCopy.cxx b/pandatool/src/cvscopy/cvsCopy.cxx index cc970748a0..17dd07eb66 100644 --- a/pandatool/src/cvscopy/cvsCopy.cxx +++ b/pandatool/src/cvscopy/cvsCopy.cxx @@ -17,6 +17,8 @@ #include "pnotify.h" #include +using std::string; + /** * */ diff --git a/pandatool/src/cvscopy/cvsSourceDirectory.cxx b/pandatool/src/cvscopy/cvsSourceDirectory.cxx index 9ccacc3afd..0eb741044d 100644 --- a/pandatool/src/cvscopy/cvsSourceDirectory.cxx +++ b/pandatool/src/cvscopy/cvsSourceDirectory.cxx @@ -17,6 +17,8 @@ #include "pnotify.h" +using std::string; + /** * */ diff --git a/pandatool/src/cvscopy/cvsSourceTree.cxx b/pandatool/src/cvscopy/cvsSourceTree.cxx index 69b483fa3c..8511afac6a 100644 --- a/pandatool/src/cvscopy/cvsSourceTree.cxx +++ b/pandatool/src/cvscopy/cvsSourceTree.cxx @@ -28,6 +28,8 @@ #include // for chdir #endif +using std::string; + bool CVSSourceTree::_got_start_fullpath = false; Filename CVSSourceTree::_start_fullpath; @@ -440,7 +442,7 @@ string CVSSourceTree:: prompt(const string &message) { nout << std::flush; while (true) { - cerr << message << std::flush; + std::cerr << message << std::flush; std::string response; std::getline(std::cin, response); diff --git a/pandatool/src/daeegg/daeCharacter.cxx b/pandatool/src/daeegg/daeCharacter.cxx index 3b98fa80a7..39aee067bd 100644 --- a/pandatool/src/daeegg/daeCharacter.cxx +++ b/pandatool/src/daeegg/daeCharacter.cxx @@ -76,7 +76,7 @@ bind_joints(JointMap &joint_map) { // Record the bind pose for each joint. for (size_t j = 0; j < num_joints; ++j) { const FCDSkinControllerJoint *skin_joint = _skin_controller->GetJoint(j); - string sid = FROM_FSTRING(skin_joint->GetId()); + std::string sid = FROM_FSTRING(skin_joint->GetId()); LMatrix4d bind_pose; bind_pose.invert_from(DAEToEggConverter::convert_matrix( skin_joint->GetBindPoseInverse())); @@ -126,7 +126,7 @@ adjust_joints(FCDSceneNode *node, const JointMap &joint_map, LMatrix4d this_transform = transform; if (node->IsJoint()) { - string sid = FROM_FSTRING(node->GetSubId()); + std::string sid = FROM_FSTRING(node->GetSubId()); JointMap::const_iterator ji = joint_map.find(sid); if (ji != joint_map.end()) { @@ -252,7 +252,7 @@ build_table(EggTable *parent, FCDSceneNode* node, const pset &keys) { return; } - string node_id = FROM_FSTRING(node->GetDaeId()); + std::string node_id = FROM_FSTRING(node->GetDaeId()); PT(EggTable) table = new EggTable(node_id); table->set_table_type(EggTable::TT_table); parent->add_child(table); diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx index 0c15fe819d..6aab105cc7 100644 --- a/pandatool/src/daeegg/daeMaterials.cxx +++ b/pandatool/src/daeegg/daeMaterials.cxx @@ -25,6 +25,9 @@ #include "filename.h" #include "string_utils.h" +using std::endl; +using std::string; + TypeHandle DaeMaterials::_type_handle; // luminance function, based on the ISOCIE color standards see ITU-R diff --git a/pandatool/src/daeegg/daeToEggConverter.cxx b/pandatool/src/daeegg/daeToEggConverter.cxx index f054643d7b..00c20a36da 100644 --- a/pandatool/src/daeegg/daeToEggConverter.cxx +++ b/pandatool/src/daeegg/daeToEggConverter.cxx @@ -48,6 +48,9 @@ #include "FCDocument/FCDGeometryPolygonsInput.h" #endif +using std::endl; +using std::string; + /** * */ diff --git a/pandatool/src/daeegg/pre_fcollada_include.h b/pandatool/src/daeegg/pre_fcollada_include.h index 18cbe7a45d..59ad054c2a 100644 --- a/pandatool/src/daeegg/pre_fcollada_include.h +++ b/pandatool/src/daeegg/pre_fcollada_include.h @@ -38,4 +38,8 @@ #define NO_LIBXML #define FCOLLADA_NOMINMAX +// FCollada does use global min/max. +using std::min; +using std::max; + #endif diff --git a/pandatool/src/daeprogs/daeToEgg.cxx b/pandatool/src/daeprogs/daeToEgg.cxx index c3ba781361..e00747344a 100644 --- a/pandatool/src/daeprogs/daeToEgg.cxx +++ b/pandatool/src/daeprogs/daeToEgg.cxx @@ -49,7 +49,7 @@ void DAEToEgg:: run() { if (_animation_convert != AC_both && _animation_convert != AC_none && _animation_convert != AC_chan && _animation_convert != AC_model) { - cerr << "Unsupported animation convert option.\n"; + std::cerr << "Unsupported animation convert option.\n"; exit(1); } diff --git a/pandatool/src/daeprogs/eggToDAE.cxx b/pandatool/src/daeprogs/eggToDAE.cxx index cc3d9facf4..b9652e698f 100644 --- a/pandatool/src/daeprogs/eggToDAE.cxx +++ b/pandatool/src/daeprogs/eggToDAE.cxx @@ -28,6 +28,8 @@ #define FROM_MAT4(v) (FMMatrix44(v.get_data())) #define FROM_FSTRING(fs) (fs.c_str()) +using std::cerr; + /** * */ diff --git a/pandatool/src/dxf/dxfFile.cxx b/pandatool/src/dxf/dxfFile.cxx index 0637c97d39..f5bb6e0912 100644 --- a/pandatool/src/dxf/dxfFile.cxx +++ b/pandatool/src/dxf/dxfFile.cxx @@ -15,6 +15,10 @@ #include "string_utils.h" #include "virtualFileSystem.h" +using std::istream; +using std::ostream; +using std::string; + DXFFile::Color DXFFile::_colors[DXF_num_colors] = { { 1, 1, 1 }, // Color 0 is not used. { 1, 0, 0 }, // Color 1 = Red diff --git a/pandatool/src/dxf/dxfLayer.cxx b/pandatool/src/dxf/dxfLayer.cxx index 5ffc96a5cc..6803cc179e 100644 --- a/pandatool/src/dxf/dxfLayer.cxx +++ b/pandatool/src/dxf/dxfLayer.cxx @@ -18,7 +18,7 @@ * */ DXFLayer:: -DXFLayer(const string &name) : Namable(name) { +DXFLayer(const std::string &name) : Namable(name) { } /** diff --git a/pandatool/src/dxf/dxfLayerMap.cxx b/pandatool/src/dxf/dxfLayerMap.cxx index 447b27e8ca..d2049c8191 100644 --- a/pandatool/src/dxf/dxfLayerMap.cxx +++ b/pandatool/src/dxf/dxfLayerMap.cxx @@ -22,7 +22,7 @@ * this function to create a specialized time, if desired. */ DXFLayer *DXFLayerMap:: -get_layer(const string &name, DXFFile *dxffile) { +get_layer(const std::string &name, DXFFile *dxffile) { iterator lmi; lmi = find(name); if (lmi != end()) { diff --git a/pandatool/src/dxfegg/dxfToEggConverter.cxx b/pandatool/src/dxfegg/dxfToEggConverter.cxx index 3620f96abd..6ba6411940 100644 --- a/pandatool/src/dxfegg/dxfToEggConverter.cxx +++ b/pandatool/src/dxfegg/dxfToEggConverter.cxx @@ -50,7 +50,7 @@ make_copy() { /** * Returns the English name of the file type this converter supports. */ -string DXFToEggConverter:: +std::string DXFToEggConverter:: get_name() const { return "DXF"; } @@ -58,7 +58,7 @@ get_name() const { /** * Returns the common extension of the file type this converter supports. */ -string DXFToEggConverter:: +std::string DXFToEggConverter:: get_extension() const { return "dxf"; } @@ -92,7 +92,7 @@ convert_file(const Filename &filename) { * */ DXFLayer *DXFToEggConverter:: -new_layer(const string &name) { +new_layer(const std::string &name) { return new DXFToEggLayer(name, get_egg_data()); } diff --git a/pandatool/src/dxfegg/dxfToEggLayer.cxx b/pandatool/src/dxfegg/dxfToEggLayer.cxx index 333cd5a69e..3ecb915efb 100644 --- a/pandatool/src/dxfegg/dxfToEggLayer.cxx +++ b/pandatool/src/dxfegg/dxfToEggLayer.cxx @@ -26,7 +26,7 @@ * */ DXFToEggLayer:: -DXFToEggLayer(const string &name, EggGroupNode *parent) : DXFLayer(name) { +DXFToEggLayer(const std::string &name, EggGroupNode *parent) : DXFLayer(name) { _group = new EggGroup(name); parent->add_child(_group); _vpool = new EggVertexPool(name); diff --git a/pandatool/src/dxfprogs/eggToDXF.cxx b/pandatool/src/dxfprogs/eggToDXF.cxx index e3fb8a85d5..412b815601 100644 --- a/pandatool/src/dxfprogs/eggToDXF.cxx +++ b/pandatool/src/dxfprogs/eggToDXF.cxx @@ -52,7 +52,7 @@ run() { // uniquify_names("layer", _layers.begin(), _layers.end()); - ostream &out = get_output(); + std::ostream &out = get_output(); // Autodesk says we don't need the header, but some DXF-reading programs // might get confused if it's missing. We'll write an empty header. @@ -107,7 +107,7 @@ get_layers(EggGroupNode *group) { * gets written later, in write_entities(). */ void EggToDXF:: -write_tables(ostream &out) { +write_tables(std::ostream &out) { out << "0\nSECTION\n" << "2\nTABLES\n" // Begin TABLES section. << "0\nTABLE\n" @@ -127,7 +127,7 @@ write_tables(ostream &out) { * Writes out the "entities", e.g. polygons, defined for all layers. */ void EggToDXF:: -write_entities(ostream &out) { +write_entities(std::ostream &out) { out << "0\nSECTION\n" << "2\nENTITIES\n"; // Begin ENTITIES section. diff --git a/pandatool/src/dxfprogs/eggToDXFLayer.cxx b/pandatool/src/dxfprogs/eggToDXFLayer.cxx index c10c51f862..6922f0b8a6 100644 --- a/pandatool/src/dxfprogs/eggToDXFLayer.cxx +++ b/pandatool/src/dxfprogs/eggToDXFLayer.cxx @@ -19,6 +19,8 @@ #include "eggPolygon.h" #include "dcast.h" +using std::ostream; + /** * */ diff --git a/pandatool/src/egg-mkfont/eggMakeFont.cxx b/pandatool/src/egg-mkfont/eggMakeFont.cxx index 8ae277126b..4efa4a5ad5 100644 --- a/pandatool/src/egg-mkfont/eggMakeFont.cxx +++ b/pandatool/src/egg-mkfont/eggMakeFont.cxx @@ -32,6 +32,8 @@ #include +using std::string; + /** * */ @@ -424,7 +426,7 @@ run() { _bg[0], _bg[1], _bg[2], _bg[3], _palette_size[0], _palette_size[1], 100.0 / _palettize_scale_factor); - istringstream txa_script(buffer); + std::istringstream txa_script(buffer); pal->read_txa_file(txa_script, "default script"); pal->all_params_set(); diff --git a/pandatool/src/egg-mkfont/rangeDescription.cxx b/pandatool/src/egg-mkfont/rangeDescription.cxx index bedfc086ea..2833f53359 100644 --- a/pandatool/src/egg-mkfont/rangeDescription.cxx +++ b/pandatool/src/egg-mkfont/rangeDescription.cxx @@ -15,6 +15,8 @@ #include "string_utils.h" #include "pnotify.h" +using std::string; + /** * */ @@ -71,7 +73,7 @@ parse_parameter(const string ¶m) { * */ void RangeDescription:: -output(ostream &out) const { +output(std::ostream &out) const { bool first_time = true; RangeList::const_iterator ri; for (ri = _range_list.begin(); ri != _range_list.end(); ++ri) { diff --git a/pandatool/src/egg-optchar/eggOptchar.cxx b/pandatool/src/egg-optchar/eggOptchar.cxx index c7027ec9ec..182b657968 100644 --- a/pandatool/src/egg-optchar/eggOptchar.cxx +++ b/pandatool/src/egg-optchar/eggOptchar.cxx @@ -34,6 +34,10 @@ #include +using std::cout; +using std::setw; +using std::string; + /** * */ diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index e81290f06c..afa7fa00b7 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -696,7 +696,7 @@ run() { bool okflag = true; if (_got_txa_script) { - istringstream txa_script(_txa_script); + std::istringstream txa_script(_txa_script); pal->read_txa_file(txa_script, "command line"); } else { @@ -757,13 +757,13 @@ run() { // And process the egg files named for addition. bool all_eggs_valid = true; - string egg_comment = get_exec_command(); + std::string egg_comment = get_exec_command(); Eggs::const_iterator ei; for (ei = _eggs.begin(); ei != _eggs.end(); ++ei) { EggData *egg_data = (*ei); Filename source_filename = egg_data->get_egg_filename(); Filename dest_filename = get_output_filename(source_filename); - string name = source_filename.get_basename(); + std::string name = source_filename.get_basename(); EggFile *egg_file = pal->get_egg_file(name); if (!egg_file->from_command_line(egg_data, source_filename, dest_filename, @@ -834,7 +834,7 @@ run() { // state file into place. We do this in case the user interrupts us (or // we core dump) before we're done; that way we won't leave the state file // incompletely written. - string dirname = state_filename.get_dirname(); + std::string dirname = state_filename.get_dirname(); if (dirname.empty()) { dirname = "."; } diff --git a/pandatool/src/egg-palettize/txaFileFilter.cxx b/pandatool/src/egg-palettize/txaFileFilter.cxx index 980dc7d114..f8c20cfb0c 100644 --- a/pandatool/src/egg-palettize/txaFileFilter.cxx +++ b/pandatool/src/egg-palettize/txaFileFilter.cxx @@ -52,7 +52,7 @@ post_load(Texture *tex) { } TextureImage tex_image; - string name = tex->get_filename().get_basename_wo_extension(); + std::string name = tex->get_filename().get_basename_wo_extension(); tex_image.set_name(name); SourceTextureImage *source = tex_image.get_source @@ -131,7 +131,7 @@ read_txa_file() { << "Filename " << filename << " not found.\n"; } else { filename.set_text(); - istream *ifile = vfs->open_read_file(filename, true); + std::istream *ifile = vfs->open_read_file(filename, true); if (ifile == nullptr) { txafile_cat.warning() << "Filename " << filename << " cannot be read.\n"; diff --git a/pandatool/src/egg-qtess/eggQtess.cxx b/pandatool/src/egg-qtess/eggQtess.cxx index fea4d09344..37473557bf 100644 --- a/pandatool/src/egg-qtess/eggQtess.cxx +++ b/pandatool/src/egg-qtess/eggQtess.cxx @@ -155,9 +155,9 @@ run() { if (_total_tris != 0) { // Whatever number of triangles we have unaccounted for, assign to the // default bucket. - int extra_tris = max(0, _total_tris - num_tris); + int extra_tris = std::max(0, _total_tris - num_tris); if (read_qtess && default_entry.get_num_surfaces() != 0) { - cerr << extra_tris << " triangles unaccounted for.\n"; + std::cerr << extra_tris << " triangles unaccounted for.\n"; } default_entry.set_num_tris(extra_tris); @@ -180,13 +180,13 @@ run() { int tris = 0; - ostream &out = get_output(); + std::ostream &out = get_output(); Surfaces::const_iterator si; for (si = _surfaces.begin(); si != _surfaces.end(); ++si) { tris += (*si)->write_qtess_parameter(out); } - cerr << tris << " tris generated.\n"; + std::cerr << tris << " tris generated.\n"; } else { @@ -197,7 +197,7 @@ run() { tris += (*si)->tesselate(); } - cerr << tris << " tris generated.\n"; + std::cerr << tris << " tris generated.\n"; // Clear out the surfaces list before removing the vertices, since each // surface is holding reference counts to the previously-used vertices. diff --git a/pandatool/src/egg-qtess/isoPlacer.cxx b/pandatool/src/egg-qtess/isoPlacer.cxx index 25c7a38b0a..fda96904e3 100644 --- a/pandatool/src/egg-qtess/isoPlacer.cxx +++ b/pandatool/src/egg-qtess/isoPlacer.cxx @@ -82,7 +82,7 @@ get_scores(int subdiv, int across, double ratio, // non-equal points. double d = v1.dot(v2); - _cscore[i] += acos(max(min(d, 1.0), -1.0)); + _cscore[i] += acos(std::max(std::min(d, 1.0), -1.0)); } } } diff --git a/pandatool/src/egg-qtess/qtessInputEntry.cxx b/pandatool/src/egg-qtess/qtessInputEntry.cxx index da7e940545..66df4c8813 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.cxx +++ b/pandatool/src/egg-qtess/qtessInputEntry.cxx @@ -21,6 +21,8 @@ #include #include +using std::string; + /** * */ @@ -354,7 +356,7 @@ count_tris(double tri_factor, int attempts) { * user control. */ void QtessInputEntry:: -output_extra(ostream &out, const pvector &iso, char axis) { +output_extra(std::ostream &out, const pvector &iso, char axis) { pvector::const_iterator di; int expect = 0; for (di = iso.begin(); di != iso.end(); ++di) { @@ -376,7 +378,7 @@ output_extra(ostream &out, const pvector &iso, char axis) { * */ void QtessInputEntry:: -output(ostream &out) const { +output(std::ostream &out) const { NodeNames::const_iterator nni; for (nni = _node_names.begin(); nni != _node_names.end(); @@ -458,6 +460,6 @@ output(ostream &out) const { * */ void QtessInputEntry:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; } diff --git a/pandatool/src/egg-qtess/qtessInputFile.cxx b/pandatool/src/egg-qtess/qtessInputFile.cxx index 850ad638f9..180a2e9547 100644 --- a/pandatool/src/egg-qtess/qtessInputFile.cxx +++ b/pandatool/src/egg-qtess/qtessInputFile.cxx @@ -15,6 +15,8 @@ #include "config_egg_qtess.h" #include "string_utils.h" +using std::string; + /** * */ @@ -306,7 +308,7 @@ count_tris() { * */ void QtessInputFile:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { (*ei).write(out, indent_level); diff --git a/pandatool/src/egg-qtess/qtessSurface.cxx b/pandatool/src/egg-qtess/qtessSurface.cxx index 896fd68079..d7ccebe76f 100644 --- a/pandatool/src/egg-qtess/qtessSurface.cxx +++ b/pandatool/src/egg-qtess/qtessSurface.cxx @@ -23,6 +23,9 @@ #include "pset.h" #include "pmap.h" +using std::max; +using std::string; + /** * */ @@ -133,7 +136,7 @@ tesselate() { * should be tesselated uniformly. Returns the number of tris. */ int QtessSurface:: -write_qtess_parameter(ostream &out) { +write_qtess_parameter(std::ostream &out) { apply_match(); if (_tess_u == 0 || _tess_v == 0) { diff --git a/pandatool/src/eggbase/eggBase.cxx b/pandatool/src/eggbase/eggBase.cxx index 1ebd65a28e..83d07a0a6a 100644 --- a/pandatool/src/eggbase/eggBase.cxx +++ b/pandatool/src/eggbase/eggBase.cxx @@ -20,6 +20,8 @@ #include "dcast.h" #include "string_utils.h" +using std::string; + /** * */ diff --git a/pandatool/src/eggbase/eggConverter.cxx b/pandatool/src/eggbase/eggConverter.cxx index a55d68856f..036b7dea18 100644 --- a/pandatool/src/eggbase/eggConverter.cxx +++ b/pandatool/src/eggbase/eggConverter.cxx @@ -21,8 +21,8 @@ * with a leading dot. */ EggConverter:: -EggConverter(const string &format_name, - const string &preferred_extension, +EggConverter(const std::string &format_name, + const std::string &preferred_extension, bool allow_last_param, bool allow_stdout) : EggFilter(allow_last_param, allow_stdout), diff --git a/pandatool/src/eggbase/eggMultiFilter.cxx b/pandatool/src/eggbase/eggMultiFilter.cxx index 87900624f6..981c8ad4cf 100644 --- a/pandatool/src/eggbase/eggMultiFilter.cxx +++ b/pandatool/src/eggbase/eggMultiFilter.cxx @@ -81,7 +81,7 @@ handle_args(ProgramBase::Args &args) { nout << "Error opening file: " << _input_filename << "\n"; return false; } - string line; + std::string line; // File should be a space-delimited list of egg files while (std::getline(input, line, ' ')) { args.push_back(line); diff --git a/pandatool/src/eggbase/eggReader.cxx b/pandatool/src/eggbase/eggReader.cxx index 428e07710a..16c5e2ad28 100644 --- a/pandatool/src/eggbase/eggReader.cxx +++ b/pandatool/src/eggbase/eggReader.cxx @@ -178,7 +178,7 @@ handle_args(ProgramBase::Args &args) { exit(1); } } else { - if (!file_data.read(cin)) { + if (!file_data.read(std::cin)) { exit(1); } } diff --git a/pandatool/src/eggbase/eggToSomething.cxx b/pandatool/src/eggbase/eggToSomething.cxx index 3aa290ee32..eb6adc89e5 100644 --- a/pandatool/src/eggbase/eggToSomething.cxx +++ b/pandatool/src/eggbase/eggToSomething.cxx @@ -19,8 +19,8 @@ * just used in printing error messages and such. */ EggToSomething:: -EggToSomething(const string &format_name, - const string &preferred_extension, +EggToSomething(const std::string &format_name, + const std::string &preferred_extension, bool allow_last_param, bool allow_stdout) : EggConverter(format_name, preferred_extension, allow_last_param, allow_stdout) @@ -34,7 +34,7 @@ EggToSomething(const string &format_name, add_runline("[opts] input.egg >output" + _preferred_extension); } - string o_description; + std::string o_description; if (_allow_stdout) { if (_allow_last_param) { diff --git a/pandatool/src/eggbase/eggWriter.cxx b/pandatool/src/eggbase/eggWriter.cxx index 28365de2c1..c881991a08 100644 --- a/pandatool/src/eggbase/eggWriter.cxx +++ b/pandatool/src/eggbase/eggWriter.cxx @@ -47,7 +47,7 @@ EggWriter(bool allow_last_param, bool allow_stdout) : add_runline("[opts] >output.egg"); } - string o_description; + std::string o_description; if (_allow_stdout) { if (_allow_last_param) { diff --git a/pandatool/src/eggbase/somethingToEgg.cxx b/pandatool/src/eggbase/somethingToEgg.cxx index 6c8017d988..45d705f12c 100644 --- a/pandatool/src/eggbase/somethingToEgg.cxx +++ b/pandatool/src/eggbase/somethingToEgg.cxx @@ -22,8 +22,8 @@ * just used in printing error messages and such. */ SomethingToEgg:: -SomethingToEgg(const string &format_name, - const string &preferred_extension, +SomethingToEgg(const std::string &format_name, + const std::string &preferred_extension, bool allow_last_param, bool allow_stdout) : EggConverter(format_name, preferred_extension, allow_last_param, allow_stdout) { @@ -316,7 +316,7 @@ post_process_egg_file() { * specified parameter. var is a pointer to an AnimationConvert variable. */ bool SomethingToEgg:: -dispatch_animation_convert(const string &opt, const string &arg, void *var) { +dispatch_animation_convert(const std::string &opt, const std::string &arg, void *var) { AnimationConvert *ip = (AnimationConvert *)var; (*ip) = string_animation_convert(arg); if ((*ip) == AC_invalid) { diff --git a/pandatool/src/eggcharbase/eggBackPointer.cxx b/pandatool/src/eggcharbase/eggBackPointer.cxx index aa4a95f73a..400d9e3b2f 100644 --- a/pandatool/src/eggcharbase/eggBackPointer.cxx +++ b/pandatool/src/eggcharbase/eggBackPointer.cxx @@ -55,5 +55,5 @@ has_vertices() const { * Applies the indicated name change to the egg file. */ void EggBackPointer:: -set_name(const string &name) { +set_name(const std::string &name) { } diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.cxx b/pandatool/src/eggcharbase/eggCharacterCollection.cxx index 3dfa5aaee8..f90c7d9a91 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.cxx +++ b/pandatool/src/eggcharbase/eggCharacterCollection.cxx @@ -29,6 +29,8 @@ #include +using std::string; + /** * @@ -626,7 +628,7 @@ rename_char(int i, const string &name) { * */ void EggCharacterCollection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Characters::const_iterator ci; for (ci = _characters.begin(); ci != _characters.end(); ++ci) { @@ -646,7 +648,7 @@ write(ostream &out, int indent_level) const { * initially different. */ void EggCharacterCollection:: -check_errors(ostream &out, bool force_initial_rest_frame) { +check_errors(std::ostream &out, bool force_initial_rest_frame) { Characters::const_iterator ci; for (ci = _characters.begin(); ci != _characters.end(); ++ci) { EggCharacterData *char_data = (*ci); diff --git a/pandatool/src/eggcharbase/eggCharacterData.cxx b/pandatool/src/eggcharbase/eggCharacterData.cxx index 03cffa7d47..d3c7a54530 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.cxx +++ b/pandatool/src/eggcharbase/eggCharacterData.cxx @@ -63,7 +63,7 @@ EggCharacterData:: * as if they are expected to have the same skeleton hierarchy. */ void EggCharacterData:: -rename_char(const string &name) { +rename_char(const std::string &name) { Models::iterator mi; for (mi = _models.begin(); mi != _models.end(); ++mi) { (*mi)._model_root->set_name(name); @@ -107,7 +107,7 @@ get_num_frames(int model_index) const { // We have a winner. Assume all other components will be similar. return num_frames; } - max_num_frames = max(max_num_frames, num_frames); + max_num_frames = std::max(max_num_frames, num_frames); } // Every component had either 1 frame or 0 frames. Return the maximum of @@ -154,7 +154,7 @@ check_num_frames(int model_index) { // than 0 or 1), we have a discrepency. This is an error condition. any_violations = true; } - max_num_frames = max(max_num_frames, num_frames); + max_num_frames = std::max(max_num_frames, num_frames); } if (any_violations) { @@ -338,7 +338,7 @@ choose_optimal_hierarchy() { * name. */ EggSliderData *EggCharacterData:: -find_slider(const string &name) const { +find_slider(const std::string &name) const { SlidersByName::const_iterator si; si = _sliders_by_name.find(name); if (si != _sliders_by_name.end()) { @@ -353,7 +353,7 @@ find_slider(const string &name) const { * already, creates a new one. */ EggSliderData *EggCharacterData:: -make_slider(const string &name) { +make_slider(const std::string &name) { SlidersByName::const_iterator si; si = _sliders_by_name.find(name); if (si != _sliders_by_name.end()) { @@ -397,7 +397,7 @@ estimate_db_size() const { * */ void EggCharacterData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Character " << get_name() << ":\n"; get_root_joint()->write(out, indent_level + 2); diff --git a/pandatool/src/eggcharbase/eggComponentData.cxx b/pandatool/src/eggcharbase/eggComponentData.cxx index 6a30bc4969..5af9dd3d57 100644 --- a/pandatool/src/eggcharbase/eggComponentData.cxx +++ b/pandatool/src/eggcharbase/eggComponentData.cxx @@ -53,7 +53,7 @@ EggComponentData:: * matched_name(). */ void EggComponentData:: -add_name(const string &name, NameUniquifier &uniquifier) { +add_name(const std::string &name, NameUniquifier &uniquifier) { if (_names.insert(name).second) { // This is a new name for this component. if (!has_name()) { @@ -71,7 +71,7 @@ add_name(const string &name, NameUniquifier &uniquifier) { * with this particular joint, false otherwise. */ bool EggComponentData:: -matches_name(const string &name) const { +matches_name(const std::string &name) const { if (name == get_name()) { return true; } diff --git a/pandatool/src/eggcharbase/eggJointData.cxx b/pandatool/src/eggcharbase/eggJointData.cxx index 8197a1ec84..65ed9505a5 100644 --- a/pandatool/src/eggcharbase/eggJointData.cxx +++ b/pandatool/src/eggcharbase/eggJointData.cxx @@ -22,6 +22,8 @@ #include "fftCompressor.h" #include "zStream.h" +using std::string; + TypeHandle EggJointData::_type_handle; @@ -259,7 +261,7 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { #else // The FFTCompressor does minimal run-length encoding, but to really get an // accurate measure we should zlib-compress the resulting stream. - ostringstream sstr; + std::ostringstream sstr; OCompressStream zstr(&sstr, false); zstr.write((const char *)dg.get_data(), dg.get_length()); zstr.flush(); @@ -442,7 +444,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { * */ void EggJointData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Joint " << get_name() << " (models:"; diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.cxx b/pandatool/src/eggcharbase/eggJointNodePointer.cxx index 4ab8a7227a..c9c891606b 100644 --- a/pandatool/src/eggcharbase/eggJointNodePointer.cxx +++ b/pandatool/src/eggcharbase/eggJointNodePointer.cxx @@ -192,7 +192,7 @@ has_vertices() const { * pointer to it. */ EggJointPointer *EggJointNodePointer:: -make_new_joint(const string &name) { +make_new_joint(const std::string &name) { EggGroup *new_joint = new EggGroup(name); new_joint->set_group_type(EggGroup::GT_joint); _joint->add_child(new_joint); @@ -203,6 +203,6 @@ make_new_joint(const string &name) { * Applies the indicated name change to the egg file. */ void EggJointNodePointer:: -set_name(const string &name) { +set_name(const std::string &name) { _joint->set_name(name); } diff --git a/pandatool/src/eggcharbase/eggJointPointer.cxx b/pandatool/src/eggcharbase/eggJointPointer.cxx index 350931d635..6a5ed44003 100644 --- a/pandatool/src/eggcharbase/eggJointPointer.cxx +++ b/pandatool/src/eggcharbase/eggJointPointer.cxx @@ -69,7 +69,7 @@ expose(EggGroup::DCSType) { * Zeroes out the named components of the transform in the animation frames. */ void EggJointPointer:: -zero_channels(const string &) { +zero_channels(const std::string &) { } /** @@ -77,7 +77,7 @@ zero_channels(const string &) { * quantum. */ void EggJointPointer:: -quantize_channels(const string &, double) { +quantize_channels(const std::string &, double) { } /** diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx index 130975fc0b..21c9c63516 100644 --- a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx @@ -17,6 +17,8 @@ #include "eggXfmAnimData.h" #include "eggXfmSAnim.h" +using std::string; + TypeHandle EggMatrixTablePointer::_type_handle; /** diff --git a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx index 18f4aaaf5c..450bb548ce 100644 --- a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx @@ -89,7 +89,7 @@ get_frame(int n) const { * Applies the indicated name change to the egg file. */ void EggScalarTablePointer:: -set_name(const string &name) { +set_name(const std::string &name) { // Actually, let's not rename the slider table (yet), because we haven't // written the code to rename all of the morph targets. diff --git a/pandatool/src/eggcharbase/eggSliderData.cxx b/pandatool/src/eggcharbase/eggSliderData.cxx index 25bbae1140..91d041366f 100644 --- a/pandatool/src/eggcharbase/eggSliderData.cxx +++ b/pandatool/src/eggcharbase/eggSliderData.cxx @@ -88,7 +88,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { * */ void EggSliderData:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Slider " << get_name() << " (models:"; diff --git a/pandatool/src/eggprogs/eggListTextures.cxx b/pandatool/src/eggprogs/eggListTextures.cxx index c804a8110b..fd44c73a48 100644 --- a/pandatool/src/eggprogs/eggListTextures.cxx +++ b/pandatool/src/eggprogs/eggListTextures.cxx @@ -48,10 +48,10 @@ run() { Filename fullpath = (*ti)->get_fullpath(); PNMImageHeader header; if (header.read_header(fullpath)) { - cout << fullpath.get_basename() << " : " + std::cout << fullpath.get_basename() << " : " << header.get_x_size() << " " << header.get_y_size() << "\n"; } else { - cout << fullpath.get_basename() << " : unknown\n"; + std::cout << fullpath.get_basename() << " : unknown\n"; } } } diff --git a/pandatool/src/eggprogs/eggRetargetAnim.cxx b/pandatool/src/eggprogs/eggRetargetAnim.cxx index 0c522652e1..ba55d19b7f 100644 --- a/pandatool/src/eggprogs/eggRetargetAnim.cxx +++ b/pandatool/src/eggprogs/eggRetargetAnim.cxx @@ -97,7 +97,7 @@ run() { exit(1); } - string ref_name = col.get_character(0)->get_name(); + std::string ref_name = col.get_character(0)->get_name(); // Now rename all of the animations to the same name as the reference model, // and add the reference animation in to the same collection to match it up @@ -111,7 +111,7 @@ run() { EggCharacterData *char_data = _collection->get_character(0); nout << "Processing " << char_data->get_name() << "\n"; - typedef pset Names; + typedef pset Names; Names keep_names; vector_string::const_iterator si; @@ -133,7 +133,7 @@ run() { */ void EggRetargetAnim:: retarget_anim(EggCharacterData *char_data, EggJointData *joint_data, - int reference_model, const pset &keep_names, + int reference_model, const pset &keep_names, EggCharacterDb &db) { if (keep_names.find(joint_data->get_name()) != keep_names.end()) { // Don't retarget this joint; keep the translation and scale and whatever. diff --git a/pandatool/src/eggprogs/eggTextureCards.cxx b/pandatool/src/eggprogs/eggTextureCards.cxx index bf7032230f..bb3350f02c 100644 --- a/pandatool/src/eggprogs/eggTextureCards.cxx +++ b/pandatool/src/eggprogs/eggTextureCards.cxx @@ -22,6 +22,8 @@ #include +using std::string; + /** * */ diff --git a/pandatool/src/eggprogs/eggToC.cxx b/pandatool/src/eggprogs/eggToC.cxx index a1f0a4d081..bafc37fde9 100644 --- a/pandatool/src/eggprogs/eggToC.cxx +++ b/pandatool/src/eggprogs/eggToC.cxx @@ -22,6 +22,9 @@ #include "eggBin.h" #include "string_utils.h" +using std::ostream; +using std::string; + /** * */ diff --git a/pandatool/src/eggprogs/eggTopstrip.cxx b/pandatool/src/eggprogs/eggTopstrip.cxx index 4b0397e065..2a46431f25 100644 --- a/pandatool/src/eggprogs/eggTopstrip.cxx +++ b/pandatool/src/eggprogs/eggTopstrip.cxx @@ -185,14 +185,14 @@ run() { */ void EggTopstrip:: check_transform_channels() { - static string expected = "ijkphrxyz"; + static std::string expected = "ijkphrxyz"; static const int num_channels = 9; bool has_each[num_channels]; memset(has_each, 0, num_channels * sizeof(bool)); for (size_t p = 0; p < _transform_channels.size(); p++) { int i = expected.find(_transform_channels[p]); - if (i == (int)string::npos) { + if (i == (int)std::string::npos) { nout << "Invalid letter for -s: " << _transform_channels[p] << "\n"; exit(1); } @@ -235,7 +235,7 @@ strip_anim(EggCharacterData *char_data, EggJointData *joint_data, int num_into_frames = char_data->get_num_frames(i); int num_from_frames = from_char->get_num_frames(model); - int num_frames = max(num_into_frames, num_from_frames); + int num_frames = std::max(num_into_frames, num_from_frames); EggBackPointer *back = joint_data->get_model(i); nassertv(back != nullptr); diff --git a/pandatool/src/flt/fltBeadID.cxx b/pandatool/src/flt/fltBeadID.cxx index 32348d583e..4b6dc695a7 100644 --- a/pandatool/src/flt/fltBeadID.cxx +++ b/pandatool/src/flt/fltBeadID.cxx @@ -28,7 +28,7 @@ FltBeadID(FltHeader *header) : FltBead(header) { * Returns the id (name) of this particular bead. Each MultiGen bead will * have a unique name. */ -const string &FltBeadID:: +const std::string &FltBeadID:: get_id() const { return _id; } @@ -38,7 +38,7 @@ get_id() const { * is unique to this bead. */ void FltBeadID:: -set_id(const string &id) { +set_id(const std::string &id) { _id = id; } @@ -48,7 +48,7 @@ set_id(const string &id) { * flt file, use FltHeader::write_flt(). */ void FltBeadID:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); if (!_id.empty()) { out << " " << _id; diff --git a/pandatool/src/flt/fltError.cxx b/pandatool/src/flt/fltError.cxx index fe9cf918bb..b0b58ea6ae 100644 --- a/pandatool/src/flt/fltError.cxx +++ b/pandatool/src/flt/fltError.cxx @@ -13,8 +13,8 @@ #include "fltError.h" -ostream & -operator << (ostream &out, FltError error) { +std::ostream & +operator << (std::ostream &out, FltError error) { switch (error) { case FE_ok: return out << "no error"; diff --git a/pandatool/src/flt/fltExternalReference.cxx b/pandatool/src/flt/fltExternalReference.cxx index 1780e577ba..fa6aaa05f4 100644 --- a/pandatool/src/flt/fltExternalReference.cxx +++ b/pandatool/src/flt/fltExternalReference.cxx @@ -45,7 +45,7 @@ apply_converted_filenames() { * flt file, use FltHeader::write_flt(). */ void FltExternalReference:: -output(ostream &out) const { +output(std::ostream &out) const { out << "External " << get_ref_filename(); if (!_bead_id.empty()) { out << " (" << _bead_id << ")"; @@ -83,7 +83,7 @@ extract_record(FltRecordReader &reader) { nassertr(reader.get_opcode() == FO_external_ref, false); DatagramIterator &iterator = reader.get_iterator(); - string name = iterator.get_fixed_string(200); + std::string name = iterator.get_fixed_string(200); iterator.skip_bytes(1 + 1); iterator.skip_bytes(2); // Undocumented additional padding. _flags = iterator.get_be_uint32(); @@ -95,7 +95,7 @@ extract_record(FltRecordReader &reader) { if (!name.empty() && name[name.length() - 1] == '>') { // Extract out the bead name. size_t open = name.rfind('<'); - if (open != string::npos) { + if (open != std::string::npos) { _orig_filename = name.substr(0, open); _bead_id = name.substr(open + 1, name.length() - open - 2); } @@ -120,7 +120,7 @@ build_record(FltRecordWriter &writer) const { writer.set_opcode(FO_external_ref); Datagram &datagram = writer.update_datagram(); - string name = _orig_filename; + std::string name = _orig_filename; if (!_bead_id.empty()) { name += "<" + _bead_id + ">"; } diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx index e6cd4dbd10..a08748637e 100644 --- a/pandatool/src/flt/fltHeader.cxx +++ b/pandatool/src/flt/fltHeader.cxx @@ -190,7 +190,7 @@ read_flt(Filename filename) { _flt_filename = filename; VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *in = vfs->open_read_file(filename, true); + std::istream *in = vfs->open_read_file(filename, true); if (in == nullptr) { assert(!flt_error_abort); return FE_could_not_open; @@ -205,7 +205,7 @@ read_flt(Filename filename) { * Returns FE_ok on success, otherwise on failure. */ FltError FltHeader:: -read_flt(istream &in) { +read_flt(std::istream &in) { FltRecordReader reader(in); FltError result = reader.advance(); if (result == FE_end_of_file) { @@ -260,7 +260,7 @@ write_flt(Filename filename) { * Returns FE_ok on success, otherwise on failure. */ FltError FltHeader:: -write_flt(ostream &out) { +write_flt(std::ostream &out) { FltRecordWriter writer(out); FltError result = write_record_and_children(writer); @@ -600,14 +600,14 @@ has_color_name(int color_index) const { /** * Returns the name associated with the given color, if any. */ -string FltHeader:: +std::string FltHeader:: get_color_name(int color_index) const { ColorNames::const_iterator ni; ni = _color_names.find(color_index); if (ni != _color_names.end()) { return (*ni).second; } - return string(); + return std::string(); } /** @@ -836,7 +836,7 @@ add_material(FltMaterial *material) { } else { // Make sure our next generated material index will be different from any // existing material indices. - _next_material_index = max(_next_material_index, material->_material_index + 1); + _next_material_index = std::max(_next_material_index, material->_material_index + 1); } _materials[material->_material_index] = material; @@ -895,7 +895,7 @@ add_texture(FltTexture *texture) { } else { // Make sure our next generated pattern index will be different from any // existing texture indices. - _next_pattern_index = max(_next_pattern_index, texture->_pattern_index + 1); + _next_pattern_index = std::max(_next_pattern_index, texture->_pattern_index + 1); } _textures[texture->_pattern_index] = texture; @@ -1563,7 +1563,7 @@ write_color_palette(FltRecordWriter &writer) const { // Now append all the names at the end. ColorNames::const_iterator ni; for (ni = _color_names.begin(); ni != _color_names.end(); ++ni) { - string name = (*ni).second.substr(0, 80); + std::string name = (*ni).second.substr(0, 80); int entry_length = name.length() + 8; datagram.add_be_uint16(entry_length); datagram.pad_bytes(2); diff --git a/pandatool/src/flt/fltInstanceRef.cxx b/pandatool/src/flt/fltInstanceRef.cxx index 8622f6180b..f33ef3b145 100644 --- a/pandatool/src/flt/fltInstanceRef.cxx +++ b/pandatool/src/flt/fltInstanceRef.cxx @@ -42,7 +42,7 @@ get_instance() const { * flt file, use FltHeader::write_flt(). */ void FltInstanceRef:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "instance"; FltInstanceDefinition *def = _header->get_instance(_instance_index); if (def != nullptr) { diff --git a/pandatool/src/flt/fltMeshPrimitive.cxx b/pandatool/src/flt/fltMeshPrimitive.cxx index 0456cad142..6db78c8059 100644 --- a/pandatool/src/flt/fltMeshPrimitive.cxx +++ b/pandatool/src/flt/fltMeshPrimitive.cxx @@ -91,7 +91,7 @@ build_record(FltRecordWriter &writer) const { int max_index = 0; Vertices::const_iterator vi; for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) { - max_index = max(max_index, (*vi)); + max_index = std::max(max_index, (*vi)); } int vertex_width; diff --git a/pandatool/src/flt/fltOpcode.cxx b/pandatool/src/flt/fltOpcode.cxx index 4ca497a9ee..92fd64afda 100644 --- a/pandatool/src/flt/fltOpcode.cxx +++ b/pandatool/src/flt/fltOpcode.cxx @@ -13,8 +13,8 @@ #include "fltOpcode.h" -ostream & -operator << (ostream &out, FltOpcode opcode) { +std::ostream & +operator << (std::ostream &out, FltOpcode opcode) { switch (opcode) { case FO_none: return out << "null opcode"; diff --git a/pandatool/src/flt/fltPackedColor.cxx b/pandatool/src/flt/fltPackedColor.cxx index cc5dc7540d..0faa4eb644 100644 --- a/pandatool/src/flt/fltPackedColor.cxx +++ b/pandatool/src/flt/fltPackedColor.cxx @@ -19,7 +19,7 @@ * */ void FltPackedColor:: -output(ostream &out) const { +output(std::ostream &out) const { out << "(" << _r << " " << _g << " " << _b << " " << _a << ")"; } diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index 5325259ec6..9fcc52fcfa 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -220,7 +220,7 @@ has_comment() const { * Retrieves the comment for this record, or empty string if the record has no * comment. */ -const string &FltRecord:: +const std::string &FltRecord:: get_comment() const { return _comment; } @@ -237,7 +237,7 @@ clear_comment() { * Changes the comment for this record. */ void FltRecord:: -set_comment(const string &comment) { +set_comment(const std::string &comment) { _comment = comment; } @@ -251,7 +251,7 @@ set_comment(const string &comment) { * this is exactly the sort of thing we expect. */ void FltRecord:: -check_remaining_size(const DatagramIterator &di, const string &name) const { +check_remaining_size(const DatagramIterator &di, const std::string &name) const { if (di.get_remaining_size() == 0) { return; } @@ -291,7 +291,7 @@ apply_converted_filenames() { * flt file, use FltHeader::write_flt(). */ void FltRecord:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_type(); } @@ -301,7 +301,7 @@ output(ostream &out) const { * flt file, use FltHeader::write_flt(). */ void FltRecord:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this; write_children(out, indent_level); } @@ -311,7 +311,7 @@ write(ostream &out, int indent_level) const { * line of the record description, writes out the list of children. */ void FltRecord:: -write_children(ostream &out, int indent_level) const { +write_children(std::ostream &out, int indent_level) const { if (!_ancillary.empty()) { out << " + " << _ancillary.size() << " ancillary"; } diff --git a/pandatool/src/flt/fltRecordReader.cxx b/pandatool/src/flt/fltRecordReader.cxx index f2650fa423..c999001d64 100644 --- a/pandatool/src/flt/fltRecordReader.cxx +++ b/pandatool/src/flt/fltRecordReader.cxx @@ -22,7 +22,7 @@ * */ FltRecordReader:: -FltRecordReader(istream &in) : +FltRecordReader(std::istream &in) : _in(in) { _opcode = FO_none; diff --git a/pandatool/src/flt/fltRecordWriter.cxx b/pandatool/src/flt/fltRecordWriter.cxx index df3d904d27..909e5ce298 100644 --- a/pandatool/src/flt/fltRecordWriter.cxx +++ b/pandatool/src/flt/fltRecordWriter.cxx @@ -28,7 +28,7 @@ static const int max_write_length = 65532; * */ FltRecordWriter:: -FltRecordWriter(ostream &out) : +FltRecordWriter(std::ostream &out) : _out(out) { } @@ -75,7 +75,7 @@ FltError FltRecordWriter:: advance() { int start_byte = 0; int write_length = - min((int)_datagram.get_length() - start_byte, max_write_length - header_size); + std::min((int)_datagram.get_length() - start_byte, max_write_length - header_size); FltOpcode opcode = _opcode; do { @@ -107,7 +107,7 @@ advance() { start_byte += write_length; write_length = - min((int)_datagram.get_length() - start_byte, max_write_length - header_size); + std::min((int)_datagram.get_length() - start_byte, max_write_length - header_size); opcode = FO_continuation; } while (write_length > 0); diff --git a/pandatool/src/flt/fltTexture.cxx b/pandatool/src/flt/fltTexture.cxx index ee56205c6f..c65f5a05e2 100644 --- a/pandatool/src/flt/fltTexture.cxx +++ b/pandatool/src/flt/fltTexture.cxx @@ -123,7 +123,7 @@ set_texture_filename(const Filename &filename) { */ Filename FltTexture:: get_attr_filename() const { - string texture_filename = get_texture_filename(); + std::string texture_filename = get_texture_filename(); return Filename::binary_filename(texture_filename + ".attr"); } @@ -142,15 +142,15 @@ read_attr_data() { } // Determine the file's size so we can read it all into one big datagram. - attr.seekg(0, ios::end); + attr.seekg(0, std::ios::end); if (attr.fail()) { return FE_read_error; } - streampos length = attr.tellg(); + std::streampos length = attr.tellg(); char *buffer = new char[length]; - attr.seekg(0, ios::beg); + attr.seekg(0, std::ios::beg); attr.read(buffer, length); if (attr.fail()) { return FE_read_error; diff --git a/pandatool/src/flt/fltUnsupportedRecord.cxx b/pandatool/src/flt/fltUnsupportedRecord.cxx index e3bcc07a2a..7a6e67aa84 100644 --- a/pandatool/src/flt/fltUnsupportedRecord.cxx +++ b/pandatool/src/flt/fltUnsupportedRecord.cxx @@ -31,7 +31,7 @@ FltUnsupportedRecord(FltHeader *header) : FltRecord(header) { * flt file, use FltHeader::write_flt(). */ void FltUnsupportedRecord:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Unsupported(" << _opcode << ")"; } diff --git a/pandatool/src/flt/fltVertexList.cxx b/pandatool/src/flt/fltVertexList.cxx index 941d35c300..65da9b5923 100644 --- a/pandatool/src/flt/fltVertexList.cxx +++ b/pandatool/src/flt/fltVertexList.cxx @@ -65,7 +65,7 @@ add_vertex(FltVertex *vertex) { * flt file, use FltHeader::write_flt(). */ void FltVertexList:: -output(ostream &out) const { +output(std::ostream &out) const { out << _vertices.size() << " vertices"; } diff --git a/pandatool/src/fltegg/fltToEggConverter.cxx b/pandatool/src/fltegg/fltToEggConverter.cxx index bd4898b0c5..98b01938c5 100644 --- a/pandatool/src/fltegg/fltToEggConverter.cxx +++ b/pandatool/src/fltegg/fltToEggConverter.cxx @@ -35,6 +35,8 @@ #include "eggExternalReference.h" #include "string_utils.h" +using std::string; + /** * diff --git a/pandatool/src/fltegg/fltToEggLevelState.cxx b/pandatool/src/fltegg/fltToEggLevelState.cxx index 238208527e..ef396fd818 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.cxx +++ b/pandatool/src/fltegg/fltToEggLevelState.cxx @@ -56,7 +56,7 @@ ParentNodes() { * group per polygon. */ EggGroupNode *FltToEggLevelState:: -get_synthetic_group(const string &name, +get_synthetic_group(const std::string &name, const FltBead *transform_bead, FltGeometry::BillboardType type) { LMatrix4d transform = transform_bead->get_transform(); diff --git a/pandatool/src/fltprogs/eggToFlt.cxx b/pandatool/src/fltprogs/eggToFlt.cxx index 5ca9224225..f6cbc9d24f 100644 --- a/pandatool/src/fltprogs/eggToFlt.cxx +++ b/pandatool/src/fltprogs/eggToFlt.cxx @@ -93,7 +93,7 @@ run() { * Dispatch function for the -attr parameter. */ bool EggToFlt:: -dispatch_attr(const string &opt, const string &arg, void *var) { +dispatch_attr(const std::string &opt, const std::string &arg, void *var) { FltHeader::AttrUpdate *ip = (FltHeader::AttrUpdate *)var; if (cmp_nocase(arg, "none") == 0) { @@ -231,7 +231,7 @@ convert_primitive(EggPrimitive *egg_primitive, FltBead *flt_node, void EggToFlt:: convert_group(EggGroup *egg_group, FltBead *flt_node, FltGeometry::BillboardType billboard) { - ostringstream egg_syntax; + std::ostringstream egg_syntax; FltGroup *flt_group = new FltGroup(_flt_header); flt_node->add_child(flt_group); @@ -450,9 +450,9 @@ apply_transform(EggTransform *egg_transform, FltBead *flt_node) { * comment, so that flt2egg will reapply it to the egg groups. */ void EggToFlt:: -apply_egg_syntax(const string &egg_syntax, FltRecord *flt_record) { +apply_egg_syntax(const std::string &egg_syntax, FltRecord *flt_record) { if (!egg_syntax.empty()) { - ostringstream out; + std::ostringstream out; out << " {\n" << egg_syntax << "}"; diff --git a/pandatool/src/fltprogs/fltInfo.cxx b/pandatool/src/fltprogs/fltInfo.cxx index a6d4649bff..bd0e9d8a83 100644 --- a/pandatool/src/fltprogs/fltInfo.cxx +++ b/pandatool/src/fltprogs/fltInfo.cxx @@ -65,7 +65,7 @@ run() { void FltInfo:: list_hierarchy(FltRecord *record, int indent_level) { // Maybe in the future we can do something fancier here. - record->write(cout, indent_level); + record->write(std::cout, indent_level); } diff --git a/pandatool/src/gtk-stats/gtkStats.cxx b/pandatool/src/gtk-stats/gtkStats.cxx index fad28f1a4b..e6889ff23b 100644 --- a/pandatool/src/gtk-stats/gtkStats.cxx +++ b/pandatool/src/gtk-stats/gtkStats.cxx @@ -66,9 +66,9 @@ main(int argc, char *argv[]) { g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(destroy), nullptr); - ostringstream stream; + std::ostringstream stream; stream << "Listening on port " << pstats_port; - string str = stream.str(); + std::string str = stream.str(); GtkWidget *label = gtk_label_new(str.c_str()); gtk_container_add(GTK_CONTAINER(main_window), label); gtk_widget_show(label); @@ -76,12 +76,12 @@ main(int argc, char *argv[]) { // Create the server object. server = new GtkStatsServer; if (!server->listen()) { - ostringstream stream; + std::ostringstream stream; stream << "Unable to open port " << pstats_port << ". Try specifying a different\n" << "port number using pstats-port in your Config file."; - string str = stream.str(); + std::string str = stream.str(); GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), diff --git a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx index 5bd5a7691f..c7f8b3f4be 100644 --- a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx +++ b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx @@ -48,7 +48,7 @@ get_menu_widget() { void GtkStatsChartMenu:: add_to_menu_bar(GtkWidget *menu_bar, int position) { const PStatClientData *client_data = _monitor->get_client_data(); - string thread_name; + std::string thread_name; if (_thread_index == 0) { // A special case for the main thread. thread_name = "Graphs"; @@ -142,7 +142,7 @@ add_view(GtkWidget *parent_menu, const PStatViewLevel *view_level, int collector = view_level->get_collector(); const PStatClientData *client_data = _monitor->get_client_data(); - string collector_name = client_data->get_collector_name(collector); + std::string collector_name = client_data->get_collector_name(collector); GtkStatsMonitor::MenuDef smd(_thread_index, collector, show_level); const GtkStatsMonitor::MenuDef *menu_def = _monitor->add_menu(smd); @@ -158,7 +158,7 @@ add_view(GtkWidget *parent_menu, const PStatViewLevel *view_level, if (num_children > 1) { // If the collector has more than one child, add a menu entry to go // directly to each of its children. - string submenu_name = collector_name + " components"; + std::string submenu_name = collector_name + " components"; GtkWidget *submenu_item = gtk_menu_item_new_with_label(submenu_name.c_str()); gtk_widget_show(submenu_item); diff --git a/pandatool/src/gtk-stats/gtkStatsGraph.cxx b/pandatool/src/gtk-stats/gtkStatsGraph.cxx index 2f1b1e7189..e56e262d23 100644 --- a/pandatool/src/gtk-stats/gtkStatsGraph.cxx +++ b/pandatool/src/gtk-stats/gtkStatsGraph.cxx @@ -341,8 +341,8 @@ void GtkStatsGraph:: setup_pixmap(int xsize, int ysize) { release_pixmap(); - _pixmap_xsize = max(xsize, 0); - _pixmap_ysize = max(ysize, 0); + _pixmap_xsize = std::max(xsize, 0); + _pixmap_ysize = std::max(ysize, 0); _pixmap = gdk_pixmap_new(_graph_window->window, _pixmap_xsize, _pixmap_ysize, -1); // g_object_ref(_pixmap); Should this be ref_sink? diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx index 1c7a8b1f1f..4f78d88450 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx @@ -67,7 +67,7 @@ GtkStatsMonitor:: * Should be redefined to return a descriptive name for the type of * PStatsMonitor this is. */ -string GtkStatsMonitor:: +std::string GtkStatsMonitor:: get_monitor_name() { return "GtkStats"; } @@ -103,7 +103,7 @@ got_hello() { void GtkStatsMonitor:: got_bad_version(int client_major, int client_minor, int server_major, int server_minor) { - ostringstream str; + std::ostringstream str; str << "Unable to honor connection attempt from " << get_client_progname() << " on " << get_client_hostname() << ": unsupported PStats version " @@ -117,7 +117,7 @@ got_bad_version(int client_major, int client_minor, << ".0 through " << server_major << "." << server_minor << ")."; } - string message = str.str(); + std::string message = str.str(); GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), GTK_DIALOG_DESTROY_WITH_PARENT, @@ -279,7 +279,7 @@ open_piano_roll(int thread_index) { */ const GtkStatsMonitor::MenuDef *GtkStatsMonitor:: add_menu(const MenuDef &menu_def) { - pair result = _menus.insert(menu_def); + std::pair result = _menus.insert(menu_def); Menus::iterator mi = result.first; const GtkStatsMonitor::MenuDef &new_menu_def = (*mi); if (result.second) { diff --git a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx index f29ae4955c..60a3dc7887 100644 --- a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx +++ b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx @@ -47,8 +47,8 @@ GtkStatsPianoRoll(GtkStatsMonitor *monitor, int thread_index) : const PStatClientData *client_data = GtkStatsGraph::_monitor->get_client_data(); - string thread_name = client_data->get_thread_name(_thread_index); - string window_title = thread_name + " thread piano roll"; + std::string thread_name = client_data->get_thread_name(_thread_index); + std::string window_title = thread_name + " thread piano roll"; gtk_window_set_title(GTK_WINDOW(_window), window_title.c_str()); gtk_widget_show_all(_window); @@ -441,7 +441,7 @@ draw_guide_label(const PStatGraph::GuideBar &bar) { } int x = height_to_pixel(bar._height); - const string &label = bar._label; + const std::string &label = bar._label; PangoLayout *layout = gtk_widget_create_pango_layout(_window, label.c_str()); int width, height; diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx index 8370cd958b..117ef96576 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx @@ -111,7 +111,7 @@ new_collector(int collector_index) { void GtkStatsStripChart:: new_data(int thread_index, int frame_number) { if (is_title_unknown()) { - string window_title = get_title_text(); + std::string window_title = get_title_text(); if (!is_title_unknown()) { gtk_window_set_title(GTK_WINDOW(_window), window_title.c_str()); } @@ -120,7 +120,7 @@ new_data(int thread_index, int frame_number) { if (!_pause) { update(); - string text = format_number(get_average_net_value(), get_guide_bar_units(), get_guide_bar_unit_name()); + std::string text = format_number(get_average_net_value(), get_guide_bar_units(), get_guide_bar_unit_name()); if (_net_value_text != text) { _net_value_text = text; gtk_label_set_text(GTK_LABEL(_total_label), _net_value_text.c_str()); @@ -575,7 +575,7 @@ draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) { } int y = height_to_pixel(bar._height); - const string &label = bar._label; + const std::string &label = bar._label; PangoLayout *layout = gtk_widget_create_pango_layout(_window, label.c_str()); int width, height; diff --git a/pandatool/src/imagebase/imageWriter.cxx b/pandatool/src/imagebase/imageWriter.cxx index 3a4bfc1d56..eb50188e29 100644 --- a/pandatool/src/imagebase/imageWriter.cxx +++ b/pandatool/src/imagebase/imageWriter.cxx @@ -26,7 +26,7 @@ ImageWriter(bool allow_last_param) : } add_runline("[opts] -o outputimage"); - string o_description; + std::string o_description; if (_allow_last_param) { o_description = "Specify the filename to which the resulting image file will be written. " diff --git a/pandatool/src/imageprogs/imageResize.cxx b/pandatool/src/imageprogs/imageResize.cxx index f3c51c8554..a41ff771de 100644 --- a/pandatool/src/imageprogs/imageResize.cxx +++ b/pandatool/src/imageprogs/imageResize.cxx @@ -87,11 +87,11 @@ run() { * Interprets the -x or -y parameters. */ bool ImageResize:: -dispatch_size_request(const string &opt, const string &arg, void *var) { +dispatch_size_request(const std::string &opt, const std::string &arg, void *var) { SizeRequest *ip = (SizeRequest *)var; if (!arg.empty() && arg[arg.length() - 1] == '%') { // A ratio. - string str = arg.substr(0, arg.length() - 1); + std::string str = arg.substr(0, arg.length() - 1); double ratio; if (!string_to_double(str, ratio)) { nout << "Invalid ratio for -" << opt << ": " diff --git a/pandatool/src/imageprogs/imageTrans.cxx b/pandatool/src/imageprogs/imageTrans.cxx index 48bc98c5d2..517abee647 100644 --- a/pandatool/src/imageprogs/imageTrans.cxx +++ b/pandatool/src/imageprogs/imageTrans.cxx @@ -144,7 +144,7 @@ run() { * Interprets the -chan parameter. */ bool ImageTrans:: -dispatch_channels(const string &opt, const string &arg, void *var) { +dispatch_channels(const std::string &opt, const std::string &arg, void *var) { Channels *ip = (Channels *)var; if (cmp_nocase(arg, "l") == 0) { (*ip) = C_l; diff --git a/pandatool/src/imageprogs/imageTransformColors.cxx b/pandatool/src/imageprogs/imageTransformColors.cxx index 0600956a91..0efee4aab0 100644 --- a/pandatool/src/imageprogs/imageTransformColors.cxx +++ b/pandatool/src/imageprogs/imageTransformColors.cxx @@ -16,6 +16,10 @@ #include "pnmImage.h" #include +using std::max; +using std::min; +using std::string; + /** * */ diff --git a/pandatool/src/lwo/iffChunk.cxx b/pandatool/src/lwo/iffChunk.cxx index e3ba7107a5..a86ac62dd9 100644 --- a/pandatool/src/lwo/iffChunk.cxx +++ b/pandatool/src/lwo/iffChunk.cxx @@ -22,7 +22,7 @@ TypeHandle IffChunk::_type_handle; * */ void IffChunk:: -output(ostream &out) const { +output(std::ostream &out) const { out << _id << " (" << get_type() << ")"; } @@ -30,7 +30,7 @@ output(ostream &out) const { * */ void IffChunk:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << _id << " { ... }\n"; } diff --git a/pandatool/src/lwo/iffGenericChunk.cxx b/pandatool/src/lwo/iffGenericChunk.cxx index 87625c2193..c8eaf015ee 100644 --- a/pandatool/src/lwo/iffGenericChunk.cxx +++ b/pandatool/src/lwo/iffGenericChunk.cxx @@ -37,7 +37,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void IffGenericChunk:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { " << _data.get_length() << " bytes }\n"; } diff --git a/pandatool/src/lwo/iffId.cxx b/pandatool/src/lwo/iffId.cxx index 6d31a79bad..eda63c0b5d 100644 --- a/pandatool/src/lwo/iffId.cxx +++ b/pandatool/src/lwo/iffId.cxx @@ -19,7 +19,7 @@ * */ void IffId:: -output(ostream &out) const { +output(std::ostream &out) const { // If all of the characters are printable, just output them. if (isprint(_id._c[0]) && isprint(_id._c[1]) && isprint(_id._c[2]) && isprint(_id._c[3])) { @@ -32,10 +32,10 @@ output(ostream &out) const { } else { // Otherwise, write out the hex. - out << "0x" << hex << setfill('0'); + out << "0x" << std::hex << std::setfill('0'); for (int i = 0; i < 4; i++) { - out << setw(2) << (int)(unsigned char)_id._c[i]; + out << std::setw(2) << (int)(unsigned char)_id._c[i]; } - out << dec << setfill(' '); + out << std::dec << std::setfill(' '); } } diff --git a/pandatool/src/lwo/iffInputFile.cxx b/pandatool/src/lwo/iffInputFile.cxx index e3ffa34044..f00dbf5469 100644 --- a/pandatool/src/lwo/iffInputFile.cxx +++ b/pandatool/src/lwo/iffInputFile.cxx @@ -51,7 +51,7 @@ open_read(Filename filename) { filename.set_binary(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *in = vfs->open_read_file(filename, true); + std::istream *in = vfs->open_read_file(filename, true); if (in == nullptr) { return false; } @@ -68,7 +68,7 @@ open_read(Filename filename) { * IffInputFile destructs. */ void IffInputFile:: -set_input(istream *input, bool owns_istream) { +set_input(std::istream *input, bool owns_istream) { if (_owns_istream) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_input); @@ -174,9 +174,9 @@ get_be_float32() { /** * Extracts a null-terminated string. */ -string IffInputFile:: +std::string IffInputFile:: get_string() { - string result; + std::string result; char byte; while (read_byte(byte)) { if (byte == 0) { diff --git a/pandatool/src/lwo/lwoBoundingBox.cxx b/pandatool/src/lwo/lwoBoundingBox.cxx index 8f23e7b403..10ef60a7b0 100644 --- a/pandatool/src/lwo/lwoBoundingBox.cxx +++ b/pandatool/src/lwo/lwoBoundingBox.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoBoundingBox:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { min = " << _min << ", max = " << _max << " }\n"; } diff --git a/pandatool/src/lwo/lwoClip.cxx b/pandatool/src/lwo/lwoClip.cxx index d0bda7993f..fd1e602a0e 100644 --- a/pandatool/src/lwo/lwoClip.cxx +++ b/pandatool/src/lwo/lwoClip.cxx @@ -36,7 +36,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoClip:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; indent(out, indent_level + 2) diff --git a/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx b/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx index f0cab49c18..3e4b0c003c 100644 --- a/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx +++ b/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx @@ -82,7 +82,7 @@ read_iff(IffInputFile *in, size_t stop_at) { } VMap &vmap = _vmad[polygon_index]; - pair ir = + std::pair ir = vmap.insert(VMap::value_type(vertex_index, value)); if (!ir.second) { // This polygonvertex pair was repeated in the vmad. Is it simply @@ -115,7 +115,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoDiscontinuousVertexMap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { map_type = " << _map_type << ", dimension = " << _dimension diff --git a/pandatool/src/lwo/lwoGroupChunk.cxx b/pandatool/src/lwo/lwoGroupChunk.cxx index a9bb29fbe7..481f27bb28 100644 --- a/pandatool/src/lwo/lwoGroupChunk.cxx +++ b/pandatool/src/lwo/lwoGroupChunk.cxx @@ -74,7 +74,7 @@ read_subchunks_iff(IffInputFile *in, size_t stop_at) { * debugging), one per line. */ void LwoGroupChunk:: -write_chunks(ostream &out, int indent_level) const { +write_chunks(std::ostream &out, int indent_level) const { Chunks::const_iterator ci; for (ci = _chunks.begin(); ci != _chunks.end(); ++ci) { (*ci)->write(out, indent_level); diff --git a/pandatool/src/lwo/lwoHeader.cxx b/pandatool/src/lwo/lwoHeader.cxx index 4fe302f54d..aba632eb93 100644 --- a/pandatool/src/lwo/lwoHeader.cxx +++ b/pandatool/src/lwo/lwoHeader.cxx @@ -61,7 +61,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoHeader:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; indent(out, indent_level + 2) diff --git a/pandatool/src/lwo/lwoInputFile.cxx b/pandatool/src/lwo/lwoInputFile.cxx index 78e7dfa10c..a6737855ea 100644 --- a/pandatool/src/lwo/lwoInputFile.cxx +++ b/pandatool/src/lwo/lwoInputFile.cxx @@ -24,6 +24,8 @@ #include "lwoSurface.h" #include "lwoVertexMap.h" +using std::string; + TypeHandle LwoInputFile::_type_handle; /** diff --git a/pandatool/src/lwo/lwoLayer.cxx b/pandatool/src/lwo/lwoLayer.cxx index 75f4a18606..1fea2cd546 100644 --- a/pandatool/src/lwo/lwoLayer.cxx +++ b/pandatool/src/lwo/lwoLayer.cxx @@ -63,9 +63,9 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoLayer:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { number = " << _number << ", flags = 0x" - << hex << _flags << dec << ", pivot = " << _pivot + << std::hex << _flags << std::dec << ", pivot = " << _pivot << ", _name = \"" << _name << "\", _parent = " << _parent << " }\n"; } diff --git a/pandatool/src/lwo/lwoPoints.cxx b/pandatool/src/lwo/lwoPoints.cxx index 875d6e8909..7abfeea668 100644 --- a/pandatool/src/lwo/lwoPoints.cxx +++ b/pandatool/src/lwo/lwoPoints.cxx @@ -58,7 +58,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoPoints:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { " << _points.size() << " points }\n"; } diff --git a/pandatool/src/lwo/lwoPolygonTags.cxx b/pandatool/src/lwo/lwoPolygonTags.cxx index aef4b051aa..48f81b47e0 100644 --- a/pandatool/src/lwo/lwoPolygonTags.cxx +++ b/pandatool/src/lwo/lwoPolygonTags.cxx @@ -73,7 +73,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoPolygonTags:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { tag_type = " << _tag_type << ", " << _tmap.size() << " values }\n"; diff --git a/pandatool/src/lwo/lwoPolygons.cxx b/pandatool/src/lwo/lwoPolygons.cxx index 4e51d3ee26..22d03c2121 100644 --- a/pandatool/src/lwo/lwoPolygons.cxx +++ b/pandatool/src/lwo/lwoPolygons.cxx @@ -113,7 +113,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoPolygons:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { polygon_type = " << _polygon_type << ", " << _polygons.size() << " polygons }\n"; diff --git a/pandatool/src/lwo/lwoStillImage.cxx b/pandatool/src/lwo/lwoStillImage.cxx index 851aa6c8ef..9a31986c43 100644 --- a/pandatool/src/lwo/lwoStillImage.cxx +++ b/pandatool/src/lwo/lwoStillImage.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoStillImage:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { filename = \"" << _filename << "\" }\n"; } diff --git a/pandatool/src/lwo/lwoSurface.cxx b/pandatool/src/lwo/lwoSurface.cxx index edbc67506a..e1318947d9 100644 --- a/pandatool/src/lwo/lwoSurface.cxx +++ b/pandatool/src/lwo/lwoSurface.cxx @@ -41,7 +41,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurface:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; indent(out, indent_level + 2) diff --git a/pandatool/src/lwo/lwoSurfaceBlock.cxx b/pandatool/src/lwo/lwoSurfaceBlock.cxx index 76babe281c..8dd32652fa 100644 --- a/pandatool/src/lwo/lwoSurfaceBlock.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlock.cxx @@ -54,7 +54,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlock:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; _header->write(out, indent_level + 2); diff --git a/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx b/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx index 8698e9dea5..3390debdea 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockAxis:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { axis = " << (int)_axis << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx b/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx index 523b379e4b..94dc45c8af 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockChannel:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { channel_id = " << _channel_id << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx index 4e1e3f0766..e2c9b77a84 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockCoordSys:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { type = " << (int)_type << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx b/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx index c4d01dd557..8240539502 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockEnabled:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { enabled = " << _enabled << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx b/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx index a4a88d982a..69351fa403 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx @@ -43,18 +43,18 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockHeader:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; indent(out, indent_level + 2) - << "ordinal = 0x" << hex << setfill('0'); + << "ordinal = 0x" << std::hex << std::setfill('0'); - string::const_iterator si; + std::string::const_iterator si; for (si = _ordinal.begin(); si != _ordinal.end(); ++si) { - out << setw(2) << (int)(unsigned char)(*si); + out << std::setw(2) << (int)(unsigned char)(*si); } - out << dec << setfill(' ') << "\n"; + out << std::dec << std::setfill(' ') << "\n"; write_chunks(out, indent_level + 2); indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockImage.cxx b/pandatool/src/lwo/lwoSurfaceBlockImage.cxx index dce817b6aa..520d8cef2a 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockImage.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockImage.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockImage:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { index = " << _index << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx b/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx index d6554d0b82..456e1383ca 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx @@ -40,7 +40,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockOpacity:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { type = " << (int)_type << ", opacity = " << _opacity * 100.0 << "%, envelope = " << _envelope diff --git a/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx b/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx index 2f6d214177..500d90c2ed 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockProjection:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { mode = " << (int)_mode << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx b/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx index d7dccc5693..1c19fedfac 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockRefObj:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { name = \"" << _name << "\" }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx b/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx index e264667caa..9036c143fc 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockRepeat:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { cycles = " << _cycles << ", envelope = " << _envelope << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx b/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx index f404910611..1f355d2d4d 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx @@ -41,7 +41,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockTMap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " {\n"; write_chunks(out, indent_level + 2); diff --git a/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx b/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx index e2fdccad18..2ed2738161 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockTransform:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { vec = " << _vec << ", envelope = " << _envelope << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx b/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx index 208f309e4c..f4db699457 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockVMapName:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { name = \"" << _name << "\" }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx b/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx index ec7cc24796..006be5f8be 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceBlockWrap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { width = " << (int)_width << ", height = " << (int)_height << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceColor.cxx b/pandatool/src/lwo/lwoSurfaceColor.cxx index ceeb5ab747..5a4526eb55 100644 --- a/pandatool/src/lwo/lwoSurfaceColor.cxx +++ b/pandatool/src/lwo/lwoSurfaceColor.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceColor:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { color = " << _color << ", envelope = " << _envelope << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceParameter.cxx b/pandatool/src/lwo/lwoSurfaceParameter.cxx index f1ff64203b..fd3543f18a 100644 --- a/pandatool/src/lwo/lwoSurfaceParameter.cxx +++ b/pandatool/src/lwo/lwoSurfaceParameter.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceParameter:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { value = " << _value << ", envelope = " << _envelope << " }\n"; diff --git a/pandatool/src/lwo/lwoSurfaceSidedness.cxx b/pandatool/src/lwo/lwoSurfaceSidedness.cxx index b67c1492be..2c773b25f6 100644 --- a/pandatool/src/lwo/lwoSurfaceSidedness.cxx +++ b/pandatool/src/lwo/lwoSurfaceSidedness.cxx @@ -38,7 +38,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceSidedness:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { sidedness = " << (int)_sidedness << " }\n"; } diff --git a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx index 1b0570c46b..49c1f729f5 100644 --- a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx +++ b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx @@ -39,7 +39,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoSurfaceSmoothingAngle:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { angle = " << rad_2_deg(_angle) << " degrees }\n"; } diff --git a/pandatool/src/lwo/lwoTags.cxx b/pandatool/src/lwo/lwoTags.cxx index c2d9ebbc8d..43eaa2ab70 100644 --- a/pandatool/src/lwo/lwoTags.cxx +++ b/pandatool/src/lwo/lwoTags.cxx @@ -30,9 +30,9 @@ get_num_tags() const { /** * Returns the nth tag of this group. */ -string LwoTags:: +std::string LwoTags:: get_tag(int n) const { - nassertr(n >= 0 && n < (int)_tags.size(), string()); + nassertr(n >= 0 && n < (int)_tags.size(), std::string()); return _tags[n]; } @@ -47,7 +47,7 @@ read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); while (lin->get_bytes_read() < stop_at && !lin->is_eof()) { - string tag = lin->get_string(); + std::string tag = lin->get_string(); _tags.push_back(tag); } @@ -58,7 +58,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoTags:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { "; diff --git a/pandatool/src/lwo/lwoVertexMap.cxx b/pandatool/src/lwo/lwoVertexMap.cxx index 396ab91b33..a0ecbf9cd5 100644 --- a/pandatool/src/lwo/lwoVertexMap.cxx +++ b/pandatool/src/lwo/lwoVertexMap.cxx @@ -79,7 +79,7 @@ read_iff(IffInputFile *in, size_t stop_at) { * */ void LwoVertexMap:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { map_type = " << _map_type << ", dimension = " << _dimension diff --git a/pandatool/src/lwoegg/cLwoPoints.cxx b/pandatool/src/lwoegg/cLwoPoints.cxx index 43f48ee690..93a89f79c6 100644 --- a/pandatool/src/lwoegg/cLwoPoints.cxx +++ b/pandatool/src/lwoegg/cLwoPoints.cxx @@ -26,7 +26,7 @@ void CLwoPoints:: add_vmap(const LwoVertexMap *lwo_vmap) { IffId map_type = lwo_vmap->_map_type; - const string &name = lwo_vmap->_name; + const std::string &name = lwo_vmap->_name; bool inserted; if (map_type == IffId("TXUV")) { @@ -52,7 +52,7 @@ add_vmap(const LwoVertexMap *lwo_vmap) { * given vertex, false otherwise. If true, fills in uv with the value. */ bool CLwoPoints:: -get_uv(const string &uv_name, int n, LPoint2 &uv) const { +get_uv(const std::string &uv_name, int n, LPoint2 &uv) const { VMap::const_iterator ni = _txuv.find(uv_name); if (ni == _txuv.end()) { return false; @@ -82,7 +82,7 @@ void CLwoPoints:: make_egg() { // Generate a vpool name based on the layer index, for lack of anything // better. - string vpool_name = "layer" + format_string(_layer->get_number()); + std::string vpool_name = "layer" + format_string(_layer->get_number()); _egg_vpool = new EggVertexPool(vpool_name); } diff --git a/pandatool/src/lwoegg/cLwoPolygons.cxx b/pandatool/src/lwoegg/cLwoPolygons.cxx index 3f64a6ee83..e6a0fac4cf 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.cxx +++ b/pandatool/src/lwoegg/cLwoPolygons.cxx @@ -25,6 +25,8 @@ #include "eggPoint.h" #include "deg_2_rad.h" +using std::string; + /** * Associates the indicated PolygonTags and Tags with the polygons in this * chunk. This may define features such as per-polygon surfaces, parts, and diff --git a/pandatool/src/lwoegg/cLwoSurface.cxx b/pandatool/src/lwoegg/cLwoSurface.cxx index b3a1c78d1d..63559dd62f 100644 --- a/pandatool/src/lwoegg/cLwoSurface.cxx +++ b/pandatool/src/lwoegg/cLwoSurface.cxx @@ -190,7 +190,7 @@ apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, } if ((_flags & F_smooth_angle) != 0) { - smooth_angle = max(smooth_angle, _smooth_angle); + smooth_angle = std::max(smooth_angle, _smooth_angle); } } diff --git a/pandatool/src/lwoegg/lwoToEggConverter.cxx b/pandatool/src/lwoegg/lwoToEggConverter.cxx index 94aa3b7fe6..42844f19f0 100644 --- a/pandatool/src/lwoegg/lwoToEggConverter.cxx +++ b/pandatool/src/lwoegg/lwoToEggConverter.cxx @@ -69,7 +69,7 @@ make_copy() { /** * Returns the English name of the file type this converter supports. */ -string LwoToEggConverter:: +std::string LwoToEggConverter:: get_name() const { return "Lightwave"; } @@ -77,7 +77,7 @@ get_name() const { /** * Returns the common extension of the file type this converter supports. */ -string LwoToEggConverter:: +std::string LwoToEggConverter:: get_extension() const { return "lwo"; } @@ -182,7 +182,7 @@ get_clip(int number) const { * there is no such surface. */ CLwoSurface *LwoToEggConverter:: -get_surface(const string &name) const { +get_surface(const std::string &name) const { Surfaces::const_iterator si; si = _surfaces.find(name); if (si != _surfaces.end()) { diff --git a/pandatool/src/lwoprogs/lwoScan.cxx b/pandatool/src/lwoprogs/lwoScan.cxx index 5bb0f5a600..c299a3a783 100644 --- a/pandatool/src/lwoprogs/lwoScan.cxx +++ b/pandatool/src/lwoprogs/lwoScan.cxx @@ -48,7 +48,7 @@ run() { nout << "Unable to read file.\n"; } else { while (chunk != nullptr) { - chunk->write(cout, 0); + chunk->write(std::cout, 0); chunk = in.get_chunk(); } } diff --git a/pandatool/src/maxegg/maxEggLoader.cxx b/pandatool/src/maxegg/maxEggLoader.cxx index e2747e6dd0..dca954c6f1 100644 --- a/pandatool/src/maxegg/maxEggLoader.cxx +++ b/pandatool/src/maxegg/maxEggLoader.cxx @@ -39,6 +39,8 @@ #include "maxEggLoader.h" +using std::vector; + class MaxEggMesh; class MaxEggJoint; class MaxEggTex; @@ -64,7 +66,7 @@ public: typedef second_of_pair_iterator MeshIterator; typedef phash_map JointTable; typedef second_of_pair_iterator JointIterator; - typedef phash_map TexTable; + typedef phash_map TexTable; typedef second_of_pair_iterator TexIterator; MeshTable _mesh_tab; @@ -296,7 +298,7 @@ void MaxEggJoint::CreateMaxBone(void) // MaxEggMesh -typedef pair MaxEggWeight; +typedef std::pair MaxEggWeight; struct MaxEggVertex { @@ -344,7 +346,7 @@ class MaxEggMesh { public: - string _name; + std::string _name; TriObject *_obj; Mesh *_mesh; INode *_node; @@ -434,7 +436,7 @@ MaxEggMesh *MaxEggLoader::GetMesh(EggVertexPool *pool) { MaxEggMesh *result = _mesh_tab[pool]; if (result == 0) { - string name = pool->get_name(); + std::string name = pool->get_name(); int nsize = name.size(); if ((nsize > 6) && (name.rfind(".verts")==(nsize-6))) name.resize(nsize-6); diff --git a/pandatool/src/maxegg/maxToEggConverter.cxx b/pandatool/src/maxegg/maxToEggConverter.cxx index 85b909a6e2..41718f66e8 100644 --- a/pandatool/src/maxegg/maxToEggConverter.cxx +++ b/pandatool/src/maxegg/maxToEggConverter.cxx @@ -27,6 +27,8 @@ #include "maxEgg.h" #include "config_putil.h" +using std::string; + /** * */ @@ -704,7 +706,7 @@ make_polyset(INode *max_node, Mesh *mesh, // standard material to the object for (int iChan=0; iChan // for chdir() #endif +using std::string; + MayaApi *MayaApi::_global_api = nullptr; // We need this bogus object just to force the application to link with @@ -255,7 +257,7 @@ read(const Filename &filename) { string dirname = _cwd.to_os_specific(); if (maya_cat.is_debug()) { - maya_cat.debug() << "cwd(read:before): " << dirname.c_str() << endl; + maya_cat.debug() << "cwd(read:before): " << dirname.c_str() << std::endl; } MFileIO::newFile(true); @@ -293,7 +295,7 @@ write(const Filename &filename) { string dirname = _cwd.to_os_specific(); if (maya_cat.is_debug()) { - maya_cat.debug() << "cwd(write:before): " << dirname.c_str() << endl; + maya_cat.debug() << "cwd(write:before): " << dirname.c_str() << std::endl; } const char *type = "mayaBinary"; diff --git a/pandatool/src/maya/mayaShader.cxx b/pandatool/src/maya/mayaShader.cxx index 78484d0be3..9be62a60d3 100644 --- a/pandatool/src/maya/mayaShader.cxx +++ b/pandatool/src/maya/mayaShader.cxx @@ -32,6 +32,9 @@ #include #include "post_maya_include.h" +using std::endl; +using std::string; + /** * Reads the Maya "shading engine" to determine the relevant shader * properties. @@ -92,7 +95,7 @@ MayaShader:: * */ void MayaShader:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Shader " << get_name(); } @@ -100,7 +103,7 @@ output(ostream &out) const { * */ void MayaShader:: -write(ostream &out) const { +write(std::ostream &out) const { out << "Shader " << get_name() << "\n"; } diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index 69aa0cd85e..73d2978d7c 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -29,6 +29,9 @@ #include #include "post_maya_include.h" +using std::endl; +using std::string; + /** * */ @@ -177,7 +180,7 @@ project_uv(const LPoint3d &pos, const LPoint3d ¢roid) const { * */ void MayaShaderColorDef:: -write(ostream &out) const { +write(std::ostream &out) const { if (_has_texture) { out << " texture filename is " << _texture_filename << "\n" << " texture name is " << _texture_name << "\n" diff --git a/pandatool/src/maya/mayaShaders.cxx b/pandatool/src/maya/mayaShaders.cxx index 7aecbd3d61..dca3712366 100644 --- a/pandatool/src/maya/mayaShaders.cxx +++ b/pandatool/src/maya/mayaShaders.cxx @@ -27,6 +27,8 @@ #include #include "post_maya_include.h" +using std::string; + /** * */ diff --git a/pandatool/src/maya/maya_funcs.cxx b/pandatool/src/maya/maya_funcs.cxx index 184a903f66..2f21adefb3 100644 --- a/pandatool/src/maya/maya_funcs.cxx +++ b/pandatool/src/maya/maya_funcs.cxx @@ -31,6 +31,9 @@ #include #include "post_maya_include.h" +using std::endl; +using std::string; + /** * Gets the named MPlug associated, if any. */ diff --git a/pandatool/src/mayaegg/mayaBlendDesc.cxx b/pandatool/src/mayaegg/mayaBlendDesc.cxx index c60ecf515a..b396ed86b6 100644 --- a/pandatool/src/mayaegg/mayaBlendDesc.cxx +++ b/pandatool/src/mayaegg/mayaBlendDesc.cxx @@ -24,7 +24,7 @@ MayaBlendDesc(MFnBlendShapeDeformer &deformer, int weight_index) : _deformer(deformer.object()), _weight_index(weight_index) { - ostringstream strm; + std::ostringstream strm; strm << _deformer.name().asChar() << "." << _weight_index; set_name(strm.str()); diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index 6664e54aa0..701278b6d6 100644 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -71,6 +71,12 @@ #include "mayaEggLoader.h" +using std::cerr; +using std::endl; +using std::ostringstream; +using std::string; +using std::vector; + class MayaEggGroup; class MayaEggGeom; class MayaEggMesh; @@ -617,7 +623,7 @@ void MayaEggJoint::CreateMayaBone(MayaEggGroup *eggParent) // MayaEggGeom : base abstract class of MayaEggMesh and MayaEggNurbsSurface -typedef pair MayaEggWeight; +typedef std::pair MayaEggWeight; struct MayaEggVertex { diff --git a/pandatool/src/mayaegg/mayaNodeDesc.cxx b/pandatool/src/mayaegg/mayaNodeDesc.cxx index 9049bf2dc8..8a86f1cb96 100644 --- a/pandatool/src/mayaegg/mayaNodeDesc.cxx +++ b/pandatool/src/mayaegg/mayaNodeDesc.cxx @@ -26,6 +26,8 @@ #include #include "post_maya_include.h" +using std::string; + TypeHandle MayaNodeDesc::_type_handle; // This is a list of the names of Maya connections that count as a transform. @@ -339,7 +341,7 @@ check_pseudo_joints(bool joint_above) { space.append(" "); } if (mayaegg_cat.is_spam()) { - mayaegg_cat.spam() << "cpj:" << space << get_name() << " joint_type: " << _joint_type << endl; + mayaegg_cat.spam() << "cpj:" << space << get_name() << " joint_type: " << _joint_type << std::endl; } if (_joint_type == JT_joint_parent && joint_above) { // This is one such node: it is the parent of a joint (JT_joint_parent is @@ -387,11 +389,11 @@ check_pseudo_joints(bool joint_above) { child->_joint_type = JT_pseudo_joint; } else if (child->_joint_type == JT_none) { if (mayaegg_cat.is_spam()) { - mayaegg_cat.spam() << "cpj: " << space << "jt_none for " << child->get_name() << endl; + mayaegg_cat.spam() << "cpj: " << space << "jt_none for " << child->get_name() << std::endl; } if (type_name.find("transform") == string::npos) { if (mayaegg_cat.is_spam()) { - mayaegg_cat.spam() << "cpj: " << space << "all_joints false for " << get_name() << endl; + mayaegg_cat.spam() << "cpj: " << space << "all_joints false for " << get_name() << std::endl; } all_joints = false; } diff --git a/pandatool/src/mayaegg/mayaNodeTree.cxx b/pandatool/src/mayaegg/mayaNodeTree.cxx index 32a6281725..f80a3c95c1 100644 --- a/pandatool/src/mayaegg/mayaNodeTree.cxx +++ b/pandatool/src/mayaegg/mayaNodeTree.cxx @@ -32,6 +32,8 @@ #include #include "post_maya_include.h" +using std::string; + /** * */ @@ -611,7 +613,7 @@ r_build_node(const string &path) { if (node_desc != _root) { MayaNodeDesc *parent_node_desc = r_build_node(parent_path); if (parent_node_desc == nullptr) - mayaegg_cat.info() << "empty parent: " << local_name << endl; + mayaegg_cat.info() << "empty parent: " << local_name << std::endl; node_desc = new MayaNodeDesc(this, parent_node_desc, local_name); _nodes.push_back(node_desc); } diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index cefe15e1cc..7943f07f03 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -76,6 +76,9 @@ #include #include "post_maya_include.h" +using std::endl; +using std::string; + /** * @@ -591,7 +594,7 @@ convert_flip(double start_frame, double end_frame, double frame_inc, while (frame <= frame_stop) { mayaegg_cat.info(false) << "frame " << frame.value() << "\n"; - ostringstream name_strm; + std::ostringstream name_strm; name_strm << "frame" << frame.value(); EggGroup *frame_root = new EggGroup(name_strm.str()); sequence_node->add_child(frame_root); diff --git a/pandatool/src/mayaprogs/blend_test.cxx b/pandatool/src/mayaprogs/blend_test.cxx index 5cbd6d413e..ed03fd3661 100644 --- a/pandatool/src/mayaprogs/blend_test.cxx +++ b/pandatool/src/mayaprogs/blend_test.cxx @@ -21,7 +21,7 @@ #include #include -using namespace std; +using std::cerr; void scan_nodes() { @@ -177,7 +177,7 @@ output_vertices(const char *filename, MFnMesh &mesh) { exit(1); } - std::ofstream file(filename, ios::out | ios::trunc); + std::ofstream file(filename, std::ios::out | std::ios::trunc); if (!file) { cerr << "Couldn't open " << filename << " for output.\n"; exit(1); diff --git a/pandatool/src/mayaprogs/mayaCopy.cxx b/pandatool/src/mayaprogs/mayaCopy.cxx index 70cb614a2d..247e0b43ad 100644 --- a/pandatool/src/mayaprogs/mayaCopy.cxx +++ b/pandatool/src/mayaprogs/mayaCopy.cxx @@ -32,6 +32,9 @@ #include #include "post_maya_include.h" +using std::endl; +using std::string; + /** * */ diff --git a/pandatool/src/mayaprogs/mayaEggImport.cxx b/pandatool/src/mayaprogs/mayaEggImport.cxx index 4b4ee413f0..5e38271517 100644 --- a/pandatool/src/mayaprogs/mayaEggImport.cxx +++ b/pandatool/src/mayaprogs/mayaEggImport.cxx @@ -115,7 +115,7 @@ MStatus MayaEggImporter::reader ( const MFileObject& file, std::ostringstream log; Notify::ptr()->set_ostream_ptr(&log, false); bool ok = MayaLoadEggFile(fileName.asChar(), merge, model, anim, false); - string txt = log.str(); + std::string txt = log.str(); if (txt != "") { MGlobal::displayError(txt.c_str()); } else { diff --git a/pandatool/src/mayaprogs/mayaPview.cxx b/pandatool/src/mayaprogs/mayaPview.cxx index 687ec99886..06fc171b14 100644 --- a/pandatool/src/mayaprogs/mayaPview.cxx +++ b/pandatool/src/mayaprogs/mayaPview.cxx @@ -119,13 +119,13 @@ doIt(const MArgList &args) { MProgressWindow::advanceProgress(1); // Now spawn a pview instance to view this temporary file. - string pview_args = "-clD"; + std::string pview_args = "-clD"; if (animate) { pview_args = "-clDa"; } // On Windows, we use the spawn function to run pview asynchronously. - string quoted = string("\"") + bam_filename.get_fullpath() + string("\""); + std::string quoted = std::string("\"") + bam_filename.get_fullpath() + std::string("\""); nout << "pview " << pview_args << " " << quoted << "\n"; int retval = _spawnlp(_P_DETACH, "pview", "pview", pview_args.c_str(), quoted.c_str(), nullptr); @@ -242,7 +242,7 @@ convert(const NodePath &parent, bool animate) { // Accept relative pathnames in the Maya file. Filename source_file = Filename::from_os_specific(MFileIO::currentFile().asChar()); - string source_dir = source_file.get_dirname(); + std::string source_dir = source_file.get_dirname(); if (!source_dir.empty()) { path_replace->_path.append_directory(source_dir); } diff --git a/pandatool/src/mayaprogs/mayaToEgg.cxx b/pandatool/src/mayaprogs/mayaToEgg.cxx index 8d58808a5b..1219f5389a 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg.cxx @@ -319,7 +319,7 @@ run() { * option. */ bool MayaToEgg:: -dispatch_transform_type(const string &opt, const string &arg, void *var) { +dispatch_transform_type(const std::string &opt, const std::string &arg, void *var) { MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var; (*ip) = MayaToEggConverter::string_transform_type(arg); diff --git a/pandatool/src/mayaprogs/mayaToEgg_client.cxx b/pandatool/src/mayaprogs/mayaToEgg_client.cxx index dfde2661c1..a92e6195ec 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_client.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg_client.cxx @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) { // Get the current working directory and make sure it's a string Filename cwd = ExecutionEnvironment::get_cwd(); - string s_cwd = (string)cwd.to_os_specific(); + std::string s_cwd = (std::string)cwd.to_os_specific(); NetDatagram datagram; // First part of the datagram is the argc diff --git a/pandatool/src/mayaprogs/mayaToEgg_server.cxx b/pandatool/src/mayaprogs/mayaToEgg_server.cxx index 8b97d920a4..e95118d33b 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_server.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg_server.cxx @@ -329,7 +329,7 @@ run() { * option. */ bool MayaToEggServer:: -dispatch_transform_type(const string &opt, const string &arg, void *var) { +dispatch_transform_type(const std::string &opt, const std::string &arg, void *var) { MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var; (*ip) = MayaToEggConverter::string_transform_type(arg); @@ -389,7 +389,7 @@ poll() { // track of all the pointers we're gonna malloc. Needed later for // cleanup. vector_string vargv; - vector buffers; + std::vector buffers; // Get the strings from the datagram and put them into the string vector int i; @@ -399,7 +399,7 @@ poll() { // Last string is the current directory the client was run from. Not // part of the argument list, but we still need it - string cwd = data.get_string(); + std::string cwd = data.get_string(); // We allocate some memory to hold the pointers to the pointers we're // going to pass in to parse_command_line(). @@ -439,7 +439,7 @@ poll() { vargv.clear(); // No, iterate through the char * vector and cleanup the malloc'd // pointers - vector::iterator vi; + std::vector::iterator vi; for ( vi = buffers.begin() ; vi != buffers.end(); vi++) { free(*vi); } diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index cac021eebe..ae9ad39ac2 100644 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -51,6 +51,10 @@ #include #endif +using std::cerr; +using std::endl; +using std::string; + #define QUOTESTR(x) #x #define TOSTRING(x) QUOTESTR(x) diff --git a/pandatool/src/mayaprogs/normal_test.cxx b/pandatool/src/mayaprogs/normal_test.cxx index ca1b4638eb..41680254de 100644 --- a/pandatool/src/mayaprogs/normal_test.cxx +++ b/pandatool/src/mayaprogs/normal_test.cxx @@ -23,7 +23,8 @@ #include #include -using namespace std; +using std::cerr; +using std::endl; void scan_nodes() { diff --git a/pandatool/src/miscprogs/binToC.cxx b/pandatool/src/miscprogs/binToC.cxx index 44eddfb1ac..f963c08986 100644 --- a/pandatool/src/miscprogs/binToC.cxx +++ b/pandatool/src/miscprogs/binToC.cxx @@ -73,13 +73,13 @@ run() { } std::ostream &out = get_output(); - string static_keyword; + std::string static_keyword; if (_static_table) { static_keyword = "static "; } - string table_type = "const unsigned char "; - string length_type = "const int "; + std::string table_type = "const unsigned char "; + std::string length_type = "const int "; if (_for_string) { // Actually, declaring the table as "const char" causes VC7 to yell about // truncating all of the values >= 0x80. table_type = "const char "; @@ -96,7 +96,7 @@ run() { << "#include \n" << "\n" << static_keyword << table_type << _table_name << "[] = {"; - out << hex << setfill('0'); + out << std::hex << std::setfill('0'); int count = 0; int col = 0; unsigned int ch; @@ -110,14 +110,14 @@ run() { } else { out << ", "; } - out << "0x" << setw(2) << ch; + out << "0x" << std::setw(2) << ch; col++; count++; ch = in.get(); } out << "\n};\n\n" << static_keyword << length_type << _table_name << "_len = " - << dec << count << ";\n\n"; + << std::dec << count << ";\n\n"; } /** diff --git a/pandatool/src/objegg/eggToObjConverter.cxx b/pandatool/src/objegg/eggToObjConverter.cxx index 96505e7f35..a03630698c 100644 --- a/pandatool/src/objegg/eggToObjConverter.cxx +++ b/pandatool/src/objegg/eggToObjConverter.cxx @@ -23,6 +23,9 @@ #include "eggLine.h" #include "dcast.h" +using std::ostream; +using std::string; + /** * */ diff --git a/pandatool/src/objegg/objToEggConverter.cxx b/pandatool/src/objegg/objToEggConverter.cxx index 05af8ce1a2..7278a32dc9 100644 --- a/pandatool/src/objegg/objToEggConverter.cxx +++ b/pandatool/src/objegg/objToEggConverter.cxx @@ -27,6 +27,8 @@ #include "triangulator3.h" #include "config_egg2pg.h" +using std::string; + /** * */ @@ -147,7 +149,7 @@ convert_to_node(const LoaderOptions &options, const Filename &filename) { bool ObjToEggConverter:: process(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *strm = vfs->open_read_file(filename, true); + std::istream *strm = vfs->open_read_file(filename, true); if (strm == nullptr) { objegg_cat.error() << "Couldn't read " << filename << "\n"; @@ -552,7 +554,7 @@ generate_egg_points() { bool ObjToEggConverter:: process_node(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - istream *strm = vfs->open_read_file(filename, true); + std::istream *strm = vfs->open_read_file(filename, true); if (strm == nullptr) { objegg_cat.error() << "Couldn't read " << filename << "\n"; @@ -799,7 +801,7 @@ generate_points() { */ int ObjToEggConverter:: add_synth_normal(const LVecBase3d &normal) { - pair result = _unique_synth_vn_table.insert(UniqueVec3Table::value_type(normal, _unique_synth_vn_table.size())); + std::pair result = _unique_synth_vn_table.insert(UniqueVec3Table::value_type(normal, _unique_synth_vn_table.size())); UniqueVec3Table::iterator ni = result.first; int index = (*ni).second; @@ -895,7 +897,7 @@ VertexData(PandaNode *parent, const string &name) : */ int ObjToEggConverter::VertexData:: add_vertex(const ObjToEggConverter *converter, const VertexEntry &entry) { - pair result; + std::pair result; UniqueVertexEntries::iterator ni; int index; diff --git a/pandatool/src/palettizer/destTextureImage.cxx b/pandatool/src/palettizer/destTextureImage.cxx index b1b3c1853b..38f9a879d1 100644 --- a/pandatool/src/palettizer/destTextureImage.cxx +++ b/pandatool/src/palettizer/destTextureImage.cxx @@ -48,8 +48,8 @@ DestTextureImage(TexturePlacement *placement) { _x_size = to_power_2(_x_size); _y_size = to_power_2(_y_size); } else { - _x_size = max(_x_size, 1); - _y_size = max(_y_size, 1); + _x_size = std::max(_x_size, 1); + _y_size = std::max(_y_size, 1); } } diff --git a/pandatool/src/palettizer/eggFile.cxx b/pandatool/src/palettizer/eggFile.cxx index 1b9e20e9e8..40376a7988 100644 --- a/pandatool/src/palettizer/eggFile.cxx +++ b/pandatool/src/palettizer/eggFile.cxx @@ -57,7 +57,7 @@ bool EggFile:: from_command_line(EggData *data, const Filename &source_filename, const Filename &dest_filename, - const string &egg_comment) { + const std::string &egg_comment) { _data = data; _had_data = true; remove_backstage(_data); @@ -588,7 +588,7 @@ write_egg() { * the indicated output stream. */ void EggFile:: -write_description(ostream &out, int indent_level) const { +write_description(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_name() << ": "; if (_explicitly_assigned_groups.empty()) { if (_default_group != nullptr) { @@ -609,7 +609,7 @@ write_description(ostream &out, int indent_level) const { * per line. */ void EggFile:: -write_texture_refs(ostream &out, int indent_level) const { +write_texture_refs(std::ostream &out, int indent_level) const { Textures::const_iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { TextureReference *reference = (*ti); @@ -663,7 +663,7 @@ rescan_textures() { // Make sure each tref name is unique within a given file. tc.uniquify_trefs(); - typedef pmap ByTRefName; + typedef pmap ByTRefName; ByTRefName by_tref_name; for (Textures::const_iterator ti = _textures.begin(); ti != _textures.end(); diff --git a/pandatool/src/palettizer/imageFile.cxx b/pandatool/src/palettizer/imageFile.cxx index eb2409aab6..15a5ebc4e6 100644 --- a/pandatool/src/palettizer/imageFile.cxx +++ b/pandatool/src/palettizer/imageFile.cxx @@ -24,6 +24,8 @@ #include "bamReader.h" #include "bamWriter.h" +using std::string; + TypeHandle ImageFile::_type_handle; /** @@ -419,7 +421,7 @@ update_egg_tex(EggTexture *egg_tex) const { * Writes the filename (or pair of filenames) to the indicated output stream. */ void ImageFile:: -output_filename(ostream &out) const { +output_filename(std::ostream &out) const { out << FilenameUnifier::make_user_filename(_filename); if (_properties.uses_alpha() && !_alpha_filename.empty()) { out << " " << FilenameUnifier::make_user_filename(_alpha_filename); diff --git a/pandatool/src/palettizer/omitReason.cxx b/pandatool/src/palettizer/omitReason.cxx index 94848b865c..6bc14240f4 100644 --- a/pandatool/src/palettizer/omitReason.cxx +++ b/pandatool/src/palettizer/omitReason.cxx @@ -13,8 +13,8 @@ #include "omitReason.h" -ostream & -operator << (ostream &out, OmitReason omit) { +std::ostream & +operator << (std::ostream &out, OmitReason omit) { switch (omit) { case OR_none: return out << "none"; diff --git a/pandatool/src/palettizer/pal_string_utils.cxx b/pandatool/src/palettizer/pal_string_utils.cxx index be747e4106..279a7aad47 100644 --- a/pandatool/src/palettizer/pal_string_utils.cxx +++ b/pandatool/src/palettizer/pal_string_utils.cxx @@ -16,6 +16,8 @@ #include "pnmFileType.h" #include "pnmFileTypeRegistry.h" +using std::string; + // Extracts the first word of the string into param, and the remainder of the // line into value. diff --git a/pandatool/src/palettizer/paletteGroup.cxx b/pandatool/src/palettizer/paletteGroup.cxx index 409bf28f33..182479216f 100644 --- a/pandatool/src/palettizer/paletteGroup.cxx +++ b/pandatool/src/palettizer/paletteGroup.cxx @@ -26,6 +26,8 @@ #include "indirectCompareNames.h" #include "pvector.h" +using std::string; + TypeHandle PaletteGroup::_type_handle; /** @@ -454,7 +456,7 @@ update_unknown_textures(const TxaFile &txa_file) { * their textures, to the indicated output stream. */ void PaletteGroup:: -write_image_info(ostream &out, int indent_level) const { +write_image_info(std::ostream &out, int indent_level) const { Pages::const_iterator pai; for (pai = _pages.begin(); pai != _pages.end(); ++pai) { PalettePage *page = (*pai).second; diff --git a/pandatool/src/palettizer/paletteGroups.cxx b/pandatool/src/palettizer/paletteGroups.cxx index ae1f810d5e..c964f2b057 100644 --- a/pandatool/src/palettizer/paletteGroups.cxx +++ b/pandatool/src/palettizer/paletteGroups.cxx @@ -213,7 +213,7 @@ end() const { * */ void PaletteGroups:: -output(ostream &out) const { +output(std::ostream &out) const { if (!_groups.empty()) { // Sort the group names into order by name for output. pvector group_vector; @@ -239,7 +239,7 @@ output(ostream &out) const { * */ void PaletteGroups:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { // Sort the group names into order by name for output. pvector group_vector; group_vector.reserve(_groups.size()); diff --git a/pandatool/src/palettizer/paletteImage.cxx b/pandatool/src/palettizer/paletteImage.cxx index ee2ae01856..871b71ca40 100644 --- a/pandatool/src/palettizer/paletteImage.cxx +++ b/pandatool/src/palettizer/paletteImage.cxx @@ -476,7 +476,7 @@ resize_swapped_image(int x_size, int y_size) { * indicated output stream, one per line. */ void PaletteImage:: -write_placements(ostream &out, int indent_level) const { +write_placements(std::ostream &out, int indent_level) const { Placements::const_iterator pi; for (pi = _placements.begin(); pi != _placements.end(); ++pi) { TexturePlacement *placement = (*pi); @@ -712,9 +712,9 @@ bool PaletteImage:: setup_filename() { // Build up the basename for the palette image, based on the supplied image // pattern. - _basename = string(); + _basename = std::string(); - string::iterator si = pal->_generated_image_pattern.begin(); + std::string::iterator si = pal->_generated_image_pattern.begin(); while (si != pal->_generated_image_pattern.end()) { if ((*si) == '%') { // Some keycode. @@ -800,7 +800,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { } next_x = overlap->get_placed_x() + overlap->get_placed_x_size(); - next_y = min(next_y, overlap->get_placed_y() + overlap->get_placed_y_size()); + next_y = std::min(next_y, overlap->get_placed_y() + overlap->get_placed_y_size()); nassertr(next_x > x, false); x = next_x; } diff --git a/pandatool/src/palettizer/palettePage.cxx b/pandatool/src/palettizer/palettePage.cxx index adc73c660f..9bdc74c57e 100644 --- a/pandatool/src/palettizer/palettePage.cxx +++ b/pandatool/src/palettizer/palettePage.cxx @@ -141,7 +141,7 @@ unplace(TexturePlacement *placement) { * their textures, to the indicated output stream. */ void PalettePage:: -write_image_info(ostream &out, int indent_level) const { +write_image_info(std::ostream &out, int indent_level) const { Images::const_iterator ii; for (ii = _images.begin(); ii != _images.end(); ++ii) { PaletteImage *image = (*ii); diff --git a/pandatool/src/palettizer/palettizer.cxx b/pandatool/src/palettizer/palettizer.cxx index 3244fd396a..157c267730 100644 --- a/pandatool/src/palettizer/palettizer.cxx +++ b/pandatool/src/palettizer/palettizer.cxx @@ -29,6 +29,9 @@ #include "bamWriter.h" #include "indent.h" +using std::cout; +using std::string; + Palettizer *pal = nullptr; // This number is written out as the first number to the pi file, to indicate @@ -60,7 +63,7 @@ int Palettizer::_read_pi_version = 0; TypeHandle Palettizer::_type_handle; -ostream &operator << (ostream &out, Palettizer::RemapUV remap) { +std::ostream &operator << (std::ostream &out, Palettizer::RemapUV remap) { switch (remap) { case Palettizer::RU_never: return out << "never"; @@ -347,7 +350,7 @@ report_statistics() const { * files. */ void Palettizer:: -read_txa_file(istream &txa_file, const string &txa_filename) { +read_txa_file(std::istream &txa_file, const string &txa_filename) { // Clear out the group dependencies, in preparation for reading them again // from the .txa file. Groups::iterator gi; @@ -890,7 +893,7 @@ string_remap(const string &str) { * texture placements, and reports this to the indicated output stream. */ void Palettizer:: -compute_statistics(ostream &out, int indent_level, +compute_statistics(std::ostream &out, int indent_level, const Palettizer::Placements &placements) const { TextureMemoryCounter counter; @@ -1021,7 +1024,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { DCAST_INTO_R(texture, p_list[index], index); string name = downcase(texture->get_name()); - pair result = _textures.insert(Textures::value_type(name, texture)); + std::pair result = _textures.insert(Textures::value_type(name, texture)); if (!result.second) { // Two textures mapped to the same slot--probably a case error (since we // just changed this rule). diff --git a/pandatool/src/palettizer/textureImage.cxx b/pandatool/src/palettizer/textureImage.cxx index f33d01c408..612aa5b3c6 100644 --- a/pandatool/src/palettizer/textureImage.cxx +++ b/pandatool/src/palettizer/textureImage.cxx @@ -31,6 +31,8 @@ #include +using std::string; + TypeHandle TextureImage::_type_handle; /** @@ -661,7 +663,7 @@ copy_unplaced(bool redo_all) { Filename filename = dest->get_filename(); FilenameUnifier::make_canonical(filename); - pair insert_result = generate.insert + std::pair insert_result = generate.insert (Dests::value_type(filename, dest)); if (!insert_result.second) { // At least two DestTextureImages map to the same filename, no sweat. @@ -780,7 +782,7 @@ is_newer_than(const Filename &reference_filename) { * to the indicated output stream, one per line. */ void TextureImage:: -write_source_pathnames(ostream &out, int indent_level) const { +write_source_pathnames(std::ostream &out, int indent_level) const { Sources::const_iterator si; for (si = _sources.begin(); si != _sources.end(); ++si) { SourceTextureImage *source = (*si).second; @@ -853,7 +855,7 @@ write_source_pathnames(ostream &out, int indent_level) const { * Writes the information about the texture's size and placement. */ void TextureImage:: -write_scale_info(ostream &out, int indent_level) { +write_scale_info(std::ostream &out, int indent_level) { SourceTextureImage *source = get_preferred_source(); indent(out, indent_level) << get_name(); diff --git a/pandatool/src/palettizer/textureMemoryCounter.cxx b/pandatool/src/palettizer/textureMemoryCounter.cxx index 3c3f78b571..91281670c6 100644 --- a/pandatool/src/palettizer/textureMemoryCounter.cxx +++ b/pandatool/src/palettizer/textureMemoryCounter.cxx @@ -81,7 +81,7 @@ add_placement(TexturePlacement *placement) { * Reports the measured texture memory usage. */ void TextureMemoryCounter:: -report(ostream &out, int indent_level) { +report(std::ostream &out, int indent_level) { indent(out, indent_level) << _num_placed << " of " << _num_textures << " textures appear on " << _num_palettes << " palette images with " << _num_unplaced @@ -120,8 +120,8 @@ report(ostream &out, int indent_level) { * Writes to the indicated ostream an indication of the fraction of the total * memory usage that is represented by fraction_bytes. */ -ostream &TextureMemoryCounter:: -format_memory_fraction(ostream &out, int fraction_bytes, int palette_bytes) { +std::ostream &TextureMemoryCounter:: +format_memory_fraction(std::ostream &out, int fraction_bytes, int palette_bytes) { out << floor(1000.0 * (double)fraction_bytes / (double)palette_bytes + 0.5) / 10.0 << "% (" << (fraction_bytes + 512) / 1024 << "k)"; return out; @@ -156,7 +156,7 @@ add_palette(PaletteImage *image) { */ void TextureMemoryCounter:: add_texture(TextureImage *texture, int bytes) { - pair result; + std::pair result; result = _textures.insert(Textures::value_type(texture, bytes)); if (result.second) { // If it was inserted, no problem--no duplicates. @@ -167,8 +167,8 @@ add_texture(TextureImage *texture, int bytes) { // If it was not inserted, we have a duplicate. Textures::iterator ti = result.first; - _duplicate_bytes += min(bytes, (*ti).second); - (*ti).second = max(bytes, (*ti).second); + _duplicate_bytes += std::min(bytes, (*ti).second); + (*ti).second = std::max(bytes, (*ti).second); } /** diff --git a/pandatool/src/palettizer/texturePlacement.cxx b/pandatool/src/palettizer/texturePlacement.cxx index 36331ed233..01f47b42a1 100644 --- a/pandatool/src/palettizer/texturePlacement.cxx +++ b/pandatool/src/palettizer/texturePlacement.cxx @@ -27,6 +27,9 @@ #include "bamWriter.h" #include "pnmImage.h" +using std::max; +using std::min; + TypeHandle TexturePlacement::_type_handle; /** @@ -88,7 +91,7 @@ TexturePlacement:: /** * Returns the name of the texture that this placement represents. */ -const string &TexturePlacement:: +const std::string &TexturePlacement:: get_name() const { return _texture->get_name(); } @@ -640,7 +643,7 @@ compute_tex_matrix(LMatrix3d &transform) { * Writes the placement position information on a line by itself. */ void TexturePlacement:: -write_placed(ostream &out, int indent_level) { +write_placed(std::ostream &out, int indent_level) { indent(out, indent_level) << get_texture()->get_name(); diff --git a/pandatool/src/palettizer/textureProperties.cxx b/pandatool/src/palettizer/textureProperties.cxx index 9538b85165..573dd784b3 100644 --- a/pandatool/src/palettizer/textureProperties.cxx +++ b/pandatool/src/palettizer/textureProperties.cxx @@ -20,6 +20,8 @@ #include "bamWriter.h" #include "string_utils.h" +using std::string; + TypeHandle TextureProperties::_type_handle; /** @@ -183,7 +185,7 @@ get_string() const { string result; if (_got_num_channels) { - ostringstream num; + std::ostringstream num; num << _effective_num_channels; result += num.str(); } diff --git a/pandatool/src/palettizer/textureReference.cxx b/pandatool/src/palettizer/textureReference.cxx index 7bb869c336..4a11b5348d 100644 --- a/pandatool/src/palettizer/textureReference.cxx +++ b/pandatool/src/palettizer/textureReference.cxx @@ -35,6 +35,10 @@ #include +using std::max; +using std::min; +using std::string; + TypeHandle TextureReference::_type_handle; /** @@ -455,7 +459,7 @@ apply_properties_to_source() { * */ void TextureReference:: -output(ostream &out) const { +output(std::ostream &out) const { out << *_source_texture; } @@ -463,7 +467,7 @@ output(ostream &out) const { * */ void TextureReference:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_texture()->get_name(); diff --git a/pandatool/src/palettizer/txaFile.cxx b/pandatool/src/palettizer/txaFile.cxx index 7aff6ad221..cb4cb5331d 100644 --- a/pandatool/src/palettizer/txaFile.cxx +++ b/pandatool/src/palettizer/txaFile.cxx @@ -20,6 +20,8 @@ #include "pnotify.h" #include "pnmFileTypeRegistry.h" +using std::string; + /** * */ @@ -32,7 +34,7 @@ TxaFile() { * there is an error. */ bool TxaFile:: -read(istream &in, const string &filename) { +read(std::istream &in, const string &filename) { string line; int line_number = 1; @@ -160,7 +162,7 @@ match_texture(TextureImage *texture) const { * output stream. This is primarily useful for debugging. */ void TxaFile:: -write(ostream &out) const { +write(std::ostream &out) const { Lines::const_iterator li; for (li = _lines.begin(); li != _lines.end(); ++li) { out << (*li) << "\n"; @@ -173,7 +175,7 @@ write(ostream &out) const { * line, or EOF if the end of file has been reached. */ int TxaFile:: -get_line_or_semicolon(istream &in, string &line) { +get_line_or_semicolon(std::istream &in, string &line) { line = string(); int ch = in.get(); char semicolon = ';'; diff --git a/pandatool/src/palettizer/txaLine.cxx b/pandatool/src/palettizer/txaLine.cxx index 51a1532610..41f9349c51 100644 --- a/pandatool/src/palettizer/txaLine.cxx +++ b/pandatool/src/palettizer/txaLine.cxx @@ -22,6 +22,8 @@ #include "pnotify.h" #include "pnmFileType.h" +using std::string; + /** * */ @@ -410,8 +412,8 @@ match_texture(TextureImage *texture) const { case ST_scale: if (source != nullptr && source->get_size()) { request._got_size = true; - request._x_size = max(1, (int)(source->get_x_size() * _scale / 100.0)); - request._y_size = max(1, (int)(source->get_y_size() * _scale / 100.0)); + request._x_size = std::max(1, (int)(source->get_x_size() * _scale / 100.0)); + request._y_size = std::max(1, (int)(source->get_y_size() * _scale / 100.0)); } break; @@ -523,7 +525,7 @@ match_texture(TextureImage *texture) const { * */ void TxaLine:: -output(ostream &out) const { +output(std::ostream &out) const { Patterns::const_iterator pi; for (pi = _texture_patterns.begin(); pi != _texture_patterns.end(); ++pi) { out << (*pi) << " "; diff --git a/pandatool/src/pandatoolbase/animationConvert.cxx b/pandatool/src/pandatoolbase/animationConvert.cxx index 6403da48cd..d09ce0f19f 100644 --- a/pandatool/src/pandatoolbase/animationConvert.cxx +++ b/pandatool/src/pandatoolbase/animationConvert.cxx @@ -19,7 +19,7 @@ /** * Returns the string corresponding to this method. */ -string +std::string format_animation_convert(AnimationConvert convert) { switch (convert) { case AC_invalid: @@ -53,8 +53,8 @@ format_animation_convert(AnimationConvert convert) { /** * */ -ostream & -operator << (ostream &out, AnimationConvert convert) { +std::ostream & +operator << (std::ostream &out, AnimationConvert convert) { return out << format_animation_convert(convert); } @@ -63,7 +63,7 @@ operator << (ostream &out, AnimationConvert convert) { * AnimationConvert types. Returns AC_invalid if the string is unknown. */ AnimationConvert -string_animation_convert(const string &str) { +string_animation_convert(const std::string &str) { if (cmp_nocase(str, "none") == 0) { return AC_none; diff --git a/pandatool/src/pandatoolbase/distanceUnit.cxx b/pandatool/src/pandatoolbase/distanceUnit.cxx index d2479de244..8ee495be3c 100644 --- a/pandatool/src/pandatoolbase/distanceUnit.cxx +++ b/pandatool/src/pandatoolbase/distanceUnit.cxx @@ -16,6 +16,10 @@ #include "string_utils.h" #include "pnotify.h" +using std::istream; +using std::ostream; +using std::string; + /** * Returns the string representing the common abbreviation for the given unit. */ diff --git a/pandatool/src/pandatoolbase/pathReplace.cxx b/pandatool/src/pandatoolbase/pathReplace.cxx index c3891cf047..b3b6bcb498 100644 --- a/pandatool/src/pandatoolbase/pathReplace.cxx +++ b/pandatool/src/pandatoolbase/pathReplace.cxx @@ -354,7 +354,7 @@ full_convert_path(const Filename &orig_filename, * */ void PathReplace:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { indent(out, indent_level) @@ -451,7 +451,7 @@ copy_this_file(Filename &filename) { * */ PathReplace::Entry:: -Entry(const string &orig_prefix, const string &replacement_prefix) : +Entry(const std::string &orig_prefix, const std::string &replacement_prefix) : _orig_prefix(orig_prefix), _replacement_prefix(replacement_prefix) { @@ -495,7 +495,7 @@ try_match(const Filename &filename, Filename &new_filename) const { } // We found a match. Construct the replacement string. - string result = _replacement_prefix; + std::string result = _replacement_prefix; while (mi < components.size()) { if (!result.empty()) { result += '/'; diff --git a/pandatool/src/pandatoolbase/pathStore.cxx b/pandatool/src/pandatoolbase/pathStore.cxx index d40fe3f276..dffacfe678 100644 --- a/pandatool/src/pandatoolbase/pathStore.cxx +++ b/pandatool/src/pandatoolbase/pathStore.cxx @@ -19,7 +19,7 @@ /** * Returns the string corresponding to this method. */ -string +std::string format_path_store(PathStore store) { switch (store) { case PS_invalid: @@ -47,8 +47,8 @@ format_path_store(PathStore store) { /** * */ -ostream & -operator << (ostream &out, PathStore store) { +std::ostream & +operator << (std::ostream &out, PathStore store) { return out << format_path_store(store); } @@ -57,7 +57,7 @@ operator << (ostream &out, PathStore store) { * PathStore types. Returns PS_invalid if the string is unknown. */ PathStore -string_path_store(const string &str) { +string_path_store(const std::string &str) { if (cmp_nocase(str, "relative") == 0 || cmp_nocase(str, "rel") == 0) { return PS_relative; diff --git a/pandatool/src/pfmprogs/pfmBba.cxx b/pandatool/src/pfmprogs/pfmBba.cxx index 30804d8fea..ce0851a47f 100644 --- a/pandatool/src/pfmprogs/pfmBba.cxx +++ b/pandatool/src/pfmprogs/pfmBba.cxx @@ -77,7 +77,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { pofstream out; if (!bba_filename.open_write(out)) { - cerr << "Unable to open " << bba_filename << "\n"; + std::cerr << "Unable to open " << bba_filename << "\n"; return false; } diff --git a/pandatool/src/pfmprogs/pfmTrans.cxx b/pandatool/src/pfmprogs/pfmTrans.cxx index fdf803b601..ffb99b2472 100644 --- a/pandatool/src/pfmprogs/pfmTrans.cxx +++ b/pandatool/src/pfmprogs/pfmTrans.cxx @@ -21,6 +21,8 @@ #include "string_utils.h" #include "pandaFileStream.h" +using std::string; + /** * */ diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index e97a536127..9cdb70263d 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -45,6 +45,12 @@ #endif // TIOCGWINSZ #endif // IOCTL_TERMINAL_WIDTH +using std::cerr; +using std::cout; +using std::max; +using std::min; +using std::string; + bool ProgramBase::SortOptionsByIndex:: operator () (const Option *a, const Option *b) const { if (a->_index_group != b->_index_group) { @@ -181,7 +187,7 @@ show_text(const string &prefix, int indent_width, string text) { * This is useful when creating a man page for this utility. */ void ProgramBase:: -write_man_page(ostream &out) { +write_man_page(std::ostream &out) { string prog = _program_name.get_basename_wo_extension(); out << ".\\\" Automatically generated by " << prog << " -write-man\n"; @@ -296,7 +302,7 @@ parse_command_line(int argc, char **argv) { write_man_page(cout); } else { - pofstream man_out(argv[2], ios::out | ios::trunc); + pofstream man_out(argv[2], std::ios::out | std::ios::trunc); if (!man_out) { cerr << "Failed to open output file " << argv[2] << "!\n"; } @@ -1277,7 +1283,7 @@ handle_help_option(const string &, const string &, void *data) { * doubled newlines. */ void ProgramBase:: -format_text(ostream &out, bool &last_newline, +format_text(std::ostream &out, bool &last_newline, const string &prefix, int indent_width, const string &text, int line_width) { indent_width = min(indent_width, line_width - 20); diff --git a/pandatool/src/progbase/withOutputFile.cxx b/pandatool/src/progbase/withOutputFile.cxx index b88dec05d8..04e5005f0e 100644 --- a/pandatool/src/progbase/withOutputFile.cxx +++ b/pandatool/src/progbase/withOutputFile.cxx @@ -46,7 +46,7 @@ WithOutputFile:: * Returns an output stream that corresponds to the user's intended egg file * output--either stdout, or the named output file. */ -ostream &WithOutputFile:: +std::ostream &WithOutputFile:: get_output() { if (_output_ptr == nullptr) { if (!_got_output_filename) { @@ -55,7 +55,7 @@ get_output() { nout << "No output filename specified.\n"; exit(1); } - _output_ptr = &cout; + _output_ptr = &std::cout; _owns_output_ptr = false; } else { diff --git a/pandatool/src/progbase/wordWrapStream.cxx b/pandatool/src/progbase/wordWrapStream.cxx index a3ac50b99b..cd069d1eaa 100644 --- a/pandatool/src/progbase/wordWrapStream.cxx +++ b/pandatool/src/progbase/wordWrapStream.cxx @@ -19,7 +19,7 @@ */ WordWrapStream:: WordWrapStream(ProgramBase *program) : - ostream(&_lsb), + std::ostream(&_lsb), _lsb(this, program) { } diff --git a/pandatool/src/progbase/wordWrapStreamBuf.cxx b/pandatool/src/progbase/wordWrapStreamBuf.cxx index f8f4dced30..0e0c4abbcb 100644 --- a/pandatool/src/progbase/wordWrapStreamBuf.cxx +++ b/pandatool/src/progbase/wordWrapStreamBuf.cxx @@ -42,7 +42,7 @@ WordWrapStreamBuf:: */ int WordWrapStreamBuf:: sync() { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); write_chars(pbase(), n); // Send all the data out now. @@ -57,7 +57,7 @@ sync() { */ int WordWrapStreamBuf:: overflow(int ch) { - streamsize n = pptr() - pbase(); + std::streamsize n = pptr() - pbase(); if (n != 0 && sync() != 0) { return EOF; @@ -81,10 +81,10 @@ void WordWrapStreamBuf:: write_chars(const char *start, int length) { if (length > 0) { set_literal_mode((_owner->flags() & Notify::get_literal_flag()) != 0); - string new_data(start, length); + std::string new_data(start, length); size_t newline = new_data.find_first_of("\n\r"); size_t p = 0; - while (newline != string::npos) { + while (newline != std::string::npos) { // The new data contains a newline; flush our data to that point. _data += new_data.substr(p, newline - p + 1); flush_data(); @@ -105,7 +105,7 @@ void WordWrapStreamBuf:: flush_data() { if (!_data.empty()) { if (_literal_mode) { - cerr << _data; + std::cerr << _data; } else { _program->show_text(_data); } diff --git a/pandatool/src/pstatserver/pStatClientData.cxx b/pandatool/src/pstatserver/pStatClientData.cxx index 77136b7f1d..26e06f069c 100644 --- a/pandatool/src/pstatserver/pStatClientData.cxx +++ b/pandatool/src/pstatserver/pStatClientData.cxx @@ -16,6 +16,8 @@ #include "pStatCollectorDef.h" +using std::string; + PStatCollectorDef PStatClientData::_null_collector(-1, "Unknown"); diff --git a/pandatool/src/pstatserver/pStatGraph.cxx b/pandatool/src/pstatserver/pStatGraph.cxx index f65dafbc3b..88130ff7ab 100644 --- a/pandatool/src/pstatserver/pStatGraph.cxx +++ b/pandatool/src/pstatserver/pStatGraph.cxx @@ -20,6 +20,8 @@ #include // for sprintf +using std::string; + /** * */ diff --git a/pandatool/src/pstatserver/pStatMonitor.cxx b/pandatool/src/pstatserver/pStatMonitor.cxx index f7e70727fe..09e22b093a 100644 --- a/pandatool/src/pstatserver/pStatMonitor.cxx +++ b/pandatool/src/pstatserver/pStatMonitor.cxx @@ -15,6 +15,8 @@ #include "pStatCollectorDef.h" +using std::string; + /** * diff --git a/pandatool/src/pstatserver/pStatReader.cxx b/pandatool/src/pstatserver/pStatReader.cxx index c302185e0f..02b01f26a2 100644 --- a/pandatool/src/pstatserver/pStatReader.cxx +++ b/pandatool/src/pstatserver/pStatReader.cxx @@ -123,7 +123,7 @@ get_monitor() { /** * Returns the current machine's hostname. */ -string PStatReader:: +std::string PStatReader:: get_hostname() { if (_hostname.empty()) { _hostname = ConnectionManager::get_host_name(); @@ -217,7 +217,7 @@ handle_client_control_message(const PStatClientControlMessage &message) { { for (int i = 0; i < (int)message._names.size(); i++) { int thread_index = message._first_thread_index + i; - string name = message._names[i]; + std::string name = message._names[i]; _client_data->define_thread(thread_index, name); _monitor->new_thread(thread_index); } diff --git a/pandatool/src/pstatserver/pStatStripChart.cxx b/pandatool/src/pstatserver/pStatStripChart.cxx index 9b64abaa02..c9ffcb3109 100644 --- a/pandatool/src/pstatserver/pStatStripChart.cxx +++ b/pandatool/src/pstatserver/pStatStripChart.cxx @@ -22,6 +22,9 @@ #include +using std::max; +using std::min; + /** * */ @@ -248,9 +251,9 @@ get_collector_under_pixel(int xpoint, int ypoint) { /** * Returns the text suitable for the title label on the top line. */ -string PStatStripChart:: +std::string PStatStripChart:: get_title_text() { - string text; + std::string text; _title_unknown = false; diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.cxx b/pandatool/src/ptloader/loaderFileTypePandatool.cxx index dade132585..769eb737d0 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.cxx +++ b/pandatool/src/ptloader/loaderFileTypePandatool.cxx @@ -47,7 +47,7 @@ LoaderFileTypePandatool:: /** * */ -string LoaderFileTypePandatool:: +std::string LoaderFileTypePandatool:: get_name() const { if (_loader != nullptr) { return _loader->get_name(); @@ -58,7 +58,7 @@ get_name() const { /** * */ -string LoaderFileTypePandatool:: +std::string LoaderFileTypePandatool:: get_extension() const { if (_loader != nullptr) { return _loader->get_extension(); @@ -70,7 +70,7 @@ get_extension() const { * Returns a space-separated list of extension, in addition to the one * returned by get_extension(), that are recognized by this converter. */ -string LoaderFileTypePandatool:: +std::string LoaderFileTypePandatool:: get_additional_extensions() const { if (_loader != nullptr) { return _loader->get_additional_extensions(); diff --git a/pandatool/src/softegg/softNodeDesc.cxx b/pandatool/src/softegg/softNodeDesc.cxx index 86d98ab7db..ff0f624a20 100644 --- a/pandatool/src/softegg/softNodeDesc.cxx +++ b/pandatool/src/softegg/softNodeDesc.cxx @@ -19,13 +19,15 @@ #include "softToEggConverter.h" #include "dcast.h" +using std::endl; + TypeHandle SoftNodeDesc::_type_handle; /** * */ SoftNodeDesc:: -SoftNodeDesc(SoftNodeDesc *parent, const string &name) : +SoftNodeDesc(SoftNodeDesc *parent, const std::string &name) : Namable(name), _parent(parent) { @@ -901,7 +903,7 @@ make_vertex_offsets(int numShapes) { SAA_Scene *scene = &stec.scene; EggVertexPool *vpool = nullptr; - string vpool_name = get_name() + ".verts"; + std::string vpool_name = get_name() + ".verts"; EggNode *t = stec._tree.get_egg_root()->find_child(vpool_name); if (t) DCAST_INTO_V(vpool, t); diff --git a/pandatool/src/softegg/softNodeTree.cxx b/pandatool/src/softegg/softNodeTree.cxx index a896bce4e0..3b5be3252b 100644 --- a/pandatool/src/softegg/softNodeTree.cxx +++ b/pandatool/src/softegg/softNodeTree.cxx @@ -25,6 +25,8 @@ #include +using std::endl; + /** * */ @@ -288,7 +290,7 @@ get_node(int n) const { * Returns the node named 'name' in the hierarchy, in an arbitrary ordering. */ SoftNodeDesc *SoftNodeTree:: -get_node(string name) const { +get_node(std::string name) const { NodesByName::const_iterator ni = _nodes_by_name.find(name); if (ni != _nodes_by_name.end()) return (*ni).second; @@ -451,7 +453,7 @@ handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name) { SoftNodeDesc *SoftNodeTree:: build_node(SAA_Scene *scene, SAA_Elem *model) { char *name, *fullname; - string node_name; + std::string node_name; int numChildren; int thisChild; SAA_Elem *children; @@ -533,7 +535,7 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { * The recursive implementation of build_node(). */ SoftNodeDesc *SoftNodeTree:: -r_build_node(SoftNodeDesc *parent_node, const string &name) { +r_build_node(SoftNodeDesc *parent_node, const std::string &name) { SoftNodeDesc *node_desc; // If we have already encountered this pathname, return the corresponding diff --git a/pandatool/src/softegg/softToEggConverter.cxx b/pandatool/src/softegg/softToEggConverter.cxx index 3e0ab21ef6..44dafefb62 100644 --- a/pandatool/src/softegg/softToEggConverter.cxx +++ b/pandatool/src/softegg/softToEggConverter.cxx @@ -32,6 +32,9 @@ #include "string_utils.h" #include "dcast.h" +using std::endl; +using std::string; + SoftToEggConverter stec; const int TEX_PER_MAT = 1; diff --git a/pandatool/src/softprogs/softCVS.cxx b/pandatool/src/softprogs/softCVS.cxx index a0351b854e..478aa682d2 100644 --- a/pandatool/src/softprogs/softCVS.cxx +++ b/pandatool/src/softprogs/softCVS.cxx @@ -18,6 +18,8 @@ #include +using std::string; + /** * */ @@ -472,7 +474,7 @@ scan_cvs(const string &dirname, pset &cvs_elements) { * reference found, increments the appropriate element file's reference count. */ bool SoftCVS:: -scan_scene_file(istream &in, Multifile &multifile) { +scan_scene_file(std::istream &in, Multifile &multifile) { bool okflag = true; int c = in.get(); @@ -493,7 +495,7 @@ scan_scene_file(istream &in, Multifile &multifile) { SoftFilename v("", word); // Increment the use count on all matching elements of the multiset. - pair range; + std::pair range; range = _element_files.equal_range(v); ElementFiles::iterator ei; diff --git a/pandatool/src/softprogs/softFilename.cxx b/pandatool/src/softprogs/softFilename.cxx index 16d69de675..4c099c56be 100644 --- a/pandatool/src/softprogs/softFilename.cxx +++ b/pandatool/src/softprogs/softFilename.cxx @@ -15,6 +15,8 @@ #include "pnotify.h" +using std::string; + /** * */ diff --git a/pandatool/src/text-stats/textMonitor.cxx b/pandatool/src/text-stats/textMonitor.cxx index 69b134cc8f..2f4f458387 100644 --- a/pandatool/src/text-stats/textMonitor.cxx +++ b/pandatool/src/text-stats/textMonitor.cxx @@ -22,7 +22,7 @@ * */ TextMonitor:: -TextMonitor(TextStats *server, ostream *outStream, bool show_raw_data ) : PStatMonitor(server) { +TextMonitor(TextStats *server, std::ostream *outStream, bool show_raw_data ) : PStatMonitor(server) { _outStream = outStream; //[PECI] _show_raw_data = show_raw_data; } @@ -39,7 +39,7 @@ get_server() { * Should be redefined to return a descriptive name for the type of * PStatsMonitor this is. */ -string TextMonitor:: +std::string TextMonitor:: get_monitor_name() { return "Text Stats"; } diff --git a/pandatool/src/vrml/parse_vrml.cxx b/pandatool/src/vrml/parse_vrml.cxx index 1e55b68594..9ec700f19a 100644 --- a/pandatool/src/vrml/parse_vrml.cxx +++ b/pandatool/src/vrml/parse_vrml.cxx @@ -30,6 +30,10 @@ #include "zStream.h" #include "virtualFileSystem.h" +using std::istream; +using std::istringstream; +using std::string; + extern int vrmlyyparse(); extern void vrmlyyResetLineNumber(); extern int vrmlyydebug; @@ -99,7 +103,7 @@ parse_vrml(Filename filename) { VrmlScene * parse_vrml(istream &in, const string &filename) { if (!get_standard_nodes()) { - cerr << "Internal error--unable to parse VRML.\n"; + std::cerr << "Internal error--unable to parse VRML.\n"; return nullptr; } @@ -121,7 +125,7 @@ parse_vrml(istream &in, const string &filename) { int main(int argc, char *argv[]) { if (argc < 2) { - cerr << "parse_vrml filename.wrl\n"; + std::cerr << "parse_vrml filename.wrl\n"; exit(1); } @@ -130,7 +134,7 @@ main(int argc, char *argv[]) { exit(1); } - cout << *scene << "\n"; + std::cout << *scene << "\n"; return (0); } #endif diff --git a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt index 87565a5ea2..cc79d45379 100644 --- a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt @@ -2723,21 +2723,18 @@ int vrmlyy_flex_debug = 0; #define YY_RESTORE_YY_MORE_OFFSET char *vrmlyytext; #line 1 "vrmlLexer.lxx" -/* -// Filename: vrmlLexer.lxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// 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." -// -//////////////////////////////////////////////////////////////////// -*/ +/** + * 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." + * + * @file vrmlLexer.lxx + * @author drose + * @date 2004-10-01 + */ /************************************************** * VRML 2.0 Parser * Copyright (C) 1996 Silicon Graphics, Inc. @@ -2774,13 +2771,13 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static std::istream *input_p = nullptr; // This is the name of the vrml file we're parsing. We keep it so we // can print it out for error messages. -static string vrml_filename; +static std::string vrml_filename; -extern void vrmlyyerror(const string &); +extern void vrmlyyerror(const std::string &); /* The YACC parser sets this to a token to direct the lexer */ /* in cases where just syntax isn't enough: */ @@ -2794,13 +2791,13 @@ static int sfImageIntsParsed = 0; static int sfImageIntsExpected = 0; // This is used while scanning a quoted string. -static string quoted_string; +static std::string quoted_string; // And this keeps track of the currently-parsing array. static MFArray *mfarray; void -vrml_init_lexer(istream &in, const string &filename) { +vrml_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ vrml_filename = filename; line_number = 0; @@ -2818,7 +2815,9 @@ vrmlyywrap(void) { } void -vrmlyyerror(const string &msg) { +vrmlyyerror(const std::string &msg) { + using std::cerr; + cerr << "\nError"; if (!vrml_filename.empty()) { cerr << " in " << vrml_filename; @@ -2831,7 +2830,9 @@ vrmlyyerror(const string &msg) { } void -vrmlyywarning(const string &msg) { +vrmlyywarning(const std::string &msg) { + using std::cerr; + cerr << "\nWarning"; if (!vrml_filename.empty()) { cerr << " in " << vrml_filename; diff --git a/pandatool/src/vrml/vrmlLexer.lxx b/pandatool/src/vrml/vrmlLexer.lxx index cd913fddc1..fb16b30c40 100644 --- a/pandatool/src/vrml/vrmlLexer.lxx +++ b/pandatool/src/vrml/vrmlLexer.lxx @@ -1,18 +1,15 @@ -/* -// Filename: vrmlLexer.lxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// 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." -// -//////////////////////////////////////////////////////////////////// -*/ +/** + * 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." + * + * @file vrmlLexer.lxx + * @author drose + * @date 2004-10-01 + */ /************************************************** * VRML 2.0 Parser @@ -50,13 +47,13 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = nullptr; +static std::istream *input_p = nullptr; // This is the name of the vrml file we're parsing. We keep it so we // can print it out for error messages. -static string vrml_filename; +static std::string vrml_filename; -extern void vrmlyyerror(const string &); +extern void vrmlyyerror(const std::string &); /* The YACC parser sets this to a token to direct the lexer */ /* in cases where just syntax isn't enough: */ @@ -70,13 +67,13 @@ static int sfImageIntsParsed = 0; static int sfImageIntsExpected = 0; // This is used while scanning a quoted string. -static string quoted_string; +static std::string quoted_string; // And this keeps track of the currently-parsing array. static MFArray *mfarray; void -vrml_init_lexer(istream &in, const string &filename) { +vrml_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ vrml_filename = filename; line_number = 0; @@ -94,7 +91,9 @@ vrmlyywrap(void) { } void -vrmlyyerror(const string &msg) { +vrmlyyerror(const std::string &msg) { + using std::cerr; + cerr << "\nError"; if (!vrml_filename.empty()) { cerr << " in " << vrml_filename; @@ -107,7 +106,9 @@ vrmlyyerror(const string &msg) { } void -vrmlyywarning(const string &msg) { +vrmlyywarning(const std::string &msg) { + using std::cerr; + cerr << "\nWarning"; if (!vrml_filename.empty()) { cerr << " in " << vrml_filename; diff --git a/pandatool/src/vrml/vrmlNode.cxx b/pandatool/src/vrml/vrmlNode.cxx index 628e09fb31..c48ce35e4a 100644 --- a/pandatool/src/vrml/vrmlNode.cxx +++ b/pandatool/src/vrml/vrmlNode.cxx @@ -43,7 +43,7 @@ get_value(const char *field_name) const { return field->dflt; } - cerr << "No such field defined for type " << _type->getName() << ": " + std::cerr << "No such field defined for type " << _type->getName() << ": " << field_name << "\n"; exit(1); // Just to make the compiler happy. @@ -52,7 +52,7 @@ get_value(const char *field_name) const { } void VrmlNode:: -output(ostream &out, int indent_level) const { +output(std::ostream &out, int indent_level) const { out << _type->getName() << " {\n"; Fields::const_iterator fi; for (fi = _fields.begin(); fi != _fields.end(); ++fi) { @@ -64,13 +64,13 @@ output(ostream &out, int indent_level) const { void Declaration:: -output(ostream &out, int indent) const { +output(std::ostream &out, int indent) const { VrmlFieldValue v; v._sfnode = _node; output_value(out, v, SFNODE, indent); } -ostream &operator << (ostream &out, const VrmlScene &scene) { +std::ostream &operator << (std::ostream &out, const VrmlScene &scene) { VrmlScene::const_iterator si; for (si = scene.begin(); si != scene.end(); ++si) { out << (*si) << "\n"; diff --git a/pandatool/src/vrml/vrmlNodeType.cxx b/pandatool/src/vrml/vrmlNodeType.cxx index 923570bd81..56652507b5 100644 --- a/pandatool/src/vrml/vrmlNodeType.cxx +++ b/pandatool/src/vrml/vrmlNodeType.cxx @@ -20,6 +20,8 @@ #include // for sprintf() +using std::ostream; + // // Static list of node types. @@ -177,8 +179,8 @@ void VrmlNodeType::addToNameSpace(VrmlNodeType *_type) { if (find(_type->getName()) != nullptr) { - cerr << "PROTO " << _type->getName() << " already defined\n"; - return; + std::cerr << "PROTO " << _type->getName() << " already defined\n"; + return; } typeList.push_front(_type); } diff --git a/pandatool/src/vrml/vrmlParser.cxx.prebuilt b/pandatool/src/vrml/vrmlParser.cxx.prebuilt index 6eaddbf170..b94bc8d5ae 100644 --- a/pandatool/src/vrml/vrmlParser.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlParser.cxx.prebuilt @@ -151,14 +151,14 @@ void storeField(const VrmlFieldValue &value); void exitField(); void expect(int type); -extern void vrmlyyerror(const string &); +extern void vrmlyyerror(const std::string &); //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// void -vrml_init_parser(istream &in, const string &filename) { +vrml_init_parser(std::istream &in, const std::string &filename) { //yydebug = 0; vrml_init_lexer(in, filename); } @@ -2189,7 +2189,7 @@ endProto() // Add this proto definition: if (currentProtoStack.empty()) { - cerr << "Error: Empty PROTO stack!\n"; + std::cerr << "Error: Empty PROTO stack!\n"; } else { VrmlNodeType *t = currentProtoStack.top(); @@ -2232,14 +2232,14 @@ add(void (VrmlNodeType::*func)(const char *, int, const VrmlFieldValue *), int type = fieldType(typeString); if (type == 0) { - cerr << "Error: invalid field type: " << type << "\n"; + std::cerr << "Error: invalid field type: " << type << "\n"; } // Need to add support for Script nodes: // if (inScript) ... ??? if (currentProtoStack.empty()) { - cerr << "Error: declaration outside of prototype\n"; + std::cerr << "Error: declaration outside of prototype\n"; return 0; } VrmlNodeType *t = currentProtoStack.top(); @@ -2271,7 +2271,7 @@ fieldType(const char *type) if (strcmp(type, "MFVec2f") == 0) return MFVEC2F; if (strcmp(type, "MFVec3f") == 0) return MFVEC3F; - cerr << "Illegal field type: " << type << "\n"; + std::cerr << "Illegal field type: " << type << "\n"; return 0; } @@ -2306,7 +2306,7 @@ exitNode() nassertr(node != NULL, NULL); currentNode.pop(); - // cerr << "Just defined node:\n" << *node << "\n\n"; + // std::cerr << "Just defined node:\n" << *node << "\n\n"; delete fr; return node; @@ -2346,7 +2346,7 @@ enterField(const char *fieldName) expect(typeRec->type); } else { - cerr << "Error: Nodes of type " << fr->nodeType->getName() << + std::cerr << "Error: Nodes of type " << fr->nodeType->getName() << " do not have fields/eventIn/eventOut named " << fieldName << "\n"; // expect(ANY_FIELD); diff --git a/pandatool/src/vrml/vrmlParser.yxx b/pandatool/src/vrml/vrmlParser.yxx index d114028828..9bbdda7bf6 100644 --- a/pandatool/src/vrml/vrmlParser.yxx +++ b/pandatool/src/vrml/vrmlParser.yxx @@ -94,14 +94,14 @@ void storeField(const VrmlFieldValue &value); void exitField(); void expect(int type); -extern void vrmlyyerror(const string &); +extern void vrmlyyerror(const std::string &); //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// void -vrml_init_parser(istream &in, const string &filename) { +vrml_init_parser(std::istream &in, const std::string &filename) { //yydebug = 0; vrml_init_lexer(in, filename); } @@ -132,7 +132,7 @@ vrml_cleanup_parser() { * %type vrmlscene declarations */ -%token IDENTIFIER +%token IDENTIFIER %token DEF USE PROTO EXTERNPROTO TO IS ROUTE SFN_NULL %token EVENTIN EVENTOUT FIELD EXPOSEDFIELD @@ -370,7 +370,7 @@ endProto() // Add this proto definition: if (currentProtoStack.empty()) { - cerr << "Error: Empty PROTO stack!\n"; + std::cerr << "Error: Empty PROTO stack!\n"; } else { VrmlNodeType *t = currentProtoStack.top(); @@ -413,14 +413,14 @@ add(void (VrmlNodeType::*func)(const char *, int, const VrmlFieldValue *), int type = fieldType(typeString); if (type == 0) { - cerr << "Error: invalid field type: " << type << "\n"; + std::cerr << "Error: invalid field type: " << type << "\n"; } // Need to add support for Script nodes: // if (inScript) ... ??? if (currentProtoStack.empty()) { - cerr << "Error: declaration outside of prototype\n"; + std::cerr << "Error: declaration outside of prototype\n"; return 0; } VrmlNodeType *t = currentProtoStack.top(); @@ -452,7 +452,7 @@ fieldType(const char *type) if (strcmp(type, "MFVec2f") == 0) return MFVEC2F; if (strcmp(type, "MFVec3f") == 0) return MFVEC3F; - cerr << "Illegal field type: " << type << "\n"; + std::cerr << "Illegal field type: " << type << "\n"; return 0; } @@ -487,7 +487,7 @@ exitNode() nassertr(node != nullptr, nullptr); currentNode.pop(); - // cerr << "Just defined node:\n" << *node << "\n\n"; + // std::cerr << "Just defined node:\n" << *node << "\n\n"; delete fr; return node; @@ -527,7 +527,7 @@ enterField(const char *fieldName) expect(typeRec->type); } else { - cerr << "Error: Nodes of type " << fr->nodeType->getName() << + std::cerr << "Error: Nodes of type " << fr->nodeType->getName() << " do not have fields/eventIn/eventOut named " << fieldName << "\n"; // expect(ANY_FIELD); diff --git a/pandatool/src/vrmlegg/indexedFaceSet.cxx b/pandatool/src/vrmlegg/indexedFaceSet.cxx index 35e03857fc..0f0dce8e68 100644 --- a/pandatool/src/vrmlegg/indexedFaceSet.cxx +++ b/pandatool/src/vrmlegg/indexedFaceSet.cxx @@ -22,6 +22,8 @@ #include "eggVertexPool.h" #include "eggPolygon.h" +using std::cerr; + /** * */ diff --git a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx index 150cf6da4c..d308e34714 100644 --- a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx +++ b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx @@ -57,7 +57,7 @@ make_copy() { /** * Returns the English name of the file type this converter supports. */ -string VRMLToEggConverter:: +std::string VRMLToEggConverter:: get_name() const { return "VRML"; } @@ -65,7 +65,7 @@ get_name() const { /** * Returns the common extension of the file type this converter supports. */ -string VRMLToEggConverter:: +std::string VRMLToEggConverter:: get_extension() const { return "wrl"; } @@ -145,7 +145,7 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { nassertv(vrml._name != nullptr); ni = nodes.find(vrml._name); if (ni == nodes.end()) { - cerr << "Unknown node reference: " << vrml._name << "\n"; + std::cerr << "Unknown node reference: " << vrml._name << "\n"; } else { // Increment the use count of the node. (*ni).second->_use_count++; @@ -214,7 +214,7 @@ vrml_grouping_node(const SFNodeRef &vrml, EggGroupNode *egg, const LMatrix4d &net_transform)) { const VrmlNode *node = vrml._p; nassertv(node != nullptr); - string name; + std::string name; if (vrml._name != nullptr) { name = vrml._name; } @@ -376,7 +376,7 @@ vrml_shape(const VrmlNode *node, EggGroup *group, IndexedFaceSet ifs(geometry, appearance); ifs.convert_to_egg(group, net_transform); } else { - cerr << "Ignoring " << geometry->_type->getName() << "\n"; + std::cerr << "Ignoring " << geometry->_type->getName() << "\n"; } } } diff --git a/pandatool/src/win-stats/winStats.cxx b/pandatool/src/win-stats/winStats.cxx index 0b22e9e0d7..7818ea5ed8 100644 --- a/pandatool/src/win-stats/winStats.cxx +++ b/pandatool/src/win-stats/winStats.cxx @@ -62,9 +62,9 @@ create_toplevel_window(HINSTANCE application) { DWORD window_style = WS_POPUP | WS_SYSMENU | WS_ICONIC; - ostringstream strm; + std::ostringstream strm; strm << "PStats " << pstats_port; - string window_name = strm.str(); + std::string window_name = strm.str(); HWND toplevel_window = CreateWindow(toplevel_class_name, window_name.c_str(), window_style, @@ -87,12 +87,12 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { // Create the server object. server = new WinStatsServer; if (!server->listen()) { - ostringstream stream; + std::ostringstream stream; stream << "Unable to open port " << pstats_port << ". Try specifying a different\n" << "port number using pstats-port in your Config file."; - string str = stream.str(); + std::string str = stream.str(); MessageBox(toplevel_window, str.c_str(), "PStats error", MB_OK | MB_ICONEXCLAMATION); exit(1); diff --git a/pandatool/src/win-stats/winStatsChartMenu.cxx b/pandatool/src/win-stats/winStatsChartMenu.cxx index faeb59d874..c042acf8ba 100644 --- a/pandatool/src/win-stats/winStatsChartMenu.cxx +++ b/pandatool/src/win-stats/winStatsChartMenu.cxx @@ -47,7 +47,7 @@ get_menu_handle() { void WinStatsChartMenu:: add_to_menu_bar(HMENU menu_bar, int before_menu_id) { const PStatClientData *client_data = _monitor->get_client_data(); - string thread_name; + std::string thread_name; if (_thread_index == 0) { // A special case for the main thread. thread_name = "Graphs"; @@ -149,7 +149,7 @@ add_view(HMENU parent_menu, const PStatViewLevel *view_level, bool show_level) { int collector = view_level->get_collector(); const PStatClientData *client_data = _monitor->get_client_data(); - string collector_name = client_data->get_collector_name(collector); + std::string collector_name = client_data->get_collector_name(collector); WinStatsMonitor::MenuDef menu_def(_thread_index, collector, show_level); int menu_id = _monitor->get_menu_id(menu_def); @@ -169,7 +169,7 @@ add_view(HMENU parent_menu, const PStatViewLevel *view_level, bool show_level) { // If the collector has more than one child, add a menu entry to go // directly to each of its children. HMENU submenu = CreatePopupMenu(); - string submenu_name = collector_name + " components"; + std::string submenu_name = collector_name + " components"; mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU; mii.fType = MFT_STRING; diff --git a/pandatool/src/win-stats/winStatsGraph.cxx b/pandatool/src/win-stats/winStatsGraph.cxx index 6eb19583f6..4946bbc671 100644 --- a/pandatool/src/win-stats/winStatsGraph.cxx +++ b/pandatool/src/win-stats/winStatsGraph.cxx @@ -467,8 +467,8 @@ move_graph_window(int graph_left, int graph_top, int graph_xsize, int graph_ysiz void WinStatsGraph:: setup_bitmap(int xsize, int ysize) { release_bitmap(); - _bitmap_xsize = max(xsize, 0); - _bitmap_ysize = max(ysize, 0); + _bitmap_xsize = std::max(xsize, 0); + _bitmap_ysize = std::max(ysize, 0); HDC hdc = GetDC(_graph_window); _bitmap_dc = CreateCompatibleDC(hdc); @@ -508,7 +508,7 @@ create_graph_window() { HINSTANCE application = GetModuleHandle(nullptr); register_graph_window_class(application); - string window_title = "graph"; + std::string window_title = "graph"; DWORD window_style = WS_CHILD | WS_CLIPSIBLINGS; _graph_window = diff --git a/pandatool/src/win-stats/winStatsLabelStack.cxx b/pandatool/src/win-stats/winStatsLabelStack.cxx index 063a7780e8..af3bcccd00 100644 --- a/pandatool/src/win-stats/winStatsLabelStack.cxx +++ b/pandatool/src/win-stats/winStatsLabelStack.cxx @@ -61,7 +61,7 @@ setup(HWND parent_window) { for (li = _labels.begin(); li != _labels.end(); ++li) { WinStatsLabel *label = (*li); label->setup(_window); - _ideal_width = max(_ideal_width, label->get_ideal_width()); + _ideal_width = std::max(_ideal_width, label->get_ideal_width()); } } @@ -192,7 +192,7 @@ add_label(WinStatsMonitor *monitor, WinStatsGraph *graph, label->setup(_window); label->set_pos(0, yp, _width); } - _ideal_width = max(_ideal_width, label->get_ideal_width()); + _ideal_width = std::max(_ideal_width, label->get_ideal_width()); int label_index = (int)_labels.size(); _labels.push_back(label); diff --git a/pandatool/src/win-stats/winStatsMonitor.cxx b/pandatool/src/win-stats/winStatsMonitor.cxx index 1b2cedee37..50c66362d1 100644 --- a/pandatool/src/win-stats/winStatsMonitor.cxx +++ b/pandatool/src/win-stats/winStatsMonitor.cxx @@ -71,7 +71,7 @@ WinStatsMonitor:: * Should be redefined to return a descriptive name for the type of * PStatsMonitor this is. */ -string WinStatsMonitor:: +std::string WinStatsMonitor:: get_monitor_name() { return "WinStats"; } @@ -107,7 +107,7 @@ got_hello() { void WinStatsMonitor:: got_bad_version(int client_major, int client_minor, int server_major, int server_minor) { - ostringstream str; + std::ostringstream str; str << "Unable to honor connection attempt from " << get_client_progname() << " on " << get_client_hostname() << ": unsupported PStats version " @@ -121,7 +121,7 @@ got_bad_version(int client_major, int client_minor, << ".0 through " << server_major << "." << server_minor << ")."; } - string message = str.str(); + std::string message = str.str(); MessageBox(nullptr, message.c_str(), "Bad version", MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); } diff --git a/pandatool/src/win-stats/winStatsPianoRoll.cxx b/pandatool/src/win-stats/winStatsPianoRoll.cxx index 7c81b65fdf..859de11b68 100644 --- a/pandatool/src/win-stats/winStatsPianoRoll.cxx +++ b/pandatool/src/win-stats/winStatsPianoRoll.cxx @@ -468,7 +468,7 @@ draw_guide_label(HDC hdc, int y, const PStatGraph::GuideBar &bar) { } int x = height_to_pixel(bar._height); - const string &label = bar._label; + const std::string &label = bar._label; SIZE size; GetTextExtentPoint32(hdc, label.data(), label.length(), &size); @@ -502,8 +502,8 @@ create_window() { const PStatClientData *client_data = WinStatsGraph::_monitor->get_client_data(); - string thread_name = client_data->get_thread_name(_thread_index); - string window_title = thread_name + " thread piano roll"; + std::string thread_name = client_data->get_thread_name(_thread_index); + std::string window_title = thread_name + " thread piano roll"; RECT win_rect = { diff --git a/pandatool/src/win-stats/winStatsStripChart.cxx b/pandatool/src/win-stats/winStatsStripChart.cxx index 79411a03d7..879b920673 100644 --- a/pandatool/src/win-stats/winStatsStripChart.cxx +++ b/pandatool/src/win-stats/winStatsStripChart.cxx @@ -16,6 +16,8 @@ #include "pStatCollectorDef.h" #include "numeric_types.h" +using std::string; + static const int default_strip_chart_width = 400; static const int default_strip_chart_height = 100; diff --git a/pandatool/src/xfile/windowsGuid.cxx b/pandatool/src/xfile/windowsGuid.cxx index 101e2b98cf..fbe649673c 100644 --- a/pandatool/src/xfile/windowsGuid.cxx +++ b/pandatool/src/xfile/windowsGuid.cxx @@ -16,6 +16,8 @@ #include // for sscanf, sprintf +using std::string; + /** * Parses the hex representation in the indicated string and stores it in the * WindowsGuid object. Returns true if successful, false if the string @@ -69,6 +71,6 @@ format_string() const { * Outputs a hex representation of the GUID. */ void WindowsGuid:: -output(ostream &out) const { +output(std::ostream &out) const { out << format_string(); } diff --git a/pandatool/src/xfile/xFile.cxx b/pandatool/src/xfile/xFile.cxx index 17fc9f1e34..c5534e0af1 100644 --- a/pandatool/src/xfile/xFile.cxx +++ b/pandatool/src/xfile/xFile.cxx @@ -22,6 +22,11 @@ #include "virtualFileSystem.h" #include "dcast.h" +using std::istream; +using std::istringstream; +using std::ostream; +using std::string; + TypeHandle XFile::_type_handle; PT(XFile) XFile::_standard_templates; diff --git a/pandatool/src/xfile/xFileArrayDef.cxx b/pandatool/src/xfile/xFileArrayDef.cxx index da5abf9f51..91078f5576 100644 --- a/pandatool/src/xfile/xFileArrayDef.cxx +++ b/pandatool/src/xfile/xFileArrayDef.cxx @@ -38,7 +38,7 @@ get_size(const XFileNode::PrevData &prev_data) const { * */ void XFileArrayDef:: -output(ostream &out) const { +output(std::ostream &out) const { if (is_fixed_size()) { out << "[" << _fixed_size << "]"; } else { diff --git a/pandatool/src/xfile/xFileDataDef.cxx b/pandatool/src/xfile/xFileDataDef.cxx index 6c133347ef..2a35528768 100644 --- a/pandatool/src/xfile/xFileDataDef.cxx +++ b/pandatool/src/xfile/xFileDataDef.cxx @@ -53,7 +53,7 @@ add_array_def(const XFileArrayDef &array_def) { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataDef:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { indent(out, indent_level); if (!_array_def.empty()) { @@ -405,7 +405,7 @@ unpack_value(const XFileParseDataList &parse_data_list, int array_index, for (int i = 0; i < array_size; i++) { if (index >= parse_data_list._list.size()) { - xyyerror(string("Expected ") + format_string(array_size) + xyyerror(std::string("Expected ") + format_string(array_size) + " array elements, found " + format_string(i)); return data_value; } diff --git a/pandatool/src/xfile/xFileDataNode.cxx b/pandatool/src/xfile/xFileDataNode.cxx index d0ebb6dba8..bc1326697e 100644 --- a/pandatool/src/xfile/xFileDataNode.cxx +++ b/pandatool/src/xfile/xFileDataNode.cxx @@ -20,7 +20,7 @@ TypeHandle XFileDataNode::_type_handle; * */ XFileDataNode:: -XFileDataNode(XFile *x_file, const string &name, +XFileDataNode(XFile *x_file, const std::string &name, XFileTemplate *xtemplate) : XFileNode(x_file, name), _template(xtemplate) @@ -46,7 +46,7 @@ is_object() const { * object must be of type XFileDataNode. */ bool XFileDataNode:: -is_standard_object(const string &template_name) const { +is_standard_object(const std::string &template_name) const { if (_template->is_standard() && _template->get_name() == template_name) { return true; @@ -59,7 +59,7 @@ is_standard_object(const string &template_name) const { * Returns a string that represents the type of object this data object * represents. */ -string XFileDataNode:: +std::string XFileDataNode:: get_type_name() const { return _template->get_name(); } diff --git a/pandatool/src/xfile/xFileDataNodeReference.cxx b/pandatool/src/xfile/xFileDataNodeReference.cxx index 157acdbba6..7796aeeeda 100644 --- a/pandatool/src/xfile/xFileDataNodeReference.cxx +++ b/pandatool/src/xfile/xFileDataNodeReference.cxx @@ -62,7 +62,7 @@ is_complex_object() const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataNodeReference:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { indent(out, indent_level) << "{ " << _object->get_name() << " }\n"; } @@ -89,6 +89,6 @@ get_element(int n) { * name. */ XFileDataObject *XFileDataNodeReference:: -get_element(const string &name) { +get_element(const std::string &name) { return &((*_object)[name]); } diff --git a/pandatool/src/xfile/xFileDataNodeTemplate.cxx b/pandatool/src/xfile/xFileDataNodeTemplate.cxx index 9f09cc0583..6464716964 100644 --- a/pandatool/src/xfile/xFileDataNodeTemplate.cxx +++ b/pandatool/src/xfile/xFileDataNodeTemplate.cxx @@ -17,6 +17,8 @@ #include "xLexerDefs.h" #include "config_xfile.h" +using std::string; + TypeHandle XFileDataNodeTemplate::_type_handle; /** @@ -127,7 +129,7 @@ add_element(XFileDataObject *element) { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataNodeTemplate:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { indent(out, indent_level) << _template->get_name(); if (has_name()) { @@ -149,7 +151,7 @@ write_text(ostream &out, int indent_level) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataNodeTemplate:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { if (!_nested_elements.empty()) { bool indented = false; for (size_t i = 0; i < _nested_elements.size() - 1; i++) { diff --git a/pandatool/src/xfile/xFileDataObject.cxx b/pandatool/src/xfile/xFileDataObject.cxx index 5abfa1e9ab..f3cf0b0303 100644 --- a/pandatool/src/xfile/xFileDataObject.cxx +++ b/pandatool/src/xfile/xFileDataObject.cxx @@ -21,6 +21,8 @@ #include "config_xfile.h" #include "indent.h" +using std::string; + TypeHandle XFileDataObject::_type_handle; /** @@ -168,7 +170,7 @@ add_element(XFileDataObject *element) { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObject:: -output_data(ostream &out) const { +output_data(std::ostream &out) const { out << "(" << get_type() << "::output_data() not implemented.)"; } @@ -176,7 +178,7 @@ output_data(ostream &out) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObject:: -write_data(ostream &out, int indent_level, const char *) const { +write_data(std::ostream &out, int indent_level, const char *) const { indent(out, indent_level) << "(" << get_type() << "::write_data() not implemented.)\n"; } diff --git a/pandatool/src/xfile/xFileDataObjectArray.cxx b/pandatool/src/xfile/xFileDataObjectArray.cxx index 10aa13d5f2..e648ef2c17 100644 --- a/pandatool/src/xfile/xFileDataObjectArray.cxx +++ b/pandatool/src/xfile/xFileDataObjectArray.cxx @@ -41,7 +41,7 @@ add_element(XFileDataObject *element) { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectArray:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { if (!_nested_elements.empty()) { bool indented = false; for (size_t i = 0; i < _nested_elements.size() - 1; i++) { diff --git a/pandatool/src/xfile/xFileDataObjectDouble.cxx b/pandatool/src/xfile/xFileDataObjectDouble.cxx index 3abd4fa909..d17b2bbb1e 100644 --- a/pandatool/src/xfile/xFileDataObjectDouble.cxx +++ b/pandatool/src/xfile/xFileDataObjectDouble.cxx @@ -31,7 +31,7 @@ XFileDataObjectDouble(const XFileDataDef *data_def, double value) : * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectDouble:: -output_data(ostream &out) const { +output_data(std::ostream &out) const { out << get_string_value(); } @@ -39,7 +39,7 @@ output_data(ostream &out) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectDouble:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { indent(out, indent_level) << get_string_value() << separator << "\n"; } @@ -79,7 +79,7 @@ get_double_value() const { /** * Returns the object's representation as a string, if it has one. */ -string XFileDataObjectDouble:: +std::string XFileDataObjectDouble:: get_string_value() const { // It's important to format with a decimal point, even if the value is // integral, since the DirectX .x reader differentiates betweens doubles and diff --git a/pandatool/src/xfile/xFileDataObjectInteger.cxx b/pandatool/src/xfile/xFileDataObjectInteger.cxx index 821363f339..ee3c539d68 100644 --- a/pandatool/src/xfile/xFileDataObjectInteger.cxx +++ b/pandatool/src/xfile/xFileDataObjectInteger.cxx @@ -31,7 +31,7 @@ XFileDataObjectInteger(const XFileDataDef *data_def, int value) : * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectInteger:: -output_data(ostream &out) const { +output_data(std::ostream &out) const { out << _value; } @@ -39,7 +39,7 @@ output_data(ostream &out) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectInteger:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { indent(out, indent_level) << _value << separator << "\n"; } @@ -71,7 +71,7 @@ get_double_value() const { /** * Returns the object's representation as a string, if it has one. */ -string XFileDataObjectInteger:: +std::string XFileDataObjectInteger:: get_string_value() const { return format_string(_value); } diff --git a/pandatool/src/xfile/xFileDataObjectString.cxx b/pandatool/src/xfile/xFileDataObjectString.cxx index 3425925b22..99ef31a89f 100644 --- a/pandatool/src/xfile/xFileDataObjectString.cxx +++ b/pandatool/src/xfile/xFileDataObjectString.cxx @@ -15,6 +15,8 @@ #include "string_utils.h" #include "indent.h" +using std::string; + TypeHandle XFileDataObjectString::_type_handle; /** @@ -31,7 +33,7 @@ XFileDataObjectString(const XFileDataDef *data_def, const string &value) : * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectString:: -output_data(ostream &out) const { +output_data(std::ostream &out) const { enquote_string(out); } @@ -39,7 +41,7 @@ output_data(ostream &out) const { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileDataObjectString:: -write_data(ostream &out, int indent_level, const char *separator) const { +write_data(std::ostream &out, int indent_level, const char *separator) const { indent(out, indent_level); enquote_string(out); out << separator << "\n"; @@ -66,7 +68,7 @@ get_string_value() const { * special characters as needed. */ void XFileDataObjectString:: -enquote_string(ostream &out) const { +enquote_string(std::ostream &out) const { // Actually, the XFile spec doesn't tell us how to escape special characters // within quotation marks. We'll just take a stab in the dark here. diff --git a/pandatool/src/xfile/xFileNode.cxx b/pandatool/src/xfile/xFileNode.cxx index a67c7488d0..51c795e42a 100644 --- a/pandatool/src/xfile/xFileNode.cxx +++ b/pandatool/src/xfile/xFileNode.cxx @@ -21,6 +21,8 @@ #include "filename.h" #include "string_utils.h" +using std::string; + TypeHandle XFileNode::_type_handle; /** @@ -214,7 +216,7 @@ clear() { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileNode:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { (*ci)->write_text(out, indent_level); diff --git a/pandatool/src/xfile/xFileParseData.cxx b/pandatool/src/xfile/xFileParseData.cxx index aeafa42a6f..0fcd8dbef9 100644 --- a/pandatool/src/xfile/xFileParseData.cxx +++ b/pandatool/src/xfile/xFileParseData.cxx @@ -34,6 +34,6 @@ XFileParseData() : * from which this object was originally parsed. */ void XFileParseData:: -yyerror(const string &message) const { +yyerror(const std::string &message) const { xyyerror(message, _line_number, _col_number, _current_line); } diff --git a/pandatool/src/xfile/xFileTemplate.cxx b/pandatool/src/xfile/xFileTemplate.cxx index 5c9691d02a..e4ef5e2c17 100644 --- a/pandatool/src/xfile/xFileTemplate.cxx +++ b/pandatool/src/xfile/xFileTemplate.cxx @@ -20,7 +20,7 @@ TypeHandle XFileTemplate::_type_handle; * */ XFileTemplate:: -XFileTemplate(XFile *x_file, const string &name, const WindowsGuid &guid) : +XFileTemplate(XFile *x_file, const std::string &name, const WindowsGuid &guid) : XFileNode(x_file, name), _guid(guid), _is_standard(false), @@ -79,7 +79,7 @@ clear() { * Writes a suitable representation of this node to an .x file in text mode. */ void XFileTemplate:: -write_text(ostream &out, int indent_level) const { +write_text(std::ostream &out, int indent_level) const { indent(out, indent_level) << "template " << get_name() << " {\n"; indent(out, indent_level + 2) diff --git a/pandatool/src/xfile/xLexer.cxx.prebuilt b/pandatool/src/xfile/xLexer.cxx.prebuilt index a52c858c96..b808f143ee 100644 --- a/pandatool/src/xfile/xLexer.cxx.prebuilt +++ b/pandatool/src/xfile/xLexer.cxx.prebuilt @@ -643,12 +643,11 @@ goto find_rule; \ #define YY_RESTORE_YY_MORE_OFFSET char *xyytext; #line 1 "xLexer.lxx" -/* -// Filename: xLexer.lxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -*/ +/** + * @file xLexer.lxx + * @author drose + * @date 2004-10-03 + */ #line 9 "xLexer.lxx" #include "xLexerDefs.h" #include "xParserDefs.h" @@ -678,11 +677,11 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static std::istream *input_p = nullptr; // This is the name of the x file we're parsing. We keep it so we // can print it out for error messages. -static string x_filename; +static std::string x_filename; //////////////////////////////////////////////////////////////////// @@ -690,7 +689,7 @@ static string x_filename; //////////////////////////////////////////////////////////////////// void -x_init_lexer(istream &in, const string &filename) { +x_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ x_filename = filename; x_line_number = 0; @@ -720,13 +719,13 @@ xyywrap(void) { } void -xyyerror(const string &msg) { +xyyerror(const std::string &msg) { xyyerror(msg, x_line_number, x_col_number, x_current_line); } void -xyyerror(const string &msg, int line_number, int col_number, - const string ¤t_line) { +xyyerror(const std::string &msg, int line_number, int col_number, + const std::string ¤t_line) { xfile_cat.error(false) << "\nError"; if (!x_filename.empty()) { xfile_cat.error(false) << " in " << x_filename; @@ -741,7 +740,7 @@ xyyerror(const string &msg, int line_number, int col_number, } void -xyywarning(const string &msg) { +xyywarning(const std::string &msg) { xfile_cat.warning(false) << "\nWarning"; if (!x_filename.empty()) { xfile_cat.warning(false) << " in " << x_filename; @@ -817,9 +816,9 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string +static std::string scan_quoted_string(char quote_mark) { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -939,7 +938,7 @@ scan_quoted_string(char quote_mark) { // scan_guid_string reads a string of hexadecimal digits delimited by // angle brackets and returns the corresponding string. -static string +static std::string scan_guid_string() { // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -956,7 +955,7 @@ scan_guid_string() { int num_digits = 0; int num_hyphens = 0; - string result; + std::string result; int c; c = read_char(line, col); @@ -971,7 +970,7 @@ scan_guid_string() { x_line_number = line; x_col_number = col; xyyerror("Invalid character in GUID."); - return string(); + return std::string(); } result += c; @@ -981,15 +980,15 @@ scan_guid_string() { if (c == EOF) { xyyerror("This GUID string is unterminated."); - return string(); + return std::string(); } else if (num_digits != 32) { xyyerror("Incorrect number of hex digits in GUID."); - return string(); + return std::string(); } else if (num_hyphens != 4) { xyyerror("Incorrect number of hyphens in GUID."); - return string(); + return std::string(); } x_line_number = line; @@ -1000,7 +999,7 @@ scan_guid_string() { // Parses the text into a list of integers and returns them. static PTA_int -scan_int_list(const string &text) { +scan_int_list(const std::string &text) { PTA_int result; vector_string words; @@ -1008,7 +1007,7 @@ scan_int_list(const string &text) { vector_string::const_iterator wi; for (wi = words.begin(); wi != words.end(); ++wi) { - string trimmed = trim(*wi); + std::string trimmed = trim(*wi); if (!trimmed.empty()) { int number = 0; string_to_int(trimmed, number); @@ -1021,7 +1020,7 @@ scan_int_list(const string &text) { // Parses the text into a list of doubles and returns them. static PTA_double -scan_double_list(const string &text) { +scan_double_list(const std::string &text) { PTA_double result; vector_string words; @@ -1029,7 +1028,7 @@ scan_double_list(const string &text) { vector_string::const_iterator wi; for (wi = words.begin(); wi != words.end(); ++wi) { - string trimmed = trim(*wi); + std::string trimmed = trim(*wi); if (!trimmed.empty()) { double number = 0.0; string_to_double(trimmed, number); @@ -1655,7 +1654,7 @@ YY_RULE_SETUP { // Any other character is invalid. accept(); - xyyerror("Invalid character '" + string(xyytext) + "'."); + xyyerror("Invalid character '" + std::string(xyytext) + "'."); } YY_BREAK case 35: diff --git a/pandatool/src/xfile/xLexer.lxx b/pandatool/src/xfile/xLexer.lxx index 614679ff34..c20ca309d2 100644 --- a/pandatool/src/xfile/xLexer.lxx +++ b/pandatool/src/xfile/xLexer.lxx @@ -1,9 +1,8 @@ -/* -// Filename: xLexer.lxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -*/ +/** + * @file xLexer.lxx + * @author drose + * @date 2004-10-03 + */ %{ #include "xLexerDefs.h" @@ -34,11 +33,11 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = nullptr; +static std::istream *input_p = nullptr; // This is the name of the x file we're parsing. We keep it so we // can print it out for error messages. -static string x_filename; +static std::string x_filename; //////////////////////////////////////////////////////////////////// @@ -46,7 +45,7 @@ static string x_filename; //////////////////////////////////////////////////////////////////// void -x_init_lexer(istream &in, const string &filename) { +x_init_lexer(std::istream &in, const std::string &filename) { input_p = ∈ x_filename = filename; x_line_number = 0; @@ -76,13 +75,13 @@ xyywrap(void) { } void -xyyerror(const string &msg) { +xyyerror(const std::string &msg) { xyyerror(msg, x_line_number, x_col_number, x_current_line); } void -xyyerror(const string &msg, int line_number, int col_number, - const string ¤t_line) { +xyyerror(const std::string &msg, int line_number, int col_number, + const std::string ¤t_line) { xfile_cat.error(false) << "\nError"; if (!x_filename.empty()) { xfile_cat.error(false) << " in " << x_filename; @@ -97,7 +96,7 @@ xyyerror(const string &msg, int line_number, int col_number, } void -xyywarning(const string &msg) { +xyywarning(const std::string &msg) { xfile_cat.warning(false) << "\nWarning"; if (!x_filename.empty()) { xfile_cat.warning(false) << " in " << x_filename; @@ -173,9 +172,9 @@ read_char(int &line, int &col) { // scan_quoted_string reads a string delimited by quotation marks and // returns it. -static string +static std::string scan_quoted_string(char quote_mark) { - string result; + std::string result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -295,7 +294,7 @@ scan_quoted_string(char quote_mark) { // scan_guid_string reads a string of hexadecimal digits delimited by // angle brackets and returns the corresponding string. -static string +static std::string scan_guid_string() { // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -312,7 +311,7 @@ scan_guid_string() { int num_digits = 0; int num_hyphens = 0; - string result; + std::string result; int c; c = read_char(line, col); @@ -327,7 +326,7 @@ scan_guid_string() { x_line_number = line; x_col_number = col; xyyerror("Invalid character in GUID."); - return string(); + return std::string(); } result += c; @@ -337,15 +336,15 @@ scan_guid_string() { if (c == EOF) { xyyerror("This GUID string is unterminated."); - return string(); + return std::string(); } else if (num_digits != 32) { xyyerror("Incorrect number of hex digits in GUID."); - return string(); + return std::string(); } else if (num_hyphens != 4) { xyyerror("Incorrect number of hyphens in GUID."); - return string(); + return std::string(); } x_line_number = line; @@ -356,7 +355,7 @@ scan_guid_string() { // Parses the text into a list of integers and returns them. static PTA_int -scan_int_list(const string &text) { +scan_int_list(const std::string &text) { PTA_int result; vector_string words; @@ -364,7 +363,7 @@ scan_int_list(const string &text) { vector_string::const_iterator wi; for (wi = words.begin(); wi != words.end(); ++wi) { - string trimmed = trim(*wi); + std::string trimmed = trim(*wi); if (!trimmed.empty()) { int number = 0; string_to_int(trimmed, number); @@ -377,7 +376,7 @@ scan_int_list(const string &text) { // Parses the text into a list of doubles and returns them. static PTA_double -scan_double_list(const string &text) { +scan_double_list(const std::string &text) { PTA_double result; vector_string words; @@ -385,7 +384,7 @@ scan_double_list(const string &text) { vector_string::const_iterator wi; for (wi = words.begin(); wi != words.end(); ++wi) { - string trimmed = trim(*wi); + std::string trimmed = trim(*wi); if (!trimmed.empty()) { double number = 0.0; string_to_double(trimmed, number); @@ -621,5 +620,5 @@ WHITESPACE [ ]+ . { // Any other character is invalid. accept(); - xyyerror("Invalid character '" + string(xyytext) + "'."); + xyyerror("Invalid character '" + std::string(xyytext) + "'."); } diff --git a/pandatool/src/xfile/xParser.cxx.prebuilt b/pandatool/src/xfile/xParser.cxx.prebuilt index 42c65a72a6..0d12c68d03 100644 --- a/pandatool/src/xfile/xParser.cxx.prebuilt +++ b/pandatool/src/xfile/xParser.cxx.prebuilt @@ -105,7 +105,7 @@ static PT(XFileDataDef) current_data_def; //////////////////////////////////////////////////////////////////// void -x_init_parser(istream &in, const string &filename, XFile &file) { +x_init_parser(std::istream &in, const std::string &filename, XFile &file) { x_file = &file; current_node = &file; x_init_lexer(in, filename); @@ -1803,7 +1803,7 @@ yyreduce: /* Line 1464 of yacc.c */ #line 325 "xParser.yxx" { - (yyval.str) = string(); + (yyval.str) = std::string(); } break; diff --git a/pandatool/src/xfile/xParser.yxx b/pandatool/src/xfile/xParser.yxx index 0f151c70ec..0352a4d454 100644 --- a/pandatool/src/xfile/xParser.yxx +++ b/pandatool/src/xfile/xParser.yxx @@ -39,7 +39,7 @@ static PT(XFileDataDef) current_data_def; //////////////////////////////////////////////////////////////////// void -x_init_parser(istream &in, const string &filename, XFile &file) { +x_init_parser(std::istream &in, const std::string &filename, XFile &file) { x_file = &file; current_node = &file; x_init_lexer(in, filename); @@ -324,7 +324,7 @@ multiword_name: optional_multiword_name: empty { - $$ = string(); + $$ = std::string(); } | multiword_name ; diff --git a/pandatool/src/xfileegg/xFileAnimationSet.cxx b/pandatool/src/xfileegg/xFileAnimationSet.cxx index 112b61ba12..f76bc33ee9 100644 --- a/pandatool/src/xfileegg/xFileAnimationSet.cxx +++ b/pandatool/src/xfileegg/xFileAnimationSet.cxx @@ -59,7 +59,7 @@ create_hierarchy(XFileToEggConverter *converter) { // Now populate those empty tables with the frame data. JointData::const_iterator ji; for (ji = _joint_data.begin(); ji != _joint_data.end(); ++ji) { - const string &joint_name = (*ji).first; + const std::string &joint_name = (*ji).first; const FrameData &table = (*ji).second; EggXfmSAnim *anim_table = get_table(joint_name); @@ -98,7 +98,7 @@ create_hierarchy(XFileToEggConverter *converter) { * Returns the table associated with the indicated joint name. */ EggXfmSAnim *XFileAnimationSet:: -get_table(const string &joint_name) const { +get_table(const std::string &joint_name) const { Tables::const_iterator ti; ti = _tables.find(joint_name); if (ti != _tables.end()) { @@ -112,7 +112,7 @@ get_table(const string &joint_name) const { * joint. */ XFileAnimationSet::FrameData &XFileAnimationSet:: -create_frame_data(const string &joint_name) { +create_frame_data(const std::string &joint_name) { return _joint_data[joint_name]; } diff --git a/pandatool/src/xfileegg/xFileMaker.cxx b/pandatool/src/xfileegg/xFileMaker.cxx index 915fa4ff20..e3d07cea0b 100644 --- a/pandatool/src/xfileegg/xFileMaker.cxx +++ b/pandatool/src/xfileegg/xFileMaker.cxx @@ -234,7 +234,7 @@ bool XFileMaker:: finalize_mesh(XFileNode *x_parent, XFileMesh *mesh) { // Get a unique number for each mesh. _mesh_index++; - string mesh_index = format_string(_mesh_index); + std::string mesh_index = format_string(_mesh_index); // Finally, create the Mesh object. mesh->make_x_mesh(x_parent, mesh_index); diff --git a/pandatool/src/xfileegg/xFileMaterial.cxx b/pandatool/src/xfileegg/xFileMaterial.cxx index 4efa732b4d..11457ebcd5 100644 --- a/pandatool/src/xfileegg/xFileMaterial.cxx +++ b/pandatool/src/xfileegg/xFileMaterial.cxx @@ -161,7 +161,7 @@ has_texture() const { * Creates a Material object for the material list. */ XFileDataNode *XFileMaterial:: -make_x_material(XFileNode *x_meshMaterials, const string &suffix) { +make_x_material(XFileNode *x_meshMaterials, const std::string &suffix) { XFileDataNode *x_material = x_meshMaterials->add_Material("material" + suffix, _face_color, _power, diff --git a/pandatool/src/xfileegg/xFileMesh.cxx b/pandatool/src/xfileegg/xFileMesh.cxx index 9ddf66bc0e..4fad113ed4 100644 --- a/pandatool/src/xfileegg/xFileMesh.cxx +++ b/pandatool/src/xfileegg/xFileMesh.cxx @@ -24,6 +24,9 @@ #include "eggPolygon.h" #include "eggGroupNode.h" +using std::min; +using std::string; + /** * */ @@ -111,7 +114,7 @@ add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim) { _has_uvs = true; } - pair result = + std::pair result = _unique_vertices.insert(UniqueVertices::value_type(vertex, next_index)); if (result.second) { @@ -140,7 +143,7 @@ add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim) { _has_normals = true; } - pair result = + std::pair result = _unique_normals.insert(UniqueNormals::value_type(normal, next_index)); if (result.second) { @@ -168,7 +171,7 @@ add_material(EggPrimitive *egg_prim) { _has_materials = true; } - pair result = + std::pair result = _unique_materials.insert(UniqueMaterials::value_type(material, next_index)); if (result.second) { diff --git a/pandatool/src/xfileegg/xFileToEggConverter.cxx b/pandatool/src/xfileegg/xFileToEggConverter.cxx index 2f65643c0f..130c42546e 100644 --- a/pandatool/src/xfileegg/xFileToEggConverter.cxx +++ b/pandatool/src/xfileegg/xFileToEggConverter.cxx @@ -26,6 +26,8 @@ #include "eggTextureCollection.h" #include "dcast.h" +using std::string; + /** * */ From c1fbeaea51014fe158d5bf8a9f5e31c1c6e21590 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 14 Jun 2018 16:08:17 +0200 Subject: [PATCH 019/360] display: allow full access to all 4 of each aux buffer category I think there was some confusion about how set_aux_rgba (and friends) worked; it seems the original intent was to toggle each individual buffer whereas it is actually interpreted as a count of how many of these buffers should be enabled. We should try to clarify the API and/or replace it with something better as soon as possible. --- panda/src/display/frameBufferProperties.I | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/panda/src/display/frameBufferProperties.I b/panda/src/display/frameBufferProperties.I index 5b6453af24..756a98c0be 100644 --- a/panda/src/display/frameBufferProperties.I +++ b/panda/src/display/frameBufferProperties.I @@ -322,7 +322,7 @@ set_accum_bits(int n) { */ INLINE void FrameBufferProperties:: set_aux_rgba(int n) { - nassertv(n < 4); + nassertv(n <= 4); _property[FBP_aux_rgba] = n; _specified |= (1 << FBP_aux_rgba); } @@ -332,7 +332,7 @@ set_aux_rgba(int n) { */ INLINE void FrameBufferProperties:: set_aux_hrgba(int n) { - nassertv(n < 4); + nassertv(n <= 4); _property[FBP_aux_hrgba] = n; _specified |= (1 << FBP_aux_hrgba); } @@ -342,7 +342,7 @@ set_aux_hrgba(int n) { */ INLINE void FrameBufferProperties:: set_aux_float(int n) { - nassertv(n < 4); + nassertv(n <= 4); _property[FBP_aux_float] = n; _specified |= (1 << FBP_aux_float); } From 83f637ea9f020292b47aeb69cf7d4ddb62f797c4 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 14 Jun 2018 19:00:13 +0200 Subject: [PATCH 020/360] ffmpeg: fix compilation for older FFMpeg versions --- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 8746540af2..4803e41297 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -117,9 +117,9 @@ init_from(FfmpegVideo *source) { _num_components = 1; _pixel_format = (int)AV_PIX_FMT_GRAY8; break; - case AV_PIX_FMT_YA8: + case AV_PIX_FMT_Y400A: // aka AV_PIX_FMT_YA8 _num_components = 2; - _pixel_format = (int)AV_PIX_FMT_YA8; + _pixel_format = (int)AV_PIX_FMT_Y400A; break; default: const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(_video_ctx->pix_fmt); From f804b10d4574ae4225e1d806941983387b9b5a12 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 14 Jun 2018 22:49:45 +0200 Subject: [PATCH 021/360] Fix more compiler warnings --- panda/src/egg/eggCompositePrimitive.cxx | 2 +- panda/src/glstuff/glGeomMunger_src.cxx | 12 ++++++------ panda/src/glstuff/glGraphicsBuffer_src.cxx | 8 ++++---- panda/src/vrpn/vrpn_interface.h | 1 - 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index f390fb67c2..fe42870846 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -431,7 +431,7 @@ void EggCompositePrimitive:: write_body(std::ostream &out, int indent_level) const { EggPrimitive::write_body(out, indent_level); - for (int i = 0; i < get_num_components(); i++) { + for (size_t i = 0; i < get_num_components(); ++i) { const EggAttributes *attrib = get_component(i); if (attrib->compare_to(*this) != 0 && (attrib->has_color() || attrib->has_normal())) { diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index fae758f2c8..b3fabdee6c 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -104,7 +104,7 @@ munge_format_impl(const GeomVertexFormat *orig, } // Convert packed formats that OpenGL may not understand. - for (int i = 0; i < orig->get_num_columns(); ++i) { + for (size_t i = 0; i < orig->get_num_columns(); ++i) { const GeomVertexColumn *column = orig->get_column(i); int array = orig->get_array_with(column->get_name()); @@ -182,7 +182,7 @@ munge_format_impl(const GeomVertexFormat *orig, if ((_flags & F_parallel_arrays) != 0) { // Split out the interleaved array into n parallel arrays. new_format = new GeomVertexFormat; - for (int i = 0; i < format->get_num_columns(); ++i) { + for (size_t i = 0; i < format->get_num_columns(); ++i) { const GeomVertexColumn *column = format->get_column(i); PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; new_array_format->add_column(column->get_name(), column->get_num_components(), @@ -290,7 +290,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { } // Convert packed formats that OpenGL may not understand. - for (int i = 0; i < orig->get_num_columns(); ++i) { + for (size_t i = 0; i < orig->get_num_columns(); ++i) { const GeomVertexColumn *column = orig->get_column(i); int array = orig->get_array_with(column->get_name()); @@ -317,7 +317,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { if ((_flags & F_parallel_arrays) != 0) { // Split out the interleaved array into n parallel arrays. new_format = new GeomVertexFormat; - for (int i = 0; i < format->get_num_columns(); ++i) { + for (size_t i = 0; i < format->get_num_columns(); ++i) { const GeomVertexColumn *column = format->get_column(i); PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; new_array_format->add_column(column->get_name(), column->get_num_components(), @@ -396,11 +396,11 @@ premunge_format_impl(const GeomVertexFormat *orig) { // Now go through the remaining arrays and make sure they are tightly // packed (with the column alignment restrictions). If not, repack them. - for (int i = 0; i < new_format->get_num_arrays(); ++i) { + for (size_t i = 0; i < new_format->get_num_arrays(); ++i) { CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i); if (orig_a->count_unused_space() != 0) { PT(GeomVertexArrayFormat) new_a = new GeomVertexArrayFormat; - for (int j = 0; j < orig_a->get_num_columns(); ++j) { + for (size_t j = 0; j < orig_a->get_num_columns(); ++j) { const GeomVertexColumn *column = orig_a->get_column(j); new_a->add_column(column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index cba097ad34..dcdeeccc56 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -389,7 +389,7 @@ rebuild_bitplanes() { _rb_size_z = 1; _rb_data_size_bytes = 0; - int num_fbos = 1; + size_t num_fbos = 1; // These variables indicate what should be bound to each bitplane. Texture *attach[RTP_COUNT]; @@ -458,7 +458,7 @@ rebuild_bitplanes() { } if (tex->get_z_size() > 1) { - num_fbos = max(num_fbos, tex->get_z_size()); + num_fbos = max(num_fbos, (size_t)tex->get_z_size()); } // Assign the texture to this slot. @@ -523,13 +523,13 @@ rebuild_bitplanes() { if (num_fbos > _fbo.size()) { // Generate more FBO handles. - int start = _fbo.size(); + size_t start = _fbo.size(); GLuint zero = 0; _fbo.resize(num_fbos, zero); glgsg->_glGenFramebuffers(num_fbos - start, &_fbo[start]); } - for (int layer = 0; layer < num_fbos; ++layer) { + for (int layer = 0; layer < (int)num_fbos; ++layer) { // Bind the FBO if (_fbo[layer] == 0) { report_my_gl_errors(); diff --git a/panda/src/vrpn/vrpn_interface.h b/panda/src/vrpn/vrpn_interface.h index e3626e9055..a788d7ae73 100644 --- a/panda/src/vrpn/vrpn_interface.h +++ b/panda/src/vrpn/vrpn_interface.h @@ -19,7 +19,6 @@ #ifdef CPPPARSER // For correct interrogate parsing of UNC's vrpn library. #if defined(WIN32_VC) || defined(WIN64_VC) - #define _WIN32 #define SOCKET int #else #define linux From 19e1b1d877b7d8bf2153544097fc1785b339dc18 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 14 Jun 2018 22:51:12 +0200 Subject: [PATCH 022/360] pgraph: add version of RenderState::get_attrib(_def) taking a CPT --- panda/src/pgraph/renderState.I | 15 +++++++++++++-- panda/src/pgraph/renderState.h | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/panda/src/pgraph/renderState.I b/panda/src/pgraph/renderState.I index faf68f2fe2..d232ecb00a 100644 --- a/panda/src/pgraph/renderState.I +++ b/panda/src/pgraph/renderState.I @@ -483,7 +483,7 @@ flush_level() { #ifndef CPPPARSER /** - * Handy templated version of get_attrib that costs to the right type. + * Handy templated version of get_attrib that casts to the right type. * Returns true if the attribute was present, false otherwise. */ template @@ -492,15 +492,26 @@ get_attrib(const AttribType *&attrib) const { attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot()); return (attrib != nullptr); } +template +INLINE bool RenderState:: +get_attrib(CPT(AttribType) &attrib) const { + attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot()); + return (attrib != nullptr); +} /** - * Handy templated version of get_attrib_def that costs to the right type. + * Handy templated version of get_attrib_def that casts to the right type. */ template INLINE void RenderState:: get_attrib_def(const AttribType *&attrib) const { attrib = (const AttribType *)get_attrib_def((int)AttribType::get_class_slot()); } +template +INLINE void RenderState:: +get_attrib_def(CPT(AttribType) &attrib) const { + attrib = (const AttribType *)get_attrib_def((int)AttribType::get_class_slot()); +} #endif // CPPPARSER /** diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index ab59a6648d..c9e3719082 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -162,7 +162,11 @@ public: template INLINE bool get_attrib(const AttribType *&attrib) const; template + INLINE bool get_attrib(CPT(AttribType) &attrib) const; + template INLINE void get_attrib_def(const AttribType *&attrib) const; + template + INLINE void get_attrib_def(CPT(AttribType) &attrib) const; #endif // CPPPARSER private: From d48695cb2e925a3d968d4cb3aa95d4af21296df8 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 14 Jun 2018 22:51:35 +0200 Subject: [PATCH 023/360] glgsg: fix occasional WeakPointerTo dereference --- panda/src/glstuff/glShaderContext_src.cxx | 5 +++-- panda/src/glstuff/glShaderContext_src.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 77c111ad75..103ebce74f 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -1910,12 +1910,14 @@ set_state_and_transform(const RenderState *target_rs, // Reset all of the state. altered |= Shader::SSD_general; _state_rs = target_rs; + target_rs->get_attrib_def(_color_attrib); } else if (state_rs != target_rs) { // The state has changed since last time. if (state_rs->get_attrib(ColorAttrib::get_class_slot()) != target_rs->get_attrib(ColorAttrib::get_class_slot())) { altered |= Shader::SSD_color; + target_rs->get_attrib_def(_color_attrib); } if (state_rs->get_attrib(ColorScaleAttrib::get_class_slot()) != target_rs->get_attrib(ColorScaleAttrib::get_class_slot())) { @@ -2227,8 +2229,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // Get the active ColorAttrib. We'll need it to determine how to apply // vertex colors. - const ColorAttrib *color_attrib; - _state_rs->get_attrib_def(color_attrib); + const ColorAttrib *color_attrib = _color_attrib.p(); const GeomVertexArrayDataHandle *array_reader; diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index 79ceeb713d..be71b93436 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -75,6 +75,7 @@ private: CPT(TransformState) _modelview_transform; CPT(TransformState) _camera_transform; CPT(TransformState) _projection_transform; + CPT(ColorAttrib) _color_attrib; /* * struct ParamContext { CPT(InternalName) _name; GLint _location; GLsizei From a6b6f4001536b1420d05c50b7ee5734b4d2f8b51 Mon Sep 17 00:00:00 2001 From: Younguk Kim Date: Fri, 15 Jun 2018 09:22:35 +0900 Subject: [PATCH 024/360] pandatool/maya: Fix compilation error by missing std namespace --- pandatool/src/maya/maya_funcs.T | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandatool/src/maya/maya_funcs.T b/pandatool/src/maya/maya_funcs.T index 80d8803d3f..3418ce3647 100644 --- a/pandatool/src/maya/maya_funcs.T +++ b/pandatool/src/maya/maya_funcs.T @@ -17,7 +17,7 @@ */ template bool -get_maya_attribute(MObject &node, const string &attribute_name, +get_maya_attribute(MObject &node, const std::string &attribute_name, ValueType &value) { bool status = false; @@ -35,7 +35,7 @@ get_maya_attribute(MObject &node, const string &attribute_name, */ template bool -set_maya_attribute(MObject &node, const string &attribute_name, +set_maya_attribute(MObject &node, const std::string &attribute_name, ValueType &value) { bool status = false; From 754344906c657c703de43f2032b254ad2637f72b Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 15 Jun 2018 18:04:17 +0200 Subject: [PATCH 025/360] mayaegg: fix various compiler warnings --- pandatool/src/mayaegg/mayaEggLoader.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index 701278b6d6..4baf1dff86 100644 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -1370,7 +1370,6 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del int numVertices = 0; for (ci = poly->begin(); ci != poly->end(); ++ci) { EggVertex *vtx = (*ci); - EggVertexPool *pool = poly->get_pool(); LTexCoordd uv(0,0); if (vtx->has_uv()) { uv = vtx->get_uv(); @@ -1571,8 +1570,8 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del mayaloader_cat.debug() << delim+delstring << "found an EggTable: " << node->get_name() << endl; } } else if (node->is_of_type(EggXfmSAnim::get_class_type())) { - MayaAnim *anim = GetAnim(DCAST(EggXfmSAnim, node)); - // anim->PrintData(); + //MayaAnim *anim = GetAnim(DCAST(EggXfmSAnim, node)); + //anim->PrintData(); if (mayaloader_cat.is_debug()) { mayaloader_cat.debug() << delim+delstring << "found an EggXfmSAnim: " << node->get_name() << endl; } @@ -1797,7 +1796,7 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a double thickness = 0.0; for (ji = _joint_tab.begin(); ji != _joint_tab.end(); ++ji) { MayaEggJoint *joint = (*ji).second; - double dfo = ((*ji).second->GetPos()).length(); + double dfo = (joint->GetPos()).length(); if (dfo > thickness) { thickness = dfo; } @@ -2013,7 +2012,6 @@ void MayaEggLoader::PrintData(MayaEggMesh *mesh) void MayaEggLoader::ParseFrameInfo(string comment) { - int length = 0; int pos, ls, le; pos = comment.find("-fri"); From 835aab5424f2f3268be1de2ef2456ab623f91877 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 15 Jun 2018 18:05:41 +0200 Subject: [PATCH 026/360] physx: fix compiler errors --- panda/src/physx/physxEnums.cxx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/panda/src/physx/physxEnums.cxx b/panda/src/physx/physxEnums.cxx index 73bf0a8534..87a0222bc3 100644 --- a/panda/src/physx/physxEnums.cxx +++ b/panda/src/physx/physxEnums.cxx @@ -16,11 +16,6 @@ #include "string_utils.h" #include "config_putil.h" -using std::istream; -using std::ostream; - -ostream & -operator << (ostream &out, PhysxEnums::PhysxUpAxis axis) { std::ostream & operator << (std::ostream &out, PhysxEnums::PhysxUpAxis axis) { @@ -38,8 +33,8 @@ operator << (std::ostream &out, PhysxEnums::PhysxUpAxis axis) { return out << "**invalid PhysxEnums::PhysxUpAxis value: (" << (int)axis << ")**"; } -istream & -operator >> (istream &in, PhysxEnums::PhysxUpAxis &axis) { +std::istream & +operator >> (std::istream &in, PhysxEnums::PhysxUpAxis &axis) { std::string word; in >> word; From d89efcfda2cb2a67ed018978e99cb155e6a5aa76 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 18 Jun 2018 20:10:47 +0200 Subject: [PATCH 027/360] makepanda: fix recognition of armv7 android systems --- makepanda/makepandacore.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 81163c8179..f738d8affa 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -321,8 +321,12 @@ def GetHostArch(): target = GetTarget() if target == 'windows': return 'x64' if host_64 else 'x86' - else: #TODO - return platform.machine() + + machine = platform.machine() + if machine.startswith('armv7'): + return 'armv7a' + else: + return machine def SetTarget(target, arch=None): """Sets the target platform; the one we're compiling for. Also From 886e1c2f16157ddd2f05ab49076574ef9f487fe3 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 18 Jun 2018 22:12:19 +0200 Subject: [PATCH 028/360] general: fix many compilation warnings in GCC 8 --- contrib/src/rplight/internalLightManager.cxx | 2 +- contrib/src/rplight/pointerSlotStorage.h | 2 +- contrib/src/rplight/rpLight.I | 2 +- contrib/src/rplight/rpLight.h | 2 +- contrib/src/rplight/shadowAtlas.cxx | 6 +-- direct/src/dcparser/dcLexer.cxx.prebuilt | 2 +- direct/src/dcparser/dcLexer.lxx | 2 +- dtool/src/interrogatedb/py_panda.I | 4 ++ dtool/src/interrogatedb/py_wrappers.cxx | 13 ----- panda/src/bullet/bulletBodyNode.cxx | 6 +-- panda/src/bullet/bulletGhostNode.cxx | 3 +- panda/src/bullet/bulletHelper.cxx | 2 +- panda/src/bullet/bulletSoftBodyNode.cxx | 2 +- panda/src/bullet/bulletTriangleMesh.cxx | 10 ++-- panda/src/bullet/bulletWheel.I | 2 +- panda/src/bullet/bulletWorld.cxx | 40 ++++++++-------- panda/src/collide/collisionPolygon.I | 6 +-- panda/src/collide/collisionPolygon.h | 4 +- panda/src/display/graphicsStateGuardian.cxx | 2 +- panda/src/egg/lexer.cxx.prebuilt | 2 +- panda/src/egg/lexer.lxx | 2 +- panda/src/egldisplay/eglGraphicsWindow.cxx | 2 +- panda/src/express/patchfile.cxx | 6 +-- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 2 +- panda/src/glstuff/glGeomMunger_src.cxx | 2 +- panda/src/glstuff/glGraphicsBuffer_src.cxx | 8 ++-- .../glstuff/glGraphicsStateGuardian_src.cxx | 15 ++++-- panda/src/glstuff/glShaderContext_src.cxx | 17 ++++--- panda/src/glstuff/glShaderContext_src.h | 2 +- panda/src/gobj/geomLinestrips.cxx | 2 +- panda/src/gobj/geomVertexArrayFormat.cxx | 4 +- panda/src/gobj/geomVertexData.I | 6 +-- panda/src/gobj/geomVertexData.cxx | 12 ++--- panda/src/gobj/geomVertexData.h | 4 +- panda/src/gobj/geomVertexReader.cxx | 2 +- panda/src/gobj/geomVertexWriter.cxx | 2 +- panda/src/gobj/shader.cxx | 12 ++--- panda/src/gobj/texture.cxx | 6 +-- panda/src/linmath/lsimpleMatrix.I | 27 ----------- panda/src/linmath/lsimpleMatrix.h | 3 -- panda/src/ode/odeTriMeshData.cxx | 4 +- panda/src/parametrics/nurbsSurfaceResult.cxx | 12 ++--- .../particlesystem/spriteParticleRenderer.cxx | 4 +- panda/src/pgraph/camera.I | 2 +- panda/src/pgraph/geomTransformer.cxx | 4 +- panda/src/pgraphnodes/shaderGenerator.cxx | 2 +- panda/src/physics/physicsObject.cxx | 2 +- panda/src/pipeline/pipeline.cxx | 2 +- panda/src/pnmimage/pfmFile.cxx | 47 ++++++++++--------- panda/src/pnmimage/pnmimage_base.h | 2 +- panda/src/pnmimagetypes/pnmFileTypeTGA.cxx | 4 +- panda/src/pstatclient/pStatCollector.I | 14 ------ panda/src/pstatclient/pStatCollector.h | 8 ++-- panda/src/putil/bitArray.cxx | 20 ++++---- panda/src/putil/doubleBitMask.I | 8 ++-- panda/src/putil/factoryBase.cxx | 45 +++--------------- panda/src/putil/factoryBase.h | 19 ++++---- panda/src/putil/factoryParams.I | 39 --------------- panda/src/putil/factoryParams.h | 12 ++--- .../tinydisplay/tinyGraphicsStateGuardian.cxx | 4 +- panda/src/tinydisplay/ztriangle.h | 6 +-- panda/src/tinydisplay/ztriangle_two.h | 16 +++++-- panda/src/x11display/x11GraphicsWindow.cxx | 2 +- pandatool/src/objegg/objToEggConverter.cxx | 6 +-- pandatool/src/vrml/vrmlLexer.cxx.prebuilt | 2 +- pandatool/src/vrml/vrmlLexer.lxx | 2 +- pandatool/src/xfile/xLexer.cxx.prebuilt | 2 +- pandatool/src/xfile/xLexer.lxx | 2 +- 68 files changed, 219 insertions(+), 323 deletions(-) diff --git a/contrib/src/rplight/internalLightManager.cxx b/contrib/src/rplight/internalLightManager.cxx index 3d80294f82..616e089cbc 100644 --- a/contrib/src/rplight/internalLightManager.cxx +++ b/contrib/src/rplight/internalLightManager.cxx @@ -135,7 +135,7 @@ void InternalLightManager::setup_shadows(RPLight* light) { } // Init all sources - for (int i = 0; i < num_sources; ++i) { + for (size_t i = 0; i < num_sources; ++i) { ShadowSource* source = light->get_shadow_source(i); // Set the source as dirty, so it gets updated in the beginning diff --git a/contrib/src/rplight/pointerSlotStorage.h b/contrib/src/rplight/pointerSlotStorage.h index c37102574f..d63594209b 100644 --- a/contrib/src/rplight/pointerSlotStorage.h +++ b/contrib/src/rplight/pointerSlotStorage.h @@ -170,7 +170,7 @@ public: _num_entries--; // Update maximum index - if (slot == _max_index) { + if ((int)slot == _max_index) { while (_max_index >= 0 && !_data[_max_index--]); } } diff --git a/contrib/src/rplight/rpLight.I b/contrib/src/rplight/rpLight.I index 9cde259478..c0e2422651 100644 --- a/contrib/src/rplight/rpLight.I +++ b/contrib/src/rplight/rpLight.I @@ -33,7 +33,7 @@ * * @return Amount of shadow sources */ -inline int RPLight::get_num_shadow_sources() const { +inline size_t RPLight::get_num_shadow_sources() const { return _shadow_sources.size(); } diff --git a/contrib/src/rplight/rpLight.h b/contrib/src/rplight/rpLight.h index 1a104f8ac7..51bca24a76 100644 --- a/contrib/src/rplight/rpLight.h +++ b/contrib/src/rplight/rpLight.h @@ -57,7 +57,7 @@ public: virtual void update_shadow_sources() = 0; virtual void write_to_command(GPUCommand &cmd); - inline int get_num_shadow_sources() const; + inline size_t get_num_shadow_sources() const; inline ShadowSource* get_shadow_source(size_t index) const; inline void clear_shadow_sources(); diff --git a/contrib/src/rplight/shadowAtlas.cxx b/contrib/src/rplight/shadowAtlas.cxx index fa2b2d3076..2f76aae33d 100644 --- a/contrib/src/rplight/shadowAtlas.cxx +++ b/contrib/src/rplight/shadowAtlas.cxx @@ -173,12 +173,12 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h void ShadowAtlas::free_region(const LVecBase4i& region) { // Out of bounds check, can't hurt nassertv(region.get_x() >= 0 && region.get_y() >= 0); - nassertv(region.get_x() + region.get_z() <= _num_tiles && region.get_y() + region.get_w() <= _num_tiles); + nassertv(region.get_x() + region.get_z() <= (int)_num_tiles && region.get_y() + region.get_w() <= (int)_num_tiles); _num_used_tiles -= region.get_z() * region.get_w(); - for (size_t x = 0; x < region.get_z(); ++x) { - for (size_t y = 0; y < region.get_w(); ++y) { + for (int x = 0; x < region.get_z(); ++x) { + for (int y = 0; y < region.get_w(); ++y) { // Could do an assert here, that the tile should have been used (=true) before set_tile(region.get_x() + x, region.get_y() + y, false); } diff --git a/direct/src/dcparser/dcLexer.cxx.prebuilt b/direct/src/dcparser/dcLexer.cxx.prebuilt index 70333927fe..660f96b5cb 100644 --- a/direct/src/dcparser/dcLexer.cxx.prebuilt +++ b/direct/src/dcparser/dcLexer.cxx.prebuilt @@ -744,7 +744,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/direct/src/dcparser/dcLexer.lxx b/direct/src/dcparser/dcLexer.lxx index 423bfe9a99..3c20a69b5f 100644 --- a/direct/src/dcparser/dcLexer.lxx +++ b/direct/src/dcparser/dcLexer.lxx @@ -169,7 +169,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index 8f889768ea..540e9ee58d 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -31,6 +31,8 @@ DtoolInstance_GetPointer(PyObject *self, T *&into) { if (_IS_FINAL(T)) { if (DtoolInstance_TYPE(self) == target_class) { into = (T *)DtoolInstance_VOID_PTR(self); + } else { + return false; } } else { into = (T *)DtoolInstance_UPCAST(self, *target_class); @@ -52,6 +54,8 @@ DtoolInstance_GetPointer(PyObject *self, T *&into, Dtool_PyTypedObject &target_c if (_IS_FINAL(T)) { if (DtoolInstance_TYPE(self) == &target_class) { into = (T *)DtoolInstance_VOID_PTR(self); + } else { + return false; } } else { into = (T *)DtoolInstance_UPCAST(self, target_class); diff --git a/dtool/src/interrogatedb/py_wrappers.cxx b/dtool/src/interrogatedb/py_wrappers.cxx index c09df0d5ab..71a5a38ffd 100644 --- a/dtool/src/interrogatedb/py_wrappers.cxx +++ b/dtool/src/interrogatedb/py_wrappers.cxx @@ -1209,19 +1209,6 @@ static PyObject *Dtool_MappingWrapper_Keys_repr(PyObject *self) { return result; } -static PySequenceMethods Dtool_MappingWrapper_Keys_SequenceMethods = { - Dtool_SequenceWrapper_length, - nullptr, // sq_concat - nullptr, // sq_repeat - Dtool_MappingWrapper_Items_getitem, - nullptr, // sq_slice - nullptr, // sq_ass_item - nullptr, // sq_ass_slice - Dtool_MappingWrapper_contains, - nullptr, // sq_inplace_concat - nullptr, // sq_inplace_repeat -}; - PyTypeObject Dtool_MappingWrapper_Keys_Type = { PyVarObject_HEAD_INIT(nullptr, 0) "sequence wrapper", diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 9c2553c892..0a4bbc40c8 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -784,7 +784,7 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { PT(BulletTriangleMesh) mesh = nullptr; - for (int j=0; jget_num_solids(); j++) { + for (size_t j = 0; j < cnode->get_num_solids(); ++j) { CPT(CollisionSolid) solid = cnode->get_solid(j); TypeHandle type = solid->get_type(); @@ -819,9 +819,9 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { mesh = new BulletTriangleMesh(); } - for (int i=2; i < polygon->get_num_points(); i++ ) { + for (size_t i = 2; i < polygon->get_num_points(); ++i) { LPoint3 p1 = polygon->get_point(0); - LPoint3 p2 = polygon->get_point(i-1); + LPoint3 p2 = polygon->get_point(i - 1); LPoint3 p3 = polygon->get_point(i); mesh->do_add_triangle(p1, p2, p3, true); diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index fad9e8141a..b4008820a1 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -97,8 +97,7 @@ do_transform_changed() { if (ts->has_scale()) { LVecBase3 scale = ts->get_scale(); if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { - for (int i=0; i < _shapes.size(); i++) { - PT(BulletShape) shape = _shapes[i]; + for (BulletShape *shape : _shapes) { shape->do_set_local_scale(scale); } } diff --git a/panda/src/bullet/bulletHelper.cxx b/panda/src/bullet/bulletHelper.cxx index d5e3f503b4..e786e34d40 100644 --- a/panda/src/bullet/bulletHelper.cxx +++ b/panda/src/bullet/bulletHelper.cxx @@ -83,7 +83,7 @@ from_collision_solids(NodePath &np, bool clear) { bool BulletHelper:: is_tangible(CollisionNode *cnode) { - for (int j=0; jget_num_solids(); j++) { + for (size_t j = 0; j < cnode->get_num_solids(); ++j) { CPT(CollisionSolid) solid = cnode->get_solid(j); if (solid->is_tangible()) { return true; diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index 4664ab75c5..9687935412 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -883,7 +883,7 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, const Geom *geom, bool randomizeCon } // Read indices - for (int i=0; iget_num_primitives(); i++) { + for (size_t i = 0; i < geom->get_num_primitives(); ++i) { CPT(GeomPrimitive) prim = geom->get_primitive(i); prim = prim->decompose(); diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 34372e5130..368aa22fac 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -55,7 +55,7 @@ LPoint3 BulletTriangleMesh:: get_vertex(size_t index) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(index < _vertices.size(), LPoint3::zero()); + nassertr(index < (size_t)_vertices.size(), LPoint3::zero()); const btVector3 &vertex = _vertices[index]; return LPoint3(vertex[0], vertex[1], vertex[2]); } @@ -68,7 +68,7 @@ get_triangle(size_t index) const { LightMutexHolder holder(BulletWorld::get_global_lock()); index *= 3; - nassertr(index + 2 < _indices.size(), LVecBase3i::zero()); + nassertr(index + 2 < (size_t)_indices.size(), LVecBase3i::zero()); return LVecBase3i(_indices[index], _indices[index + 1], _indices[index + 2]); } @@ -228,7 +228,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState } } - for (int k = 0; k < geom->get_num_primitives(); ++k) { + for (size_t k = 0; k < geom->get_num_primitives(); ++k) { CPT(GeomPrimitive) prim = geom->get_primitive(k); prim = prim->decompose(); @@ -271,7 +271,7 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState } // Add triangles - for (int k = 0; k < geom->get_num_primitives(); ++k) { + for (size_t k = 0; k < geom->get_num_primitives(); ++k) { CPT(GeomPrimitive) prim = geom->get_primitive(k); prim = prim->decompose(); @@ -367,7 +367,7 @@ write(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":" << endl; const IndexedMeshArray &array = _mesh.getIndexedMeshArray(); - for (size_t i = 0; i < array.size(); ++i) { + for (int i = 0; i < array.size(); ++i) { indent(out, indent_level + 2) << "IndexedMesh " << i << ":" << endl; const btIndexedMesh &mesh = array[0]; indent(out, indent_level + 4) << "num triangles:" << mesh.m_numTriangles << endl; diff --git a/panda/src/bullet/bulletWheel.I b/panda/src/bullet/bulletWheel.I index cbf82a40bc..0523ba9727 100644 --- a/panda/src/bullet/bulletWheel.I +++ b/panda/src/bullet/bulletWheel.I @@ -34,7 +34,7 @@ INLINE BulletWheelRaycastInfo:: INLINE BulletWheel BulletWheel:: empty() { - btWheelInfoConstructionInfo ci; + btWheelInfoConstructionInfo ci {}; btWheelInfo info(ci); return BulletWheel(info); diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index e4c395267c..fce29fd2ba 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -42,7 +42,7 @@ BulletWorld:: BulletWorld() { // Init groups filter matrix - for (int i=0; i<32; i++) { + for (size_t i = 0; i < 32; ++i) { _filter_cb2._collide[i].clear(); _filter_cb2._collide[i].set_bit(i); } @@ -253,20 +253,20 @@ do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) { void BulletWorld:: do_sync_p2b(PN_stdfloat dt, int num_substeps) { - for (int i=0; i < _bodies.size(); i++) { - _bodies[i]->do_sync_p2b(); + for (BulletRigidBodyNode *body : _bodies) { + body->do_sync_p2b(); } - for (int i=0; i < _softbodies.size(); i++) { - _softbodies[i]->do_sync_p2b(); + for (BulletSoftBodyNode *softbody : _softbodies) { + softbody->do_sync_p2b(); } - for (int i=0; i < _ghosts.size(); i++) { - _ghosts[i]->do_sync_p2b(); + for (BulletGhostNode *ghost : _ghosts) { + ghost->do_sync_p2b(); } - for (int i=0; i < _characters.size(); i++) { - _characters[i]->do_sync_p2b(dt, num_substeps); + for (BulletBaseCharacterControllerNode *character : _characters) { + character->do_sync_p2b(dt, num_substeps); } } @@ -276,24 +276,24 @@ do_sync_p2b(PN_stdfloat dt, int num_substeps) { void BulletWorld:: do_sync_b2p() { - for (int i=0; i < _vehicles.size(); i++) { - _vehicles[i]->do_sync_b2p(); + for (BulletVehicle *vehicle : _vehicles) { + vehicle->do_sync_b2p(); } - for (int i=0; i < _bodies.size(); i++) { - _bodies[i]->do_sync_b2p(); + for (BulletRigidBodyNode *body : _bodies) { + body->do_sync_b2p(); } - for (int i=0; i < _softbodies.size(); i++) { - _softbodies[i]->do_sync_b2p(); + for (BulletSoftBodyNode *softbody : _softbodies) { + softbody->do_sync_b2p(); } - for (int i=0; i < _ghosts.size(); i++) { - _ghosts[i]->do_sync_b2p(); + for (BulletGhostNode *ghost : _ghosts) { + ghost->do_sync_b2p(); } - for (int i=0; i < _characters.size(); i++) { - _characters[i]->do_sync_b2p(); + for (BulletBaseCharacterControllerNode *character : _characters) { + character->do_sync_b2p(); } } @@ -1273,7 +1273,7 @@ needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) co // cout << mask0 << " " << mask1 << endl; - for (int i=0; i<32; i++) { + for (size_t i = 0; i < 32; ++i) { if (mask0.get_bit(i)) { if ((_collide[i] & mask1) != 0) // cout << "collide: i=" << i << " _collide[i]" << _collide[i] << endl; diff --git a/panda/src/collide/collisionPolygon.I b/panda/src/collide/collisionPolygon.I index 4a048a3995..6c7785d730 100644 --- a/panda/src/collide/collisionPolygon.I +++ b/panda/src/collide/collisionPolygon.I @@ -57,7 +57,7 @@ CollisionPolygon() { /** * Returns the number of vertices of the CollisionPolygon. */ -INLINE int CollisionPolygon:: +INLINE size_t CollisionPolygon:: get_num_points() const { return _points.size(); } @@ -66,8 +66,8 @@ get_num_points() const { * Returns the nth vertex of the CollisionPolygon, expressed in 3-D space. */ INLINE LPoint3 CollisionPolygon:: -get_point(int n) const { - nassertr(n >= 0 && n < (int)_points.size(), LPoint3::zero()); +get_point(size_t n) const { + nassertr(n < _points.size(), LPoint3::zero()); LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); return to_3d(_points[n]._p, to_3d_mat); diff --git a/panda/src/collide/collisionPolygon.h b/panda/src/collide/collisionPolygon.h index 1ef095fd92..f7fa771bfa 100644 --- a/panda/src/collide/collisionPolygon.h +++ b/panda/src/collide/collisionPolygon.h @@ -45,8 +45,8 @@ public: PUBLISHED: virtual LPoint3 get_collision_origin() const; - INLINE int get_num_points() const; - INLINE LPoint3 get_point(int n) const; + INLINE size_t get_num_points() const; + INLINE LPoint3 get_point(size_t n) const; MAKE_SEQ(get_points, get_num_points, get_point); diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 94330cfa11..1050f8372f 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -763,7 +763,7 @@ get_geom_munger(const RenderState *state, Thread *current_thread) { // multiple times during a frame. Also, this might well be the only GSG // in the world anyway. int mi = state->_last_mi; - if (mi >= 0 && mi < mungers.get_num_entries() && mungers.get_key(mi) == _id) { + if (mi >= 0 && (size_t)mi < mungers.get_num_entries() && mungers.get_key(mi) == _id) { PT(GeomMunger) munger = mungers.get_data(mi); if (munger->is_registered()) { return munger; diff --git a/panda/src/egg/lexer.cxx.prebuilt b/panda/src/egg/lexer.cxx.prebuilt index c736ac335e..9e412bce1f 100644 --- a/panda/src/egg/lexer.cxx.prebuilt +++ b/panda/src/egg/lexer.cxx.prebuilt @@ -1145,7 +1145,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index 1c07166635..e88e5a388f 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -200,7 +200,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/panda/src/egldisplay/eglGraphicsWindow.cxx b/panda/src/egldisplay/eglGraphicsWindow.cxx index 29f7ffbf49..efb550c728 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.cxx +++ b/panda/src/egldisplay/eglGraphicsWindow.cxx @@ -84,7 +84,7 @@ move_pointer(int device, int x, int y) { return true; } else { // Move a raw mouse. - if ((device < 1)||(device >= _input_devices.size())) { + if (device < 1 || (size_t)device >= _input_devices.size()) { return false; } _input_devices[device].set_pointer_in_window(x, y); diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index 4c6d9984f4..a527d78a02 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -1111,7 +1111,7 @@ compute_mf_patches(ostream &write_stream, index_orig, index_new)) { return false; } - nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + mf_new.get_index_end(), false); + nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)mf_new.get_index_end(), false); } // Now walk through each subfile in the new multifile. If a particular @@ -1120,7 +1120,7 @@ compute_mf_patches(ostream &write_stream, // removed, we simply don't add it (we'll never even notice this case). int new_num_subfiles = mf_new.get_num_subfiles(); for (int ni = 0; ni < new_num_subfiles; ++ni) { - nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + mf_new.get_subfile_internal_start(ni), false); + nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)mf_new.get_subfile_internal_start(ni), false); string name = mf_new.get_subfile_name(ni); int oi = mf_orig.find_subfile(name); @@ -1517,7 +1517,7 @@ patch_subfile(ostream &write_stream, const Filename &filename, IStreamWrapper &stream_orig, streampos orig_start, streampos orig_end, IStreamWrapper &stream_new, streampos new_start, streampos new_end) { - nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + new_start, false); + nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + (uint32_t)new_start, false); size_t new_size = new_end - new_start; size_t orig_size = orig_end - orig_start; diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index dd5d49cc59..621de7fe8a 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -307,7 +307,7 @@ reload_buffer() { // First, let's fill the codec's input buffer with as many packets as it'll // take: - int ret; + int ret = 0; while (_packet->data != nullptr) { ret = avcodec_send_packet(_audio_ctx, _packet); diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index b3fabdee6c..27f226a6cc 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -400,7 +400,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i); if (orig_a->count_unused_space() != 0) { PT(GeomVertexArrayFormat) new_a = new GeomVertexArrayFormat; - for (size_t j = 0; j < orig_a->get_num_columns(); ++j) { + for (int j = 0; j < orig_a->get_num_columns(); ++j) { const GeomVertexColumn *column = orig_a->get_column(j); new_a->add_column(column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index dcdeeccc56..f46c8288f1 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -1297,7 +1297,7 @@ set_size(int x, int y) { */ void CLP(GraphicsBuffer):: select_target_tex_page(int page) { - nassertv(page >= 0 && page < _fbo.size()); + nassertv(page >= 0 && (size_t)page < _fbo.size()); CLP(GraphicsStateGuardian) *glgsg = (CLP(GraphicsStateGuardian) *)_gsg.p(); @@ -1574,10 +1574,10 @@ close_buffer() { report_my_gl_errors(); // Delete the FBO itself. - for (int i = 0; i < _fbo.size(); ++i) { - glgsg->_glDeleteFramebuffers(1, &_fbo[i]); + if (!_fbo.empty()) { + glgsg->_glDeleteFramebuffers(_fbo.size(), _fbo.data()); + _fbo.clear(); } - _fbo.clear(); report_my_gl_errors(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index b6790e4931..6958c4ff9a 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -4374,9 +4374,9 @@ unbind_buffers() { if (_current_vertex_buffers.size() > 1 && _supports_multi_bind) { _glBindVertexBuffers(0, _current_vertex_buffers.size(), nullptr, nullptr, nullptr); } else { - for (int i = 0; i < _current_vertex_buffers.size(); ++i) { + for (size_t i = 0; i < _current_vertex_buffers.size(); ++i) { if (_current_vertex_buffers[i] != 0) { - _glBindVertexBuffer(i, 0, 0, 0); + _glBindVertexBuffer((GLuint)i, 0, 0, 0); } } } @@ -13309,7 +13309,10 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { GLint wrap_u, wrap_v, wrap_w; GLint minfilter, magfilter; + +#ifndef OPENGLES GLfloat border_color[4]; +#endif #ifdef OPENGLES if (true) { @@ -13803,11 +13806,13 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { tex->set_wrap_u(get_panda_wrap_mode(wrap_u)); tex->set_wrap_v(get_panda_wrap_mode(wrap_v)); tex->set_wrap_w(get_panda_wrap_mode(wrap_w)); - tex->set_border_color(LColor(border_color[0], border_color[1], - border_color[2], border_color[3])); - tex->set_minfilter(get_panda_filter_type(minfilter)); //tex->set_magfilter(get_panda_filter_type(magfilter)); + +#ifndef OPENGLES + tex->set_border_color(LColor(border_color[0], border_color[1], + border_color[2], border_color[3])); +#endif } PTA_uchar image; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 103ebce74f..ac9b28e784 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -352,7 +352,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext StorageBlock block; block._name = InternalName::make(block_name_cstr); block._binding_index = values[0]; - block._min_size = values[1]; + block._min_size = (GLuint)values[1]; _storage_blocks.push_back(block); } } @@ -681,6 +681,9 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b break; } + (void)numeric_type; + (void)contents; + (void)num_components; // GeomVertexColumn column(InternalName::make(name_buffer), // num_components, numeric_type, contents, offsets[ui], 4, param_size, // astrides[ui]); block_format.add_column(column); @@ -1986,7 +1989,7 @@ issue_parameters(int altered) { if (altered & (Shader::SSD_shaderinputs | Shader::SSD_frame)) { // If we have an osg_FrameNumber input, set it now. - if ((altered | Shader::SSD_frame) != 0 && _frame_number_loc >= 0) { + if ((altered & Shader::SSD_frame) != 0 && _frame_number_loc >= 0) { _glgsg->_glUniform1i(_frame_number_loc, _frame_number); } @@ -2169,7 +2172,7 @@ update_transform_table(const TransformTable *table) { #endif } } - for (; i < _transform_table_size; ++i) { + for (; i < (size_t)_transform_table_size; ++i) { matrices[i] = LMatrix4f::ident_mat(); } @@ -2237,7 +2240,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // Use experimental new separated formatbinding state. const GeomVertexDataPipelineReader *data_reader = _glgsg->_data_reader; - for (int ai = 0; ai < data_reader->get_num_arrays(); ++ai) { + for (size_t ai = 0; ai < data_reader->get_num_arrays(); ++ai) { array_reader = data_reader->get_array_reader(ai); // Make sure the vertex buffer is up-to-date. @@ -2294,7 +2297,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { int start, stride, num_values; size_t nvarying = _shader->_var_spec.size(); - GLuint max_p = 0; + GLint max_p = 0; for (size_t i = 0; i < nvarying; ++i) { const Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; @@ -2312,7 +2315,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { } } - GLuint p = bind._id._seqno; + GLint p = bind._id._seqno; max_p = max(max_p, p + 1); // Don't apply vertex colors if they are disabled with a ColorAttrib. @@ -2401,7 +2404,7 @@ disable_shader_texture_bindings() { DO_PSTATS_STUFF(_glgsg->_texture_state_pcollector.add_level(1)); - for (int i = 0; i < _shader->_tex_spec.size(); ++i) { + for (size_t i = 0; i < _shader->_tex_spec.size(); ++i) { #ifndef OPENGLES // Check if bindless was used, if so, there's nothing to unbind. if (_glgsg->_supports_bindless_texture) { diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index be71b93436..91130e9224 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -99,7 +99,7 @@ private: struct StorageBlock { CPT(InternalName) _name; GLuint _binding_index; - GLint _min_size; + GLuint _min_size; }; typedef pvector StorageBlocks; StorageBlocks _storage_blocks; diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index f6550a0de3..3e37496bad 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -145,7 +145,7 @@ make_adjacency() const { // Add the actual vertices in the strip. adj->add_vertex(v0); - int v1; + int v1 = v0; while (vi < end) { v1 = from.get_vertex(vi++); adj->add_vertex(v1); diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index 2a82eef81f..578e99d805 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -557,9 +557,7 @@ get_format_string(bool pad) const { int fi = 0; int offset = 0; - for (int ci = 0; ci < get_num_columns(); ++ci) { - const GeomVertexColumn *column = get_column(ci); - + for (const GeomVertexColumn *column : _columns) { if (offset < column->get_start()) { // Add padding bytes to fill the gap. int pad = column->get_start() - offset; diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index dd1d800309..bfea5a10ef 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -677,7 +677,7 @@ has_column(const InternalName *name) const { /** * */ -INLINE int GeomVertexDataPipelineBase:: +INLINE size_t GeomVertexDataPipelineBase:: get_num_arrays() const { return _cdata->_arrays.size(); } @@ -686,8 +686,8 @@ get_num_arrays() const { * */ INLINE CPT(GeomVertexArrayData) GeomVertexDataPipelineBase:: -get_array(int i) const { - nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), nullptr); +get_array(size_t i) const { + nassertr(i < _cdata->_arrays.size(), nullptr); return _cdata->_arrays[i].get_read_pointer(); } diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index e87e573552..5e5fa7a1d4 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -344,7 +344,7 @@ void GeomVertexData:: clear_rows() { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, true, current_thread); - nassertv(cdata->_format->get_num_arrays() == (int)cdata->_arrays.size()); + nassertv(cdata->_format->get_num_arrays() == cdata->_arrays.size()); Arrays::iterator ai; for (ai = cdata->_arrays.begin(); @@ -2243,7 +2243,7 @@ get_num_bytes() const { */ int GeomVertexDataPipelineReader:: get_num_rows() const { - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), 0); nassertr(_got_array_readers, 0); if (_cdata->_format->get_num_arrays() == 0) { @@ -2395,7 +2395,7 @@ make_array_readers() { */ int GeomVertexDataPipelineWriter:: get_num_rows() const { - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), 0); nassertr(_got_array_writers, 0); if (_cdata->_format->get_num_arrays() == 0) { @@ -2414,7 +2414,7 @@ get_num_rows() const { bool GeomVertexDataPipelineWriter:: set_num_rows(int n) { nassertr(_got_array_writers, false); - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false); bool any_changed = false; @@ -2510,7 +2510,7 @@ set_num_rows(int n) { bool GeomVertexDataPipelineWriter:: unclean_set_num_rows(int n) { nassertr(_got_array_writers, false); - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false); bool any_changed = false; @@ -2537,7 +2537,7 @@ unclean_set_num_rows(int n) { bool GeomVertexDataPipelineWriter:: reserve_num_rows(int n) { nassertr(_got_array_writers, false); - nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), false); + nassertr(_cdata->_format->get_num_arrays() == _cdata->_arrays.size(), false); bool any_changed = false; diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 52d177e5e2..9b861c1cbc 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -419,8 +419,8 @@ public: INLINE bool has_column(const InternalName *name) const; INLINE UsageHint get_usage_hint() const; - INLINE int get_num_arrays() const; - INLINE CPT(GeomVertexArrayData) get_array(int i) const; + INLINE size_t get_num_arrays() const; + INLINE CPT(GeomVertexArrayData) get_array(size_t i) const; INLINE const TransformTable *get_transform_table() const; INLINE CPT(TransformBlendTable) get_transform_blend_table() const; INLINE const SliderTable *get_slider_table() const; diff --git a/panda/src/gobj/geomVertexReader.cxx b/panda/src/gobj/geomVertexReader.cxx index 00bd42a33f..c1a4f96051 100644 --- a/panda/src/gobj/geomVertexReader.cxx +++ b/panda/src/gobj/geomVertexReader.cxx @@ -102,7 +102,7 @@ set_vertex_column(int array, const GeomVertexColumn *column, #ifndef NDEBUG _array = -1; _packer = nullptr; - nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); + nassertr(array >= 0 && (size_t)array < _vertex_data->get_num_arrays(), false); #endif _array = array; diff --git a/panda/src/gobj/geomVertexWriter.cxx b/panda/src/gobj/geomVertexWriter.cxx index a433bef9e2..eaae2603ac 100644 --- a/panda/src/gobj/geomVertexWriter.cxx +++ b/panda/src/gobj/geomVertexWriter.cxx @@ -133,7 +133,7 @@ set_vertex_column(int array, const GeomVertexColumn *column, #ifndef NDEBUG _array = -1; _packer = nullptr; - nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); + nassertr(array >= 0 && (size_t)array < _vertex_data->get_num_arrays(), false); #endif _array = array; diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index b5e9e78489..5914fd3598 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -2652,7 +2652,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } char pragma[64]; - int nread = 0; + size_t nread = 0; // What kind of directive is it? if (strcmp(directive, "pragma") == 0 && sscanf(line.c_str(), " # pragma %63s", pragma) == 1) { @@ -2661,13 +2661,13 @@ r_preprocess_source(ostream &out, const Filename &fn, Filename incfn, source_dir; { char incfile[2048]; - if (sscanf(line.c_str(), " # pragma%*[ \t]include \"%2047[^\"]\" %n", incfile, &nread) == 1 + if (sscanf(line.c_str(), " # pragma%*[ \t]include \"%2047[^\"]\" %zn", incfile, &nread) == 1 && nread == line.size()) { // A regular include, with double quotes. Probably a local file. source_dir = full_fn.get_dirname(); incfn = incfile; - } else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %n", incfile, &nread) == 1 + } else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %zn", incfile, &nread) == 1 && nread == line.size()) { // Angled includes are also OK, but we don't search in the directory // of the source file. @@ -2696,7 +2696,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } else if (strcmp(pragma, "once") == 0) { // Do a stricter syntax check, just to be extra safe. - if (sscanf(line.c_str(), " # pragma%*[ \t]once %n", &nread) != 0 || + if (sscanf(line.c_str(), " # pragma%*[ \t]once %zn", &nread) != 0 || nread != line.size()) { shader_cat.error() << "Malformed #pragma once at line " << lineno @@ -2788,7 +2788,7 @@ r_preprocess_source(ostream &out, const Filename &fn, Filename incfn; { char incfile[2048]; - if (sscanf(line.c_str(), " # include%*[ \t]\"%2047[^\"]\" %n", incfile, &nread) != 1 + if (sscanf(line.c_str(), " # include%*[ \t]\"%2047[^\"]\" %zn", incfile, &nread) != 1 || nread != line.size()) { // Couldn't parse it. shader_cat.error() @@ -2815,7 +2815,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } else if (ext_google_line > 0 && strcmp(directive, "line") == 0) { // It's a #line directive. See if it uses a string instead of number. char filestr[2048]; - if (sscanf(line.c_str(), " # line%*[ \t]%d%*[ \t]\"%2047[^\"]\" %n", &lineno, filestr, &nread) == 2 + if (sscanf(line.c_str(), " # line%*[ \t]%d%*[ \t]\"%2047[^\"]\" %zn", &lineno, filestr, &nread) == 2 && nread == line.size()) { // Warn about extension use if requested. if (ext_google_line == 1) { diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 1ebeec18db..5918210fdc 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -4224,7 +4224,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } // See: https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ - uint32_t gl_type, type_size, gl_format, internal_format, gl_base_format, + uint32_t gl_type, /*type_size,*/ gl_format, internal_format, gl_base_format, width, height, depth, num_array_elements, num_faces, num_mipmap_levels, kvdata_size; @@ -4232,7 +4232,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) if (ktx.get_uint32() == 0x04030201) { big_endian = false; gl_type = ktx.get_uint32(); - type_size = ktx.get_uint32(); + /*type_size = */ktx.get_uint32(); gl_format = ktx.get_uint32(); internal_format = ktx.get_uint32(); gl_base_format = ktx.get_uint32(); @@ -4246,7 +4246,7 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } else { big_endian = true; gl_type = ktx.get_be_uint32(); - type_size = ktx.get_be_uint32(); + /*type_size = */ktx.get_be_uint32(); gl_format = ktx.get_be_uint32(); internal_format = ktx.get_be_uint32(); gl_base_format = ktx.get_be_uint32(); diff --git a/panda/src/linmath/lsimpleMatrix.I b/panda/src/linmath/lsimpleMatrix.I index 7ce8b4ed69..6d322bfb75 100644 --- a/panda/src/linmath/lsimpleMatrix.I +++ b/panda/src/linmath/lsimpleMatrix.I @@ -11,33 +11,6 @@ * @date 2011-12-15 */ -/** - * - */ -template -INLINE LSimpleMatrix:: -LSimpleMatrix() { - // No default initialization. -} - -/** - * - */ -template -INLINE LSimpleMatrix:: -LSimpleMatrix(const LSimpleMatrix ©) { - memcpy(_array, copy._array, sizeof(_array)); -} - -/** - * - */ -template -INLINE void LSimpleMatrix:: -operator = (const LSimpleMatrix ©) { - memcpy(_array, copy._array, sizeof(_array)); -} - /** * */ diff --git a/panda/src/linmath/lsimpleMatrix.h b/panda/src/linmath/lsimpleMatrix.h index 3228caf5bb..faeecd9516 100644 --- a/panda/src/linmath/lsimpleMatrix.h +++ b/panda/src/linmath/lsimpleMatrix.h @@ -28,9 +28,6 @@ template class LSimpleMatrix { public: - INLINE LSimpleMatrix(); - INLINE LSimpleMatrix(const LSimpleMatrix ©); - INLINE void operator = (const LSimpleMatrix ©); INLINE const FloatType &operator () (int row, int col) const; INLINE FloatType &operator () (int row, int col); INLINE const FloatType &operator () (int col) const; diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx index 4ca05ea17a..c92602ac34 100644 --- a/panda/src/ode/odeTriMeshData.cxx +++ b/panda/src/ode/odeTriMeshData.cxx @@ -221,7 +221,7 @@ process_geom(const Geom *geom) { CPT(GeomVertexData) vData = geom->get_vertex_data(); - for (int i = 0; i < geom->get_num_primitives(); ++i) { + for (size_t i = 0; i < geom->get_num_primitives(); ++i) { process_primitive(geom->get_primitive(i), vData); } } @@ -308,7 +308,7 @@ analyze(const Geom *geom) { return; } - for (int i = 0; i < geom->get_num_primitives(); ++i) { + for (size_t i = 0; i < geom->get_num_primitives(); ++i) { analyze(geom->get_primitive(i)); } } diff --git a/panda/src/parametrics/nurbsSurfaceResult.cxx b/panda/src/parametrics/nurbsSurfaceResult.cxx index e1bfccb168..86b6f6615f 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.cxx +++ b/panda/src/parametrics/nurbsSurfaceResult.cxx @@ -62,10 +62,10 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis, // Create four geometry matrices from our (up to) sixteen involved // vertices. LMatrix4 geom_x, geom_y, geom_z, geom_w; - memset(&geom_x, 0, sizeof(geom_x)); - memset(&geom_y, 0, sizeof(geom_y)); - memset(&geom_z, 0, sizeof(geom_z)); - memset(&geom_w, 0, sizeof(geom_w)); + geom_x.fill(0); + geom_y.fill(0); + geom_z.fill(0); + geom_w.fill(0); for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { @@ -178,7 +178,7 @@ eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) int vn = _v_basis.get_vertex_index(vi); LMatrix4 geom; - memset(&geom, 0, sizeof(geom)); + geom.fill(0); for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { @@ -223,7 +223,7 @@ eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d for (int n = 0; n < num_values; n++) { LMatrix4 geom; - memset(&geom, 0, sizeof(geom)); + geom.fill(0); for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { diff --git a/panda/src/particlesystem/spriteParticleRenderer.cxx b/panda/src/particlesystem/spriteParticleRenderer.cxx index 9aa9c77e52..cdd340c989 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.cxx +++ b/panda/src/particlesystem/spriteParticleRenderer.cxx @@ -294,7 +294,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { GeomVertexReader texcoord(geom->get_vertex_data(), InternalName::get_texcoord()); if (texcoord.has_column()) { - for (int pi = 0; pi < geom->get_num_primitives(); ++pi) { + for (size_t pi = 0; pi < geom->get_num_primitives(); ++pi) { primitive = geom->get_primitive(pi); for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) { int vert = primitive->get_vertex(vi); @@ -338,7 +338,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { GeomVertexReader vertex(geom->get_vertex_data(), InternalName::get_vertex()); if (vertex.has_column()) { - for (int pi = 0; pi < geom->get_num_primitives(); ++pi) { + for (size_t pi = 0; pi < geom->get_num_primitives(); ++pi) { primitive = geom->get_primitive(pi); for (int vi = 0; vi < primitive->get_num_vertices(); ++vi) { int vert = primitive->get_vertex(vi); diff --git a/panda/src/pgraph/camera.I b/panda/src/pgraph/camera.I index 1ab7bc2e41..7d32f433d3 100644 --- a/panda/src/pgraph/camera.I +++ b/panda/src/pgraph/camera.I @@ -64,7 +64,7 @@ get_num_display_regions() const { */ INLINE DisplayRegion *Camera:: get_display_region(size_t n) const { - nassertr(n < (int)_display_regions.size(), nullptr); + nassertr(n < _display_regions.size(), nullptr); return _display_regions[n]; } diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index 6e4d30955e..cfc023b528 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -1479,7 +1479,7 @@ remove_unused_vertices(const GeomVertexData *vdata) { PT(GeomVertexData) new_vdata = new GeomVertexData(*vdata); new_vdata->unclean_set_num_rows(new_num_vertices); - int num_arrays = vdata->get_num_arrays(); + size_t num_arrays = vdata->get_num_arrays(); nassertv(num_arrays == new_vdata->get_num_arrays()); GeomVertexDataPipelineReader reader(vdata, current_thread); @@ -1487,7 +1487,7 @@ remove_unused_vertices(const GeomVertexData *vdata) { GeomVertexDataPipelineWriter writer(new_vdata, true, current_thread); writer.check_array_writers(); - for (int a = 0; a < num_arrays; ++a) { + for (size_t a = 0; a < num_arrays; ++a) { const GeomVertexArrayDataHandle *array_reader = reader.get_array_reader(a); GeomVertexArrayDataHandle *array_writer = writer.get_array_writer(a); diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index dceb4abf4b..22d0b32259 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -261,7 +261,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { rs->get_attrib_def(la); bool have_ambient = false; - for (int i = 0; i < la->get_num_on_lights(); ++i) { + for (size_t i = 0; i < la->get_num_on_lights(); ++i) { NodePath np = la->get_on_light(i); nassertv(!np.is_empty()); PandaNode *node = np.node(); diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index 79c1829374..9cca9f6d2f 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -112,7 +112,7 @@ add_impact(const LPoint3 &offset, a = a.cross(b); PN_stdfloat angle = a.length(); if (angle) { - LRotation torque; + LRotation torque(0, 0, 0, 0); PN_stdfloat spin = force.length()*0.1; // todo: this should account for // impact distance and mass. a.normalize(); diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index 763dc3a8d6..a3633226bc 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -94,7 +94,7 @@ cycle() { pvector< PT(CycleData) > saved_cdatas; { ReMutexHolder cycle_holder(_cycle_lock); - int prev_seq, next_seq; + unsigned int prev_seq, next_seq; PipelineCyclerLinks prev_dirty; { // We can't hold the lock protecting the linked lists during the cycling diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index abe2845add..57b9671d1a 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -1726,35 +1726,32 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 // Now determine the minmax. PN_float32 min_x, min_y, min_z, max_x, max_y, max_z; - bool got_point = false; if (points_only) { - LPoint3f points[4] = { + const LPoint3f points[4] = { p0 * rinv, p1 * rinv, p2 * rinv, p3 * rinv, }; - for (int i = 0; i < 4; ++i) { - const LPoint3f &point = points[i]; - if (!got_point) { - min_x = point[0]; - min_y = point[1]; - min_z = point[2]; - max_x = point[0]; - max_y = point[1]; - max_z = point[2]; - got_point = true; - } else { - min_x = min(min_x, point[0]); - min_y = min(min_y, point[1]); - min_z = min(min_z, point[2]); - max_x = max(max_x, point[0]); - max_y = max(max_y, point[1]); - max_z = max(max_z, point[2]); - } - } + const LPoint3f &point = points[0]; + min_x = point[0]; + min_y = point[1]; + min_z = point[2]; + max_x = point[0]; + max_y = point[1]; + max_z = point[2]; + for (int i = 1; i < 4; ++i) { + const LPoint3f &point = points[i]; + min_x = min(min_x, point[0]); + min_y = min(min_y, point[1]); + min_z = min(min_z, point[2]); + max_x = max(max_x, point[0]); + max_y = max(max_y, point[1]); + max_z = max(max_z, point[2]); + } } else { + bool got_point = false; for (int yi = 0; yi < _y_size; ++yi) { for (int xi = 0; xi < _x_size; ++xi) { if (!has_point(xi, yi)) { @@ -1780,6 +1777,14 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 } } } + if (!got_point) { + min_x = 0.0f; + min_y = 0.0f; + min_z = 0.0f; + max_x = 0.0f; + max_y = 0.0f; + max_z = 0.0f; + } } PT(BoundingHexahedron) bounds; diff --git a/panda/src/pnmimage/pnmimage_base.h b/panda/src/pnmimage/pnmimage_base.h index a332d693dc..ca1f356c48 100644 --- a/panda/src/pnmimage/pnmimage_base.h +++ b/panda/src/pnmimage/pnmimage_base.h @@ -40,7 +40,7 @@ typedef unsigned char gray; struct pixel { PUBLISHED: - pixel() { } + pixel() = default; pixel(gray fill) : r(fill), g(fill), b(fill) { } pixel(gray r, gray g, gray b) : r(r), g(g), b(b) { } diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index 18fc389150..a50ae370ae 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -721,8 +721,8 @@ get_pixel( istream *ifp, pixel *dest, int Size, gray *alpha_p) { Red = getbyte( ifp ); if ( Size == 32 ) Alpha = getbyte( ifp ); - else - Alpha = 0; + else + Alpha = 0; l = 0; break; diff --git a/panda/src/pstatclient/pStatCollector.I b/panda/src/pstatclient/pStatCollector.I index a729a22fa8..710d803e3e 100644 --- a/panda/src/pstatclient/pStatCollector.I +++ b/panda/src/pstatclient/pStatCollector.I @@ -25,20 +25,6 @@ PStatCollector(PStatClient *client, int index) : { } -/** - * Creates an invalid PStatCollector. Any attempt to use this collector will - * crash messily. - * - * You can reassign it to a different, valid one later. - */ -INLINE PStatCollector:: -PStatCollector() : - _client(nullptr), - _index(0), - _level(0.0f) -{ -} - /** * Creates a new PStatCollector, ready to start accumulating data. The name * of the collector uniquely identifies it among the other collectors; if two diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index a007faa61c..aeb74f7cdb 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/panda/src/pstatclient/pStatCollector.h @@ -47,7 +47,7 @@ private: INLINE PStatCollector(PStatClient *client, int index); public: - INLINE PStatCollector(); + PStatCollector() = default; PUBLISHED: INLINE explicit PStatCollector(const std::string &name, @@ -99,9 +99,9 @@ PUBLISHED: INLINE int get_index() const; private: - PStatClient *_client; - int _index; - double _level; + PStatClient *_client = nullptr; + int _index = 0; + double _level = 0.0; friend class PStatClient; diff --git a/panda/src/putil/bitArray.cxx b/panda/src/putil/bitArray.cxx index 42f0d47259..2ba077e0c1 100644 --- a/panda/src/putil/bitArray.cxx +++ b/panda/src/putil/bitArray.cxx @@ -87,7 +87,7 @@ is_all_on() const { */ bool BitArray:: has_any_of(int low_bit, int size) const { - if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) { + if ((size_t)(low_bit + size) > get_num_bits()) { // This range touches the highest bits. if (_highest_bits) { return true; @@ -97,7 +97,7 @@ has_any_of(int low_bit, int size) const { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // This range is entirely among the highest bits. return (_highest_bits != 0); } @@ -126,7 +126,7 @@ has_any_of(int low_bit, int size) const { size -= num_bits_per_word; ++w; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // Now we're up to the highest bits. return (_highest_bits != 0); } @@ -140,7 +140,7 @@ has_any_of(int low_bit, int size) const { */ bool BitArray:: has_all_of(int low_bit, int size) const { - if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) { + if ((size_t)(low_bit + size) > get_num_bits()) { // This range touches the highest bits. if (!_highest_bits) { return false; @@ -150,7 +150,7 @@ has_all_of(int low_bit, int size) const { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // This range is entirely among the highest bits. return (_highest_bits != 0); } @@ -179,7 +179,7 @@ has_all_of(int low_bit, int size) const { size -= num_bits_per_word; ++w; - if (w >= get_num_words()) { + if (w >= (int)get_num_words()) { // Now we're up to the highest bits. return (_highest_bits != 0); } @@ -196,7 +196,7 @@ set_range(int low_bit, int size) { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words() && _highest_bits) { + if (w >= (int)get_num_words() && _highest_bits) { // All the highest bits are already on. return; } @@ -229,7 +229,7 @@ set_range(int low_bit, int size) { size -= num_bits_per_word; ++w; - if (w >= get_num_words() && _highest_bits) { + if (w >= (int)get_num_words() && _highest_bits) { // All the highest bits are already on. normalize(); return; @@ -246,7 +246,7 @@ clear_range(int low_bit, int size) { int w = low_bit / num_bits_per_word; int b = low_bit % num_bits_per_word; - if (w >= get_num_words() && !_highest_bits) { + if (w >= (int)get_num_words() && !_highest_bits) { // All the highest bits are already off. return; } @@ -279,7 +279,7 @@ clear_range(int low_bit, int size) { size -= num_bits_per_word; ++w; - if (w >= get_num_words() && !_highest_bits) { + if (w >= (int)get_num_words() && !_highest_bits) { // All the highest bits are already off. normalize(); return; diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index 35ede588a4..cc400a14fb 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -214,8 +214,8 @@ has_any_of(int low_bit, int size) const { } else { int hi_portion = low_bit + size - half_bits; int lo_portion = size - hi_portion; - return (_hi.has_any_of(0, hi_portion) << lo_portion) || - _lo.has_any_of(low_bit, lo_portion); + return _hi.has_any_of(0, hi_portion) + || _lo.has_any_of(low_bit, lo_portion); } } @@ -232,8 +232,8 @@ has_all_of(int low_bit, int size) const { } else { int hi_portion = low_bit + size - half_bits; int lo_portion = size - hi_portion; - return (_hi.has_all_of(0, hi_portion) << lo_portion) && - _lo.has_all_of(low_bit, lo_portion); + return _hi.has_all_of(0, hi_portion) + && _lo.has_all_of(low_bit, lo_portion); } } diff --git a/panda/src/putil/factoryBase.cxx b/panda/src/putil/factoryBase.cxx index eeba7183dc..341028d068 100644 --- a/panda/src/putil/factoryBase.cxx +++ b/panda/src/putil/factoryBase.cxx @@ -15,20 +15,6 @@ #include "indent.h" #include "config_putil.h" -/** - * - */ -FactoryBase:: -FactoryBase() { -} - -/** - * - */ -FactoryBase:: -~FactoryBase() { -} - /** * Attempts to create a new instance of some class of the indicated type, or * some derivative if necessary. If an instance of the exact type cannot be @@ -145,7 +131,7 @@ register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data) { /** * Returns the number of different types the Factory knows how to create. */ -int FactoryBase:: +size_t FactoryBase:: get_num_types() const { return _creators.size(); } @@ -156,8 +142,8 @@ get_num_types() const { * Normally you wouldn't need to traverse the list of the Factory's types. */ TypeHandle FactoryBase:: -get_type(int n) const { - nassertr(n >= 0 && n < get_num_types(), TypeHandle::none()); +get_type(size_t n) const { + nassertr(n < get_num_types(), TypeHandle::none()); Creators::const_iterator ci; for (ci = _creators.begin(); ci != _creators.end(); ++ci) { if (n == 0) { @@ -193,7 +179,7 @@ add_preferred(TypeHandle handle) { /** * Returns the number of types added to the preferred-type list. */ -int FactoryBase:: +size_t FactoryBase:: get_num_preferred() const { return _preferred.size(); } @@ -202,8 +188,8 @@ get_num_preferred() const { * Returns the nth type added to the preferred-type list. */ TypeHandle FactoryBase:: -get_preferred(int n) const { - nassertr(n >= 0 && n < get_num_preferred(), TypeHandle::none()); +get_preferred(size_t n) const { + nassertr(n < get_num_preferred(), TypeHandle::none()); return _preferred[n]; } @@ -219,21 +205,6 @@ write_types(std::ostream &out, int indent_level) const { } } - -/** - * Don't copy Factories. - */ -FactoryBase:: -FactoryBase(const FactoryBase &) { -} - -/** - * Don't copy Factories. - */ -void FactoryBase:: -operator = (const FactoryBase &) { -} - /** * Attempts to create an instance of the exact type requested by the given * handle. Returns the new instance created, or NULL if the instance could @@ -262,9 +233,7 @@ make_instance_more_specific(TypeHandle handle, FactoryParams params) { // First, walk through the established preferred list. Maybe one of these // qualifies. - Preferred::const_iterator pi; - for (pi = _preferred.begin(); pi != _preferred.end(); ++pi) { - TypeHandle ptype = (*pi); + for (TypeHandle ptype : _preferred) { if (ptype.is_derived_from(handle)) { TypedObject *object = make_instance_exact(ptype, params); if (object != nullptr) { diff --git a/panda/src/putil/factoryBase.h b/panda/src/putil/factoryBase.h index 7ef256f1a8..65617f254b 100644 --- a/panda/src/putil/factoryBase.h +++ b/panda/src/putil/factoryBase.h @@ -39,8 +39,11 @@ public: // public interface public: - FactoryBase(); - ~FactoryBase(); + FactoryBase() = default; + FactoryBase(const FactoryBase ©) = delete; + ~FactoryBase() = default; + + FactoryBase &operator = (const FactoryBase ©) = delete; TypedObject *make_instance(TypeHandle handle, const FactoryParams ¶ms); @@ -58,21 +61,17 @@ public: void register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data = nullptr); - int get_num_types() const; - TypeHandle get_type(int n) const; + size_t get_num_types() const; + TypeHandle get_type(size_t n) const; void clear_preferred(); void add_preferred(TypeHandle handle); - int get_num_preferred() const; - TypeHandle get_preferred(int n) const; + size_t get_num_preferred() const; + TypeHandle get_preferred(size_t n) const; void write_types(std::ostream &out, int indent_level = 0) const; private: - // These are private; we shouldn't be copy-constructing Factories. - FactoryBase(const FactoryBase ©); - void operator = (const FactoryBase ©); - // internal utility functions TypedObject *make_instance_exact(TypeHandle handle, FactoryParams params); TypedObject *make_instance_more_specific(TypeHandle handle, diff --git a/panda/src/putil/factoryParams.I b/panda/src/putil/factoryParams.I index b62406861a..0f71e62969 100644 --- a/panda/src/putil/factoryParams.I +++ b/panda/src/putil/factoryParams.I @@ -13,45 +13,6 @@ #include "pnotify.h" -/** - * - */ -INLINE FactoryParams:: -FactoryParams() : _user_data(nullptr) { -} - -/** - * - */ -INLINE FactoryParams:: -FactoryParams(const FactoryParams ©) : - _params(copy._params), - _user_data(copy._user_data) {} - -/** - * - */ -INLINE FactoryParams:: -~FactoryParams() { -} - -/** - * - */ -INLINE FactoryParams:: -FactoryParams(FactoryParams &&from) noexcept : - _params(std::move(from._params)), - _user_data(from._user_data) {} - -/** - * - */ -INLINE void FactoryParams:: -operator = (FactoryParams &&from) noexcept { - _params = std::move(from._params); - _user_data = from._user_data; -} - /** * Returns the custom pointer that was associated with the factory function. */ diff --git a/panda/src/putil/factoryParams.h b/panda/src/putil/factoryParams.h index 3f987e7f66..b76dc81e84 100644 --- a/panda/src/putil/factoryParams.h +++ b/panda/src/putil/factoryParams.h @@ -35,12 +35,12 @@ */ class EXPCL_PANDA_PUTIL FactoryParams { public: - INLINE FactoryParams(); - INLINE FactoryParams(const FactoryParams ©); - INLINE FactoryParams(FactoryParams &&from) noexcept; - INLINE ~FactoryParams(); + FactoryParams() = default; + FactoryParams(const FactoryParams ©) = default; + FactoryParams(FactoryParams &&from) noexcept = default; + ~FactoryParams() = default; - INLINE void operator = (FactoryParams &&from) noexcept; + FactoryParams &operator = (FactoryParams &&from) noexcept = default; void add_param(FactoryParam *param); void clear(); @@ -56,7 +56,7 @@ private: typedef pvector< PT(TypedReferenceCount) > Params; Params _params; - void *_user_data; + void *_user_data = nullptr; friend class FactoryBase; }; diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 3717405893..8f49433ebd 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -2251,10 +2251,10 @@ do_issue_texture() { // The following special cases are handled inline, rather than relying // on the above wrap function pointers. - if (wrap_u && SamplerState::WM_border_color && wrap_v == SamplerState::WM_border_color) { + if (wrap_u == SamplerState::WM_border_color && wrap_v == SamplerState::WM_border_color) { texture_def->tex_minfilter_func = apply_wrap_border_color_minfilter; texture_def->tex_magfilter_func = apply_wrap_border_color_magfilter; - } else if (wrap_u && SamplerState::WM_clamp && wrap_v == SamplerState::WM_clamp) { + } else if (wrap_u == SamplerState::WM_clamp && wrap_v == SamplerState::WM_clamp) { texture_def->tex_minfilter_func = apply_wrap_clamp_minfilter; texture_def->tex_magfilter_func = apply_wrap_clamp_magfilter; } diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index daa035dc75..72f3c1ae11 100644 --- a/panda/src/tinydisplay/ztriangle.h +++ b/panda/src/tinydisplay/ztriangle.h @@ -14,7 +14,7 @@ int error, derror; int x1, dxdy_min, dxdy_max; /* warning: x2 is multiplied by 2^16 */ - UNUSED int x2, dx2dy2; + int x2, dx2dy2; #ifdef INTERP_Z int z1 = 0, dzdx = 0, dzdy = 0, dzdl_min = 0, dzdl_max = 0; @@ -348,10 +348,10 @@ int n; #ifdef INTERP_Z ZPOINT *pz; - UNUSED unsigned int z,zz; + unsigned int z,zz; #endif #ifdef INTERP_RGB - UNUSED unsigned int or1,og1,ob1,oa1; + unsigned int or1,og1,ob1,oa1; #endif #ifdef INTERP_ST unsigned int s,t; diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index 49c4550b4a..0d9db0df0f 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -1,3 +1,9 @@ +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#endif + static void FNAME(white_untextured) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) @@ -229,7 +235,7 @@ FNAME(smooth_textured) (ZBuffer *zb, c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \ if (c0 == c1 && c0 == c2) { \ /* It's really a flat-shaded triangle. */ \ - if (c0 == 0xffffffff) { \ + if (c0 == 0xffffffffu) { \ /* Actually, it's a white triangle. */ \ FNAME(white_textured)(zb, p0, p1, p2); \ return; \ @@ -537,13 +543,13 @@ FNAME(smooth_perspective) (ZBuffer *zb, #define EARLY_OUT() \ { \ - int c0, c1, c2; \ + unsigned int c0, c1, c2; \ c0 = RGBA_TO_PIXEL(p0->r, p0->g, p0->b, p0->a); \ c1 = RGBA_TO_PIXEL(p1->r, p1->g, p1->b, p1->a); \ c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \ if (c0 == c1 && c0 == c2) { \ /* It's really a flat-shaded triangle. */ \ - if (c0 == 0xffffffff) { \ + if (c0 == 0xffffffffu) { \ /* Actually, it's a white triangle. */ \ FNAME(white_perspective)(zb, p0, p1, p2); \ return; \ @@ -1008,3 +1014,7 @@ FNAME(smooth_multitex3) (ZBuffer *zb, #undef INTERP_MIPMAP #undef CALC_MIPMAP_LEVEL #undef ZB_LOOKUP_TEXTURE + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 0187139828..af1e9de489 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -174,7 +174,7 @@ move_pointer(int device, int x, int y) { return true; } else { // Move a raw mouse. - if ((device < 1)||(device >= _input_devices.size())) { + if (device < 1 || (size_t)device >= _input_devices.size()) { return false; } _input_devices[device].set_pointer_in_window(x, y); diff --git a/pandatool/src/objegg/objToEggConverter.cxx b/pandatool/src/objegg/objToEggConverter.cxx index 7278a32dc9..7044409ca5 100644 --- a/pandatool/src/objegg/objToEggConverter.cxx +++ b/pandatool/src/objegg/objToEggConverter.cxx @@ -649,7 +649,7 @@ process_f_node(vector_string &words) { _f_given = true; bool all_vn = true; - int non_vn_index = -1; + //int non_vn_index = -1; pvector verts; verts.reserve(words.size() - 1); @@ -658,7 +658,7 @@ process_f_node(vector_string &words) { verts.push_back(entry); if (entry._vni == 0) { all_vn = false; - non_vn_index = i; + //non_vn_index = i; } } @@ -706,7 +706,7 @@ process_f_node(vector_string &words) { } if (_current_vertex_data->_prim->get_num_vertices() + 3 * num_tris > egg_max_indices || - _current_vertex_data->_entries.size() + verts.size() > egg_max_vertices) { + _current_vertex_data->_entries.size() + verts.size() > (size_t)egg_max_vertices) { // We'll exceed our specified limit with these triangles; start a new // Geom. _current_vertex_data->close_geom(this); diff --git a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt index cc79d45379..8022d21f4b 100644 --- a/pandatool/src/vrml/vrmlLexer.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlLexer.cxx.prebuilt @@ -2883,7 +2883,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/pandatool/src/vrml/vrmlLexer.lxx b/pandatool/src/vrml/vrmlLexer.lxx index fb16b30c40..6b03b79894 100644 --- a/pandatool/src/vrml/vrmlLexer.lxx +++ b/pandatool/src/vrml/vrmlLexer.lxx @@ -159,7 +159,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/pandatool/src/xfile/xLexer.cxx.prebuilt b/pandatool/src/xfile/xLexer.cxx.prebuilt index b808f143ee..92eb941a15 100644 --- a/pandatool/src/xfile/xLexer.cxx.prebuilt +++ b/pandatool/src/xfile/xLexer.cxx.prebuilt @@ -794,7 +794,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } diff --git a/pandatool/src/xfile/xLexer.lxx b/pandatool/src/xfile/xLexer.lxx index c20ca309d2..7a5aac98a1 100644 --- a/pandatool/src/xfile/xLexer.lxx +++ b/pandatool/src/xfile/xLexer.lxx @@ -150,7 +150,7 @@ input_chars(char *buffer, int &result, int max_size) { // Define this macro carefully, since different flex versions call it // with a different type for result. #define YY_INPUT(buffer, result, max_size) { \ - int int_result; \ + int int_result = 0; \ input_chars((buffer), int_result, (max_size)); \ (result) = int_result; \ } From b0bbc66f06b1cc3dce3358865c2868193c6f184b Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 19 Jun 2018 00:35:04 +0200 Subject: [PATCH 029/360] bullet: document that sweep_test_closest is convex-only in API ref Closes #356 --- panda/src/bullet/bulletWorld.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index fce29fd2ba..38186101d6 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -947,7 +947,9 @@ ray_test_all(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMask & } /** - * + * Performs a sweep test against all other shapes that match the given group + * mask. The provided shape must be a convex shape; it is an error to invoke + * this method using a non-convex shape. */ BulletClosestHitSweepResult BulletWorld:: sweep_test_closest(BulletShape *shape, const TransformState &from_ts, const TransformState &to_ts, const CollideMask &mask, PN_stdfloat penetration) const { From 0367c73026bf41adcfe478417a75673651a41f80 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 22 Jun 2018 20:49:19 +0200 Subject: [PATCH 030/360] py_panda: fix leak of reference counted class with inaccessible dtor If a class inherits from ReferenceCount, it can be destructed by downcasting to ReferenceCount, so it should not be an obstacle to properly clean it up when such a class is returned from C++. This issue comes up when a CycleData is returned via MemoryUsagePointers, which is not exposed so is wrapped as NodeReferenceCount instead, which has a protected destructor. --- dtool/src/interrogatedb/py_panda.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 4025b965d5..258ff66484 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -158,6 +158,16 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ Py_TYPE(self)->tp_free(self);\ } +#define Define_Dtool_FreeInstanceRef_Private(CLASS_NAME,CNAME)\ +static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ + if (DtoolInstance_VOID_PTR(self) != nullptr) {\ + if (((Dtool_PyInstDef *)self)->_memory_rules) {\ + unref_delete((ReferenceCount *)(CNAME *)DtoolInstance_VOID_PTR(self));\ + }\ + }\ + Py_TYPE(self)->tp_free(self);\ +} + #define Define_Dtool_Simple_FreeInstance(CLASS_NAME, CNAME)\ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ ((Dtool_InstDef_##CLASS_NAME *)self)->_value.~##CLASS_NAME();\ @@ -292,7 +302,7 @@ Define_Dtool_Class(MODULE_NAME,CLASS_NAME,PUBLIC_NAME) #define Define_Module_ClassRef_Private(MODULE_NAME,CLASS_NAME,CNAME,PUBLIC_NAME)\ Define_Module_Class_Internal(MODULE_NAME,CLASS_NAME,CNAME)\ Define_Dtool_new(CLASS_NAME,CNAME)\ -Define_Dtool_FreeInstance_Private(CLASS_NAME,CNAME)\ +Define_Dtool_FreeInstanceRef_Private(CLASS_NAME,CNAME)\ Define_Dtool_Class(MODULE_NAME,CLASS_NAME,PUBLIC_NAME) #define Define_Module_ClassRef(MODULE_NAME,CLASS_NAME,CNAME,PUBLIC_NAME)\ From 582cc2991ede171667c30d6a15f62e6b775e00a9 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 22 Jun 2018 20:52:44 +0200 Subject: [PATCH 031/360] pipeline: add TypeHandle for CycleData if DO_PIPELINING is set This helps to identify CycleData when tracking memory usage via MemoryUsage. --- panda/src/pipeline/config_pipeline.cxx | 2 ++ panda/src/pipeline/cycleData.cxx | 3 +++ panda/src/pipeline/cycleData.h | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/panda/src/pipeline/config_pipeline.cxx b/panda/src/pipeline/config_pipeline.cxx index 8f82307c86..60f077688f 100644 --- a/panda/src/pipeline/config_pipeline.cxx +++ b/panda/src/pipeline/config_pipeline.cxx @@ -12,6 +12,7 @@ */ #include "config_pipeline.h" +#include "cycleData.h" #include "mainThread.h" #include "externalThread.h" #include "genericThread.h" @@ -70,6 +71,7 @@ init_libpipeline() { } initialized = true; + CycleData::init_type(); MainThread::init_type(); ExternalThread::init_type(); GenericThread::init_type(); diff --git a/panda/src/pipeline/cycleData.cxx b/panda/src/pipeline/cycleData.cxx index 62359cd451..346a6e8042 100644 --- a/panda/src/pipeline/cycleData.cxx +++ b/panda/src/pipeline/cycleData.cxx @@ -13,6 +13,9 @@ #include "cycleData.h" +#ifdef DO_PIPELINING +TypeHandle CycleData::_type_handle; +#endif /** * diff --git a/panda/src/pipeline/cycleData.h b/panda/src/pipeline/cycleData.h index bd28d4bc60..de90bdf226 100644 --- a/panda/src/pipeline/cycleData.h +++ b/panda/src/pipeline/cycleData.h @@ -65,6 +65,22 @@ public: virtual TypeHandle get_parent_type() const; virtual void output(std::ostream &out) const; + +#ifdef DO_PIPELINING +public: + static TypeHandle get_class_type() { + return _type_handle; + } + + static void init_type() { + NodeReferenceCount::init_type(); + register_type(_type_handle, "CycleData", + NodeReferenceCount::get_class_type()); + } + +private: + static TypeHandle _type_handle; +#endif }; INLINE std::ostream & From 927fcda8176fa5a21a79b410b26051a1ac56f46f Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 22 Jun 2018 20:53:56 +0200 Subject: [PATCH 032/360] shader: fix shader newline error with Intel drivers It appears that Intel drivers always need a newline at the end of the file. --- panda/src/gobj/shader.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 5914fd3598..31a8d986ed 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -2497,6 +2497,9 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { into.resize(into.size() - 1); } + // Except add back a newline at the end, which is needed by Intel drivers. + into += "\n"; + return true; } From 29a08932ea92bcf0e953994c524cafc1717930b5 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 22 Jun 2018 23:52:49 +0200 Subject: [PATCH 033/360] display: improve mouselook smoothness significantly, esp if low FPS This problem occurs when movePointer is used to reset the mouse back to the center every frame, a very common way to implement mouselook on Windows (which has no relative mouse mode). Any movement between the last event loop run and the call to movePointer is destroyed, resulting in quite choppy mouselook in most implementations. The solution is for getPointer to always return the latest mouse cursor position. This goes a long way but is not 100% perfect; see the discussion in #359 for other solutions. Fixes #359 --- panda/src/display/graphicsWindow.h | 2 +- panda/src/windisplay/winGraphicsWindow.cxx | 28 ++++++++++++++++++++ panda/src/windisplay/winGraphicsWindow.h | 1 + panda/src/x11display/x11GraphicsWindow.cxx | 30 ++++++++++++++++++++++ panda/src/x11display/x11GraphicsWindow.h | 1 + 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index e41dad65ba..c9c9900d3e 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -93,7 +93,7 @@ PUBLISHED: void enable_pointer_mode(int device, double speed); void disable_pointer_mode(int device); - MouseData get_pointer(int device) const; + virtual MouseData get_pointer(int device) const; virtual bool move_pointer(int device, int x, int y); virtual void close_ime(); diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index eee4a30365..4370621815 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -120,6 +120,34 @@ WinGraphicsWindow:: } } +/** + * Returns the MouseData associated with the nth input device's pointer. + */ +MouseData WinGraphicsWindow:: +get_pointer(int device) const { + MouseData result; + { + LightMutexHolder holder(_input_lock); + nassertr(device >= 0 && device < (int)_input_devices.size(), MouseData()); + + result = _input_devices[device].get_pointer(); + + // We recheck this immediately to get the most up-to-date value. + POINT cpos; + if (device == 0 && GetCursorPos(&cpos) && ScreenToClient(_hWnd, &cpos)) { + double time = ClockObject::get_global_clock()->get_real_time(); + RECT view_rect; + if (GetClientRect(_hWnd, &view_rect)) { + result._in_window = PtInRect(&view_rect, cpos); + result._xpos = cpos.x; + result._ypos = cpos.y; + ((GraphicsWindowInputDevice &)_input_devices[0]).set_pointer(result._in_window, result._xpos, result._ypos, time); + } + } + } + return result; +} + /** * Forces the pointer to the indicated position within the window, if * possible. diff --git a/panda/src/windisplay/winGraphicsWindow.h b/panda/src/windisplay/winGraphicsWindow.h index ffcbc79553..ff0340aa0d 100644 --- a/panda/src/windisplay/winGraphicsWindow.h +++ b/panda/src/windisplay/winGraphicsWindow.h @@ -72,6 +72,7 @@ public: GraphicsOutput *host); virtual ~WinGraphicsWindow(); + virtual MouseData get_pointer(int device) const; virtual bool move_pointer(int device, int x, int y); virtual void close_ime(); diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index af1e9de489..41fa95571d 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -143,6 +143,36 @@ x11GraphicsWindow:: } } +/** + * Returns the MouseData associated with the nth input device's pointer. This + * is deprecated; use get_pointer_device().get_pointer() instead, or for raw + * mice, use the InputDeviceManager interface. + */ +MouseData x11GraphicsWindow:: +get_pointer(int device) const { + MouseData result; + { + LightMutexHolder holder(_input_lock); + nassertr(device >= 0 && device < (int)_input_devices.size(), MouseData()); + + result = _input_devices[device].get_pointer(); + + // We recheck this immediately to get the most up-to-date value. + if (device == 0 && !_dga_mouse_enabled && result._in_window) { + XEvent event; + if (XQueryPointer(_display, _xwindow, &event.xbutton.root, + &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, + &event.xbutton.x, &event.xbutton.y, &event.xbutton.state)) { + double time = ClockObject::get_global_clock()->get_real_time(); + result._xpos = event.xbutton.x; + result._ypos = event.xbutton.y; + ((GraphicsWindowInputDevice &)_input_devices[0]).set_pointer(result._in_window, result._xpos, result._ypos, time); + } + } + } + return result; +} + /** * Forces the pointer to the indicated position within the window, if * possible. diff --git a/panda/src/x11display/x11GraphicsWindow.h b/panda/src/x11display/x11GraphicsWindow.h index 46b93225dd..078b016262 100644 --- a/panda/src/x11display/x11GraphicsWindow.h +++ b/panda/src/x11display/x11GraphicsWindow.h @@ -34,6 +34,7 @@ public: GraphicsOutput *host); virtual ~x11GraphicsWindow(); + virtual MouseData get_pointer(int device) const; virtual bool move_pointer(int device, int x, int y); virtual bool begin_frame(FrameMode mode, Thread *current_thread); virtual void end_frame(FrameMode mode, Thread *current_thread); From c18abad8c3373aff134dd02d099d476d094b0b69 Mon Sep 17 00:00:00 2001 From: David Carlsson Date: Tue, 12 Jun 2018 18:45:58 +0200 Subject: [PATCH 034/360] bullet: Interpolate BulletVehicle-wheel transform before syncing it to panda Bullet automatically interpolate most bodies for us (for example the "chassis" of a BulletVehicle), but BulletVehicle-wheels must be manually interpolated by calling 'updateWheelTransform()'. Otherwise they will slowly rubber-band between their intended position and a position one frame ahead in time. For more information see issue #250. --- panda/src/bullet/bulletVehicle.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/bullet/bulletVehicle.cxx b/panda/src/bullet/bulletVehicle.cxx index 5575d6ff22..5dbb70cc7f 100644 --- a/panda/src/bullet/bulletVehicle.cxx +++ b/panda/src/bullet/bulletVehicle.cxx @@ -232,6 +232,9 @@ void BulletVehicle:: do_sync_b2p() { for (int i=0; i < _vehicle->getNumWheels(); i++) { + // synchronize the wheels with the (interpolated) chassis worldtransform + _vehicle->updateWheelTransform(i, true); + btWheelInfo info = _vehicle->getWheelInfo(i); PandaNode *node = (PandaNode *)info.m_clientInfo; From 371e60c768cfd1a1383c5b05f1cab2078014ccea Mon Sep 17 00:00:00 2001 From: David Carlsson Date: Sat, 23 Jun 2018 00:02:10 +0200 Subject: [PATCH 035/360] bullet: Change the b2p sync-order to allow parenting BulletWheels to a BulletVehicle Parenting a BulletVehicle's wheels to the chassis-BulletRigidBodyNode now works as expected. Previously doing this would make the wheels appear to be positioned one frame ahead of the chassis, because the wheel's position were synced before the chassis' position. For more information see issue #250. Closes #349 --- panda/src/bullet/bulletWorld.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 38186101d6..e1e416a2bb 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -276,10 +276,6 @@ do_sync_p2b(PN_stdfloat dt, int num_substeps) { void BulletWorld:: do_sync_b2p() { - for (BulletVehicle *vehicle : _vehicles) { - vehicle->do_sync_b2p(); - } - for (BulletRigidBodyNode *body : _bodies) { body->do_sync_b2p(); } @@ -295,6 +291,10 @@ do_sync_b2p() { for (BulletBaseCharacterControllerNode *character : _characters) { character->do_sync_b2p(); } + + for (BulletVehicle *vehicle : _vehicles) { + vehicle->do_sync_b2p(); + } } /** From c03a75d755eb3aa79e2d6364b9d8e638d6ac5004 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jun 2018 17:18:14 +0200 Subject: [PATCH 036/360] interrogate: use range for in various places for code cleanliness --- .../interfaceMakerPythonNative.cxx | 199 +++++------------- 1 file changed, 53 insertions(+), 146 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 6a47257eda..7961286874 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -673,12 +673,7 @@ get_valid_child_classes(std::map &answer, CPPStructTyp return; } - CPPStructType::Derivation::const_iterator bi; - for (bi = inclass->_derivation.begin(); - bi != inclass->_derivation.end(); - ++bi) { - - const CPPStructType::Base &base = (*bi); + for (const CPPStructType::Base &base : inclass->_derivation) { // if (base._vis <= V_public) can_downcast = false; CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); if (base_type != nullptr) { @@ -801,11 +796,10 @@ write_prototypes(ostream &out_code, ostream *out_h) { } /* - for (fi = _functions.begin(); fi != _functions.end(); ++fi) - { - Function *func = (*fi); - if (!func->_itype.is_global() && is_function_legal(func)) - write_prototype_for (out_code, func); + for (Function *func : _functions) { + if (!func->_itype.is_global() && is_function_legal(func)) { + write_prototype_for(out_code, func); + } } */ @@ -828,8 +822,7 @@ write_prototypes(ostream &out_code, ostream *out_h) { out_code << " * Extern declarations for imported classes\n"; out_code << " */\n"; - for (std::set::iterator ii = _external_imports.begin(); ii != _external_imports.end(); ii++) { - CPPType *type = (*ii); + for (CPPType *type : _external_imports) { string class_name = type->get_local_name(&parser); string safe_name = make_safe_name(class_name); @@ -926,15 +919,13 @@ write_prototypes_class(ostream &out_code, ostream *out_h, Object *obj) { out_code << " */\n"; /* - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { - Function *func = (*fi); + for (Function *func : obj->_methods) { write_prototype_for(out_code, func); } */ /* - for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { - Function *func = (*fi); + for (Function *func : obj->_constructors) { std::string fname = "int Dtool_Init_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)"; write_prototype_for_name(out_code, obj, func, fname); } @@ -993,9 +984,6 @@ write_functions(ostream &out) { */ void InterfaceMakerPythonNative:: write_class_details(ostream &out, Object *obj) { - Functions::iterator fi; - Function::Remaps::const_iterator ri; - // std::string cClassName = obj->_itype.get_scoped_name(); std::string ClassName = make_safe_name(obj->_itype.get_scoped_name()); std::string cClassName = obj->_itype.get_true_name(); @@ -1005,8 +993,7 @@ write_class_details(ostream &out, Object *obj) { out << " */\n"; // First write out all the wrapper functions for the methods. - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { - Function *func = (*fi); + for (Function *func : obj->_methods) { if (func) { // Write the definition of the generic wrapper function for this // function. @@ -1015,18 +1002,13 @@ write_class_details(ostream &out, Object *obj) { } // Now write out generated getters and setters for the properties. - Properties::const_iterator pit; - for (pit = obj->_properties.begin(); pit != obj->_properties.end(); ++pit) { - Property *property = (*pit); - + for (Property *property : obj->_properties) { write_getset(out, obj, property); } // Write the constructors. std::string fname = "static int Dtool_Init_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)"; - for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { - Function *func = (*fi); - + for (Function *func : obj->_constructors) { string expected_params; write_function_for_name(out, obj, func->_remaps, fname, expected_params, true, AT_keyword_args, RF_int); } @@ -1052,17 +1034,16 @@ write_class_details(ostream &out, Object *obj) { } // Write make seqs: generated methods that return a sequence of items. - MakeSeqs::iterator msi; - for (msi = obj->_make_seqs.begin(); msi != obj->_make_seqs.end(); ++msi) { - if (is_function_legal((*msi)->_length_getter) && - is_function_legal((*msi)->_element_getter)) { - write_make_seq(out, obj, ClassName, cClassName, *msi); + for (MakeSeq *make_seq : obj->_make_seqs) { + if (is_function_legal(make_seq->_length_getter) && + is_function_legal(make_seq->_element_getter)) { + write_make_seq(out, obj, ClassName, cClassName, make_seq); } else { - if (!is_function_legal((*msi)->_length_getter)) { - std::cerr << "illegal length function for MAKE_SEQ: " << (*msi)->_length_getter->_name << "\n"; + if (!is_function_legal(make_seq->_length_getter)) { + std::cerr << "illegal length function for MAKE_SEQ: " << make_seq->_length_getter->_name << "\n"; } - if (!is_function_legal((*msi)->_element_getter)) { - std::cerr << "illegal element function for MAKE_SEQ: " << (*msi)->_element_getter->_name << "\n"; + if (!is_function_legal(make_seq->_element_getter)) { + std::cerr << "illegal element function for MAKE_SEQ: " << make_seq->_element_getter->_name << "\n"; } } } @@ -1297,11 +1278,11 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << "#ifndef LINK_ALL_STATIC\n"; out << " // Resolve externally imported types.\n"; - for (std::set::iterator ii = _external_imports.begin(); ii != _external_imports.end(); ++ii) { - string class_name = (*ii)->get_local_name(&parser); + for (CPPType *type : _external_imports) { + string class_name = type->get_local_name(&parser); string safe_name = make_safe_name(class_name); - if (has_get_class_type_function(*ii)) { + if (has_get_class_type_function(type)) { out << " Dtool_Ptr_" << safe_name << " = LookupRuntimeTypedClass(" << class_name << "::get_class_type());\n"; } else { out << " Dtool_Ptr_" << safe_name << " = LookupNamedClass(\"" << class_name << "\");\n"; @@ -1555,7 +1536,6 @@ write_module_class(ostream &out, Object *obj) { is_runtime_typed = true; } - Functions::iterator fi; out << "/**\n"; out << " * Python method tables for " << ClassName << " (" << export_class_name << ")\n" ; out << " */\n"; @@ -1566,8 +1546,7 @@ write_module_class(ostream &out, Object *obj) { bool got_copy = false; bool got_deepcopy = false; - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { - Function *func = (*fi); + for (Function *func : obj->_methods) { if (func->_name == "__copy__") { got_copy = true; } else if (func->_name == "__deepcopy__") { @@ -1604,9 +1583,7 @@ write_module_class(ostream &out, Object *obj) { bool has_nonslotted = false; - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { if (!is_remap_legal(remap)) { continue; } @@ -1698,9 +1675,7 @@ write_module_class(ostream &out, Object *obj) { out << " {\"__deepcopy__\", &map_deepcopy_to_copy, METH_VARARGS, nullptr},\n"; } - MakeSeqs::iterator msi; - for (msi = obj->_make_seqs.begin(); msi != obj->_make_seqs.end(); ++msi) { - MakeSeq *make_seq = (*msi); + for (MakeSeq *make_seq : obj->_make_seqs) { if (!is_function_legal(make_seq->_length_getter) || !is_function_legal(make_seq->_element_getter)) { continue; @@ -1876,10 +1851,7 @@ write_module_class(ostream &out, Object *obj) { // This function handles both delattr and setattr. Fish out the // remaps for both types. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); - + for (FunctionRemap *remap : def._remaps) { if (remap->_cppfunc->get_simple_name() == "__delattr__" && remap->_parameters.size() == 2) { delattr_remaps.insert(remap); @@ -2029,10 +2001,7 @@ write_module_class(ostream &out, Object *obj) { // This function handles both delitem and setitem. Fish out the // remaps for either one. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); - + for (FunctionRemap *remap : def._remaps) { if (remap->_flags & FunctionRemap::F_setitem_int) { setitem_remaps.insert(remap); @@ -2098,10 +2067,7 @@ write_module_class(ostream &out, Object *obj) { // This function handles both delitem and setitem. Fish out the // remaps for either one. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); - + for (FunctionRemap *remap : def._remaps) { if (remap->_flags & FunctionRemap::F_setitem) { setitem_remaps.insert(remap); @@ -2185,9 +2151,7 @@ write_module_class(ostream &out, Object *obj) { // Iterate through the remaps to find the one that matches our // parameters. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : def._remaps) { if (remap->_const_method) { if ((remap->_flags & FunctionRemap::F_explicit_self) == 0) { params_const.push_back("self"); @@ -2254,9 +2218,7 @@ write_module_class(ostream &out, Object *obj) { // Iterate through the remaps to find the one that matches our // parameters. - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : def._remaps) { if (remap->_const_method) { if ((remap->_flags & FunctionRemap::F_explicit_self) == 0) { params_const.push_back("self"); @@ -2340,10 +2302,7 @@ write_module_class(ostream &out, Object *obj) { set one_param_remaps; set two_param_remaps; - set::const_iterator ri; - for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); - + for (FunctionRemap *remap : def._remaps) { if (remap->_parameters.size() == 2) { one_param_remaps.insert(remap); @@ -2537,17 +2496,14 @@ write_module_class(ostream &out, Object *obj) { out << " return nullptr;\n"; out << " }\n\n"; - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { + for (Function *func : obj->_methods) { std::set remaps; - Function *func = (*fi); if (!func) { continue; } // We only accept comparison operators that take one parameter (besides // 'this'). - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { if (is_remap_legal(remap) && remap->_has_this && (remap->_args_type == AT_single_arg)) { remaps.insert(remap); } @@ -2634,9 +2590,7 @@ write_module_class(ostream &out, Object *obj) { if (obj->_properties.size() > 0) { // Write out the array of properties, telling Python which getter and // setter to call when they are assigned or queried in Python code. - Properties::const_iterator pit; - for (pit = obj->_properties.begin(); pit != obj->_properties.end(); ++pit) { - Property *property = (*pit); + for (Property *property : obj->_properties) { const InterrogateElement &ielem = property->_ielement; if (!property->_has_this || property->_getter_remaps.empty()) { continue; @@ -3060,10 +3014,10 @@ write_module_class(ostream &out, Object *obj) { out << " // Dependent objects\n"; if (bases.size() > 0) { string baseargs; - for (std::vector::iterator bi = bases.begin(); bi != bases.end(); ++bi) { - string safe_name = make_safe_name((*bi)->get_local_name(&parser)); + for (CPPType *base : bases) { + string safe_name = make_safe_name(base->get_local_name(&parser)); - if (isExportThisRun(*bi)) { + if (isExportThisRun(base)) { baseargs += ", (PyTypeObject *)&Dtool_" + safe_name; out << " Dtool_PyModuleClassInit_" << safe_name << "(nullptr);\n"; @@ -3207,9 +3161,7 @@ write_module_class(ostream &out, Object *obj) { } // Also add the static properties, which can't be added via getset. - Properties::const_iterator pit; - for (pit = obj->_properties.begin(); pit != obj->_properties.end(); ++pit) { - Property *property = (*pit); + for (Property *property : obj->_properties) { const InterrogateElement &ielem = property->_ielement; if (property->_has_this || property->_getter_remaps.empty()) { continue; @@ -3354,9 +3306,7 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker // should even write it. bool has_remaps = false; - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { if (!is_remap_legal(remap)) { continue; } @@ -3805,18 +3755,12 @@ void InterfaceMakerPythonNative:: write_coerce_constructor(ostream &out, Object *obj, bool is_const) { std::map > map_sets; std::map >::iterator mii; - std::set::iterator sii; int max_required_args = 0; - Functions::iterator fi; - Function::Remaps::const_iterator ri; - // Go through the methods and find appropriate static make() functions. - for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { - Function *func = (*fi); - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (Function *func : obj->_methods) { + for (FunctionRemap *remap : func->_remaps) { if (is_remap_legal(remap) && remap->_flags & FunctionRemap::F_coerce_constructor) { nassertd(!remap->_has_this) continue; @@ -3850,10 +3794,8 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { // Now go through the constructors that are suitable for coercion. This // excludes copy constructors and ones marked "explicit". - for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { - Function *func = (*fi); - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (Function *func : obj->_constructors) { + for (FunctionRemap *remap : func->_remaps) { if (is_remap_legal(remap) && remap->_flags & FunctionRemap::F_coerce_constructor) { nassertd(!remap->_has_this) continue; @@ -6504,11 +6446,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the getters that take one integral argument. - Function::Remaps::iterator it; - for (it = property->_getter_remaps.begin(); - it != property->_getter_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_getter_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 1 && max_num_args >= 1 && @@ -6573,11 +6511,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the setters that take two arguments. - Function::Remaps::iterator it; - for (it = property->_setter_remaps.begin(); - it != property->_setter_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_setter_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 2 && max_num_args >= 2 && @@ -6675,11 +6609,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the getters that take one argument. Fish out the ones // already taken by the sequence getter. - Function::Remaps::iterator it; - for (it = property->_getter_remaps.begin(); - it != property->_getter_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_getter_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 1 && max_num_args >= 1 && @@ -6808,11 +6738,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the getters that take one integral argument. - Function::Remaps::iterator it; - for (it = property->_getkey_function->_remaps.begin(); - it != property->_getkey_function->_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_getkey_function->_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 1 && max_num_args >= 1 && @@ -6969,11 +6895,7 @@ write_getset(ostream &out, Object *obj, Property *property) { std::set remaps; // Extract only the setters that take one argument. - Function::Remaps::iterator it; - for (it = property->_setter_remaps.begin(); - it != property->_setter_remaps.end(); - ++it) { - FunctionRemap *remap = *it; + for (FunctionRemap *remap : property->_setter_remaps) { int min_num_args = remap->get_min_num_args(); int max_num_args = remap->get_max_num_args(); if (min_num_args <= 1 && max_num_args >= 1) { @@ -7362,9 +7284,7 @@ isExportThisRun(Function *func) { return false; } - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end();) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { return isExportThisRun(remap->_cpptype); } @@ -7439,10 +7359,7 @@ has_coerce_constructor(CPPStructType *type) { CPPScope::Functions::iterator fgi; for (fgi = scope->_functions.begin(); fgi != scope->_functions.end(); ++fgi) { CPPFunctionGroup *fgroup = fgi->second; - - CPPFunctionGroup::Instances::iterator ii; - for (ii = fgroup->_instances.begin(); ii != fgroup->_instances.end(); ++ii) { - CPPInstance *inst = (*ii); + for (CPPInstance *inst : fgroup->_instances) { CPPFunctionType *ftype = inst->_type->as_function_type(); if (ftype == nullptr) { continue; @@ -7527,9 +7444,7 @@ is_remap_coercion_possible(FunctionRemap *remap) { */ bool InterfaceMakerPythonNative:: is_function_legal(Function *func) { - Function::Remaps::const_iterator ri; - for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { - FunctionRemap *remap = (*ri); + for (FunctionRemap *remap : func->_remaps) { if (is_remap_legal(remap)) { // printf(" Function Is Marked Legal %s\n",func->_name.c_str()); @@ -7575,13 +7490,7 @@ DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { return true; } - CPPStructType::Derivation::const_iterator bi; - for (bi = inclass->_derivation.begin(); - bi != inclass->_derivation.end(); - ++bi) { - - const CPPStructType::Base &base = (*bi); - + for (const CPPStructType::Base &base : inclass->_derivation) { CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); if (base_type != nullptr) { if (DoesInheritFromIsClass(base_type, name)) { @@ -7632,9 +7541,7 @@ has_init_type_function(CPPType *type) { } const CPPFunctionGroup *group = it->second; - CPPFunctionGroup::Instances::const_iterator ii; - for (ii = group->_instances.begin(); ii != group->_instances.end(); ++ii) { - const CPPInstance *cppinst = *ii; + for (const CPPInstance *cppinst : group->_instances) { const CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); if (cppfunc != nullptr && From 94cbdc563b0ddf802e7b3ba0ed6578c4c6d0316b Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jun 2018 17:19:23 +0200 Subject: [PATCH 037/360] general: fix a few more compiler warnings --- panda/src/glstuff/glCgShaderContext_src.cxx | 2 +- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 4 +++- panda/src/x11display/x11GraphicsWindow.cxx | 4 +--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 353c68dc46..c7ba6ad3e7 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -525,7 +525,7 @@ issue_parameters(int altered) { } // Check if the size of the shader input and ptr_data match - int input_size = spec._dim[0] * spec._dim[1] * spec._dim[2]; + size_t input_size = spec._dim[0] * spec._dim[1] * spec._dim[2]; // dimension is negative only if the parameter had the (deprecated)k_ // prefix. diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 6958c4ff9a..cde43352bc 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -11610,17 +11610,18 @@ do_issue_tex_gen() { // effectively define an identity matrix that maps the spatial coordinates // one-for-one to UV's. If you want a mapping other than identity, use a // TexMatrixAttrib (or a TexProjectorEffect). +#ifndef OPENGLES static const PN_stdfloat s_data[4] = { 1, 0, 0, 0 }; static const PN_stdfloat t_data[4] = { 0, 1, 0, 0 }; static const PN_stdfloat r_data[4] = { 0, 0, 1, 0 }; static const PN_stdfloat q_data[4] = { 0, 0, 0, 1 }; +#endif _tex_gen_modifies_mat = false; bool got_point_sprites = false; for (int i = 0; i < _num_active_texture_stages; i++) { - TextureStage *stage = _target_texture->get_on_ff_stage(i); set_active_texture_stage(i); if (_supports_point_sprite) { #ifdef OPENGLES @@ -11636,6 +11637,7 @@ do_issue_tex_gen() { glDisable(GL_TEXTURE_GEN_R); glDisable(GL_TEXTURE_GEN_Q); + TextureStage *stage = _target_texture->get_on_ff_stage(i); TexGenAttrib::Mode mode = _target_tex_gen->get_mode(stage); switch (mode) { case TexGenAttrib::M_off: diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 41fa95571d..5eef6b2ea5 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -1382,9 +1382,7 @@ open_raw_mice() { void x11GraphicsWindow:: poll_raw_mice() { #ifdef PHAVE_LINUX_INPUT_H - for (int di = 0; di < _mouse_device_info.size(); ++di) { - MouseDeviceInfo &inf = _mouse_device_info[di]; - + for (MouseDeviceInfo &inf : _mouse_device_info) { // Read all bytes into buffer. if (inf._fd >= 0) { while (1) { From b2c04a8c7acde07c76fad045db75a7eb975c12d2 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jun 2018 17:33:09 +0200 Subject: [PATCH 038/360] interrogate: support scoped enum args and return values --- .../interfaceMakerPythonNative.cxx | 86 +++++++++++++++++-- dtool/src/interrogate/typeManager.cxx | 20 +++++ dtool/src/interrogate/typeManager.h | 1 + dtool/src/interrogatedb/py_panda.I | 14 +++ dtool/src/interrogatedb/py_panda.cxx | 5 +- dtool/src/interrogatedb/py_panda.h | 6 +- 6 files changed, 121 insertions(+), 11 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 7961286874..6f300eed03 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -815,6 +815,11 @@ write_prototypes(ostream &out_code, ostream *out_h) { // _external_imports.insert(object->_itype._cpptype); } } + } else if (object->_itype.is_scoped_enum() && isExportThisRun(object->_itype._cpptype)) { + // Forward declare where we will put the scoped enum type. + string class_name = object->_itype._cpptype->get_local_name(&parser); + string safe_name = make_safe_name(class_name); + out_code << "static PyTypeObject *Dtool_Ptr_" << safe_name << " = nullptr;\n"; } } @@ -1301,7 +1306,10 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { int enum_count = object->_itype.number_of_enum_values(); if (object->_itype.is_scoped_enum()) { - // Convert as Python 3.4 enum. + // Convert as Python 3.4-style enum. + string class_name = object->_itype._cpptype->get_local_name(&parser); + string safe_name = make_safe_name(class_name); + CPPType *underlying_type = TypeManager::unwrap_const(object->_itype._cpptype->as_enum_type()->get_underlying_type()); string cast_to = underlying_type->get_local_name(&parser); out << "#if PY_VERSION_HEX >= 0x03040000\n\n"; @@ -1318,9 +1326,11 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { << object->_itype.get_enum_value_name(xx) << "));\n" " PyTuple_SET_ITEM(members, " << xx << ", member);\n"; } + out << " Dtool_Ptr_" << safe_name << " = Dtool_EnumType_Create(\"" + << object->_itype.get_name() << "\", members, \"" + << _def->module_name << "\");\n"; out << " PyModule_AddObject(module, \"" << object->_itype.get_name() - << "\", Dtool_EnumType_Create(\"" << object->_itype.get_name() - << "\", members, \"" << _def->module_name << "\"));\n"; + << "\", (PyObject *)Dtool_Ptr_" << safe_name << ");\n"; out << " }\n"; out << "#endif\n"; } else { @@ -3112,7 +3122,10 @@ write_module_class(ostream &out, Object *obj) { // support recently. } else if (nested_obj->_itype.is_scoped_enum()) { - // Convert enum class as Python 3.4 enum. + // Convert enum class as Python 3.4-style enum. + string class_name = nested_obj->_itype._cpptype->get_local_name(&parser); + string safe_name = make_safe_name(class_name); + int enum_count = nested_obj->_itype.number_of_enum_values(); CPPType *underlying_type = TypeManager::unwrap_const(nested_obj->_itype._cpptype->as_enum_type()->get_underlying_type()); string cast_to = underlying_type->get_local_name(&parser); @@ -3130,9 +3143,11 @@ write_module_class(ostream &out, Object *obj) { << nested_obj->_itype.get_enum_value_name(xx) << "));\n" " PyTuple_SET_ITEM(members, " << xx << ", member);\n"; } + out << " Dtool_Ptr_" << safe_name << " = Dtool_EnumType_Create(\"" + << nested_obj->_itype.get_name() << "\", members, \"" + << _def->module_name << "\");\n"; out << " PyDict_SetItemString(dict, \"" << nested_obj->_itype.get_name() - << "\", Dtool_EnumType_Create(\"" << nested_obj->_itype.get_name() - << "\", members, \"" << _def->module_name << "\"));\n"; + << "\", (PyObject *)Dtool_Ptr_" << safe_name << ");\n"; out << " }\n"; out << "#endif\n"; @@ -4821,6 +4836,46 @@ write_function_instance(ostream &out, FunctionRemap *remap, clear_error = true; only_pyobjects = false; + } else if (TypeManager::is_scoped_enum(type)) { + if (args_type == AT_single_arg) { + param_name = "arg"; + } else { + indent(out, indent_level) << "PyObject *" << param_name; + if (default_value != nullptr) { + out << " = nullptr"; + } + out << ";\n"; + format_specifiers += "O"; + parameter_list += ", &" + param_name; + } + + CPPEnumType *enum_type = (CPPEnumType *)TypeManager::unwrap(type); + CPPType *underlying_type = enum_type->get_underlying_type(); + underlying_type = TypeManager::unwrap_const(underlying_type); + + //indent(out, indent_level); + //underlying_type->output_instance(out, param_name + "_val", &parser); + //out << default_expr << ";\n"; + extra_convert << "long " << param_name << "_val"; + + if (default_value != nullptr) { + extra_convert << " = (long)"; + default_value->output(extra_convert, 0, &parser, false); + extra_convert << + ";\nif (" << param_name << " != nullptr) {\n" + " " << param_name << "_val = Dtool_EnumValue_AsLong(" + param_name + ");\n" + "}"; + } else { + extra_convert + << ";\n" + << param_name << "_val = Dtool_EnumValue_AsLong(" + param_name + ");\n"; + } + + pexpr_string = "(" + enum_type->get_local_name(&parser) + ")" + param_name + "_val"; + expected_params += classNameFromCppName(enum_type->get_simple_name(), false); + extra_param_check << " && " << param_name << "_val != -1"; + clear_error = true; + } else if (TypeManager::is_bool(type)) { if (args_type == AT_single_arg) { param_name = "arg"; @@ -6220,7 +6275,24 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, CPPType *orig_type = return_type->get_orig_type(); CPPType *type = return_type->get_new_type(); - if (return_type->new_type_is_atomic_string() || + if (TypeManager::is_scoped_enum(type)) { + InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); + TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)), false); + const InterrogateType &itype = idb->get_type(type_index); + string safe_name = make_safe_name(itype.get_scoped_name()); + + indent(out, indent_level) + << "return PyObject_CallFunction((PyObject *)Dtool_Ptr_" << safe_name; + + CPPType *underlying_type = ((CPPEnumType *)itype._cpptype)->get_underlying_type(); + if (TypeManager::is_unsigned_integer(underlying_type)) { + out << ", \"k\", (unsigned long)"; + } else { + out << ", \"l\", (long)"; + } + out << "(" << return_expr << "));\n"; + + } else if (return_type->new_type_is_atomic_string() || TypeManager::is_simple(type) || TypeManager::is_char_pointer(type) || TypeManager::is_wchar_pointer(type) || diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index b7b744aa86..f12541111d 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -310,6 +310,26 @@ is_struct(CPPType *type) { } } +/** + * Returns true if the indicated type is an enum class, const or otherwise. + */ +bool TypeManager:: +is_scoped_enum(CPPType *type) { + switch (type->get_subtype()) { + case CPPDeclaration::ST_enum: + return ((CPPEnumType *)type)->is_scoped(); + + case CPPDeclaration::ST_const: + return is_scoped_enum(type->as_const_type()->_wrapped_around); + + case CPPDeclaration::ST_typedef: + return is_scoped_enum(type->as_typedef_type()->_type); + + default: + return false; + } +} + /** * Returns true if the indicated type is some kind of enumerated type, const * or otherwise. diff --git a/dtool/src/interrogate/typeManager.h b/dtool/src/interrogate/typeManager.h index d507e947ef..db831cdafc 100644 --- a/dtool/src/interrogate/typeManager.h +++ b/dtool/src/interrogate/typeManager.h @@ -52,6 +52,7 @@ public: static bool is_pointer(CPPType *type); static bool is_const(CPPType *type); static bool is_struct(CPPType *type); + static bool is_scoped_enum(CPPType *type); static bool is_enum(CPPType *type); static bool is_const_enum(CPPType *type); static bool is_const_ref_to_enum(CPPType *type); diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index 540e9ee58d..69f8961463 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -97,6 +97,20 @@ INLINE PyObject *DtoolInstance_RichComparePointers(PyObject *v1, PyObject *v2, i Py_RETURN_RICHCOMPARE(cmpval, 0, op); } +/** + * Converts the enum value to a C long. + */ +INLINE long Dtool_EnumValue_AsLong(PyObject *value) { + PyObject *val = PyObject_GetAttrString(value, "value"); + if (val != nullptr) { + long as_long = PyLongOrInt_AS_LONG(val); + Py_DECREF(val); + return as_long; + } else { + return -1; + } +} + /** * These functions wrap a pointer for a class that defines get_type_handle(). */ diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 7e867aacad..9e7563036d 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -309,7 +309,7 @@ PyObject *_Dtool_Return(PyObject *value) { /** * Creates a Python 3.4-style enum type. Steals reference to 'names'. */ -PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *module) { +PyTypeObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *module) { static PyObject *enum_class = nullptr; static PyObject *enum_meta = nullptr; static PyObject *enum_create = nullptr; @@ -330,7 +330,8 @@ PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *m PyObject_SetAttrString(result, "__module__", modstr); Py_DECREF(modstr); } - return result; + nassertr(PyType_Check(result), nullptr); + return (PyTypeObject *)result; } /** diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 258ff66484..7916147e4d 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -258,8 +258,10 @@ EXPCL_INTERROGATEDB PyObject *_Dtool_Return(PyObject *value); /** * Wrapper around Python 3.4's enum library, which does not have a C API. */ -EXPCL_INTERROGATEDB PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, - const char *module = nullptr); +EXPCL_INTERROGATEDB PyTypeObject *Dtool_EnumType_Create(const char *name, PyObject *names, + const char *module = nullptr); +EXPCL_INTERROGATEDB INLINE long Dtool_EnumValue_AsLong(PyObject *value); + /** From e191ee84f4075bfe103b67bef9b763a2ad1f1a2e Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jun 2018 17:34:20 +0200 Subject: [PATCH 039/360] cppparser: class is not implicitly copyable if it has a move ctor --- dtool/src/cppparser/cppStructType.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dtool/src/cppparser/cppStructType.cxx b/dtool/src/cppparser/cppStructType.cxx index aba4bdbb60..d0707c4404 100644 --- a/dtool/src/cppparser/cppStructType.cxx +++ b/dtool/src/cppparser/cppStructType.cxx @@ -545,6 +545,13 @@ is_copy_constructible(CPPVisibility min_vis) const { return true; } + if (get_move_constructor() != nullptr || + get_move_assignment_operator() != nullptr) { + // A user-declared move constructor or move assignment operator means that + // the implicitly-declared copy constructor is deleted. + return false; + } + CPPInstance *destructor = get_destructor(); if (destructor != nullptr) { if (destructor->_vis > min_vis) { From 9441c28f61f622dbc7db9bc662914cc7d984e31e Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jun 2018 17:34:54 +0200 Subject: [PATCH 040/360] interrogate: do not wrap methods with rvalue arguments This could in theory be supported, but this is not really intuitive from a Python user's point of view. --- .../interfaceMakerPythonNative.cxx | 4 ++++ dtool/src/interrogate/typeManager.cxx | 20 +++++++++++++++++++ dtool/src/interrogate/typeManager.h | 1 + 3 files changed, 25 insertions(+) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 6f300eed03..c3611fb4df 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -7298,6 +7298,10 @@ is_cpp_type_legal(CPPType *in_ctype) { // bool answer = false; CPPType *type = TypeManager::resolve_type(in_ctype); + if (TypeManager::is_rvalue_reference(type)) { + return false; + } + type = TypeManager::unwrap(type); if (TypeManager::is_void(type)) { diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index f12541111d..ab1fbffce3 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -124,6 +124,26 @@ is_reference(CPPType *type) { } } +/** + * Returns true if the indicated type is some kind of an rvalue reference. + */ +bool TypeManager:: +is_rvalue_reference(CPPType *type) { + switch (type->get_subtype()) { + case CPPDeclaration::ST_const: + return is_rvalue_reference(type->as_const_type()->_wrapped_around); + + case CPPDeclaration::ST_reference: + return type->as_reference_type()->_value_category == CPPReferenceType::VC_rvalue; + + case CPPDeclaration::ST_typedef: + return is_rvalue_reference(type->as_typedef_type()->_type); + + default: + return false; + } +} + /** * Returns true if the indicated type is some kind of a reference or const * reference type at all, false otherwise. diff --git a/dtool/src/interrogate/typeManager.h b/dtool/src/interrogate/typeManager.h index db831cdafc..f1aa2908b1 100644 --- a/dtool/src/interrogate/typeManager.h +++ b/dtool/src/interrogate/typeManager.h @@ -44,6 +44,7 @@ public: static bool is_assignable(CPPType *type); static bool is_reference(CPPType *type); + static bool is_rvalue_reference(CPPType *type); static bool is_ref_to_anything(CPPType *type); static bool is_const_ref_to_anything(CPPType *type); static bool is_const_pointer_to_anything(CPPType *type); From f5a78d599d0ad93dffd53ba8809774cc887fe145 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 30 Jun 2018 17:36:08 +0200 Subject: [PATCH 041/360] putil: make LinkedListNode moveable --- panda/src/putil/linkedListNode.I | 36 ++++++++++++++++++++++++++++++++ panda/src/putil/linkedListNode.h | 3 +++ 2 files changed, 39 insertions(+) diff --git a/panda/src/putil/linkedListNode.I b/panda/src/putil/linkedListNode.I index faed3b5c96..a61aaa854c 100644 --- a/panda/src/putil/linkedListNode.I +++ b/panda/src/putil/linkedListNode.I @@ -33,6 +33,25 @@ LinkedListNode(bool) { _prev = this; } +/** + * This move constructor replaces the other link with this one. + */ +INLINE LinkedListNode:: +LinkedListNode(LinkedListNode &&from) noexcept { + if (from._prev != nullptr) { + nassertv(from._prev->_next == &from); + from._prev->_next = this; + } + _prev = from._prev; + if (from._next != nullptr) { + nassertv(from._next->_prev == &from); + from._next->_prev = this; + } + _next = from._next; + from._next = nullptr; + from._prev = nullptr; +} + /** * */ @@ -41,6 +60,23 @@ INLINE LinkedListNode:: nassertv((_next == nullptr && _prev == nullptr) || (_next == this && _prev == this)); } +/** + * Replaces the given other node with this node. + */ +INLINE LinkedListNode &LinkedListNode:: +operator = (LinkedListNode &&from) { + nassertr((_next == nullptr && _prev == nullptr) || (_next == this && _prev == this), *this); + nassertr(from._prev != nullptr && from._next != nullptr, *this); + nassertr(from._prev->_next == &from && from._next->_prev == &from, *this); + from._prev->_next = this; + from._next->_prev = this; + _prev = from._prev; + _next = from._next; + from._next = nullptr; + from._prev = nullptr; + return *this; +} + /** * Returns true if the node is member of any list, false if it has been * removed or never added. The head of a list generally appears to to always diff --git a/panda/src/putil/linkedListNode.h b/panda/src/putil/linkedListNode.h index 9dedbe9e4d..5f8e6f1909 100644 --- a/panda/src/putil/linkedListNode.h +++ b/panda/src/putil/linkedListNode.h @@ -32,8 +32,11 @@ class EXPCL_PANDA_PUTIL LinkedListNode { protected: INLINE LinkedListNode(); INLINE LinkedListNode(bool); + INLINE LinkedListNode(LinkedListNode &&from) noexcept; INLINE ~LinkedListNode(); + INLINE LinkedListNode &operator = (LinkedListNode &&from); + INLINE bool is_on_list() const; INLINE void remove_from_list(); INLINE void insert_before(LinkedListNode *node); From cce21a5bee05b76a52fb4f5b7b13cdedca531e2c Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 2 Jul 2018 11:54:27 +0200 Subject: [PATCH 042/360] Add .pytest_cache/ directory to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f99867f73a..0b40b42f79 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ __pycache__/ # Test tool cache directories .tox/ .cache/ +.pytest_cache/ From 68e7f681f48e91451d5d42862340a17e74cf9e71 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 2 Jul 2018 12:16:35 +0200 Subject: [PATCH 043/360] interrogate: support enum class to limited extent in Python 2 Only the basics are supported; the __members__ or iter interface is not supported at this time. See also #351 for discussion on pulling in enum34 module. --- .../interfaceMakerPythonNative.cxx | 22 +++-- dtool/src/interrogatedb/py_panda.cxx | 86 ++++++++++++++++++- dtool/src/pystub/pystub.cxx | 2 + 3 files changed, 101 insertions(+), 9 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index c3611fb4df..3134fcb2eb 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -1312,15 +1312,19 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { CPPType *underlying_type = TypeManager::unwrap_const(object->_itype._cpptype->as_enum_type()->get_underlying_type()); string cast_to = underlying_type->get_local_name(&parser); - out << "#if PY_VERSION_HEX >= 0x03040000\n\n"; out << " // enum class " << object->_itype.get_scoped_name() << "\n"; out << " {\n"; out << " PyObject *members = PyTuple_New(" << enum_count << ");\n"; out << " PyObject *member;\n"; for (int xx = 0; xx < enum_count; xx++) { out << " member = PyTuple_New(2);\n" - " PyTuple_SET_ITEM(member, 0, PyUnicode_FromString(\"" + "#if PY_MAJOR_VERSION >= 3\n" + " PyTuple_SET_ITEM(member, 0, PyUnicode_FromString(\"" << object->_itype.get_enum_value_name(xx) << "\"));\n" + "#else\n" + " PyTuple_SET_ITEM(member, 0, PyString_FromString(\"" + << object->_itype.get_enum_value_name(xx) << "\"));\n" + "#endif\n" " PyTuple_SET_ITEM(member, 1, Dtool_WrapValue((" << cast_to << ")" << object->_itype.get_scoped_name() << "::" << object->_itype.get_enum_value_name(xx) << "));\n" @@ -1332,7 +1336,6 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << " PyModule_AddObject(module, \"" << object->_itype.get_name() << "\", (PyObject *)Dtool_Ptr_" << safe_name << ");\n"; out << " }\n"; - out << "#endif\n"; } else { out << " // enum " << object->_itype.get_scoped_name() << "\n"; for (int xx = 0; xx < enum_count; xx++) { @@ -3129,27 +3132,30 @@ write_module_class(ostream &out, Object *obj) { int enum_count = nested_obj->_itype.number_of_enum_values(); CPPType *underlying_type = TypeManager::unwrap_const(nested_obj->_itype._cpptype->as_enum_type()->get_underlying_type()); string cast_to = underlying_type->get_local_name(&parser); - out << "#if PY_VERSION_HEX >= 0x03040000\n\n"; out << " // enum class " << nested_obj->_itype.get_scoped_name() << ";\n"; out << " {\n"; out << " PyObject *members = PyTuple_New(" << enum_count << ");\n"; out << " PyObject *member;\n"; for (int xx = 0; xx < enum_count; xx++) { out << " member = PyTuple_New(2);\n" + "#if PY_MAJOR_VERSION >= 3\n" " PyTuple_SET_ITEM(member, 0, PyUnicode_FromString(\"" << nested_obj->_itype.get_enum_value_name(xx) << "\"));\n" + "#else\n" + " PyTuple_SET_ITEM(member, 0, PyString_FromString(\"" + << nested_obj->_itype.get_enum_value_name(xx) << "\"));\n" + "#endif\n" " PyTuple_SET_ITEM(member, 1, Dtool_WrapValue((" << cast_to << ")" << nested_obj->_itype.get_scoped_name() << "::" << nested_obj->_itype.get_enum_value_name(xx) << "));\n" " PyTuple_SET_ITEM(members, " << xx << ", member);\n"; } - out << " Dtool_Ptr_" << safe_name << " = Dtool_EnumType_Create(\"" - << nested_obj->_itype.get_name() << "\", members, \"" - << _def->module_name << "\");\n"; + out << " Dtool_Ptr_" << safe_name << " = Dtool_EnumType_Create(\"" + << nested_obj->_itype.get_name() << "\", members, \"" + << _def->module_name << "\");\n"; out << " PyDict_SetItemString(dict, \"" << nested_obj->_itype.get_name() << "\", (PyObject *)Dtool_Ptr_" << safe_name << ");\n"; out << " }\n"; - out << "#endif\n"; } else if (nested_obj->_itype.is_enum()) { out << " // enum " << nested_obj->_itype.get_scoped_name() << ";\n"; diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 9e7563036d..e900ab0e7f 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -306,11 +306,39 @@ PyObject *_Dtool_Return(PyObject *value) { return value; } +#if PY_VERSION_HEX < 0x03040000 +static PyObject *Dtool_EnumType_Str(PyObject *self) { + PyObject *name = PyObject_GetAttrString(self, "name"); +#if PY_MAJOR_VERSION >= 3 + PyObject *repr = PyUnicode_FromFormat("%s.%s", Py_TYPE(self)->tp_name, PyString_AS_STRING(name)); +#else + PyObject *repr = PyString_FromFormat("%s.%s", Py_TYPE(self)->tp_name, PyString_AS_STRING(name)); +#endif + Py_DECREF(name); + return repr; +} + +static PyObject *Dtool_EnumType_Repr(PyObject *self) { + PyObject *name = PyObject_GetAttrString(self, "name"); + PyObject *value = PyObject_GetAttrString(self, "value"); +#if PY_MAJOR_VERSION >= 3 + PyObject *repr = PyUnicode_FromFormat("<%s.%s: %ld>", Py_TYPE(self)->tp_name, PyString_AS_STRING(name), PyLongOrInt_AS_LONG(value)); +#else + PyObject *repr = PyString_FromFormat("<%s.%s: %ld>", Py_TYPE(self)->tp_name, PyString_AS_STRING(name), PyLongOrInt_AS_LONG(value)); +#endif + Py_DECREF(name); + Py_DECREF(value); + return repr; +} +#endif + /** - * Creates a Python 3.4-style enum type. Steals reference to 'names'. + * Creates a Python 3.4-style enum type. Steals reference to 'names', which + * should be a tuple of (name, value) pairs. */ PyTypeObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *module) { static PyObject *enum_class = nullptr; +#if PY_VERSION_HEX >= 0x03040000 static PyObject *enum_meta = nullptr; static PyObject *enum_create = nullptr; if (enum_meta == nullptr) { @@ -325,6 +353,62 @@ PyTypeObject *Dtool_EnumType_Create(const char *name, PyObject *names, const cha PyObject *result = PyObject_CallFunction(enum_create, (char *)"OsN", enum_class, name, names); nassertr(result != nullptr, nullptr); +#else + static PyObject *name_str; + static PyObject *name_sunder_str; + static PyObject *value_str; + static PyObject *value_sunder_str; + // Emulate something vaguely like the enum module. + if (enum_class == nullptr) { +#if PY_MAJOR_VERSION >= 3 + name_str = PyUnicode_InternFromString("name"); + value_str = PyUnicode_InternFromString("value"); + name_sunder_str = PyUnicode_InternFromString("_name_"); + value_sunder_str = PyUnicode_InternFromString("_value_"); +#else + name_str = PyString_InternFromString("name"); + value_str = PyString_InternFromString("value"); + name_sunder_str = PyString_InternFromString("_name_"); + value_sunder_str = PyString_InternFromString("_value_"); +#endif + PyObject *name_value_tuple = PyTuple_New(4); + PyTuple_SET_ITEM(name_value_tuple, 0, name_str); + PyTuple_SET_ITEM(name_value_tuple, 1, value_str); + PyTuple_SET_ITEM(name_value_tuple, 2, name_sunder_str); + PyTuple_SET_ITEM(name_value_tuple, 3, value_sunder_str); + Py_INCREF(name_str); + Py_INCREF(value_str); + + PyObject *slots_dict = PyDict_New(); + PyDict_SetItemString(slots_dict, "__slots__", name_value_tuple); + Py_DECREF(name_value_tuple); + + enum_class = PyObject_CallFunction((PyObject *)&PyType_Type, (char *)"s()N", "Enum", slots_dict); + nassertr(enum_class != nullptr, nullptr); + } + PyObject *result = PyObject_CallFunction((PyObject *)&PyType_Type, (char *)"s(O)N", name, enum_class, PyDict_New()); + nassertr(result != nullptr, nullptr); + + ((PyTypeObject *)result)->tp_str = Dtool_EnumType_Str; + ((PyTypeObject *)result)->tp_repr = Dtool_EnumType_Repr; + + // Copy the names as instances of the above to the class dict. + Py_ssize_t size = PyTuple_GET_SIZE(names); + for (Py_ssize_t i = 0; i < size; ++i) { + PyObject *item = PyTuple_GET_ITEM(names, i); + PyObject *name = PyTuple_GET_ITEM(item, 0); + PyObject *value = PyTuple_GET_ITEM(item, 1); + PyObject *member = _PyObject_CallNoArg(result); + PyObject_SetAttr(member, name_str, name); + PyObject_SetAttr(member, name_sunder_str, name); + PyObject_SetAttr(member, value_str, value); + PyObject_SetAttr(member, value_sunder_str, value); + PyObject_SetAttr(result, name, member); + Py_DECREF(member); + } + Py_DECREF(names); +#endif + if (module != nullptr) { PyObject *modstr = PyUnicode_FromString(module); PyObject_SetAttrString(result, "__module__", modstr); diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index cf617cd6f7..ac6586c6ff 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -121,6 +121,7 @@ extern "C" { EXPCL_PYSTUB int PyObject_Repr(...); EXPCL_PYSTUB int PyObject_RichCompareBool(...); EXPCL_PYSTUB int PyObject_SelfIter(...); + EXPCL_PYSTUB int PyObject_SetAttr(...); EXPCL_PYSTUB int PyObject_SetAttrString(...); EXPCL_PYSTUB int PyObject_Str(...); EXPCL_PYSTUB int PyObject_Type(...); @@ -351,6 +352,7 @@ int PyObject_Malloc(...) { return 0; } int PyObject_Repr(...) { return 0; } int PyObject_RichCompareBool(...) { return 0; } int PyObject_SelfIter(...) { return 0; } +int PyObject_SetAttr(...) { return 0; } int PyObject_SetAttrString(...) { return 0; } int PyObject_Str(...) { return 0; } int PyObject_Type(...) { return 0; } From f2976b03ecdde973d1fcfaa671246565e4138a90 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 2 Jul 2018 12:55:18 +0200 Subject: [PATCH 044/360] gobj: add alignment support and move semantics to SimpleAllocator --- panda/src/gobj/simpleAllocator.I | 44 ++++++++++++++++++++++++++-- panda/src/gobj/simpleAllocator.cxx | 47 +++++++++++++++++++++++++----- panda/src/gobj/simpleAllocator.h | 19 ++++++++---- 3 files changed, 96 insertions(+), 14 deletions(-) diff --git a/panda/src/gobj/simpleAllocator.I b/panda/src/gobj/simpleAllocator.I index 2129ba6681..1f8bf4e01c 100644 --- a/panda/src/gobj/simpleAllocator.I +++ b/panda/src/gobj/simpleAllocator.I @@ -32,9 +32,9 @@ SimpleAllocator(size_t max_size, Mutex &lock) : * pointer. */ SimpleAllocatorBlock *SimpleAllocator:: -alloc(size_t size) { +alloc(size_t size, size_t alignment) { MutexHolder holder(_lock); - return do_alloc(size); + return do_alloc(size, alignment); } /** @@ -148,6 +148,24 @@ SimpleAllocatorBlock(SimpleAllocator *alloc, { } +/** + * Transfers ownership from the given SimpleAllocatorBlock to this one. + */ +INLINE SimpleAllocatorBlock:: +SimpleAllocatorBlock(SimpleAllocatorBlock &&from) : + _allocator(from._allocator) +{ + if (_allocator == nullptr) { + return; + } + + MutexHolder holder(_allocator->_lock); + _start = from._start; + _size = from._size; + LinkedListNode::operator = (std::move(from)); + from._allocator = nullptr; +} + /** * The block automatically frees itself when it destructs. */ @@ -156,6 +174,28 @@ INLINE SimpleAllocatorBlock:: free(); } +/** + * Frees this block and instead takes ownership of the given other block. + */ +INLINE SimpleAllocatorBlock &SimpleAllocatorBlock:: +operator = (SimpleAllocatorBlock &&from) { + free(); + + _allocator = from._allocator; + if (_allocator == nullptr) { + _start = 0; + _size = 0; + return *this; + } + + MutexHolder holder(_allocator->_lock); + _start = from._start; + _size = from._size; + LinkedListNode::operator = (std::move(from)); + from._allocator = nullptr; + return *this; +} + /** * Releases the allocated space. */ diff --git a/panda/src/gobj/simpleAllocator.cxx b/panda/src/gobj/simpleAllocator.cxx index 0cc087e2d7..fa6b20d1a3 100644 --- a/panda/src/gobj/simpleAllocator.cxx +++ b/panda/src/gobj/simpleAllocator.cxx @@ -13,6 +13,37 @@ #include "simpleAllocator.h" +/** + * Move constructor. + */ +SimpleAllocator:: +SimpleAllocator(SimpleAllocator &&from) noexcept : + LinkedListNode(std::move(from)), + _total_size(from._total_size), + _max_size(from._max_size), + _contiguous(from._contiguous), + _lock(from._lock) +{ + MutexHolder holder(_lock); + from._total_size = 0; + from._max_size = 0; + from._contiguous = 0; + + // We still need to leave the list in a valid state. + from._prev = &from; + from._next = &from; + + // Change all the blocks to point to the new allocator. + LinkedListNode *next = _next; + while (next != this) { + SimpleAllocatorBlock *block = (SimpleAllocatorBlock *)next; + nassertv(block->_allocator == &from); + block->_allocator = this; + + next = block->_next; + } +} + /** * */ @@ -66,7 +97,7 @@ write(std::ostream &out) const { * Assumes the lock is already held. */ SimpleAllocatorBlock *SimpleAllocator:: -do_alloc(size_t size) { +do_alloc(size_t size, size_t alignment) { if (size > _contiguous) { // Don't even bother. return nullptr; @@ -86,9 +117,9 @@ do_alloc(size_t size) { // Scan until we have reached the last allocated block. while (block->_next != this) { SimpleAllocatorBlock *next = (SimpleAllocatorBlock *)block->_next; - size_t free_size = next->_start - end; - if (size <= free_size) { - SimpleAllocatorBlock *new_block = make_block(end, size); + size_t start = end + ((alignment - end) % alignment); + if (start + size <= next->_start) { + SimpleAllocatorBlock *new_block = make_block(start, size); nassertr(new_block->get_allocator() == this, nullptr); new_block->insert_before(next); @@ -103,6 +134,7 @@ do_alloc(size_t size) { } return new_block; } + size_t free_size = next->_start - end; if (free_size > best) { best = free_size; } @@ -113,9 +145,9 @@ do_alloc(size_t size) { } // No free blocks; check for room at the end. - size_t free_size = _max_size - end; - if (size <= free_size) { - SimpleAllocatorBlock *new_block = make_block(end, size); + size_t start = end + ((alignment - end) % alignment); + if (start + size <= _max_size) { + SimpleAllocatorBlock *new_block = make_block(start, size); nassertr(new_block->get_allocator() == this, nullptr); new_block->insert_before(this); @@ -131,6 +163,7 @@ do_alloc(size_t size) { return new_block; } + size_t free_size = _max_size - end; if (free_size > best) { best = free_size; } diff --git a/panda/src/gobj/simpleAllocator.h b/panda/src/gobj/simpleAllocator.h index 9e4cb7661b..5a9ca7b616 100644 --- a/panda/src/gobj/simpleAllocator.h +++ b/panda/src/gobj/simpleAllocator.h @@ -29,9 +29,10 @@ class SimpleAllocatorBlock; class EXPCL_PANDA_GOBJ SimpleAllocator : public LinkedListNode { PUBLISHED: INLINE explicit SimpleAllocator(size_t max_size, Mutex &lock); + SimpleAllocator(SimpleAllocator &&from) noexcept; virtual ~SimpleAllocator(); - INLINE SimpleAllocatorBlock *alloc(size_t size); + INLINE SimpleAllocatorBlock *alloc(size_t size, size_t alignment=1); INLINE bool is_empty() const; INLINE size_t get_total_size() const; @@ -45,7 +46,7 @@ PUBLISHED: void write(std::ostream &out) const; protected: - SimpleAllocatorBlock *do_alloc(size_t size); + SimpleAllocatorBlock *do_alloc(size_t size, size_t alignment=1); INLINE bool do_is_empty() const; virtual SimpleAllocatorBlock *make_block(size_t start, size_t size); @@ -91,6 +92,14 @@ protected: INLINE SimpleAllocatorBlock(SimpleAllocator *alloc, size_t start, size_t size); +public: + SimpleAllocatorBlock() = default; + SimpleAllocatorBlock(const SimpleAllocatorBlock ©) = delete; + INLINE SimpleAllocatorBlock(SimpleAllocatorBlock &&from); + + SimpleAllocatorBlock &operator = (const SimpleAllocatorBlock ©) = delete; + INLINE SimpleAllocatorBlock &operator = (SimpleAllocatorBlock &&from); + PUBLISHED: INLINE ~SimpleAllocatorBlock(); INLINE void free(); @@ -114,9 +123,9 @@ protected: INLINE bool do_realloc(size_t size); private: - SimpleAllocator *_allocator; - size_t _start; - size_t _size; + SimpleAllocator *_allocator = nullptr; + size_t _start = 0; + size_t _size = 0; friend class SimpleAllocator; }; From 66c5d65bf69fa267270c70c2815cf4f08ed3dc9b Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Jul 2018 19:11:59 +0200 Subject: [PATCH 045/360] maxegg: fix compilation errors with min/max --- pandatool/src/maxegg/maxEgg.h | 4 ++++ pandatool/src/maxegg/maxEggLoader.cxx | 3 +++ pandatool/src/maxprogs/maxEggImport.cxx | 3 +++ 3 files changed, 10 insertions(+) diff --git a/pandatool/src/maxegg/maxEgg.h b/pandatool/src/maxegg/maxEgg.h index 88ae826490..2d9765ee01 100644 --- a/pandatool/src/maxegg/maxEgg.h +++ b/pandatool/src/maxegg/maxEgg.h @@ -19,6 +19,10 @@ #include #include #include "errno.h" + +using std::min; +using std::max; + #include "Max.h" #include "eggGroup.h" #include "eggTable.h" diff --git a/pandatool/src/maxegg/maxEggLoader.cxx b/pandatool/src/maxegg/maxEggLoader.cxx index dca954c6f1..a6855657e6 100644 --- a/pandatool/src/maxegg/maxEggLoader.cxx +++ b/pandatool/src/maxegg/maxEggLoader.cxx @@ -26,6 +26,9 @@ #include "eggPolysetMaker.h" #include "eggBin.h" +using std::min; +using std::max; + #include #include "Max.h" #include "istdplug.h" diff --git a/pandatool/src/maxprogs/maxEggImport.cxx b/pandatool/src/maxprogs/maxEggImport.cxx index b180b12ca8..08a0184a8e 100644 --- a/pandatool/src/maxprogs/maxEggImport.cxx +++ b/pandatool/src/maxprogs/maxEggImport.cxx @@ -22,6 +22,9 @@ // Include this before everything #include "pandatoolbase.h" +using std::min; +using std::max; + // MAX includes #include "maxEggLoader.h" #include "Max.h" From e9e18c22770122a9b560ce19457522eff6535905 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Jul 2018 20:29:31 +0200 Subject: [PATCH 046/360] dtoolutil: fix PandaSystem TypeHandle static init issue --- dtool/src/dtoolutil/pandaSystem.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/dtool/src/dtoolutil/pandaSystem.cxx b/dtool/src/dtoolutil/pandaSystem.cxx index d09fecb663..3d80d0f6b5 100644 --- a/dtool/src/dtoolutil/pandaSystem.cxx +++ b/dtool/src/dtoolutil/pandaSystem.cxx @@ -435,6 +435,7 @@ write(std::ostream &out) const { PandaSystem *PandaSystem:: get_global_ptr() { if (_global_ptr == nullptr) { + init_type(); _global_ptr = new PandaSystem; } From 00888518fe3c25a414267d6e5728478a9baa853f Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Jul 2018 20:31:08 +0200 Subject: [PATCH 047/360] gobj: add F_r32i and F_r32 to TexturePeeker --- panda/src/gobj/texturePeeker.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index 5dc3368909..ef007d91dd 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -108,6 +108,8 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { case Texture::F_depth_component32: case Texture::F_red: case Texture::F_r16: + case Texture::F_r32: + case Texture::F_r32i: _get_texel = get_texel_r; break; From c5dd683366ec6ef61b554f1db71f6b8aebd6cc00 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Jul 2018 20:36:48 +0200 Subject: [PATCH 048/360] tests: add unit test for writing to and extracting buffer textures --- tests/display/test_glsl_shader.py | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/display/test_glsl_shader.py b/tests/display/test_glsl_shader.py index f4ff2d7ea0..33bcf969f0 100644 --- a/tests/display/test_glsl_shader.py +++ b/tests/display/test_glsl_shader.py @@ -1,4 +1,5 @@ from panda3d import core +import struct import pytest from _pytest.outcomes import Failed @@ -18,6 +19,7 @@ layout(r8ui) uniform writeonly uimageBuffer _triggered; void _reset() {{ imageStore(_triggered, 0, uvec4(0, 0, 0, 0)); + memoryBarrier(); }} void _assert(bool cond, int line) {{ @@ -275,3 +277,40 @@ def test_glsl_pta_mat4(gsg): assert(pta[1][3] == vec4(28, 29, 30, 31)); """ run_glsl_test(gsg, code, preamble, {'pta': pta}), code + + +def test_glsl_write_extract_image_buffer(gsg): + # Tests that we can write to a buffer texture on the GPU, and then extract + # the data on the CPU. We test two textures since there was in the past a + # where it would only work correctly for one texture. + tex1 = core.Texture("tex1") + tex1.set_clear_color(0) + tex1.setup_buffer_texture(1, core.Texture.T_unsigned_int, core.Texture.F_r32i, + core.GeomEnums.UH_static) + tex2 = core.Texture("tex2") + tex2.set_clear_color(0) + tex2.setup_buffer_texture(1, core.Texture.T_int, core.Texture.F_r32i, + core.GeomEnums.UH_static) + + preamble = """ + layout(r32ui) uniform uimageBuffer tex1; + layout(r32i) uniform iimageBuffer tex2; + """ + code = """ + assert(imageLoad(tex1, 0).r == 0); + assert(imageLoad(tex2, 0).r == 0); + imageStore(tex1, 0, uvec4(123)); + imageStore(tex2, 0, ivec4(-456)); + memoryBarrier(); + assert(imageLoad(tex1, 0).r == 123); + assert(imageLoad(tex2, 0).r == -456); + """ + + run_glsl_test(gsg, code, preamble, {'tex1': tex1, 'tex2': tex2}) + + engine = core.GraphicsEngine.get_global_ptr() + assert engine.extract_texture_data(tex1, gsg) + assert engine.extract_texture_data(tex2, gsg) + + assert struct.unpack('I', tex1.get_ram_image()) == (123,) + assert struct.unpack('i', tex2.get_ram_image()) == (-456,) From 96a48a684878d169e2eefacb5d737e8be2de3fcd Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Jul 2018 20:55:30 +0200 Subject: [PATCH 049/360] glgsg: fix issue with extract_texture_data and buffer textures It would always extract the last-created buffer texture, not the texture in question. --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index cde43352bc..b167f1baa8 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -13309,6 +13309,12 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { << "glBindTexture(0x" << hex << target << dec << ", " << gtc->_index << "): " << *tex << "\n"; } +#ifndef OPENGLES + if (target == GL_TEXTURE_BUFFER) { + _glBindBuffer(GL_TEXTURE_BUFFER, gtc->_buffer); + } +#endif + GLint wrap_u, wrap_v, wrap_w; GLint minfilter, magfilter; From 5fe294a467f63852f9d038025885afe38f4b0905 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 5 Jul 2018 10:08:50 +0200 Subject: [PATCH 050/360] bullet: prevent softbody with AABB out of bounds from asserting See #357 --- panda/src/bullet/bulletSoftBodyNode.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index 9687935412..cf027f208d 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -276,8 +276,15 @@ do_sync_b2p() { // Update the synchronized transform with the current approximate center of // the soft body - LVecBase3 pos = this->do_get_aabb().get_approx_center(); - CPT(TransformState) ts = TransformState::make_pos(pos); + btVector3 pMin, pMax; + _soft->getAabb(pMin, pMax); + LPoint3 pos = (btVector3_to_LPoint3(pMin) + btVector3_to_LPoint3(pMax)) * 0.5; + CPT(TransformState) ts; + if (!pos.is_nan()) { + ts = TransformState::make_pos(pos); + } else { + ts = TransformState::make_identity(); + } NodePath np = NodePath::any_path((PandaNode *)this); LVecBase3 scale = np.get_net_transform()->get_scale(); From ec06d3f4f8d8ba387d79d95d988937866a7794df Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 5 Jul 2018 12:59:02 +0200 Subject: [PATCH 051/360] tests: fix occasional timing issue in future test --- tests/event/test_futures.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/event/test_futures.py b/tests/event/test_futures.py index 0778605da4..e120a2ab8e 100644 --- a/tests/event/test_futures.py +++ b/tests/event/test_futures.py @@ -48,10 +48,9 @@ def test_future_wait(): fut.set_result(None) thread = threading.Thread(target=thread_main) - thread.start() - # Make sure it didn't sneakily already run the thread assert not fut.done() + thread.start() assert fut.result() is None @@ -69,10 +68,9 @@ def test_future_wait_cancel(): fut.cancel() thread = threading.Thread(target=thread_main) - thread.start() - # Make sure it didn't sneakily already run the thread assert not fut.done() + thread.start() with pytest.raises(CancelledError): fut.result() From b85fead09d99c61d9c20c54e2b97df4ab67d69d4 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 5 Jul 2018 17:55:39 +0200 Subject: [PATCH 052/360] wgldisplay: report context binding error, keep track of thread This isn't really a complete solution, just a stopgap measure to prevent a crash. --- panda/src/wgldisplay/wglGraphicsPipe.cxx | 11 ++++++++--- panda/src/wgldisplay/wglGraphicsPipe.h | 3 ++- panda/src/wgldisplay/wglGraphicsStateGuardian.cxx | 7 ++++++- panda/src/wgldisplay/wglGraphicsWindow.cxx | 6 +++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/panda/src/wgldisplay/wglGraphicsPipe.cxx b/panda/src/wgldisplay/wglGraphicsPipe.cxx index 1a55059dbd..4186c35a35 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.cxx +++ b/panda/src/wgldisplay/wglGraphicsPipe.cxx @@ -22,6 +22,7 @@ TypeHandle wglGraphicsPipe::_type_handle; bool wglGraphicsPipe::_current_valid; HDC wglGraphicsPipe::_current_hdc; HGLRC wglGraphicsPipe::_current_hglrc; +Thread *wglGraphicsPipe::_current_thread; /** * @@ -41,16 +42,19 @@ wglGraphicsPipe:: /** * a thin wrapper around wglMakeCurrent to avoid unnecessary OS-call overhead. */ -void wglGraphicsPipe:: +bool wglGraphicsPipe:: wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector) { + Thread *thread = Thread::get_current_thread(); if ((_current_valid) && (_current_hdc == hdc) && - (_current_hglrc == hglrc)) { - return; + (_current_hglrc == hglrc) && + (_current_thread == thread)) { + return true; } _current_valid = true; _current_hdc = hdc; _current_hglrc = hglrc; + _current_thread = thread; BOOL res; if (collector) { PStatTimer timer(*collector); @@ -58,6 +62,7 @@ wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector) { } else { res = wglMakeCurrent(hdc, hglrc); } + return (res != 0); } /** diff --git a/panda/src/wgldisplay/wglGraphicsPipe.h b/panda/src/wgldisplay/wglGraphicsPipe.h index 176483f92c..49ff95cd5a 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.h +++ b/panda/src/wgldisplay/wglGraphicsPipe.h @@ -46,11 +46,12 @@ protected: private: static std::string format_pfd_flags(DWORD pfd_flags); - static void wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector); + static bool wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector); static bool _current_valid; static HDC _current_hdc; static HGLRC _current_hglrc; + static Thread *_current_thread; public: static TypeHandle get_class_type() { diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index b1dc143da5..735f7fc409 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -319,7 +319,12 @@ choose_pixel_format(const FrameBufferProperties &properties, return; } - wglGraphicsPipe::wgl_make_current(twindow_dc, twindow_ctx, nullptr); + if (!wglGraphicsPipe::wgl_make_current(twindow_dc, twindow_ctx, nullptr)) { + wgldisplay_cat.error() + << "Failed to make WGL context current.\n"; + wglDeleteContext(twindow_ctx); + return; + } _extensions.clear(); save_extensions((const char *)GLP(GetString)(GL_EXTENSIONS)); diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index d6a892ee30..6ff5b88c36 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -79,7 +79,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { HGLRC context = wglgsg->get_context(_hdc); nassertr(context, false); - wglGraphicsPipe::wgl_make_current(_hdc, context, &_make_current_pcollector); + if (!wglGraphicsPipe::wgl_make_current(_hdc, context, &_make_current_pcollector)) { + wgldisplay_cat.error() + << "Failed to make WGL context current.\n"; + return false; + } wglgsg->reset_if_new(); if (mode == FM_render) { From d4d582484fff0ddfdd1ec03e80dfb2cfd66da66d Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 5 Jul 2018 19:02:37 +0200 Subject: [PATCH 053/360] display: fix ability to make screenshots in multithreaded pipeline Problem is that WGL is strict about binding context in different thread while it is still bound in another thread. Either way we need to make sure the draw thread is not rendering, so if you call get_screenshot() from a thread other than the draw thread, it uses the GraphicsEngine to wait until the draw thread is idle and then asks it to do the get_screenshot(). Fixes #360 --- panda/src/display/displayRegion.cxx | 8 ++++++ panda/src/display/graphicsEngine.cxx | 42 ++++++++++++++++++++++++++++ panda/src/display/graphicsEngine.h | 5 +++- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index e32b0f5a50..e1765861e1 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -483,6 +483,14 @@ get_screenshot() { GraphicsStateGuardian *gsg = window->get_gsg(); nassertr(gsg != nullptr, nullptr); + // Are we on the draw thread? + if (gsg->get_threading_model().get_draw_stage() != current_thread->get_pipeline_stage()) { + // Ask the engine to do on the draw thread. + GraphicsEngine *engine = window->get_engine(); + return engine->do_get_screenshot(this, gsg); + } + + // We are on the draw thread. if (!window->begin_frame(GraphicsOutput::FM_refresh, current_thread)) { return nullptr; } diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 0b4e8448b1..dd637d7a9a 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -1249,6 +1249,43 @@ texture_uploaded(Texture *tex) { // Usually only called by DisplayRegion::do_cull. } +/** + * Called by DisplayRegion::do_get_screenshot + */ +PT(Texture) GraphicsEngine:: +do_get_screenshot(DisplayRegion *region, GraphicsStateGuardian *gsg) { + // A multi-threaded environment. We have to wait until the draw thread + // has finished its current task. + + ReMutexHolder holder(_lock); + + const std::string &draw_name = gsg->get_threading_model().get_draw_name(); + WindowRenderer *wr = get_window_renderer(draw_name, 0); + RenderThread *thread = (RenderThread *)wr; + MutexHolder cv_holder(thread->_cv_mutex); + + while (thread->_thread_state != TS_wait) { + thread->_cv_done.wait(); + } + + // Now that the draw thread is idle, signal it to do the extraction task. + thread->_region = region; + thread->_thread_state = TS_do_screenshot; + thread->_cv_start.notify(); + thread->_cv_mutex.release(); + thread->_cv_mutex.acquire(); + + //XXX is this necessary, or is acquiring the mutex enough? + while (thread->_thread_state != TS_wait) { + thread->_cv_done.wait(); + } + + PT(Texture) tex = std::move(thread->_texture); + thread->_region = nullptr; + thread->_texture = nullptr; + return tex; +} + /** * Fires off a cull traversal using the indicated camera. */ @@ -2633,6 +2670,11 @@ thread_main() { _result = _gsg->extract_texture_data(_texture); break; + case TS_do_screenshot: + nassertd(_region != nullptr) break; + _texture = _region->get_screenshot(); + break; + case TS_terminate: do_pending(_engine, current_thread); do_close(_engine, current_thread); diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index 667490b3d3..3371f20b39 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -125,11 +125,13 @@ public: TS_do_windows, TS_do_compute, TS_do_extract, + TS_do_screenshot, TS_terminate, TS_done }; void texture_uploaded(Texture *tex); + PT(Texture) do_get_screenshot(DisplayRegion *region, GraphicsStateGuardian *gsg); public: static void do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, @@ -304,8 +306,9 @@ private: // These are stored for extract_texture_data and dispatch_compute. GraphicsStateGuardian *_gsg; - Texture *_texture; + PT(Texture) _texture; const RenderState *_state; + DisplayRegion *_region; LVecBase3i _work_groups; bool _result; }; From fd227f64922112c82766a5dd550e7f74d00e74d6 Mon Sep 17 00:00:00 2001 From: Brian Lach Date: Fri, 6 Jul 2018 13:31:00 -0400 Subject: [PATCH 054/360] bullet: allow creation of BulletCapsuleShape from CollisionTube --- panda/src/bullet/bulletBodyNode.cxx | 9 +++++++++ panda/src/bullet/bulletCapsuleShape.cxx | 16 ++++++++++++++++ panda/src/bullet/bulletCapsuleShape.h | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 0a4bbc40c8..9067999599 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -20,6 +20,7 @@ #include "collisionPlane.h" #include "collisionSphere.h" #include "collisionPolygon.h" +#include "collisionTube.h" TypeHandle BulletBodyNode::_type_handle; @@ -804,6 +805,14 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { do_add_shape(BulletBoxShape::make_from_solid(box), ts); } + // CollisionTube + else if (CollisionTube::get_class_type() == type) { + CPT(CollisionTube) tube = DCAST(CollisionTube, solid); + CPT(TransformState) ts = TransformState::make_pos((tube->get_point_b() + tube->get_point_a()) / 2.0); + + do_add_shape(BulletCapsuleShape::make_from_solid(tube), ts); + } + // CollisionPlane else if (CollisionPlane::get_class_type() == type) { CPT(CollisionPlane) plane = DCAST(CollisionPlane, solid); diff --git a/panda/src/bullet/bulletCapsuleShape.cxx b/panda/src/bullet/bulletCapsuleShape.cxx index 85171d9b46..ba9e02ab83 100644 --- a/panda/src/bullet/bulletCapsuleShape.cxx +++ b/panda/src/bullet/bulletCapsuleShape.cxx @@ -82,6 +82,22 @@ ptr() const { return _shape; } + +/** + * Constructs a new BulletCapsuleShape using the information from a + * CollisionTube from the builtin collision system. + */ +BulletCapsuleShape *BulletCapsuleShape:: +make_from_solid(const CollisionTube *solid) { + + PN_stdfloat radius = solid->get_radius(); + // CollisionTube height includes the hemispheres, Bullet only wants the cylinder height. + PN_stdfloat height = (solid->get_point_b() - solid->get_point_a()).length() - (radius * 2); + + // CollisionTubes are always Z-Up. + return new BulletCapsuleShape(radius, height, Z_up); +} + /** * Tells the BamReader how to create objects of type BulletShape. */ diff --git a/panda/src/bullet/bulletCapsuleShape.h b/panda/src/bullet/bulletCapsuleShape.h index 9994d9f1dc..f8eecfe3d7 100644 --- a/panda/src/bullet/bulletCapsuleShape.h +++ b/panda/src/bullet/bulletCapsuleShape.h @@ -20,6 +20,8 @@ #include "bullet_utils.h" #include "bulletShape.h" +#include "collisionTube.h" + /** * */ @@ -33,6 +35,8 @@ PUBLISHED: BulletCapsuleShape(const BulletCapsuleShape ©); INLINE ~BulletCapsuleShape(); + static BulletCapsuleShape *make_from_solid(const CollisionTube *solid); + INLINE PN_stdfloat get_radius() const; INLINE PN_stdfloat get_half_height() const; From 0c1fa6a765871a04561c45c77bddbdeaae8fd3e5 Mon Sep 17 00:00:00 2001 From: Tohka Date: Sat, 7 Jul 2018 18:08:41 +0300 Subject: [PATCH 055/360] nsis: Correct building on NSIS 3.0 LVM_GETITEMCOUNT and LVM_GETITEMTEXT are already defined post NSIS 3.0. --- makepanda/installer.nsi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index 39b7dd3518..976bfd84f5 100644 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -1239,8 +1239,13 @@ done: FunctionEnd +!ifndef LVM_GETITEMCOUNT !define LVM_GETITEMCOUNT 0x1004 +!endif + +!ifndef LVM_GETITEMTEXT !define LVM_GETITEMTEXT 0x102D +!endif Function DumpLog Exch $5 From 835a895c5151f0b219fee776559db9ff0efb427b Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 7 Jul 2018 22:55:45 +0200 Subject: [PATCH 056/360] windisplay: don't adjust in_window during get_pointer This restores the old behaviour from before 29a08932ea92bcf0e953994c524cafc1717930b5, which makes in_window true during pointer capture (ie. click-and-drag) even if the cursor leaves the window. X11 behaviour is already not to adjust in_window. Fixes #363 --- panda/src/windisplay/winGraphicsWindow.cxx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 4370621815..954d8aca41 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -134,15 +134,11 @@ get_pointer(int device) const { // We recheck this immediately to get the most up-to-date value. POINT cpos; - if (device == 0 && GetCursorPos(&cpos) && ScreenToClient(_hWnd, &cpos)) { + if (device == 0 && result._in_window && GetCursorPos(&cpos) && ScreenToClient(_hWnd, &cpos)) { double time = ClockObject::get_global_clock()->get_real_time(); - RECT view_rect; - if (GetClientRect(_hWnd, &view_rect)) { - result._in_window = PtInRect(&view_rect, cpos); - result._xpos = cpos.x; - result._ypos = cpos.y; - ((GraphicsWindowInputDevice &)_input_devices[0]).set_pointer(result._in_window, result._xpos, result._ypos, time); - } + result._xpos = cpos.x; + result._ypos = cpos.y; + ((GraphicsWindowInputDevice &)_input_devices[0]).set_pointer(result._in_window, result._xpos, result._ypos, time); } } return result; From cf451bde23822b1cd8b51b42cca8ebb597691458 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Jul 2018 21:11:36 +0200 Subject: [PATCH 057/360] tests: add some fuzz to bullet plane shape testing Needed to unbreak the test suite on macOS. --- tests/bullet/test_bullet_bam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bullet/test_bullet_bam.py b/tests/bullet/test_bullet_bam.py index e22aa57ba2..386e044f9f 100644 --- a/tests/bullet/test_bullet_bam.py +++ b/tests/bullet/test_bullet_bam.py @@ -117,7 +117,7 @@ def test_plane_shape(): assert type(shape) is type(shape2) assert shape.margin == shape2.margin assert shape.name == shape2.name - assert shape.plane_normal == shape2.plane_normal + assert shape.plane_normal.almost_equal(shape2.plane_normal, 0.1) assert shape.plane_constant == shape2.plane_constant From eda47c7f3b4cf155442527e265ca80d4aafee040 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Jul 2018 21:13:13 +0200 Subject: [PATCH 058/360] bullet: support Plane class in BulletPlaneShape --- panda/src/bullet/bulletPlaneShape.cxx | 23 +++++++++++++++++++++++ panda/src/bullet/bulletPlaneShape.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/panda/src/bullet/bulletPlaneShape.cxx b/panda/src/bullet/bulletPlaneShape.cxx index 0d1a97fd4e..98dce53577 100644 --- a/panda/src/bullet/bulletPlaneShape.cxx +++ b/panda/src/bullet/bulletPlaneShape.cxx @@ -15,6 +15,18 @@ TypeHandle BulletPlaneShape::_type_handle; +/** + * Creates a plane shape from a plane definition. + */ +BulletPlaneShape:: +BulletPlaneShape(LPlane plane) { + + btVector3 btNormal = LVecBase3_to_btVector3(plane.get_normal()); + + _shape = new btStaticPlaneShape(btNormal, plane.get_w()); + _shape->setUserPointer(this); +} + /** * */ @@ -50,6 +62,17 @@ ptr() const { return _shape; } +/** + * + */ +LPlane BulletPlaneShape:: +get_plane() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + btVector3 normal = _shape->getPlaneNormal(); + return LPlane(normal[0], normal[1], normal[2], (PN_stdfloat)_shape->getPlaneConstant()); +} + /** * */ diff --git a/panda/src/bullet/bulletPlaneShape.h b/panda/src/bullet/bulletPlaneShape.h index 95aa16d9ef..4521007ecb 100644 --- a/panda/src/bullet/bulletPlaneShape.h +++ b/panda/src/bullet/bulletPlaneShape.h @@ -32,15 +32,18 @@ private: INLINE BulletPlaneShape() : _shape(nullptr) {}; PUBLISHED: + explicit BulletPlaneShape(LPlane plane); explicit BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant); BulletPlaneShape(const BulletPlaneShape ©); INLINE ~BulletPlaneShape(); + LPlane get_plane() const; LVector3 get_plane_normal() const; PN_stdfloat get_plane_constant() const; static BulletPlaneShape *make_from_solid(const CollisionPlane *solid); + MAKE_PROPERTY(plane, get_plane); MAKE_PROPERTY(plane_normal, get_plane_normal); MAKE_PROPERTY(plane_constant, get_plane_constant); From 269d154aea28e69dd6f2ac454a2b729c19c06487 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Jul 2018 21:15:40 +0200 Subject: [PATCH 059/360] chan: fix thread-unsafe access of WeakPointerTo --- panda/src/chan/partBundle.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index dffed55d50..966987995a 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -154,10 +154,11 @@ apply_transform(const TransformState *transform) { AppliedTransforms::iterator ati = _applied_transforms.find(transform); if (ati != _applied_transforms.end()) { - if ((*ati).first.is_valid_pointer() && - (*ati).second.is_valid_pointer()) { - // Here's our cached result. - return (*ati).second.lock(); + if ((*ati).first.is_valid_pointer()) { + if (auto new_bundle = (*ati).second.lock()) { + // Here's our cached result. + return new_bundle; + } } } From fb82a1c557d02f331fe1ccee46987ffa16232c16 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Jul 2018 21:22:25 +0200 Subject: [PATCH 060/360] express: enable WeakPointerToBase comparison operators on Win32 I'm not sure why they were ifdeffed out, but they should certainly be available so that it is possible to compare WeakPointerTo in a thread-safe manner. --- panda/src/express/weakPointerToBase.I | 2 -- panda/src/express/weakPointerToBase.h | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 30690458be..2e537c9639 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -202,7 +202,6 @@ update_type(To *ptr) { } #ifndef CPPPARSER -#ifndef WIN32_VC /** * */ @@ -426,7 +425,6 @@ INLINE bool WeakPointerToBase:: operator >= (const PointerToBase &other) const { return (To *)_void_ptr >= (To *)((WeakPointerToBase *)&other)->_void_ptr; } -#endif // WIN32_VC /** * diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index b1267c448a..a34b39bdb5 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -48,7 +48,6 @@ public: // These comparison functions are common to all things PointerTo, so they're // defined up here. #ifndef CPPPARSER -#ifndef WIN32_VC INLINE bool operator == (const To *other) const; INLINE bool operator != (const To *other) const; INLINE bool operator > (const To *other) const; @@ -77,7 +76,7 @@ public: INLINE bool operator > (const PointerToBase &other) const; INLINE bool operator <= (const PointerToBase &other) const; INLINE bool operator >= (const PointerToBase &other) const; -#endif // WIN32_VC + INLINE bool operator < (const To *other) const; INLINE bool operator < (std::nullptr_t) const; INLINE bool operator < (const WeakPointerToBase &other) const; From 409231d214ebfce847d6242cee587ab7f9f72f85 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Jul 2018 21:25:08 +0200 Subject: [PATCH 061/360] express: make WeakPointerTo cast operators explicit This prevents accidentally (and unsafely) decaying a WeakPointerTo to a regular pointer. --- panda/src/express/weakPointerTo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index 5834113b7a..2e8c6029a5 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -38,7 +38,7 @@ public: INLINE To &operator *() const; INLINE To *operator -> () const; // MSVC.NET 2005 insists that we use T *, and not To *, here. - INLINE operator T *() const; + INLINE explicit operator T *() const; PUBLISHED: INLINE PointerTo lock() const; @@ -75,7 +75,7 @@ PUBLISHED: public: INLINE const To &operator *() const; INLINE const To *operator -> () const; - INLINE operator const T *() const; + INLINE explicit operator const T *() const; PUBLISHED: INLINE ConstPointerTo lock() const; From 23128e4695d2e8581551be161f20cf7d53ca87b5 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Jul 2018 21:33:49 +0200 Subject: [PATCH 062/360] express: support casting between compatible PointerTo types This makes it possible to implicitly convert a PT of a derived type to a (C)PT of a base type, without needing to first convert it to a regular pointer. This also applies to moves, which are now more efficient due to the lack of need for ref/unref pair even if the pointer type is not exactly the same. --- panda/src/express/pointerTo.I | 162 ++++++++++++++++++++++++++++++ panda/src/express/pointerTo.h | 34 +++++++ panda/src/express/pointerToBase.I | 56 +++++++++-- panda/src/express/pointerToBase.h | 8 ++ 4 files changed, 252 insertions(+), 8 deletions(-) diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index e0f8c85046..8c7aa38a4e 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -39,6 +39,41 @@ PointerTo(PointerTo &&from) noexcept : { } +#ifndef CPPPARSER +/** + * + */ +template +template +ALWAYS_INLINE PointerTo:: +PointerTo(Y *ptr) noexcept : + PointerToBase(ptr) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE PointerTo:: +PointerTo(const PointerTo &r) noexcept : + PointerToBase(r.p()) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE PointerTo:: +PointerTo(PointerTo &&r) noexcept : + PointerToBase(std::move(r)) +{ +} +#endif // !CPPPARSER + /** * */ @@ -49,6 +84,30 @@ operator = (PointerTo &&from) noexcept { return *this; } +#ifndef CPPPARSER +/** + * + */ +template +template +ALWAYS_INLINE PointerTo &PointerTo:: +operator = (const PointerTo &r) noexcept { + this->reassign(r.p()); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE PointerTo &PointerTo:: +operator = (PointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} +#endif // !CPPPARSER + /** * */ @@ -172,6 +231,63 @@ ConstPointerTo(ConstPointerTo &&from) noexcept : { } +#ifndef CPPPARSER +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(const Y *ptr) noexcept : + PointerToBase((Y *)ptr) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(const PointerTo &r) noexcept : + PointerToBase(r.p()) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(const ConstPointerTo &r) noexcept : + PointerToBase((Y *)r.p()) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(PointerTo &&r) noexcept : + PointerToBase(std::move(r)) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo:: +ConstPointerTo(ConstPointerTo &&r) noexcept : + PointerToBase(std::move(r)) +{ +} +#endif // !CPPPARSER + /** * */ @@ -192,6 +308,52 @@ operator = (ConstPointerTo &&from) noexcept { return *this; } +#ifndef CPPPARSER +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: +operator = (const PointerTo &r) noexcept { + this->reassign(r.p()); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: +operator = (const ConstPointerTo &r) noexcept { + this->reassign((Y *)r.p()); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: +operator = (PointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE ConstPointerTo &ConstPointerTo:: +operator = (ConstPointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} +#endif // !CPPPARSER + /** * */ diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index 1f9704c3f3..e9250a2f8a 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -77,8 +77,21 @@ PUBLISHED: public: INLINE PointerTo(PointerTo &&from) noexcept; + + template + ALWAYS_INLINE explicit PointerTo(Y *ptr) noexcept; + template + ALWAYS_INLINE PointerTo(const PointerTo &r) noexcept; + template + ALWAYS_INLINE PointerTo(PointerTo &&r) noexcept; + INLINE PointerTo &operator = (PointerTo &&from) noexcept; + template + ALWAYS_INLINE PointerTo &operator = (const PointerTo &r) noexcept; + template + ALWAYS_INLINE PointerTo &operator = (PointerTo &&r) noexcept; + constexpr To &operator *() const noexcept; constexpr To *operator -> () const noexcept; // MSVC.NET 2005 insists that we use T *, and not To *, here. @@ -141,9 +154,30 @@ PUBLISHED: public: INLINE ConstPointerTo(PointerTo &&from) noexcept; INLINE ConstPointerTo(ConstPointerTo &&from) noexcept; + + template + ALWAYS_INLINE explicit ConstPointerTo(const Y *ptr) noexcept; + template + ALWAYS_INLINE ConstPointerTo(const PointerTo &r) noexcept; + template + ALWAYS_INLINE ConstPointerTo(const ConstPointerTo &r) noexcept; + template + ALWAYS_INLINE ConstPointerTo(PointerTo &&r) noexcept; + template + ALWAYS_INLINE ConstPointerTo(ConstPointerTo &&r) noexcept; + INLINE ConstPointerTo &operator = (PointerTo &&from) noexcept; INLINE ConstPointerTo &operator = (ConstPointerTo &&from) noexcept; + template + ALWAYS_INLINE ConstPointerTo &operator = (const PointerTo &r) noexcept; + template + ALWAYS_INLINE ConstPointerTo &operator = (const ConstPointerTo &r) noexcept; + template + ALWAYS_INLINE ConstPointerTo &operator = (PointerTo &&r) noexcept; + template + ALWAYS_INLINE ConstPointerTo &operator = (ConstPointerTo &&r) noexcept; + constexpr const To &operator *() const noexcept; constexpr const To *operator -> () const noexcept; constexpr operator const T *() const noexcept; diff --git a/panda/src/express/pointerToBase.I b/panda/src/express/pointerToBase.I index e6e749f1f4..819e16efec 100644 --- a/panda/src/express/pointerToBase.I +++ b/panda/src/express/pointerToBase.I @@ -44,11 +44,24 @@ PointerToBase(const PointerToBase ©) { */ template INLINE PointerToBase:: -~PointerToBase() { - if (_void_ptr != nullptr) { - unref_delete((To *)_void_ptr); - _void_ptr = nullptr; - } +PointerToBase(PointerToBase &&from) noexcept { + _void_ptr = from._void_ptr; + from._void_ptr = nullptr; +} + +/** + * + */ +template +template +INLINE PointerToBase:: +PointerToBase(PointerToBase &&r) noexcept { + // If this next line gives an error, you are trying to convert a PointerTo + // from an incompatible type of another PointerTo. + To *ptr = (Y *)r._void_ptr; + + this->_void_ptr = ptr; + r._void_ptr = nullptr; } /** @@ -56,9 +69,11 @@ INLINE PointerToBase:: */ template INLINE PointerToBase:: -PointerToBase(PointerToBase &&from) noexcept { - _void_ptr = from._void_ptr; - from._void_ptr = nullptr; +~PointerToBase() { + if (_void_ptr != nullptr) { + unref_delete((To *)_void_ptr); + _void_ptr = nullptr; + } } /** @@ -84,6 +99,31 @@ reassign(PointerToBase &&from) noexcept { } } +/** + * Like above, but casts from a compatible pointer type. + */ +template +template +INLINE void PointerToBase:: +reassign(PointerToBase &&from) noexcept { + // Protect against self-move-assignment. + if (from._void_ptr != this->_void_ptr) { + To *old_ptr = (To *)this->_void_ptr; + + // If there is a compile error on this line, it means you tried to assign + // an incompatible type. + To *new_ptr = (Y *)from._void_ptr; + + this->_void_ptr = new_ptr; + from._void_ptr = nullptr; + + // Now delete the old pointer. + if (old_ptr != nullptr) { + unref_delete(old_ptr); + } + } +} + /** * This is the main work of the PointerTo family. When the pointer is * reassigned, decrement the old reference count and increment the new one. diff --git a/panda/src/express/pointerToBase.h b/panda/src/express/pointerToBase.h index 057a465454..959574aba7 100644 --- a/panda/src/express/pointerToBase.h +++ b/panda/src/express/pointerToBase.h @@ -35,17 +35,25 @@ protected: INLINE PointerToBase(To *ptr); INLINE PointerToBase(const PointerToBase ©); INLINE PointerToBase(PointerToBase &&from) noexcept; + template + INLINE PointerToBase(PointerToBase &&r) noexcept; + INLINE ~PointerToBase(); INLINE void reassign(To *ptr); INLINE void reassign(const PointerToBase ©); INLINE void reassign(PointerToBase &&from) noexcept; + template + INLINE void reassign(PointerToBase &&from) noexcept; INLINE void update_type(To *ptr); // No assignment or retrieval functions are declared in PointerToBase, // because we will have to specialize on const vs. non-const later. + // This is needed to be able to access the privates of other instantiations. + template friend class PointerToBase; + PUBLISHED: ALWAYS_INLINE void clear(); From c6ed4e1836440c459873f9bc784c83b1eaae2e64 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Jul 2018 21:39:43 +0200 Subject: [PATCH 063/360] general: don't cast to regular pointer when returning a PointerTo This is inefficient because it induces an unnecessary ref()/unref() pair when we just need to move the pointer out of the function. Thanks to 23128e4695d2e8581551be161f20cf7d53ca87b5, we can now move between related pointer types, making the .p() hack unnecessary. --- panda/src/collide/collisionParabola.cxx | 2 +- panda/src/collide/collisionPolygon.cxx | 4 ++-- panda/src/collide/collisionSegment.cxx | 2 +- panda/src/collide/collisionSolid.cxx | 4 ++-- panda/src/downloader/virtualFileMountHTTP.cxx | 2 +- panda/src/dxgsg9/wdxGraphicsPipe9.cxx | 2 +- panda/src/express/virtualFileMount.cxx | 2 +- panda/src/ffmpeg/ffmpegVideo.cxx | 2 +- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 4 ++-- panda/src/framework/windowFramework.cxx | 2 +- panda/src/gobj/geomLines.cxx | 2 +- panda/src/gobj/geomLinestrips.cxx | 6 +++--- panda/src/gobj/geomLinestripsAdjacency.cxx | 4 ++-- panda/src/gobj/geomPrimitive.cxx | 2 +- panda/src/gobj/geomTriangles.cxx | 6 +++--- panda/src/gobj/geomTrianglesAdjacency.cxx | 4 ++-- panda/src/gobj/geomTrifans.cxx | 4 ++-- panda/src/gobj/geomTristrips.cxx | 4 ++-- panda/src/gobj/internalName_ext.cxx | 2 +- panda/src/gobj/lens.cxx | 2 +- panda/src/gobj/shader.cxx | 3 +-- panda/src/gobj/texture.cxx | 3 +-- panda/src/grutil/cardMaker.cxx | 2 +- panda/src/grutil/fisheyeMaker.cxx | 2 +- panda/src/grutil/movieTexture.cxx | 2 +- panda/src/pgraph/stateMunger.cxx | 2 +- panda/src/pgui/pgFrameStyle.cxx | 8 ++++---- panda/src/speedtree/loaderFileTypeSrt.cxx | 2 +- panda/src/speedtree/loaderFileTypeStf.cxx | 2 +- panda/src/text/textNode.cxx | 6 +++--- panda/src/vision/openCVTexture.cxx | 2 +- pandatool/src/ptloader/loaderFileTypePandatool.cxx | 2 +- pandatool/src/xfile/xFileDataDef.cxx | 2 +- 33 files changed, 49 insertions(+), 51 deletions(-) diff --git a/panda/src/collide/collisionParabola.cxx b/panda/src/collide/collisionParabola.cxx index b439440228..b758cf037a 100644 --- a/panda/src/collide/collisionParabola.cxx +++ b/panda/src/collide/collisionParabola.cxx @@ -157,7 +157,7 @@ compute_internal_bounds() const { LPoint3(0.01, 0, max_z), LPoint3(-0.01, 0, max_z)); // And convert that back into real space. volume->xform(from_parabola); - return volume.p(); + return volume; } /** diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index 25dc01d272..24c8230d2f 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -271,9 +271,9 @@ get_viz(const CullTraverser *trav, const CullTraverserData &data, draw_polygon(viz_geom_node, bounds_viz_geom_node, new_points); if (bounds_only) { - return bounds_viz_geom_node.p(); + return bounds_viz_geom_node; } else { - return viz_geom_node.p(); + return viz_geom_node; } } diff --git a/panda/src/collide/collisionSegment.cxx b/panda/src/collide/collisionSegment.cxx index 802259b338..f0ea03f12a 100644 --- a/panda/src/collide/collisionSegment.cxx +++ b/panda/src/collide/collisionSegment.cxx @@ -131,7 +131,7 @@ compute_internal_bounds() const { LPoint3(0.01, -0.01, 0.01), LPoint3(-0.01, -0.01, 0.01)); volume->xform(from_segment); - return volume.p(); + return volume; } /** diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index 0e83c647de..b862ec7c73 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -146,9 +146,9 @@ get_viz(const CullTraverser *, const CullTraverserData &, bool bounds_only) cons } if (bounds_only) { - return _bounds_viz_geom.p(); + return _bounds_viz_geom; } else { - return _viz_geom.p(); + return _viz_geom; } } diff --git a/panda/src/downloader/virtualFileMountHTTP.cxx b/panda/src/downloader/virtualFileMountHTTP.cxx index 25e9dc99ea..09625d53bc 100644 --- a/panda/src/downloader/virtualFileMountHTTP.cxx +++ b/panda/src/downloader/virtualFileMountHTTP.cxx @@ -168,7 +168,7 @@ make_virtual_file(const Filename &local_filename, new VirtualFileHTTP(this, local_filename, implicit_pz_file, open_flags); vfile->set_original_filename(original_filename); - return vfile.p(); + return vfile; } /** diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index cbfada1b41..6c85c6652f 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -846,7 +846,7 @@ make_device(void *scrn) { _device = device; wdxdisplay9_cat.info() << "walla: device" << device << "\n"; - return device.p(); + return device; } pmap g_D3DFORMATmap; diff --git a/panda/src/express/virtualFileMount.cxx b/panda/src/express/virtualFileMount.cxx index 37e3554ac2..0bfc9fc3e3 100644 --- a/panda/src/express/virtualFileMount.cxx +++ b/panda/src/express/virtualFileMount.cxx @@ -58,7 +58,7 @@ make_virtual_file(const Filename &local_filename, make_directory(local); } - return file.p(); + return file; } /** diff --git a/panda/src/ffmpeg/ffmpegVideo.cxx b/panda/src/ffmpeg/ffmpegVideo.cxx index c12892fe47..3cc7105fdd 100644 --- a/panda/src/ffmpeg/ffmpegVideo.cxx +++ b/panda/src/ffmpeg/ffmpegVideo.cxx @@ -60,7 +60,7 @@ open() { ffmpeg_cat.error() << "Could not open " << _filename << "\n"; return nullptr; } else { - return result.p(); + return result; } } diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 4803e41297..f8c2163b73 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -446,7 +446,7 @@ fetch_buffer() { << " at frame " << _current_frame << ", returning NULL\n"; } } - return frame.p(); + return frame; } /** @@ -455,7 +455,7 @@ fetch_buffer() { PT(MovieVideoCursor::Buffer) FfmpegVideoCursor:: make_new_buffer() { PT(FfmpegBuffer) frame = new FfmpegBuffer(size_x() * size_y() * get_num_components(), _video_timebase); - return frame.p(); + return frame; } /** diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 1a6c8b1d77..db49ee97e8 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -1334,7 +1334,7 @@ load_image_as_model(const Filename &filename) { card_node->add_geom(geom); - return card_node.p(); + return card_node; } /** diff --git a/panda/src/gobj/geomLines.cxx b/panda/src/gobj/geomLines.cxx index 2d38fc8838..d9b460b14a 100644 --- a/panda/src/gobj/geomLines.cxx +++ b/panda/src/gobj/geomLines.cxx @@ -128,7 +128,7 @@ make_adjacency() const { } adj->set_vertices(std::move(new_vertices)); - return adj.p(); + return adj; } /** diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index 3e37496bad..8e85ac870a 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -164,7 +164,7 @@ make_adjacency() const { } nassertr(vi == num_vertices, nullptr); - return adj.p(); + return adj; } /** @@ -220,7 +220,7 @@ decompose_impl() const { // Skip unused vertices between tristrips. vi += num_unused; int end = ends[li]; - nassertr(vi + 1 <= end, lines.p()); + nassertr(vi + 1 <= end, lines); int v0 = get_vertex(vi); ++vi; while (vi < end) { @@ -235,7 +235,7 @@ decompose_impl() const { } nassertr(vi == get_num_vertices(), nullptr); - return lines.p(); + return lines; } /** diff --git a/panda/src/gobj/geomLinestripsAdjacency.cxx b/panda/src/gobj/geomLinestripsAdjacency.cxx index 11d14ab319..c9d4ba6891 100644 --- a/panda/src/gobj/geomLinestripsAdjacency.cxx +++ b/panda/src/gobj/geomLinestripsAdjacency.cxx @@ -142,7 +142,7 @@ decompose_impl() const { // Skip unused vertices between tristrips. vi += num_unused; int end = ends[li]; - nassertr(vi + 3 <= end, lines.p()); + nassertr(vi + 3 <= end, lines); int v0 = from.get_vertex(vi++); int v1 = from.get_vertex(vi++); int v2 = from.get_vertex(vi++); @@ -160,7 +160,7 @@ decompose_impl() const { } nassertr(vi == num_vertices, nullptr); - return lines.p(); + return lines; } /** diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index f52e06663a..da3c10dffd 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -55,7 +55,7 @@ GeomPrimitive() { */ PT(CopyOnWriteObject) GeomPrimitive:: make_cow_copy() { - return make_copy().p(); + return make_copy(); } /** diff --git a/panda/src/gobj/geomTriangles.cxx b/panda/src/gobj/geomTriangles.cxx index 809b9199c0..5171ec6b5f 100644 --- a/panda/src/gobj/geomTriangles.cxx +++ b/panda/src/gobj/geomTriangles.cxx @@ -138,7 +138,7 @@ make_adjacency() const { } adj->set_vertices(std::move(new_vertices)); - return adj.p(); + return adj; } /** @@ -199,7 +199,7 @@ doubleside_impl() const { reversed = (GeomTriangles *)DCAST(GeomTriangles, reversed->rotate()); } - return reversed.p(); + return reversed; } /** @@ -232,7 +232,7 @@ reverse_impl() const { break; } - return reversed.p(); + return reversed; } /** diff --git a/panda/src/gobj/geomTrianglesAdjacency.cxx b/panda/src/gobj/geomTrianglesAdjacency.cxx index 0dffa74329..5278d69bbb 100644 --- a/panda/src/gobj/geomTrianglesAdjacency.cxx +++ b/panda/src/gobj/geomTrianglesAdjacency.cxx @@ -133,7 +133,7 @@ doubleside_impl() const { reversed = (GeomTrianglesAdjacency *)DCAST(GeomTrianglesAdjacency, reversed->rotate()); } - return reversed.p(); + return reversed; } /** @@ -166,7 +166,7 @@ reverse_impl() const { break; } - return reversed.p(); + return reversed; } /** diff --git a/panda/src/gobj/geomTrifans.cxx b/panda/src/gobj/geomTrifans.cxx index 0c5d87f53a..a99481e92e 100644 --- a/panda/src/gobj/geomTrifans.cxx +++ b/panda/src/gobj/geomTrifans.cxx @@ -110,7 +110,7 @@ decompose_impl() const { int li = 0; while (li < (int)ends.size()) { int end = ends[li]; - nassertr(vi + 2 <= end, triangles.p()); + nassertr(vi + 2 <= end, triangles); int v0 = get_vertex(vi); ++vi; int v1 = get_vertex(vi); @@ -129,7 +129,7 @@ decompose_impl() const { nassertr(vi == num_vertices, nullptr); - return triangles.p(); + return triangles; } /** diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index 0b88bcf8f1..15b46c409a 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -219,7 +219,7 @@ make_adjacency() const { } nassertr(vi == num_vertices, nullptr); - return adj.p(); + return adj; } /** @@ -358,7 +358,7 @@ decompose_impl() const { nassertr(vi == num_vertices, nullptr); } - return triangles.p(); + return triangles; } /** diff --git a/panda/src/gobj/internalName_ext.cxx b/panda/src/gobj/internalName_ext.cxx index 4967b330b5..f1cdf0a725 100644 --- a/panda/src/gobj/internalName_ext.cxx +++ b/panda/src/gobj/internalName_ext.cxx @@ -76,7 +76,7 @@ make(PyStringObject *str) { iname->ref(); InternalName::_py_intern_table.insert(std::make_pair((PyObject *)str, iname.p())); - return iname.p(); + return iname; } } diff --git a/panda/src/gobj/lens.cxx b/panda/src/gobj/lens.cxx index 470b64447a..f66f2ba6b9 100644 --- a/panda/src/gobj/lens.cxx +++ b/panda/src/gobj/lens.cxx @@ -630,7 +630,7 @@ make_geometry() { PT(Geom) geom = new Geom(cdata->_geom_data); geom->add_primitive(line); - return geom.p(); + return geom; } /** diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 31a8d986ed..22a5389b8b 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -3417,8 +3417,7 @@ parse_eof() { */ PT(AsyncFuture) Shader:: prepare(PreparedGraphicsObjects *prepared_objects) { - PT(PreparedGraphicsObjects::EnqueuedObject) obj = prepared_objects->enqueue_shader_future(this); - return obj.p(); + return prepared_objects->enqueue_shader_future(this); } /** diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 5918210fdc..c538391018 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -1427,8 +1427,7 @@ peek() { */ PT(AsyncFuture) Texture:: prepare(PreparedGraphicsObjects *prepared_objects) { - PT(PreparedGraphicsObjects::EnqueuedObject) obj = prepared_objects->enqueue_texture_future(this); - return obj.p(); + return prepared_objects->enqueue_texture_future(this); } /** diff --git a/panda/src/grutil/cardMaker.cxx b/panda/src/grutil/cardMaker.cxx index 1b68d1482a..33f6fc88ad 100644 --- a/panda/src/grutil/cardMaker.cxx +++ b/panda/src/grutil/cardMaker.cxx @@ -133,7 +133,7 @@ generate() { gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } /** diff --git a/panda/src/grutil/fisheyeMaker.cxx b/panda/src/grutil/fisheyeMaker.cxx index ad7a8a90ef..5e7d7395ec 100644 --- a/panda/src/grutil/fisheyeMaker.cxx +++ b/panda/src/grutil/fisheyeMaker.cxx @@ -322,7 +322,7 @@ generate() { } } - return geom_node.p(); + return geom_node; } /** diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index 280079948d..36f4913085 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -409,7 +409,7 @@ make_copy_impl() const { CDWriter cdata_copy(copy->_cycler, true); copy->do_assign(cdata_copy, cdata_copy_tex, this, cdata, cdata_tex); - return copy.p(); + return copy; } /** diff --git a/panda/src/pgraph/stateMunger.cxx b/panda/src/pgraph/stateMunger.cxx index 8eba900f70..5b52442db0 100644 --- a/panda/src/pgraph/stateMunger.cxx +++ b/panda/src/pgraph/stateMunger.cxx @@ -40,7 +40,7 @@ munge_state(const RenderState *state) { } CPT(RenderState) result = munge_state_impl(state); - munged_states.store(id, result.p()); + munged_states.store(id, result); return result; } diff --git a/panda/src/pgui/pgFrameStyle.cxx b/panda/src/pgui/pgFrameStyle.cxx index b4590bf8f0..a8f53478cb 100644 --- a/panda/src/pgui/pgFrameStyle.cxx +++ b/panda/src/pgui/pgFrameStyle.cxx @@ -257,7 +257,7 @@ generate_flat_geom(const LVecBase4 &frame) { geom->add_primitive(strip); gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } /** @@ -431,7 +431,7 @@ generate_bevel_geom(const LVecBase4 &frame, bool in) { } gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } /** @@ -663,7 +663,7 @@ generate_groove_geom(const LVecBase4 &frame, bool in) { } gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } /** @@ -803,5 +803,5 @@ generate_texture_border_geom(const LVecBase4 &frame) { geom->add_primitive(strip); gnode->add_geom(geom, state); - return gnode.p(); + return gnode; } diff --git a/panda/src/speedtree/loaderFileTypeSrt.cxx b/panda/src/speedtree/loaderFileTypeSrt.cxx index fa1f7b3a48..a0fe4e3022 100644 --- a/panda/src/speedtree/loaderFileTypeSrt.cxx +++ b/panda/src/speedtree/loaderFileTypeSrt.cxx @@ -68,5 +68,5 @@ load_file(const Filename &path, const LoaderOptions &, PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename()); st->add_instance(tree, STTransform()); - return st.p(); + return st; } diff --git a/panda/src/speedtree/loaderFileTypeStf.cxx b/panda/src/speedtree/loaderFileTypeStf.cxx index 981d36b59b..9d83bddd3d 100644 --- a/panda/src/speedtree/loaderFileTypeStf.cxx +++ b/panda/src/speedtree/loaderFileTypeStf.cxx @@ -62,5 +62,5 @@ load_file(const Filename &path, const LoaderOptions &options, PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename()); st->add_from_stf(path, options); - return st.p(); + return st; } diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index 19395788c3..92001d7b40 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -755,7 +755,7 @@ make_frame() { frame_node->add_geom(geom2, state); } - return frame_node.p(); + return frame_node; } /** @@ -795,7 +795,7 @@ make_card() { card_node->add_geom(geom); - return card_node.p(); + return card_node; } @@ -896,7 +896,7 @@ make_card_with_border() { card_node->add_geom(geom); - return card_node.p(); + return card_node; } /** diff --git a/panda/src/vision/openCVTexture.cxx b/panda/src/vision/openCVTexture.cxx index 702e0932af..58c233232a 100644 --- a/panda/src/vision/openCVTexture.cxx +++ b/panda/src/vision/openCVTexture.cxx @@ -98,7 +98,7 @@ make_copy_impl() const { Texture::CDWriter cdata_copy_tex(copy->Texture::_cycler, true); copy->do_assign(cdata_copy_tex, this, cdata_tex); - return copy.p(); + return copy; } /** diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.cxx b/pandatool/src/ptloader/loaderFileTypePandatool.cxx index 769eb737d0..9536b3fe65 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.cxx +++ b/pandatool/src/ptloader/loaderFileTypePandatool.cxx @@ -196,7 +196,7 @@ load_file(const Filename &path, const LoaderOptions &options, } delete loader; - return result.p(); + return result; } /** diff --git a/pandatool/src/xfile/xFileDataDef.cxx b/pandatool/src/xfile/xFileDataDef.cxx index 2a35528768..5fe983891b 100644 --- a/pandatool/src/xfile/xFileDataDef.cxx +++ b/pandatool/src/xfile/xFileDataDef.cxx @@ -376,7 +376,7 @@ unpack_template_value(const XFileParseDataList &parse_data_list, return nullptr; } - return data_value.p(); + return data_value; } /** From abe20fc4894603058e8e2dc3ffe92aa6c4b1e4e8 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Jul 2018 21:49:37 +0200 Subject: [PATCH 064/360] fmod: return NullAudioSound if file does not exist This matches the OpenAL behaviour, and is needed to fix the unit tests on macOS. --- panda/src/audiotraits/fmodAudioManager.cxx | 20 ++++++++++++-------- panda/src/audiotraits/fmodAudioSound.cxx | 17 ++++++----------- panda/src/audiotraits/fmodAudioSound.h | 7 ++++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 1f7ed7cd22..42fd08c536 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -419,15 +419,19 @@ get_sound(const std::string &file_name, bool positional, int) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->resolve_filename(path, get_model_path()); - // Build a new AudioSound from the audio data. - PT(AudioSound) audioSound; - PT(FmodAudioSound) fmodAudioSound = new FmodAudioSound(this, path, positional); + // Locate the file on disk. + path.set_binary(); + PT(VirtualFile) file = vfs->get_file(path); + if (file != nullptr) { + // Build a new AudioSound from the audio data. + PT(FmodAudioSound) sound = new FmodAudioSound(this, file, positional); - _all_sounds.insert(fmodAudioSound); - - audioSound = fmodAudioSound; - - return audioSound; + _all_sounds.insert(sound); + return sound; + } else { + audio_error("createSound(" << path << "): File not found."); + return get_null_sound(); + } } /** diff --git a/panda/src/audiotraits/fmodAudioSound.cxx b/panda/src/audiotraits/fmodAudioSound.cxx index 02d8ae51aa..dd060844e9 100644 --- a/panda/src/audiotraits/fmodAudioSound.cxx +++ b/panda/src/audiotraits/fmodAudioSound.cxx @@ -39,9 +39,10 @@ TypeHandle FmodAudioSound::_type_handle; */ FmodAudioSound:: -FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { +FmodAudioSound(AudioManager *manager, VirtualFile *file, bool positional) { ReMutexHolder holder(FmodAudioManager::_lock); - audio_debug("FmodAudioSound::FmodAudioSound() Creating new sound, filename: " << file_name ); + audio_debug("FmodAudioSound::FmodAudioSound() Creating new sound, filename: " + << file->get_original_filename()); _active = manager->get_active(); _paused = false; @@ -77,20 +78,14 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { _manager = fmanager; _channel = 0; - _file_name = file_name; + _file_name = file->get_original_filename(); _file_name.set_binary(); // Get the Speaker Mode [Important for later on.] result = _manager->_system->getSpeakerMode( &_speakermode ); fmod_audio_errcheck("_system->getSpeakerMode()", result); - VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - PT(VirtualFile) file = vfs->get_file(_file_name); - if (file == nullptr) { - // File not found. We will display the appropriate error message below. - result = FMOD_ERR_FILE_NOTFOUND; - - } else { + { bool preload = (fmod_audio_preload_threshold < 0) || (file->get_file_size() < fmod_audio_preload_threshold); int flags = FMOD_SOFTWARE; flags |= positional ? FMOD_3D : FMOD_2D; @@ -149,7 +144,7 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) // Otherwise, if the Panda threading system is compiled in, we can // assign callbacks to read the file through the VFS. - name_or_data = (const char *)file.p(); + name_or_data = (const char *)file; sound_info.length = (unsigned int)info.get_size(); sound_info.useropen = open_callback; sound_info.userclose = close_callback; diff --git a/panda/src/audiotraits/fmodAudioSound.h b/panda/src/audiotraits/fmodAudioSound.h index 8d0ad4408c..40de00823d 100644 --- a/panda/src/audiotraits/fmodAudioSound.h +++ b/panda/src/audiotraits/fmodAudioSound.h @@ -70,10 +70,11 @@ #include #include -class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { - public: +class VirtualFile; - FmodAudioSound(AudioManager *manager, Filename fn, bool positional ); +class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { +public: + FmodAudioSound(AudioManager *manager, VirtualFile *file, bool positional); ~FmodAudioSound(); // For best compatibility, set the loop_count, start_time, volume, and From 7c8426a79f25321b8d5f2d22aa46b4880c70027c Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Jul 2018 22:28:52 +0200 Subject: [PATCH 065/360] tests: fix int overflow error with GLSL shader test on some drivers --- tests/display/test_glsl_shader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/display/test_glsl_shader.py b/tests/display/test_glsl_shader.py index 33bcf969f0..c13e99e92e 100644 --- a/tests/display/test_glsl_shader.py +++ b/tests/display/test_glsl_shader.py @@ -168,7 +168,7 @@ def test_glsl_int(gsg): inputs = dict( zero=0, intmax=0x7fffffff, - intmin=-0x80000000, + intmin=-0x7fffffff, ) preamble = """ uniform int zero; @@ -178,7 +178,7 @@ def test_glsl_int(gsg): code = """ assert(zero == 0); assert(intmax == 0x7fffffff); - assert(intmin == -0x80000000); + assert(intmin == -0x7fffffff); """ run_glsl_test(gsg, code, preamble, inputs) From e673937384ae2303809db43d8fa513527e01e4c2 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 9 Jul 2018 16:02:06 +0200 Subject: [PATCH 066/360] parser-inc: add include to unordered_map/set for allocator --- dtool/src/parser-inc/unordered_map | 3 ++- dtool/src/parser-inc/unordered_set | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dtool/src/parser-inc/unordered_map b/dtool/src/parser-inc/unordered_map index e3c6220d35..035932bd49 100644 --- a/dtool/src/parser-inc/unordered_map +++ b/dtool/src/parser-inc/unordered_map @@ -24,9 +24,10 @@ #include #include #include +#include namespace std { - + template , diff --git a/dtool/src/parser-inc/unordered_set b/dtool/src/parser-inc/unordered_set index 766161d12b..53b6d794c8 100644 --- a/dtool/src/parser-inc/unordered_set +++ b/dtool/src/parser-inc/unordered_set @@ -24,6 +24,7 @@ #include #include #include +#include namespace std { @@ -46,7 +47,7 @@ namespace std { typedef typename allocator_type::const_reference const_reference; typedef size_t size_type; typedef std::ptrdiff_t difference_type; - + class iterator; class const_iterator; class local_iterator; From fbce833aae112d1bc3c99a8d851337de7575d0c8 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 9 Jul 2018 16:09:50 +0200 Subject: [PATCH 067/360] pgui: reduce unnecessary locking in PGItem A deadlock has been observed if the lock is held while traversing the scene graph, so the need for locking in cull_callback is now reduced. --- panda/src/pgui/pgItem.I | 13 ++++ panda/src/pgui/pgItem.cxx | 133 ++++++++++++++++++++++---------------- panda/src/pgui/pgItem.h | 8 ++- 3 files changed, 97 insertions(+), 57 deletions(-) diff --git a/panda/src/pgui/pgItem.I b/panda/src/pgui/pgItem.I index f60e4a256c..cfbf10f6b0 100644 --- a/panda/src/pgui/pgItem.I +++ b/panda/src/pgui/pgItem.I @@ -202,6 +202,19 @@ get_suppress_flags() const { return _region->get_suppress_flags(); } +/** + * Returns the Node that is the root of the subgraph that will be drawn when + * the PGItem is in the indicated state. The first time this is called for a + * particular state index, it may create the Node. + */ +INLINE NodePath &PGItem:: +get_state_def(int state) { + nassertr(state >= 0 && state < 1000, get_state_def(0)); // Sanity check. + + LightReMutexHolder holder(_lock); + return do_get_state_def(state); +} + /** * Returns the unique ID assigned to this PGItem. This will be assigned to * the region created with the MouseWatcher, and will thus be used to generate diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index 582c12985b..a266547ced 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -35,8 +35,6 @@ #include "audioSound.h" #endif -using std::max; -using std::min; using std::string; TypeHandle PGItem::_type_handle; @@ -59,16 +57,15 @@ is_right(const LVector2 &v1, const LVector2 &v2) { PGItem:: PGItem(const string &name) : PandaNode(name), - _lock(name) + _lock(name), + _notify(nullptr), + _has_frame(false), + _frame(0, 0, 0, 0), + _region(new PGMouseWatcherRegion(this)), + _state(0), + _flags(0) { set_cull_callback(); - - _notify = nullptr; - _has_frame = false; - _frame.set(0, 0, 0, 0); - _region = new PGMouseWatcherRegion(this); - _state = 0; - _flags = 0; } /** @@ -96,17 +93,16 @@ PGItem:: PGItem:: PGItem(const PGItem ©) : PandaNode(copy), + _notify(nullptr), _has_frame(copy._has_frame), _frame(copy._frame), _state(copy._state), - _flags(copy._flags) + _flags(copy._flags), + _region(new PGMouseWatcherRegion(this)) #ifdef HAVE_AUDIO , _sounds(copy._sounds) #endif { - _notify = nullptr; - _region = new PGMouseWatcherRegion(this); - // We give our region the same name as the region for the PGItem we're // copying--so that this PGItem will generate the same event names when the // user interacts with it. @@ -190,9 +186,29 @@ draw_mask_changed() { */ bool PGItem:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - LightReMutexHolder holder(_lock); - bool this_node_hidden = data.is_this_node_hidden(trav->get_camera_mask()); - if (!this_node_hidden && has_frame() && get_active()) { + // We try not to hold the lock for longer than necessary. + PT(PandaNode) state_def_root; + bool has_frame; + PGMouseWatcherRegion *region; + { + LightReMutexHolder holder(_lock); + has_frame = _has_frame && ((_flags & F_active) != 0); + region = _region; + + int state = _state; + if (state >= 0 && (size_t)state < _state_defs.size()) { + StateDef &state_def = _state_defs[state]; + if (!state_def._root.is_empty()) { + if (state_def._frame_stale) { + update_frame(state); + } + + state_def_root = state_def._root.node(); + } + } + } + + if (has_frame && !data.is_this_node_hidden(trav->get_camera_mask())) { // The item has a frame, so we want to generate a region for it and update // the MouseWatcher. @@ -202,8 +218,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { PGCullTraverser *pg_trav; DCAST_INTO_R(pg_trav, trav, true); - CPT(TransformState) net_transform = data.get_net_transform(trav); - const LMatrix4 &transform = net_transform->get_mat(); + const LMatrix4 &transform = data.get_net_transform(trav)->get_mat(); // Consider the cull bin this object is in. Since the binning affects // the render order, we want bins that render later to get higher sort @@ -240,19 +255,20 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // the existing interface which only provides one. sort = (bin_sort << 16) | ((sort + 0x8000) & 0xffff); - if (activate_region(transform, sort, - DCAST(ClipPlaneAttrib, data._state->get_attrib(ClipPlaneAttrib::get_class_slot())), - DCAST(ScissorAttrib, data._state->get_attrib(ScissorAttrib::get_class_slot())))) { - pg_trav->_top->add_region(get_region()); + const ClipPlaneAttrib *clip = nullptr; + const ScissorAttrib *scissor = nullptr; + data._state->get_attrib(clip); + data._state->get_attrib(scissor); + if (activate_region(transform, sort, clip, scissor)) { + pg_trav->_top->add_region(region); } } } - if (has_state_def(get_state())) { + if (state_def_root != nullptr) { // This item has a current state definition that we should use to render // the item. - NodePath &root = get_state_def(get_state()); - CullTraverserData next_data(data, root.node()); + CullTraverserData next_data(data, state_def_root); trav->traverse(next_data); } @@ -306,7 +322,7 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, // get_state_def() on each one, to ensure that the frames are updated // correctly before we measure their bounding volumes. for (int i = 0; i < (int)_state_defs.size(); i++) { - NodePath &root = ((PGItem *)this)->get_state_def(i); + NodePath &root = ((PGItem *)this)->do_get_state_def(i); if (!root.is_empty()) { PandaNode *node = root.node(); child_volumes.push_back(node->get_bounds(current_thread)); @@ -388,6 +404,9 @@ bool PGItem:: activate_region(const LMatrix4 &transform, int sort, const ClipPlaneAttrib *cpa, const ScissorAttrib *sa) { + using std::min; + using std::max; + LightReMutexHolder holder(_lock); // Transform all four vertices, and get the new bounding box. This way the // region works (mostly) even if has been rotated. @@ -935,30 +954,6 @@ clear_state_def(int state) { mark_internal_bounds_stale(); } -/** - * Returns the Node that is the root of the subgraph that will be drawn when - * the PGItem is in the indicated state. The first time this is called for a - * particular state index, it may create the Node. - */ -NodePath &PGItem:: -get_state_def(int state) { - LightReMutexHolder holder(_lock); - nassertr(state >= 0 && state < 1000, get_state_def(0)); // Sanity check. - slot_state_def(state); - - if (_state_defs[state]._root.is_empty()) { - // Create a new node. - _state_defs[state]._root = NodePath("state_" + format_string(state)); - _state_defs[state]._frame_stale = true; - } - - if (_state_defs[state]._frame_stale) { - update_frame(state); - } - - return _state_defs[state]._root; -} - /** * Parents an instance of the bottom node of the indicated NodePath to the * indicated state index. @@ -973,7 +968,7 @@ instance_to_state_def(int state, const NodePath &path) { mark_internal_bounds_stale(); - return path.instance_to(get_state_def(state)); + return path.instance_to(do_get_state_def(state)); } /** @@ -998,7 +993,7 @@ set_frame_style(int state, const PGFrameStyle &style) { LightReMutexHolder holder(_lock); // Get the state def node, mainly to ensure that this state is slotted and // listed as having been defined. - NodePath &root = get_state_def(state); + NodePath &root = do_get_state_def(state); nassertv(!root.is_empty()); _state_defs[state]._frame_style = style; @@ -1097,6 +1092,9 @@ play_sound(const string &event) { */ void PGItem:: reduce_region(LVecBase4 &frame, PGItem *obscurer) const { + using std::min; + using std::max; + if (obscurer != nullptr && !obscurer->is_overall_hidden()) { LVecBase4 oframe = get_relative_frame(obscurer); @@ -1124,6 +1122,9 @@ reduce_region(LVecBase4 &frame, PGItem *obscurer) const { */ LVecBase4 PGItem:: get_relative_frame(PGItem *item) const { + using std::min; + using std::max; + NodePath this_np = NodePath::any_path((PGItem *)this); NodePath item_np = this_np.find_path_to(item); if (item_np.is_empty()) { @@ -1174,6 +1175,30 @@ frame_changed() { } } +/** + * Returns the Node that is the root of the subgraph that will be drawn when + * the PGItem is in the indicated state. The first time this is called for a + * particular state index, it may create the Node. + * + * Assumes the lock is already held. + */ +NodePath &PGItem:: +do_get_state_def(int state) { + slot_state_def(state); + + if (_state_defs[state]._root.is_empty()) { + // Create a new node. + _state_defs[state]._root = NodePath("state_" + format_string(state)); + _state_defs[state]._frame_stale = true; + } + + if (_state_defs[state]._frame_stale) { + update_frame(state); + } + + return _state_defs[state]._root; +} + /** * Ensures there is a slot in the array for the given state definition. */ @@ -1200,7 +1225,7 @@ update_frame(int state) { // Now create new frame geometry. if (has_frame()) { - NodePath &root = get_state_def(state); + NodePath &root = do_get_state_def(state); _state_defs[state]._frame = _state_defs[state]._frame_style.generate_into(root, _frame); } diff --git a/panda/src/pgui/pgItem.h b/panda/src/pgui/pgItem.h index fc7f8ff6d4..2c26f91602 100644 --- a/panda/src/pgui/pgItem.h +++ b/panda/src/pgui/pgItem.h @@ -77,11 +77,12 @@ protected: GeomTransformer &transformer, Thread *current_thread); -public: virtual void xform(const LMatrix4 &mat); bool activate_region(const LMatrix4 &transform, int sort, const ClipPlaneAttrib *cpa, const ScissorAttrib *sa); + +public: INLINE PGMouseWatcherRegion *get_region() const; virtual void enter_region(const MouseWatcherParameter ¶m); @@ -130,7 +131,7 @@ PUBLISHED: int get_num_state_defs() const; void clear_state_def(int state); bool has_state_def(int state) const; - NodePath &get_state_def(int state); + INLINE NodePath &get_state_def(int state); MAKE_SEQ(get_state_defs, get_num_state_defs, get_state_def); NodePath instance_to_state_def(int state, const NodePath &path); @@ -187,6 +188,7 @@ protected: virtual void frame_changed(); private: + NodePath &do_get_state_def(int state); void slot_state_def(int state); void update_frame(int state); void mark_frames_stale(); @@ -215,7 +217,7 @@ private: }; int _flags; - PT(PGMouseWatcherRegion) _region; + PT(PGMouseWatcherRegion) const _region; LMatrix4 _frame_inv_xform; From 55146b9f82645873b92d45953fd764c81ee4c638 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 9 Jul 2018 17:09:11 +0200 Subject: [PATCH 068/360] dxgsg9: fix compilation error with WeakPointerTo comparison --- panda/src/dxgsg9/dxGeomMunger9.I | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/panda/src/dxgsg9/dxGeomMunger9.I b/panda/src/dxgsg9/dxGeomMunger9.I index 596802b871..cc972bf94b 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.I +++ b/panda/src/dxgsg9/dxGeomMunger9.I @@ -17,14 +17,21 @@ INLINE DXGeomMunger9:: DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : StandardMunger(gsg, state, 1, NT_packed_dabc, C_color), - _texture(DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_slot()))), - _tex_gen(DCAST(TexGenAttrib, state->get_attrib(TexGenAttrib::get_class_slot()))) + _texture(nullptr), + _tex_gen(nullptr) { + const TextureAttrib *texture = nullptr; + const TexGenAttrib *tex_gen = nullptr; + state->get_attrib(texture); + state->get_attrib(tex_gen); + _texture = texture; + _tex_gen = tex_gen; + _filtered_texture = nullptr; _reffed_filtered_texture = false; - if (_texture != nullptr) { - _filtered_texture = _texture->filter_to_max(gsg->get_max_texture_stages()); - if (_filtered_texture != _texture) { + if (texture != nullptr) { + _filtered_texture = texture->filter_to_max(gsg->get_max_texture_stages()); + if (_filtered_texture != texture) { _filtered_texture->ref(); _reffed_filtered_texture = true; } From ff3d0052307991c357cddf5ee1bb8a17f02c3a32 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 11 Jul 2018 13:32:39 +0200 Subject: [PATCH 069/360] x11display: fix Xlib thread safety problems --- panda/src/x11display/x11GraphicsWindow.cxx | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 5eef6b2ea5..d1f49eedc3 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -136,10 +136,11 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, */ x11GraphicsWindow:: ~x11GraphicsWindow() { - pmap::iterator it; - - for (it = _cursor_filenames.begin(); it != _cursor_filenames.end(); it++) { - XFreeCursor(_display, it->second); + if (!_cursor_filenames.empty()) { + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); + for (auto item : _cursor_filenames) { + XFreeCursor(_display, item.second); + } } } @@ -157,17 +158,21 @@ get_pointer(int device) const { result = _input_devices[device].get_pointer(); - // We recheck this immediately to get the most up-to-date value. - if (device == 0 && !_dga_mouse_enabled && result._in_window) { + // We recheck this immediately to get the most up-to-date value, but we + // won't bother waiting for the lock if we can't. + if (device == 0 && !_dga_mouse_enabled && result._in_window && + x11GraphicsPipe::_x_mutex.try_lock()) { XEvent event; + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); if (XQueryPointer(_display, _xwindow, &event.xbutton.root, &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state)) { double time = ClockObject::get_global_clock()->get_real_time(); result._xpos = event.xbutton.x; result._ypos = event.xbutton.y; - ((GraphicsWindowInputDevice &)_input_devices[0]).set_pointer(result._in_window, result._xpos, result._ypos, time); + ((GraphicsWindowInputDevice &)_input_devices[0]).set_pointer_in_window(result._xpos, result._ypos, time); } + x11GraphicsPipe::_x_mutex.release(); } } return result; @@ -197,6 +202,7 @@ move_pointer(int device, int x, int y) { const MouseData &md = _input_devices[0].get_pointer(); if (!md.get_in_window() || md.get_x() != x || md.get_y() != y) { if (!_dga_mouse_enabled) { + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); XWarpPointer(_display, None, _xwindow, 0, 0, 0, 0, x, y); } _input_devices[0].set_pointer_in_window(x, y); @@ -532,6 +538,8 @@ set_properties_now(WindowProperties &properties) { x11GraphicsPipe *x11_pipe; DCAST_INTO_V(x11_pipe, _pipe); + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); + // We're either going into or out of fullscreen, or are in fullscreen and // are changing the resolution. bool is_fullscreen = _properties.has_fullscreen() && _properties.get_fullscreen(); @@ -858,6 +866,7 @@ close_window() { _gsg.clear(); } + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); if (_ic != (XIC)nullptr) { XDestroyIC(_ic); _ic = (XIC)nullptr; @@ -916,6 +925,9 @@ open_window() { _properties.set_size(100, 100); } + // Make sure we are not making X11 calls from other threads. + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); + if (_properties.get_fullscreen() && x11_pipe->_have_xrandr) { XRRScreenConfiguration* conf = _XRRGetScreenInfo(_display, x11_pipe->get_root()); if (_orig_size_id == (SizeID) -1) { @@ -1059,6 +1071,8 @@ open_window() { * If already_mapped is true, the window has already been mapped (manifested) * on the display. This means we may need to use a different action in some * cases. + * + * Assumes the X11 lock is held. */ void x11GraphicsWindow:: set_wm_properties(const WindowProperties &properties, bool already_mapped) { From 16daf08e42fba21a3e919a0733db76228fd963a5 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 11 Jul 2018 13:33:50 +0200 Subject: [PATCH 070/360] glgsg: fix some GCC warning messages --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 6 ++++++ panda/src/glstuff/glShaderContext_src.cxx | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index b167f1baa8..8df6b605bb 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -613,6 +613,8 @@ reset() { get_extension_func("glDebugMessageControlARB"); _supports_debug = true; #endif + } else { + _supports_debug = false; } if (_supports_debug) { @@ -12778,7 +12780,9 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, int width = tex->get_expected_mipmap_x_size(n); int height = tex->get_expected_mipmap_y_size(n); +#ifndef OPENGLES_1 int depth = tex->get_expected_mipmap_z_size(n); +#endif #ifdef DO_PSTATS _data_transferred_pcollector.add_level(view_size); @@ -12958,7 +12962,9 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, int width = tex->get_expected_mipmap_x_size(n); int height = tex->get_expected_mipmap_y_size(n); +#ifndef OPENGLES_1 int depth = tex->get_expected_mipmap_z_size(n); +#endif #ifdef DO_PSTATS _data_transferred_pcollector.add_level(view_size); diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index ac9b28e784..94adf2f6a8 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -2612,8 +2612,8 @@ update_shader_texture_bindings(ShaderContext *prev) { } size_t num_textures = _shader->_tex_spec.size(); - GLuint *textures; - GLuint *samplers; + GLuint *textures = nullptr; + GLuint *samplers = nullptr; #ifdef OPENGLES static const bool multi_bind = false; #else From 828233a8f2e8423c5b0c9ee177a329abb671b82f Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 12 Jul 2018 11:39:57 +0200 Subject: [PATCH 071/360] glgsg: support gl-depth-zero-to-one to get same NDC Z range as D3D --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 12 +++- .../glstuff/glGraphicsStateGuardian_src.cxx | 65 ++++++++++++++++++- .../src/glstuff/glGraphicsStateGuardian_src.h | 6 ++ panda/src/glstuff/glmisc_src.cxx | 7 ++ 4 files changed, 87 insertions(+), 3 deletions(-) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index f46c8288f1..50491df38d 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -864,14 +864,22 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, case RTP_depth_stencil: if (_fb_properties.get_depth_bits() > 24 || _fb_properties.get_float_depth()) { - gl_format = GL_DEPTH32F_STENCIL8; + if (!glgsg->_use_remapped_depth_range) { + gl_format = GL_DEPTH32F_STENCIL8; + } else { + gl_format = GL_DEPTH32F_STENCIL8_NV; + } } else { gl_format = GL_DEPTH24_STENCIL8; } break; case RTP_depth: if (_fb_properties.get_float_depth()) { - gl_format = GL_DEPTH_COMPONENT32F; + if (!glgsg->_use_remapped_depth_range) { + gl_format = GL_DEPTH_COMPONENT32F; + } else { + gl_format = GL_DEPTH_COMPONENT32F_NV; + } } else if (_fb_properties.get_depth_bits() > 24) { gl_format = GL_DEPTH_COMPONENT32; } else if (_fb_properties.get_depth_bits() > 16) { diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 8df6b605bb..74080f274f 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -2997,6 +2997,50 @@ reset() { } #endif + // Set depth range from zero to one if requested. +#ifndef OPENGLES + _use_depth_zero_to_one = false; + _use_remapped_depth_range = false; + + if (gl_depth_zero_to_one) { + if (is_at_least_gl_version(4, 5) || has_extension("GL_ARB_clip_control")) { + PFNGLCLIPCONTROLPROC pglClipControl = + (PFNGLCLIPCONTROLPROC)get_extension_func("glClipControl"); + + if (pglClipControl != nullptr) { + pglClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE); + _use_depth_zero_to_one = true; + + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Set zero-to-one depth using glClipControl\n"; + } + } + }/* else if (has_extension("GL_NV_depth_buffer_float")) { + // Alternatively, all GeForce 8+ and even some AMD drivers support this + // extension, which (unlike the core glDepthRange, which clamps its + // input parameters) can compensate for the built-in depth remapping. + _glDepthRangedNV = (PFNGLDEPTHRANGEDNVPROC)get_extension_func("glDepthRangedNV"); + + if (_glDepthRangedNV != nullptr) { + _glDepthRangedNV(-1.0, 1.0); + _use_depth_zero_to_one = true; + _use_remapped_depth_range = true; + + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Set zero-to-one depth using glDepthRangedNV\n"; + } + } + }*/ + + if (!_use_depth_zero_to_one) { + GLCAT.warning() + << "Zero-to-one depth was requested, but driver does not support it.\n"; + } + } +#endif + // Set up all the enableddisabled flags to GL's known initial values: // everything off. _multisample_mode = 0; @@ -3646,6 +3690,19 @@ calc_projection_mat(const Lens *lens) { lens->get_coordinate_system()) * lens->get_projection_mat(_current_stereo_channel); +#ifndef OPENGLES + if (_use_depth_zero_to_one) { + // If we requested that the OpenGL NDC Z goes from zero to one like in + // Direct3D, we need to scale the projection matrix, which assumes -1..1. + static const LMatrix4 rescale_mat + (1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 0.5, 0, + 0, 0, 0.5, 1); + result *= rescale_mat; + } +#endif + if (_scene_setup->get_inverted()) { // If the scene is supposed to be inverted, then invert the projection // matrix. @@ -7452,7 +7509,13 @@ do_issue_depth_offset() { glDepthRangef((GLclampf)min_value, (GLclampf)max_value); #else // Mainline OpenGL uses a double-precision call. - glDepthRange((GLclampd)min_value, (GLclampd)max_value); + if (!_use_remapped_depth_range) { + glDepthRange((GLclampd)min_value, (GLclampd)max_value); + } else { + // If we have a remapped depth range, we should adjust the values to range + // from -1 to 1. We need to use an NV extension to pass unclamped values. + _glDepthRangedNV(min_value * 2.0 - 1.0, max_value * 2.0 - 1.0); + } #endif // OPENGLES report_my_gl_errors(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index c0f75a21d5..d00478a58d 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -743,6 +743,12 @@ protected: #endif public: +#ifndef OPENGLES + bool _use_depth_zero_to_one; + bool _use_remapped_depth_range; + PFNGLDEPTHRANGEDNVPROC _glDepthRangedNV; +#endif + bool _supports_point_parameters; PFNGLPOINTPARAMETERFVPROC _glPointParameterfv; bool _supports_point_sprite; diff --git a/panda/src/glstuff/glmisc_src.cxx b/panda/src/glstuff/glmisc_src.cxx index fd2bcf7aee..08e200a4a0 100644 --- a/panda/src/glstuff/glmisc_src.cxx +++ b/panda/src/glstuff/glmisc_src.cxx @@ -313,6 +313,13 @@ ConfigVariableEnum gl_coordinate_system "creating a shader-only application, it may be easier and " "more efficient to set this to default.")); +ConfigVariableBool gl_depth_zero_to_one + ("gl-depth-zero-to-one", false, + PRC_DESC("Normally, OpenGL uses an NDC coordinate space wherein the Z " + "ranges from -1 to 1. This setting can be used to instead use a " + "range from 0 to 1, matching other graphics APIs. This setting " + "requires OpenGL 4.5, or NVIDIA GeForce 8+ hardware.")); + extern ConfigVariableBool gl_parallel_arrays; void CLP(init_classes)() { From e41eeaae23d9bb99a9560b26df8920ef784b6f8f Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 12 Jul 2018 14:17:02 +0200 Subject: [PATCH 072/360] glgsg: if 32-bit unorm depth is not available, fallback to float This prevents falling back to 24-bit depth if 32-bit depth is requested. --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 50491df38d..66a9e6d407 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -989,6 +989,23 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, GLint depth_size = 0; glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, gl_format, _rb_size_x, _rb_size_y); glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_DEPTH_SIZE_EXT, &depth_size); + +#ifndef OPENGLES + // Are we getting only 24 bits of depth when we requested 32? It may be + // because GL_DEPTH_COMPONENT32 is not a required format, while 32F is. + if (gl_format == GL_DEPTH_COMPONENT32 && depth_size < 32) { + if (!glgsg->_use_remapped_depth_range) { + gl_format = GL_DEPTH_COMPONENT32F; + } else { + gl_format = GL_DEPTH_COMPONENT32F_NV; + } + glgsg->_glRenderbufferStorage(GL_RENDERBUFFER_EXT, gl_format, _rb_size_x, _rb_size_y); + glgsg->_glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_DEPTH_SIZE_EXT, &depth_size); + + _fb_properties.set_float_depth(true); + } +#endif + _fb_properties.set_depth_bits(depth_size); _rb_data_size_bytes += _rb_size_x * _rb_size_y * (depth_size / 8); From c434e08a9c3d6b463124a3d461ebfe9e00e9005e Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 12 Jul 2018 14:20:13 +0200 Subject: [PATCH 073/360] tests: add various depth buffer rendering tests --- tests/display/test_depth_buffer.py | 150 +++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 tests/display/test_depth_buffer.py diff --git a/tests/display/test_depth_buffer.py b/tests/display/test_depth_buffer.py new file mode 100644 index 0000000000..02b0c11b69 --- /dev/null +++ b/tests/display/test_depth_buffer.py @@ -0,0 +1,150 @@ +from panda3d import core +import pytest + + +@pytest.fixture(scope='module', params=[32, 24, 16]) +def depth_region(request, graphics_pipe): + """Creates and returns a DisplayRegion with a depth buffer.""" + + engine = core.GraphicsEngine() + engine.set_threading_model("") + + host_fbprops = core.FrameBufferProperties() + host_fbprops.force_hardware = True + + host = engine.make_output( + graphics_pipe, + 'host', + 0, + host_fbprops, + core.WindowProperties.size(32, 32), + core.GraphicsPipe.BF_refuse_window, + ) + engine.open_windows() + + if host is None: + pytest.skip("GraphicsPipe cannot make offscreen buffers") + + fbprops = core.FrameBufferProperties() + fbprops.force_hardware = True + fbprops.depth_bits = request.param + + if fbprops.depth_bits >= 32: + fbprops.float_depth = True + + buffer = engine.make_output( + graphics_pipe, + 'buffer', + 0, + fbprops, + core.WindowProperties.size(32, 32), + core.GraphicsPipe.BF_refuse_window, + host.gsg, + host + ) + engine.open_windows() + + if buffer is None: + pytest.skip("Cannot make depth buffer") + + if buffer.get_fb_properties().depth_bits != request.param: + pytest.skip("Could not make buffer with desired bit count") + + yield buffer.make_display_region() + + if buffer is not None: + engine.remove_window(buffer) + + +def render_depth_pixel(region, distance, near, far, clear=None, write=True): + """Renders a fragment at the specified distance using the specified render + settings, and returns the resulting depth value.""" + + # Set up the scene with a blank card rendering at specified distance. + scene = core.NodePath("root") + scene.set_attrib(core.DepthTestAttrib.make(core.RenderAttrib.M_always)) + scene.set_depth_write(write) + + camera = scene.attach_new_node(core.Camera("camera")) + camera.node().get_lens(0).set_near_far(near, far) + camera.node().set_cull_bounds(core.OmniBoundingVolume()) + + if distance is not None: + cm = core.CardMaker("card") + cm.set_frame(-1, 1, -1, 1) + card = scene.attach_new_node(cm.generate()) + card.set_pos(0, distance, 0) + card.set_scale(60) + + region.active = True + region.camera = camera + + if clear is not None: + region.set_clear_depth_active(True) + region.set_clear_depth(clear) + + depth_texture = core.Texture("depth") + region.window.add_render_texture(depth_texture, + core.GraphicsOutput.RTM_copy_ram, + core.GraphicsOutput.RTP_depth) + + region.window.engine.render_frame() + region.window.clear_render_textures() + + depth_texture.write("test2.png") + + col = core.LColor() + depth_texture.peek().lookup(col, 0.5, 0.5) + return col[0] + + +def test_depth_clear(depth_region): + assert 1.0 == render_depth_pixel(depth_region, None, near=1, far=10, clear=1.0) + assert 0.0 == render_depth_pixel(depth_region, None, near=1, far=10, clear=0.0) + + +def test_depth_write(depth_region): + assert 1.0 == render_depth_pixel(depth_region, 5.0, near=1, far=10, clear=1.0, write=False) + assert 0.99 > render_depth_pixel(depth_region, 5.0, near=1, far=10, clear=1.0, write=True) + + +def test_depth_far_inf(depth_region): + inf = float("inf") + assert 0.99 > render_depth_pixel(depth_region, 100.0, near=1, far=inf, clear=1.0) + + +def test_depth_clipping(depth_region): + # Get the actual depth resulting from the clear value. + clr = render_depth_pixel(depth_region, None, near=1, far=10, clear=0.5) + + # We try rendering something at various distances to make sure that the + # resulting depth value matches our expectations. + + # Too close; read clear value. + assert clr == render_depth_pixel(depth_region, 0.999, near=1, far=10, clear=0.5) + + # Too far; read clear value. + assert clr == render_depth_pixel(depth_region, 10.01, near=1, far=10, clear=0.5) + + # Just close enough; read a value close to 0.0. + assert 0.01 > render_depth_pixel(depth_region, 1.001, near=1, far=10, clear=0.5) + + # Just far enough; read 1.0. + assert 0.99 < render_depth_pixel(depth_region, 9.999, near=1, far=10, clear=0.5) + + +def test_inverted_depth_clipping(depth_region): + # Get the actual depth resulting from the clear value. + clr = render_depth_pixel(depth_region, None, near=1, far=10, clear=0.5) + + # Too close; read clear value. + assert clr == render_depth_pixel(depth_region, 0.999, near=10, far=1, clear=0.5) + + # Too far; read clear value. + assert clr == render_depth_pixel(depth_region, 10.01, near=10, far=1, clear=0.5) + + # Just close enough; read a value close to 1.0. + assert 0.99 < render_depth_pixel(depth_region, 1.001, near=10, far=1, clear=0.5) + + # Just far enough; read a value close to 0.0. + assert 0.01 > render_depth_pixel(depth_region, 9.999, near=10, far=1, clear=0.5) From 10fe8659c656c5ce33a35897baa5c2cd12ee7f3f Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 12 Jul 2018 14:22:27 +0200 Subject: [PATCH 074/360] gobj: work around a deadlock in GeomCacheManager::flush() --- panda/src/gobj/geomCacheManager.cxx | 5 +++++ panda/src/gobj/geomMunger.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/panda/src/gobj/geomCacheManager.cxx b/panda/src/gobj/geomCacheManager.cxx index 7fef373373..4eb06a25b4 100644 --- a/panda/src/gobj/geomCacheManager.cxx +++ b/panda/src/gobj/geomCacheManager.cxx @@ -13,7 +13,9 @@ #include "geomCacheManager.h" #include "geomCacheEntry.h" +#include "geomMunger.h" #include "lightMutexHolder.h" +#include "lightReMutexHolder.h" #include "clockObject.h" GeomCacheManager *GeomCacheManager::_global_ptr = nullptr; @@ -53,6 +55,9 @@ GeomCacheManager:: */ void GeomCacheManager:: flush() { + // Prevent deadlock + LightReMutexHolder registry_holder(GeomMunger::get_registry()->_registry_lock); + LightMutexHolder holder(_lock); evict_old_entries(0, false); } diff --git a/panda/src/gobj/geomMunger.h b/panda/src/gobj/geomMunger.h index 00105108bf..e8aa67bd61 100644 --- a/panda/src/gobj/geomMunger.h +++ b/panda/src/gobj/geomMunger.h @@ -149,6 +149,8 @@ private: static PStatCollector _munge_pcollector; + friend class GeomCacheManager; + public: static TypeHandle get_class_type() { return _type_handle; From 61084a3f4e54555d741302c0f8e0d26309033e47 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 12 Jul 2018 14:24:40 +0200 Subject: [PATCH 075/360] pgraph: work around C++11 bug in something or other (see #355) --- panda/src/pgraph/cacheStats.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/pgraph/cacheStats.h b/panda/src/pgraph/cacheStats.h index 5658a0472f..daeeb5340d 100644 --- a/panda/src/pgraph/cacheStats.h +++ b/panda/src/pgraph/cacheStats.h @@ -24,7 +24,7 @@ */ class EXPCL_PANDA_PGRAPH CacheStats { public: - constexpr CacheStats() = default; + CacheStats() = default; void init(); void reset(double now); void write(std::ostream &out, const char *name) const; From 799f0b4f7881bc36a4a061c1cacec0beacad4e6d Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 17:04:50 +0200 Subject: [PATCH 076/360] glgsg: work around driver bug extracting buffer texture data Some drivers would report the wrong internal format. But it's silly that we query the internal format anyway, since buffer textures have a fixed sized internal format. --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 74080f274f..90bbaecf40 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -13442,7 +13442,14 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { GLint internal_format = GL_RGBA; #ifndef OPENGLES - glGetTexLevelParameteriv(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format); + if (target != GL_TEXTURE_BUFFER) { + glGetTexLevelParameteriv(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format); + } else { + // Some drivers give the wrong result for the above call. No problem; we + // already know the internal format of a buffer texture since glTexBuffer + // required passing the exact sized format. + internal_format = gtc->_internal_format; + } #endif // OPENGLES // Make sure we were able to query those parameters properly. From 6cd59807dd63553f149211a617b7f40627ba1028 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 19:38:10 +0200 Subject: [PATCH 077/360] Remove useless test_display.cxx file --- makepanda/makepanda.vcproj | 1 - panda/src/display/test_display.cxx | 18 ------------------ 2 files changed, 19 deletions(-) delete mode 100644 panda/src/display/test_display.cxx diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj index b8bdcbf07b..23ed91cdf5 100644 --- a/makepanda/makepanda.vcproj +++ b/makepanda/makepanda.vcproj @@ -1379,7 +1379,6 @@ - diff --git a/panda/src/display/test_display.cxx b/panda/src/display/test_display.cxx deleted file mode 100644 index 6adfdaf269..0000000000 --- a/panda/src/display/test_display.cxx +++ /dev/null @@ -1,18 +0,0 @@ -/** - * 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." - * - * @file test_display.cxx - * @author shochet - * @date 2000-02-02 - */ - -#include "graphicsWindow.h" - -int main() { - return 0; -} From 57578ee58fc4fa89d7b928f5246029b74c5740a3 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 22:20:35 +0200 Subject: [PATCH 078/360] direct: add MetaInterval underscore aliases (fixes override bug) These methods are supposed to override the underlying C methods, which do have underscore aliases, so it is important that the Python class defines these underscore aliases as well. --- direct/src/interval/MetaInterval.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/direct/src/interval/MetaInterval.py b/direct/src/interval/MetaInterval.py index 259d7f66a3..4f31c9839d 100644 --- a/direct/src/interval/MetaInterval.py +++ b/direct/src/interval/MetaInterval.py @@ -573,7 +573,23 @@ class MetaInterval(CMetaInterval): out = ostream CMetaInterval.timeline(self, out) - + add_sequence = addSequence + add_parallel = addParallel + add_parallel_end_together = addParallelEndTogether + add_track = addTrack + add_interval = addInterval + set_manager = setManager + get_manager = getManager + set_t = setT + resume_until = resumeUntil + clear_to_initial = clearToInitial + clear_intervals = clearIntervals + set_play_rate = setPlayRate + priv_do_event = privDoEvent + priv_post_event = privPostEvent + set_interval_start_time = setIntervalStartTime + get_interval_start_time = getIntervalStartTime + get_duration = getDuration class Sequence(MetaInterval): From 684a58e7e91394213d9649bb0dcef638163b33ca Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 22:21:44 +0200 Subject: [PATCH 079/360] parser-inc: add timespec --- dtool/src/parser-inc/time.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dtool/src/parser-inc/time.h b/dtool/src/parser-inc/time.h index 74093ee881..23e49129d2 100644 --- a/dtool/src/parser-inc/time.h +++ b/dtool/src/parser-inc/time.h @@ -1 +1,8 @@ +#pragma once + #include + +struct timespec { + time_t tv_sec; + long tv_nsec; +}; From 71b4b807f8173b683b76936c0f7d7fe8bbd2b556 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 22:24:35 +0200 Subject: [PATCH 080/360] collide: add line-into-box test, improve segment/ray into box --- panda/src/collide/collisionBox.cxx | 239 ++++++++++++++++------------- panda/src/collide/collisionBox.h | 7 + 2 files changed, 141 insertions(+), 105 deletions(-) diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index 46666722e2..494013c75b 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -398,6 +398,49 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { return new_entry; } +/** + * + */ +PT(CollisionEntry) CollisionBox:: +test_intersection_from_line(const CollisionEntry &entry) const { + const CollisionLine *line; + DCAST_INTO_R(line, entry.get_from(), nullptr); + + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); + + LPoint3 from_origin = line->get_origin() * wrt_mat; + LVector3 from_direction = line->get_direction() * wrt_mat; + + double t1, t2; + if (!intersects_line(t1, t2, from_origin, from_direction)) { + // No intersection. + return nullptr; + } + + if (collide_cat.is_debug()) { + collide_cat.debug() + << "intersection detected from " << entry.get_from_node_path() + << " into " << entry.get_into_node_path() << "\n"; + } + PT(CollisionEntry) new_entry = new CollisionEntry(entry); + + LPoint3 point = from_origin + t1 * from_direction; + new_entry->set_surface_point(point); + + if (has_effective_normal() && line->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else { + LVector3 normal( + IS_NEARLY_EQUAL(point[0], _max[0]) - IS_NEARLY_EQUAL(point[0], _min[0]), + IS_NEARLY_EQUAL(point[1], _max[1]) - IS_NEARLY_EQUAL(point[1], _min[1]), + IS_NEARLY_EQUAL(point[2], _max[2]) - IS_NEARLY_EQUAL(point[2], _min[2]) + ); + normal.normalize(); + new_entry->set_surface_normal(normal); + } + + return new_entry; +} /** * Double dispatch point for ray as a FROM object @@ -411,51 +454,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { LPoint3 from_origin = ray->get_origin() * wrt_mat; LVector3 from_direction = ray->get_direction() * wrt_mat; - int i, j; - PN_stdfloat t; - PN_stdfloat near_t = 0.0; - bool intersect; - LPlane plane; - LPlane near_plane; - - // Returns the details about the first plane of the box that the ray - // intersects. - for (i = 0, intersect = false, t = 0, j = 0; i < 6 && j < 2; i++) { - plane = get_plane(i); - - if (!plane.intersects_line(t, from_origin, from_direction)) { - // No intersection. The ray is parallel to the plane. - continue; - } - - if (t < 0.0f) { - // The intersection point is before the start of the ray, and so the ray - // is entirely in front of the plane. - continue; - } - LPoint3 plane_point = from_origin + t * from_direction; - LPoint2 p = to_2d(plane_point, i); - - if (!point_is_inside(p, _points[i])){ - continue; - } - intersect = true; - if (j) { - if(t < near_t) { - near_plane = plane; - near_t = t; - } - } - else { - near_plane = plane; - near_t = t; - } - ++j; - } - - - if(!intersect) { - // No intersection with ANY of the box's planes has been detected + double t1, t2; + if (!intersects_line(t1, t2, from_origin, from_direction) || (t1 < 0.0 && t2 < 0.0)) { + // No intersection. return nullptr; } @@ -464,22 +465,32 @@ test_intersection_from_ray(const CollisionEntry &entry) const { << "intersection detected from " << entry.get_from_node_path() << " into " << entry.get_into_node_path() << "\n"; } - PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3 into_intersection_point = from_origin + near_t * from_direction; + if (t1 < 0.0) { + // The origin is inside the box, so we take the exit as our surface point. + new_entry->set_interior_point(from_origin); + t1 = t2; + } - LVector3 normal = - (has_effective_normal() && ray->get_respect_effective_normal()) - ? get_effective_normal() : near_plane.get_normal(); + LPoint3 point = from_origin + t1 * from_direction; + new_entry->set_surface_point(point); - new_entry->set_surface_normal(normal); - new_entry->set_surface_point(into_intersection_point); + if (has_effective_normal() && ray->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else { + LVector3 normal( + IS_NEARLY_EQUAL(point[0], _max[0]) - IS_NEARLY_EQUAL(point[0], _min[0]), + IS_NEARLY_EQUAL(point[1], _max[1]) - IS_NEARLY_EQUAL(point[1], _min[1]), + IS_NEARLY_EQUAL(point[2], _max[2]) - IS_NEARLY_EQUAL(point[2], _min[2]) + ); + normal.normalize(); + new_entry->set_surface_normal(normal); + } return new_entry; } - /** * Double dispatch point for segment as a FROM object */ @@ -493,51 +504,10 @@ test_intersection_from_segment(const CollisionEntry &entry) const { LPoint3 from_extent = seg->get_point_b() * wrt_mat; LVector3 from_direction = from_extent - from_origin; - int i, j; - PN_stdfloat t; - PN_stdfloat near_t = 0.0; - bool intersect; - LPlane plane; - LPlane near_plane; - - // Returns the details about the first plane of the box that the segment - // intersects. - for(i = 0, intersect = false, t = 0, j = 0; i < 6 && j < 2; i++) { - plane = get_plane(i); - - if (!plane.intersects_line(t, from_origin, from_direction)) { - // No intersection. The segment is parallel to the plane. - continue; - } - - if (t < 0.0f || t > 1.0f) { - // The intersection point is before the start of the segment, or after - // the end of the segment, so the segment is either entirely in front of - // or behind the plane. - continue; - } - LPoint3 plane_point = from_origin + t * from_direction; - LPoint2 p = to_2d(plane_point, i); - - if (!point_is_inside(p, _points[i])){ - continue; - } - intersect = true; - if(j) { - if(t < near_t) { - near_plane = plane; - near_t = t; - } - } - else { - near_plane = plane; - near_t = t; - } - ++j; - } - - if(!intersect) { - // No intersection with ANY of the box's planes has been detected + double t1, t2; + if (!intersects_line(t1, t2, from_origin, from_direction) || + (t1 < 0.0 && t2 < 0.0) || (t1 > 1.0 && t2 > 1.0)) { + // No intersection. return nullptr; } @@ -546,17 +516,31 @@ test_intersection_from_segment(const CollisionEntry &entry) const { << "intersection detected from " << entry.get_from_node_path() << " into " << entry.get_into_node_path() << "\n"; } - PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LPoint3 into_intersection_point = from_origin + near_t * from_direction; + // In case the segment is entirely inside the cube, we consider the point + // closest to the surface as our entry point. + if (t1 < (1.0 - t2)) { + std::swap(t1, t2); + } - LVector3 normal = - (has_effective_normal() && seg->get_respect_effective_normal()) - ? get_effective_normal() : near_plane.get_normal(); + // Our interior point is the closest point to t2 that is inside the segment. + new_entry->set_interior_point(from_origin + std::min(std::max(t2, 0.0), 1.0) * from_direction); - new_entry->set_surface_normal(normal); - new_entry->set_surface_point(into_intersection_point); + LPoint3 point = from_origin + t1 * from_direction; + new_entry->set_surface_point(point); + + if (has_effective_normal() && seg->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else { + LVector3 normal( + IS_NEARLY_EQUAL(point[0], _max[0]) - IS_NEARLY_EQUAL(point[0], _min[0]), + IS_NEARLY_EQUAL(point[1], _max[1]) - IS_NEARLY_EQUAL(point[1], _min[1]), + IS_NEARLY_EQUAL(point[2], _max[2]) - IS_NEARLY_EQUAL(point[2], _min[2]) + ); + normal.normalize(); + new_entry->set_surface_normal(normal); + } return new_entry; } @@ -823,6 +807,51 @@ fill_viz_geom() { _bounds_viz_geom->add_geom(geom, get_solid_bounds_viz_state()); } +/** + * Determine the point(s) of intersection of a parametric line with the box. + * The line is infinite in both directions, and passes through "from" and + * from+delta. If the line does not intersect the box, the function returns + * false, and t1 and t2 are undefined. If it does intersect the box, it + * returns true, and t1 and t2 are set to the points along the equation + * from+t*delta that correspond to the two points of intersection. + */ +bool CollisionBox:: +intersects_line(double &t1, double &t2, + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat inflate_size) const { + + LPoint3 bmin = _min - LVector3(inflate_size); + LPoint3 bmax = _max + LVector3(inflate_size); + + double tmin = -DBL_MAX; + double tmax = DBL_MAX; + + for (int i = 0; i < 3; ++i) { + PN_stdfloat d = delta[i]; + if (!IS_NEARLY_ZERO(d)) { + double tmin2 = (bmin[i] - from[i]) / d; + double tmax2 = (bmax[i] - from[i]) / d; + if (tmin2 > tmax2) { + std::swap(tmin2, tmax2); + } + tmin = std::max(tmin, tmin2); + tmax = std::min(tmax, tmax2); + + if (tmin > tmax) { + return false; + } + + } else if (from[i] < bmin[i] || from[i] > bmax[i]) { + // The line is entirely parallel in this dimension. + return false; + } + } + + t1 = tmin; + t2 = tmax; + return true; +} + /** * Clips the polygon by all of the clip planes named in the clip plane * attribute and fills new_points up with the resulting points. diff --git a/panda/src/collide/collisionBox.h b/panda/src/collide/collisionBox.h index 0888d7e4da..0810aa95e2 100644 --- a/panda/src/collide/collisionBox.h +++ b/panda/src/collide/collisionBox.h @@ -75,6 +75,8 @@ protected: virtual PT(BoundingVolume) compute_internal_bounds() const; virtual PT(CollisionEntry) test_intersection_from_sphere(const CollisionEntry &entry) const; + virtual PT(CollisionEntry) + test_intersection_from_line(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_ray(const CollisionEntry &entry) const; virtual PT(CollisionEntry) @@ -84,6 +86,11 @@ protected: virtual void fill_viz_geom(); +protected: + bool intersects_line(double &t1, double &t2, + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat inflate_size=0) const; + private: LPoint3 _center; LPoint3 _min; From 911a54938625dc22278f6eced827e0ff484b5f05 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 22:30:06 +0200 Subject: [PATCH 081/360] collide: add tube-into-tube collision test --- panda/src/collide/collisionTube.cxx | 152 ++++++++++++++++++++++++++-- panda/src/collide/collisionTube.h | 11 +- 2 files changed, 152 insertions(+), 11 deletions(-) diff --git a/panda/src/collide/collisionTube.cxx b/panda/src/collide/collisionTube.cxx index 174935368e..90f82a3630 100644 --- a/panda/src/collide/collisionTube.cxx +++ b/panda/src/collide/collisionTube.cxx @@ -391,6 +391,70 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return new_entry; } +/** + * + */ +PT(CollisionEntry) CollisionTube:: +test_intersection_from_tube(const CollisionEntry &entry) const { + const CollisionTube *tube; + DCAST_INTO_R(tube, entry.get_from(), nullptr); + + LPoint3 into_a = _a; + LVector3 into_direction = _b - into_a; + + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); + + LPoint3 from_a = tube->get_point_a() * wrt_mat; + LPoint3 from_b = tube->get_point_b() * wrt_mat; + LVector3 from_direction = from_b - from_a; + + LVector3 from_radius_v = + LVector3(tube->get_radius(), 0.0f, 0.0f) * wrt_mat; + PN_stdfloat from_radius = length(from_radius_v); + + // Determine the points on each segment with the smallest distance between. + double into_t, from_t; + calc_closest_segment_points(into_t, from_t, + into_a, into_direction, + from_a, from_direction); + LPoint3 into_closest = into_a + into_direction * into_t; + LPoint3 from_closest = from_a + from_direction * from_t; + + // If the distance is greater than the sum of tube radii, the test fails. + LVector3 closest_vec = from_closest - into_closest; + PN_stdfloat distance = closest_vec.length(); + if (distance > _radius + from_radius) { + return nullptr; + } + + if (collide_cat.is_debug()) { + collide_cat.debug() + << "intersection detected from " << entry.get_from_node_path() + << " into " << entry.get_into_node_path() << "\n"; + } + PT(CollisionEntry) new_entry = new CollisionEntry(entry); + + if (distance != 0) { + // This is the most common case, where the line segments don't touch + // exactly. We point the normal along the vector of the closest distance. + LVector3 surface_normal = closest_vec * (1.0 / distance); + + new_entry->set_surface_point(into_closest + surface_normal * _radius); + new_entry->set_interior_point(from_closest - surface_normal * from_radius); + + if (has_effective_normal() && tube->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else if (distance != 0) { + new_entry->set_surface_normal(surface_normal); + } + } else { + // The rare case of the line segments touching exactly. + set_intersection_point(new_entry, into_closest, 0); + } + + return new_entry; +} + /** * */ @@ -578,6 +642,80 @@ calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, return LVertex(x, y, z); } +/** + * Given line segments s1 and s2 defined by two points each, computes the + * point on each segment with the closest distance between them. + */ +void CollisionTube:: +calc_closest_segment_points(double &t1, double &t2, + const LPoint3 &from1, const LVector3 &delta1, + const LPoint3 &from2, const LVector3 &delta2) { + // Copyright 2001 softSurfer, 2012 Dan Sunday + // This code may be freely used, distributed and modified for any purpose + // providing that this copyright notice is included with it. + // SoftSurfer makes no warranty for this code, and cannot be held + // liable for any real or imagined damage resulting from its use. + // Users of this code must verify correctness for their application. + LVector3 w = from1 - from2; + PN_stdfloat a = delta1.dot(delta1); // always >= 0 + PN_stdfloat b = delta1.dot(delta2); + PN_stdfloat c = delta2.dot(delta2); // always >= 0 + PN_stdfloat d = delta1.dot(w); + PN_stdfloat e = delta2.dot(w); + PN_stdfloat D = a * c - b * b; // always >= 0 + PN_stdfloat sN, sD = D; + PN_stdfloat tN, tD = D; + + // compute the line parameters of the two closest points + if (IS_NEARLY_ZERO(D)) { // the lines are almost parallel + sN = 0.0; // force using point P0 on segment S1 + sD = 1.0; // to prevent possible division by 0.0 later + tN = e; + tD = c; + } else { + // get the closest points on the infinite lines + sN = (b*e - c*d); + tN = (a*e - b*d); + if (sN < 0.0) { // sc < 0 => the s=0 edge is visible + sN = 0.0; + tN = e; + tD = c; + } else if (sN > sD) { // sc > 1 => the s=1 edge is visible + sN = sD; + tN = e + b; + tD = c; + } + } + + if (tN < 0.0) { // tc < 0 => the t=0 edge is visible + tN = 0.0; + // recompute sc for this edge + if (-d < 0.0) { + sN = 0.0; + } else if (-d > a) { + sN = sD; + } else { + sN = -d; + sD = a; + } + } else if (tN > tD) { // tc > 1 => the t=1 edge is visible + tN = tD; + // recompute sc for this edge + if ((-d + b) < 0.0) { + sN = 0; + } else if ((-d + b) > a) { + sN = sD; + } else { + sN = (-d + b); + sD = a; + } + } + + // finally do the division to get sc and tc + t1 = (IS_NEARLY_ZERO(sN) ? 0.0 : sN / sD); + t2 = (IS_NEARLY_ZERO(tN) ? 0.0 : tN / tD); +} + /** * Determine the point(s) of intersection of a parametric line with the tube. * The line is infinite in both directions, and passes through "from" and @@ -692,7 +830,7 @@ intersects_line(double &t1, double &t2, // The starting point is off the bottom of the tube. Test the line // against the first endcap. double t1a, t2a; - if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, inflate_radius)) { + if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, radius)) { // If there's no intersection with the endcap, there can't be an // intersection with the cylinder. return false; @@ -703,7 +841,7 @@ intersects_line(double &t1, double &t2, // The starting point is off the top of the tube. Test the line against // the second endcap. double t1b, t2b; - if (!sphere_intersects_line(t1b, t2b, _length, from, delta, inflate_radius)) { + if (!sphere_intersects_line(t1b, t2b, _length, from, delta, radius)) { // If there's no intersection with the endcap, there can't be an // intersection with the cylinder. return false; @@ -715,7 +853,7 @@ intersects_line(double &t1, double &t2, // The ending point is off the bottom of the tube. Test the line against // the first endcap. double t1a, t2a; - if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, inflate_radius)) { + if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, radius)) { // If there's no intersection with the endcap, there can't be an // intersection with the cylinder. return false; @@ -726,7 +864,7 @@ intersects_line(double &t1, double &t2, // The ending point is off the top of the tube. Test the line against the // second endcap. double t1b, t2b; - if (!sphere_intersects_line(t1b, t2b, _length, from, delta, inflate_radius)) { + if (!sphere_intersects_line(t1b, t2b, _length, from, delta, radius)) { // If there's no intersection with the endcap, there can't be an // intersection with the cylinder. return false; @@ -740,16 +878,14 @@ intersects_line(double &t1, double &t2, /** * After confirming that the line intersects an infinite cylinder, test * whether it intersects one or the other endcaps. The y parameter specifies - * the center of the sphere (and hence the particular endcap. + * the center of the sphere (and hence the particular endcap). */ bool CollisionTube:: sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, const LPoint3 &from, const LVector3 &delta, - PN_stdfloat inflate_radius) const { + PN_stdfloat radius) { // See CollisionSphere::intersects_line() for a derivation of the formula // here. - PN_stdfloat radius = _radius + inflate_radius; - double A = dot(delta, delta); nassertr(A != 0.0, false); diff --git a/panda/src/collide/collisionTube.h b/panda/src/collide/collisionTube.h index 1742e24927..70f1832b9b 100644 --- a/panda/src/collide/collisionTube.h +++ b/panda/src/collide/collisionTube.h @@ -82,6 +82,8 @@ protected: virtual PT(CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const; virtual PT(CollisionEntry) + test_intersection_from_tube(const CollisionEntry &entry) const; + virtual PT(CollisionEntry) test_intersection_from_parabola(const CollisionEntry &entry) const; virtual void fill_viz_geom(); @@ -93,12 +95,15 @@ private: LVertex calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, PN_stdfloat length); + static void calc_closest_segment_points(double &t1, double &t2, + const LPoint3 &from1, const LVector3 &delta1, + const LPoint3 &from2, const LVector3 &delta2); bool intersects_line(double &t1, double &t2, const LPoint3 &from, const LVector3 &delta, PN_stdfloat inflate_radius) const; - bool sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, - const LPoint3 &from, const LVector3 &delta, - PN_stdfloat inflate_radius) const; + static bool sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, + const LPoint3 &from, const LVector3 &delta, + PN_stdfloat radius); bool intersects_parabola(double &t, const LParabola ¶bola, double t1, double t2, const LPoint3 &p1, const LPoint3 &p2) const; From 06539f5c667616a69758add4c4c58ec8bc515a44 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 22:32:34 +0200 Subject: [PATCH 082/360] glsl: support passing uint variables to shader --- panda/src/glstuff/glCgShaderContext_src.cxx | 1 + .../glstuff/glGraphicsStateGuardian_src.cxx | 12 ++++ .../src/glstuff/glGraphicsStateGuardian_src.h | 8 +++ panda/src/glstuff/glShaderContext_src.cxx | 61 ++++++++++++++++++- panda/src/gobj/shader.h | 1 + tests/display/test_glsl_shader.py | 5 +- 6 files changed, 83 insertions(+), 5 deletions(-) diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index c7ba6ad3e7..fc1dac82ca 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -648,6 +648,7 @@ issue_parameters(int altered) { continue; case Shader::SPT_int: + case Shader::SPT_uint: switch (spec._info._class) { case Shader::SAC_scalar: cgSetParameter1iv(p, (int*)ptr_data->_ptr); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 90bbaecf40..7ca4bd21e8 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1699,6 +1699,14 @@ reset() { get_extension_func("glUniform3iv"); _glUniform4iv = (PFNGLUNIFORM4IVPROC) get_extension_func("glUniform4iv"); + _glUniform1uiv = (PFNGLUNIFORM1UIVPROC) + get_extension_func("glUniform1uiv"); + _glUniform2uiv = (PFNGLUNIFORM2UIVPROC) + get_extension_func("glUniform2uiv"); + _glUniform3uiv = (PFNGLUNIFORM3UIVPROC) + get_extension_func("glUniform3uiv"); + _glUniform4uiv = (PFNGLUNIFORM4UIVPROC) + get_extension_func("glUniform4uiv"); _glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) get_extension_func("glUniformMatrix3fv"); _glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) @@ -1777,6 +1785,10 @@ reset() { _glUniform2fv = glUniform2fv; _glUniform3fv = glUniform3fv; _glUniform4fv = glUniform4fv; + _glUniform1iv = glUniform1iv; + _glUniform2iv = glUniform2iv; + _glUniform3iv = glUniform3iv; + _glUniform4iv = glUniform4iv; _glUniformMatrix3fv = glUniformMatrix3fv; _glUniformMatrix4fv = glUniformMatrix4fv; _glValidateProgram = glValidateProgram; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index d00478a58d..67de9ac54c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -175,6 +175,10 @@ typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, con typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); @@ -984,6 +988,10 @@ public: PFNGLUNIFORM2IVPROC _glUniform2iv; PFNGLUNIFORM3IVPROC _glUniform3iv; PFNGLUNIFORM4IVPROC _glUniform4iv; + PFNGLUNIFORM1UIVPROC _glUniform1uiv; + PFNGLUNIFORM2UIVPROC _glUniform2uiv; + PFNGLUNIFORM3UIVPROC _glUniform3uiv; + PFNGLUNIFORM4UIVPROC _glUniform4uiv; PFNGLUNIFORMMATRIX3FVPROC _glUniformMatrix3fv; PFNGLUNIFORMMATRIX4FVPROC _glUniformMatrix4fv; PFNGLVALIDATEPROGRAMPROC _glValidateProgram; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 94adf2f6a8..979c6dada1 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -1501,21 +1501,29 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { case GL_INT: case GL_INT_VEC2: case GL_INT_VEC3: - case GL_INT_VEC4: { + case GL_INT_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: { Shader::ShaderPtrSpec bind; bind._id = arg_id; switch (param_type) { case GL_BOOL: case GL_INT: + case GL_UNSIGNED_INT: case GL_FLOAT: bind._dim[1] = 1; break; case GL_BOOL_VEC2: case GL_INT_VEC2: + case GL_UNSIGNED_INT_VEC2: case GL_FLOAT_VEC2: bind._dim[1] = 2; break; case GL_BOOL_VEC3: case GL_INT_VEC3: + case GL_UNSIGNED_INT_VEC3: case GL_FLOAT_VEC3: bind._dim[1] = 3; break; case GL_BOOL_VEC4: case GL_INT_VEC4: + case GL_UNSIGNED_INT_VEC4: case GL_FLOAT_VEC4: bind._dim[1] = 4; break; case GL_FLOAT_MAT3: bind._dim[1] = 9; break; case GL_FLOAT_MAT4: bind._dim[1] = 16; break; @@ -1525,6 +1533,12 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { case GL_BOOL_VEC2: case GL_BOOL_VEC3: case GL_BOOL_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + bind._type = Shader::SPT_uint; + break; case GL_INT: case GL_INT_VEC2: case GL_INT_VEC3: @@ -1604,6 +1618,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { case GL_INT_VEC2: case GL_INT_VEC3: case GL_INT_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: case GL_FLOAT: case GL_FLOAT_VEC2: case GL_FLOAT_VEC3: @@ -1633,6 +1651,12 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { case GL_BOOL_VEC2: case GL_BOOL_VEC3: case GL_BOOL_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + bind._type = Shader::SPT_uint; + break; case GL_INT: case GL_INT_VEC2: case GL_INT_VEC3: @@ -2003,6 +2027,8 @@ issue_parameters(int altered) { return; } + nassertd(spec._dim[1] > 0) continue; + GLint p = spec._id._seqno; int array_size = min(spec._dim[0], (int)ptr_data->_size / spec._dim[1]); switch (spec._type) { @@ -2019,6 +2045,14 @@ issue_parameters(int altered) { } break; + case Shader::SPT_uint: + // Convert unsigned int data to float data. + data = (float*) alloca(sizeof(float) * array_size * spec._dim[1]); + for (int i = 0; i < (array_size * spec._dim[1]); ++i) { + data[i] = (float)(((unsigned int*)ptr_data->_ptr)[i]); + } + break; + case Shader::SPT_double: // Downgrade double data to float data. data = (float*) alloca(sizeof(float) * array_size * spec._dim[1]); @@ -2048,7 +2082,8 @@ issue_parameters(int altered) { break; case Shader::SPT_int: - if (ptr_data->_type != Shader::SPT_int) { + if (ptr_data->_type != Shader::SPT_int && + ptr_data->_type != Shader::SPT_uint) { GLCAT.error() << "Cannot pass floating-point data to integer shader input '" << spec._id._name << "'\n"; @@ -2068,6 +2103,28 @@ issue_parameters(int altered) { } break; + case Shader::SPT_uint: + if (ptr_data->_type != Shader::SPT_uint && + ptr_data->_type != Shader::SPT_int) { + GLCAT.error() + << "Cannot pass floating-point data to integer shader input '" << spec._id._name << "'\n"; + + // Deactivate it to make sure the user doesn't get flooded with this + // error. + spec._dep[0] = 0; + spec._dep[1] = 0; + + } else { + switch (spec._dim[1]) { + case 1: _glgsg->_glUniform1uiv(p, array_size, (GLuint *)ptr_data->_ptr); continue; + case 2: _glgsg->_glUniform2uiv(p, array_size, (GLuint *)ptr_data->_ptr); continue; + case 3: _glgsg->_glUniform3uiv(p, array_size, (GLuint *)ptr_data->_ptr); continue; + case 4: _glgsg->_glUniform4uiv(p, array_size, (GLuint *)ptr_data->_ptr); continue; + } + nassertd(false) continue; + } + break; + case Shader::SPT_double: GLCAT.error() << "Passing double-precision shader inputs to GLSL shaders is not currently supported\n"; diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 8e65c005e9..1cc6533044 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -346,6 +346,7 @@ public: SPT_float, SPT_double, SPT_int, + SPT_uint, SPT_unknown }; diff --git a/tests/display/test_glsl_shader.py b/tests/display/test_glsl_shader.py index c13e99e92e..0c9c9e8e95 100644 --- a/tests/display/test_glsl_shader.py +++ b/tests/display/test_glsl_shader.py @@ -183,7 +183,6 @@ def test_glsl_int(gsg): run_glsl_test(gsg, code, preamble, inputs) -@pytest.mark.xfail def test_glsl_uint(gsg): #TODO: fix passing uints greater than intmax inputs = dict( @@ -191,8 +190,8 @@ def test_glsl_uint(gsg): intmax=0x7fffffff, ) preamble = """ - uniform unsigned int zero; - uniform unsigned int intmax; + uniform uint zero; + uniform uint intmax; """ code = """ assert(zero == 0); From b5194d9ff25033615f9282706ec7fc9266f9925a Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 22:55:35 +0200 Subject: [PATCH 083/360] glgsg: pad SSBOs to 16 byte boundary (required by some drivers) --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 3 ++- panda/src/gobj/shaderBuffer.I | 12 ++++++++---- panda/src/gobj/shaderBuffer.cxx | 2 +- panda/src/gobj/shaderBuffer.h | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 7ca4bd21e8..d6fab2a434 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -6404,7 +6404,8 @@ prepare_shader_buffer(ShaderBuffer *data) { _glObjectLabel(GL_SHADER_STORAGE_BUFFER, gbc->_index, name.size(), name.data()); } - uint64_t num_bytes = data->get_data_size_bytes(); + // Some drivers require the buffer to be padded to 16 byte boundary. + uint64_t num_bytes = (data->get_data_size_bytes() + 15u) & ~15u; if (_supports_buffer_storage) { _glBufferStorage(GL_SHADER_STORAGE_BUFFER, num_bytes, data->get_initial_data(), 0); } else { diff --git a/panda/src/gobj/shaderBuffer.I b/panda/src/gobj/shaderBuffer.I index 59d62d0171..ccbd160521 100644 --- a/panda/src/gobj/shaderBuffer.I +++ b/panda/src/gobj/shaderBuffer.I @@ -19,8 +19,7 @@ INLINE ShaderBuffer:: ShaderBuffer(const std::string &name, uint64_t size, UsageHint usage_hint) : Namable(name), _data_size_bytes(size), - _usage_hint(usage_hint), - _contexts(nullptr) { + _usage_hint(usage_hint) { } /** @@ -32,8 +31,13 @@ ShaderBuffer(const std::string &name, vector_uchar initial_data, UsageHint usage Namable(name), _data_size_bytes(initial_data.size()), _usage_hint(usage_hint), - _initial_data(initial_data), - _contexts(nullptr) { + _initial_data(std::move(initial_data)) { + + // Make sure it is padded to 16 bytes. Some drivers like that. + if ((_initial_data.size() & 15u) != 0) { + _initial_data.resize((_initial_data.size() + 15u) & ~15u, 0); + _data_size_bytes = _initial_data.size(); + } } /** diff --git a/panda/src/gobj/shaderBuffer.cxx b/panda/src/gobj/shaderBuffer.cxx index 971787f0e6..4e21319b49 100644 --- a/panda/src/gobj/shaderBuffer.cxx +++ b/panda/src/gobj/shaderBuffer.cxx @@ -193,7 +193,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { if (scan.get_bool() && _data_size_bytes > 0) { nassertv_always(_data_size_bytes <= scan.get_remaining_size()); - _initial_data.resize(_data_size_bytes); + _initial_data.resize((_data_size_bytes + 15u) & ~15u); scan.extract_bytes(&_initial_data[0], _data_size_bytes); } else { _initial_data.clear(); diff --git a/panda/src/gobj/shaderBuffer.h b/panda/src/gobj/shaderBuffer.h index 69bdf985d9..bdf0538857 100644 --- a/panda/src/gobj/shaderBuffer.h +++ b/panda/src/gobj/shaderBuffer.h @@ -63,7 +63,7 @@ private: vector_uchar _initial_data; typedef pmap Contexts; - Contexts *_contexts; + Contexts *_contexts = nullptr; public: static void register_with_read_factory(); From 359ce3e9efcaed82b3990f65a32620f1c48bf0e1 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 22:59:23 +0200 Subject: [PATCH 084/360] glgsg: fix error with glObjectLabel and SSBO --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index d6fab2a434..7e8a08aacd 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -6401,7 +6401,7 @@ prepare_shader_buffer(ShaderBuffer *data) { if (_use_object_labels) { string name = data->get_name(); - _glObjectLabel(GL_SHADER_STORAGE_BUFFER, gbc->_index, name.size(), name.data()); + _glObjectLabel(GL_BUFFER, gbc->_index, name.size(), name.data()); } // Some drivers require the buffer to be padded to 16 byte boundary. From eafab53729442671e8cb234526992b52f5bf91e8 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 22:59:38 +0200 Subject: [PATCH 085/360] tests: fix depth buffer test failure --- tests/display/test_depth_buffer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/display/test_depth_buffer.py b/tests/display/test_depth_buffer.py index 02b0c11b69..f4fe924b63 100644 --- a/tests/display/test_depth_buffer.py +++ b/tests/display/test_depth_buffer.py @@ -110,7 +110,7 @@ def test_depth_write(depth_region): def test_depth_far_inf(depth_region): inf = float("inf") - assert 0.99 > render_depth_pixel(depth_region, 100.0, near=1, far=inf, clear=1.0) + assert 0.99 > render_depth_pixel(depth_region, 10.0, near=1, far=inf, clear=1.0) def test_depth_clipping(depth_region): From cf240d95c19ec2a7acc9351f59e1922f06644e41 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 22:59:54 +0200 Subject: [PATCH 086/360] gobj: support infinite near distance in PerspectiveLens Useful when rendering with near/far planes flipped around. --- panda/src/gobj/perspectiveLens.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/panda/src/gobj/perspectiveLens.cxx b/panda/src/gobj/perspectiveLens.cxx index 0fc83ec15b..160ae74aca 100644 --- a/panda/src/gobj/perspectiveLens.cxx +++ b/panda/src/gobj/perspectiveLens.cxx @@ -71,9 +71,14 @@ do_compute_projection_mat(Lens::CData *lens_cdata) { PN_stdfloat fNear = do_get_near(lens_cdata); PN_stdfloat a, b; + // Take the limits if either near or far is infinite. if (cinf(fFar)) { a = 1; b = -2 * fNear; + } else if (cinf(fNear)) { + // This is valid if the near/far planes are inverted. + a = -1; + b = 2 * fFar; } else { PN_stdfloat far_minus_near = fFar-fNear; a = (fFar + fNear); From bbb15631c6bd9969e875ad0f144f6a5b6258393d Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 23:00:57 +0200 Subject: [PATCH 087/360] mathutil: support infinite near/far in LFrustum I don't know if anyone is using LFrustum, but just in case, it's good to support this corner case. --- panda/src/mathutil/frustum_src.I | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/panda/src/mathutil/frustum_src.I b/panda/src/mathutil/frustum_src.I index f76d5bec53..f884b29f45 100644 --- a/panda/src/mathutil/frustum_src.I +++ b/panda/src/mathutil/frustum_src.I @@ -140,7 +140,6 @@ get_perspective_projection_mat(CoordinateSystem cs) const { cs = get_default_coordinate_system(); } - FLOATTYPE recip_far_minus_near = 1.0f/(_ffar - _fnear); FLOATTYPE recip_r_minus_l = 1.0f/(_r - _l); FLOATTYPE recip_t_minus_b = 1.0f/(_t - _b); FLOATTYPE two_fnear = 2.0f*_fnear; @@ -149,8 +148,20 @@ get_perspective_projection_mat(CoordinateSystem cs) const { FLOATTYPE a = two_fnear * recip_r_minus_l; FLOATTYPE e = two_fnear * recip_t_minus_b; FLOATTYPE b = (_t + _b) * recip_t_minus_b; - FLOATTYPE c = (_ffar + _fnear) * recip_far_minus_near; - FLOATTYPE f = -_ffar * two_fnear * recip_far_minus_near; + FLOATTYPE c, f; + + // Take the limits if either near or far is infinite. + if (cinf(_ffar)) { + c = 1; + f = -2 * _fnear; + } else if (cinf(_fnear)) { + c = -1; + f = 2 * _ffar; + } else { + FLOATTYPE recip_far_minus_near = 1.0f / (_ffar - _fnear); + c = (_ffar + _fnear) * recip_far_minus_near; + f = -_ffar * two_fnear * recip_far_minus_near; + } /* FLOATTYPE a = (2.0f * _fnear) / (_r - _l); From f45fa747d1cdf9e19a25fdaa7b7fedcf23348ef8 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 23:01:44 +0200 Subject: [PATCH 088/360] x11display: fix BadWindow if get_pointer called after win close --- panda/src/x11display/x11GraphicsWindow.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index d1f49eedc3..45c04909a2 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -163,8 +163,8 @@ get_pointer(int device) const { if (device == 0 && !_dga_mouse_enabled && result._in_window && x11GraphicsPipe::_x_mutex.try_lock()) { XEvent event; - LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); - if (XQueryPointer(_display, _xwindow, &event.xbutton.root, + if (_xwindow != None && + XQueryPointer(_display, _xwindow, &event.xbutton.root, &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state)) { double time = ClockObject::get_global_clock()->get_real_time(); From 71e18eb9606fe9da975858c9a877bc62c46a80d0 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 17 Jul 2018 23:23:38 +0200 Subject: [PATCH 089/360] tests: add test for setting near distance to infinitiy --- tests/display/test_depth_buffer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/display/test_depth_buffer.py b/tests/display/test_depth_buffer.py index f4fe924b63..8581fe47ea 100644 --- a/tests/display/test_depth_buffer.py +++ b/tests/display/test_depth_buffer.py @@ -113,6 +113,11 @@ def test_depth_far_inf(depth_region): assert 0.99 > render_depth_pixel(depth_region, 10.0, near=1, far=inf, clear=1.0) +def test_depth_near_inf(depth_region): + inf = float("inf") + assert 0.01 < render_depth_pixel(depth_region, 10.0, near=inf, far=1, clear=0.0) + + def test_depth_clipping(depth_region): # Get the actual depth resulting from the clear value. clr = render_depth_pixel(depth_region, None, near=1, far=10, clear=0.5) From 1a6d329fde5e9961236a6a96ce936b78d4f06ad9 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 23 Jul 2018 08:32:58 +0200 Subject: [PATCH 090/360] gobj: support T_unsigned_int_24_8 in TexturePeeker --- panda/src/gobj/texture.I | 18 ++++++++++++++++++ panda/src/gobj/texture.h | 1 + panda/src/gobj/texturePeeker.cxx | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index c766c5b82d..4abb480348 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -2342,6 +2342,24 @@ get_unsigned_int(const unsigned char *&p) { return (double)v.ui / 4294967295.0; } +/** + * This is used by store() to retrieve the next consecutive component value + * from the indicated element of the array, which is taken to be an array of + * unsigned ints with the value packed in the 24 least significant bits. + */ +INLINE double Texture:: +get_unsigned_int_24(const unsigned char *&p) { + union { + uint32_t ui; + uint8_t uc[4]; + } v; + v.uc[0] = (*p++); + v.uc[1] = (*p++); + v.uc[2] = (*p++); + v.uc[3] = (*p++); + return (double)(v.ui & 0xffffff) / (double)0xffffff; +} + /** * This is used by store() to retrieve the next consecutive component value * from the indicated element of the array, which is taken to be an array of diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 852f618c81..7cb5f305fb 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -858,6 +858,7 @@ private: INLINE static double get_unsigned_byte(const unsigned char *&p); INLINE static double get_unsigned_short(const unsigned char *&p); INLINE static double get_unsigned_int(const unsigned char *&p); + INLINE static double get_unsigned_int_24(const unsigned char *&p); INLINE static double get_float(const unsigned char *&p); INLINE static double get_half_float(const unsigned char *&p); diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index ef007d91dd..7bb17ab87a 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -94,6 +94,10 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { _get_component = Texture::get_half_float; break; + case Texture::T_unsigned_int_24_8: + _get_component = Texture::get_unsigned_int_24; + break; + default: // Not supported. _image.clear(); From 7fe72c47f352661d423f4629fb3fc0de692cfca7 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 23 Jul 2018 09:02:12 +0200 Subject: [PATCH 091/360] glgsg: update copy of glext.h --- panda/src/glstuff/panda_glext.h | 765 ++++++++++++++++++++++++++++++-- 1 file changed, 732 insertions(+), 33 deletions(-) diff --git a/panda/src/glstuff/panda_glext.h b/panda/src/glstuff/panda_glext.h index 3be88b13c5..decfc9fcf4 100644 --- a/panda/src/glstuff/panda_glext.h +++ b/panda/src/glstuff/panda_glext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2013-2015 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -31,9 +31,7 @@ extern "C" { ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 31717 $ on $Date: 2015-07-20 05:42:11 -0400 (Mon, 20 Jul 2015) $ +** https://github.com/KhronosGroup/OpenGL-Registry */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -53,7 +51,7 @@ extern "C" { #define GLAPI extern #endif -#define GL_GLEXT_VERSION 20150720 +#define GL_GLEXT_VERSION 20180525 /* Generated C header for: * API: gl @@ -355,15 +353,17 @@ GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); #define GL_TEXTURE_FILTER_CONTROL 0x8500 #define GL_DEPTH_TEXTURE_MODE 0x884B #define GL_COMPARE_R_TO_TEXTURE 0x884E -#define GL_FUNC_ADD 0x8006 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); @@ -2654,7 +2654,7 @@ typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint fram typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil); +//typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); @@ -2777,7 +2777,7 @@ GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLs GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil); +//GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); @@ -2867,6 +2867,42 @@ GLAPI void APIENTRY glTextureBarrier (void); #endif #endif /* GL_VERSION_4_5 */ +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED +typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + #ifndef GL_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 #endif /* GL_ARB_ES2_compatibility */ @@ -2875,6 +2911,17 @@ GLAPI void APIENTRY glTextureBarrier (void); #define GL_ARB_ES3_1_compatibility 1 #endif /* GL_ARB_ES3_1_compatibility */ +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 +typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + #ifndef GL_ARB_ES3_compatibility #define GL_ARB_ES3_compatibility 1 #endif /* GL_ARB_ES3_compatibility */ @@ -3288,6 +3335,10 @@ GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B #endif /* GL_ARB_fragment_shader */ +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + #ifndef GL_ARB_framebuffer_no_attachments #define GL_ARB_framebuffer_no_attachments 1 #endif /* GL_ARB_framebuffer_no_attachments */ @@ -3340,6 +3391,16 @@ GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachmen #define GL_ARB_get_texture_sub_image 1 #endif /* GL_ARB_get_texture_sub_image */ +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 +typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + #ifndef GL_ARB_gpu_shader5 #define GL_ARB_gpu_shader5 1 #endif /* GL_ARB_gpu_shader5 */ @@ -3348,6 +3409,91 @@ GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachmen #define GL_ARB_gpu_shader_fp64 1 #endif /* GL_ARB_gpu_shader_fp64 */ +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); +GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); +GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); +GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); +GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); +GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); +GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ + #ifndef GL_ARB_half_float_pixel #define GL_ARB_half_float_pixel 1 typedef unsigned short GLhalfARB; @@ -3360,8 +3506,6 @@ typedef unsigned short GLhalfARB; #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 -#define GL_BLEND_COLOR 0x8005 -#define GL_BLEND_EQUATION 0x8009 #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 @@ -3498,11 +3642,11 @@ GLAPI void APIENTRY glResetMinmax (GLenum target); #define GL_ARB_indirect_parameters 1 #define GL_PARAMETER_BUFFER_ARB 0x80EE #define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif #endif /* GL_ARB_indirect_parameters */ @@ -3727,6 +3871,16 @@ GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *par #define GL_ARB_occlusion_query2 1 #endif /* GL_ARB_occlusion_query2 */ +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + #ifndef GL_ARB_pipeline_statistics_query #define GL_ARB_pipeline_statistics_query 1 #define GL_VERTICES_SUBMITTED_ARB 0x82EE @@ -3769,6 +3923,14 @@ GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); #define GL_COORD_REPLACE_ARB 0x8862 #endif /* GL_ARB_point_sprite */ +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + #ifndef GL_ARB_program_interface_query #define GL_ARB_program_interface_query 1 #endif /* GL_ARB_program_interface_query */ @@ -3842,6 +4004,26 @@ GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum form #define GL_ARB_robustness_isolation 1 #endif /* GL_ARB_robustness_isolation */ +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glEvaluateDepthValuesARB (void); +#endif +#endif /* GL_ARB_sample_locations */ + #ifndef GL_ARB_sample_shading #define GL_ARB_sample_shading 1 #define GL_SAMPLE_SHADING_ARB 0x8C36 @@ -3868,14 +4050,26 @@ GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #define GL_ARB_separate_shader_objects 1 #endif /* GL_ARB_separate_shader_objects */ +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ + #ifndef GL_ARB_shader_atomic_counters #define GL_ARB_shader_atomic_counters 1 #endif /* GL_ARB_shader_atomic_counters */ +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ + #ifndef GL_ARB_shader_bit_encoding #define GL_ARB_shader_bit_encoding 1 #endif /* GL_ARB_shader_bit_encoding */ +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ + #ifndef GL_ARB_shader_draw_parameters #define GL_ARB_shader_draw_parameters 1 #endif /* GL_ARB_shader_draw_parameters */ @@ -4040,6 +4234,10 @@ GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GL #define GL_ARB_shader_texture_lod 1 #endif /* GL_ARB_shader_texture_lod */ +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ + #ifndef GL_ARB_shading_language_100 #define GL_ARB_shading_language_100 1 #define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C @@ -4119,6 +4317,18 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #endif #endif /* GL_ARB_sparse_texture */ +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + #ifndef GL_ARB_stencil_texturing #define GL_ARB_stencil_texturing 1 #endif /* GL_ARB_stencil_texturing */ @@ -4271,6 +4481,16 @@ GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void #define GL_DOT3_RGBA_ARB 0x86AF #endif /* GL_ARB_texture_env_dot3 */ +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + #ifndef GL_ARB_texture_float #define GL_ARB_texture_float 1 #define GL_TEXTURE_RED_TYPE_ARB 0x8C10 @@ -4493,6 +4713,9 @@ GLAPI void APIENTRY glVertexBlendARB (GLint count); #ifndef GL_ARB_vertex_buffer_object #define GL_ARB_vertex_buffer_object 1 +#include +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; #define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_USAGE_ARB 0x8765 #define GL_ARRAY_BUFFER_ARB 0x8892 @@ -4528,9 +4751,9 @@ typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); @@ -4540,9 +4763,9 @@ GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); -GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); @@ -4768,6 +4991,16 @@ GLAPI void APIENTRY glBlendBarrierKHR (void); #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 #endif /* GL_KHR_no_error */ +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + #ifndef GL_KHR_robust_buffer_access_behavior #define GL_KHR_robust_buffer_access_behavior 1 #endif /* GL_KHR_robust_buffer_access_behavior */ @@ -4813,6 +5046,10 @@ GLAPI void APIENTRY glBlendBarrierKHR (void); #define GL_KHR_texture_compression_astc_ldr 1 #endif /* GL_KHR_texture_compression_astc_ldr */ +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + #ifndef GL_OES_byte_coordinates #define GL_OES_byte_coordinates 1 typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); @@ -5204,10 +5441,49 @@ GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRG #endif #endif /* GL_AMD_draw_buffers_blend */ +#ifndef GL_AMD_framebuffer_sample_positions +#define GL_AMD_framebuffer_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#define GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE +#define GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF +#define GL_ALL_PIXELS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERFVAMDPROC) (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERFVAMDPROC) (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSamplePositionsfvAMD (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glNamedFramebufferSamplePositionsfvAMD (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glGetFramebufferParameterfvAMD (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#endif +#endif /* GL_AMD_framebuffer_sample_positions */ + #ifndef GL_AMD_gcn_shader #define GL_AMD_gcn_shader 1 #endif /* GL_AMD_gcn_shader */ +#ifndef GL_AMD_gpu_shader_half_float +#define GL_AMD_gpu_shader_half_float 1 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_FLOAT16_MAT2_AMD 0x91C5 +#define GL_FLOAT16_MAT3_AMD 0x91C6 +#define GL_FLOAT16_MAT4_AMD 0x91C7 +#define GL_FLOAT16_MAT2x3_AMD 0x91C8 +#define GL_FLOAT16_MAT2x4_AMD 0x91C9 +#define GL_FLOAT16_MAT3x2_AMD 0x91CA +#define GL_FLOAT16_MAT3x4_AMD 0x91CB +#define GL_FLOAT16_MAT4x2_AMD 0x91CC +#define GL_FLOAT16_MAT4x3_AMD 0x91CD +#endif /* GL_AMD_gpu_shader_half_float */ + +#ifndef GL_AMD_gpu_shader_int16 +#define GL_AMD_gpu_shader_int16 1 +#endif /* GL_AMD_gpu_shader_int16 */ + #ifndef GL_AMD_gpu_shader_int64 #define GL_AMD_gpu_shader_int64 1 typedef int64_t GLint64EXT; @@ -5235,10 +5511,6 @@ typedef int64_t GLint64EXT; #define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 #define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 #define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); @@ -5411,7 +5683,6 @@ GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname #ifndef GL_AMD_sample_positions #define GL_AMD_sample_positions 1 -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); @@ -5426,6 +5697,22 @@ GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLf #define GL_AMD_shader_atomic_counter_ops 1 #endif /* GL_AMD_shader_atomic_counter_ops */ +#ifndef GL_AMD_shader_ballot +#define GL_AMD_shader_ballot 1 +#endif /* GL_AMD_shader_ballot */ + +#ifndef GL_AMD_shader_explicit_vertex_parameter +#define GL_AMD_shader_explicit_vertex_parameter 1 +#endif /* GL_AMD_shader_explicit_vertex_parameter */ + +#ifndef GL_AMD_shader_gpu_shader_half_float_fetch +#define GL_AMD_shader_gpu_shader_half_float_fetch 1 +#endif /* GL_AMD_shader_gpu_shader_half_float_fetch */ + +#ifndef GL_AMD_shader_image_load_store_lod +#define GL_AMD_shader_image_load_store_lod 1 +#endif /* GL_AMD_shader_image_load_store_lod */ + #ifndef GL_AMD_shader_stencil_export #define GL_AMD_shader_stencil_export 1 #endif /* GL_AMD_shader_stencil_export */ @@ -5465,6 +5752,10 @@ GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); #endif #endif /* GL_AMD_stencil_operation_extended */ +#ifndef GL_AMD_texture_gather_bias_lod +#define GL_AMD_texture_gather_bias_lod 1 +#endif /* GL_AMD_texture_gather_bias_lod */ + #ifndef GL_AMD_texture_texture4 #define GL_AMD_texture_texture4 1 #endif /* GL_AMD_texture_texture4 */ @@ -6165,6 +6456,17 @@ GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); #define GL_422_REV_AVERAGE_EXT 0x80CF #endif /* GL_EXT_422_pixels */ +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void *GLeglImageOES; +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #define GL_ABGR_EXT 0x8000 @@ -7016,6 +7318,17 @@ GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint en #endif #endif /* GL_EXT_draw_range_elements */ +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + #ifndef GL_EXT_fog_coord #define GL_EXT_fog_coord 1 #define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 @@ -7359,6 +7672,89 @@ GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); #endif #endif /* GL_EXT_light_texture */ +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + #ifndef GL_EXT_misc_attribute #define GL_EXT_misc_attribute 1 #endif /* GL_EXT_misc_attribute */ @@ -7600,6 +7996,55 @@ GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei #endif #endif /* GL_EXT_secondary_color */ +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #define GL_ACTIVE_PROGRAM_EXT 0x8B8D @@ -7620,6 +8065,19 @@ GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *strin #define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA #endif /* GL_EXT_separate_specular_color */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + #ifndef GL_EXT_shader_image_load_formatted #define GL_EXT_shader_image_load_formatted 1 #endif /* GL_EXT_shader_image_load_formatted */ @@ -7920,6 +8378,8 @@ GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint #ifndef GL_EXT_texture_filter_minmax #define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 #endif /* GL_EXT_texture_filter_minmax */ #ifndef GL_EXT_texture_integer @@ -8466,6 +8926,30 @@ GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei s #endif #endif /* GL_EXT_vertex_weighting */ +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + #ifndef GL_EXT_x11_sync_object #define GL_EXT_x11_sync_object 1 #define GL_SYNC_X11_FENCE_EXT 0x90E1 @@ -8643,10 +9127,28 @@ GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRG #define GL_INTERLACE_READ_INGR 0x8568 #endif /* GL_INGR_interlace_read */ +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + #ifndef GL_INTEL_fragment_shader_ordering #define GL_INTEL_fragment_shader_ordering 1 #endif /* GL_INTEL_fragment_shader_ordering */ +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + #ifndef GL_INTEL_map_texture #define GL_INTEL_map_texture 1 #define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF @@ -8711,7 +9213,7 @@ typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #ifdef GL_GLEXT_PROTOTYPES @@ -8722,7 +9224,7 @@ GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #endif @@ -8743,6 +9245,11 @@ GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLen #define GL_PACK_INVERT_MESA 0x8758 #endif /* GL_MESA_pack_invert */ +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + #ifndef GL_MESA_resize_buffers #define GL_MESA_resize_buffers 1 typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); @@ -8751,6 +9258,17 @@ GLAPI void APIENTRY glResizeBuffersMESA (void); #endif #endif /* GL_MESA_resize_buffers */ +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_MESA_tile_raster_order +#define GL_MESA_tile_raster_order 1 +#define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA +#endif /* GL_MESA_tile_raster_order */ + #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); @@ -8812,6 +9330,10 @@ GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); #define GL_YCBCR_MESA 0x8757 #endif /* GL_MESA_ycbcr_texture */ +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + #ifndef GL_NVX_conditional_render #define GL_NVX_conditional_render 1 typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); @@ -8831,6 +9353,32 @@ GLAPI void APIENTRY glEndConditionalRenderNVX (void); #define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B #endif /* GL_NVX_gpu_memory_info */ +#ifndef GL_NVX_linked_gpu_multicast +#define GL_NVX_linked_gpu_multicast 1 +#define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 +#define GL_MAX_LGPU_GPUS_NVX 0x92BA +typedef void (APIENTRYP PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLLGPUINTERLOCKNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLGPUNamedBufferSubDataNVX (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glLGPUCopyImageSubDataNVX (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glLGPUInterlockNVX (void); +#endif +#endif /* GL_NVX_linked_gpu_multicast */ + +#ifndef GL_NV_alpha_to_coverage_dither_control +#define GL_NV_alpha_to_coverage_dither_control 1 +#define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D +#define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E +#define GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F +#define GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF +typedef void (APIENTRYP PFNGLALPHATOCOVERAGEDITHERCONTROLNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaToCoverageDitherControlNV (GLenum mode); +#endif +#endif /* GL_NV_alpha_to_coverage_dither_control */ + #ifndef GL_NV_bindless_multi_draw_indirect #define GL_NV_bindless_multi_draw_indirect 1 typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); @@ -8947,10 +9495,25 @@ GLAPI void APIENTRY glBlendBarrierNV (void); #define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 #endif /* GL_NV_blend_equation_advanced_coherent */ +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#endif /* GL_NV_blend_minmax_factor */ + #ifndef GL_NV_blend_square #define GL_NV_blend_square 1 #endif /* GL_NV_blend_square */ +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + #ifndef GL_NV_command_list #define GL_NV_command_list 1 #define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 @@ -9053,6 +9616,26 @@ GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat valu #endif #endif /* GL_NV_conservative_raster_dilate */ +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + #ifndef GL_NV_copy_depth_to_color #define GL_NV_copy_depth_to_color 1 #define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E @@ -9102,6 +9685,23 @@ GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, #endif #endif /* GL_NV_draw_texture */ +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (APIENTRY *GLVULKANPROCNV)(void); +typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); +GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + #ifndef GL_NV_evaluators #define GL_NV_evaluators 1 #define GL_EVAL_2D_NV 0x86C0 @@ -9336,6 +9936,41 @@ GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachmen #define GL_NV_geometry_shader_passthrough 1 #endif /* GL_NV_geometry_shader_passthrough */ +#ifndef GL_NV_gpu_multicast +#define GL_NV_gpu_multicast 1 +#define GL_PER_GPU_STORAGE_BIT_NV 0x0800 +#define GL_MULTICAST_GPUS_NV 0x92BA +#define GL_RENDER_GPU_MASK_NV 0x9558 +#define GL_PER_GPU_STORAGE_NV 0x9548 +#define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 +typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTBARRIERNVPROC) (void); +typedef void (APIENTRYP PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGpu, GLbitfield waitGpuMask); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderGpuMaskNV (GLbitfield mask); +GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glMulticastFramebufferSampleLocationsfvNV (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastBarrierNV (void); +GLAPI void APIENTRY glMulticastWaitSyncNV (GLuint signalGpu, GLbitfield waitGpuMask); +GLAPI void APIENTRY glMulticastGetQueryObjectivNV (GLuint gpu, GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glMulticastGetQueryObjectuivNV (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMulticastGetQueryObjecti64vNV (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glMulticastGetQueryObjectui64vNV (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_NV_gpu_multicast */ + #ifndef GL_NV_gpu_program4 #define GL_NV_gpu_program4 1 #define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 @@ -9953,6 +10588,32 @@ GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); #endif #endif /* GL_NV_primitive_restart */ +#ifndef GL_NV_query_resource +#define GL_NV_query_resource 1 +#define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 +#define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 +#define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 +#define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 +#define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 +#define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 +typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); +#endif +#endif /* GL_NV_query_resource */ + +#ifndef GL_NV_query_resource_tag +#define GL_NV_query_resource_tag 1 +typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); +typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); +typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); +GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); +GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); +#endif +#endif /* GL_NV_query_resource_tag */ + #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 #define GL_REGISTER_COMBINERS_NV 0x8522 @@ -10045,6 +10706,11 @@ GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, #endif #endif /* GL_NV_register_combiners2 */ +#ifndef GL_NV_robustness_video_memory_purge +#define GL_NV_robustness_video_memory_purge 1 +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif /* GL_NV_robustness_video_memory_purge */ + #ifndef GL_NV_sample_locations #define GL_NV_sample_locations 1 #define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D @@ -10077,6 +10743,10 @@ GLAPI void APIENTRY glResolveDepthValuesNV (void); #define GL_NV_shader_atomic_float 1 #endif /* GL_NV_shader_atomic_float */ +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + #ifndef GL_NV_shader_atomic_fp16_vector #define GL_NV_shader_atomic_fp16_vector 1 #endif /* GL_NV_shader_atomic_fp16_vector */ @@ -10140,6 +10810,10 @@ GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLs #define GL_NV_shader_thread_shuffle 1 #endif /* GL_NV_shader_thread_shuffle */ +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + #ifndef GL_NV_tessellation_program5 #define GL_NV_tessellation_program5 1 #define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 @@ -10216,6 +10890,10 @@ GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenu #define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 #endif /* GL_NV_texture_rectangle */ +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 #define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C @@ -10879,7 +11557,7 @@ GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint #define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B #define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); @@ -10892,7 +11570,7 @@ typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_ typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptr offset); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); @@ -10910,6 +11588,26 @@ GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot #define GL_NV_viewport_array2 1 #endif /* GL_NV_viewport_array2 */ +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + #ifndef GL_OML_interlace #define GL_OML_interlace 1 #define GL_INTERLACE_OML 0x8980 @@ -10937,6 +11635,7 @@ GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 #define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); From ecfeae8a276cab954e37661269a27f814558a1ec Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 26 Jul 2018 13:50:54 +0200 Subject: [PATCH 092/360] shader: support double-precision vertex columns in GLSL --- panda/src/glstuff/glCgShaderContext_src.cxx | 22 +++++--- panda/src/glstuff/glShaderContext_src.cxx | 60 ++++++++++++++------- panda/src/gobj/shader.cxx | 27 ++++++++-- panda/src/gobj/shader.h | 20 +++---- 4 files changed, 86 insertions(+), 43 deletions(-) diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index fc1dac82ca..3a9b2fea6a 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -885,17 +885,21 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { _glgsg->enable_vertex_attrib_array(p); - if (bind._integer) { - _glgsg->_glVertexAttribIPointer(p, num_values, type, - stride, client_pointer); - } else if (numeric_type == GeomEnums::NT_packed_dabc) { + if (numeric_type == GeomEnums::NT_packed_dabc) { // GL_BGRA is a special accepted value available since OpenGL 3.2. // It requires us to pass GL_TRUE for normalized. _glgsg->_glVertexAttribPointer(p, GL_BGRA, GL_UNSIGNED_BYTE, GL_TRUE, stride, client_pointer); - } else { + } else if (bind._numeric_type == Shader::SPT_float || + numeric_type == GeomEnums::NT_float32) { _glgsg->_glVertexAttribPointer(p, num_values, type, normalized, stride, client_pointer); + } else if (bind._numeric_type == Shader::SPT_double) { + _glgsg->_glVertexAttribLPointer(p, num_values, type, + stride, client_pointer); + } else { + _glgsg->_glVertexAttribIPointer(p, num_values, type, + stride, client_pointer); } if (divisor > 0) { @@ -952,10 +956,12 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // So, we work around this by just binding something silly to 0. // This breaks flat colors, but it's better than invisible objects? _glgsg->enable_vertex_attrib_array(0); - if (bind._integer) { - _glgsg->_glVertexAttribIPointer(0, 4, GL_INT, 0, 0); - } else { + if (bind._numeric_type == Shader::SPT_float) { _glgsg->_glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); + } else if (bind._numeric_type == Shader::SPT_double) { + _glgsg->_glVertexAttribLPointer(0, 4, GL_DOUBLE, 0, 0); + } else { + _glgsg->_glVertexAttribIPointer(0, 4, GL_INT, 0, 0); } } else if (p >= 0) { diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 979c6dada1..a96a07a2e8 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -426,18 +426,34 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { bind._elements = 1; // Check if this is an integer input- if so, we have to bind it differently. - bind._integer = (param_type == GL_BOOL || - param_type == GL_BOOL_VEC2 || - param_type == GL_BOOL_VEC3 || - param_type == GL_BOOL_VEC4 || - param_type == GL_INT || - param_type == GL_INT_VEC2 || - param_type == GL_INT_VEC3 || - param_type == GL_INT_VEC4 || - param_type == GL_UNSIGNED_INT_VEC2 || - param_type == GL_UNSIGNED_INT_VEC3 || - param_type == GL_UNSIGNED_INT_VEC4 || - param_type == GL_UNSIGNED_INT); + switch (param_type) { + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + bind._numeric_type = Shader::SPT_int; + break; + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_VEC2: + case GL_UNSIGNED_INT_VEC3: + case GL_UNSIGNED_INT_VEC4: + bind._numeric_type = Shader::SPT_uint; + break; +#ifndef OPENGLES + case GL_DOUBLE: + case GL_DOUBLE_VEC2: + case GL_DOUBLE_VEC3: + case GL_DOUBLE_VEC4: + bind._numeric_type = Shader::SPT_double; + break; +#endif + default: + bind._numeric_type = Shader::SPT_float; + } // Check if it has a p3d_ prefix - if so, assign special meaning. if (strncmp(name_buffer, "p3d_", 4) == 0) { @@ -2264,7 +2280,7 @@ disable_shader_vertex_arrays() { return; } - for (int i=0; i<(int)_shader->_var_spec.size(); i++) { + for (size_t i = 0; i < _shader->_var_spec.size(); ++i) { const Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; GLint p = bind._id._seqno; @@ -2389,21 +2405,25 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { } client_pointer += start; + GLenum type = _glgsg->get_numeric_type(numeric_type); for (int i = 0; i < num_elements; ++i) { _glgsg->enable_vertex_attrib_array(p); - if (bind._integer) { - _glgsg->_glVertexAttribIPointer(p, num_values, _glgsg->get_numeric_type(numeric_type), - stride, client_pointer); - } else if (numeric_type == GeomEnums::NT_packed_dabc) { + if (numeric_type == GeomEnums::NT_packed_dabc) { // GL_BGRA is a special accepted value available since OpenGL 3.2. // It requires us to pass GL_TRUE for normalized. _glgsg->_glVertexAttribPointer(p, GL_BGRA, GL_UNSIGNED_BYTE, GL_TRUE, stride, client_pointer); - } else { - _glgsg->_glVertexAttribPointer(p, num_values, - _glgsg->get_numeric_type(numeric_type), + } else if (bind._numeric_type == Shader::SPT_float || + numeric_type == GeomEnums::NT_float32) { + _glgsg->_glVertexAttribPointer(p, num_values, type, normalized, stride, client_pointer); + } else if (bind._numeric_type == Shader::SPT_double) { + _glgsg->_glVertexAttribLPointer(p, num_values, type, + stride, client_pointer); + } else { + _glgsg->_glVertexAttribIPointer(p, num_values, type, + stride, client_pointer); } if (divisor > 0) { diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 22a5389b8b..220bd56ed2 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -619,12 +619,29 @@ cg_recurse_parameters(CGparameter parameter, const ShaderType &type, p._type = arg_type; p._direction = arg_dir; p._varying = (vbl == CG_VARYING); - p._integer = (base_type == CG_UINT || base_type == CG_INT || - base_type == CG_ULONG || base_type == CG_LONG || - base_type == CG_USHORT || base_type == CG_SHORT || - base_type == CG_UCHAR || base_type == CG_CHAR); p._cat = shader_cat.get_safe_ptr(); + //NB. Cg does have a CG_DOUBLE type, but at least for the ARB + // profiles and GLSL profiles it just maps to float. + switch (base_type) { + case CG_UINT: + case CG_ULONG: + case CG_USHORT: + case CG_UCHAR: + case CG_BOOL: + p._numeric_type = SPT_uint; + break; + case CG_INT: + case CG_LONG: + case CG_SHORT: + case CG_CHAR: + p._numeric_type = SPT_int; + break; + default: + p._numeric_type = SPT_float; + break; + } + success &= compile_parameter(p, arg_dim); break; } @@ -681,7 +698,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { ShaderVarSpec bind; bind._id = p._id; bind._append_uv = -1; - bind._integer = p._integer; + bind._numeric_type = p._numeric_type; if (pieces.size() == 2) { if (pieces[1] == "position") { diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 1cc6533044..99b8d45e53 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -331,6 +331,14 @@ public: int _seqno; }; + enum ShaderPtrType { + SPT_float, + SPT_double, + SPT_int, + SPT_uint, + SPT_unknown + }; + struct ShaderArgInfo { ShaderArgId _id; ShaderArgClass _class; @@ -338,18 +346,10 @@ public: ShaderArgType _type; ShaderArgDir _direction; bool _varying; - bool _integer; + ShaderPtrType _numeric_type; NotifyCategory *_cat; }; - enum ShaderPtrType { - SPT_float, - SPT_double, - SPT_int, - SPT_uint, - SPT_unknown - }; - // Container structure for data of parameters ShaderPtrSpec. struct ShaderPtrData { private: @@ -425,7 +425,7 @@ public: PT(InternalName) _name; int _append_uv; int _elements; - bool _integer; + ShaderPtrType _numeric_type; }; struct ShaderPtrSpec { From c634c455fd737a0a55b0c1371f8ee73c1dae5e3e Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 26 Jul 2018 19:33:42 +0200 Subject: [PATCH 093/360] framework: add zero-argument version of open_framework() --- panda/src/framework/pandaFramework.cxx | 10 +++++++++- panda/src/framework/pandaFramework.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 4dfbaee572..706ff4995d 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -82,7 +82,7 @@ PandaFramework:: * control parameters. */ void PandaFramework:: -open_framework(int &argc, char **&argv) { +open_framework() { if (_is_open) { return; } @@ -162,6 +162,14 @@ open_framework(int &argc, char **&argv) { _event_handler.add_hook("window-event", event_window_event, this); } +/** + * @deprecated See the version of open_framework() without arguments. + */ +void PandaFramework:: +open_framework(int &argc, char **&argv) { + open_framework(); +} + /** * Should be called at the end of an application to close Panda. This is * optional, as the destructor will do the same thing. diff --git a/panda/src/framework/pandaFramework.h b/panda/src/framework/pandaFramework.h index ef570a6c96..3c901d8e27 100644 --- a/panda/src/framework/pandaFramework.h +++ b/panda/src/framework/pandaFramework.h @@ -40,6 +40,7 @@ public: PandaFramework(); virtual ~PandaFramework(); + void open_framework(); void open_framework(int &argc, char **&argv); void close_framework(); From d081b4d4204ab022c94c9e250625a11d9e28682f Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 26 Jul 2018 19:34:23 +0200 Subject: [PATCH 094/360] mathutil: override plane.normalize() to be meaningful for planes Now it only divides by the length of the normal, rather than also adding in the square of the w component. --- panda/src/mathutil/plane_src.I | 31 +++++++++++++++++++++++++++++++ panda/src/mathutil/plane_src.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/panda/src/mathutil/plane_src.I b/panda/src/mathutil/plane_src.I index f357b34e60..7ea0acc828 100644 --- a/panda/src/mathutil/plane_src.I +++ b/panda/src/mathutil/plane_src.I @@ -137,6 +137,37 @@ dist_to_plane(const FLOATNAME(LPoint3) &point) const { return (_v(0) * point[0] + _v(1) * point[1] + _v(2) * point[2] + _v(3)); } +/** + * Normalizes the plane in place. Returns true if the plane was normalized, + * false if the plane had a zero-length normal vector. + */ +INLINE_MATHUTIL bool FLOATNAME(LPlane):: +normalize() { + FLOATTYPE l2 = get_normal().length_squared(); + if (l2 == (FLOATTYPE)0.0f) { + return false; + + } else if (!IS_THRESHOLD_EQUAL(l2, 1.0f, NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE))) { + (*this) /= csqrt(l2); + } + + return true; +} + +/** + * Normalizes the plane and returns the normalized plane as a copy. If the + * plane's normal was a zero-length vector, the same plane is returned. + */ +INLINE_MATHUTIL FLOATNAME(LPlane) FLOATNAME(LPlane):: +normalized() const { + FLOATTYPE l2 = get_normal().length_squared(); + if (l2 != (FLOATTYPE)0.0f) { + return (*this) / csqrt(l2); + } else { + return (*this); + } +} + /** * Returns the point within the plane nearest to the indicated point in space. */ diff --git a/panda/src/mathutil/plane_src.h b/panda/src/mathutil/plane_src.h index c3301aa641..c1dffc4d5d 100644 --- a/panda/src/mathutil/plane_src.h +++ b/panda/src/mathutil/plane_src.h @@ -39,6 +39,9 @@ PUBLISHED: FLOATNAME(LPoint3) get_point() const; INLINE_MATHUTIL FLOATTYPE dist_to_plane(const FLOATNAME(LPoint3) &point) const; + + INLINE_MATHUTIL bool normalize(); + INLINE_MATHUTIL FLOATNAME(LPlane) normalized() const; INLINE_MATHUTIL FLOATNAME(LPoint3) project(const FLOATNAME(LPoint3) &point) const; INLINE_MATHUTIL void flip(); From 0f4168a3047c253ef1e0b7e55d7d3e1f9bc84203 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 26 Jul 2018 19:35:57 +0200 Subject: [PATCH 095/360] text: use 64-bit coords in TextAssembler if vertices-float64 set --- panda/src/text/textAssembler.cxx | 114 +++++++++++++++---------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index bb3a789504..3925715c6d 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -1137,52 +1137,30 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { GeomTextGlyph::Glyphs glyphs; glyphs.reserve(quads.size()); - static CPT(GeomVertexFormat) format; - if (format.is_null()) { - // The optimized code below assumes 32-bit floats, so let's make sure we - // got the right format by creating it ourselves. - format = GeomVertexFormat::register_format(new GeomVertexArrayFormat( - InternalName::get_vertex(), 3, GeomEnums::NT_float32, GeomEnums::C_point, - InternalName::get_texcoord(), 2, GeomEnums::NT_float32, GeomEnums::C_texcoord)); - } - + const GeomVertexFormat *format = GeomVertexFormat::get_v3t2(); PT(GeomVertexData) vdata = new GeomVertexData("text", format, Geom::UH_static); - PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); - if (quads.size() > 10922) { - tris->set_index_type(GeomEnums::NT_uint32); - } else { - tris->set_index_type(GeomEnums::NT_uint16); - } - - int i = 0; + Thread *current_thread = Thread::get_current_thread(); // This is quite a critical loop and GeomVertexWriter quickly becomes the // bottleneck. So, I've written this out the hard way instead. Two - // versions of the loop: one for 32-bit indices, one for 16-bit. + // versions of the loop: one for 32-bit floats, the other for 64-bit. { PT(GeomVertexArrayDataHandle) vtx_handle = vdata->modify_array_handle(0); vtx_handle->unclean_set_num_rows(quads.size() * 4); - Thread *current_thread = Thread::get_current_thread(); unsigned char *write_ptr = vtx_handle->get_write_pointer(); - size_t stride = format->get_array(0)->get_stride() / sizeof(PN_float32); - PN_float32 *vtx_ptr = (PN_float32 *) - (write_ptr + format->get_column(InternalName::get_vertex())->get_start()); - PN_float32 *tex_ptr = (PN_float32 *) - (write_ptr + format->get_column(InternalName::get_texcoord())->get_start()); + if (format->get_vertex_column()->get_numeric_type() == GeomEnums::NT_float32) { + // 32-bit vertex case. + size_t stride = format->get_array(0)->get_stride() / sizeof(PN_float32); - if (tris->get_index_type() == GeomEnums::NT_uint32) { - // 32-bit index case. - PT(GeomVertexArrayDataHandle) idx_handle = tris->modify_vertices_handle(current_thread); - idx_handle->unclean_set_num_rows(quads.size() * 6); - uint32_t *idx_ptr = (uint32_t *)idx_handle->get_write_pointer(); - - QuadDefs::const_iterator qi; - for (qi = quads.begin(); qi != quads.end(); ++qi) { - const QuadDef &quad = (*qi); + PN_float32 *vtx_ptr = (PN_float32 *) + (write_ptr + format->get_column(InternalName::get_vertex())->get_start()); + PN_float32 *tex_ptr = (PN_float32 *) + (write_ptr + format->get_column(InternalName::get_texcoord())->get_start()); + for (const QuadDef &quad : quads) { vtx_ptr[0] = quad._dimensions[0] + quad._slanth; vtx_ptr[1] = 0; vtx_ptr[2] = quad._dimensions[3]; @@ -1219,26 +1197,18 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { tex_ptr[1] = quad._uvs[1]; tex_ptr += stride; - *(idx_ptr++) = i + 0; - *(idx_ptr++) = i + 1; - *(idx_ptr++) = i + 2; - *(idx_ptr++) = i + 2; - *(idx_ptr++) = i + 1; - *(idx_ptr++) = i + 3; - i += 4; - glyphs.push_back(move(quad._glyph)); } } else { - // 16-bit index case. - PT(GeomVertexArrayDataHandle) idx_handle = tris->modify_vertices_handle(current_thread); - idx_handle->unclean_set_num_rows(quads.size() * 6); - uint16_t *idx_ptr = (uint16_t *)idx_handle->get_write_pointer(); + // 64-bit vertex case. + size_t stride = format->get_array(0)->get_stride() / sizeof(PN_float64); - QuadDefs::const_iterator qi; - for (qi = quads.begin(); qi != quads.end(); ++qi) { - const QuadDef &quad = (*qi); + PN_float64 *vtx_ptr = (PN_float64 *) + (write_ptr + format->get_column(InternalName::get_vertex())->get_start()); + PN_float64 *tex_ptr = (PN_float64 *) + (write_ptr + format->get_column(InternalName::get_texcoord())->get_start()); + for (const QuadDef &quad : quads) { vtx_ptr[0] = quad._dimensions[0] + quad._slanth; vtx_ptr[1] = 0; vtx_ptr[2] = quad._dimensions[3]; @@ -1275,21 +1245,51 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { tex_ptr[1] = quad._uvs[1]; tex_ptr += stride; - *(idx_ptr++) = i + 0; - *(idx_ptr++) = i + 1; - *(idx_ptr++) = i + 2; - *(idx_ptr++) = i + 2; - *(idx_ptr++) = i + 1; - *(idx_ptr++) = i + 3; - i += 4; - glyphs.push_back(move(quad._glyph)); } } } + // Now write the indices. Two cases: 32-bit indices and 16-bit indices. + int vtx_count = quads.size() * 4; + PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); + if (vtx_count > 65535) { + tris->set_index_type(GeomEnums::NT_uint32); + } else { + tris->set_index_type(GeomEnums::NT_uint16); + } + { + PT(GeomVertexArrayDataHandle) idx_handle = tris->modify_vertices_handle(current_thread); + idx_handle->unclean_set_num_rows(quads.size() * 6); + if (tris->get_index_type() == GeomEnums::NT_uint16) { + // 16-bit index case. + uint16_t *idx_ptr = (uint16_t *)idx_handle->get_write_pointer(); + + for (int i = 0; i < vtx_count; i += 4) { + *(idx_ptr++) = i + 0; + *(idx_ptr++) = i + 1; + *(idx_ptr++) = i + 2; + *(idx_ptr++) = i + 2; + *(idx_ptr++) = i + 1; + *(idx_ptr++) = i + 3; + } + } else { + // 32-bit index case. + uint32_t *idx_ptr = (uint32_t *)idx_handle->get_write_pointer(); + + for (int i = 0; i < vtx_count; i += 4) { + *(idx_ptr++) = i + 0; + *(idx_ptr++) = i + 1; + *(idx_ptr++) = i + 2; + *(idx_ptr++) = i + 2; + *(idx_ptr++) = i + 1; + *(idx_ptr++) = i + 3; + } + } + } + // We can compute this value much faster than GeomPrimitive can. - tris->set_minmax(0, i - 1, nullptr, nullptr); + tris->set_minmax(0, vtx_count - 1, nullptr, nullptr); PT(GeomTextGlyph) geom = new GeomTextGlyph(vdata); geom->_glyphs.swap(glyphs); From 02b32a5814f0bed820677d2383cc4b4d249d929c Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 26 Jul 2018 20:05:35 +0200 Subject: [PATCH 096/360] glgsg: support vertices-float64 in core profile shaders Requires OpenGL 4.1 or GL_ARB_vertex_attrib_64bit extension. --- .../glstuff/glGraphicsStateGuardian_src.cxx | 58 +++++++++++++++++-- .../src/glstuff/glGraphicsStateGuardian_src.h | 2 +- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 7e8a08aacd..25a57a9a17 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -92,10 +92,6 @@ PStatCollector CLP(GraphicsStateGuardian)::_texture_update_pcollector("Draw:Upda PStatCollector CLP(GraphicsStateGuardian)::_fbo_bind_pcollector("Draw:Bind FBO"); PStatCollector CLP(GraphicsStateGuardian)::_check_error_pcollector("Draw:Check errors"); -#ifndef OPENGLES_1 -PT(Shader) CLP(GraphicsStateGuardian)::_default_shader = nullptr; -#endif - // The following noop functions are assigned to the corresponding glext // function pointers in the class, in case the functions are not defined by // the GL, just so it will always be safe to call the extension functions. @@ -188,6 +184,48 @@ static const string default_vshader = " color = p3d_Color * p3d_ColorScale;\n" "}\n"; +#ifndef OPENGLES +// This version of the shader is used if vertices-float64 is enabled. +static const string default_vshader_fp64 = +#ifdef __APPLE__ + "#version 150\n" +#else + "#version 130\n" +#endif + "#extension GL_ARB_vertex_attrib_64bit : require\n" + "#extension GL_ARB_gpu_shader_fp64 : require\n" + "in dvec3 p3d_Vertex;\n" + "in vec4 p3d_Color;\n" + "in dvec2 p3d_MultiTexCoord0;\n" + "out vec2 texcoord;\n" + "out vec4 color;\n" + "uniform mat4 p3d_ModelViewMatrix;\n" + "uniform mat4 p3d_ProjectionMatrix;\n" + "uniform vec4 p3d_ColorScale;\n" + "void main(void) {\n" // Apply proj & modelview in two steps, more precise + " gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n" + " texcoord = vec2(p3d_MultiTexCoord0);\n" + " color = p3d_Color * p3d_ColorScale;\n" + "}\n"; + +// Same as above, but for OpenGL 4.1. +static const string default_vshader_fp64_gl41 = + "#version 410\n" + "in dvec3 p3d_Vertex;\n" + "in vec4 p3d_Color;\n" + "in dvec2 p3d_MultiTexCoord0;\n" + "out vec2 texcoord;\n" + "out vec4 color;\n" + "uniform mat4 p3d_ModelViewMatrix;\n" + "uniform mat4 p3d_ProjectionMatrix;\n" + "uniform vec4 p3d_ColorScale;\n" + "void main(void) {\n" // Apply proj & modelview in two steps, more precise + " gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n" + " texcoord = vec2(p3d_MultiTexCoord0);\n" + " color = p3d_Color * p3d_ColorScale;\n" + "}\n"; +#endif + static const string default_fshader = #ifndef OPENGLES #ifdef __APPLE__ // Apple's GL 3.2 contexts require at least GLSL 1.50. @@ -1839,7 +1877,17 @@ reset() { // shader just outputs a red color, indicating that something went wrong. #ifndef OPENGLES_1 if (_default_shader == nullptr && !has_fixed_function_pipeline()) { - _default_shader = Shader::make(Shader::SL_GLSL, default_vshader, default_fshader); +#ifndef OPENGLES + bool use_float64 = vertices_float64; + if (use_float64 && is_at_least_gl_version(4, 1)) { + _default_shader = Shader::make(Shader::SL_GLSL, default_vshader_fp64_gl41, default_fshader); + } else if (use_float64 && has_extension("GL_ARB_vertex_attrib_64bit")) { + _default_shader = Shader::make(Shader::SL_GLSL, default_vshader_fp64, default_fshader); + } else +#endif + { + _default_shader = Shader::make(Shader::SL_GLSL, default_vshader, default_fshader); + } } #endif diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 67de9ac54c..a8cd3a2e3b 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -674,7 +674,7 @@ protected: PT(Shader) _texture_binding_shader; ShaderContext *_texture_binding_shader_context; - static PT(Shader) _default_shader; + PT(Shader) _default_shader; #ifndef OPENGLES bool _shader_point_size; From 0cb763a10af44220e3ff651e5d066d54368bc978 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 26 Jul 2018 21:56:22 +0200 Subject: [PATCH 097/360] ShaderGenerator: always use generic attr on Linux 48808fe269eac07b725dead80e2b18c838b53abb disabled this on Linux, but I believe this was an accidental change. --- panda/src/pgraphnodes/shaderGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 22d0b32259..71379ddbac 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -77,7 +77,7 @@ ShaderGenerator(const GraphicsStateGuardianBase *gsg) { #ifdef _WIN32 _use_generic_attr = !gsg->get_supports_hlsl(); #else - _use_generic_attr = false; + _use_generic_attr = true; #endif // Do we want to use the ARB_shadow extension? This also allows us to use From f12bc29d6d4b28124a6db9c8ba08e963277ed5b6 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 26 Jul 2018 22:57:09 +0200 Subject: [PATCH 098/360] tests: do not attempt to run GLSL tests without buffer tex support --- tests/display/test_glsl_shader.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/display/test_glsl_shader.py b/tests/display/test_glsl_shader.py index 0c9c9e8e95..91816353f6 100644 --- a/tests/display/test_glsl_shader.py +++ b/tests/display/test_glsl_shader.py @@ -45,6 +45,9 @@ def run_glsl_test(gsg, body, preamble="", inputs={}, version=430): if not gsg.supports_compute_shaders or not gsg.supports_glsl: pytest.skip("compute shaders not supported") + if not gsg.supports_buffer_texture: + pytest.skip("buffer textures not supported") + __tracebackhide__ = True preamble = preamble.strip() From 2d7e80a89e9c8a245778fe19d537ecfc9819d248 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 30 Jul 2018 11:04:20 +0200 Subject: [PATCH 099/360] express: add full range of WeakPointerTo ctors and assign ops Matches PointerTo constructors/assignment operators, supporting conversion between related pointer types. Fixes #367 --- panda/src/express/pointerToVoid.I | 7 - panda/src/express/pointerToVoid.h | 4 +- panda/src/express/weakPointerTo.I | 258 ++++++++++++++++++++++++++ panda/src/express/weakPointerTo.h | 60 +++++- panda/src/express/weakPointerToBase.I | 58 ++++-- panda/src/express/weakPointerToBase.h | 8 +- panda/src/express/weakPointerToVoid.I | 7 - panda/src/express/weakPointerToVoid.h | 4 +- 8 files changed, 373 insertions(+), 33 deletions(-) diff --git a/panda/src/express/pointerToVoid.I b/panda/src/express/pointerToVoid.I index c6f981a7fb..8704ce4ce6 100644 --- a/panda/src/express/pointerToVoid.I +++ b/panda/src/express/pointerToVoid.I @@ -11,13 +11,6 @@ * @date 2004-09-27 */ -/** - * - */ -constexpr PointerToVoid:: -PointerToVoid() noexcept : _void_ptr(nullptr) { -} - /** * */ diff --git a/panda/src/express/pointerToVoid.h b/panda/src/express/pointerToVoid.h index 1f5fadd492..e185911eab 100644 --- a/panda/src/express/pointerToVoid.h +++ b/panda/src/express/pointerToVoid.h @@ -32,7 +32,7 @@ */ class EXPCL_PANDA_EXPRESS PointerToVoid : public MemoryBase { protected: - constexpr PointerToVoid() noexcept; + constexpr PointerToVoid() noexcept = default; //INLINE ~PointerToVoid(); private: @@ -63,7 +63,7 @@ protected: // a PointerTo any class that inherits virtually from ReferenceCount. (You // can't downcast past a virtual inheritance level, but you can always // cross-cast from a void pointer.) - AtomicAdjust::Pointer _void_ptr; + AtomicAdjust::Pointer _void_ptr = nullptr; }; #include "pointerToVoid.I" diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index c6e570979f..354846807a 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -39,6 +39,49 @@ WeakPointerTo(const WeakPointerTo ©) : { } +/** + * + */ +template +INLINE WeakPointerTo:: +WeakPointerTo(WeakPointerTo &&from) noexcept : + WeakPointerToBase(std::move(from)) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo:: +WeakPointerTo(const WeakPointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo:: +WeakPointerTo(const PointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo:: +WeakPointerTo(WeakPointerTo &&r) noexcept : + WeakPointerToBase(std::move(r)) +{ +} + /** * */ @@ -152,6 +195,49 @@ operator = (const WeakPointerTo ©) { return *this; } +/** + * + */ +template +INLINE WeakPointerTo &WeakPointerTo:: +operator = (WeakPointerTo &&from) noexcept { + this->reassign(std::move(from)); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo &WeakPointerTo:: +operator = (const WeakPointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo &WeakPointerTo:: +operator = (const PointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakPointerTo &WeakPointerTo:: +operator = (WeakPointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} + /** * */ @@ -202,6 +288,92 @@ WeakConstPointerTo(const WeakConstPointerTo ©) : { } +/** + * + */ +template +INLINE WeakConstPointerTo:: +WeakConstPointerTo(WeakPointerTo &&from) noexcept : + WeakPointerToBase(std::move(from)) +{ +} + +/** + * + */ +template +INLINE WeakConstPointerTo:: +WeakConstPointerTo(WeakConstPointerTo &&from) noexcept : + WeakPointerToBase(std::move(from)) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(const WeakPointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(const WeakConstPointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(const PointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(const ConstPointerTo &r) noexcept : + WeakPointerToBase(r) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(WeakPointerTo &&r) noexcept : + WeakPointerToBase(std::move(r)) +{ +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo:: +WeakConstPointerTo(WeakConstPointerTo &&r) noexcept : + WeakPointerToBase(std::move(r)) +{ +} + /** * */ @@ -332,3 +504,89 @@ operator = (const WeakConstPointerTo ©) { ((WeakConstPointerTo *)this)->reassign(*(const PointerToBase *)©); return *this; } + +/** + * + */ +template +INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (WeakPointerTo &&from) noexcept { + this->reassign(std::move(from)); + return *this; +} + +/** + * + */ +template +INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (WeakConstPointerTo &&from) noexcept { + this->reassign(std::move(from)); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (const WeakPointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (const WeakConstPointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (const PointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (const ConstPointerTo &r) noexcept { + this->reassign(r); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (WeakPointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} + +/** + * + */ +template +template +ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: +operator = (WeakConstPointerTo &&r) noexcept { + this->reassign(std::move(r)); + return *this; +} diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index 2e8c6029a5..ee50b0ebc3 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -30,11 +30,21 @@ class WeakPointerTo : public WeakPointerToBase { public: typedef typename WeakPointerToBase::To To; PUBLISHED: - INLINE WeakPointerTo(To *ptr = nullptr); + constexpr WeakPointerTo() noexcept = default; + INLINE WeakPointerTo(To *ptr); INLINE WeakPointerTo(const PointerTo ©); INLINE WeakPointerTo(const WeakPointerTo ©); public: + INLINE WeakPointerTo(WeakPointerTo &&from) noexcept; + + template + ALWAYS_INLINE WeakPointerTo(const WeakPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakPointerTo(const PointerTo &r) noexcept; + template + ALWAYS_INLINE WeakPointerTo(WeakPointerTo &&r) noexcept; + INLINE To &operator *() const; INLINE To *operator -> () const; // MSVC.NET 2005 insists that we use T *, and not To *, here. @@ -49,6 +59,17 @@ PUBLISHED: INLINE WeakPointerTo &operator = (const PointerTo ©); INLINE WeakPointerTo &operator = (const WeakPointerTo ©); +public: + INLINE WeakPointerTo &operator = (WeakPointerTo &&from) noexcept; + + template + ALWAYS_INLINE WeakPointerTo &operator = (const WeakPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakPointerTo &operator = (const PointerTo &r) noexcept; + template + ALWAYS_INLINE WeakPointerTo &operator = (WeakPointerTo &&r) noexcept; + +PUBLISHED: // This function normally wouldn't need to be redefined here, but we do so // anyway just to help out interrogate (which doesn't seem to want to // automatically export the WeakPointerToBase class). When this works again @@ -66,13 +87,30 @@ class WeakConstPointerTo : public WeakPointerToBase { public: typedef typename WeakPointerToBase::To To; PUBLISHED: - INLINE WeakConstPointerTo(const To *ptr = nullptr); + constexpr WeakConstPointerTo() noexcept = default; + INLINE WeakConstPointerTo(const To *ptr); INLINE WeakConstPointerTo(const PointerTo ©); INLINE WeakConstPointerTo(const ConstPointerTo ©); INLINE WeakConstPointerTo(const WeakPointerTo ©); INLINE WeakConstPointerTo(const WeakConstPointerTo ©); public: + INLINE WeakConstPointerTo(WeakPointerTo &&from) noexcept; + INLINE WeakConstPointerTo(WeakConstPointerTo &&from) noexcept; + + template + ALWAYS_INLINE WeakConstPointerTo(const WeakPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(const WeakConstPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(const PointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(const ConstPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(WeakPointerTo &&r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo(WeakConstPointerTo &&r) noexcept; + INLINE const To &operator *() const; INLINE const To *operator -> () const; INLINE explicit operator const T *() const; @@ -88,6 +126,24 @@ PUBLISHED: INLINE WeakConstPointerTo &operator = (const WeakPointerTo ©); INLINE WeakConstPointerTo &operator = (const WeakConstPointerTo ©); +public: + INLINE WeakConstPointerTo &operator = (WeakPointerTo &&from) noexcept; + INLINE WeakConstPointerTo &operator = (WeakConstPointerTo &&from) noexcept; + + template + ALWAYS_INLINE WeakConstPointerTo &operator = (const WeakPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (const WeakConstPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (const PointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (const ConstPointerTo &r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (WeakPointerTo &&r) noexcept; + template + ALWAYS_INLINE WeakConstPointerTo &operator = (WeakConstPointerTo &&r) noexcept; + +PUBLISHED: // These functions normally wouldn't need to be redefined here, but we do so // anyway just to help out interrogate (which doesn't seem to want to // automatically export the WeakPointerToBase class). When this works again diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 2e537c9639..5410903fdd 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -64,20 +64,27 @@ WeakPointerToBase(const WeakPointerToBase ©) { template INLINE WeakPointerToBase:: WeakPointerToBase(WeakPointerToBase &&from) noexcept { - // Protect against self-move-assignment. - if (from._void_ptr != this->_void_ptr) { - WeakReferenceList *old_ref = (To *)this->_weak_ref; + this->_void_ptr = from._void_ptr; + this->_weak_ref = from._weak_ref; + from._void_ptr = nullptr; + from._weak_ref = nullptr; +} - this->_void_ptr = from._void_ptr; - this->_weak_ref = from._weak_ref; - from._void_ptr = nullptr; - from._weak_ref = nullptr; +/** + * + */ +template +template +INLINE WeakPointerToBase:: +WeakPointerToBase(WeakPointerToBase &&r) noexcept { + // If this next line gives an error, you are trying to convert a WeakPointerTo + // from an incompatible type of another WeakPointerTo. + To *ptr = (Y *)r._void_ptr; - // Now delete the old pointer. - if (old_ref != nullptr && !old_ref->unref()) { - delete old_ref; - } - } + this->_void_ptr = ptr; + this->_weak_ref = r._weak_ref; + r._void_ptr = nullptr; + r._weak_ref = nullptr; } /** @@ -180,6 +187,33 @@ reassign(WeakPointerToBase &&from) noexcept { } } +/** + * Like above, but casts from a compatible pointer type. + */ +template +template +INLINE void WeakPointerToBase:: +reassign(WeakPointerToBase &&from) noexcept { + // Protect against self-move-assignment. + if (from._void_ptr != this->_void_ptr) { + WeakReferenceList *old_ref = (WeakReferenceList *)this->_weak_ref; + + // If there is a compile error on this line, it means you tried to assign + // an incompatible type. + To *new_ptr = (Y *)from._void_ptr; + + this->_void_ptr = new_ptr; + this->_weak_ref = from._weak_ref; + from._void_ptr = nullptr; + from._weak_ref = nullptr; + + // Now delete the old pointer. + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; + } + } +} + /** * Ensures that the MemoryUsage record for the pointer has the right type of * object, if we know the type ourselves. diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index a34b39bdb5..94efd051eb 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -28,16 +28,22 @@ public: typedef T To; protected: - INLINE WeakPointerToBase(To *ptr); + constexpr WeakPointerToBase() noexcept = default; + INLINE explicit WeakPointerToBase(To *ptr); INLINE WeakPointerToBase(const PointerToBase ©); INLINE WeakPointerToBase(const WeakPointerToBase ©); INLINE WeakPointerToBase(WeakPointerToBase &&from) noexcept; + template + INLINE WeakPointerToBase(WeakPointerToBase &&r) noexcept; + INLINE ~WeakPointerToBase(); void reassign(To *ptr); INLINE void reassign(const PointerToBase ©); INLINE void reassign(const WeakPointerToBase ©); INLINE void reassign(WeakPointerToBase &&from) noexcept; + template + INLINE void reassign(WeakPointerToBase &&from) noexcept; INLINE void update_type(To *ptr); diff --git a/panda/src/express/weakPointerToVoid.I b/panda/src/express/weakPointerToVoid.I index 120836510d..187a659fc1 100644 --- a/panda/src/express/weakPointerToVoid.I +++ b/panda/src/express/weakPointerToVoid.I @@ -11,13 +11,6 @@ * @date 2004-09-27 */ -/** - * - */ -INLINE WeakPointerToVoid:: -WeakPointerToVoid() : _weak_ref(nullptr) { -} - /** * Sets a callback that will be made when the pointer is deleted. Does * nothing if this is a null pointer. diff --git a/panda/src/express/weakPointerToVoid.h b/panda/src/express/weakPointerToVoid.h index 56ace2dcb2..3eadfffc4d 100644 --- a/panda/src/express/weakPointerToVoid.h +++ b/panda/src/express/weakPointerToVoid.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDA_EXPRESS WeakPointerToVoid : public PointerToVoid { protected: - INLINE WeakPointerToVoid(); + constexpr WeakPointerToVoid() noexcept = default; public: INLINE void add_callback(WeakPointerCallback *callback) const; @@ -36,7 +36,7 @@ PUBLISHED: INLINE bool is_valid_pointer() const; protected: - mutable WeakReferenceList *_weak_ref; + mutable WeakReferenceList *_weak_ref = nullptr; }; #include "weakPointerToVoid.I" From ad3ab3ad211650fe0cf7c304a4032c87326a0d10 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 30 Jul 2018 17:27:09 +0200 Subject: [PATCH 100/360] Define stable ordering for WeakPointerTo for use as map/set key Currently, the WeakPointerTo comparison operators compare the raw pointers, but this is not useful as it may cause a false equality if one weak pointer in the comparison is expired and points to memory that has since been reused. Instead, we can define a comparison based on the control block pointer, which exists since the new weak pointer implementation in 0bb81a43c9e4fffb37cc2234c1b0fbae42020ceb. This is implemented in the owner_before method, matching C++11 std::weak_ptr semantics. I would now recommend deprecating most comparison operators of WeakPointerTo or redefining them to make more sense, ie. comparing equal if they (once) referred to the same object and not if they simply point to the same memory address. This has not yet been done, though code that uses the comparison operators has been fixed in this commit. Overloads of std::owner_less have been provided for creating a map or set with Weak(Const)PointerTo keys. --- dtool/src/dtoolbase/dtoolbase_cc.h | 2 + panda/src/chan/partBundle.h | 2 +- panda/src/char/characterJointEffect.I | 6 +- panda/src/dxgsg9/dxGeomMunger9.cxx | 14 ++-- panda/src/express/pointerTo.h | 20 ++++++ panda/src/express/pointerToBase.h | 1 + panda/src/express/weakPointerTo.h | 19 ++++++ panda/src/express/weakPointerToBase.I | 94 +++++++++++++++++++------- panda/src/express/weakPointerToBase.h | 5 ++ panda/src/glstuff/glGeomMunger_src.cxx | 28 +++++--- panda/src/pgraph/nodePath.cxx | 14 ++-- panda/src/pgraph/weakNodePath.I | 21 +++--- 12 files changed, 167 insertions(+), 59 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index b4ce1d597c..3af3c9c250 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -111,6 +111,8 @@ namespace std { template typename remove_reference::type &&move(T &&t) { return static_cast::type&&>(t); } + + template struct owner_less; }; #endif diff --git a/panda/src/chan/partBundle.h b/panda/src/chan/partBundle.h index 7a611a80de..f8fda4bd47 100644 --- a/panda/src/chan/partBundle.h +++ b/panda/src/chan/partBundle.h @@ -172,7 +172,7 @@ private: typedef pvector Nodes; Nodes _nodes; - typedef pmap AppliedTransforms; + typedef pmap > AppliedTransforms; AppliedTransforms _applied_transforms; double _update_delay; diff --git a/panda/src/char/characterJointEffect.I b/panda/src/char/characterJointEffect.I index e4d596dafe..34e2502afa 100644 --- a/panda/src/char/characterJointEffect.I +++ b/panda/src/char/characterJointEffect.I @@ -35,5 +35,9 @@ get_character() const { */ INLINE bool CharacterJointEffect:: matches_character(Character *character) const { - return _character == character; + // This works because while the Character is destructing, the ref count will + // be 0 but was_deleted() will still return false. We cannot construct a + // PointerTo to the character (via lock() or otherwise) when the reference + // count is 0 since that will cause double deletion. + return _character.get_orig() == character && !_character.was_deleted(); } diff --git a/panda/src/dxgsg9/dxGeomMunger9.cxx b/panda/src/dxgsg9/dxGeomMunger9.cxx index 8aa539c11f..638b121f27 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.cxx +++ b/panda/src/dxgsg9/dxGeomMunger9.cxx @@ -300,8 +300,11 @@ compare_to_impl(const GeomMunger *other) const { if (_filtered_texture != om->_filtered_texture) { return _filtered_texture < om->_filtered_texture ? -1 : 1; } - if (_tex_gen != om->_tex_gen) { - return _tex_gen < om->_tex_gen ? -1 : 1; + if (_tex_gen.owner_before(om->_tex_gen)) { + return -1; + } + if (om->_tex_gen.owner_before(_tex_gen)) { + return 1; } return StandardMunger::compare_to_impl(other); @@ -321,8 +324,11 @@ geom_compare_to_impl(const GeomMunger *other) const { if (_filtered_texture != om->_filtered_texture) { return _filtered_texture < om->_filtered_texture ? -1 : 1; } - if (_tex_gen != om->_tex_gen) { - return _tex_gen < om->_tex_gen ? -1 : 1; + if (_tex_gen.owner_before(om->_tex_gen)) { + return -1; + } + if (om->_tex_gen.owner_before(_tex_gen)) { + return 1; } return StandardMunger::geom_compare_to_impl(other); diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index e9250a2f8a..cb790ebd81 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -215,6 +215,26 @@ void swap(ConstPointerTo &one, ConstPointerTo &two) noexcept { } +// Define owner_less specializations, for completeness' sake. +namespace std { + template + struct owner_less > { + bool operator () (const PointerTo &lhs, + const PointerTo &rhs) const noexcept { + return lhs < rhs; + } + }; + + template + struct owner_less > { + bool operator () (const ConstPointerTo &lhs, + const ConstPointerTo &rhs) const noexcept { + return lhs < rhs; + } + }; +} + + // Finally, we'll define a couple of handy abbreviations to save on all that // wasted typing time. diff --git a/panda/src/express/pointerToBase.h b/panda/src/express/pointerToBase.h index 959574aba7..832717e14e 100644 --- a/panda/src/express/pointerToBase.h +++ b/panda/src/express/pointerToBase.h @@ -53,6 +53,7 @@ protected: // This is needed to be able to access the privates of other instantiations. template friend class PointerToBase; + template friend class WeakPointerToBase; PUBLISHED: ALWAYS_INLINE void clear(); diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index ee50b0ebc3..bd302e0ec9 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -152,6 +152,25 @@ PUBLISHED: INLINE void clear() { WeakPointerToBase::clear(); } }; +// Provide specializations of std::owner_less, for using a WPT as a map key. +namespace std { + template + struct owner_less > { + bool operator () (const WeakPointerTo &lhs, + const WeakPointerTo &rhs) const noexcept { + return lhs.owner_before(rhs); + } + }; + + template + struct owner_less > { + bool operator () (const WeakConstPointerTo &lhs, + const WeakConstPointerTo &rhs) const noexcept { + return lhs.owner_before(rhs); + } + }; +} + #define WPT(type) WeakPointerTo< type > #define WCPT(type) WeakConstPointerTo< type > diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 5410903fdd..c57ea31719 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -12,7 +12,8 @@ */ /** - * + * Constructs a weak pointer from a plain pointer (or nullptr). It is the + * caller's responsibility to ensure that it points to a valid object. */ template INLINE WeakPointerToBase:: @@ -27,7 +28,7 @@ WeakPointerToBase(To *ptr) { } /** - * + * Constructs a weak pointer from a reference-counting pointer. */ template INLINE WeakPointerToBase:: @@ -42,24 +43,25 @@ WeakPointerToBase(const PointerToBase ©) { } /** - * + * Copies a weak pointer. This is always safe, even for expired pointers. */ template INLINE WeakPointerToBase:: WeakPointerToBase(const WeakPointerToBase ©) { _void_ptr = copy._void_ptr; - // Don't bother increasing the weak reference count if the object was - // already deleted. + // While it is tempting to stop maintaining the control block pointer after + // the object has been deleted, we still need it in order to define a + // consistent ordering in owner_before. WeakReferenceList *weak_ref = copy._weak_ref; - if (weak_ref != nullptr && !weak_ref->was_deleted()) { + if (weak_ref != nullptr/* && !weak_ref->was_deleted()*/) { _weak_ref = copy._weak_ref; _weak_ref->ref(); } } /** - * + * Moves a weak pointer. This is always safe, even for expired pointers. */ template INLINE WeakPointerToBase:: @@ -71,7 +73,7 @@ WeakPointerToBase(WeakPointerToBase &&from) noexcept { } /** - * + * Moves a weak pointer from a cast-convertible weak pointer type. */ template template @@ -148,10 +150,11 @@ reassign(const WeakPointerToBase ©) { WeakReferenceList *old_ref = (WeakReferenceList *)_weak_ref; _void_ptr = new_ptr; - // Don't bother increasing the weak reference count if the object was - // already deleted. + // While it is tempting to stop maintaining the control block pointer + // after the object has been deleted, we still need it in order to define + // a consistent ordering in owner_before. WeakReferenceList *weak_ref = copy._weak_ref; - if (weak_ref != nullptr && !weak_ref->was_deleted()) { + if (weak_ref != nullptr/* && !weak_ref->was_deleted()*/) { weak_ref->ref(); _weak_ref = weak_ref; } else { @@ -371,7 +374,11 @@ operator >= (std::nullptr_t) const { } /** - * + * Returns true if both pointers have the same raw pointer value. For this to + * be meaningful, neither pointer may have expired, since if one has expired + * while the other was allocated at the expired pointer's memory address, this + * comparison will be true even though they didn't refer to the same object. + * @see owner_before */ template INLINE bool WeakPointerToBase:: @@ -380,7 +387,7 @@ operator == (const WeakPointerToBase &other) const { } /** - * + * @see operator == */ template INLINE bool WeakPointerToBase:: @@ -389,7 +396,8 @@ operator != (const WeakPointerToBase &other) const { } /** - * + * Defines an ordering between WeakPointerTo based on their raw pointer value. + * @deprecated Do not use this. Use owner_before or std::owner_less instead. */ template INLINE bool WeakPointerToBase:: @@ -398,7 +406,8 @@ operator > (const WeakPointerToBase &other) const { } /** - * + * Defines an ordering between WeakPointerTo based on their raw pointer value. + * @deprecated Do not use this. Use owner_before or std::owner_less instead. */ template INLINE bool WeakPointerToBase:: @@ -407,7 +416,8 @@ operator <= (const WeakPointerToBase &other) const { } /** - * + * Defines an ordering between WeakPointerTo based on their raw pointer value. + * @deprecated Do not use this. Use owner_before or std::owner_less instead. */ template INLINE bool WeakPointerToBase:: @@ -416,7 +426,7 @@ operator >= (const WeakPointerToBase &other) const { } /** - * + * Returns true if both pointers point to the same object. */ template INLINE bool WeakPointerToBase:: @@ -425,7 +435,7 @@ operator == (const PointerToBase &other) const { } /** - * + * Returns false if both pointers point to the same object. */ template INLINE bool WeakPointerToBase:: @@ -479,7 +489,8 @@ operator < (std::nullptr_t) const { } /** - * + * Defines an ordering between WeakPointerTo based on their raw pointer value. + * @deprecated Do not use this. Use owner_before or std::owner_less instead. */ template INLINE bool WeakPointerToBase:: @@ -498,6 +509,35 @@ operator < (const PointerToBase &other) const { #endif // CPPPARSER +/** + * Defines an ordering that is guaranteed to remain consistent even after the + * weak pointers have expired. This may result in two pointers with the same + * get_orig() value comparing unequal if one of them is a new object that was + * allocated at the same memory address as the older, expired pointer. + */ +template +template +INLINE bool WeakPointerToBase:: +owner_before(const WeakPointerToBase &other) const noexcept { + return _weak_ref < other._weak_ref; +} + +/** + * Defines an ordering that is guaranteed to remain consistent even after this + * weak pointer has expired. This may result in two pointers with the same + * get_orig() value comparing unequal if one of them is a new object that was + * allocated at the same memory address as the older, expired pointer. + */ +template +template +INLINE bool WeakPointerToBase:: +owner_before(const PointerToBase &other) const noexcept { + // Unfortunately, this may needlessly cause a control block to be allocated, + // but I do not see a more efficient solution. + return (other._void_ptr != nullptr) && + (_void_ptr == nullptr || _weak_ref < ((const Y *)other._void_ptr)->get_weak_list()); +} + /** * A convenient way to set the PointerTo object to NULL. (Assignment to a NULL * pointer also works, of course.) @@ -539,9 +579,17 @@ template INLINE void WeakPointerToBase:: output(std::ostream &out) const { out << _void_ptr; - if (was_deleted()) { - out << ":deleted"; - } else if (_void_ptr != nullptr) { - out << ":" << ((To *)_void_ptr)->get_ref_count(); + + WeakReferenceList *weak_ref = this->_weak_ref; + if (weak_ref != nullptr) { + weak_ref->_lock.lock(); + if (!weak_ref->was_deleted()) { + out << ":" << ((To *)_void_ptr)->get_ref_count(); + } else { + out << ":deleted"; + } + weak_ref->_lock.unlock(); + } else { + out << ":invalid"; } } diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index 94efd051eb..60be402c4c 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -89,6 +89,11 @@ public: INLINE bool operator < (const PointerToBase &other) const; #endif // CPPPARSER + template + INLINE bool owner_before(const WeakPointerToBase &other) const noexcept; + template + INLINE bool owner_before(const PointerToBase &other) const noexcept; + PUBLISHED: INLINE void clear(); INLINE void refresh() const; diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index 27f226a6cc..923b8e5b76 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -426,11 +426,17 @@ premunge_format_impl(const GeomVertexFormat *orig) { int CLP(GeomMunger):: compare_to_impl(const GeomMunger *other) const { const CLP(GeomMunger) *om = (CLP(GeomMunger) *)other; - if (_texture != om->_texture) { - return _texture < om->_texture ? -1 : 1; + if (_texture.owner_before(om->_texture)) { + return -1; } - if (_tex_gen != om->_tex_gen) { - return _tex_gen < om->_tex_gen ? -1 : 1; + if (om->_texture.owner_before(_texture)) { + return 1; + } + if (_tex_gen.owner_before(om->_tex_gen)) { + return -1; + } + if (om->_tex_gen.owner_before(_tex_gen)) { + return 1; } if (_flags != om->_flags) { return _flags < om->_flags ? -1 : 1; @@ -447,11 +453,17 @@ compare_to_impl(const GeomMunger *other) const { int CLP(GeomMunger):: geom_compare_to_impl(const GeomMunger *other) const { const CLP(GeomMunger) *om = (CLP(GeomMunger) *)other; - if (_texture != om->_texture) { - return _texture < om->_texture ? -1 : 1; + if (_texture.owner_before(om->_texture)) { + return -1; } - if (_tex_gen != om->_tex_gen) { - return _tex_gen < om->_tex_gen ? -1 : 1; + if (om->_texture.owner_before(_texture)) { + return 1; + } + if (_tex_gen.owner_before(om->_tex_gen)) { + return -1; + } + if (om->_tex_gen.owner_before(_tex_gen)) { + return 1; } if (_flags != om->_flags) { return _flags < om->_flags ? -1 : 1; diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 9123a951b5..a21df38d19 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -5177,7 +5177,7 @@ get_stashed_ancestor(Thread *current_thread) const { */ bool NodePath:: operator == (const WeakNodePath &other) const { - return _head == other._head; + return (other == *this); } /** @@ -5185,7 +5185,7 @@ operator == (const WeakNodePath &other) const { */ bool NodePath:: operator != (const WeakNodePath &other) const { - return _head != other._head; + return (other != *this); } /** @@ -5196,7 +5196,7 @@ operator != (const WeakNodePath &other) const { */ bool NodePath:: operator < (const WeakNodePath &other) const { - return _head < other._head; + return other.compare_to(*this) > 0; } /** @@ -5211,13 +5211,7 @@ operator < (const WeakNodePath &other) const { */ int NodePath:: compare_to(const WeakNodePath &other) const { - // Nowadays, the NodePathComponents at the head are pointerwise equivalent - // if and only if the NodePaths are equivalent. So we only have to compare - // pointers. - if (_head != other._head) { - return _head < other._head ? -1 : 1; - } - return 0; + return -other.compare_to(*this); } /** diff --git a/panda/src/pgraph/weakNodePath.I b/panda/src/pgraph/weakNodePath.I index c2d4b0a523..3096f99c41 100644 --- a/panda/src/pgraph/weakNodePath.I +++ b/panda/src/pgraph/weakNodePath.I @@ -124,7 +124,7 @@ node() const { */ INLINE bool WeakNodePath:: operator == (const NodePath &other) const { - return _head == other._head; + return _head.get_orig() == other._head && !_head.was_deleted(); } /** @@ -132,7 +132,7 @@ operator == (const NodePath &other) const { */ INLINE bool WeakNodePath:: operator != (const NodePath &other) const { - return _head != other._head; + return !operator == (other); } /** @@ -143,7 +143,7 @@ operator != (const NodePath &other) const { */ INLINE bool WeakNodePath:: operator < (const NodePath &other) const { - return _head < other._head; + return _head.owner_before(other._head); } /** @@ -158,8 +158,8 @@ operator < (const NodePath &other) const { */ INLINE int WeakNodePath:: compare_to(const NodePath &other) const { - if (_head != other._head) { - return _head < other._head ? -1 : 1; + if (operator != (other)) { + return _head.owner_before(other._head) ? -1 : 1; } return 0; } @@ -170,7 +170,7 @@ compare_to(const NodePath &other) const { */ INLINE bool WeakNodePath:: operator == (const WeakNodePath &other) const { - return _head == other._head; + return !_head.owner_before(other._head) && !other._head.owner_before(_head); } /** @@ -178,7 +178,7 @@ operator == (const WeakNodePath &other) const { */ INLINE bool WeakNodePath:: operator != (const WeakNodePath &other) const { - return _head != other._head; + return _head.owner_before(other._head) || other._head.owner_before(_head); } /** @@ -189,7 +189,7 @@ operator != (const WeakNodePath &other) const { */ INLINE bool WeakNodePath:: operator < (const WeakNodePath &other) const { - return _head < other._head; + return _head.owner_before(other._head); } /** @@ -204,10 +204,7 @@ operator < (const WeakNodePath &other) const { */ INLINE int WeakNodePath:: compare_to(const WeakNodePath &other) const { - if (_head != other._head) { - return _head < other._head ? -1 : 1; - } - return 0; + return other._head.owner_before(_head) - _head.owner_before(other._head); } /** From 243ee75e47563def6620c3cfebf6dcc12f4c9b31 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 30 Jul 2018 22:24:55 +0200 Subject: [PATCH 101/360] express: refactor WeakPointerTo::lock() a little bit --- panda/src/express/weakPointerTo.I | 40 ++++----------------------- panda/src/express/weakPointerToBase.I | 28 +++++++++++++++++++ panda/src/express/weakPointerToBase.h | 2 ++ panda/src/express/weakPointerToVoid.I | 8 ++++-- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index 354846807a..8d60057c31 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -125,23 +125,9 @@ operator T * () const { template INLINE PointerTo WeakPointerTo:: lock() const { - WeakReferenceList *weak_ref = this->_weak_ref; - if (weak_ref != nullptr) { - PointerTo ptr; - weak_ref->_lock.lock(); - if (!weak_ref->was_deleted()) { - // We also need to check that the reference count is not zero (which can - // happen if the object is currently being destructed), since that could - // cause double deletion. - To *plain_ptr = (To *)WeakPointerToBase::_void_ptr; - if (plain_ptr != nullptr && plain_ptr->ref_if_nonzero()) { - ptr.cheat() = plain_ptr; - } - } - weak_ref->_lock.unlock(); - return ptr; - } - return nullptr; + PointerTo ptr; + this->lock_into(ptr); + return ptr; } /** @@ -415,23 +401,9 @@ operator const T * () const { template INLINE ConstPointerTo WeakConstPointerTo:: lock() const { - WeakReferenceList *weak_ref = this->_weak_ref; - if (weak_ref != nullptr) { - ConstPointerTo ptr; - weak_ref->_lock.lock(); - if (!weak_ref->was_deleted()) { - // We also need to check that the reference count is not zero (which can - // happen if the object is currently being destructed), since that could - // cause double deletion. - const To *plain_ptr = (const To *)WeakPointerToBase::_void_ptr; - if (plain_ptr != nullptr && plain_ptr->ref_if_nonzero()) { - ptr.cheat() = plain_ptr; - } - } - weak_ref->_lock.unlock(); - return ptr; - } - return nullptr; + ConstPointerTo ptr; + this->lock_into(ptr); + return ptr; } /** diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index c57ea31719..8c6de65523 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -238,6 +238,34 @@ update_type(To *ptr) { #endif // DO_MEMORY_USAGE } +/** + * A thread-safe way to access the underlying pointer; will only write to the + * given pointer if the underlying pointer has not yet been deleted and is not + * null. Note that it may leave the pointer unassigned even if was_deleted() + * still returns true, which can occur if the object has reached reference + * count 0 and is about to be destroyed. + */ +template +INLINE void WeakPointerToBase:: +lock_into(PointerToBase &locked) const { + WeakReferenceList *weak_ref = this->_weak_ref; + if (weak_ref != nullptr) { + weak_ref->_lock.lock(); + if (!weak_ref->was_deleted()) { + // We also need to check that the reference count is not zero (which can + // happen if the object is currently being destructed), since that could + // cause double deletion. + To *plain_ptr = (To *)WeakPointerToBase::_void_ptr; + if (plain_ptr != nullptr && plain_ptr->ref_if_nonzero()) { + // It is valid and we successfully grabbed a reference. Assign it, + // noting we have already incremented the reference count. + locked._void_ptr = plain_ptr; + } + } + weak_ref->_lock.unlock(); + } +} + #ifndef CPPPARSER /** * diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index 60be402c4c..474514b055 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -47,6 +47,8 @@ protected: INLINE void update_type(To *ptr); + INLINE void lock_into(PointerToBase &locked) const; + // No assignment or retrieval functions are declared in WeakPointerToBase, // because we will have to specialize on const vs. non-const later. diff --git a/panda/src/express/weakPointerToVoid.I b/panda/src/express/weakPointerToVoid.I index 187a659fc1..83253c7921 100644 --- a/panda/src/express/weakPointerToVoid.I +++ b/panda/src/express/weakPointerToVoid.I @@ -40,7 +40,11 @@ remove_callback(WeakPointerCallback *callback) const { /** * Returns true if the object we are pointing to has been deleted, false - * otherwise. + * otherwise. If this returns true, it means that the pointer can not yet be + * reused, but it does not guarantee that it can be safely accessed. See the + * lock() method for a safe way to access the underlying pointer. + * + * This will always return true for a null pointer, unlike is_valid_pointer(). */ INLINE bool WeakPointerToVoid:: was_deleted() const { @@ -49,7 +53,7 @@ was_deleted() const { /** * Returns true if the pointer is not null and the object has not been - * deleted. + * deleted. See was_deleted() for caveats. */ INLINE bool WeakPointerToVoid:: is_valid_pointer() const { From 91b01e562128c4a18e20edbafd8fe97da04dc0a0 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 30 Jul 2018 22:37:02 +0200 Subject: [PATCH 102/360] collide: add tube-into-box collision test --- panda/src/collide/collisionBox.cxx | 145 +++++++++++++++++++++++++++++ panda/src/collide/collisionBox.h | 2 + panda/src/collide/collisionTube.h | 2 + 3 files changed, 149 insertions(+) diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index 494013c75b..119284f905 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -545,6 +545,151 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return new_entry; } +/** + * Double dispatch point for tube as a FROM object + */ +PT(CollisionEntry) CollisionBox:: +test_intersection_from_tube(const CollisionEntry &entry) const { + const CollisionTube *tube; + DCAST_INTO_R(tube, entry.get_from(), nullptr); + + const LMatrix4 &wrt_mat = entry.get_wrt_mat(); + + LPoint3 from_a = tube->get_point_a() * wrt_mat; + LPoint3 from_b = tube->get_point_b() * wrt_mat; + LVector3 from_direction = from_b - from_a; + PN_stdfloat radius_sq = wrt_mat.xform_vec(LVector3(0, 0, tube->get_radius())).length_squared(); + PN_stdfloat radius = csqrt(radius_sq); + + LPoint3 box_min = get_min(); + LPoint3 box_max = get_max(); + LVector3 dimensions = box_max - box_min; + + // The method below is inspired by Christer Ericson's book Real-Time + // Collision Detection. Instead of testing a capsule against a box, we test + // a segment against an box that is oversized by the capsule radius. + + // First, we test if the line segment intersects a box with its faces + // expanded outwards by the capsule radius. If not, there is no collision. + double t1, t2; + if (!intersects_line(t1, t2, from_a, from_direction, radius)) { + return nullptr; + } + + if (t2 < 0.0 || t1 > 1.0) { + return nullptr; + } + + t1 = std::min(1.0, std::max(0.0, (t1 + t2) * 0.5)); + LPoint3 point = from_a + from_direction * t1; + + // We now have a point of intersection between the line segment and the + // oversized box. Check on how many axes it lies outside the box. If it is + // less than two, we know that it does not lie in one of the rounded regions + // of the oversized rounded box, and it is a guaranteed hit. Otherwise, we + // will need to test against the edge regions. + if ((point[0] < box_min[0] || point[0] > box_max[0]) + + (point[1] < box_min[1] || point[1] > box_max[1]) + + (point[2] < box_min[2] || point[2] > box_max[2]) > 1) { + // Test the capsule against each edge of the box. + static const struct { + LPoint3 point; + int axis; + } edges[] = { + {{0, 0, 0}, 0}, + {{0, 1, 0}, 0}, + {{0, 0, 1}, 0}, + {{0, 1, 1}, 0}, + {{0, 0, 0}, 1}, + {{0, 0, 1}, 1}, + {{1, 0, 0}, 1}, + {{1, 0, 1}, 1}, + {{0, 0, 0}, 2}, + {{0, 1, 0}, 2}, + {{1, 0, 0}, 2}, + {{1, 1, 0}, 2}, + }; + + PN_stdfloat best_dist_sq = FLT_MAX; + + for (int i = 0; i < 12; ++i) { + LPoint3 vertex = edges[i].point; + vertex.componentwise_mult(dimensions); + vertex += box_min; + LVector3 delta(0); + delta[edges[i].axis] = dimensions[edges[i].axis]; + double u1, u2; + CollisionTube::calc_closest_segment_points(u1, u2, from_a, from_direction, vertex, delta); + PN_stdfloat dist_sq = ((from_a + from_direction * u1) - (vertex + delta * u2)).length_squared(); + if (dist_sq < best_dist_sq) { + best_dist_sq = dist_sq; + } + } + + if (best_dist_sq > radius_sq) { + // It is not actually touching any edge. + return nullptr; + } + } + + if (collide_cat.is_debug()) { + collide_cat.debug() + << "intersection detected from " << entry.get_from_node_path() + << " into " << entry.get_into_node_path() << "\n"; + } + PT(CollisionEntry) new_entry = new CollisionEntry(entry); + + // Which is the longest axis? + LVector3 diff = point - _center; + diff[0] /= dimensions[0]; + diff[1] /= dimensions[1]; + diff[2] /= dimensions[2]; + int axis = 0; + if (cabs(diff[0]) > cabs(diff[1])) { + if (cabs(diff[0]) > cabs(diff[2])) { + axis = 0; + } else { + axis = 2; + } + } else { + if (cabs(diff[1]) > cabs(diff[2])) { + axis = 1; + } else { + axis = 2; + } + } + LVector3 normal(0); + normal[axis] = std::copysign(1, diff[axis]); + + LPoint3 clamped = point.fmax(box_min).fmin(box_max); + LPoint3 surface_point = clamped; + surface_point[axis] = (diff[axis] >= 0.0f) ? box_max[axis] : box_min[axis]; + + // Is the point inside the box? + LVector3 interior_vec; + if (clamped != point) { + // No, it is outside. The interior point is in the direction of the + // surface point. + interior_vec = point - surface_point; + if (!interior_vec.normalize()) { + interior_vec = normal; + } + } else { + // It is inside. I think any point will work for this. + interior_vec = normal; + } + new_entry->set_interior_point(point - interior_vec * radius); + new_entry->set_surface_point(surface_point); + + if (has_effective_normal() && tube->get_respect_effective_normal()) { + new_entry->set_surface_normal(get_effective_normal()); + } else { + new_entry->set_surface_normal(normal); + } + + return new_entry; +} + /** * Double dispatch point for box as a FROM object */ diff --git a/panda/src/collide/collisionBox.h b/panda/src/collide/collisionBox.h index 0810aa95e2..cf9e8bc15b 100644 --- a/panda/src/collide/collisionBox.h +++ b/panda/src/collide/collisionBox.h @@ -81,6 +81,8 @@ protected: test_intersection_from_ray(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const; + virtual PT(CollisionEntry) + test_intersection_from_tube(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_box(const CollisionEntry &entry) const; diff --git a/panda/src/collide/collisionTube.h b/panda/src/collide/collisionTube.h index 70f1832b9b..3d91ce2506 100644 --- a/panda/src/collide/collisionTube.h +++ b/panda/src/collide/collisionTube.h @@ -151,6 +151,8 @@ public: private: static TypeHandle _type_handle; + + friend class CollisionBox; }; #include "collisionTube.I" From 247575df62f1c3b0bbda84abf503c8646cbe15ef Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 30 Jul 2018 21:02:55 -0700 Subject: [PATCH 103/360] CoordinateSystem: Document enumerators --- panda/src/linmath/coordinateSystem.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/panda/src/linmath/coordinateSystem.h b/panda/src/linmath/coordinateSystem.h index 313645a35e..b365297f84 100644 --- a/panda/src/linmath/coordinateSystem.h +++ b/panda/src/linmath/coordinateSystem.h @@ -26,10 +26,10 @@ enum CoordinateSystem { // turn is loaded from the config variable "coordinate-system". CS_default, - CS_zup_right, - CS_yup_right, - CS_zup_left, - CS_yup_left, + CS_zup_right, // Z-Up, Right-handed + CS_yup_right, // Y-Up, Right-handed + CS_zup_left, // Z-Up, Left-handed + CS_yup_left, // Y-Up, Left-handed // CS_invalid is not a coordinate system at all. It can be used in user- // input processing code to indicate a contradictory coordinate system From 079a7495f279080b6745ea4fceb5a313aca3d4b8 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 31 Jul 2018 10:47:16 +0200 Subject: [PATCH 104/360] Fix macOS build by providing missing std::copysign --- dtool/src/dtoolbase/dtoolbase_cc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 3af3c9c250..ff52c6291a 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -97,10 +97,12 @@ typedef std::ios::seekdir ios_seekdir; // in some important missing functions. #if defined(__GLIBCXX__) && __GLIBCXX__ <= 20070719 #include +#include namespace std { using std::tr1::tuple; using std::tr1::tie; + using std::tr1::copysign; typedef decltype(nullptr) nullptr_t; From 4e42c4c94173e09d8638e50b230966653afc766f Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 31 Jul 2018 11:08:14 +0200 Subject: [PATCH 105/360] nativenet: fix interrogate error recognizing sockaddr types --- panda/src/nativenet/socket_portable.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/panda/src/nativenet/socket_portable.h b/panda/src/nativenet/socket_portable.h index d4bdd1fa98..a4a249f92e 100644 --- a/panda/src/nativenet/socket_portable.h +++ b/panda/src/nativenet/socket_portable.h @@ -12,7 +12,9 @@ const int BASIC_ERROR = -1; // Interrogate doesn't need to parse any of this. typedef unsigned long SOCKET; -typedef unsigned short sa_family_t; + +#include +#include /************************************************************************ * HP SOCKET LIBRARY STUFF From fe1bfef5c01281dd42b7e2fd7d99f46233ae6d61 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 31 Jul 2018 14:02:58 +0200 Subject: [PATCH 106/360] express: fix a few compile errors with certain WeakPointerTo uses Fixes #367 --- panda/src/express/weakPointerToBase.I | 48 +++++++++++++++++++++++++++ panda/src/express/weakPointerToBase.h | 7 ++++ 2 files changed, 55 insertions(+) diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 8c6de65523..5673114764 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -72,6 +72,26 @@ WeakPointerToBase(WeakPointerToBase &&from) noexcept { from._weak_ref = nullptr; } +/** + * Copies a weak pointer from a cast-convertible weak pointer type. + */ +template +template +INLINE WeakPointerToBase:: +WeakPointerToBase(const WeakPointerToBase &r) { + // If this next line gives an error, you are trying to convert a WeakPointerTo + // from an incompatible type of another WeakPointerTo. + To *ptr = (Y *)r._void_ptr; + + this->_void_ptr = ptr; + + WeakReferenceList *weak_ref = r._weak_ref; + if (weak_ref != nullptr) { + _weak_ref = weak_ref; + weak_ref->ref(); + } +} + /** * Moves a weak pointer from a cast-convertible weak pointer type. */ @@ -190,6 +210,34 @@ reassign(WeakPointerToBase &&from) noexcept { } } +/** + * Like above, but casts from a compatible pointer type. + */ +template +template +INLINE void WeakPointerToBase:: +reassign(const WeakPointerToBase ©) { + // If there is a compile error on this line, it means you tried to assign + // an incompatible type. + To *new_ptr = (Y *)copy._void_ptr; + + if (new_ptr != (To *)_void_ptr) { + WeakReferenceList *old_ref = (WeakReferenceList *)_weak_ref; + WeakReferenceList *new_ref = copy._weak_ref; + _void_ptr = new_ptr; + _weak_ref = new_ref; + + if (new_ref != nullptr) { + new_ref->ref(); + } + + // Now remove the old reference. + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; + } + } +} + /** * Like above, but casts from a compatible pointer type. */ diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index 474514b055..291cd587e4 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -34,6 +34,8 @@ protected: INLINE WeakPointerToBase(const WeakPointerToBase ©); INLINE WeakPointerToBase(WeakPointerToBase &&from) noexcept; template + INLINE WeakPointerToBase(const WeakPointerToBase &r); + template INLINE WeakPointerToBase(WeakPointerToBase &&r) noexcept; INLINE ~WeakPointerToBase(); @@ -43,6 +45,8 @@ protected: INLINE void reassign(const WeakPointerToBase ©); INLINE void reassign(WeakPointerToBase &&from) noexcept; template + INLINE void reassign(const WeakPointerToBase ©); + template INLINE void reassign(WeakPointerToBase &&from) noexcept; INLINE void update_type(To *ptr); @@ -96,6 +100,9 @@ public: template INLINE bool owner_before(const PointerToBase &other) const noexcept; + // This is needed to be able to access the privates of other instantiations. + template friend class WeakPointerToBase; + PUBLISHED: INLINE void clear(); INLINE void refresh() const; From 30721ba33bbd4f90c40e61825f47571ac6ff3893 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 31 Jul 2018 14:05:08 +0200 Subject: [PATCH 107/360] cppparser: fix issues when parsing templated constructor definition --- dtool/src/cppparser/cppBison.cxx.prebuilt | 2759 +++++++++++---------- dtool/src/cppparser/cppBison.h.prebuilt | 4 +- dtool/src/cppparser/cppBison.yxx | 32 +- 3 files changed, 1420 insertions(+), 1375 deletions(-) diff --git a/dtool/src/cppparser/cppBison.cxx.prebuilt b/dtool/src/cppparser/cppBison.cxx.prebuilt index 4bff774461..be3f2b4e95 100644 --- a/dtool/src/cppparser/cppBison.cxx.prebuilt +++ b/dtool/src/cppparser/cppBison.cxx.prebuilt @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.0.5. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "3.0.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -104,15 +104,15 @@ using std::string; // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// -CPPScope *current_scope = NULL; -CPPScope *global_scope = NULL; -CPPPreprocessor *current_lexer = NULL; +CPPScope *current_scope = nullptr; +CPPScope *global_scope = nullptr; +CPPPreprocessor *current_lexer = nullptr; -static CPPStructType *current_struct = NULL; -static CPPEnumType *current_enum = NULL; +static CPPStructType *current_struct = nullptr; +static CPPEnumType *current_enum = nullptr; static int current_storage_class = 0; -static CPPType *current_type = NULL; -static CPPExpression *current_expr = NULL; +static CPPType *current_type = nullptr; +static CPPExpression *current_expr = nullptr; static int publish_nest_level = 0; static CPPVisibility publish_previous; static YYLTYPE publish_loc; @@ -186,7 +186,7 @@ parse_const_expr(CPPPreprocessor *pp, CPPScope *new_current_scope, current_scope = new_current_scope; global_scope = new_global_scope; - current_expr = (CPPExpression *)NULL; + current_expr = nullptr; current_lexer = pp; yyparse(); @@ -210,7 +210,7 @@ parse_type(CPPPreprocessor *pp, CPPScope *new_current_scope, current_scope = new_current_scope; global_scope = new_global_scope; - current_type = (CPPType *)NULL; + current_type = nullptr; current_lexer = pp; yyparse(); @@ -227,7 +227,7 @@ parse_type(CPPPreprocessor *pp, CPPScope *new_current_scope, static void push_scope(CPPScope *new_scope) { last_scopes.push_back(current_scope); - if (new_scope != NULL) { + if (new_scope != nullptr) { current_scope = new_scope; } } @@ -266,7 +266,7 @@ pop_struct() { } -#line 268 "built/tmp/cppBison.yxx.c" /* yacc.c:339 */ +#line 270 "built/tmp/cppBison.yxx.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -617,7 +617,7 @@ int cppyyparse (void); /* Copy the second part of user declarations. */ -#line 619 "built/tmp/cppBison.yxx.c" /* yacc.c:358 */ +#line 621 "built/tmp/cppBison.yxx.c" /* yacc.c:358 */ #ifdef short # undef short @@ -931,83 +931,83 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 450, 450, 451, 455, 462, 463, 464, 468, 469, - 473, 477, 481, 494, 493, 505, 506, 507, 508, 509, - 510, 511, 524, 533, 537, 545, 549, 553, 574, 601, - 622, 651, 687, 730, 742, 763, 799, 833, 855, 891, - 913, 924, 938, 937, 952, 956, 961, 965, 976, 980, - 984, 988, 992, 996, 1000, 1004, 1008, 1012, 1016, 1020, - 1025, 1029, 1036, 1037, 1041, 1042, 1043, 1048, 1047, 1063, - 1073, 1072, 1089, 1097, 1105, 1116, 1132, 1131, 1146, 1161, - 1170, 1185, 1184, 1209, 1208, 1236, 1235, 1266, 1265, 1284, - 1283, 1304, 1303, 1335, 1334, 1360, 1373, 1377, 1381, 1385, - 1398, 1402, 1406, 1410, 1414, 1419, 1424, 1428, 1432, 1436, - 1443, 1447, 1451, 1455, 1459, 1463, 1467, 1471, 1475, 1479, - 1483, 1487, 1491, 1495, 1499, 1503, 1507, 1511, 1515, 1519, - 1523, 1527, 1531, 1535, 1539, 1543, 1547, 1551, 1555, 1559, - 1563, 1567, 1571, 1575, 1579, 1583, 1587, 1591, 1595, 1602, - 1603, 1604, 1608, 1610, 1609, 1617, 1618, 1622, 1623, 1627, - 1633, 1642, 1643, 1647, 1651, 1655, 1659, 1665, 1671, 1677, - 1684, 1689, 1698, 1702, 1707, 1715, 1727, 1731, 1745, 1760, - 1765, 1770, 1775, 1780, 1785, 1790, 1795, 1801, 1800, 1831, - 1841, 1851, 1855, 1859, 1868, 1872, 1880, 1884, 1889, 1893, - 1898, 1906, 1911, 1919, 1923, 1928, 1932, 1937, 1945, 1950, - 1958, 1962, 1969, 1973, 1980, 1984, 1988, 1992, 1996, 2003, - 2007, 2011, 2015, 2019, 2023, 2030, 2031, 2032, 2036, 2039, - 2040, 2041, 2045, 2050, 2056, 2062, 2067, 2073, 2079, 2083, - 2094, 2098, 2108, 2112, 2116, 2121, 2126, 2131, 2136, 2141, - 2146, 2154, 2158, 2162, 2167, 2172, 2177, 2182, 2187, 2192, - 2197, 2203, 2211, 2216, 2221, 2226, 2231, 2236, 2241, 2246, - 2251, 2256, 2262, 2270, 2274, 2279, 2284, 2289, 2294, 2299, - 2304, 2309, 2314, 2322, 2326, 2331, 2336, 2341, 2346, 2351, - 2356, 2361, 2366, 2371, 2377, 2384, 2391, 2401, 2405, 2413, - 2417, 2421, 2425, 2429, 2445, 2461, 2470, 2474, 2484, 2491, - 2502, 2506, 2514, 2518, 2522, 2526, 2530, 2546, 2562, 2580, - 2589, 2593, 2603, 2610, 2614, 2622, 2626, 2642, 2658, 2667, - 2677, 2684, 2688, 2696, 2700, 2705, 2709, 2717, 2718, 2719, - 2720, 2725, 2724, 2749, 2748, 2778, 2779, 2786, 2787, 2791, - 2792, 2796, 2800, 2804, 2808, 2812, 2816, 2820, 2824, 2828, - 2832, 2839, 2847, 2851, 2855, 2860, 2868, 2872, 2879, 2880, - 2885, 2892, 2893, 2898, 2906, 2910, 2914, 2921, 2925, 2929, - 2937, 2936, 2959, 2958, 2981, 2982, 2986, 2992, 2999, 3008, - 3009, 3010, 3014, 3018, 3022, 3026, 3030, 3034, 3039, 3044, - 3049, 3054, 3058, 3063, 3072, 3077, 3085, 3089, 3093, 3101, - 3111, 3111, 3121, 3122, 3126, 3127, 3128, 3129, 3130, 3131, - 3132, 3133, 3134, 3135, 3136, 3137, 3137, 3137, 3138, 3138, - 3138, 3138, 3139, 3139, 3139, 3139, 3139, 3140, 3140, 3140, - 3141, 3141, 3141, 3141, 3141, 3142, 3142, 3142, 3142, 3142, - 3143, 3143, 3144, 3144, 3144, 3144, 3144, 3145, 3145, 3145, - 3145, 3145, 3146, 3146, 3146, 3146, 3147, 3147, 3147, 3147, - 3147, 3148, 3148, 3148, 3148, 3148, 3149, 3149, 3149, 3149, - 3149, 3149, 3150, 3150, 3150, 3150, 3150, 3151, 3151, 3151, - 3151, 3152, 3152, 3152, 3152, 3153, 3153, 3153, 3153, 3153, - 3154, 3154, 3154, 3154, 3155, 3155, 3155, 3155, 3155, 3156, - 3156, 3156, 3156, 3157, 3157, 3157, 3157, 3157, 3158, 3158, - 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, - 3161, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, - 3162, 3163, 3163, 3167, 3171, 3178, 3182, 3189, 3193, 3200, - 3204, 3208, 3212, 3216, 3220, 3224, 3228, 3240, 3244, 3248, - 3252, 3256, 3260, 3264, 3268, 3272, 3276, 3280, 3284, 3288, - 3292, 3296, 3300, 3304, 3308, 3312, 3316, 3320, 3324, 3328, - 3332, 3336, 3340, 3344, 3348, 3352, 3356, 3360, 3368, 3372, - 3376, 3380, 3384, 3388, 3392, 3402, 3412, 3418, 3424, 3430, - 3436, 3442, 3448, 3455, 3462, 3469, 3476, 3482, 3488, 3492, - 3504, 3508, 3512, 3516, 3520, 3531, 3542, 3546, 3550, 3554, - 3558, 3562, 3566, 3570, 3574, 3578, 3582, 3586, 3590, 3594, - 3598, 3602, 3606, 3610, 3614, 3618, 3622, 3626, 3630, 3634, - 3638, 3642, 3646, 3650, 3654, 3658, 3662, 3669, 3673, 3677, - 3681, 3685, 3689, 3693, 3697, 3701, 3707, 3713, 3717, 3723, - 3730, 3734, 3738, 3742, 3746, 3750, 3754, 3758, 3762, 3766, - 3770, 3774, 3778, 3782, 3786, 3790, 3794, 3808, 3812, 3816, - 3820, 3824, 3828, 3832, 3836, 3848, 3852, 3856, 3860, 3864, - 3875, 3886, 3890, 3894, 3898, 3902, 3906, 3910, 3914, 3918, - 3922, 3926, 3930, 3934, 3938, 3942, 3946, 3950, 3954, 3958, - 3962, 3966, 3970, 3974, 3978, 3982, 3986, 3990, 3994, 3998, - 4002, 4009, 4013, 4017, 4021, 4025, 4029, 4033, 4037, 4041, - 4047, 4053, 4061, 4065, 4069, 4073, 4080, 4090, 4096, 4102, - 4112, 4124, 4132, 4136, 4166, 4170, 4174, 4178, 4182, 4186, - 4192, 4196, 4200, 4204, 4208, 4219, 4223, 4227, 4231, 4239, - 4243, 4247, 4253, 4264 + 0, 452, 452, 453, 457, 464, 465, 466, 470, 471, + 475, 479, 483, 496, 495, 507, 508, 509, 510, 511, + 512, 513, 526, 535, 539, 547, 551, 555, 576, 603, + 624, 653, 689, 732, 744, 765, 801, 835, 857, 893, + 915, 926, 940, 939, 954, 958, 963, 967, 978, 982, + 986, 990, 994, 998, 1002, 1006, 1010, 1014, 1018, 1022, + 1027, 1031, 1038, 1039, 1043, 1044, 1045, 1050, 1049, 1065, + 1075, 1074, 1091, 1099, 1107, 1118, 1134, 1133, 1148, 1163, + 1172, 1187, 1186, 1224, 1223, 1260, 1259, 1290, 1289, 1308, + 1307, 1328, 1327, 1359, 1358, 1384, 1397, 1401, 1405, 1409, + 1422, 1426, 1430, 1434, 1438, 1443, 1448, 1452, 1456, 1460, + 1467, 1471, 1475, 1479, 1483, 1487, 1491, 1495, 1499, 1503, + 1507, 1511, 1515, 1519, 1523, 1527, 1531, 1535, 1539, 1543, + 1547, 1551, 1555, 1559, 1563, 1567, 1571, 1575, 1579, 1583, + 1587, 1591, 1595, 1599, 1603, 1607, 1611, 1615, 1619, 1626, + 1627, 1628, 1632, 1634, 1633, 1641, 1642, 1646, 1647, 1651, + 1657, 1666, 1667, 1671, 1675, 1679, 1683, 1689, 1695, 1701, + 1708, 1713, 1722, 1726, 1731, 1739, 1751, 1755, 1769, 1784, + 1789, 1794, 1799, 1804, 1809, 1814, 1819, 1825, 1824, 1855, + 1865, 1875, 1879, 1883, 1892, 1896, 1904, 1908, 1913, 1917, + 1922, 1930, 1935, 1943, 1947, 1952, 1956, 1961, 1969, 1974, + 1982, 1986, 1993, 1997, 2004, 2008, 2012, 2016, 2020, 2027, + 2031, 2035, 2039, 2043, 2047, 2054, 2055, 2056, 2060, 2063, + 2064, 2065, 2069, 2074, 2080, 2086, 2091, 2097, 2103, 2107, + 2118, 2122, 2132, 2136, 2140, 2145, 2150, 2155, 2160, 2165, + 2170, 2178, 2182, 2186, 2191, 2196, 2201, 2206, 2211, 2216, + 2221, 2227, 2235, 2240, 2245, 2250, 2255, 2260, 2265, 2270, + 2275, 2280, 2286, 2294, 2298, 2303, 2308, 2313, 2318, 2323, + 2328, 2333, 2338, 2346, 2350, 2355, 2360, 2365, 2370, 2375, + 2380, 2385, 2390, 2395, 2401, 2408, 2415, 2425, 2429, 2437, + 2441, 2445, 2449, 2453, 2469, 2485, 2494, 2498, 2508, 2515, + 2526, 2530, 2538, 2542, 2546, 2550, 2554, 2570, 2586, 2604, + 2613, 2617, 2627, 2634, 2638, 2646, 2650, 2666, 2682, 2691, + 2701, 2708, 2712, 2720, 2724, 2729, 2733, 2741, 2742, 2743, + 2744, 2749, 2748, 2773, 2772, 2802, 2803, 2810, 2811, 2815, + 2816, 2820, 2824, 2828, 2832, 2836, 2840, 2844, 2848, 2852, + 2856, 2863, 2871, 2875, 2879, 2884, 2892, 2896, 2903, 2904, + 2909, 2916, 2917, 2922, 2930, 2934, 2938, 2945, 2949, 2953, + 2961, 2960, 2983, 2982, 3005, 3006, 3010, 3016, 3023, 3032, + 3033, 3034, 3038, 3042, 3046, 3050, 3054, 3058, 3063, 3068, + 3073, 3078, 3082, 3087, 3096, 3101, 3109, 3113, 3117, 3125, + 3135, 3135, 3145, 3146, 3150, 3151, 3152, 3153, 3154, 3155, + 3156, 3157, 3158, 3159, 3160, 3161, 3161, 3161, 3162, 3162, + 3162, 3162, 3163, 3163, 3163, 3163, 3163, 3164, 3164, 3164, + 3165, 3165, 3165, 3165, 3165, 3166, 3166, 3166, 3166, 3166, + 3167, 3167, 3168, 3168, 3168, 3168, 3168, 3169, 3169, 3169, + 3169, 3169, 3170, 3170, 3170, 3170, 3171, 3171, 3171, 3171, + 3171, 3172, 3172, 3172, 3172, 3172, 3173, 3173, 3173, 3173, + 3173, 3173, 3174, 3174, 3174, 3174, 3174, 3175, 3175, 3175, + 3175, 3176, 3176, 3176, 3176, 3177, 3177, 3177, 3177, 3177, + 3178, 3178, 3178, 3178, 3179, 3179, 3179, 3179, 3179, 3180, + 3180, 3180, 3180, 3181, 3181, 3181, 3181, 3181, 3182, 3182, + 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, + 3185, 3186, 3186, 3186, 3186, 3186, 3186, 3186, 3186, 3186, + 3186, 3187, 3187, 3191, 3195, 3202, 3206, 3213, 3217, 3224, + 3228, 3232, 3236, 3240, 3244, 3248, 3252, 3264, 3268, 3272, + 3276, 3280, 3284, 3288, 3292, 3296, 3300, 3304, 3308, 3312, + 3316, 3320, 3324, 3328, 3332, 3336, 3340, 3344, 3348, 3352, + 3356, 3360, 3364, 3368, 3372, 3376, 3380, 3384, 3392, 3396, + 3400, 3404, 3408, 3412, 3416, 3426, 3436, 3442, 3448, 3454, + 3460, 3466, 3472, 3479, 3486, 3493, 3500, 3506, 3512, 3516, + 3528, 3532, 3536, 3540, 3544, 3555, 3566, 3570, 3574, 3578, + 3582, 3586, 3590, 3594, 3598, 3602, 3606, 3610, 3614, 3618, + 3622, 3626, 3630, 3634, 3638, 3642, 3646, 3650, 3654, 3658, + 3662, 3666, 3670, 3674, 3678, 3682, 3686, 3693, 3697, 3701, + 3705, 3709, 3713, 3717, 3721, 3725, 3731, 3737, 3741, 3747, + 3754, 3758, 3762, 3766, 3770, 3774, 3778, 3782, 3786, 3790, + 3794, 3798, 3802, 3806, 3810, 3814, 3818, 3832, 3836, 3840, + 3844, 3848, 3852, 3856, 3860, 3872, 3876, 3880, 3884, 3888, + 3899, 3910, 3914, 3918, 3922, 3926, 3930, 3934, 3938, 3942, + 3946, 3950, 3954, 3958, 3962, 3966, 3970, 3974, 3978, 3982, + 3986, 3990, 3994, 3998, 4002, 4006, 4010, 4014, 4018, 4022, + 4026, 4033, 4037, 4041, 4045, 4049, 4053, 4057, 4061, 4065, + 4071, 4077, 4085, 4089, 4093, 4097, 4104, 4114, 4120, 4126, + 4136, 4148, 4156, 4160, 4190, 4194, 4198, 4202, 4206, 4210, + 4216, 4220, 4224, 4228, 4232, 4243, 4247, 4251, 4255, 4263, + 4267, 4271, 4277, 4288 }; #endif @@ -3673,6 +3673,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -4014,70 +4015,71 @@ yyreduce: GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; - /* Default location. */ + /* Default location. */ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + yyerror_range[1] = yyloc; YY_REDUCE_PRINT (yyn); switch (yyn) { case 3: -#line 452 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 454 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_expr = (yyvsp[0].u.expr); } -#line 4026 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4030 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 4: -#line 456 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 458 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_type = (yyvsp[0].u.type); } -#line 4034 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4038 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 10: -#line 474 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 476 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { delete (yyvsp[-1].u.expr); } -#line 4042 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4046 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 11: -#line 478 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 480 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { delete (yyvsp[-2].u.expr); } -#line 4050 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4054 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 12: -#line 482 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 484 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { delete (yyvsp[-1].u.expr); } -#line 4058 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4062 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 13: -#line 494 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 496 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_storage_class((current_storage_class & ~CPPInstance::SC_c_binding) | ((yyvsp[-1].u.integer) & CPPInstance::SC_c_binding)); } -#line 4067 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4071 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 14: -#line 499 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 501 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_storage_class(); } -#line 4075 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4079 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 21: -#line 512 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 514 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (publish_nest_level != 0) { yyerror("Unclosed __begin_publish", publish_loc); @@ -4090,11 +4092,11 @@ yyreduce: publish_nest_level++; current_scope->set_current_vis(V_published); } -#line 4092 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4096 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 22: -#line 525 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 527 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (publish_nest_level != 1) { yyerror("Unmatched __end_publish", (yylsp[0])); @@ -4103,19 +4105,19 @@ yyreduce: } publish_nest_level = 0; } -#line 4105 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4109 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 23: -#line 534 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 536 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_scope->set_current_vis(V_published); } -#line 4113 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4117 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 24: -#line 538 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 540 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (publish_nest_level > 0) { current_scope->set_current_vis(V_published); @@ -4123,27 +4125,27 @@ yyreduce: current_scope->set_current_vis(V_public); } } -#line 4125 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4129 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 25: -#line 546 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 548 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_scope->set_current_vis(V_protected); } -#line 4133 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4137 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 26: -#line 550 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 552 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_scope->set_current_vis(V_private); } -#line 4141 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4145 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 27: -#line 554 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 556 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-3].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4164,11 +4166,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-7])); } } -#line 4166 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4170 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 28: -#line 575 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 577 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-6].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4195,11 +4197,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-10])); } } -#line 4197 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4201 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 29: -#line 602 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 604 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-4].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4220,11 +4222,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-8])); } } -#line 4222 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4226 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 30: -#line 623 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 625 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-6].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4253,16 +4255,16 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-10])); } } -#line 4255 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4259 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 31: -#line 652 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 654 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-8].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + (yyvsp[-8].u.identifier)->get_fully_scoped_name(), (yylsp[-8])); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *getter = (yyvsp[-6].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); @@ -4293,16 +4295,16 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-12])); } } -#line 4295 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4299 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 32: -#line 688 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 690 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-10].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + (yyvsp[-10].u.identifier)->get_fully_scoped_name(), (yylsp[-10])); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *getter = (yyvsp[-8].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); @@ -4340,11 +4342,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-14])); } } -#line 4342 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4346 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 33: -#line 731 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 733 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-2].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4356,11 +4358,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-6])); } } -#line 4358 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4362 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 34: -#line 743 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 745 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-2].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4381,11 +4383,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-8])); } } -#line 4383 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4387 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 35: -#line 764 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 766 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-5].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4421,11 +4423,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-11])); } } -#line 4423 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4427 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 36: -#line 800 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 802 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-4].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4459,11 +4461,11 @@ yyreduce: } } } -#line 4461 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4465 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 37: -#line 834 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 836 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-2].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4485,11 +4487,11 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-8])); } } -#line 4487 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4491 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 38: -#line 856 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 858 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *getter = (yyvsp[-6].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == nullptr || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -4525,25 +4527,25 @@ yyreduce: current_scope->add_declaration(make_property, global_scope, current_lexer, (yylsp[-12])); } } -#line 4527 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4531 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 39: -#line 892 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 894 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *length_getter = (yyvsp[-4].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (length_getter == (CPPDeclaration *)NULL || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { + if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + (yyvsp[-4].u.identifier)->get_fully_scoped_name(), (yylsp[-4])); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *element_getter = (yyvsp[-2].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (element_getter == (CPPDeclaration *)NULL || element_getter->get_subtype() != CPPDeclaration::ST_function_group) { + if (element_getter == nullptr || element_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid element method: " + (yyvsp[-2].u.identifier)->get_fully_scoped_name(), (yylsp[-4])); - element_getter = NULL; + element_getter = nullptr; } - if (length_getter != (CPPDeclaration *)NULL && element_getter != (CPPDeclaration *)NULL) { + if (length_getter != nullptr && element_getter != nullptr) { CPPMakeSeq *make_seq = new CPPMakeSeq((yyvsp[-6].u.identifier), length_getter->as_function_group(), element_getter->as_function_group(), @@ -4551,11 +4553,11 @@ yyreduce: current_scope->add_declaration(make_seq, global_scope, current_lexer, (yylsp[-8])); } } -#line 4553 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4557 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 40: -#line 914 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 916 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPExpression::Result result = (yyvsp[-4].u.expr)->evaluate(); if (result._type == CPPExpression::RT_error) { @@ -4566,11 +4568,11 @@ yyreduce: yywarning("static_assert failed: " + str.str(), (yylsp[-4])); } } -#line 4568 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4572 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 41: -#line 925 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 927 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This alternative version of static_assert was introduced in C++17. CPPExpression::Result result = (yyvsp[-2].u.expr)->evaluate(); @@ -4580,55 +4582,55 @@ yyreduce: yywarning("static_assert failed", (yylsp[-2])); } } -#line 4582 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4586 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 42: -#line 938 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 940 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *new_scope = new CPPScope(current_scope, CPPNameComponent("temp"), V_public); push_scope(new_scope); } -#line 4592 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4596 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 43: -#line 944 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 946 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { delete current_scope; pop_scope(); } -#line 4601 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4605 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 44: -#line 953 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 955 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = 0; } -#line 4609 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4613 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 45: -#line 957 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This isn't really a storage class, but it helps with parsing. (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_const; } -#line 4618 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4622 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 46: -#line 962 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 964 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_extern; } -#line 4626 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4630 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 47: -#line 966 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 968 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_extern; if ((yyvsp[-1].str) == "C") { @@ -4639,124 +4641,124 @@ yyreduce: yywarning("Ignoring unknown linkage type \"" + (yyvsp[-1].str) + "\"", (yylsp[-1])); } } -#line 4641 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4645 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 48: -#line 977 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 979 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_static; } -#line 4649 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4653 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 49: -#line 981 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_inline; } -#line 4657 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4661 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 50: -#line 985 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_virtual; } -#line 4665 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4669 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 51: -#line 989 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 991 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_explicit; } -#line 4673 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4677 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 52: -#line 993 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 995 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_register; } -#line 4681 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4685 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 53: -#line 997 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 999 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_volatile; } -#line 4689 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4693 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 54: -#line 1001 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1003 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_mutable; } -#line 4697 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4701 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 55: -#line 1005 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1007 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_constexpr; } -#line 4705 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4709 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 56: -#line 1009 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1011 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_blocking; } -#line 4713 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4717 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 57: -#line 1013 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1015 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_extension; } -#line 4721 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4725 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 58: -#line 1017 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1019 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer) | (int)CPPInstance::SC_thread_local; } -#line 4729 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4733 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 59: -#line 1021 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1023 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Ignore attribute specifiers for now. (yyval.u.integer) = (yyvsp[0].u.integer); } -#line 4738 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4742 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 60: -#line 1026 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1028 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer); } -#line 4746 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4750 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 61: -#line 1030 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1032 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[0].u.integer); } -#line 4754 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4758 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 67: -#line 1048 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1050 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // We don't need to push/pop type, because we can't nest // type_like_declaration. @@ -4767,19 +4769,19 @@ yyreduce: } push_storage_class((yyvsp[-1].u.integer)); } -#line 4769 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4773 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 68: -#line 1059 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1061 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_storage_class(); } -#line 4777 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4781 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 69: -#line 1064 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1066 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // We don't really care about the storage class here. In fact, it's // not actually legal to define a class or struct using a particular @@ -4788,48 +4790,48 @@ yyreduce: current_scope->add_declaration((yyvsp[-1].u.decl), global_scope, current_lexer, (yylsp[-1])); } -#line 4790 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4794 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 70: -#line 1073 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1075 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[0].u.instance) != (CPPInstance *)NULL) { + if ((yyvsp[0].u.instance) != nullptr) { // Push the scope so that the initializers can make use of things defined // in the class body. push_scope((yyvsp[0].u.instance)->get_scope(current_scope, global_scope)); (yyvsp[0].u.instance)->_storage_class |= (current_storage_class | (yyvsp[-1].u.integer)); } } -#line 4803 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4807 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 71: -#line 1082 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1084 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-2].u.instance) != (CPPInstance *)NULL) { + if ((yyvsp[-2].u.instance) != nullptr) { pop_scope(); current_scope->add_declaration((yyvsp[-2].u.instance), global_scope, current_lexer, (yylsp[-2])); (yyvsp[-2].u.instance)->set_initializer((yyvsp[0].u.expr)); } } -#line 4815 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4819 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 72: -#line 1090 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1092 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-1].u.instance) != (CPPInstance *)NULL) { + if ((yyvsp[-1].u.instance) != nullptr) { (yyvsp[-1].u.instance)->_storage_class |= (current_storage_class | (yyvsp[-2].u.integer)); current_scope->add_declaration((yyvsp[-1].u.instance), global_scope, current_lexer, (yylsp[-1])); (yyvsp[-1].u.instance)->set_initializer((yyvsp[0].u.expr)); } } -#line 4827 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4831 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 74: -#line 1106 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1108 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (current_storage_class & CPPInstance::SC_const) { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); @@ -4840,11 +4842,11 @@ yyreduce: inst->set_initializer((yyvsp[0].u.expr)); current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[-1])); } -#line 4842 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4846 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 75: -#line 1117 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1119 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (current_storage_class & CPPInstance::SC_const) { (yyvsp[-3].u.inst_ident)->add_modifier(IIT_const); @@ -4855,11 +4857,11 @@ yyreduce: inst->set_initializer((yyvsp[-2].u.expr)); current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[-3])); } -#line 4857 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4861 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 76: -#line 1132 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1134 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // We don't need to push/pop type, because we can't nest // multiple_var_declarations. @@ -4870,23 +4872,23 @@ yyreduce: } push_storage_class((yyvsp[-1].u.integer)); } -#line 4872 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4876 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 77: -#line 1143 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1145 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_storage_class(); } -#line 4880 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4884 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 78: -#line 1147 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1149 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-1].u.instance) != (CPPDeclaration *)NULL) { + if ((yyvsp[-1].u.instance) != nullptr) { CPPInstance *inst = (yyvsp[-1].u.instance)->as_instance(); - if (inst != (CPPInstance *)NULL) { + if (inst != nullptr) { inst->_storage_class |= (current_storage_class | (yyvsp[-2].u.integer)); current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[-1])); CPPTypedefType *typedef_type = new CPPTypedefType(inst->_type, inst->_ident, current_scope); @@ -4894,11 +4896,11 @@ yyreduce: } } } -#line 4896 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4900 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 79: -#line 1162 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1164 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (current_storage_class & CPPInstance::SC_const) { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); @@ -4907,11 +4909,11 @@ yyreduce: CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[-1].u.inst_ident), current_scope, (yylsp[-1]).file); current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, (yylsp[-1])); } -#line 4909 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4913 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 80: -#line 1171 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1173 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { if (current_storage_class & CPPInstance::SC_const) { (yyvsp[-3].u.inst_ident)->add_modifier(IIT_const); @@ -4920,24 +4922,37 @@ yyreduce: CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[-3].u.inst_ident), current_scope, (yylsp[-3]).file); current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, (yylsp[-3])); } -#line 4922 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4926 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 81: -#line 1185 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1187 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - push_scope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope)); + // Create a scope for this function. + CPPScope *scope = new CPPScope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope), + (yyvsp[-1].u.identifier)->_names.back(), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } -#line 4930 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4943 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 82: -#line 1189 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1200 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { + CPPScope *scope = (yyvsp[-5].u.identifier)->get_scope(current_scope, global_scope); CPPType *type; - if ((yyvsp[-5].u.identifier)->get_simple_name() == current_scope->get_simple_name() || - (yyvsp[-5].u.identifier)->get_simple_name() == string("~") + current_scope->get_simple_name()) { - // This is a constructor, and has no return. + std::string simple_name = (yyvsp[-5].u.identifier)->get_simple_name(); + if (!simple_name.empty() && simple_name[0] == '~') { + // A destructor has no return type. + type = new CPPSimpleType(CPPSimpleType::T_void); + } else if (scope != nullptr && simple_name == scope->get_simple_name()) { + // Neither does a constructor. type = new CPPSimpleType(CPPSimpleType::T_void); } else { // This isn't a constructor, so it has an implicit return type of @@ -4952,19 +4967,28 @@ yyreduce: (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-5]).file); } -#line 4954 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4971 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 83: -#line 1209 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1224 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - push_scope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope)); + // Create a scope for this function. + CPPScope *scope = new CPPScope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope), + (yyvsp[-1].u.identifier)->_names.back(), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } -#line 4962 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 4988 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 84: -#line 1213 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1237 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); CPPType *type; @@ -4982,19 +5006,19 @@ yyreduce: (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-5]).file); } -#line 4984 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5010 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 85: -#line 1236 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1260 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_scope((yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope)); } -#line 4992 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5018 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 86: -#line 1240 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1264 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); if ((yyvsp[-5].u.identifier)->is_scoped()) { @@ -5013,75 +5037,75 @@ yyreduce: (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-5]).file); } } -#line 5015 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5041 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 87: -#line 1266 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1290 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_scope((yyvsp[-2].u.inst_ident)->get_scope(current_scope, global_scope)); } -#line 5023 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5049 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 88: -#line 1270 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1294 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); CPPType *type = (yyvsp[-10].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[-10].u.identifier)->get_fully_scoped_name(), (yylsp[-10])); } - assert(type != NULL); + assert(type != nullptr); CPPInstanceIdentifier *ii = (yyvsp[-7].u.inst_ident); ii->add_modifier(IIT_pointer); ii->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer)); (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-10]).file); } -#line 5041 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5067 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 89: -#line 1284 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1308 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_scope((yyvsp[-2].u.inst_ident)->get_scope(current_scope, global_scope)); } -#line 5049 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5075 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 90: -#line 1288 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1312 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); CPPType *type = (yyvsp[-11].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[-11].u.identifier)->get_fully_scoped_name(), (yylsp[-11])); } - assert(type != NULL); + assert(type != nullptr); CPPInstanceIdentifier *ii = (yyvsp[-7].u.inst_ident); ii->add_scoped_pointer_modifier((yyvsp[-9].u.identifier)); ii->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer)); (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[-11]).file); } -#line 5067 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5093 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 91: -#line 1304 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1328 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-3].u.identifier) != NULL) { + if ((yyvsp[-3].u.identifier) != nullptr) { push_scope((yyvsp[-3].u.identifier)->get_scope(current_scope, global_scope)); } } -#line 5077 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5103 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 92: -#line 1310 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1334 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-7].u.identifier) != NULL) { + if ((yyvsp[-7].u.identifier) != nullptr) { pop_scope(); } @@ -5096,7 +5120,7 @@ yyreduce: // the method's return type to determine the full type description. string name = "operator typecast " + (yyvsp[-6].u.type)->get_simple_name(); CPPIdentifier *ident = (yyvsp[-7].u.identifier); - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier(name, (yylsp[-6])); } else { ident->add_name(name); @@ -5104,28 +5128,28 @@ yyreduce: (yyval.u.instance) = CPPInstance::make_typecast_function (new CPPInstance((yyvsp[-6].u.type), (yyvsp[-5].u.inst_ident), 0, (yylsp[-5]).file), ident, (yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } -#line 5106 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5132 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 93: -#line 1335 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1359 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-4].u.identifier) != NULL) { + if ((yyvsp[-4].u.identifier) != nullptr) { push_scope((yyvsp[-4].u.identifier)->get_scope(current_scope, global_scope)); } } -#line 5116 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5142 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 94: -#line 1341 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1365 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - if ((yyvsp[-8].u.identifier) != NULL) { + if ((yyvsp[-8].u.identifier) != nullptr) { pop_scope(); } CPPIdentifier *ident = (yyvsp[-8].u.identifier); - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator typecast", (yylsp[-5])); } else { ident->add_name("operator typecast"); @@ -5134,626 +5158,626 @@ yyreduce: (yyval.u.instance) = CPPInstance::make_typecast_function (new CPPInstance((yyvsp[-6].u.type), (yyvsp[-5].u.inst_ident), 0, (yylsp[-5]).file), ident, (yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } -#line 5136 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5162 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 95: -#line 1361 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1385 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *decl = (yyvsp[0].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (decl != (CPPDeclaration *)NULL) { + if (decl != nullptr) { (yyval.u.instance) = decl->as_instance(); } else { - (yyval.u.instance) = (CPPInstance *)NULL; + (yyval.u.instance) = nullptr; } } -#line 5150 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5176 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 96: -#line 1374 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1398 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = 0; } -#line 5158 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5184 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 97: -#line 1378 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1402 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_const_method; } -#line 5166 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5192 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 98: -#line 1382 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1406 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_volatile_method; } -#line 5174 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5200 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 99: -#line 1386 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1410 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_noexcept; } -#line 5182 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5208 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 100: -#line 1399 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1423 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_final; } -#line 5190 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5216 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 101: -#line 1403 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1427 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_override; } -#line 5198 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5224 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 102: -#line 1407 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1431 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_lvalue_method; } -#line 5206 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5232 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 103: -#line 1411 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1435 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-1].u.integer) | (int)CPPFunctionType::F_rvalue_method; } -#line 5214 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5240 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 104: -#line 1415 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1439 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Used for lambdas, currently ignored. (yyval.u.integer) = (yyvsp[-1].u.integer); } -#line 5223 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5249 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 105: -#line 1420 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1444 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Used for lambdas in C++17, currently ignored. (yyval.u.integer) = (yyvsp[-1].u.integer); } -#line 5232 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5258 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 106: -#line 1425 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1449 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-3].u.integer); } -#line 5240 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5266 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 107: -#line 1429 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1453 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-4].u.integer); } -#line 5248 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5274 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 108: -#line 1433 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1457 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-5].u.integer); } -#line 5256 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5282 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 109: -#line 1437 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1461 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.integer) = (yyvsp[-3].u.integer); } -#line 5264 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5290 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 110: -#line 1444 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1468 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "!"; } -#line 5272 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5298 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 111: -#line 1448 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1472 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "~"; } -#line 5280 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5306 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 112: -#line 1452 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1476 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "*"; } -#line 5288 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5314 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 113: -#line 1456 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1480 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "/"; } -#line 5296 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5322 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 114: -#line 1460 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1484 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "%"; } -#line 5304 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5330 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 115: -#line 1464 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1488 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "+"; } -#line 5312 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5338 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 116: -#line 1468 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1492 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "-"; } -#line 5320 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5346 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 117: -#line 1472 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1496 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "|"; } -#line 5328 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5354 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 118: -#line 1476 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1500 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "&"; } -#line 5336 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5362 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 119: -#line 1480 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1504 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "^"; } -#line 5344 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5370 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 120: -#line 1484 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1508 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "||"; } -#line 5352 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5378 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 121: -#line 1488 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1512 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "&&"; } -#line 5360 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5386 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 122: -#line 1492 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1516 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "=="; } -#line 5368 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5394 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 123: -#line 1496 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1520 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "!="; } -#line 5376 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5402 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 124: -#line 1500 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1524 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "<="; } -#line 5384 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5410 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 125: -#line 1504 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1528 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ">="; } -#line 5392 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5418 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 126: -#line 1508 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1532 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "<"; } -#line 5400 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5426 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 127: -#line 1512 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1536 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ">"; } -#line 5408 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5434 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 128: -#line 1516 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1540 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "<<"; } -#line 5416 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5442 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 129: -#line 1520 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1544 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ">>"; } -#line 5424 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5450 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 130: -#line 1524 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1548 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "="; } -#line 5432 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5458 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 131: -#line 1528 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1552 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ","; } -#line 5440 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5466 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 132: -#line 1532 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1556 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "++"; } -#line 5448 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5474 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 133: -#line 1536 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1560 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "--"; } -#line 5456 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5482 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 134: -#line 1540 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1564 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "*="; } -#line 5464 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5490 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 135: -#line 1544 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1568 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "/="; } -#line 5472 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5498 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 136: -#line 1548 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1572 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "%="; } -#line 5480 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5506 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 137: -#line 1552 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1576 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "+="; } -#line 5488 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5514 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 138: -#line 1556 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1580 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "-="; } -#line 5496 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5522 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 139: -#line 1560 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1584 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "|="; } -#line 5504 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5530 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 140: -#line 1564 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1588 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "&="; } -#line 5512 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5538 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 141: -#line 1568 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1592 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "^="; } -#line 5520 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5546 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 142: -#line 1572 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1596 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "<<="; } -#line 5528 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5554 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 143: -#line 1576 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1600 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = ">>="; } -#line 5536 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5562 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 144: -#line 1580 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1604 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "->"; } -#line 5544 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5570 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 145: -#line 1584 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1608 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "[]"; } -#line 5552 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5578 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 146: -#line 1588 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1612 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "()"; } -#line 5560 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5586 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 147: -#line 1592 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1616 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "new"; } -#line 5568 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5594 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 148: -#line 1596 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1620 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.str) = "delete"; } -#line 5576 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5602 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 153: -#line 1610 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1634 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { push_scope(new CPPTemplateScope(current_scope)); } -#line 5584 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5610 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 154: -#line 1614 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1638 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); } -#line 5592 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5618 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 159: -#line 1628 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1652 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPTemplateScope *ts = current_scope->as_template_scope(); - assert(ts != NULL); + assert(ts != nullptr); ts->add_template_parameter((yyvsp[0].u.decl)); } -#line 5602 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5628 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 160: -#line 1634 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1658 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPTemplateScope *ts = current_scope->as_template_scope(); - assert(ts != NULL); + assert(ts != nullptr); ts->add_template_parameter((yyvsp[0].u.decl)); } -#line 5612 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5638 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 163: -#line 1648 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1672 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((CPPIdentifier *)NULL)); + (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter(nullptr)); } -#line 5620 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5646 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 164: -#line 1652 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1676 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[0].u.identifier))); } -#line 5628 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5654 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 165: -#line 1656 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1680 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[-2].u.identifier), (yyvsp[0].u.type))); } -#line 5636 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5662 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 166: -#line 1660 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1684 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter((CPPIdentifier *)NULL); + CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter(nullptr); ctp->_packed = true; (yyval.u.decl) = CPPType::new_type(ctp); } -#line 5646 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5672 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 167: -#line 1666 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1690 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter((yyvsp[0].u.identifier)); ctp->_packed = true; (yyval.u.decl) = CPPType::new_type(ctp); } -#line 5656 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5682 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 168: -#line 1672 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1696 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPInstance *inst = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); inst->set_initializer((yyvsp[0].u.expr)); (yyval.u.decl) = inst; } -#line 5666 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5692 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 169: -#line 1678 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1702 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); inst->set_initializer((yyvsp[0].u.expr)); (yyval.u.decl) = inst; } -#line 5677 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5703 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 170: -#line 1685 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1709 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPInstance *inst = new CPPInstance((yyvsp[-1].u.type), (yyvsp[0].u.inst_ident), 0, (yylsp[0]).file); (yyval.u.decl) = inst; } -#line 5686 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5712 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 171: -#line 1690 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1714 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[0].u.inst_ident)->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance((yyvsp[-1].u.type), (yyvsp[0].u.inst_ident), 0, (yylsp[0]).file); (yyval.u.decl) = inst; } -#line 5696 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5722 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 172: -#line 1699 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1723 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 5704 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5730 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 173: -#line 1703 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1727 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { yywarning("Not a type: " + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_unknown)); } -#line 5713 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5739 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 174: -#line 1708 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1732 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 5725 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5751 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 175: -#line 1716 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1740 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 5737 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5763 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 176: -#line 1728 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1752 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); } -#line 5745 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5771 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 177: -#line 1732 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1756 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // For an operator function. We implement this simply by building a // ficticious name for the function; in other respects it's just // like a regular function. CPPIdentifier *ident = (yyvsp[-1].u.identifier); - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator "+(yyvsp[0].str), (yylsp[0])); } else { ident->_names.push_back("operator "+(yyvsp[0].str)); @@ -5761,18 +5785,18 @@ yyreduce: (yyval.u.inst_ident) = new CPPInstanceIdentifier(ident); } -#line 5763 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5789 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 178: -#line 1746 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1770 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A C++11 literal operator. if (!(yyvsp[-1].str).empty()) { yyerror("expected empty string", (yylsp[-1])); } CPPIdentifier *ident = (yyvsp[-2].u.identifier); - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator \"\" "+(yyvsp[0].u.identifier)->get_simple_name(), (yylsp[0])); } else { ident->_names.push_back("operator \"\" "+(yyvsp[0].u.identifier)->get_simple_name()); @@ -5780,83 +5804,83 @@ yyreduce: (yyval.u.inst_ident) = new CPPInstanceIdentifier(ident); } -#line 5782 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5808 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 179: -#line 1761 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1785 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 5791 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5817 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 180: -#line 1766 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1790 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 5800 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5826 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 181: -#line 1771 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1795 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 5809 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5835 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 182: -#line 1776 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1800 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 5818 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5844 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 183: -#line 1781 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1805 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 5827 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5853 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 184: -#line 1786 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1810 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 5836 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5862 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 185: -#line 1791 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1815 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 5845 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5871 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 186: -#line 1796 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1820 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-1].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); } -#line 5854 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5880 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 187: -#line 1801 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1825 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Create a scope for this function (in case it is a function) CPPScope *scope = new CPPScope((yyvsp[-1].u.inst_ident)->get_scope(current_scope, global_scope), @@ -5869,11 +5893,11 @@ yyreduce: push_scope(scope); } -#line 5871 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5897 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 188: -#line 1814 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1838 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); (yyval.u.inst_ident) = (yyvsp[-5].u.inst_ident); @@ -5887,1410 +5911,1410 @@ yyreduce: (yyval.u.inst_ident)->add_func_modifier((yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } } -#line 5889 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5915 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 189: -#line 1832 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1856 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This is handled a bit awkwardly right now. Ideally it'd be wrapped // up in the instance_identifier rule, but then more needs to happen in // order to avoid shift/reduce conflicts. - if ((yyvsp[0].u.type) != NULL) { + if ((yyvsp[0].u.type) != nullptr) { (yyvsp[-1].u.inst_ident)->add_trailing_return_type((yyvsp[0].u.type)); } (yyval.u.inst_ident) = (yyvsp[-1].u.inst_ident); } -#line 5903 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5929 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 190: -#line 1842 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1866 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Bitfield definition. (yyvsp[-2].u.inst_ident)->_bit_width = (yyvsp[0].u.integer); (yyval.u.inst_ident) = (yyvsp[-2].u.inst_ident); } -#line 5913 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5939 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 191: -#line 1852 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1876 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.type) = NULL; + (yyval.u.type) = nullptr; } -#line 5921 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5947 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 192: -#line 1856 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1880 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 5929 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5955 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 193: -#line 1860 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1884 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[0].u.inst_ident)->add_modifier(IIT_const); (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 5938 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5964 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 194: -#line 1869 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1893 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.identifier) = NULL; + (yyval.u.identifier) = nullptr; } -#line 5946 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5972 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 195: -#line 1873 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1897 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 5954 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5980 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 196: -#line 1881 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1905 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; } -#line 5962 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5988 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 197: -#line 1885 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1909 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_includes_ellipsis = true; } -#line 5971 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 5997 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 198: -#line 1890 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1914 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[0].u.param_list); } -#line 5979 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6005 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 199: -#line 1894 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1918 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-2].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } -#line 5988 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6014 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 200: -#line 1899 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1923 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-1].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } -#line 5997 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6023 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 201: -#line 1907 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1931 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_parameters.push_back((yyvsp[0].u.instance)); } -#line 6006 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6032 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 202: -#line 1912 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1936 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-2].u.param_list); (yyval.u.param_list)->_parameters.push_back((yyvsp[0].u.instance)); } -#line 6015 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6041 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 203: -#line 1920 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1944 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; } -#line 6023 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6049 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 204: -#line 1924 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1948 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_includes_ellipsis = true; } -#line 6032 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6058 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 205: -#line 1929 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1953 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[0].u.param_list); } -#line 6040 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6066 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 206: -#line 1933 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1957 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-2].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } -#line 6049 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6075 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 207: -#line 1938 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1962 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-1].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } -#line 6058 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6084 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 208: -#line 1946 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1970 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_parameters.push_back((yyvsp[0].u.instance)); } -#line 6067 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6093 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 209: -#line 1951 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1975 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.param_list) = (yyvsp[-2].u.param_list); (yyval.u.param_list)->_parameters.push_back((yyvsp[0].u.instance)); } -#line 6076 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6102 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 210: -#line 1959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6084 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6110 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 211: -#line 1963 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 6092 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6118 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 212: -#line 1970 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1994 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6100 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6126 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 213: -#line 1974 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 1998 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 6108 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6134 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 214: -#line 1981 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2005 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6116 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6142 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 215: -#line 1985 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2009 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6124 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6150 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 216: -#line 1989 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2013 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6132 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6158 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 217: -#line 1993 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2017 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_default()); } -#line 6140 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6166 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 218: -#line 1997 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2021 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_delete()); } -#line 6148 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6174 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 219: -#line 2004 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2028 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6156 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6182 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 220: -#line 2008 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2032 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6164 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6190 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 221: -#line 2012 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2036 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[-1].u.expr); } -#line 6172 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6198 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 222: -#line 2016 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2040 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_default()); } -#line 6180 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6206 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 223: -#line 2020 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2044 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_delete()); } -#line 6188 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6214 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 224: -#line 2024 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2048 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 6196 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6222 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 228: -#line 2037 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2061 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { } -#line 6203 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6229 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 232: -#line 2046 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2070 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6212 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6238 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 233: -#line 2051 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2075 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6222 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6248 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 234: -#line 2057 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2081 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-2]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6232 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6258 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 235: -#line 2063 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2087 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6241 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6267 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 236: -#line 2068 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2092 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-1]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6251 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6277 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 237: -#line 2074 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2098 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-1].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[-2].u.type), (yyvsp[-1].u.inst_ident), 0, (yylsp[-2]).file); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6261 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6287 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 238: -#line 2080 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2104 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = (yyvsp[0].u.instance); } -#line 6269 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6295 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 239: -#line 2084 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2108 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = (yyvsp[0].u.instance); } -#line 6277 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6303 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 240: -#line 2095 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2119 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.instance) = (yyvsp[0].u.instance); } -#line 6285 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6311 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 241: -#line 2099 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2123 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_parameter)); (yyval.u.instance) = new CPPInstance(type, "expr"); (yyval.u.instance)->set_initializer((yyvsp[0].u.expr)); } -#line 6296 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6322 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 242: -#line 2109 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2133 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); } -#line 6304 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6330 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 243: -#line 2113 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2137 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); } -#line 6312 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6338 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 244: -#line 2117 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2141 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6321 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6347 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 245: -#line 2122 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2146 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6330 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6356 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 246: -#line 2127 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2151 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6339 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6365 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 247: -#line 2132 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2156 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6348 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6374 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 248: -#line 2137 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2161 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6357 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6383 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 249: -#line 2142 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2166 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6366 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6392 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 250: -#line 2147 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2171 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6375 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6401 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 251: -#line 2155 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2179 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); } -#line 6383 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6409 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 252: -#line 2159 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); } -#line 6391 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6417 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 253: -#line 2163 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2187 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6400 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6426 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 254: -#line 2168 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2192 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6409 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6435 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 255: -#line 2173 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2197 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6418 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6444 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 256: -#line 2178 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2202 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6427 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6453 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 257: -#line 2183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2207 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6436 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6462 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 258: -#line 2188 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2212 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6445 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6471 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 259: -#line 2193 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2217 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6454 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6480 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 260: -#line 2198 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2222 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-5].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } -#line 6464 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6490 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 261: -#line 2204 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2228 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-1].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); } -#line 6473 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6499 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 262: -#line 2212 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2236 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); (yyval.u.inst_ident)->_packed = true; } -#line 6482 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6508 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 263: -#line 2217 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2241 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); (yyval.u.inst_ident)->_packed = true; } -#line 6491 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6517 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 264: -#line 2222 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2246 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6500 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6526 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 265: -#line 2227 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2251 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6509 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6535 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 266: -#line 2232 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2256 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6518 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6544 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 267: -#line 2237 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2261 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6527 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6553 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 268: -#line 2242 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2266 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6536 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6562 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 269: -#line 2247 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2271 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6545 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6571 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 270: -#line 2252 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2276 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6554 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6580 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 271: -#line 2257 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2281 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-5].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-2].u.param_list), (yyvsp[0].u.integer)); } -#line 6564 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6590 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 272: -#line 2263 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2287 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-1].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); } -#line 6573 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6599 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 273: -#line 2271 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2295 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); } -#line 6581 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6607 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 274: -#line 2275 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2299 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); (yyval.u.inst_ident)->_packed = true; } -#line 6590 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6616 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 275: -#line 2280 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2304 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); (yyval.u.inst_ident)->_packed = true; } -#line 6599 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6625 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 276: -#line 2285 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2309 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6608 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6634 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 277: -#line 2290 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2314 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6617 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6643 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 278: -#line 2295 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2319 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6626 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6652 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 279: -#line 2300 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2324 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6635 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6661 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 280: -#line 2305 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2329 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6644 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6670 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 281: -#line 2310 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2334 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6653 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6679 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 282: -#line 2315 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2339 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6662 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6688 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 283: -#line 2323 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2347 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); } -#line 6670 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6696 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 284: -#line 2327 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2351 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); (yyval.u.inst_ident)->_packed = true; } -#line 6679 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6705 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 285: -#line 2332 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2356 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[0].u.identifier)); (yyval.u.inst_ident)->_packed = true; } -#line 6688 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6714 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 286: -#line 2337 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2361 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } -#line 6697 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6723 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 287: -#line 2342 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2366 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } -#line 6706 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6732 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 288: -#line 2347 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2371 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } -#line 6715 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6741 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 289: -#line 2352 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2376 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } -#line 6724 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6750 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 290: -#line 2357 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2381 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } -#line 6733 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6759 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 291: -#line 2362 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2386 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[0].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[-2].u.identifier)); } -#line 6742 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6768 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 292: -#line 2367 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2391 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-3].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[-1].u.expr)); } -#line 6751 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6777 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 293: -#line 2372 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2396 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident) = new CPPInstanceIdentifier(nullptr); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer), (yyvsp[0].u.type)); } -#line 6761 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6787 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 294: -#line 2378 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2402 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-6].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer), (yyvsp[0].u.type)); } -#line 6772 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6798 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 295: -#line 2385 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2409 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-6].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer), (yyvsp[0].u.type)); } -#line 6783 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6809 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 296: -#line 2392 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2416 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.inst_ident) = (yyvsp[-6].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); (yyval.u.inst_ident)->add_modifier(IIT_paren); (yyval.u.inst_ident)->add_func_modifier((yyvsp[-3].u.param_list), (yyvsp[-1].u.integer), (yyvsp[0].u.type)); } -#line 6794 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6820 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 297: -#line 2402 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2426 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 6802 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6828 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 298: -#line 2406 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2430 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 6814 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6840 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 299: -#line 2414 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2438 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } -#line 6822 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6848 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 300: -#line 2418 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2442 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.struct_type)); } -#line 6830 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6856 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 301: -#line 2422 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2446 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.struct_type)); } -#line 6838 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6864 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 302: -#line 2426 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2450 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.enum_type)); } -#line 6846 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6872 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 303: -#line 2430 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2454 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.type) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-2].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-2]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.type) = et; } } -#line 6866 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6892 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 304: -#line 2446 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2470 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[-2].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.type) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-3].u.extension_enum), (yyvsp[-2].u.identifier), current_scope, (yylsp[-3]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[-2].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.type) = et; } } -#line 6886 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6912 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 305: -#line 2462 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2486 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[-1].u.expr)->determine_type(); - if ((yyval.u.type) == (CPPType *)NULL) { + if ((yyval.u.type) == nullptr) { stringstream str; str << *(yyvsp[-1].u.expr); yyerror("could not determine type of " + str.str(), (yylsp[-1])); } } -#line 6899 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6925 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 306: -#line 2471 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2495 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 6907 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6933 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 307: -#line 2475 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2499 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPEnumType *enum_type = (yyvsp[-1].u.type)->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", (yylsp[-1])); (yyval.u.type) = (yyvsp[-1].u.type); } else { (yyval.u.type) = enum_type->get_underlying_type(); } } -#line 6921 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6947 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 308: -#line 2485 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2509 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 6929 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6955 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 309: -#line 2492 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2516 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 6941 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6967 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 310: -#line 2503 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2527 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 6949 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6975 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 311: -#line 2507 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2531 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.decl) == NULL) { + if ((yyval.u.decl) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.decl) != NULL); + assert((yyval.u.decl) != nullptr); } -#line 6961 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6987 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 312: -#line 2515 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2539 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } -#line 6969 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 6995 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 313: -#line 2519 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2543 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type((yyvsp[0].u.struct_type)); } -#line 6977 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7003 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 314: -#line 2523 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2547 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[0].u.struct_type))); } -#line 6985 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7011 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 315: -#line 2527 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2551 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[0].u.enum_type))); } -#line 6993 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7019 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 316: -#line 2531 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2555 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.decl) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-2].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-2]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.decl) = et; } } -#line 7013 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7039 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 317: -#line 2547 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2571 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[-2].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.decl) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-3].u.extension_enum), (yyvsp[-2].u.identifier), current_scope, (yylsp[-3]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[-2].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.decl) = et; } } -#line 7033 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7059 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 318: -#line 2563 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2587 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { yywarning(string("C++ does not permit forward declaration of untyped enum ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[-1])); CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.decl) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-1].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-1]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.decl) = et; } } -#line 7055 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7081 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 319: -#line 2581 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2605 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = (yyvsp[-1].u.expr)->determine_type(); - if ((yyval.u.decl) == (CPPType *)NULL) { + if ((yyval.u.decl) == nullptr) { stringstream str; str << *(yyvsp[-1].u.expr); yyerror("could not determine type of " + str.str(), (yylsp[-1])); } } -#line 7068 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7094 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 320: -#line 2590 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2614 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 7076 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7102 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 321: -#line 2594 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2618 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPEnumType *enum_type = (yyvsp[-1].u.type)->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", (yylsp[-1])); (yyval.u.decl) = (yyvsp[-1].u.type); } else { (yyval.u.decl) = enum_type->get_underlying_type(); } } -#line 7090 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7116 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 322: -#line 2604 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2628 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 7098 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7124 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 323: -#line 2611 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2635 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 7106 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7132 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 324: -#line 2615 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2639 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if ((yyval.u.type) == NULL) { + if ((yyval.u.type) == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[0].u.identifier)->get_fully_scoped_name(), (yylsp[0])); } - assert((yyval.u.type) != NULL); + assert((yyval.u.type) != nullptr); } -#line 7118 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7144 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 325: -#line 2623 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2647 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } -#line 7126 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7152 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 326: -#line 2627 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2651 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.type) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-2].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-2]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.type) = et; } } -#line 7146 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7172 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 327: -#line 2643 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2667 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { (yyval.u.type) = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType((yyvsp[-1].u.extension_enum), (yyvsp[0].u.identifier), current_scope, (yylsp[-1]).file)) ->as_extension_type(); CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } (yyval.u.type) = et; } } -#line 7166 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7192 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 328: -#line 2659 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2683 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[-1].u.expr)->determine_type(); - if ((yyval.u.type) == (CPPType *)NULL) { + if ((yyval.u.type) == nullptr) { stringstream str; str << *(yyvsp[-1].u.expr); yyerror("could not determine type of " + str.str(), (yylsp[-1])); } } -#line 7179 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7205 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 329: -#line 2668 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2692 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPEnumType *enum_type = (yyvsp[-1].u.type)->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", (yylsp[-1])); (yyval.u.type) = (yyvsp[-1].u.type); } else { (yyval.u.type) = enum_type->get_underlying_type(); } } -#line 7193 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7219 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 330: -#line 2678 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2702 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } -#line 7201 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7227 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 331: -#line 2685 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2709 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.decl) = (yyvsp[0].u.decl); } -#line 7209 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7235 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 332: -#line 2689 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2713 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { yyerror(string("unknown type '") + (yyvsp[0].u.identifier)->get_fully_scoped_name() + "'", (yylsp[0])); (yyval.u.decl) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_unknown)); } -#line 7219 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7245 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 333: -#line 2697 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2721 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 7227 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7253 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 334: -#line 2701 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2725 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[0].u.inst_ident)->add_modifier(IIT_const); (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 7236 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7262 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 335: -#line 2706 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2730 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 7244 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7270 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 336: -#line 2710 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2734 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[0].u.inst_ident)->add_modifier(IIT_const); (yyval.u.type) = (yyvsp[0].u.inst_ident)->unroll_type((yyvsp[-1].u.type)); } -#line 7253 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7279 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 341: -#line 2725 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2749 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPVisibility starting_vis = ((yyvsp[-2].u.extension_enum) == CPPExtensionType::T_class) ? V_private : V_public; CPPScope *new_scope = new CPPScope(current_scope, CPPNameComponent("anon"), starting_vis); - CPPStructType *st = new CPPStructType((yyvsp[-2].u.extension_enum), NULL, current_scope, + CPPStructType *st = new CPPStructType((yyvsp[-2].u.extension_enum), nullptr, current_scope, new_scope, (yylsp[-2]).file); new_scope->set_struct_type(st); push_scope(new_scope); push_struct(st); } -#line 7271 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7297 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 342: -#line 2739 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2763 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.struct_type) = current_struct; current_struct->_incomplete = false; pop_struct(); pop_scope(); } -#line 7282 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7308 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 343: -#line 2749 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2773 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPVisibility starting_vis = ((yyvsp[-2].u.extension_enum) == CPPExtensionType::T_class) ? V_private : V_public; CPPScope *scope = (yyvsp[0].u.identifier)->get_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { scope = current_scope; } CPPScope *new_scope = new CPPScope(scope, (yyvsp[0].u.identifier)->_names.back(), @@ -7304,260 +7328,260 @@ yyreduce: push_scope(new_scope); push_struct(st); } -#line 7306 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7332 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 344: -#line 2769 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2793 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.struct_type) = current_struct; current_struct->_incomplete = false; pop_struct(); pop_scope(); } -#line 7317 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7343 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 346: -#line 2780 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2804 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->_final = true; } -#line 7325 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7351 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 351: -#line 2797 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2821 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_unknown, false); } -#line 7333 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7359 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 352: -#line 2801 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2825 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_public, false); } -#line 7341 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7367 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 353: -#line 2805 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2829 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_protected, false); } -#line 7349 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7375 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 354: -#line 2809 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2833 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_private, false); } -#line 7357 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7383 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 355: -#line 2813 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2837 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_public, true); } -#line 7365 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7391 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 356: -#line 2817 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2841 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_protected, true); } -#line 7373 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7399 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 357: -#line 2821 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2845 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_private, true); } -#line 7381 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7407 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 358: -#line 2825 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2849 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_public, true); } -#line 7389 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7415 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 359: -#line 2829 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2853 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_protected, true); } -#line 7397 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7423 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 360: -#line 2833 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2857 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_struct->append_derivation((yyvsp[0].u.type), V_private, true); } -#line 7405 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7431 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 361: -#line 2840 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2864 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.enum_type) = current_enum; - current_enum = NULL; + current_enum = nullptr; } -#line 7414 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7440 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 362: -#line 2848 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2872 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - current_enum = new CPPEnumType((yyvsp[-2].u.extension_enum), NULL, (yyvsp[0].u.type), current_scope, NULL, (yylsp[-2]).file); + current_enum = new CPPEnumType((yyvsp[-2].u.extension_enum), nullptr, (yyvsp[0].u.type), current_scope, nullptr, (yylsp[-2]).file); } -#line 7422 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7448 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 363: -#line 2852 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2876 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - current_enum = new CPPEnumType((yyvsp[0].u.extension_enum), NULL, current_scope, NULL, (yylsp[0]).file); + current_enum = new CPPEnumType((yyvsp[0].u.extension_enum), nullptr, current_scope, nullptr, (yylsp[0]).file); } -#line 7430 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7456 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 364: -#line 2856 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2880 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *new_scope = new CPPScope(current_scope, (yyvsp[-2].u.identifier)->_names.back(), V_public); current_enum = new CPPEnumType((yyvsp[-3].u.extension_enum), (yyvsp[-2].u.identifier), (yyvsp[0].u.type), current_scope, new_scope, (yylsp[-3]).file); } -#line 7439 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7465 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 365: -#line 2861 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2885 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *new_scope = new CPPScope(current_scope, (yyvsp[0].u.identifier)->_names.back(), V_public); current_enum = new CPPEnumType((yyvsp[-1].u.extension_enum), (yyvsp[0].u.identifier), current_scope, new_scope, (yylsp[-1]).file); } -#line 7448 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7474 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 366: -#line 2869 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2893 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type((yyvsp[0].u.simple_type)); } -#line 7456 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7482 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 367: -#line 2873 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2897 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); } -#line 7464 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7490 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 369: -#line 2881 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2905 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - assert(current_enum != NULL); - current_enum->add_element((yyvsp[-1].u.identifier)->get_simple_name(), NULL, current_lexer, (yylsp[-1])); + assert(current_enum != nullptr); + current_enum->add_element((yyvsp[-1].u.identifier)->get_simple_name(), nullptr, current_lexer, (yylsp[-1])); } -#line 7473 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7499 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 370: -#line 2886 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2910 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - assert(current_enum != NULL); + assert(current_enum != nullptr); current_enum->add_element((yyvsp[-3].u.identifier)->get_simple_name(), (yyvsp[-1].u.expr), current_lexer, (yylsp[-3])); } -#line 7482 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7508 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 372: -#line 2894 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2918 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - assert(current_enum != NULL); - current_enum->add_element((yyvsp[0].u.identifier)->get_simple_name(), NULL, current_lexer, (yylsp[0])); + assert(current_enum != nullptr); + current_enum->add_element((yyvsp[0].u.identifier)->get_simple_name(), nullptr, current_lexer, (yylsp[0])); } -#line 7491 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7517 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 373: -#line 2899 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2923 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - assert(current_enum != NULL); + assert(current_enum != nullptr); current_enum->add_element((yyvsp[-2].u.identifier)->get_simple_name(), (yyvsp[0].u.expr), current_lexer, (yylsp[-2])); } -#line 7500 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7526 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 374: -#line 2907 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2931 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_enum; } -#line 7508 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7534 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 375: -#line 2911 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2935 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_enum_class; } -#line 7516 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7542 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 376: -#line 2915 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2939 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_enum_struct; } -#line 7524 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7550 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 377: -#line 2922 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2946 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_class; } -#line 7532 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7558 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 378: -#line 2926 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2950 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_struct; } -#line 7540 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7566 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 379: -#line 2930 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2954 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.extension_enum) = CPPExtensionType::T_union; } -#line 7548 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7574 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 380: -#line 2937 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2961 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *scope = (yyvsp[-1].u.identifier)->find_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { // This must be a new namespace declaration. CPPScope *parent_scope = (yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope, current_lexer); - if (parent_scope == NULL) { + if (parent_scope == nullptr) { parent_scope = current_scope; } scope = new CPPScope(parent_scope, (yyvsp[-1].u.identifier)->_names.back(), V_public); @@ -7568,26 +7592,26 @@ yyreduce: current_scope->define_namespace(nspace); push_scope(scope); } -#line 7570 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7596 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 381: -#line 2955 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2979 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); } -#line 7578 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7604 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 382: -#line 2959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 2983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPScope *scope = (yyvsp[-1].u.identifier)->find_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { // This must be a new namespace declaration. CPPScope *parent_scope = (yyvsp[-1].u.identifier)->get_scope(current_scope, global_scope, current_lexer); - if (parent_scope == NULL) { + if (parent_scope == nullptr) { parent_scope = current_scope; } scope = new CPPScope(parent_scope, (yyvsp[-1].u.identifier)->_names.back(), V_public); @@ -7599,143 +7623,143 @@ yyreduce: current_scope->define_namespace(nspace); push_scope(scope); } -#line 7601 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7627 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 383: -#line 2978 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3002 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { pop_scope(); } -#line 7609 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7635 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 386: -#line 2987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3011 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPUsing *using_decl = new CPPUsing((yyvsp[-1].u.identifier), false, (yylsp[-2]).file); current_scope->add_declaration(using_decl, global_scope, current_lexer, (yylsp[-2])); current_scope->add_using(using_decl, global_scope, current_lexer); } -#line 7619 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7645 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 387: -#line 2993 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3017 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This is really just an alternative way to declare a typedef. CPPTypedefType *typedef_type = new CPPTypedefType((yyvsp[-1].u.type), (yyvsp[-3].u.identifier), current_scope); typedef_type->_using = true; current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, (yylsp[-4])); } -#line 7630 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7656 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 388: -#line 3000 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3024 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPUsing *using_decl = new CPPUsing((yyvsp[-1].u.identifier), true, (yylsp[-3]).file); current_scope->add_declaration(using_decl, global_scope, current_lexer, (yylsp[-3])); current_scope->add_using(using_decl, global_scope, current_lexer); } -#line 7640 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7666 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 392: -#line 3015 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3039 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_bool); } -#line 7648 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7674 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 393: -#line 3019 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3043 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char); } -#line 7656 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7682 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 394: -#line 3023 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3047 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_wchar_t); } -#line 7664 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7690 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 395: -#line 3027 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3051 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char16_t); } -#line 7672 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7698 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 396: -#line 3031 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3055 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char32_t); } -#line 7680 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7706 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 397: -#line 3035 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3059 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_short); } -#line 7689 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7715 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 398: -#line 3040 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3064 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_long); } -#line 7698 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7724 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 399: -#line 3045 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3069 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_unsigned); } -#line 7707 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7733 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 400: -#line 3050 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3074 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_signed); } -#line 7716 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7742 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 401: -#line 3055 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3079 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int); } -#line 7724 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7750 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 402: -#line 3059 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3083 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = (yyvsp[0].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_short; } -#line 7733 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7759 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 403: -#line 3064 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3088 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = (yyvsp[0].u.simple_type); if ((yyval.u.simple_type)->_flags & CPPSimpleType::F_long) { @@ -7744,192 +7768,192 @@ yyreduce: (yyval.u.simple_type)->_flags |= CPPSimpleType::F_long; } } -#line 7746 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7772 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 404: -#line 3073 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3097 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = (yyvsp[0].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_unsigned; } -#line 7755 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7781 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 405: -#line 3078 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3102 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = (yyvsp[0].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_signed; } -#line 7764 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7790 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 406: -#line 3086 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3110 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_float); } -#line 7772 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7798 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 407: -#line 3090 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3114 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_double); } -#line 7780 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7806 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 408: -#line 3094 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3118 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_double, CPPSimpleType::F_long); } -#line 7789 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7815 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 409: -#line 3102 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3126 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_void); } -#line 7797 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7823 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 410: -#line 3111 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3135 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_lexer->_resolve_identifiers = false; } -#line 7805 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7831 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 411: -#line 3115 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3139 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { current_lexer->_resolve_identifiers = true; } -#line 7813 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7839 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 519: -#line 3159 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { } -#line 7820 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7846 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 543: -#line 3168 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3192 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 7828 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7854 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 544: -#line 3172 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3196 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 7836 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7862 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 545: -#line 3179 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3203 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.expr) = nullptr; } -#line 7844 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7870 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 546: -#line 3183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3207 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 7852 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7878 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 547: -#line 3190 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3214 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 7860 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7886 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 548: -#line 3194 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3218 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(',', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 7868 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7894 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 549: -#line 3201 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3225 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 7876 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7902 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 550: -#line 3205 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3229 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-2].u.type), (yyvsp[0].u.expr))); } -#line 7884 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7910 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 551: -#line 3209 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3233 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_static_cast)); } -#line 7892 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7918 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 552: -#line 3213 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3237 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_dynamic_cast)); } -#line 7900 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7926 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 553: -#line 3217 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3241 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_const_cast)); } -#line 7908 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7934 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 554: -#line 3221 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3245 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_reinterpret_cast)); } -#line 7916 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7942 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 555: -#line 3225 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3249 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[-1].u.type))); } -#line 7924 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7950 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 556: -#line 3229 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3253 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *arg = (yyvsp[-1].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + (yyvsp[-1].u.identifier)->get_fully_scoped_name(), (yylsp[-1])); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -7938,470 +7962,470 @@ yyreduce: (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func(arg->as_type())); } } -#line 7940 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7966 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 557: -#line 3241 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3265 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_ellipsis_func((yyvsp[-1].u.identifier))); } -#line 7948 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7974 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 558: -#line 3245 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3269 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[-1].u.type))); } -#line 7956 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7982 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 559: -#line 3249 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3273 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[0].u.expr)); } -#line 7964 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7990 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 560: -#line 3253 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3277 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[0].u.expr)); } -#line 7972 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 7998 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 561: -#line 3257 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3281 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[0].u.expr)); } -#line 7980 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8006 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 562: -#line 3261 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3285 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_PLUS, (yyvsp[0].u.expr)); } -#line 7988 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8014 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 563: -#line 3265 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3289 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[0].u.expr)); } -#line 7996 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8022 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 564: -#line 3269 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3293 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[0].u.expr)); } -#line 8004 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8030 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 565: -#line 3273 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3297 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('*', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8012 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8038 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 566: -#line 3277 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3301 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('/', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8020 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8046 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 567: -#line 3281 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3305 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('%', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8028 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8054 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 568: -#line 3285 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3309 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('+', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8036 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8062 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 569: -#line 3289 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3313 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('-', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8044 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8070 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 570: -#line 3293 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3317 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('|', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8052 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8078 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 571: -#line 3297 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3321 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('^', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8060 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8086 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 572: -#line 3301 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3325 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('&', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8068 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8094 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 573: -#line 3305 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3329 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8076 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8102 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 574: -#line 3309 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3333 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8084 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8110 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 575: -#line 3313 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3337 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8092 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8118 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 576: -#line 3317 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3341 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8100 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8126 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 577: -#line 3321 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3345 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8108 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8134 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 578: -#line 3325 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3349 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8116 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8142 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 579: -#line 3329 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3353 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8124 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8150 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 580: -#line 3333 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3357 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8132 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8158 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 581: -#line 3337 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3361 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('?', (yyvsp[-4].u.expr), (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8140 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8166 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 582: -#line 3341 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3365 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('[', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 8148 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8174 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 583: -#line 3345 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3369 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 8156 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8182 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 584: -#line 3349 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3373 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-2].u.expr)); } -#line 8164 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8190 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 585: -#line 3353 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3377 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('.', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8172 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8198 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 586: -#line 3357 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3381 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8180 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8206 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 587: -#line 3361 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3385 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[-1].u.expr); } -#line 8188 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8214 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 588: -#line 3369 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3393 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 8196 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8222 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 589: -#line 3373 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3397 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-2].u.type), (yyvsp[0].u.expr))); } -#line 8204 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8230 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 590: -#line 3377 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3401 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_static_cast)); } -#line 8212 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8238 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 591: -#line 3381 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3405 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_dynamic_cast)); } -#line 8220 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8246 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 592: -#line 3385 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3409 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_const_cast)); } -#line 8228 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8254 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 593: -#line 3389 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3413 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_reinterpret_cast)); } -#line 8236 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8262 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 594: -#line 3393 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3417 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A constructor call. CPPType *type = (yyvsp[-3].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[-3].u.identifier)->get_fully_scoped_name(), (yylsp[-3])); } - assert(type != NULL); + assert(type != nullptr); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8250 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8276 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 595: -#line 3403 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3427 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // Aggregate initialization. CPPType *type = (yyvsp[-3].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + (yyvsp[-3].u.identifier)->get_fully_scoped_name(), (yylsp[-3])); } - assert(type != NULL); + assert(type != nullptr); (yyval.u.expr) = new CPPExpression(CPPExpression::aggregate_init_op(type, (yyvsp[-1].u.expr))); } -#line 8264 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8290 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 596: -#line 3413 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3437 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8274 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8300 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 597: -#line 3419 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3443 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8284 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8310 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 598: -#line 3425 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3449 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_wchar_t)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8294 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8320 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 599: -#line 3431 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3455 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char16_t)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8304 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8330 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 600: -#line 3437 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3461 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char32_t)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8314 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8340 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 601: -#line 3443 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3467 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_bool)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8324 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8350 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 602: -#line 3449 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3473 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_short)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8335 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8361 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 603: -#line 3456 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3480 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_long)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8346 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8372 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 604: -#line 3463 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3487 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_unsigned)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8357 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8383 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 605: -#line 3470 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3494 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_signed)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8368 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8394 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 606: -#line 3477 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3501 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_float)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8378 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8404 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 607: -#line 3483 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3507 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_double)); (yyval.u.expr) = new CPPExpression(CPPExpression::construct_op(type, (yyvsp[-1].u.expr))); } -#line 8388 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8414 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 608: -#line 3489 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3513 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[-1].u.type))); } -#line 8396 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8422 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 609: -#line 3493 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3517 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *arg = (yyvsp[-1].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + (yyvsp[-1].u.identifier)->get_fully_scoped_name(), (yylsp[-1])); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -8410,43 +8434,43 @@ yyreduce: (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func(arg->as_type())); } } -#line 8412 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8438 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 610: -#line 3505 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3529 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_ellipsis_func((yyvsp[-1].u.identifier))); } -#line 8420 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8446 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 611: -#line 3509 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3533 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[-1].u.type))); } -#line 8428 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8454 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 612: -#line 3513 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3537 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[0].u.type))); } -#line 8436 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8462 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 613: -#line 3517 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3541 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[-3].u.type), (yyvsp[-1].u.expr))); } -#line 8444 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8470 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 614: -#line 3521 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3545 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPIdentifier ident(""); ident.add_name("std"); @@ -8457,11 +8481,11 @@ yyreduce: } (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[-1].u.type), std_type_info)); } -#line 8459 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8485 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 615: -#line 3532 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3556 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPIdentifier ident(""); ident.add_name("std"); @@ -8472,567 +8496,567 @@ yyreduce: } (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[-1].u.expr), std_type_info)); } -#line 8474 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8500 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 616: -#line 3543 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3567 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[0].u.expr)); } -#line 8482 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8508 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 617: -#line 3547 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3571 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[0].u.expr)); } -#line 8490 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8516 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 618: -#line 3551 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3575 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[0].u.expr)); } -#line 8498 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8524 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 619: -#line 3555 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3579 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_PLUS, (yyvsp[0].u.expr)); } -#line 8506 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8532 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 620: -#line 3559 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3583 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[0].u.expr)); } -#line 8514 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8540 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 621: -#line 3563 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3587 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[0].u.expr)); } -#line 8522 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8548 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 622: -#line 3567 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3591 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('*', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8530 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8556 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 623: -#line 3571 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3595 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('/', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8538 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8564 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 624: -#line 3575 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3599 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('%', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8546 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8572 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 625: -#line 3579 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3603 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('+', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8554 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8580 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 626: -#line 3583 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3607 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('-', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8562 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8588 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 627: -#line 3587 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3611 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('|', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8570 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8596 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 628: -#line 3591 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3615 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('^', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8578 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8604 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 629: -#line 3595 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3619 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('&', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8586 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8612 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 630: -#line 3599 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3623 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8594 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8620 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 631: -#line 3603 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3627 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8602 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8628 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 632: -#line 3607 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3631 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8610 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8636 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 633: -#line 3611 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3635 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8618 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8644 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 634: -#line 3615 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3639 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8626 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8652 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 635: -#line 3619 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3643 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8634 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8660 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 636: -#line 3623 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3647 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('<', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8642 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8668 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 637: -#line 3627 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3651 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('>', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8650 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8676 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 638: -#line 3631 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3655 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8658 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8684 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 639: -#line 3635 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3659 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8666 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8692 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 640: -#line 3639 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3663 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('?', (yyvsp[-4].u.expr), (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8674 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8700 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 641: -#line 3643 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3667 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('[', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 8682 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8708 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 642: -#line 3647 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3671 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 8690 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8716 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 643: -#line 3651 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3675 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-2].u.expr)); } -#line 8698 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8724 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 644: -#line 3655 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3679 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('.', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8706 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8732 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 645: -#line 3659 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3683 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 8714 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8740 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 646: -#line 3663 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3687 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[-1].u.expr); } -#line 8722 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8748 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 647: -#line 3670 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3694 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.integer)); } -#line 8730 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8756 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 648: -#line 3674 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3698 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(true); } -#line 8738 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8764 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 649: -#line 3678 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3702 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(false); } -#line 8746 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8772 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 650: -#line 3682 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3706 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.integer)); } -#line 8754 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8780 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 651: -#line 3686 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3710 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.real)); } -#line 8762 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8788 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 652: -#line 3690 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3714 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 8770 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8796 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 653: -#line 3694 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3718 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 8778 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8804 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 654: -#line 3698 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3722 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.identifier), current_scope, global_scope, current_lexer); } -#line 8786 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8812 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 655: -#line 3702 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3726 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A variable named "final". C++11 explicitly permits this. CPPIdentifier *ident = new CPPIdentifier("final", (yylsp[0])); (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); } -#line 8796 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8822 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 656: -#line 3708 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3732 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A variable named "override". C++11 explicitly permits this. CPPIdentifier *ident = new CPPIdentifier("override", (yylsp[0])); (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); } -#line 8806 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8832 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 657: -#line 3714 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3738 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_nullptr()); } -#line 8814 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8840 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 658: -#line 3718 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3742 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-6].u.closure_type)->_flags = (yyvsp[-4].u.integer); (yyvsp[-6].u.closure_type)->_return_type = (yyvsp[-3].u.type); (yyval.u.expr) = new CPPExpression(CPPExpression::lambda((yyvsp[-6].u.closure_type))); } -#line 8824 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8850 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 659: -#line 3724 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3748 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyvsp[-9].u.closure_type)->_parameters = (yyvsp[-6].u.param_list); (yyvsp[-9].u.closure_type)->_flags = (yyvsp[-4].u.integer); (yyvsp[-9].u.closure_type)->_return_type = (yyvsp[-3].u.type); (yyval.u.expr) = new CPPExpression(CPPExpression::lambda((yyvsp[-9].u.closure_type))); } -#line 8835 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8861 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 660: -#line 3731 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3755 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_HAS_VIRTUAL_DESTRUCTOR, (yyvsp[-1].u.type))); } -#line 8843 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8869 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 661: -#line 3735 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3759 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_ABSTRACT, (yyvsp[-1].u.type))); } -#line 8851 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8877 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 662: -#line 3739 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3763 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CLASS, (yyvsp[-3].u.type), (yyvsp[-1].u.type))); } -#line 8859 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8885 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 663: -#line 3743 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3767 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CLASS, (yyvsp[-1].u.type))); } -#line 8867 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8893 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 664: -#line 3747 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3771 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CONSTRUCTIBLE, (yyvsp[-1].u.type))); } -#line 8875 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8901 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 665: -#line 3751 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3775 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CONSTRUCTIBLE, (yyvsp[-3].u.type), (yyvsp[-1].u.type))); } -#line 8883 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8909 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 666: -#line 3755 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3779 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_CONVERTIBLE_TO, (yyvsp[-3].u.type), (yyvsp[-1].u.type))); } -#line 8891 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8917 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 667: -#line 3759 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3783 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_DESTRUCTIBLE, (yyvsp[-1].u.type))); } -#line 8899 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8925 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 668: -#line 3763 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3787 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_EMPTY, (yyvsp[-1].u.type))); } -#line 8907 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8933 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 669: -#line 3767 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3791 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_ENUM, (yyvsp[-1].u.type))); } -#line 8915 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8941 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 670: -#line 3771 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3795 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_FINAL, (yyvsp[-1].u.type))); } -#line 8923 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8949 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 671: -#line 3775 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3799 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_FUNDAMENTAL, (yyvsp[-1].u.type))); } -#line 8931 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8957 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 672: -#line 3779 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3803 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_POD, (yyvsp[-1].u.type))); } -#line 8939 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8965 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 673: -#line 3783 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3807 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_POLYMORPHIC, (yyvsp[-1].u.type))); } -#line 8947 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8973 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 674: -#line 3787 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3811 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_STANDARD_LAYOUT, (yyvsp[-1].u.type))); } -#line 8955 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8981 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 675: -#line 3791 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3815 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_TRIVIAL, (yyvsp[-1].u.type))); } -#line 8963 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8989 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 676: -#line 3795 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3819 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::type_trait(KW_IS_UNION, (yyvsp[-1].u.type))); } -#line 8971 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 8997 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 677: -#line 3809 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3833 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 8979 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9005 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 678: -#line 3813 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3837 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-2].u.type), (yyvsp[0].u.expr))); } -#line 8987 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9013 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 679: -#line 3817 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3841 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_static_cast)); } -#line 8995 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9021 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 680: -#line 3821 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3845 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_dynamic_cast)); } -#line 9003 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9029 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 681: -#line 3825 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3849 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_const_cast)); } -#line 9011 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9037 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 682: -#line 3829 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3853 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[-4].u.type), (yyvsp[-1].u.expr), CPPExpression::T_reinterpret_cast)); } -#line 9019 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9045 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 683: -#line 3833 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3857 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[-1].u.type))); } -#line 9027 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9053 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 684: -#line 3837 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3861 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPDeclaration *arg = (yyvsp[-1].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + (yyvsp[-1].u.identifier)->get_fully_scoped_name(), (yylsp[-1])); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -9041,43 +9065,43 @@ yyreduce: (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func(arg->as_type())); } } -#line 9043 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9069 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 685: -#line 3849 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3873 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_ellipsis_func((yyvsp[-1].u.identifier))); } -#line 9051 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9077 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 686: -#line 3853 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3877 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[-1].u.type))); } -#line 9059 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9085 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 687: -#line 3857 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3881 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[0].u.type))); } -#line 9067 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9093 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 688: -#line 3861 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3885 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[-3].u.type), (yyvsp[-1].u.expr))); } -#line 9075 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9101 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 689: -#line 3865 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3889 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPIdentifier ident(""); ident.add_name("std"); @@ -9088,11 +9112,11 @@ yyreduce: } (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[-1].u.type), std_type_info)); } -#line 9090 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9116 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 690: -#line 3876 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3900 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPIdentifier ident(""); ident.add_name("std"); @@ -9103,409 +9127,409 @@ yyreduce: } (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[-1].u.expr), std_type_info)); } -#line 9105 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9131 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 691: -#line 3887 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3911 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[0].u.expr)); } -#line 9113 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9139 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 692: -#line 3891 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3915 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[0].u.expr)); } -#line 9121 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9147 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 693: -#line 3895 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3919 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[0].u.expr)); } -#line 9129 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9155 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 694: -#line 3899 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3923 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_PLUS, (yyvsp[0].u.expr)); } -#line 9137 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9163 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 695: -#line 3903 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3927 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[0].u.expr)); } -#line 9145 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9171 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 696: -#line 3907 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3931 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('*', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9153 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9179 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 697: -#line 3911 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3935 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('/', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9161 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9187 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 698: -#line 3915 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3939 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('%', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9169 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9195 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 699: -#line 3919 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3943 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('+', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9177 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9203 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 700: -#line 3923 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3947 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('-', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9185 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9211 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 701: -#line 3927 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3951 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('|', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9193 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9219 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 702: -#line 3931 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3955 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('^', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9201 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9227 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 703: -#line 3935 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('&', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9209 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9235 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 704: -#line 3939 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3963 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9217 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9243 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 705: -#line 3943 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3967 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9225 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9251 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 706: -#line 3947 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3971 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9233 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9259 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 707: -#line 3951 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3975 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9241 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9267 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 708: -#line 3955 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3979 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9249 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9275 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 709: -#line 3959 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9257 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9283 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 710: -#line 3963 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('<', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9265 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9291 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 711: -#line 3967 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3991 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('>', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9273 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9299 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 712: -#line 3971 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3995 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9281 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9307 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 713: -#line 3975 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 3999 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9289 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9315 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 714: -#line 3979 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4003 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('?', (yyvsp[-4].u.expr), (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9297 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9323 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 715: -#line 3983 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4007 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('[', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 9305 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9331 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 716: -#line 3987 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4011 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-3].u.expr), (yyvsp[-1].u.expr)); } -#line 9313 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9339 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 717: -#line 3991 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4015 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('f', (yyvsp[-2].u.expr)); } -#line 9321 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9347 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 718: -#line 3995 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4019 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression('.', (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9329 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9355 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 719: -#line 3999 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4023 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[-2].u.expr), (yyvsp[0].u.expr)); } -#line 9337 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9363 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 720: -#line 4003 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4027 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[-1].u.expr); } -#line 9345 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9371 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 721: -#line 4010 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4034 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.integer)); } -#line 9353 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9379 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 722: -#line 4014 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4038 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(true); } -#line 9361 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9387 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 723: -#line 4018 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4042 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(false); } -#line 9369 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9395 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 724: -#line 4022 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4046 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.integer)); } -#line 9377 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9403 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 725: -#line 4026 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4050 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.real)); } -#line 9385 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9411 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 726: -#line 4030 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4054 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 9393 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9419 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 727: -#line 4034 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4058 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 9401 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9427 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 728: -#line 4038 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4062 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].u.identifier), current_scope, global_scope, current_lexer); } -#line 9409 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9435 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 729: -#line 4042 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4066 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A variable named "final". C++11 explicitly permits this. CPPIdentifier *ident = new CPPIdentifier("final", (yylsp[0])); (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); } -#line 9419 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9445 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 730: -#line 4048 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4072 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // A variable named "override". C++11 explicitly permits this. CPPIdentifier *ident = new CPPIdentifier("override", (yylsp[0])); (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); } -#line 9429 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9455 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 731: -#line 4054 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4078 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression(CPPExpression::get_nullptr()); } -#line 9437 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9463 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 732: -#line 4062 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4086 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = new CPPClosureType(); } -#line 9445 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9471 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 733: -#line 4066 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4090 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = new CPPClosureType(CPPClosureType::CT_by_value); } -#line 9453 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9479 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 734: -#line 4070 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4094 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = new CPPClosureType(CPPClosureType::CT_by_reference); } -#line 9461 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9487 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 735: -#line 4074 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4098 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = new CPPClosureType(); (yyvsp[-1].u.capture)->_initializer = (yyvsp[0].u.expr); (yyval.u.closure_type)->_captures.push_back(*(yyvsp[-1].u.capture)); delete (yyvsp[-1].u.capture); } -#line 9472 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9498 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 736: -#line 4081 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4105 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.closure_type) = (yyvsp[-3].u.closure_type); (yyvsp[-1].u.capture)->_initializer = (yyvsp[0].u.expr); (yyval.u.closure_type)->_captures.push_back(*(yyvsp[-1].u.capture)); delete (yyvsp[-1].u.capture); } -#line 9483 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9509 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 737: -#line 4091 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4115 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.capture) = new CPPClosureType::Capture; (yyval.u.capture)->_name = (yyvsp[0].u.identifier)->get_simple_name(); (yyval.u.capture)->_type = CPPClosureType::CT_by_reference; } -#line 9493 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9519 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 738: -#line 4097 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4121 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.capture) = new CPPClosureType::Capture; (yyval.u.capture)->_name = (yyvsp[-1].u.identifier)->get_simple_name(); (yyval.u.capture)->_type = CPPClosureType::CT_by_reference; } -#line 9503 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9529 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 739: -#line 4103 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4127 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.capture) = new CPPClosureType::Capture; (yyval.u.capture)->_name = (yyvsp[0].u.identifier)->get_simple_name(); @@ -9515,11 +9539,11 @@ yyreduce: (yyval.u.capture)->_type = CPPClosureType::CT_by_value; } } -#line 9517 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9543 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 740: -#line 4113 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4137 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.capture) = new CPPClosureType::Capture; (yyval.u.capture)->_name = (yyvsp[0].u.identifier)->get_simple_name(); @@ -9528,189 +9552,189 @@ yyreduce: yywarning("only capture name 'this' may be preceded by an asterisk", (yylsp[0])); } } -#line 9530 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9556 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 741: -#line 4125 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4149 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPType *type = (yyvsp[0].u.identifier)->find_type(current_scope, global_scope, true); - if (type == NULL) { + if (type == nullptr) { type = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } (yyval.u.type) = type; } -#line 9542 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9568 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 742: -#line 4133 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4157 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[0].u.identifier))); } -#line 9550 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9576 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 743: -#line 4137 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4161 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter((yyvsp[-1].u.identifier)); ctp->_packed = true; (yyval.u.type) = CPPType::new_type(ctp); } -#line 9560 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9586 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 744: -#line 4167 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4191 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9568 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9594 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 745: -#line 4171 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4195 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9576 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9602 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 746: -#line 4175 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4199 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9584 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9610 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 747: -#line 4179 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4203 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("final", (yylsp[0])); } -#line 9592 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9618 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 748: -#line 4183 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4207 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("override", (yylsp[0])); } -#line 9600 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9626 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 749: -#line 4187 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4211 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // This is not a keyword in Python, so it is useful to be able to use this // in MAKE_PROPERTY definitions, etc. (yyval.u.identifier) = new CPPIdentifier("signed", (yylsp[0])); } -#line 9610 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9636 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 750: -#line 4193 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4217 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("float", (yylsp[0])); } -#line 9618 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9644 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 751: -#line 4197 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4221 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("public", (yylsp[0])); } -#line 9626 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9652 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 752: -#line 4201 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4225 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("private", (yylsp[0])); } -#line 9634 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9660 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 753: -#line 4205 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4229 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("static", (yylsp[0])); } -#line 9642 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9668 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 754: -#line 4209 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4233 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("default", (yylsp[0])); } -#line 9650 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9676 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 755: -#line 4220 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4244 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9658 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9684 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 756: -#line 4224 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4248 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9666 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9692 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 757: -#line 4228 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4252 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = (yyvsp[0].u.identifier); } -#line 9674 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9700 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 758: -#line 4232 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4256 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.identifier) = new CPPIdentifier("override", (yylsp[0])); } -#line 9682 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9708 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 759: -#line 4240 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4264 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = new CPPExpression((yyvsp[0].str)); } -#line 9690 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9716 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 760: -#line 4244 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4268 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { (yyval.u.expr) = (yyvsp[0].u.expr); } -#line 9698 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9724 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 761: -#line 4248 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4272 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // The right string takes on the literal type of the left. (yyval.u.expr) = (yyvsp[-1].u.expr); (yyval.u.expr)->_str += (yyvsp[0].str); } -#line 9708 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9734 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; case 762: -#line 4254 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ +#line 4278 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1648 */ { // We have to check that the two literal types match up. (yyval.u.expr) = (yyvsp[-1].u.expr); @@ -9719,11 +9743,11 @@ yyreduce: } (yyval.u.expr)->_str += (yyvsp[0].u.expr)->_str; } -#line 9721 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9747 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ break; -#line 9725 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ +#line 9751 "built/tmp/cppBison.yxx.c" /* yacc.c:1648 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -9846,7 +9870,6 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[1] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); diff --git a/dtool/src/cppparser/cppBison.h.prebuilt b/dtool/src/cppparser/cppBison.h.prebuilt index a2ec1fca8c..c33ce691eb 100644 --- a/dtool/src/cppparser/cppBison.h.prebuilt +++ b/dtool/src/cppparser/cppBison.h.prebuilt @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.0.5. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index 5c2721eea7..5a82fa5d9f 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -1185,14 +1185,27 @@ constructor_prototype: /* Functions with implicit return types, and constructors */ IDENTIFIER '(' { - push_scope($1->get_scope(current_scope, global_scope)); + // Create a scope for this function. + CPPScope *scope = new CPPScope($1->get_scope(current_scope, global_scope), + $1->_names.back(), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } function_parameter_list ')' function_post { + CPPScope *scope = $1->get_scope(current_scope, global_scope); CPPType *type; - if ($1->get_simple_name() == current_scope->get_simple_name() || - $1->get_simple_name() == string("~") + current_scope->get_simple_name()) { - // This is a constructor, and has no return. + std::string simple_name = $1->get_simple_name(); + if (!simple_name.empty() && simple_name[0] == '~') { + // A destructor has no return type. + type = new CPPSimpleType(CPPSimpleType::T_void); + } else if (scope != nullptr && simple_name == scope->get_simple_name()) { + // Neither does a constructor. type = new CPPSimpleType(CPPSimpleType::T_void); } else { // This isn't a constructor, so it has an implicit return type of @@ -1209,7 +1222,16 @@ constructor_prototype: } | TYPENAME_IDENTIFIER '(' { - push_scope($1->get_scope(current_scope, global_scope)); + // Create a scope for this function. + CPPScope *scope = new CPPScope($1->get_scope(current_scope, global_scope), + $1->_names.back(), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } function_parameter_list ')' function_post { From 0cd69c8748340a4bdeeb63d7852244a01d2552eb Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 31 Jul 2018 14:56:04 +0200 Subject: [PATCH 108/360] gobj: fix TexturePool ambiguity when loading tex with other settings Previously, if you called load_texture a second time with different parameters (such as an alpha filename), you would still get the old texture. --- panda/src/gobj/texturePool.I | 20 +++ panda/src/gobj/texturePool.cxx | 239 ++++++++++++++++++--------------- panda/src/gobj/texturePool.h | 13 +- 3 files changed, 160 insertions(+), 112 deletions(-) diff --git a/panda/src/gobj/texturePool.I b/panda/src/gobj/texturePool.I index 6ff48f14d3..1c25485f51 100644 --- a/panda/src/gobj/texturePool.I +++ b/panda/src/gobj/texturePool.I @@ -275,3 +275,23 @@ PT(Texture) TexturePool:: make_texture(const std::string &extension) { return get_global_ptr()->ns_make_texture(extension); } + +/** + * Defines relative ordering between LookupKey instances. + */ +INLINE bool TexturePool::LookupKey:: +operator < (const LookupKey &other) const { + if (_fullpath != other._fullpath) { + return _fullpath < other._fullpath; + } + if (_alpha_fullpath != other._alpha_fullpath) { + return _alpha_fullpath < other._alpha_fullpath; + } + if (_primary_file_num_channels != other._primary_file_num_channels) { + return _primary_file_num_channels < other._primary_file_num_channels; + } + if (_alpha_file_channel != other._alpha_file_channel) { + return _alpha_file_channel < other._alpha_file_channel; + } + return _texture_type < other._texture_type; +} diff --git a/panda/src/gobj/texturePool.cxx b/panda/src/gobj/texturePool.cxx index d62b68b377..c09df1d9e3 100644 --- a/panda/src/gobj/texturePool.cxx +++ b/panda/src/gobj/texturePool.cxx @@ -177,16 +177,23 @@ bool TexturePool:: ns_has_texture(const Filename &orig_filename) { MutexHolder holder(_lock); - Filename filename; - resolve_filename(filename, orig_filename, false, LoaderOptions()); + LookupKey key; + resolve_filename(key._fullpath, orig_filename, false, LoaderOptions()); Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. return true; } + // It might still have been loaded with non-standard settings. + for (ti = _textures.begin(); ti != _textures.end(); ++ti) { + if (ti->first._fullpath == key._fullpath) { + return true; + } + } + return false; } @@ -196,13 +203,14 @@ ns_has_texture(const Filename &orig_filename) { Texture *TexturePool:: ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, bool read_mipmaps, const LoaderOptions &options) { - Filename filename; - + LookupKey key; + key._primary_file_num_channels = primary_file_num_channels; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); + Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. Texture *tex = (*ti).second; @@ -222,54 +230,54 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading texture " << filename << "\n"; + << "Loading texture " << key._fullpath << "\n"; - string ext = downcase(filename.get_extension()); + string ext = downcase(key._fullpath.get_extension()); if (ext == "txo" || ext == "bam") { // Assume this is a txo file, which might conceivably contain a movie // file or some other subclass of Texture. In that case, use // make_from_txo() to load it instead of read(). VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - filename.set_binary(); - PT(VirtualFile) file = vfs->get_file(filename); + key._fullpath.set_binary(); + PT(VirtualFile) file = vfs->get_file(key._fullpath); if (file == nullptr) { // No such file. gobj_cat.error() - << "Could not find " << filename << "\n"; + << "Could not find " << key._fullpath << "\n"; return nullptr; } if (gobj_cat.is_debug()) { gobj_cat.debug() - << "Reading texture object " << filename << "\n"; + << "Reading texture object " << key._fullpath << "\n"; } istream *in = file->open_read_file(true); - tex = Texture::make_from_txo(*in, filename); + tex = Texture::make_from_txo(*in, key._fullpath); vfs->close_read_file(in); if (tex == nullptr) { return nullptr; } - tex->set_fullpath(filename); + tex->set_fullpath(key._fullpath); tex->clear_alpha_fullpath(); tex->set_keep_ram_image(false); } else { // Read it the conventional way. tex = ns_make_texture(ext); - if (!tex->read(filename, Filename(), primary_file_num_channels, 0, + if (!tex->read(key._fullpath, Filename(), primary_file_num_channels, 0, 0, 0, false, read_mipmaps, record, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } } @@ -304,8 +312,8 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, // Set the original filename, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(orig_filename); - tex->set_fullpath(filename); - tex->_texture_pool_key = filename; + tex->set_fullpath(key._fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); @@ -313,7 +321,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, // Now look again--someone may have just loaded this texture in another // thread. Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. Texture *tex = (*ti).second; @@ -321,7 +329,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, return tex; } - _textures[filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -357,16 +365,16 @@ ns_load_texture(const Filename &orig_filename, read_mipmaps, options); } - Filename filename; - Filename alpha_filename; - + LookupKey key; + key._primary_file_num_channels = primary_file_num_channels; + key._alpha_file_channel = alpha_file_channel; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); - resolve_filename(alpha_filename, orig_alpha_filename, read_mipmaps, options); + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); + resolve_filename(key._alpha_fullpath, orig_alpha_filename, read_mipmaps, options); Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. Texture *tex = (*ti).second; @@ -380,26 +388,26 @@ ns_load_texture(const Filename &orig_filename, bool store_record = false; // Can one of our texture filters supply the texture? - tex = pre_load(orig_filename, alpha_filename, primary_file_num_channels, + tex = pre_load(orig_filename, orig_alpha_filename, primary_file_num_channels, alpha_file_channel, read_mipmaps, options); BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading texture " << filename << " and alpha component " - << alpha_filename << std::endl; - tex = ns_make_texture(filename.get_extension()); - if (!tex->read(filename, alpha_filename, primary_file_num_channels, + << "Loading texture " << key._fullpath << " and alpha component " + << key._alpha_fullpath << std::endl; + tex = ns_make_texture(key._fullpath.get_extension()); + if (!tex->read(key._fullpath, key._alpha_fullpath, primary_file_num_channels, alpha_file_channel, 0, 0, false, read_mipmaps, nullptr, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } @@ -433,17 +441,17 @@ ns_load_texture(const Filename &orig_filename, // Set the original filenames, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(orig_filename); - tex->set_fullpath(filename); + tex->set_fullpath(key._fullpath); tex->set_alpha_filename(orig_alpha_filename); - tex->set_alpha_fullpath(alpha_filename); - tex->_texture_pool_key = filename; + tex->set_alpha_fullpath(key._alpha_fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. Texture *tex = (*ti).second; @@ -451,7 +459,7 @@ ns_load_texture(const Filename &orig_filename, return tex; } - _textures[filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -482,18 +490,19 @@ ns_load_3d_texture(const Filename &filename_pattern, Filename orig_filename(filename_pattern); orig_filename.set_pattern(true); - Filename filename; + LookupKey key; + key._texture_type = Texture::TT_3d_texture; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { - if ((*ti).second->get_texture_type() == Texture::TT_3d_texture) { - // This texture was previously loaded, as a 3d texture - return (*ti).second; - } + // This texture was previously loaded. + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } } @@ -503,7 +512,7 @@ ns_load_3d_texture(const Filename &filename_pattern, BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr || @@ -511,12 +520,12 @@ ns_load_3d_texture(const Filename &filename_pattern, // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading 3-d texture " << filename << "\n"; - tex = ns_make_texture(filename.get_extension()); + << "Loading 3-d texture " << key._fullpath << "\n"; + tex = ns_make_texture(key._fullpath.get_extension()); tex->setup_3d_texture(); - if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { + if (!tex->read(key._fullpath, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } store_record = (record != nullptr); @@ -545,23 +554,23 @@ ns_load_3d_texture(const Filename &filename_pattern, // Set the original filename, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); - tex->set_fullpath(filename); - tex->_texture_pool_key = filename; + tex->set_fullpath(key._fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { - if ((*ti).second->get_texture_type() == Texture::TT_3d_texture) { - // This texture was previously loaded, as a 3d texture - return (*ti).second; - } + // This texture was previously loaded. + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } - _textures[filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -583,21 +592,19 @@ ns_load_2d_texture_array(const Filename &filename_pattern, Filename orig_filename(filename_pattern); orig_filename.set_pattern(true); - Filename filename; - Filename unique_filename; //differentiate 3d-textures from 2d-texture arrays + LookupKey key; + key._texture_type = Texture::TT_2d_texture_array; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); - // Differentiate from preloaded 3d textures - unique_filename = filename + ".2DARRAY"; + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); Textures::const_iterator ti; - ti = _textures.find(unique_filename); + ti = _textures.find(key); if (ti != _textures.end()) { - if ((*ti).second->get_texture_type() == Texture::TT_2d_texture_array) { - // This texture was previously loaded, as a 2d texture array - return (*ti).second; - } + // This texture was previously loaded. + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } } @@ -607,7 +614,7 @@ ns_load_2d_texture_array(const Filename &filename_pattern, BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr || @@ -615,12 +622,12 @@ ns_load_2d_texture_array(const Filename &filename_pattern, // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading 2-d texture array " << filename << "\n"; - tex = ns_make_texture(filename.get_extension()); + << "Loading 2-d texture array " << key._fullpath << "\n"; + tex = ns_make_texture(key._fullpath.get_extension()); tex->setup_2d_texture_array(); - if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { + if (!tex->read(key._fullpath, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } store_record = (record != nullptr); @@ -649,23 +656,23 @@ ns_load_2d_texture_array(const Filename &filename_pattern, // Set the original filename, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); - tex->set_fullpath(filename); - tex->_texture_pool_key = unique_filename; + tex->set_fullpath(key._fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; - ti = _textures.find(unique_filename); + ti = _textures.find(key); if (ti != _textures.end()) { - if ((*ti).second->get_texture_type() == Texture::TT_2d_texture_array) { - // This texture was previously loaded, as a 2d texture array - return (*ti).second; - } + // This texture was previously loaded. + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } - _textures[unique_filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -687,16 +694,19 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, Filename orig_filename(filename_pattern); orig_filename.set_pattern(true); - Filename filename; + LookupKey key; + key._texture_type = Texture::TT_cube_map; { MutexHolder holder(_lock); - resolve_filename(filename, orig_filename, read_mipmaps, options); + resolve_filename(key._fullpath, orig_filename, read_mipmaps, options); Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. - return (*ti).second; + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } } @@ -706,7 +716,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, BamCache *cache = BamCache::get_global_ptr(); bool compressed_cache_record = false; - try_load_cache(tex, cache, filename, record, compressed_cache_record, + try_load_cache(tex, cache, key._fullpath, record, compressed_cache_record, options); if (tex == nullptr || @@ -714,12 +724,12 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() - << "Loading cube map texture " << filename << "\n"; - tex = ns_make_texture(filename.get_extension()); + << "Loading cube map texture " << key._fullpath << "\n"; + tex = ns_make_texture(key._fullpath.get_extension()); tex->setup_cube_map(); - if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { + if (!tex->read(key._fullpath, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. - report_texture_unreadable(filename); + report_texture_unreadable(key._fullpath); return nullptr; } store_record = (record != nullptr); @@ -748,21 +758,23 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, // Set the original filename, before we searched along the path. nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); - tex->set_fullpath(filename); - tex->_texture_pool_key = filename; + tex->set_fullpath(key._fullpath); + tex->_texture_pool_key = key._fullpath; { MutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; - ti = _textures.find(filename); + ti = _textures.find(key); if (ti != _textures.end()) { // This texture was previously loaded. - return (*ti).second; + Texture *tex = (*ti).second; + nassertr(!tex->get_fullpath().empty(), tex); + return tex; } - _textures[filename] = tex; + _textures[std::move(key)] = tex; } if (store_record && tex->is_cacheable()) { @@ -819,15 +831,22 @@ ns_add_texture(Texture *tex) { if (!tex->_texture_pool_key.empty()) { ns_release_texture(tex); } - string filename = tex->get_fullpath(); - if (filename.empty()) { + + Texture::CDReader tex_cdata(tex->_cycler); + if (tex_cdata->_fullpath.empty()) { gobj_cat.error() << "Attempt to call add_texture() on an unnamed texture.\n"; + return; } + LookupKey key; + key._fullpath = tex_cdata->_fullpath; + key._alpha_fullpath = tex_cdata->_alpha_fullpath; + key._alpha_file_channel = tex_cdata->_alpha_file_channel; + key._texture_type = tex_cdata->_texture_type; + // We blow away whatever texture was there previously, if any. - tex->_texture_pool_key = filename; - _textures[filename] = tex; - nassertv(!tex->get_fullpath().empty()); + tex->_texture_pool_key = key._fullpath; + _textures[key] = tex; } /** @@ -837,13 +856,13 @@ void TexturePool:: ns_release_texture(Texture *tex) { MutexHolder holder(_lock); - if (!tex->_texture_pool_key.empty()) { - Textures::iterator ti; - ti = _textures.find(tex->_texture_pool_key); - if (ti != _textures.end() && (*ti).second == tex) { + Textures::iterator ti; + for (ti = _textures.begin(); ti != _textures.end(); ++ti) { + if (tex == (*ti).second) { _textures.erase(ti); + tex->_texture_pool_key = string(); + break; } - tex->_texture_pool_key = string(); } // Blow away the cache of resolved relative filenames. @@ -886,7 +905,7 @@ ns_garbage_collect() { if (tex->get_ref_count() == 1) { if (gobj_cat.is_debug()) { gobj_cat.debug() - << "Releasing " << (*ti).first << "\n"; + << "Releasing " << (*ti).first._fullpath << "\n"; } ++num_released; tex->_texture_pool_key = string(); @@ -927,14 +946,14 @@ ns_list_contents(ostream &out) const { total_ram_size = 0; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { Texture *tex = (*ti).second; - out << (*ti).first << "\n"; + out << (*ti).first._fullpath << "\n"; out << " (count = " << tex->get_ref_count() << ", ram = " << tex->get_ram_image_size() << ", size = " << tex->get_ram_page_size() << ", w = " << tex->get_x_size() << ", h = " << tex->get_y_size() << ")\n"; - nassertv(tex->_texture_pool_key == (*ti).first); + nassertv(tex->_texture_pool_key == (*ti).first._fullpath); total_ram_size += tex->get_ram_image_size(); total_size += tex->get_ram_page_size(); } diff --git a/panda/src/gobj/texturePool.h b/panda/src/gobj/texturePool.h index 866374ec96..de6812e4d5 100644 --- a/panda/src/gobj/texturePool.h +++ b/panda/src/gobj/texturePool.h @@ -149,8 +149,17 @@ private: static TexturePool *_global_ptr; Mutex _lock; - typedef pmap Textures; - Textures _textures; // indexed by fullpath + struct LookupKey { + Filename _fullpath; + Filename _alpha_fullpath; + int _primary_file_num_channels = 0; + int _alpha_file_channel = 0; + Texture::TextureType _texture_type = Texture::TT_2d_texture; + + INLINE bool operator < (const LookupKey &other) const; + }; + typedef pmap Textures; + Textures _textures; typedef pmap RelpathLookup; RelpathLookup _relpath_lookup; From 4b8ff0573e8b912591d02062e1240c2726e09323 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 31 Jul 2018 14:57:55 +0200 Subject: [PATCH 109/360] tests: add TexturePool unit tests --- tests/gobj/test_texture_pool.py | 196 ++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 tests/gobj/test_texture_pool.py diff --git a/tests/gobj/test_texture_pool.py b/tests/gobj/test_texture_pool.py new file mode 100644 index 0000000000..b07e8a0cb9 --- /dev/null +++ b/tests/gobj/test_texture_pool.py @@ -0,0 +1,196 @@ +from panda3d import core +import pytest +import tempfile + +@pytest.fixture(scope='function') +def pool(): + "This fixture ensures the pool is properly emptied" + pool = core.TexturePool + pool.release_all_textures() + yield pool + pool.release_all_textures() + + +def write_image(filename, channels): + img = core.PNMImage(1, 1, channels) + img.set_xel_a(0, 0, (0.0, 0.25, 0.5, 0.75)) + assert img.write(filename) + + +@pytest.fixture(scope='session') +def image_rgb_path(): + "Generates an RGB image." + + file = tempfile.NamedTemporaryFile(suffix='-rgb.png') + write_image(file.name, 3) + yield file.name + file.close() + + +@pytest.fixture(scope='session') +def image_rgba_path(): + "Generates an RGBA image." + + file = tempfile.NamedTemporaryFile(suffix='-rgba.png') + write_image(file.name, 4) + yield file.name + file.close() + + +@pytest.fixture(scope='session') +def image_gray_path(): + "Generates a grayscale image." + + file = tempfile.NamedTemporaryFile(suffix='-gray.png') + write_image(file.name, 1) + yield file.name + file.close() + + +def test_load_texture_rgba(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 4 + + +def test_load_texture_rgba4(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 4) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 4 + + +def test_load_texture_rgba3(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 3) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 3 + + +def test_load_texture_rgba2(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 2) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 2 + + +def test_load_texture_rgba1(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 1) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 1 + + +def test_load_texture_rgb(pool, image_rgb_path): + tex = pool.load_texture(image_rgb_path) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + +def test_load_texture_rgb4(pool, image_rgb_path): + # Will not increase this + tex = pool.load_texture(image_rgb_path, 4) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + +def test_load_texture_rgb3(pool, image_rgb_path): + tex = pool.load_texture(image_rgb_path, 3) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + +def test_load_texture_rgb2(pool, image_rgb_path): + # Cannot reduce this, since it would add an alpha channel + tex = pool.load_texture(image_rgb_path, 2) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + +def test_load_texture_rgb1(pool, image_rgb_path): + tex = pool.load_texture(image_rgb_path, 1) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 1 + + +def test_load_texture_rgba_alpha(pool, image_rgba_path, image_gray_path): + tex = pool.load_texture(image_rgba_path, image_gray_path) + assert tex.num_components == 4 + + +def test_load_texture_rgba4_alpha(pool, image_rgba_path, image_gray_path): + tex = pool.load_texture(image_rgba_path, image_gray_path, 4) + assert tex.num_components == 4 + + +def test_load_texture_rgba3_alpha(pool, image_rgba_path, image_gray_path): + tex = pool.load_texture(image_rgba_path, image_gray_path, 3) + assert tex.num_components == 4 + + +def test_load_texture_rgba2_alpha(pool, image_rgba_path, image_gray_path): + #FIXME: why is this not consistent with test_load_texture_rgb2_alpha? + tex = pool.load_texture(image_rgba_path, image_gray_path, 2) + assert tex.num_components == 2 + + +def test_load_texture_rgba1_alpha(pool, image_rgba_path, image_gray_path): + tex = pool.load_texture(image_rgba_path, image_gray_path, 1) + assert tex.num_components == 2 + + +def test_load_texture_rgb_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path) + assert tex.num_components == 4 + + +def test_load_texture_rgb4_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path, 4) + assert tex.num_components == 4 + + +def test_load_texture_rgb3_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path, 3) + assert tex.num_components == 4 + + +def test_load_texture_rgb2_alpha(pool, image_rgb_path, image_gray_path): + #FIXME: why is this not consistent with test_load_texture_rgba2_alpha? + tex = pool.load_texture(image_rgb_path, image_gray_path, 2) + assert tex.num_components == 4 + + +def test_load_texture_rgb1_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path, 1) + assert tex.num_components == 2 + + +def test_reload_texture_fewer_channels(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 4 + + tex = pool.load_texture(image_rgba_path, 3) + assert tex.num_components == 3 + + +def test_reload_texture_more_channels(pool, image_rgba_path): + tex = pool.load_texture(image_rgba_path, 3) + assert pool.has_texture(image_rgba_path) + assert tex.num_components == 3 + + tex = pool.load_texture(image_rgba_path) + assert tex.num_components == 4 + + +def test_reload_texture_with_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path) + assert pool.has_texture(image_rgb_path) + assert tex.num_components == 3 + + tex = pool.load_texture(image_rgb_path, image_gray_path) + assert tex.num_components == 4 + + +def test_reload_texture_without_alpha(pool, image_rgb_path, image_gray_path): + tex = pool.load_texture(image_rgb_path, image_gray_path) + assert tex.num_components == 4 + + tex = pool.load_texture(image_rgb_path) + assert tex.num_components == 3 From 2b7ef93e2f2acad2762b2be31f72df7c7bd4dd33 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 2 Aug 2018 20:28:07 +0200 Subject: [PATCH 110/360] travis: set skip_join to false The IRC channel had +n mode set to it due to spam problems, which disallows external send. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 582c7fd62f..9de0326d78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,4 +51,4 @@ notifications: on_success: change on_failure: always use_notice: true - skip_join: true + skip_join: false From f813d2fb60f13405e9973ac10552d41b2fdac757 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 2 Aug 2018 20:29:48 +0200 Subject: [PATCH 111/360] stdpy: fix broken threading.Event --- direct/src/stdpy/threading.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/direct/src/stdpy/threading.py b/direct/src/stdpy/threading.py index 466a198a3a..45409f9e18 100644 --- a/direct/src/stdpy/threading.py +++ b/direct/src/stdpy/threading.py @@ -312,7 +312,7 @@ class Event: object. """ def __init__(self): - self.__lock = core.Lock("Python Event") + self.__lock = core.Mutex("Python Event") self.__cvar = core.ConditionVarFull(self.__lock) self.__flag = False @@ -325,7 +325,7 @@ class Event: self.__lock.acquire() try: self.__flag = True - self.__cvar.signalAll() + self.__cvar.notifyAll() finally: self.__lock.release() From 0fbfeb712fc3303ce235e77a9ee6b539cba35b36 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 2 Aug 2018 20:30:54 +0200 Subject: [PATCH 112/360] ParticlePanel: comment out unimplemented OrientedParticleFactory --- direct/src/tkpanels/ParticlePanel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/direct/src/tkpanels/ParticlePanel.py b/direct/src/tkpanels/ParticlePanel.py index 81d00aefc9..9c4ba56a79 100644 --- a/direct/src/tkpanels/ParticlePanel.py +++ b/direct/src/tkpanels/ParticlePanel.py @@ -263,7 +263,8 @@ class ParticlePanel(AppShell): 'Factory', 'Factory Type', 'Select type of particle factory', ('PointParticleFactory', 'ZSpinParticleFactory', - 'OrientedParticleFactory'), + #'OrientedParticleFactory' + ), self.selectFactoryType) factoryWidgets = ( ('Factory', 'Life Span', From 2a2b48134b8008417887d4f175f50e63dd4ba415 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 2 Aug 2018 21:24:37 +0200 Subject: [PATCH 113/360] parser-inc: fix bad socklen_t definition in ws2tcpip.h --- dtool/src/parser-inc/ws2tcpip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/parser-inc/ws2tcpip.h b/dtool/src/parser-inc/ws2tcpip.h index 49262434c5..002bb035b5 100644 --- a/dtool/src/parser-inc/ws2tcpip.h +++ b/dtool/src/parser-inc/ws2tcpip.h @@ -1 +1 @@ -typedef DWORD socklen_t; +typedef int socklen_t; From c959d274be1cf3eee4320454a16e4c266a5a4f00 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Aug 2018 20:22:09 +0200 Subject: [PATCH 114/360] makewheel: add __version__ and docstring to panda3d/__init__.py --- makepanda/makewheel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index f727f10e73..e490f1c05e 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -488,7 +488,10 @@ def makewheel(version, output_dir, platform=default_platform): # Write the panda3d tree. We use a custom empty __init__ since the # default one adds the bin directory to the PATH, which we don't have. - whl.write_file_data('panda3d/__init__.py', '') + whl.write_file_data('panda3d/__init__.py', """"Python bindings for the Panda3D libraries" + +__version__ = '{0}' +""".format(version)) ext_suffix = GetExtensionSuffix() From 668a093c26f3b4f7873d65c224d38f1b751646e9 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Aug 2018 20:45:29 +0200 Subject: [PATCH 115/360] gobj: try to fix some deadlocks modifying geometry while rendering The correct locking order should be: the Geom's GeomVertexArrayData first, *then* the GeomPrimitive. --- panda/src/cull/cullBinBackToFront.cxx | 5 ++- panda/src/cull/cullBinFixed.cxx | 5 ++- panda/src/cull/cullBinFrontToBack.cxx | 5 ++- panda/src/cull/cullBinStateSorted.cxx | 5 ++- panda/src/cull/cullBinUnsorted.cxx | 8 ++-- panda/src/gobj/geom.cxx | 61 +++++++++++++++++++++------ panda/src/gobj/geomPrimitive.I | 14 ++++-- panda/src/gobj/geomPrimitive.h | 1 + 8 files changed, 76 insertions(+), 28 deletions(-) diff --git a/panda/src/cull/cullBinBackToFront.cxx b/panda/src/cull/cullBinBackToFront.cxx index 00c6ba7c32..c27c7e8ed4 100644 --- a/panda/src/cull/cullBinBackToFront.cxx +++ b/panda/src/cull/cullBinBackToFront.cxx @@ -96,9 +96,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/cull/cullBinFixed.cxx b/panda/src/cull/cullBinFixed.cxx index 557b3435a3..3507ce4582 100644 --- a/panda/src/cull/cullBinFixed.cxx +++ b/panda/src/cull/cullBinFixed.cxx @@ -82,9 +82,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/cull/cullBinFrontToBack.cxx b/panda/src/cull/cullBinFrontToBack.cxx index 4337b42d7c..5f5d99e51c 100644 --- a/panda/src/cull/cullBinFrontToBack.cxx +++ b/panda/src/cull/cullBinFrontToBack.cxx @@ -96,9 +96,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/cull/cullBinStateSorted.cxx b/panda/src/cull/cullBinStateSorted.cxx index ad4d26cd12..3e2fca2e9a 100644 --- a/panda/src/cull/cullBinStateSorted.cxx +++ b/panda/src/cull/cullBinStateSorted.cxx @@ -81,9 +81,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/cull/cullBinUnsorted.cxx b/panda/src/cull/cullBinUnsorted.cxx index 14766f9bbd..0f37ae97b0 100644 --- a/panda/src/cull/cullBinUnsorted.cxx +++ b/panda/src/cull/cullBinUnsorted.cxx @@ -55,9 +55,6 @@ void CullBinUnsorted:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi); @@ -66,9 +63,10 @@ draw(bool force, Thread *current_thread) { nassertd(object->_geom != nullptr) continue; _gsg->set_state_and_transform(object->_state, object->_internal_transform); - data_reader.set_object(object->_munged_data); + + GeomPipelineReader geom_reader(object->_geom, current_thread); + GeomVertexDataPipelineReader data_reader(object->_munged_data, current_thread); data_reader.check_array_readers(); - geom_reader.set_object(object->_geom); geom_reader.draw(_gsg, &data_reader, force); } else { // It has a callback associated. diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 5cf18838d8..565f8c47b4 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -195,6 +195,9 @@ offset_vertices(const GeomVertexData *data, int offset) { cdata->_data = (GeomVertexData *)data; #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(data, current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -203,7 +206,7 @@ offset_vertices(const GeomVertexData *data, int offset) { prim->offset_vertices(offset); #ifndef NDEBUG - if (!prim->check_valid(data)) { + if (!prim->check_valid(&data_reader)) { gobj_cat.warning() << *prim << " is invalid for " << *data << ":\n"; prim->write(gobj_cat.warning(false), 4); @@ -423,6 +426,9 @@ decompose_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -431,7 +437,7 @@ decompose_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -457,6 +463,9 @@ doubleside_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -465,7 +474,7 @@ doubleside_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -491,6 +500,9 @@ reverse_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -499,7 +511,7 @@ reverse_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -525,6 +537,9 @@ rotate_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -533,7 +548,7 @@ rotate_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -640,6 +655,9 @@ unify_in_place(int max_indices, bool preserve_order) { // primitives.) nassertv(false); } + + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); #endif // Finally, iterate through the remaining primitives, and copy them to the @@ -649,7 +667,7 @@ unify_in_place(int max_indices, bool preserve_order) { for (npi = new_prims.begin(); npi != new_prims.end(); ++npi) { GeomPrimitive *prim = (*npi).second; - nassertv(prim->check_valid(cdata->_data.get_read_pointer(current_thread))); + nassertv(prim->check_valid(&data_reader)); // Each new primitive, naturally, inherits the Geom's overall shade model. prim->set_shade_model(cdata->_shade_model); @@ -748,6 +766,9 @@ make_lines_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -756,7 +777,7 @@ make_lines_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -782,6 +803,9 @@ make_points_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -790,7 +814,7 @@ make_points_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -816,6 +840,9 @@ make_patches_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -824,7 +851,7 @@ make_patches_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -850,6 +877,9 @@ make_adjacency_in_place() { CDWriter cdata(_cycler, true, current_thread); #ifndef NDEBUG + GeomVertexDataPipelineReader data_reader(cdata->_data.get_read_pointer(current_thread), current_thread); + data_reader.check_array_readers(); + bool all_is_valid = true; #endif Primitives::iterator pi; @@ -859,7 +889,7 @@ make_adjacency_in_place() { (*pi) = (GeomPrimitive *)new_prim.p(); #ifndef NDEBUG - if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + if (!new_prim->check_valid(&data_reader)) { all_is_valid = false; } #endif @@ -1465,13 +1495,20 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { */ bool Geom:: check_will_be_valid(const GeomVertexData *vertex_data) const { - CDReader cdata(_cycler); + Thread *current_thread = Thread::get_current_thread(); + + CDReader cdata(_cycler, current_thread); + + GeomVertexDataPipelineReader data_reader(vertex_data, current_thread); + data_reader.check_array_readers(); Primitives::const_iterator pi; for (pi = cdata->_primitives.begin(); pi != cdata->_primitives.end(); ++pi) { - if (!(*pi).get_read_pointer()->check_valid(vertex_data)) { + GeomPrimitivePipelineReader reader((*pi).get_read_pointer(), current_thread); + reader.check_minmax(); + if (!reader.check_valid(&data_reader)) { return false; } } diff --git a/panda/src/gobj/geomPrimitive.I b/panda/src/gobj/geomPrimitive.I index 0984dbecb3..f314c81090 100644 --- a/panda/src/gobj/geomPrimitive.I +++ b/panda/src/gobj/geomPrimitive.I @@ -223,11 +223,19 @@ get_modified() const { INLINE bool GeomPrimitive:: check_valid(const GeomVertexData *vertex_data) const { Thread *current_thread = Thread::get_current_thread(); - GeomPrimitivePipelineReader reader(this, current_thread); - reader.check_minmax(); GeomVertexDataPipelineReader data_reader(vertex_data, current_thread); data_reader.check_array_readers(); - return reader.check_valid(&data_reader); + return check_valid(&data_reader); +} + +/** + * + */ +INLINE bool GeomPrimitive:: +check_valid(const GeomVertexDataPipelineReader *data_reader) const { + GeomPrimitivePipelineReader reader(this, data_reader->get_current_thread()); + reader.check_minmax(); + return reader.check_valid(data_reader); } /** diff --git a/panda/src/gobj/geomPrimitive.h b/panda/src/gobj/geomPrimitive.h index b8012507b8..392fffe1cf 100644 --- a/panda/src/gobj/geomPrimitive.h +++ b/panda/src/gobj/geomPrimitive.h @@ -146,6 +146,7 @@ PUBLISHED: bool request_resident(Thread *current_thread = Thread::get_current_thread()) const; INLINE bool check_valid(const GeomVertexData *vertex_data) const; + INLINE bool check_valid(const GeomVertexDataPipelineReader *data_reader) const; virtual void output(std::ostream &out) const; virtual void write(std::ostream &out, int indent_level) const; From 7e290b221bc58fd7bc496fcf3540920840dce4b2 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Aug 2018 21:05:12 +0200 Subject: [PATCH 116/360] Remove a few unused and obsolete C++ test files --- makepanda/makepanda.vcproj | 3 -- panda/src/collide/test_collide.cxx | 70 --------------------------- panda/src/gobj/test_gobj.cxx | 25 ---------- panda/src/testbed/text_test.cxx | 78 ------------------------------ 4 files changed, 176 deletions(-) delete mode 100644 panda/src/collide/test_collide.cxx delete mode 100644 panda/src/gobj/test_gobj.cxx delete mode 100644 panda/src/testbed/text_test.cxx diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj index 23ed91cdf5..6be22d7d1a 100644 --- a/makepanda/makepanda.vcproj +++ b/makepanda/makepanda.vcproj @@ -760,7 +760,6 @@ - @@ -1114,7 +1113,6 @@ - @@ -3705,7 +3703,6 @@ - diff --git a/panda/src/collide/test_collide.cxx b/panda/src/collide/test_collide.cxx deleted file mode 100644 index 38736d5d38..0000000000 --- a/panda/src/collide/test_collide.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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." - * - * @file test_collide.cxx - * @author drose - * @date 2000-04-24 - */ - -#include "collisionTraverser.h" -#include "collisionNode.h" -#include "collisionSphere.h" -#include "collisionPlane.h" -#include "collisionHandlerPusher.h" - -#include "namedNode.h" -#include "pt_NamedNode.h" -#include "pointerTo.h" -#include "transformTransition.h" -#include "luse.h" -#include "get_rel_pos.h" -#include "renderRelation.h" - -int -main(int argc, char *argv[]) { - PT_NamedNode r = new NamedNode("r"); - - PT_NamedNode a = new NamedNode("a"); - PT_NamedNode b = new NamedNode("b"); - - PT(CollisionNode) aa = new CollisionNode("aa"); - PT(CollisionNode) ab = new CollisionNode("ab"); - PT(CollisionNode) ba = new CollisionNode("ba"); - - RenderRelation *r_a = new RenderRelation(r, a); - RenderRelation *r_b = new RenderRelation(r, b); - - RenderRelation *a_aa = new RenderRelation(a, aa); - RenderRelation *a_ab = new RenderRelation(a, ab); - RenderRelation *b_ba = new RenderRelation(b, ba); - - - CollisionSphere *aa1 = new CollisionSphere(LPoint3f(0, 0, 0), 1); - aa->add_solid(aa1); - a_aa->set_transition(new TransformTransition(LMatrix4f::translate_mat(0, -5, 0))); - - CollisionSphere *ab1 = new CollisionSphere(LPoint3f(0, 2, 0), 1.5); - ab->add_solid(ab1); - - Planef plane(LVector3f(0, 1, 0), LPoint3f(0, 0, 0)); - CollisionPlane *ba1 = new CollisionPlane(plane); - ba->add_solid(ba1); - - CollisionTraverser ct; - PT(CollisionHandlerPusher) chp = new CollisionHandlerPusher; - chp->add_collider(aa, a_aa); - ct.add_collider(aa, chp); - - ct.traverse(r); - - nout << "\nFrame 2:\n\n"; - - ct.traverse(r); - - return (0); -} diff --git a/panda/src/gobj/test_gobj.cxx b/panda/src/gobj/test_gobj.cxx deleted file mode 100644 index 0bbe93e907..0000000000 --- a/panda/src/gobj/test_gobj.cxx +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 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." - * - * @file test_gobj.cxx - * @author shochet - * @date 2000-02-02 - */ - -#include "geom.h" -#include "perspectiveProjection.h" - -int main() { - nout << "running test_gobj" << std::endl; - PT(GeomTri) triangle = new GeomTri; - Frustumf frust; - PT(PerspectiveProjection) proj = new PerspectiveProjection(frust); - LMatrix4f mat = proj->get_projection_mat(); - nout << "default proj matrix: " << mat; - return 0; -} diff --git a/panda/src/testbed/text_test.cxx b/panda/src/testbed/text_test.cxx deleted file mode 100644 index f0689940ad..0000000000 --- a/panda/src/testbed/text_test.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/** - * 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." - * - * @file text_test.cxx - */ - -#include "eventHandler.h" -#include "chancfg.h" -#include "textNode.h" -#include "eggLoader.h" -#include "pnotify.h" -#include "pt_NamedNode.h" - -extern PT_NamedNode render; -extern PT_NamedNode egg_root; -extern EventHandler event_handler; - -extern int framework_main(int argc, char *argv[]); -extern void (*define_keys)(EventHandler&); - -PT(TextNode) text_node; -char *textStr; - -void event_p(CPT_Event) { - text_node->set_text("I'm a woo woo woo!"); - - nout << "text is " << text_node->get_width() << " by " - << text_node->get_height() << "\n"; -} - -void event_s(CPT_Event) { - text_node->set_wordwrap(5.0); - - nout << "text is " << text_node->get_width() << " by " - << text_node->get_height() << "\n"; -} - -void text_keys(EventHandler& eh) { - eh.add_hook("p", event_p); - eh.add_hook("s", event_s); - - text_node = new TextNode("text_node"); - PT_NamedNode font = loader.load_sync("cmr12"); - text_node->set_font(font.p()); - text_node->set_wordwrap(20.0); - text_node->set_card_as_margin(0.25, 0.25, 0.25, 0.25); - PT(Texture) tex = new Texture; - tex->set_name("genericButton.rgb"); - tex->set_minfilter(SamplerState::FT_linear); - tex->set_magfilter(SamplerState::FT_linear); - tex->read("/beta/toons/textures/smGreyButtonUp.rgb"); - text_node->set_card_texture( tex ); - text_node->set_card_border(0.1, 0.1); - text_node->set_text( textStr ); - text_node->set_text_color( 0.0, 0.0, 0.0, 1.0 ); - if (text_node->has_card_texture()) - nout << "I've got a texture!" << "\n"; - else - nout << "I don't have a texture..." << "\n"; - nout << "text is " << text_node->get_width() << " by " - << text_node->get_height() << "\n"; - - new RenderRelation(egg_root, text_node); -} - -int main(int argc, char *argv[]) { - define_keys = &text_keys; - if (argc > 1) - textStr = argv[1]; - else - textStr = argv[0]; - return framework_main(argc, argv); -} From 1e9a64fe6324d8b4ac96daafa7427e9f55e6dd38 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Aug 2018 21:10:26 +0200 Subject: [PATCH 117/360] tests: add Geom.decompose tests --- tests/gobj/test_geom.py | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/gobj/test_geom.py diff --git a/tests/gobj/test_geom.py b/tests/gobj/test_geom.py new file mode 100644 index 0000000000..2a5a462659 --- /dev/null +++ b/tests/gobj/test_geom.py @@ -0,0 +1,42 @@ +from panda3d import core + +empty_format = core.GeomVertexFormat.get_empty() + + +def test_geom_decompose_in_place(): + vertex_data = core.GeomVertexData("", empty_format, core.GeomEnums.UH_static) + prim = core.GeomTristrips(core.GeomEnums.UH_static) + prim.add_vertex(0) + prim.add_vertex(1) + prim.add_vertex(2) + prim.add_vertex(3) + prim.close_primitive() + + geom = core.Geom(vertex_data) + geom.add_primitive(prim) + + geom.decompose_in_place() + + prim = geom.get_primitive(0) + assert tuple(prim.get_vertex_list()) == (0, 1, 2, 2, 1, 3) + + +def test_geom_decompose(): + vertex_data = core.GeomVertexData("", empty_format, core.GeomEnums.UH_static) + prim = core.GeomTristrips(core.GeomEnums.UH_static) + prim.add_vertex(0) + prim.add_vertex(1) + prim.add_vertex(2) + prim.add_vertex(3) + prim.close_primitive() + + geom = core.Geom(vertex_data) + geom.add_primitive(prim) + + new_geom = geom.decompose() + + new_prim = new_geom.get_primitive(0) + assert tuple(new_prim.get_vertex_list()) == (0, 1, 2, 2, 1, 3) + + # Old primitive should still be unchanged + assert prim == geom.get_primitive(0) From 9ba2d7242e6ed91da981829b27f9842943cf8329 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Aug 2018 21:27:58 +0200 Subject: [PATCH 118/360] gobj: get rid of enforce-attrib-lock, just DTRT instead This setting causes asserts when modifying certain material flags after they are assigned to a node, in case a shader has been generated that uses the materials, which cannot efficiently detect whether the material has changed. However, we already sort of have a (inefficient, but effective) solution for this in TextureStage (see #178) that we could just apply here as well: changing the material attributes after such a shader has been generated could call GraphicsStateGuardianBase::mark_rehash_generated_shaders(). In the future, we should replace the material model with one that does not require shader regeneration for such seemingly trivial property changes. Fixes #370 --- panda/src/gobj/config_gobj.cxx | 12 ----- panda/src/gobj/config_gobj.h | 1 - panda/src/gobj/material.I | 58 ++++++++++++++++------ panda/src/gobj/material.cxx | 59 ++++++++++------------- panda/src/gobj/material.h | 6 +++ panda/src/pgraphnodes/shaderGenerator.cxx | 8 ++- 6 files changed, 80 insertions(+), 64 deletions(-) diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index b7d0e02eb5..7da3b1d31e 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -260,18 +260,6 @@ ConfigVariableBool cache_generated_shaders PRC_DESC("Set this true to cause all generated shaders to be cached in " "memory. This is useful to prevent unnecessary recompilation.")); -ConfigVariableBool enforce_attrib_lock -("enforce-attrib-lock", true, - PRC_DESC("When a MaterialAttrib, TextureAttrib, or LightAttrib is " - "constructed, the corresponding Material, Texture, or Light " - "is 'attrib locked.' The attrib lock prevents qualitative " - "changes to the object. This makes it possible to hardwire " - "information about material, light, and texture properties " - "into generated shaders. This config variable can disable " - "the attrib lock. Disabling the lock will break the shader " - "generator, but doing so may be necessary for backward " - "compatibility with old code.")); - ConfigVariableBool vertices_float64 ("vertices-float64", false, PRC_DESC("When this is true, the default float format for vertices " diff --git a/panda/src/gobj/config_gobj.h b/panda/src/gobj/config_gobj.h index d3b651d3d4..7e769c0f45 100644 --- a/panda/src/gobj/config_gobj.h +++ b/panda/src/gobj/config_gobj.h @@ -51,7 +51,6 @@ extern EXPCL_PANDA_GOBJ ConfigVariableBool connect_triangle_strips; extern EXPCL_PANDA_GOBJ ConfigVariableBool preserve_triangle_strips; extern EXPCL_PANDA_GOBJ ConfigVariableBool dump_generated_shaders; extern EXPCL_PANDA_GOBJ ConfigVariableBool cache_generated_shaders; -extern EXPCL_PANDA_GOBJ ConfigVariableBool enforce_attrib_lock; extern EXPCL_PANDA_GOBJ ConfigVariableBool vertices_float64; extern EXPCL_PANDA_GOBJ ConfigVariableInt vertex_column_alignment; extern EXPCL_PANDA_GOBJ ConfigVariableBool vertex_animation_align_16; diff --git a/panda/src/gobj/material.I b/panda/src/gobj/material.I index b9e30ba262..dcaef86980 100644 --- a/panda/src/gobj/material.I +++ b/panda/src/gobj/material.I @@ -32,8 +32,18 @@ Material(const std::string &name) : Namable(name) { * */ INLINE Material:: -Material(const Material ©) : Namable(copy) { - operator = (copy); +Material(const Material ©) : + Namable(copy) , + _base_color(copy._base_color), + _ambient(copy._ambient), + _diffuse(copy._diffuse), + _specular(copy._specular), + _emission(copy._emission), + _shininess(copy._shininess), + _roughness(copy._roughness), + _metallic(copy._metallic), + _refractive_index(copy._refractive_index), + _flags(copy._flags & ~(F_attrib_lock | F_used_by_auto_shader)) { } /** @@ -99,8 +109,8 @@ get_ambient() const { */ INLINE void Material:: clear_ambient() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_ambient() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_ambient; _ambient = _base_color; @@ -129,8 +139,8 @@ get_diffuse() const { */ INLINE void Material:: clear_diffuse() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_diffuse() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_diffuse; _diffuse = _base_color * (1 - _metallic); @@ -177,8 +187,8 @@ get_emission() const { */ INLINE void Material:: clear_emission() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_emission() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_emission; _emission.set(0.0f, 0.0f, 0.0f, 0.0f); @@ -253,8 +263,8 @@ get_local() const { */ INLINE void Material:: set_local(bool local) { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (is_used_by_auto_shader() && get_local() != local) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } if (local) { _flags |= F_local; @@ -278,8 +288,8 @@ get_twoside() const { */ INLINE void Material:: set_twoside(bool twoside) { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (is_used_by_auto_shader() && get_twoside() != twoside) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } if (twoside) { _flags |= F_twoside; @@ -313,7 +323,7 @@ operator < (const Material &other) const { } /** - * + * @deprecated This no longer has any meaning in 1.10. */ INLINE bool Material:: is_attrib_locked() const { @@ -321,17 +331,35 @@ is_attrib_locked() const { } /** - * + * @deprecated This no longer has any meaning in 1.10. */ INLINE void Material:: set_attrib_lock() { _flags |= F_attrib_lock; } +/** + * Internal. Returns true if a shader has been generated that uses this. + */ +INLINE bool Material:: +is_used_by_auto_shader() const { + return (_flags & F_attrib_lock) != 0; +} + +/** + * Called by the shader generator to indicate that a shader has been generated + * that uses this material. + */ +INLINE void Material:: +mark_used_by_auto_shader() { + _flags |= F_used_by_auto_shader; +} + /** * */ INLINE int Material:: get_flags() const { - return _flags; + // F_used_by_auto_shader is an internal flag, ignore it. + return _flags & ~F_used_by_auto_shader; } diff --git a/panda/src/gobj/material.cxx b/panda/src/gobj/material.cxx index 1952066649..24bc0fb590 100644 --- a/panda/src/gobj/material.cxx +++ b/panda/src/gobj/material.cxx @@ -28,6 +28,11 @@ PT(Material) Material::_default; void Material:: operator = (const Material ©) { Namable::operator = (copy); + + if (is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); + } + _base_color = copy._base_color; _ambient = copy._ambient; _diffuse = copy._diffuse; @@ -37,7 +42,7 @@ operator = (const Material ©) { _roughness = copy._roughness; _metallic = copy._metallic; _refractive_index = copy._refractive_index; - _flags = copy._flags & (~F_attrib_lock); + _flags = (copy._flags & ~(F_attrib_lock | F_used_by_auto_shader)) | (_flags & (F_attrib_lock | F_used_by_auto_shader)); } /** @@ -53,10 +58,8 @@ operator = (const Material ©) { */ void Material:: set_base_color(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_base_color) == 0) { - nassertv(!is_attrib_locked()); - } + if (!has_base_color() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _base_color = color; _flags |= F_base_color | F_metallic; @@ -81,8 +84,8 @@ set_base_color(const LColor &color) { */ void Material:: clear_base_color() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_base_color() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_base_color; _base_color.set(0.0f, 0.0f, 0.0f, 0.0f); @@ -116,10 +119,8 @@ clear_base_color() { */ void Material:: set_ambient(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_ambient)==0) { - nassertv(!is_attrib_locked()); - } + if (!has_ambient() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _ambient = color; _flags |= F_ambient; @@ -137,10 +138,8 @@ set_ambient(const LColor &color) { */ void Material:: set_diffuse(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_diffuse)==0) { - nassertv(!is_attrib_locked()); - } + if (!has_diffuse() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _diffuse = color; _flags |= F_diffuse; @@ -160,10 +159,8 @@ set_diffuse(const LColor &color) { */ void Material:: set_specular(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_specular)==0) { - nassertv(!is_attrib_locked()); - } + if (!has_specular() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _specular = color; _flags |= F_specular; @@ -174,8 +171,8 @@ set_specular(const LColor &color) { */ void Material:: clear_specular() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); + if (has_specular() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _flags &= ~F_specular; @@ -201,10 +198,8 @@ clear_specular() { */ void Material:: set_emission(const LColor &color) { - if (enforce_attrib_lock) { - if ((_flags & F_emission)==0) { - nassertv(!is_attrib_locked()); - } + if (!has_emission() && is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); } _emission = color; _flags |= F_emission; @@ -275,11 +270,6 @@ set_roughness(PN_stdfloat roughness) { */ void Material:: set_metallic(PN_stdfloat metallic) { - if (enforce_attrib_lock) { - if ((_flags & F_metallic) == 0) { - nassertv(!is_attrib_locked()); - } - } _metallic = metallic; _flags |= F_metallic; @@ -305,9 +295,6 @@ set_metallic(PN_stdfloat metallic) { */ void Material:: clear_metallic() { - if (enforce_attrib_lock) { - nassertv(!is_attrib_locked()); - } _flags &= ~F_metallic; _metallic = 0; @@ -482,7 +469,7 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_string(get_name()); if (manager->get_file_minor_ver() >= 39) { - me.add_int32(_flags); + me.add_int32(_flags & ~F_used_by_auto_shader); if (_flags & F_metallic) { // Metalness workflow. @@ -570,4 +557,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { set_roughness(_shininess); } } + + if (is_used_by_auto_shader()) { + GraphicsStateGuardianBase::mark_rehash_generated_shaders(); + } } diff --git a/panda/src/gobj/material.h b/panda/src/gobj/material.h index 5835a81ae3..259d5d6874 100644 --- a/panda/src/gobj/material.h +++ b/panda/src/gobj/material.h @@ -21,6 +21,7 @@ #include "luse.h" #include "numeric_types.h" #include "config_gobj.h" +#include "graphicsStateGuardianBase.h" class FactoryParams; @@ -127,7 +128,11 @@ PUBLISHED: MAKE_PROPERTY(local, get_local, set_local); MAKE_PROPERTY(twoside, get_twoside, set_twoside); +protected: + INLINE bool is_used_by_auto_shader() const; + public: + INLINE void mark_used_by_auto_shader(); INLINE int get_flags() const; enum Flags { @@ -142,6 +147,7 @@ public: F_metallic = 0x100, F_base_color = 0x200, F_refractive_index = 0x400, + F_used_by_auto_shader = 0x800, }; private: diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 71379ddbac..1673b82358 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -252,8 +252,12 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { // Store the material flags (not the material values itself). const MaterialAttrib *material; rs->get_attrib_def(material); - if (material->get_material() != nullptr) { - key._material_flags = material->get_material()->get_flags(); + Material *mat = material->get_material(); + if (mat != nullptr) { + // The next time the Material flags change, the Material should cause the + // states to be rehashed. + mat->mark_used_by_auto_shader(); + key._material_flags = mat->get_flags(); } // Break out the lights by type. From 8806dedb51d3c25cbf6e6507b73c8597058b2c27 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Aug 2018 22:24:48 +0200 Subject: [PATCH 119/360] ShaderGenerator: avoid writing vtx_color input if unneeded --- panda/src/pgraphnodes/shaderGenerator.cxx | 27 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 1673b82358..91729f6e79 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -735,6 +735,19 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { } } + bool need_color = false; + if (key._color_type == ColorAttrib::T_vertex) { + if (key._lighting) { + if ((key._material_flags & Material::F_ambient) == 0 || + (key._material_flags & Material::F_diffuse) == 0 || + key._calc_primary_alpha) { + need_color = true; + } + } else { + need_color = true; + } + } + text << "void vshader(\n"; for (size_t i = 0; i < key._textures.size(); ++i) { const ShaderKey::TextureInfo &tex = key._textures[i]; @@ -798,7 +811,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t out float4 l_tangent : " << tangent_freg << ",\n"; text << "\t out float4 l_binormal : " << binormal_freg << ",\n"; } - if (key._color_type == ColorAttrib::T_vertex) { + if (need_color && key._color_type == ColorAttrib::T_vertex) { text << "\t in float4 vtx_color : " << color_vreg << ",\n"; text << "\t out float4 l_color : COLOR0,\n"; } @@ -919,7 +932,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { string tcname = it->first->join("_"); text << "\t l_" << tcname << " = vtx_" << tcname << ";\n"; } - if (key._color_type == ColorAttrib::T_vertex) { + if (need_color && key._color_type == ColorAttrib::T_vertex) { text << "\t l_color = vtx_color;\n"; } if (key._texture_flags & ShaderKey::TF_map_normal) { @@ -1019,10 +1032,12 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { } text << "\t out float4 o_color : COLOR0,\n"; - if (key._color_type == ColorAttrib::T_vertex) { - text << "\t in float4 l_color : COLOR0,\n"; - } else if (key._color_type == ColorAttrib::T_flat) { - text << "\t uniform float4 attr_color,\n"; + if (need_color) { + if (key._color_type == ColorAttrib::T_vertex) { + text << "\t in float4 l_color : COLOR0,\n"; + } else if (key._color_type == ColorAttrib::T_flat) { + text << "\t uniform float4 attr_color,\n"; + } } for (int i = 0; i < key._num_clip_planes; ++i) { From 929808b8676dfc6b4a31d92d5cb6136838e3e500 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Aug 2018 22:58:29 +0200 Subject: [PATCH 120/360] ShaderGenerator: fix regression with flat colors --- panda/src/pgraphnodes/shaderGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 91729f6e79..47d735c781 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -736,7 +736,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { } bool need_color = false; - if (key._color_type == ColorAttrib::T_vertex) { + if (key._color_type != ColorAttrib::T_off) { if (key._lighting) { if ((key._material_flags & Material::F_ambient) == 0 || (key._material_flags & Material::F_diffuse) == 0 || From b836a60adb9942ff7137231ddcd6c4ebf8776bdf Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 3 Aug 2018 22:59:04 +0200 Subject: [PATCH 121/360] cull: remove unused variable declarations --- panda/src/cull/cullBinBackToFront.cxx | 3 --- panda/src/cull/cullBinFixed.cxx | 3 --- panda/src/cull/cullBinFrontToBack.cxx | 3 --- panda/src/cull/cullBinStateSorted.cxx | 3 --- 4 files changed, 12 deletions(-) diff --git a/panda/src/cull/cullBinBackToFront.cxx b/panda/src/cull/cullBinBackToFront.cxx index c27c7e8ed4..34eef90ccf 100644 --- a/panda/src/cull/cullBinBackToFront.cxx +++ b/panda/src/cull/cullBinBackToFront.cxx @@ -85,9 +85,6 @@ void CullBinBackToFront:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::const_iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi)._object; diff --git a/panda/src/cull/cullBinFixed.cxx b/panda/src/cull/cullBinFixed.cxx index 3507ce4582..8bd81cf8fe 100644 --- a/panda/src/cull/cullBinFixed.cxx +++ b/panda/src/cull/cullBinFixed.cxx @@ -71,9 +71,6 @@ void CullBinFixed:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::const_iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi)._object; diff --git a/panda/src/cull/cullBinFrontToBack.cxx b/panda/src/cull/cullBinFrontToBack.cxx index 5f5d99e51c..a552c027fa 100644 --- a/panda/src/cull/cullBinFrontToBack.cxx +++ b/panda/src/cull/cullBinFrontToBack.cxx @@ -85,9 +85,6 @@ void CullBinFrontToBack:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::const_iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi)._object; diff --git a/panda/src/cull/cullBinStateSorted.cxx b/panda/src/cull/cullBinStateSorted.cxx index 3e2fca2e9a..2bd71094bd 100644 --- a/panda/src/cull/cullBinStateSorted.cxx +++ b/panda/src/cull/cullBinStateSorted.cxx @@ -70,9 +70,6 @@ void CullBinStateSorted:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); - GeomPipelineReader geom_reader(current_thread); - GeomVertexDataPipelineReader data_reader(current_thread); - Objects::const_iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { CullableObject *object = (*oi)._object; From 60468b0becbe1b11aefd068c90b72d0398a19ec3 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 5 Aug 2018 12:48:48 +0200 Subject: [PATCH 122/360] ShaderGenerator: additional case where vtx_color isn't needed See sample code in a comment in #370 --- panda/src/pgraphnodes/shaderGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 47d735c781..f52d0f4579 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -738,7 +738,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { bool need_color = false; if (key._color_type != ColorAttrib::T_off) { if (key._lighting) { - if ((key._material_flags & Material::F_ambient) == 0 || + if (((key._material_flags & Material::F_ambient) == 0 && key._have_separate_ambient) || (key._material_flags & Material::F_diffuse) == 0 || key._calc_primary_alpha) { need_color = true; From 8348f16665e5e8c68609472a6a6faeb1ce29c6bd Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 5 Aug 2018 12:51:27 +0200 Subject: [PATCH 123/360] glgsg: fix incorrect behavior if mat has either ambient or diffuse This might have only been an issue in some drivers (not sure, spec is a bit vague here). Apparently we need to call glMaterial *after* the color material setting has been disabled for it to stick. Fixes #369 --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 25a57a9a17..8fe943108b 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -7633,7 +7633,6 @@ do_issue_material() { } else if (material->has_ambient()) { // The material specifies an ambient, but not a diffuse component. The // diffuse component comes from the object's color. - call_glMaterialfv(face, GL_AMBIENT, material->get_ambient()); if (has_material_force_color) { glDisable(GL_COLOR_MATERIAL); call_glMaterialfv(face, GL_DIFFUSE, _material_force_color); @@ -7643,11 +7642,11 @@ do_issue_material() { #endif // OPENGLES glEnable(GL_COLOR_MATERIAL); } + call_glMaterialfv(face, GL_AMBIENT, material->get_ambient()); } else if (material->has_diffuse()) { // The material specifies a diffuse, but not an ambient component. The // ambient component comes from the object's color. - call_glMaterialfv(face, GL_DIFFUSE, material->get_diffuse()); if (has_material_force_color) { glDisable(GL_COLOR_MATERIAL); call_glMaterialfv(face, GL_AMBIENT, _material_force_color); @@ -7657,6 +7656,7 @@ do_issue_material() { #endif // OPENGLES glEnable(GL_COLOR_MATERIAL); } + call_glMaterialfv(face, GL_DIFFUSE, material->get_diffuse()); } else { // The material specifies neither a diffuse nor an ambient component. From 2556d006f708a5e4d84361e917764d618c497c02 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 5 Aug 2018 13:01:42 +0200 Subject: [PATCH 124/360] glgsg: a few version check tweaks --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 14 +++++++++----- panda/src/glstuff/glGraphicsStateGuardian_src.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 8fe943108b..fb22fdb644 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -2286,8 +2286,10 @@ reset() { if (is_at_least_gl_version(4, 5) || has_extension("GL_ARB_direct_state_access")) { _glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC) get_extension_func("glGenerateTextureMipmap"); + + _supports_dsa = true; } else { - _glGenerateTextureMipmap = nullptr; + _supports_dsa = false; } #endif @@ -2830,7 +2832,9 @@ reset() { // Check availability of anisotropic texture filtering. _supports_anisotropy = false; _max_anisotropy = 1.0; - if (has_extension("GL_EXT_texture_filter_anisotropic")) { + if (is_at_least_gl_version(4, 6) || + has_extension("GL_EXT_texture_filter_anisotropic") || + has_extension("GL_ARB_texture_filter_anisotropic")) { GLfloat max_anisotropy; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy); _max_anisotropy = (PN_stdfloat)max_anisotropy; @@ -3237,7 +3241,7 @@ reset() { if (GLCAT.is_debug()) { if (_supports_get_program_binary) { GLCAT.debug() - << "Supported shader binary formats:\n"; + << "Supported program binary formats:\n"; GLCAT.debug() << " "; pset::const_iterator it; @@ -3249,7 +3253,7 @@ reset() { } GLCAT.debug(false) << "\n"; } else { - GLCAT.debug() << "No shader binary formats supported.\n"; + GLCAT.debug() << "No program binary formats supported.\n"; } } #endif @@ -13193,7 +13197,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, void CLP(GraphicsStateGuardian):: generate_mipmaps(CLP(TextureContext) *gtc) { #ifndef OPENGLES - if (_glGenerateTextureMipmap != nullptr) { + if (_supports_dsa) { // OpenGL 4.5 offers an easy way to do this without binding. _glGenerateTextureMipmap(gtc->_index); return; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index a8cd3a2e3b..99c8296336 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -909,6 +909,7 @@ public: PFNGLBINDPROGRAMARBPROC _glBindProgram; #ifndef OPENGLES + bool _supports_dsa; PFNGLGENERATETEXTUREMIPMAPPROC _glGenerateTextureMipmap; #endif From 7c375ac53101b933f5969871ed8c854299f20e24 Mon Sep 17 00:00:00 2001 From: bfrisby2000 Date: Tue, 7 Aug 2018 20:23:16 -0400 Subject: [PATCH 125/360] showbase: Add blendType argument for Fade/Iris/Letterbox This allows the 'blendType' argument to be passed through the three transitions' Lerp Intervals. --- direct/src/showbase/Transitions.py | 32 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/direct/src/showbase/Transitions.py b/direct/src/showbase/Transitions.py index 5c449c6997..9e05daad3e 100644 --- a/direct/src/showbase/Transitions.py +++ b/direct/src/showbase/Transitions.py @@ -89,7 +89,7 @@ class Transitions: self.fade.setBin('unsorted', 0) self.fade.setColor(0,0,0,0) - def getFadeInIval(self, t=0.5, finishIval=None): + def getFadeInIval(self, t=0.5, finishIval=None, blendType='noBlend'): """ Returns an interval without starting it. This is particularly useful in cutscenes, so when the cutsceneIval is escaped out of we can finish the fade immediately @@ -103,6 +103,7 @@ class Transitions: self.lerpFunc(self.fade, t, self.alphaOff, # self.alphaOn, + blendType=blendType ), Func(self.fade.detachNode), name = self.fadeTaskName, @@ -111,7 +112,7 @@ class Transitions: transitionIval.append(finishIval) return transitionIval - def getFadeOutIval(self, t=0.5, finishIval=None): + def getFadeOutIval(self, t=0.5, finishIval=None, blendType='noBlend'): """ Create a sequence that lerps the color out, then parents the fade to hidden @@ -125,6 +126,7 @@ class Transitions: self.lerpFunc(self.fade, t, self.alphaOn, # self.alphaOff, + blendType=blendType ), name = self.fadeTaskName, ) @@ -132,7 +134,7 @@ class Transitions: transitionIval.append(finishIval) return transitionIval - def fadeIn(self, t=0.5, finishIval=None): + def fadeIn(self, t=0.5, finishIval=None, blendType='noBlend'): """ Play a fade in transition over t seconds. Places a polygon on the aspect2d plane then lerps the color @@ -159,13 +161,13 @@ class Transitions: else: # Create a sequence that lerps the color out, then # parents the fade to hidden - self.transitionIval = self.getFadeInIval(t, finishIval) + self.transitionIval = self.getFadeInIval(t, finishIval, blendType) self.transitionIval.append(Func(self.__finishTransition)) self.__transitionFuture = AsyncFuture() self.transitionIval.start() return self.__transitionFuture - def fadeOut(self, t=0.5, finishIval=None): + def fadeOut(self, t=0.5, finishIval=None, blendType='noBlend'): """ Play a fade out transition over t seconds. Places a polygon on the aspect2d plane then lerps the color @@ -189,7 +191,7 @@ class Transitions: else: # Create a sequence that lerps the color out, then # parents the fade to hidden - self.transitionIval = self.getFadeOutIval(t, finishIval) + self.transitionIval = self.getFadeOutIval(t, finishIval, blendType) self.transitionIval.append(Func(self.__finishTransition)) self.__transitionFuture = AsyncFuture() self.transitionIval.start() @@ -264,7 +266,7 @@ class Transitions: self.iris = loader.loadModel(self.IrisModelName) self.iris.setPos(0, 0, 0) - def irisIn(self, t=0.5, finishIval=None): + def irisIn(self, t=0.5, finishIval=None, blendType = 'noBlend'): """ Play an iris in transition over t seconds. Places a polygon on the aspect2d plane then lerps the scale @@ -284,7 +286,8 @@ class Transitions: scale = 0.18 * max(base.a2dRight, base.a2dTop) self.transitionIval = Sequence(LerpScaleInterval(self.iris, t, scale = scale, - startScale = 0.01), + startScale = 0.01, + blendType=blendType), Func(self.iris.detachNode), Func(self.__finishTransition), name = self.irisTaskName, @@ -295,7 +298,7 @@ class Transitions: self.transitionIval.start() return self.__transitionFuture - def irisOut(self, t=0.5, finishIval=None): + def irisOut(self, t=0.5, finishIval=None, blendType='noBlend'): """ Play an iris out transition over t seconds. Places a polygon on the aspect2d plane then lerps the scale @@ -318,7 +321,8 @@ class Transitions: scale = 0.18 * max(base.a2dRight, base.a2dTop) self.transitionIval = Sequence(LerpScaleInterval(self.iris, t, scale = 0.01, - startScale = scale), + startScale = scale, + blendType=blendType), Func(self.iris.detachNode), # Use the fade to cover up the hole that the iris would leave Func(self.fadeOut, 0), @@ -441,7 +445,7 @@ class Transitions: self.__letterboxFuture.setResult(None) self.__letterboxFuture = None - def letterboxOn(self, t=0.25, finishIval=None): + def letterboxOn(self, t=0.25, finishIval=None, blendType='noBlend'): """ Move black bars in over t seconds. """ @@ -461,11 +465,13 @@ class Transitions: t, pos = Vec3(0, 0, -1), #startPos = Vec3(0, 0, -1.2), + blendType=blendType ), LerpPosInterval(self.letterboxTop, t, pos = Vec3(0, 0, 0.8), # startPos = Vec3(0, 0, 1), + blendType=blendType ), ), Func(self.__finishLetterbox), @@ -476,7 +482,7 @@ class Transitions: self.letterboxIval.start() return self.__letterboxFuture - def letterboxOff(self, t=0.25, finishIval=None): + def letterboxOff(self, t=0.25, finishIval=None, blendType='noBlend'): """ Move black bars away over t seconds. """ @@ -495,11 +501,13 @@ class Transitions: t, pos = Vec3(0, 0, -1.2), # startPos = Vec3(0, 0, -1), + blendType=blendType ), LerpPosInterval(self.letterboxTop, t, pos = Vec3(0, 0, 1), # startPos = Vec3(0, 0, 0.8), + blendType=blendType ), ), Func(self.letterbox.stash), From ee318a73f3df14eccdefca1f5db34c354e94063a Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 8 Aug 2018 20:16:11 +0200 Subject: [PATCH 126/360] interval: prevent hypothetical stack overflow --- direct/src/interval/cMetaInterval.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/direct/src/interval/cMetaInterval.cxx b/direct/src/interval/cMetaInterval.cxx index d43ea9cebf..08f8887706 100644 --- a/direct/src/interval/cMetaInterval.cxx +++ b/direct/src/interval/cMetaInterval.cxx @@ -679,7 +679,7 @@ write(std::ostream &out, int indent_level) const { int total_digits = num_decimals + 4; static const int max_digits = 32; // totally arbitrary nassertv(total_digits <= max_digits); - char format_str[12]; + char format_str[16]; sprintf(format_str, "%%%d.%df", total_digits, num_decimals); indent(out, indent_level) << get_name() << ":\n"; @@ -708,7 +708,7 @@ timeline(std::ostream &out) const { int total_digits = num_decimals + 4; static const int max_digits = 32; // totally arbitrary nassertv(total_digits <= max_digits); - char format_str[12]; + char format_str[16]; sprintf(format_str, "%%%d.%df", total_digits, num_decimals); int extra_indent_level = 0; From 433f734d43afe0a138b402afaf166778145dd4f6 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 8 Aug 2018 20:18:37 +0200 Subject: [PATCH 127/360] mathutil: BoundingPlane improvements --- panda/src/mathutil/boundingHexahedron.cxx | 9 +++++++++ panda/src/mathutil/boundingHexahedron.h | 1 + panda/src/mathutil/boundingPlane.cxx | 24 ++++++++++++++++++++++- panda/src/mathutil/boundingPlane.h | 3 +++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/panda/src/mathutil/boundingHexahedron.cxx b/panda/src/mathutil/boundingHexahedron.cxx index 1e500cb64c..7046215821 100644 --- a/panda/src/mathutil/boundingHexahedron.cxx +++ b/panda/src/mathutil/boundingHexahedron.cxx @@ -14,6 +14,7 @@ #include "boundingHexahedron.h" #include "boundingSphere.h" #include "boundingBox.h" +#include "boundingPlane.h" #include "config_mathutil.h" #include @@ -356,6 +357,14 @@ contains_box(const BoundingBox *box) const { return result; } +/** + * + */ +int BoundingHexahedron:: +contains_plane(const BoundingPlane *plane) const { + return plane->contains_hexahedron(this) & ~IF_all; +} + /** * */ diff --git a/panda/src/mathutil/boundingHexahedron.h b/panda/src/mathutil/boundingHexahedron.h index ac87135509..de09e03dac 100644 --- a/panda/src/mathutil/boundingHexahedron.h +++ b/panda/src/mathutil/boundingHexahedron.h @@ -79,6 +79,7 @@ protected: virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const; virtual int contains_sphere(const BoundingSphere *sphere) const; virtual int contains_box(const BoundingBox *box) const; + virtual int contains_plane(const BoundingPlane *plane) const; virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const; private: diff --git a/panda/src/mathutil/boundingPlane.cxx b/panda/src/mathutil/boundingPlane.cxx index 9690bb8dae..5c2ee9b386 100644 --- a/panda/src/mathutil/boundingPlane.cxx +++ b/panda/src/mathutil/boundingPlane.cxx @@ -202,7 +202,29 @@ contains_line(const BoundingLine *line) const { */ int BoundingPlane:: contains_plane(const BoundingPlane *plane) const { - return IF_possible; + // We assume the plane normals are normalized. + LPlane other_plane = plane->get_plane(); + PN_stdfloat dot = _plane.get_normal().dot(other_plane.get_normal()); + if (dot >= 1.0) { + // The planes are parallel, with the same normal. + if (_plane.get_w() <= other_plane.get_w()) { + return IF_possible | IF_some | IF_all; + } else { + return IF_possible | IF_some; + } + + } else if (dot <= -1.0) { + // The planes are opposing. + if (_plane.get_w() >= -other_plane.get_w()) { + return IF_no_intersection; + } else { + return IF_possible | IF_some; + } + + } else { + // The planes are not parallel, so they inevitably intersect. + return IF_possible | IF_some; + } } /** diff --git a/panda/src/mathutil/boundingPlane.h b/panda/src/mathutil/boundingPlane.h index 82e02870a0..ecfdfea4ca 100644 --- a/panda/src/mathutil/boundingPlane.h +++ b/panda/src/mathutil/boundingPlane.h @@ -42,6 +42,8 @@ public: PUBLISHED: INLINE_MATHUTIL const LPlane &get_plane() const; + MAKE_PROPERTY(plane, get_plane); + public: virtual const BoundingPlane *as_bounding_plane() const; @@ -82,6 +84,7 @@ private: friend class BoundingSphere; friend class BoundingBox; + friend class BoundingHexahedron; }; #include "boundingPlane.I" From aa66d8313ee66c329fc49423a699c988d383eeda Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 8 Aug 2018 20:21:09 +0200 Subject: [PATCH 128/360] tests: add BoundingPlane unit tests --- tests/mathutil/test_bounding_plane.py | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/mathutil/test_bounding_plane.py diff --git a/tests/mathutil/test_bounding_plane.py b/tests/mathutil/test_bounding_plane.py new file mode 100644 index 0000000000..eeb9b2b11e --- /dev/null +++ b/tests/mathutil/test_bounding_plane.py @@ -0,0 +1,64 @@ +from panda3d.core import Plane, BoundingPlane, BoundingSphere, BoundingVolume + + +def test_plane_contains_sphere(): + plane = BoundingPlane((0, 0, 1, 0)) + + # Sphere above plane + assert plane.contains(BoundingSphere((0, 0, 2), 1)) == BoundingVolume.IF_no_intersection + + # Sphere intersecting surface of plane + assert plane.contains(BoundingSphere((0, 0, 0), 1)) == BoundingVolume.IF_possible | BoundingVolume.IF_some + + # Sphere below plane + assert plane.contains(BoundingSphere((0, 0, -2), 1)) == BoundingVolume.IF_possible | BoundingVolume.IF_some | BoundingVolume.IF_all + + +def test_plane_contains_plane(): + # Plane should always fully contain itself. + a = BoundingPlane((1, 0, 0, 1)) + assert a.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some | BoundingVolume.IF_all + + # Plane with its mirror image + a = BoundingPlane((1, 0, 0, 1)) + b = BoundingPlane((-1, 0, 0, -1)) + assert a.contains(b) == BoundingVolume.IF_no_intersection + assert b.contains(a) == BoundingVolume.IF_no_intersection + + # One plane above the other + a = BoundingPlane(Plane((1, 0, 0), (1, 0, 0))) + b = BoundingPlane(Plane((1, 0, 0), (2, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some | BoundingVolume.IF_all + + # Opposing planes with distance between them. + a = BoundingPlane(Plane((1, 0, 0), (1, 0, 0))) + b = BoundingPlane(Plane((-1, 0, 0), (2, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_no_intersection + assert b.contains(a) == BoundingVolume.IF_no_intersection + + # Planes overlapping in the same axis. + a = BoundingPlane(Plane((1, 0, 0), (2, 0, 0))) + b = BoundingPlane(Plane((-1, 0, 0), (1, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some + + # Planes overlapping due to not sharing a normal vector. + a = BoundingPlane(Plane((1, 0, 0), (2, 0, 0))) + b = BoundingPlane(Plane((0.8, 0.6, 0), (4, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some + + # Same as above. + a = BoundingPlane(Plane((1, 0, 0), (2, 0, 0))) + b = BoundingPlane(Plane((-0.8, -0.6, 0), (4, 0, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(a) == BoundingVolume.IF_possible | BoundingVolume.IF_some + + # Planes pointing along different major axes. + a = BoundingPlane(Plane((1, 0, 0, 0))) + b = BoundingPlane(Plane((0, 1, 0, 0))) + c = BoundingPlane(Plane((0, 0, 1, 0))) + assert a.contains(b) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert b.contains(c) == BoundingVolume.IF_possible | BoundingVolume.IF_some + assert a.contains(c) == BoundingVolume.IF_possible | BoundingVolume.IF_some From eb0f753a3c59fcbe70448c10ca538837746d9d63 Mon Sep 17 00:00:00 2001 From: deflected Date: Wed, 8 Aug 2018 21:26:28 +0200 Subject: [PATCH 129/360] x11display: fix loading cursor from compressed/encrypted stream --- panda/src/x11display/x11GraphicsWindow.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 45c04909a2..17f6ca0a2a 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -2193,7 +2193,13 @@ get_cursor(const Filename &filename) { << "Could not read from cursor file " << filename << "\n"; return None; } - str->seekg(0, istream::beg); + + // Put back the read bytes. Do not use seekg, because this will + // corrupt the stream if it points to encrypted/compressed file + str->putback(magic[3]); + str->putback(magic[2]); + str->putback(magic[1]); + str->putback(magic[0]); X11_Cursor h = None; if (memcmp(magic, "Xcur", 4) == 0) { From 4ff619b75fab6b80cd6fe717effbef1c4c3d8723 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 9 Aug 2018 14:56:40 +0200 Subject: [PATCH 130/360] pystub: fix some definitions that should be variables, not funcs This is needed to compile Panda3D with -flto. --- dtool/src/pystub/pystub.cxx | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index ac6586c6ff..b2e9d4d62f 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -36,7 +36,6 @@ extern "C" { EXPCL_PYSTUB int PyDict_SetItem(...); EXPCL_PYSTUB int PyDict_SetItemString(...); EXPCL_PYSTUB int PyDict_Size(...); - EXPCL_PYSTUB int PyDict_Type(...); EXPCL_PYSTUB int PyErr_Clear(...); EXPCL_PYSTUB int PyErr_ExceptionMatches(...); EXPCL_PYSTUB int PyErr_Fetch(...); @@ -54,9 +53,7 @@ extern "C" { EXPCL_PYSTUB int PyEval_SaveThread(...); EXPCL_PYSTUB int PyFloat_AsDouble(...); EXPCL_PYSTUB int PyFloat_FromDouble(...); - EXPCL_PYSTUB int PyFloat_Type(...); EXPCL_PYSTUB int PyGen_Check(...); - EXPCL_PYSTUB int PyGen_Type(...); EXPCL_PYSTUB int PyGILState_Ensure(...); EXPCL_PYSTUB int PyGILState_Release(...); EXPCL_PYSTUB int PyImport_GetModuleDict(...); @@ -65,14 +62,12 @@ extern "C" { EXPCL_PYSTUB int PyInt_AsSsize_t(...); EXPCL_PYSTUB int PyInt_FromLong(...); EXPCL_PYSTUB int PyInt_FromSize_t(...); - EXPCL_PYSTUB int PyInt_Type(...); EXPCL_PYSTUB int PyIter_Next(...); EXPCL_PYSTUB int PyList_Append(...); EXPCL_PYSTUB int PyList_AsTuple(...); EXPCL_PYSTUB int PyList_GetItem(...); EXPCL_PYSTUB int PyList_New(...); EXPCL_PYSTUB int PyList_SetItem(...); - EXPCL_PYSTUB int PyList_Type(...); EXPCL_PYSTUB int PyLong_AsLong(...); EXPCL_PYSTUB int PyLong_AsLongLong(...); EXPCL_PYSTUB int PyLong_AsSsize_t(...); @@ -83,7 +78,6 @@ extern "C" { EXPCL_PYSTUB int PyLong_FromSize_t(...); EXPCL_PYSTUB int PyLong_FromUnsignedLong(...); EXPCL_PYSTUB int PyLong_FromUnsignedLongLong(...); - EXPCL_PYSTUB int PyLong_Type(...); EXPCL_PYSTUB int PyMapping_GetItemString(...); EXPCL_PYSTUB int PyMem_Free(...); EXPCL_PYSTUB int PyMemoryView_FromObject(...); @@ -124,7 +118,6 @@ extern "C" { EXPCL_PYSTUB int PyObject_SetAttr(...); EXPCL_PYSTUB int PyObject_SetAttrString(...); EXPCL_PYSTUB int PyObject_Str(...); - EXPCL_PYSTUB int PyObject_Type(...); EXPCL_PYSTUB int PySeqIter_New(...); EXPCL_PYSTUB int PySequence_Check(...); EXPCL_PYSTUB int PySequence_Fast(...); @@ -139,7 +132,6 @@ extern "C" { EXPCL_PYSTUB int PyString_InternFromString(...); EXPCL_PYSTUB int PyString_InternInPlace(...); EXPCL_PYSTUB int PyString_Size(...); - EXPCL_PYSTUB int PyString_Type(...); EXPCL_PYSTUB int PySys_GetObject(...); EXPCL_PYSTUB int PyThreadState_Clear(...); EXPCL_PYSTUB int PyThreadState_Delete(...); @@ -181,7 +173,6 @@ extern "C" { EXPCL_PYSTUB int PyUnicode_GetSize(...); EXPCL_PYSTUB int PyUnicode_InternFromString(...); EXPCL_PYSTUB int PyUnicode_InternInPlace(...); - EXPCL_PYSTUB int PyUnicode_Type(...); EXPCL_PYSTUB int Py_BuildValue(...); EXPCL_PYSTUB int Py_GetVersion(...); EXPCL_PYSTUB int Py_InitModule4(...); @@ -233,8 +224,17 @@ extern "C" { EXPCL_PYSTUB extern void *PyExc_SystemExit; EXPCL_PYSTUB extern void *PyExc_TypeError; EXPCL_PYSTUB extern void *PyExc_ValueError; + EXPCL_PYSTUB extern void *PyDict_Type; + EXPCL_PYSTUB extern void *PyFloat_Type; + EXPCL_PYSTUB extern void *PyGen_Type; + EXPCL_PYSTUB extern void *PyInt_Type; + EXPCL_PYSTUB extern void *PyList_Type; + EXPCL_PYSTUB extern void *PyLong_Type; + EXPCL_PYSTUB extern void *PyObject_Type; + EXPCL_PYSTUB extern void *PyString_Type; EXPCL_PYSTUB extern void *PyTuple_Type; EXPCL_PYSTUB extern void *PyType_Type; + EXPCL_PYSTUB extern void *PyUnicode_Type; EXPCL_PYSTUB extern void *_PyThreadState_Current; EXPCL_PYSTUB extern void *_Py_FalseStruct; EXPCL_PYSTUB extern void *_Py_NoneStruct; @@ -266,7 +266,6 @@ int PyDict_Next(...) { return 0; }; int PyDict_SetItem(...) { return 0; }; int PyDict_SetItemString(...) { return 0; }; int PyDict_Size(...){ return 0; } -int PyDict_Type(...) { return 0; }; int PyErr_Clear(...) { return 0; }; int PyErr_ExceptionMatches(...) { return 0; }; int PyErr_Fetch(...) { return 0; } @@ -285,9 +284,7 @@ int PyEval_RestoreThread(...) { return 0; } int PyEval_SaveThread(...) { return 0; } int PyFloat_AsDouble(...) { return 0; } int PyFloat_FromDouble(...) { return 0; } -int PyFloat_Type(...) { return 0; } int PyGen_Check(...) { return 0; } -int PyGen_Type(...) { return 0; } int PyGILState_Ensure(...) { return 0; } int PyGILState_Release(...) { return 0; } int PyImport_GetModuleDict(...) { return 0; } @@ -296,14 +293,12 @@ int PyInt_AsLong(...) { return 0; } int PyInt_AsSsize_t(...) { return 0; } int PyInt_FromLong(...) { return 0; } int PyInt_FromSize_t(...) { return 0; } -int PyInt_Type(...) { return 0; } int PyIter_Next(...) { return 0; } int PyList_Append(...) { return 0; } int PyList_AsTuple(...) { return 0; } int PyList_GetItem(...) { return 0; } int PyList_New(...) { return 0; } int PyList_SetItem(...) { return 0; } -int PyList_Type(...) { return 0; } int PyLong_AsLong(...) { return 0; } int PyLong_AsLongLong(...) { return 0; } int PyLong_AsSsize_t(...) { return 0; } @@ -314,7 +309,6 @@ int PyLong_FromLongLong(...) { return 0; } int PyLong_FromSize_t(...) { return 0; } int PyLong_FromUnsignedLong(...) { return 0; } int PyLong_FromUnsignedLongLong(...) { return 0; } -int PyLong_Type(...) { return 0; } int PyMapping_GetItemString(...) { return 0; } int PyMem_Free(...) { return 0; } int PyMemoryView_FromObject(...) { return 0; } @@ -355,7 +349,6 @@ int PyObject_SelfIter(...) { return 0; } int PyObject_SetAttr(...) { return 0; } int PyObject_SetAttrString(...) { return 0; } int PyObject_Str(...) { return 0; } -int PyObject_Type(...) { return 0; } int PySeqIter_New(...) { return 0; } int PySequence_Check(...) { return 0; } int PySequence_Fast(...) { return 0; } @@ -369,8 +362,6 @@ int PyString_FromString(...) { return 0; } int PyString_FromStringAndSize(...) { return 0; } int PyString_InternFromString(...) { return 0; } int PyString_InternInPlace(...) { return 0; } -int PyString_Size(...) { return 0; } -int PyString_Type(...) { return 0; } int PySys_GetObject(...) { return 0; } int PyThreadState_Clear(...) { return 0; } int PyThreadState_Delete(...) { return 0; } @@ -412,7 +403,6 @@ int PyUnicode_FromWideChar(...) { return 0; } int PyUnicode_GetSize(...) { return 0; } int PyUnicode_InternFromString(...) { return 0; } int PyUnicode_InternInPlace(...) { return 0; } -int PyUnicode_Type(...) { return 0; } int Py_GetVersion(...) { return 0; } int Py_BuildValue(...) { return 0; } int Py_InitModule4(...) { return 0; } @@ -470,8 +460,17 @@ void *PyExc_StopIteration = nullptr; void *PyExc_SystemExit = nullptr; void *PyExc_TypeError = nullptr; void *PyExc_ValueError = nullptr; +void *PyDict_Type = nullptr; +void *PyFloat_Type = nullptr; +void *PyGen_Type = nullptr; +void *PyInt_Type = nullptr; +void *PyList_Type = nullptr; +void *PyLong_Type = nullptr; +void *PyObject_Type = nullptr; +void *PyString_Type = nullptr; void *PyTuple_Type = nullptr; void *PyType_Type = nullptr; +void *PyUnicode_Type = nullptr; void *_PyThreadState_Current = nullptr; void *_Py_FalseStruct = nullptr; void *_Py_NoneStruct = nullptr; From be19411cf894b480b37575a4e43e9085c9aff7c3 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 10 Aug 2018 14:28:02 +0200 Subject: [PATCH 131/360] Add support for Maya 2018 --- makepanda/makepandacore.py | 3 ++- pandatool/src/maya/mayaShader.h | 1 - pandatool/src/maya/mayaShaderColorDef.cxx | 16 +++++++++++----- pandatool/src/maya/mayaShaderColorDef.h | 2 -- pandatool/src/maya/mayaShaders.h | 1 - pandatool/src/maya/maya_funcs.h | 1 - pandatool/src/maya/pre_maya_include.h | 17 +++++++++++++++++ pandatool/src/mayaegg/mayaToEggConverter.cxx | 17 +++++++++++------ pandatool/src/mayaegg/mayaToEggConverter.h | 9 --------- pandatool/src/mayaprogs/mayaCopy.cxx | 3 ++- pandatool/src/mayaprogs/mayaCopy.h | 8 ++++++-- pandatool/src/mayaprogs/mayapath.cxx | 1 + 12 files changed, 50 insertions(+), 29 deletions(-) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index f738d8affa..76dec39406 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -102,7 +102,8 @@ MAYAVERSIONINFO = [("MAYA6", "6.0"), ("MAYA2015","2015"), ("MAYA2016","2016"), ("MAYA20165","2016.5"), - ("MAYA2017","2017") + ("MAYA2017","2017"), + ("MAYA2018","2018"), ] MAXVERSIONINFO = [("MAX6", "SOFTWARE\\Autodesk\\3DSMAX\\6.0", "installdir", "maxsdk\\cssdk\\include"), diff --git a/pandatool/src/maya/mayaShader.h b/pandatool/src/maya/mayaShader.h index 41c9bdf77f..34ff13a808 100644 --- a/pandatool/src/maya/mayaShader.h +++ b/pandatool/src/maya/mayaShader.h @@ -21,7 +21,6 @@ #include "lmatrix.h" #include "namable.h" -class MObject; /** * Corresponds to a single "shader" in Maya. This extracts out all the diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index 73d2978d7c..cbaa82d5b7 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -367,15 +367,17 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { if (li > -1) { // found a blend mode if (maya_cat.is_spam()) { + MString name = inputsPlug.name(); maya_cat.spam() << "*** Start doIt... ***" << endl; - maya_cat.spam() << "inputsPlug Name: " << inputsPlug.name() << endl; + maya_cat.spam() << "inputsPlug Name: " << name.asChar() << endl; } status = blendModePlug.selectAncestorLogicalIndex(li,inputsPlug); blendModePlug.getValue(blendValue); if (maya_cat.is_spam()) { + MString name = blendModePlug.name(); maya_cat.spam() - << blendModePlug.name() << ": has value " << blendValue << endl; + << name.asChar() << ": has value " << blendValue << endl; } MFnEnumAttribute blendModeEnum(blendModePlug); @@ -397,9 +399,13 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { bt = BT_add; break; } - maya_cat.info() << layered_fn.name() << ": blendMode used " << blendName << endl; - if (maya_cat.is_spam()) { - maya_cat.spam() << "*** END doIt... ***" << endl; + + if (maya_cat.is_info()) { + MString name = layered_fn.name(); + maya_cat.info() << name.asChar() << ": blendMode used " << blendName.asChar() << endl; + if (maya_cat.is_spam()) { + maya_cat.spam() << "*** END doIt... ***" << endl; + } } // advance to the next plug, because that is where the shader info are diff --git a/pandatool/src/maya/mayaShaderColorDef.h b/pandatool/src/maya/mayaShaderColorDef.h index ca2d532f13..2609f2bb43 100644 --- a/pandatool/src/maya/mayaShaderColorDef.h +++ b/pandatool/src/maya/mayaShaderColorDef.h @@ -21,8 +21,6 @@ #include "pmap.h" #include "pvector.h" -class MObject; -class MPlug; class MayaShader; class MayaShaderColorDef; typedef pvector MayaShaderColorList; diff --git a/pandatool/src/maya/mayaShaders.h b/pandatool/src/maya/mayaShaders.h index f1c107a755..5428ab5f73 100644 --- a/pandatool/src/maya/mayaShaders.h +++ b/pandatool/src/maya/mayaShaders.h @@ -21,7 +21,6 @@ #include "mayaShaderColorDef.h" class MayaShader; -class MObject; /** * Collects the set of MayaShaders that have been encountered so far. diff --git a/pandatool/src/maya/maya_funcs.h b/pandatool/src/maya/maya_funcs.h index 2966fef9e3..ad0a7210b3 100644 --- a/pandatool/src/maya/maya_funcs.h +++ b/pandatool/src/maya/maya_funcs.h @@ -28,7 +28,6 @@ #include #include "post_maya_include.h" -class MObject; bool get_maya_plug(MObject &node, const std::string &attribute_name, MPlug &plug); diff --git a/pandatool/src/maya/pre_maya_include.h b/pandatool/src/maya/pre_maya_include.h index 0244ec7ba4..85442c1e7b 100644 --- a/pandatool/src/maya/pre_maya_include.h +++ b/pandatool/src/maya/pre_maya_include.h @@ -43,4 +43,21 @@ #if MAYA_API_VERSION < 201600 #include #endif +#else +// This defines MAYA_API_VERSION +#include +#endif + +#if MAYA_API_VERSION >= 20180000 +#include +#else +class MObject; +class MDagPath; +class MFloatArray; +class MFnDagNode; +class MFnMesh; +class MFnNurbsCurve; +class MFnNurbsSurface; +class MPlug; +class MPointArray; #endif diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index 7943f07f03..747c8ac279 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -838,12 +838,14 @@ process_model_node(MayaNodeDesc *node_desc) { // Extract some interesting Camera data if (mayaegg_cat.is_spam()) { MPoint eyePoint = camera.eyePoint(MSpace::kWorld); + MVector upDirection = camera.upDirection(MSpace::kWorld); + MVector viewDirection = camera.viewDirection(MSpace::kWorld); mayaegg_cat.spam() << " eyePoint: " << eyePoint.x << " " << eyePoint.y << " " << eyePoint.z << endl; - mayaegg_cat.spam() << " upDirection: " - << camera.upDirection(MSpace::kWorld) << endl; - mayaegg_cat.spam() << " viewDirection: " - << camera.viewDirection(MSpace::kWorld) << endl; + mayaegg_cat.spam() << " upDirection: " << upDirection.x << " " + << upDirection.y << " " << upDirection.z << endl; + mayaegg_cat.spam() << " viewDirection: " << viewDirection.x << " " + << viewDirection.y << " " << viewDirection.z << endl; mayaegg_cat.spam() << " aspectRatio: " << camera.aspectRatio() << endl; mayaegg_cat.spam() << " horizontalFilmAperture: " << camera.horizontalFilmAperture() << endl; @@ -922,9 +924,12 @@ process_model_node(MayaNodeDesc *node_desc) { mayaegg_cat.error() << "light extraction failed" << endl; return false; } - mayaegg_cat.info() << "-- Light found -- tranlations in cm, rotations in rads\n"; - mayaegg_cat.info() << "\"" << dag_path.partialPathName() << "\" : \n"; + if (mayaegg_cat.is_info()) { + MString name = dag_path.partialPathName(); + mayaegg_cat.info() << "-- Light found -- tranlations in cm, rotations in rads\n"; + mayaegg_cat.info() << "\"" << name.asChar() << "\" : \n"; + } // Get the translationrotationscale data MObject transformNode = dag_path.transform(&status); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.h b/pandatool/src/mayaegg/mayaToEggConverter.h index 3e3782a601..c2266e0096 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.h +++ b/pandatool/src/mayaegg/mayaToEggConverter.h @@ -42,15 +42,6 @@ class EggPrimitive; class EggXfmSAnim; class MayaShaderColorDef; -class MObject; -class MDagPath; -class MFnDagNode; -class MFnNurbsSurface; -class MFnNurbsCurve; -class MFnMesh; -class MPointArray; -class MFloatArray; - /** * This class supervises the construction of an EggData structure from a * single Maya file, or from the data already in the global Maya model space. diff --git a/pandatool/src/mayaprogs/mayaCopy.cxx b/pandatool/src/mayaprogs/mayaCopy.cxx index 247e0b43ad..d10ed8e0aa 100644 --- a/pandatool/src/mayaprogs/mayaCopy.cxx +++ b/pandatool/src/mayaprogs/mayaCopy.cxx @@ -16,7 +16,6 @@ #include "mayaCopy.h" #include "config_maya.h" #include "cvsSourceDirectory.h" -#include "mayaShader.h" #include "dcast.h" #include "pre_maya_include.h" @@ -32,6 +31,8 @@ #include #include "post_maya_include.h" +#include "mayaShader.h" + using std::endl; using std::string; diff --git a/pandatool/src/mayaprogs/mayaCopy.h b/pandatool/src/mayaprogs/mayaCopy.h index 90ceddfbc0..38f0aef9de 100644 --- a/pandatool/src/mayaprogs/mayaCopy.h +++ b/pandatool/src/mayaprogs/mayaCopy.h @@ -17,15 +17,19 @@ #include "pandatoolbase.h" #include "cvsCopy.h" #include "mayaApi.h" -#include "mayaShaders.h" #include "dSearchPath.h" #include "pointerTo.h" #include "pset.h" +#include "pre_maya_include.h" +#include +#include "post_maya_include.h" + +#include "mayaShaders.h" + class MayaShader; class MayaShaderColorDef; -class MDagPath; /** * A program to copy Maya .mb files into the cvs tree. diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index ae9ad39ac2..441a22c0e2 100644 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -105,6 +105,7 @@ struct MayaVerInfo maya_versions[] = { { "MAYA2016", "2016"}, { "MAYA20165", "2016.5"}, { "MAYA2017", "2017"}, + { "MAYA2018", "2018"}, { 0, 0 }, }; From e99f8a7bcc709e4de9a3031b1fab6478e5b6e1ff Mon Sep 17 00:00:00 2001 From: John Cote Date: Fri, 10 Aug 2018 23:10:22 +0200 Subject: [PATCH 132/360] sceneeditor: clean up scene editor code, removing deprecated calls Closes #373 --- contrib/src/sceneeditor/collisionWindow.py | 2 +- contrib/src/sceneeditor/lightingPanel.py | 2 +- contrib/src/sceneeditor/propertyWindow.py | 2 +- contrib/src/sceneeditor/quad.py | 4 +-- contrib/src/sceneeditor/sceneEditor.py | 13 +++++--- contrib/src/sceneeditor/seCameraControl.py | 3 +- contrib/src/sceneeditor/seFileSaver.py | 2 +- contrib/src/sceneeditor/seForceGroup.py | 4 +-- contrib/src/sceneeditor/seGeometry.py | 2 +- contrib/src/sceneeditor/seLights.py | 2 +- contrib/src/sceneeditor/seManipulation.py | 2 +- contrib/src/sceneeditor/seMopathRecorder.py | 30 +++++++++---------- contrib/src/sceneeditor/seParticleEffect.py | 2 +- contrib/src/sceneeditor/seParticles.py | 24 ++------------- contrib/src/sceneeditor/sePlacer.py | 8 ++--- .../src/sceneeditor/seSceneGraphExplorer.py | 4 +-- contrib/src/sceneeditor/seSelection.py | 23 +++++++++----- contrib/src/sceneeditor/seSession.py | 9 ++++-- contrib/src/sceneeditor/seTree.py | 2 +- 19 files changed, 66 insertions(+), 74 deletions(-) diff --git a/contrib/src/sceneeditor/collisionWindow.py b/contrib/src/sceneeditor/collisionWindow.py index 7122e801bb..3c6b70e607 100644 --- a/contrib/src/sceneeditor/collisionWindow.py +++ b/contrib/src/sceneeditor/collisionWindow.py @@ -11,7 +11,7 @@ from direct.tkwidgets import Floater from direct.tkwidgets import Slider from Tkinter import * import string, math, types -from pandac.PandaModules import * +from panda3d.core import * class collisionWindow(AppShell): diff --git a/contrib/src/sceneeditor/lightingPanel.py b/contrib/src/sceneeditor/lightingPanel.py index edca358d61..729186a78d 100644 --- a/contrib/src/sceneeditor/lightingPanel.py +++ b/contrib/src/sceneeditor/lightingPanel.py @@ -9,7 +9,7 @@ from direct.tkwidgets.VectorWidgets import Vector3Entry from direct.tkwidgets.Slider import Slider from Tkinter import Frame, Button, Menubutton, Menu import string, math, types, Pmw, Tkinter -from pandac.PandaModules import * +from panda3d.core import * class lightingPanel(AppShell): ################################################################# diff --git a/contrib/src/sceneeditor/propertyWindow.py b/contrib/src/sceneeditor/propertyWindow.py index 35f239eee5..7406d33ffa 100644 --- a/contrib/src/sceneeditor/propertyWindow.py +++ b/contrib/src/sceneeditor/propertyWindow.py @@ -11,7 +11,7 @@ from direct.tkwidgets import Floater from direct.tkwidgets import Dial from direct.tkwidgets import Slider from direct.tkwidgets import VectorWidgets -from pandac.PandaModules import * +from panda3d.core import * from Tkinter import * import Pmw diff --git a/contrib/src/sceneeditor/quad.py b/contrib/src/sceneeditor/quad.py index 47524739ae..329dcb92a3 100644 --- a/contrib/src/sceneeditor/quad.py +++ b/contrib/src/sceneeditor/quad.py @@ -9,10 +9,8 @@ from direct.showbase.ShowBaseGlobal import * from direct.interval.IntervalGlobal import * from direct.showbase.DirectObject import DirectObject -from pandac.PandaModules import * +from panda3d.core import * import math -#Manakel 2/12/2005: replace from pandac import by from pandac.PandaModules import -from pandac.PandaModules import MouseWatcher class ViewPort: diff --git a/contrib/src/sceneeditor/sceneEditor.py b/contrib/src/sceneeditor/sceneEditor.py index ca35baa92b..37d05c3a08 100644 --- a/contrib/src/sceneeditor/sceneEditor.py +++ b/contrib/src/sceneeditor/sceneEditor.py @@ -3,8 +3,10 @@ import sys try: import _tkinter except: sys.exit("Please install python module 'Tkinter'") -import direct -from direct.directbase.DirectStart import* +from direct.showbase.ShowBase import ShowBase + +ShowBase() + from direct.showbase.TkGlobal import spawnTkLoop from Tkinter import * from tkFileDialog import * @@ -251,7 +253,10 @@ class myLevelEditor(AppShell): for event in self.actionEvents: self.accept(event[0], event[1], extraArgs = event[2:]) - camera.toggleVis() + if camera.is_hidden(): + camera.show() + else: + camera.hide() self.selectNode(base.camera) ## Initially, we select camera as the first node... def appInit(self): @@ -1705,4 +1710,4 @@ class myLevelEditor(AppShell): editor = myLevelEditor(parent = base.tkRoot) -run() +base.run() diff --git a/contrib/src/sceneeditor/seCameraControl.py b/contrib/src/sceneeditor/seCameraControl.py index 31ab30ee9f..721ebe9c31 100644 --- a/contrib/src/sceneeditor/seCameraControl.py +++ b/contrib/src/sceneeditor/seCameraControl.py @@ -392,8 +392,7 @@ class DirectCameraControl(DirectObject): sf = 0.1 self.coaMarker.setScale(sf) # Lerp color to fade out - self.coaMarker.lerpColor(VBase4(1,0,0,1), VBase4(1,0,0,0), 3.0, - task = 'fadeAway') + self.coaMarker.colorInterval(3.0, VBase4(1, 0, 0, 0), name='fadeAway').start() def homeCam(self): # Record undo point diff --git a/contrib/src/sceneeditor/seFileSaver.py b/contrib/src/sceneeditor/seFileSaver.py index 317c9427f2..0b2e088e12 100644 --- a/contrib/src/sceneeditor/seFileSaver.py +++ b/contrib/src/sceneeditor/seFileSaver.py @@ -3,7 +3,7 @@ # This code saves the scene out as python code... the scene is stored in the various dictionaries in "dataHolder.py" ...the class "AllScene" # #################################################################################################################################################### -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.ShowBaseGlobal import * import os diff --git a/contrib/src/sceneeditor/seForceGroup.py b/contrib/src/sceneeditor/seForceGroup.py index 7d27c78ebd..87c08a4904 100644 --- a/contrib/src/sceneeditor/seForceGroup.py +++ b/contrib/src/sceneeditor/seForceGroup.py @@ -1,8 +1,6 @@ -from pandac.PandaModules import * +from panda3d.core import * from direct.showbase.DirectObject import DirectObject from direct.showbase.PhysicsManagerGlobal import * -#Manakel 2/12/2005: replace from pandac import by from pandac.PandaModules import -from pandac.PandaModules import ForceNode from direct.directnotify import DirectNotifyGlobal import sys diff --git a/contrib/src/sceneeditor/seGeometry.py b/contrib/src/sceneeditor/seGeometry.py index 79115e5531..4074c986a2 100644 --- a/contrib/src/sceneeditor/seGeometry.py +++ b/contrib/src/sceneeditor/seGeometry.py @@ -12,7 +12,7 @@ # ################################################################# -from pandac.PandaModules import * +from panda3d.core import * from direct.directtools.DirectGlobals import * from direct.directtools.DirectUtil import * import math diff --git a/contrib/src/sceneeditor/seLights.py b/contrib/src/sceneeditor/seLights.py index ccc58ce0cd..09c5b2140a 100644 --- a/contrib/src/sceneeditor/seLights.py +++ b/contrib/src/sceneeditor/seLights.py @@ -5,7 +5,7 @@ from direct.showbase.DirectObject import * from string import lower from direct.directtools import DirectUtil -from pandac.PandaModules import * +from panda3d.core import * import string diff --git a/contrib/src/sceneeditor/seManipulation.py b/contrib/src/sceneeditor/seManipulation.py index e4d50d81dc..4d0c781b1e 100644 --- a/contrib/src/sceneeditor/seManipulation.py +++ b/contrib/src/sceneeditor/seManipulation.py @@ -520,7 +520,7 @@ class ObjectHandles(NodePath,DirectObject): # To avoid recreating a vec every frame self.hitPt = Vec3(0) # Get a handle on the components - self.xHandles = self.find('**/X') + self.xHandles = self.find('**/ohScalingNode') self.xPostGroup = self.xHandles.find('**/x-post-group') self.xPostCollision = self.xHandles.find('**/x-post') self.xRingGroup = self.xHandles.find('**/x-ring-group') diff --git a/contrib/src/sceneeditor/seMopathRecorder.py b/contrib/src/sceneeditor/seMopathRecorder.py index 7ba2ee52d7..0f856237d2 100644 --- a/contrib/src/sceneeditor/seMopathRecorder.py +++ b/contrib/src/sceneeditor/seMopathRecorder.py @@ -682,16 +682,16 @@ class MopathRecorder(AppShell, DirectObject): marker if subnode selected """ taskMgr.remove(self.name + '-curveEditTask') - print nodePath.id() - if nodePath.id() in self.playbackMarkerIds: + print nodePath.get_key() + if nodePath.get_key() in self.playbackMarkerIds: SEditor.select(self.playbackMarker) - elif nodePath.id() in self.tangentMarkerIds: + elif nodePath.get_key() in self.tangentMarkerIds: SEditor.select(self.tangentMarker) - elif nodePath.id() == self.playbackMarker.id(): + elif nodePath.get_key() == self.playbackMarker.get_key(): self.tangentGroup.show() taskMgr.add(self.curveEditTask, self.name + '-curveEditTask') - elif nodePath.id() == self.tangentMarker.id(): + elif nodePath.get_key() == self.tangentMarker.get_key(): self.tangentGroup.show() taskMgr.add(self.curveEditTask, self.name + '-curveEditTask') @@ -699,7 +699,7 @@ class MopathRecorder(AppShell, DirectObject): self.tangentGroup.hide() def getChildIds(self, nodePath): - ids = [nodePath.id()] + ids = [nodePath.get_key()] kids = nodePath.getChildren() for kid in kids: ids += self.getChildIds(kid) @@ -710,14 +710,14 @@ class MopathRecorder(AppShell, DirectObject): Hook called upon deselection of a node path used to select playback marker if subnode selected """ - if ((nodePath.id() == self.playbackMarker.id()) or - (nodePath.id() == self.tangentMarker.id())): + if ((nodePath.get_key() == self.playbackMarker.get_key()) or + (nodePath.get_key() == self.tangentMarker.get_key())): self.tangentGroup.hide() def curveEditTask(self,state): if self.curveCollection != None: # Update curve position - if self.manipulandumId == self.playbackMarker.id(): + if self.manipulandumId == self.playbackMarker.get_key(): # Show playback marker self.playbackMarker.getChild(0).show() pos = Point3(0) @@ -731,7 +731,7 @@ class MopathRecorder(AppShell, DirectObject): # Note: this calls recompute on the curves self.nurbsCurveDrawer.draw() # Update tangent - if self.manipulandumId == self.tangentMarker.id(): + if self.manipulandumId == self.tangentMarker.get_key(): # If manipulating marker, update tangent # Hide playback marker self.playbackMarker.getChild(0).hide() @@ -766,10 +766,10 @@ class MopathRecorder(AppShell, DirectObject): def manipulateObjectStartHook(self): self.manipulandumId = None if SEditor.selected.last: - if SEditor.selected.last.id() == self.playbackMarker.id(): - self.manipulandumId = self.playbackMarker.id() - elif SEditor.selected.last.id() == self.tangentMarker.id(): - self.manipulandumId = self.tangentMarker.id() + if SEditor.selected.last.get_key() == self.playbackMarker.get_key(): + self.manipulandumId = self.playbackMarker.get_key() + elif SEditor.selected.last.get_key() == self.tangentMarker.get_key(): + self.manipulandumId = self.tangentMarker.get_key() def manipulateObjectCleanupHook(self): # Clear flag @@ -1282,7 +1282,7 @@ class MopathRecorder(AppShell, DirectObject): dictName = name else: # Generate a unique name for the dict - dictName = name # + '-' + `nodePath.id()` + dictName = name # + '-' + `nodePath.get_key()` if not dict.has_key(dictName): # Update combo box to include new item names.append(dictName) diff --git a/contrib/src/sceneeditor/seParticleEffect.py b/contrib/src/sceneeditor/seParticleEffect.py index 068f8f234e..8ad3a658a8 100644 --- a/contrib/src/sceneeditor/seParticleEffect.py +++ b/contrib/src/sceneeditor/seParticleEffect.py @@ -1,4 +1,4 @@ -from pandac.PandaModules import * +from panda3d.core import * import seParticles import seForceGroup from direct.directnotify import DirectNotifyGlobal diff --git a/contrib/src/sceneeditor/seParticles.py b/contrib/src/sceneeditor/seParticles.py index b062a3e00a..655d06b804 100644 --- a/contrib/src/sceneeditor/seParticles.py +++ b/contrib/src/sceneeditor/seParticles.py @@ -1,28 +1,8 @@ -from pandac.PandaModules import * +from panda3d.core import * +from panda3d.physics import * from direct.particles.ParticleManagerGlobal import * from direct.showbase.PhysicsManagerGlobal import * -#Manakel 2/12/2005: replace from pandac import by from pandac.PandaModules import -from pandac.PandaModules import ParticleSystem -from pandac.PandaModules import BaseParticleFactory -from pandac.PandaModules import PointParticleFactory -from pandac.PandaModules import ZSpinParticleFactory #import OrientedParticleFactory -from pandac.PandaModules import BaseParticleRenderer -from pandac.PandaModules import PointParticleRenderer -from pandac.PandaModules import LineParticleRenderer -from pandac.PandaModules import GeomParticleRenderer -from pandac.PandaModules import SparkleParticleRenderer -from pandac.PandaModules import SpriteParticleRenderer -from pandac.PandaModules import BaseParticleEmitter -from pandac.PandaModules import BoxEmitter -from pandac.PandaModules import DiscEmitter -from pandac.PandaModules import LineEmitter -from pandac.PandaModules import PointEmitter -from pandac.PandaModules import RectangleEmitter -from pandac.PandaModules import RingEmitter -from pandac.PandaModules import SphereSurfaceEmitter -from pandac.PandaModules import SphereVolumeEmitter -from pandac.PandaModules import TangentRingEmitter import string import os from direct.directnotify import DirectNotifyGlobal diff --git a/contrib/src/sceneeditor/sePlacer.py b/contrib/src/sceneeditor/sePlacer.py index 108ef7fbc6..3f2b3b4b75 100644 --- a/contrib/src/sceneeditor/sePlacer.py +++ b/contrib/src/sceneeditor/sePlacer.py @@ -6,7 +6,7 @@ from direct.tkwidgets.AppShell import AppShell from direct.tkwidgets.Dial import AngleDial from direct.tkwidgets.Floater import Floater from Tkinter import Button, Menubutton, Menu, StringVar -from pandac.PandaModules import * +from panda3d.core import * import Tkinter, Pmw """ TODO: @@ -428,7 +428,7 @@ class Placer(AppShell): background = self.nodePathMenuBG) # Check to see if node path and ref node path are the same if ((self.refCS != None) and - (self.refCS.id() == self['nodePath'].id())): + (self.refCS.get_key() == self['nodePath'].get_key())): # Yes they are, use temp CS as ref # This calls updatePlacer self.setReferenceNodePath(self.tempCS) @@ -473,7 +473,7 @@ class Placer(AppShell): listbox = self.refNodePathMenu.component('scrolledlist') listbox.setlist(self.refNodePathNames) # Check to see if node path and ref node path are the same - if (nodePath != None) and (nodePath.id() == self['nodePath'].id()): + if (nodePath != None) and (nodePath.get_key() == self['nodePath'].get_key()): # Yes they are, use temp CS and update listbox accordingly nodePath = self.tempCS self.refNodePathMenu.selectitem('parent') @@ -508,7 +508,7 @@ class Placer(AppShell): dictName = name else: # Generate a unique name for the dict - dictName = name + '-' + `nodePath.id()` + dictName = name + '-' + `nodePath.get_key()` if not dict.has_key(dictName): # Update combo box to include new item names.append(dictName) diff --git a/contrib/src/sceneeditor/seSceneGraphExplorer.py b/contrib/src/sceneeditor/seSceneGraphExplorer.py index a864d11e90..fc7f29370a 100644 --- a/contrib/src/sceneeditor/seSceneGraphExplorer.py +++ b/contrib/src/sceneeditor/seSceneGraphExplorer.py @@ -141,7 +141,7 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject): self._node.deselecttree() def selectNodePath(self,nodePath, callBack=True): - item = self._node.find(nodePath.id()) + item = self._node.find(nodePath.get_key()) if item!= None: item.select(callBack) else: @@ -164,7 +164,7 @@ class SceneGraphExplorerItem(TreeItem): return name def GetKey(self): - return self.nodePath.id() + return self.nodePath.get_key() def IsEditable(self): # All nodes' names can be edited nowadays. diff --git a/contrib/src/sceneeditor/seSelection.py b/contrib/src/sceneeditor/seSelection.py index 73cdb1ea46..0d34ad120a 100644 --- a/contrib/src/sceneeditor/seSelection.py +++ b/contrib/src/sceneeditor/seSelection.py @@ -11,7 +11,7 @@ # (If we do change original directools, it will force user has to install the latest version of OUR Panda) # ################################################################# -from pandac.PandaModules import GeomNode +from panda3d.core import GeomNode from direct.directtools.DirectGlobals import * from direct.directtools.DirectUtil import * from seGeometry import * @@ -78,7 +78,7 @@ class SelectedNodePaths(DirectObject): self.deselectAll() # Get this pointer - id = nodePath.id() + id = nodePath.get_key() # First see if its already in the selected dictionary dnp = self.getSelectedDict(id) # If so, we're done @@ -96,7 +96,7 @@ class SelectedNodePaths(DirectObject): # Show its bounding box dnp.highlight() # Add it to the selected dictionary - self.selectedDict[dnp.id()] = dnp + self.selectedDict[dnp.get_key()] = dnp # And update last __builtins__["last"] = self.last = dnp return dnp @@ -104,7 +104,7 @@ class SelectedNodePaths(DirectObject): def deselect(self, nodePath): """ Deselect the specified node path """ # Get this pointer - id = nodePath.id() + id = nodePath.get_key() # See if it is in the selected dictionary dnp = self.getSelectedDict(id) if dnp: @@ -204,15 +204,24 @@ class SelectedNodePaths(DirectObject): # Remove all selected nodePaths from the Scene Graph self.forEachSelectedNodePathDo(NodePath.remove) + def toggleVis(self, nodePath): + if nodePath.is_hidden(): + nodePath.show() + else: + nodePath.hide() + def toggleVisSelected(self): selected = self.last # Toggle visibility of selected node paths if selected: - selected.toggleVis() + if selected.is_hidden(): + selected.show() + else: + selected.hide() def toggleVisAll(self): # Toggle viz for all selected node paths - self.forEachSelectedNodePathDo(NodePath.toggleVis) + self.forEachSelectedNodePathDo(self.toggleVis) def isolateSelected(self): selected = self.last @@ -221,7 +230,7 @@ class SelectedNodePaths(DirectObject): def getDirectNodePath(self, nodePath): # Get this pointer - id = nodePath.id() + id = nodePath.get_key() # First check selected dict dnp = self.getSelectedDict(id) if dnp: diff --git a/contrib/src/sceneeditor/seSession.py b/contrib/src/sceneeditor/seSession.py index 95f235829b..ab466c4388 100644 --- a/contrib/src/sceneeditor/seSession.py +++ b/contrib/src/sceneeditor/seSession.py @@ -388,7 +388,7 @@ class SeSession(DirectObject): ### Customized DirectSession messenger.send('DIRECT_preSelectNodePath', [dnp]) if fResetAncestry: # Update ancestry - self.ancestry = dnp.getAncestors() + self.ancestry = list(dnp.getAncestors()) self.ancestry.reverse() self.ancestryIndex = 0 # Update the selectedNPReadout @@ -479,7 +479,7 @@ class SeSession(DirectObject): ### Customized DirectSession def isNotCycle(self, nodePath, parent): - if nodePath.id() == parent.id(): + if nodePath.get_key() == parent.get_key(): print 'DIRECT.reparent: Invalid parent' return 0 elif parent.hasParent(): @@ -520,7 +520,10 @@ class SeSession(DirectObject): ### Customized DirectSession nodePath = self.selected.last if nodePath: # Now toggle node path's visibility state - nodePath.toggleVis() + if nodePath.is_hidden(): + nodePath.show() + else: + nodePath.hide() def removeNodePath(self, nodePath = 'None Given'): if nodePath == 'None Given': diff --git a/contrib/src/sceneeditor/seTree.py b/contrib/src/sceneeditor/seTree.py index 018d6af410..9685d54b35 100644 --- a/contrib/src/sceneeditor/seTree.py +++ b/contrib/src/sceneeditor/seTree.py @@ -15,7 +15,7 @@ import os, sys, string, Pmw, Tkinter from direct.showbase.DirectObject import DirectObject from Tkinter import IntVar, Menu, PhotoImage, Label, Frame, Entry -from pandac.PandaModules import * +from panda3d.core import * # Initialize icon directory ICONDIR = getModelPath().findFile(Filename('icons')).toOsSpecific() From 3d383a3d9c04f2a7322a42e22d58f6bd8194c14f Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 10 Aug 2018 23:53:33 +0200 Subject: [PATCH 133/360] sceneeditor: get it to run with Python 3 --- contrib/src/sceneeditor/MetadataPanel.py | 2 +- contrib/src/sceneeditor/SideWindow.py | 66 ++-- contrib/src/sceneeditor/collisionWindow.py | 5 +- contrib/src/sceneeditor/controllerWindow.py | 366 +++++++++--------- contrib/src/sceneeditor/dataHolder.py | 98 ++--- contrib/src/sceneeditor/duplicateWindow.py | 4 +- contrib/src/sceneeditor/lightingPanel.py | 55 +-- contrib/src/sceneeditor/propertyWindow.py | 7 +- contrib/src/sceneeditor/quad.py | 10 +- contrib/src/sceneeditor/sceneEditor.py | 72 ++-- contrib/src/sceneeditor/seAnimPanel.py | 14 +- contrib/src/sceneeditor/seBlendAnimPanel.py | 14 +- contrib/src/sceneeditor/seCameraControl.py | 18 +- contrib/src/sceneeditor/seColorEntry.py | 10 +- contrib/src/sceneeditor/seFileSaver.py | 34 +- contrib/src/sceneeditor/seGeometry.py | 14 +- contrib/src/sceneeditor/seLights.py | 19 +- contrib/src/sceneeditor/seMopathRecorder.py | 273 ++++++------- contrib/src/sceneeditor/seParticleEffect.py | 6 +- contrib/src/sceneeditor/seParticlePanel.py | 51 +-- contrib/src/sceneeditor/seParticles.py | 6 +- contrib/src/sceneeditor/sePlacer.py | 55 +-- .../src/sceneeditor/seSceneGraphExplorer.py | 21 +- contrib/src/sceneeditor/seSelection.py | 8 +- contrib/src/sceneeditor/seSession.py | 6 +- contrib/src/sceneeditor/seTree.py | 22 +- 26 files changed, 665 insertions(+), 591 deletions(-) diff --git a/contrib/src/sceneeditor/MetadataPanel.py b/contrib/src/sceneeditor/MetadataPanel.py index 7510f3d7fc..9f6bc222f4 100644 --- a/contrib/src/sceneeditor/MetadataPanel.py +++ b/contrib/src/sceneeditor/MetadataPanel.py @@ -36,7 +36,7 @@ class MetadataPanel(AppShell,Pmw.MegaWidget): def appInit(self): - print "Metadata Panel" + print("Metadata Panel") def createInterface(self): interior = self.interior() diff --git a/contrib/src/sceneeditor/SideWindow.py b/contrib/src/sceneeditor/SideWindow.py index 58a41a05be..96c225c58f 100644 --- a/contrib/src/sceneeditor/SideWindow.py +++ b/contrib/src/sceneeditor/SideWindow.py @@ -6,8 +6,16 @@ from direct.tkwidgets.AppShell import AppShell from direct.tkwidgets.VectorWidgets import ColorEntry from direct.showbase.TkGlobal import spawnTkLoop import seSceneGraphExplorer -from Tkinter import Frame, IntVar, Checkbutton, Toplevel -import Pmw, Tkinter + +import Pmw, sys + +if sys.version_info >= (3, 0): + from tkinter import Frame, IntVar, Checkbutton, Toplevel + import tkinter +else: + from Tkinter import Frame, IntVar, Checkbutton, Toplevel + import Tkinter as tkinter + class sideWindow(AppShell): ################################################################# @@ -65,7 +73,7 @@ class sideWindow(AppShell): self.parent.resizable(False,False) ## Disable the ability to resize for this Window. def appInit(self): - print '----SideWindow is Initialized!!' + print('----SideWindow is Initialized!!') def createInterface(self): # The interior of the toplevel panel @@ -73,7 +81,7 @@ class sideWindow(AppShell): mainFrame = Frame(interior) ## Creat NoteBook self.notebookFrame = Pmw.NoteBook(mainFrame) - self.notebookFrame.pack(fill=Tkinter.BOTH,expand=1) + self.notebookFrame.pack(fill=tkinter.BOTH,expand=1) sgePage = self.notebookFrame.add('Tree Graph') envPage = self.notebookFrame.add('World Setting') self.notebookFrame['raisecommand'] = self.updateInfo @@ -83,7 +91,7 @@ class sideWindow(AppShell): sgePage, nodePath = render, scrolledCanvas_hull_width = 270, scrolledCanvas_hull_height = 570) - self.SGE.pack(fill = Tkinter.BOTH, expand = 0) + self.SGE.pack(fill = tkinter.BOTH, expand = 0) ## World Setting Page envPage = Frame(envPage) @@ -95,8 +103,8 @@ class sideWindow(AppShell): text = 'Enable Lighting', variable = self.LightingVar, command = self.toggleLights) - self.LightingButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.LightingButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.CollisionVar = IntVar() @@ -106,8 +114,8 @@ class sideWindow(AppShell): text = 'Show Collision Object', variable = self.CollisionVar, command = self.showCollision) - self.CollisionButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.CollisionButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.ParticleVar = IntVar() @@ -117,8 +125,8 @@ class sideWindow(AppShell): text = 'Show Particle Dummy', variable = self.ParticleVar, command = self.enableParticle) - self.ParticleButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.ParticleButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.baseUseDriveVar = IntVar() @@ -128,8 +136,8 @@ class sideWindow(AppShell): text = 'Enable base.usedrive', variable = self.baseUseDriveVar, command = self.enablebaseUseDrive) - self.baseUseDriveButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.baseUseDriveButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.backfaceVar = IntVar() @@ -139,8 +147,8 @@ class sideWindow(AppShell): text = 'Enable BackFace', variable = self.backfaceVar, command = self.toggleBackface) - self.backfaceButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.backfaceButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.textureVar = IntVar() @@ -150,8 +158,8 @@ class sideWindow(AppShell): text = 'Enable Texture', variable = self.textureVar, command = self.toggleTexture) - self.textureButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.textureButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.wireframeVar = IntVar() @@ -161,8 +169,8 @@ class sideWindow(AppShell): text = 'Enable Wireframe', variable = self.wireframeVar, command = self.toggleWireframe) - self.wireframeButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.wireframeButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.gridVar = IntVar() @@ -172,8 +180,8 @@ class sideWindow(AppShell): text = 'Enable Grid', variable = self.gridVar, command = self.toggleGrid) - self.gridButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.gridButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.widgetVisVar = IntVar() @@ -183,8 +191,8 @@ class sideWindow(AppShell): text = 'Enable WidgetVisible', variable = self.widgetVisVar, command = self.togglewidgetVis) - self.widgetVisButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.widgetVisButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.enableAutoCameraVar = IntVar() @@ -194,17 +202,17 @@ class sideWindow(AppShell): text = 'Enable Auto Camera Movement for Loading Objects', variable = self.enableAutoCameraVar, command = self.toggleAutoCamera) - self.enableAutoCameraButton.pack(side=Tkinter.LEFT, expand=False) - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + self.enableAutoCameraButton.pack(side=tkinter.LEFT, expand=False) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) pageFrame = Frame(envPage) self.backgroundColor = ColorEntry( pageFrame, text = 'BG Color', value=self.worldColor) self.backgroundColor['command'] = self.setBackgroundColorVec self.backgroundColor['resetValue'] = [0,0,0,0] - self.backgroundColor.pack(side=Tkinter.LEFT, expand=False) + self.backgroundColor.pack(side=tkinter.LEFT, expand=False) self.bind(self.backgroundColor, 'Set background color') - pageFrame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True) + pageFrame.pack(side=tkinter.TOP, fill=tkinter.X, expand=True) envPage.pack(expand=False) @@ -320,11 +328,11 @@ class sideWindow(AppShell): # ################################################################# if self.enableBaseUseDrive==0: - print 'Enabled' + print('Enabled') base.useDrive() self.enableBaseUseDrive = 1 else: - print 'disabled' + print('disabled') #base.useTrackball() base.disableMouse() self.enableBaseUseDrive = 0 diff --git a/contrib/src/sceneeditor/collisionWindow.py b/contrib/src/sceneeditor/collisionWindow.py index 3c6b70e607..9155db871a 100644 --- a/contrib/src/sceneeditor/collisionWindow.py +++ b/contrib/src/sceneeditor/collisionWindow.py @@ -9,7 +9,6 @@ from seColorEntry import * from direct.tkwidgets import VectorWidgets from direct.tkwidgets import Floater from direct.tkwidgets import Slider -from Tkinter import * import string, math, types from panda3d.core import * @@ -195,7 +194,7 @@ class collisionWindow(AppShell): # put the object into a CollisionNode and attach it to the target nodePath ################################################################# collisionObject = None - print self.objType + print(self.objType) if self.objType=='collisionPolygon': pointA = Point3(float(self.widgetDict['PolygonPoint A'][0]._entry.get()), float(self.widgetDict['PolygonPoint A'][1]._entry.get()), @@ -236,7 +235,7 @@ class collisionWindow(AppShell): float(self.widgetDict['RayDirection'][1]._entry.get()), float(self.widgetDict['RayDirection'][2]._entry.get())) - print vector, point + print(vector, point) collisionObject = CollisionRay() collisionObject.setOrigin(point) diff --git a/contrib/src/sceneeditor/controllerWindow.py b/contrib/src/sceneeditor/controllerWindow.py index b66e390c73..03ca35d6d8 100644 --- a/contrib/src/sceneeditor/controllerWindow.py +++ b/contrib/src/sceneeditor/controllerWindow.py @@ -4,8 +4,14 @@ ################################################################# from direct.tkwidgets.AppShell import AppShell -from Tkinter import Frame, Label, Button -import string, Pmw, Tkinter +import sys, Pmw + +if sys.version_info >= (3, 0): + from tkinter import Frame, Label, Button + import tkinter +else: + from Tkinter import Frame, Label, Button + import Tkinter as tkinter # Define the Category KEYBOARD = 'Keyboard-' @@ -75,11 +81,11 @@ class controllerWindow(AppShell): self.cotrollerTypeEntry = self.createcomponent( 'Controller Type', (), None, Pmw.ComboBox, (frame,), - labelpos = Tkinter.W, label_text='Controller Type:', entry_width = 20,entry_state = Tkinter.DISABLED, + labelpos = tkinter.W, label_text='Controller Type:', entry_width = 20,entry_state = tkinter.DISABLED, selectioncommand = self.setControllerType, scrolledlist_items = self.controllerList) - self.cotrollerTypeEntry.pack(side=Tkinter.LEFT) - frame.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=False, pady = 3) + self.cotrollerTypeEntry.pack(side=tkinter.LEFT) + frame.pack(side=tkinter.TOP, fill=tkinter.X, expand=False, pady = 3) self.cotrollerTypeEntry.selectitem('Keyboard', setentry=True) self.inputZone = Pmw.Group(mainFrame, tag_pyclass = None) @@ -102,7 +108,7 @@ class controllerWindow(AppShell): keyboardPage = self.objNotebook.add('Keyboard') tarckerPage = self.objNotebook.add('Tracker') self.objNotebook.selectpage('Keyboard') - self.objNotebook.pack(side = Tkinter.TOP, fill='both',expand=False) + self.objNotebook.pack(side = tkinter.TOP, fill='both',expand=False) # Put this here so it isn't called right away self.objNotebook['raisecommand'] = self.updateControlInfo @@ -113,11 +119,11 @@ class controllerWindow(AppShell): widget = self.createcomponent( 'Target Type', (), None, Pmw.ComboBox, (Interior,), - labelpos = Tkinter.W, label_text='Target Object:', entry_width = 20, entry_state = Tkinter.DISABLED, + labelpos = tkinter.W, label_text='Target Object:', entry_width = 20, entry_state = tkinter.DISABLED, selectioncommand = self.setTargetObj, scrolledlist_items = self.listOfObj) - widget.pack(side=Tkinter.LEFT, padx=3) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 5) + widget.pack(side=tkinter.LEFT, padx=3) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 5) widget.selectitem(self.nameOfNode, setentry=True) self.widgetsDict[KEYBOARD+'ObjList'] = widget @@ -126,411 +132,411 @@ class controllerWindow(AppShell): settingFrame = inputZone.interior() Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Assign a Key For:').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True,pady = 6 ) + widget = Label(Interior, text = 'Assign a Key For:').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True,pady = 6 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Forward :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Forward :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Forward key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyForward'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyForward'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Forward Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedForward'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedForward'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Backward :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Backward :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Backward key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyBackward'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyBackward'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Backward Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedBackward'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedBackward'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Right :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Right :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Right key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyRight'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyRight'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Right Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedRight'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedRight'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Left :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Left :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Left key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyLeft'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyLeft'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Left Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedLeft'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedLeft'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Up :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Up :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Up key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Up Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Down :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Down :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Down Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Turn Right:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Turn Right:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Right key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyTurnRight'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyTurnRight'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Right Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedTurnRight'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedTurnRight'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Turn Left :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Turn Left :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Left key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyTurnLeft'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyTurnLeft'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Left Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedTurnLeft'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedTurnLeft'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Turn UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Turn UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyTurnUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyTurnUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedTurnUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedTurnUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Turn Down :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Turn Down :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyTurnDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyTurnDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Turn Down Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedTurnDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedTurnDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Roll Right:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Roll Right:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Roll Right key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyRollRight'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyRollRight'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Roll Right Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedRollRight'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedRollRight'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Roll Left :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Roll Left :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Roll Left key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyRollLeft'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyRollLeft'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Roll Left Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedRollLeft'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedRollLeft'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Down:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Down:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale X UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale X UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale X UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleXUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleXUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale X UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleXUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleXUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale X Down:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale X Down:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale X Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleXDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleXDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down X Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleXDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleXDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Y UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Y UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Y UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleYUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleYUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Y UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleYUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleYUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Y Down:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Y Down:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Y Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleYDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleYDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down XY Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleYDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleYDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Z UP :', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Z UP :', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Z UP key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleZUp'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleZUp'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Z UP Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleZUp'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleZUp'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) Interior = Frame(settingFrame) - widget = Label(Interior, text = 'Scale Z Down:', width = 20, anchor = Tkinter.W).pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = 'Scale Z Down:', width = 20, anchor = tkinter.W).pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Z Down key', (), None, Pmw.EntryField, (Interior,), value = self.keyboardMapDict['KeyScaleZDown'], - labelpos = Tkinter.W, label_text='Key :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Key :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'KeyScaleZDown'] = widget - widget = Label(Interior, text = ' ').pack(side=Tkinter.LEFT, expand = False) + widget = Label(Interior, text = ' ').pack(side=tkinter.LEFT, expand = False) widget = self.createcomponent( 'Scale Down Z Speed', (), None, Pmw.EntryField, (Interior,), value = self.keyboardSpeedDict['SpeedScaleZDown'], - labelpos = Tkinter.W, label_text='Speed :', entry_width = 10) - widget.pack(side=Tkinter.LEFT, expand = False) + labelpos = tkinter.W, label_text='Speed :', entry_width = 10) + widget.pack(side=tkinter.LEFT, expand = False) self.widgetsDict[KEYBOARD+'SpeedScaleZDown'] = widget - widget = Label(Interior, text = 'Per Second').pack(side=Tkinter.LEFT, expand = False) - Interior.pack(side=Tkinter.TOP, fill=Tkinter.X, expand=True, pady = 4 ) + widget = Label(Interior, text = 'Per Second').pack(side=tkinter.LEFT, expand = False) + Interior.pack(side=tkinter.TOP, fill=tkinter.X, expand=True, pady = 4 ) - assignFrame.pack(side=Tkinter.TOP, expand=True, fill = Tkinter.X) - keyboardPage.pack(side=Tkinter.TOP, expand=True, fill = Tkinter.X) + assignFrame.pack(side=tkinter.TOP, expand=True, fill = tkinter.X) + keyboardPage.pack(side=tkinter.TOP, expand=True, fill = tkinter.X) #################################################################### #################################################################### @@ -539,12 +545,12 @@ class controllerWindow(AppShell): #################################################################### # Pack the mainFrame frame = Frame(mainFrame) - widget = Button(frame, text='OK', width = 13, command=self.ok_press).pack(side=Tkinter.RIGHT) - widget = Button(frame, text='Enable Control', width = 13, command=self.enableControl).pack(side=Tkinter.LEFT) - widget = Button(frame, text='Disable Control', width = 13, command=self.disableControl).pack(side=Tkinter.LEFT) - widget = Button(frame, text='Save & Keep', width = 13, command=self.saveKeepControl).pack(side=Tkinter.LEFT) - frame.pack(side = Tkinter.BOTTOM, expand=1, fill = Tkinter.X) - mainFrame.pack(expand=1, fill = Tkinter.BOTH) + widget = Button(frame, text='OK', width = 13, command=self.ok_press).pack(side=tkinter.RIGHT) + widget = Button(frame, text='Enable Control', width = 13, command=self.enableControl).pack(side=tkinter.LEFT) + widget = Button(frame, text='Disable Control', width = 13, command=self.disableControl).pack(side=tkinter.LEFT) + widget = Button(frame, text='Save & Keep', width = 13, command=self.saveKeepControl).pack(side=tkinter.LEFT) + frame.pack(side = tkinter.BOTTOM, expand=1, fill = tkinter.X) + mainFrame.pack(expand=1, fill = tkinter.BOTH) def onDestroy(self, event): # Check if user wish to keep the control after the window closed. @@ -688,7 +694,7 @@ class controllerWindow(AppShell): self.keyboardMapDict[index] = self.widgetsDict['Keyboard-'+index].getvalue() for index in self.keyboardSpeedDict: self.keyboardSpeedDict[index] = float(self.widgetsDict['Keyboard-'+index].getvalue()) - print self.nodePath + print(self.nodePath) messenger.send('ControlW_saveSetting', ['Keyboard', [self.nodePath, self.keyboardMapDict, self.keyboardSpeedDict]]) return diff --git a/contrib/src/sceneeditor/dataHolder.py b/contrib/src/sceneeditor/dataHolder.py index 0981df643d..4e01ab2fa4 100644 --- a/contrib/src/sceneeditor/dataHolder.py +++ b/contrib/src/sceneeditor/dataHolder.py @@ -2,13 +2,15 @@ # TK and PMW INTERFACE MODULES# ############################### from direct.showbase.TkGlobal import* -from tkFileDialog import * import Pmw -import tkFileDialog -import tkMessageBox from direct.tkwidgets import Dial from direct.tkwidgets import Floater +if sys.version_info >= (3, 0): + from tkinter.filedialog import askopenfilename +else: + from tkFileDialog import askopenfilename + ############################# # Scene Editor Python Files # @@ -154,7 +156,7 @@ class dataHolder: self.ActorNum=0 self.theScene=None messenger.send('SGE_Update Explorer',[render]) - print 'Scene should be cleaned up!' + print('Scene should be cleaned up!') def removeObj(self, nodePath): ################################################################# @@ -169,7 +171,7 @@ class dataHolder: childrenList = nodePath.getChildren() - if self.ModelDic.has_key(name): + if name in self.ModelDic: del self.ModelDic[name] del self.ModelRefDic[name] if len(childrenList) != 0: @@ -178,7 +180,7 @@ class dataHolder: nodePath.removeNode() self.ModelNum -= 1 pass - elif self.ActorDic.has_key(name): + elif name in self.ActorDic: del self.ActorDic[name] del self.ActorRefDic[name] if len(childrenList) != 0: @@ -187,14 +189,14 @@ class dataHolder: nodePath.removeNode() self.ActorNum -= 1 pass - elif self.collisionDict.has_key(name): + elif name in self.collisionDict: del self.collisionDict[name] if len(childrenList) != 0: for node in childrenList: self.removeObj(node) nodePath.removeNode() pass - elif self.dummyDict.has_key(name): + elif name in self.dummyDict: del self.dummyDict[name] if len(childrenList) != 0: for node in childrenList: @@ -207,12 +209,12 @@ class dataHolder: self.removeObj(node) list = self.lightManager.delete(name) return list - elif self.particleNodes.has_key(name): + elif name in self.particleNodes: self.particleNodes[name].removeNode() del self.particleNodes[name] del self.particleDict[name] else: - print 'You cannot remove this NodePath' + print('You cannot remove this NodePath') return messenger.send('SGE_Update Explorer',[render]) @@ -237,15 +239,15 @@ class dataHolder: cHpr = hpr cScale = scale parent = nodePath.getParent() - if self.ActorDic.has_key(name): + if name in self.ActorDic: holder = self.ActorDic holderRef = self.ActorRefDic isModel = False - elif self.ModelDic.has_key(name): + elif name in self.ModelDic: holder = self.ModelDic holderRef = self.ModelRefDic else: - print '---- DataHolder: Target Obj is not a legal object could be duplicate!' + print('---- DataHolder: Target Obj is not a legal object could be duplicate!') return FilePath = holderRef[name] @@ -356,7 +358,7 @@ class dataHolder: # This funciton will return True if there is an Actor in the scene named "name" # and will return False if not. ########################################################################### - return self.ActorDic.has_key(name) + return name in self.ActorDic def getActor(self, name): ########################################################################### @@ -366,7 +368,7 @@ class dataHolder: if self.isActor(name): return self.ActorDic[name] else: - print '----No Actor named: ', name + print('----No Actor named: ', name) return None def getModel(self, name): @@ -377,7 +379,7 @@ class dataHolder: if self.isModel(name): return self.ModelDic[name] else: - print '----No Model named: ', name + print('----No Model named: ', name) return None def isModel(self, name): @@ -386,7 +388,7 @@ class dataHolder: # This funciton will return True if there is a Model in the scene named "name" # and will return False if not. ########################################################################### - return self.ModelDic.has_key(name) + return name in self.ModelDic def loadAnimation(self,name, Dic): ########################################################################### @@ -406,7 +408,7 @@ class dataHolder: messenger.send('DataH_loadFinish'+name) return else: - print '------ Error when loading animation for Actor: ', name + print('------ Error when loading animation for Actor: ', name) def removeAnimation(self, name, anim): ########################################################################### @@ -527,7 +529,7 @@ class dataHolder: self.ActorDic[nName]= self.ActorDic[oName] self.ActorRefDic[nName]= self.ActorRefDic[oName] self.ActorDic[nName].setName(nName) - if self.blendAnimDict.has_key(oName): + if oName in self.blendAnimDict: self.blendAnimDict[nName] = self.blendAnimDict[oName] del self.blendAnimDict[oName] del self.ActorDic[oName] @@ -540,16 +542,16 @@ class dataHolder: del self.ModelRefDic[oName] elif self.lightManager.isLight(oName): list, lightNode = self.lightManager.rename(oName, nName) - elif self.dummyDict.has_key(oName): + elif oName in self.dummyDict: self.dummyDict[nName]= self.dummyDict[oName] self.dummyDict[nName].setName(nName) del self.dummyDict[oName] - elif self.collisionDict.has_key(oName): + elif oName in self.collisionDict: self.collisionDict[nName]= self.collisionDict[oName] self.collisionDict[nName].setName(nName) del self.collisionDict[oName] - elif self.particleNodes.has_key(oName): + elif oName in self.particleNodes: self.particleNodes[nName]= self.particleNodes[oName] self.particleDict[nName]= self.particleDict[oName] self.particleDict[nName].setName(nName) @@ -557,9 +559,9 @@ class dataHolder: del self.particleNodes[oName] del self.particleDict[oName] else: - print '----Error: This Object is not allowed to this function!' + print('----Error: This Object is not allowed to this function!') - if self.curveDict.has_key(oName): + if oName in self.curveDict: self.curveDict[nName] = self.curveDict[oName] del self.curveDict[oName] @@ -578,11 +580,11 @@ class dataHolder: return True elif self.lightManager.isLight(name): return True - elif self.dummyDict.has_key(name): + elif name in self.dummyDict: return True - elif self.collisionDict.has_key(name): + elif name in self.collisionDict: return True - elif self.particleNodes.has_key(name): + elif name in self.particleNodes: return True elif (name == 'render')or(name == 'SEditor')or(name == 'Lights')or(name == 'camera'): return True @@ -596,7 +598,7 @@ class dataHolder: # using the node name as a reference to assosiate a list which contains all curves related to that node. ########################################################################### name = node.getName() - if self.curveDict.has_key(name): + if name in self.curveDict: self.curveDict[name].append(curveCollection) return else: @@ -612,7 +614,7 @@ class dataHolder: # If the input node has not been bindedwith any curve, it will return None. ########################################################################### name = nodePath.getName() - if self.curveDict.has_key(name): + if name in self.curveDict: return self.curveDict[name] else: return None @@ -626,7 +628,7 @@ class dataHolder: # This message will be caught by Property Window for this node. ########################################################################### name =nodePath.getName() - if self.curveDict.has_key(name): + if name in self.curveDict: index = None for curve in self.curveDict[name]: if curve.getCurve(0).getName() == curveName: @@ -677,12 +679,12 @@ class dataHolder: elif self.isLight(name): type = 'Light' info['lightNode'] = self.lightManager.getLightNode(name) - elif self.dummyDict.has_key(name): + elif name in self.dummyDict: type = 'dummy' - elif self.collisionDict.has_key(name): + elif name in self.collisionDict: type = 'collisionNode' info['collisionNode'] = self.collisionDict[name] - if self.curveDict.has_key(name): + if name in self.curveDict: info['curveList'] = self.getCurveList(nodePath) return type, info @@ -794,7 +796,7 @@ class dataHolder: # The formate of thsi dictionary is # {"name of Blend Animation" : ["Animation A, Animation B, Effect(Float, 0~1)"]} ########################################################################### - if self.blendAnimDict.has_key(name): + if name in self.blendAnimDict: return self.blendAnimDict[name] else: return {} @@ -808,8 +810,8 @@ class dataHolder: # Also, if this blend is the first blend animation that the target actor has, # this function will add a "Blending" tag on this actor which is "True". ########################################################################### - if self.blendAnimDict.has_key(actorName): - if self.blendAnimDict[actorName].has_key(blendName): + if actorName in self.blendAnimDict: + if blendName in self.blendAnimDict[actorName]: ### replace the original setting self.blendAnimDict[actorName][blendName][0] = animNameA self.blendAnimDict[actorName][blendName][1] = animNameB @@ -832,7 +834,7 @@ class dataHolder: # it will also rewrite the data to the newest one. ########################################################################### self.removeBlendAnim(actorName,oName) - print self.blendAnimDict + print(self.blendAnimDict) return self.saveBlendAnim(actorName, nName, animNameA, animNameB, effect) def removeBlendAnim(self, actorName, blendName): @@ -844,8 +846,8 @@ class dataHolder: # Also, it will check that there is any blended animation remained for this actor, # If none, this function will clear the "Blending" tag of this object. ########################################################################### - if self.blendAnimDict.has_key(actorName): - if self.blendAnimDict[actorName].has_key(blendName): + if actorName in self.blendAnimDict: + if blendName in self.blendAnimDict[actorName]: ### replace the original setting del self.blendAnimDict[actorName][blendName] if len(self.blendAnimDict[actorName])==0: @@ -876,15 +878,15 @@ class dataHolder: ########################################################################### if name == 'camera': return camera - elif self.ModelDic.has_key(name): + elif name in self.ModelDic: return self.ModelDic[name] - elif self.ActorDic.has_key(name): + elif name in self.ActorDic: return self.ActorDic[name] - elif self.collisionDict.has_key(name): + elif name in self.collisionDict: return self.collisionDict[name] - elif self.dummyDict.has_key(name): + elif name in self.dummyDict: return self.dummyDict[name] - elif self.particleNodes.has_key(name): + elif name in self.particleNodes: return self.particleNodes[name] elif self.lightManager.isLight(name): return self.lightManager.getLightNode(name) @@ -935,13 +937,13 @@ class dataHolder: ########################################################################### ### Ask for a filename - OpenFilename = tkFileDialog.askopenfilename(filetypes = [("PY","py")],title = "Load Scene") + OpenFilename = askopenfilename(filetypes = [("PY","py")],title = "Load Scene") if(not OpenFilename): return None f=Filename.fromOsSpecific(OpenFilename) fileName=f.getBasenameWoExtension() dirName=f.getFullpathWoExtension() - print "DATAHOLDER::" + dirName + print("DATAHOLDER::" + dirName) ############################################################################ # Append the path to this file to our sys path where python looks for modules # We do this so that we can use "import" on our saved scene code and execute it @@ -976,7 +978,7 @@ class dataHolder: self.ActorDic[actor]=self.Scene.ActorDic[actor] #self.ActorRefDic[actor]=self.Scene.ActorRefDic[actor] # Old way of doing absolute paths self.ActorRefDic[actor]=Filename(dirName + "/" + self.Scene.ActorRefDic[actor]) # Relative Paths - if(self.Scene.blendAnimDict.has_key(str(actor))): + if(str(actor) in self.Scene.blendAnimDict): self.blendAnimDict[actor]=self.Scene.blendAnimDict[actor] self.ActorNum=self.ActorNum+1 @@ -1006,7 +1008,7 @@ class dataHolder: atten=alight.getAttenuation() self.lightManager.create('spot',alight.getColor(),alight.getSpecularColor(),thenode.getPos(),thenode.getHpr(),atten.getX(),atten.getY(),atten.getZ(),alight.getExponent(),name=alight.getName(),tag=thenode.getTag("Metadata")) else: - print 'Invalid light type' + print('Invalid light type') ############################################################################ # Populate Dummy related Dictionaries diff --git a/contrib/src/sceneeditor/duplicateWindow.py b/contrib/src/sceneeditor/duplicateWindow.py index 24f20b7d09..b82a5449e1 100644 --- a/contrib/src/sceneeditor/duplicateWindow.py +++ b/contrib/src/sceneeditor/duplicateWindow.py @@ -45,7 +45,7 @@ class duplicateWindow(AppShell): self.parent.resizable(False,False) ## Disable the ability to resize for this Window. def appInit(self): - print '----SideWindow is Initialized!!' + print('----SideWindow is Initialized!!') def createInterface(self): # The interior of the toplevel panel @@ -122,7 +122,7 @@ class duplicateWindow(AppShell): # This message will be caught by sceneEditor. ################################################################# if not self.allEntryValid(): - print '---- Duplication Window: Invalid value!!' + print('---- Duplication Window: Invalid value!!') return x = self.move_x.getvalue() y = self.move_y.getvalue() diff --git a/contrib/src/sceneeditor/lightingPanel.py b/contrib/src/sceneeditor/lightingPanel.py index 729186a78d..eeb8cafa20 100644 --- a/contrib/src/sceneeditor/lightingPanel.py +++ b/contrib/src/sceneeditor/lightingPanel.py @@ -7,10 +7,17 @@ from direct.tkwidgets.AppShell import AppShell from seColorEntry import * from direct.tkwidgets.VectorWidgets import Vector3Entry from direct.tkwidgets.Slider import Slider -from Tkinter import Frame, Button, Menubutton, Menu -import string, math, types, Pmw, Tkinter +import sys, math, types, Pmw from panda3d.core import * +if sys.version_info >= (3, 0): + from tkinter import Frame, Button, Menubutton, Menu + import tkinter +else: + from Tkinter import Frame, Button, Menubutton, Menu + import Tkinter as tkinter + + class lightingPanel(AppShell): ################################################################# # lightingPanel(AppShell) @@ -51,25 +58,25 @@ class lightingPanel(AppShell): mainFrame = Frame(interior) self.listZone = Pmw.Group(mainFrame,tag_pyclass = None) - self.listZone.pack(expand=0, fill=Tkinter.X,padx=3,pady=3) + self.listZone.pack(expand=0, fill=tkinter.X,padx=3,pady=3) listFrame = self.listZone.interior() self.lightEntry = self.createcomponent( 'Lights List', (), None, Pmw.ComboBox, (listFrame,),label_text='Light :', - labelpos = Tkinter.W, entry_width = 25, selectioncommand = self.selectLight, + labelpos = tkinter.W, entry_width = 25, selectioncommand = self.selectLight, scrolledlist_items = self.lightList) - self.lightEntry.pack(side=Tkinter.LEFT) + self.lightEntry.pack(side=tkinter.LEFT) self.renameButton = self.createcomponent( 'Rename Light', (), None, Button, (listFrame,), text = ' Rename ', command = self.renameLight) - self.renameButton.pack(side=Tkinter.LEFT) + self.renameButton.pack(side=tkinter.LEFT) self.addLighZone = Pmw.Group(listFrame,tag_pyclass = None) - self.addLighZone.pack(side=Tkinter.LEFT) + self.addLighZone.pack(side=tkinter.LEFT) insideFrame = self.addLighZone.interior() self.lightsButton = Menubutton(insideFrame, text = 'Add light',borderwidth = 3, activebackground = '#909090') @@ -91,13 +98,13 @@ class lightingPanel(AppShell): Button, (listFrame,), text = ' Delete ', command = self.deleteLight) - self.deleteButton.pack(side=Tkinter.LEFT) + self.deleteButton.pack(side=tkinter.LEFT) self.lightColor = seColorEntry( mainFrame, text = 'Light Color', value=self.lightColor) self.lightColor['command'] = self.setLightingColorVec self.lightColor['resetValue'] = [0.3*255,0.3*255,0.3*255,0] - self.lightColor.pack(fill=Tkinter.X,expand=0) + self.lightColor.pack(fill=tkinter.X,expand=0) self.bind(self.lightColor, 'Set light color') # Notebook pages for light specific controls @@ -114,27 +121,27 @@ class lightingPanel(AppShell): self.dSpecularColor = seColorEntry( directionalPage, text = 'Specular Color') self.dSpecularColor['command'] = self.setSpecularColor - self.dSpecularColor.pack(fill = Tkinter.X, expand = 0) + self.dSpecularColor.pack(fill = tkinter.X, expand = 0) self.bind(self.dSpecularColor, 'Set directional light specular color') self.dPosition = Vector3Entry( directionalPage, text = 'Position') self.dPosition['command'] = self.setPosition self.dPosition['resetValue'] = [0,0,0,0] - self.dPosition.pack(fill = Tkinter.X, expand = 0) + self.dPosition.pack(fill = tkinter.X, expand = 0) self.bind(self.dPosition, 'Set directional light position') self.dOrientation = Vector3Entry( directionalPage, text = 'Orientation') self.dOrientation['command'] = self.setOrientation self.dOrientation['resetValue'] = [0,0,0,0] - self.dOrientation.pack(fill = Tkinter.X, expand = 0) + self.dOrientation.pack(fill = tkinter.X, expand = 0) self.bind(self.dOrientation, 'Set directional light orientation') # Point light controls self.pSpecularColor = seColorEntry( pointPage, text = 'Specular Color') self.pSpecularColor['command'] = self.setSpecularColor - self.pSpecularColor.pack(fill = Tkinter.X, expand = 0) + self.pSpecularColor.pack(fill = tkinter.X, expand = 0) self.bind(self.pSpecularColor, 'Set point light specular color') @@ -142,7 +149,7 @@ class lightingPanel(AppShell): pointPage, text = 'Position') self.pPosition['command'] = self.setPosition self.pPosition['resetValue'] = [0,0,0,0] - self.pPosition.pack(fill = Tkinter.X, expand = 0) + self.pPosition.pack(fill = tkinter.X, expand = 0) self.bind(self.pPosition, 'Set point light position') self.pConstantAttenuation = Slider( @@ -152,7 +159,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 1.0) self.pConstantAttenuation['command'] = self.setConstantAttenuation - self.pConstantAttenuation.pack(fill = Tkinter.X, expand = 0) + self.pConstantAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.pConstantAttenuation, 'Set point light constant attenuation') @@ -163,7 +170,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.pLinearAttenuation['command'] = self.setLinearAttenuation - self.pLinearAttenuation.pack(fill = Tkinter.X, expand = 0) + self.pLinearAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.pLinearAttenuation, 'Set point light linear attenuation') @@ -174,7 +181,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.pQuadraticAttenuation['command'] = self.setQuadraticAttenuation - self.pQuadraticAttenuation.pack(fill = Tkinter.X, expand = 0) + self.pQuadraticAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.pQuadraticAttenuation, 'Set point light quadratic attenuation') @@ -182,7 +189,7 @@ class lightingPanel(AppShell): self.sSpecularColor = seColorEntry( spotPage, text = 'Specular Color') self.sSpecularColor['command'] = self.setSpecularColor - self.sSpecularColor.pack(fill = Tkinter.X, expand = 0) + self.sSpecularColor.pack(fill = tkinter.X, expand = 0) self.bind(self.sSpecularColor, 'Set spot light specular color') @@ -193,7 +200,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 1.0) self.sConstantAttenuation['command'] = self.setConstantAttenuation - self.sConstantAttenuation.pack(fill = Tkinter.X, expand = 0) + self.sConstantAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.sConstantAttenuation, 'Set spot light constant attenuation') @@ -204,7 +211,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.sLinearAttenuation['command'] = self.setLinearAttenuation - self.sLinearAttenuation.pack(fill = Tkinter.X, expand = 0) + self.sLinearAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.sLinearAttenuation, 'Set spot light linear attenuation') @@ -215,7 +222,7 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.sQuadraticAttenuation['command'] = self.setQuadraticAttenuation - self.sQuadraticAttenuation.pack(fill = Tkinter.X, expand = 0) + self.sQuadraticAttenuation.pack(fill = tkinter.X, expand = 0) self.bind(self.sQuadraticAttenuation, 'Set spot light quadratic attenuation') @@ -226,16 +233,16 @@ class lightingPanel(AppShell): resolution = 0.01, value = 0.0) self.sExponent['command'] = self.setExponent - self.sExponent.pack(fill = Tkinter.X, expand = 0) + self.sExponent.pack(fill = tkinter.X, expand = 0) self.bind(self.sExponent, 'Set spot light exponent') # MRM: Add frustum controls self.lightNotebook.setnaturalsize() - self.lightNotebook.pack(expand = 1, fill = Tkinter.BOTH) + self.lightNotebook.pack(expand = 1, fill = tkinter.BOTH) - mainFrame.pack(expand=1, fill = Tkinter.BOTH) + mainFrame.pack(expand=1, fill = tkinter.BOTH) def onDestroy(self, event): messenger.send('LP_close') diff --git a/contrib/src/sceneeditor/propertyWindow.py b/contrib/src/sceneeditor/propertyWindow.py index 7406d33ffa..d741324271 100644 --- a/contrib/src/sceneeditor/propertyWindow.py +++ b/contrib/src/sceneeditor/propertyWindow.py @@ -12,7 +12,6 @@ from direct.tkwidgets import Dial from direct.tkwidgets import Slider from direct.tkwidgets import VectorWidgets from panda3d.core import * -from Tkinter import * import Pmw class propertyWindow(AppShell,Pmw.MegaWidget): @@ -108,7 +107,7 @@ class propertyWindow(AppShell,Pmw.MegaWidget): self.curveFrame = None #### If nodePath has been binded with any curves - if self.info.has_key('curveList'): + if 'curveList' in self.info: self.createCurveFrame(self.contentFrame) ## Set all stuff done @@ -271,7 +270,7 @@ class propertyWindow(AppShell,Pmw.MegaWidget): # And, it will set the call back function to setNodeColorVec() ################################################################# color = self.nodePath.getColor() - print color + print(color) self.nodeColor = VectorWidgets.ColorEntry( contentFrame, text = 'Node Color', value=[color.getX()*255, color.getY()*255, @@ -725,7 +724,7 @@ class propertyWindow(AppShell,Pmw.MegaWidget): # But, not directly removed be this function. # This function will send out a message to notice dataHolder to remove this animation ################################################################# - print anim + print(anim) widget = self.widgetsDict[anim] self.accept('animRemovedFromNode',self.redrawAnimProperty) messenger.send('PW_removeAnimFromNode',[self.name, anim]) diff --git a/contrib/src/sceneeditor/quad.py b/contrib/src/sceneeditor/quad.py index 329dcb92a3..6f4fcf03d0 100644 --- a/contrib/src/sceneeditor/quad.py +++ b/contrib/src/sceneeditor/quad.py @@ -504,7 +504,7 @@ class QuadView(DirectObject): ansY=-1.0+y2 self.xy=[ansX,ansY] - print "Sent X:%f Sent Y:%f"%(ansX,ansY) + print("Sent X:%f Sent Y:%f"%(ansX,ansY)) #SEditor.iRay.pick(render,self.xy) SEditor.manipulationControl.manipulationStop(self.xy) #print "MouseX " + str(base.mouseWatcherNode.getMouseX()) + "MouseY " + str(base.mouseWatcherNode.getMouseY()) + "\n" @@ -548,28 +548,28 @@ class QuadView(DirectObject): dr.setDimensions(0.5,1,0,0.5) def setLeft(self): - print "LEFT" + print("LEFT") self.CurrentQuad=3 self.ChangeBaseDR() self.Left.setCam() #self.Left.setDR(self.mouseWatcherNode) def setTop(self): - print "TOP" + print("TOP") self.CurrentQuad=2 self.ChangeBaseDR() self.Top.setCam() #self.Top.setDR(self.mouseWatcherNode) def setPerspective(self): - print "PERSPECTIVE" + print("PERSPECTIVE") self.CurrentQuad=4 self.ChangeBaseDR() self.Perspective.setCam() #self.Perspective.setDR(self.mouseWatcherNode) def setFront(self): - print "FRONT" + print("FRONT") self.CurrentQuad=1 self.ChangeBaseDR() self.Front.setCam() diff --git a/contrib/src/sceneeditor/sceneEditor.py b/contrib/src/sceneeditor/sceneEditor.py index 37d05c3a08..1565e9eaed 100644 --- a/contrib/src/sceneeditor/sceneEditor.py +++ b/contrib/src/sceneeditor/sceneEditor.py @@ -8,8 +8,14 @@ from direct.showbase.ShowBase import ShowBase ShowBase() from direct.showbase.TkGlobal import spawnTkLoop -from Tkinter import * -from tkFileDialog import * + +if sys.version_info >= (3, 0): + from tkinter import * + from tkinter.filedialog import * +else: + from Tkinter import * + from tkFileDialog import * + from direct.directtools.DirectGlobals import * from direct.tkwidgets.AppShell import* @@ -391,31 +397,31 @@ class myLevelEditor(AppShell): self.showAbout() return elif buttonIndex==12: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==13: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==14: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==15: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==16: - print "Your scene will be eliminated within five seconds, Save your world!!!, Number %d."%buttonIndex + print("Your scene will be eliminated within five seconds, Save your world!!!, Number %d."%buttonIndex) return elif buttonIndex==17: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==18: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==19: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return elif buttonIndex==20: - print "You haven't defined the function for this Button, Number %d."%buttonIndex + print("You haven't defined the function for this Button, Number %d."%buttonIndex) return return @@ -671,17 +677,17 @@ class myLevelEditor(AppShell): ################################################################# type, info = AllScene.getInfoOfThisNode(nodePath) name = nodePath.getName() - if not self.propertyWindow.has_key(name): + if name not in self.propertyWindow: self.propertyWindow[name] = propertyWindow(nodePath, type,info ) pass def closePropertyWindow(self, name): - if self.propertyWindow.has_key(name): + if name in self.propertyWindow: del self.propertyWindow[name] return def openMetadataPanel(self,nodePath=None): - print nodePath + print(nodePath) self.MetadataPanel=MetadataPanel(nodePath) pass @@ -690,7 +696,7 @@ class myLevelEditor(AppShell): # duplicate(self, nodePath = None) # This function will be called when user try to open the duplication window ################################################################# - print '----Duplication!!' + print('----Duplication!!') if nodePath != None: self.duplicateWindow = duplicateWindow(nodePath = nodePath) pass @@ -796,8 +802,8 @@ class myLevelEditor(AppShell): ################################################################# name = nodePath.getName() if AllScene.isActor(name): - if self.animPanel.has_key(name): - print '---- You already have an animation panel for this Actor!' + if name in self.animPanel: + print('---- You already have an animation panel for this Actor!') return else: Actor = AllScene.getActor(name) @@ -847,9 +853,9 @@ class myLevelEditor(AppShell): # Let us actually remove the scene from sys modules... this is done because every scene is loaded as a module # And if we reload a scene python wont reload since its already in sys.modules... and hence we delete it # If there is ever a garbage colleciton bug..this might be a point to look at - if sys.modules.has_key(currentModName): + if currentModName in sys.modules: del sys.modules[currentModName] - print sys.getrefcount(AllScene.theScene) + print(sys.getrefcount(AllScene.theScene)) del AllScene.theScene else: AllScene.resetAll() @@ -877,9 +883,9 @@ class myLevelEditor(AppShell): # Let us actually remove the scene from sys modules... this is done because every scene is loaded as a module # And if we reload a scene python wont reload since its already in sys.modules... and hence we delete it # If there is ever a garbage colleciton bug..this might be a point to look at - if sys.modules.has_key(currentModName): + if currentModName in sys.modules: del sys.modules[currentModName] - print sys.getrefcount(AllScene.theScene) + print(sys.getrefcount(AllScene.theScene)) del AllScene.theScene else: AllScene.resetAll() @@ -891,7 +897,7 @@ class myLevelEditor(AppShell): thefile=Filename(self.CurrentFileName) thedir=thefile.getFullpathWoExtension() - print "SCENE EDITOR::" + thedir + print("SCENE EDITOR::" + thedir) self.CurrentDirName=thedir if self.CurrentFileName != None: self.parent.title('Scene Editor - '+ Filename.fromOsSpecific(self.CurrentFileName).getBasenameWoExtension()) @@ -939,7 +945,7 @@ class myLevelEditor(AppShell): theScene.writeBamFile(fileName) else: render.writeBamFile(fileName+".bad") - print " Scenegraph saved as :" +str(fileName) + print(" Scenegraph saved as :" +str(fileName)) def loadFromBam(self): fileName = tkFileDialog.askopenfilename(filetypes = [("BAM",".bam")],title = "Load Scenegraph from Bam file") @@ -964,7 +970,7 @@ class myLevelEditor(AppShell): ############################################################################### # !!!!! See if a module exists by this name... if it does you cannot use this filename !!!!! ############################################################################### - if(sys.modules.has_key(fCheck.getBasenameWoExtension())): + if(fCheck.getBasenameWoExtension() in sys.modules): tkMessageBox.showwarning( "Save file", "Cannot save with this name because there is a system module with the same name. Please resave as something else." @@ -998,7 +1004,7 @@ class myLevelEditor(AppShell): if modelFilename: self.makeDirty() if not AllScene.loadModel(modelFilename, Filename.fromOsSpecific(modelFilename)): - print '----Error! No Such Model File!' + print('----Error! No Such Model File!') pass def loadActor(self): @@ -1021,12 +1027,12 @@ class myLevelEditor(AppShell): if ActorFilename: self.makeDirty() if not AllScene.loadActor(ActorFilename, Filename.fromOsSpecific(ActorFilename)): - print '----Error! No Such Model File!' + print('----Error! No Such Model File!') pass def importScene(self): self.makeDirty() - print '----God bless you Please Import!' + print('----God bless you Please Import!') pass @@ -1500,7 +1506,7 @@ class myLevelEditor(AppShell): return def animPanelClose(self, name): - if self.animPanel.has_key(name): + if name in self.animPanel: del self.animPanel[name] return @@ -1513,8 +1519,8 @@ class myLevelEditor(AppShell): ################################################################ name = nodePath.getName() if AllScene.isActor(name): - if self.animBlendPanel.has_key(name): - print '---- You already have an Blend Animation Panel for this Actor!' + if name in self.animBlendPanel: + print('---- You already have an Blend Animation Panel for this Actor!') return else: Actor = AllScene.getActor(name) @@ -1559,7 +1565,7 @@ class myLevelEditor(AppShell): # This function will be called when Blend panel has been closed. # Here we will reset the reference dictionary so it can be open again. ################################################################ - if self.animBlendPanel.has_key(name): + if name in self.animBlendPanel: del self.animBlendPanel[name] return @@ -1618,7 +1624,7 @@ class myLevelEditor(AppShell): def openAlignPanel(self, nodePath=None): name = nodePath.getName() - if not self.alignPanelDict.has_key(name): + if name not in self.alignPanelDict: list = AllScene.getAllObjNameAsList() if name in list: list.remove(name) @@ -1628,7 +1634,7 @@ class myLevelEditor(AppShell): return def closeAlignPanel(self, name=None): - if self.alignPanelDict.has_key(name): + if name in self.alignPanelDict: del self.alignPanelDict[name] def alignObject(self, nodePath, name, list): diff --git a/contrib/src/sceneeditor/seAnimPanel.py b/contrib/src/sceneeditor/seAnimPanel.py index 86c245a3ef..2dd3ceee53 100644 --- a/contrib/src/sceneeditor/seAnimPanel.py +++ b/contrib/src/sceneeditor/seAnimPanel.py @@ -5,12 +5,16 @@ # Import Tkinter, Pmw, and the floater code from this directory tree. from direct.tkwidgets.AppShell import * from direct.showbase.TkGlobal import * -from tkSimpleDialog import askfloat import string import math import types from direct.task import Task +if sys.version_info >= (3, 0): + from tkinter.simpledialog import askfloat +else: + from tkSimpleDialog import askfloat + FRAMES = 0 SECONDS = 1 @@ -112,7 +116,7 @@ class AnimPanel(AppShell): self.playRateEntry.selectitem('1.0') ### Loop checkbox - Label(actorFrame, text= "Loop:", font=('MSSansSerif', 12)).place(x=420,y=05,anchor=NW) + Label(actorFrame, text= "Loop:", font=('MSSansSerif', 12)).place(x=420,y=5,anchor=NW) self.loopVar = IntVar() self.loopVar.set(0) @@ -250,7 +254,7 @@ class AnimPanel(AppShell): self['animList'] = self['actor'].getAnimNames() animL = self['actor'].getAnimNames() self.AnimEntry.setlist(animL) - print '-----',animL + print('-----',animL) return def loadAnimation(self): @@ -278,7 +282,7 @@ class AnimPanel(AppShell): taskMgr.add(self.playTask, self.id + '_UpdateTask') self.stopButton.config(state=NORMAL) else: - print '----Illegal Animaion name!!', self.animName + print('----Illegal Animaion name!!', self.animName) return def playTask(self, task): @@ -591,7 +595,7 @@ class LoadAnimPanel(AppShell): else: self.animList.append(name) self.AnimName_1.setlist(self.animList) - print self.animDic + print(self.animDic) return def ok_press(self): diff --git a/contrib/src/sceneeditor/seBlendAnimPanel.py b/contrib/src/sceneeditor/seBlendAnimPanel.py index 6895b81417..2ab28210c5 100644 --- a/contrib/src/sceneeditor/seBlendAnimPanel.py +++ b/contrib/src/sceneeditor/seBlendAnimPanel.py @@ -5,12 +5,16 @@ # Import Tkinter, Pmw, and the floater code from this directory tree. from direct.tkwidgets.AppShell import * from direct.showbase.TkGlobal import * -from tkSimpleDialog import askfloat import string import math import types from direct.task import Task +if sys.version_info >= (3, 0): + from tkinter.simpledialog import askfloat +else: + from tkSimpleDialog import askfloat + FRAMES = 0 SECONDS = 1 @@ -304,7 +308,7 @@ class BlendAnimPanel(AppShell): taskMgr.add(self.playTask, self.id + '_UpdateTask') self.stopButton.config(state=NORMAL) else: - print '----Illegal Animaion name!!', self.animNameA + ', '+ self.animNameB + print('----Illegal Animaion name!!', self.animNameA + ', '+ self.animNameB) return def playTask(self, task): @@ -348,7 +352,7 @@ class BlendAnimPanel(AppShell): # setAnimation(self, animation, AB = 'a') # see play(self) ################################################################# - print 'OK!!!' + print('OK!!!') if AB == 'a': if self.animNameA != None: self['actor'].setControlEffect(self.animNameA, 1.0, 'modelRoot','lodRoot') @@ -519,7 +523,7 @@ class BlendAnimPanel(AppShell): # then this function will set Animation A to "a" and animation B # to "b" and set the ratio slider to "c" position. ################################################################# - if self.blendDict.has_key(name): + if name in self.blendDict: self.currentBlendName = name animA = self.blendDict[name][0] animB = self.blendDict[name][1] @@ -544,7 +548,7 @@ class BlendAnimPanel(AppShell): self.blendDict.clear() del self.blendDict self.blendDict = dict.copy() - print self.blendDict + print(self.blendDict) if len(self.blendDict)>0: self.blendList = self.blendDict.keys() else: diff --git a/contrib/src/sceneeditor/seCameraControl.py b/contrib/src/sceneeditor/seCameraControl.py index 721ebe9c31..95237db8be 100644 --- a/contrib/src/sceneeditor/seCameraControl.py +++ b/contrib/src/sceneeditor/seCameraControl.py @@ -55,14 +55,14 @@ class DirectCameraControl(DirectObject): ['n', self.pickNextCOA], ['u', self.orbitUprightCam], ['shift-u', self.uprightCam], - [`1`, self.spawnMoveToView, 1], - [`2`, self.spawnMoveToView, 2], - [`3`, self.spawnMoveToView, 3], - [`4`, self.spawnMoveToView, 4], - [`5`, self.spawnMoveToView, 5], - [`6`, self.spawnMoveToView, 6], - [`7`, self.spawnMoveToView, 7], - [`8`, self.spawnMoveToView, 8], + ['1', self.spawnMoveToView, 1], + ['2', self.spawnMoveToView, 2], + ['3', self.spawnMoveToView, 3], + ['4', self.spawnMoveToView, 4], + ['5', self.spawnMoveToView, 5], + ['6', self.spawnMoveToView, 6], + ['7', self.spawnMoveToView, 7], + ['8', self.spawnMoveToView, 8], ['9', self.swingCamAboutWidget, -90.0, t], ['0', self.swingCamAboutWidget, 90.0, t], ['`', self.removeManipulateCameraTask], @@ -351,7 +351,7 @@ class DirectCameraControl(DirectObject): # MRM: Would be nice to be able to control this # At least display it dist = pow(10.0, self.nullHitPointCount) - SEditor.message('COA Distance: ' + `dist`) + SEditor.message('COA Distance: ' + repr(dist)) coa.set(0,dist,0) # Compute COA Dist coaDist = Vec3(coa - ZERO_POINT).length() diff --git a/contrib/src/sceneeditor/seColorEntry.py b/contrib/src/sceneeditor/seColorEntry.py index 6cc14b27c6..9dcb3136f7 100644 --- a/contrib/src/sceneeditor/seColorEntry.py +++ b/contrib/src/sceneeditor/seColorEntry.py @@ -12,9 +12,15 @@ from direct.tkwidgets import Valuator from direct.tkwidgets import Floater from direct.tkwidgets import Slider -import string, Pmw, Tkinter, tkColorChooser +import sys, Pmw from direct.tkwidgets.VectorWidgets import VectorEntry +if sys.version_info >= (3, 0): + from tkinter.colorchooser import askcolor +else: + from tkColorChooser import askcolor + + class seColorEntry(VectorEntry): def __init__(self, parent = None, **kw): # Initialize options for the class (overriding some superclass options) @@ -41,7 +47,7 @@ class seColorEntry(VectorEntry): def popupColorPicker(self): # Can pass in current color with: color = (255, 0, 0) - color = tkColorChooser.askcolor( + color = askcolor( parent = self.interior(), # Initialize it to current color initialcolor = tuple(self.get()[:3]))[0] diff --git a/contrib/src/sceneeditor/seFileSaver.py b/contrib/src/sceneeditor/seFileSaver.py index 0b2e088e12..9d58fa0580 100644 --- a/contrib/src/sceneeditor/seFileSaver.py +++ b/contrib/src/sceneeditor/seFileSaver.py @@ -42,7 +42,7 @@ class FileSaver: i1=" " # indentation i2=i1+i1 # double indentation out_file = open(filename,"w") - print "dirname:" + dirname + print("dirname:" + dirname) if( not os.path.isdir(dirname)): os.mkdir(dirname) savepathname=Filename(filename) @@ -176,7 +176,7 @@ class FileSaver: newtexpathF=Filename(newtexpath) newtexpathSpecific=newtexpathF.toOsSpecific() - print "TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific + print("TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific) if(oldtexpath != newtexpathSpecific): shutil.copyfile(oldtexpath,newtexpathSpecific) @@ -187,7 +187,7 @@ class FileSaver: # Copy the file over to the relative directory oldModelpath=AllScene.ModelRefDic[model].toOsSpecific() - print "FILESAVER:: copying from " + AllScene.ModelRefDic[model].toOsSpecific() + "to" + newpathSpecific + print("FILESAVER:: copying from " + AllScene.ModelRefDic[model].toOsSpecific() + "to" + newpathSpecific) if(oldModelpath!=newpathSpecific): shutil.copyfile(oldModelpath,newpathSpecific) @@ -197,7 +197,7 @@ class FileSaver: etc=EggTextureCollection() etc.extractTextures(e) for index in range(len(fnamelist)): - print fnamelist[index] + print(fnamelist[index]) tex=etc.findFilename(Filename(fnamelist[index])) fn=Filename(tex.getFilename()) fn.setDirname("") @@ -305,14 +305,14 @@ class FileSaver: newtexpath=dirname + "/" + texfilename.getBasename() newtexpathF=Filename(newtexpath) newtexpathSpecific=newtexpathF.toOsSpecific() - print "TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific + print("TEXTURE SAVER:: copying" + oldtexpath + " to " + newtexpathSpecific) if(oldtexpath != newtexpathSpecific): shutil.copyfile(oldtexpath,newtexpathSpecific) # Copy the file over to the relative directory oldActorpath=AllScene.ActorRefDic[actor].toOsSpecific() - print "FILESAVER:: copying from " + AllScene.ActorRefDic[actor].toOsSpecific() + "to" + newpathSpecific + print("FILESAVER:: copying from " + AllScene.ActorRefDic[actor].toOsSpecific() + "to" + newpathSpecific) if(oldActorpath!=newpathSpecific): shutil.copyfile(oldActorpath,newpathSpecific) @@ -322,7 +322,7 @@ class FileSaver: etc=EggTextureCollection() etc.extractTextures(e) for index in range(len(actorfnamelist)): - print actorfnamelist[index] + print(actorfnamelist[index]) tex=etc.findFilename(Filename(actorfnamelist[index])) fn=Filename(tex.getFilename()) fn.setDirname("") @@ -362,12 +362,12 @@ class FileSaver: #out_file.write(i2+ "self."+ actorS + ".loadAnims(" + str(ActorAnimations) +")\n") # Old way with absolute paths #Manakel 2/12/2004: solve the not empty but not defined animation case if not animation is None: - print "ACTOR ANIMATIONS:" + ActorAnimations[animation] + print("ACTOR ANIMATIONS:" + ActorAnimations[animation]) oldAnimPath=Filename(ActorAnimations[animation]) oldAnim=oldAnimPath.toOsSpecific() dirOS=Filename(dirname) newAnim=dirOS.toOsSpecific() + "\\" + oldAnimPath.getBasename() - print "ACTOR ANIM SAVER:: Comparing" + oldAnim +"and" + newAnim + print("ACTOR ANIM SAVER:: Comparing" + oldAnim +"and" + newAnim) if(oldAnim!=newAnim): shutil.copyfile(oldAnim,newAnim) newAnimF=Filename.fromOsSpecific(newAnim) @@ -379,16 +379,16 @@ class FileSaver: out_file.write(i2+ i1+"self."+ actorS + ".loadAnims(" + str(ActorAnimations) +")\n") # Now with new relative paths out_file.write(i2+"else:\n") theloadAnimString=str(ActorAnimationsInvoke)# We hack the "self.executionpath" part into the dictionary as a variable using string replace - print "LOAD ANIM STRING BEFORE" + theloadAnimString + print("LOAD ANIM STRING BEFORE" + theloadAnimString) theloadAnimString=theloadAnimString.replace('\'self.executionpath +','self.executionpath + \'') - print "LOAD ANIM STRING AFTER" + theloadAnimString + print("LOAD ANIM STRING AFTER" + theloadAnimString) out_file.write(i2+ i1+"self."+ actorS + ".loadAnims(" + theloadAnimString +")\n") # Now with new relative paths based on editor invocation out_file.write(i2+ "self.ActorDic[\'" + actorS + "\']=self." + AllScene.ActorDic[actor].getName()+"\n") #out_file.write(i2+ "self.ActorRefDic[\'" + actorS + "\']=Filename(\'"+AllScene.ActorRefDic[actor].getFullpath() +"\')\n") # Old way with absolute paths out_file.write(i2+ "self.ActorRefDic[\'" + actorS + "\']=\'"+ AllScene.ActorRefDic[actor].getBasename() +"\'\n")# Relative paths out_file.write(i2+ "self.ActorDic[\'"+ actorS + "\'].setName(\'"+ actorS +"\')\n") - if(AllScene.blendAnimDict.has_key(actor)): # Check if a dictionary of blended animations exists + if(actor in AllScene.blendAnimDict): # Check if a dictionary of blended animations exists out_file.write(i2+ "self.blendAnimDict[\"" + actorS +"\"]=" + str(AllScene.blendAnimDict[actor]) + "\n") @@ -458,7 +458,7 @@ class FileSaver: pass else: - print "Invalid Collision Node: " + nodetype + print("Invalid Collision Node: " + nodetype) out_file.write("\n") @@ -653,7 +653,7 @@ class FileSaver: if(parent=="render" or parent=="camera"): out_file.write(i2+ "self."+ modelS + ".reparentTo(" + parent + ")\n") else: - if(AllScene.particleDict.has_key(parent)): + if(parent in AllScene.particleDict): out_file.write(i2+ "self."+ modelS + ".reparentTo(self." + parent + ".getEffect())\n") else: out_file.write(i2+ "self."+ modelS + ".reparentTo(self." + parent + ")\n") @@ -666,7 +666,7 @@ class FileSaver: if(parent=="render" or parent=="camera"): out_file.write(i2+ "self."+ dummyS + ".reparentTo(" + parent + ")\n") else: - if(AllScene.particleDict.has_key(parent)): + if(parent in AllScene.particleDict): out_file.write(i2+ "self."+ dummyS + ".reparentTo(self." + parent + ".getEffect())\n") else: out_file.write(i2+ "self."+ dummyS + ".reparentTo(self." + parent + ")\n") @@ -680,7 +680,7 @@ class FileSaver: if(parent=="render" or parent=="camera"): out_file.write(i2+ "self."+ actorS + ".reparentTo(" + parent + ")\n") else: - if(AllScene.particleDict.has_key(parent)): + if(parent in AllScene.particleDict): out_file.write(i2+ "self."+ actorS + ".reparentTo(self." + parent + ".getEffect())\n") else: out_file.write(i2+ "self."+ actorS + ".reparentTo(self." + parent + ")\n") @@ -698,7 +698,7 @@ class FileSaver: out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]="+ parentname + ".attachNewNode(self." + collnodeS + "_Node)\n") else: #Manakel 2/12/2005: parent replaced by parent Name but why Parent name in partice and parent for other objects? - if(AllScene.particleDict.has_key(parentname)): + if(parentname in AllScene.particleDict): out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]=self."+ parentname + "getEffect().attachNewNode(self." + collnodeS + "_Node)\n") else: out_file.write(i2+"self.collisionDict[\"" + collnodeS + "\"]=self."+ parentname + ".attachNewNode(self." + collnodeS + "_Node)\n") diff --git a/contrib/src/sceneeditor/seGeometry.py b/contrib/src/sceneeditor/seGeometry.py index 4074c986a2..99afa62a1f 100644 --- a/contrib/src/sceneeditor/seGeometry.py +++ b/contrib/src/sceneeditor/seGeometry.py @@ -41,10 +41,10 @@ class LineNodePath(NodePath): ls.setColor(colorVec) def moveTo( self, *_args ): - apply( self.lineSegs.moveTo, _args ) + self.lineSegs.moveTo(*_args) def drawTo( self, *_args ): - apply( self.lineSegs.drawTo, _args ) + self.lineSegs.drawTo(*_args) def create( self, frameAccurate = 0 ): self.lineSegs.create( self.lineNode, frameAccurate ) @@ -60,13 +60,13 @@ class LineNodePath(NodePath): self.lineSegs.setThickness( thickness ) def setColor( self, *_args ): - apply( self.lineSegs.setColor, _args ) + self.lineSegs.setColor(*_args) def setVertex( self, *_args): - apply( self.lineSegs.setVertex, _args ) + self.lineSegs.setVertex(*_args) def setVertexColor( self, vertex, *_args ): - apply( self.lineSegs.setVertexColor, (vertex,) + _args ) + self.lineSegs.setVertexColor(*(vertex,) + _args) def getCurrentPosition( self ): return self.lineSegs.getCurrentPosition() @@ -132,9 +132,9 @@ class LineNodePath(NodePath): Given a list of lists of points, draw a separate line for each list """ for pointList in lineList: - apply(self.moveTo, pointList[0]) + self.moveTo(*pointList[0]) for point in pointList[1:]: - apply(self.drawTo, point) + self.drawTo(*point) ## ## Given a point in space, and a direction, find the point of intersection diff --git a/contrib/src/sceneeditor/seLights.py b/contrib/src/sceneeditor/seLights.py index 09c5b2140a..2353512af5 100644 --- a/contrib/src/sceneeditor/seLights.py +++ b/contrib/src/sceneeditor/seLights.py @@ -3,7 +3,6 @@ # Written by Yi-Hong Lin, yihhongl@andrew.cmu.edu, 2004 ################################################################# from direct.showbase.DirectObject import * -from string import lower from direct.directtools import DirectUtil from panda3d.core import * import string @@ -341,7 +340,7 @@ class seLightManager(NodePath): if type == 'ambient': self.ambientCount += 1 if(name=='DEFAULT_NAME'): - light = AmbientLight('ambient_' + `self.ambientCount`) + light = AmbientLight('ambient_' + repr(self.ambientCount)) else: light = AmbientLight(name) @@ -350,7 +349,7 @@ class seLightManager(NodePath): elif type == 'directional': self.directionalCount += 1 if(name=='DEFAULT_NAME'): - light = DirectionalLight('directional_' + `self.directionalCount`) + light = DirectionalLight('directional_' + repr(self.directionalCount)) else: light = DirectionalLight(name) @@ -360,7 +359,7 @@ class seLightManager(NodePath): elif type == 'point': self.pointCount += 1 if(name=='DEFAULT_NAME'): - light = PointLight('point_' + `self.pointCount`) + light = PointLight('point_' + repr(self.pointCount)) else: light = PointLight(name) @@ -371,7 +370,7 @@ class seLightManager(NodePath): elif type == 'spot': self.spotCount += 1 if(name=='DEFAULT_NAME'): - light = Spotlight('spot_' + `self.spotCount`) + light = Spotlight('spot_' + repr(self.spotCount)) else: light = Spotlight(name) @@ -382,7 +381,7 @@ class seLightManager(NodePath): light.setAttenuation(Vec3(constant, linear, quadratic)) light.setExponent(exponent) else: - print 'Invalid light type' + print('Invalid light type') return None # Create the seLight objects and put the light object we just created into it. @@ -411,7 +410,7 @@ class seLightManager(NodePath): # Attention!! # only Spotlight obj nneds to be specified a lens node first. i.e. setLens() first! ################################################################# - type = lower(light.getType().getName()) + type = light.getType().getName().lower() specularColor = VBase4(1) position = Point3(0,0,0) @@ -451,7 +450,7 @@ class seLightManager(NodePath): quadratic = Attenuation.getZ() exponent = light.getExponent() else: - print 'Invalid light type' + print('Invalid light type') return None lightNode = seLight(light,self,type, @@ -508,7 +507,7 @@ class seLightManager(NodePath): # isLight(self.name) # Use a string as a index to check if there existing a light named "name" ################################################################# - return self.lightDict.has_key(name) + return name in self.lightDict def rename(self,oName,nName): ################################################################# @@ -523,7 +522,7 @@ class seLightManager(NodePath): del self.lightDict[oName] return self.lightDict.keys(),lightNode else: - print '----Light Mnager: No such Light!' + print('----Light Mnager: No such Light!') def getLightNodeList(self): ################################################################# diff --git a/contrib/src/sceneeditor/seMopathRecorder.py b/contrib/src/sceneeditor/seMopathRecorder.py index 0f856237d2..dc8bbd8d22 100644 --- a/contrib/src/sceneeditor/seMopathRecorder.py +++ b/contrib/src/sceneeditor/seMopathRecorder.py @@ -25,10 +25,17 @@ from direct.tkwidgets.Slider import Slider from direct.tkwidgets.EntryScale import EntryScale from direct.tkwidgets.VectorWidgets import Vector2Entry, Vector3Entry from direct.tkwidgets.VectorWidgets import ColorEntry -from Tkinter import Button, Frame, Radiobutton, Checkbutton, Label -from Tkinter import StringVar, BooleanVar, Entry, Scale -import os, string, Tkinter, Pmw -import __builtin__ +import os, string, sys, Pmw + +if sys.version_info >= (3, 0): + from tkinter import Button, Frame, Radiobutton, Checkbutton, Label + from tkinter import StringVar, BooleanVar, Entry, Scale + import tkinter +else: + from Tkinter import Button, Frame, Radiobutton, Checkbutton, Label + from Tkinter import StringVar, BooleanVar, Entry, Scale + import Tkinter as tkinter + PRF_UTILITIES = [ 'lambda: camera.lookAt(render)', @@ -123,7 +130,7 @@ class MopathRecorder(AppShell, DirectObject): self.postPoints = [] self.pointSetDict = {} self.pointSetCount = 0 - self.pointSetName = self.name + '-ps-' + `self.pointSetCount` + self.pointSetName = self.name + '-ps-' + repr(self.pointSetCount) # User callback to call before recording point self.samplingMode = 'Continuous' self.preRecordFunc = None @@ -233,7 +240,7 @@ class MopathRecorder(AppShell, DirectObject): self.undoButton['state'] = 'normal' else: self.undoButton['state'] = 'disabled' - self.undoButton.pack(side = Tkinter.LEFT, expand = 0) + self.undoButton.pack(side = tkinter.LEFT, expand = 0) self.bind(self.undoButton, 'Undo last operation') self.redoButton = Button(self.menuFrame, text = 'Redo', @@ -242,19 +249,19 @@ class MopathRecorder(AppShell, DirectObject): self.redoButton['state'] = 'normal' else: self.redoButton['state'] = 'disabled' - self.redoButton.pack(side = Tkinter.LEFT, expand = 0) + self.redoButton.pack(side = tkinter.LEFT, expand = 0) self.bind(self.redoButton, 'Redo last operation') # Record button - mainFrame = Frame(interior, relief = Tkinter.SUNKEN, borderwidth = 2) + mainFrame = Frame(interior, relief = tkinter.SUNKEN, borderwidth = 2) frame = Frame(mainFrame) # Active node path # Button to select active node path widget = self.createButton(frame, 'Recording', 'Node Path:', 'Select Active Mopath Node Path', lambda s = self: SEditor.select(s.nodePath), - side = Tkinter.LEFT, expand = 0) - widget['relief'] = Tkinter.FLAT + side = tkinter.LEFT, expand = 0) + widget['relief'] = tkinter.FLAT self.nodePathMenu = Pmw.ComboBox( frame, entry_width = 20, selectioncommand = self.selectNodePathNamed, @@ -264,7 +271,7 @@ class MopathRecorder(AppShell, DirectObject): self.nodePathMenu.component('entryfield_entry')) self.nodePathMenuBG = ( self.nodePathMenuEntry.configure('background')[3]) - self.nodePathMenu.pack(side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + self.nodePathMenu.pack(side = tkinter.LEFT, fill = tkinter.X, expand = 1) self.bind(self.nodePathMenu, 'Select active node path used for recording and playback') # Recording type @@ -285,81 +292,81 @@ class MopathRecorder(AppShell, DirectObject): 'Recording', 'Extend', ('Next record session extends existing path'), self.recordingType, 'Extend', expand = 0) - frame.pack(fill = Tkinter.X, expand = 1) + frame.pack(fill = tkinter.X, expand = 1) frame = Frame(mainFrame) widget = self.createCheckbutton( frame, 'Recording', 'Record', 'On: path is being recorded', self.toggleRecord, 0, - side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = 1) - widget.configure(foreground = 'Red', relief = Tkinter.RAISED, borderwidth = 2, - anchor = Tkinter.CENTER, width = 16) + side = tkinter.LEFT, fill = tkinter.BOTH, expand = 1) + widget.configure(foreground = 'Red', relief = tkinter.RAISED, borderwidth = 2, + anchor = tkinter.CENTER, width = 16) widget = self.createButton(frame, 'Recording', 'Add Keyframe', 'Add Keyframe To Current Path', self.addKeyframe, - side = Tkinter.LEFT, expand = 1) + side = tkinter.LEFT, expand = 1) widget = self.createButton(frame, 'Recording', 'Bind Path to Node', 'Bind Motion Path to selected Object', self.bindMotionPathToNode, - side = Tkinter.LEFT, expand = 1) + side = tkinter.LEFT, expand = 1) - frame.pack(fill = Tkinter.X, expand = 1) + frame.pack(fill = tkinter.X, expand = 1) - mainFrame.pack(expand = 1, fill = Tkinter.X, pady = 3) + mainFrame.pack(expand = 1, fill = tkinter.X, pady = 3) # Playback controls - playbackFrame = Frame(interior, relief = Tkinter.SUNKEN, + playbackFrame = Frame(interior, relief = tkinter.SUNKEN, borderwidth = 2) Label(playbackFrame, text = 'PLAYBACK CONTROLS', - font=('MSSansSerif', 12, 'bold')).pack(fill = Tkinter.X) + font=('MSSansSerif', 12, 'bold')).pack(fill = tkinter.X) # Main playback control slider widget = self.createEntryScale( playbackFrame, 'Playback', 'Time', 'Set current playback time', - resolution = 0.01, command = self.playbackGoTo, side = Tkinter.TOP) - widget.component('hull')['relief'] = Tkinter.RIDGE + resolution = 0.01, command = self.playbackGoTo, side = tkinter.TOP) + widget.component('hull')['relief'] = tkinter.RIDGE # Kill playback task if drag slider widget['preCallback'] = self.stopPlayback # Jam duration entry into entry scale self.createLabeledEntry(widget.labelFrame, 'Resample', 'Path Duration', 'Set total curve duration', command = self.setPathDuration, - side = Tkinter.LEFT, expand = 0) + side = tkinter.LEFT, expand = 0) # Start stop buttons frame = Frame(playbackFrame) widget = self.createButton(frame, 'Playback', '<<', 'Jump to start of playback', self.jumpToStartOfPlayback, - side = Tkinter.LEFT, expand = 1) + side = tkinter.LEFT, expand = 1) widget['font'] = (('MSSansSerif', 12, 'bold')) widget = self.createCheckbutton(frame, 'Playback', 'Play', 'Start/Stop playback', self.startStopPlayback, 0, - side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = 1) + side = tkinter.LEFT, fill = tkinter.BOTH, expand = 1) widget.configure(anchor = 'center', justify = 'center', - relief = Tkinter.RAISED, font = ('MSSansSerif', 12, 'bold')) + relief = tkinter.RAISED, font = ('MSSansSerif', 12, 'bold')) widget = self.createButton(frame, 'Playback', '>>', 'Jump to end of playback', self.jumpToEndOfPlayback, - side = Tkinter.LEFT, expand = 1) + side = tkinter.LEFT, expand = 1) widget['font'] = (('MSSansSerif', 12, 'bold')) self.createCheckbutton(frame, 'Playback', 'Loop', 'On: loop playback', self.setLoopPlayback, self.loopPlayback, - side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = 0) - frame.pack(fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.BOTH, expand = 0) + frame.pack(fill = tkinter.X, expand = 1) # Speed control frame = Frame(playbackFrame) - widget = Button(frame, text = 'PB Speed Vernier', relief = Tkinter.FLAT, + widget = Button(frame, text = 'PB Speed Vernier', relief = tkinter.FLAT, command = lambda s = self: s.setSpeedScale(1.0)) - widget.pack(side = Tkinter.LEFT, expand = 0) + widget.pack(side = tkinter.LEFT, expand = 0) self.speedScale = Scale(frame, from_ = -1, to = 1, resolution = 0.01, showvalue = 0, width = 10, orient = 'horizontal', command = self.setPlaybackSF) - self.speedScale.pack(side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + self.speedScale.pack(side = tkinter.LEFT, fill = tkinter.X, expand = 1) self.speedVar = StringVar() self.speedVar.set("0.00") self.speedEntry = Entry(frame, textvariable = self.speedVar, @@ -368,14 +375,14 @@ class MopathRecorder(AppShell, DirectObject): '', lambda e = None, s = self: s.setSpeedScale( string.atof(s.speedVar.get()))) - self.speedEntry.pack(side = Tkinter.LEFT, expand = 0) - frame.pack(fill = Tkinter.X, expand = 1) + self.speedEntry.pack(side = tkinter.LEFT, expand = 0) + frame.pack(fill = tkinter.X, expand = 1) - playbackFrame.pack(fill = Tkinter.X, pady = 2) + playbackFrame.pack(fill = tkinter.X, pady = 2) # Create notebook pages self.mainNotebook = Pmw.NoteBook(interior) - self.mainNotebook.pack(fill = Tkinter.BOTH, expand = 1) + self.mainNotebook.pack(fill = tkinter.BOTH, expand = 1) self.resamplePage = self.mainNotebook.add('Resample') self.refinePage = self.mainNotebook.add('Refine') self.extendPage = self.mainNotebook.add('Extend') @@ -386,35 +393,35 @@ class MopathRecorder(AppShell, DirectObject): ## RESAMPLE PAGE label = Label(self.resamplePage, text = 'RESAMPLE CURVE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) # Resample resampleFrame = Frame( - self.resamplePage, relief = Tkinter.SUNKEN, borderwidth = 2) + self.resamplePage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(resampleFrame, text = 'RESAMPLE CURVE', font=('MSSansSerif', 12, 'bold')).pack() widget = self.createSlider( resampleFrame, 'Resample', 'Num. Samples', 'Number of samples in resampled curve', resolution = 1, min = 2, max = 1000, command = self.setNumSamples) - widget.component('hull')['relief'] = Tkinter.RIDGE + widget.component('hull')['relief'] = tkinter.RIDGE widget['postCallback'] = self.sampleCurve frame = Frame(resampleFrame) self.createButton( frame, 'Resample', 'Make Even', 'Apply timewarp so resulting path has constant velocity', - self.makeEven, side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + self.makeEven, side = tkinter.LEFT, fill = tkinter.X, expand = 1) self.createButton( frame, 'Resample', 'Face Forward', 'Compute HPR so resulting hpr curve faces along xyz tangent', - self.faceForward, side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) - frame.pack(fill = Tkinter.X, expand = 0) - resampleFrame.pack(fill = Tkinter.X, expand = 0, pady = 2) + self.faceForward, side = tkinter.LEFT, fill = tkinter.X, expand = 1) + frame.pack(fill = tkinter.X, expand = 0) + resampleFrame.pack(fill = tkinter.X, expand = 0, pady = 2) # Desample desampleFrame = Frame( - self.resamplePage, relief = Tkinter.SUNKEN, borderwidth = 2) + self.resamplePage, relief = tkinter.SUNKEN, borderwidth = 2) Label(desampleFrame, text = 'DESAMPLE CURVE', font=('MSSansSerif', 12, 'bold')).pack() widget = self.createSlider( @@ -422,16 +429,16 @@ class MopathRecorder(AppShell, DirectObject): 'Specify number of points to skip between samples', min = 1, max = 100, resolution = 1, command = self.setDesampleFrequency) - widget.component('hull')['relief'] = Tkinter.RIDGE + widget.component('hull')['relief'] = tkinter.RIDGE widget['postCallback'] = self.desampleCurve - desampleFrame.pack(fill = Tkinter.X, expand = 0, pady = 2) + desampleFrame.pack(fill = tkinter.X, expand = 0, pady = 2) ## REFINE PAGE ## - refineFrame = Frame(self.refinePage, relief = Tkinter.SUNKEN, + refineFrame = Frame(self.refinePage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(refineFrame, text = 'REFINE CURVE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) widget = self.createSlider(refineFrame, 'Refine Page', 'Refine From', @@ -460,14 +467,14 @@ class MopathRecorder(AppShell, DirectObject): command = self.setRefineStop) widget['preCallback'] = self.setRefineMode widget['postCallback'] = self.getPostPoints - refineFrame.pack(fill = Tkinter.X) + refineFrame.pack(fill = tkinter.X) ## EXTEND PAGE ## - extendFrame = Frame(self.extendPage, relief = Tkinter.SUNKEN, + extendFrame = Frame(self.extendPage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(extendFrame, text = 'EXTEND CURVE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) widget = self.createSlider(extendFrame, 'Extend Page', 'Extend From', @@ -483,14 +490,14 @@ class MopathRecorder(AppShell, DirectObject): resolution = 0.01, command = self.setControlStart) widget['preCallback'] = self.setExtendMode - extendFrame.pack(fill = Tkinter.X) + extendFrame.pack(fill = tkinter.X) ## CROP PAGE ## - cropFrame = Frame(self.cropPage, relief = Tkinter.SUNKEN, + cropFrame = Frame(self.cropPage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(cropFrame, text = 'CROP CURVE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) widget = self.createSlider( cropFrame, @@ -508,11 +515,11 @@ class MopathRecorder(AppShell, DirectObject): self.createButton(cropFrame, 'Crop Page', 'Crop Curve', 'Crop curve to specified from to times', - self.cropCurve, fill = Tkinter.NONE) - cropFrame.pack(fill = Tkinter.X) + self.cropCurve, fill = tkinter.NONE) + cropFrame.pack(fill = tkinter.X) ## DRAW PAGE ## - drawFrame = Frame(self.drawPage, relief = Tkinter.SUNKEN, + drawFrame = Frame(self.drawPage, relief = tkinter.SUNKEN, borderwidth = 2) self.sf = Pmw.ScrolledFrame(self.drawPage, horizflex = 'elastic') @@ -521,57 +528,57 @@ class MopathRecorder(AppShell, DirectObject): label = Label(sfFrame, text = 'CURVE RENDERING STYLE', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) frame = Frame(sfFrame) - Label(frame, text = 'SHOW:').pack(side = Tkinter.LEFT, expand = 0) + Label(frame, text = 'SHOW:').pack(side = tkinter.LEFT, expand = 0) widget = self.createCheckbutton( frame, 'Style', 'Path', 'On: path is visible', self.setPathVis, 1, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'Knots', 'On: path knots are visible', self.setKnotVis, 1, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'CVs', 'On: path CVs are visible', self.setCvVis, 0, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'Hull', 'On: path hull is visible', self.setHullVis, 0, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'Trace', 'On: record is visible', self.setTraceVis, 0, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) widget = self.createCheckbutton( frame, 'Style', 'Marker', 'On: playback marker is visible', self.setMarkerVis, 0, - side = Tkinter.LEFT, fill = Tkinter.X, expand = 1) - frame.pack(fill = Tkinter.X, expand = 1) + side = tkinter.LEFT, fill = tkinter.X, expand = 1) + frame.pack(fill = tkinter.X, expand = 1) # Sliders widget = self.createSlider( sfFrame, 'Style', 'Num Segs', 'Set number of segments used to approximate each parametric unit', min = 1.0, max = 400, resolution = 1.0, value = 40, - command = self.setNumSegs, side = Tkinter.TOP) - widget.component('hull')['relief'] = Tkinter.RIDGE + command = self.setNumSegs, side = tkinter.TOP) + widget.component('hull')['relief'] = tkinter.RIDGE widget = self.createSlider( sfFrame, 'Style', 'Num Ticks', 'Set number of tick marks drawn for each unit of time', min = 0.0, max = 10.0, resolution = 1.0, value = 0.0, - command = self.setNumTicks, side = Tkinter.TOP) - widget.component('hull')['relief'] = Tkinter.RIDGE + command = self.setNumTicks, side = tkinter.TOP) + widget.component('hull')['relief'] = tkinter.RIDGE widget = self.createSlider( sfFrame, 'Style', 'Tick Scale', 'Set visible size of time tick marks', min = 0.01, max = 100.0, resolution = 0.01, value = 5.0, - command = self.setTickScale, side = Tkinter.TOP) - widget.component('hull')['relief'] = Tkinter.RIDGE + command = self.setTickScale, side = tkinter.TOP) + widget.component('hull')['relief'] = tkinter.RIDGE self.createColorEntry( sfFrame, 'Style', 'Path Color', 'Color of curve', @@ -598,14 +605,14 @@ class MopathRecorder(AppShell, DirectObject): command = self.setHullColor, value = [255.0,128.0,128.0,255.0]) - #drawFrame.pack(fill = Tkinter.X) + #drawFrame.pack(fill = tkinter.X) ## OPTIONS PAGE ## - optionsFrame = Frame(self.optionsPage, relief = Tkinter.SUNKEN, + optionsFrame = Frame(self.optionsPage, relief = tkinter.SUNKEN, borderwidth = 2) label = Label(optionsFrame, text = 'RECORDING OPTIONS', font=('MSSansSerif', 12, 'bold')) - label.pack(fill = Tkinter.X) + label.pack(fill = tkinter.X) # Hooks frame = Frame(optionsFrame) widget = self.createLabeledEntry( @@ -614,7 +621,7 @@ class MopathRecorder(AppShell, DirectObject): value = self.startStopHook, command = self.setStartStopHook)[0] label = self.getWidget('Recording', 'Record Hook-Label') - label.configure(width = 16, anchor = Tkinter.W) + label.configure(width = 16, anchor = tkinter.W) self.setStartStopHook() widget = self.createLabeledEntry( frame, 'Recording', 'Keyframe Hook', @@ -622,9 +629,9 @@ class MopathRecorder(AppShell, DirectObject): value = self.keyframeHook, command = self.setKeyframeHook)[0] label = self.getWidget('Recording', 'Keyframe Hook-Label') - label.configure(width = 16, anchor = Tkinter.W) + label.configure(width = 16, anchor = tkinter.W) self.setKeyframeHook() - frame.pack(expand = 1, fill = Tkinter.X) + frame.pack(expand = 1, fill = tkinter.X) # PreRecordFunc frame = Frame(optionsFrame) widget = self.createComboBox( @@ -632,17 +639,17 @@ class MopathRecorder(AppShell, DirectObject): 'Function called before sampling each point', PRF_UTILITIES, self.setPreRecordFunc, history = 1, expand = 1) - widget.configure(label_width = 16, label_anchor = Tkinter.W) + widget.configure(label_width = 16, label_anchor = tkinter.W) widget.configure(entryfield_entry_state = 'normal') # Initialize preRecordFunc self.preRecordFunc = eval(PRF_UTILITIES[0]) self.createCheckbutton(frame, 'Recording', 'PRF Active', 'On: Pre Record Func enabled', None, 0, - side = Tkinter.LEFT, fill = Tkinter.BOTH, expand = 0) - frame.pack(expand = 1, fill = Tkinter.X) + side = tkinter.LEFT, fill = tkinter.BOTH, expand = 0) + frame.pack(expand = 1, fill = tkinter.X) # Pack record frame - optionsFrame.pack(fill = Tkinter.X, pady = 2) + optionsFrame.pack(fill = tkinter.X, pady = 2) self.mainNotebook.setnaturalsize() @@ -682,7 +689,7 @@ class MopathRecorder(AppShell, DirectObject): marker if subnode selected """ taskMgr.remove(self.name + '-curveEditTask') - print nodePath.get_key() + print(nodePath.get_key()) if nodePath.get_key() in self.playbackMarkerIds: SEditor.select(self.playbackMarker) elif nodePath.get_key() in self.tangentMarkerIds: @@ -799,7 +806,7 @@ class MopathRecorder(AppShell, DirectObject): def createNewPointSet(self, curveName = None): if curveName == None: - self.pointSetName = self.name + '-ps-' + `self.pointSetCount` + self.pointSetName = self.name + '-ps-' + repr(self.pointSetCount) else: self.pointSetName = curveName # Update dictionary and record pointer to new point set @@ -1137,7 +1144,7 @@ class MopathRecorder(AppShell, DirectObject): def computeCurves(self): # Check to make sure curve fitters have points if (self.curveFitter.getNumSamples() == 0): - print 'MopathRecorder.computeCurves: Must define curve first' + print('MopathRecorder.computeCurves: Must define curve first') return # Create curves # XYZ @@ -1282,8 +1289,8 @@ class MopathRecorder(AppShell, DirectObject): dictName = name else: # Generate a unique name for the dict - dictName = name # + '-' + `nodePath.get_key()` - if not dict.has_key(dictName): + dictName = name # + '-' + repr(nodePath.get_key()) + if dictName not in dict: # Update combo box to include new item names.append(dictName) listbox = menu.component('scrolledlist') @@ -1386,7 +1393,7 @@ class MopathRecorder(AppShell, DirectObject): def desampleCurve(self): if (self.curveFitter.getNumSamples() == 0): - print 'MopathRecorder.desampleCurve: Must define curve first' + print('MopathRecorder.desampleCurve: Must define curve first') return # NOTE: This is destructive, points will be deleted from curve fitter self.curveFitter.desample(self.desampleFrequency) @@ -1400,7 +1407,7 @@ class MopathRecorder(AppShell, DirectObject): def sampleCurve(self, fCompute = 1, curveName = None): if self.curveCollection == None: - print 'MopathRecorder.sampleCurve: Must define curve first' + print('MopathRecorder.sampleCurve: Must define curve first') return # Reset curve fitters self.curveFitter.reset() @@ -1617,7 +1624,7 @@ class MopathRecorder(AppShell, DirectObject): def cropCurve(self): if self.pointSet == None: - print 'Empty Point Set' + print('Empty Point Set') return # Keep handle on old points oldPoints = self.pointSet @@ -1653,15 +1660,15 @@ class MopathRecorder(AppShell, DirectObject): # Use first directory in model path mPath = getModelPath() if mPath.getNumDirectories() > 0: - if `mPath.getDirectory(0)` == '.': + if repr(mPath.getDirectory(0)) == '.': path = '.' else: path = mPath.getDirectory(0).toOsSpecific() else: path = '.' if not os.path.isdir(path): - print 'MopathRecorder Info: Empty Model Path!' - print 'Using current directory' + print('MopathRecorder Info: Empty Model Path!') + print('Using current directory') path = '.' mopathFilename = askopenfilename( defaultextension = '.egg', @@ -1692,15 +1699,15 @@ class MopathRecorder(AppShell, DirectObject): # Use first directory in model path mPath = getModelPath() if mPath.getNumDirectories() > 0: - if `mPath.getDirectory(0)` == '.': + if repr(mPath.getDirectory(0)) == '.': path = '.' else: path = mPath.getDirectory(0).toOsSpecific() else: path = '.' if not os.path.isdir(path): - print 'MopathRecorder Info: Empty Model Path!' - print 'Using current directory' + print('MopathRecorder Info: Empty Model Path!') + print('Using current directory') path = '.' mopathFilename = asksaveasfilename( defaultextension = '.egg', @@ -1734,28 +1741,28 @@ class MopathRecorder(AppShell, DirectObject): def createLabeledEntry(self, parent, category, text, balloonHelp, value = '', command = None, - relief = 'sunken', side = Tkinter.LEFT, + relief = 'sunken', side = tkinter.LEFT, expand = 1, width = 12): frame = Frame(parent) variable = StringVar() variable.set(value) label = Label(frame, text = text) - label.pack(side = Tkinter.LEFT, fill = Tkinter.X) + label.pack(side = tkinter.LEFT, fill = tkinter.X) self.bind(label, balloonHelp) self.widgetDict[category + '-' + text + '-Label'] = label entry = Entry(frame, width = width, relief = relief, textvariable = variable) - entry.pack(side = Tkinter.LEFT, fill = Tkinter.X, expand = expand) + entry.pack(side = tkinter.LEFT, fill = tkinter.X, expand = expand) self.bind(entry, balloonHelp) self.widgetDict[category + '-' + text] = entry self.variableDict[category + '-' + text] = variable if command: entry.bind('', command) - frame.pack(side = side, fill = Tkinter.X, expand = expand) + frame.pack(side = side, fill = tkinter.X, expand = expand) return (frame, label, entry) def createButton(self, parent, category, text, balloonHelp, command, - side = 'top', expand = 0, fill = Tkinter.X): + side = 'top', expand = 0, fill = tkinter.X): widget = Button(parent, text = text) # Do this after the widget so command isn't called on creation widget['command'] = command @@ -1766,10 +1773,10 @@ class MopathRecorder(AppShell, DirectObject): def createCheckbutton(self, parent, category, text, balloonHelp, command, initialState, - side = 'top', fill = Tkinter.X, expand = 0): + side = 'top', fill = tkinter.X, expand = 0): bool = BooleanVar() bool.set(initialState) - widget = Checkbutton(parent, text = text, anchor = Tkinter.W, + widget = Checkbutton(parent, text = text, anchor = tkinter.W, variable = bool) # Do this after the widget so command isn't called on creation widget['command'] = command @@ -1781,8 +1788,8 @@ class MopathRecorder(AppShell, DirectObject): def createRadiobutton(self, parent, side, category, text, balloonHelp, variable, value, - command = None, fill = Tkinter.X, expand = 0): - widget = Radiobutton(parent, text = text, anchor = Tkinter.W, + command = None, fill = tkinter.X, expand = 0): + widget = Radiobutton(parent, text = text, anchor = tkinter.W, variable = variable, value = value) # Do this after the widget so command isn't called on creation widget['command'] = command @@ -1798,10 +1805,10 @@ class MopathRecorder(AppShell, DirectObject): kw['min'] = min kw['maxVelocity'] = maxVelocity kw['resolution'] = resolution - widget = apply(Floater, (parent,), kw) + widget = Floater(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1809,10 +1816,10 @@ class MopathRecorder(AppShell, DirectObject): def createAngleDial(self, parent, category, text, balloonHelp, command = None, **kw): kw['text'] = text - widget = apply(AngleDial,(parent,), kw) + widget = AngleDial(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1820,13 +1827,13 @@ class MopathRecorder(AppShell, DirectObject): def createSlider(self, parent, category, text, balloonHelp, command = None, min = 0.0, max = 1.0, resolution = None, - side = Tkinter.TOP, fill = Tkinter.X, expand = 1, **kw): + side = tkinter.TOP, fill = tkinter.X, expand = 1, **kw): kw['text'] = text kw['min'] = min kw['max'] = max kw['resolution'] = resolution #widget = apply(EntryScale, (parent,), kw) - widget = apply(Slider, (parent,), kw) + widget = Slider(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(side = side, fill = fill, expand = expand) @@ -1837,12 +1844,12 @@ class MopathRecorder(AppShell, DirectObject): def createEntryScale(self, parent, category, text, balloonHelp, command = None, min = 0.0, max = 1.0, resolution = None, - side = Tkinter.TOP, fill = Tkinter.X, expand = 1, **kw): + side = tkinter.TOP, fill = tkinter.X, expand = 1, **kw): kw['text'] = text kw['min'] = min kw['max'] = max kw['resolution'] = resolution - widget = apply(EntryScale, (parent,), kw) + widget = EntryScale(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(side = side, fill = fill, expand = expand) @@ -1854,10 +1861,10 @@ class MopathRecorder(AppShell, DirectObject): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(Vector2Entry, (parent,), kw) + widget = Vector2Entry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1866,10 +1873,10 @@ class MopathRecorder(AppShell, DirectObject): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(Vector3Entry, (parent,), kw) + widget = Vector3Entry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1878,10 +1885,10 @@ class MopathRecorder(AppShell, DirectObject): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(ColorEntry, (parent,) ,kw) + widget = ColorEntry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget, balloonHelp) self.widgetDict[category + '-' + text] = widget return widget @@ -1891,13 +1898,13 @@ class MopathRecorder(AppShell, DirectObject): optionVar = StringVar() if len(items) > 0: optionVar.set(items[0]) - widget = Pmw.OptionMenu(parent, labelpos = Tkinter.W, label_text = text, + widget = Pmw.OptionMenu(parent, labelpos = tkinter.W, label_text = text, label_width = 12, menu_tearoff = 1, menubutton_textvariable = optionVar, items = items) # Do this after the widget so command isn't called on creation widget['command'] = command - widget.pack(fill = Tkinter.X) + widget.pack(fill = tkinter.X) self.bind(widget.component('menubutton'), balloonHelp) self.widgetDict[category + '-' + text] = widget self.variableDict[category + '-' + text] = optionVar @@ -1905,9 +1912,9 @@ class MopathRecorder(AppShell, DirectObject): def createComboBox(self, parent, category, text, balloonHelp, items, command, history = 0, - side = Tkinter.LEFT, expand = 0, fill = Tkinter.X): + side = tkinter.LEFT, expand = 0, fill = tkinter.X): widget = Pmw.ComboBox(parent, - labelpos = Tkinter.W, + labelpos = tkinter.W, label_text = text, label_anchor = 'e', label_width = 12, @@ -1959,14 +1966,14 @@ class MopathRecorder(AppShell, DirectObject): def bindMotionPathToNode(self): if self.curveCollection == None: - print '----Error: you need to select or create a curve first!' + print('----Error: you need to select or create a curve first!') return self.accept('MP_checkName', self.bindMotionPath) self.askName = namePathPanel(MopathRecorder.count) return def bindMotionPath(self,name=None,test=None): - print test + print(test) self.ignore('MP_checkName') del self.askName self.curveCollection.getCurve(0).setName(name) @@ -1993,7 +2000,7 @@ class MopathRecorder(AppShell, DirectObject): If the list is not None, it will put the vurve back into the curve list. else, do nothing. ''' - print curveList + print(curveList) self.ignore('curveListFor'+self.name) if curveList != None: for collection in curveList: @@ -2037,8 +2044,8 @@ class namePathPanel(AppShell): dataFrame = Frame(mainFrame) label = Label(dataFrame, text='This name will be used as a reference for this Path.',font=('MSSansSerif', 10)) - label.pack(side = Tkinter.TOP, expand = 0, fill = Tkinter.X) - dataFrame.pack(side = Tkinter.TOP, expand = 0, fill = Tkinter.X, padx=5, pady=10) + label.pack(side = tkinter.TOP, expand = 0, fill = tkinter.X) + dataFrame.pack(side = tkinter.TOP, expand = 0, fill = tkinter.X, padx=5, pady=10) dataFrame = Frame(mainFrame) self.inputZone = Pmw.EntryField(dataFrame, labelpos='w', label_text = 'Name Selected Path: ', @@ -2046,14 +2053,14 @@ class namePathPanel(AppShell): label_font=('MSSansSerif', 10), validate = None, entry_width = 20) - self.inputZone.pack(side = Tkinter.LEFT, fill=Tkinter.X,expand=0) + self.inputZone.pack(side = tkinter.LEFT, fill=tkinter.X,expand=0) self.button_ok = Button(dataFrame, text="OK", command=self.ok_press,width=10) - self.button_ok.pack(fill=Tkinter.X,expand=0,side=Tkinter.LEFT, padx = 3) + self.button_ok.pack(fill=tkinter.X,expand=0,side=tkinter.LEFT, padx = 3) - dataFrame.pack(side = Tkinter.TOP, expand = 0, fill = Tkinter.X, padx=10, pady=10) + dataFrame.pack(side = tkinter.TOP, expand = 0, fill = tkinter.X, padx=10, pady=10) - mainFrame.pack(expand = 1, fill = Tkinter.BOTH) + mainFrame.pack(expand = 1, fill = tkinter.BOTH) diff --git a/contrib/src/sceneeditor/seParticleEffect.py b/contrib/src/sceneeditor/seParticleEffect.py index 8ad3a658a8..a36f7d4025 100644 --- a/contrib/src/sceneeditor/seParticleEffect.py +++ b/contrib/src/sceneeditor/seParticleEffect.py @@ -209,9 +209,9 @@ class ParticleEffect(NodePath): """loadConfig(filename)""" #try: # if vfs: - print vfs.readFile(filename) - exec vfs.readFile(filename) - print "Particle Effect Reading using VFS" + print(vfs.readFile(filename)) + exec(vfs.readFile(filename)) + print("Particle Effect Reading using VFS") # else: # execfile(filename.toOsSpecific()) # print "Shouldnt be wrong" diff --git a/contrib/src/sceneeditor/seParticlePanel.py b/contrib/src/sceneeditor/seParticlePanel.py index 099e31012d..3c359e2628 100644 --- a/contrib/src/sceneeditor/seParticlePanel.py +++ b/contrib/src/sceneeditor/seParticlePanel.py @@ -2,9 +2,7 @@ # Import Tkinter, Pmw, and the floater code from this directory tree. from direct.tkwidgets.AppShell import AppShell -from tkFileDialog import * -from tkSimpleDialog import askstring -import os, Pmw, Tkinter +import os, Pmw, sys from direct.tkwidgets.Dial import AngleDial from direct.tkwidgets.Floater import Floater from direct.tkwidgets.Slider import Slider @@ -15,6 +13,15 @@ import seForceGroup import seParticles import seParticleEffect + +if sys.version_info >= (3, 0): + from tkinter.filedialog import * + from tkinter.simpledialog import askstring +else: + from tkFileDialog import * + from tkSimpleDialog import askstring + + class ParticlePanel(AppShell): # Override class variables appname = 'Particle Panel' @@ -774,7 +781,7 @@ class ParticlePanel(AppShell): kw['min'] = min kw['resolution'] = resolution kw['numDigits'] = numDigits - widget = apply(Floater, (parent,), kw) + widget = Floater(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -786,7 +793,7 @@ class ParticlePanel(AppShell): command = None, **kw): kw['text'] = text kw['style'] = 'mini' - widget = apply(AngleDial,(parent,), kw) + widget = AngleDial(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -801,7 +808,7 @@ class ParticlePanel(AppShell): kw['min'] = min kw['max'] = max kw['resolution'] = resolution - widget = apply(Slider, (parent,), kw) + widget = Slider(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -813,7 +820,7 @@ class ParticlePanel(AppShell): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(Vector2Entry, (parent,), kw) + widget = Vector2Entry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -825,7 +832,7 @@ class ParticlePanel(AppShell): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(Vector3Entry, (parent,), kw) + widget = Vector3Entry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -837,7 +844,7 @@ class ParticlePanel(AppShell): command = None, **kw): # Set label's text kw['text'] = text - widget = apply(ColorEntry, (parent,) ,kw) + widget = ColorEntry(parent, **kw) # Do this after the widget so command isn't called on creation widget['command'] = command widget.pack(fill = X) @@ -992,7 +999,7 @@ class ParticlePanel(AppShell): self.mainNotebook.selectpage('System') self.updateInfo('System') else: - print 'ParticlePanel: No effect named ' + name + print('ParticlePanel: No effect named ' + name) def toggleEffect(self, effect, var): if var.get(): @@ -1041,15 +1048,15 @@ class ParticlePanel(AppShell): # Find path to particle directory pPath = getParticlePath() if pPath.getNumDirectories() > 0: - if `pPath.getDirectory(0)` == '.': + if repr(pPath.getDirectory(0)) == '.': path = '.' else: path = pPath.getDirectory(0).toOsSpecific() else: path = '.' if not os.path.isdir(path): - print 'ParticlePanel Warning: Invalid default DNA directory!' - print 'Using current directory' + print('ParticlePanel Warning: Invalid default DNA directory!') + print('Using current directory') path = '.' particleFilename = askopenfilename( defaultextension = '.ptf', @@ -1070,15 +1077,15 @@ class ParticlePanel(AppShell): # Find path to particle directory pPath = getParticlePath() if pPath.getNumDirectories() > 0: - if `pPath.getDirectory(0)` == '.': + if repr(pPath.getDirectory(0)) == '.': path = '.' else: path = pPath.getDirectory(0).toOsSpecific() else: path = '.' if not os.path.isdir(path): - print 'ParticlePanel Warning: Invalid default DNA directory!' - print 'Using current directory' + print('ParticlePanel Warning: Invalid default DNA directory!') + print('Using current directory') path = '.' particleFilename = asksaveasfilename( defaultextension = '.ptf', @@ -1654,7 +1661,7 @@ class ParticlePanel(AppShell): def setRendererSpriteNonAnimatedTheta(self, theta): self.particles.renderer.setNonanimatedTheta(theta) def setRendererSpriteBlendMethod(self, blendMethod): - print blendMethod + print(blendMethod) if blendMethod == 'PP_NO_BLEND': bMethod = BaseParticleRenderer.PPNOBLEND elif blendMethod == 'PP_BLEND_LINEAR': @@ -1863,7 +1870,7 @@ class ParticlePanel(AppShell): count, force): def setVec(vec, f = force): f.setVector(vec[0], vec[1], vec[2]) - forceName = 'Vector Force-' + `count` + forceName = 'Vector Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) vec = force.getLocalVector() @@ -1875,7 +1882,7 @@ class ParticlePanel(AppShell): def createLinearRandomForceWidget(self, forcePage, pageName, count, force, type): - forceName = type + ' Force-' + `count` + forceName = type + ' Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) self.createForceActiveWidget(frame, pageName, forceName, force) @@ -1884,7 +1891,7 @@ class ParticlePanel(AppShell): count, force): def setCoef(coef, f = force): f.setCoef(coef) - forceName = 'Friction Force-' + `count` + forceName = 'Friction Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) self.createFloater(frame, pageName, forceName + ' Coef', @@ -1895,7 +1902,7 @@ class ParticlePanel(AppShell): def createLinearCylinderVortexForceWidget(self, forcePage, pageName, count, force): - forceName = 'Vortex Force-' + `count` + forceName = 'Vortex Force-' + repr(count) def setCoef(coef, f = force): f.setCoef(coef) def setLength(length, f = force): @@ -1934,7 +1941,7 @@ class ParticlePanel(AppShell): f.setForceCenter(Point3(vec[0], vec[1], vec[2])) def setRadius(radius, f = force): f.setRadius(radius) - forceName = type + ' Force-' + `count` + forceName = type + ' Force-' + repr(count) frame = self.createForceFrame(forcePage, forceName, force) self.createLinearForceWidgets(frame, pageName, forceName, force) var = self.createOptionMenu( diff --git a/contrib/src/sceneeditor/seParticles.py b/contrib/src/sceneeditor/seParticles.py index 655d06b804..a4f0d0e5d6 100644 --- a/contrib/src/sceneeditor/seParticles.py +++ b/contrib/src/sceneeditor/seParticles.py @@ -93,7 +93,7 @@ class Particles(ParticleSystem): elif (type == "OrientedParticleFactory"): self.factory = OrientedParticleFactory.OrientedParticleFactory() else: - print "unknown factory type: %s" % type + print("unknown factory type: %s" % type) return None self.factory.setLifespanBase(0.5) ParticleSystem.ParticleSystem.setFactory(self, self.factory) @@ -132,7 +132,7 @@ class Particles(ParticleSystem): # See sourceFileName and sourceNodeName in SpriteParticleRenderer-extensions.py self.renderer.setTextureFromNode() else: - print "unknown renderer type: %s" % type + print("unknown renderer type: %s" % type) return None ParticleSystem.ParticleSystem.setRenderer(self, self.renderer) @@ -163,7 +163,7 @@ class Particles(ParticleSystem): elif (type == "TangentRingEmitter"): self.emitter = TangentRingEmitter.TangentRingEmitter() else: - print "unknown emitter type: %s" % type + print("unknown emitter type: %s" % type) return None ParticleSystem.ParticleSystem.setEmitter(self, self.emitter) diff --git a/contrib/src/sceneeditor/sePlacer.py b/contrib/src/sceneeditor/sePlacer.py index 3f2b3b4b75..15804629a7 100644 --- a/contrib/src/sceneeditor/sePlacer.py +++ b/contrib/src/sceneeditor/sePlacer.py @@ -5,9 +5,16 @@ from direct.directtools.DirectGlobals import * from direct.tkwidgets.AppShell import AppShell from direct.tkwidgets.Dial import AngleDial from direct.tkwidgets.Floater import Floater -from Tkinter import Button, Menubutton, Menu, StringVar from panda3d.core import * -import Tkinter, Pmw +import sys, Pmw + +if sys.version_info >= (3, 0): + from tkinter import Button, Menubutton, Menu, StringVar + import tkinter +else: + from Tkinter import Button, Menubutton, Menu, StringVar + import Tkinter as tkinter + """ TODO: Task to monitor pose @@ -84,7 +91,7 @@ class Placer(AppShell): def createInterface(self): # The interior of the toplevel panel interior = self.interior() - interior['relief'] = Tkinter.FLAT + interior['relief'] = tkinter.FLAT # Add placer commands to menubar self.menuBar.addmenu('Placer', 'Placer Panel Operations') self.menuBar.addmenuitem('Placer', 'command', @@ -113,7 +120,7 @@ class Placer(AppShell): # Get a handle to the menu frame menuFrame = self.menuFrame self.nodePathMenu = Pmw.ComboBox( - menuFrame, labelpos = Tkinter.W, label_text = 'Node Path:', + menuFrame, labelpos = tkinter.W, label_text = 'Node Path:', entry_width = 20, selectioncommand = self.selectNodePathNamed, scrolledlist_items = self.nodePathNames) @@ -168,7 +175,7 @@ class Placer(AppShell): tag_text = 'Position', tag_font=('MSSansSerif', 14), tag_activebackground = '#909090', - ring_relief = Tkinter.RIDGE) + ring_relief = tkinter.RIDGE) posMenubutton = posGroup.component('tag') self.bind(posMenubutton, 'Position menu operations') posMenu = Menu(posMenubutton, tearoff = 0) @@ -182,7 +189,7 @@ class Placer(AppShell): # Create the dials self.posX = self.createcomponent('posX', (), None, Floater, (posInterior,), - text = 'X', relief = Tkinter.FLAT, + text = 'X', relief = tkinter.FLAT, value = 0.0, label_foreground = 'Red') self.posX['commandData'] = ['x'] @@ -193,7 +200,7 @@ class Placer(AppShell): self.posY = self.createcomponent('posY', (), None, Floater, (posInterior,), - text = 'Y', relief = Tkinter.FLAT, + text = 'Y', relief = tkinter.FLAT, value = 0.0, label_foreground = '#00A000') self.posY['commandData'] = ['y'] @@ -204,7 +211,7 @@ class Placer(AppShell): self.posZ = self.createcomponent('posZ', (), None, Floater, (posInterior,), - text = 'Z', relief = Tkinter.FLAT, + text = 'Z', relief = tkinter.FLAT, value = 0.0, label_foreground = 'Blue') self.posZ['commandData'] = ['z'] @@ -219,7 +226,7 @@ class Placer(AppShell): tag_text = 'Orientation', tag_font=('MSSansSerif', 14), tag_activebackground = '#909090', - ring_relief = Tkinter.RIDGE) + ring_relief = tkinter.RIDGE) hprMenubutton = hprGroup.component('tag') self.bind(hprMenubutton, 'Orientation menu operations') hprMenu = Menu(hprMenubutton, tearoff = 0) @@ -234,7 +241,7 @@ class Placer(AppShell): AngleDial, (hprInterior,), style = 'mini', text = 'H', value = 0.0, - relief = Tkinter.FLAT, + relief = tkinter.FLAT, label_foreground = 'blue') self.hprH['commandData'] = ['h'] self.hprH['preCallback'] = self.xformStart @@ -246,7 +253,7 @@ class Placer(AppShell): AngleDial, (hprInterior,), style = 'mini', text = 'P', value = 0.0, - relief = Tkinter.FLAT, + relief = tkinter.FLAT, label_foreground = 'red') self.hprP['commandData'] = ['p'] self.hprP['preCallback'] = self.xformStart @@ -258,7 +265,7 @@ class Placer(AppShell): AngleDial, (hprInterior,), style = 'mini', text = 'R', value = 0.0, - relief = Tkinter.FLAT, + relief = tkinter.FLAT, label_foreground = '#00A000') self.hprR['commandData'] = ['r'] self.hprR['preCallback'] = self.xformStart @@ -276,7 +283,7 @@ class Placer(AppShell): tag_pyclass = Menubutton, tag_font=('MSSansSerif', 14), tag_activebackground = '#909090', - ring_relief = Tkinter.RIDGE) + ring_relief = tkinter.RIDGE) self.scaleMenubutton = scaleGroup.component('tag') self.bind(self.scaleMenubutton, 'Scale menu operations') self.scaleMenubutton['textvariable'] = self.scalingMode @@ -302,7 +309,7 @@ class Placer(AppShell): self.scaleX = self.createcomponent('scaleX', (), None, Floater, (scaleInterior,), text = 'X Scale', - relief = Tkinter.FLAT, + relief = tkinter.FLAT, min = 0.0001, value = 1.0, resetValue = 1.0, label_foreground = 'Red') @@ -315,7 +322,7 @@ class Placer(AppShell): self.scaleY = self.createcomponent('scaleY', (), None, Floater, (scaleInterior,), text = 'Y Scale', - relief = Tkinter.FLAT, + relief = tkinter.FLAT, min = 0.0001, value = 1.0, resetValue = 1.0, label_foreground = '#00A000') @@ -328,7 +335,7 @@ class Placer(AppShell): self.scaleZ = self.createcomponent('scaleZ', (), None, Floater, (scaleInterior,), text = 'Z Scale', - relief = Tkinter.FLAT, + relief = tkinter.FLAT, min = 0.0001, value = 1.0, resetValue = 1.0, label_foreground = 'Blue') @@ -508,8 +515,8 @@ class Placer(AppShell): dictName = name else: # Generate a unique name for the dict - dictName = name + '-' + `nodePath.get_key()` - if not dict.has_key(dictName): + dictName = name + '-' + repr(nodePath.get_key()) + if dictName not in dict: # Update combo box to include new item names.append(dictName) listbox = menu.component('scrolledlist') @@ -769,12 +776,12 @@ class Placer(AppShell): posString = '%.2f, %.2f, %.2f' % (pos[0], pos[1], pos[2]) hprString = '%.2f, %.2f, %.2f' % (hpr[0], hpr[1], hpr[2]) scaleString = '%.2f, %.2f, %.2f' % (scale[0], scale[1], scale[2]) - print 'NodePath: %s' % name - print 'Pos: %s' % posString - print 'Hpr: %s' % hprString - print 'Scale: %s' % scaleString - print ('%s.setPosHprScale(%s, %s, %s)' % - (name, posString, hprString, scaleString)) + print('NodePath: %s' % name) + print('Pos: %s' % posString) + print('Hpr: %s' % hprString) + print('Scale: %s' % scaleString) + print(('%s.setPosHprScale(%s, %s, %s)' % + (name, posString, hprString, scaleString))) def onDestroy(self, event): # Remove hooks diff --git a/contrib/src/sceneeditor/seSceneGraphExplorer.py b/contrib/src/sceneeditor/seSceneGraphExplorer.py index fc7f29370a..163287965c 100644 --- a/contrib/src/sceneeditor/seSceneGraphExplorer.py +++ b/contrib/src/sceneeditor/seSceneGraphExplorer.py @@ -9,9 +9,16 @@ # ################################################################# from direct.showbase.DirectObject import DirectObject -from Tkinter import IntVar, Frame, Label from seTree import TreeNode, TreeItem -import Pmw, Tkinter + +import Pmw, sys + +if sys.version_info >= (3, 0): + from tkinter import IntVar, Frame, Label + import tkinter +else: + from Tkinter import IntVar, Frame, Label + import Tkinter as tkinter # changing these strings requires changing sceneEditor.py SGE_ strs too! # This list of items will be showed on the pop out window when user right click on @@ -57,7 +64,7 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject): # Setup up container interior = self.interior() - interior.configure(relief = Tkinter.GROOVE, borderwidth = 2) + interior.configure(relief = tkinter.GROOVE, borderwidth = 2) # Create a label and an entry self._scrolledCanvas = self.createcomponent( @@ -69,7 +76,7 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject): self._canvas = self._scrolledCanvas.component('canvas') self._canvas['scrollregion'] = ('0i', '0i', '2i', '4i') self._scrolledCanvas.resizescrollregion() - self._scrolledCanvas.pack(padx = 3, pady = 3, expand=1, fill = Tkinter.BOTH) + self._scrolledCanvas.pack(padx = 3, pady = 3, expand=1, fill = tkinter.BOTH) self._canvas.bind('', self.mouse2Down) self._canvas.bind('', self.mouse2Motion) @@ -91,8 +98,8 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject): (), None, Label, (interior,), text = 'Active Reparent Target: ', - anchor = Tkinter.W, justify = Tkinter.LEFT) - self._label.pack(fill = Tkinter.X) + anchor = tkinter.W, justify = tkinter.LEFT) + self._label.pack(fill = tkinter.X) # Add update parent label def updateLabel(nodePath = None, s = self): @@ -145,7 +152,7 @@ class seSceneGraphExplorer(Pmw.MegaWidget, DirectObject): if item!= None: item.select(callBack) else: - print '----SGE: Error Selection' + print('----SGE: Error Selection') class SceneGraphExplorerItem(TreeItem): diff --git a/contrib/src/sceneeditor/seSelection.py b/contrib/src/sceneeditor/seSelection.py index 0d34ad120a..b7d9b260dc 100644 --- a/contrib/src/sceneeditor/seSelection.py +++ b/contrib/src/sceneeditor/seSelection.py @@ -70,7 +70,7 @@ class SelectedNodePaths(DirectObject): """ Select the specified node path. Multiselect as required """ # Do nothing if nothing selected if not nodePath: - print 'Nothing selected!!' + print('Nothing selected!!') return None # Reset selected objects and highlight if multiSelect is false @@ -124,7 +124,7 @@ class SelectedNodePaths(DirectObject): Return a list of all selected node paths. No verification of connectivity is performed on the members of the list """ - return self.selectedDict.values()[:] + return list(self.selectedDict.values()) def __getitem__(self,index): return self.getSelectedAsList()[index] @@ -141,7 +141,7 @@ class SelectedNodePaths(DirectObject): return None def getDeselectedAsList(self): - return self.deselectedDict.values()[:] + return list(self.deselectedDict.values()) def getDeselectedDict(self, id): """ @@ -385,7 +385,7 @@ class DirectBoundingBox: return '%.2f %.2f %.2f' % (vec[0], vec[1], vec[2]) def __repr__(self): - return (`self.__class__` + + return (repr(self.__class__) + '\nNodePath:\t%s\n' % self.nodePath.getName() + 'Min:\t\t%s\n' % self.vecAsString(self.min) + 'Max:\t\t%s\n' % self.vecAsString(self.max) + diff --git a/contrib/src/sceneeditor/seSession.py b/contrib/src/sceneeditor/seSession.py index ab466c4388..c8e7a1a20f 100644 --- a/contrib/src/sceneeditor/seSession.py +++ b/contrib/src/sceneeditor/seSession.py @@ -480,7 +480,7 @@ class SeSession(DirectObject): ### Customized DirectSession def isNotCycle(self, nodePath, parent): if nodePath.get_key() == parent.get_key(): - print 'DIRECT.reparent: Invalid parent' + print('DIRECT.reparent: Invalid parent') return 0 elif parent.hasParent(): return self.isNotCycle(nodePath, parent.getParent()) @@ -735,8 +735,8 @@ class SeSession(DirectObject): ### Customized DirectSession hprB = base.camera.getHpr() posE = Point3((radius*-1.41)+center.getX(), (radius*-1.41)+center.getY(), (radius*1.41)+center.getZ()) hprE = Point3(-45, -38, 0) - print posB, hprB - print posE, hprE + print(posB, hprB) + print(posE, hprE) posInterval1 = base.camera.posInterval(time, posE, bakeInStart = 1) posInterval2 = base.camera.posInterval(time, posB, bakeInStart = 1) diff --git a/contrib/src/sceneeditor/seTree.py b/contrib/src/sceneeditor/seTree.py index 9685d54b35..9927c11112 100644 --- a/contrib/src/sceneeditor/seTree.py +++ b/contrib/src/sceneeditor/seTree.py @@ -12,15 +12,21 @@ # ################################################################# -import os, sys, string, Pmw, Tkinter +import os, sys, string, Pmw from direct.showbase.DirectObject import DirectObject -from Tkinter import IntVar, Menu, PhotoImage, Label, Frame, Entry from panda3d.core import * +if sys.version_info >= (3, 0): + import tkinter + from tkinter import IntVar, Menu, PhotoImage, Label, Frame, Entry +else: + import Tkinter as tkinter + from Tkinter import IntVar, Menu, PhotoImage, Label, Frame, Entry + # Initialize icon directory ICONDIR = getModelPath().findFile(Filename('icons')).toOsSpecific() if not os.path.isdir(ICONDIR): - raise RuntimeError, "can't find DIRECT icon directory (%s)" % `ICONDIR` + raise RuntimeError("can't find DIRECT icon directory (%r)" % ICONDIR) class TreeNode: @@ -187,9 +193,9 @@ class TreeNode: oldcursor = self.canvas['cursor'] self.canvas['cursor'] = "watch" self.canvas.update() - self.canvas.delete(Tkinter.ALL) # XXX could be more subtle + self.canvas.delete(tkinter.ALL) # XXX could be more subtle self.draw(7, 2) - x0, y0, x1, y1 = self.canvas.bbox(Tkinter.ALL) + x0, y0, x1, y1 = self.canvas.bbox(tkinter.ALL) self.canvas.configure(scrollregion=(0, 0, x1, y1)) self.canvas['cursor'] = oldcursor @@ -208,7 +214,7 @@ class TreeNode: self.kidKeys = [] for item in sublist: key = item.GetKey() - if self.children.has_key(key): + if key in self.children: child = self.children[key] else: child = TreeNode(self.canvas, self, item, self.menuList) @@ -309,7 +315,7 @@ class TreeNode: def edit(self, event=None): self.entry = Entry(self.label, bd=0, highlightthickness=1, width=0) self.entry.insert(0, self.label['text']) - self.entry.selection_range(0, Tkinter.END) + self.entry.selection_range(0, tkinter.END) self.entry.pack(ipadx=5) self.entry.focus_set() self.entry.bind("", self.edit_finish) @@ -344,7 +350,7 @@ class TreeNode: for item in sublist: key = item.GetKey() # Use existing child or create new TreeNode if none exists - if self.children.has_key(key): + if key in self.children: child = self.children[key] else: child = TreeNode(self.canvas, self, item, self.menuList) From 54ec57547233fae4e3bb65e1ab0c8066c5cc53d0 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 12 Aug 2018 22:05:25 +0200 Subject: [PATCH 134/360] egg: add properties to EggData / EggNode --- panda/src/egg/eggData.h | 6 ++++++ panda/src/egg/eggGroupNode.h | 1 + panda/src/egg/eggNode.h | 15 +++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/panda/src/egg/eggData.h b/panda/src/egg/eggData.h index ad5d3a9917..0352de17e3 100644 --- a/panda/src/egg/eggData.h +++ b/panda/src/egg/eggData.h @@ -68,6 +68,12 @@ PUBLISHED: INLINE void set_egg_timestamp(time_t egg_timestamp); INLINE time_t get_egg_timestamp() const; + MAKE_PROPERTY(auto_resolve_externals, get_auto_resolve_externals, + set_auto_resolve_externals); + MAKE_PROPERTY(coordinate_system, get_coordinate_system, set_coordinate_system); + MAKE_PROPERTY(egg_filename, get_egg_filename, set_egg_filename); + MAKE_PROPERTY(egg_timestamp, get_egg_timestamp, set_egg_timestamp); + INLINE void recompute_vertex_normals(double threshold); INLINE void recompute_polygon_normals(); INLINE void strip_normals(); diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index 346c2ed817..8bbf48aea0 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/panda/src/egg/eggGroupNode.h @@ -109,6 +109,7 @@ PUBLISHED: EggNode *get_next_child(); EXTENSION(PyObject *get_children() const); + MAKE_PROPERTY(children, get_children); EggNode *add_child(EggNode *node); PT(EggNode) remove_child(EggNode *node); diff --git a/panda/src/egg/eggNode.h b/panda/src/egg/eggNode.h index c2d811859e..950ae5e257 100644 --- a/panda/src/egg/eggNode.h +++ b/panda/src/egg/eggNode.h @@ -44,6 +44,9 @@ PUBLISHED: INLINE bool is_under_transform() const; INLINE bool is_local_coord() const; + MAKE_PROPERTY(parent, get_parent); + MAKE_PROPERTY(depth, get_depth); + INLINE const LMatrix4d &get_vertex_frame() const; INLINE const LMatrix4d &get_node_frame() const; INLINE const LMatrix4d &get_vertex_frame_inv() const; @@ -51,12 +54,12 @@ PUBLISHED: INLINE const LMatrix4d &get_vertex_to_node() const; INLINE const LMatrix4d &get_node_to_vertex() const; - INLINE const LMatrix4d *get_vertex_frame_ptr()const; - INLINE const LMatrix4d *get_node_frame_ptr()const; - INLINE const LMatrix4d *get_vertex_frame_inv_ptr()const; - INLINE const LMatrix4d *get_node_frame_inv_ptr()const; - INLINE const LMatrix4d *get_vertex_to_node_ptr()const; - INLINE const LMatrix4d *get_node_to_vertex_ptr()const; + INLINE const LMatrix4d *get_vertex_frame_ptr() const; + INLINE const LMatrix4d *get_node_frame_ptr() const; + INLINE const LMatrix4d *get_vertex_frame_inv_ptr() const; + INLINE const LMatrix4d *get_node_frame_inv_ptr() const; + INLINE const LMatrix4d *get_vertex_to_node_ptr() const; + INLINE const LMatrix4d *get_node_to_vertex_ptr() const; INLINE void transform(const LMatrix4d &mat); INLINE void transform_vertices_only(const LMatrix4d &mat); From 72e593800f3866d92ca34580cfa412ae16a1fc39 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 12 Aug 2018 22:06:13 +0200 Subject: [PATCH 135/360] gobj: don't recalculate proj mat on set_near/far with existing value --- panda/src/gobj/lens.I | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/panda/src/gobj/lens.I b/panda/src/gobj/lens.I index 91fb6e7170..d20d53bfd7 100644 --- a/panda/src/gobj/lens.I +++ b/panda/src/gobj/lens.I @@ -667,9 +667,11 @@ do_get_film_offset(const CData *cdata) const { */ INLINE void Lens:: do_set_near(CData *cdata, PN_stdfloat near_distance) { - cdata->_near_distance = near_distance; - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); - do_throw_change_event(cdata); + if (near_distance != cdata->_near_distance) { + cdata->_near_distance = near_distance; + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); + do_throw_change_event(cdata); + } } /** @@ -685,9 +687,11 @@ do_get_near(const CData *cdata) const { */ INLINE void Lens:: do_set_far(CData *cdata, PN_stdfloat far_distance) { - cdata->_far_distance = far_distance; - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); - do_throw_change_event(cdata); + if (far_distance != cdata->_far_distance) { + cdata->_far_distance = far_distance; + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); + do_throw_change_event(cdata); + } } /** @@ -703,10 +707,12 @@ do_get_far(const CData *cdata) const { */ INLINE void Lens:: do_set_near_far(CData *cdata, PN_stdfloat near_distance, PN_stdfloat far_distance) { - cdata->_near_distance = near_distance; - cdata->_far_distance = far_distance; - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); - do_throw_change_event(cdata); + if (near_distance != cdata->_near_distance || far_distance != cdata->_far_distance) { + cdata->_near_distance = near_distance; + cdata->_far_distance = far_distance; + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv, 0); + do_throw_change_event(cdata); + } } INLINE std::ostream & From 838d238f6ef4529dd9e7649c78fb617b4133082e Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 12 Aug 2018 22:11:42 +0200 Subject: [PATCH 136/360] tests: add various test cases to test egg loading and transforms Used to track down and reproduce the issue in #228. --- tests/egg/test_egg_transform.py | 134 ++++++++++++++++++++++++++++ tests/egg2pg/test_egg_coordsys.py | 103 +++++++++++++++++++++ tests/linmath/test_matrix_invert.py | 20 +++++ 3 files changed, 257 insertions(+) create mode 100644 tests/egg/test_egg_transform.py create mode 100644 tests/egg2pg/test_egg_coordsys.py create mode 100644 tests/linmath/test_matrix_invert.py diff --git a/tests/egg/test_egg_transform.py b/tests/egg/test_egg_transform.py new file mode 100644 index 0000000000..70e4d17fc6 --- /dev/null +++ b/tests/egg/test_egg_transform.py @@ -0,0 +1,134 @@ +import pytest +from panda3d import core + +# Skip these tests if we can't import egg. +egg = pytest.importorskip("panda3d.egg") + + +EGG_TRANSFORM_MISSING = """ + { %s } + { +} +""" + +EGG_TRANSFORM_EMPTY = """ + { %s } + { + { + } +} +""" + +EGG_TRANSFORM_IDENT = """ + { %s } + { + { + { + 1 0 0 0 + 0 1 0 0 + 0 0 1 0 + 0 0 0 1 + } + } +} +""" + +EGG_TRANSFORM_MATRIX = """ + { %s } + { + { + { + 5 2 -3 4 + 5 6 7 8 + 9 1 -3 2 + 5 2 5 2 + } + } +} +""" + +COORD_SYSTEMS = { + core.CS_zup_right: "zup-right", + core.CS_yup_right: "yup-right", + core.CS_zup_left: "zup-left", + core.CS_yup_left: "yup-left", +} + +def read_egg_string(string): + """Reads an EggData from a string.""" + stream = core.StringStream(string.encode('utf-8')) + data = egg.EggData() + assert data.read(stream) + return data + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS.keys()) +def test_egg_transform_missing(coordsys): + data = read_egg_string(EGG_TRANSFORM_MISSING % COORD_SYSTEMS[coordsys]) + assert data.get_coordinate_system() == coordsys + + child, = data.get_children() + assert not child.has_transform3d() + assert child.transform_is_identity() + + assert child.get_vertex_frame() == core.Mat4D.ident_mat() + assert child.get_node_frame() == core.Mat4D.ident_mat() + assert child.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert child.get_node_frame_inv() == core.Mat4D.ident_mat() + assert child.get_vertex_to_node() == core.Mat4D.ident_mat() + assert child.get_node_to_vertex() == core.Mat4D.ident_mat() + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS.keys()) +def test_egg_transform_empty(coordsys): + data = read_egg_string(EGG_TRANSFORM_EMPTY % COORD_SYSTEMS[coordsys]) + assert data.get_coordinate_system() == coordsys + + child, = data.get_children() + assert not child.has_transform3d() + assert child.transform_is_identity() + + assert child.get_vertex_frame() == core.Mat4D.ident_mat() + assert child.get_node_frame() == core.Mat4D.ident_mat() + assert child.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert child.get_node_frame_inv() == core.Mat4D.ident_mat() + assert child.get_vertex_to_node() == core.Mat4D.ident_mat() + assert child.get_node_to_vertex() == core.Mat4D.ident_mat() + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS.keys()) +def test_egg_transform_ident(coordsys): + data = read_egg_string(EGG_TRANSFORM_IDENT % COORD_SYSTEMS[coordsys]) + assert data.get_coordinate_system() == coordsys + + child, = data.get_children() + assert child.has_transform3d() + assert child.transform_is_identity() + + assert child.get_vertex_frame() == core.Mat4D.ident_mat() + assert child.get_node_frame() == core.Mat4D.ident_mat() + assert child.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert child.get_node_frame_inv() == core.Mat4D.ident_mat() + assert child.get_vertex_to_node() == core.Mat4D.ident_mat() + assert child.get_node_to_vertex() == core.Mat4D.ident_mat() + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS.keys()) +def test_egg_transform_matrix(coordsys): + data = read_egg_string(EGG_TRANSFORM_MATRIX % COORD_SYSTEMS[coordsys]) + assert data.get_coordinate_system() == coordsys + + mat = core.Mat4D(5, 2, -3, 4, 5, 6, 7, 8, 9, 1, -3, 2, 5, 2, 5, 2) + mat_inv = core.invert(mat) + + child, = data.get_children() + assert child.has_transform3d() + assert not child.transform_is_identity() + assert child.get_transform3d() == mat + + assert child.get_vertex_frame() == core.Mat4D.ident_mat() + assert child.get_node_frame() == mat + assert child.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert child.get_node_frame_inv() == mat_inv + assert child.get_vertex_to_node() == mat_inv + assert child.get_node_to_vertex() == mat diff --git a/tests/egg2pg/test_egg_coordsys.py b/tests/egg2pg/test_egg_coordsys.py new file mode 100644 index 0000000000..b3c5583075 --- /dev/null +++ b/tests/egg2pg/test_egg_coordsys.py @@ -0,0 +1,103 @@ +import pytest +from panda3d import core + +# Skip these tests if we can't import egg. +egg = pytest.importorskip("panda3d.egg") + + +COORD_SYSTEMS = [core.CS_zup_right, core.CS_yup_right, core.CS_zup_left, core.CS_yup_left] + + +@pytest.mark.parametrize("egg_coordsys", COORD_SYSTEMS) +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS) +def test_egg2pg_transform_ident(egg_coordsys, coordsys): + # Ensures that an identity matrix always remains untouched. + group = egg.EggGroup("group") + group.add_matrix4(core.Mat4D.ident_mat()) + assert group.transform_is_identity() + + assert group.get_vertex_frame() == core.Mat4D.ident_mat() + assert group.get_node_frame() == core.Mat4D.ident_mat() + assert group.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert group.get_node_frame_inv() == core.Mat4D.ident_mat() + assert group.get_vertex_to_node() == core.Mat4D.ident_mat() + assert group.get_node_to_vertex() == core.Mat4D.ident_mat() + + data = egg.EggData() + data.set_coordinate_system(egg_coordsys) + data.add_child(group) + + root = egg.load_egg_data(data, coordsys) + assert root + node, = root.children + + assert node.transform.is_identity() + + +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS) +def test_egg2pg_transform_mat_unchanged(coordsys): + # Ensures that the matrix remains unchanged if coordinate system is same. + mat = (5, 2, -3, 4, 5, 6, 7, 8, 9, 1, -3, 2, 5, 2, 5, 2) + group = egg.EggGroup("group") + group.add_matrix4(mat) + assert not group.transform_is_identity() + + assert group.get_vertex_frame() == core.Mat4D.ident_mat() + assert group.get_node_frame() == mat + assert group.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert group.get_node_frame_inv() == core.invert(mat) + assert group.get_vertex_to_node() == core.invert(mat) + assert group.get_node_to_vertex() == mat + + data = egg.EggData() + data.set_coordinate_system(coordsys) + data.add_child(group) + + root = egg.load_egg_data(data, coordsys) + assert root + node, = root.children + + assert node.transform.mat == mat + + +@pytest.mark.parametrize("egg_coordsys", COORD_SYSTEMS) +@pytest.mark.parametrize("coordsys", COORD_SYSTEMS) +def test_egg2pg_transform_pos3d(egg_coordsys, coordsys): + vpool = egg.EggVertexPool("vpool") + vtx = vpool.make_new_vertex(core.Point3D.rfu(-8, 0.5, 4.5, egg_coordsys)) + + point = egg.EggPoint() + point.add_vertex(vtx) + + group = egg.EggGroup("group") + group.add_translate3d(core.Point3D.rfu(1, 2, 3, egg_coordsys)) + assert not group.transform_is_identity() + group.add_child(point) + + mat = group.get_transform3d() + assert group.get_vertex_frame() == core.Mat4D.ident_mat() + assert group.get_node_frame() == mat + assert group.get_vertex_frame_inv() == core.Mat4D.ident_mat() + assert group.get_node_frame_inv() == core.invert(mat) + assert group.get_vertex_to_node() == core.invert(mat) + assert group.get_node_to_vertex() == mat + + assert group.get_vertex_frame_ptr() is None + assert group.get_vertex_frame_inv_ptr() is None + + data = egg.EggData() + data.set_coordinate_system(egg_coordsys) + data.add_child(vpool) + data.add_child(group) + + root = egg.load_egg_data(data, coordsys) + assert root + node, = root.children + + # Ensure the node has the expected position. + assert node.transform.pos == core.Point3.rfu(1, 2, 3, coordsys) + + # Get the location of the vertex. This is a quick, hacky way to get it. + point = core.NodePath(node).get_tight_bounds()[0] + assert point == core.Point3.rfu(-8, 0.5, 4.5, coordsys) + diff --git a/tests/linmath/test_matrix_invert.py b/tests/linmath/test_matrix_invert.py new file mode 100644 index 0000000000..b2e6dd49bf --- /dev/null +++ b/tests/linmath/test_matrix_invert.py @@ -0,0 +1,20 @@ +import pytest +from panda3d import core + + +@pytest.mark.parametrize("type", (core.Mat4, core.Mat4D)) +def test_mat4_invert(type): + mat = type((1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 1, 2, 3, 1)) + inv = type() + assert inv.invert_from(mat) + + assert inv == type(( 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + -1, -2, -3, 1)) + + assert (mat * inv).is_identity() + assert (inv * mat).is_identity() From f84b0840f90011f3d34097d624551ca9a8850f0d Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 12 Aug 2018 22:15:40 +0200 Subject: [PATCH 137/360] makepanda: work around GCC/Eigen double matrix invert bug Fixes #228 --- makepanda/makepanda.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index df25c49f39..6181ccf87e 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1351,6 +1351,9 @@ def CompileCxx(obj,src,opts): # Fast math is nice, but we'd like to see NaN in dev builds. cmd += " -fno-finite-math-only" + # Make sure this is off to avoid GCC/Eigen bug (see GitHub #228) + cmd += " -fno-unsafe-math-optimizations" + if (optlevel==1): cmd += " -ggdb -D_DEBUG" if (optlevel==2): cmd += " -O1 -D_DEBUG" if (optlevel==3): cmd += " -O2" From 00b5c9d168b225bbd5bc17acf78c24654aa6f27f Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 12 Aug 2018 22:22:25 +0200 Subject: [PATCH 138/360] assimp: add various config variables, change default winding order --- pandatool/src/assimp/assimpLoader.cxx | 31 ++++++++++++++++-- pandatool/src/assimp/config_assimp.cxx | 44 ++++++++++++++++++++++++++ pandatool/src/assimp/config_assimp.h | 11 ++++++- 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index 61c7514aa6..d04c1d55ad 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -103,9 +103,34 @@ bool AssimpLoader:: read(const Filename &filename) { _filename = filename; - // I really don't know why we need to flip the winding order, but otherwise - // the models I tested with are showing inside out. - _scene = _importer.ReadFile(_filename.c_str(), aiProcess_Triangulate | aiProcess_GenUVCoords | aiProcess_FlipWindingOrder); + unsigned int flags = aiProcess_Triangulate | aiProcess_GenUVCoords; + + if (assimp_calc_tangent_space) { + flags |= aiProcess_CalcTangentSpace; + } + if (assimp_join_identical_vertices) { + flags |= aiProcess_JoinIdenticalVertices; + } + if (assimp_improve_cache_locality) { + flags |= aiProcess_ImproveCacheLocality; + } + if (assimp_remove_redundant_materials) { + flags |= aiProcess_RemoveRedundantMaterials; + } + if (assimp_fix_infacing_normals) { + flags |= aiProcess_FixInfacingNormals; + } + if (assimp_optimize_meshes) { + flags |= aiProcess_OptimizeMeshes; + } + if (assimp_optimize_graph) { + flags |= aiProcess_OptimizeGraph; + } + if (assimp_flip_winding_order) { + flags |= aiProcess_FlipWindingOrder; + } + + _scene = _importer.ReadFile(_filename.c_str(), flags); if (_scene == nullptr) { _error = true; return false; diff --git a/pandatool/src/assimp/config_assimp.cxx b/pandatool/src/assimp/config_assimp.cxx index 6e7dfcfe86..2dbf29fa16 100644 --- a/pandatool/src/assimp/config_assimp.cxx +++ b/pandatool/src/assimp/config_assimp.cxx @@ -25,6 +25,50 @@ ConfigureFn(config_assimp) { init_libassimp(); } +ConfigVariableBool assimp_calc_tangent_space +("assimp-calc-tangent-space", false, + PRC_DESC("Calculates tangents and binormals for meshes imported via Assimp.")); + +ConfigVariableBool assimp_join_identical_vertices +("assimp-join-identical-vertices", true, + PRC_DESC("Merges duplicate vertices. Set this to false if you want each " + "vertex to only be in use on one triangle.")); + +ConfigVariableBool assimp_improve_cache_locality +("assimp-improve-cache-locality", true, + PRC_DESC("Improves rendering performance of the loaded meshes by reordering " + "triangles for better vertex cache locality. Set this to false if " + "you need geometry to be loaded in the exact order that it was " + "specified in the file, or to improve load performance.")); + +ConfigVariableBool assimp_remove_redundant_materials +("assimp-remove-redundant-materials", true, + PRC_DESC("Removes redundant/unreferenced materials from assets.")); + +ConfigVariableBool assimp_fix_infacing_normals +("assimp-fix-infacing-normals", false, + PRC_DESC("Determines which normal vectors are facing inward and inverts them " + "so that they are facing outward.")); + +ConfigVariableBool assimp_optimize_meshes +("assimp-optimize-meshes", true, + PRC_DESC("Removes the number of draw calls by unifying geometry with the same " + "materials. Especially effective in conjunction with " + "assimp-optimize-graph and assimp-remove-redundant-materials.")); + +ConfigVariableBool assimp_optimize_graph +("assimp-optimize-graph", false, + PRC_DESC("Optimizes the scene geometry by flattening the scene hierarchy. " + "This is very efficient (combined with assimp-optimize-meshes), but " + "it may result the hierarchy to become lost, so it is disabled by " + "default.")); + +ConfigVariableBool assimp_flip_winding_order +("assimp-flip-winding-order", false, + PRC_DESC("Set this true to flip the winding order of all models loaded via " + "the Assimp loader. Note that you may need to clear the model-cache " + "after changing this.")); + /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/pandatool/src/assimp/config_assimp.h b/pandatool/src/assimp/config_assimp.h index 7ca6a98094..16efc8a754 100644 --- a/pandatool/src/assimp/config_assimp.h +++ b/pandatool/src/assimp/config_assimp.h @@ -15,12 +15,21 @@ #define CONFIG_ASSIMP_H #include "pandatoolbase.h" - +#include "configVariableBool.h" #include "dconfig.h" ConfigureDecl(config_assimp, EXPCL_ASSIMP, EXPTP_ASSIMP); NotifyCategoryDecl(assimp, EXPCL_ASSIMP, EXPTP_ASSIMP); +extern ConfigVariableBool assimp_calc_tangent_space; +extern ConfigVariableBool assimp_join_identical_vertices; +extern ConfigVariableBool assimp_improve_cache_locality; +extern ConfigVariableBool assimp_remove_redundant_materials; +extern ConfigVariableBool assimp_fix_infacing_normals; +extern ConfigVariableBool assimp_optimize_meshes; +extern ConfigVariableBool assimp_optimize_graph; +extern ConfigVariableBool assimp_flip_winding_order; + extern EXPCL_ASSIMP void init_libassimp(); #endif From 6105953b40d424e932a8f4a8446b0ecca19dd6b7 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 14 Aug 2018 17:23:48 -0600 Subject: [PATCH 139/360] general: Add forgotten include --- panda/src/collide/collisionBox.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index 119284f905..a8af257456 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -16,6 +16,7 @@ #include "collisionRay.h" #include "collisionSphere.h" #include "collisionSegment.h" +#include "collisionTube.h" #include "collisionHandler.h" #include "collisionEntry.h" #include "config_collide.h" From 06f7da521548609f2e32b549b6728253c81c5162 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 14 Aug 2018 21:56:52 -0600 Subject: [PATCH 140/360] express: Fix misclassified EXPCL_PANDA_ macro --- panda/src/express/zStreamBuf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/express/zStreamBuf.h b/panda/src/express/zStreamBuf.h index 35446090db..3dadd1543d 100644 --- a/panda/src/express/zStreamBuf.h +++ b/panda/src/express/zStreamBuf.h @@ -24,7 +24,7 @@ /** * The streambuf object that implements IDecompressStream and OCompressStream. */ -class EXPCL_PANDA_DOWNLOADER ZStreamBuf : public std::streambuf { +class EXPCL_PANDA_EXPRESS ZStreamBuf : public std::streambuf { public: ZStreamBuf(); virtual ~ZStreamBuf(); From 97d6d84adef4f072e6273d5a1b05c41f612fe228 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 15 Aug 2018 20:38:00 -0600 Subject: [PATCH 141/360] dcparser: Add BUILDING_DIRECT_DCPARSER switch Resolves GH #342. --- direct/src/dcparser/dcArrayParameter.h | 2 +- direct/src/dcparser/dcAtomicField.h | 2 +- direct/src/dcparser/dcClass.h | 2 +- direct/src/dcparser/dcClassParameter.h | 2 +- direct/src/dcparser/dcDeclaration.h | 2 +- direct/src/dcparser/dcField.h | 2 +- direct/src/dcparser/dcFile.h | 2 +- direct/src/dcparser/dcKeyword.h | 2 +- direct/src/dcparser/dcKeywordList.h | 2 +- direct/src/dcparser/dcMolecularField.h | 2 +- direct/src/dcparser/dcNumericRange.h | 2 +- direct/src/dcparser/dcPackData.h | 2 +- direct/src/dcparser/dcPacker.h | 2 +- direct/src/dcparser/dcPackerCatalog.h | 2 +- direct/src/dcparser/dcPackerInterface.h | 2 +- direct/src/dcparser/dcParameter.h | 2 +- direct/src/dcparser/dcParserDefs.h | 2 +- direct/src/dcparser/dcSimpleParameter.h | 2 +- direct/src/dcparser/dcSwitch.h | 2 +- direct/src/dcparser/dcSwitchParameter.h | 2 +- direct/src/dcparser/dcTypedef.h | 2 +- direct/src/dcparser/dcbase.h | 5 +++++ direct/src/dcparser/hashGenerator.h | 2 +- direct/src/dcparser/primeNumberGenerator.h | 2 +- direct/src/directbase/directsymbols.h | 9 +++++++++ 25 files changed, 37 insertions(+), 23 deletions(-) diff --git a/direct/src/dcparser/dcArrayParameter.h b/direct/src/dcparser/dcArrayParameter.h index fd5008fb97..97fb32bdf0 100644 --- a/direct/src/dcparser/dcArrayParameter.h +++ b/direct/src/dcparser/dcArrayParameter.h @@ -23,7 +23,7 @@ * parameter type accepts an arbitrary (or possibly fixed) number of nested * fields, all of which are of the same type. */ -class DCArrayParameter : public DCParameter { +class EXPCL_DIRECT_DCPARSER DCArrayParameter : public DCParameter { public: DCArrayParameter(DCParameter *element_type, const DCUnsignedIntRange &size = DCUnsignedIntRange()); diff --git a/direct/src/dcparser/dcAtomicField.h b/direct/src/dcparser/dcAtomicField.h index e0d7cee58e..9eb92e2527 100644 --- a/direct/src/dcparser/dcAtomicField.h +++ b/direct/src/dcparser/dcAtomicField.h @@ -27,7 +27,7 @@ * This defines an interface to the Distributed Class, and is always * implemented as a remote procedure method. */ -class DCAtomicField : public DCField { +class EXPCL_DIRECT_DCPARSER DCAtomicField : public DCField { public: DCAtomicField(const std::string &name, DCClass *dclass, bool bogus_field); virtual ~DCAtomicField(); diff --git a/direct/src/dcparser/dcClass.h b/direct/src/dcparser/dcClass.h index 9f7945b372..cd69716470 100644 --- a/direct/src/dcparser/dcClass.h +++ b/direct/src/dcparser/dcClass.h @@ -41,7 +41,7 @@ class DCParameter; /** * Defines a particular DistributedClass as read from an input .dc file. */ -class DCClass : public DCDeclaration { +class EXPCL_DIRECT_DCPARSER DCClass : public DCDeclaration { public: DCClass(DCFile *dc_file, const std::string &name, bool is_struct, bool bogus_class); diff --git a/direct/src/dcparser/dcClassParameter.h b/direct/src/dcparser/dcClassParameter.h index 3657190bf9..05b84e84c3 100644 --- a/direct/src/dcparser/dcClassParameter.h +++ b/direct/src/dcparser/dcClassParameter.h @@ -23,7 +23,7 @@ class DCClass; * This represents a class (or struct) object used as a parameter itself. * This means that all the fields of the class get packed into the message. */ -class DCClassParameter : public DCParameter { +class EXPCL_DIRECT_DCPARSER DCClassParameter : public DCParameter { public: DCClassParameter(const DCClass *dclass); DCClassParameter(const DCClassParameter ©); diff --git a/direct/src/dcparser/dcDeclaration.h b/direct/src/dcparser/dcDeclaration.h index 0fd4392ca6..c6b8b7dd54 100644 --- a/direct/src/dcparser/dcDeclaration.h +++ b/direct/src/dcparser/dcDeclaration.h @@ -26,7 +26,7 @@ class DCSwitch; * only purpose is so that classes and typedefs can be stored in one list * together so they can be ordered correctly on output. */ -class DCDeclaration { +class EXPCL_DIRECT_DCPARSER DCDeclaration { public: virtual ~DCDeclaration(); diff --git a/direct/src/dcparser/dcField.h b/direct/src/dcparser/dcField.h index 6744ea93d4..dc06ff76f2 100644 --- a/direct/src/dcparser/dcField.h +++ b/direct/src/dcparser/dcField.h @@ -34,7 +34,7 @@ class HashGenerator; /** * A single field of a Distributed Class, either atomic or molecular. */ -class DCField : public DCPackerInterface, public DCKeywordList { +class EXPCL_DIRECT_DCPARSER DCField : public DCPackerInterface, public DCKeywordList { public: DCField(); DCField(const std::string &name, DCClass *dclass); diff --git a/direct/src/dcparser/dcFile.h b/direct/src/dcparser/dcFile.h index 7d7550804f..37ebbe9181 100644 --- a/direct/src/dcparser/dcFile.h +++ b/direct/src/dcparser/dcFile.h @@ -29,7 +29,7 @@ class DCDeclaration; * Represents the complete list of Distributed Class descriptions as read from * a .dc file. */ -class DCFile { +class EXPCL_DIRECT_DCPARSER DCFile { PUBLISHED: DCFile(); ~DCFile(); diff --git a/direct/src/dcparser/dcKeyword.h b/direct/src/dcparser/dcKeyword.h index a82bd1ef0f..7447b6ed78 100644 --- a/direct/src/dcparser/dcKeyword.h +++ b/direct/src/dcparser/dcKeyword.h @@ -25,7 +25,7 @@ class HashGenerator; * define a communication property associated with a field, for instance * "broadcast" or "airecv". */ -class DCKeyword : public DCDeclaration { +class EXPCL_DIRECT_DCPARSER DCKeyword : public DCDeclaration { public: DCKeyword(const std::string &name, int historical_flag = ~0); virtual ~DCKeyword(); diff --git a/direct/src/dcparser/dcKeywordList.h b/direct/src/dcparser/dcKeywordList.h index d9905c64db..ac0ed574fe 100644 --- a/direct/src/dcparser/dcKeywordList.h +++ b/direct/src/dcparser/dcKeywordList.h @@ -23,7 +23,7 @@ class HashGenerator; * This is a list of keywords (see DCKeyword) that may be set on a particular * field. */ -class DCKeywordList { +class EXPCL_DIRECT_DCPARSER DCKeywordList { public: DCKeywordList(); DCKeywordList(const DCKeywordList ©); diff --git a/direct/src/dcparser/dcMolecularField.h b/direct/src/dcparser/dcMolecularField.h index db7d850e00..8983eddab0 100644 --- a/direct/src/dcparser/dcMolecularField.h +++ b/direct/src/dcparser/dcMolecularField.h @@ -25,7 +25,7 @@ class DCParameter; * This represents a combination of two or more related atomic fields, that * will often be treated as a unit. */ -class DCMolecularField : public DCField { +class EXPCL_DIRECT_DCPARSER DCMolecularField : public DCField { public: DCMolecularField(const std::string &name, DCClass *dclass); diff --git a/direct/src/dcparser/dcNumericRange.h b/direct/src/dcparser/dcNumericRange.h index b3450f89e4..f751323b01 100644 --- a/direct/src/dcparser/dcNumericRange.h +++ b/direct/src/dcparser/dcNumericRange.h @@ -23,7 +23,7 @@ * to constrain simple numeric types, as well as array sizes. */ template -class DCNumericRange { +class EXPCL_DIRECT_DCPARSER DCNumericRange { public: typedef NUM Number; diff --git a/direct/src/dcparser/dcPackData.h b/direct/src/dcparser/dcPackData.h index 7f891a1d5d..e5a3b53e5d 100644 --- a/direct/src/dcparser/dcPackData.h +++ b/direct/src/dcparser/dcPackData.h @@ -19,7 +19,7 @@ /** * This is a block of data that receives the results of DCPacker. */ -class DCPackData { +class EXPCL_DIRECT_DCPARSER DCPackData { PUBLISHED: INLINE DCPackData(); INLINE ~DCPackData(); diff --git a/direct/src/dcparser/dcPacker.h b/direct/src/dcparser/dcPacker.h index 9de32ff2cd..68a01a5999 100644 --- a/direct/src/dcparser/dcPacker.h +++ b/direct/src/dcparser/dcPacker.h @@ -31,7 +31,7 @@ class DCSwitchParameter; * See also direct/src/doc/dcPacker.txt for a more complete description and * examples of using this class. */ -class DCPacker { +class EXPCL_DIRECT_DCPARSER DCPacker { PUBLISHED: DCPacker(); ~DCPacker(); diff --git a/direct/src/dcparser/dcPackerCatalog.h b/direct/src/dcparser/dcPackerCatalog.h index c03b1b5fc6..9a37f84a41 100644 --- a/direct/src/dcparser/dcPackerCatalog.h +++ b/direct/src/dcparser/dcPackerCatalog.h @@ -26,7 +26,7 @@ class DCSwitchParameter; * requested from a particular field; its ownership is retained by the field * so it must not be deleted. */ -class DCPackerCatalog { +class EXPCL_DIRECT_DCPARSER DCPackerCatalog { private: DCPackerCatalog(const DCPackerInterface *root); DCPackerCatalog(const DCPackerCatalog ©); diff --git a/direct/src/dcparser/dcPackerInterface.h b/direct/src/dcparser/dcPackerInterface.h index 171ed3f0ca..ef28b85647 100644 --- a/direct/src/dcparser/dcPackerInterface.h +++ b/direct/src/dcparser/dcPackerInterface.h @@ -64,7 +64,7 @@ END_PUBLISH * Normally these methods are called only by the DCPacker object; the user * wouldn't normally call these directly. */ -class DCPackerInterface { +class EXPCL_DIRECT_DCPARSER DCPackerInterface { public: DCPackerInterface(const std::string &name = std::string()); DCPackerInterface(const DCPackerInterface ©); diff --git a/direct/src/dcparser/dcParameter.h b/direct/src/dcparser/dcParameter.h index 59a34dc440..49e6df12fe 100644 --- a/direct/src/dcparser/dcParameter.h +++ b/direct/src/dcparser/dcParameter.h @@ -32,7 +32,7 @@ class HashGenerator; * This may also be a typedef reference to another type, which has the same * properties as the referenced type, but a different name. */ -class DCParameter : public DCField { +class EXPCL_DIRECT_DCPARSER DCParameter : public DCField { protected: DCParameter(); DCParameter(const DCParameter ©); diff --git a/direct/src/dcparser/dcParserDefs.h b/direct/src/dcparser/dcParserDefs.h index da1747ab15..28659a37e3 100644 --- a/direct/src/dcparser/dcParserDefs.h +++ b/direct/src/dcparser/dcParserDefs.h @@ -43,7 +43,7 @@ extern DCFile *dc_file; // that has member functions in a union), so we'll use a class instead. That // means we need to declare it externally, here. -class DCTokenType { +class EXPCL_DIRECT_DCPARSER DCTokenType { public: union U { int s_int; diff --git a/direct/src/dcparser/dcSimpleParameter.h b/direct/src/dcparser/dcSimpleParameter.h index b6da9a8bff..7b47773a3d 100644 --- a/direct/src/dcparser/dcSimpleParameter.h +++ b/direct/src/dcparser/dcSimpleParameter.h @@ -25,7 +25,7 @@ * divisor, which is meaningful only for the numeric type elements (and * represents a fixed-point numeric convention). */ -class DCSimpleParameter : public DCParameter { +class EXPCL_DIRECT_DCPARSER DCSimpleParameter : public DCParameter { public: DCSimpleParameter(DCSubatomicType type, unsigned int divisor = 1); DCSimpleParameter(const DCSimpleParameter ©); diff --git a/direct/src/dcparser/dcSwitch.h b/direct/src/dcparser/dcSwitch.h index 17e4e856a2..ac58f5439d 100644 --- a/direct/src/dcparser/dcSwitch.h +++ b/direct/src/dcparser/dcSwitch.h @@ -27,7 +27,7 @@ class DCField; * and represents two or more alternative unpacking schemes based on the first * field read. */ -class DCSwitch : public DCDeclaration { +class EXPCL_DIRECT_DCPARSER DCSwitch : public DCDeclaration { public: DCSwitch(const std::string &name, DCField *key_parameter); virtual ~DCSwitch(); diff --git a/direct/src/dcparser/dcSwitchParameter.h b/direct/src/dcparser/dcSwitchParameter.h index 51b8b673f6..7d123493aa 100644 --- a/direct/src/dcparser/dcSwitchParameter.h +++ b/direct/src/dcparser/dcSwitchParameter.h @@ -23,7 +23,7 @@ class DCSwitch; * This represents a switch object used as a parameter itself, which packs the * appropriate fields of the switch into the message. */ -class DCSwitchParameter : public DCParameter { +class EXPCL_DIRECT_DCPARSER DCSwitchParameter : public DCParameter { public: DCSwitchParameter(const DCSwitch *dswitch); DCSwitchParameter(const DCSwitchParameter ©); diff --git a/direct/src/dcparser/dcTypedef.h b/direct/src/dcparser/dcTypedef.h index 654c8998a8..769f1f129f 100644 --- a/direct/src/dcparser/dcTypedef.h +++ b/direct/src/dcparser/dcTypedef.h @@ -23,7 +23,7 @@ class DCParameter; * This represents a single typedef declaration in the dc file. It assigns a * particular type to a new name, just like a C typedef. */ -class DCTypedef : public DCDeclaration { +class EXPCL_DIRECT_DCPARSER DCTypedef : public DCDeclaration { public: DCTypedef(DCParameter *parameter, bool implicit = false); DCTypedef(const std::string &name); diff --git a/direct/src/dcparser/dcbase.h b/direct/src/dcparser/dcbase.h index 4f2712f148..64ef117158 100644 --- a/direct/src/dcparser/dcbase.h +++ b/direct/src/dcparser/dcbase.h @@ -70,6 +70,11 @@ #define END_PUBLISH #define BLOCKING +// These control the declspec(dllexport/dllimport) on Windows. When compiling +// outside of Panda, we assume we aren't part of a DLL. +#define EXPCL_DIRECT_DCPARSER +#define EXPTP_DIRECT_DCPARSER + // Panda defines some assert-type macros. We map those to the standard assert // macro outside of Panda. #define nassertr(condition, return_value) assert(condition) diff --git a/direct/src/dcparser/hashGenerator.h b/direct/src/dcparser/hashGenerator.h index 94031cd2f6..29ae1a6609 100644 --- a/direct/src/dcparser/hashGenerator.h +++ b/direct/src/dcparser/hashGenerator.h @@ -20,7 +20,7 @@ /** * This class generates an arbitrary hash number from a sequence of ints. */ -class HashGenerator { +class EXPCL_DIRECT_DCPARSER HashGenerator { public: HashGenerator(); diff --git a/direct/src/dcparser/primeNumberGenerator.h b/direct/src/dcparser/primeNumberGenerator.h index 8b24ae6b5c..7aa49e09a9 100644 --- a/direct/src/dcparser/primeNumberGenerator.h +++ b/direct/src/dcparser/primeNumberGenerator.h @@ -30,7 +30,7 @@ typedef std::vector vector_int; * For a given integer n, it will return the nth prime number. This will * involve a recompute step only if n is greater than any previous n. */ -class PrimeNumberGenerator { +class EXPCL_DIRECT_DCPARSER PrimeNumberGenerator { public: PrimeNumberGenerator(); diff --git a/direct/src/directbase/directsymbols.h b/direct/src/directbase/directsymbols.h index cdd07e1a0c..55fd2bd4e8 100644 --- a/direct/src/directbase/directsymbols.h +++ b/direct/src/directbase/directsymbols.h @@ -18,6 +18,7 @@ /* BUILDING_DIRECT is just a buildsystem shortcut for all of these: */ #ifdef BUILDING_DIRECT + #define BUILDING_DIRECT_DCPARSER #define BUILDING_DIRECT_DEADREC #define BUILDING_DIRECT_DIRECTD #define BUILDING_DIRECT_INTERVAL @@ -26,6 +27,14 @@ #define BUILDING_DIRECT_DISTRIBUTED #endif +#ifdef BUILDING_DIRECT_DCPARSER + #define EXPCL_DIRECT_DCPARSER EXPORT_CLASS + #define EXPTP_DIRECT_DCPARSER EXPORT_TEMPL +#else + #define EXPCL_DIRECT_DCPARSER IMPORT_CLASS + #define EXPTP_DIRECT_DCPARSER IMPORT_TEMPL +#endif + #ifdef BUILDING_DIRECT_DEADREC #define EXPCL_DIRECT_DEADREC EXPORT_CLASS #define EXPTP_DIRECT_DEADREC EXPORT_TEMPL From ba345d590fbeba5c0103b1458971f576461bd526 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 13:40:38 +0200 Subject: [PATCH 142/360] express: make Datagram.get_message() return bytes in Python 3 This is done using a Python extension function, which also happens to make the call more efficient as this avoids an extra copy. The C++ version still returns std::string as there is still a lot of C++ code that relies on that. Fixes #297 --- panda/src/express/datagram.I | 12 ---------- panda/src/express/datagram.h | 7 +++++- panda/src/express/datagram_ext.I | 35 ++++++++++++++++++++++++++++ panda/src/express/datagram_ext.h | 40 ++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 13 deletions(-) create mode 100644 panda/src/express/datagram_ext.I create mode 100644 panda/src/express/datagram_ext.h diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 98b71820e5..8c555c777d 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -316,18 +316,6 @@ get_message() const { } } -/** - * Returns the datagram's data as a bytes object. - */ -INLINE vector_uchar Datagram:: -__bytes__() const { - if (!_data.empty()) { - return vector_uchar(_data.v()); - } else { - return vector_uchar(); - } -} - /** * Returns a pointer to the beginning of the datagram's data. */ diff --git a/panda/src/express/datagram.h b/panda/src/express/datagram.h index 69dce69e31..b2a3acb363 100644 --- a/panda/src/express/datagram.h +++ b/panda/src/express/datagram.h @@ -85,11 +85,16 @@ PUBLISHED: void append_data(const void *data, size_t size); INLINE void append_data(const vector_uchar &data); +public: void assign(const void *data, size_t size); INLINE std::string get_message() const; - INLINE vector_uchar __bytes__() const; INLINE const void *get_data() const; + +PUBLISHED: + EXTENSION(INLINE PyObject *get_message() const); + EXTENSION(INLINE PyObject *__bytes__() const); + INLINE size_t get_length() const; INLINE void set_array(PTA_uchar data); diff --git a/panda/src/express/datagram_ext.I b/panda/src/express/datagram_ext.I new file mode 100644 index 0000000000..a35c5410b2 --- /dev/null +++ b/panda/src/express/datagram_ext.I @@ -0,0 +1,35 @@ +/** + * 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." + * + * @file datagram_ext.I + * @author rdb + * @date 2018-08-19 + */ + +/** + * Returns the datagram's data as a bytes object. + */ +INLINE PyObject *Extension:: +get_message() const { + const char *data = (const char *)_this->get_data(); + size_t size = _this->get_length(); + +#if PY_MAJOR_VERSION >= 3 + return PyBytes_FromStringAndSize((char *)data, size); +#else + return PyString_FromStringAndSize((char *)data, size); +#endif +} + +/** + * Returns the datagram's data as a bytes object. + */ +PyObject *Extension:: +__bytes__() const { + return get_message(); +} diff --git a/panda/src/express/datagram_ext.h b/panda/src/express/datagram_ext.h new file mode 100644 index 0000000000..35f2e32bc6 --- /dev/null +++ b/panda/src/express/datagram_ext.h @@ -0,0 +1,40 @@ +/** + * 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." + * + * @file datagram_ext.h + * @author rdb + * @date 2018-08-19 + */ + +#ifndef DATAGRAM_EXT_H +#define DATAGRAM_EXT_H + +#include "dtoolbase.h" + +#ifdef HAVE_PYTHON + +#include "extension.h" +#include "datagram.h" +#include "py_panda.h" + +/** + * This class defines the extension methods for Datagram, which are called + * instead of any C++ methods with the same prototype. + */ +template<> +class Extension : public ExtensionBase { +public: + INLINE PyObject *get_message() const; + INLINE PyObject *__bytes__() const; +}; + +#include "datagram_ext.I" + +#endif // HAVE_PYTHON + +#endif // DATAGRAM_EXT_H From 74442e41f14539504305b0f9d50e61f4af4af6ec Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 14:21:23 +0200 Subject: [PATCH 143/360] express: slight Datagram constructor cleanup --- panda/src/express/datagram.I | 29 ++--------------------------- panda/src/express/datagram.h | 9 +++++++-- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 8c555c777d..350fa3d30c 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -11,30 +11,11 @@ * @date 2000-06-06 */ -/** - * Constructs an empty datagram. - */ -INLINE Datagram:: -Datagram() : -#ifdef STDFLOAT_DOUBLE - _stdfloat_double(true) -#else - _stdfloat_double(false) -#endif -{ -} - /** * Constructs a datagram from an existing block of data. */ INLINE Datagram:: -Datagram(const void *data, size_t size) : -#ifdef STDFLOAT_DOUBLE - _stdfloat_double(true) -#else - _stdfloat_double(false) -#endif -{ +Datagram(const void *data, size_t size) { append_data(data, size); } @@ -43,13 +24,7 @@ Datagram(const void *data, size_t size) : */ INLINE Datagram:: Datagram(vector_uchar data) : - _data(std::move(data)), -#ifdef STDFLOAT_DOUBLE - _stdfloat_double(true) -#else - _stdfloat_double(false) -#endif -{ + _data(std::move(data)) { } /** diff --git a/panda/src/express/datagram.h b/panda/src/express/datagram.h index b2a3acb363..420175c114 100644 --- a/panda/src/express/datagram.h +++ b/panda/src/express/datagram.h @@ -37,7 +37,7 @@ */ class EXPCL_PANDA_EXPRESS Datagram : public TypedObject { PUBLISHED: - INLINE Datagram(); + INLINE Datagram() = default; INLINE Datagram(const void *data, size_t size); INLINE explicit Datagram(vector_uchar data); Datagram(const Datagram ©) = default; @@ -114,7 +114,12 @@ PUBLISHED: private: PTA_uchar _data; - bool _stdfloat_double; + +#ifdef STDFLOAT_DOUBLE + bool _stdfloat_double = true; +#else + bool _stdfloat_double = false; +#endif public: From b1d21110372250b1c91a3829ae0c3f809a7d99d2 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 16:01:39 +0200 Subject: [PATCH 144/360] express: add Datagram add_blob and add_blob32, et al. This is for writing Python 2/3 agnostic code for writing binary data to a datagram, and reading from it using DatagramIterator. --- direct/src/distributed/PyDatagram.py | 4 +-- direct/src/distributed/PyDatagramIterator.py | 4 +-- panda/src/express/datagram.I | 34 ++++++++++++++++++++ panda/src/express/datagram.h | 5 +++ panda/src/express/datagramIterator.I | 21 ++++++++++++ panda/src/express/datagramIterator.h | 3 ++ panda/src/recorder/socketStreamRecorder.cxx | 5 +-- tests/putil/test_datagram.py | 12 +++++++ 8 files changed, 80 insertions(+), 8 deletions(-) diff --git a/direct/src/distributed/PyDatagram.py b/direct/src/distributed/PyDatagram.py index eebc06e440..f45c3c52c1 100755 --- a/direct/src/distributed/PyDatagram.py +++ b/direct/src/distributed/PyDatagram.py @@ -25,8 +25,8 @@ class PyDatagram(Datagram): STUint64: (Datagram.addUint64, int), STFloat64: (Datagram.addFloat64, None), STString: (Datagram.addString, None), - STBlob: (Datagram.addString, None), - STBlob32: (Datagram.addString32, None), + STBlob: (Datagram.addBlob, None), + STBlob32: (Datagram.addBlob32, None), } #def addChannel(self, channelId): diff --git a/direct/src/distributed/PyDatagramIterator.py b/direct/src/distributed/PyDatagramIterator.py index 60267a1ab9..6ce96e77e4 100755 --- a/direct/src/distributed/PyDatagramIterator.py +++ b/direct/src/distributed/PyDatagramIterator.py @@ -23,8 +23,8 @@ class PyDatagramIterator(DatagramIterator): STUint64: DatagramIterator.getUint64, STFloat64: DatagramIterator.getFloat64, STString: DatagramIterator.getString, - STBlob: DatagramIterator.getString, - STBlob32: DatagramIterator.getString32, + STBlob: DatagramIterator.getBlob, + STBlob32: DatagramIterator.getBlob32, } getChannel = DatagramIterator.getUint64 diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 350fa3d30c..42cc6b9cf1 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -270,6 +270,35 @@ add_fixed_string(const std::string &str, size_t size) { } } +/** + * Adds a variable-length binary blob to the datagram. This actually adds a + * count followed by n bytes. + */ +INLINE void Datagram:: +add_blob(const vector_uchar &data) { + // The max sendable size for a blob is 2^16. + nassertv(data.size() <= (uint16_t)0xffff); + + // Blobs always are preceded by their size + add_uint16((uint16_t)data.size()); + + // Add the blob + append_data(data.data(), data.size()); +} + +/** + * Adds a variable-length binary blob to the datagram, using a 32-bit length + * field to allow very long blobs. + */ +INLINE void Datagram:: +add_blob32(const vector_uchar &data) { + // Blobs always are preceded by their size + add_uint32((uint32_t)data.size()); + + // Add the blob + append_data(data.data(), data.size()); +} + /** * Appends some more raw data to the end of the datagram. */ @@ -445,3 +474,8 @@ INLINE void generic_write_datagram(Datagram &dest, const std::wstring &value) { dest.add_wstring(value); } + +INLINE void +generic_write_datagram(Datagram &dest, const vector_uchar &value) { + dest.add_blob(value); +} diff --git a/panda/src/express/datagram.h b/panda/src/express/datagram.h index 420175c114..9611645eed 100644 --- a/panda/src/express/datagram.h +++ b/panda/src/express/datagram.h @@ -81,6 +81,9 @@ PUBLISHED: INLINE void add_fixed_string(const std::string &str, size_t size); void add_wstring(const std::wstring &str); + INLINE void add_blob(const vector_uchar &); + INLINE void add_blob32(const vector_uchar &); + void pad_bytes(size_t size); void append_data(const void *data, size_t size); INLINE void append_data(const vector_uchar &data); @@ -158,6 +161,8 @@ INLINE void generic_write_datagram(Datagram &dest, const std::string &value); INLINE void generic_write_datagram(Datagram &dest, const std::wstring &value); +INLINE void +generic_write_datagram(Datagram &dest, const vector_uchar &value); #include "datagram.I" diff --git a/panda/src/express/datagramIterator.I b/panda/src/express/datagramIterator.I index 763850b60c..140151089a 100644 --- a/panda/src/express/datagramIterator.I +++ b/panda/src/express/datagramIterator.I @@ -400,6 +400,22 @@ get_be_float64() { return tempvar; } +/** + * Extracts a variable-length binary blob. + */ +INLINE vector_uchar DatagramIterator:: +get_blob() { + return extract_bytes(get_uint16()); +} + +/** + * Extracts a variable-length binary blob with a 32-bit size field. + */ +INLINE vector_uchar DatagramIterator:: +get_blob32() { + return extract_bytes(get_uint32()); +} + /** * Skips over the indicated number of bytes in the datagram. */ @@ -485,3 +501,8 @@ INLINE void generic_read_datagram(std::wstring &result, DatagramIterator &source) { result = source.get_wstring(); } + +INLINE void +generic_read_datagram(vector_uchar &result, DatagramIterator &source) { + result = source.get_blob(); +} diff --git a/panda/src/express/datagramIterator.h b/panda/src/express/datagramIterator.h index 570e34c3c4..867c7de58c 100644 --- a/panda/src/express/datagramIterator.h +++ b/panda/src/express/datagramIterator.h @@ -61,6 +61,9 @@ PUBLISHED: std::string get_fixed_string(size_t size); std::wstring get_wstring(); + INLINE vector_uchar get_blob(); + INLINE vector_uchar get_blob32(); + INLINE void skip_bytes(size_t size); vector_uchar extract_bytes(size_t size); size_t extract_bytes(unsigned char *into, size_t size); diff --git a/panda/src/recorder/socketStreamRecorder.cxx b/panda/src/recorder/socketStreamRecorder.cxx index 5ee6168d44..8418485b20 100644 --- a/panda/src/recorder/socketStreamRecorder.cxx +++ b/panda/src/recorder/socketStreamRecorder.cxx @@ -82,10 +82,7 @@ play_frame(DatagramIterator &scan, BamReader *manager) { int num_packets = scan.get_uint16(); for (int i = 0; i < num_packets; i++) { - size_t size = scan.get_uint16(); - vector_uchar packet(size); - scan.extract_bytes(&packet[0], size); - _data.push_back(Datagram(std::move(packet))); + _data.push_back(Datagram(scan.get_blob())); } } diff --git a/tests/putil/test_datagram.py b/tests/putil/test_datagram.py index 171363109a..7919a1360f 100644 --- a/tests/putil/test_datagram.py +++ b/tests/putil/test_datagram.py @@ -28,6 +28,9 @@ def datagram_small(request): dg.add_string32('this is another string') dg.add_string('this is yet a third string') + dg.add_blob(b'blob data \x00\xf2\xa0\x00\x00') + dg.add_blob32(b'\xc9\x8f\x00 test blob32') + dg.add_stdfloat(800.2) dg.add_stdfloat(3.1415926) dg.add_stdfloat(2.7182818) @@ -49,6 +52,9 @@ def datagram_small(request): assert dgi.get_string32() == 'this is another string' assert dgi.get_string() == 'this is yet a third string' + assert dgi.get_blob() == b'blob data \x00\xf2\xa0\x00\x00' + assert dgi.get_blob32() == b'\xc9\x8f\x00 test blob32' + assert dgi.get_stdfloat() == pytest.approx(800.2) assert dgi.get_stdfloat() == pytest.approx(3.1415926) assert dgi.get_stdfloat() == pytest.approx(2.7182818) @@ -88,6 +94,12 @@ def test_datagram_bytes(): dgi.get_remaining_bytes() == b'abc\x00\xff123' +def test_datagram_get_message(): + dg = core.Datagram(b'abc\x00') + dg.append_data(b'\xff123') + assert dg.get_message() == b'abc\x00\xff123' + + def test_iterator(datagram_small): """This tests Datagram/DatagramIterator, and sort of serves as a self-check of the test fixtures too.""" From 5da8b63a668e8266ba9a81dd661bfc690e9cf65b Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 16:04:56 +0200 Subject: [PATCH 145/360] cppparser: fix formatting of typecast operator --- dtool/src/cppparser/cppFunctionType.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dtool/src/cppparser/cppFunctionType.cxx b/dtool/src/cppparser/cppFunctionType.cxx index 27699d711b..731b6b0cf5 100644 --- a/dtool/src/cppparser/cppFunctionType.cxx +++ b/dtool/src/cppparser/cppFunctionType.cxx @@ -292,6 +292,10 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, out << str; + } else if (_flags & F_operator_typecast) { + out << "operator "; + _return_type->output_instance(out, indent_level, scope, complete, "", prename + str); + } else { if (prename.empty()) { _return_type->output_instance(out, indent_level, scope, complete, From 21f5e77467a72197d096f36759e12b0f117a5dd1 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 16:05:39 +0200 Subject: [PATCH 146/360] dtoolbase: prefer GCC AtomicAdjust implementation over i386 asm one --- dtool/src/dtoolbase/atomicAdjust.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/dtool/src/dtoolbase/atomicAdjust.h b/dtool/src/dtoolbase/atomicAdjust.h index 1180529ded..804224e5c3 100644 --- a/dtool/src/dtoolbase/atomicAdjust.h +++ b/dtool/src/dtoolbase/atomicAdjust.h @@ -30,6 +30,20 @@ struct AtomicAdjust { #include "atomicAdjustDummyImpl.h" typedef AtomicAdjustDummyImpl AtomicAdjust; +#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (defined(__clang__) && (__clang_major__ >= 3)) +// GCC 4.7 and above has built-in __atomic functions for atomic operations. +// Clang 3.0 and above also supports them. + +#include "atomicAdjustGccImpl.h" +typedef AtomicAdjustGccImpl AtomicAdjust; + +#if (__GCC_ATOMIC_INT_LOCK_FREE + __GCC_ATOMIC_LONG_LOCK_FREE) > 0 +#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1 +#endif +#if __GCC_ATOMIC_POINTER_LOCK_FREE > 0 +#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1 +#endif + #elif (defined(__i386__) || defined(_M_IX86)) && !defined(__APPLE__) // For an i386 architecture, we'll always use the i386 implementation. It // should be safe for any OS, and it might be a bit faster than any OS- @@ -45,20 +59,6 @@ typedef AtomicAdjustI386Impl AtomicAdjust; #define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1 #define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1 -#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (defined(__clang__) && (__clang_major__ >= 3)) -// GCC 4.7 and above has built-in __atomic functions for atomic operations. -// Clang 3.0 and above also supports them. - -#include "atomicAdjustGccImpl.h" -typedef AtomicAdjustGccImpl AtomicAdjust; - -#if (__GCC_ATOMIC_INT_LOCK_FREE + __GCC_ATOMIC_INT_LOCK_FREE) > 0 -#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1 -#endif -#if __GCC_ATOMIC_POINTER_LOCK_FREE > 0 -#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1 -#endif - #elif defined(THREAD_WIN32_IMPL) #include "atomicAdjustWin32Impl.h" From c4b657b5b23c72fcaeaf4d2d0205cdbcf1482c25 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 16:06:16 +0200 Subject: [PATCH 147/360] interrogate: support implicit typecast operators in some cases For example, this will let us pass a ConfigVariableFilename to anything that accepts a Filename, just like in C++. Does not work if the return value if the typecast operator requires management. --- .../interfaceMakerPythonNative.cxx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 3134fcb2eb..e20aff91ef 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -1089,6 +1089,27 @@ write_class_details(ostream &out, Object *obj) { } } + // Are there any implicit cast operators that can cast this object to our + // desired pointer? + for (Function *func : obj->_methods) { + for (FunctionRemap *remap : func->_remaps) { + if (remap->_type == FunctionRemap::T_typecast_method && + is_remap_legal(remap) && + !remap->_return_type->return_value_needs_management() && + (remap->_cppfunc->_storage_class & CPPInstance::SC_explicit) == 0 && + TypeManager::is_pointer(remap->_return_type->get_new_type())) { + + CPPType *cast_type = remap->_return_type->get_orig_type(); + CPPType *obj_type = TypeManager::unwrap(TypeManager::resolve_type(remap->_return_type->get_new_type())); + string return_expr = "(" + cast_type->get_local_name(&parser) + ")*local_this"; + out << " // " << *remap->_cppfunc << "\n"; + out << " if (requested_type == Dtool_Ptr_" << make_safe_name(obj_type->get_local_name(&parser)) << ") {\n"; + out << " return (void *)(" << remap->_return_type->get_return_expr(return_expr) << ");\n"; + out << " }\n"; + } + } + } + out << " return nullptr;\n"; out << "}\n\n"; From 371c34d13bcd138a0daea42d3612e7dee1850240 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 16:40:35 +0200 Subject: [PATCH 148/360] linmath: allow constructing matrix from rows This also enables using mat[n] wherever an LVecBase4 is accepted, as well as Mat4(*mat). --- panda/src/linmath/lmatrix3_src.I | 42 ++++++++++++++++++++++++++ panda/src/linmath/lmatrix3_src.h | 12 +++++--- panda/src/linmath/lmatrix4_src.I | 51 ++++++++++++++++++++++++++++++++ panda/src/linmath/lmatrix4_src.h | 14 ++++++--- 4 files changed, 111 insertions(+), 8 deletions(-) diff --git a/panda/src/linmath/lmatrix3_src.I b/panda/src/linmath/lmatrix3_src.I index 8bfb3909ce..782c8599ee 100644 --- a/panda/src/linmath/lmatrix3_src.I +++ b/panda/src/linmath/lmatrix3_src.I @@ -44,6 +44,14 @@ size() { return 3; } +/** + * + */ +INLINE_LINMATH FLOATNAME(LMatrix3)::Row:: +operator const FLOATNAME(LVecBase3) &() const { + return *(const FLOATNAME(LVecBase3) *)_row; +} + /** * Defines a row-level constant accessor to the matrix. */ @@ -68,6 +76,14 @@ size() { return 3; } +/** + * + */ +INLINE_LINMATH FLOATNAME(LMatrix3)::CRow:: +operator const FLOATNAME(LVecBase3) &() const { + return *(const FLOATNAME(LVecBase3) *)_row; +} + /** * Returns an identity matrix. * @@ -132,6 +148,32 @@ FLOATNAME(LMatrix3)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, _m(2, 2) = e22; } +/** + * Constructs the matrix from three individual rows. + */ +INLINE_LINMATH FLOATNAME(LMatrix3):: +FLOATNAME(LMatrix3)(const FLOATNAME(LVecBase3) &row0, + const FLOATNAME(LVecBase3) &row1, + const FLOATNAME(LVecBase3) &row2) { + TAU_PROFILE("LMatrix3::LMatrix3(const LVecBase3 &, ...)", " ", TAU_USER); + +#ifdef HAVE_EIGEN + _m.row(0) = row0._v; + _m.row(1) = row1._v; + _m.row(2) = row2._v; +#else + _m(0, 0) = row0._v(0); + _m(0, 1) = row0._v(1); + _m(0, 2) = row0._v(2); + _m(1, 0) = row1._v(0); + _m(1, 1) = row1._v(1); + _m(1, 2) = row1._v(2); + _m(2, 0) = row2._v(0); + _m(2, 1) = row2._v(1); + _m(2, 2) = row2._v(2); +#endif // HAVE_EIGEN +} + /** * */ diff --git a/panda/src/linmath/lmatrix3_src.h b/panda/src/linmath/lmatrix3_src.h index 399508ed5f..2138f0fc39 100644 --- a/panda/src/linmath/lmatrix3_src.h +++ b/panda/src/linmath/lmatrix3_src.h @@ -38,6 +38,7 @@ PUBLISHED: INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH FLOATTYPE &operator [](int i); INLINE_LINMATH static int size(); + INLINE_LINMATH operator const FLOATNAME(LVecBase3) &() const; public: FLOATTYPE *_row; friend class FLOATNAME(LMatrix3); @@ -48,6 +49,7 @@ PUBLISHED: PUBLISHED: INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH static int size(); + INLINE_LINMATH operator const FLOATNAME(LVecBase3) &() const; public: const FLOATTYPE *_row; friend class FLOATNAME(LMatrix3); @@ -58,10 +60,12 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LMatrix3) &operator = ( const FLOATNAME(LMatrix3) &other); INLINE_LINMATH FLOATNAME(LMatrix3) &operator = (FLOATTYPE fill_value); - INLINE_LINMATH FLOATNAME(LMatrix3)( - FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, - FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, - FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22); + INLINE_LINMATH FLOATNAME(LMatrix3)(FLOATTYPE, FLOATTYPE, FLOATTYPE, + FLOATTYPE, FLOATTYPE, FLOATTYPE, + FLOATTYPE, FLOATTYPE, FLOATTYPE); + INLINE_LINMATH FLOATNAME(LMatrix3)(const FLOATNAME(LVecBase3) &, + const FLOATNAME(LVecBase3) &, + const FLOATNAME(LVecBase3) &); ALLOC_DELETED_CHAIN(FLOATNAME(LMatrix3)); EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const); diff --git a/panda/src/linmath/lmatrix4_src.I b/panda/src/linmath/lmatrix4_src.I index d5c16d5ce7..a887d393f1 100644 --- a/panda/src/linmath/lmatrix4_src.I +++ b/panda/src/linmath/lmatrix4_src.I @@ -44,6 +44,14 @@ size() { return 4; } +/** + * + */ +INLINE_LINMATH FLOATNAME(LMatrix4)::Row:: +operator const FLOATNAME(LVecBase4) &() const { + return *(const FLOATNAME(LVecBase4) *)_row; +} + /** * Defines a row-level constant accessor to the matrix. */ @@ -68,6 +76,14 @@ size() { return 4; } +/** + * + */ +INLINE_LINMATH FLOATNAME(LMatrix4)::CRow:: +operator const FLOATNAME(LVecBase4) &() const { + return *(const FLOATNAME(LVecBase4) *)_row; +} + /** * Returns an identity matrix. * @@ -178,6 +194,41 @@ FLOATNAME(LMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, _m(3, 3) = e33; } +/** + * Constructs the matrix from four individual rows. + */ +INLINE_LINMATH FLOATNAME(LMatrix4):: +FLOATNAME(LMatrix4)(const FLOATNAME(LVecBase4) &row0, + const FLOATNAME(LVecBase4) &row1, + const FLOATNAME(LVecBase4) &row2, + const FLOATNAME(LVecBase4) &row3) { + TAU_PROFILE("LMatrix4::LMatrix4(const LVecBase4 &, ...)", " ", TAU_USER); + +#ifdef HAVE_EIGEN + _m.row(0) = row0._v; + _m.row(1) = row1._v; + _m.row(2) = row2._v; + _m.row(3) = row3._v; +#else + _m(0, 0) = row0._v(0); + _m(0, 1) = row0._v(1); + _m(0, 2) = row0._v(2); + _m(0, 3) = row0._v(3); + _m(1, 0) = row1._v(0); + _m(1, 1) = row1._v(1); + _m(1, 2) = row1._v(2); + _m(1, 3) = row1._v(3); + _m(2, 0) = row2._v(0); + _m(2, 1) = row2._v(1); + _m(2, 2) = row2._v(2); + _m(2, 3) = row2._v(3); + _m(3, 0) = row3._v(0); + _m(3, 1) = row3._v(1); + _m(3, 2) = row3._v(2); + _m(3, 3) = row3._v(3); +#endif // HAVE_EIGEN +} + /** * */ diff --git a/panda/src/linmath/lmatrix4_src.h b/panda/src/linmath/lmatrix4_src.h index 4d749cddd5..a66a5ab45f 100644 --- a/panda/src/linmath/lmatrix4_src.h +++ b/panda/src/linmath/lmatrix4_src.h @@ -36,6 +36,7 @@ PUBLISHED: INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH FLOATTYPE &operator [](int i); INLINE_LINMATH static int size(); + INLINE_LINMATH operator const FLOATNAME(LVecBase4) &() const; public: FLOATTYPE *_row; friend class FLOATNAME(LMatrix4); @@ -46,6 +47,7 @@ PUBLISHED: PUBLISHED: INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH static int size(); + INLINE_LINMATH operator const FLOATNAME(LVecBase4) &() const; public: const FLOATTYPE *_row; friend class FLOATNAME(LMatrix4); @@ -60,10 +62,14 @@ PUBLISHED: const FLOATNAME(UnalignedLMatrix4) &other); INLINE_LINMATH FLOATNAME(LMatrix4) &operator = (FLOATTYPE fill_value); - INLINE_LINMATH FLOATNAME(LMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, - FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13, - FLOATTYPE e20, FLOATTYPE e21, FLOATTYPE e22, FLOATTYPE e23, - FLOATTYPE e30, FLOATTYPE e31, FLOATTYPE e32, FLOATTYPE e33); + INLINE_LINMATH FLOATNAME(LMatrix4)(FLOATTYPE, FLOATTYPE, FLOATTYPE, FLOATTYPE, + FLOATTYPE, FLOATTYPE, FLOATTYPE, FLOATTYPE, + FLOATTYPE, FLOATTYPE, FLOATTYPE, FLOATTYPE, + FLOATTYPE, FLOATTYPE, FLOATTYPE, FLOATTYPE); + INLINE_LINMATH FLOATNAME(LMatrix4)(const FLOATNAME(LVecBase4) &, + const FLOATNAME(LVecBase4) &, + const FLOATNAME(LVecBase4) &, + const FLOATNAME(LVecBase4) &); ALLOC_DELETED_CHAIN(FLOATNAME(LMatrix4)); EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const); From b4abea17d59416ce77580adfcb73aeb58a1e009b Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 16:43:34 +0200 Subject: [PATCH 149/360] tests: add various matrix unit tests --- tests/linmath/test_lmatrix3.py | 62 ++++++++++++++++++++ tests/linmath/test_lmatrix4.py | 89 +++++++++++++++++++++++++++++ tests/linmath/test_matrix_invert.py | 20 ------- 3 files changed, 151 insertions(+), 20 deletions(-) create mode 100644 tests/linmath/test_lmatrix3.py create mode 100644 tests/linmath/test_lmatrix4.py delete mode 100644 tests/linmath/test_matrix_invert.py diff --git a/tests/linmath/test_lmatrix3.py b/tests/linmath/test_lmatrix3.py new file mode 100644 index 0000000000..b0ce53685a --- /dev/null +++ b/tests/linmath/test_lmatrix3.py @@ -0,0 +1,62 @@ +import pytest +from copy import copy +from panda3d import core + + +def test_mat3_aliases(): + assert core.LMatrix3 is core.Mat3 + assert core.LMatrix3f is core.Mat3F + assert core.LMatrix3d is core.Mat3D + + assert (core.LMatrix3f is core.Mat3) != (core.LMatrix3d is core.Mat3) + + +@pytest.mark.parametrize("type", (core.LMatrix3f, core.LMatrix3d)) +def test_mat3_constructor(type): + # Test that three ways of construction produce the same matrix. + mat1 = type((1, 2, 3), + (4, 5, 6), + (7, 8, 9)) + + mat2 = type(1, 2, 3, 4, 5, 6, 7, 8, 9) + + mat3 = type((1, 2, 3, 4, 5, 6, 7, 8, 9)) + + assert mat1 == mat2 + assert mat2 == mat3 + assert mat1 == mat3 + + +@pytest.mark.parametrize("type", (core.LMatrix3d, core.LMatrix3f)) +def test_mat3_copy_constuctor(type): + mat1 = type((1, 2, 3), + (4, 5, 6), + (7, 8, 9)) + + # Make a copy. Changing it should not change the original. + mat2 = type(mat1) + assert mat1 == mat2 + mat2[0][0] = 100 + assert mat1 != mat2 + + # Make a copy by unpacking. + mat2 = type(*mat1) + assert mat1 == mat2 + mat2[0][0] = 100 + assert mat1 != mat2 + + # Make a copy by calling copy.copy. + mat2 = copy(mat1) + assert mat1 == mat2 + mat2[0][0] = 100 + assert mat1 != mat2 + + +@pytest.mark.parametrize("type", (core.LMatrix3d, core.LMatrix3f)) +def test_mat3_invert_same_type(type): + mat = type((1, 0, 0, + 0, 1, 0, + 1, 2, 3)) + + inv = core.invert(mat) + assert mat.__class__ == inv.__class__ diff --git a/tests/linmath/test_lmatrix4.py b/tests/linmath/test_lmatrix4.py new file mode 100644 index 0000000000..23c1bcc5e9 --- /dev/null +++ b/tests/linmath/test_lmatrix4.py @@ -0,0 +1,89 @@ +import pytest +from copy import copy +from panda3d import core + + +def test_mat4_aliases(): + assert core.LMatrix4 is core.Mat4 + assert core.LMatrix4f is core.Mat4F + assert core.LMatrix4d is core.Mat4D + + assert (core.LMatrix4f is core.Mat4) != (core.LMatrix4d is core.Mat4) + + +@pytest.mark.parametrize("type", (core.LMatrix4d, core.LMatrix4f)) +def test_mat4_constructor(type): + # Test that three ways of construction produce the same matrix. + mat1 = type((1, 2, 3, 4), + (5, 6, 7, 8), + (9, 10, 11, 12), + (13, 14, 15, 16)) + + mat2 = type(1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16) + + mat3 = type((1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16)) + + assert mat1 == mat2 + assert mat2 == mat3 + assert mat1 == mat3 + + +@pytest.mark.parametrize("type", (core.LMatrix4d, core.LMatrix4f)) +def test_mat4_copy_constuctor(type): + mat1 = type((1, 2, 3, 4), + (5, 6, 7, 8), + (9, 10, 11, 12), + (13, 14, 15, 16)) + + # Make a copy. Changing it should not change the original. + mat2 = type(mat1) + assert mat1 == mat2 + mat2[0][0] = 100 + assert mat1 != mat2 + + # Make a copy by unpacking. + mat2 = type(*mat1) + assert mat1 == mat2 + mat2[0][0] = 100 + assert mat1 != mat2 + + # Make a copy by calling copy.copy. + mat2 = copy(mat1) + assert mat1 == mat2 + mat2[0][0] = 100 + assert mat1 != mat2 + + +@pytest.mark.parametrize("type", (core.LMatrix4d, core.LMatrix4f)) +def test_mat4_invert_same_type(type): + mat = type((1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 1, 2, 3, 1)) + + inv = core.invert(mat) + assert mat.__class__ == inv.__class__ + + +@pytest.mark.parametrize("type", (core.LMatrix4d, core.LMatrix4f)) +def test_mat4_invert_correct(type): + mat = type((1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 1, 2, 3, 1)) + inv = type() + assert inv.invert_from(mat) + + assert inv == type(( 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + -1, -2, -3, 1)) + + assert (mat * inv).is_identity() + assert (inv * mat).is_identity() diff --git a/tests/linmath/test_matrix_invert.py b/tests/linmath/test_matrix_invert.py deleted file mode 100644 index b2e6dd49bf..0000000000 --- a/tests/linmath/test_matrix_invert.py +++ /dev/null @@ -1,20 +0,0 @@ -import pytest -from panda3d import core - - -@pytest.mark.parametrize("type", (core.Mat4, core.Mat4D)) -def test_mat4_invert(type): - mat = type((1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 1, 2, 3, 1)) - inv = type() - assert inv.invert_from(mat) - - assert inv == type(( 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - -1, -2, -3, 1)) - - assert (mat * inv).is_identity() - assert (inv * mat).is_identity() From 91ae68f04bef3241c2b254b5529590477602803e Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 16:49:54 +0200 Subject: [PATCH 150/360] tests: attempt to fix egg2pg test failure on macOS --- tests/egg2pg/test_egg_coordsys.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/egg2pg/test_egg_coordsys.py b/tests/egg2pg/test_egg_coordsys.py index b3c5583075..1c014ebf46 100644 --- a/tests/egg2pg/test_egg_coordsys.py +++ b/tests/egg2pg/test_egg_coordsys.py @@ -37,7 +37,8 @@ def test_egg2pg_transform_ident(egg_coordsys, coordsys): @pytest.mark.parametrize("coordsys", COORD_SYSTEMS) def test_egg2pg_transform_mat_unchanged(coordsys): # Ensures that the matrix remains unchanged if coordinate system is same. - mat = (5, 2, -3, 4, 5, 6, 7, 8, 9, 1, -3, 2, 5, 2, 5, 2) + matv = (5, 2, -3, 4, 5, 6, 7, 8, 9, 1, -3, 2, 5, 2, 5, 2) + mat = core.Mat4D(*matv) group = egg.EggGroup("group") group.add_matrix4(mat) assert not group.transform_is_identity() @@ -57,7 +58,7 @@ def test_egg2pg_transform_mat_unchanged(coordsys): assert root node, = root.children - assert node.transform.mat == mat + assert node.transform.mat == core.Mat4(*matv) @pytest.mark.parametrize("egg_coordsys", COORD_SYSTEMS) From 044d84c8fd42c1cec89fb4660280b0080eec01b8 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 16:53:03 +0200 Subject: [PATCH 151/360] mayaegg: fix various compilation warnings --- pandatool/src/mayaegg/mayaEggLoader.cxx | 18 +++++++++--------- pandatool/src/mayaegg/mayaToEggConverter.cxx | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index 4baf1dff86..68fcb8d0f7 100644 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -837,12 +837,12 @@ int MayaEggGeom::GetVert(EggVertex *vert, EggGroup *context) void MayaEggGeom::AssignNames(void) { string name = _pool->get_name(); - int nsize = name.size(); - if ((nsize > 6) && (name.rfind(".verts")==(nsize-6))) { - name.resize(nsize-6); + size_t nsize = name.size(); + if (nsize > 6 && name.rfind(".verts") == (nsize - 6)) { + name.resize(nsize - 6); } - if ((nsize > 4) && (name.rfind(".cvs")==(nsize-4))) { - name.resize(nsize-4); + if (nsize > 4 && name.rfind(".cvs") == (nsize - 4)) { + name.resize(nsize - 4); } MFnDependencyNode dnshape(_shapeNode); @@ -913,7 +913,7 @@ void MayaEggGeom::AddEggFlag(MString fieldName) { typedef phash_map TVertTable; typedef phash_map CVertTable; -class MayaEggMesh : public MayaEggGeom +class MayaEggMesh final : public MayaEggGeom { public: MColorArray _faceColorArray; @@ -937,7 +937,7 @@ public: int GetCVert(const LColor &col); int AddFace(unsigned numVertices, MIntArray mvertIndices, MIntArray mtvertIndices, MayaEggTex *tex); - void ConnectTextures(void); + void ConnectTextures(void) override; }; int MayaEggMesh::GetTVert(const LTexCoordd &uv) @@ -2012,7 +2012,7 @@ void MayaEggLoader::PrintData(MayaEggMesh *mesh) void MayaEggLoader::ParseFrameInfo(string comment) { - int pos, ls, le; + size_t pos, ls, le; pos = comment.find("-fri"); if (pos != string::npos) { @@ -2143,7 +2143,7 @@ bool MayaEggLoader::ConvertEggFile(const char *name, bool merge, bool model, boo MObject MayaEggLoader::GetDependencyNode(string givenName) { MObject node = MObject::kNullObj; - int pos; + size_t pos; string name; pos = givenName.find(":"); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index 747c8ac279..3f693dd004 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -2742,7 +2742,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, // shader on the list is the base one, which should always pick up // the alpha from the texture file. But the top textures may have // to strip the alpha - if (i!=shader._color.size()-1) { + if ((size_t)i != shader._color.size() - 1) { if (!i && is_interpolate) { // this is the grass path mode where alpha on this texture // determines whether to show layer1 or layer2. Since by now @@ -2846,7 +2846,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, _textures.create_unique_texture(tex, ~0); if (mesh) { - if (uvset_name.find("not found") == -1) { + if (uvset_name.find("not found") == string::npos) { primitive.add_texture(new_tex); color_def->_uvset_name.assign(uvset_name.c_str()); if (uvset_name != "map1") { From f663d215d56bb24bb316339c8bf621b674618d37 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 19 Aug 2018 16:55:07 +0200 Subject: [PATCH 152/360] Remove some unused variables --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 5 +---- panda/src/egg/eggPrimitive.cxx | 2 +- panda/src/egg2pg/eggLoader.cxx | 1 - panda/src/pgraph/geomNode.cxx | 1 - panda/src/pgraph/geomTransformer.cxx | 1 - panda/src/text/dynamicTextFont.cxx | 1 - 6 files changed, 2 insertions(+), 9 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index e20aff91ef..5752fe126b 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -789,8 +789,6 @@ InterfaceMakerPythonNative:: */ void InterfaceMakerPythonNative:: write_prototypes(ostream &out_code, ostream *out_h) { - Functions::iterator fi; - if (out_h != nullptr) { *out_h << "#include \"py_panda.h\"\n\n"; } @@ -917,7 +915,6 @@ write_prototypes_class_external(ostream &out, Object *obj) { void InterfaceMakerPythonNative:: write_prototypes_class(ostream &out_code, ostream *out_h, Object *obj) { std::string ClassName = make_safe_name(obj->_itype.get_scoped_name()); - Functions::iterator fi; out_code << "/**\n"; out_code << " * Forward declarations for top-level class " << ClassName << "\n"; @@ -3322,7 +3319,7 @@ write_prototype_for(ostream &out, InterfaceMaker::Function *func) { */ void InterfaceMakerPythonNative:: write_prototype_for_name(ostream &out, InterfaceMaker::Function *func, const std::string &function_namename) { - Function::Remaps::const_iterator ri; +// Function::Remaps::const_iterator ri; // for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { // FunctionRemap *remap = (*ri); diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index f4985dfc90..158866855f 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -558,7 +558,7 @@ remove_doubled_verts(bool closed) { */ void EggPrimitive:: remove_nonunique_verts() { - Vertices::iterator vi, vj; + Vertices::iterator vi; Vertices new_vertices; int num_removed = 0; diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index e26a4120b9..9d885e0234 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -2661,7 +2661,6 @@ set_occluder_polygon(EggGroup *egg_group, OccluderNode *pnode) { } else { LMatrix4d mat = poly->get_vertex_to_node(); - EggPolygon::const_iterator vi; LPoint3d v0 = (*poly)[0]->get_pos3() * mat; LPoint3d v1 = (*poly)[1]->get_pos3() * mat; LPoint3d v2 = (*poly)[2]->get_pos3() * mat; diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index 328870364a..16e95442c2 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -115,7 +115,6 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, Thread *current_thread = Thread::get_current_thread(); OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); - GeomList::iterator gi; PT(GeomList) geoms = cdata->modify_geoms(); // Iterate based on the number of geoms, not using STL iterators. This diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index cfc023b528..fe6b022d2d 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -742,7 +742,6 @@ make_compatible_state(GeomNode *node) { } GeomNode::CDWriter cdata(node->_cycler); - GeomNode::GeomList::iterator gi; PT(GeomNode::GeomList) geoms = cdata->modify_geoms(); // For each geom, calculate a canonicalized RenderState, and classify all diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index 4eb4afc96a..347841a92f 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -1072,7 +1072,6 @@ render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { // create more vertices--they don't share the same normals. for (ci = _contours.begin(); ci != _contours.end(); ++ci) { const Contour &contour = (*ci); - Points::const_iterator pi; for (size_t i = 0; i < contour._points.size(); ++i) { const ContourPoint &cp = contour._points[i]; From 35fff81b6ab9fffff61def1bae96f8142a780db1 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 19 Aug 2018 18:52:48 +0200 Subject: [PATCH 153/360] makepanda: fix missing BUILDING_DIRECT_DCPARSER [skip ci] --- direct/src/dcparser/dcNumericRange.I | 10 +++++----- direct/src/dcparser/dcNumericRange.h | 10 +++++----- makepanda/makepanda.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/direct/src/dcparser/dcNumericRange.I b/direct/src/dcparser/dcNumericRange.I index bd41418205..92973d4410 100644 --- a/direct/src/dcparser/dcNumericRange.I +++ b/direct/src/dcparser/dcNumericRange.I @@ -52,7 +52,7 @@ operator = (const DCNumericRange ©) { * otherwise. */ template -bool DCNumericRange:: +INLINE bool DCNumericRange:: is_in_range(Number num) const { if (_ranges.empty()) { return true; @@ -106,7 +106,7 @@ get_one_value() const { * */ template -void DCNumericRange:: +INLINE void DCNumericRange:: generate_hash(HashGenerator &hashgen) const { if (!_ranges.empty()) { hashgen.add_int(_ranges.size()); @@ -124,7 +124,7 @@ generate_hash(HashGenerator &hashgen) const { * */ template -void DCNumericRange:: +INLINE void DCNumericRange:: output(std::ostream &out, Number divisor) const { if (!_ranges.empty()) { typename Ranges::const_iterator ri; @@ -144,7 +144,7 @@ output(std::ostream &out, Number divisor) const { * characters. */ template -void DCNumericRange:: +INLINE void DCNumericRange:: output_char(std::ostream &out, Number divisor) const { if (divisor != 1) { output(out, divisor); @@ -179,7 +179,7 @@ clear() { * minmax overlaps an existing minmax. */ template -bool DCNumericRange:: +INLINE bool DCNumericRange:: add_range(Number min, Number max) { // Check for an overlap. This is probably indicative of a typo and should // be reported. diff --git a/direct/src/dcparser/dcNumericRange.h b/direct/src/dcparser/dcNumericRange.h index f751323b01..888c54939e 100644 --- a/direct/src/dcparser/dcNumericRange.h +++ b/direct/src/dcparser/dcNumericRange.h @@ -32,20 +32,20 @@ public: INLINE DCNumericRange(const DCNumericRange ©); INLINE void operator = (const DCNumericRange ©); - bool is_in_range(Number num) const; + INLINE bool is_in_range(Number num) const; INLINE void validate(Number num, bool &range_error) const; INLINE bool has_one_value() const; INLINE Number get_one_value() const; - void generate_hash(HashGenerator &hashgen) const; + INLINE void generate_hash(HashGenerator &hashgen) const; - void output(std::ostream &out, Number divisor = 1) const; - void output_char(std::ostream &out, Number divisor = 1) const; + INLINE void output(std::ostream &out, Number divisor = 1) const; + INLINE void output_char(std::ostream &out, Number divisor = 1) const; public: INLINE void clear(); - bool add_range(Number min, Number max); + INLINE bool add_range(Number min, Number max); INLINE bool is_empty() const; INLINE int get_num_ranges() const; diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 6181ccf87e..00dd2c3cd3 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -5219,7 +5219,7 @@ if (PkgSkip("DIRECT")==0): # if (PkgSkip("DIRECT")==0): - OPTS=['DIR:direct/src/dcparser', 'WITHINPANDA', 'BISONPREFIX_dcyy', 'PYTHON'] + OPTS=['DIR:direct/src/dcparser', 'BUILDING:DIRECT_DCPARSER', 'WITHINPANDA', 'BISONPREFIX_dcyy', 'PYTHON'] CreateFile(GetOutputDir()+"/include/dcParser.h") TargetAdd('p3dcparser_dcParser.obj', opts=OPTS, input='dcParser.yxx') TargetAdd('dcParser.h', input='p3dcparser_dcParser.obj', opts=['DEPENDENCYONLY']) From 4f9a2aca85c530e9026f675fa44fa524f82a5023 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 20 Aug 2018 16:25:55 +0200 Subject: [PATCH 154/360] tests: fix issues with temp files without correct case on Windows --- tests/gobj/test_texture_pool.py | 18 ++++++++++------ tests/putil/test_datagram.py | 37 ++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/tests/gobj/test_texture_pool.py b/tests/gobj/test_texture_pool.py index b07e8a0cb9..c8ac5ae44a 100644 --- a/tests/gobj/test_texture_pool.py +++ b/tests/gobj/test_texture_pool.py @@ -22,8 +22,10 @@ def image_rgb_path(): "Generates an RGB image." file = tempfile.NamedTemporaryFile(suffix='-rgb.png') - write_image(file.name, 3) - yield file.name + path = core.Filename.from_os_specific(file.name) + path.make_true_case() + write_image(path, 3) + yield path file.close() @@ -32,8 +34,10 @@ def image_rgba_path(): "Generates an RGBA image." file = tempfile.NamedTemporaryFile(suffix='-rgba.png') - write_image(file.name, 4) - yield file.name + path = core.Filename.from_os_specific(file.name) + path.make_true_case() + write_image(path, 4) + yield path file.close() @@ -42,8 +46,10 @@ def image_gray_path(): "Generates a grayscale image." file = tempfile.NamedTemporaryFile(suffix='-gray.png') - write_image(file.name, 1) - yield file.name + path = core.Filename.from_os_specific(file.name) + path.make_true_case() + write_image(path, 1) + yield path file.close() diff --git a/tests/putil/test_datagram.py b/tests/putil/test_datagram.py index 7919a1360f..751ea0dc03 100644 --- a/tests/putil/test_datagram.py +++ b/tests/putil/test_datagram.py @@ -1,6 +1,7 @@ import pytest from panda3d import core import sys +import tempfile # Fixtures for generating interesting datagrams (and verification functions) on # the fly... @@ -147,30 +148,39 @@ def do_file_test(dg, verify, filename): dgi = core.DatagramIterator(dg2) verify(dgi) -def test_file_small(datagram_small, tmpdir): +@pytest.fixture +def tmpfile(): + file = tempfile.NamedTemporaryFile(suffix='.bin') + yield file + file.close() + +def test_file_small(datagram_small, tmpfile): """This tests DatagramOutputFile/DatagramInputFile on small datagrams.""" dg, verify = datagram_small - p = tmpdir.join('datagram.bin') - filename = core.Filename.from_os_specific(str(p)) + file = tempfile.NamedTemporaryFile(suffix='.bin') + filename = core.Filename.from_os_specific(file.name) + filename.make_true_case() do_file_test(dg, verify, filename) -def test_file_large(datagram_large, tmpdir): +def test_file_large(datagram_large, tmpfile): """This tests DatagramOutputFile/DatagramInputFile on very large datagrams.""" dg, verify = datagram_large - p = tmpdir.join('datagram.bin') - filename = core.Filename.from_os_specific(str(p)) + file = tempfile.NamedTemporaryFile(suffix='.bin') + filename = core.Filename.from_os_specific(file.name) + filename.make_true_case() do_file_test(dg, verify, filename) -def test_file_corrupt(datagram_small, tmpdir): +def test_file_corrupt(datagram_small, tmpfile): """This tests DatagramInputFile's handling of a corrupt size header.""" dg, verify = datagram_small - p = tmpdir.join('datagram.bin') - filename = core.Filename.from_os_specific(str(p)) + file = tempfile.NamedTemporaryFile(suffix='.bin') + filename = core.Filename.from_os_specific(file.name) + filename.make_true_case() dof = core.DatagramOutputFile() dof.open(filename) @@ -178,9 +188,9 @@ def test_file_corrupt(datagram_small, tmpdir): dof.close() # Corrupt the size header to 1GB - with p.open(mode='r+b') as f: - f.seek(0) - f.write(b'\xFF\xFF\xFF\x4F') + file.seek(0) + file.write(b'\xFF\xFF\xFF\x4F') + file.flush() dg2 = core.Datagram() dif = core.DatagramInputFile() @@ -190,8 +200,7 @@ def test_file_corrupt(datagram_small, tmpdir): # Truncate the file for size in [12, 8, 4, 3, 2, 1, 0]: - with p.open(mode='r+b') as f: - f.truncate(size) + file.truncate(size) dg2 = core.Datagram() dif = core.DatagramInputFile() From 5147674980d3d81314bbe3e5ddbad4c01e9ffc21 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 20 Aug 2018 16:57:34 +0200 Subject: [PATCH 155/360] Add script to run test suite on a wheel in a virtualenv [skip ci] --- makepanda/test_wheel.py | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 makepanda/test_wheel.py diff --git a/makepanda/test_wheel.py b/makepanda/test_wheel.py new file mode 100755 index 0000000000..00555a5e60 --- /dev/null +++ b/makepanda/test_wheel.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +""" +Tests a .whl file by installing it and pytest into a virtual environment and +running the test suite. + +Requires pip to be installed, as well as 'virtualenv' on Python 2. +""" + +import os +import sys +import shutil +import subprocess +import tempfile +from optparse import OptionParser + + +def test_wheel(wheel, verbose=False): + envdir = tempfile.mkdtemp(prefix="venv-") + print("Setting up virtual environment in {0}".format(envdir)) + + if sys.version_info >= (3, 0): + subprocess.call([sys.executable, "-m", "venv", "--clear", envdir]) + else: + subprocess.call([sys.executable, "-m", "virtualenv", "--clear", envdir]) + + # Install pytest into the environment, as well as our wheel. + if sys.platform == "win32": + pip = os.path.join(envdir, "Scripts", "pip.exe") + else: + pip = os.path.join(envdir, "bin", "pip") + if subprocess.call([pip, "install", "pytest", wheel]) != 0: + shutil.rmtree(envdir) + sys.exit(1) + + # Run the test suite. + if sys.platform == "win32": + python = os.path.join(envdir, "Scripts", "python.exe") + else: + python = os.path.join(envdir, "bin", "python") + test_cmd = [python, "-m", "pytest", "tests"] + if verbose: + test_cmd.append("--verbose") + + exit_code = subprocess.call(test_cmd) + shutil.rmtree(envdir) + + if exit_code != 0: + sys.exit(exit_code) + + +if __name__ == "__main__": + parser = OptionParser(usage="%prog [options] file...") + parser.add_option('', '--verbose', dest = 'verbose', help = 'Enable verbose output', action = 'store_true', default = False) + (options, args) = parser.parse_args() + + if not args: + parser.print_usage() + sys.exit(1) + + for arg in args: + test_wheel(arg, verbose=options.verbose) From c9372c369981e196efa51aecf1c4d9812c5c01d1 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Aug 2018 14:02:33 +0200 Subject: [PATCH 156/360] Fix a few GCC compile warnings --- dtool/src/dtoolbase/stl_compares.I | 2 +- panda/src/event/asyncTask.cxx | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dtool/src/dtoolbase/stl_compares.I b/dtool/src/dtoolbase/stl_compares.I index 501435f547..4190cca45f 100644 --- a/dtool/src/dtoolbase/stl_compares.I +++ b/dtool/src/dtoolbase/stl_compares.I @@ -169,7 +169,7 @@ add_hash(size_t hash, const Key &key) { #ifdef _DEBUG // We assume that the sequence is laid out sequentially in memory. if (key.size() > 0) { - assert(&key[key.size() - 1] - &key[0] == key.size() - 1); + assert(&key[key.size() - 1] - &key[0] == (ptrdiff_t)key.size() - 1); } #endif size_t num_bytes = (key.size() * sizeof(key[0])); diff --git a/panda/src/event/asyncTask.cxx b/panda/src/event/asyncTask.cxx index 806d8e87af..e00b4f46e3 100644 --- a/panda/src/event/asyncTask.cxx +++ b/panda/src/event/asyncTask.cxx @@ -403,6 +403,9 @@ unlock_and_do_task() { Thread *current_thread = Thread::get_current_thread(); nassertr(current_thread->_current_task == nullptr, DS_interrupt); +#ifdef __GNUC__ + __attribute__((unused)) +#endif void *ptr = AtomicAdjust::compare_and_exchange_ptr (current_thread->_current_task, nullptr, (TypedReferenceCount *)this); From a90159271bd5b6ea10c81c6bf53dcbb62fe72a30 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Aug 2018 14:02:52 +0200 Subject: [PATCH 157/360] tests: remove unused fixture from Datagram tests --- tests/putil/test_datagram.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/putil/test_datagram.py b/tests/putil/test_datagram.py index 751ea0dc03..5a654b75ed 100644 --- a/tests/putil/test_datagram.py +++ b/tests/putil/test_datagram.py @@ -148,13 +148,7 @@ def do_file_test(dg, verify, filename): dgi = core.DatagramIterator(dg2) verify(dgi) -@pytest.fixture -def tmpfile(): - file = tempfile.NamedTemporaryFile(suffix='.bin') - yield file - file.close() - -def test_file_small(datagram_small, tmpfile): +def test_file_small(datagram_small): """This tests DatagramOutputFile/DatagramInputFile on small datagrams.""" dg, verify = datagram_small @@ -164,7 +158,7 @@ def test_file_small(datagram_small, tmpfile): do_file_test(dg, verify, filename) -def test_file_large(datagram_large, tmpfile): +def test_file_large(datagram_large): """This tests DatagramOutputFile/DatagramInputFile on very large datagrams.""" dg, verify = datagram_large @@ -174,7 +168,7 @@ def test_file_large(datagram_large, tmpfile): do_file_test(dg, verify, filename) -def test_file_corrupt(datagram_small, tmpfile): +def test_file_corrupt(datagram_small): """This tests DatagramInputFile's handling of a corrupt size header.""" dg, verify = datagram_small From 115f8df4d593649fda3d2917339519a3e1303a35 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Aug 2018 14:03:44 +0200 Subject: [PATCH 158/360] putil: work around GCC bug causing undefined reference in debug build --- panda/src/putil/bitMask.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index cb11fe10bf..ca5c9d8362 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -37,7 +37,7 @@ PUBLISHED: enum { num_bits = nbits }; constexpr BitMask() = default; - constexpr BitMask(WordType init_value); + ALWAYS_INLINE constexpr BitMask(WordType init_value); INLINE static BitMask all_on(); INLINE static BitMask all_off(); From 27dbad6fd9012438a234f27d713ce7884ad9509a Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Aug 2018 14:04:19 +0200 Subject: [PATCH 159/360] leveleditor: add missing import --- direct/src/leveleditor/ProtoPalette.py | 1 + 1 file changed, 1 insertion(+) diff --git a/direct/src/leveleditor/ProtoPalette.py b/direct/src/leveleditor/ProtoPalette.py index 0f8aacee3b..12a3c4605c 100755 --- a/direct/src/leveleditor/ProtoPalette.py +++ b/direct/src/leveleditor/ProtoPalette.py @@ -3,6 +3,7 @@ Palette for Prototyping """ from .ProtoPaletteBase import * +import os class ProtoPalette(ProtoPaletteBase): def __init__(self): From b1fc88027abff8810b67c3e36cbf3014ed2155b5 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Aug 2018 14:04:48 +0200 Subject: [PATCH 160/360] dtoolbase: add missing DTOOL_PLATFORM for linux_aarch64 --- dtool/src/dtoolbase/dtool_platform.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dtool/src/dtoolbase/dtool_platform.h b/dtool/src/dtoolbase/dtool_platform.h index 2a6ed12a9b..16ea54d88a 100644 --- a/dtool/src/dtoolbase/dtool_platform.h +++ b/dtool/src/dtoolbase/dtool_platform.h @@ -63,6 +63,9 @@ #define DTOOL_PLATFORM "android_i386" #endif +#elif defined(__aarch64__) +#define DTOOL_PLATFORM "linux_aarch64" + #elif defined(__x86_64) #define DTOOL_PLATFORM "linux_amd64" From 4695557a5d05c11c6d87c0f8e612db0abffee340 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 31 Aug 2018 22:11:11 -0600 Subject: [PATCH 161/360] general: Don't require BUILDING_* for static builds --- direct/src/deadrec/config_deadrec.cxx | 2 +- direct/src/directd/directd.cxx | 2 +- direct/src/distributed/config_distributed.cxx | 2 +- direct/src/interval/config_interval.cxx | 2 +- direct/src/motiontrail/config_motiontrail.cxx | 2 +- direct/src/showbase/showBase.cxx | 2 +- dtool/src/dconfig/config_dconfig.cxx | 2 +- dtool/src/dtoolbase/dtoolbase.cxx | 2 +- dtool/src/dtoolutil/config_dtoolutil.cxx | 2 +- dtool/src/prc/config_prc.cxx | 2 +- panda/metalibs/panda/panda.cxx | 2 +- panda/src/audio/config_audio.cxx | 2 +- panda/src/audiotraits/config_fmodAudio.cxx | 2 +- panda/src/audiotraits/config_milesAudio.cxx | 2 +- panda/src/audiotraits/config_openalAudio.cxx | 2 +- panda/src/awesomium/config_awesomium.cxx | 2 +- panda/src/bullet/config_bullet.cxx | 2 +- panda/src/chan/config_chan.cxx | 2 +- panda/src/char/config_char.cxx | 2 +- panda/src/cocoadisplay/config_cocoadisplay.mm | 2 +- panda/src/collada/config_collada.cxx | 2 +- panda/src/collide/config_collide.cxx | 2 +- panda/src/cull/config_cull.cxx | 2 +- panda/src/device/config_device.cxx | 2 +- panda/src/dgraph/config_dgraph.cxx | 2 +- panda/src/display/config_display.cxx | 2 +- panda/src/distort/config_distort.cxx | 2 +- panda/src/downloader/config_downloader.cxx | 2 +- panda/src/dxgsg9/config_dxgsg9.cxx | 2 +- panda/src/dxml/config_dxml.cxx | 2 +- panda/src/egg/config_egg.cxx | 2 +- panda/src/egg2pg/config_egg2pg.cxx | 2 +- panda/src/egldisplay/config_egldisplay.cxx | 2 +- panda/src/event/config_event.cxx | 2 +- panda/src/express/config_express.cxx | 2 +- panda/src/ffmpeg/config_ffmpeg.cxx | 2 +- panda/src/framework/config_framework.cxx | 2 +- panda/src/gles2gsg/config_gles2gsg.cxx | 2 +- panda/src/glesgsg/config_glesgsg.cxx | 2 +- panda/src/glgsg/config_glgsg.cxx | 2 +- panda/src/glxdisplay/config_glxdisplay.cxx | 2 +- panda/src/gobj/config_gobj.cxx | 2 +- panda/src/grutil/config_grutil.cxx | 2 +- panda/src/gsgbase/config_gsgbase.cxx | 2 +- panda/src/linmath/config_linmath.cxx | 2 +- panda/src/mathutil/config_mathutil.cxx | 2 +- panda/src/movies/config_movies.cxx | 2 +- panda/src/nativenet/config_nativenet.cxx | 2 +- panda/src/net/config_net.cxx | 2 +- panda/src/ode/config_ode.cxx | 2 +- panda/src/osxdisplay/config_osxdisplay.cxx | 2 +- panda/src/parametrics/config_parametrics.cxx | 2 +- panda/src/particlesystem/config_particlesystem.cxx | 2 +- panda/src/pgraph/config_pgraph.cxx | 2 +- panda/src/pgraphnodes/config_pgraphnodes.cxx | 2 +- panda/src/pgui/config_pgui.cxx | 2 +- panda/src/physics/config_physics.cxx | 2 +- panda/src/physx/config_physx.cxx | 2 +- panda/src/pipeline/config_pipeline.cxx | 2 +- panda/src/pnmimage/config_pnmimage.cxx | 2 +- panda/src/pnmimagetypes/config_pnmimagetypes.cxx | 2 +- panda/src/pnmtext/config_pnmtext.cxx | 2 +- panda/src/pstatclient/config_pstatclient.cxx | 2 +- panda/src/putil/config_putil.cxx | 2 +- panda/src/recorder/config_recorder.cxx | 2 +- panda/src/rocket/config_rocket.cxx | 2 +- panda/src/skel/config_skel.cxx | 2 +- panda/src/speedtree/config_speedtree.cxx | 2 +- panda/src/text/config_text.cxx | 2 +- panda/src/tform/config_tform.cxx | 2 +- panda/src/tinydisplay/config_tinydisplay.cxx | 2 +- panda/src/vision/config_vision.cxx | 2 +- panda/src/vrpn/config_vrpn.cxx | 2 +- panda/src/wgldisplay/config_wgldisplay.cxx | 2 +- panda/src/windisplay/config_windisplay.cxx | 2 +- panda/src/x11display/config_x11display.cxx | 2 +- 76 files changed, 76 insertions(+), 76 deletions(-) diff --git a/direct/src/deadrec/config_deadrec.cxx b/direct/src/deadrec/config_deadrec.cxx index eb1c43a9c6..87e1cffe68 100644 --- a/direct/src/deadrec/config_deadrec.cxx +++ b/direct/src/deadrec/config_deadrec.cxx @@ -15,7 +15,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DEADREC) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_DEADREC) #error Buildsystem error: BUILDING_DIRECT_DEADREC not defined #endif diff --git a/direct/src/directd/directd.cxx b/direct/src/directd/directd.cxx index 817706acb5..93a4df905c 100644 --- a/direct/src/directd/directd.cxx +++ b/direct/src/directd/directd.cxx @@ -30,7 +30,7 @@ #include "pset.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DIRECTD) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_DIRECTD) #error Buildsystem error: BUILDING_DIRECT_DIRECTD not defined #endif diff --git a/direct/src/distributed/config_distributed.cxx b/direct/src/distributed/config_distributed.cxx index 312964568f..0160f5f1bf 100644 --- a/direct/src/distributed/config_distributed.cxx +++ b/direct/src/distributed/config_distributed.cxx @@ -14,7 +14,7 @@ #include "config_distributed.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DISTRIBUTED) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_DISTRIBUTED) #error Buildsystem error: BUILDING_DIRECT_DISTRIBUTED not defined #endif diff --git a/direct/src/interval/config_interval.cxx b/direct/src/interval/config_interval.cxx index f56ce67e17..767ad32695 100644 --- a/direct/src/interval/config_interval.cxx +++ b/direct/src/interval/config_interval.cxx @@ -29,7 +29,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_INTERVAL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_INTERVAL) #error Buildsystem error: BUILDING_DIRECT_INTERVAL not defined #endif diff --git a/direct/src/motiontrail/config_motiontrail.cxx b/direct/src/motiontrail/config_motiontrail.cxx index 997a1a3059..c60a67f95c 100644 --- a/direct/src/motiontrail/config_motiontrail.cxx +++ b/direct/src/motiontrail/config_motiontrail.cxx @@ -14,7 +14,7 @@ #include "config_motiontrail.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_MOTIONTRAIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_MOTIONTRAIL) #error Buildsystem error: BUILDING_DIRECT_MOTIONTRAIL not defined #endif diff --git a/direct/src/showbase/showBase.cxx b/direct/src/showbase/showBase.cxx index f14d9610a4..7d8973996f 100644 --- a/direct/src/showbase/showBase.cxx +++ b/direct/src/showbase/showBase.cxx @@ -37,7 +37,7 @@ FILTERKEYS g_StartupFilterKeys = {sizeof(FILTERKEYS), 0}; using std::max; using std::min; -#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_SHOWBASE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DIRECT_SHOWBASE) #error Buildsystem error: BUILDING_DIRECT_SHOWBASE not defined #endif diff --git a/dtool/src/dconfig/config_dconfig.cxx b/dtool/src/dconfig/config_dconfig.cxx index d0800084ca..f828fc8f7d 100644 --- a/dtool/src/dconfig/config_dconfig.cxx +++ b/dtool/src/dconfig/config_dconfig.cxx @@ -13,7 +13,7 @@ #include "config_dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_DCONFIG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DTOOL_DCONFIG) #error Buildsystem error: BUILDING_DTOOL_DCONFIG not defined #endif diff --git a/dtool/src/dtoolbase/dtoolbase.cxx b/dtool/src/dtoolbase/dtoolbase.cxx index 10d1790ccf..a45a1de4e0 100644 --- a/dtool/src/dtoolbase/dtoolbase.cxx +++ b/dtool/src/dtoolbase/dtoolbase.cxx @@ -14,7 +14,7 @@ #include "dtoolbase.h" #include "memoryHook.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_DTOOLBASE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DTOOL_DTOOLBASE) #error Buildsystem error: BUILDING_DTOOL_DTOOLBASE not defined #endif diff --git a/dtool/src/dtoolutil/config_dtoolutil.cxx b/dtool/src/dtoolutil/config_dtoolutil.cxx index 98b3c42760..b7b6505d28 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.cxx +++ b/dtool/src/dtoolutil/config_dtoolutil.cxx @@ -16,7 +16,7 @@ #include "filename.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_DTOOLUTIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DTOOL_DTOOLUTIL) #error Buildsystem error: BUILDING_DTOOL_DCTOOLUTIL not defined #endif diff --git a/dtool/src/prc/config_prc.cxx b/dtool/src/prc/config_prc.cxx index 2728e642bd..65b7c77265 100644 --- a/dtool/src/prc/config_prc.cxx +++ b/dtool/src/prc/config_prc.cxx @@ -16,7 +16,7 @@ #include "configVariableEnum.h" #include "pandaFileStreamBuf.h" -#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_PRC) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DTOOL_PRC) #error Buildsystem error: BUILDING_DTOOL_PRC not defined #endif diff --git a/panda/metalibs/panda/panda.cxx b/panda/metalibs/panda/panda.cxx index 9c9cb8bb60..99da6b4f5b 100644 --- a/panda/metalibs/panda/panda.cxx +++ b/panda/metalibs/panda/panda.cxx @@ -14,7 +14,7 @@ #include "config_pstatclient.h" #endif -#if !defined(CPPPARSER) && !defined(BUILDING_LIBPANDA) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_LIBPANDA) #error Buildsystem error: BUILDING_LIBPANDA not defined #endif diff --git a/panda/src/audio/config_audio.cxx b/panda/src/audio/config_audio.cxx index 1ea8053eb6..ce9b1413d3 100644 --- a/panda/src/audio/config_audio.cxx +++ b/panda/src/audio/config_audio.cxx @@ -21,7 +21,7 @@ #include "nullAudioSound.h" #include "string_utils.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_AUDIO) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_AUDIO) #error Buildsystem error: BUILDING_PANDA_AUDIO not defined #endif diff --git a/panda/src/audiotraits/config_fmodAudio.cxx b/panda/src/audiotraits/config_fmodAudio.cxx index f0a188fbc5..c49b54f730 100644 --- a/panda/src/audiotraits/config_fmodAudio.cxx +++ b/panda/src/audiotraits/config_fmodAudio.cxx @@ -19,7 +19,7 @@ #include "pandaSystem.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_FMOD_AUDIO) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_FMOD_AUDIO) #error Buildsystem error: BUILDING_FMOD_AUDIO not defined #endif diff --git a/panda/src/audiotraits/config_milesAudio.cxx b/panda/src/audiotraits/config_milesAudio.cxx index 6877b3700e..87cd36321c 100644 --- a/panda/src/audiotraits/config_milesAudio.cxx +++ b/panda/src/audiotraits/config_milesAudio.cxx @@ -22,7 +22,7 @@ #include "pandaSystem.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_MILES_AUDIO) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_MILES_AUDIO) #error Buildsystem error: BUILDING_MILES_AUDIO not defined #endif diff --git a/panda/src/audiotraits/config_openalAudio.cxx b/panda/src/audiotraits/config_openalAudio.cxx index ad51368d75..72b6923928 100644 --- a/panda/src/audiotraits/config_openalAudio.cxx +++ b/panda/src/audiotraits/config_openalAudio.cxx @@ -18,7 +18,7 @@ #include "pandaSystem.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_OPENAL_AUDIO) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_OPENAL_AUDIO) #error Buildsystem error: BUILDING_OPENAL_AUDIO not defined #endif diff --git a/panda/src/awesomium/config_awesomium.cxx b/panda/src/awesomium/config_awesomium.cxx index 95ce655fe7..35987d0e27 100644 --- a/panda/src/awesomium/config_awesomium.cxx +++ b/panda/src/awesomium/config_awesomium.cxx @@ -18,7 +18,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAAWESOMIUM) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAAWESOMIUM) #error Buildsystem error: BUILDING_PANDAAWESOMIUM not defined #endif diff --git a/panda/src/bullet/config_bullet.cxx b/panda/src/bullet/config_bullet.cxx index 5997bf575b..f9eed1b6b8 100644 --- a/panda/src/bullet/config_bullet.cxx +++ b/panda/src/bullet/config_bullet.cxx @@ -56,7 +56,7 @@ extern ContactDestroyedCallback gContactDestroyedCallback; #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDABULLET) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDABULLET) #error Buildsystem error: BUILDING_PANDABULLET not defined #endif diff --git a/panda/src/chan/config_chan.cxx b/panda/src/chan/config_chan.cxx index 8992cfbbf9..3a049d67f6 100644 --- a/panda/src/chan/config_chan.cxx +++ b/panda/src/chan/config_chan.cxx @@ -34,7 +34,7 @@ #include "luse.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_CHAN) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_CHAN) #error Buildsystem error: BUILDING_PANDA_CHAN not defined #endif diff --git a/panda/src/char/config_char.cxx b/panda/src/char/config_char.cxx index 5d536bfc4c..25ab775316 100644 --- a/panda/src/char/config_char.cxx +++ b/panda/src/char/config_char.cxx @@ -21,7 +21,7 @@ #include "jointVertexTransform.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_CHAR) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_CHAR) #error Buildsystem error: BUILDING_PANDA_CHAR not defined #endif diff --git a/panda/src/cocoadisplay/config_cocoadisplay.mm b/panda/src/cocoadisplay/config_cocoadisplay.mm index a41e5bc579..96662d6c9c 100644 --- a/panda/src/cocoadisplay/config_cocoadisplay.mm +++ b/panda/src/cocoadisplay/config_cocoadisplay.mm @@ -20,7 +20,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_COCOADISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_COCOADISPLAY) #error Buildsystem error: BUILDING_PANDA_COCOADISPLAY not defined #endif diff --git a/panda/src/collada/config_collada.cxx b/panda/src/collada/config_collada.cxx index fa97023656..1fec2da68e 100644 --- a/panda/src/collada/config_collada.cxx +++ b/panda/src/collada/config_collada.cxx @@ -17,7 +17,7 @@ #include "loaderFileTypeDae.h" #include "loaderFileTypeRegistry.h" -#if !defined(CPPPARSER) && !defined(BUILDING_COLLADA) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_COLLADA) #error Buildsystem error: BUILDING_COLLADA not defined #endif diff --git a/panda/src/collide/config_collide.cxx b/panda/src/collide/config_collide.cxx index 01d517df04..38c821ed05 100644 --- a/panda/src/collide/config_collide.cxx +++ b/panda/src/collide/config_collide.cxx @@ -42,7 +42,7 @@ #include "collisionVisualizer.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_COLLIDE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_COLLIDE) #error Buildsystem error: BUILDING_PANDA_COLLIDE not defined #endif diff --git a/panda/src/cull/config_cull.cxx b/panda/src/cull/config_cull.cxx index 452c69ea0c..04ce4ca63c 100644 --- a/panda/src/cull/config_cull.cxx +++ b/panda/src/cull/config_cull.cxx @@ -22,7 +22,7 @@ #include "cullBinManager.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_CULL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_CULL) #error Buildsystem error: BUILDING_PANDA_CULL not defined #endif diff --git a/panda/src/device/config_device.cxx b/panda/src/device/config_device.cxx index eb8d1a2f10..fb7f4d8928 100644 --- a/panda/src/device/config_device.cxx +++ b/panda/src/device/config_device.cxx @@ -27,7 +27,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DEVICE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DEVICE) #error Buildsystem error: BUILDING_PANDA_DEVICE not defined #endif diff --git a/panda/src/dgraph/config_dgraph.cxx b/panda/src/dgraph/config_dgraph.cxx index 3c91aeea18..5a107635b7 100644 --- a/panda/src/dgraph/config_dgraph.cxx +++ b/panda/src/dgraph/config_dgraph.cxx @@ -17,7 +17,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DGRAPH) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DGRAPH) #error Buildsystem error: BUILDING_PANDA_DGRAPH not defined #endif diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 0d3fea3937..1c2f612fcc 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -31,7 +31,7 @@ #include "subprocessWindow.h" #include "windowHandle.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DISPLAY) #error Buildsystem error: BUILDING_PANDA_DISPLAY not defined #endif diff --git a/panda/src/distort/config_distort.cxx b/panda/src/distort/config_distort.cxx index eaa0147dae..b14f9aae45 100644 --- a/panda/src/distort/config_distort.cxx +++ b/panda/src/distort/config_distort.cxx @@ -20,7 +20,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAFX) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAFX) #error Buildsystem error: BUILDING_PANDAFX not defined #endif diff --git a/panda/src/downloader/config_downloader.cxx b/panda/src/downloader/config_downloader.cxx index 4e60b4028c..cd8f1de723 100644 --- a/panda/src/downloader/config_downloader.cxx +++ b/panda/src/downloader/config_downloader.cxx @@ -19,7 +19,7 @@ #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DOWNLOADER) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DOWNLOADER) #error Buildsystem error: BUILDING_PANDA_DOWNLOADER not defined #endif diff --git a/panda/src/dxgsg9/config_dxgsg9.cxx b/panda/src/dxgsg9/config_dxgsg9.cxx index d5777602db..07ebca58a0 100644 --- a/panda/src/dxgsg9/config_dxgsg9.cxx +++ b/panda/src/dxgsg9/config_dxgsg9.cxx @@ -27,7 +27,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDADX) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDADX) #error Buildsystem error: BUILDING_PANDADX not defined #endif diff --git a/panda/src/dxml/config_dxml.cxx b/panda/src/dxml/config_dxml.cxx index 0441f1fdc5..bbc119cb14 100644 --- a/panda/src/dxml/config_dxml.cxx +++ b/panda/src/dxml/config_dxml.cxx @@ -19,7 +19,7 @@ BEGIN_PUBLISH #include "tinyxml.h" END_PUBLISH -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DXML) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_DXML) #error Buildsystem error: BUILDING_PANDA_DXML not defined #endif diff --git a/panda/src/egg/config_egg.cxx b/panda/src/egg/config_egg.cxx index ec0009819f..cbcc00d32f 100644 --- a/panda/src/egg/config_egg.cxx +++ b/panda/src/egg/config_egg.cxx @@ -58,7 +58,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EGG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_EGG) #error Buildsystem error: BUILDING_PANDA_EGG not defined #endif diff --git a/panda/src/egg2pg/config_egg2pg.cxx b/panda/src/egg2pg/config_egg2pg.cxx index 36247ad2c4..e32aa19914 100644 --- a/panda/src/egg2pg/config_egg2pg.cxx +++ b/panda/src/egg2pg/config_egg2pg.cxx @@ -20,7 +20,7 @@ #include "configVariableCore.h" #include "eggRenderState.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EGG2PG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_EGG2PG) #error Buildsystem error: BUILDING_PANDA_EGG2PG not defined #endif diff --git a/panda/src/egldisplay/config_egldisplay.cxx b/panda/src/egldisplay/config_egldisplay.cxx index f76b1b9d1f..2f8e99cc0f 100644 --- a/panda/src/egldisplay/config_egldisplay.cxx +++ b/panda/src/egldisplay/config_egldisplay.cxx @@ -19,7 +19,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGLES) && !defined(BUILDING_PANDAGLES2) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAGLES) && !defined(BUILDING_PANDAGLES2) #error Buildsystem error: BUILDING_PANDAGLES(2) not defined #endif diff --git a/panda/src/event/config_event.cxx b/panda/src/event/config_event.cxx index c7f1c8eecc..ccae0d95ae 100644 --- a/panda/src/event/config_event.cxx +++ b/panda/src/event/config_event.cxx @@ -27,7 +27,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EVENT) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_EVENT) #error Buildsystem error: BUILDING_PANDA_EVENT not defined #endif diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index 3a4343ac32..c9e664db34 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -36,7 +36,7 @@ #include "dconfig.h" #include "streamWrapper.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EXPRESS) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_EXPRESS) #error Buildsystem error: BUILDING_PANDA_EXPRESS not defined #endif diff --git a/panda/src/ffmpeg/config_ffmpeg.cxx b/panda/src/ffmpeg/config_ffmpeg.cxx index 850cf62937..27270757a8 100644 --- a/panda/src/ffmpeg/config_ffmpeg.cxx +++ b/panda/src/ffmpeg/config_ffmpeg.cxx @@ -26,7 +26,7 @@ extern "C" { #include "libavutil/avutil.h" } -#if !defined(CPPPARSER) && !defined(BUILDING_FFMPEG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_FFMPEG) #error Buildsystem error: BUILDING_FFMPEG not defined #endif diff --git a/panda/src/framework/config_framework.cxx b/panda/src/framework/config_framework.cxx index 4ddc4b553a..febf588dd8 100644 --- a/panda/src/framework/config_framework.cxx +++ b/panda/src/framework/config_framework.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" #include "windowFramework.h" -#if !defined(CPPPARSER) && !defined(BUILDING_FRAMEWORK) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_FRAMEWORK) #error Buildsystem error: BUILDING_FRAMEWORK not defined #endif diff --git a/panda/src/gles2gsg/config_gles2gsg.cxx b/panda/src/gles2gsg/config_gles2gsg.cxx index aee9c925fb..0e5a71aadb 100644 --- a/panda/src/gles2gsg/config_gles2gsg.cxx +++ b/panda/src/gles2gsg/config_gles2gsg.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGLES2) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAGLES2) #error Buildsystem error: BUILDING_PANDAGLES2 not defined #endif diff --git a/panda/src/glesgsg/config_glesgsg.cxx b/panda/src/glesgsg/config_glesgsg.cxx index b30cf23322..77d711f1f5 100644 --- a/panda/src/glesgsg/config_glesgsg.cxx +++ b/panda/src/glesgsg/config_glesgsg.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGLES) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAGLES) #error Buildsystem error: BUILDING_PANDAGLES not defined #endif diff --git a/panda/src/glgsg/config_glgsg.cxx b/panda/src/glgsg/config_glgsg.cxx index 1c7ddcbfd5..21a3a2ec61 100644 --- a/panda/src/glgsg/config_glgsg.cxx +++ b/panda/src/glgsg/config_glgsg.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GLGSG) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GLGSG) #error Buildsystem error: BUILDING_PANDA_GLGSG not defined #endif diff --git a/panda/src/glxdisplay/config_glxdisplay.cxx b/panda/src/glxdisplay/config_glxdisplay.cxx index 23b8aef8fa..c7a66644d9 100644 --- a/panda/src/glxdisplay/config_glxdisplay.cxx +++ b/panda/src/glxdisplay/config_glxdisplay.cxx @@ -23,7 +23,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GLXDISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GLXDISPLAY) #error Buildsystem error: BUILDING_PANDA_GLXDISPLAY not defined #endif diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index 7da3b1d31e..12840f7d04 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -70,7 +70,7 @@ #include "dconfig.h" #include "string_utils.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GOBJ) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GOBJ) #error Buildsystem error: BUILDING_PANDA_GOBJ not defined #endif diff --git a/panda/src/grutil/config_grutil.cxx b/panda/src/grutil/config_grutil.cxx index 337abd11bb..6f74fd5e1b 100644 --- a/panda/src/grutil/config_grutil.cxx +++ b/panda/src/grutil/config_grutil.cxx @@ -27,7 +27,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GRUTIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GRUTIL) #error Buildsystem error: BUILDING_PANDA_GRUTIL not defined #endif diff --git a/panda/src/gsgbase/config_gsgbase.cxx b/panda/src/gsgbase/config_gsgbase.cxx index 52da83f9c8..bb60e50533 100644 --- a/panda/src/gsgbase/config_gsgbase.cxx +++ b/panda/src/gsgbase/config_gsgbase.cxx @@ -17,7 +17,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GSGBASE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_GSGBASE) #error Buildsystem error: BUILDING_PANDA_GSGBASE not defined #endif diff --git a/panda/src/linmath/config_linmath.cxx b/panda/src/linmath/config_linmath.cxx index fb0942aa55..c93eb8caac 100644 --- a/panda/src/linmath/config_linmath.cxx +++ b/panda/src/linmath/config_linmath.cxx @@ -17,7 +17,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_LINMATH) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_LINMATH) #error Buildsystem error: BUILDING_PANDA_LINMATH not defined #endif diff --git a/panda/src/mathutil/config_mathutil.cxx b/panda/src/mathutil/config_mathutil.cxx index 2084b2b670..bb10014f0c 100644 --- a/panda/src/mathutil/config_mathutil.cxx +++ b/panda/src/mathutil/config_mathutil.cxx @@ -26,7 +26,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_MATHUTIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_MATHUTIL) #error Buildsystem error: BUILDING_PANDA_MATHUTIL not defined #endif diff --git a/panda/src/movies/config_movies.cxx b/panda/src/movies/config_movies.cxx index 93448cfe8d..f6e889b6e8 100644 --- a/panda/src/movies/config_movies.cxx +++ b/panda/src/movies/config_movies.cxx @@ -32,7 +32,7 @@ #include "wavAudio.h" #include "wavAudioCursor.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_MOVIES) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_MOVIES) #error Buildsystem error: BUILDING_PANDA_MOVIES not defined #endif diff --git a/panda/src/nativenet/config_nativenet.cxx b/panda/src/nativenet/config_nativenet.cxx index 172e56afa8..f90e106e81 100644 --- a/panda/src/nativenet/config_nativenet.cxx +++ b/panda/src/nativenet/config_nativenet.cxx @@ -26,7 +26,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_NATIVENET) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_NATIVENET) #error Buildsystem error: BUILDING_PANDA_NATIVENET not defined #endif diff --git a/panda/src/net/config_net.cxx b/panda/src/net/config_net.cxx index 80af80147a..753a5beb53 100644 --- a/panda/src/net/config_net.cxx +++ b/panda/src/net/config_net.cxx @@ -18,7 +18,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_NET) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_NET) #error Buildsystem error: BUILDING_PANDA_NET not defined #endif diff --git a/panda/src/ode/config_ode.cxx b/panda/src/ode/config_ode.cxx index 214281d579..a87bb6922e 100644 --- a/panda/src/ode/config_ode.cxx +++ b/panda/src/ode/config_ode.cxx @@ -47,7 +47,7 @@ #include "odeCollisionEntry.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAODE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAODE) #error Buildsystem error: BUILDING_PANDAODE not defined #endif diff --git a/panda/src/osxdisplay/config_osxdisplay.cxx b/panda/src/osxdisplay/config_osxdisplay.cxx index 43f897b862..0ebc9454bd 100644 --- a/panda/src/osxdisplay/config_osxdisplay.cxx +++ b/panda/src/osxdisplay/config_osxdisplay.cxx @@ -20,7 +20,7 @@ #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_OSXDISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_OSXDISPLAY) #error Buildsystem error: BUILDING_PANDA_OSXDISPLAY not defined #endif diff --git a/panda/src/parametrics/config_parametrics.cxx b/panda/src/parametrics/config_parametrics.cxx index 2b07e493bd..0ab86efcf7 100644 --- a/panda/src/parametrics/config_parametrics.cxx +++ b/panda/src/parametrics/config_parametrics.cxx @@ -22,7 +22,7 @@ #include "ropeNode.h" #include "sheetNode.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PARAMETRICS) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PARAMETRICS) #error Buildsystem error: BUILDING_PANDA_PARAMETRICS not defined #endif diff --git a/panda/src/particlesystem/config_particlesystem.cxx b/panda/src/particlesystem/config_particlesystem.cxx index 61f1224ea4..92f19c8f15 100644 --- a/panda/src/particlesystem/config_particlesystem.cxx +++ b/panda/src/particlesystem/config_particlesystem.cxx @@ -16,7 +16,7 @@ #include "geomParticleRenderer.h" #include "geomNode.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PARTICLESYSTEM) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PARTICLESYSTEM) #error Buildsystem error: BUILDING_PANDA_PARTICLESYSTEM not defined #endif diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 54fa621f7b..e969dee72f 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -92,7 +92,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PGRAPH) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PGRAPH) #error Buildsystem error: BUILDING_PANDA_PGRAPH not defined #endif diff --git a/panda/src/pgraphnodes/config_pgraphnodes.cxx b/panda/src/pgraphnodes/config_pgraphnodes.cxx index 3879a980b3..309605b201 100644 --- a/panda/src/pgraphnodes/config_pgraphnodes.cxx +++ b/panda/src/pgraphnodes/config_pgraphnodes.cxx @@ -37,7 +37,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PGRAPHNODES) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PGRAPHNODES) #error Buildsystem error: BUILDING_PANDA_PGRAPHNODES not defined #endif diff --git a/panda/src/pgui/config_pgui.cxx b/panda/src/pgui/config_pgui.cxx index c2c3e72405..bb334756e3 100644 --- a/panda/src/pgui/config_pgui.cxx +++ b/panda/src/pgui/config_pgui.cxx @@ -28,7 +28,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PGUI) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PGUI) #error Buildsystem error: BUILDING_PANDA_PGUI not defined #endif diff --git a/panda/src/physics/config_physics.cxx b/panda/src/physics/config_physics.cxx index b4ad867f66..b952dae04f 100644 --- a/panda/src/physics/config_physics.cxx +++ b/panda/src/physics/config_physics.cxx @@ -26,7 +26,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PHYSICS) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PHYSICS) #error Buildsystem error: BUILDING_PANDA_PHYSICS not defined #endif diff --git a/panda/src/physx/config_physx.cxx b/panda/src/physx/config_physx.cxx index 4880e37e88..6a1b421eaf 100644 --- a/panda/src/physx/config_physx.cxx +++ b/panda/src/physx/config_physx.cxx @@ -67,7 +67,7 @@ #include "physxWheel.h" #include "physxWheelShape.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAPHYSX) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAPHYSX) #error Buildsystem error: BUILDING_PANDAPHYSX not defined #endif diff --git a/panda/src/pipeline/config_pipeline.cxx b/panda/src/pipeline/config_pipeline.cxx index 60f077688f..2e7bf6487e 100644 --- a/panda/src/pipeline/config_pipeline.cxx +++ b/panda/src/pipeline/config_pipeline.cxx @@ -21,7 +21,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PIPELINE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PIPELINE) #error Buildsystem error: BUILDING_PANDA_PIPELINE not defined #endif diff --git a/panda/src/pnmimage/config_pnmimage.cxx b/panda/src/pnmimage/config_pnmimage.cxx index 5bb734cf85..7bafe9fb09 100644 --- a/panda/src/pnmimage/config_pnmimage.cxx +++ b/panda/src/pnmimage/config_pnmimage.cxx @@ -17,7 +17,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PNMIMAGE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PNMIMAGE) #error Buildsystem error: BUILDING_PANDA_PNMIMAGE not defined #endif diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index 551c351c43..bf70c56d1f 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -32,7 +32,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PNMIMAGETYPES) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PNMIMAGETYPES) #error Buildsystem error: BUILDING_PANDA_PNMIMAGETYPES not defined #endif diff --git a/panda/src/pnmtext/config_pnmtext.cxx b/panda/src/pnmtext/config_pnmtext.cxx index a0a627aca7..a653fac26f 100644 --- a/panda/src/pnmtext/config_pnmtext.cxx +++ b/panda/src/pnmtext/config_pnmtext.cxx @@ -16,7 +16,7 @@ #include "dconfig.h" #include "freetypeFace.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PNMTEXT) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PNMTEXT) #error Buildsystem error: BUILDING_PANDA_PNMTEXT not defined #endif diff --git a/panda/src/pstatclient/config_pstatclient.cxx b/panda/src/pstatclient/config_pstatclient.cxx index 4be7472441..1335254590 100644 --- a/panda/src/pstatclient/config_pstatclient.cxx +++ b/panda/src/pstatclient/config_pstatclient.cxx @@ -15,7 +15,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PSTATCLIENT) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PSTATCLIENT) #error Buildsystem error: BUILDING_PANDA_PSTATCLIENT not defined #endif diff --git a/panda/src/putil/config_putil.cxx b/panda/src/putil/config_putil.cxx index c3083f306f..593da51fd0 100644 --- a/panda/src/putil/config_putil.cxx +++ b/panda/src/putil/config_putil.cxx @@ -47,7 +47,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PUTIL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_PUTIL) #error Buildsystem error: BUILDING_PANDA_PUTIL not defined #endif diff --git a/panda/src/recorder/config_recorder.cxx b/panda/src/recorder/config_recorder.cxx index 97335e17cd..c24e320391 100644 --- a/panda/src/recorder/config_recorder.cxx +++ b/panda/src/recorder/config_recorder.cxx @@ -22,7 +22,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_RECORDER) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_RECORDER) #error Buildsystem error: BUILDING_PANDA_RECORDER not defined #endif diff --git a/panda/src/rocket/config_rocket.cxx b/panda/src/rocket/config_rocket.cxx index 4de7bf3e28..61b5c634e2 100644 --- a/panda/src/rocket/config_rocket.cxx +++ b/panda/src/rocket/config_rocket.cxx @@ -26,7 +26,7 @@ #include #undef Factory -#if !defined(CPPPARSER) && !defined(BUILDING_ROCKET) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_ROCKET) #error Buildsystem error: BUILDING_ROCKET not defined #endif diff --git a/panda/src/skel/config_skel.cxx b/panda/src/skel/config_skel.cxx index 5fa6f6595c..dd6e808502 100644 --- a/panda/src/skel/config_skel.cxx +++ b/panda/src/skel/config_skel.cxx @@ -16,7 +16,7 @@ #include "typedSkel.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDASKEL) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDASKEL) #error Buildsystem error: BUILDING_PANDASKEL not defined #endif diff --git a/panda/src/speedtree/config_speedtree.cxx b/panda/src/speedtree/config_speedtree.cxx index f820239665..dfc4d455c6 100644 --- a/panda/src/speedtree/config_speedtree.cxx +++ b/panda/src/speedtree/config_speedtree.cxx @@ -21,7 +21,7 @@ #include "loaderFileTypeRegistry.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDASPEEDTREE) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDASPEEDTREE) #error Buildsystem error: BUILDING_PANDASPEEDTREE not defined #endif diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index 77dd27beba..dee79539ba 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -27,7 +27,7 @@ #include "dconfig.h" #include "config_express.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_TEXT) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_TEXT) #error Buildsystem error: BUILDING_PANDA_TEXT not defined #endif diff --git a/panda/src/tform/config_tform.cxx b/panda/src/tform/config_tform.cxx index b8a578d07c..6620e5724c 100644 --- a/panda/src/tform/config_tform.cxx +++ b/panda/src/tform/config_tform.cxx @@ -25,7 +25,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_TFORM) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_TFORM) #error Buildsystem error: BUILDING_PANDA_TFORM not defined #endif diff --git a/panda/src/tinydisplay/config_tinydisplay.cxx b/panda/src/tinydisplay/config_tinydisplay.cxx index 31ef112ee5..9740001c01 100644 --- a/panda/src/tinydisplay/config_tinydisplay.cxx +++ b/panda/src/tinydisplay/config_tinydisplay.cxx @@ -29,7 +29,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_TINYDISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_TINYDISPLAY) #error Buildsystem error: BUILDING_TINYDISPLAY not defined #endif diff --git a/panda/src/vision/config_vision.cxx b/panda/src/vision/config_vision.cxx index ffe3719962..4b4eee02f8 100644 --- a/panda/src/vision/config_vision.cxx +++ b/panda/src/vision/config_vision.cxx @@ -23,7 +23,7 @@ #include "texturePool.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_VISION) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_VISION) #error Buildsystem error: BUILDING_VISION not defined #endif diff --git a/panda/src/vrpn/config_vrpn.cxx b/panda/src/vrpn/config_vrpn.cxx index cc577bd328..54ac23f565 100644 --- a/panda/src/vrpn/config_vrpn.cxx +++ b/panda/src/vrpn/config_vrpn.cxx @@ -21,7 +21,7 @@ #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_VRPN) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_VRPN) #error Buildsystem error: BUILDING_VRPN not defined #endif diff --git a/panda/src/wgldisplay/config_wgldisplay.cxx b/panda/src/wgldisplay/config_wgldisplay.cxx index fa04606dca..63d40fdea8 100644 --- a/panda/src/wgldisplay/config_wgldisplay.cxx +++ b/panda/src/wgldisplay/config_wgldisplay.cxx @@ -20,7 +20,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_WGLDISPLAY) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_WGLDISPLAY) #error Buildsystem error: BUILDING_PANDA_WGLDISPLAY not defined #endif diff --git a/panda/src/windisplay/config_windisplay.cxx b/panda/src/windisplay/config_windisplay.cxx index 1af5cf95da..6e0ea2406d 100644 --- a/panda/src/windisplay/config_windisplay.cxx +++ b/panda/src/windisplay/config_windisplay.cxx @@ -16,7 +16,7 @@ #include "winGraphicsWindow.h" #include "dconfig.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAWIN) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAWIN) #error Buildsystem error: BUILDING_PANDAWIN not defined #endif diff --git a/panda/src/x11display/config_x11display.cxx b/panda/src/x11display/config_x11display.cxx index bca59d5a17..4a633303ba 100644 --- a/panda/src/x11display/config_x11display.cxx +++ b/panda/src/x11display/config_x11display.cxx @@ -18,7 +18,7 @@ #include "dconfig.h" #include "pandaSystem.h" -#if !defined(CPPPARSER) && !defined(BUILDING_PANDAX11) +#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDAX11) #error Buildsystem error: BUILDING_PANDAX11 not defined #endif From c4fe1ed8835ba5ca613569091635e485db0f01e7 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 2 Sep 2018 10:54:07 +0200 Subject: [PATCH 162/360] gobj: slight refactor of Texture::do_get_clear_data() --- panda/src/gobj/texture.cxx | 171 ++++++++++--------------------------- 1 file changed, 45 insertions(+), 126 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index c538391018..ed983527f8 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -5594,180 +5594,99 @@ do_set_ram_mipmap_image(CData *cdata, int n, CPTA_uchar image, size_t page_size) size_t Texture:: do_get_clear_data(const CData *cdata, unsigned char *into) const { nassertr(cdata->_has_clear_color, 0); - nassertr(cdata->_num_components <= 4, 0); + + int num_components = cdata->_num_components; + nassertr(num_components > 0, 0); + nassertr(num_components <= 4, 0); + + LVecBase4 clear_value = cdata->_clear_color; + + // Swap red and blue components. + if (num_components >= 3) { + std::swap(clear_value[0], clear_value[2]); + } switch (cdata->_component_type) { case T_unsigned_byte: if (is_srgb(cdata->_format)) { xel color; xelval alpha; - encode_sRGB_uchar(cdata->_clear_color, color, alpha); - switch (cdata->_num_components) { - case 2: - into[1] = (unsigned char)color.g; - case 1: - into[0] = (unsigned char)color.r; - break; - case 4: - into[3] = (unsigned char)alpha; - case 3: // BGR <-> RGB - into[0] = (unsigned char)color.b; - into[1] = (unsigned char)color.g; - into[2] = (unsigned char)color.r; - break; + encode_sRGB_uchar(clear_value, color, alpha); + switch (num_components) { + case 4: into[3] = (unsigned char)alpha; + case 3: into[2] = (unsigned char)color.b; + case 2: into[1] = (unsigned char)color.g; + case 1: into[0] = (unsigned char)color.r; } - break; } else { - LColor scaled = cdata->_clear_color.fmin(LColor(1)).fmax(LColor::zero()); + LColor scaled = clear_value.fmin(LColor(1)).fmax(LColor::zero()); scaled *= 255; - switch (cdata->_num_components) { - case 2: - into[1] = (unsigned char)scaled[1]; - case 1: - into[0] = (unsigned char)scaled[0]; - break; - case 4: - into[3] = (unsigned char)scaled[3]; - case 3: // BGR <-> RGB - into[0] = (unsigned char)scaled[2]; - into[1] = (unsigned char)scaled[1]; - into[2] = (unsigned char)scaled[0]; - break; + for (int i = 0; i < num_components; ++i) { + into[i] = (unsigned char)scaled[i]; } - break; } + break; case T_unsigned_short: { - LColor scaled = cdata->_clear_color.fmin(LColor(1)).fmax(LColor::zero()); + LColor scaled = clear_value.fmin(LColor(1)).fmax(LColor::zero()); scaled *= 65535; - switch (cdata->_num_components) { - case 2: - ((unsigned short *)into)[1] = (unsigned short)scaled[1]; - case 1: - ((unsigned short *)into)[0] = (unsigned short)scaled[0]; - break; - case 4: - ((unsigned short *)into)[3] = (unsigned short)scaled[3]; - case 3: // BGR <-> RGB - ((unsigned short *)into)[0] = (unsigned short)scaled[2]; - ((unsigned short *)into)[1] = (unsigned short)scaled[1]; - ((unsigned short *)into)[2] = (unsigned short)scaled[0]; - break; + for (int i = 0; i < num_components; ++i) { + ((unsigned short *)into)[i] = (unsigned short)scaled[i]; } break; } case T_float: - switch (cdata->_num_components) { - case 2: - ((float *)into)[1] = cdata->_clear_color[1]; - case 1: - ((float *)into)[0] = cdata->_clear_color[0]; - break; - case 4: - ((float *)into)[3] = cdata->_clear_color[3]; - case 3: // BGR <-> RGB - ((float *)into)[0] = cdata->_clear_color[2]; - ((float *)into)[1] = cdata->_clear_color[1]; - ((float *)into)[2] = cdata->_clear_color[0]; - break; + for (int i = 0; i < num_components; ++i) { + ((float *)into)[i] = clear_value[i]; } break; case T_unsigned_int_24_8: - nassertr(cdata->_num_components == 1, 0); + nassertr(num_components == 1, 0); *((unsigned int *)into) = - ((unsigned int)(cdata->_clear_color[0] * 16777215) << 8) + - (unsigned int)max(min(cdata->_clear_color[1], (PN_stdfloat)255), (PN_stdfloat)0); + ((unsigned int)(clear_value[0] * 16777215) << 8) + + (unsigned int)max(min(clear_value[1], (PN_stdfloat)255), (PN_stdfloat)0); break; case T_int: - { - // Note: there are no 32-bit UNORM textures. Therefore, we don't do any - // normalization here, either. - switch (cdata->_num_components) { - case 2: - ((int *)into)[1] = (int)cdata->_clear_color[1]; - case 1: - ((int *)into)[0] = (int)cdata->_clear_color[0]; - break; - case 4: - ((int *)into)[3] = (int)cdata->_clear_color[3]; - case 3: // BGR <-> RGB - ((int *)into)[0] = (int)cdata->_clear_color[2]; - ((int *)into)[1] = (int)cdata->_clear_color[1]; - ((int *)into)[2] = (int)cdata->_clear_color[0]; - break; - } - break; + // Note: there are no 32-bit UNORM textures. Therefore, we don't do any + // normalization here, either. + for (int i = 0; i < num_components; ++i) { + ((int *)into)[i] = (int)clear_value[i]; } + break; case T_byte: { - LColor scaled = cdata->_clear_color.fmin(LColor(1)).fmax(LColor(-1)); + LColor scaled = clear_value.fmin(LColor(1)).fmax(LColor(-1)); scaled *= 127; - switch (cdata->_num_components) { - case 2: - into[1] = (char)scaled[1]; - case 1: - into[0] = (char)scaled[0]; - break; - case 4: - into[3] = (char)scaled[3]; - case 3: // BGR <-> RGB - into[0] = (char)scaled[2]; - into[1] = (char)scaled[1]; - into[2] = (char)scaled[0]; - break; + for (int i = 0; i < num_components; ++i) { + ((signed char *)into)[i] = (signed char)scaled[i]; } break; } case T_short: { - LColor scaled = cdata->_clear_color.fmin(LColor(1)).fmax(LColor(-1)); + LColor scaled = clear_value.fmin(LColor(1)).fmax(LColor(-1)); scaled *= 32767; - switch (cdata->_num_components) { - case 2: - ((short *)into)[1] = (short)scaled[1]; - case 1: - ((short *)into)[0] = (short)scaled[0]; - break; - case 4: - ((short *)into)[3] = (short)scaled[3]; - case 3: // BGR <-> RGB - ((short *)into)[0] = (short)scaled[2]; - ((short *)into)[1] = (short)scaled[1]; - ((short *)into)[2] = (short)scaled[0]; - break; + for (int i = 0; i < num_components; ++i) { + ((short *)into)[i] = (short)scaled[i]; } break; } case T_unsigned_int: - { - // Note: there are no 32-bit UNORM textures. Therefore, we don't do any - // normalization here, either. - switch (cdata->_num_components) { - case 2: - ((unsigned int *)into)[1] = (unsigned int)cdata->_clear_color[1]; - case 1: - ((unsigned int *)into)[0] = (unsigned int)cdata->_clear_color[0]; - break; - case 4: - ((unsigned int *)into)[3] = (unsigned int)cdata->_clear_color[3]; - case 3: // BGR <-> RGB - ((unsigned int *)into)[0] = (unsigned int)cdata->_clear_color[2]; - ((unsigned int *)into)[1] = (unsigned int)cdata->_clear_color[1]; - ((unsigned int *)into)[2] = (unsigned int)cdata->_clear_color[0]; - break; - } - break; + // Note: there are no 32-bit UNORM textures. Therefore, we don't do any + // normalization here, either. + for (int i = 0; i < num_components; ++i) { + ((unsigned int *)into)[i] = (unsigned int)clear_value[i]; } } - return cdata->_num_components * cdata->_component_width; + return num_components * cdata->_component_width; } /** From c670cd45d984ae67fa3da8da89ee713adad26271 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 2 Sep 2018 10:56:20 +0200 Subject: [PATCH 163/360] gobj: handle infinity and NaN when peeking half float values --- panda/src/gobj/texture.I | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 4abb480348..7d859dbda8 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -2390,8 +2390,13 @@ get_half_float(const unsigned char *&p) { uint32_t t3 = in & 0x7c00; // Exponent t1 <<= 13; // Align mantissa on MSB t2 <<= 16; // Shift sign bit into position - t1 += 0x38000000; // Adjust bias - t1 = (t3 == 0 ? 0 : t1); // Denormals-as-zero + if (t3 != 0x7c00) { + t1 += 0x38000000; // Adjust bias + t1 = (t3 == 0 ? 0 : t1); // Denormals-as-zero + } else { + // Infinity / NaN + t1 |= 0x7f800000; + } t1 |= t2; // Re-insert sign bit v.ui = t1; return v.uf; From 3495537bf971ba5830809b4a3c881ff0eb06c014 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 2 Sep 2018 10:58:02 +0200 Subject: [PATCH 164/360] gobj: support clearing half-float textures Fixes #374 --- panda/src/gobj/texture.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index ed983527f8..c0cd14db0a 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -5678,6 +5678,21 @@ do_get_clear_data(const CData *cdata, unsigned char *into) const { break; } + case T_half_float: + for (int i = 0; i < num_components; ++i) { + union { + uint32_t ui; + float uf; + } v; + v.uf = clear_value[i]; + uint16_t sign = ((v.ui & 0x80000000u) >> 16u); + uint32_t mantissa = (v.ui & 0x007fffffu); + uint16_t exponent = (uint16_t)std::min(std::max((int)((v.ui & 0x7f800000u) >> 23u) - 112, 0), 31); + mantissa += (mantissa & 0x00001000u) << 1u; + ((uint16_t *)into)[i] = (uint16_t)(sign | ((exponent << 10u) | (mantissa >> 13u))); + } + break; + case T_unsigned_int: // Note: there are no 32-bit UNORM textures. Therefore, we don't do any // normalization here, either. From 9dec2aafb5a3b6f2f57c6028d7a79466558749bb Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 2 Sep 2018 10:59:46 +0200 Subject: [PATCH 165/360] Fix static init ordering crashes in static build of pview Fixes #381 --- panda/src/event/asyncTaskManager.cxx | 1 + panda/src/event/eventHandler.cxx | 1 + panda/src/event/eventQueue.cxx | 1 + panda/src/pipeline/thread.cxx | 2 ++ 4 files changed, 5 insertions(+) diff --git a/panda/src/event/asyncTaskManager.cxx b/panda/src/event/asyncTaskManager.cxx index b80908ddc5..a570609f8a 100644 --- a/panda/src/event/asyncTaskManager.cxx +++ b/panda/src/event/asyncTaskManager.cxx @@ -643,6 +643,7 @@ void AsyncTaskManager:: make_global_ptr() { nassertv(_global_ptr == nullptr); + init_memory_hook(); _global_ptr = new AsyncTaskManager("TaskManager"); _global_ptr->ref(); } diff --git a/panda/src/event/eventHandler.cxx b/panda/src/event/eventHandler.cxx index f74bd8c519..e3e389e1bf 100644 --- a/panda/src/event/eventHandler.cxx +++ b/panda/src/event/eventHandler.cxx @@ -351,6 +351,7 @@ remove_all_hooks() { */ void EventHandler:: make_global_event_handler() { + init_memory_hook(); _global_event_handler = new EventHandler(EventQueue::get_global_event_queue()); } diff --git a/panda/src/event/eventQueue.cxx b/panda/src/event/eventQueue.cxx index bbd07a3725..69c025734c 100644 --- a/panda/src/event/eventQueue.cxx +++ b/panda/src/event/eventQueue.cxx @@ -106,5 +106,6 @@ dequeue_event() { */ void EventQueue:: make_global_event_queue() { + init_memory_hook(); _global_event_queue = new EventQueue; } diff --git a/panda/src/pipeline/thread.cxx b/panda/src/pipeline/thread.cxx index 351e316033..80c32fa7f5 100644 --- a/panda/src/pipeline/thread.cxx +++ b/panda/src/pipeline/thread.cxx @@ -211,6 +211,7 @@ init_main_thread() { static int count = 0; ++count; if (count == 1 && _main_thread == nullptr) { + init_memory_hook(); _main_thread = new MainThread; _main_thread->ref(); } @@ -222,6 +223,7 @@ init_main_thread() { void Thread:: init_external_thread() { if (_external_thread == nullptr) { + init_memory_hook(); _external_thread = new ExternalThread; _external_thread->ref(); } From eb62d7f2235bd97ab7e59a19cffc79eb48263a97 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 2 Sep 2018 11:49:57 +0200 Subject: [PATCH 166/360] tests: add unit tests for clearing and then peeking texture --- tests/gobj/test_texture.py | 48 +++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/gobj/test_texture.py b/tests/gobj/test_texture.py index 8fa0ed27c8..c16e0732b3 100644 --- a/tests/gobj/test_texture.py +++ b/tests/gobj/test_texture.py @@ -1,5 +1,6 @@ -from panda3d.core import Texture, PNMImage +from panda3d.core import Texture, PNMImage, LColor from array import array +import math def image_from_stored_pixel(component_type, format, data): @@ -15,6 +16,20 @@ def image_from_stored_pixel(component_type, format, data): return img +def peek_tex_with_clear_color(component_type, format, clear_color): + """ Creates a 1-pixel texture with the given settings and clear color, + then peeks the value at this pixel and returns it. """ + + tex = Texture("") + tex.setup_1d_texture(1, component_type, format) + tex.set_clear_color(clear_color) + tex.make_ram_image() + + col = LColor() + tex.peek().fetch_pixel(col, 0, 0) + return col + + def test_texture_store_unsigned_byte(): data = array('B', (2, 1, 0, 0xff)) img = image_from_stored_pixel(Texture.T_unsigned_byte, Texture.F_rgba, data) @@ -88,3 +103,34 @@ def test_texture_store_srgb_alpha(): assert img.maxval == 0xff col = img.get_xel_a(0, 0) assert col.almost_equal((0.5, 0.5, 0.5, 188 / 255.0), 1 / 255.0) + + +def test_texture_clear_unsigned_byte(): + col = peek_tex_with_clear_color(Texture.T_float, Texture.F_rgba, (0, 1 / 255.0, 254 / 255.0, 255.0)) + assert col == LColor(0, 1 / 255.0, 254 / 255.0, 255.0) + + +def test_texture_clear_float(): + col = peek_tex_with_clear_color(Texture.T_float, Texture.F_rgba, (0, 0.25, -0.5, 2)) + assert col == LColor(0, 0.25, -0.5, 2) + + +def test_texture_clear_half(): + col = peek_tex_with_clear_color(Texture.T_half_float, Texture.F_rgba, (0, 0.25, -0.5, 2)) + assert col == LColor(0, 0.25, -0.5, 2) + + # Test edge cases + inf = float('inf') + nan = float('nan') + col = peek_tex_with_clear_color(Texture.T_half_float, Texture.F_rgba, (65504, 65536, inf, nan)) + assert col.x == 65504 + assert col.y == inf + assert col.z == inf + assert math.isnan(col.w) + + # Negative edge case + col = peek_tex_with_clear_color(Texture.T_half_float, Texture.F_rgba, (-65504, -65536, -inf, -nan)) + assert col.x == -65504 + assert col.y == -inf + assert col.z == -inf + assert math.isnan(col.w) From b1f32e3f84d6255b0f11c36140a80c5a88d5c816 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 2 Sep 2018 12:00:30 +0200 Subject: [PATCH 167/360] shader: reserve SL_SPIR_V ShaderLanguage value (as on vulkan branch) --- panda/src/gobj/shader.h | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 99b8d45e53..67906210f6 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -53,6 +53,7 @@ PUBLISHED: SL_Cg, SL_GLSL, SL_HLSL, + SL_SPIR_V, }; enum ShaderType { From 845ec7a990e6c4c6cad6a3761047979c1a470969 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 2 Sep 2018 20:55:18 +0200 Subject: [PATCH 168/360] cull: don't munge_points_to_quads if shader handles point size --- panda/src/pgraph/cullableObject.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index dae73b00ed..920e524659 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -90,6 +90,15 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, geom_rendering = _internal_transform->get_geom_rendering(geom_rendering); unsupported_bits = geom_rendering & ~gsg_bits; + if (unsupported_bits & Geom::GR_per_point_size) { + // If we have a shader that processes the point size, we can assume it + // does the right thing. + const ShaderAttrib *sattr; + if (_state->get_attrib(sattr) && sattr->get_flag(ShaderAttrib::F_shader_point_size)) { + unsupported_bits &= ~Geom::GR_per_point_size; + } + } + if (geom_rendering & Geom::GR_point_bits) { if (geom_reader.get_primitive_type() != Geom::PT_points) { if (singular_points || From 17bf50f1e8d3f136bea14cfdb30346d4aba9c974 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 2 Sep 2018 20:55:58 +0200 Subject: [PATCH 169/360] audio: get_sound and uncache_sound should take Filename, not string --- panda/src/audio/audioManager.h | 4 ++-- panda/src/audio/nullAudioManager.cxx | 4 ++-- panda/src/audio/nullAudioManager.h | 4 ++-- panda/src/audiotraits/fmodAudioManager.cxx | 4 ++-- panda/src/audiotraits/fmodAudioManager.h | 4 ++-- panda/src/audiotraits/milesAudioManager.cxx | 4 ++-- panda/src/audiotraits/milesAudioManager.h | 4 ++-- panda/src/audiotraits/openalAudioManager.cxx | 4 ++-- panda/src/audiotraits/openalAudioManager.h | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index 2ee14f10cb..62d9a5d090 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -86,7 +86,7 @@ PUBLISHED: virtual bool is_valid() = 0; // Get a sound: - virtual PT(AudioSound) get_sound(const std::string& file_name, bool positional = false, int mode=SM_heuristic) = 0; + virtual PT(AudioSound) get_sound(const Filename &file_name, bool positional = false, int mode=SM_heuristic) = 0; virtual PT(AudioSound) get_sound(MovieAudio *source, bool positional = false, int mode=SM_heuristic) = 0; PT(AudioSound) get_null_sound(); @@ -95,7 +95,7 @@ PUBLISHED: // doesn't break any connection between AudioSounds that have already given // by get_sound() from this manager. It's only affecting whether the // AudioManager keeps a copy of the sound in its poolcache. - virtual void uncache_sound(const std::string& file_name) = 0; + virtual void uncache_sound(const Filename &file_name) = 0; virtual void clear_cache() = 0; virtual void set_cache_limit(unsigned int count) = 0; virtual unsigned int get_cache_limit() const = 0; diff --git a/panda/src/audio/nullAudioManager.cxx b/panda/src/audio/nullAudioManager.cxx index dabeb8c825..c9f490e54f 100644 --- a/panda/src/audio/nullAudioManager.cxx +++ b/panda/src/audio/nullAudioManager.cxx @@ -49,7 +49,7 @@ is_valid() { * */ PT(AudioSound) NullAudioManager:: -get_sound(const std::string&, bool positional, int mode) { +get_sound(const Filename &, bool positional, int mode) { return get_null_sound(); } @@ -65,7 +65,7 @@ get_sound(MovieAudio *sound, bool positional, int mode) { * */ void NullAudioManager:: -uncache_sound(const std::string&) { +uncache_sound(const Filename &) { // intentionally blank. } diff --git a/panda/src/audio/nullAudioManager.h b/panda/src/audio/nullAudioManager.h index 9a8ff921e4..a4e2c47511 100644 --- a/panda/src/audio/nullAudioManager.h +++ b/panda/src/audio/nullAudioManager.h @@ -29,9 +29,9 @@ public: virtual bool is_valid(); - virtual PT(AudioSound) get_sound(const std::string&, bool positional = false, int mode=SM_heuristic); + virtual PT(AudioSound) get_sound(const Filename &, bool positional = false, int mode=SM_heuristic); virtual PT(AudioSound) get_sound(MovieAudio *sound, bool positional = false, int mode=SM_heuristic); - virtual void uncache_sound(const std::string&); + virtual void uncache_sound(const Filename &); virtual void clear_cache(); virtual void set_cache_limit(unsigned int); virtual unsigned int get_cache_limit() const; diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 42fd08c536..cdccbfbd0e 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -409,7 +409,7 @@ configure_filters(FilterProperties *config) { * This is what creates a sound instance. */ PT(AudioSound) FmodAudioManager:: -get_sound(const std::string &file_name, bool positional, int) { +get_sound(const Filename &file_name, bool positional, int) { ReMutexHolder holder(_lock); // Needed so People use Panda's Generic UNIX Style Paths for Filename. // path.to_os_specific() converts it back to the proper OS version later on. @@ -772,7 +772,7 @@ reduce_sounds_playing_to(unsigned int count) { * NOT USED FOR FMOD-EX!!! Clears a sound out of the sound cache. */ void FmodAudioManager:: -uncache_sound(const std::string& file_name) { +uncache_sound(const Filename &file_name) { audio_debug("FmodAudioManager::uncache_sound(\""< Date: Sun, 2 Sep 2018 20:59:40 +0200 Subject: [PATCH 170/360] travis: use verbose flag to pytest --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9de0326d78..728367f785 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ install: script: - $PYTHONV makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT $FLAGS --threads 4 - LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV makepanda/test_imports.py - - LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV -m pytest tests + - LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV -m pytest -v tests notifications: irc: channels: From b168fa6a852be045c517be320d64d6e43836b4d7 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 2 Sep 2018 21:02:35 +0200 Subject: [PATCH 171/360] tests: fix erroneous test_texture_clear_unsigned_byte test --- tests/gobj/test_texture.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/gobj/test_texture.py b/tests/gobj/test_texture.py index c16e0732b3..4bf917a8c2 100644 --- a/tests/gobj/test_texture.py +++ b/tests/gobj/test_texture.py @@ -106,8 +106,8 @@ def test_texture_store_srgb_alpha(): def test_texture_clear_unsigned_byte(): - col = peek_tex_with_clear_color(Texture.T_float, Texture.F_rgba, (0, 1 / 255.0, 254 / 255.0, 255.0)) - assert col == LColor(0, 1 / 255.0, 254 / 255.0, 255.0) + col = peek_tex_with_clear_color(Texture.T_unsigned_byte, Texture.F_rgba, (0, 1 / 255.0, 254 / 255.0, 1.0)) + assert col == LColor(0, 1 / 255.0, 254 / 255.0, 1.0) def test_texture_clear_float(): From 8c09477e374bc85ff2c01dfbe48ebb0b11f57622 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 2 Sep 2018 14:33:57 -0600 Subject: [PATCH 172/360] bullet: Add missing includes and declarations for non-composite build --- panda/src/bullet/bulletBodyNode.cxx | 10 +++++++++- panda/src/bullet/bulletBodyNode.h | 4 ++-- panda/src/bullet/bulletBoxShape.cxx | 3 +++ panda/src/bullet/bulletCapsuleShape.cxx | 2 ++ panda/src/bullet/bulletCharacterControllerNode.cxx | 4 ++++ panda/src/bullet/bulletConeShape.cxx | 4 ++++ panda/src/bullet/bulletConeTwistConstraint.cxx | 2 ++ panda/src/bullet/bulletConstraint.cxx | 2 ++ panda/src/bullet/bulletConvexHullShape.cxx | 2 ++ panda/src/bullet/bulletConvexHullShape.h | 1 + panda/src/bullet/bulletConvexPointCloudShape.cxx | 4 ++++ panda/src/bullet/bulletCylinderShape.cxx | 2 ++ panda/src/bullet/bulletDebugNode.cxx | 4 ++++ panda/src/bullet/bulletDebugNode.h | 5 +++++ panda/src/bullet/bulletGenericConstraint.cxx | 2 ++ panda/src/bullet/bulletGhostNode.cxx | 2 ++ panda/src/bullet/bulletHeightfieldShape.cxx | 4 ++++ panda/src/bullet/bulletHelper.cxx | 4 ++++ panda/src/bullet/bulletHelper.h | 2 ++ panda/src/bullet/bulletHingeConstraint.cxx | 2 ++ panda/src/bullet/bulletManifoldPoint.cxx | 2 ++ panda/src/bullet/bulletMinkowskiSumShape.cxx | 2 ++ panda/src/bullet/bulletMultiSphereShape.cxx | 2 ++ panda/src/bullet/bulletMultiSphereShape.h | 1 + panda/src/bullet/bulletPersistentManifold.cxx | 2 ++ panda/src/bullet/bulletPlaneShape.cxx | 2 ++ panda/src/bullet/bulletRigidBodyNode.cxx | 4 ++++ panda/src/bullet/bulletRotationalLimitMotor.cxx | 2 ++ panda/src/bullet/bulletShape.cxx | 3 +++ panda/src/bullet/bulletShape.h | 2 +- panda/src/bullet/bulletSliderConstraint.cxx | 2 ++ panda/src/bullet/bulletSoftBodyConfig.cxx | 4 ++++ panda/src/bullet/bulletSoftBodyConfig.h | 2 ++ panda/src/bullet/bulletSoftBodyMaterial.cxx | 2 ++ panda/src/bullet/bulletSoftBodyMaterial.h | 2 ++ panda/src/bullet/bulletSoftBodyNode.cxx | 2 ++ panda/src/bullet/bulletSoftBodyNode.h | 1 + panda/src/bullet/bulletSoftBodyShape.cxx | 2 ++ panda/src/bullet/bulletSoftBodyWorldInfo.cxx | 2 ++ panda/src/bullet/bulletSphereShape.cxx | 2 ++ panda/src/bullet/bulletSphericalConstraint.cxx | 2 ++ panda/src/bullet/bulletTranslationalLimitMotor.cxx | 2 ++ panda/src/bullet/bulletTriangleMesh.cxx | 3 +++ panda/src/bullet/bulletTriangleMeshShape.cxx | 4 ++++ panda/src/bullet/bulletTriangleMeshShape.h | 1 + panda/src/bullet/bulletVehicle.cxx | 3 +++ panda/src/bullet/bulletWheel.cxx | 2 ++ panda/src/bullet/bulletWorld.cxx | 5 +++++ panda/src/bullet/bullet_utils.h | 2 ++ 49 files changed, 128 insertions(+), 4 deletions(-) diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 9067999599..81a056adc2 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -12,9 +12,17 @@ */ #include "bulletBodyNode.h" + +#include "config_bullet.h" + #include "bulletShape.h" -#include "bulletWorld.h" +#include "bulletBoxShape.h" +#include "bulletCapsuleShape.h" +#include "bulletPlaneShape.h" +#include "bulletSphereShape.h" +#include "bulletTriangleMeshShape.h" #include "bulletTriangleMesh.h" +#include "bulletWorld.h" #include "collisionBox.h" #include "collisionPlane.h" diff --git a/panda/src/bullet/bulletBodyNode.h b/panda/src/bullet/bulletBodyNode.h index 90578eb62b..09f2ffe7c1 100644 --- a/panda/src/bullet/bulletBodyNode.h +++ b/panda/src/bullet/bulletBodyNode.h @@ -16,6 +16,8 @@ #include "pandabase.h" +#include "bulletShape.h" + #include "bullet_includes.h" #include "bullet_utils.h" @@ -25,8 +27,6 @@ #include "transformState.h" #include "boundingSphere.h" -class BulletShape; - /** * */ diff --git a/panda/src/bullet/bulletBoxShape.cxx b/panda/src/bullet/bulletBoxShape.cxx index 1e18d77899..d2d6912605 100644 --- a/panda/src/bullet/bulletBoxShape.cxx +++ b/panda/src/bullet/bulletBoxShape.cxx @@ -12,6 +12,9 @@ */ #include "bulletBoxShape.h" + +#include "bulletWorld.h" + #include "bullet_utils.h" TypeHandle BulletBoxShape::_type_handle; diff --git a/panda/src/bullet/bulletCapsuleShape.cxx b/panda/src/bullet/bulletCapsuleShape.cxx index ba9e02ab83..8ff2b3e37a 100644 --- a/panda/src/bullet/bulletCapsuleShape.cxx +++ b/panda/src/bullet/bulletCapsuleShape.cxx @@ -13,6 +13,8 @@ #include "bulletCapsuleShape.h" +#include "config_bullet.h" + TypeHandle BulletCapsuleShape::_type_handle; /** diff --git a/panda/src/bullet/bulletCharacterControllerNode.cxx b/panda/src/bullet/bulletCharacterControllerNode.cxx index e9652de7e5..44a6137c0a 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.cxx +++ b/panda/src/bullet/bulletCharacterControllerNode.cxx @@ -13,6 +13,10 @@ #include "bulletCharacterControllerNode.h" +#include "config_bullet.h" + +#include "bulletWorld.h" + #if BT_BULLET_VERSION >= 285 static const btVector3 up_vectors[3] = {btVector3(1.0f, 0.0f, 0.0f), btVector3(0.0f, 1.0f, 0.0f), btVector3(0.0f, 0.0f, 1.0f)}; #endif diff --git a/panda/src/bullet/bulletConeShape.cxx b/panda/src/bullet/bulletConeShape.cxx index c4c554ba2f..f9c952402d 100644 --- a/panda/src/bullet/bulletConeShape.cxx +++ b/panda/src/bullet/bulletConeShape.cxx @@ -13,6 +13,10 @@ #include "bulletConeShape.h" +#include "config_bullet.h" + +#include "bulletWorld.h" + TypeHandle BulletConeShape::_type_handle; /** diff --git a/panda/src/bullet/bulletConeTwistConstraint.cxx b/panda/src/bullet/bulletConeTwistConstraint.cxx index 9b60ab31ce..b5ccc17d05 100644 --- a/panda/src/bullet/bulletConeTwistConstraint.cxx +++ b/panda/src/bullet/bulletConeTwistConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletConeTwistConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" #include "deg_2_rad.h" diff --git a/panda/src/bullet/bulletConstraint.cxx b/panda/src/bullet/bulletConstraint.cxx index 28efe703ff..44eddc37e5 100644 --- a/panda/src/bullet/bulletConstraint.cxx +++ b/panda/src/bullet/bulletConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletShape.h" TypeHandle BulletConstraint::_type_handle; diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index 487219c7fd..b61722e773 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -13,6 +13,8 @@ #include "bulletConvexHullShape.h" +#include "bulletWorld.h" + #include "nodePathCollection.h" #include "geomNode.h" #include "geomVertexReader.h" diff --git a/panda/src/bullet/bulletConvexHullShape.h b/panda/src/bullet/bulletConvexHullShape.h index 78485ed12c..27e006f1d0 100644 --- a/panda/src/bullet/bulletConvexHullShape.h +++ b/panda/src/bullet/bulletConvexHullShape.h @@ -22,6 +22,7 @@ #include "luse.h" #include "geom.h" #include "pta_LVecBase3.h" +#include "transformState.h" /** * diff --git a/panda/src/bullet/bulletConvexPointCloudShape.cxx b/panda/src/bullet/bulletConvexPointCloudShape.cxx index 1a4cb6e16c..8b7ca82f79 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.cxx +++ b/panda/src/bullet/bulletConvexPointCloudShape.cxx @@ -13,6 +13,10 @@ #include "bulletConvexPointCloudShape.h" +#include "bulletWorld.h" + +#include "bullet_utils.h" + #include "geomVertexReader.h" TypeHandle BulletConvexPointCloudShape::_type_handle; diff --git a/panda/src/bullet/bulletCylinderShape.cxx b/panda/src/bullet/bulletCylinderShape.cxx index 976daac96e..8b2d7986a3 100644 --- a/panda/src/bullet/bulletCylinderShape.cxx +++ b/panda/src/bullet/bulletCylinderShape.cxx @@ -13,6 +13,8 @@ #include "bulletCylinderShape.h" +#include "config_bullet.h" + using std::endl; TypeHandle BulletCylinderShape::_type_handle; diff --git a/panda/src/bullet/bulletDebugNode.cxx b/panda/src/bullet/bulletDebugNode.cxx index ce0c044758..2f221eb447 100644 --- a/panda/src/bullet/bulletDebugNode.cxx +++ b/panda/src/bullet/bulletDebugNode.cxx @@ -13,6 +13,10 @@ #include "bulletDebugNode.h" +#include "config_bullet.h" + +#include "bulletWorld.h" + #include "cullHandler.h" #include "cullTraverser.h" #include "cullableObject.h" diff --git a/panda/src/bullet/bulletDebugNode.h b/panda/src/bullet/bulletDebugNode.h index c780429a79..f42bd4722d 100644 --- a/panda/src/bullet/bulletDebugNode.h +++ b/panda/src/bullet/bulletDebugNode.h @@ -16,8 +16,13 @@ #include "pandabase.h" +#include "pandaNode.h" + #include "bullet_includes.h" +class CullTraverser; +class CullTraverserData; + /** * */ diff --git a/panda/src/bullet/bulletGenericConstraint.cxx b/panda/src/bullet/bulletGenericConstraint.cxx index de98b5d40b..dfd1fe5b68 100644 --- a/panda/src/bullet/bulletGenericConstraint.cxx +++ b/panda/src/bullet/bulletGenericConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletGenericConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" TypeHandle BulletGenericConstraint::_type_handle; diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index b4008820a1..d3dcb7aaf5 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -12,7 +12,9 @@ */ #include "bulletGhostNode.h" + #include "bulletShape.h" +#include "bulletWorld.h" TypeHandle BulletGhostNode::_type_handle; diff --git a/panda/src/bullet/bulletHeightfieldShape.cxx b/panda/src/bullet/bulletHeightfieldShape.cxx index 15e8d6f75f..08f91bd036 100644 --- a/panda/src/bullet/bulletHeightfieldShape.cxx +++ b/panda/src/bullet/bulletHeightfieldShape.cxx @@ -13,6 +13,10 @@ #include "bulletHeightfieldShape.h" +#include "config_bullet.h" + +#include "bulletWorld.h" + TypeHandle BulletHeightfieldShape::_type_handle; /** diff --git a/panda/src/bullet/bulletHelper.cxx b/panda/src/bullet/bulletHelper.cxx index e786e34d40..fcf0678f1a 100644 --- a/panda/src/bullet/bulletHelper.cxx +++ b/panda/src/bullet/bulletHelper.cxx @@ -12,13 +12,17 @@ */ #include "bulletHelper.h" + #include "bulletRigidBodyNode.h" +#include "bulletSoftBodyNode.h" #include "bulletGhostNode.h" #include "geomLines.h" #include "geomTriangles.h" #include "geomVertexRewriter.h" +#include "bullet_utils.h" + PT(InternalName) BulletHelper::_sb_index; PT(InternalName) BulletHelper::_sb_flip; diff --git a/panda/src/bullet/bulletHelper.h b/panda/src/bullet/bulletHelper.h index f2195d4d92..4633c40928 100644 --- a/panda/src/bullet/bulletHelper.h +++ b/panda/src/bullet/bulletHelper.h @@ -23,6 +23,8 @@ #include "nodePath.h" #include "nodePathCollection.h" +class BulletSoftBodyNode; + /** * */ diff --git a/panda/src/bullet/bulletHingeConstraint.cxx b/panda/src/bullet/bulletHingeConstraint.cxx index 5cbfa44d94..9e96c82cf4 100644 --- a/panda/src/bullet/bulletHingeConstraint.cxx +++ b/panda/src/bullet/bulletHingeConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletHingeConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" #include "deg_2_rad.h" diff --git a/panda/src/bullet/bulletManifoldPoint.cxx b/panda/src/bullet/bulletManifoldPoint.cxx index b56244ed29..c32a437ac2 100644 --- a/panda/src/bullet/bulletManifoldPoint.cxx +++ b/panda/src/bullet/bulletManifoldPoint.cxx @@ -13,6 +13,8 @@ #include "bulletManifoldPoint.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletMinkowskiSumShape.cxx b/panda/src/bullet/bulletMinkowskiSumShape.cxx index d750e22244..586968ae6d 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.cxx +++ b/panda/src/bullet/bulletMinkowskiSumShape.cxx @@ -13,6 +13,8 @@ #include "bulletMinkowskiSumShape.h" +#include "bulletWorld.h" + TypeHandle BulletMinkowskiSumShape::_type_handle; /** diff --git a/panda/src/bullet/bulletMultiSphereShape.cxx b/panda/src/bullet/bulletMultiSphereShape.cxx index 52d1edc42f..2cbf63fcfd 100644 --- a/panda/src/bullet/bulletMultiSphereShape.cxx +++ b/panda/src/bullet/bulletMultiSphereShape.cxx @@ -13,6 +13,8 @@ #include "bulletMultiSphereShape.h" +#include "bulletWorld.h" + #include "geomVertexReader.h" TypeHandle BulletMultiSphereShape::_type_handle; diff --git a/panda/src/bullet/bulletMultiSphereShape.h b/panda/src/bullet/bulletMultiSphereShape.h index d6fd7af7b7..2beb123bf5 100644 --- a/panda/src/bullet/bulletMultiSphereShape.h +++ b/panda/src/bullet/bulletMultiSphereShape.h @@ -19,6 +19,7 @@ #include "bullet_includes.h" #include "bulletShape.h" +#include "factoryParams.h" #include "pta_LVecBase3.h" #include "pta_stdfloat.h" diff --git a/panda/src/bullet/bulletPersistentManifold.cxx b/panda/src/bullet/bulletPersistentManifold.cxx index 67d760e8df..9876ff35ee 100644 --- a/panda/src/bullet/bulletPersistentManifold.cxx +++ b/panda/src/bullet/bulletPersistentManifold.cxx @@ -12,7 +12,9 @@ */ #include "bulletPersistentManifold.h" + #include "bulletManifoldPoint.h" +#include "bulletWorld.h" /** * diff --git a/panda/src/bullet/bulletPlaneShape.cxx b/panda/src/bullet/bulletPlaneShape.cxx index 98dce53577..f5dc9f9514 100644 --- a/panda/src/bullet/bulletPlaneShape.cxx +++ b/panda/src/bullet/bulletPlaneShape.cxx @@ -13,6 +13,8 @@ #include "bulletPlaneShape.h" +#include "bulletWorld.h" + TypeHandle BulletPlaneShape::_type_handle; /** diff --git a/panda/src/bullet/bulletRigidBodyNode.cxx b/panda/src/bullet/bulletRigidBodyNode.cxx index b0d36f705e..6f5bff0d46 100644 --- a/panda/src/bullet/bulletRigidBodyNode.cxx +++ b/panda/src/bullet/bulletRigidBodyNode.cxx @@ -12,7 +12,11 @@ */ #include "bulletRigidBodyNode.h" + +#include "config_bullet.h" + #include "bulletShape.h" +#include "bulletWorld.h" TypeHandle BulletRigidBodyNode::_type_handle; diff --git a/panda/src/bullet/bulletRotationalLimitMotor.cxx b/panda/src/bullet/bulletRotationalLimitMotor.cxx index d521b7ad94..3fed47f4f7 100644 --- a/panda/src/bullet/bulletRotationalLimitMotor.cxx +++ b/panda/src/bullet/bulletRotationalLimitMotor.cxx @@ -13,6 +13,8 @@ #include "bulletRotationalLimitMotor.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletShape.cxx b/panda/src/bullet/bulletShape.cxx index 49bd6e4f92..dcc41f1243 100644 --- a/panda/src/bullet/bulletShape.cxx +++ b/panda/src/bullet/bulletShape.cxx @@ -12,6 +12,9 @@ */ #include "bulletShape.h" + +#include "bulletWorld.h" + #include "bullet_utils.h" TypeHandle BulletShape::_type_handle; diff --git a/panda/src/bullet/bulletShape.h b/panda/src/bullet/bulletShape.h index e9dd08bf14..7b368c987c 100644 --- a/panda/src/bullet/bulletShape.h +++ b/panda/src/bullet/bulletShape.h @@ -18,7 +18,7 @@ #include "bullet_includes.h" -#include "typedReferenceCount.h" +#include "typedWritableReferenceCount.h" #include "boundingSphere.h" /** diff --git a/panda/src/bullet/bulletSliderConstraint.cxx b/panda/src/bullet/bulletSliderConstraint.cxx index c803f509cd..6712120cd8 100644 --- a/panda/src/bullet/bulletSliderConstraint.cxx +++ b/panda/src/bullet/bulletSliderConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletSliderConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" #include "deg_2_rad.h" diff --git a/panda/src/bullet/bulletSoftBodyConfig.cxx b/panda/src/bullet/bulletSoftBodyConfig.cxx index a6db77cb96..861387a397 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.cxx +++ b/panda/src/bullet/bulletSoftBodyConfig.cxx @@ -13,6 +13,10 @@ #include "bulletSoftBodyConfig.h" +#include "bulletWorld.h" + +#include "lightMutexHolder.h" + /** * */ diff --git a/panda/src/bullet/bulletSoftBodyConfig.h b/panda/src/bullet/bulletSoftBodyConfig.h index 18bbd49dfa..3d2bf30e42 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.h +++ b/panda/src/bullet/bulletSoftBodyConfig.h @@ -18,6 +18,8 @@ #include "bullet_includes.h" +#include "numeric_types.h" + /** * */ diff --git a/panda/src/bullet/bulletSoftBodyMaterial.cxx b/panda/src/bullet/bulletSoftBodyMaterial.cxx index d40a7bd984..a7a66a5f62 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.cxx +++ b/panda/src/bullet/bulletSoftBodyMaterial.cxx @@ -13,6 +13,8 @@ #include "bulletSoftBodyMaterial.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletSoftBodyMaterial.h b/panda/src/bullet/bulletSoftBodyMaterial.h index bf8c8589a9..3df77904d8 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.h +++ b/panda/src/bullet/bulletSoftBodyMaterial.h @@ -18,6 +18,8 @@ #include "bullet_includes.h" +#include "numeric_types.h" + /** * */ diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index cf027f208d..f4ae8d2120 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -12,12 +12,14 @@ */ #include "bulletSoftBodyNode.h" + #include "bulletSoftBodyConfig.h" #include "bulletSoftBodyControl.h" #include "bulletSoftBodyMaterial.h" #include "bulletSoftBodyShape.h" #include "bulletSoftBodyWorldInfo.h" #include "bulletHelper.h" +#include "bulletWorld.h" #include "geomVertexRewriter.h" #include "geomVertexReader.h" diff --git a/panda/src/bullet/bulletSoftBodyNode.h b/panda/src/bullet/bulletSoftBodyNode.h index 26d7cc6fce..e19b6c730f 100644 --- a/panda/src/bullet/bulletSoftBodyNode.h +++ b/panda/src/bullet/bulletSoftBodyNode.h @@ -29,6 +29,7 @@ #include "nurbsSurfaceEvaluator.h" #include "pta_LVecBase3.h" +class BulletRigidBodyNode; class BulletSoftBodyConfig; class BulletSoftBodyControl; class BulletSoftBodyMaterial; diff --git a/panda/src/bullet/bulletSoftBodyShape.cxx b/panda/src/bullet/bulletSoftBodyShape.cxx index c6df128687..0f47e470e0 100644 --- a/panda/src/bullet/bulletSoftBodyShape.cxx +++ b/panda/src/bullet/bulletSoftBodyShape.cxx @@ -12,7 +12,9 @@ */ #include "bulletSoftBodyShape.h" + #include "bulletSoftBodyNode.h" +#include "bulletWorld.h" TypeHandle BulletSoftBodyShape::_type_handle; diff --git a/panda/src/bullet/bulletSoftBodyWorldInfo.cxx b/panda/src/bullet/bulletSoftBodyWorldInfo.cxx index 2fb6957c29..eb18b9d6fc 100644 --- a/panda/src/bullet/bulletSoftBodyWorldInfo.cxx +++ b/panda/src/bullet/bulletSoftBodyWorldInfo.cxx @@ -13,6 +13,8 @@ #include "bulletSoftBodyWorldInfo.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletSphereShape.cxx b/panda/src/bullet/bulletSphereShape.cxx index b05e09e418..a2965bb16a 100644 --- a/panda/src/bullet/bulletSphereShape.cxx +++ b/panda/src/bullet/bulletSphereShape.cxx @@ -13,6 +13,8 @@ #include "bulletSphereShape.h" +#include "bulletWorld.h" + TypeHandle BulletSphereShape::_type_handle; /** diff --git a/panda/src/bullet/bulletSphericalConstraint.cxx b/panda/src/bullet/bulletSphericalConstraint.cxx index 8686e1d546..b07d96c649 100644 --- a/panda/src/bullet/bulletSphericalConstraint.cxx +++ b/panda/src/bullet/bulletSphericalConstraint.cxx @@ -12,7 +12,9 @@ */ #include "bulletSphericalConstraint.h" + #include "bulletRigidBodyNode.h" +#include "bulletWorld.h" TypeHandle BulletSphericalConstraint::_type_handle; diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.cxx b/panda/src/bullet/bulletTranslationalLimitMotor.cxx index 48dd7ae3e8..fb5e6b93a4 100644 --- a/panda/src/bullet/bulletTranslationalLimitMotor.cxx +++ b/panda/src/bullet/bulletTranslationalLimitMotor.cxx @@ -13,6 +13,8 @@ #include "bulletTranslationalLimitMotor.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 368aa22fac..ac487be61e 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -13,7 +13,10 @@ #include "bulletTriangleMesh.h" +#include "bulletWorld.h" + #include "pvector.h" +#include "geomTriangles.h" #include "geomVertexData.h" #include "geomVertexReader.h" diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index 8416c52cbc..688bccd478 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -12,7 +12,11 @@ */ #include "bulletTriangleMeshShape.h" + +#include "config_bullet.h" + #include "bulletTriangleMesh.h" +#include "bulletWorld.h" #include "nodePathCollection.h" #include "geomNode.h" diff --git a/panda/src/bullet/bulletTriangleMeshShape.h b/panda/src/bullet/bulletTriangleMeshShape.h index 199efb75d1..fcfb9281a0 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.h +++ b/panda/src/bullet/bulletTriangleMeshShape.h @@ -19,6 +19,7 @@ #include "bullet_includes.h" #include "bulletShape.h" +#include "factoryParams.h" #include "luse.h" class BulletTriangleMesh; diff --git a/panda/src/bullet/bulletVehicle.cxx b/panda/src/bullet/bulletVehicle.cxx index 5dbb70cc7f..f4321cd911 100644 --- a/panda/src/bullet/bulletVehicle.cxx +++ b/panda/src/bullet/bulletVehicle.cxx @@ -12,6 +12,9 @@ */ #include "bulletVehicle.h" + +#include "config_bullet.h" + #include "bulletWorld.h" #include "bulletRigidBodyNode.h" #include "bulletWheel.h" diff --git a/panda/src/bullet/bulletWheel.cxx b/panda/src/bullet/bulletWheel.cxx index c24369546b..21a6eefd76 100644 --- a/panda/src/bullet/bulletWheel.cxx +++ b/panda/src/bullet/bulletWheel.cxx @@ -13,6 +13,8 @@ #include "bulletWheel.h" +#include "bulletWorld.h" + /** * */ diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index e1e416a2bb..930fe10111 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -12,9 +12,14 @@ */ #include "bulletWorld.h" + +#include "config_bullet.h" + +#include "bulletFilterCallbackData.h" #include "bulletPersistentManifold.h" #include "bulletShape.h" #include "bulletSoftBodyWorldInfo.h" +#include "bulletTickCallbackData.h" #include "collideMask.h" #include "lightMutexHolder.h" diff --git a/panda/src/bullet/bullet_utils.h b/panda/src/bullet/bullet_utils.h index b1577ede5e..080c70986a 100644 --- a/panda/src/bullet/bullet_utils.h +++ b/panda/src/bullet/bullet_utils.h @@ -44,6 +44,8 @@ EXPCL_PANDABULLET CPT(TransformState) btTrans_to_TransformState( EXPCL_PANDABULLET btTransform TransformState_to_btTrans( CPT(TransformState) ts); +EXPCL_PANDABULLET void get_node_transform(btTransform &trans, PandaNode *node); + // UpAxis BEGIN_PUBLISH From 5f72e9c763e328dee6fa8591b40d2fa09f58539b Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 2 Sep 2018 15:37:10 -0600 Subject: [PATCH 173/360] bullet: Fix misplaced INLINE getter --- panda/src/bullet/bulletSoftBodyMaterial.I | 9 +++++++++ panda/src/bullet/bulletSoftBodyMaterial.cxx | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/panda/src/bullet/bulletSoftBodyMaterial.I b/panda/src/bullet/bulletSoftBodyMaterial.I index 7514fc7cbf..13326a54d9 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.I +++ b/panda/src/bullet/bulletSoftBodyMaterial.I @@ -30,3 +30,12 @@ empty() { return BulletSoftBodyMaterial(material); } + +/** + * + */ +INLINE btSoftBody::Material &BulletSoftBodyMaterial:: +get_material() const { + + return _material; +} diff --git a/panda/src/bullet/bulletSoftBodyMaterial.cxx b/panda/src/bullet/bulletSoftBodyMaterial.cxx index a7a66a5f62..052cd5a8aa 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.cxx +++ b/panda/src/bullet/bulletSoftBodyMaterial.cxx @@ -23,15 +23,6 @@ BulletSoftBodyMaterial(btSoftBody::Material &material) : _material(material) { } -/** - * - */ -btSoftBody::Material &BulletSoftBodyMaterial:: -get_material() const { - - return _material; -} - /** * Getter for the property m_kLST. */ From e13a4d653984eaaa4d3a30fcb76df9a7d17f085c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 3 Sep 2018 16:10:31 -0600 Subject: [PATCH 174/360] pstatclient: Never pass nullptr to memcpy Even though the only time this happened was when the size was 0, it's still undefined to pass memcpy a nullptr. --- panda/src/pstatclient/pStatClient.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index c69e1ea032..a0ddb2ae38 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -1056,7 +1056,9 @@ add_collector(PStatClient::Collector *collector) { // the lock. int new_collectors_size = (_collectors_size == 0) ? 128 : _collectors_size * 2; CollectorPointer *new_collectors = new CollectorPointer[new_collectors_size]; - memcpy(new_collectors, _collectors, _num_collectors * sizeof(CollectorPointer)); + if (_collectors != nullptr) { + memcpy(new_collectors, _collectors, _num_collectors * sizeof(CollectorPointer)); + } AtomicAdjust::set_ptr(_collectors, new_collectors); AtomicAdjust::set(_collectors_size, new_collectors_size); @@ -1091,7 +1093,9 @@ add_thread(PStatClient::InternalThread *thread) { // the lock. int new_threads_size = (_threads_size == 0) ? 128 : _threads_size * 2; ThreadPointer *new_threads = new ThreadPointer[new_threads_size]; - memcpy(new_threads, _threads, _num_threads * sizeof(ThreadPointer)); + if (_threads != nullptr) { + memcpy(new_threads, _threads, _num_threads * sizeof(ThreadPointer)); + } // We assume that assignment to a pointer and to an int are each atomic. AtomicAdjust::set_ptr(_threads, new_threads); AtomicAdjust::set(_threads_size, new_threads_size); From 217cecb77f434a5b3de1e43411148426f474349c Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 3 Sep 2018 17:40:03 +0200 Subject: [PATCH 175/360] pgui: remove some unnecessary reentrant locking in PGItem --- panda/src/pgui/pgItem.cxx | 49 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index a266547ced..aeff5bff25 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -147,8 +147,8 @@ void PGItem:: transform_changed() { LightReMutexHolder holder(_lock); PandaNode::transform_changed(); - if (has_notify()) { - get_notify()->item_transform_changed(this); + if (_notify != nullptr) { + _notify->item_transform_changed(this); } } @@ -161,8 +161,8 @@ void PGItem:: draw_mask_changed() { LightReMutexHolder holder(_lock); PandaNode::draw_mask_changed(); - if (has_notify()) { - get_notify()->item_draw_mask_changed(this); + if (_notify != nullptr) { + _notify->item_draw_mask_changed(this); } } @@ -530,8 +530,8 @@ enter_region(const MouseWatcherParameter ¶m) { play_sound(event); throw_event(event, EventParameter(ep)); - if (has_notify()) { - get_notify()->item_enter(this, param); + if (_notify != nullptr) { + _notify->item_enter(this, param); } } @@ -554,8 +554,8 @@ exit_region(const MouseWatcherParameter ¶m) { play_sound(event); throw_event(event, EventParameter(ep)); - if (has_notify()) { - get_notify()->item_exit(this, param); + if (_notify != nullptr) { + _notify->item_exit(this, param); } // pgui_cat.info() << get_name() << "::exit()" << endl; @@ -580,8 +580,8 @@ within_region(const MouseWatcherParameter ¶m) { play_sound(event); throw_event(event, EventParameter(ep)); - if (has_notify()) { - get_notify()->item_within(this, param); + if (_notify != nullptr) { + _notify->item_within(this, param); } } @@ -602,8 +602,8 @@ without_region(const MouseWatcherParameter ¶m) { play_sound(event); throw_event(event, EventParameter(ep)); - if (has_notify()) { - get_notify()->item_without(this, param); + if (_notify != nullptr) { + _notify->item_without(this, param); } } @@ -623,8 +623,8 @@ focus_in() { play_sound(event); throw_event(event); - if (has_notify()) { - get_notify()->item_focus_in(this); + if (_notify != nullptr) { + _notify->item_focus_in(this); } } @@ -644,8 +644,8 @@ focus_out() { play_sound(event); throw_event(event); - if (has_notify()) { - get_notify()->item_focus_out(this); + if (_notify != nullptr) { + _notify->item_focus_out(this); } } @@ -673,8 +673,8 @@ press(const MouseWatcherParameter ¶m, bool background) { throw_event(event, EventParameter(ep)); } - if (has_notify()) { - get_notify()->item_press(this, param); + if (_notify != nullptr) { + _notify->item_press(this, param); } } @@ -697,8 +697,8 @@ release(const MouseWatcherParameter ¶m, bool background) { throw_event(event, EventParameter(ep)); } - if (has_notify()) { - get_notify()->item_release(this, param); + if (_notify != nullptr) { + _notify->item_release(this, param); } } @@ -757,8 +757,8 @@ move(const MouseWatcherParameter ¶m) { << *this << "::move(" << param << ")\n"; } - if (has_notify()) { - get_notify()->item_move(this, param); + if (_notify != nullptr) { + _notify->item_move(this, param); } } @@ -1169,9 +1169,10 @@ mouse_to_local(const LPoint2 &mouse_point) const { */ void PGItem:: frame_changed() { + LightReMutexHolder holder(_lock); mark_frames_stale(); - if (has_notify()) { - get_notify()->item_frame_changed(this); + if (_notify != nullptr) { + _notify->item_frame_changed(this); } } From 670047b4b011b27cb918baa2d62eb79fa0421db1 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 4 Sep 2018 11:41:12 +0200 Subject: [PATCH 176/360] dtoolbase: enable use of std::atomic_flag, also on macOS --- dtool/src/dtoolbase/dtoolbase_cc.h | 65 ++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index ff52c6291a..36da6b2b0b 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -49,6 +49,8 @@ // interrogate pass (CPPPARSER isn't defined), this maps to public. #define PUBLISHED __published +#define PHAVE_ATOMIC 1 + typedef int ios_openmode; typedef int ios_fmtflags; typedef int ios_iostate; @@ -93,6 +95,23 @@ typedef std::ios::iostate ios_iostate; typedef std::ios::seekdir ios_seekdir; #endif +#ifdef _MSC_VER +#define ALWAYS_INLINE __forceinline +#elif defined(__GNUC__) +#define ALWAYS_INLINE __attribute__((always_inline)) inline +#else +#define ALWAYS_INLINE inline +#endif + +#ifdef FORCE_INLINING +// If FORCE_INLINING is defined, we use the keyword __forceinline, which tells +// MS VC++ to override its internal benefit heuristic and inline the fn if it +// is technically possible to do so. +#define INLINE ALWAYS_INLINE +#else +#define INLINE inline +#endif + // Apple has an outdated libstdc++. Not all is lost, though, as we can fill // in some important missing functions. #if defined(__GLIBCXX__) && __GLIBCXX__ <= 20070719 @@ -115,24 +134,38 @@ namespace std { } template struct owner_less; + + typedef enum memory_order { + memory_order_relaxed, + memory_order_consume, + memory_order_acquire, + memory_order_release, + memory_order_acq_rel, + memory_order_seq_cst, + } memory_order; + + #define ATOMIC_FLAG_INIT { 0 } + class atomic_flag { + bool _flag; + + public: + atomic_flag() noexcept = default; + ALWAYS_INLINE constexpr atomic_flag(bool flag) noexcept : _flag(flag) {} + atomic_flag(const atomic_flag &) = delete; + ~atomic_flag() noexcept = default; + atomic_flag &operator = (const atomic_flag&) = delete; + + ALWAYS_INLINE bool test_and_set(memory_order order = memory_order_seq_cst) noexcept { + return __atomic_test_and_set(&_flag, order); + } + ALWAYS_INLINE void clear(memory_order order = memory_order_seq_cst) noexcept { + __atomic_clear(&_flag, order); + } + }; }; -#endif - -#ifdef _MSC_VER -#define ALWAYS_INLINE __forceinline -#elif defined(__GNUC__) -#define ALWAYS_INLINE __attribute__((always_inline)) inline #else -#define ALWAYS_INLINE inline -#endif - -#ifdef FORCE_INLINING -// If FORCE_INLINING is defined, we use the keyword __forceinline, which tells -// MS VC++ to override its internal benefit heuristic and inline the fn if it -// is technically possible to do so. -#define INLINE ALWAYS_INLINE -#else -#define INLINE inline +// Expect that we have access to the header. +#define PHAVE_ATOMIC 1 #endif // Determine the availability of C++11 features. From cf4f8b35b689d487c90e7f0d85ccc2dc7db3252d Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 4 Sep 2018 11:45:17 +0200 Subject: [PATCH 177/360] pgui: fix deadlock in PGScrollFrame/PGSliderBar --- panda/src/pgui/pgScrollFrame.cxx | 64 +++++++++++++++++--------------- panda/src/pgui/pgScrollFrame.h | 6 ++- panda/src/pgui/pgVirtualFrame.h | 2 +- 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/panda/src/pgui/pgScrollFrame.cxx b/panda/src/pgui/pgScrollFrame.cxx index a41916d3c9..9631f66685 100644 --- a/panda/src/pgui/pgScrollFrame.cxx +++ b/panda/src/pgui/pgScrollFrame.cxx @@ -19,19 +19,18 @@ TypeHandle PGScrollFrame::_type_handle; * */ PGScrollFrame:: -PGScrollFrame(const std::string &name) : PGVirtualFrame(name) +PGScrollFrame(const std::string &name) : + PGVirtualFrame(name), + _needs_remanage(false), + _needs_recompute_clip(false), + _has_virtual_frame(false), + _virtual_frame(0.0f, 0.0f, 0.0f, 0.0f), + _manage_pieces(false), + _auto_hide(false) { - set_cull_callback(); + _canvas_computed.test_and_set(); - _needs_remanage = false; - _needs_recompute_canvas = false; - _needs_recompute_clip = false; - _has_virtual_frame = false; - _virtual_frame.set(0.0f, 0.0f, 0.0f, 0.0f); - _manage_pieces = false; - _auto_hide = false; - _horizontal_slider = nullptr; - _vertical_slider = nullptr; + set_cull_callback(); } /** @@ -55,8 +54,8 @@ PGScrollFrame(const PGScrollFrame ©) : _auto_hide(copy._auto_hide) { _needs_remanage = false; - _needs_recompute_canvas = true; _needs_recompute_clip = true; + _canvas_computed.clear(); } /** @@ -97,7 +96,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (_needs_recompute_clip) { recompute_clip(); } - if (_needs_recompute_canvas) { + if (!_canvas_computed.test_and_set()) { recompute_canvas(); } return PGVirtualFrame::cull_callback(trav, data); @@ -257,7 +256,7 @@ remanage() { // Showing or hiding one of the scroll bars might have set this flag again // indirectly; we clear it again to avoid a feedback loop. _needs_remanage = false; -} + } // Are either or both of the scroll bars hidden? if (got_horizontal && _horizontal_slider->is_overall_hidden()) { @@ -329,19 +328,20 @@ item_draw_mask_changed(PGItem *) { */ void PGScrollFrame:: slider_bar_adjust(PGSliderBar *) { - LightReMutexHolder holder(_lock); - _needs_recompute_canvas = true; + // Indicate that recompute_canvas() needs to be called. + _canvas_computed.clear(); } /** * Recomputes the clipping window of the PGScrollFrame, based on the position * of the slider bars. + * + * Assumes the lock is held. */ void PGScrollFrame:: recompute_clip() { - LightReMutexHolder holder(_lock); _needs_recompute_clip = false; - _needs_recompute_canvas = true; + _canvas_computed.clear(); // Figure out how to remove the scroll bars from the clip region. LVecBase4 clip = get_frame_style(get_state()).get_internal_frame(get_frame()); @@ -361,34 +361,40 @@ recompute_clip() { /** * Recomputes the portion of the virtual canvas that is visible within the * PGScrollFrame, based on the values of the slider bars. + * + * Assumes the lock is held. */ void PGScrollFrame:: recompute_canvas() { - LightReMutexHolder holder(_lock); - _needs_recompute_canvas = false; + const LVecBase4 &clip = _has_clip_frame ? _clip_frame : get_frame(); - const LVecBase4 &clip = get_clip_frame(); + // Set this to true before we sample the slider bar ratios. + // If slider_bar_adjust happens to get called while we do this, no big deal, + // this method will just be called again next frame. + _canvas_computed.test_and_set(); - PN_stdfloat x = interpolate_canvas(clip[0], clip[1], - _virtual_frame[0], _virtual_frame[1], - _horizontal_slider); + PN_stdfloat cx, cy; + cx = interpolate_canvas(clip[0], clip[1], + _virtual_frame[0], _virtual_frame[1], + _horizontal_slider); - PN_stdfloat y = interpolate_canvas(clip[3], clip[2], - _virtual_frame[3], _virtual_frame[2], - _vertical_slider); + cy = interpolate_canvas(clip[3], clip[2], + _virtual_frame[3], _virtual_frame[2], + _vertical_slider); - get_canvas_node()->set_transform(TransformState::make_pos(LVector3::rfu(x, 0, y))); + _canvas_node->set_transform(TransformState::make_pos(LVector3::rfu(cx, 0, cy))); } /** * Computes the linear translation that should be applied to the virtual * canvas node, based on the corresponding slider bar's position. + * + * Assumes the lock is held. */ PN_stdfloat PGScrollFrame:: interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, PN_stdfloat canvas_min, PN_stdfloat canvas_max, PGSliderBar *slider_bar) { - LightReMutexHolder holder(_lock); PN_stdfloat t = 0.0f; if (slider_bar != nullptr) { t = slider_bar->get_ratio(); diff --git a/panda/src/pgui/pgScrollFrame.h b/panda/src/pgui/pgScrollFrame.h index de01954e0d..bb8b3a3af3 100644 --- a/panda/src/pgui/pgScrollFrame.h +++ b/panda/src/pgui/pgScrollFrame.h @@ -20,6 +20,10 @@ #include "pgSliderBarNotify.h" #include "pgSliderBar.h" +#ifdef PHAVE_ATOMIC +#include +#endif + /** * This is a special kind of frame that pretends to be much larger than it * actually is. You can scroll through the frame, as if you're looking @@ -92,7 +96,7 @@ private: private: bool _needs_remanage; bool _needs_recompute_clip; - bool _needs_recompute_canvas; + std::atomic_flag _canvas_computed; bool _has_virtual_frame; LVecBase4 _virtual_frame; diff --git a/panda/src/pgui/pgVirtualFrame.h b/panda/src/pgui/pgVirtualFrame.h index c8aff4fca6..d284b08ab0 100644 --- a/panda/src/pgui/pgVirtualFrame.h +++ b/panda/src/pgui/pgVirtualFrame.h @@ -72,7 +72,7 @@ protected: private: void setup_child_nodes(); -private: +protected: bool _has_clip_frame; LVecBase4 _clip_frame; From 171ba35f2693142e826df3d39e970df586d980b2 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 4 Sep 2018 11:47:27 +0200 Subject: [PATCH 178/360] tests: add some simple smoke tests for Mutex and ReMutex --- tests/pipeline/test_mutex.py | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/pipeline/test_mutex.py diff --git a/tests/pipeline/test_mutex.py b/tests/pipeline/test_mutex.py new file mode 100644 index 0000000000..e930e90e02 --- /dev/null +++ b/tests/pipeline/test_mutex.py @@ -0,0 +1,54 @@ +from panda3d.core import Mutex, ReMutex + + +def test_mutex_acquire_release(): + m = Mutex() + m.acquire() + + # Assert that the lock is truly held now + assert not m.try_acquire() + + # Release the lock + m.release() + + # Make sure the lock is properly released + assert m.try_acquire() + + # Clean up + m.release() + + +def test_mutex_try_acquire(): + m = Mutex() + + # Trying to acquire the lock should succeed + assert m.try_acquire() + + # Assert that the lock is truly held now + assert not m.try_acquire() + + # Clean up + m.release() + + +def test_remutex_acquire_release(): + m = ReMutex() + m.acquire() + m.acquire() + m.release() + m.release() + + +def test_remutex_try_acquire(): + m = ReMutex() + + # Trying to acquire the lock should succeed + assert m.try_acquire() + + # Trying a second time should succeed + assert m.try_acquire() + + # Clean up + m.release() + m.release() + From 809f9b04f65865348bf8bb680da6a8a52be6d01d Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 4 Sep 2018 11:53:27 +0200 Subject: [PATCH 179/360] Fix problems with spinlock mutex/cvar implementation This reimplements the spinlock on top of std::atomic_flag, which is guaranteed to be lockless. It also inserts the PAUSE (REP NOP) instruction which is strongly recommended to be placed in busy-wait loops by Intel. This also includes a recursive spinlock implementation. The spinlock implementation is disabled by default, but can be enabled by adding the --override MUTEX_SPINLOCK=1 flag to makepanda. --- dtool/src/dtoolbase/mutexSpinlockImpl.I | 11 +--- dtool/src/dtoolbase/mutexSpinlockImpl.cxx | 11 +++- dtool/src/dtoolbase/mutexSpinlockImpl.h | 8 ++- makepanda/makepanda.py | 1 + .../src/pipeline/conditionVarSpinlockImpl.cxx | 31 +++++++++- panda/src/pipeline/conditionVarSpinlockImpl.h | 1 + panda/src/pipeline/lightReMutexDirect.I | 15 ----- panda/src/pipeline/lightReMutexDirect.h | 4 +- panda/src/pipeline/mutexTrueImpl.h | 7 +++ panda/src/pipeline/p3pipeline_composite2.cxx | 1 + panda/src/pipeline/reMutexDirect.I | 12 ++++ panda/src/pipeline/reMutexDirect.cxx | 4 +- panda/src/pipeline/reMutexDirect.h | 4 +- panda/src/pipeline/reMutexSpinlockImpl.I | 23 ++++++++ panda/src/pipeline/reMutexSpinlockImpl.cxx | 57 +++++++++++++++++++ panda/src/pipeline/reMutexSpinlockImpl.h | 54 ++++++++++++++++++ 16 files changed, 208 insertions(+), 36 deletions(-) create mode 100644 panda/src/pipeline/reMutexSpinlockImpl.I create mode 100644 panda/src/pipeline/reMutexSpinlockImpl.cxx create mode 100644 panda/src/pipeline/reMutexSpinlockImpl.h diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.I b/dtool/src/dtoolbase/mutexSpinlockImpl.I index b3eb084181..53ce89445f 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.I +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.I @@ -11,13 +11,6 @@ * @date 2006-04-11 */ -/** - * - */ -constexpr MutexSpinlockImpl:: -MutexSpinlockImpl() : _lock(0) { -} - /** * */ @@ -33,7 +26,7 @@ lock() { */ INLINE bool MutexSpinlockImpl:: try_lock() { - return (AtomicAdjust::compare_and_exchange(_lock, 0, 1) == 0); + return !_flag.test_and_set(std::memory_order_acquire); } /** @@ -41,5 +34,5 @@ try_lock() { */ INLINE void MutexSpinlockImpl:: unlock() { - AtomicAdjust::set(_lock, 0); + _flag.clear(std::memory_order_release); } diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.cxx b/dtool/src/dtoolbase/mutexSpinlockImpl.cxx index 32a84fa28f..73f2683ff2 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.cxx +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.cxx @@ -17,12 +17,21 @@ #include "mutexSpinlockImpl.h" +#if defined(__i386__) || defined(__x86_64) || defined(_M_IX86) || defined(_M_X64) +#include +#define PAUSE() _mm_pause() +#else +#define PAUSE() +#endif + /** * */ void MutexSpinlockImpl:: do_lock() { - while (AtomicAdjust::compare_and_exchange(_lock, 0, 1) != 0) { + // Loop until we changed the flag from 0 to 1 (and it wasn't already 1). + while (_flag.test_and_set(std::memory_order_acquire)) { + PAUSE(); } } diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.h b/dtool/src/dtoolbase/mutexSpinlockImpl.h index c7dfb72cf2..cd858f5551 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.h +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.h @@ -19,7 +19,9 @@ #ifdef MUTEX_SPINLOCK -#include "atomicAdjust.h" +#ifdef PHAVE_ATOMIC +#include +#endif /** * Uses a simple user-space spinlock to implement a mutex. It is usually not @@ -29,7 +31,7 @@ */ class EXPCL_DTOOL_DTOOLBASE MutexSpinlockImpl { public: - constexpr MutexSpinlockImpl(); + constexpr MutexSpinlockImpl() noexcept = default; MutexSpinlockImpl(const MutexSpinlockImpl ©) = delete; MutexSpinlockImpl &operator = (const MutexSpinlockImpl ©) = delete; @@ -42,7 +44,7 @@ public: private: void do_lock(); - TVOLATILE AtomicAdjust::Integer _lock; + std::atomic_flag _flag = ATOMIC_FLAG_INIT; }; #include "mutexSpinlockImpl.I" diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 00dd2c3cd3..e371fbd3e8 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2271,6 +2271,7 @@ DTOOL_CONFIG=[ ("OS_SIMPLE_THREADS", '1', '1'), ("DEBUG_THREADS", 'UNDEF', 'UNDEF'), ("HAVE_POSIX_THREADS", 'UNDEF', '1'), + ("MUTEX_SPINLOCK", 'UNDEF', 'UNDEF'), ("HAVE_AUDIO", '1', '1'), ("NOTIFY_DEBUG", 'UNDEF', 'UNDEF'), ("DO_PSTATS", 'UNDEF', 'UNDEF'), diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.cxx b/panda/src/pipeline/conditionVarSpinlockImpl.cxx index f36bc83125..d35d8cd1f7 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.cxx +++ b/panda/src/pipeline/conditionVarSpinlockImpl.cxx @@ -16,6 +16,14 @@ #ifdef MUTEX_SPINLOCK #include "conditionVarSpinlockImpl.h" +#include "trueClock.h" + +#if defined(__i386__) || defined(__x86_64) || defined(_M_IX86) || defined(_M_X64) +#include +#define PAUSE() _mm_pause() +#else +#define PAUSE() +#endif /** * @@ -23,12 +31,31 @@ void ConditionVarSpinlockImpl:: wait() { AtomicAdjust::Integer current = _event; - _mutex.release(); + _mutex.unlock(); while (AtomicAdjust::get(_event) == current) { + PAUSE(); } - _mutex.acquire(); + _mutex.lock(); +} + +/** + * + */ +void ConditionVarSpinlockImpl:: +wait(double timeout) { + TrueClock *clock = TrueClock::get_global_ptr(); + double end_time = clock->get_short_time() + timeout; + + AtomicAdjust::Integer current = _event; + _mutex.unlock(); + + while (AtomicAdjust::get(_event) == current && clock->get_short_time() < end_time) { + PAUSE(); + } + + _mutex.lock(); } #endif // MUTEX_SPINLOCK diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.h b/panda/src/pipeline/conditionVarSpinlockImpl.h index 5d8da7bbf7..34b61645f8 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.h +++ b/panda/src/pipeline/conditionVarSpinlockImpl.h @@ -37,6 +37,7 @@ public: INLINE ~ConditionVarSpinlockImpl(); void wait(); + void wait(double timeout); INLINE void notify(); INLINE void notify_all(); diff --git a/panda/src/pipeline/lightReMutexDirect.I b/panda/src/pipeline/lightReMutexDirect.I index 08bb0daa67..8484092ecc 100644 --- a/panda/src/pipeline/lightReMutexDirect.I +++ b/panda/src/pipeline/lightReMutexDirect.I @@ -11,21 +11,6 @@ * @date 2008-10-08 */ -/** - * - */ -INLINE LightReMutexDirect:: -LightReMutexDirect() -#ifndef HAVE_REMUTEXIMPL - : _cvar_impl(_lock_impl) -#endif -{ -#ifndef HAVE_REMUTEXIMPL - _locking_thread = nullptr; - _lock_count = 0; -#endif -} - /** * Alias for acquire() to match C++11 semantics. * @see acquire() diff --git a/panda/src/pipeline/lightReMutexDirect.h b/panda/src/pipeline/lightReMutexDirect.h index 56371cc443..d1bc022740 100644 --- a/panda/src/pipeline/lightReMutexDirect.h +++ b/panda/src/pipeline/lightReMutexDirect.h @@ -29,7 +29,7 @@ class Thread; */ class EXPCL_PANDA_PIPELINE LightReMutexDirect { protected: - INLINE LightReMutexDirect(); + LightReMutexDirect() = default; LightReMutexDirect(const LightReMutexDirect ©) = delete; ~LightReMutexDirect() = default; @@ -57,7 +57,7 @@ PUBLISHED: private: #ifdef HAVE_REMUTEXTRUEIMPL - mutable ReMutexImpl _impl; + mutable ReMutexTrueImpl _impl; #else // If we don't have a reentrant mutex, use the one we hand-rolled in diff --git a/panda/src/pipeline/mutexTrueImpl.h b/panda/src/pipeline/mutexTrueImpl.h index 2366159a38..5a4850a4a0 100644 --- a/panda/src/pipeline/mutexTrueImpl.h +++ b/panda/src/pipeline/mutexTrueImpl.h @@ -43,6 +43,13 @@ typedef MutexImpl MutexTrueImpl; #if HAVE_REMUTEXIMPL typedef ReMutexImpl ReMutexTrueImpl; #define HAVE_REMUTEXTRUEIMPL 1 + +#elif MUTEX_SPINLOCK +// This is defined here because it needs code from pipeline. +#include "reMutexSpinlockImpl.h" +typedef ReMutexSpinlockImpl ReMutexTrueImpl; +#define HAVE_REMUTEXTRUEIMPL 1 + #else #undef HAVE_REMUTEXTRUEIMPL #endif // HAVE_REMUTEXIMPL diff --git a/panda/src/pipeline/p3pipeline_composite2.cxx b/panda/src/pipeline/p3pipeline_composite2.cxx index e6607a6ebf..e9e928ee4c 100644 --- a/panda/src/pipeline/p3pipeline_composite2.cxx +++ b/panda/src/pipeline/p3pipeline_composite2.cxx @@ -13,6 +13,7 @@ #include "reMutex.cxx" #include "reMutexDirect.cxx" #include "reMutexHolder.cxx" +#include "reMutexSpinlockImpl.cxx" #include "thread.cxx" #include "threadDummyImpl.cxx" #include "threadPosixImpl.cxx" diff --git a/panda/src/pipeline/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I index 0785473e7c..e7fa3a6fce 100644 --- a/panda/src/pipeline/reMutexDirect.I +++ b/panda/src/pipeline/reMutexDirect.I @@ -33,7 +33,11 @@ ReMutexDirect() INLINE void ReMutexDirect:: lock() { TAU_PROFILE("void ReMutexDirect::acquire()", " ", TAU_USER); +#ifdef HAVE_REMUTEXTRUEIMPL _impl.lock(); +#else + ((ReMutexDirect *)this)->do_lock(); +#endif // HAVE_REMUTEXTRUEIMPL } /** @@ -43,7 +47,11 @@ lock() { INLINE bool ReMutexDirect:: try_lock() { TAU_PROFILE("void ReMutexDirect::try_acquire()", " ", TAU_USER); +#ifdef HAVE_REMUTEXTRUEIMPL return _impl.try_lock(); +#else + return ((ReMutexDirect *)this)->do_try_lock(); +#endif // HAVE_REMUTEXTRUEIMPL } /** @@ -53,7 +61,11 @@ try_lock() { INLINE void ReMutexDirect:: unlock() { TAU_PROFILE("void ReMutexDirect::unlock()", " ", TAU_USER); +#ifdef HAVE_REMUTEXTRUEIMPL _impl.unlock(); +#else + ((ReMutexDirect *)this)->do_unlock(); +#endif // HAVE_REMUTEXTRUEIMPL } /** diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index 7bfdcb8f8d..f6cd59e4de 100644 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -141,11 +141,11 @@ do_elevate_lock() { * mutex). */ void ReMutexDirect:: -do_unlock() { +do_unlock(Thread *current_thread) { _lock_impl.lock(); #ifdef _DEBUG - if (_locking_thread != Thread::get_current_thread()) { + if (_locking_thread != current_thread) { std::ostringstream ostr; ostr << *_locking_thread << " attempted to release " << *this << " which it does not own"; diff --git a/panda/src/pipeline/reMutexDirect.h b/panda/src/pipeline/reMutexDirect.h index b6f5215319..faf46d0fb0 100644 --- a/panda/src/pipeline/reMutexDirect.h +++ b/panda/src/pipeline/reMutexDirect.h @@ -59,7 +59,7 @@ PUBLISHED: private: #ifdef HAVE_REMUTEXTRUEIMPL - mutable ReMutexImpl _impl; + mutable ReMutexTrueImpl _impl; #else // If we don't have a reentrant mutex, we have to hand-roll one. @@ -68,7 +68,7 @@ private: INLINE bool do_try_lock(); bool do_try_lock(Thread *current_thread); void do_elevate_lock(); - void do_unlock(); + void do_unlock(Thread *current_thread = Thread::get_current_thread()); Thread *_locking_thread; int _lock_count; diff --git a/panda/src/pipeline/reMutexSpinlockImpl.I b/panda/src/pipeline/reMutexSpinlockImpl.I new file mode 100644 index 0000000000..5f5e2d89c3 --- /dev/null +++ b/panda/src/pipeline/reMutexSpinlockImpl.I @@ -0,0 +1,23 @@ +/** + * 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." + * + * @file reMutexSpinlockImpl.I + * @author rdb + * @date 2018-09-03 + */ + +/** + * + */ +INLINE void ReMutexSpinlockImpl:: +unlock() { + assert(_counter > 0); + if (!--_counter) { + AtomicAdjust::set_ptr(_locking_thread, nullptr); + } +} diff --git a/panda/src/pipeline/reMutexSpinlockImpl.cxx b/panda/src/pipeline/reMutexSpinlockImpl.cxx new file mode 100644 index 0000000000..0de12f986f --- /dev/null +++ b/panda/src/pipeline/reMutexSpinlockImpl.cxx @@ -0,0 +1,57 @@ +/** + * 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." + * + * @file reMutexSpinlockImpl.cxx + * @author rdb + * @date 2018-09-03 + */ + +#include "selectThreadImpl.h" + +#ifdef MUTEX_SPINLOCK + +#include "reMutexSpinlockImpl.h" +#include "thread.h" + +#if defined(__i386__) || defined(__x86_64) || defined(_M_IX86) || defined(_M_X64) +#include +#define PAUSE() _mm_pause() +#else +#define PAUSE() +#endif + +/** + * + */ +void ReMutexSpinlockImpl:: +lock() { + Thread *current_thread = Thread::get_current_thread(); + Thread *locking_thread = (Thread *)AtomicAdjust::compare_and_exchange_ptr(_locking_thread, nullptr, current_thread); + while (locking_thread != nullptr && locking_thread != current_thread) { + PAUSE(); + locking_thread = (Thread *)AtomicAdjust::compare_and_exchange_ptr(_locking_thread, nullptr, current_thread); + } + ++_counter; +} + +/** + * + */ +bool ReMutexSpinlockImpl:: +try_lock() { + Thread *current_thread = Thread::get_current_thread(); + Thread *locking_thread = (Thread *)AtomicAdjust::compare_and_exchange_ptr(_locking_thread, nullptr, current_thread); + if (locking_thread == nullptr || locking_thread == current_thread) { + ++_counter; + return true; + } else { + return false; + } +} + +#endif // MUTEX_SPINLOCK diff --git a/panda/src/pipeline/reMutexSpinlockImpl.h b/panda/src/pipeline/reMutexSpinlockImpl.h new file mode 100644 index 0000000000..666ed832e3 --- /dev/null +++ b/panda/src/pipeline/reMutexSpinlockImpl.h @@ -0,0 +1,54 @@ +/** + * 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." + * + * @file reMutexSpinlockImpl.h + * @author rdb + * @date 2018-09-03 + */ + +#ifndef REMUTEXSPINLOCKIMPL_H +#define REMUTEXSPINLOCKIMPL_H + +#include "dtoolbase.h" +#include "selectThreadImpl.h" + +#ifdef MUTEX_SPINLOCK + +#include "atomicAdjust.h" + +class Thread; + +/** + * Uses a simple user-space spinlock to implement a mutex. It is usually not + * a good idea to use this implementation, unless you are building Panda for a + * specific application on a specific SMP machine, and you are confident that + * you have at least as many CPU's as you have threads. + */ +class EXPCL_PANDA_PIPELINE ReMutexSpinlockImpl { +public: + constexpr ReMutexSpinlockImpl() noexcept = default; + ReMutexSpinlockImpl(const ReMutexSpinlockImpl ©) = delete; + + ReMutexSpinlockImpl &operator = (const ReMutexSpinlockImpl ©) = delete; + +public: + void lock(); + bool try_lock(); + INLINE void unlock(); + +private: + AtomicAdjust::Pointer _locking_thread = nullptr; + unsigned int _counter = 0; +}; + + +#include "reMutexSpinlockImpl.I" + +#endif // MUTEX_SPINLOCK + +#endif From 11ecd3af87d4d25d41eb447f559075d191710c79 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 4 Sep 2018 12:01:34 +0200 Subject: [PATCH 180/360] putil: make ButtonHandle::none() constexpr --- panda/src/putil/buttonHandle.I | 9 --------- panda/src/putil/buttonHandle.cxx | 3 --- panda/src/putil/buttonHandle.h | 3 +-- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/panda/src/putil/buttonHandle.I b/panda/src/putil/buttonHandle.I index c45145dd40..55edc7f61a 100644 --- a/panda/src/putil/buttonHandle.I +++ b/panda/src/putil/buttonHandle.I @@ -137,15 +137,6 @@ output(std::ostream &out) const { out << get_name(); } -/** - * Returns a special zero-valued ButtonHandle that is used to indicate no - * button. - */ -INLINE ButtonHandle ButtonHandle:: -none() { - return _none; -} - /** * ButtonHandle::none() evaluates to false, everything else evaluates to true. */ diff --git a/panda/src/putil/buttonHandle.cxx b/panda/src/putil/buttonHandle.cxx index 831a3daddd..4ce3cd5a91 100644 --- a/panda/src/putil/buttonHandle.cxx +++ b/panda/src/putil/buttonHandle.cxx @@ -14,9 +14,6 @@ #include "buttonHandle.h" #include "buttonRegistry.h" -// This is initialized to zero by static initialization. -ButtonHandle ButtonHandle::_none; - TypeHandle ButtonHandle::_type_handle; /** diff --git a/panda/src/putil/buttonHandle.h b/panda/src/putil/buttonHandle.h index ad43ad2a86..6e9dd9a40f 100644 --- a/panda/src/putil/buttonHandle.h +++ b/panda/src/putil/buttonHandle.h @@ -53,7 +53,7 @@ PUBLISHED: constexpr int get_index() const; INLINE void output(std::ostream &out) const; - INLINE static ButtonHandle none(); + constexpr static ButtonHandle none() { return ButtonHandle(0); } INLINE operator bool () const; @@ -65,7 +65,6 @@ PUBLISHED: private: int _index; - static ButtonHandle _none; public: static TypeHandle get_class_type() { From 1a94e65b17d6dad33e8f0adc8f85eae5ef999e5d Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 4 Sep 2018 23:01:41 +0200 Subject: [PATCH 181/360] tests: fix mutex test on win32 where mutexes are always reentrant --- tests/pipeline/test_mutex.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/pipeline/test_mutex.py b/tests/pipeline/test_mutex.py index e930e90e02..2073c09efa 100644 --- a/tests/pipeline/test_mutex.py +++ b/tests/pipeline/test_mutex.py @@ -6,7 +6,7 @@ def test_mutex_acquire_release(): m.acquire() # Assert that the lock is truly held now - assert not m.try_acquire() + assert m.debug_is_locked() # Release the lock m.release() @@ -25,7 +25,7 @@ def test_mutex_try_acquire(): assert m.try_acquire() # Assert that the lock is truly held now - assert not m.try_acquire() + assert m.debug_is_locked() # Clean up m.release() @@ -45,9 +45,15 @@ def test_remutex_try_acquire(): # Trying to acquire the lock should succeed assert m.try_acquire() + # Should report being locked + assert m.debug_is_locked() + # Trying a second time should succeed assert m.try_acquire() + # Should still report being locked + assert m.debug_is_locked() + # Clean up m.release() m.release() From cb9e65720a27ca654ba1c8fc4f10d01f1cde78b5 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 9 Sep 2018 13:45:12 +0200 Subject: [PATCH 182/360] interrogate: do not use MOVE in generated code, but use std::move --- dtool/src/interrogate/functionRemap.cxx | 5 ++--- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 4 ++-- dtool/src/interrogate/parameterRemapConcreteToPointer.cxx | 2 +- dtool/src/interrogate/parameterRemapReferenceToPointer.cxx | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index e7a2f828d9..9836a23bfc 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -254,14 +254,13 @@ call_function(ostream &out, int indent_level, bool convert_result, &parser); out << " = " << call << ";\n"; - // MOVE() expands to std::move() when we are compiling with a compiler - // that supports rvalue references. It basically turns an lvalue into + // Use of the C++11 std::move function basically turns an lvalue into // an rvalue, allowing a move constructor to be called instead of a // copy constructor (since we won't be using the return value any // more), which is usually more efficient if it exists. If it // doesn't, it shouldn't do any harm. string new_str = - _return_type->prepare_return_expr(out, indent_level, "MOVE(result)"); + _return_type->prepare_return_expr(out, indent_level, "std::move(result)"); return_expr = _return_type->get_return_expr(new_str); } else { diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 5752fe126b..8d2b0f2288 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -5491,7 +5491,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, // Use move constructor when available for functions that take an // actual PointerTo. This eliminates an unref()ref() pair. - pexpr_string = "MOVE(" + param_name + "_this)"; + pexpr_string = "std::move(" + param_name + "_this)"; } else { // This is a move-assignable type, such as TypeHandle or LVecBase4. @@ -6156,7 +6156,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, indent(out, indent_level) << "return true;\n"; } else if (TypeManager::is_reference_count(remap->_cpptype)) { - indent(out, indent_level) << "coerced = MOVE(" << return_expr << ");\n"; + indent(out, indent_level) << "coerced = std::move(" << return_expr << ");\n"; indent(out, indent_level) << "return true;\n"; } else { diff --git a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx index f5e7c35b39..9f217076cb 100644 --- a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx @@ -40,7 +40,7 @@ pass_parameter(std::ostream &out, const std::string &variable_name) { if (variable_name.size() > 1 && variable_name[0] == '&') { // Prevent generating something like *¶m Also, if this is really some // local type, we can presumably just move it? - out << "MOVE(" << variable_name.substr(1) << ")"; + out << "std::move(" << variable_name.substr(1) << ")"; } else { out << "*" << variable_name; } diff --git a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx index 6c8e8b05a9..4e8d1fad90 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx @@ -42,7 +42,7 @@ pass_parameter(std::ostream &out, const std::string &variable_name) { // this parameter is an rvalue reference, but CPPParser can't know that, // and it might have an overload that takes an rvalue reference. It // shouldn't hurt either way. - out << "MOVE(" << variable_name.substr(1) << ")"; + out << "std::move(" << variable_name.substr(1) << ")"; } else { out << "*" << variable_name; } From a333353af61ffb83000596953beaffda92996fa2 Mon Sep 17 00:00:00 2001 From: jspam Date: Thu, 6 Sep 2018 17:21:03 +0200 Subject: [PATCH 183/360] Make Loader.loadSound() accept a MovieAudio instance as soundPath This functionality seems to have inadvertently been removed by refactoring commit 23bf9ea5. Closes #383 --- direct/src/showbase/Loader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/direct/src/showbase/Loader.py b/direct/src/showbase/Loader.py index 17c9cea25e..924b396616 100644 --- a/direct/src/showbase/Loader.py +++ b/direct/src/showbase/Loader.py @@ -934,8 +934,8 @@ class Loader(DirectObject): just as in loadModel(); otherwise, the loading happens before loadSound() returns.""" - if not isinstance(soundPath, (MovieAudio, tuple, list, set)): - # We were given a single sound pathname. + if not isinstance(soundPath, (tuple, list, set)): + # We were given a single sound pathname or a MovieAudio instance. soundList = [soundPath] gotList = False else: From b183e9969221b46d5cfad73459884b5247a09b86 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 9 Sep 2018 20:23:48 +0200 Subject: [PATCH 184/360] gobj: fix bug printing Material base color --- panda/src/gobj/material.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/gobj/material.cxx b/panda/src/gobj/material.cxx index 24bc0fb590..091c7eff2f 100644 --- a/panda/src/gobj/material.cxx +++ b/panda/src/gobj/material.cxx @@ -422,7 +422,7 @@ void Material:: write(std::ostream &out, int indent_level) const { indent(out, indent_level) << "Material " << get_name() << "\n"; if (has_base_color()) { - indent(out, indent_level + 2) << "base_color = " << get_ambient() << "\n"; + indent(out, indent_level + 2) << "base_color = " << get_base_color() << "\n"; } if (has_ambient()) { indent(out, indent_level + 2) << "ambient = " << get_ambient() << "\n"; From 47496068d33de66ea479168b78501305bf63fe49 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 9 Sep 2018 20:56:37 +0200 Subject: [PATCH 185/360] Show materials with only base color applied properly --- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 6 +++--- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 2 +- panda/src/pgraphnodes/shaderGenerator.cxx | 5 +++++ panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 0e5687d490..0921350629 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -3463,7 +3463,7 @@ do_issue_material() { cur_material.Emissive = *(D3DCOLORVALUE *)(color.get_data()); cur_material.Power = material->get_shininess(); - if (material->has_diffuse()) { + if (material->has_diffuse() || material->has_base_color()) { // If the material specifies an diffuse color, use it. set_render_state(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); } else { @@ -3476,7 +3476,7 @@ do_issue_material() { set_render_state(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1); } } - if (material->has_ambient()) { + if (material->has_ambient() || material->has_base_color()) { // If the material specifies an ambient color, use it. set_render_state(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL); } else { @@ -3490,7 +3490,7 @@ do_issue_material() { } } - if (material->has_specular()) { + if (material->has_specular() || material->has_base_color()) { set_render_state(D3DRS_SPECULARENABLE, TRUE); } else { set_render_state(D3DRS_SPECULARENABLE, FALSE); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index fb22fdb644..48b9112387 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -7627,7 +7627,7 @@ do_issue_material() { call_glMaterialfv(face, GL_EMISSION, material->get_emission()); glMaterialf(face, GL_SHININESS, max(min(material->get_shininess(), (PN_stdfloat)128), (PN_stdfloat)0)); - if (material->has_ambient() && material->has_diffuse()) { + if ((material->has_ambient() && material->has_diffuse()) || material->has_base_color()) { // The material has both an ambient and diffuse specified. This means we // do not need glMaterialColor(). glDisable(GL_COLOR_MATERIAL); diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index f52d0f4579..d954ddcafc 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -258,6 +258,11 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { // states to be rehashed. mat->mark_used_by_auto_shader(); key._material_flags = mat->get_flags(); + + if ((key._material_flags & Material::F_base_color) != 0) { + key._material_flags |= (Material::F_diffuse | Material::F_specular | Material::F_ambient); + key._material_flags &= ~Material::F_base_color; + } } // Break out the lights by type. diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 8f49433ebd..fd3c44c917 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -2951,7 +2951,7 @@ setup_material(GLMaterial *gl_material, const Material *material) { _color_material_flags = CMF_ambient | CMF_diffuse; - if (material->has_ambient()) { + if (material->has_ambient() || material->has_base_color()) { const LColor &ambient = material->get_ambient(); gl_material->ambient.v[0] = ambient[0]; gl_material->ambient.v[1] = ambient[1]; @@ -2961,7 +2961,7 @@ setup_material(GLMaterial *gl_material, const Material *material) { _color_material_flags &= ~CMF_ambient; } - if (material->has_diffuse()) { + if (material->has_diffuse() || material->has_base_color()) { const LColor &diffuse = material->get_diffuse(); gl_material->diffuse.v[0] = diffuse[0]; gl_material->diffuse.v[1] = diffuse[1]; From ecb2b6f546ee9efd7bc0d8c38f8685b457cb672d Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 13 Sep 2018 20:23:14 +0200 Subject: [PATCH 186/360] movies: forbid automatic coercion from string to MovieAudio This was causing issues in the unit test when calling audiomgr.get_sound() with string. --- panda/src/movies/movieAudio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/movies/movieAudio.h b/panda/src/movies/movieAudio.h index cce8eb3465..819f501e35 100644 --- a/panda/src/movies/movieAudio.h +++ b/panda/src/movies/movieAudio.h @@ -43,7 +43,7 @@ class MovieAudioCursor; */ class EXPCL_PANDA_MOVIES MovieAudio : public TypedWritableReferenceCount, public Namable { PUBLISHED: - MovieAudio(const std::string &name = "Blank Audio"); + explicit MovieAudio(const std::string &name = "Blank Audio"); virtual ~MovieAudio(); virtual PT(MovieAudioCursor) open(); static PT(MovieAudio) get(const Filename &name); From 3417b9df09248da91431dba99af2b3b2aa6257c8 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 13 Sep 2018 20:23:58 +0200 Subject: [PATCH 187/360] egg: work around compiler bug in Visual Studio 2017 Fixes #379 --- panda/src/egg/eggVertexPool.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index 8fa3b5e637..6f2768599e 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -677,7 +677,15 @@ transform(const LMatrix4d &mat) { typedef pvector Verts; Verts verts; verts.reserve(size()); + + // Work around MSVC 2017 compiler bug, see GitHub issue #379 +#ifdef _MSC_VER + for (const IndexVertices::value_type &v : _index_vertices) { + verts.push_back(v.second); + } +#else std::copy(begin(), end(), std::back_inserter(verts)); +#endif Verts::const_iterator vi; for (vi = verts.begin(); vi != verts.end(); ++vi) { From 8b3cc74cad5177f8185883a06c938f06a2a05be9 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 13 Sep 2018 20:42:16 +0200 Subject: [PATCH 188/360] interrogate: write out OS-generic filenames in #include directives Fixes #386 --- dtool/src/interrogate/interrogate.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index d11bd22ff6..964d38020c 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -516,7 +516,7 @@ main(int argc, char **argv) { cerr << "Error parsing file: '" << argv[i] << "'\n"; exit(1); } - builder.add_source_file(filename); + builder.add_source_file(filename.to_os_generic()); } // Now that we've parsed all the source code, change the way things are From 822f89fadbd2e7a0c0900f8f51155089f87bfb42 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 13 Sep 2018 20:58:11 +0200 Subject: [PATCH 189/360] dgui: accept arg in setText, setImage, setGeom, also add clearers This enables the "setters" to behave in a way that people expect setters to behave. Since `setText(None)` now does not behave expectedly, a `clearText()` has also been added to remove the text. Closes #385 --- direct/src/gui/DirectFrame.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/direct/src/gui/DirectFrame.py b/direct/src/gui/DirectFrame.py index e078b28021..684fda005c 100644 --- a/direct/src/gui/DirectFrame.py +++ b/direct/src/gui/DirectFrame.py @@ -61,7 +61,14 @@ class DirectFrame(DirectGuiWidget): def destroy(self): DirectGuiWidget.destroy(self) - def setText(self): + def clearText(self): + self['text'] = None + self.setText() + + def setText(self, text=None): + if text is not None: + self['text'] = text + # Determine if user passed in single string or a sequence if self['text'] == None: textList = (None,) * self['numStates'] @@ -100,7 +107,14 @@ class DirectFrame(DirectGuiWidget): sort = DGG.TEXT_SORT_INDEX, ) - def setGeom(self): + def clearGeom(self): + self['geom'] = None + self.setGeom() + + def setGeom(self, geom=None): + if geom is not None: + self['geom'] = geom + # Determine argument type geom = self['geom'] @@ -142,7 +156,14 @@ class DirectFrame(DirectGuiWidget): geom = geom, scale = 1, sort = DGG.GEOM_SORT_INDEX) - def setImage(self): + def clearImage(self): + self['image'] = None + self.setImage() + + def setImage(self, image=None): + if image is not None: + self['image'] = image + # Determine argument type arg = self['image'] if arg == None: From 0af1b9c9882bcaf4590ef4831c2cd5d82c7d974e Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 17 Sep 2018 16:39:09 +0200 Subject: [PATCH 190/360] makewheel: update manylinux1 platform check for latest image [skip ci] --- makepanda/makewheel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index e490f1c05e..74ee15d7f1 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -28,7 +28,7 @@ default_platform = get_platform() if default_platform.startswith("linux-"): # Is this manylinux1? - if os.path.isfile("/lib/libc-2.5.so") and os.path.isdir("/opt/python"): + if (os.path.isfile("/lib/libc-2.5.so") or os.path.isfile("/lib64/libc-2.5.so")) and os.path.isdir("/opt/python"): default_platform = default_platform.replace("linux", "manylinux1") From ba9ea8ea2736a3b0731b30ef5d40a37833b0ce15 Mon Sep 17 00:00:00 2001 From: Younguk Kim Date: Wed, 19 Sep 2018 09:55:29 +0900 Subject: [PATCH 191/360] chan: add missing export macro --- panda/src/chan/partBundle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/chan/partBundle.h b/panda/src/chan/partBundle.h index f8fda4bd47..7e9d21259d 100644 --- a/panda/src/chan/partBundle.h +++ b/panda/src/chan/partBundle.h @@ -248,8 +248,8 @@ inline std::ostream &operator <<(std::ostream &out, const PartBundle &bundle) { return out; } -std::ostream &operator <<(std::ostream &out, PartBundle::BlendType blend_type); -std::istream &operator >>(std::istream &in, PartBundle::BlendType &blend_type); +EXPCL_PANDA_CHAN std::ostream &operator <<(std::ostream &out, PartBundle::BlendType blend_type); +EXPCL_PANDA_CHAN std::istream &operator >>(std::istream &in, PartBundle::BlendType &blend_type); #include "partBundle.I" From b64e850539a9df1f26f06c359e01db227089ffd6 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 19 Sep 2018 13:16:45 -0600 Subject: [PATCH 192/360] egg(2pg): Fix missing EXPCL_PANDA_EGG(2PG) --- panda/src/egg/eggMesher.h | 2 +- panda/src/egg/eggMesherEdge.h | 2 +- panda/src/egg/eggMesherFanMaker.h | 2 +- panda/src/egg/eggMesherStrip.h | 2 +- panda/src/egg2pg/eggBinner.h | 2 +- panda/src/egg2pg/eggLoader.h | 2 +- panda/src/egg2pg/eggRenderState.h | 2 +- panda/src/egg2pg/eggSaver.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/panda/src/egg/eggMesher.h b/panda/src/egg/eggMesher.h index 5d1a3e0070..5b4d9b63d1 100644 --- a/panda/src/egg/eggMesher.h +++ b/panda/src/egg/eggMesher.h @@ -30,7 +30,7 @@ * connectivity, and generates a set of EggTriangleStrips that represent the * same geometry. */ -class EggMesher { +class EXPCL_PANDA_EGG EggMesher { public: EggMesher(); diff --git a/panda/src/egg/eggMesherEdge.h b/panda/src/egg/eggMesherEdge.h index 5ef30c1c69..17e463b79d 100644 --- a/panda/src/egg/eggMesherEdge.h +++ b/panda/src/egg/eggMesherEdge.h @@ -26,7 +26,7 @@ class EggMesherStrip; * connected triangles. The edge is actually represented as a pair of vertex * indices into the same vertex pool. */ -class EggMesherEdge { +class EXPCL_PANDA_EGG EggMesherEdge { public: INLINE EggMesherEdge(int vi_a, int vi_b); INLINE EggMesherEdge(const EggMesherEdge ©); diff --git a/panda/src/egg/eggMesherFanMaker.h b/panda/src/egg/eggMesherFanMaker.h index f320b2858b..894462b493 100644 --- a/panda/src/egg/eggMesherFanMaker.h +++ b/panda/src/egg/eggMesherFanMaker.h @@ -31,7 +31,7 @@ class EggMesher; * This class is used by EggMesher::find_fans() to attempt to make an * EggTriangleFan out of the polygons connected to the indicated vertex. */ -class EggMesherFanMaker { +class EXPCL_PANDA_EGG EggMesherFanMaker { public: typedef plist Edges; typedef plist Strips; diff --git a/panda/src/egg/eggMesherStrip.h b/panda/src/egg/eggMesherStrip.h index 6064388ce0..72a2e54fa3 100644 --- a/panda/src/egg/eggMesherStrip.h +++ b/panda/src/egg/eggMesherStrip.h @@ -27,7 +27,7 @@ class EggMesherEdge; * mesher. It might also represent a single polygon such as a triangle or * quad, since that's how strips generally start out. */ -class EggMesherStrip { +class EXPCL_PANDA_EGG EggMesherStrip { public: enum PrimType { PT_poly, diff --git a/panda/src/egg2pg/eggBinner.h b/panda/src/egg2pg/eggBinner.h index a7e3c10894..007f434190 100644 --- a/panda/src/egg2pg/eggBinner.h +++ b/panda/src/egg2pg/eggBinner.h @@ -27,7 +27,7 @@ class EggLoader; * It is used to collect similar polygons together for a Geom, as well as to * group related LOD children together under a single LOD node. */ -class EggBinner : public EggBinMaker { +class EXPCL_PANDA_EGG2PG EggBinner : public EggBinMaker { public: // The BinNumber serves to identify why a particular EggBin was created. enum BinNumber { diff --git a/panda/src/egg2pg/eggLoader.h b/panda/src/egg2pg/eggLoader.h index aa36475e05..eb81317bd8 100644 --- a/panda/src/egg2pg/eggLoader.h +++ b/panda/src/egg2pg/eggLoader.h @@ -64,7 +64,7 @@ class CharacterMaker; * * This class isn't exported from this package. */ -class EggLoader { +class EXPCL_PANDA_EGG2PG EggLoader { public: EggLoader(); EggLoader(const EggData *data); diff --git a/panda/src/egg2pg/eggRenderState.h b/panda/src/egg2pg/eggRenderState.h index 44993dffcf..82af78be70 100644 --- a/panda/src/egg2pg/eggRenderState.h +++ b/panda/src/egg2pg/eggRenderState.h @@ -36,7 +36,7 @@ class EggMaterial; * should be assigned to each primitive. It is assigned to EggPrimitive * objects via the EggBinner. */ -class EggRenderState : public EggUserData { +class EXPCL_PANDA_EGG2PG EggRenderState : public EggUserData { public: INLINE EggRenderState(EggLoader &loader); INLINE void add_attrib(const RenderAttrib *attrib); diff --git a/panda/src/egg2pg/eggSaver.h b/panda/src/egg2pg/eggSaver.h index 8041d346cc..48a9693dec 100644 --- a/panda/src/egg2pg/eggSaver.h +++ b/panda/src/egg2pg/eggSaver.h @@ -50,7 +50,7 @@ class EggVertex; * complete (some Panda or egg constructs are not fully supported by this * class). */ -class EggSaver { +class EXPCL_PANDA_EGG2PG EggSaver { PUBLISHED: EggSaver(EggData *data = nullptr); From aacafe7be3cd8de64190535b3b454c5146bc69a7 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Sep 2018 13:03:47 +0200 Subject: [PATCH 193/360] dtoolutil: give DSearchPath a defaulted move constructor --- dtool/src/dtoolutil/dSearchPath.cxx | 31 ----------------------------- dtool/src/dtoolutil/dSearchPath.h | 11 ++++++---- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/dtool/src/dtoolutil/dSearchPath.cxx b/dtool/src/dtoolutil/dSearchPath.cxx index 4a094f1d98..c17b3d61ec 100644 --- a/dtool/src/dtoolutil/dSearchPath.cxx +++ b/dtool/src/dtoolutil/dSearchPath.cxx @@ -116,13 +116,6 @@ write(ostream &out, int indent_level) const { } } -/** - * Creates an empty search path. - */ -DSearchPath:: -DSearchPath() { -} - /** * */ @@ -139,30 +132,6 @@ DSearchPath(const Filename &directory) { append_directory(directory); } -/** - * - */ -DSearchPath:: -DSearchPath(const DSearchPath ©) : - _directories(copy._directories) -{ -} - -/** - * - */ -void DSearchPath:: -operator = (const DSearchPath ©) { - _directories = copy._directories; -} - -/** - * - */ -DSearchPath:: -~DSearchPath() { -} - /** * Removes all the directories from the search list. */ diff --git a/dtool/src/dtoolutil/dSearchPath.h b/dtool/src/dtoolutil/dSearchPath.h index 8cb769c378..7258a71f26 100644 --- a/dtool/src/dtoolutil/dSearchPath.h +++ b/dtool/src/dtoolutil/dSearchPath.h @@ -52,12 +52,15 @@ PUBLISHED: Files _files; }; - DSearchPath(); + DSearchPath() = default; DSearchPath(const std::string &path, const std::string &separator = std::string()); DSearchPath(const Filename &directory); - DSearchPath(const DSearchPath ©); - void operator = (const DSearchPath ©); - ~DSearchPath(); + DSearchPath(const DSearchPath ©) = default; + DSearchPath(DSearchPath &&from) = default; + ~DSearchPath() = default; + + DSearchPath &operator = (const DSearchPath ©) = default; + DSearchPath &operator = (DSearchPath &&from) = default; void clear(); void append_directory(const Filename &directory); From d6b7abedfe9d03c483f1973e34995c9201da46d0 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Sep 2018 13:05:52 +0200 Subject: [PATCH 194/360] prc: fix some race conditions querying bool and searchpath vars This is not perfect, and we need to more thoroughly address thread safety in the PRC system, but it will nonetheless address a lot of the race condition issues when querying these variables from two threads at the same time. --- dtool/src/prc/configDeclaration.cxx | 37 ++++++++++++++++++++++ dtool/src/prc/configDeclaration.h | 3 ++ dtool/src/prc/configVariableBool.cxx | 16 ++++++++-- dtool/src/prc/configVariableFilename.cxx | 10 +----- dtool/src/prc/configVariableSearchPath.I | 22 +++++++++++-- dtool/src/prc/configVariableSearchPath.cxx | 13 ++------ dtool/src/prc/configVariableSearchPath.h | 5 +-- 7 files changed, 80 insertions(+), 26 deletions(-) diff --git a/dtool/src/prc/configDeclaration.cxx b/dtool/src/prc/configDeclaration.cxx index 7cbfa5ba6e..b401df73d4 100644 --- a/dtool/src/prc/configDeclaration.cxx +++ b/dtool/src/prc/configDeclaration.cxx @@ -16,6 +16,8 @@ #include "config_prc.h" #include "pstrtod.h" #include "string_utils.h" +#include "executionEnvironment.h" +#include "mutexImpl.h" using std::string; @@ -131,6 +133,41 @@ set_double_word(size_t n, double value) { invalidate_cache(); } +/** + * Interprets the string value as a filename and returns it, with any + * variables expanded. + */ +Filename ConfigDeclaration:: +get_filename_value() const { + // Since we are about to set THIS_PRC_DIR globally, we need to ensure that + // no two threads call this method at the same time. + // NB. MSVC doesn't guarantee that this mutex is initialized in a + // thread-safe manner. But chances are that the first time this is called + // is at static init time, when there is no risk of data races. + static MutexImpl lock; + + string str = _string_value; + + // Are there any variables to be expanded? + if (str.find('$') != string::npos) { + Filename page_filename(_page->get_name()); + Filename page_dirname = page_filename.get_dirname(); + + lock.lock(); + ExecutionEnvironment::shadow_environment_variable("THIS_PRC_DIR", page_dirname.to_os_specific()); + str = ExecutionEnvironment::expand_string(str); + ExecutionEnvironment::clear_shadow("THIS_PRC_DIR"); + lock.unlock(); + } + + Filename fn; + if (!str.empty()) { + fn = Filename::from_os_specific(str); + fn.make_true_case(); + } + return fn; +} + /** * */ diff --git a/dtool/src/prc/configDeclaration.h b/dtool/src/prc/configDeclaration.h index 38129670d5..11cb97728a 100644 --- a/dtool/src/prc/configDeclaration.h +++ b/dtool/src/prc/configDeclaration.h @@ -19,6 +19,7 @@ #include "configPage.h" #include "vector_string.h" #include "numeric_types.h" +#include "filename.h" #include @@ -68,6 +69,8 @@ PUBLISHED: void set_int64_word(size_t n, int64_t value); void set_double_word(size_t n, double value); + Filename get_filename_value() const; + INLINE int get_decl_seq() const; void output(std::ostream &out) const; diff --git a/dtool/src/prc/configVariableBool.cxx b/dtool/src/prc/configVariableBool.cxx index 7fb604642d..701f40c65d 100644 --- a/dtool/src/prc/configVariableBool.cxx +++ b/dtool/src/prc/configVariableBool.cxx @@ -18,6 +18,18 @@ */ void ConfigVariableBool:: reload_value() const { - mark_cache_valid(_local_modified); - _cache = get_bool_word(0); + // NB. MSVC doesn't guarantee that this mutex is initialized in a + // thread-safe manner. But chances are that the first time this is called + // is at static init time, when there is no risk of data races. + static MutexImpl lock; + lock.lock(); + + // We check again for cache validity since another thread may have beaten + // us to the punch while we were waiting for the lock. + if (!is_cache_valid(_local_modified)) { + _cache = get_bool_word(0); + mark_cache_valid(_local_modified); + } + + lock.unlock(); } diff --git a/dtool/src/prc/configVariableFilename.cxx b/dtool/src/prc/configVariableFilename.cxx index 4c8941babd..1015a32e66 100644 --- a/dtool/src/prc/configVariableFilename.cxx +++ b/dtool/src/prc/configVariableFilename.cxx @@ -29,17 +29,9 @@ reload_cache() { // us to the punch while we were waiting for the lock. if (!is_cache_valid(_local_modified)) { nassertv(_core != nullptr); - const ConfigDeclaration *decl = _core->get_declaration(0); - const ConfigPage *page = decl->get_page(); - - Filename page_filename(page->get_name()); - Filename page_dirname = page_filename.get_dirname(); - ExecutionEnvironment::shadow_environment_variable("THIS_PRC_DIR", page_dirname.to_os_specific()); - - _cache = Filename::expand_from(decl->get_string_value()); - ExecutionEnvironment::clear_shadow("THIS_PRC_DIR"); + _cache = decl->get_filename_value(); mark_cache_valid(_local_modified); } lock.unlock(); diff --git a/dtool/src/prc/configVariableSearchPath.I b/dtool/src/prc/configVariableSearchPath.I index 46e542e24c..89a9ac7df9 100644 --- a/dtool/src/prc/configVariableSearchPath.I +++ b/dtool/src/prc/configVariableSearchPath.I @@ -93,20 +93,24 @@ INLINE ConfigVariableSearchPath:: * Returns the variable's value. */ INLINE ConfigVariableSearchPath:: -operator const DSearchPath & () const { +operator DSearchPath () const { return get_value(); } /** * */ -INLINE const DSearchPath &ConfigVariableSearchPath:: +INLINE DSearchPath ConfigVariableSearchPath:: get_value() const { TAU_PROFILE("const DSearchPath &ConfigVariableSearchPath::get_value() const", " ", TAU_USER); + DSearchPath value; + _lock.lock(); if (!is_cache_valid(_local_modified)) { ((ConfigVariableSearchPath *)this)->reload_search_path(); } - return _cache; + value = _cache; + _lock.unlock(); + return value; } /** @@ -123,6 +127,7 @@ get_default_value() const { */ INLINE bool ConfigVariableSearchPath:: clear_local_value() { + _lock.lock(); nassertr(_core != nullptr, false); bool any_to_clear = !_prefix.is_empty() || _postfix.is_empty(); @@ -134,6 +139,7 @@ clear_local_value() { } _local_modified = initial_invalid_cache(); + _lock.unlock(); return any_to_clear; } @@ -151,8 +157,10 @@ clear() { */ INLINE void ConfigVariableSearchPath:: append_directory(const Filename &directory) { + _lock.lock(); _postfix.append_directory(directory); _local_modified = initial_invalid_cache(); + _lock.unlock(); } /** @@ -160,8 +168,10 @@ append_directory(const Filename &directory) { */ INLINE void ConfigVariableSearchPath:: prepend_directory(const Filename &directory) { + _lock.lock(); _prefix.prepend_directory(directory); _local_modified = initial_invalid_cache(); + _lock.unlock(); } /** @@ -170,8 +180,10 @@ prepend_directory(const Filename &directory) { */ INLINE void ConfigVariableSearchPath:: append_path(const std::string &path, const std::string &separator) { + _lock.lock(); _postfix.append_path(path, separator); _local_modified = initial_invalid_cache(); + _lock.unlock(); } /** @@ -180,8 +192,10 @@ append_path(const std::string &path, const std::string &separator) { */ INLINE void ConfigVariableSearchPath:: append_path(const DSearchPath &path) { + _lock.lock(); _postfix.append_path(path); _local_modified = initial_invalid_cache(); + _lock.unlock(); } /** @@ -190,8 +204,10 @@ append_path(const DSearchPath &path) { */ INLINE void ConfigVariableSearchPath:: prepend_path(const DSearchPath &path) { + _lock.lock(); _prefix.prepend_path(path); _local_modified = initial_invalid_cache(); + _lock.unlock(); } /** diff --git a/dtool/src/prc/configVariableSearchPath.cxx b/dtool/src/prc/configVariableSearchPath.cxx index 2231626a7a..32620253b3 100644 --- a/dtool/src/prc/configVariableSearchPath.cxx +++ b/dtool/src/prc/configVariableSearchPath.cxx @@ -27,17 +27,10 @@ reload_search_path() { size_t num_unique_references = _core->get_num_unique_references(); for (size_t i = 0; i < num_unique_references; i++) { const ConfigDeclaration *decl = _core->get_unique_reference(i); - const ConfigPage *page = decl->get_page(); - Filename page_filename(page->get_name()); - Filename page_dirname = page_filename.get_dirname(); - ExecutionEnvironment::shadow_environment_variable("THIS_PRC_DIR", page_dirname.to_os_specific()); - std::string expanded = ExecutionEnvironment::expand_string(decl->get_string_value()); - ExecutionEnvironment::clear_shadow("THIS_PRC_DIR"); - if (!expanded.empty()) { - Filename dir = Filename::from_os_specific(expanded); - dir.make_true_case(); - _cache.append_directory(dir); + Filename fn = decl->get_filename_value(); + if (!fn.empty()) { + _cache.append_directory(std::move(fn)); } } diff --git a/dtool/src/prc/configVariableSearchPath.h b/dtool/src/prc/configVariableSearchPath.h index 02a4fd65c3..12ad1c54c9 100644 --- a/dtool/src/prc/configVariableSearchPath.h +++ b/dtool/src/prc/configVariableSearchPath.h @@ -48,8 +48,8 @@ PUBLISHED: int flags = 0); INLINE ~ConfigVariableSearchPath(); - INLINE operator const DSearchPath & () const; - INLINE const DSearchPath &get_value() const; + INLINE operator DSearchPath () const; + INLINE DSearchPath get_value() const; INLINE const DSearchPath &get_default_value() const; MAKE_PROPERTY(value, get_value); MAKE_PROPERTY(default_value, get_default_value); @@ -81,6 +81,7 @@ PUBLISHED: private: void reload_search_path(); + mutable MutexImpl _lock; DSearchPath _default_value; DSearchPath _prefix, _postfix; From 77724f49dc4036fe5b3151a5fd2f44d354fc1ae1 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Sep 2018 13:50:06 +0200 Subject: [PATCH 195/360] dtoolbase: remove TypeHandle::_none symbol, no longer needed --- dtool/src/dtoolbase/typeHandle.cxx | 3 --- dtool/src/dtoolbase/typeHandle.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index 1b96352723..15fac6b60f 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -15,9 +15,6 @@ #include "typeRegistryNode.h" #include "atomicAdjust.h" -// This is initialized to zero by static initialization. -TypeHandle TypeHandle::_none; - /** * Returns the total allocated memory used by objects of this type, for the * indicated memory class. This is only updated if track-memory-usage is set diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index da66074750..97dc445443 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -147,9 +147,6 @@ public: private: constexpr TypeHandle(int index); - // Only kept temporarily for ABI compatibility. - static TypeHandle _none; - int _index; friend class TypeRegistry; }; From a3a7c0cf9da82be9ab59e164f7a05b5715eb333b Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Sep 2018 14:21:19 +0200 Subject: [PATCH 196/360] parser-inc: add more POSIX system header stubs --- dtool/src/parser-inc/dirent.h | 3 +++ dtool/src/parser-inc/sys/inotify.h | 1 + dtool/src/parser-inc/sys/ioctl.h | 3 +++ dtool/src/parser-inc/sys/mman.h | 3 +++ dtool/src/parser-inc/sys/select.h | 1 + dtool/src/parser-inc/sys/sysinfo.h | 1 + 6 files changed, 12 insertions(+) create mode 100644 dtool/src/parser-inc/dirent.h create mode 100644 dtool/src/parser-inc/sys/inotify.h create mode 100644 dtool/src/parser-inc/sys/ioctl.h create mode 100644 dtool/src/parser-inc/sys/mman.h create mode 100644 dtool/src/parser-inc/sys/select.h create mode 100644 dtool/src/parser-inc/sys/sysinfo.h diff --git a/dtool/src/parser-inc/dirent.h b/dtool/src/parser-inc/dirent.h new file mode 100644 index 0000000000..5c0877bfcd --- /dev/null +++ b/dtool/src/parser-inc/dirent.h @@ -0,0 +1,3 @@ +typedef struct __dirstream DIR; +struct dirent; +typedef unsigned long ino_t; diff --git a/dtool/src/parser-inc/sys/inotify.h b/dtool/src/parser-inc/sys/inotify.h new file mode 100644 index 0000000000..52ef884e79 --- /dev/null +++ b/dtool/src/parser-inc/sys/inotify.h @@ -0,0 +1 @@ +struct inotify_event; diff --git a/dtool/src/parser-inc/sys/ioctl.h b/dtool/src/parser-inc/sys/ioctl.h new file mode 100644 index 0000000000..d57d62d983 --- /dev/null +++ b/dtool/src/parser-inc/sys/ioctl.h @@ -0,0 +1,3 @@ +struct winsize; +struct termio; + diff --git a/dtool/src/parser-inc/sys/mman.h b/dtool/src/parser-inc/sys/mman.h new file mode 100644 index 0000000000..c540c66b78 --- /dev/null +++ b/dtool/src/parser-inc/sys/mman.h @@ -0,0 +1,3 @@ +#include + +struct posix_typed_mem_info; diff --git a/dtool/src/parser-inc/sys/select.h b/dtool/src/parser-inc/sys/select.h new file mode 100644 index 0000000000..18a03a58e7 --- /dev/null +++ b/dtool/src/parser-inc/sys/select.h @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/sys/sysinfo.h b/dtool/src/parser-inc/sys/sysinfo.h new file mode 100644 index 0000000000..72e2bef1b2 --- /dev/null +++ b/dtool/src/parser-inc/sys/sysinfo.h @@ -0,0 +1 @@ +struct sysinfo; From 3ac50a23473ce251019da9fe3a880763cf9471bf Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Sep 2018 14:22:41 +0200 Subject: [PATCH 197/360] movies: fix crash on simultaneous threaded audio/video load --- panda/src/movies/movieTypeRegistry.cxx | 15 +++++++++++++++ panda/src/movies/movieTypeRegistry.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/panda/src/movies/movieTypeRegistry.cxx b/panda/src/movies/movieTypeRegistry.cxx index 012deff1cd..51468ac2a4 100644 --- a/panda/src/movies/movieTypeRegistry.cxx +++ b/panda/src/movies/movieTypeRegistry.cxx @@ -29,6 +29,8 @@ PT(MovieAudio) MovieTypeRegistry:: make_audio(const Filename &name) { string ext = downcase(name.get_extension()); + _audio_lock.lock(); + // Make sure that the list of audio types has been read in. load_audio_types(); @@ -41,6 +43,7 @@ make_audio(const Filename &name) { // Explicit extension is preferred over catch-all. if (_audio_type_registry.count(ext)) { MakeAudioFunc func = _audio_type_registry[ext]; + _audio_lock.unlock(); return (*func)(name); } @@ -53,12 +56,14 @@ make_audio(const Filename &name) { if (_audio_type_registry.count("*")) { MakeAudioFunc func = _audio_type_registry["*"]; + _audio_lock.unlock(); return (*func)(name); } movies_cat.error() << "Support for audio files with extension ." << ext << " was not enabled.\n"; + _audio_lock.unlock(); return new MovieAudio("Load-Failure Stub"); } @@ -68,6 +73,7 @@ make_audio(const Filename &name) { */ void MovieTypeRegistry:: register_audio_type(MakeAudioFunc func, const string &extensions) { + ReMutexHolder holder(_audio_lock); vector_string words; extract_words(downcase(extensions), words); @@ -89,6 +95,7 @@ register_audio_type(MakeAudioFunc func, const string &extensions) { */ void MovieTypeRegistry:: load_audio_types() { + ReMutexHolder holder(_audio_lock); static bool audio_types_loaded = false; if (!audio_types_loaded) { @@ -145,6 +152,8 @@ PT(MovieVideo) MovieTypeRegistry:: make_video(const Filename &name) { string ext = downcase(name.get_extension()); + _video_lock.lock(); + // Make sure that the list of video types has been read in. load_video_types(); @@ -157,6 +166,7 @@ make_video(const Filename &name) { // Explicit extension is preferred over catch-all. if (_video_type_registry.count(ext)) { MakeVideoFunc func = _video_type_registry[ext]; + _video_lock.unlock(); return (*func)(name); } @@ -169,12 +179,14 @@ make_video(const Filename &name) { if (_video_type_registry.count("*")) { MakeVideoFunc func = _video_type_registry["*"]; + _video_lock.unlock(); return (*func)(name); } movies_cat.error() << "Support for video files with extension ." << ext << " was not enabled.\n"; + _video_lock.unlock(); return new MovieVideo("Load-Failure Stub"); } @@ -184,6 +196,7 @@ make_video(const Filename &name) { */ void MovieTypeRegistry:: register_video_type(MakeVideoFunc func, const string &extensions) { + ReMutexHolder holder(_video_lock); vector_string words; extract_words(downcase(extensions), words); @@ -205,6 +218,7 @@ register_video_type(MakeVideoFunc func, const string &extensions) { */ void MovieTypeRegistry:: load_video_types() { + ReMutexHolder holder(_video_lock); static bool video_types_loaded = false; if (!video_types_loaded) { @@ -259,6 +273,7 @@ load_video_types() { */ void MovieTypeRegistry:: load_movie_library(const string &name) { + ReMutexHolder holder(_video_lock); Filename dlname = Filename::dso_filename("lib" + name + ".so"); movies_cat.info() << "loading video type module: " << name << endl; diff --git a/panda/src/movies/movieTypeRegistry.h b/panda/src/movies/movieTypeRegistry.h index ee5fc14da2..c9ddb53f15 100644 --- a/panda/src/movies/movieTypeRegistry.h +++ b/panda/src/movies/movieTypeRegistry.h @@ -19,6 +19,7 @@ #include "movieVideo.h" #include "filename.h" #include "pmap.h" +#include "reMutex.h" /** * This class records the different types of MovieAudio and MovieVideo that @@ -43,9 +44,11 @@ public: private: static MovieTypeRegistry *_global_ptr; + ReMutex _audio_lock; pmap _audio_type_registry; pmap _deferred_audio_types; + ReMutex _video_lock; pmap _video_type_registry; pmap _deferred_video_types; }; From 5457d76b947273bf0eae561b2de3e52fc1df08a4 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 25 Sep 2018 11:08:22 +0200 Subject: [PATCH 198/360] text: slight perf improvement for TextNode card/frame generation --- panda/src/text/textNode.cxx | 109 +++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 50 deletions(-) diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index 92001d7b40..a68ebba812 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -255,11 +255,16 @@ is_whitespace(wchar_t character) const { */ PN_stdfloat TextNode:: calc_width(const std::wstring &line) const { + TextFont *font = get_font(); + if (font == nullptr) { + return 0.0f; + } + PN_stdfloat width = 0.0f; std::wstring::const_iterator si; for (si = line.begin(); si != line.end(); ++si) { - width += calc_width(*si); + width += TextAssembler::calc_width(*si, *this); } return width; @@ -730,15 +735,16 @@ make_frame() { CPT(RenderState) state = RenderState::make(thick); PT(GeomVertexData) vdata = new GeomVertexData - ("text", GeomVertexFormat::get_v3(), get_usage_hint()); + ("text", GeomVertexFormat::get_v3(), _usage_hint); + vdata->unclean_set_num_rows(4); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - vertex.add_data3(left, 0.0f, top); - vertex.add_data3(left, 0.0f, bottom); - vertex.add_data3(right, 0.0f, bottom); - vertex.add_data3(right, 0.0f, top); + vertex.set_data3(left, 0.0f, top); + vertex.set_data3(left, 0.0f, bottom); + vertex.set_data3(right, 0.0f, bottom); + vertex.set_data3(right, 0.0f, top); - PT(GeomLinestrips) frame = new GeomLinestrips(get_usage_hint()); + PT(GeomLinestrips) frame = new GeomLinestrips(_usage_hint); frame->add_consecutive_vertices(0, 4); frame->add_vertex(0); frame->close_primitive(); @@ -772,19 +778,20 @@ make_card() { PN_stdfloat top = dimensions[3]; PT(GeomVertexData) vdata = new GeomVertexData - ("text", GeomVertexFormat::get_v3t2(), get_usage_hint()); + ("text", GeomVertexFormat::get_v3t2(), _usage_hint); + vdata->unclean_set_num_rows(4); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - vertex.add_data3(left, 0.0f, top); - vertex.add_data3(left, 0.0f, bottom); - vertex.add_data3(right, 0.0f, top); - vertex.add_data3(right, 0.0f, bottom); + vertex.set_data3(left, 0.0f, top); + vertex.set_data3(left, 0.0f, bottom); + vertex.set_data3(right, 0.0f, top); + vertex.set_data3(right, 0.0f, bottom); - texcoord.add_data2(0.0f, 1.0f); - texcoord.add_data2(0.0f, 0.0f); - texcoord.add_data2(1.0f, 1.0f); - texcoord.add_data2(1.0f, 0.0f); + texcoord.set_data2(0.0f, 1.0f); + texcoord.set_data2(0.0f, 0.0f); + texcoord.set_data2(1.0f, 1.0f); + texcoord.set_data2(1.0f, 0.0f); PT(GeomTristrips) card = new GeomTristrips(get_usage_hint()); card->add_consecutive_vertices(0, 4); @@ -820,57 +827,59 @@ make_card_with_border() { */ PT(GeomVertexData) vdata = new GeomVertexData - ("text", GeomVertexFormat::get_v3t2(), get_usage_hint()); + ("text", GeomVertexFormat::get_v3t2(), _usage_hint); + vdata->unclean_set_num_rows(16); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); // verts 1,2,3,4 - vertex.add_data3(left, 0.02, top); - vertex.add_data3(left, 0.02, top - _card_border_size); - vertex.add_data3(left + _card_border_size, 0.02, top); - vertex.add_data3(left + _card_border_size, 0.02, + vertex.set_data3(left, 0.02, top); + vertex.set_data3(left, 0.02, top - _card_border_size); + vertex.set_data3(left + _card_border_size, 0.02, top); + vertex.set_data3(left + _card_border_size, 0.02, top - _card_border_size); // verts 5,6,7,8 - vertex.add_data3(right - _card_border_size, 0.02, top); - vertex.add_data3(right - _card_border_size, 0.02, + vertex.set_data3(right - _card_border_size, 0.02, top); + vertex.set_data3(right - _card_border_size, 0.02, top - _card_border_size); - vertex.add_data3(right, 0.02, top); - vertex.add_data3(right, 0.02, top - _card_border_size); + vertex.set_data3(right, 0.02, top); + vertex.set_data3(right, 0.02, top - _card_border_size); // verts 9,10,11,12 - vertex.add_data3(left, 0.02, bottom + _card_border_size); - vertex.add_data3(left, 0.02, bottom); - vertex.add_data3(left + _card_border_size, 0.02, + vertex.set_data3(left, 0.02, bottom + _card_border_size); + vertex.set_data3(left, 0.02, bottom); + vertex.set_data3(left + _card_border_size, 0.02, bottom + _card_border_size); - vertex.add_data3(left + _card_border_size, 0.02, bottom); + vertex.set_data3(left + _card_border_size, 0.02, bottom); // verts 13,14,15,16 - vertex.add_data3(right - _card_border_size, 0.02, + vertex.set_data3(right - _card_border_size, 0.02, bottom + _card_border_size); - vertex.add_data3(right - _card_border_size, 0.02, bottom); - vertex.add_data3(right, 0.02, bottom + _card_border_size); - vertex.add_data3(right, 0.02, bottom); + vertex.set_data3(right - _card_border_size, 0.02, bottom); + vertex.set_data3(right, 0.02, bottom + _card_border_size); + vertex.set_data3(right, 0.02, bottom); - texcoord.add_data2(0.0f, 1.0f); //1 - texcoord.add_data2(0.0f, 1.0f - _card_border_uv_portion); //2 - texcoord.add_data2(0.0f + _card_border_uv_portion, 1.0f); //3 - texcoord.add_data2(0.0f + _card_border_uv_portion, + texcoord.set_data2(0.0f, 1.0f); //1 + texcoord.set_data2(0.0f, 1.0f - _card_border_uv_portion); //2 + texcoord.set_data2(0.0f + _card_border_uv_portion, 1.0f); //3 + texcoord.set_data2(0.0f + _card_border_uv_portion, 1.0f - _card_border_uv_portion); //4 - texcoord.add_data2(1.0f -_card_border_uv_portion, 1.0f); //5 - texcoord.add_data2(1.0f -_card_border_uv_portion, + texcoord.set_data2(1.0f -_card_border_uv_portion, 1.0f); //5 + texcoord.set_data2(1.0f -_card_border_uv_portion, 1.0f - _card_border_uv_portion); //6 - texcoord.add_data2(1.0f, 1.0f); //7 - texcoord.add_data2(1.0f, 1.0f - _card_border_uv_portion); //8 + texcoord.set_data2(1.0f, 1.0f); //7 + texcoord.set_data2(1.0f, 1.0f - _card_border_uv_portion); //8 - texcoord.add_data2(0.0f, _card_border_uv_portion); //9 - texcoord.add_data2(0.0f, 0.0f); //10 - texcoord.add_data2(_card_border_uv_portion, _card_border_uv_portion); //11 - texcoord.add_data2(_card_border_uv_portion, 0.0f); //12 + texcoord.set_data2(0.0f, _card_border_uv_portion); //9 + texcoord.set_data2(0.0f, 0.0f); //10 + texcoord.set_data2(_card_border_uv_portion, _card_border_uv_portion); //11 + texcoord.set_data2(_card_border_uv_portion, 0.0f); //12 - texcoord.add_data2(1.0f - _card_border_uv_portion, _card_border_uv_portion);//13 - texcoord.add_data2(1.0f - _card_border_uv_portion, 0.0f);//14 - texcoord.add_data2(1.0f, _card_border_uv_portion);//15 - texcoord.add_data2(1.0f, 0.0f);//16 + texcoord.set_data2(1.0f - _card_border_uv_portion, _card_border_uv_portion);//13 + texcoord.set_data2(1.0f - _card_border_uv_portion, 0.0f);//14 + texcoord.set_data2(1.0f, _card_border_uv_portion);//15 + texcoord.set_data2(1.0f, 0.0f);//16 - PT(GeomTristrips) card = new GeomTristrips(get_usage_hint()); + PT(GeomTristrips) card = new GeomTristrips(_usage_hint); + card->reserve_num_vertices(24); // tristrip #1 card->add_consecutive_vertices(0, 8); From 1e084e0b2b16046ed4d996b086880497d64d3ad2 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 25 Sep 2018 11:35:16 +0200 Subject: [PATCH 199/360] text: add thread safety to TextNode This does not 100% cover all the base class TextProperties, however, so you still need to be careful not to access those from two threads at once. --- panda/src/text/textNode.I | 170 +++++++++-- panda/src/text/textNode.cxx | 595 +++++++++++++++++++----------------- panda/src/text/textNode.h | 10 +- 3 files changed, 462 insertions(+), 313 deletions(-) diff --git a/panda/src/text/textNode.I b/panda/src/text/textNode.I index 313685c504..8070504c6b 100644 --- a/panda/src/text/textNode.I +++ b/panda/src/text/textNode.I @@ -33,6 +33,7 @@ get_line_height() const { */ INLINE void TextNode:: set_max_rows(int max_rows) { + MutexHolder holder(_lock); _max_rows = max_rows; invalidate_with_measure(); } @@ -43,6 +44,7 @@ set_max_rows(int max_rows) { */ INLINE void TextNode:: clear_max_rows() { + MutexHolder holder(_lock); _max_rows = 0; invalidate_with_measure(); } @@ -53,6 +55,7 @@ clear_max_rows() { */ INLINE bool TextNode:: has_max_rows() const { + MutexHolder holder(_lock); return _max_rows > 0; } @@ -62,6 +65,7 @@ has_max_rows() const { */ INLINE int TextNode:: get_max_rows() const { + MutexHolder holder(_lock); return _max_rows; } @@ -71,6 +75,7 @@ get_max_rows() const { */ INLINE bool TextNode:: has_overflow() const { + MutexHolder holder(_lock); check_measure(); return (_flags & F_has_overflow) != 0; } @@ -88,6 +93,7 @@ set_frame_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { */ INLINE void TextNode:: set_frame_color(const LColor &frame_color) { + MutexHolder holder(_lock); if (_frame_color != frame_color) { _frame_color = frame_color; invalidate_no_measure(); @@ -99,6 +105,7 @@ set_frame_color(const LColor &frame_color) { */ INLINE LColor TextNode:: get_frame_color() const { + MutexHolder holder(_lock); return _frame_color; } @@ -107,7 +114,8 @@ get_frame_color() const { */ INLINE void TextNode:: set_card_border(PN_stdfloat size, PN_stdfloat uv_portion) { - if (!has_card_border() || _card_border_size != size || _card_border_uv_portion != uv_portion) { + MutexHolder holder(_lock); + if ((_flags & F_has_card_border) == 0 || _card_border_size != size || _card_border_uv_portion != uv_portion) { _flags |= F_has_card_border; _card_border_size = size; _card_border_uv_portion = uv_portion; @@ -120,7 +128,8 @@ set_card_border(PN_stdfloat size, PN_stdfloat uv_portion) { */ INLINE void TextNode:: clear_card_border() { - if (has_card_border()) { + MutexHolder holder(_lock); + if (_flags & F_has_card_border) { _flags &= ~F_has_card_border; invalidate_no_measure(); } @@ -131,6 +140,7 @@ clear_card_border() { */ INLINE PN_stdfloat TextNode:: get_card_border_size() const { + MutexHolder holder(_lock); return _card_border_size; } @@ -139,6 +149,7 @@ get_card_border_size() const { */ INLINE PN_stdfloat TextNode:: get_card_border_uv_portion() const { + MutexHolder holder(_lock); return _card_border_uv_portion; } @@ -147,6 +158,7 @@ get_card_border_uv_portion() const { */ INLINE bool TextNode:: has_card_border() const { + MutexHolder holder(_lock); return (_flags & F_has_card_border) != 0; } @@ -163,6 +175,7 @@ set_card_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { */ INLINE void TextNode:: set_card_color(const LColor &card_color) { + MutexHolder holder(_lock); if (_card_color != card_color) { _card_color = card_color; invalidate_no_measure(); @@ -174,6 +187,7 @@ set_card_color(const LColor &card_color) { */ INLINE LColor TextNode:: get_card_color() const { + MutexHolder holder(_lock); return _card_color; } @@ -185,7 +199,8 @@ set_card_texture(Texture *card_texture) { if (card_texture == nullptr) { clear_card_texture(); } else { - if (!has_card_texture() || _card_texture != card_texture) { + MutexHolder holder(_lock); + if ((_flags & F_has_card_texture) == 0 || _card_texture != card_texture) { _flags |= F_has_card_texture; _card_texture = card_texture; invalidate_no_measure(); @@ -198,7 +213,8 @@ set_card_texture(Texture *card_texture) { */ INLINE void TextNode:: clear_card_texture() { - if (has_card_texture()) { + MutexHolder holder(_lock); + if (_flags & F_has_card_texture) { _flags &= ~F_has_card_texture; _card_texture = nullptr; invalidate_no_measure(); @@ -210,6 +226,7 @@ clear_card_texture() { */ INLINE bool TextNode:: has_card_texture() const { + MutexHolder holder(_lock); return (_flags & F_has_card_texture) != 0; } @@ -218,6 +235,7 @@ has_card_texture() const { */ INLINE Texture *TextNode:: get_card_texture() const { + MutexHolder holder(_lock); return _card_texture; } @@ -229,6 +247,7 @@ get_card_texture() const { */ INLINE void TextNode:: set_frame_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + MutexHolder holder(_lock); _flags |= (F_has_frame | F_frame_as_margin); _frame_ul.set(left, top); _frame_lr.set(right, bottom); @@ -243,6 +262,7 @@ set_frame_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_ */ INLINE void TextNode:: set_frame_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + MutexHolder holder(_lock); _flags |= F_has_frame; _flags &= ~F_frame_as_margin; _frame_ul.set(left, top); @@ -255,6 +275,7 @@ set_frame_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_std */ INLINE void TextNode:: clear_frame() { + MutexHolder holder(_lock); _flags &= ~F_has_frame; invalidate_no_measure(); } @@ -264,6 +285,7 @@ clear_frame() { */ INLINE bool TextNode:: has_frame() const { + MutexHolder holder(_lock); return (_flags & F_has_frame) != 0; } @@ -276,7 +298,8 @@ has_frame() const { */ INLINE bool TextNode:: is_frame_as_margin() const { - nassertr(has_frame(), false); + MutexHolder holder(_lock); + nassertr((_flags & F_has_frame) != 0, false); return (_flags & F_frame_as_margin) != 0; } @@ -288,7 +311,8 @@ is_frame_as_margin() const { */ INLINE LVecBase4 TextNode:: get_frame_as_set() const { - nassertr(has_frame(), LVecBase4(0.0, 0.0, 0.0, 0.0)); + MutexHolder holder(_lock); + nassertr((_flags & F_has_frame) != 0, LVecBase4(0.0, 0.0, 0.0, 0.0)); return LVecBase4(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]); } @@ -303,18 +327,20 @@ get_frame_as_set() const { */ INLINE LVecBase4 TextNode:: get_frame_actual() const { - if (!has_frame()) { + MutexHolder holder(_lock); + if (_flags & F_has_frame) { + if (_flags & F_frame_as_margin) { + check_measure(); + return LVecBase4(_text_ul[0] - _frame_ul[0], + _text_lr[0] + _frame_lr[0], + _text_lr[1] - _frame_lr[1], + _text_ul[1] + _frame_ul[1]); + } else { + return LVecBase4(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]); + } + } else { check_measure(); return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]); - - } else if (is_frame_as_margin()) { - check_measure(); - return LVecBase4(_text_ul[0] - _frame_ul[0], - _text_lr[0] + _frame_lr[0], - _text_lr[1] - _frame_lr[1], - _text_ul[1] + _frame_ul[1]); - } else { - return get_frame_as_set(); } } @@ -323,6 +349,7 @@ get_frame_actual() const { */ INLINE void TextNode:: set_frame_line_width(PN_stdfloat frame_width) { + MutexHolder holder(_lock); _frame_width = frame_width; invalidate_no_measure(); } @@ -332,6 +359,7 @@ set_frame_line_width(PN_stdfloat frame_width) { */ INLINE PN_stdfloat TextNode:: get_frame_line_width() const { + MutexHolder holder(_lock); return _frame_width; } @@ -342,6 +370,7 @@ get_frame_line_width() const { */ INLINE void TextNode:: set_frame_corners(bool corners) { + MutexHolder holder(_lock); if (corners) { _flags |= F_frame_corners; } else { @@ -355,6 +384,7 @@ set_frame_corners(bool corners) { */ INLINE bool TextNode:: get_frame_corners() const { + MutexHolder holder(_lock); return (_flags & F_frame_corners) != 0; } @@ -366,6 +396,7 @@ get_frame_corners() const { */ INLINE void TextNode:: set_card_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + MutexHolder holder(_lock); _flags |= (F_has_card | F_card_as_margin); _card_ul.set(left, top); _card_lr.set(right, bottom); @@ -380,6 +411,7 @@ set_card_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_s */ INLINE void TextNode:: set_card_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { + MutexHolder holder(_lock); _flags |= F_has_card; _flags &= ~F_card_as_margin; _card_ul.set(left, top); @@ -394,6 +426,7 @@ set_card_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdf */ INLINE void TextNode:: set_card_decal(bool card_decal) { + MutexHolder holder(_lock); if (card_decal) { _flags |= F_card_decal; } else { @@ -407,6 +440,7 @@ set_card_decal(bool card_decal) { */ INLINE void TextNode:: clear_card() { + MutexHolder holder(_lock); _flags &= ~F_has_card; invalidate_no_measure(); } @@ -416,6 +450,7 @@ clear_card() { */ INLINE bool TextNode:: has_card() const { + MutexHolder holder(_lock); return (_flags & F_has_card) != 0; } @@ -424,6 +459,7 @@ has_card() const { */ INLINE bool TextNode:: get_card_decal() const { + MutexHolder holder(_lock); return (_flags & F_card_decal) != 0; } @@ -436,7 +472,8 @@ get_card_decal() const { */ INLINE bool TextNode:: is_card_as_margin() const { - nassertr(has_card(), false); + MutexHolder holder(_lock); + nassertr((_flags & F_has_card) != 0, false); return (_flags & F_card_as_margin) != 0; } @@ -448,7 +485,8 @@ is_card_as_margin() const { */ INLINE LVecBase4 TextNode:: get_card_as_set() const { - nassertr(has_card(), LVecBase4(0.0, 0.0, 0.0, 0.0)); + MutexHolder holder(_lock); + nassertr((_flags & F_has_card) != 0, LVecBase4(0.0, 0.0, 0.0, 0.0)); return LVecBase4(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]); } @@ -463,18 +501,20 @@ get_card_as_set() const { */ INLINE LVecBase4 TextNode:: get_card_actual() const { - if (!has_card()) { + MutexHolder holder(_lock); + if (_flags & F_has_card) { + if (_flags & F_card_as_margin) { + check_measure(); + return LVecBase4(_text_ul[0] - _card_ul[0], + _text_lr[0] + _card_lr[0], + _text_lr[1] - _card_lr[1], + _text_ul[1] + _card_ul[1]); + } else { + return LVecBase4(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]); + } + } else { check_measure(); return LVecBase4(_text_ul[0], _text_lr[0], _text_lr[1], _text_ul[1]); - - } else if (is_card_as_margin()) { - check_measure(); - return LVecBase4(_text_ul[0] - _card_ul[0], - _text_lr[0] + _card_lr[0], - _text_lr[1] - _card_lr[1], - _text_ul[1] + _card_ul[1]); - } else { - return get_card_as_set(); } } @@ -487,6 +527,8 @@ get_card_actual() const { INLINE LVecBase4 TextNode:: get_card_transformed() const { LVecBase4 card = get_card_actual(); + + MutexHolder holder(_lock); LPoint3 ul = LPoint3(card[0], 0.0, card[3]) * _transform; LPoint3 lr = LPoint3(card[1], 0.0, card[2]) * _transform; @@ -498,6 +540,7 @@ get_card_transformed() const { */ INLINE void TextNode:: set_transform(const LMatrix4 &transform) { + MutexHolder holder(_lock); _transform = transform; invalidate_with_measure(); } @@ -507,6 +550,7 @@ set_transform(const LMatrix4 &transform) { */ INLINE LMatrix4 TextNode:: get_transform() const { + MutexHolder holder(_lock); return _transform; } @@ -515,6 +559,7 @@ get_transform() const { */ INLINE void TextNode:: set_coordinate_system(CoordinateSystem coordinate_system) { + MutexHolder holder(_lock); _coordinate_system = coordinate_system; invalidate_with_measure(); } @@ -524,6 +569,7 @@ set_coordinate_system(CoordinateSystem coordinate_system) { */ INLINE CoordinateSystem TextNode:: get_coordinate_system() const { + MutexHolder holder(_lock); return _coordinate_system; } @@ -535,6 +581,7 @@ get_coordinate_system() const { */ INLINE void TextNode:: set_usage_hint(Geom::UsageHint usage_hint) { + MutexHolder holder(_lock); _usage_hint = usage_hint; invalidate_no_measure(); } @@ -545,6 +592,7 @@ set_usage_hint(Geom::UsageHint usage_hint) { */ INLINE Geom::UsageHint TextNode:: get_usage_hint() const { + MutexHolder holder(_lock); return _usage_hint; } @@ -585,6 +633,7 @@ get_usage_hint() const { */ INLINE void TextNode:: set_flatten_flags(int flatten_flags) { + MutexHolder holder(_lock); _flatten_flags = flatten_flags; } @@ -593,6 +642,7 @@ set_flatten_flags(int flatten_flags) { */ INLINE int TextNode:: get_flatten_flags() const { + MutexHolder holder(_lock); return _flatten_flags; } @@ -602,6 +652,7 @@ get_flatten_flags() const { */ INLINE void TextNode:: set_font(TextFont *font) { + MutexHolder holder(_lock); TextProperties::set_font(font); invalidate_with_measure(); } @@ -611,6 +662,7 @@ set_font(TextFont *font) { */ INLINE void TextNode:: clear_font() { + MutexHolder holder(_lock); TextProperties::clear_font(); invalidate_with_measure(); } @@ -631,6 +683,7 @@ clear_font() { */ INLINE void TextNode:: set_small_caps(bool small_caps) { + MutexHolder holder(_lock); TextProperties::set_small_caps(small_caps); invalidate_with_measure(); } @@ -640,6 +693,7 @@ set_small_caps(bool small_caps) { */ INLINE void TextNode:: clear_small_caps() { + MutexHolder holder(_lock); TextProperties::clear_small_caps(); invalidate_with_measure(); } @@ -651,6 +705,7 @@ clear_small_caps() { */ INLINE void TextNode:: set_small_caps_scale(PN_stdfloat small_caps_scale) { + MutexHolder holder(_lock); TextProperties::set_small_caps_scale(small_caps_scale); invalidate_with_measure(); } @@ -660,6 +715,7 @@ set_small_caps_scale(PN_stdfloat small_caps_scale) { */ INLINE void TextNode:: clear_small_caps_scale() { + MutexHolder holder(_lock); TextProperties::clear_small_caps_scale(); invalidate_with_measure(); } @@ -669,6 +725,7 @@ clear_small_caps_scale() { */ INLINE void TextNode:: set_slant(PN_stdfloat slant) { + MutexHolder holder(_lock); TextProperties::set_slant(slant); invalidate_with_measure(); } @@ -678,6 +735,7 @@ set_slant(PN_stdfloat slant) { */ INLINE void TextNode:: clear_slant() { + MutexHolder holder(_lock); TextProperties::clear_slant(); invalidate_with_measure(); } @@ -687,6 +745,7 @@ clear_slant() { */ INLINE void TextNode:: set_align(TextNode::Alignment align_type) { + MutexHolder holder(_lock); TextProperties::set_align(align_type); invalidate_with_measure(); } @@ -696,6 +755,7 @@ set_align(TextNode::Alignment align_type) { */ INLINE void TextNode:: clear_align() { + MutexHolder holder(_lock); TextProperties::clear_align(); invalidate_with_measure(); } @@ -706,6 +766,7 @@ clear_align() { */ INLINE void TextNode:: set_indent(PN_stdfloat indent) { + MutexHolder holder(_lock); TextProperties::set_indent(indent); invalidate_with_measure(); } @@ -715,6 +776,7 @@ set_indent(PN_stdfloat indent) { */ INLINE void TextNode:: clear_indent() { + MutexHolder holder(_lock); TextProperties::clear_indent(); invalidate_with_measure(); } @@ -725,6 +787,7 @@ clear_indent() { */ INLINE void TextNode:: set_wordwrap(PN_stdfloat wordwrap) { + MutexHolder holder(_lock); TextProperties::set_wordwrap(wordwrap); invalidate_with_measure(); } @@ -735,6 +798,7 @@ set_wordwrap(PN_stdfloat wordwrap) { */ INLINE void TextNode:: clear_wordwrap() { + MutexHolder holder(_lock); TextProperties::clear_wordwrap(); invalidate_with_measure(); } @@ -744,6 +808,7 @@ clear_wordwrap() { */ INLINE void TextNode:: set_text_color(const LColor &text_color) { + MutexHolder holder(_lock); TextProperties::set_text_color(text_color); invalidate_no_measure(); } @@ -762,6 +827,7 @@ set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { */ INLINE void TextNode:: clear_text_color() { + MutexHolder holder(_lock); TextProperties::clear_text_color(); invalidate_no_measure(); } @@ -779,6 +845,7 @@ set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { */ INLINE void TextNode:: set_shadow_color(const LColor &shadow_color) { + MutexHolder holder(_lock); TextProperties::set_shadow_color(shadow_color); invalidate_no_measure(); } @@ -788,6 +855,7 @@ set_shadow_color(const LColor &shadow_color) { */ INLINE void TextNode:: clear_shadow_color() { + MutexHolder holder(_lock); TextProperties::clear_shadow_color(); invalidate_with_measure(); } @@ -807,6 +875,7 @@ set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) { */ INLINE void TextNode:: set_shadow(const LVecBase2 &shadow_offset) { + MutexHolder holder(_lock); TextProperties::set_shadow(shadow_offset); invalidate_no_measure(); } @@ -816,6 +885,7 @@ set_shadow(const LVecBase2 &shadow_offset) { */ INLINE void TextNode:: clear_shadow() { + MutexHolder holder(_lock); TextProperties::clear_shadow(); invalidate_no_measure(); } @@ -831,6 +901,7 @@ clear_shadow() { */ INLINE void TextNode:: set_bin(const std::string &bin) { + MutexHolder holder(_lock); TextProperties::set_bin(bin); invalidate_no_measure(); } @@ -841,6 +912,7 @@ set_bin(const std::string &bin) { */ INLINE void TextNode:: clear_bin() { + MutexHolder holder(_lock); TextProperties::clear_bin(); invalidate_no_measure(); } @@ -858,6 +930,7 @@ clear_bin() { */ INLINE int TextNode:: set_draw_order(int draw_order) { + MutexHolder holder(_lock); invalidate_no_measure(); return TextProperties::set_draw_order(draw_order); } @@ -867,6 +940,7 @@ set_draw_order(int draw_order) { */ INLINE void TextNode:: clear_draw_order() { + MutexHolder holder(_lock); TextProperties::clear_draw_order(); invalidate_with_measure(); } @@ -877,6 +951,7 @@ clear_draw_order() { */ INLINE void TextNode:: set_tab_width(PN_stdfloat tab_width) { + MutexHolder holder(_lock); TextProperties::set_tab_width(tab_width); invalidate_with_measure(); } @@ -886,6 +961,7 @@ set_tab_width(PN_stdfloat tab_width) { */ INLINE void TextNode:: clear_tab_width() { + MutexHolder holder(_lock); TextProperties::clear_tab_width(); invalidate_with_measure(); } @@ -897,6 +973,7 @@ clear_tab_width() { */ INLINE void TextNode:: set_glyph_scale(PN_stdfloat glyph_scale) { + MutexHolder holder(_lock); TextProperties::set_glyph_scale(glyph_scale); invalidate_with_measure(); } @@ -906,6 +983,7 @@ set_glyph_scale(PN_stdfloat glyph_scale) { */ INLINE void TextNode:: clear_glyph_scale() { + MutexHolder holder(_lock); TextProperties::clear_glyph_scale(); invalidate_with_measure(); } @@ -917,6 +995,7 @@ clear_glyph_scale() { */ INLINE void TextNode:: set_glyph_shift(PN_stdfloat glyph_shift) { + MutexHolder holder(_lock); TextProperties::set_glyph_shift(glyph_shift); invalidate_with_measure(); } @@ -926,6 +1005,7 @@ set_glyph_shift(PN_stdfloat glyph_shift) { */ INLINE void TextNode:: clear_glyph_shift() { + MutexHolder holder(_lock); TextProperties::clear_glyph_shift(); invalidate_with_measure(); } @@ -936,6 +1016,7 @@ clear_glyph_shift() { */ INLINE void TextNode:: set_text(const std::string &text) { + MutexHolder holder(_lock); TextEncoder::set_text(text); invalidate_with_measure(); } @@ -948,6 +1029,7 @@ set_text(const std::string &text) { */ INLINE void TextNode:: set_text(const std::string &text, TextNode::Encoding encoding) { + MutexHolder holder(_lock); TextEncoder::set_text(text, encoding); invalidate_with_measure(); } @@ -957,6 +1039,7 @@ set_text(const std::string &text, TextNode::Encoding encoding) { */ INLINE void TextNode:: clear_text() { + MutexHolder holder(_lock); TextEncoder::clear_text(); invalidate_with_measure(); } @@ -966,6 +1049,7 @@ clear_text() { */ INLINE void TextNode:: append_text(const std::string &text) { + MutexHolder holder(_lock); TextEncoder::append_text(text); invalidate_with_measure(); } @@ -976,6 +1060,7 @@ append_text(const std::string &text) { */ INLINE void TextNode:: append_unicode_char(wchar_t character) { + MutexHolder holder(_lock); TextEncoder::append_unicode_char(character); invalidate_with_measure(); } @@ -1008,6 +1093,7 @@ calc_width(const std::string &line) const { */ INLINE void TextNode:: set_wtext(const std::wstring &wtext) { + MutexHolder holder(_lock); TextEncoder::set_wtext(wtext); invalidate_with_measure(); } @@ -1017,6 +1103,7 @@ set_wtext(const std::wstring &wtext) { */ INLINE void TextNode:: append_wtext(const std::wstring &wtext) { + MutexHolder holder(_lock); TextEncoder::append_wtext(wtext); invalidate_with_measure(); } @@ -1030,6 +1117,7 @@ append_wtext(const std::wstring &wtext) { */ INLINE std::wstring TextNode:: get_wordwrapped_wtext() const { + MutexHolder holder(_lock); check_measure(); return _wordwrapped_wtext; } @@ -1040,6 +1128,7 @@ get_wordwrapped_wtext() const { */ INLINE PN_stdfloat TextNode:: get_left() const { + MutexHolder holder(_lock); check_measure(); return _text_ul[0]; } @@ -1050,6 +1139,7 @@ get_left() const { */ INLINE PN_stdfloat TextNode:: get_right() const { + MutexHolder holder(_lock); check_measure(); return _text_lr[0]; } @@ -1060,6 +1150,7 @@ get_right() const { */ INLINE PN_stdfloat TextNode:: get_bottom() const { + MutexHolder holder(_lock); check_measure(); return _text_lr[1]; } @@ -1070,6 +1161,7 @@ get_bottom() const { */ INLINE PN_stdfloat TextNode:: get_top() const { + MutexHolder holder(_lock); check_measure(); return _text_ul[1]; } @@ -1079,6 +1171,7 @@ get_top() const { */ INLINE PN_stdfloat TextNode:: get_height() const { + MutexHolder holder(_lock); check_measure(); return _text_ul[1] - _text_lr[1]; } @@ -1088,6 +1181,7 @@ get_height() const { */ INLINE PN_stdfloat TextNode:: get_width() const { + MutexHolder holder(_lock); check_measure(); return _text_lr[0] - _text_ul[0]; } @@ -1098,6 +1192,7 @@ get_width() const { */ INLINE LPoint3 TextNode:: get_upper_left_3d() const { + MutexHolder holder(_lock); check_measure(); return _ul3d; } @@ -1108,6 +1203,7 @@ get_upper_left_3d() const { */ INLINE LPoint3 TextNode:: get_lower_right_3d() const { + MutexHolder holder(_lock); check_measure(); return _lr3d; } @@ -1118,10 +1214,22 @@ get_lower_right_3d() const { */ INLINE int TextNode:: get_num_rows() const { + MutexHolder holder(_lock); check_measure(); return _num_rows; } +/** + * Generates the text, according to the parameters indicated within the + * TextNode, and returns a Node that may be parented within the tree to + * represent it. + */ +PT(PandaNode) TextNode:: +generate() { + MutexHolder holder(_lock); + return do_generate(); +} + /** * Can be called after the TextNode has been fully configured, to force the * node to recompute its text immediately, rather than waiting for it to be @@ -1129,6 +1237,7 @@ get_num_rows() const { */ INLINE void TextNode:: update() { + MutexHolder holder(_lock); check_rebuild(); } @@ -1140,8 +1249,9 @@ update() { */ INLINE void TextNode:: force_update() { - invalidate_with_measure(); - check_rebuild(); + MutexHolder holder(_lock); + mark_internal_bounds_stale(); + do_rebuild(); } /** diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index a68ebba812..1ecfc1ea65 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -74,7 +74,7 @@ TextNode(const string &name) : PandaNode(name) { } if (text_small_caps) { - set_small_caps(true); + TextProperties::set_small_caps(true); } _frame_color.set(1.0f, 1.0f, 1.0f, 1.0f); @@ -277,10 +277,10 @@ void TextNode:: output(std::ostream &out) const { PandaNode::output(out); - check_rebuild(); + PT(PandaNode) internal_geom = do_get_internal_geom(); int geom_count = 0; - if (_internal_geom != nullptr) { - geom_count = count_geoms(_internal_geom); + if (internal_geom != nullptr) { + geom_count = count_geoms(internal_geom); } out << " (" << geom_count << " geoms)"; @@ -291,6 +291,7 @@ output(std::ostream &out) const { */ void TextNode:: write(std::ostream &out, int indent_level) const { + MutexHolder holder(_lock); PandaNode::write(out, indent_level); TextProperties::write(out, indent_level + 2); indent(out, indent_level + 2) @@ -301,13 +302,263 @@ write(std::ostream &out, int indent_level) const { << "text is " << get_text() << "\n"; } +/** + * Returns the actual node that is used internally to render the text, if the + * TextNode is parented within the scene graph. + * + * In general, you should not call this method. Call generate() instead if + * you want to get a handle to geometry that represents the text. This method + * is provided as a debugging aid only. + */ +PT(PandaNode) TextNode:: +get_internal_geom() const { + // Output a nuisance warning to discourage the naive from calling this + // method accidentally. + text_cat.info() + << "TextNode::get_internal_geom() called.\n"; + return do_get_internal_geom(); +} + +/** + * Returns the union of all attributes from SceneGraphReducer::AttribTypes + * that may not safely be applied to the vertices of this node. If this is + * nonzero, these attributes must be dropped at this node as a state change. + * + * This is a generalization of safe_to_transform(). + */ +int TextNode:: +get_unsafe_to_apply_attribs() const { + // We have no way to apply these kinds of attributes to our TextNode, so + // insist they get dropped into the PandaNode's basic state. + return + SceneGraphReducer::TT_tex_matrix | + SceneGraphReducer::TT_other; +} + +/** + * Applies whatever attributes are specified in the AccumulatedAttribs object + * (and by the attrib_types bitmask) to the vertices on this node, if + * appropriate. If this node uses geom arrays like a GeomNode, the supplied + * GeomTransformer may be used to unify shared arrays across multiple + * different nodes. + * + * This is a generalization of xform(). + */ +void TextNode:: +apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, + GeomTransformer &transformer) { + MutexHolder holder(_lock); + if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { + const LMatrix4 &mat = attribs._transform->get_mat(); + _transform *= mat; + + if ((_flags & F_needs_measure) == 0) { + // If we already have a measure, transform it too. We don't need to + // invalidate the 2-d parts, since that's not affected by the transform + // anyway. + _ul3d = _ul3d * mat; + _lr3d = _lr3d * mat; + } + } + if ((attrib_types & SceneGraphReducer::TT_color) != 0) { + if (attribs._color != nullptr) { + const ColorAttrib *ca = DCAST(ColorAttrib, attribs._color); + if (ca->get_color_type() == ColorAttrib::T_flat) { + const LColor &c = ca->get_color(); + TextProperties::set_text_color(c); + TextProperties::set_shadow_color(c); + _frame_color = c; + _card_color = c; + invalidate_no_measure(); + } + } + } + if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { + if (attribs._color_scale != nullptr) { + const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attribs._color_scale); + const LVecBase4 &s = csa->get_scale(); + if (s != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)) { + LVecBase4 tc = get_text_color(); + tc.componentwise_mult(s); + TextProperties::set_text_color(tc); + + LVecBase4 sc = get_shadow_color(); + sc.componentwise_mult(s); + TextProperties::set_shadow_color(sc); + + _frame_color.componentwise_mult(s); + _card_color.componentwise_mult(s); + + invalidate_no_measure(); + } + } + } + + // Now propagate the attributes down to our already-generated geometry, if + // we have any. + if ((_flags & F_needs_rebuild) == 0 && + _internal_geom != nullptr) { + SceneGraphReducer gr; + gr.apply_attribs(_internal_geom, attribs, attrib_types, transformer); + } +} + +/** + * This is used to support NodePath::calc_tight_bounds(). It is not intended + * to be called directly, and it has nothing to do with the normal Panda + * bounding-volume computation. + * + * If the node contains any geometry, this updates min_point and max_point to + * enclose its bounding box. found_any is to be set true if the node has any + * geometry at all, or left alone if it has none. This method may be called + * over several nodes, so it may enter with min_point, max_point, and + * found_any already set. + */ +CPT(TransformState) TextNode:: +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, + const TransformState *transform, Thread *current_thread) const { + CPT(TransformState) next_transform = + PandaNode::calc_tight_bounds(min_point, max_point, found_any, transform, + current_thread); + + PT(PandaNode) geom = do_get_internal_geom(); + if (geom != nullptr) { + geom->calc_tight_bounds(min_point, max_point, + found_any, next_transform, current_thread); + } + + return next_transform; +} + +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ +bool TextNode:: +cull_callback(CullTraverser *trav, CullTraverserData &data) { + + PT(PandaNode) internal_geom = do_get_internal_geom(); + if (internal_geom != nullptr) { + // Render the text with this node. + CullTraverserData next_data(data, internal_geom); + trav->traverse(next_data); + } + + // Now continue to render everything else below this node. + return true; +} + +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ +bool TextNode:: +is_renderable() const { + return true; +} + +/** + * Called when needed to recompute the node's _internal_bound object. Nodes + * that contain anything of substance should redefine this to do the right + * thing. + */ +void TextNode:: +compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, + int &internal_vertices, + int pipeline_stage, + Thread *current_thread) const { + // First, get ourselves a fresh, empty bounding volume. + PT(BoundingVolume) bound = new BoundingSphere; + + GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bound); + + // Now enclose the bounding box around the text. We can do this without + // actually generating the text, if we have at least measured it. + LPoint3 vertices[8]; + { + MutexHolder holder(_lock); + check_measure(); + + vertices[0].set(_ul3d[0], _ul3d[1], _ul3d[2]); + vertices[1].set(_ul3d[0], _ul3d[1], _lr3d[2]); + vertices[2].set(_ul3d[0], _lr3d[1], _ul3d[2]); + vertices[3].set(_ul3d[0], _lr3d[1], _lr3d[2]); + vertices[4].set(_lr3d[0], _ul3d[1], _ul3d[2]); + vertices[5].set(_lr3d[0], _ul3d[1], _lr3d[2]); + vertices[6].set(_lr3d[0], _lr3d[1], _ul3d[2]); + vertices[7].set(_lr3d[0], _lr3d[1], _lr3d[2]); + } + + gbv->around(vertices, vertices + 8); + + internal_bounds = bound; + internal_vertices = 0; // TODO: estimate this better. +} + +/** + * The recursive implementation of prepare_scene(). Don't call this directly; + * call PandaNode::prepare_scene() or NodePath::prepare_scene() instead. + */ +void TextNode:: +r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, + GeomTransformer &transformer, Thread *current_thread) { + + PT(PandaNode) child = do_get_internal_geom(); + if (child != nullptr) { + CPT(RenderState) child_state = node_state->compose(child->get_state()); + child->r_prepare_scene(gsg, child_state, transformer, current_thread); + } + + PandaNode::r_prepare_scene(gsg, node_state, transformer, current_thread); +} + +/** + * Removes any existing children of the TextNode, and adds the newly generated + * text instead. + */ +void TextNode:: +do_rebuild() { + nassertv(_lock.debug_is_locked()); + _flags &= ~(F_needs_rebuild | F_needs_measure); + _internal_geom = do_generate(); +} + + +/** + * Can be called in lieu of do_rebuild() to measure the text and set up the + * bounding boxes properly without actually assembling it. + */ +void TextNode:: +do_measure() { + // We no longer make this a special case. + do_rebuild(); +} + /** * Generates the text, according to the parameters indicated within the * TextNode, and returns a Node that may be parented within the tree to * represent it. */ PT(PandaNode) TextNode:: -generate() { +do_generate() { + nassertr(_lock.debug_is_locked(), nullptr); + PStatTimer timer(_text_generate_pcollector); if (text_cat.is_debug()) { text_cat.debug() @@ -408,20 +659,20 @@ generate() { // Now deal with the decorations. - if (has_card()) { + if (_flags & F_has_card) { PT(PandaNode) card_root; - if (has_card_border()) { + if (_flags & F_has_card_border) { card_root = make_card_with_border(); } else { card_root = make_card(); } card_root->set_transform(transform); - card_root->set_attrib(ColorAttrib::make_flat(get_card_color())); - if (get_card_color()[3] != 1.0f) { + card_root->set_attrib(ColorAttrib::make_flat(_card_color)); + if (_card_color[3] != 1.0f) { card_root->set_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha)); } - if (has_card_texture()) { - card_root->set_attrib(TextureAttrib::make(get_card_texture())); + if (_flags & F_has_card_texture) { + card_root->set_attrib(TextureAttrib::make(_card_texture)); } if (has_bin()) { @@ -437,17 +688,17 @@ generate() { card_root->add_child(root); root = card_root; - if (get_card_decal()) { + if (_flags & F_card_decal) { card_root->set_effect(DecalEffect::make()); } } - if (has_frame()) { + if (_flags & F_has_frame) { PT(PandaNode) frame_root = make_frame(); frame_root->set_transform(transform); root->add_child(frame_root, get_draw_order() + 1); - frame_root->set_attrib(ColorAttrib::make_flat(get_frame_color())); - if (get_frame_color()[3] != 1.0f) { + frame_root->set_attrib(ColorAttrib::make_flat(_frame_color)); + if (_frame_color[3] != 1.0f) { frame_root->set_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha)); } @@ -465,271 +716,35 @@ generate() { /** * Returns the actual node that is used internally to render the text, if the * TextNode is parented within the scene graph. - * - * In general, you should not call this method. Call generate() instead if - * you want to get a handle to geometry that represents the text. This method - * is provided as a debugging aid only. */ -PandaNode *TextNode:: -get_internal_geom() const { - // Output a nuisance warning to discourage the naive from calling this - // method accidentally. - text_cat.info() - << "TextNode::get_internal_geom() called.\n"; +PT(PandaNode) TextNode:: +do_get_internal_geom() const { + MutexHolder holder(_lock); check_rebuild(); return _internal_geom; } -/** - * Returns the union of all attributes from SceneGraphReducer::AttribTypes - * that may not safely be applied to the vertices of this node. If this is - * nonzero, these attributes must be dropped at this node as a state change. - * - * This is a generalization of safe_to_transform(). - */ -int TextNode:: -get_unsafe_to_apply_attribs() const { - // We have no way to apply these kinds of attributes to our TextNode, so - // insist they get dropped into the PandaNode's basic state. - return - SceneGraphReducer::TT_tex_matrix | - SceneGraphReducer::TT_other; -} - -/** - * Applies whatever attributes are specified in the AccumulatedAttribs object - * (and by the attrib_types bitmask) to the vertices on this node, if - * appropriate. If this node uses geom arrays like a GeomNode, the supplied - * GeomTransformer may be used to unify shared arrays across multiple - * different nodes. - * - * This is a generalization of xform(). - */ -void TextNode:: -apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, - GeomTransformer &transformer) { - if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { - const LMatrix4 &mat = attribs._transform->get_mat(); - _transform *= mat; - - if ((_flags & F_needs_measure) == 0) { - // If we already have a measure, transform it too. We don't need to - // invalidate the 2-d parts, since that's not affected by the transform - // anyway. - _ul3d = _ul3d * mat; - _lr3d = _lr3d * mat; - } - } - if ((attrib_types & SceneGraphReducer::TT_color) != 0) { - if (attribs._color != nullptr) { - const ColorAttrib *ca = DCAST(ColorAttrib, attribs._color); - if (ca->get_color_type() == ColorAttrib::T_flat) { - const LColor &c = ca->get_color(); - set_text_color(c); - set_frame_color(c); - set_card_color(c); - set_shadow_color(c); - } - } - } - if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - if (attribs._color_scale != nullptr) { - const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attribs._color_scale); - const LVecBase4 &s = csa->get_scale(); - if (s != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)) { - LVecBase4 tc = get_text_color(); - tc[0] *= s[0]; - tc[1] *= s[1]; - tc[2] *= s[2]; - tc[3] *= s[3]; - set_text_color(tc); - LVecBase4 sc = get_shadow_color(); - sc[0] *= s[0]; - sc[1] *= s[1]; - sc[2] *= s[2]; - sc[3] *= s[3]; - set_shadow_color(sc); - LVecBase4 fc = get_frame_color(); - fc[0] *= s[0]; - fc[1] *= s[1]; - fc[2] *= s[2]; - fc[3] *= s[3]; - set_frame_color(fc); - LVecBase4 cc = get_card_color(); - cc[0] *= s[0]; - cc[1] *= s[1]; - cc[2] *= s[2]; - cc[3] *= s[3]; - set_card_color(cc); - } - } - } - - // Now propagate the attributes down to our already-generated geometry, if - // we have any. - if ((_flags & F_needs_rebuild) == 0 && - _internal_geom != nullptr) { - SceneGraphReducer gr; - gr.apply_attribs(_internal_geom, attribs, attrib_types, transformer); - } -} - -/** - * This is used to support NodePath::calc_tight_bounds(). It is not intended - * to be called directly, and it has nothing to do with the normal Panda - * bounding-volume computation. - * - * If the node contains any geometry, this updates min_point and max_point to - * enclose its bounding box. found_any is to be set true if the node has any - * geometry at all, or left alone if it has none. This method may be called - * over several nodes, so it may enter with min_point, max_point, and - * found_any already set. - */ -CPT(TransformState) TextNode:: -calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, - const TransformState *transform, Thread *current_thread) const { - CPT(TransformState) next_transform = - PandaNode::calc_tight_bounds(min_point, max_point, found_any, transform, - current_thread); - - check_rebuild(); - - if (_internal_geom != nullptr) { - _internal_geom->calc_tight_bounds(min_point, max_point, - found_any, next_transform, current_thread); - } - - return next_transform; -} - -/** - * This function will be called during the cull traversal to perform any - * additional operations that should be performed at cull time. This may - * include additional manipulation of render state or additional - * visible/invisible decisions, or any other arbitrary operation. - * - * Note that this function will *not* be called unless set_cull_callback() is - * called in the constructor of the derived class. It is necessary to call - * set_cull_callback() to indicated that we require cull_callback() to be - * called. - * - * By the time this function is called, the node has already passed the - * bounding-volume test for the viewing frustum, and the node's transform and - * state have already been applied to the indicated CullTraverserData object. - * - * The return value is true if this node should be visible, or false if it - * should be culled. - */ -bool TextNode:: -cull_callback(CullTraverser *trav, CullTraverserData &data) { - check_rebuild(); - if (_internal_geom != nullptr) { - // Render the text with this node. - CullTraverserData next_data(data, _internal_geom); - trav->traverse(next_data); - } - - // Now continue to render everything else below this node. - return true; -} - -/** - * Returns true if there is some value to visiting this particular node during - * the cull traversal for any camera, false otherwise. This will be used to - * optimize the result of get_net_draw_show_mask(), so that any subtrees that - * contain only nodes for which is_renderable() is false need not be visited. - */ -bool TextNode:: -is_renderable() const { - return true; -} - -/** - * Called when needed to recompute the node's _internal_bound object. Nodes - * that contain anything of substance should redefine this to do the right - * thing. - */ -void TextNode:: -compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, - int &internal_vertices, - int pipeline_stage, - Thread *current_thread) const { - // First, get ourselves a fresh, empty bounding volume. - PT(BoundingVolume) bound = new BoundingSphere; - - GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bound); - - // Now enclose the bounding box around the text. We can do this without - // actually generating the text, if we have at least measured it. - check_measure(); - - LPoint3 vertices[8]; - vertices[0].set(_ul3d[0], _ul3d[1], _ul3d[2]); - vertices[1].set(_ul3d[0], _ul3d[1], _lr3d[2]); - vertices[2].set(_ul3d[0], _lr3d[1], _ul3d[2]); - vertices[3].set(_ul3d[0], _lr3d[1], _lr3d[2]); - vertices[4].set(_lr3d[0], _ul3d[1], _ul3d[2]); - vertices[5].set(_lr3d[0], _ul3d[1], _lr3d[2]); - vertices[6].set(_lr3d[0], _lr3d[1], _ul3d[2]); - vertices[7].set(_lr3d[0], _lr3d[1], _lr3d[2]); - - gbv->around(vertices, vertices + 8); - - internal_bounds = bound; - internal_vertices = 0; // TODO: estimate this better. -} - -/** - * The recursive implementation of prepare_scene(). Don't call this directly; - * call PandaNode::prepare_scene() or NodePath::prepare_scene() instead. - */ -void TextNode:: -r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, - GeomTransformer &transformer, Thread *current_thread) { - check_rebuild(); - - PandaNode *child = _internal_geom; - if (child != nullptr) { - CPT(RenderState) child_state = node_state->compose(child->get_state()); - child->r_prepare_scene(gsg, child_state, transformer, current_thread); - } - - PandaNode::r_prepare_scene(gsg, node_state, transformer, current_thread); -} - -/** - * Removes any existing children of the TextNode, and adds the newly generated - * text instead. - */ -void TextNode:: -do_rebuild() { - _flags &= ~(F_needs_rebuild | F_needs_measure); - _internal_geom = generate(); -} - - -/** - * Can be called in lieu of do_rebuild() to measure the text and set up the - * bounding boxes properly without actually assembling it. - */ -void TextNode:: -do_measure() { - // We no longer make this a special case. - do_rebuild(); -} - /** * Creates a frame around the text. */ PT(PandaNode) TextNode:: make_frame() { + nassertr(_lock.debug_is_locked(), nullptr); + nassertr((_flags & F_needs_measure) == 0, nullptr); + PT(GeomNode) frame_node = new GeomNode("frame"); - LVector4 dimensions = get_frame_actual(); - PN_stdfloat left = dimensions[0]; - PN_stdfloat right = dimensions[1]; - PN_stdfloat bottom = dimensions[2]; - PN_stdfloat top = dimensions[3]; + PN_stdfloat left = _frame_ul[0]; + PN_stdfloat right = _frame_lr[0]; + PN_stdfloat bottom = _frame_lr[1]; + PN_stdfloat top = _frame_ul[1]; + + if (_flags & F_frame_as_margin) { + left = _text_ul[0] - left; + right = _text_lr[0] + right; + bottom = _text_lr[1] - bottom; + top = _text_ul[1] + top; + } CPT(RenderAttrib) thick = RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _frame_width); CPT(RenderState) state = RenderState::make(thick); @@ -753,8 +768,8 @@ make_frame() { geom->add_primitive(frame); frame_node->add_geom(geom, state); - if (get_frame_corners()) { - PT(GeomPoints) corners = new GeomPoints(get_usage_hint()); + if (_flags & F_frame_corners) { + PT(GeomPoints) corners = new GeomPoints(_usage_hint); corners->add_consecutive_vertices(0, 4); PT(Geom) geom2 = new Geom(vdata); geom2->add_primitive(corners); @@ -769,13 +784,22 @@ make_frame() { */ PT(PandaNode) TextNode:: make_card() { + nassertr(_lock.debug_is_locked(), nullptr); + nassertr((_flags & F_needs_measure) == 0, nullptr); + PT(GeomNode) card_node = new GeomNode("card"); - LVector4 dimensions = get_card_actual(); - PN_stdfloat left = dimensions[0]; - PN_stdfloat right = dimensions[1]; - PN_stdfloat bottom = dimensions[2]; - PN_stdfloat top = dimensions[3]; + PN_stdfloat left = _card_ul[0]; + PN_stdfloat right = _card_lr[0]; + PN_stdfloat bottom = _card_lr[1]; + PN_stdfloat top = _card_ul[1]; + + if (_flags & F_card_as_margin) { + left = _text_ul[0] - left; + right = _text_lr[0] + right; + bottom = _text_lr[1] - bottom; + top = _text_ul[1] + top; + } PT(GeomVertexData) vdata = new GeomVertexData ("text", GeomVertexFormat::get_v3t2(), _usage_hint); @@ -793,7 +817,7 @@ make_card() { texcoord.set_data2(1.0f, 1.0f); texcoord.set_data2(1.0f, 0.0f); - PT(GeomTristrips) card = new GeomTristrips(get_usage_hint()); + PT(GeomTristrips) card = new GeomTristrips(_usage_hint); card->add_consecutive_vertices(0, 4); card->close_primitive(); @@ -812,13 +836,22 @@ make_card() { */ PT(PandaNode) TextNode:: make_card_with_border() { + nassertr(_lock.debug_is_locked(), nullptr); + nassertr((_flags & F_needs_measure) == 0, nullptr); + PT(GeomNode) card_node = new GeomNode("card"); - LVector4 dimensions = get_card_actual(); - PN_stdfloat left = dimensions[0]; - PN_stdfloat right = dimensions[1]; - PN_stdfloat bottom = dimensions[2]; - PN_stdfloat top = dimensions[3]; + PN_stdfloat left = _card_ul[0]; + PN_stdfloat right = _card_lr[0]; + PN_stdfloat bottom = _card_lr[1]; + PN_stdfloat top = _card_ul[1]; + + if (_flags & F_card_as_margin) { + left = _text_ul[0] - left; + right = _text_lr[0] + right; + bottom = _text_lr[1] - bottom; + top = _text_ul[1] + top; + } /* * we now create three tri-strips instead of one with vertices arranged as diff --git a/panda/src/text/textNode.h b/panda/src/text/textNode.h index 4f37f806f4..ecf7dcafcf 100644 --- a/panda/src/text/textNode.h +++ b/panda/src/text/textNode.h @@ -24,6 +24,8 @@ #include "pandaNode.h" #include "luse.h" #include "geom.h" +#include "pmutex.h" +#include "mutexHolder.h" /** * The primary interface to this module. This class does basic text assembly; @@ -225,11 +227,11 @@ PUBLISHED: INLINE int get_num_rows() const; - PT(PandaNode) generate(); + INLINE PT(PandaNode) generate(); INLINE void update(); INLINE void force_update(); - PandaNode *get_internal_geom() const; + PT(PandaNode) get_internal_geom() const; PUBLISHED: MAKE_PROPERTY(max_rows, get_max_rows, set_max_rows); @@ -312,12 +314,16 @@ private: void do_rebuild(); void do_measure(); + PT(PandaNode) do_generate(); + PT(PandaNode) do_get_internal_geom() const; + PT(PandaNode) make_frame(); PT(PandaNode) make_card(); PT(PandaNode) make_card_with_border(); static int count_geoms(PandaNode *node); + Mutex _lock; PT(PandaNode) _internal_geom; PT(Texture) _card_texture; From a6ad608207c42de37017313e0eb0fddde5cd21be Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 25 Sep 2018 11:38:03 +0200 Subject: [PATCH 200/360] tests: add some unit tests for TextNode --- tests/text/test_textnode.py | 106 ++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 tests/text/test_textnode.py diff --git a/tests/text/test_textnode.py b/tests/text/test_textnode.py new file mode 100644 index 0000000000..1f9a8349b9 --- /dev/null +++ b/tests/text/test_textnode.py @@ -0,0 +1,106 @@ +from panda3d import core + + +def test_textnode_card_as_margin(): + text = core.TextNode("test") + text.text = "Test" + + l, r, b, t = 0.1, 0.2, 0.3, 0.4 + text.set_card_as_margin(l, r, b, t) + + assert text.has_card() + assert text.is_card_as_margin() + assert text.get_card_as_set() == (l, r, b, t) + + card_actual = text.get_card_actual() + card_expect = core.LVecBase4( + text.get_left() - l, + text.get_right() + r, + text.get_bottom() - b, + text.get_top() + t) + assert card_actual == card_expect + + +def test_textnode_card_actual(): + text = core.TextNode("test") + text.text = "Test" + + l, r, b, t = 0.1, 0.2, 0.3, 0.4 + text.set_card_actual(l, r, b, t) + + assert text.has_card() + assert not text.is_card_as_margin() + assert text.get_card_as_set() == (l, r, b, t) + + card_actual = text.get_card_actual() + card_expect = core.LVecBase4(l, r, b, t) + assert card_actual == card_expect + + +def test_textnode_frame_as_margin(): + text = core.TextNode("test") + text.text = "Test" + + l, r, b, t = 0.1, 0.2, 0.3, 0.4 + text.set_frame_as_margin(l, r, b, t) + + assert text.has_frame() + assert text.is_frame_as_margin() + assert text.get_frame_as_set() == (l, r, b, t) + + frame_actual = text.get_frame_actual() + frame_expect = core.LVecBase4( + text.get_left() - l, + text.get_right() + r, + text.get_bottom() - b, + text.get_top() + t) + assert frame_actual == frame_expect + + +def test_textnode_frame_actual(): + text = core.TextNode("test") + text.text = "Test" + + l, r, b, t = 0.1, 0.2, 0.3, 0.4 + text.set_frame_actual(l, r, b, t) + + assert text.has_frame() + assert not text.is_frame_as_margin() + assert text.get_frame_as_set() == (l, r, b, t) + + frame_actual = text.get_frame_actual() + frame_expect = core.LVecBase4(l, r, b, t) + assert frame_actual == frame_expect + + +def test_textnode_flatten_color(): + text = core.TextNode("test") + text.text_color = (0, 0, 0, 1) + path = core.NodePath(text) + + color = core.LColor(1, 0, 0, 1) + path.set_color(color) + path.flatten_strong() + + assert text.text_color == color + assert text.shadow_color == color + assert text.frame_color == color + assert text.card_color == color + + +def test_textnode_flatten_colorscale(): + text = core.TextNode("test") + text.text_color = (1, 0, 0, 0) + text.shadow_color = (0, 1, 0, 0) + text.frame_color = (0, 0, 1, 0) + text.card_color = (0, 0, 0, 1) + path = core.NodePath(text) + + color = core.LColor(.5, .5, .5, .5) + path.set_color_scale(color) + path.flatten_strong() + + assert text.text_color == (.5, 0, 0, 0) + assert text.shadow_color == (0, .5, 0, 0) + assert text.frame_color == (0, 0, .5, 0) + assert text.card_color == (0, 0, 0, .5) From cd033c27e8f458d3c8e0fb19380eb2906a232435 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 25 Sep 2018 21:00:08 +0200 Subject: [PATCH 201/360] grutil: add thread safety to ShaderTerrainMesh --- panda/src/grutil/shaderTerrainMesh.I | 10 ++++++++++ panda/src/grutil/shaderTerrainMesh.cxx | 3 +++ panda/src/grutil/shaderTerrainMesh.h | 3 +++ 3 files changed, 16 insertions(+) diff --git a/panda/src/grutil/shaderTerrainMesh.I b/panda/src/grutil/shaderTerrainMesh.I index f6a66bc7f5..f4a6b4286e 100644 --- a/panda/src/grutil/shaderTerrainMesh.I +++ b/panda/src/grutil/shaderTerrainMesh.I @@ -22,6 +22,7 @@ * @param filename Heightfield texture */ INLINE void ShaderTerrainMesh::set_heightfield(Texture* heightfield) { + MutexHolder holder(_lock); _heightfield_tex = heightfield; } @@ -33,6 +34,7 @@ INLINE void ShaderTerrainMesh::set_heightfield(Texture* heightfield) { * @return Path to the heightfield */ INLINE Texture* ShaderTerrainMesh::get_heightfield() const { + MutexHolder holder(_lock); return _heightfield_tex; } @@ -54,6 +56,7 @@ INLINE Texture* ShaderTerrainMesh::get_heightfield() const { * @param chunk_size Size of the chunks, has to be a power of two */ INLINE void ShaderTerrainMesh::set_chunk_size(size_t chunk_size) { + MutexHolder holder(_lock); _chunk_size = chunk_size; } @@ -63,6 +66,7 @@ INLINE void ShaderTerrainMesh::set_chunk_size(size_t chunk_size) { * @return Chunk size */ INLINE size_t ShaderTerrainMesh::get_chunk_size() const { + MutexHolder holder(_lock); return _chunk_size; } @@ -81,6 +85,7 @@ INLINE size_t ShaderTerrainMesh::get_chunk_size() const { * @param generate_patches [description] */ INLINE void ShaderTerrainMesh::set_generate_patches(bool generate_patches) { + MutexHolder holder(_lock); _generate_patches = generate_patches; } @@ -92,6 +97,7 @@ INLINE void ShaderTerrainMesh::set_generate_patches(bool generate_patches) { * @return Whether to generate patches */ INLINE bool ShaderTerrainMesh::get_generate_patches() const { + MutexHolder holder(_lock); return _generate_patches; } @@ -107,6 +113,7 @@ INLINE bool ShaderTerrainMesh::get_generate_patches() const { * @param target_triangle_width Desired triangle width in pixels */ INLINE void ShaderTerrainMesh::set_target_triangle_width(PN_stdfloat target_triangle_width) { + MutexHolder holder(_lock); _target_triangle_width = target_triangle_width; } @@ -118,6 +125,7 @@ INLINE void ShaderTerrainMesh::set_target_triangle_width(PN_stdfloat target_tria * @return Target triangle width */ INLINE PN_stdfloat ShaderTerrainMesh::get_target_triangle_width() const { + MutexHolder holder(_lock); return _target_triangle_width; } @@ -131,6 +139,7 @@ INLINE PN_stdfloat ShaderTerrainMesh::get_target_triangle_width() const { * @param update_enabled Whether to update the terrain */ INLINE void ShaderTerrainMesh::set_update_enabled(bool update_enabled) { + MutexHolder holder(_lock); _update_enabled = update_enabled; } @@ -142,6 +151,7 @@ INLINE void ShaderTerrainMesh::set_update_enabled(bool update_enabled) { * @return Whether to update the terrain */ INLINE bool ShaderTerrainMesh::get_update_enabled() const { + MutexHolder holder(_lock); return _update_enabled; } diff --git a/panda/src/grutil/shaderTerrainMesh.cxx b/panda/src/grutil/shaderTerrainMesh.cxx index 44c8397279..a0f3c34690 100644 --- a/panda/src/grutil/shaderTerrainMesh.cxx +++ b/panda/src/grutil/shaderTerrainMesh.cxx @@ -122,6 +122,7 @@ ShaderTerrainMesh::ShaderTerrainMesh() : * @return true if the terrain was initialized, false if an error occured */ bool ShaderTerrainMesh::generate() { + MutexHolder holder(_lock); if (!do_check_heightfield()) return false; @@ -461,6 +462,7 @@ bool ShaderTerrainMesh::safe_to_combine() const { * @copydoc PandaNode::add_for_draw() */ void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &data) { + MutexHolder holder(_lock); // Make sure the terrain was properly initialized, and the geom was created // successfully @@ -711,6 +713,7 @@ void ShaderTerrainMesh::do_emit_chunk(Chunk* chunk, TraversalData* data) { * @return World-Space point */ LPoint3 ShaderTerrainMesh::uv_to_world(const LTexCoord& coord) const { + MutexHolder holder(_lock); nassertr(_heightfield_tex != nullptr, LPoint3(0)); // Heightfield not set yet nassertr(_heightfield_tex->has_ram_image(), LPoint3(0)); // Heightfield not in memory diff --git a/panda/src/grutil/shaderTerrainMesh.h b/panda/src/grutil/shaderTerrainMesh.h index c57a5d4e74..9c4f8d9a3a 100644 --- a/panda/src/grutil/shaderTerrainMesh.h +++ b/panda/src/grutil/shaderTerrainMesh.h @@ -25,6 +25,8 @@ #include "configVariableInt.h" #include "pStatCollector.h" #include "filename.h" +#include "pmutex.h" +#include "mutexHolder.h" #include extern ConfigVariableBool stm_use_hexagonal_layout; @@ -160,6 +162,7 @@ private: void do_emit_chunk(Chunk* chunk, TraversalData* data); bool do_check_lod_matches(Chunk* chunk, TraversalData* data); + Mutex _lock; Chunk _base_chunk; size_t _size; size_t _chunk_size; From 4c67861a289e3e0816cb1ee166d9761a4d4ebc84 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 25 Sep 2018 21:03:09 +0200 Subject: [PATCH 202/360] samples: set heightfield to clamp mode in shader-terrain sample --- samples/shader-terrain/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/samples/shader-terrain/main.py b/samples/shader-terrain/main.py index 92ff61467a..10bffb3767 100644 --- a/samples/shader-terrain/main.py +++ b/samples/shader-terrain/main.py @@ -34,7 +34,10 @@ class ShaderTerrainDemo(ShowBase): # Set a heightfield, the heightfield should be a 16-bit png and # have a quadratic size of a power of two. - self.terrain_node.heightfield = self.loader.loadTexture("heightfield.png") + heightfield = self.loader.loadTexture("heightfield.png") + heightfield.wrap_u = SamplerState.WM_clamp + heightfield.wrap_v = SamplerState.WM_clamp + self.terrain_node.heightfield = heightfield # Set the target triangle width. For a value of 10.0 for example, # the terrain will attempt to make every triangle 10 pixels wide on screen. From a099c852459be8a59ef1d8044c09ceea869cb3ed Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 25 Sep 2018 21:18:48 +0200 Subject: [PATCH 203/360] ShaderGenerator: fix broken handling of CO_undefined alpha operand Fixes #394 --- panda/src/pgraphnodes/shaderGenerator.cxx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index d954ddcafc..1b08e921b0 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -53,14 +53,22 @@ TypeHandle ShaderGenerator::_type_handle; #ifdef HAVE_CG -#define PACK_COMBINE(src0, op0, src1, op1, src2, op2) ( \ - ((uint16_t)src0) | ((((uint16_t)op0 - 1u) & 3u) << 3u) | \ - ((uint16_t)src1 << 5u) | ((((uint16_t)op1 - 1u) & 3u) << 8u) | \ - ((uint16_t)src2 << 10u) | ((((uint16_t)op2 - 1u) & 3u) << 13u)) - #define UNPACK_COMBINE_SRC(from, n) (TextureStage::CombineSource)((from >> ((uint16_t)n * 5u)) & 7u) #define UNPACK_COMBINE_OP(from, n) (TextureStage::CombineOperand)(((from >> (((uint16_t)n * 5u) + 3u)) & 3u) + 1u) +static inline uint16_t +pack_combine(TextureStage::CombineSource src0, TextureStage::CombineOperand op0, + TextureStage::CombineSource src1, TextureStage::CombineOperand op1, + TextureStage::CombineSource src2, TextureStage::CombineOperand op2) { + if (op0 == TextureStage::CO_undefined) op0 = TextureStage::CO_src_alpha; + if (op1 == TextureStage::CO_undefined) op1 = TextureStage::CO_src_alpha; + if (op2 == TextureStage::CO_undefined) op2 = TextureStage::CO_src_alpha; + + return ((uint16_t)src0) | ((((uint16_t)op0 - 1u) & 3u) << 3u) | + ((uint16_t)src1 << 5u) | ((((uint16_t)op1 - 1u) & 3u) << 8u) | + ((uint16_t)src2 << 10u) | ((((uint16_t)op2 - 1u) & 3u) << 13u); +} + static PStatCollector lookup_collector("*:Munge:ShaderGen:Lookup"); static PStatCollector synthesize_collector("*:Munge:ShaderGen:Synthesize"); @@ -399,11 +407,12 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { if (stage->get_alpha_scale() == 4) { info._flags |= ShaderKey::TF_alpha_scale_4; } - info._combine_rgb = PACK_COMBINE( + + info._combine_rgb = pack_combine( stage->get_combine_rgb_source0(), stage->get_combine_rgb_operand0(), stage->get_combine_rgb_source1(), stage->get_combine_rgb_operand1(), stage->get_combine_rgb_source2(), stage->get_combine_rgb_operand2()); - info._combine_alpha = PACK_COMBINE( + info._combine_alpha = pack_combine( stage->get_combine_alpha_source0(), stage->get_combine_alpha_operand0(), stage->get_combine_alpha_source1(), stage->get_combine_alpha_operand1(), stage->get_combine_alpha_source2(), stage->get_combine_alpha_operand2()); From 5ae38a8a924d839cba7a5d0a99112909c533787c Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 27 Sep 2018 22:14:47 +0200 Subject: [PATCH 204/360] Fix crash loading from search path Possible fix for #395 --- dtool/src/prc/configVariableSearchPath.I | 8 ++++++-- dtool/src/prc/configVariableSearchPath.h | 2 +- panda/src/pgraph/loader.cxx | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dtool/src/prc/configVariableSearchPath.I b/dtool/src/prc/configVariableSearchPath.I index 89a9ac7df9..37c4383c02 100644 --- a/dtool/src/prc/configVariableSearchPath.I +++ b/dtool/src/prc/configVariableSearchPath.I @@ -229,9 +229,13 @@ get_num_directories() const { /** * Returns the nth directory on the search list. */ -INLINE const Filename &ConfigVariableSearchPath:: +INLINE Filename ConfigVariableSearchPath:: get_directory(size_t n) const { - return get_value().get_directory(n); + Filename dir; + _lock.lock(); + dir = _cache.get_directory(n); + _lock.unlock(); + return dir; } /** diff --git a/dtool/src/prc/configVariableSearchPath.h b/dtool/src/prc/configVariableSearchPath.h index 12ad1c54c9..ca575c078a 100644 --- a/dtool/src/prc/configVariableSearchPath.h +++ b/dtool/src/prc/configVariableSearchPath.h @@ -66,7 +66,7 @@ PUBLISHED: INLINE bool is_empty() const; INLINE size_t get_num_directories() const; - INLINE const Filename &get_directory(size_t n) const; + INLINE Filename get_directory(size_t n) const; MAKE_SEQ(get_directories, get_num_directories, get_directory); MAKE_SEQ_PROPERTY(directories, get_num_directories, get_directory); diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 03ae0e0587..3c04578a55 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -207,7 +207,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const { if (search) { // Look for the file along the model path. - const ConfigVariableSearchPath &model_path = get_model_path(); + DSearchPath model_path(get_model_path()); int num_dirs = model_path.get_num_directories(); for (int i = 0; i < num_dirs; ++i) { Filename pathname(model_path.get_directory(i), this_filename); From c43d9b50029c59db212be10c0d31f89653f7b6db Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 27 Sep 2018 22:23:10 +0200 Subject: [PATCH 205/360] tests: fix issue with double-precision TextNode tests --- tests/text/test_textnode.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/text/test_textnode.py b/tests/text/test_textnode.py index 1f9a8349b9..e96c9e5371 100644 --- a/tests/text/test_textnode.py +++ b/tests/text/test_textnode.py @@ -82,10 +82,10 @@ def test_textnode_flatten_color(): path.set_color(color) path.flatten_strong() - assert text.text_color == color - assert text.shadow_color == color - assert text.frame_color == color - assert text.card_color == color + assert text.text_color.almost_equal(color) + assert text.shadow_color.almost_equal(color) + assert text.frame_color.almost_equal(color) + assert text.card_color.almost_equal(color) def test_textnode_flatten_colorscale(): @@ -100,7 +100,7 @@ def test_textnode_flatten_colorscale(): path.set_color_scale(color) path.flatten_strong() - assert text.text_color == (.5, 0, 0, 0) - assert text.shadow_color == (0, .5, 0, 0) - assert text.frame_color == (0, 0, .5, 0) - assert text.card_color == (0, 0, 0, .5) + assert text.text_color.almost_equal((.5, 0, 0, 0)) + assert text.shadow_color.almost_equal((0, .5, 0, 0)) + assert text.frame_color.almost_equal((0, 0, .5, 0)) + assert text.card_color.almost_equal((0, 0, 0, .5)) From fac82e6dcaeda1cb205ecdb1f7fcd0a04c883893 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 28 Sep 2018 13:19:36 +0200 Subject: [PATCH 206/360] pgraph: fix precision issues with Color(Scale)Attrib quantization --- panda/src/pgraph/colorAttrib.cxx | 10 +++++----- panda/src/pgraph/colorScaleAttrib.cxx | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/panda/src/pgraph/colorAttrib.cxx b/panda/src/pgraph/colorAttrib.cxx index 7bfbecee79..129f5a9184 100644 --- a/panda/src/pgraph/colorAttrib.cxx +++ b/panda/src/pgraph/colorAttrib.cxx @@ -133,17 +133,17 @@ get_hash_impl() const { } /** - * Quantizes the color color to the nearest multiple of 1000, just to prevent + * Quantizes the flat color to the nearest multiple of 1024, just to prevent * runaway accumulation of only slightly-different ColorAttribs. */ void ColorAttrib:: quantize_color() { switch (_type) { case T_flat: - _color[0] = cfloor(_color[0] * 1000.0f + 0.5f) * 0.001f; - _color[1] = cfloor(_color[1] * 1000.0f + 0.5f) * 0.001f; - _color[2] = cfloor(_color[2] * 1000.0f + 0.5f) * 0.001f; - _color[3] = cfloor(_color[3] * 1000.0f + 0.5f) * 0.001f; + _color[0] = cfloor(_color[0] * 1024.0f + 0.5f) / 1024.0f; + _color[1] = cfloor(_color[1] * 1024.0f + 0.5f) / 1024.0f; + _color[2] = cfloor(_color[2] * 1024.0f + 0.5f) / 1024.0f; + _color[3] = cfloor(_color[3] * 1024.0f + 0.5f) / 1024.0f; break; case T_off: diff --git a/panda/src/pgraph/colorScaleAttrib.cxx b/panda/src/pgraph/colorScaleAttrib.cxx index 088c3142ef..04001dd0ab 100644 --- a/panda/src/pgraph/colorScaleAttrib.cxx +++ b/panda/src/pgraph/colorScaleAttrib.cxx @@ -230,15 +230,15 @@ invert_compose_impl(const RenderAttrib *other) const { } /** - * Quantizes the color scale to the nearest multiple of 1000, just to prevent + * Quantizes the color scale to the nearest multiple of 1024, just to prevent * runaway accumulation of only slightly-different ColorScaleAttribs. */ void ColorScaleAttrib:: quantize_scale() { - _scale[0] = cfloor(_scale[0] * 1000.0f + 0.5f) * 0.001f; - _scale[1] = cfloor(_scale[1] * 1000.0f + 0.5f) * 0.001f; - _scale[2] = cfloor(_scale[2] * 1000.0f + 0.5f) * 0.001f; - _scale[3] = cfloor(_scale[3] * 1000.0f + 0.5f) * 0.001f; + _scale[0] = cfloor(_scale[0] * 1024.0f + 0.5f) / 1024.0f; + _scale[1] = cfloor(_scale[1] * 1024.0f + 0.5f) / 1024.0f; + _scale[2] = cfloor(_scale[2] * 1024.0f + 0.5f) / 1024.0f; + _scale[3] = cfloor(_scale[3] * 1024.0f + 0.5f) / 1024.0f; } /** From cd9673ae9b10123e9376a52fd29bb93e2d39092f Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 28 Sep 2018 14:19:40 +0200 Subject: [PATCH 207/360] tests: fix pytest deprecation warnings --- tests/interrogate/test_property.py | 34 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/interrogate/test_property.py b/tests/interrogate/test_property.py index e39f45f9dc..4d521d03e5 100755 --- a/tests/interrogate/test_property.py +++ b/tests/interrogate/test_property.py @@ -2,7 +2,11 @@ import sys import pytest from panda3d import core from contextlib import contextmanager -import collections + +if sys.version_info >= (3, 3): + import collections.abc as collections_abc +else: + import _abcoll as collections_abc @contextmanager @@ -52,7 +56,6 @@ def test_property2(): # The next tests are for MAKE_SEQ_PROPERTY. -@pytest.fixture def seq_property(*items): """ Returns a sequence property initialized with the given items. """ @@ -73,11 +76,11 @@ item_c = core.CollisionSphere((0, 0, 0), 3) def test_seq_property_abc(): prop = seq_property() - assert isinstance(prop, collections.Container) - assert isinstance(prop, collections.Sized) - assert isinstance(prop, collections.Iterable) - assert isinstance(prop, collections.MutableSequence) - assert isinstance(prop, collections.Sequence) + assert isinstance(prop, collections_abc.Container) + assert isinstance(prop, collections_abc.Sized) + assert isinstance(prop, collections_abc.Iterable) + assert isinstance(prop, collections_abc.MutableSequence) + assert isinstance(prop, collections_abc.Sequence) def test_seq_property_empty(): @@ -411,7 +414,6 @@ def test_seq_property_extend(): # The next tests are for MAKE_MAP_PROPERTY. -@pytest.fixture def map_property(**items): """ Returns a mapping property initialized with the given values. """ @@ -425,11 +427,11 @@ def map_property(**items): def test_map_property_abc(): prop = map_property() - assert isinstance(prop, collections.Container) - assert isinstance(prop, collections.Sized) - assert isinstance(prop, collections.Iterable) - assert isinstance(prop, collections.MutableMapping) - assert isinstance(prop, collections.Mapping) + assert isinstance(prop, collections_abc.Container) + assert isinstance(prop, collections_abc.Sized) + assert isinstance(prop, collections_abc.Iterable) + assert isinstance(prop, collections_abc.MutableMapping) + assert isinstance(prop, collections_abc.Mapping) def test_map_property_empty(): @@ -607,19 +609,19 @@ def test_map_property_update(): def test_map_property_keys(): prop = map_property(key='value', key2='value2') - assert isinstance(prop.keys(), collections.MappingView) + assert isinstance(prop.keys(), collections_abc.MappingView) assert frozenset(prop.keys()) == frozenset(('key', 'key2')) def test_map_property_values(): prop = map_property(key='value', key2='value2') - assert isinstance(prop.values(), collections.ValuesView) + assert isinstance(prop.values(), collections_abc.ValuesView) assert frozenset(prop.values()) == frozenset(('value', 'value2')) def test_map_property_items(): prop = map_property(key='value', key2='value2') - assert isinstance(prop.items(), collections.MappingView) + assert isinstance(prop.items(), collections_abc.MappingView) assert frozenset(prop.items()) == frozenset((('key', 'value'), ('key2', 'value2'))) From 183d66a5c2620034854a79e2e2e3b6f78f7e59f9 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 28 Sep 2018 14:20:47 +0200 Subject: [PATCH 208/360] pipeline: fix compiler warning due to PAUSE symbol redefined --- panda/src/pipeline/conditionVarSpinlockImpl.cxx | 2 ++ panda/src/pipeline/reMutexSpinlockImpl.cxx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.cxx b/panda/src/pipeline/conditionVarSpinlockImpl.cxx index d35d8cd1f7..2b4be0d4e7 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.cxx +++ b/panda/src/pipeline/conditionVarSpinlockImpl.cxx @@ -58,4 +58,6 @@ wait(double timeout) { _mutex.lock(); } +#undef PAUSE + #endif // MUTEX_SPINLOCK diff --git a/panda/src/pipeline/reMutexSpinlockImpl.cxx b/panda/src/pipeline/reMutexSpinlockImpl.cxx index 0de12f986f..de0b2c0355 100644 --- a/panda/src/pipeline/reMutexSpinlockImpl.cxx +++ b/panda/src/pipeline/reMutexSpinlockImpl.cxx @@ -54,4 +54,6 @@ try_lock() { } } +#undef PAUSE + #endif // MUTEX_SPINLOCK From 87d1048f7913834a2e78dc5b45182007d00e2253 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 30 Sep 2018 15:43:32 -0600 Subject: [PATCH 209/360] mathutil: mersenne.h parameters should not be an enum This makes no sense as an enum; they're constants, so they should be static const. --- panda/src/mathutil/mersenne.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/panda/src/mathutil/mersenne.h b/panda/src/mathutil/mersenne.h index 7bcb00cb8f..15d96029e4 100644 --- a/panda/src/mathutil/mersenne.h +++ b/panda/src/mathutil/mersenne.h @@ -69,14 +69,12 @@ PUBLISHED: }; private: - enum { - // Period parameters - N = 624, - M = 397, - MATRIX_A = 0x9908b0dfUL, // constant vector a - UPPER_MASK = 0x80000000UL, // most significant w-r bits - LOWER_MASK = 0x7fffffffUL, // least significant r bits - }; + // Period parameters + static const unsigned long N = 624; + static const unsigned long M = 397; + static const unsigned long MATRIX_A = 0x9908b0dfUL; // constant vector a + static const unsigned long UPPER_MASK = 0x80000000UL; // most significant w-r bits + static const unsigned long LOWER_MASK = 0x7fffffffUL; // least significant r bits unsigned long mt[N]; // the array for the state vector unsigned int mti; // mti==N+1 means mt[N] is not initialized From 51497da8fbe38985677d38f079b1cf79ae183020 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 7 Oct 2018 01:33:18 -0600 Subject: [PATCH 210/360] movies: Fix missing include --- panda/src/movies/movieTypeRegistry.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/panda/src/movies/movieTypeRegistry.cxx b/panda/src/movies/movieTypeRegistry.cxx index 51468ac2a4..5bc8228bb4 100644 --- a/panda/src/movies/movieTypeRegistry.cxx +++ b/panda/src/movies/movieTypeRegistry.cxx @@ -12,10 +12,12 @@ */ #include "movieTypeRegistry.h" + #include "string_utils.h" #include "config_movies.h" #include "config_putil.h" #include "load_dso.h" +#include "reMutexHolder.h" using std::endl; using std::string; From 8d147056894ab4af3936aa3200a5adee23781891 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 7 Oct 2018 01:36:18 -0600 Subject: [PATCH 211/360] interrogate: Fix typo --- dtool/src/interrogate/interrogateBuilder.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index f579f1586d..15607c95ea 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -2943,7 +2943,7 @@ define_method(CPPInstance *function, InterrogateType &itype, // specifically flag get_class_type() as published. bool force_publish = false; if (function->get_simple_name() == "get_class_type" && - (function->_storage_class && CPPInstance::SC_static) != 0 && + (function->_storage_class & CPPInstance::SC_static) != 0 && function->_vis <= V_public) { force_publish = true; } From 83753405820bcf4884d78e116eb2f8f31c4151a7 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 20:24:19 +0200 Subject: [PATCH 212/360] py_panda: fix TypeError being raised instead of AttributeError This prevented doing something like hasattr(vec3, "stuff") --- dtool/src/interrogatedb/py_panda.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index e900ab0e7f..42bcdb9a35 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -235,8 +235,8 @@ PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute) { "'%.100s' object has no attribute '%.200s'", Py_TYPE(obj)->tp_name, attribute); - Py_INCREF(PyExc_TypeError); - PyErr_Restore(PyExc_TypeError, message, nullptr); + Py_INCREF(PyExc_AttributeError); + PyErr_Restore(PyExc_AttributeError, message, nullptr); return nullptr; } From 8cb048022242db4be1fa18ef66fbc5fc934c107e Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 20:25:08 +0200 Subject: [PATCH 213/360] readme: update Win build instructions to mention MSVC 2017 --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cf45f0dfd2..3a088a5cc1 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,9 @@ Building Panda3D Windows ------- -We currently build using the Microsoft Visual C++ 2015 compiler. You will -also need to install the [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk), +You can build Panda3D with the Microsoft Visual C++ 2015 or 2017 compiler, +which can be downloaded for free from the [Visual Studio site](https://visualstudio.microsoft.com/downloads/). +You will also need to install the [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk), and if you intend to target Windows XP, you will also need the [Windows 7.1 SDK](https://www.microsoft.com/en-us/download/details.aspx?id=8279). @@ -58,11 +59,12 @@ http://rdb.name/thirdparty-vc14-x64.7z http://rdb.name/thirdparty-vc14.7z After acquiring these dependencies, you may simply build Panda3D from the -command prompt using the following command. (Add the `--windows-sdk=10` -option if you don't need to support Windows XP.) +command prompt using the following command. (Change `14.1` to `14` if you are +using Visual C++ 2015 instead of 2017. Add the `--windows-sdk=10` option if +you don't need to support Windows XP and did not install the Windows 7.1 SDK.) ```bash -makepanda\makepanda.bat --everything --installer --no-eigen --threads=2 +makepanda\makepanda.bat --everything --installer --msvc-version=14.1 --no-eigen --threads=2 ``` When the build succeeds, it will produce an .exe file that you can use to From 7d3b7036acec39082abc462f11b0a0dc18f14bae Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 20:25:53 +0200 Subject: [PATCH 214/360] readme: suggest libassimp-dev and libopenexr-dev on Ubuntu --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a088a5cc1..14ab95e8b1 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ If you are on Ubuntu, this command should cover the most frequently used third-party packages: ```bash -sudo apt-get install build-essential pkg-config python-dev libpng-dev libjpeg-dev libtiff-dev zlib1g-dev libssl-dev libx11-dev libgl1-mesa-dev libxrandr-dev libxxf86dga-dev libxcursor-dev bison flex libfreetype6-dev libvorbis-dev libeigen3-dev libopenal-dev libode-dev libbullet-dev nvidia-cg-toolkit libgtk2.0-dev +sudo apt-get install build-essential pkg-config python-dev libpng-dev libjpeg-dev libtiff-dev zlib1g-dev libssl-dev libx11-dev libgl1-mesa-dev libxrandr-dev libxxf86dga-dev libxcursor-dev bison flex libfreetype6-dev libvorbis-dev libeigen3-dev libopenal-dev libode-dev libbullet-dev nvidia-cg-toolkit libgtk2.0-dev libassimp-dev libopenexr-dev ``` Once Panda3D has built, you can either install the .deb or .rpm package that From 86c9d11a538d3485012de438419a1e1642b91941 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 20:26:24 +0200 Subject: [PATCH 215/360] readme: add Android/termux build instructions --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 14ab95e8b1..43feb9b19c 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,36 @@ python3.6 makepanda/makepanda.py --everything --installer --no-egl --no-gles --n If successful, this will produce a .pkg file in the root of the source directory which you can install using `pkg install`. +Android +------- + +Note: building on Android is very experimental and not guaranteed to work. + +You can experimentally build the Android Python runner via the [termux](https://termux.com/) +shell. You will need to install [Termux](https://play.google.com/store/apps/details?id=com.termux) +and [Termux API](https://play.google.com/store/apps/details?id=com.termux.api) +from the Play Store. Many of the dependencies can be installed by running the +following command in the Termux shell: + +```bash +pkg install python-dev termux-tools ndk-stl ndk-sysroot clang libvorbis-dev libopus-dev opusfile-dev openal-soft-dev freetype-dev harfbuzz-dev libpng-dev ecj4.6 dx patchelf aapt apksigner libcrypt-dev +``` + +Then, you can build and install the .apk right away using these commands: + +```bash +python makepanda/makepanda.py --everything --target android-21 --installer +xdg-open panda3d.apk +``` + +To launch a Python program from Termux, you can use the `run_python.sh` script +inside the `panda/src/android` directory. It will launch Python in a separate +activity, load it with the Python script you passed as argument, and use a +socket for returning the command-line output to the Termux shell. Do note +that this requires the Python application to reside on the SD card and that +Termux needs to be set up with access to the SD card (using the +`termux-setup-storage` command). + Running Tests ============= From b0c9000000f2da908478826e8e7614dfd5438e75 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 21:41:02 +0200 Subject: [PATCH 216/360] display: fix assert when app exits before window fully opens Possibly addressing #403 --- panda/src/display/graphicsEngine.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index dd637d7a9a..57a592f05d 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -593,8 +593,7 @@ remove_all_windows() { Windows old_windows; old_windows.swap(_windows); Windows::iterator wi; - for (wi = old_windows.begin(); wi != old_windows.end(); ++wi) { - GraphicsOutput *win = (*wi); + for (GraphicsOutput *win : old_windows) { nassertv(win != nullptr); do_remove_window(win, current_thread); GraphicsStateGuardian *gsg = win->get_gsg(); @@ -605,6 +604,14 @@ remove_all_windows() { { MutexHolder new_windows_holder(_new_windows_lock, current_thread); + for (GraphicsOutput *win : _new_windows) { + nassertv(win != nullptr); + do_remove_window(win, current_thread); + GraphicsStateGuardian *gsg = win->get_gsg(); + if (gsg != nullptr) { + gsg->release_all(); + } + } _new_windows.clear(); } From e1af4abf11ef1600ee686a8fa603506293c554c1 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 21:42:02 +0200 Subject: [PATCH 217/360] glgsg: fix sRGB for FBOs created from non-sRGB host window In this case _current_properties in begin_frame() will not have srgb_color set, as the current props are set by the host window --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 66a9e6d407..eab850bdba 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -283,6 +283,13 @@ begin_frame(FrameMode mode, Thread *current_thread) { rebuild_bitplanes(); } + // The host window may not have had sRGB enabled, so we need to do this. +#ifndef OPENGLES + if (get_fb_properties().get_srgb_color()) { + glEnable(GL_FRAMEBUFFER_SRGB); + } +#endif + _gsg->set_current_properties(&get_fb_properties()); report_my_gl_errors(); return true; From 51414466da2f241157e075c39da6ac35ac05b32d Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 22:52:49 +0200 Subject: [PATCH 218/360] display: ignore material if no lights are applied This fixes materials suddenly showing up when a color scale is applied and color-scale-via-lighting is set. Fixes #404 --- panda/src/display/standardMunger.cxx | 23 ++++++++++++++++++++++- panda/src/display/standardMunger.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/panda/src/display/standardMunger.cxx b/panda/src/display/standardMunger.cxx index 5d2a3f5102..94f376e99b 100644 --- a/panda/src/display/standardMunger.cxx +++ b/panda/src/display/standardMunger.cxx @@ -36,7 +36,8 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, _munge_color(false), _munge_color_scale(false), _auto_shader(false), - _shader_skinning(false) + _shader_skinning(false), + _remove_material(false) { const ShaderAttrib *shader_attrib; state->get_attrib_def(shader_attrib); @@ -94,6 +95,19 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, // effort to detect this contrived situation and handle it correctly. } } + + // If we have no lights but do have a material, we will need to remove it so + // that it won't appear when we enable color scale via lighting. + const LightAttrib *light_attrib; + const MaterialAttrib *material_attrib; + if (get_gsg()->get_color_scale_via_lighting() && + (!state->get_attrib(light_attrib) || !light_attrib->has_any_on_light()) && + state->get_attrib(material_attrib) && + material_attrib->get_material() != nullptr && + shader_attrib->get_shader() == nullptr) { + _remove_material = true; + _should_munge_state = true; + } } /** @@ -291,6 +305,9 @@ compare_to_impl(const GeomMunger *other) const { if (_auto_shader != om->_auto_shader) { return (int)_auto_shader - (int)om->_auto_shader; } + if (_remove_material != om->_remove_material) { + return (int)_remove_material - (int)om->_remove_material; + } return StateMunger::compare_to_impl(other); } @@ -344,5 +361,9 @@ munge_state_impl(const RenderState *state) { munged_state = munged_state->remove_attrib(ColorScaleAttrib::get_class_slot()); } + if (_remove_material) { + munged_state = munged_state->remove_attrib(MaterialAttrib::get_class_slot()); + } + return munged_state; } diff --git a/panda/src/display/standardMunger.h b/panda/src/display/standardMunger.h index 05e8ee0344..5703fd01b5 100644 --- a/panda/src/display/standardMunger.h +++ b/panda/src/display/standardMunger.h @@ -55,6 +55,7 @@ private: bool _munge_color_scale; bool _auto_shader; bool _shader_skinning; + bool _remove_material; LColor _color; LVecBase4 _color_scale; From a9ff8a22f0e76218220010189de375dd48d2741b Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 23:00:17 +0200 Subject: [PATCH 219/360] makepanda: enable Assimp in default Confauto.prc if built --- makepanda/confauto.in | 5 +++++ makepanda/makepanda.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/makepanda/confauto.in b/makepanda/confauto.in index 608a6daf68..41655f1bbc 100644 --- a/makepanda/confauto.in +++ b/makepanda/confauto.in @@ -21,6 +21,11 @@ load-file-type egg pandaegg +# If we built with Assimp support, we can enable the Assimp loader, +# which allows us to load many model formats natively. + +load-file-type p3assimp + # These entries work very similar to load-file-type, except they are # used by the MovieVideo and MovieAudio code to determine which module # should be loaded in order to decode files of the given extension. diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index e371fbd3e8..a81ea7fe56 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2882,6 +2882,9 @@ else: # otherwise, disable it. confautoprc = confautoprc.replace('#st#', '#') +if PkgSkip("ASSIMP"): + confautoprc = confautoprc.replace("load-file-type p3assimp", "#load-file-type p3assimp") + if (os.path.isfile("makepanda/myconfig.in")): configprc = ReadFile("makepanda/myconfig.in") else: From 80951b3268a4894903b8cff0555bc535c79a7b36 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 23:02:50 +0200 Subject: [PATCH 220/360] task: provide more properties on AsyncTask --- panda/src/event/asyncTask.h | 21 +++++++++++++++++++++ panda/src/event/pythonTask.h | 7 ------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/panda/src/event/asyncTask.h b/panda/src/event/asyncTask.h index f5871ae2f2..5a7a2cd805 100644 --- a/panda/src/event/asyncTask.h +++ b/panda/src/event/asyncTask.h @@ -99,6 +99,27 @@ PUBLISHED: virtual void output(std::ostream &out) const; +PUBLISHED: + MAKE_PROPERTY(state, get_state); + MAKE_PROPERTY(alive, is_alive); + MAKE_PROPERTY(manager, get_manager); + + // The name of this task. + MAKE_PROPERTY(name, get_name, set_name); + + // This is a number guaranteed to be unique for each different AsyncTask + // object in the universe. + MAKE_PROPERTY(id, get_task_id); + + MAKE_PROPERTY(task_chain, get_task_chain, set_task_chain); + MAKE_PROPERTY(sort, get_sort, set_sort); + MAKE_PROPERTY(priority, get_priority, set_priority); + MAKE_PROPERTY(done_event, get_done_event, set_done_event); + + MAKE_PROPERTY(dt, get_dt); + MAKE_PROPERTY(max_dt, get_max_dt); + MAKE_PROPERTY(average_dt, get_average_dt); + protected: void jump_to_task_chain(AsyncTaskManager *manager); DoneStatus unlock_and_do_task(); diff --git a/panda/src/event/pythonTask.h b/panda/src/event/pythonTask.h index 3771d46d8b..06ff8b6fe4 100644 --- a/panda/src/event/pythonTask.h +++ b/panda/src/event/pythonTask.h @@ -61,9 +61,6 @@ PUBLISHED: int __clear__(); PUBLISHED: - // The name of this task. - MAKE_PROPERTY(name, get_name, set_name); - // The amount of seconds that have elapsed since the task was started, // according to the task manager's clock. MAKE_PROPERTY(time, get_elapsed_time); @@ -88,10 +85,6 @@ PUBLISHED: // according to the task manager's clock. MAKE_PROPERTY(frame, get_elapsed_frames); - // This is a number guaranteed to be unique for each different AsyncTask - // object in the universe. - MAKE_PROPERTY(id, get_task_id); - // This is a special variable to hold the instance dictionary in which // custom variables may be stored. PyObject *__dict__; From 102a256b05092f97a75a221b18dd3d86253a7625 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 7 Oct 2018 23:03:07 +0200 Subject: [PATCH 221/360] tests: remove accidentally added debug image output --- tests/display/test_depth_buffer.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/display/test_depth_buffer.py b/tests/display/test_depth_buffer.py index 8581fe47ea..c655758703 100644 --- a/tests/display/test_depth_buffer.py +++ b/tests/display/test_depth_buffer.py @@ -91,8 +91,6 @@ def render_depth_pixel(region, distance, near, far, clear=None, write=True): region.window.engine.render_frame() region.window.clear_render_textures() - depth_texture.write("test2.png") - col = core.LColor() depth_texture.peek().lookup(col, 0.5, 0.5) return col[0] From 914ef2e13d497c0dec444fd82ab80dd08f15de61 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 8 Oct 2018 00:59:22 +0200 Subject: [PATCH 222/360] tests: add various unit tests for color-related render states --- tests/display/test_color_buffer.py | 271 +++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100644 tests/display/test_color_buffer.py diff --git a/tests/display/test_color_buffer.py b/tests/display/test_color_buffer.py new file mode 100644 index 0000000000..dab73cbbb8 --- /dev/null +++ b/tests/display/test_color_buffer.py @@ -0,0 +1,271 @@ +from panda3d import core +import pytest + +TEST_COLOR = core.LColor(1, 127/255.0, 0, 127/255.0) +TEST_COLOR_SCALE = core.LVecBase4(0.5, 0.5, 0.5, 0.5) +TEST_SCALED_COLOR = core.LColor(TEST_COLOR) +TEST_SCALED_COLOR.componentwise_mult(TEST_COLOR_SCALE) +FUZZ = 0.02 + + +@pytest.fixture(scope='session', params=[False, True], ids=["shader:off", "shader:auto"]) +def shader_attrib(request): + """Returns two ShaderAttribs: one with auto shader, one without.""" + if request.param: + return core.ShaderAttrib.make_default().set_shader_auto(True) + else: + return core.ShaderAttrib.make_off() + + +@pytest.fixture(scope='session', params=["mat:off", "mat:empty", "mat:amb", "mat:diff", "mat:both"]) +def material_attrib(request): + """Returns two MaterialAttribs: one with material, one without. It + shouldn't really matter what we set them to, since the tests in here do + not use lighting, and therefore the material should be ignored.""" + + if request.param == "mat:off": + return core.MaterialAttrib.make_off() + + elif request.param == "mat:empty": + return core.MaterialAttrib.make(core.Material()) + + elif request.param == "mat:amb": + mat = core.Material() + mat.ambient = (0.1, 1, 0.5, 1) + return core.MaterialAttrib.make(mat) + + elif request.param == "mat:diff": + mat = core.Material() + mat.diffuse = (0.1, 1, 0.5, 1) + return core.MaterialAttrib.make(mat) + + elif request.param == "mat:both": + mat = core.Material() + mat.diffuse = (0.1, 1, 0.5, 1) + mat.ambient = (0.1, 1, 0.5, 1) + return core.MaterialAttrib.make(mat) + + +@pytest.fixture(scope='module', params=[False, True], ids=["srgb:off", "srgb:on"]) +def color_region(request, graphics_pipe): + """Creates and returns a DisplayRegion with a depth buffer.""" + + engine = core.GraphicsEngine() + engine.set_threading_model("") + + host_fbprops = core.FrameBufferProperties() + host_fbprops.force_hardware = True + + host = engine.make_output( + graphics_pipe, + 'host', + 0, + host_fbprops, + core.WindowProperties.size(32, 32), + core.GraphicsPipe.BF_refuse_window, + ) + engine.open_windows() + + if host is None: + pytest.skip("GraphicsPipe cannot make offscreen buffers") + + fbprops = core.FrameBufferProperties() + fbprops.force_hardware = True + fbprops.set_rgba_bits(8, 8, 8, 8) + fbprops.srgb_color = request.param + + buffer = engine.make_output( + graphics_pipe, + 'buffer', + 0, + fbprops, + core.WindowProperties.size(32, 32), + core.GraphicsPipe.BF_refuse_window, + host.gsg, + host + ) + engine.open_windows() + + if buffer is None: + pytest.skip("Cannot make color buffer") + + if fbprops.srgb_color != buffer.get_fb_properties().srgb_color: + pytest.skip("Cannot make buffer with required srgb_color setting") + + buffer.set_clear_color_active(True) + buffer.set_clear_color((0, 0, 0, 1)) + + yield buffer.make_display_region() + + if buffer is not None: + engine.remove_window(buffer) + + +def render_color_pixel(region, state, vertex_color=None): + """Renders a fragment using the specified render settings, and returns the + resulting color value.""" + + # Set up the scene with a blank card rendering at specified distance. + scene = core.NodePath("root") + scene.set_attrib(core.DepthTestAttrib.make(core.RenderAttrib.M_always)) + + camera = scene.attach_new_node(core.Camera("camera")) + camera.node().get_lens(0).set_near_far(1, 3) + camera.node().set_cull_bounds(core.OmniBoundingVolume()) + + cm = core.CardMaker("card") + cm.set_frame(-1, 1, -1, 1) + + if vertex_color is not None: + cm.set_color(vertex_color) + + card = scene.attach_new_node(cm.generate()) + card.set_state(state) + card.set_pos(0, 2, 0) + card.set_scale(60) + + region.active = True + region.camera = camera + + color_texture = core.Texture("color") + region.window.add_render_texture(color_texture, + core.GraphicsOutput.RTM_copy_ram, + core.GraphicsOutput.RTP_color) + + region.window.engine.render_frame() + region.window.clear_render_textures() + + col = core.LColor() + color_texture.peek().lookup(col, 0.5, 0.5) + return col + + +def test_color_write_mask(color_region): + state = core.RenderState.make( + core.ColorWriteAttrib.make(core.ColorWriteAttrib.C_green), + ) + result = render_color_pixel(color_region, state) + assert result == (0, 1, 0, 1) + + +def test_color_empty(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state) + assert result == (1, 1, 1, 1) + + +def test_color_off(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + core.ColorAttrib.make_off(), + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state) + assert result == (1, 1, 1, 1) + + +def test_color_flat(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + core.ColorAttrib.make_flat(TEST_COLOR), + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state) + assert result.almost_equal(TEST_COLOR, FUZZ) + + +def test_color_vertex(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + core.ColorAttrib.make_vertex(), + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state, vertex_color=TEST_COLOR) + assert result.almost_equal(TEST_COLOR, FUZZ) + + +def test_color_empty_vertex(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state, vertex_color=TEST_COLOR) + assert result.almost_equal(TEST_COLOR, FUZZ) + + +def test_color_off_vertex(color_region, shader_attrib, material_attrib): + #XXX This behaviour is really odd. + state = core.RenderState.make( + core.ColorAttrib.make_off(), + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state, vertex_color=TEST_COLOR) + assert result.almost_equal(TEST_COLOR, FUZZ) + + +def test_scaled_color_empty(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state) + assert result == (1, 1, 1, 1) + + +def test_scaled_color_off(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + core.ColorAttrib.make_off(), + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state) + assert result == (1, 1, 1, 1) + + +def test_scaled_color_flat(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + core.ColorAttrib.make_flat(TEST_COLOR), + core.ColorScaleAttrib.make(TEST_COLOR_SCALE), + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state) + assert result.almost_equal(TEST_SCALED_COLOR, FUZZ) + + +def test_scaled_color_vertex(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + core.ColorAttrib.make_vertex(), + core.ColorScaleAttrib.make(TEST_COLOR_SCALE), + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state, vertex_color=TEST_COLOR) + assert result.almost_equal(TEST_SCALED_COLOR, FUZZ) + + +def test_scaled_color_empty_vertex(color_region, shader_attrib, material_attrib): + state = core.RenderState.make( + core.ColorScaleAttrib.make(TEST_COLOR_SCALE), + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state, vertex_color=TEST_COLOR) + assert result.almost_equal(TEST_SCALED_COLOR, FUZZ) + + +def test_scaled_color_off_vertex(color_region, shader_attrib, material_attrib): + #XXX This behaviour is really odd. + state = core.RenderState.make( + core.ColorAttrib.make_off(), + core.ColorScaleAttrib.make(TEST_COLOR_SCALE), + shader_attrib, + material_attrib, + ) + result = render_color_pixel(color_region, state, vertex_color=TEST_COLOR) + assert result.almost_equal(TEST_SCALED_COLOR, FUZZ) + From 93a3e7e6991d5d3143aba2ea42dfdf7bed52f431 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 8 Oct 2018 14:46:07 +0200 Subject: [PATCH 223/360] Changes to make ColorAttrib behavior more consistent: - T_off now actually properly disables vertex colours - T_vertex is now the default, to preserve the previous behaviour - ShaderGenerator behavior is now the same as in the FFP - tests are updated to verify new behavior - tests now properly use vertex colours, previously they accidentally only used flat colors - With color-scale-via-lighting off and no color scale, color is no longer munged - p3d_Color in GLSL shaders is now properly set to white instead of black with T_off mode - In DX9 shaders will now sample white color for absent or disabled vertex color Fixes #401 Also see #371 --- panda/src/display/graphicsStateGuardian.cxx | 13 +++- panda/src/display/standardMunger.cxx | 20 +------ panda/src/display/standardMunger.h | 5 +- panda/src/dxgsg9/dxGeomMunger9.I | 31 ---------- panda/src/dxgsg9/dxGeomMunger9.cxx | 60 +++++++++++++++++++ panda/src/dxgsg9/dxGeomMunger9.h | 2 +- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 40 +++++++++++++ panda/src/dxgsg9/dxGraphicsStateGuardian9.h | 8 +-- panda/src/dxgsg9/dxShaderContext9.cxx | 23 +++++++ .../glstuff/glGraphicsStateGuardian_src.cxx | 11 +++- panda/src/glstuff/glShaderContext_src.cxx | 4 +- panda/src/pgraph/colorAttrib.cxx | 2 +- panda/src/pgraph/colorAttrib.h | 2 +- tests/display/test_color_buffer.py | 40 ++++++++++--- 14 files changed, 188 insertions(+), 73 deletions(-) diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 1050f8372f..b76a7f751c 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -2722,7 +2722,7 @@ do_issue_color_scale() { } if (_alpha_scale_via_texture && !_has_scene_graph_color && - target_color_scale->has_alpha_scale()) { + _vertex_colors_enabled && target_color_scale->has_alpha_scale()) { // This color scale will set a special texture--so again, clear the // texture. _state_mask.clear_bit(TextureAttrib::get_class_slot()); @@ -3168,6 +3168,17 @@ determine_light_color_scale() { _scene_graph_color[3] * _current_color_scale[3]); } + } else if (!_vertex_colors_enabled) { + // We don't have a scene graph color, but we don't want to enable vertex + // colors either, so we still need to force a white material color in + // absence of any other color. + _has_material_force_color = true; + _material_force_color.set(1.0f, 1.0f, 1.0f, 1.0f); + _light_color_scale.set(1.0f, 1.0f, 1.0f, 1.0f); + if (!_color_blend_involves_color_scale && _color_scale_enabled) { + _material_force_color.componentwise_mult(_current_color_scale); + } + } else { // Otherise, leave the materials alone, but we might still scale the // lights. diff --git a/panda/src/display/standardMunger.cxx b/panda/src/display/standardMunger.cxx index 94f376e99b..4bb96fcfd5 100644 --- a/panda/src/display/standardMunger.cxx +++ b/panda/src/display/standardMunger.cxx @@ -55,24 +55,10 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, const ColorScaleAttrib *color_scale_attrib; if (state->get_attrib(color_attrib) && - color_attrib->get_color_type() == ColorAttrib::T_flat) { + color_attrib->get_color_type() != ColorAttrib::T_vertex) { - if (!get_gsg()->get_color_scale_via_lighting()) { - // We only need to munge the color directly if the GSG says it can't - // cheat the color via lighting (presumably, in this case, by applying - // a material). - _color = color_attrib->get_color(); - if (state->get_attrib(color_scale_attrib) && - color_scale_attrib->has_scale()) { - const LVecBase4 &cs = color_scale_attrib->get_scale(); - _color.set(_color[0] * cs[0], - _color[1] * cs[1], - _color[2] * cs[2], - _color[3] * cs[3]); - } - _munge_color = true; - _should_munge_state = true; - } + // In this case, we don't need to munge anything as we can apply the + // color and color scale via glColor4f. } else if (state->get_attrib(color_scale_attrib) && color_scale_attrib->has_scale()) { diff --git a/panda/src/display/standardMunger.h b/panda/src/display/standardMunger.h index 5703fd01b5..d7c71e28e5 100644 --- a/panda/src/display/standardMunger.h +++ b/panda/src/display/standardMunger.h @@ -51,12 +51,13 @@ private: NumericType _numeric_type; Contents _contents; - bool _munge_color; - bool _munge_color_scale; bool _auto_shader; bool _shader_skinning; bool _remove_material; +protected: + bool _munge_color; + bool _munge_color_scale; LColor _color; LVecBase4 _color_scale; diff --git a/panda/src/dxgsg9/dxGeomMunger9.I b/panda/src/dxgsg9/dxGeomMunger9.I index cc972bf94b..2accff3b11 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.I +++ b/panda/src/dxgsg9/dxGeomMunger9.I @@ -10,34 +10,3 @@ * @author drose * @date 2005-03-11 */ - -/** - * - */ -INLINE DXGeomMunger9:: -DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : - StandardMunger(gsg, state, 1, NT_packed_dabc, C_color), - _texture(nullptr), - _tex_gen(nullptr) -{ - const TextureAttrib *texture = nullptr; - const TexGenAttrib *tex_gen = nullptr; - state->get_attrib(texture); - state->get_attrib(tex_gen); - _texture = texture; - _tex_gen = tex_gen; - - _filtered_texture = nullptr; - _reffed_filtered_texture = false; - if (texture != nullptr) { - _filtered_texture = texture->filter_to_max(gsg->get_max_texture_stages()); - if (_filtered_texture != texture) { - _filtered_texture->ref(); - _reffed_filtered_texture = true; - } - } - // Set a callback to unregister ourselves when either the Texture or the - // TexGen object gets deleted. - _texture.add_callback(this); - _tex_gen.add_callback(this); -} diff --git a/panda/src/dxgsg9/dxGeomMunger9.cxx b/panda/src/dxgsg9/dxGeomMunger9.cxx index 638b121f27..0e95070c91 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.cxx +++ b/panda/src/dxgsg9/dxGeomMunger9.cxx @@ -19,6 +19,66 @@ GeomMunger *DXGeomMunger9::_deleted_chain = nullptr; TypeHandle DXGeomMunger9::_type_handle; +/** + * + */ +DXGeomMunger9:: +DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : + StandardMunger(gsg, state, 1, NT_packed_dabc, C_color), + _texture(nullptr), + _tex_gen(nullptr) +{ + const TextureAttrib *texture = nullptr; + const TexGenAttrib *tex_gen = nullptr; + state->get_attrib(texture); + state->get_attrib(tex_gen); + _texture = texture; + _tex_gen = tex_gen; + + if (!gsg->get_color_scale_via_lighting()) { + // We might need to munge the colors, if we are overriding the vertex + // colors and the GSG can't cheat the color via lighting. + + const ColorAttrib *color_attrib; + const ShaderAttrib *shader_attrib; + state->get_attrib_def(shader_attrib); + + if (!shader_attrib->auto_shader() && + shader_attrib->get_shader() == nullptr && + state->get_attrib(color_attrib) && + color_attrib->get_color_type() != ColorAttrib::T_vertex) { + + if (color_attrib->get_color_type() == ColorAttrib::T_off) { + _color.set(1, 1, 1, 1); + } else { + _color = color_attrib->get_color(); + } + + const ColorScaleAttrib *color_scale_attrib; + if (state->get_attrib(color_scale_attrib) && + color_scale_attrib->has_scale()) { + _color.componentwise_mult(color_scale_attrib->get_scale()); + } + _munge_color = true; + _should_munge_state = true; + } + } + + _filtered_texture = nullptr; + _reffed_filtered_texture = false; + if (texture != nullptr) { + _filtered_texture = texture->filter_to_max(gsg->get_max_texture_stages()); + if (_filtered_texture != texture) { + _filtered_texture->ref(); + _reffed_filtered_texture = true; + } + } + // Set a callback to unregister ourselves when either the Texture or the + // TexGen object gets deleted. + _texture.add_callback(this); + _tex_gen.add_callback(this); +} + /** * */ diff --git a/panda/src/dxgsg9/dxGeomMunger9.h b/panda/src/dxgsg9/dxGeomMunger9.h index c0762e3cf3..c0cb8f8edd 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.h +++ b/panda/src/dxgsg9/dxGeomMunger9.h @@ -28,7 +28,7 @@ */ class EXPCL_PANDADX DXGeomMunger9 : public StandardMunger, public WeakPointerCallback { public: - INLINE DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state); + DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state); virtual ~DXGeomMunger9(); ALLOC_DELETED_CHAIN(DXGeomMunger9); diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 0921350629..b18c937d81 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -140,6 +140,7 @@ DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) : _last_fvf = 0; _num_bound_streams = 0; + _white_vbuffer = nullptr; _vertex_shader_version_major = 0; _vertex_shader_version_minor = 0; @@ -4545,6 +4546,11 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, release_all_vertex_buffers(); release_all_index_buffers(); + if (_white_vbuffer != nullptr) { + _white_vbuffer->Release(); + _white_vbuffer = nullptr; + } + // must be called before reset Thread *current_thread = Thread::get_current_thread(); _prepared_objects->begin_frame(this, current_thread); @@ -5404,6 +5410,40 @@ set_cg_device(LPDIRECT3DDEVICE9 cg_device) { #endif // HAVE_CG } +/** + * Returns a vertex buffer containing only a full-white color. + */ +LPDIRECT3DVERTEXBUFFER9 DXGraphicsStateGuardian9:: +get_white_vbuffer() { + if (_white_vbuffer != nullptr) { + return _white_vbuffer; + } + + LPDIRECT3DVERTEXBUFFER9 vbuffer; + HRESULT hr; + hr = _screen->_d3d_device->CreateVertexBuffer(sizeof(D3DCOLOR), D3DUSAGE_WRITEONLY, D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &vbuffer, nullptr); + + if (FAILED(hr)) { + dxgsg9_cat.error() + << "CreateVertexBuffer failed" << D3DERRORSTRING(hr); + return nullptr; + } + + D3DCOLOR *local_pointer; + hr = vbuffer->Lock(0, sizeof(D3DCOLOR), (void **) &local_pointer, D3DLOCK_DISCARD); + if (FAILED(hr)) { + dxgsg9_cat.error() + << "VertexBuffer::Lock failed" << D3DERRORSTRING(hr); + return false; + } + + *local_pointer = D3DCOLOR_ARGB(255, 255, 255, 255); + + vbuffer->Unlock(); + _white_vbuffer = vbuffer; + return vbuffer; +} + typedef std::string KEY; typedef struct _KEY_ELEMENT diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index 66b2fb82d5..8852f413a7 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -168,6 +168,7 @@ public: static void set_cg_device(LPDIRECT3DDEVICE9 cg_device); virtual bool get_supports_cg_profile(const std::string &name) const; + LPDIRECT3DVERTEXBUFFER9 get_white_vbuffer(); protected: void do_issue_transform(); @@ -274,12 +275,6 @@ protected: RenderBuffer::Type _cur_read_pixel_buffer; // source for copy_pixel_buffer operation - PN_stdfloat _material_ambient; - PN_stdfloat _material_diffuse; - PN_stdfloat _material_specular; - PN_stdfloat _material_shininess; - PN_stdfloat _material_emission; - enum DxgsgFogType { None, PerVertexFog=D3DRS_FOGVERTEXMODE, @@ -320,6 +315,7 @@ protected: DWORD _last_fvf; int _num_bound_streams; + LPDIRECT3DVERTEXBUFFER9 _white_vbuffer; // Cache the data necessary to bind each particular light each frame, so if // we bind a given light multiple times, we only have to compute its data diff --git a/panda/src/dxgsg9/dxShaderContext9.cxx b/panda/src/dxgsg9/dxShaderContext9.cxx index 6513ce8a89..a737c342bf 100644 --- a/panda/src/dxgsg9/dxShaderContext9.cxx +++ b/panda/src/dxgsg9/dxShaderContext9.cxx @@ -390,6 +390,8 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { // arrays ("streams"), and we repeatedly iterate the parameters to pull // out only those for a single stream. + bool apply_white_color = false; + int number_of_arrays = gsg->_data_reader->get_num_arrays(); for (int array_index = 0; array_index < number_of_arrays; ++array_index) { const GeomVertexArrayDataHandle* array_reader = @@ -423,6 +425,11 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { } } + if (name == InternalName::get_color() && !gsg->_vertex_colors_enabled) { + apply_white_color = true; + continue; + } + const GeomVertexArrayDataHandle *param_array_reader; Geom::NumericType numeric_type; int num_values, start, stride; @@ -435,6 +442,9 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { // shader parameter, which can cause Bad Things to happen so I'd // like to at least get a hint as to what's gone wrong. dxgsg9_cat.info() << "Geometry contains no data for shader parameter " << *name << "\n"; + if (name == InternalName::get_color()) { + apply_white_color = true; + } continue; } @@ -564,6 +574,19 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { _num_bound_streams = number_of_arrays; + if (apply_white_color) { + // The shader needs a vertex color, but vertex colors are disabled. + // Bind a vertex buffer containing only one white colour. + int array_index = number_of_arrays; + LPDIRECT3DVERTEXBUFFER9 vbuffer = gsg->get_white_vbuffer(); + hr = device->SetStreamSource(array_index, vbuffer, 0, 0); + if (FAILED(hr)) { + dxgsg9_cat.error() << "SetStreamSource failed" << D3DERRORSTRING(hr); + } + vertex_element_array->add_diffuse_color_vertex_element(array_index, 0); + ++_num_bound_streams; + } + if (_vertex_element_array != nullptr && _vertex_element_array->add_end_vertex_element()) { if (dxgsg9_cat.is_debug()) { diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 48b9112387..616784e0cc 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -4392,7 +4392,8 @@ update_standard_vertex_arrays(bool force) { GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } else #endif // NDEBUG - if (_data_reader->get_color_info(array_reader, num_values, numeric_type, + if (_vertex_colors_enabled && + _data_reader->get_color_info(array_reader, num_values, numeric_type, start, stride)) { if (!setup_array_data(client_pointer, array_reader, force)) { return false; @@ -4409,7 +4410,13 @@ update_standard_vertex_arrays(bool force) { glDisableClientState(GL_COLOR_ARRAY); // Since we don't have per-vertex color, the implicit color is white. - GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); + if (_color_scale_via_lighting) { + GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); + } else { + LColor color = _scene_graph_color; + color.componentwise_mult(_current_color_scale); + GLPf(Color4)(color[0], color[1], color[2], color[3]); + } } // Now set up each of the active texture coordinate stages--or at least diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index a96a07a2e8..64a5e77553 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -2440,9 +2440,9 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { if (p == _color_attrib_index) { // Vertex colors are disabled or not present. Apply flat color. #ifdef STDFLOAT_DOUBLE - _glgsg->_glVertexAttrib4dv(p, color_attrib->get_color().get_data()); + _glgsg->_glVertexAttrib4dv(p, _glgsg->_scene_graph_color.get_data()); #else - _glgsg->_glVertexAttrib4fv(p, color_attrib->get_color().get_data()); + _glgsg->_glVertexAttrib4fv(p, _glgsg->_scene_graph_color.get_data()); #endif } } diff --git a/panda/src/pgraph/colorAttrib.cxx b/panda/src/pgraph/colorAttrib.cxx index 129f5a9184..f1d71845cd 100644 --- a/panda/src/pgraph/colorAttrib.cxx +++ b/panda/src/pgraph/colorAttrib.cxx @@ -68,7 +68,7 @@ make_off() { */ CPT(RenderAttrib) ColorAttrib:: make_default() { - return make_off(); + return make_vertex(); } /** diff --git a/panda/src/pgraph/colorAttrib.h b/panda/src/pgraph/colorAttrib.h index a92543c855..b652233a62 100644 --- a/panda/src/pgraph/colorAttrib.h +++ b/panda/src/pgraph/colorAttrib.h @@ -88,7 +88,7 @@ public: register_type(_type_handle, "ColorAttrib", RenderAttrib::get_class_type()); _attrib_slot = register_slot(_type_handle, 100, - new ColorAttrib(T_off, LColor(1, 1, 1, 1))); + new ColorAttrib(T_vertex, LColor::zero())); } virtual TypeHandle get_type() const { return get_class_type(); diff --git a/tests/display/test_color_buffer.py b/tests/display/test_color_buffer.py index dab73cbbb8..d95913b0f7 100644 --- a/tests/display/test_color_buffer.py +++ b/tests/display/test_color_buffer.py @@ -113,14 +113,38 @@ def render_color_pixel(region, state, vertex_color=None): camera.node().get_lens(0).set_near_far(1, 3) camera.node().set_cull_bounds(core.OmniBoundingVolume()) - cm = core.CardMaker("card") - cm.set_frame(-1, 1, -1, 1) + if vertex_color is not None: + format = core.GeomVertexFormat.get_v3cp() + else: + format = core.GeomVertexFormat.get_v3() + + vdata = core.GeomVertexData("card", format, core.Geom.UH_static) + vdata.unclean_set_num_rows(4) + + vertex = core.GeomVertexWriter(vdata, "vertex") + vertex.set_data3(core.Vec3.rfu(-1, 0, 1)) + vertex.set_data3(core.Vec3.rfu(-1, 0, -1)) + vertex.set_data3(core.Vec3.rfu(1, 0, 1)) + vertex.set_data3(core.Vec3.rfu(1, 0, -1)) if vertex_color is not None: - cm.set_color(vertex_color) + color = core.GeomVertexWriter(vdata, "color") + color.set_data4(vertex_color) + color.set_data4(vertex_color) + color.set_data4(vertex_color) + color.set_data4(vertex_color) - card = scene.attach_new_node(cm.generate()) - card.set_state(state) + strip = core.GeomTristrips(core.Geom.UH_static) + strip.set_shade_model(core.Geom.SM_uniform) + strip.add_next_vertices(4) + strip.close_primitive() + + geom = core.Geom(vdata) + geom.add_primitive(strip) + + gnode = core.GeomNode("card") + gnode.add_geom(geom, state) + card = scene.attach_new_node(gnode) card.set_pos(0, 2, 0) card.set_scale(60) @@ -197,14 +221,13 @@ def test_color_empty_vertex(color_region, shader_attrib, material_attrib): def test_color_off_vertex(color_region, shader_attrib, material_attrib): - #XXX This behaviour is really odd. state = core.RenderState.make( core.ColorAttrib.make_off(), shader_attrib, material_attrib, ) result = render_color_pixel(color_region, state, vertex_color=TEST_COLOR) - assert result.almost_equal(TEST_COLOR, FUZZ) + assert result == (1, 1, 1, 1) def test_scaled_color_empty(color_region, shader_attrib, material_attrib): @@ -259,7 +282,6 @@ def test_scaled_color_empty_vertex(color_region, shader_attrib, material_attrib) def test_scaled_color_off_vertex(color_region, shader_attrib, material_attrib): - #XXX This behaviour is really odd. state = core.RenderState.make( core.ColorAttrib.make_off(), core.ColorScaleAttrib.make(TEST_COLOR_SCALE), @@ -267,5 +289,5 @@ def test_scaled_color_off_vertex(color_region, shader_attrib, material_attrib): material_attrib, ) result = render_color_pixel(color_region, state, vertex_color=TEST_COLOR) - assert result.almost_equal(TEST_SCALED_COLOR, FUZZ) + assert result.almost_equal(TEST_COLOR_SCALE, FUZZ) From 96860b88e041d5230f6823e201d913e535f4d415 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 8 Oct 2018 22:11:55 +0200 Subject: [PATCH 224/360] dxgsg9: fix problems with window without depth buffer --- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 4 ++-- panda/src/dxgsg9/wdxGraphicsWindow9.cxx | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index b18c937d81..904f47afc3 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -799,9 +799,9 @@ clear(DrawableRegion *clearable) { main_flags |= D3DCLEAR_TARGET; } - if (clearable->get_clear_depth_active()) { + if (clearable->get_clear_depth_active() && + _screen->_presentation_params.EnableAutoDepthStencil) { aux_flags |= D3DCLEAR_ZBUFFER; - nassertv(_screen->_presentation_params.EnableAutoDepthStencil); } if (clearable->get_clear_stencil_active()) { diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index 3136d75fd0..3207c81189 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -1229,7 +1229,10 @@ init_resized_window() { DWORD flags; D3DCOLOR clear_color; - flags = D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER; + flags = D3DCLEAR_TARGET; + if (_fb_properties.get_depth_bits() > 0) { + flags |= D3DCLEAR_ZBUFFER; + } clear_color = 0x00000000; hr = _wcontext._d3d_device-> Clear (0, nullptr, flags, clear_color, 0.0f, 0); if (FAILED(hr)) { From 9061fd941648056d5a00069b5bc451907a6fda79 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 8 Oct 2018 22:13:08 +0200 Subject: [PATCH 225/360] dtoolutil: fix TextEncoder methods for Python 3 The no-arguments get_text() and set_text() will now return Unicode strings in Python 3, but passing in an encoding will make them return/take bytes objects. In Python 2, they all take regular strings, but Unicode is also accepted by the no-argument get_text() and set_text(). In the future we probably want to remove most of this interface for Python users, to whom all this is unnecessary since it duplicates functionality already in the standard library. --- .../dtoolutil/p3dtoolutil_ext_composite.cxx | 1 + dtool/src/dtoolutil/textEncoder.I | 25 ++- dtool/src/dtoolutil/textEncoder.cxx | 8 + dtool/src/dtoolutil/textEncoder.h | 24 +++ dtool/src/dtoolutil/textEncoder_ext.I | 30 ++++ dtool/src/dtoolutil/textEncoder_ext.cxx | 159 ++++++++++++++++++ dtool/src/dtoolutil/textEncoder_ext.h | 50 ++++++ makepanda/makepanda.py | 1 + panda/src/text/textNode.I | 77 --------- panda/src/text/textNode.cxx | 9 + panda/src/text/textNode.h | 17 +- 11 files changed, 305 insertions(+), 96 deletions(-) create mode 100644 dtool/src/dtoolutil/textEncoder_ext.I create mode 100644 dtool/src/dtoolutil/textEncoder_ext.cxx create mode 100644 dtool/src/dtoolutil/textEncoder_ext.h diff --git a/dtool/src/dtoolutil/p3dtoolutil_ext_composite.cxx b/dtool/src/dtoolutil/p3dtoolutil_ext_composite.cxx index 89a0ebcc30..2cd825ff58 100644 --- a/dtool/src/dtoolutil/p3dtoolutil_ext_composite.cxx +++ b/dtool/src/dtoolutil/p3dtoolutil_ext_composite.cxx @@ -1,2 +1,3 @@ #include "filename_ext.cxx" #include "globPattern_ext.cxx" +#include "textEncoder_ext.cxx" diff --git a/dtool/src/dtoolutil/textEncoder.I b/dtool/src/dtoolutil/textEncoder.I index e07f489ab0..417ef386e2 100644 --- a/dtool/src/dtoolutil/textEncoder.I +++ b/dtool/src/dtoolutil/textEncoder.I @@ -90,6 +90,7 @@ set_text(const std::string &text) { if (!has_text() || _text != text) { _text = text; _flags = (_flags | F_got_text) & ~F_got_wtext; + text_changed(); } } @@ -101,7 +102,11 @@ set_text(const std::string &text) { */ INLINE void TextEncoder:: set_text(const std::string &text, TextEncoder::Encoding encoding) { - set_wtext(decode_text(text, encoding)); + if (encoding == _encoding) { + set_text(text); + } else { + set_wtext(decode_text(text, encoding)); + } } /** @@ -112,6 +117,7 @@ clear_text() { _text = std::string(); _wtext = std::wstring(); _flags |= (F_got_text | F_got_wtext); + text_changed(); } /** @@ -151,8 +157,11 @@ get_text(TextEncoder::Encoding encoding) const { */ INLINE void TextEncoder:: append_text(const std::string &text) { - _text = get_text() + text; - _flags = (_flags | F_got_text) & ~F_got_wtext; + if (!text.empty()) { + _text = get_text() + text; + _flags = (_flags | F_got_text) & ~F_got_wtext; + text_changed(); + } } /** @@ -163,6 +172,7 @@ INLINE void TextEncoder:: append_unicode_char(int character) { _wtext = get_wtext() + std::wstring(1, (wchar_t)character); _flags = (_flags | F_got_wtext) & ~F_got_text; + text_changed(); } /** @@ -200,6 +210,7 @@ set_unicode_char(size_t index, int character) { if (index < _wtext.length()) { _wtext[index] = character; _flags &= ~F_got_text; + text_changed(); } } @@ -418,6 +429,7 @@ set_wtext(const std::wstring &wtext) { if (!has_text() || _wtext != wtext) { _wtext = wtext; _flags = (_flags | F_got_wtext) & ~F_got_text; + text_changed(); } } @@ -439,8 +451,11 @@ get_wtext() const { */ INLINE void TextEncoder:: append_wtext(const std::wstring &wtext) { - _wtext = get_wtext() + wtext; - _flags = (_flags | F_got_wtext) & ~F_got_text; + if (!wtext.empty()) { + _wtext = get_wtext() + wtext; + _flags = (_flags | F_got_wtext) & ~F_got_text; + text_changed(); + } } /** diff --git a/dtool/src/dtoolutil/textEncoder.cxx b/dtool/src/dtoolutil/textEncoder.cxx index 1e1cd4bc61..da835b7bfb 100644 --- a/dtool/src/dtoolutil/textEncoder.cxx +++ b/dtool/src/dtoolutil/textEncoder.cxx @@ -35,6 +35,7 @@ make_upper() { (*si) = unicode_toupper(*si); } _flags &= ~F_got_text; + text_changed(); } /** @@ -49,6 +50,7 @@ make_lower() { (*si) = unicode_tolower(*si); } _flags &= ~F_got_text; + text_changed(); } /** @@ -314,6 +316,12 @@ expand_amp_sequence(StringDecoder &decoder) const { } */ +/** + * Called whenever the text has been changed. + */ +void TextEncoder:: +text_changed() { +} /** * diff --git a/dtool/src/dtoolutil/textEncoder.h b/dtool/src/dtoolutil/textEncoder.h index a7eaf395ff..baa0ef9b3e 100644 --- a/dtool/src/dtoolutil/textEncoder.h +++ b/dtool/src/dtoolutil/textEncoder.h @@ -48,17 +48,28 @@ PUBLISHED: INLINE static Encoding get_default_encoding(); MAKE_PROPERTY(default_encoding, get_default_encoding, set_default_encoding); +#ifdef CPPPARSER + EXTEND void set_text(PyObject *text); + EXTEND void set_text(PyObject *text, Encoding encoding); +#else INLINE void set_text(const std::string &text); INLINE void set_text(const std::string &text, Encoding encoding); +#endif INLINE void clear_text(); INLINE bool has_text() const; void make_upper(); void make_lower(); +#ifdef CPPPARSER + EXTEND PyObject *get_text() const; + EXTEND PyObject *get_text(Encoding encoding) const; + EXTEND void append_text(PyObject *text); +#else INLINE std::string get_text() const; INLINE std::string get_text(Encoding encoding) const; INLINE void append_text(const std::string &text); +#endif INLINE void append_unicode_char(int character); INLINE size_t get_num_chars() const; INLINE int get_unicode_char(size_t index) const; @@ -91,11 +102,24 @@ PUBLISHED: std::wstring get_wtext_as_ascii() const; bool is_wtext() const; +#ifdef CPPPARSER + EXTEND static PyObject *encode_wchar(wchar_t ch, Encoding encoding); + EXTEND INLINE PyObject *encode_wtext(const std::wstring &wtext) const; + EXTEND static PyObject *encode_wtext(const std::wstring &wtext, Encoding encoding); + EXTEND INLINE PyObject *decode_text(PyObject *text) const; + EXTEND static PyObject *decode_text(PyObject *text, Encoding encoding); +#else static std::string encode_wchar(wchar_t ch, Encoding encoding); INLINE std::string encode_wtext(const std::wstring &wtext) const; static std::string encode_wtext(const std::wstring &wtext, Encoding encoding); INLINE std::wstring decode_text(const std::string &text) const; static std::wstring decode_text(const std::string &text, Encoding encoding); +#endif + + MAKE_PROPERTY(text, get_text, set_text); + +protected: + virtual void text_changed(); private: enum Flags { diff --git a/dtool/src/dtoolutil/textEncoder_ext.I b/dtool/src/dtoolutil/textEncoder_ext.I new file mode 100644 index 0000000000..2924fda011 --- /dev/null +++ b/dtool/src/dtoolutil/textEncoder_ext.I @@ -0,0 +1,30 @@ +/** + * 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." + * + * @file textEncoder_ext.I + * @author rdb + * @date 2018-10-08 + */ + +/** + * Encodes a wide-text string into a single-char string, according to the + * current encoding. + */ +INLINE PyObject *Extension:: +encode_wtext(const std::wstring &wtext) const { + return encode_wtext(wtext, _this->get_encoding()); +} + +/** + * Returns the given wstring decoded to a single-byte string, via the current + * encoding system. + */ +INLINE PyObject *Extension:: +decode_text(PyObject *text) const { + return decode_text(text, _this->get_encoding()); +} diff --git a/dtool/src/dtoolutil/textEncoder_ext.cxx b/dtool/src/dtoolutil/textEncoder_ext.cxx new file mode 100644 index 0000000000..b085b8a965 --- /dev/null +++ b/dtool/src/dtoolutil/textEncoder_ext.cxx @@ -0,0 +1,159 @@ +/** + * 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." + * + * @file textEncoder_ext.cxx + * @author rdb + * @date 2018-09-29 + */ + +#include "textEncoder_ext.h" + +#ifdef HAVE_PYTHON + +/** + * Sets the text as a Unicode string. In Python 2, if a regular str is given, + * it is assumed to be in the TextEncoder's specified encoding. + */ +void Extension:: +set_text(PyObject *text) { + if (PyUnicode_Check(text)) { +#if PY_VERSION_HEX >= 0x03030000 + Py_ssize_t len; + const char *str = PyUnicode_AsUTF8AndSize(text, &len); + _this->set_text(std::string(str, len), TextEncoder::E_utf8); +#else + Py_ssize_t len = PyUnicode_GET_SIZE(text); + wchar_t *str = (wchar_t *)alloca(sizeof(wchar_t) * (len + 1)); + PyUnicode_AsWideChar((PyUnicodeObject *)text, str, len); + _this->set_wtext(std::wstring(str, len)); +#endif + } else { +#if PY_MAJOR_VERSION >= 3 + Dtool_Raise_TypeError("expected string"); +#else + char *str; + Py_ssize_t len; + if (PyString_AsStringAndSize(text, (char **)&str, &len) != -1) { + _this->set_text(std::string(str, len)); + } +#endif + } +} + +/** + * Sets the text as an encoded byte string of the given encoding. + */ +void Extension:: +set_text(PyObject *text, TextEncoder::Encoding encoding) { + char *str; + Py_ssize_t len; + if (PyBytes_AsStringAndSize(text, &str, &len) >= 0) { + _this->set_text(std::string(str, len), encoding); + } +} + +/** + * Returns the text as a string. In Python 2, the returned string is in the + * TextEncoder's specified encoding. In Python 3, it is returned as unicode. + */ +PyObject *Extension:: +get_text() const { +#if PY_MAJOR_VERSION >= 3 + std::wstring text = _this->get_wtext(); + return PyUnicode_FromWideChar(text.data(), (Py_ssize_t)text.size()); +#else + std::string text = _this->get_text(); + return PyString_FromStringAndSize((char *)text.data(), (Py_ssize_t)text.size()); +#endif +} + +/** + * Returns the text as a bytes object in the given encoding. + */ +PyObject *Extension:: +get_text(TextEncoder::Encoding encoding) const { + std::string text = _this->get_text(encoding); +#if PY_MAJOR_VERSION >= 3 + return PyBytes_FromStringAndSize((char *)text.data(), (Py_ssize_t)text.size()); +#else + return PyString_FromStringAndSize((char *)text.data(), (Py_ssize_t)text.size()); +#endif +} + +/** + * Appends the text as a string (or Unicode object in Python 2). + */ +void Extension:: +append_text(PyObject *text) { + if (PyUnicode_Check(text)) { +#if PY_VERSION_HEX >= 0x03030000 + Py_ssize_t len; + const char *str = PyUnicode_AsUTF8AndSize(text, &len); + _this->append_text(std::string(str, len)); +#else + Py_ssize_t len = PyUnicode_GET_SIZE(text); + wchar_t *str = (wchar_t *)alloca(sizeof(wchar_t) * (len + 1)); + PyUnicode_AsWideChar((PyUnicodeObject *)text, str, len); + _this->append_wtext(std::wstring(str, len)); +#endif + } else { +#if PY_MAJOR_VERSION >= 3 + Dtool_Raise_TypeError("expected string"); +#else + char *str; + Py_ssize_t len; + if (PyString_AsStringAndSize(text, (char **)&str, &len) != -1) { + _this->append_text(std::string(str, len)); + } +#endif + } +} + +/** + * Encodes the given wide character as byte string in the given encoding. + */ +PyObject *Extension:: +encode_wchar(char32_t ch, TextEncoder::Encoding encoding) { + std::string value = TextEncoder::encode_wchar(ch, encoding); +#if PY_MAJOR_VERSION >= 3 + return PyBytes_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size()); +#else + return PyString_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size()); +#endif +} + +/** + * Encodes a wide-text string into a single-char string, according to the + * given encoding. + */ +PyObject *Extension:: +encode_wtext(const wstring &wtext, TextEncoder::Encoding encoding) { + std::string value = TextEncoder::encode_wtext(wtext, encoding); +#if PY_MAJOR_VERSION >= 3 + return PyBytes_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size()); +#else + return PyString_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size()); +#endif +} + +/** + * Returns the given wstring decoded to a single-byte string, via the given + * encoding system. + */ +PyObject *Extension:: +decode_text(PyObject *text, TextEncoder::Encoding encoding) { + char *str; + Py_ssize_t len; + if (PyBytes_AsStringAndSize(text, &str, &len) >= 0) { + return Dtool_WrapValue(TextEncoder::decode_text(std::string(str, len), encoding)); + } else { + return nullptr; + } +} + +#endif // HAVE_PYTHON diff --git a/dtool/src/dtoolutil/textEncoder_ext.h b/dtool/src/dtoolutil/textEncoder_ext.h new file mode 100644 index 0000000000..049c16e493 --- /dev/null +++ b/dtool/src/dtoolutil/textEncoder_ext.h @@ -0,0 +1,50 @@ +/** + * 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." + * + * @file textEncoder_ext.h + * @author rdb + * @date 2018-09-29 + */ + +#ifndef TEXTENCODER_EXT_H +#define TEXTENCODER_EXT_H + +#include "dtoolbase.h" + +#ifdef HAVE_PYTHON + +#include "extension.h" +#include "textEncoder.h" +#include "py_panda.h" + +/** + * This class defines the extension methods for TextEncoder, which are called + * instead of any C++ methods with the same prototype. + */ +template<> +class Extension : public ExtensionBase { +public: + void set_text(PyObject *text); + void set_text(PyObject *text, TextEncoder::Encoding encoding); + + PyObject *get_text() const; + PyObject *get_text(TextEncoder::Encoding encoding) const; + void append_text(PyObject *text); + + static PyObject *encode_wchar(char32_t ch, TextEncoder::Encoding encoding); + INLINE PyObject *encode_wtext(const std::wstring &wtext) const; + static PyObject *encode_wtext(const std::wstring &wtext, TextEncoder::Encoding encoding); + INLINE PyObject *decode_text(PyObject *text) const; + static PyObject *decode_text(PyObject *text, TextEncoder::Encoding encoding); +}; + +#include "textEncoder_ext.I" + +#endif // HAVE_PYTHON + +#endif // TEXTENCODER_EXT_H diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index a81ea7fe56..0164278d1e 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3551,6 +3551,7 @@ IGATEFILES += [ "dSearchPath.h", "executionEnvironment.h", "textEncoder.h", + "textEncoder_ext.h", "filename.h", "filename_ext.h", "globPattern.h", diff --git a/panda/src/text/textNode.I b/panda/src/text/textNode.I index 8070504c6b..1d02442451 100644 --- a/panda/src/text/textNode.I +++ b/panda/src/text/textNode.I @@ -1010,61 +1010,6 @@ clear_glyph_shift() { invalidate_with_measure(); } - -/** - * Changes the text that is displayed under the TextNode. - */ -INLINE void TextNode:: -set_text(const std::string &text) { - MutexHolder holder(_lock); - TextEncoder::set_text(text); - invalidate_with_measure(); -} - -/** - * The two-parameter version of set_text() accepts an explicit encoding; the - * text is immediately decoded and stored as a wide-character string. - * Subsequent calls to get_text() will return the same text re-encoded using - * whichever encoding is specified by set_encoding(). - */ -INLINE void TextNode:: -set_text(const std::string &text, TextNode::Encoding encoding) { - MutexHolder holder(_lock); - TextEncoder::set_text(text, encoding); - invalidate_with_measure(); -} - -/** - * Removes the text from the TextNode. - */ -INLINE void TextNode:: -clear_text() { - MutexHolder holder(_lock); - TextEncoder::clear_text(); - invalidate_with_measure(); -} - -/** - * Appends the indicates string to the end of the stored text. - */ -INLINE void TextNode:: -append_text(const std::string &text) { - MutexHolder holder(_lock); - TextEncoder::append_text(text); - invalidate_with_measure(); -} - -/** - * Appends a single character to the end of the stored text. This may be a - * wide character, up to 16 bits in Unicode. - */ -INLINE void TextNode:: -append_unicode_char(wchar_t character) { - MutexHolder holder(_lock); - TextEncoder::append_unicode_char(character); - invalidate_with_measure(); -} - /** * Returns a string that represents the contents of the text, as it has been * formatted by wordwrap rules. @@ -1086,28 +1031,6 @@ calc_width(const std::string &line) const { return calc_width(decode_text(line)); } -/** - * Changes the text that is displayed under the TextNode, with a wide text. - * This automatically sets the string reported by get_text() to the 8-bit - * encoded version of the same string. - */ -INLINE void TextNode:: -set_wtext(const std::wstring &wtext) { - MutexHolder holder(_lock); - TextEncoder::set_wtext(wtext); - invalidate_with_measure(); -} - -/** - * Appends the indicates string to the end of the stored wide-character text. - */ -INLINE void TextNode:: -append_wtext(const std::wstring &wtext) { - MutexHolder holder(_lock); - TextEncoder::append_wtext(wtext); - invalidate_with_measure(); -} - /** * Returns a wstring that represents the contents of the text, as it has been * formatted by wordwrap rules. diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index 1ecfc1ea65..5a0c0c7f7f 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -319,6 +319,15 @@ get_internal_geom() const { return do_get_internal_geom(); } +/** + * Called whenever the text has been changed. + */ +void TextNode:: +text_changed() { + MutexHolder holder(_lock); + invalidate_with_measure(); +} + /** * Returns the union of all attributes from SceneGraphReducer::AttribTypes * that may not safely be applied to the vertices of this node. If this is diff --git a/panda/src/text/textNode.h b/panda/src/text/textNode.h index ecf7dcafcf..02e1cb51c7 100644 --- a/panda/src/text/textNode.h +++ b/panda/src/text/textNode.h @@ -182,14 +182,6 @@ PUBLISHED: INLINE void set_glyph_shift(PN_stdfloat glyph_shift); INLINE void clear_glyph_shift(); - // These methods are inherited from TextEncoder, but we override here so we - // can flag the TextNode as dirty when they have been changed. - INLINE void set_text(const std::string &text); - INLINE void set_text(const std::string &text, Encoding encoding); - INLINE void clear_text(); - INLINE void append_text(const std::string &text); - INLINE void append_unicode_char(wchar_t character); - // After the text has been set, you can query this to determine how it will // be wordwrapped. INLINE std::string get_wordwrapped_text() const; @@ -203,10 +195,6 @@ PUBLISHED: bool has_character(wchar_t character) const; bool is_whitespace(wchar_t character) const; - // Direct support for wide-character strings. - INLINE void set_wtext(const std::wstring &wtext); - INLINE void append_wtext(const std::wstring &text); - INLINE std::wstring get_wordwrapped_wtext() const; PN_stdfloat calc_width(const std::wstring &line) const; @@ -245,8 +233,6 @@ PUBLISHED: MAKE_PROPERTY(usage_hint, get_usage_hint, set_usage_hint); MAKE_PROPERTY(flatten_flags, get_flatten_flags, set_flatten_flags); - MAKE_PROPERTY(text, get_text, set_text); - MAKE_PROPERTY2(font, has_font, get_font, set_font, clear_font); MAKE_PROPERTY2(small_caps, has_small_caps, get_small_caps, set_small_caps, clear_small_caps); @@ -281,6 +267,9 @@ PUBLISHED: set_text_scale, clear_text_scale); public: + // From parent class TextEncoder; + virtual void text_changed() final; + // From parent class PandaNode virtual int get_unsafe_to_apply_attribs() const; virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs, From 29b577971f71c0e6d2dfc07fb8eeeef6712d2f58 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 8 Oct 2018 22:33:54 +0200 Subject: [PATCH 226/360] dtoolutil: improve Unicode encoding/decoding, support non-BMP chars - Support encoding and decoding four-byte UTF-8 sequences - E_unicode supports surrogate pairs, renamed to E_utf16be for clarity - char32_t should be used for storing a Unicode code point --- dtool/src/dtoolutil/stringDecoder.I | 2 +- dtool/src/dtoolutil/stringDecoder.cxx | 79 +++++++++++++++++++++---- dtool/src/dtoolutil/stringDecoder.h | 15 +++-- dtool/src/dtoolutil/textEncoder.I | 17 +++++- dtool/src/dtoolutil/textEncoder.cxx | 84 +++++++++++++++++++++------ dtool/src/dtoolutil/textEncoder.h | 11 ++-- 6 files changed, 167 insertions(+), 41 deletions(-) diff --git a/dtool/src/dtoolutil/stringDecoder.I b/dtool/src/dtoolutil/stringDecoder.I index f7a3b14701..ce128833d0 100644 --- a/dtool/src/dtoolutil/stringDecoder.I +++ b/dtool/src/dtoolutil/stringDecoder.I @@ -53,5 +53,5 @@ StringUtf8Decoder(const std::string &input) : StringDecoder(input) { * */ INLINE StringUnicodeDecoder:: -StringUnicodeDecoder(const std::string &input) : StringDecoder(input) { +StringUtf16Decoder(const std::string &input) : StringDecoder(input) { } diff --git a/dtool/src/dtoolutil/stringDecoder.cxx b/dtool/src/dtoolutil/stringDecoder.cxx index e77e0c5e13..f9ecfdecd3 100644 --- a/dtool/src/dtoolutil/stringDecoder.cxx +++ b/dtool/src/dtoolutil/stringDecoder.cxx @@ -26,7 +26,7 @@ StringDecoder:: /** * Returns the next character in sequence. */ -int StringDecoder:: +char32_t StringDecoder:: get_next_character() { if (test_eof()) { return -1; @@ -57,19 +57,20 @@ get_notify_ptr() { /* In UTF-8, each 16-bit Unicode character is encoded as a sequence of -one, two, or three 8-bit bytes, depending on the value of the +one, two, three or four 8-bit bytes, depending on the value of the character. The following table shows the format of such UTF-8 byte sequences (where the "free bits" shown by x's in the table are combined in the order shown, and interpreted from most significant to least significant): Binary format of bytes in sequence: - Number of Maximum expressible - 1st byte 2nd byte 3rd byte free bits: Unicode value: + Number of Maximum expressible + 1st byte 2nd byte 3rd byte 4th byte free bits: Unicode value: - 0xxxxxxx 7 007F hex (127) - 110xxxxx 10xxxxxx (5+6)=11 07FF hex (2047) - 1110xxxx 10xxxxxx 10xxxxxx (4+6+6)=16 FFFF hex (65535) + 0xxxxxxx 7 007F hex (127) + 110xxxxx 10xxxxxx (5+6)=11 07FF hex (2047) + 1110xxxx 10xxxxxx 10xxxxxx (4+6+6)=16 FFFF hex (65535) + 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx (4+6*3)=21 10FFFF hex (1114111) The value of each individual byte indicates its UTF-8 function, as follows: @@ -77,12 +78,13 @@ The value of each individual byte indicates its UTF-8 function, as follows: 80 to BF hex (128 to 191): continuing byte in a multi-byte sequence. C2 to DF hex (194 to 223): first byte of a two-byte sequence. E0 to EF hex (224 to 239): first byte of a three-byte sequence. + F0 to F7 hex (240 to 247): first byte of a four-byte sequence. */ /** * Returns the next character in sequence. */ -int StringUtf8Decoder:: +char32_t StringUtf8Decoder:: get_next_character() { unsigned int result; while (!test_eof()) { @@ -125,6 +127,35 @@ get_next_character() { unsigned int three = (unsigned char)_input[_p++]; result = ((result & 0x0f) << 12) | ((two & 0x3f) << 6) | (three & 0x3f); return result; + + } else if ((result & 0xf8) == 0xf0) { + // First byte of four. + if (test_eof()) { + if (_notify_ptr != nullptr) { + (*_notify_ptr) + << "utf-8 encoded string '" << _input << "' ends abruptly.\n"; + } + return -1; + } + unsigned int two = (unsigned char)_input[_p++]; + if (test_eof()) { + if (_notify_ptr != nullptr) { + (*_notify_ptr) + << "utf-8 encoded string '" << _input << "' ends abruptly.\n"; + } + return -1; + } + unsigned int three = (unsigned char)_input[_p++]; + if (test_eof()) { + if (_notify_ptr != nullptr) { + (*_notify_ptr) + << "utf-8 encoded string '" << _input << "' ends abruptly.\n"; + } + return -1; + } + unsigned int four = (unsigned char)_input[_p++]; + result = ((result & 0x07) << 18) | ((two & 0x3f) << 12) | ((three & 0x3f) << 6) | (four & 0x3f); + return result; } // Otherwise--the high bit is set but it is not one of the introductory @@ -144,7 +175,7 @@ get_next_character() { /** * Returns the next character in sequence. */ -int StringUnicodeDecoder:: +char32_t StringUtf16Decoder:: get_next_character() { if (test_eof()) { return -1; @@ -159,5 +190,33 @@ get_next_character() { return -1; } unsigned int low = (unsigned char)_input[_p++]; - return ((high << 8) | low); + int ch = ((high << 8) | low); + + /* + using std::swap; + + if (ch == 0xfffe) { + // This is a byte-swapped byte-order-marker. That means we need to swap + // the endianness of the rest of the stream. + char *data = (char *)_input.data(); + for (size_t p = _p; p < _input.size() - 1; p += 2) { + std::swap(data[p], data[p + 1]); + } + ch = 0xfeff; + } + */ + + if (ch >= 0xd800 && ch < 0xdc00 && (_p + 1) < _input.size()) { + // This is a high surrogate. Look for a subsequent low surrogate. + unsigned int high = (unsigned char)_input[_p]; + unsigned int low = (unsigned char)_input[_p + 1]; + int ch2 = ((high << 8) | low); + if (ch2 >= 0xdc00 && ch2 < 0xe000) { + // Yes, this is a low surrogate. + _p += 2; + return 0x10000 + ((ch - 0xd800) << 10) + (ch2 - 0xdc00); + } + } + // No, this is just a regular character, or an unpaired surrogate. + return ch; } diff --git a/dtool/src/dtoolutil/stringDecoder.h b/dtool/src/dtoolutil/stringDecoder.h index c0b2534ee2..6885f77e08 100644 --- a/dtool/src/dtoolutil/stringDecoder.h +++ b/dtool/src/dtoolutil/stringDecoder.h @@ -26,7 +26,7 @@ public: INLINE StringDecoder(const std::string &input); virtual ~StringDecoder(); - virtual int get_next_character(); + virtual char32_t get_next_character(); INLINE bool is_eof(); static void set_notify_ptr(std::ostream *ptr); @@ -48,20 +48,23 @@ class StringUtf8Decoder : public StringDecoder { public: INLINE StringUtf8Decoder(const std::string &input); - virtual int get_next_character(); + virtual char32_t get_next_character(); }; /** * This decoder extracts characters two at a time to get a plain wide - * character sequence. + * character sequence. It supports surrogate pairs. */ -class StringUnicodeDecoder : public StringDecoder { +class StringUtf16Decoder : public StringDecoder { public: - INLINE StringUnicodeDecoder(const std::string &input); + INLINE StringUtf16Decoder(const std::string &input); - virtual int get_next_character(); + virtual char32_t get_next_character(); }; +// Deprecated alias of StringUtf16Encoder. +typedef StringUtf16Decoder StringUnicodeDecoder; + #include "stringDecoder.I" #endif diff --git a/dtool/src/dtoolutil/textEncoder.I b/dtool/src/dtoolutil/textEncoder.I index 417ef386e2..766319d6da 100644 --- a/dtool/src/dtoolutil/textEncoder.I +++ b/dtool/src/dtoolutil/textEncoder.I @@ -169,8 +169,23 @@ append_text(const std::string &text) { * wide character, up to 16 bits in Unicode. */ INLINE void TextEncoder:: -append_unicode_char(int character) { +append_unicode_char(char32_t character) { +#if WCHAR_MAX >= 0x10FFFF + // wchar_t might be UTF-32. _wtext = get_wtext() + std::wstring(1, (wchar_t)character); +#else + if ((character & ~0xffff) == 0) { + _wtext = get_wtext() + std::wstring(1, (wchar_t)character); + } else { + // Encode as a surrogate pair. + uint32_t v = (uint32_t)character - 0x10000u; + wchar_t wstr[2] = { + (wchar_t)((v >> 10u) | 0xd800u), + (wchar_t)((v & 0x3ffu) | 0xdc00u), + }; + _wtext = get_wtext() + std::wstring(wstr, 2); + } +#endif _flags = (_flags | F_got_wtext) & ~F_got_text; text_changed(); } diff --git a/dtool/src/dtoolutil/textEncoder.cxx b/dtool/src/dtoolutil/textEncoder.cxx index da835b7bfb..1065f21dcb 100644 --- a/dtool/src/dtoolutil/textEncoder.cxx +++ b/dtool/src/dtoolutil/textEncoder.cxx @@ -21,7 +21,7 @@ using std::ostream; using std::string; using std::wstring; -TextEncoder::Encoding TextEncoder::_default_encoding = TextEncoder::E_iso8859; +TextEncoder::Encoding TextEncoder::_default_encoding = TextEncoder::E_utf8; /** * Adjusts the text stored within the encoder to all uppercase letters @@ -109,11 +109,11 @@ is_wtext() const { } /** - * Encodes a single wide char into a one-, two-, or three-byte string, - * according to the given encoding system. + * Encodes a single Unicode character into a one-, two-, three-, or four-byte + * string, according to the given encoding system. */ string TextEncoder:: -encode_wchar(wchar_t ch, TextEncoder::Encoding encoding) { +encode_wchar(char32_t ch, TextEncoder::Encoding encoding) { switch (encoding) { case E_iso8859: if ((ch & ~0xff) == 0) { @@ -145,17 +145,38 @@ encode_wchar(wchar_t ch, TextEncoder::Encoding encoding) { return string(1, (char)((ch >> 6) | 0xc0)) + string(1, (char)((ch & 0x3f) | 0x80)); - } else { + } else if ((ch & ~0xffff) == 0) { return string(1, (char)((ch >> 12) | 0xe0)) + string(1, (char)(((ch >> 6) & 0x3f) | 0x80)) + string(1, (char)((ch & 0x3f) | 0x80)); + } else { + return + string(1, (char)((ch >> 18) | 0xf0)) + + string(1, (char)(((ch >> 12) & 0x3f) | 0x80)) + + string(1, (char)(((ch >> 6) & 0x3f) | 0x80)) + + string(1, (char)((ch & 0x3f) | 0x80)); } - case E_unicode: - return - string(1, (char)(ch >> 8)) + - string(1, (char)(ch & 0xff)); + case E_utf16be: + if ((ch & ~0xffff) == 0) { + // Note that this passes through surrogates and BOMs unharmed. + return + string(1, (char)(ch >> 8)) + + string(1, (char)(ch & 0xff)); + } else { + // Use a surrogate pair. + uint32_t v = (uint32_t)ch - 0x10000u; + uint16_t hi = (v >> 10u) | 0xd800u; + uint16_t lo = (v & 0x3ffu) | 0xdc00u; + char encoded[4] = { + (char)(hi >> 8), + (char)(hi & 0xff), + (char)(lo >> 8), + (char)(lo & 0xff), + }; + return string(encoded, 4); + } } return ""; @@ -169,8 +190,25 @@ string TextEncoder:: encode_wtext(const wstring &wtext, TextEncoder::Encoding encoding) { string result; - for (wstring::const_iterator pi = wtext.begin(); pi != wtext.end(); ++pi) { - result += encode_wchar(*pi, encoding); + for (size_t i = 0; i < wtext.size(); ++i) { + wchar_t ch = wtext[i]; + + // On some systems, wstring may be UTF-16, and contain surrogate pairs. +#if WCHAR_MAX < 0x10FFFF + if (ch >= 0xd800 && ch < 0xdc00 && (i + 1) < wtext.size()) { + // This is a high surrogate. Look for a subsequent low surrogate. + wchar_t ch2 = wtext[i + 1]; + if (ch2 >= 0xdc00 && ch2 < 0xe000) { + // Yes, this is a low surrogate. + char32_t code_point = 0x10000 + ((ch - 0xd800) << 10) + (ch2 - 0xdc00); + result += encode_wchar(code_point, encoding); + i++; + continue; + } + } +#endif + + result += encode_wchar(ch, encoding); } return result; @@ -189,9 +227,9 @@ decode_text(const string &text, TextEncoder::Encoding encoding) { return decode_text_impl(decoder); } - case E_unicode: + case E_utf16be: { - StringUnicodeDecoder decoder(text); + StringUtf16Decoder decoder(text); return decode_text_impl(decoder); } @@ -213,7 +251,7 @@ decode_text_impl(StringDecoder &decoder) { wstring result; // bool expand_amp = get_expand_amp(); - wchar_t character = decoder.get_next_character(); + char32_t character = decoder.get_next_character(); while (!decoder.is_eof()) { /* if (character == '&' && expand_amp) { @@ -221,7 +259,14 @@ decode_text_impl(StringDecoder &decoder) { character = expand_amp_sequence(decoder); } */ - result += character; + if (character <= WCHAR_MAX) { + result += character; + } else { + // We need to encode this as a surrogate pair. + uint32_t v = (uint32_t)character - 0x10000u; + result += (wchar_t)((v >> 10u) | 0xd800u); + result += (wchar_t)((v & 0x3ffu) | 0xdc00u); + } character = decoder.get_next_character(); } @@ -335,8 +380,8 @@ operator << (ostream &out, TextEncoder::Encoding encoding) { case TextEncoder::E_utf8: return out << "utf8"; - case TextEncoder::E_unicode: - return out << "unicode"; + case TextEncoder::E_utf16be: + return out << "utf16be"; }; return out << "**invalid TextEncoder::Encoding(" << (int)encoding << ")**"; @@ -354,8 +399,9 @@ operator >> (istream &in, TextEncoder::Encoding &encoding) { encoding = TextEncoder::E_iso8859; } else if (word == "utf8" || word == "utf-8") { encoding = TextEncoder::E_utf8; - } else if (word == "unicode") { - encoding = TextEncoder::E_unicode; + } else if (word == "unicode" || word == "utf16be" || word == "utf-16be" || + word == "utf16-be" || word == "utf-16-be") { + encoding = TextEncoder::E_utf16be; } else { ostream *notify_ptr = StringDecoder::get_notify_ptr(); if (notify_ptr != nullptr) { diff --git a/dtool/src/dtoolutil/textEncoder.h b/dtool/src/dtoolutil/textEncoder.h index baa0ef9b3e..71d93a71ca 100644 --- a/dtool/src/dtoolutil/textEncoder.h +++ b/dtool/src/dtoolutil/textEncoder.h @@ -35,7 +35,10 @@ PUBLISHED: enum Encoding { E_iso8859, E_utf8, - E_unicode + E_utf16be, + + // Deprecated alias for E_utf16be + E_unicode = E_utf16be, }; INLINE TextEncoder(); @@ -70,7 +73,7 @@ PUBLISHED: INLINE std::string get_text(Encoding encoding) const; INLINE void append_text(const std::string &text); #endif - INLINE void append_unicode_char(int character); + INLINE void append_unicode_char(char32_t character); INLINE size_t get_num_chars() const; INLINE int get_unicode_char(size_t index) const; INLINE void set_unicode_char(size_t index, int character); @@ -103,13 +106,13 @@ PUBLISHED: bool is_wtext() const; #ifdef CPPPARSER - EXTEND static PyObject *encode_wchar(wchar_t ch, Encoding encoding); + EXTEND static PyObject *encode_wchar(char32_t ch, Encoding encoding); EXTEND INLINE PyObject *encode_wtext(const std::wstring &wtext) const; EXTEND static PyObject *encode_wtext(const std::wstring &wtext, Encoding encoding); EXTEND INLINE PyObject *decode_text(PyObject *text) const; EXTEND static PyObject *decode_text(PyObject *text, Encoding encoding); #else - static std::string encode_wchar(wchar_t ch, Encoding encoding); + static std::string encode_wchar(char32_t ch, Encoding encoding); INLINE std::string encode_wtext(const std::wstring &wtext) const; static std::string encode_wtext(const std::wstring &wtext, Encoding encoding); INLINE std::wstring decode_text(const std::string &text) const; From 0561d7920f54900fa87238cbfb8abfb27e99b965 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 8 Oct 2018 23:19:29 +0200 Subject: [PATCH 227/360] tests: add unit tests for TextEncoder --- tests/dtoolutil/test_textencoder.py | 101 ++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tests/dtoolutil/test_textencoder.py diff --git a/tests/dtoolutil/test_textencoder.py b/tests/dtoolutil/test_textencoder.py new file mode 100644 index 0000000000..ef03c7d826 --- /dev/null +++ b/tests/dtoolutil/test_textencoder.py @@ -0,0 +1,101 @@ +import sys +import pytest +from panda3d.core import TextEncoder + +if sys.version_info >= (3, 0): + unichr = chr + xrange = range + + +def valid_characters(): + """Generator yielding all valid Unicode code points.""" + + for i in xrange(0xd800): + yield unichr(i) + + for i in xrange(0xe000, sys.maxunicode + 1): + if i != 0xfeff and i & 0xfffe != 0xfffe: + yield unichr(i) + + +def test_text_decode_iso8859(): + encoder = TextEncoder() + encoder.set_encoding(TextEncoder.E_iso8859) + + for i in xrange(255): + enc = unichr(i).encode('latin-1') + assert len(enc) == 1 + + dec = encoder.decode_text(enc) + assert len(dec) == 1 + assert ord(dec) == i + + +def test_text_decode_utf8(): + encoder = TextEncoder() + encoder.set_encoding(TextEncoder.E_utf8) + + for c in valid_characters(): + enc = c.encode('utf-8') + assert len(enc) <= 4 + + dec = encoder.decode_text(enc) + assert len(dec) == 1 + assert dec == c + + +def test_text_decode_utf16be(): + encoder = TextEncoder() + encoder.set_encoding(TextEncoder.E_utf16be) + + for c in valid_characters(): + enc = c.encode('utf-16be') + + dec = encoder.decode_text(enc) + assert len(c) == len(dec) + assert c == dec + + +def test_text_encode_iso8859(): + encoder = TextEncoder() + encoder.set_encoding(TextEncoder.E_iso8859) + + for i in xrange(255): + c = unichr(i) + enc = encoder.encode_wtext(c) + assert enc == c.encode('latin-1') + + +def test_text_encode_utf8(): + encoder = TextEncoder() + encoder.set_encoding(TextEncoder.E_utf8) + + for c in valid_characters(): + enc = encoder.encode_wtext(c) + assert enc == c.encode('utf-8') + + +def test_text_encode_utf16be(): + encoder = TextEncoder() + encoder.set_encoding(TextEncoder.E_utf16be) + + for c in valid_characters(): + enc = encoder.encode_wtext(c) + assert enc == c.encode('utf-16-be') + + +def test_text_append_unicode_char(): + encoder = TextEncoder() + encoder.set_encoding(TextEncoder.E_iso8859) + + code_points = [] + for code_point in [0, 1, 127, 128, 255, 256, 0xfffd, 0x10000, 0x10ffff]: + if code_point <= sys.maxunicode: + code_points.append(code_point) + encoder.append_unicode_char(code_point) + + encoded = encoder.get_wtext() + assert len(encoded) == len(code_points) + + for a, b in zip(code_points, encoded): + assert a == ord(b) From 7bd8cbdeb6984673fff9ba0f56402208026a5f74 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 8 Oct 2018 23:20:04 +0200 Subject: [PATCH 228/360] windisplay: allow changing undecorated/fixed_size after window open Fixes #405 --- panda/src/windisplay/winGraphicsWindow.cxx | 38 ++++++++++++++++++---- panda/src/windisplay/winGraphicsWindow.h | 4 +-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 954d8aca41..be14041027 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -283,6 +283,25 @@ set_properties_now(WindowProperties &properties) { return; } + if (properties.has_undecorated() || + properties.has_fixed_size()) { + if (properties.has_undecorated()) { + _properties.set_undecorated(properties.get_undecorated()); + properties.clear_undecorated(); + } + if (properties.has_fixed_size()) { + _properties.set_fixed_size(properties.get_fixed_size()); + properties.clear_fixed_size(); + } + DWORD window_style = make_style(_properties); + SetWindowLong(_hWnd, GWL_STYLE, window_style); + + // We need to call this to ensure that the style change takes effect. + SetWindowPos(_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | + SWP_FRAMECHANGED | SWP_NOSENDCHANGING | SWP_SHOWWINDOW); + } + if (properties.has_title()) { std::string title = properties.get_title(); _properties.set_title(title); @@ -487,7 +506,7 @@ open_window() { // CreateWindow() and know which window it is sending events to even before // it gives us a handle. Warning: this is not thread safe! _creating_window = this; - bool opened = open_graphic_window(is_fullscreen()); + bool opened = open_graphic_window(); _creating_window = nullptr; if (!opened) { @@ -865,7 +884,9 @@ do_fullscreen_switch() { return false; } - DWORD window_style = make_style(true); + WindowProperties props(_properties); + props.set_fullscreen(true); + DWORD window_style = make_style(props); SetWindowLong(_hWnd, GWL_STYLE, window_style); WINDOW_METRICS metrics; @@ -885,7 +906,10 @@ do_fullscreen_switch() { bool WinGraphicsWindow:: do_windowed_switch() { do_fullscreen_disable(); - DWORD window_style = make_style(false); + + WindowProperties props(_properties); + props.set_fullscreen(false); + DWORD window_style = make_style(props); SetWindowLong(_hWnd, GWL_STYLE, window_style); WINDOW_METRICS metrics; @@ -928,7 +952,7 @@ support_overlay_window(bool) { * Constructs a dwStyle for the specified mode, be it windowed or fullscreen. */ DWORD WinGraphicsWindow:: -make_style(bool fullscreen) { +make_style(const WindowProperties &properties) { // from MSDN: An OpenGL window has its own pixel format. Because of this, // only device contexts retrieved for the client area of an OpenGL window // are allowed to draw into the window. As a result, an OpenGL window @@ -938,7 +962,7 @@ make_style(bool fullscreen) { DWORD window_style = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - if (fullscreen){ + if (_properties.get_fullscreen()) { window_style |= WS_SYSMENU; } else if (!_properties.get_undecorated()) { window_style |= (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX); @@ -1015,8 +1039,8 @@ calculate_metrics(bool fullscreen, DWORD window_style, WINDOW_METRICS &metrics, * Creates a regular or fullscreen window. */ bool WinGraphicsWindow:: -open_graphic_window(bool fullscreen) { - DWORD window_style = make_style(fullscreen); +open_graphic_window() { + DWORD window_style = make_style(_properties); wstring title; if (_properties.has_title()) { diff --git a/panda/src/windisplay/winGraphicsWindow.h b/panda/src/windisplay/winGraphicsWindow.h index ff0340aa0d..5b0bb208c1 100644 --- a/panda/src/windisplay/winGraphicsWindow.h +++ b/panda/src/windisplay/winGraphicsWindow.h @@ -119,7 +119,7 @@ protected: virtual bool calculate_metrics(bool fullscreen, DWORD style, WINDOW_METRICS &metrics, bool &has_origin); - virtual DWORD make_style(bool fullscreen); + DWORD make_style(const WindowProperties &properties); virtual void reconsider_fullscreen_size(DWORD &x_size, DWORD &y_size, DWORD &bitdepth); @@ -127,7 +127,7 @@ protected: virtual void support_overlay_window(bool flag); private: - bool open_graphic_window(bool fullscreen); + bool open_graphic_window(); void adjust_z_order(); void adjust_z_order(WindowProperties::ZOrder last_z_order, WindowProperties::ZOrder this_z_order); From 6f623963735ed498e9bfcfa4ed887fc2e1adbe93 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 12 Oct 2018 15:37:18 -0600 Subject: [PATCH 229/360] general: Resolve a few compiler warnings - display: GraphicsWindowProc should have a virtual destructor, as it's meant to be subclassed. - express: set_matrix_view helper should always fail an assert when 'size' is wrong, even on release builds. - express: Fix filename capitalization on some #includes. They're normally Windows-only, where case doesn't matter, but it's better to be consistent. - gobj: Fix typo. - particlesystem: Remove BaseParticle::_last_position. Last position is tracked by PhysicsObject now. - windisplay: Heed warnings about casting bool to (PVOID). Also, per MSDN docs, SPI_SETMOUSETRAILS uses the uiParam argument and ignores pvParam, so pass the _saved_mouse_trails value in that way. --- panda/src/display/graphicsWindowProc.h | 1 + panda/src/express/pointerToArray_ext.I | 2 +- panda/src/express/pointerToArray_ext.h | 10 +++++----- panda/src/gobj/textureStage.cxx | 2 +- panda/src/particlesystem/baseParticle.cxx | 1 - panda/src/particlesystem/baseParticle.h | 2 -- panda/src/windisplay/winGraphicsWindow.cxx | 8 ++++---- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/panda/src/display/graphicsWindowProc.h b/panda/src/display/graphicsWindowProc.h index c9c056eebd..a330c06a11 100644 --- a/panda/src/display/graphicsWindowProc.h +++ b/panda/src/display/graphicsWindowProc.h @@ -32,6 +32,7 @@ class GraphicsWindow; class EXPCL_PANDA_DISPLAY GraphicsWindowProc { public: GraphicsWindowProc(); + virtual ~GraphicsWindowProc() = default; #if defined(__WIN32__) || defined(_WIN32) virtual LONG wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); diff --git a/panda/src/express/pointerToArray_ext.I b/panda/src/express/pointerToArray_ext.I index ee4c10e155..db14284e97 100644 --- a/panda/src/express/pointerToArray_ext.I +++ b/panda/src/express/pointerToArray_ext.I @@ -38,7 +38,7 @@ INLINE void set_matrix_view(Py_buffer &view, int flags, int length, int size, bo } else if (size == 4 && double_prec) { mat_size = sizeof(UnalignedLMatrix4d); } else { - assert(false); + nassertv_always(false); } view.len = length * mat_size; diff --git a/panda/src/express/pointerToArray_ext.h b/panda/src/express/pointerToArray_ext.h index 2daf885943..f17d1b634a 100644 --- a/panda/src/express/pointerToArray_ext.h +++ b/panda/src/express/pointerToArray_ext.h @@ -97,11 +97,11 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const; #ifdef _MSC_VER // Ugh... MSVC needs this because they still don't have a decent linker. -#include "PTA_uchar.h" -#include "PTA_ushort.h" -#include "PTA_float.h" -#include "PTA_double.h" -#include "PTA_int.h" +#include "pta_uchar.h" +#include "pta_ushort.h" +#include "pta_float.h" +#include "pta_double.h" +#include "pta_int.h" template class EXPORT_THIS Extension; template class EXPORT_THIS Extension; diff --git a/panda/src/gobj/textureStage.cxx b/panda/src/gobj/textureStage.cxx index 4fecd20999..0d6202d949 100644 --- a/panda/src/gobj/textureStage.cxx +++ b/panda/src/gobj/textureStage.cxx @@ -84,7 +84,7 @@ operator = (const TextureStage &other) { _combine_rgb_operand2 = other._combine_rgb_operand2; _combine_alpha_mode = other._combine_alpha_mode; _combine_alpha_source0 = other._combine_alpha_source0; - _combine_alpha_operand0 = _combine_alpha_operand0; + _combine_alpha_operand0 = other._combine_alpha_operand0; _combine_alpha_source1 = other._combine_alpha_source1; _combine_alpha_operand1 = other._combine_alpha_operand1; _combine_alpha_source2 = other._combine_alpha_source2; diff --git a/panda/src/particlesystem/baseParticle.cxx b/panda/src/particlesystem/baseParticle.cxx index 046b2dfb40..46e18179da 100644 --- a/panda/src/particlesystem/baseParticle.cxx +++ b/panda/src/particlesystem/baseParticle.cxx @@ -68,7 +68,6 @@ write(std::ostream &out, int indent) const { out.width(indent+2); out<<""; out<<"_lifespan "<<_lifespan<<"\n"; out.width(indent+2); out<<""; out<<"_alive "<<_alive<<"\n"; out.width(indent+2); out<<""; out<<"_index "<<_index<<"\n"; - out.width(indent+2); out<<""; out<<"_last_position "<<_last_position<<"\n"; PhysicsObject::write(out, indent+2); #endif //] NDEBUG } diff --git a/panda/src/particlesystem/baseParticle.h b/panda/src/particlesystem/baseParticle.h index 487f9ba476..834327bfec 100644 --- a/panda/src/particlesystem/baseParticle.h +++ b/panda/src/particlesystem/baseParticle.h @@ -62,8 +62,6 @@ private: PN_stdfloat _lifespan; bool _alive; int _index; - - LPoint3 _last_position; }; #include "baseParticle.I" diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index be14041027..b42ee43992 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -2210,12 +2210,12 @@ update_cursor_window(WinGraphicsWindow *to_window) { // We are leaving a graphics window; we should restore the Win2000 // effects. if (_got_saved_params) { - SystemParametersInfo(SPI_SETMOUSETRAILS, 0, - (PVOID)_saved_mouse_trails, 0); + SystemParametersInfo(SPI_SETMOUSETRAILS, _saved_mouse_trails, + 0, 0); SystemParametersInfo(SPI_SETCURSORSHADOW, 0, - (PVOID)_saved_cursor_shadow, 0); + _saved_cursor_shadow ? (PVOID)1 : nullptr, 0); SystemParametersInfo(SPI_SETMOUSEVANISH, 0, - (PVOID)_saved_mouse_vanish, 0); + _saved_mouse_vanish ? (PVOID)1 : nullptr, 0); _got_saved_params = false; } From 84ed19e8a7d34d78060c1215aebbfede5082cca8 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 12 Oct 2018 21:49:49 -0600 Subject: [PATCH 230/360] display: Add two missing includes (lightAttrib.h and materialAttrib.h) --- panda/src/display/standardMunger.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/panda/src/display/standardMunger.cxx b/panda/src/display/standardMunger.cxx index 4bb96fcfd5..2dba4aa6c0 100644 --- a/panda/src/display/standardMunger.cxx +++ b/panda/src/display/standardMunger.cxx @@ -12,10 +12,14 @@ */ #include "standardMunger.h" -#include "renderState.h" -#include "graphicsStateGuardian.h" + #include "config_gobj.h" + #include "displayRegion.h" +#include "graphicsStateGuardian.h" +#include "lightAttrib.h" +#include "materialAttrib.h" +#include "renderState.h" TypeHandle StandardMunger::_type_handle; From 602ea6ebf4678150531ad1520d3b7b1666b7760f Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 13 Oct 2018 15:18:05 -0600 Subject: [PATCH 231/360] general: Fix a couple more compiler warnings - express: Fix a warning when compiling for debug - dtoolutil: Give TextEncoder a virtual destructor --- dtool/src/dtoolutil/textEncoder.h | 2 ++ panda/src/express/pointerToArray_ext.I | 1 + 2 files changed, 3 insertions(+) diff --git a/dtool/src/dtoolutil/textEncoder.h b/dtool/src/dtoolutil/textEncoder.h index 71d93a71ca..30004ef5d3 100644 --- a/dtool/src/dtoolutil/textEncoder.h +++ b/dtool/src/dtoolutil/textEncoder.h @@ -44,6 +44,8 @@ PUBLISHED: INLINE TextEncoder(); INLINE TextEncoder(const TextEncoder ©); + virtual ~TextEncoder() = default; + INLINE void set_encoding(Encoding encoding); INLINE Encoding get_encoding() const; diff --git a/panda/src/express/pointerToArray_ext.I b/panda/src/express/pointerToArray_ext.I index db14284e97..5bcd1b77e9 100644 --- a/panda/src/express/pointerToArray_ext.I +++ b/panda/src/express/pointerToArray_ext.I @@ -39,6 +39,7 @@ INLINE void set_matrix_view(Py_buffer &view, int flags, int length, int size, bo mat_size = sizeof(UnalignedLMatrix4d); } else { nassertv_always(false); + return; // Make sure compiler knows control flow doesn't proceed. } view.len = length * mat_size; From 2d80d6d063ef30d96d93bdd3683a634cce33b2b0 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 14 Oct 2018 15:50:06 -0600 Subject: [PATCH 232/360] general: Add missing includes and remove deprecated type Credit for missing includes to @treamology in Git commit 16cfac482923bc734447d234fd8eaaa99483847d CGTableCount removed; modern macOS seems to call this a uint32_t instead. I can find no reference to CGTableCount in any documentation, and the (very old) source code I dig up just typedefs it anyway. --- panda/src/cocoadisplay/cocoaPandaApp.mm | 1 + panda/src/display/subprocessWindow.cxx | 2 ++ panda/src/osxdisplay/osxGraphicsStateGuardian.h | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/panda/src/cocoadisplay/cocoaPandaApp.mm b/panda/src/cocoadisplay/cocoaPandaApp.mm index e7226786da..83f0b8ef42 100644 --- a/panda/src/cocoadisplay/cocoaPandaApp.mm +++ b/panda/src/cocoadisplay/cocoaPandaApp.mm @@ -12,6 +12,7 @@ */ #import "cocoaPandaApp.h" +#include "config_cocoadisplay.h" @implementation CocoaPandaApp - (void) sendEvent: (NSEvent *) event { diff --git a/panda/src/display/subprocessWindow.cxx b/panda/src/display/subprocessWindow.cxx index fe4b2eff5d..5ea85c3cc9 100644 --- a/panda/src/display/subprocessWindow.cxx +++ b/panda/src/display/subprocessWindow.cxx @@ -18,6 +18,8 @@ #include "graphicsEngine.h" #include "config_display.h" #include "nativeWindowHandle.h" +#include "mouseButton.h" +#include "throw_event.h" using std::string; diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.h b/panda/src/osxdisplay/osxGraphicsStateGuardian.h index 038ba42055..96c86f28dd 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.h +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.h @@ -64,7 +64,7 @@ private: CGGammaValue _gOriginalRedTable[ 256 ]; CGGammaValue _gOriginalGreenTable[ 256 ]; CGGammaValue _gOriginalBlueTable[ 256 ]; - CGTableCount _sampleCount; + uint32_t _sampleCount; CGDisplayErr _cgErr; public: From d7f19b73e0f903a6c7341716822d16219e0075e9 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Oct 2018 13:27:36 +0200 Subject: [PATCH 233/360] dtoolutil: minor fix to TextEncoder::append_text --- dtool/src/dtoolutil/textEncoder_ext.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dtool/src/dtoolutil/textEncoder_ext.cxx b/dtool/src/dtoolutil/textEncoder_ext.cxx index b085b8a965..1947e6c749 100644 --- a/dtool/src/dtoolutil/textEncoder_ext.cxx +++ b/dtool/src/dtoolutil/textEncoder_ext.cxx @@ -94,7 +94,12 @@ append_text(PyObject *text) { #if PY_VERSION_HEX >= 0x03030000 Py_ssize_t len; const char *str = PyUnicode_AsUTF8AndSize(text, &len); - _this->append_text(std::string(str, len)); + std::string text_str(str, len); + if (_this->get_encoding() == TextEncoder::E_utf8) { + _this->append_text(text_str); + } else { + _this->append_wtext(TextEncoder::decode_text(text_str, TextEncoder::E_utf8)); + } #else Py_ssize_t len = PyUnicode_GET_SIZE(text); wchar_t *str = (wchar_t *)alloca(sizeof(wchar_t) * (len + 1)); From 02a72d4273dcd580b68c7332683303cdca200483 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Oct 2018 13:30:22 +0200 Subject: [PATCH 234/360] makepanda: remove reference to QuickTime framework Doesn't appear to be necessary, and QuickTime framework is removed in Mojave. Fixes #412 --- makepanda/makepanda.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 0164278d1e..dedd90b059 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -946,8 +946,6 @@ if (COMPILER=="GCC"): if GetTarget() == 'darwin': LibName("ALWAYS", "-framework AppKit") - if (PkgSkip("OPENCV")==0): - LibName("OPENCV", "-framework QuickTime") LibName("AGL", "-framework AGL") LibName("CARBON", "-framework Carbon") LibName("COCOA", "-framework Cocoa") From a765c32baef8da0185f4551945f27bd8ffa5f289 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Oct 2018 13:32:22 +0200 Subject: [PATCH 235/360] makepanda: don't use -fno-rtti on macOS, it fails to compile It appears that (included by ) uses RTTI, so we can't enable this for now. --- makepanda/makepanda.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index dedd90b059..540d9e86cf 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1332,9 +1332,10 @@ def CompileCxx(obj,src,opts): # Work around Apple compiler bug. cmd += " -U__EXCEPTIONS" - if 'RTTI' not in opts: + target = GetTarget() + if 'RTTI' not in opts and target != "darwin": # We always disable RTTI on Android for memory usage reasons. - if optlevel >= 4 or GetTarget() == "android": + if optlevel >= 4 or target == "android": cmd += " -fno-rtti" if ('SSE2' in opts or not PkgSkip("SSE2")) and not arch.startswith("arm") and arch != 'aarch64': From 70f4c1cd4e08918c86d809316f14618e5560087e Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Oct 2018 14:09:25 +0200 Subject: [PATCH 236/360] glgsg: change missing Cg attrib error message to debug This can occur if a variable is optimized out by the GLSL compiler but not by the Cg compiler. So it should not be reported as an error. Fixes #417 --- panda/src/glstuff/glCgShaderContext_src.cxx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 3a9b2fea6a..649208fb47 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -226,12 +226,14 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte if (!resource) { resource = "unknown"; } - GLCAT.error() - << "Could not find Cg varying " << cgGetParameterName(p); - if (attribname) { - GLCAT.error(false) << " : " << attribname; + if (GLCAT.is_debug()) { + GLCAT.debug() + << "Could not find Cg varying " << cgGetParameterName(p); + if (attribname) { + GLCAT.debug(false) << " : " << attribname; + } + GLCAT.debug(false) << " (" << resource << ") in the compiled GLSL program.\n"; } - GLCAT.error(false) << " (" << resource << ") in the compiled GLSL program.\n"; } else if (loc != 0 && bind._id._name == "vtx_position") { // We really have to bind the vertex position to attribute 0, since @@ -312,10 +314,10 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte GLCAT.debug(false) << " is bound to a conventional attribute (" << resource << ")\n"; } - } - if (loc == CA_unknown) { - // Suggest fix to developer. - GLCAT.error() << "Try using a different semantic.\n"; + if (loc == CA_unknown) { + // Suggest fix to developer. + GLCAT.debug() << "Try using a different semantic.\n"; + } } #endif From 6e370ebbdd63dc92dcdec7bc2575825a4a20c587 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Oct 2018 22:06:04 +0200 Subject: [PATCH 237/360] gobj: speed up GeomVertexData::get_num_rows() considerably --- panda/src/gobj/geomVertexArrayData.I | 4 +++- panda/src/gobj/geomVertexData.I | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index cfe12f9013..30e5c590e8 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -45,7 +45,9 @@ has_column(const InternalName *name) const { */ INLINE int GeomVertexArrayData:: get_num_rows() const { - return get_handle()->get_num_rows(); + CDReader cdata(_cycler); + nassertr(_array_format->get_stride() != 0, 0); + return cdata->_buffer.get_size() / _array_format->get_stride(); } /** diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index bfea5a10ef..bd68fc4cf4 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -60,9 +60,20 @@ has_column(const InternalName *name) const { */ INLINE int GeomVertexData:: get_num_rows() const { - GeomVertexDataPipelineReader reader(this, Thread::get_current_thread()); - reader.check_array_readers(); - return reader.get_num_rows(); + CPT(GeomVertexArrayData) array; + { + CDReader cdata(_cycler); + nassertr(cdata->_format->get_num_arrays() == cdata->_arrays.size(), 0); + + if (cdata->_arrays.size() == 0) { + // No arrays means no rows. Weird but legal. + return 0; + } + + array = cdata->_arrays[0].get_read_pointer(); + } + + return array->get_num_rows(); } /** From 0131d1013bba9688001a7c5b95069b28117932ba Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Oct 2018 22:07:32 +0200 Subject: [PATCH 238/360] gobj: fix assert when enabling hw anim if blend has 5+ transforms Instead, we reduce the TransformBlend down to the 4 most-weighted joints. --- panda/src/gobj/geomVertexData.cxx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 5e5fa7a1d4..d97197e25c 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -621,13 +621,26 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, const TransformBlend &blend = blend_table->get_blend(from.get_data1i()); LVecBase4 weights = LVecBase4::zero(); LVecBase4i indices(0, 0, 0, 0); - nassertv(blend.get_num_transforms() <= 4); - for (size_t i = 0; i < blend.get_num_transforms(); i++) { - weights[i] = blend.get_weight(i); - indices[i] = add_transform(transform_table, blend.get_transform(i), - already_added); + if (blend.get_num_transforms() <= 4) { + for (size_t i = 0; i < blend.get_num_transforms(); i++) { + weights[i] = blend.get_weight(i); + indices[i] = add_transform(transform_table, blend.get_transform(i), + already_added); + } + } else { + // Limit the number of blends to the four with highest weights. + TransformBlend blend2(blend); + blend2.limit_transforms(4); + blend2.normalize_weights(); + + for (size_t i = 0; i < 4; i++) { + weights[i] = blend2.get_weight(i); + indices[i] = add_transform(transform_table, blend2.get_transform(i), + already_added); + } } + if (weight.has_column()) { weight.set_data4(weights); } From bcc2e3e4042c31b2fe18de863159197c68b2749d Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Oct 2018 22:11:54 +0200 Subject: [PATCH 239/360] gobj: add Geom::get_animated_vertex_data() short-hand This is a method for getting the animated vertex data that will keep working even if GeomVertexData::animate_vertices() gets deprecated due to #421 being fixed. --- panda/src/collide/collisionTraverser.cxx | 2 +- panda/src/distort/projectionScreen.cxx | 8 +++----- panda/src/gobj/geom.cxx | 25 ++++++++++++++++++++++-- panda/src/gobj/geom.h | 2 ++ panda/src/grutil/multitexReducer.cxx | 2 +- panda/src/pgraph/geomNode.cxx | 5 ++--- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index 6e8a01d68f..35f7966a3f 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -1254,7 +1254,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, if (geom->get_primitive_type() == Geom::PT_polygons) { Thread *current_thread = Thread::get_current_thread(); - CPT(GeomVertexData) data = geom->get_vertex_data()->animate_vertices(true, current_thread); + CPT(GeomVertexData) data = geom->get_animated_vertex_data(true, current_thread); GeomVertexReader vertex(data, InternalName::get_vertex()); int num_primitives = geom->get_num_primitives(); diff --git a/panda/src/distort/projectionScreen.cxx b/panda/src/distort/projectionScreen.cxx index e3bed91e27..74314bce06 100644 --- a/panda/src/distort/projectionScreen.cxx +++ b/panda/src/distort/projectionScreen.cxx @@ -484,8 +484,7 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { const LMatrix4 &to_uv = _invert_uvs ? lens_to_uv_inverted : lens_to_uv; // Iterate through all the vertices in the Geom. - CPT(GeomVertexData) vdata = geom->get_vertex_data(current_thread); - vdata = vdata->animate_vertices(true, current_thread); + CPT(GeomVertexData) vdata = geom->get_animated_vertex_data(true, current_thread); CPT(GeomVertexFormat) vformat = vdata->get_format(); if (!vformat->has_column(_texcoord_name) || (_texcoord_3d && vformat->get_column(_texcoord_name)->get_num_components() < 3)) { @@ -507,7 +506,7 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { PT(GeomVertexData) modify_vdata = geom->modify_vertex_data(); // Maybe the vdata has animation that we should consider. - CPT(GeomVertexData) animated_vdata = geom->get_vertex_data(current_thread)->animate_vertices(true, current_thread); + CPT(GeomVertexData) animated_vdata = geom->get_animated_vertex_data(true, current_thread); GeomVertexWriter texcoord(modify_vdata, _texcoord_name, current_thread); GeomVertexWriter color(modify_vdata, current_thread); @@ -674,9 +673,8 @@ make_mesh_geom(const Geom *geom, Lens *lens, LMatrix4 &rel_mat) { Thread *current_thread = Thread::get_current_thread(); PT(Geom) new_geom = geom->make_copy(); + new_geom->set_vertex_data(new_geom->get_animated_vertex_data(false, current_thread)); PT(GeomVertexData) vdata = new_geom->modify_vertex_data(); - new_geom->set_vertex_data(vdata->animate_vertices(false, current_thread)); - vdata = new_geom->modify_vertex_data(); GeomVertexRewriter vertex(vdata, InternalName::get_vertex()); while (!vertex.is_at_end()) { LVertex vert = vertex.get_data3(); diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 565f8c47b4..bafe523e0f 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -286,6 +286,28 @@ make_nonindexed(bool composite_only) { return num_changed; } +/** + * Returns a GeomVertexData that represents the results of computing the + * vertex animation on the CPU for this Geom's vertex data. + * + * If there is no CPU-defined vertex animation on this object, this just + * returns the original object. + * + * If there is vertex animation, but the VertexTransform values have not + * changed since last time, this may return the same pointer it returned + * previously. Even if the VertexTransform values have changed, it may still + * return the same pointer, but with its contents modified (this is preferred, + * since it allows the graphics backend to update vertex buffers optimally). + * + * If force is false, this method may return immediately with stale data, if + * the vertex data is not completely resident. If force is true, this method + * will never return stale data, but may block until the data is available. + */ +CPT(GeomVertexData) Geom:: +get_animated_vertex_data(bool force, Thread *current_thread) const { + return get_vertex_data()->animate_vertices(force, current_thread); +} + /** * Replaces the ith GeomPrimitive object stored within the Geom with the new * object. @@ -1311,8 +1333,7 @@ compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { int num_vertices = 0; // Get the vertex data, after animation. - CPT(GeomVertexData) vertex_data = cdata->_data.get_read_pointer(current_thread); - vertex_data = vertex_data->animate_vertices(true, current_thread); + CPT(GeomVertexData) vertex_data = get_animated_vertex_data(true, current_thread); // Now actually compute the bounding volume. We do this by using // calc_tight_bounds to determine our box first. diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index 833ac3cd83..82aac75cfa 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -85,6 +85,8 @@ PUBLISHED: void offset_vertices(const GeomVertexData *data, int offset); int make_nonindexed(bool composite_only); + CPT(GeomVertexData) get_animated_vertex_data(bool force, Thread *current_thread) const; + INLINE bool is_empty() const; INLINE size_t get_num_primitives() const; diff --git a/panda/src/grutil/multitexReducer.cxx b/panda/src/grutil/multitexReducer.cxx index fdad25bb48..2fff484de3 100644 --- a/panda/src/grutil/multitexReducer.cxx +++ b/panda/src/grutil/multitexReducer.cxx @@ -866,7 +866,7 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, PT(Geom) geom = orig_geom->make_copy(); // Ensure that any vertex animation has been applied. - geom->set_vertex_data(geom->get_vertex_data(current_thread)->animate_vertices(true, current_thread)); + geom->set_vertex_data(geom->get_animated_vertex_data(true, current_thread)); // Now get a modifiable pointer to the vertex data in the new Geom. This // will actually perform a deep copy of the vertex data. diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index 16e95442c2..17d5555e5d 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -376,8 +376,7 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, geom = transformer.premunge_geom(geom, munger); // Prepare each of the vertex arrays in the munged Geom. - CPT(GeomVertexData) vdata = geom->get_vertex_data(current_thread); - vdata = vdata->animate_vertices(false, current_thread); + CPT(GeomVertexData) vdata = geom->get_animated_vertex_data(false, current_thread); GeomVertexDataPipelineReader vdata_reader(vdata, current_thread); int num_arrays = vdata_reader.get_num_arrays(); for (int i = 0; i < num_arrays; ++i) { @@ -474,7 +473,7 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, for (gi = geoms->begin(); gi != geoms->end(); ++gi) { CPT(Geom) geom = (*gi)._geom.get_read_pointer(); geom->calc_tight_bounds(min_point, max_point, found_any, - geom->get_vertex_data(current_thread)->animate_vertices(true, current_thread), + geom->get_animated_vertex_data(true, current_thread), !next_transform->is_identity(), mat, current_thread); } From ebfb3702acf79a54ab3ce455ff6d0abfbcfd66e9 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Oct 2018 22:21:45 +0200 Subject: [PATCH 240/360] prc: work around macOS compiler error when making optimized build --- dtool/src/prc/notifyCategory.I | 20 -------------------- dtool/src/prc/notifyCategory.h | 4 ++-- dtool/src/prc/notifyCategoryProxy.I | 12 ------------ dtool/src/prc/notifyCategoryProxy.h | 4 ++-- 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/dtool/src/prc/notifyCategory.I b/dtool/src/prc/notifyCategory.I index 5793917d91..20678fbace 100644 --- a/dtool/src/prc/notifyCategory.I +++ b/dtool/src/prc/notifyCategory.I @@ -82,26 +82,6 @@ is_debug() const { // Instruct the compiler to optimize for the usual case. return UNLIKELY(is_on(NS_debug)); } -#else -/** - * When NOTIFY_DEBUG is not defined, the categories are never set to "spam" or - * "debug" severities, and these methods are redefined to be static to make it - * more obvious to the compiler. - */ -constexpr bool NotifyCategory:: -is_spam() { - return false; -} - -/** - * When NOTIFY_DEBUG is not defined, the categories are never set to "spam" or - * "debug" severities, and these methods are redefined to be static to make it - * more obvious to the compiler. - */ -constexpr bool NotifyCategory:: -is_debug() { - return false; -} #endif /** diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index f3e99b09ba..9a2a9fa4e2 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -55,8 +55,8 @@ PUBLISHED: INLINE bool is_spam() const; INLINE bool is_debug() const; #else - constexpr static bool is_spam(); - constexpr static bool is_debug(); + constexpr static bool is_spam() { return false; } + constexpr static bool is_debug() { return false; } #endif INLINE bool is_info() const; INLINE bool is_warning() const; diff --git a/dtool/src/prc/notifyCategoryProxy.I b/dtool/src/prc/notifyCategoryProxy.I index eaca9b6e33..fbdac1f0ca 100644 --- a/dtool/src/prc/notifyCategoryProxy.I +++ b/dtool/src/prc/notifyCategoryProxy.I @@ -72,12 +72,6 @@ is_spam() { // Instruct the compiler to optimize for the usual case. return UNLIKELY(get_unsafe_ptr()->is_spam()); } -#else -template -constexpr bool NotifyCategoryProxy:: -is_spam() { - return false; -} #endif /** @@ -90,12 +84,6 @@ is_debug() { // Instruct the compiler to optimize for the usual case. return UNLIKELY(get_unsafe_ptr()->is_debug()); } -#else -template -constexpr bool NotifyCategoryProxy:: -is_debug() { - return false; -} #endif /** diff --git a/dtool/src/prc/notifyCategoryProxy.h b/dtool/src/prc/notifyCategoryProxy.h index 06f38ec804..5465529583 100644 --- a/dtool/src/prc/notifyCategoryProxy.h +++ b/dtool/src/prc/notifyCategoryProxy.h @@ -75,8 +75,8 @@ public: INLINE bool is_spam(); INLINE bool is_debug(); #else - constexpr static bool is_spam(); - constexpr static bool is_debug(); + constexpr static bool is_spam() { return false; } + constexpr static bool is_debug() { return false; } #endif INLINE bool is_info(); INLINE bool is_warning(); From 51f5124048f8f50b3580cec0815cb358de8cd041 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Oct 2018 22:23:45 +0200 Subject: [PATCH 241/360] dtoolutil: consistently use char32_t for Unicode code points Unlike wchar_t, char32_t is guaranteed to be able to hold a UTF-32 character. --- dtool/src/dtoolutil/textEncoder.I | 18 +++++++++--------- dtool/src/dtoolutil/textEncoder.h | 20 ++++++++++---------- dtool/src/dtoolutil/unicodeLatinMap.cxx | 2 +- dtool/src/dtoolutil/unicodeLatinMap.h | 10 +++++----- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/dtool/src/dtoolutil/textEncoder.I b/dtool/src/dtoolutil/textEncoder.I index 766319d6da..c9eeb0ec66 100644 --- a/dtool/src/dtoolutil/textEncoder.I +++ b/dtool/src/dtoolutil/textEncoder.I @@ -220,7 +220,7 @@ get_unicode_char(size_t index) const { * according to set_encoding(). */ INLINE void TextEncoder:: -set_unicode_char(size_t index, int character) { +set_unicode_char(size_t index, char32_t character) { get_wtext(); if (index < _wtext.length()) { _wtext[index] = character; @@ -283,7 +283,7 @@ reencode_text(const std::string &text, TextEncoder::Encoding from, * otherwise. This is akin to ctype's isalpha(), extended to Unicode. */ INLINE bool TextEncoder:: -unicode_isalpha(int character) { +unicode_isalpha(char32_t character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == nullptr) { return false; @@ -297,7 +297,7 @@ unicode_isalpha(int character) { * otherwise. This is akin to ctype's isdigit(), extended to Unicode. */ INLINE bool TextEncoder:: -unicode_isdigit(int character) { +unicode_isdigit(char32_t character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == nullptr) { // The digits aren't actually listed in the map. @@ -312,7 +312,7 @@ unicode_isdigit(int character) { * otherwise. This is akin to ctype's ispunct(), extended to Unicode. */ INLINE bool TextEncoder:: -unicode_ispunct(int character) { +unicode_ispunct(char32_t character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == nullptr) { // Some punctuation marks aren't listed in the map. @@ -326,7 +326,7 @@ unicode_ispunct(int character) { * otherwise. This is akin to ctype's isupper(), extended to Unicode. */ INLINE bool TextEncoder:: -unicode_isupper(int character) { +unicode_isupper(char32_t character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == nullptr) { return false; @@ -339,7 +339,7 @@ unicode_isupper(int character) { * otherwise. This is akin to ctype's isspace(), extended to Unicode. */ INLINE bool TextEncoder:: -unicode_isspace(int character) { +unicode_isspace(char32_t character) { switch (character) { case ' ': case '\t': @@ -356,7 +356,7 @@ unicode_isspace(int character) { * otherwise. This is akin to ctype's islower(), extended to Unicode. */ INLINE bool TextEncoder:: -unicode_islower(int character) { +unicode_islower(char32_t character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == nullptr) { return false; @@ -369,7 +369,7 @@ unicode_islower(int character) { * akin to ctype's toupper(), extended to Unicode. */ INLINE int TextEncoder:: -unicode_toupper(int character) { +unicode_toupper(char32_t character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == nullptr) { return character; @@ -382,7 +382,7 @@ unicode_toupper(int character) { * akin to ctype's tolower(), extended to Unicode. */ INLINE int TextEncoder:: -unicode_tolower(int character) { +unicode_tolower(char32_t character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == nullptr) { return character; diff --git a/dtool/src/dtoolutil/textEncoder.h b/dtool/src/dtoolutil/textEncoder.h index 30004ef5d3..1e1d9eeda4 100644 --- a/dtool/src/dtoolutil/textEncoder.h +++ b/dtool/src/dtoolutil/textEncoder.h @@ -23,7 +23,7 @@ class StringDecoder; /** * This class can be used to convert text between multiple representations, - * e.g. utf-8 to Unicode. You may use it as a static class object, passing + * e.g. UTF-8 to UTF-16. You may use it as a static class object, passing * the encoding each time, or you may create an instance and use that object, * which will record the current encoding and retain the current string. * @@ -78,21 +78,21 @@ PUBLISHED: INLINE void append_unicode_char(char32_t character); INLINE size_t get_num_chars() const; INLINE int get_unicode_char(size_t index) const; - INLINE void set_unicode_char(size_t index, int character); + INLINE void set_unicode_char(size_t index, char32_t character); INLINE std::string get_encoded_char(size_t index) const; INLINE std::string get_encoded_char(size_t index, Encoding encoding) const; INLINE std::string get_text_as_ascii() const; INLINE static std::string reencode_text(const std::string &text, Encoding from, Encoding to); - INLINE static bool unicode_isalpha(int character); - INLINE static bool unicode_isdigit(int character); - INLINE static bool unicode_ispunct(int character); - INLINE static bool unicode_islower(int character); - INLINE static bool unicode_isupper(int character); - INLINE static bool unicode_isspace(int character); - INLINE static int unicode_toupper(int character); - INLINE static int unicode_tolower(int character); + INLINE static bool unicode_isalpha(char32_t character); + INLINE static bool unicode_isdigit(char32_t character); + INLINE static bool unicode_ispunct(char32_t character); + INLINE static bool unicode_islower(char32_t character); + INLINE static bool unicode_isupper(char32_t character); + INLINE static bool unicode_isspace(char32_t character); + INLINE static int unicode_toupper(char32_t character); + INLINE static int unicode_tolower(char32_t character); INLINE static std::string upper(const std::string &source); INLINE static std::string upper(const std::string &source, Encoding encoding); diff --git a/dtool/src/dtoolutil/unicodeLatinMap.cxx b/dtool/src/dtoolutil/unicodeLatinMap.cxx index 87c9cb5a7d..288b85a4ce 100644 --- a/dtool/src/dtoolutil/unicodeLatinMap.cxx +++ b/dtool/src/dtoolutil/unicodeLatinMap.cxx @@ -1378,7 +1378,7 @@ static const wchar_t combining_accent_map[] = { * Returns the Entry associated with the indicated character, if there is one. */ const UnicodeLatinMap::Entry *UnicodeLatinMap:: -look_up(wchar_t character) { +look_up(char32_t character) { if (!_initialized) { init(); } diff --git a/dtool/src/dtoolutil/unicodeLatinMap.h b/dtool/src/dtoolutil/unicodeLatinMap.h index fb94154f7f..6ed3c5f17c 100644 --- a/dtool/src/dtoolutil/unicodeLatinMap.h +++ b/dtool/src/dtoolutil/unicodeLatinMap.h @@ -112,17 +112,17 @@ public: class Entry { public: - wchar_t _character; + char32_t _character; CharType _char_type; char _ascii_equiv; char _ascii_additional; - wchar_t _tolower_character; - wchar_t _toupper_character; + char32_t _tolower_character; + char32_t _toupper_character; AccentType _accent_type; int _additional_flags; }; - static const Entry *look_up(wchar_t character); + static const Entry *look_up(char32_t character); static wchar_t get_combining_accent(AccentType accent); @@ -130,7 +130,7 @@ private: static void init(); static bool _initialized; - typedef phash_map > ByCharacter; + typedef phash_map > ByCharacter; static ByCharacter *_by_character; enum { max_direct_chars = 256 }; static const Entry *_direct_chars[max_direct_chars]; From 75826c9a517b43053529e9e233b8d20524e99e02 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 16 Oct 2018 15:20:45 +0200 Subject: [PATCH 242/360] glgsg: fix error with multisampled float depth buffer Fixes #416 --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index eab850bdba..d5a8763fc8 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -1097,6 +1097,15 @@ bind_slot_multisample(bool rb_resize, Texture **attach, RenderTexturePlane slot, #endif glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]); GLuint format = GL_DEPTH_COMPONENT; +#ifndef OPENGLES + if (_fb_properties.get_float_depth()) { + if (!glgsg->_use_remapped_depth_range) { + format = GL_DEPTH_COMPONENT32F; + } else { + format = GL_DEPTH_COMPONENT32F_NV; + } + } else +#endif if (tex) { switch (tex->get_format()) { case Texture::F_depth_component16: From bfeb5060b814d25282ad395e8ab2411c01932585 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 16 Oct 2018 15:23:52 +0200 Subject: [PATCH 243/360] gobj: don't create pointless future in TextureReloadRequest --- panda/src/gobj/textureReloadRequest.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/gobj/textureReloadRequest.cxx b/panda/src/gobj/textureReloadRequest.cxx index 4c17b550b7..b63acb6090 100644 --- a/panda/src/gobj/textureReloadRequest.cxx +++ b/panda/src/gobj/textureReloadRequest.cxx @@ -40,7 +40,7 @@ do_task() { // become a kind of a leak (if the texture is never rendered again on // this GSG, we'll just end up carrying the texture memory in RAM // forever, instead of dumping it as soon as it gets prepared). - _texture->prepare(_pgo); + _pgo->enqueue_texture(_texture); } } From b569875bf91dcb510daaef7880c36c70fb8cdb69 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 16 Oct 2018 16:31:46 +0200 Subject: [PATCH 244/360] windisplay: fix window size changing when switching undecorated --- panda/src/windisplay/winGraphicsWindow.cxx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index b42ee43992..703aba0149 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -293,13 +293,29 @@ set_properties_now(WindowProperties &properties) { _properties.set_fixed_size(properties.get_fixed_size()); properties.clear_fixed_size(); } + // When switching undecorated mode, Windows will keep the window at the + // current outer size, whereas we want to keep it with the configured + // inner size. Store the current size and origin. + LPoint2i top_left = _properties.get_origin(); + LPoint2i bottom_right = top_left + _properties.get_size(); + DWORD window_style = make_style(_properties); SetWindowLong(_hWnd, GWL_STYLE, window_style); + // Now calculate the proper size and origin with the new window style. + RECT view_rect; + SetRect(&view_rect, top_left[0], top_left[1], + bottom_right[0], bottom_right[1]); + WINDOWINFO wi; + GetWindowInfo(_hWnd, &wi); + AdjustWindowRectEx(&view_rect, wi.dwStyle, FALSE, wi.dwExStyle); + // We need to call this to ensure that the style change takes effect. - SetWindowPos(_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | - SWP_FRAMECHANGED | SWP_NOSENDCHANGING | SWP_SHOWWINDOW); + SetWindowPos(_hWnd, HWND_NOTOPMOST, view_rect.left, view_rect.top, + view_rect.right - view_rect.left, + view_rect.bottom - view_rect.top, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED | + SWP_NOSENDCHANGING | SWP_SHOWWINDOW); } if (properties.has_title()) { From 82e2c391723e972f2d05d46fec28b88109cee6e9 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 16 Oct 2018 16:32:57 +0200 Subject: [PATCH 245/360] dtoolutil: fix tautological comparison compile warning --- dtool/src/dtoolutil/textEncoder.I | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/dtoolutil/textEncoder.I b/dtool/src/dtoolutil/textEncoder.I index c9eeb0ec66..aa6b42fdb5 100644 --- a/dtool/src/dtoolutil/textEncoder.I +++ b/dtool/src/dtoolutil/textEncoder.I @@ -316,7 +316,7 @@ unicode_ispunct(char32_t character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == nullptr) { // Some punctuation marks aren't listed in the map. - return (character >= 0 && character < 128 && ispunct(character)); + return (character < 128 && ispunct(character)); } return entry->_char_type == UnicodeLatinMap::CT_punct; } From fbf939141b4a2bd472a40fe5caa85e356d8d2b4c Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 16 Oct 2018 21:13:27 +0200 Subject: [PATCH 246/360] gobj: fix typo causing crash when preparing shader --- panda/src/gobj/preparedGraphicsObjects.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 4f6ecea1ed..96fcd80269 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -1619,8 +1619,8 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) { ++qsi) { Shader *shader = qsi->first; ShaderContext *sc = shader->prepare_now(this, gsg); - if (qti->second != nullptr) { - qti->second->set_result(sc); + if (qsi->second != nullptr) { + qsi->second->set_result(sc); } } From 0c9c698d136f3e8418c8356848e992ab9230f8b4 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 16 Oct 2018 21:18:02 +0200 Subject: [PATCH 247/360] pipeline: make BlockerSimple constexpr (needed by MutexSimpleImpl) --- panda/src/pipeline/blockerSimple.I | 8 -------- panda/src/pipeline/blockerSimple.h | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/panda/src/pipeline/blockerSimple.I b/panda/src/pipeline/blockerSimple.I index 0188281728..89be34a412 100644 --- a/panda/src/pipeline/blockerSimple.I +++ b/panda/src/pipeline/blockerSimple.I @@ -11,14 +11,6 @@ * @date 2007-06-20 */ -/** - * - */ -INLINE BlockerSimple:: -BlockerSimple() { - _flags = 0; -} - /** * */ diff --git a/panda/src/pipeline/blockerSimple.h b/panda/src/pipeline/blockerSimple.h index 71ae25c41d..d375d5dc16 100644 --- a/panda/src/pipeline/blockerSimple.h +++ b/panda/src/pipeline/blockerSimple.h @@ -28,7 +28,7 @@ */ class EXPCL_PANDA_PIPELINE BlockerSimple { protected: - INLINE BlockerSimple(); + constexpr BlockerSimple() = default; INLINE ~BlockerSimple(); protected: @@ -38,7 +38,7 @@ protected: F_has_waiters = 0x40000000, }; - unsigned int _flags; + unsigned int _flags = 0; friend class ThreadSimpleManager; }; From 88b0f3327ddf4cbbcf0c2af261daa658d4fee4d1 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 16 Oct 2018 21:19:06 +0200 Subject: [PATCH 248/360] Warning fixes and cleanups when building with SIMPLE_THREADS --- panda/src/net/connection.cxx | 2 +- .../src/pipeline/contextSwitch_longjmp_src.c | 19 ++++++------ panda/src/pipeline/contextSwitch_posix_src.c | 29 +++++++++---------- .../src/pipeline/contextSwitch_ucontext_src.c | 13 ++++----- .../src/pipeline/contextSwitch_windows_src.c | 19 ++++++------ panda/src/pipeline/pythonThread.cxx | 2 +- panda/src/pipeline/threadSimpleManager.cxx | 4 ++- 7 files changed, 43 insertions(+), 45 deletions(-) diff --git a/panda/src/net/connection.cxx b/panda/src/net/connection.cxx index aecfc111ac..27f5c8bb24 100644 --- a/panda/src/net/connection.cxx +++ b/panda/src/net/connection.cxx @@ -445,7 +445,7 @@ do_flush() { if (data_sent > 0) { total_sent += data_sent; } - double last_report = 0; + while (!okflag && tcp->Active() && (data_sent > 0 || tcp->GetLastError() == LOCAL_BLOCKING_ERROR)) { if (data_sent == 0) { diff --git a/panda/src/pipeline/contextSwitch_longjmp_src.c b/panda/src/pipeline/contextSwitch_longjmp_src.c index c3640b8f1f..5dec92804a 100644 --- a/panda/src/pipeline/contextSwitch_longjmp_src.c +++ b/panda/src/pipeline/contextSwitch_longjmp_src.c @@ -1,8 +1,4 @@ -/* Filename: contextSwitch_longjmp_src.c - * Created by: drose (15Apr10) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file contextSwitch_longjmp_src.c + * @author drose + * @date 2010-04-15 + */ /* This is the implementation of user-space context switching using setmp() / longjmp(). This is the hackier implementation, @@ -90,14 +89,14 @@ void cs_longjmp(cs_jmp_buf env) { _asm { mov eax, env; - + mov ebx, [eax + 0]; mov edi, [eax + 4]; mov esi, [eax + 8]; mov ebp, [eax + 12]; mov esp, [eax + 16]; mov edx, [eax + 20]; - + frstor [eax + 24]; /* restore floating-point state */ mov eax, 1; /* return 1 from setjmp: pass 2 return */ @@ -251,7 +250,7 @@ setup_context_1(void) { } void -init_thread_context(struct ThreadContext *context, +init_thread_context(struct ThreadContext *context, unsigned char *stack, size_t stack_size, ThreadFunction *thread_func, void *data) { /* Copy all of the input parameters to static variables, then begin @@ -263,7 +262,7 @@ init_thread_context(struct ThreadContext *context, st_data = data; setup_context_1(); -} +} void save_thread_context(struct ThreadContext *context, diff --git a/panda/src/pipeline/contextSwitch_posix_src.c b/panda/src/pipeline/contextSwitch_posix_src.c index 6f5df46445..f553cefc45 100644 --- a/panda/src/pipeline/contextSwitch_posix_src.c +++ b/panda/src/pipeline/contextSwitch_posix_src.c @@ -1,8 +1,4 @@ -/* Filename: contextSwitch_posix_src.c - * Created by: drose (15Apr10) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file contextSwitch_posix_src.c + * @author drose + * @date 2010-04-15 + */ /* This is the implementation of user-space context switching using posix threads to manage the different execution contexts. This @@ -44,7 +43,7 @@ struct ThreadContext { pthread_mutex_t _ready_mutex; pthread_cond_t _ready_cvar; int _ready_flag; - + /* This is set FALSE while the thread is alive, and TRUE if the thread is to be terminated when it next wakes up. */ int _terminated; @@ -83,19 +82,19 @@ thread_main(void *data) { } void -init_thread_context(struct ThreadContext *context, +init_thread_context(struct ThreadContext *context, unsigned char *stack, size_t stack_size, ThreadFunction *thread_func, void *data) { context->_thread_func = thread_func; context->_data = data; - pthread_attr_t attr; - pthread_attr_init(&attr); + pthread_attr_t attr; + pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, stack_size); - pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); - pthread_create(&(context->_thread), &attr, thread_main, context); - pthread_attr_destroy(&attr); + pthread_create(&(context->_thread), &attr, thread_main, context); + pthread_attr_destroy(&attr); } void @@ -142,7 +141,7 @@ switch_to_thread_context(struct ThreadContext *from_context, /* We've been rudely terminated. Exit gracefully. */ pthread_exit(NULL); } - + /* Now we have been signaled again, and we're ready to resume the thread. */ longjmp(from_context->_jmp_context, 1); @@ -164,7 +163,7 @@ alloc_thread_context() { pthread_mutexattr_init(&attr); // The symbol PTHREAD_MUTEX_DEFAULT isn't always available? // pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT); - int result = pthread_mutex_init(&context->_ready_mutex, &attr); + pthread_mutex_init(&context->_ready_mutex, &attr); pthread_mutexattr_destroy(&attr); pthread_cond_init(&context->_ready_cvar, NULL); diff --git a/panda/src/pipeline/contextSwitch_ucontext_src.c b/panda/src/pipeline/contextSwitch_ucontext_src.c index f589dbb5bf..f08c6d9afe 100644 --- a/panda/src/pipeline/contextSwitch_ucontext_src.c +++ b/panda/src/pipeline/contextSwitch_ucontext_src.c @@ -1,8 +1,4 @@ -/* Filename: contextSwitch_ucontext_src.c - * Created by: drose (15Apr10) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file contextSwitch_ucontext_src.c + * @author drose + * @date 2010-04-15 + */ /* This is the implementation of user-space context switching using getcontext() / setcontext(). This is the preferred implementation, @@ -43,7 +42,7 @@ begin_context(ThreadFunction *thread_func, void *data) { } void -init_thread_context(struct ThreadContext *context, +init_thread_context(struct ThreadContext *context, unsigned char *stack, size_t stack_size, ThreadFunction *thread_func, void *data) { if (getcontext(&context->_ucontext) != 0) { diff --git a/panda/src/pipeline/contextSwitch_windows_src.c b/panda/src/pipeline/contextSwitch_windows_src.c index 9f157d8eec..727eef43b9 100644 --- a/panda/src/pipeline/contextSwitch_windows_src.c +++ b/panda/src/pipeline/contextSwitch_windows_src.c @@ -1,8 +1,4 @@ -/* Filename: contextSwitch_windows_src.c - * Created by: drose (15Apr10) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file contextSwitch_windows_src.c + * @author drose + * @date 2010-04-15 + */ /* This is the implementation of user-space context switching using native Windows threading constructs to manage the different @@ -37,7 +36,7 @@ struct ThreadContext { /* This event is in the signaled state when the thread is ready to roll. */ HANDLE _ready; - + /* This is set FALSE while the thread is alive, and TRUE if the thread is to be terminated when it next wakes up. */ int _terminated; @@ -71,13 +70,13 @@ thread_main(LPVOID data) { } void -init_thread_context(struct ThreadContext *context, +init_thread_context(struct ThreadContext *context, unsigned char *stack, size_t stack_size, ThreadFunction *thread_func, void *data) { context->_thread_func = thread_func; context->_data = data; - context->_thread = CreateThread(NULL, stack_size, + context->_thread = CreateThread(NULL, stack_size, thread_main, context, 0, NULL); } @@ -117,7 +116,7 @@ switch_to_thread_context(struct ThreadContext *from_context, /* We've been rudely terminated. Exit gracefully. */ ExitThread(1); } - + /* Now we have been signaled again, and we're ready to resume the thread. */ longjmp(from_context->_jmp_context, 1); diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index ab41070fb8..53a811401e 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -225,7 +225,7 @@ call_python_func(PyObject *function, PyObject *args) { } else { // No exception. Restore the thread state normally. - PyThreadState *state = PyThreadState_Swap(orig_thread_state); + PyThreadState_Swap(orig_thread_state); thread_states.push_back(new_thread_state); // PyThreadState_Clear(new_thread_state); // PyThreadState_Delete(new_thread_state); diff --git a/panda/src/pipeline/threadSimpleManager.cxx b/panda/src/pipeline/threadSimpleManager.cxx index 4d9890dfd4..10b599116b 100644 --- a/panda/src/pipeline/threadSimpleManager.cxx +++ b/panda/src/pipeline/threadSimpleManager.cxx @@ -20,7 +20,9 @@ #include "mainThread.h" #ifdef WIN32 -#define WIN32_LEAN_AND_MEAN +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif #include #endif From 90cc8fe385255a5cdefa9035b7abd1e227128f03 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 16 Oct 2018 22:15:36 +0200 Subject: [PATCH 249/360] Fix building with SIMPLE_THREADS=1 --- dtool/src/dtoolbase/dtoolbase.cxx | 8 ++++++++ dtool/src/dtoolbase/dtoolbase_cc.h | 9 +++++++++ dtool/src/interrogatedb/py_panda.cxx | 5 +++++ dtool/src/parser-inc/Python.h | 2 +- panda/src/pipeline/threadSimpleImpl.I | 8 -------- panda/src/pipeline/threadSimpleImpl.cxx | 14 +++++++++++--- panda/src/pipeline/threadSimpleImpl.h | 2 +- panda/src/pipeline/threadSimpleManager.cxx | 14 ++------------ 8 files changed, 37 insertions(+), 25 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase.cxx b/dtool/src/dtoolbase/dtoolbase.cxx index a45a1de4e0..3bd34815c9 100644 --- a/dtool/src/dtoolbase/dtoolbase.cxx +++ b/dtool/src/dtoolbase/dtoolbase.cxx @@ -62,4 +62,12 @@ default_thread_consider_yield() { void (*global_thread_yield)() = default_thread_yield; void (*global_thread_consider_yield)() = default_thread_consider_yield; +#ifdef HAVE_PYTHON +static PyThreadState * +default_thread_state_swap(PyThreadState *state) { + return nullptr; +} +PyThreadState *(*global_thread_state_swap)(PyThreadState *tstate) = default_thread_state_swap; +#endif // HAVE_PYTHON + #endif // HAVE_THREADS && SIMPLE_THREADS diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 36da6b2b0b..8894469422 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -233,6 +233,15 @@ INLINE void thread_consider_yield() { (*global_thread_consider_yield)(); } +#ifdef HAVE_PYTHON +typedef struct _ts PyThreadState; +extern EXPCL_DTOOL_DTOOLBASE PyThreadState *(*global_thread_state_swap)(PyThreadState *tstate); + +INLINE PyThreadState *thread_state_swap(PyThreadState *tstate) { + return (*global_thread_state_swap)(tstate); +} +#endif // HAVE_PYTHON + #else INLINE void thread_yield() { diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 42bcdb9a35..dbb97ed0ff 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -752,6 +752,11 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { ExecutionEnvironment::shadow_environment_variable("MAIN_DIR", main_dir.to_os_specific()); PyErr_Clear(); initialized_main_dir = true; + + // Also, while we are at it, initialize the thread swap hook. +#if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) + global_thread_state_swap = PyThreadState_Swap; +#endif } PyModule_AddIntConstant(module, "Dtool_PyNativeInterface", 1); diff --git a/dtool/src/parser-inc/Python.h b/dtool/src/parser-inc/Python.h index ddd660072d..5f1a98a825 100644 --- a/dtool/src/parser-inc/Python.h +++ b/dtool/src/parser-inc/Python.h @@ -28,7 +28,7 @@ typedef _typeobject PyTypeObject; typedef struct {} PyStringObject; typedef struct {} PyUnicodeObject; -class PyThreadState; +typedef struct _ts PyThreadState; typedef int Py_ssize_t; typedef struct bufferinfo Py_buffer; diff --git a/panda/src/pipeline/threadSimpleImpl.I b/panda/src/pipeline/threadSimpleImpl.I index 001f3037d4..d712892883 100644 --- a/panda/src/pipeline/threadSimpleImpl.I +++ b/panda/src/pipeline/threadSimpleImpl.I @@ -51,14 +51,6 @@ is_threading_supported() { return true; } -/** - * - */ -INLINE bool ThreadSimpleImpl:: -is_true_threads() { - return (is_os_threads != 0); -} - /** * */ diff --git a/panda/src/pipeline/threadSimpleImpl.cxx b/panda/src/pipeline/threadSimpleImpl.cxx index a631421503..14d6f7561f 100644 --- a/panda/src/pipeline/threadSimpleImpl.cxx +++ b/panda/src/pipeline/threadSimpleImpl.cxx @@ -141,8 +141,8 @@ start(ThreadPriority priority, bool joinable) { #ifdef HAVE_PYTHON // Query the current Python thread state. - _python_state = PyThreadState_Swap(nullptr); - PyThreadState_Swap(_python_state); + _python_state = thread_state_swap(nullptr); + thread_state_swap(_python_state); #endif // HAVE_PYTHON init_thread_context(_context, _stack, _stack_size, st_begin_thread, this); @@ -201,6 +201,14 @@ prepare_for_exit() { manager->prepare_for_exit(); } +/** + * + */ +bool ThreadSimpleImpl:: +is_true_threads() { + return (is_os_threads != 0); +} + /** * */ @@ -238,7 +246,7 @@ st_begin_thread(void *data) { void ThreadSimpleImpl:: begin_thread() { #ifdef HAVE_PYTHON - PyThreadState_Swap(_python_state); + thread_state_swap(_python_state); #endif // HAVE_PYTHON #ifdef HAVE_POSIX_THREADS diff --git a/panda/src/pipeline/threadSimpleImpl.h b/panda/src/pipeline/threadSimpleImpl.h index c552dd1357..5bd6af3fdc 100644 --- a/panda/src/pipeline/threadSimpleImpl.h +++ b/panda/src/pipeline/threadSimpleImpl.h @@ -63,7 +63,7 @@ public: INLINE static void bind_thread(Thread *thread); INLINE static bool is_threading_supported(); - INLINE static bool is_true_threads(); + static bool is_true_threads(); INLINE static bool is_simple_threads(); INLINE static void sleep(double seconds); INLINE static void yield(); diff --git a/panda/src/pipeline/threadSimpleManager.cxx b/panda/src/pipeline/threadSimpleManager.cxx index 10b599116b..861e19cd77 100644 --- a/panda/src/pipeline/threadSimpleManager.cxx +++ b/panda/src/pipeline/threadSimpleManager.cxx @@ -237,7 +237,7 @@ next_context() { #ifdef HAVE_PYTHON // Save the current Python thread state. - _current_thread->_python_state = PyThreadState_Swap(nullptr); + _current_thread->_python_state = thread_state_swap(nullptr); #endif // HAVE_PYTHON #ifdef DO_PSTATS @@ -258,7 +258,7 @@ next_context() { #endif // DO_PSTATS #ifdef HAVE_PYTHON - PyThreadState_Swap(_current_thread->_python_state); + thread_state_swap(_current_thread->_python_state); #endif // HAVE_PYTHON } @@ -470,16 +470,6 @@ init_pointers() { _pointers_initialized = true; _global_ptr = new ThreadSimpleManager; Thread::get_main_thread(); - -#ifdef HAVE_PYTHON - // Ensure that the Python threading system is initialized and ready to go. - -#if PY_VERSION_HEX >= 0x03020000 - Py_Initialize(); -#endif - - PyEval_InitThreads(); -#endif } } From d6efceb1ed5fe98f7e7032dcf7000e39ff1c1041 Mon Sep 17 00:00:00 2001 From: Younguk Kim Date: Wed, 17 Oct 2018 20:42:37 +0900 Subject: [PATCH 250/360] dtoolbase: fix NOMINMAX macro redefinition warning --- dtool/src/dtoolbase/dtoolbase.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index f21e653695..2f8e7ca05d 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -63,8 +63,10 @@ /* Windows likes to define min() and max() macros, which will conflict with std::min() and std::max() respectively, unless we do this: */ #ifdef WIN32 +#ifndef NOMINMAX #define NOMINMAX #endif +#endif #ifndef __has_builtin #define __has_builtin(x) 0 From 4bc0a1ef5e4f0ff330b6a9a1bfb88352bb909d97 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 17 Oct 2018 17:28:25 +0200 Subject: [PATCH 251/360] tests: fix futures test when building without true threading --- tests/event/test_futures.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/event/test_futures.py b/tests/event/test_futures.py index e120a2ab8e..adef5b33fc 100644 --- a/tests/event/test_futures.py +++ b/tests/event/test_futures.py @@ -1,6 +1,5 @@ from panda3d import core import pytest -import threading import time import sys @@ -39,7 +38,11 @@ def test_future_timeout(): fut.result(0.001) +@pytest.mark.skipif(not core.Thread.is_threading_supported(), + reason="Threading support disabled") def test_future_wait(): + threading = pytest.importorskip("direct.stdpy.threading") + fut = core.AsyncFuture() # Launch a thread to set the result value. @@ -59,7 +62,11 @@ def test_future_wait(): assert fut.result() is None +@pytest.mark.skipif(not core.Thread.is_threading_supported(), + reason="Threading support disabled") def test_future_wait_cancel(): + threading = pytest.importorskip("direct.stdpy.threading") + fut = core.AsyncFuture() # Launch a thread to cancel the future. From bea15cd39a9507a9cf572c6ff582c2e19a25307a Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 17 Oct 2018 17:29:08 +0200 Subject: [PATCH 252/360] pgraph: fix crash when cull_callback modifies node in some way --- panda/src/pgraph/cullTraverserData.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index 8d54308af8..a260dd3ebb 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -54,6 +54,9 @@ apply_transform_and_state(CullTraverser *trav) { CPT(TransformState) node_transform = _node_reader.get_transform(); node_effects->cull_callback(trav, *this, node_transform, node_state); apply_transform(node_transform); + + // The cull callback may have changed the node properties. + _node_reader.check_cached(false); } if (!node_state->is_empty()) { From 90c13cbd4e142ae0570a332431f3a5fea026518f Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 17 Oct 2018 17:32:19 +0200 Subject: [PATCH 253/360] glgsg: fix error downloading texture with WM_repeat --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 616784e0cc..19594750c8 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -8925,6 +8925,9 @@ get_panda_wrap_mode(GLenum wm) { case GL_REPEAT: return SamplerState::WM_repeat; + case GL_MIRRORED_REPEAT: + return SamplerState::WM_mirror; + #ifndef OPENGLES case GL_MIRROR_CLAMP_EXT: case GL_MIRROR_CLAMP_TO_EDGE_EXT: From 6488e46cc71f93e392a2f2d0d7c94818043857d3 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 17 Oct 2018 17:33:27 +0200 Subject: [PATCH 254/360] Fix errors when building with --override DO_PIPELINING=UNDEF --- panda/src/gobj/geomVertexData.I | 2 + panda/src/pipeline/config_pipeline.cxx | 3 + panda/src/pipeline/cycleData.h | 5 +- .../src/pipeline/cycleDataLockedStageReader.I | 51 ++++++++++++----- panda/src/pipeline/cycleDataStageWriter.I | 57 +++++++++++++------ 5 files changed, 86 insertions(+), 32 deletions(-) diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index bd68fc4cf4..d0c6bba632 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -772,7 +772,9 @@ set_object(const GeomVertexData *object) { _cdata = (GeomVertexData::CData *)_object->_cycler.read_unlocked(_current_thread); _got_array_readers = false; +#ifdef DO_PIPELINING _cdata->ref(); +#endif // DO_PIPELINING } /** diff --git a/panda/src/pipeline/config_pipeline.cxx b/panda/src/pipeline/config_pipeline.cxx index 2e7bf6487e..4fd5214323 100644 --- a/panda/src/pipeline/config_pipeline.cxx +++ b/panda/src/pipeline/config_pipeline.cxx @@ -71,7 +71,10 @@ init_libpipeline() { } initialized = true; +#ifdef DO_PIPELINING CycleData::init_type(); +#endif + MainThread::init_type(); ExternalThread::init_type(); GenericThread::init_type(); diff --git a/panda/src/pipeline/cycleData.h b/panda/src/pipeline/cycleData.h index de90bdf226..bf0071ac67 100644 --- a/panda/src/pipeline/cycleData.h +++ b/panda/src/pipeline/cycleData.h @@ -50,10 +50,13 @@ class EXPCL_PANDA_PIPELINE CycleData { public: INLINE CycleData() = default; - INLINE CycleData(CycleData &&from) = default; + INLINE CycleData(CycleData &&from) noexcept = default; INLINE CycleData(const CycleData ©) = default; virtual ~CycleData(); + CycleData &operator = (CycleData &&from) noexcept = default; + CycleData &operator = (const CycleData ©) = default; + virtual CycleData *make_copy() const=0; virtual void write_datagram(BamWriter *, Datagram &) const; diff --git a/panda/src/pipeline/cycleDataLockedStageReader.I b/panda/src/pipeline/cycleDataLockedStageReader.I index 22b8785c82..a471aac0b7 100644 --- a/panda/src/pipeline/cycleDataLockedStageReader.I +++ b/panda/src/pipeline/cycleDataLockedStageReader.I @@ -47,6 +47,20 @@ CycleDataLockedStageReader(const CycleDataLockedStageReader © _cycler->increment_read(_pointer); } +/** + * + */ +template +INLINE CycleDataLockedStageReader:: +CycleDataLockedStageReader(CycleDataLockedStageReader &&from) noexcept : + _cycler(from._cycler), + _current_thread(from._current_thread), + _pointer(from._pointer), + _stage(from._stage) +{ + from._pointer = nullptr; +} + /** * */ @@ -64,20 +78,6 @@ operator = (const CycleDataLockedStageReader ©) { _cycler->increment_read(_pointer); } -/** - * - */ -template -INLINE CycleDataLockedStageReader:: -CycleDataLockedStageReader(CycleDataLockedStageReader &&from) noexcept : - _cycler(from._cycler), - _current_thread(from._current_thread), - _pointer(from._pointer), - _stage(from._stage) -{ - from._pointer = nullptr; -} - /** * */ @@ -174,6 +174,17 @@ CycleDataLockedStageReader(const CycleDataLockedStageReader © { } +/** + * + */ +template +INLINE CycleDataLockedStageReader:: +CycleDataLockedStageReader(CycleDataLockedStageReader &&from) noexcept : + _pointer(from._cycler) +{ + from._pointer = nullptr; +} + /** * */ @@ -183,6 +194,18 @@ operator = (const CycleDataLockedStageReader ©) { _pointer = copy._pointer; } +/** + * + */ +template +INLINE void CycleDataLockedStageReader:: +operator = (CycleDataLockedStageReader &&from) noexcept { + nassertv(_pointer == nullptr); + + _pointer = from._pointer; + from._pointer = nullptr; +} + /** * */ diff --git a/panda/src/pipeline/cycleDataStageWriter.I b/panda/src/pipeline/cycleDataStageWriter.I index a4c1851dde..cf25cf807a 100644 --- a/panda/src/pipeline/cycleDataStageWriter.I +++ b/panda/src/pipeline/cycleDataStageWriter.I @@ -62,23 +62,6 @@ CycleDataStageWriter(const CycleDataStageWriter ©) : _cycler->increment_write(_pointer); } -/** - * - */ -template -INLINE void CycleDataStageWriter:: -operator = (const CycleDataStageWriter ©) { - nassertv(_pointer == nullptr); - nassertv(_current_thread == copy._current_thread); - - _cycler = copy._cycler; - _pointer = copy._pointer; - _stage = copy._stage; - - nassertv(_pointer != nullptr); - _cycler->increment_write(_pointer); -} - /** * This flavor of the constructor elevates the pointer from the * CycleDataLockedStageReader from a read to a write pointer (and invalidates @@ -128,6 +111,23 @@ CycleDataStageWriter(CycleDataStageWriter &&from) noexcept : from._pointer = nullptr; } +/** + * + */ +template +INLINE void CycleDataStageWriter:: +operator = (const CycleDataStageWriter ©) { + nassertv(_pointer == nullptr); + nassertv(_current_thread == copy._current_thread); + + _cycler = copy._cycler; + _pointer = copy._pointer; + _stage = copy._stage; + + nassertv(_pointer != nullptr); + _cycler->increment_write(_pointer); +} + /** * */ @@ -227,6 +227,17 @@ CycleDataStageWriter(const CycleDataStageWriter ©) : { } +/** + * + */ +template +INLINE CycleDataStageWriter:: +CycleDataStageWriter(CycleDataStageWriter &&from) noexcept : + _pointer(from._pointer) +{ + from._pointer = nullptr; +} + /** * */ @@ -236,6 +247,18 @@ operator = (const CycleDataStageWriter ©) { _pointer = copy._pointer; } +/** + * + */ +template +INLINE void CycleDataStageWriter:: +operator = (CycleDataStageWriter &&from) noexcept { + nassertv(_pointer == nullptr); + + _pointer = from._pointer; + from._pointer = nullptr; +} + /** * This flavor of the constructor elevates the pointer from the * CycleDataLockedStageReader from a read to a write pointer (and invalidates From 775e4cecff88095155500bb29f3a240acfe64dec Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 17 Oct 2018 19:09:36 +0200 Subject: [PATCH 255/360] pgraph: fix freeze in garbage_collect(), esp. when rate-limit is on --- panda/src/pgraph/renderAttrib.cxx | 5 ++++- panda/src/pgraph/renderState.cxx | 3 +++ panda/src/pgraph/transformState.cxx | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 73b1e4b392..9bac4e666a 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -211,7 +211,7 @@ garbage_collect() { } num_this_pass = std::min(num_this_pass, size); - size_t stop_at_element = (_garbage_index + num_this_pass) % size; + size_t stop_at_element = (si + num_this_pass) % size; do { RenderAttrib *attrib = (RenderAttrib *)_attribs->get_key(si); @@ -229,6 +229,9 @@ garbage_collect() { // still need to visit. --size; --si; + if (stop_at_element > 0) { + --stop_at_element; + } } si = (si + 1) % size; diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 927d1e7073..5ce1527247 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -950,6 +950,9 @@ garbage_collect() { // still need to visit. --size; --si; + if (stop_at_element > 0) { + --stop_at_element; + } } si = (si + 1) % size; diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index 453fb505b4..4d02425683 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -1216,6 +1216,9 @@ garbage_collect() { // still need to visit. --size; --si; + if (stop_at_element > 0) { + --stop_at_element; + } } si = (si + 1) % size; From eac88fc64a22f483c23729f57c2d3e89d476cc62 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 17 Oct 2018 19:43:41 +0200 Subject: [PATCH 256/360] chan: disable AnimControl copy ctor and assignment operators --- panda/src/chan/animControl.cxx | 4 ++-- panda/src/chan/animControl.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index aa47ea7486..df7fb26498 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -32,14 +32,14 @@ AnimControl(const std::string &name, PartBundle *part, Namable(name), _pending_lock(name), _pending_cvar(_pending_lock), - _bound_joints(BitArray::all_on()) + _bound_joints(BitArray::all_on()), + _part(part) { #ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, get_class_type()); #endif _pending = true; - _part = part; _anim = nullptr; _channel_index = -1; set_frame_rate(frame_rate); diff --git a/panda/src/chan/animControl.h b/panda/src/chan/animControl.h index bee9f7223b..d52b2e4835 100644 --- a/panda/src/chan/animControl.h +++ b/panda/src/chan/animControl.h @@ -39,6 +39,8 @@ class EXPCL_PANDA_CHAN AnimControl : public TypedReferenceCount, public AnimInte public: AnimControl(const std::string &name, PartBundle *part, double frame_rate, int num_frames); + AnimControl(const AnimControl ©) = delete; + void setup_anim(PartBundle *part, AnimBundle *anim, int channel_index, const BitArray &bound_joints); void set_bound_joints(const BitArray &bound_joints); @@ -82,7 +84,7 @@ private: // This is a PT(PartGroup) instead of a PT(PartBundle), just because we // can't include partBundle.h for circular reasons. But it actually keeps a // pointer to a PartBundle. - PT(PartGroup) _part; + const PT(PartGroup) _part; PT(AnimBundle) _anim; int _channel_index; From a05e928a75ab34f58e11395b0bb3d7681b69b849 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 17 Oct 2018 19:44:39 +0200 Subject: [PATCH 257/360] chan: fix crash in certain cases after AnimControl destruction --- panda/src/chan/partBundle.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index 966987995a..cd9fe3f5ce 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -558,6 +558,12 @@ control_removed(AnimControl *control) { if (cbi != cdata->_blend.end()) { cdata->_blend.erase(cbi); cdata->_anim_changed = true; + + // We need to make sure that any _effective_channel pointers that point + // to this control are cleared. + if (pipeline_stage == 0) { + determine_effective_channels(cdata); + } } } CLOSE_ITERATE_ALL_STAGES(_cycler); From 2cd5a04f3f862c9c3fcce1a2841ce4aa610b3303 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 17 Oct 2018 19:54:29 +0200 Subject: [PATCH 258/360] pipeline: fix compiler error on older versions of GCC --- panda/src/pipeline/cycleData.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/pipeline/cycleData.h b/panda/src/pipeline/cycleData.h index bf0071ac67..ef21ad7a33 100644 --- a/panda/src/pipeline/cycleData.h +++ b/panda/src/pipeline/cycleData.h @@ -50,11 +50,11 @@ class EXPCL_PANDA_PIPELINE CycleData { public: INLINE CycleData() = default; - INLINE CycleData(CycleData &&from) noexcept = default; + INLINE CycleData(CycleData &&from) = default; INLINE CycleData(const CycleData ©) = default; virtual ~CycleData(); - CycleData &operator = (CycleData &&from) noexcept = default; + CycleData &operator = (CycleData &&from) = default; CycleData &operator = (const CycleData ©) = default; virtual CycleData *make_copy() const=0; From e67d2a16c1733843e169543763c1bc05203ec449 Mon Sep 17 00:00:00 2001 From: loblao Date: Thu, 18 Oct 2018 12:14:20 -0300 Subject: [PATCH 259/360] Dtool_PyModuleInitHelper: Fix segfault --- dtool/src/interrogatedb/py_panda.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index dbb97ed0ff..c29796def6 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -722,7 +722,10 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { // Extract the __file__ attribute, if present. Filename main_dir; - PyObject *file_attr = PyObject_GetAttrString(main_module, "__file__"); + PyObject *file_attr = nullptr; + if (main_module != nullptr) { + file_attr = PyObject_GetAttrString(main_module, "__file__"); + } if (file_attr == nullptr) { // Must be running in the interactive interpreter. Use the CWD. main_dir = ExecutionEnvironment::get_cwd(); From f35c9e5d799617bc8636174fe4f9930a8e6a3d87 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 18 Oct 2018 22:03:16 +0200 Subject: [PATCH 260/360] chan: adjust _net_blend when AnimControl destructs --- panda/src/chan/partBundle.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index cd9fe3f5ce..9d960f3e7d 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -556,6 +556,7 @@ control_removed(AnimControl *control) { CDStageWriter cdata(_cycler, pipeline_stage); ChannelBlend::iterator cbi = cdata->_blend.find(control); if (cbi != cdata->_blend.end()) { + cdata->_net_blend -= cbi->second; cdata->_blend.erase(cbi); cdata->_anim_changed = true; From f8b47dc14c27b0189a9d8395efb09e7be0f846e3 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 18 Oct 2018 22:19:55 +0200 Subject: [PATCH 261/360] direct: fix slowness in big games with Func(messenger.send) --- direct/src/interval/FunctionInterval.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/direct/src/interval/FunctionInterval.py b/direct/src/interval/FunctionInterval.py index 8f84ca9df8..db626c404e 100644 --- a/direct/src/interval/FunctionInterval.py +++ b/direct/src/interval/FunctionInterval.py @@ -77,7 +77,10 @@ class FunctionInterval(Interval.Interval): @staticmethod def makeUniqueName(func, suffix = ''): - name = 'Func-%s-%d' % (getattr(func, '__name__', str(func)), FunctionInterval.functionIntervalNum) + func_name = getattr(func, '__name__', None) + if func_name is None: + func_name = str(func) + name = 'Func-%s-%d' % (func_name, FunctionInterval.functionIntervalNum) FunctionInterval.functionIntervalNum += 1 if suffix: name = '%s-%s' % (name, str(suffix)) From 30f1c8ba92df4ee1fc35d7b54ff716ef18272fa4 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 19 Oct 2018 00:12:53 +0200 Subject: [PATCH 262/360] display: slight cleanup of graphicsPipeSelection.cxx This seemed to halve the compile time of this file under MSVC. --- panda/src/display/graphicsPipeSelection.cxx | 42 +++++++-------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index 9c4f52ff63..58866efef6 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -18,7 +18,6 @@ #include "load_dso.h" #include "config_display.h" #include "typeRegistry.h" -#include "pset.h" #include "config_putil.h" #include @@ -61,8 +60,8 @@ GraphicsPipeSelection() : _lock("GraphicsPipeSelection") { // Also get the set of modules named in the various aux-display Config // variables. We'll want to know this when we call load_modules() later. - int num_aux = aux_display.get_num_unique_values(); - for (int i = 0; i < num_aux; i++) { + size_t num_aux = aux_display.get_num_unique_values(); + for (size_t i = 0; i < num_aux; ++i) { string name = aux_display.get_unique_value(i); if (name != _default_display_module) { _display_modules.push_back(name); @@ -124,9 +123,7 @@ print_pipe_types() const { LightMutexHolder holder(_lock); nout << "Known pipe types:" << std::endl; - PipeTypes::const_iterator pi; - for (pi = _pipe_types.begin(); pi != _pipe_types.end(); ++pi) { - const PipeType &pipe_type = (*pi); + for (const PipeType &pipe_type : _pipe_types) { nout << " " << pipe_type._type << "\n"; } if (_display_modules.empty()) { @@ -187,11 +184,9 @@ make_pipe(const string &type_name, const string &module_name) { PT(GraphicsPipe) GraphicsPipeSelection:: make_pipe(TypeHandle type) { LightMutexHolder holder(_lock); - PipeTypes::const_iterator ti; // First, look for an exact match of the requested type. - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (ptype._type == type) { // Here's an exact match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); @@ -202,8 +197,7 @@ make_pipe(TypeHandle type) { } // Now look for a more-specific type. - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (ptype._type.is_derived_from(type)) { // Here's an approximate match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); @@ -215,8 +209,7 @@ make_pipe(TypeHandle type) { // Couldn't find any match; load the default module and try again. load_default_module(); - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (ptype._type.is_derived_from(type)) { // Here's an approximate match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); @@ -260,13 +253,11 @@ make_default_pipe() { load_default_module(); LightMutexHolder holder(_lock); - PipeTypes::const_iterator ti; if (!_default_pipe_name.empty()) { // First, look for an exact match of the default type name from the // Configrc file (excepting case and hyphenunderscore). - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (cmp_nocase_uh(ptype._type.get_name(), _default_pipe_name) == 0) { // Here's an exact match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); @@ -278,8 +269,7 @@ make_default_pipe() { // No match; look for a substring match. string preferred_name = downcase(_default_pipe_name); - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { string ptype_name = downcase(ptype._type.get_name()); if (ptype_name.find(preferred_name) != string::npos) { // Here's a substring match. @@ -292,8 +282,7 @@ make_default_pipe() { } // Couldn't find a matching pipe type; choose the first one on the list. - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { PT(GraphicsPipe) pipe = (*ptype._constructor)(); if (pipe != nullptr) { return pipe; @@ -310,9 +299,8 @@ make_default_pipe() { */ void GraphicsPipeSelection:: load_aux_modules() { - DisplayModules::iterator di; - for (di = _display_modules.begin(); di != _display_modules.end(); ++di) { - load_named_module(*di); + for (const string &module : _display_modules) { + load_named_module(module); } _display_modules.clear(); @@ -337,9 +325,7 @@ add_pipe_type(TypeHandle type, PipeConstructorFunc *func) { // First, make sure we don't already have a GraphicsPipe of this type. LightMutexHolder holder(_lock); - PipeTypes::const_iterator ti; - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (ptype._type == type) { display_cat->warning() << "Attempt to register GraphicsPipe type " << type @@ -375,8 +361,8 @@ do_load_default_module() { load_named_module(_default_display_module); DisplayModules::iterator di = - find(_display_modules.begin(), _display_modules.end(), - _default_display_module); + std::find(_display_modules.begin(), _display_modules.end(), + _default_display_module); if (di != _display_modules.end()) { _display_modules.erase(di); } From 175d7ff56bd1741ddaffd7f6702bc538bea20866 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 19 Oct 2018 00:30:14 +0200 Subject: [PATCH 263/360] display: significantly decrease p3display_composite2 compile time This applies to building with MSVC and Eigen specifically. Apparently, fetch_specified_part is taking up most of the compile time here. I have no idea why these changes in particular make it faster, but they just do. --- panda/src/display/graphicsStateGuardian.cxx | 86 +++++++++++---------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index b76a7f751c..0e82a23f88 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -24,7 +24,6 @@ #include "renderBuffer.h" #include "light.h" #include "planeNode.h" -#include "ambientLight.h" #include "throw_event.h" #include "clockObject.h" #include "pStatTimer.h" @@ -60,7 +59,6 @@ #include "fogAttrib.h" #include "config_pstatclient.h" -#include #include using std::string; @@ -932,12 +930,12 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } case Shader::SMO_frame_time: { PN_stdfloat time = ClockObject::get_global_clock()->get_frame_time(); - t = LMatrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, time, time, time, time); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, time, time, time, time); return &t; } case Shader::SMO_frame_delta: { PN_stdfloat dt = ClockObject::get_global_clock()->get_dt(); - t = LMatrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, dt, dt, dt, dt); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, dt, dt, dt, dt); return &t; } case Shader::SMO_texpad_x: { @@ -949,7 +947,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, double cx = (sx * 0.5) / tex->get_x_size(); double cy = (sy * 0.5) / tex->get_y_size(); double cz = (sz * 0.5) / tex->get_z_size(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,cx,cy,cz,0); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, cx, cy, cz, 0); return &t; } case Shader::SMO_texpix_x: { @@ -958,7 +956,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, double px = 1.0 / tex->get_x_size(); double py = 1.0 / tex->get_y_size(); double pz = 1.0 / tex->get_z_size(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,px,py,pz,0); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, px, py, pz, 0); return &t; } case Shader::SMO_attr_material: { @@ -966,7 +964,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, _target_rs->get_attrib_def(MaterialAttrib::get_class_slot()); // Material matrix contains AMBIENT, DIFFUSE, EMISSION, SPECULAR+SHININESS if (target_material->is_off()) { - t = LMatrix4(1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0); + t.set(1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0); return &t; } Material *m = target_material->get_material(); @@ -975,17 +973,17 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LVecBase4 const &emm = m->get_emission(); LVecBase4 spc = m->get_specular(); spc[3] = m->get_shininess(); - t = LMatrix4(amb[0],amb[1],amb[2],amb[3], - dif[0],dif[1],dif[2],dif[3], - emm[0],emm[1],emm[2],emm[3], - spc[0],spc[1],spc[2],spc[3]); + t.set(amb[0], amb[1], amb[2], amb[3], + dif[0], dif[1], dif[2], dif[3], + emm[0], emm[1], emm[2], emm[3], + spc[0], spc[1], spc[2], spc[3]); return &t; } case Shader::SMO_attr_material2: { const MaterialAttrib *target_material = (const MaterialAttrib *) _target_rs->get_attrib_def(MaterialAttrib::get_class_slot()); if (target_material->is_off()) { - t = LMatrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); return &t; } Material *m = target_material->get_material(); @@ -1000,7 +998,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, return &LMatrix4::ones_mat(); } LVecBase4 c = target_color->get_color(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,c[0],c[1],c[2],c[3]); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, c[0], c[1], c[2], c[3]); return &t; } case Shader::SMO_attr_colorscale: { @@ -1010,7 +1008,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, return &LMatrix4::ones_mat(); } LVecBase4 cs = target_color->get_scale(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,cs[0],cs[1],cs[2],cs[3]); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, cs[0], cs[1], cs[2], cs[3]); return &t; } case Shader::SMO_attr_fog: { @@ -1022,7 +1020,8 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } PN_stdfloat start, end; fog->get_linear_range(start, end); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,fog->get_exp_density(),start,end,1.0f/(end-start)); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + fog->get_exp_density(), start, end, 1.0f / (end - start)); return &t; } case Shader::SMO_attr_fogcolor: { @@ -1033,7 +1032,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, return &LMatrix4::ones_mat(); } LVecBase4 c = fog->get_color(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,c[0],c[1],c[2],c[3]); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, c[0], c[1], c[2], c[3]); return &t; } case Shader::SMO_alight_x: { @@ -1042,7 +1041,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, AmbientLight *lt; DCAST_INTO_R(lt, np.node(), &LMatrix4::zeros_mat()); LColor const &c = lt->get_color(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,c[0],c[1],c[2],c[3]); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, c[0], c[1], c[2], c[3]); return &t; } case Shader::SMO_satten_x: { @@ -1052,7 +1051,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, DCAST_INTO_R(lt, np.node(), &LMatrix4::ones_mat()); LVecBase3 const &a = lt->get_attenuation(); PN_stdfloat x = lt->get_exponent(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,a[0],a[1],a[2],x); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, a[0], a[1], a[2], x); return &t; } case Shader::SMO_dlight_x: { @@ -1069,7 +1068,10 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, d.normalize(); LVecBase3 h = d + LVecBase3(0,-1,0); h.normalize(); - t = LMatrix4(c[0],c[1],c[2],c[3],s[0],s[1],s[2],c[3],d[0],d[1],d[2],0,h[0],h[1],h[2],0); + t.set(c[0], c[1], c[2], c[3], + s[0], s[1], s[2], c[3], + d[0], d[1], d[2], 0, + h[0], h[1], h[2], 0); return &t; } case Shader::SMO_plight_x: { @@ -1087,7 +1089,10 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, Lens *lens = lt->get_lens(0); PN_stdfloat lnear = lens->get_near(); PN_stdfloat lfar = lens->get_far(); - t = LMatrix4(c[0],c[1],c[2],c[3],s[0],s[1],s[2],s[3],p[0],p[1],p[2],lnear,a[0],a[1],a[2],lfar); + t.set(c[0], c[1], c[2], c[3], + s[0], s[1], s[2], s[3], + p[0], p[1], p[2], lnear, + a[0], a[1], a[2], lfar); return &t; } case Shader::SMO_slight_x: { @@ -1105,7 +1110,10 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, _scene_setup->get_world_transform()->get_mat(); LVecBase3 p = t.xform_point(lens->get_nodal_point()); LVecBase3 d = -(t.xform_vec(lens->get_view_vector())); - t = LMatrix4(c[0],c[1],c[2],c[3],s[0],s[1],s[2],s[3],p[0],p[1],p[2],0,d[0],d[1],d[2],cutoff); + t.set(c[0], c[1], c[2], c[3], + s[0], s[1], s[2], s[3], + p[0], p[1], p[2], 0, + d[0], d[1], d[2], cutoff); return &t; } case Shader::SMO_light_ambient: { @@ -1149,7 +1157,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, if (_target_rs->get_attrib(ta) && _target_rs->get_attrib(tma) && index < ta->get_num_on_stages()) { LVecBase3 scale = tma->get_transform(ta->get_on_stage(index))->get_scale(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,scale[0],scale[1],scale[2],0); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, scale[0], scale[1], scale[2], 0); return &t; } else { return &LMatrix4::ident_mat(); @@ -1173,7 +1181,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, index < ta->get_num_on_stages()) { TextureStage *ts = ta->get_on_stage(index); PN_stdfloat v = (ta->get_on_texture(ts)->get_format() == Texture::F_alpha); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,v,v,v,0); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, v, v, v, 0); return &t; } else { return &LMatrix4::zeros_mat(); @@ -1185,7 +1193,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, const PlaneNode *plane_node; DCAST_INTO_R(plane_node, np.node(), &LMatrix4::zeros_mat()); LPlane p = plane_node->get_plane(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,p[0],p[1],p[2],p[3]); + t.set(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_clipplane_x: { @@ -1235,10 +1243,10 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, case Shader::SMO_vec_constant_x: { const LVecBase4 &input = _target_shader->get_shader_input_vector(name); const PN_stdfloat *data = input.get_data(); - t = LMatrix4(data[0],data[1],data[2],data[3], - data[0],data[1],data[2],data[3], - data[0],data[1],data[2],data[3], - data[0],data[1],data[2],data[3]); + t.set(data[0], data[1], data[2], data[3], + data[0], data[1], data[2], data[3], + data[0], data[1], data[2], data[3], + data[0], data[1], data[2], data[3]); return &t; } case Shader::SMO_world_to_view: { @@ -1394,10 +1402,10 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, // There is an input specifying precisely this whole thing, with dot and // all. Support this, even if only for backward compatibility. const LVecBase4 &data = _target_shader->get_shader_input_vector(name); - t = LMatrix4(data[0],data[1],data[2],data[3], - data[0],data[1],data[2],data[3], - data[0],data[1],data[2],data[3], - data[0],data[1],data[2],data[3]); + t.set(data[0], data[1], data[2], data[3], + data[0], data[1], data[2], data[3], + data[0], data[1], data[2], data[3], + data[0], data[1], data[2], data[3]); return &t; } @@ -1578,11 +1586,11 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } else if (attrib == IN_position) { if (np.is_empty()) { - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0); return &t; } else if (node->is_ambient_light()) { // Ambient light has no position. - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); return &t; } else if (node->is_of_type(DirectionalLight::get_class_type())) { DirectionalLight *light; @@ -1591,7 +1599,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) CPT(TransformState) transform = np.get_transform(_scene_setup->get_scene_root().get_parent()); LVector3 dir = -(light->get_direction() * transform->get_mat()); dir *= _scene_setup->get_cs_world_transform()->get_mat(); - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,dir[0],dir[1],dir[2],0); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, dir[0], dir[1], dir[2], 0); return &t; } else { LightLensNode *light; @@ -1611,11 +1619,11 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } else if (attrib == IN_halfVector) { if (np.is_empty()) { - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0); return &t; } else if (node->is_ambient_light()) { // Ambient light has no half-vector. - t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); return &t; } else if (node->is_of_type(DirectionalLight::get_class_type())) { DirectionalLight *light; @@ -1627,7 +1635,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) 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); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, dir[0], dir[1], dir[2], 1); return &t; } else { LightLensNode *light; @@ -1644,7 +1652,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) 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); + t.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, pos[0],pos[1],pos[2], 1); return &t; } From df77bacf06fa3a8e00f609621128872a3e05e1a2 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 19 Oct 2018 00:37:00 +0200 Subject: [PATCH 264/360] makepanda: compile graphicsStateGuardian.cxx separately, earlier Since this still takes a long time to build, even with the previous change, it would be better for one CPU to chew on this in the background while the rest of the build continues. --- makepanda/makepanda.py | 52 +++++++++++----------- panda/src/display/p3display_composite2.cxx | 1 - 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 540d9e86cf..caa5a164a9 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3158,10 +3158,10 @@ CopyAllHeaders('panda/src/movies') CopyAllHeaders('panda/src/pgraphnodes') CopyAllHeaders('panda/src/pgraph') CopyAllHeaders('panda/src/cull') +CopyAllHeaders('panda/src/display') CopyAllHeaders('panda/src/chan') CopyAllHeaders('panda/src/char') CopyAllHeaders('panda/src/dgraph') -CopyAllHeaders('panda/src/display') CopyAllHeaders('panda/src/device') CopyAllHeaders('panda/src/pnmtext') CopyAllHeaders('panda/src/text') @@ -3874,6 +3874,31 @@ if (not RUNTIME): TargetAdd('libp3cull.in', opts=['IMOD:panda3d.core', 'ILIB:libp3cull', 'SRCDIR:panda/src/cull']) TargetAdd('libp3cull_igate.obj', input='libp3cull.in', opts=["DEPENDENCYONLY"]) +# +# DIRECTORY: panda/src/display/ +# + +if (not RUNTIME): + OPTS=['DIR:panda/src/display', 'BUILDING:PANDA'] + TargetAdd('p3display_graphicsStateGuardian.obj', opts=OPTS, input='graphicsStateGuardian.cxx') + 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', 'PYTHON'] + IGATEFILES=GetDirectoryContents('panda/src/display', ["*.h", "*_composite*.cxx"]) + IGATEFILES.remove("renderBuffer.h") + TargetAdd('libp3display.in', opts=OPTS, input=IGATEFILES) + TargetAdd('libp3display.in', opts=['IMOD:panda3d.core', 'ILIB:libp3display', 'SRCDIR:panda/src/display']) + 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'] + TargetAdd('subprocessWindowBuffer.obj', opts=OPTS, input='subprocessWindowBuffer.cxx') + TargetAdd('libp3subprocbuffer.ilb', input='subprocessWindowBuffer.obj') + # # DIRECTORY: panda/src/chan/ # @@ -3921,30 +3946,6 @@ if (not RUNTIME): TargetAdd('libp3dgraph.in', opts=['IMOD:panda3d.core', 'ILIB:libp3dgraph', 'SRCDIR:panda/src/dgraph']) TargetAdd('libp3dgraph_igate.obj', input='libp3dgraph.in', opts=["DEPENDENCYONLY"]) -# -# DIRECTORY: panda/src/display/ -# - -if (not RUNTIME): - 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', 'PYTHON'] - IGATEFILES=GetDirectoryContents('panda/src/display', ["*.h", "*_composite*.cxx"]) - IGATEFILES.remove("renderBuffer.h") - TargetAdd('libp3display.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3display.in', opts=['IMOD:panda3d.core', 'ILIB:libp3display', 'SRCDIR:panda/src/display']) - 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'] - TargetAdd('subprocessWindowBuffer.obj', opts=OPTS, input='subprocessWindowBuffer.cxx') - TargetAdd('libp3subprocbuffer.ilb', input='subprocessWindowBuffer.obj') - # # DIRECTORY: panda/src/device/ # @@ -4166,6 +4167,7 @@ if (not RUNTIME): TargetAdd('libpanda.dll', input='p3device_composite2.obj') TargetAdd('libpanda.dll', input='p3dgraph_composite1.obj') TargetAdd('libpanda.dll', input='p3dgraph_composite2.obj') + TargetAdd('libpanda.dll', input='p3display_graphicsStateGuardian.obj') TargetAdd('libpanda.dll', input='p3display_composite1.obj') TargetAdd('libpanda.dll', input='p3display_composite2.obj') TargetAdd('libpanda.dll', input='p3pipeline_composite1.obj') diff --git a/panda/src/display/p3display_composite2.cxx b/panda/src/display/p3display_composite2.cxx index b3ba58995b..b9d33ab445 100644 --- a/panda/src/display/p3display_composite2.cxx +++ b/panda/src/display/p3display_composite2.cxx @@ -1,5 +1,4 @@ #include "graphicsPipeSelection.cxx" -#include "graphicsStateGuardian.cxx" #include "graphicsThreadingModel.cxx" #include "graphicsWindow.cxx" #include "graphicsWindowProc.cxx" From 3b7b9cd18cc3c4e7b1ba8979c525a9f25c4547ea Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 20 Oct 2018 17:54:54 -0600 Subject: [PATCH 265/360] tests: Enhance GLSL test - Don't assume GLSL 4.30 is available just because the driver supports compute shaders. Drivers before OpenGL 4.3 may still offer the extension. - Use GLSL 1.30 by default, and turn on additional features using extensions. Skip any tests requiring extensions that aren't supported by the driver. - Unsigned literal ints should have a 'u' suffix. - Clean up a few dead Python expressions --- tests/display/test_glsl_shader.py | 37 +++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/tests/display/test_glsl_shader.py b/tests/display/test_glsl_shader.py index 91816353f6..0a0a5f5737 100644 --- a/tests/display/test_glsl_shader.py +++ b/tests/display/test_glsl_shader.py @@ -10,6 +10,7 @@ from _pytest.outcomes import Failed # The reset() function serves to prevent the _triggered variable from being # optimized out in the case that the assertions are being optimized out. GLSL_COMPUTE_TEMPLATE = """#version {version} +{extensions} layout(local_size_x = 1, local_size_y = 1) in; @@ -37,7 +38,7 @@ void main() {{ """ -def run_glsl_test(gsg, body, preamble="", inputs={}, version=430): +def run_glsl_test(gsg, body, preamble="", inputs={}, version=130, exts=set()): """ Runs a GLSL test on the given GSG. The given body is executed in the main function and should call assert(). The preamble should contain all of the shader inputs. """ @@ -48,11 +49,20 @@ def run_glsl_test(gsg, body, preamble="", inputs={}, version=430): if not gsg.supports_buffer_texture: pytest.skip("buffer textures not supported") + exts = exts | {'GL_ARB_compute_shader', 'GL_ARB_shader_image_load_store'} + missing_exts = sorted(ext for ext in exts if not gsg.has_extension(ext)) + if missing_exts: + pytest.skip("missing extensions: " + ' '.join(missing_exts)) + + extensions = '' + for ext in exts: + extensions += '#extension {ext} : require\n'.format(ext=ext) + __tracebackhide__ = True preamble = preamble.strip() body = body.rstrip().lstrip('\n') - code = GLSL_COMPUTE_TEMPLATE.format(version=version, preamble=preamble, body=body) + code = GLSL_COMPUTE_TEMPLATE.format(version=version, extensions=extensions, preamble=preamble, body=body) line_offset = code[:code.find(body)].count('\n') + 1 shader = core.Shader.make_compute(core.Shader.SL_GLSL, code) assert shader, code @@ -122,7 +132,7 @@ def test_glsl_sampler(gsg): assert(texelFetch(tex1, 0, 0) == vec4(0, 2 / 255.0, 1, 1)); assert(texelFetch(tex2, ivec2(0, 0), 0) == vec4(1.0, 2.0, -3.14, 0.0)); """ - run_glsl_test(gsg, code, preamble, {'tex1': tex1, 'tex2': tex2}), code + run_glsl_test(gsg, code, preamble, {'tex1': tex1, 'tex2': tex2}) def test_glsl_image(gsg): @@ -142,7 +152,7 @@ def test_glsl_image(gsg): assert(imageLoad(tex1, 0) == vec4(0, 2 / 255.0, 1, 1)); assert(imageLoad(tex2, ivec2(0, 0)) == vec4(1.0, 2.0, -3.14, 0.0)); """ - run_glsl_test(gsg, code, preamble, {'tex1': tex1, 'tex2': tex2}), code + run_glsl_test(gsg, code, preamble, {'tex1': tex1, 'tex2': tex2}) def test_glsl_ssbo(gsg): @@ -164,7 +174,10 @@ def test_glsl_ssbo(gsg): assert(value1 == 1234567); assert(value2 == -1234567); """ - run_glsl_test(gsg, code, preamble, {'buffer1': buffer1, 'buffer2': buffer2}), code + run_glsl_test(gsg, code, preamble, {'buffer1': buffer1, 'buffer2': buffer2}, + exts={'GL_ARB_shader_storage_buffer_object', + 'GL_ARB_uniform_buffer_object', + 'GL_ARB_shading_language_420pack'}) def test_glsl_int(gsg): @@ -197,8 +210,8 @@ def test_glsl_uint(gsg): uniform uint intmax; """ code = """ - assert(zero == 0); - assert(intmax == 0x7fffffff); + assert(zero == 0u); + assert(intmax == 0x7fffffffu); """ run_glsl_test(gsg, code, preamble, inputs) @@ -243,7 +256,7 @@ def test_glsl_pta_int(gsg): assert(pta[2] == 2); assert(pta[3] == 3); """ - run_glsl_test(gsg, code, preamble, {'pta': pta}), code + run_glsl_test(gsg, code, preamble, {'pta': pta}) def test_glsl_pta_ivec4(gsg): @@ -256,7 +269,7 @@ def test_glsl_pta_ivec4(gsg): assert(pta[0] == ivec4(0, 1, 2, 3)); assert(pta[1] == ivec4(4, 5, 6, 7)); """ - run_glsl_test(gsg, code, preamble, {'pta': pta}), code + run_glsl_test(gsg, code, preamble, {'pta': pta}) def test_glsl_pta_mat4(gsg): @@ -278,7 +291,7 @@ def test_glsl_pta_mat4(gsg): assert(pta[1][2] == vec4(24, 25, 26, 27)); assert(pta[1][3] == vec4(28, 29, 30, 31)); """ - run_glsl_test(gsg, code, preamble, {'pta': pta}), code + run_glsl_test(gsg, code, preamble, {'pta': pta}) def test_glsl_write_extract_image_buffer(gsg): @@ -299,12 +312,12 @@ def test_glsl_write_extract_image_buffer(gsg): layout(r32i) uniform iimageBuffer tex2; """ code = """ - assert(imageLoad(tex1, 0).r == 0); + assert(imageLoad(tex1, 0).r == 0u); assert(imageLoad(tex2, 0).r == 0); imageStore(tex1, 0, uvec4(123)); imageStore(tex2, 0, ivec4(-456)); memoryBarrier(); - assert(imageLoad(tex1, 0).r == 123); + assert(imageLoad(tex1, 0).r == 123u); assert(imageLoad(tex2, 0).r == -456); """ From b8b86dc2f283115ae8aea90ec9c3930c0ddd9eb2 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 27 Oct 2018 19:41:51 -0600 Subject: [PATCH 266/360] glesgsg: Only use the iOS GLES framework when "BUILD_IPHONE" is defined --- panda/src/gles2gsg/gles2gsg.h | 2 +- panda/src/glesgsg/glesgsg.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/gles2gsg/gles2gsg.h b/panda/src/gles2gsg/gles2gsg.h index 8d80e690eb..363baad0ca 100644 --- a/panda/src/gles2gsg/gles2gsg.h +++ b/panda/src/gles2gsg/gles2gsg.h @@ -51,7 +51,7 @@ // OpenGL ES 2 has no fixed-function pipeline. #undef SUPPORT_FIXED_FUNCTION -#ifdef IS_OSX +#ifdef BUILD_IPHONE #include // #include #else diff --git a/panda/src/glesgsg/glesgsg.h b/panda/src/glesgsg/glesgsg.h index 64d64db216..b7c7348cb9 100644 --- a/panda/src/glesgsg/glesgsg.h +++ b/panda/src/glesgsg/glesgsg.h @@ -54,7 +54,7 @@ #define __glext_h_ #define ES1_GLEXT_H_GUARD -#ifdef IS_OSX +#ifdef BUILD_IPHONE #include // #include #else From 466a68a985c646ba8625dfdd933942d25204a3a5 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 28 Oct 2018 03:11:51 -0600 Subject: [PATCH 267/360] pandatool: Fix several missing includes --- pandatool/src/eggcharbase/eggBackPointer.cxx | 2 ++ pandatool/src/eggcharbase/eggCharacterDb.h | 1 + pandatool/src/eggcharbase/eggJointData.cxx | 2 ++ pandatool/src/eggcharbase/eggJointNodePointer.cxx | 3 ++- pandatool/src/eggcharbase/eggMatrixTablePointer.cxx | 2 ++ pandatool/src/palettizer/paletteGroup.cxx | 1 + pandatool/src/xfileegg/xFileMaterial.cxx | 1 + pandatool/src/xfileegg/xFileMesh.cxx | 2 ++ pandatool/src/xfileegg/xFileMesh.h | 2 ++ pandatool/src/xfileegg/xFileToEggConverter.cxx | 1 + 10 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pandatool/src/eggcharbase/eggBackPointer.cxx b/pandatool/src/eggcharbase/eggBackPointer.cxx index 400d9e3b2f..b1e269624a 100644 --- a/pandatool/src/eggcharbase/eggBackPointer.cxx +++ b/pandatool/src/eggcharbase/eggBackPointer.cxx @@ -13,6 +13,8 @@ #include "eggBackPointer.h" +#include "pnotify.h" + TypeHandle EggBackPointer::_type_handle; diff --git a/pandatool/src/eggcharbase/eggCharacterDb.h b/pandatool/src/eggcharbase/eggCharacterDb.h index 037367dc8b..31af55f231 100644 --- a/pandatool/src/eggcharbase/eggCharacterDb.h +++ b/pandatool/src/eggcharbase/eggCharacterDb.h @@ -29,6 +29,7 @@ */ class EggJointPointer; +class LMatrix4d; /** * This class is used during joint optimization or restructuring to store the diff --git a/pandatool/src/eggcharbase/eggJointData.cxx b/pandatool/src/eggcharbase/eggJointData.cxx index 65ed9505a5..ebf656b113 100644 --- a/pandatool/src/eggcharbase/eggJointData.cxx +++ b/pandatool/src/eggcharbase/eggJointData.cxx @@ -12,6 +12,8 @@ */ #include "eggJointData.h" + +#include "eggCharacterDb.h" #include "eggJointNodePointer.h" #include "eggMatrixTablePointer.h" #include "pvector.h" diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.cxx b/pandatool/src/eggcharbase/eggJointNodePointer.cxx index c9c891606b..23bf7ea480 100644 --- a/pandatool/src/eggcharbase/eggJointNodePointer.cxx +++ b/pandatool/src/eggcharbase/eggJointNodePointer.cxx @@ -14,8 +14,9 @@ #include "eggJointNodePointer.h" #include "dcast.h" -#include "eggObject.h" +#include "eggCharacterDb.h" #include "eggGroup.h" +#include "eggObject.h" #include "pointerTo.h" diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx index 21c9c63516..267296483f 100644 --- a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx @@ -12,7 +12,9 @@ */ #include "eggMatrixTablePointer.h" + #include "dcast.h" +#include "eggCharacterDb.h" #include "eggSAnimData.h" #include "eggXfmAnimData.h" #include "eggXfmSAnim.h" diff --git a/pandatool/src/palettizer/paletteGroup.cxx b/pandatool/src/palettizer/paletteGroup.cxx index 182479216f..5f231b2e14 100644 --- a/pandatool/src/palettizer/paletteGroup.cxx +++ b/pandatool/src/palettizer/paletteGroup.cxx @@ -17,6 +17,7 @@ #include "textureImage.h" #include "palettizer.h" #include "paletteImage.h" +#include "sourceTextureImage.h" #include "indent.h" #include "datagram.h" diff --git a/pandatool/src/xfileegg/xFileMaterial.cxx b/pandatool/src/xfileegg/xFileMaterial.cxx index 11457ebcd5..9eaac25fbd 100644 --- a/pandatool/src/xfileegg/xFileMaterial.cxx +++ b/pandatool/src/xfileegg/xFileMaterial.cxx @@ -18,6 +18,7 @@ #include "eggTexture.h" #include "eggPrimitive.h" #include "datagram.h" +#include "config_xfile.h" #include // for strcmp, strdup diff --git a/pandatool/src/xfileegg/xFileMesh.cxx b/pandatool/src/xfileegg/xFileMesh.cxx index 4fad113ed4..e253ee385d 100644 --- a/pandatool/src/xfileegg/xFileMesh.cxx +++ b/pandatool/src/xfileegg/xFileMesh.cxx @@ -12,6 +12,7 @@ */ #include "xFileMesh.h" +#include "xFileToEggConverter.h" #include "xFileFace.h" #include "xFileVertex.h" #include "xFileNormal.h" @@ -22,6 +23,7 @@ #include "eggVertexPool.h" #include "eggVertex.h" #include "eggPolygon.h" +#include "eggGroup.h" #include "eggGroupNode.h" using std::min; diff --git a/pandatool/src/xfileegg/xFileMesh.h b/pandatool/src/xfileegg/xFileMesh.h index 417d7c4253..339ba2038f 100644 --- a/pandatool/src/xfileegg/xFileMesh.h +++ b/pandatool/src/xfileegg/xFileMesh.h @@ -22,6 +22,8 @@ #include "namable.h" #include "coordinateSystem.h" +#include "luse.h" + class XFileNode; class XFileDataNode; class XFileMesh; diff --git a/pandatool/src/xfileegg/xFileToEggConverter.cxx b/pandatool/src/xfileegg/xFileToEggConverter.cxx index 130c42546e..91ba21ba97 100644 --- a/pandatool/src/xfileegg/xFileToEggConverter.cxx +++ b/pandatool/src/xfileegg/xFileToEggConverter.cxx @@ -19,6 +19,7 @@ #include "eggData.h" #include "eggGroup.h" +#include "eggTable.h" #include "eggXfmSAnim.h" #include "eggGroupUniquifier.h" #include "datagram.h" From 43142e4e80ea6d9ba1adab6e53fcce144de16e10 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 28 Oct 2018 04:08:15 -0600 Subject: [PATCH 268/360] pandatool: Delete softegg/softprogs These depend on "SAA" - a Softimage library so long gone I can't even find references to it on Google. --- pandatool/src/softegg/config_softegg.cxx | 55 - pandatool/src/softegg/config_softegg.h | 28 - pandatool/src/softegg/soft2Egg.c | 4751 ----------------- pandatool/src/softegg/softEggGroupUserData.I | 44 - .../src/softegg/softEggGroupUserData.cxx | 16 - pandatool/src/softegg/softEggGroupUserData.h | 53 - pandatool/src/softegg/softNodeDesc.cxx | 1310 ----- pandatool/src/softegg/softNodeDesc.h | 159 - pandatool/src/softegg/softNodeTree.cxx | 561 -- pandatool/src/softegg/softNodeTree.h | 78 - pandatool/src/softegg/softToEggConverter.cxx | 2122 -------- pandatool/src/softegg/softToEggConverter.h | 179 - pandatool/src/softprogs/softCVS.cxx | 588 -- pandatool/src/softprogs/softCVS.h | 70 - pandatool/src/softprogs/softFilename.cxx | 291 - pandatool/src/softprogs/softFilename.h | 73 - 16 files changed, 10378 deletions(-) delete mode 100644 pandatool/src/softegg/config_softegg.cxx delete mode 100644 pandatool/src/softegg/config_softegg.h delete mode 100644 pandatool/src/softegg/soft2Egg.c delete mode 100644 pandatool/src/softegg/softEggGroupUserData.I delete mode 100644 pandatool/src/softegg/softEggGroupUserData.cxx delete mode 100644 pandatool/src/softegg/softEggGroupUserData.h delete mode 100644 pandatool/src/softegg/softNodeDesc.cxx delete mode 100644 pandatool/src/softegg/softNodeDesc.h delete mode 100644 pandatool/src/softegg/softNodeTree.cxx delete mode 100644 pandatool/src/softegg/softNodeTree.h delete mode 100644 pandatool/src/softegg/softToEggConverter.cxx delete mode 100644 pandatool/src/softegg/softToEggConverter.h delete mode 100644 pandatool/src/softprogs/softCVS.cxx delete mode 100644 pandatool/src/softprogs/softCVS.h delete mode 100644 pandatool/src/softprogs/softFilename.cxx delete mode 100644 pandatool/src/softprogs/softFilename.h diff --git a/pandatool/src/softegg/config_softegg.cxx b/pandatool/src/softegg/config_softegg.cxx deleted file mode 100644 index 89ad412508..0000000000 --- a/pandatool/src/softegg/config_softegg.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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." - * - * @file config_softegg.cxx - * @author masad - * @date 2003-09-25 - */ - -#include "config_softegg.h" -#include "softEggGroupUserData.h" -#include "softNodeDesc.h" - -#include "dconfig.h" - -Configure(config_softegg); -NotifyCategoryDef(softegg, ":soft"); - -ConfigureFn(config_softegg) { - init_libsoftegg(); -} - -// These control the default behavior of the softegg converter, but not -// necessarily the default behavior of the soft2egg command-line tool (which -// has its own defaults). - -// Should we respect the Soft? double-sided flag (true) or ignore it and -// assume everything is single-sided (false)? -ConfigVariableBool soft_default_double_sided("soft-default-double-sided", false); - -// Should we apply vertex color even when a texture is applied (true) or only -// when no texture is applied or the vertex-color egg flag is set (false)? -ConfigVariableBool soft_default_vertex_color("soft-default-vertex-color", true); - -/** - * Initializes the library. This must be called at least once before any of - * the functions or classes in this library can be used. Normally it will be - * called by the static initializers and need not be called explicitly, but - * special cases exist. - */ -void -init_libsoftegg() { - static bool initialized = false; - if (initialized) { - return; - } - initialized = true; - - SoftEggGroupUserData::init_type(); - SoftNodeDesc::init_type(); -} diff --git a/pandatool/src/softegg/config_softegg.h b/pandatool/src/softegg/config_softegg.h deleted file mode 100644 index 8deb0cb7aa..0000000000 --- a/pandatool/src/softegg/config_softegg.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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." - * - * @file config_softegg.h - * @author masad - * @date 2003-09-25 - */ - -#ifndef CONFIG_SOFTEGG_H -#define CONFIG_SOFTEGG_H - -#include "pandatoolbase.h" -#include "notifyCategoryProxy.h" -#include "configVariableBool.h" - -NotifyCategoryDeclNoExport(softegg); - -extern ConfigVariableBool soft_default_double_sided; -extern ConfigVariableBool soft_default_vertex_color; - -extern void init_libsoftegg(); - -#endif diff --git a/pandatool/src/softegg/soft2Egg.c b/pandatool/src/softegg/soft2Egg.c deleted file mode 100644 index 9e744b8655..0000000000 --- a/pandatool/src/softegg/soft2Egg.c +++ /dev/null @@ -1,4751 +0,0 @@ -/** - * 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." - * - * @file soft2Egg.c - * @author masad - * @date 2003-09-26 - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include "pandatoolbase.h" - -int init_soft2egg(int, char **); - -#if 0 -// DWD includes -#include "eggBase.h" -#include -#include -#include - -// system includes -#include -#include -#include -#include -#include -#include - -// Performer includes -#include - -// SoftImage includes -#include -#include - -static const int TEX_PER_MAT = 1; -static FILE *outStream = stdout; -// static FILE *outStream = stderr; - -class soft2egg : public EggBase -{ - public: - - soft2egg() : EggBase("r:d:s:m:t:P:b:e:f:T:S:M:A:N:v:o:FhknpaxiucCD") - { - rsrc_path = "/ful/ufs/soft371_mips2/3D/rsrc"; - database_name = NULL; - scene_name = NULL; - model_name = NULL; - animFileName = NULL; - eggFileName = NULL; - tex_path = NULL; - eggGroupName = NULL; - tex_filename = NULL; - search_prefix = NULL; - result = SI_SUCCESS; - - skeleton = new EggGroup(); - foundRoot = FALSE; - animRoot = NULL; - morphRoot = NULL; - geom_as_joint = 0; - make_anim = 0; - make_nurbs = 0; - make_poly = 0; - make_soft = 0; - make_morph = 1; - make_duv = 1; - make_dart = TRUE; - has_morph = 0; - make_pose = 0; - animData.is_z_up = FALSE; - nurbs_step = 1; - anim_start = -1000; - anim_end = -1000; - anim_rate = 24; - pose_frame = -1; - verbose = 0; - flatten = 0; - shift_textures = 0; - ignore_tex_offsets = 0; - use_prefix = 0; - } - - virtual void Help(); - virtual void Usage(); - virtual void ShowOpts(); - - virtual boolean UseOutputSwitch() const { - return false; - } - - virtual boolean - HandleGetopts(char flag, char *optarg, int &optind, int argc, char **argv); - - int isNum( float ); - char *GetRootName( const char * ); - char *RemovePathName( const char * ); - char *GetSliderName( const char * ); - char *GetFullName( SAA_Scene *, SAA_Elem * ); - char *GetName( SAA_Scene *, SAA_Elem * ); - char *GetModelNoteInfo( SAA_Scene *, SAA_Elem * ); - char *MakeTableName( const char *, int ); - char *DepointellizeName( char * ); - SAA_Elem *FindModelByName( char *, SAA_Scene *, SAA_Elem *, int ); - char *ConvertTexture( SAA_Scene *, SAA_Elem * ); - int *FindClosestTriVert( EggVertexPool *, SAA_DVector *, int ); - int *MakeIndexMap( int *, int, int ); - int findShapeVert( SAA_DVector, SAA_DVector *, int ); - void LoadSoft(); - void MakeEgg( EggGroup *, EggJoint *, AnimGroup *, SAA_Scene *, SAA_Elem * ); - void MakeSurfaceCurve( SAA_Scene *, SAA_Elem *, EggGroup *, - EggNurbsSurface *&, int , SAA_SubElem *, bool ); - - EggNurbsCurve *MakeUVNurbsCurve( int, long *, double *, double *, - EggGroup *, char * ); - - EggNurbsCurve *MakeNurbsCurve( SAA_Scene *, SAA_Elem *, EggGroup *, - float [4][4], char * ); - - void AddKnots( perf_vector &, double *, int, SAA_Boolean, int ); - void MakeJoint( SAA_Scene *, EggJoint *&, AnimGroup *&, SAA_Elem *, char * ); - void MakeSoftSkin( SAA_Scene *, SAA_Elem *, SAA_Elem *, int, char * ); - void CleanUpSoftSkin( SAA_Scene *, SAA_Elem *, char * ); - void MakeAnimTable( SAA_Scene *, SAA_Elem *, char * ); - void MakeVertexOffsets( SAA_Scene *, SAA_Elem *, SAA_ModelType type, - int, int, SAA_DVector *, float (*)[4], char * ); - void MakeMorphTable( SAA_Scene *, SAA_Elem *, SAA_Elem *, int, char *, - float ); - void MakeLinearMorphTable( SAA_Scene *, SAA_Elem *, int, char *, float ); - void MakeWeightedMorphTable( SAA_Scene *, SAA_Elem *, SAA_Elem *, int, - int, char *, float ); - void MakeExpressionMorphTable( SAA_Scene *, SAA_Elem *, SAA_Elem *, int, - int, char *, float ); - void MakeTexAnim( SAA_Scene *, SAA_Elem *, char * ); - - private: - - char *rsrc_path; - char *database_name; - char *scene_name; - char *model_name; - char *eggFileName; - char *animFileName; - char *eggGroupName; - char *tex_path; - char *tex_filename; - char *search_prefix; - - SI_Error result; - SAA_Scene scene; - SAA_Elem model; - SAA_Database database; - EggGroup *dart; - EggGroup *skeleton; - AnimGroup *rootAnim; - EggJoint *rootJnt; - AnimGroup *animRoot; - AnimGroup *morphRoot; - EggData animData; - - int nurbs_step; - int anim_start; - int anim_end; - int anim_rate; - int pose_frame; - int verbose; - int flatten; - int shift_textures; - int ignore_tex_offsets; - int use_prefix; - - bool foundRoot; - bool geom_as_joint; - bool make_anim; - bool make_nurbs; - bool make_poly; - bool make_soft; - bool make_morph; - bool make_duv; - bool make_dart; - bool has_morph; - bool make_pose; - - std::ofstream eggFile; - std::ofstream animFile; - std::ofstream texFile; -}; - - -/** - * Displays the "what is this program" message, along with the usage message. - * Should be overridden in base classes to describe the current program. - */ -void soft2egg:: -Help() -{ - cerr << - "soft2egg takes a SoftImage scene or model\n" - "and outputs its contents as an egg file\n"; - - Usage(); -} - -/** - * Displays the usage message. - */ -void soft2egg:: -Usage() { - cerr << "\nUsage:\n" - << _commandName << " [opts] (must specify -m or -s)\n\n" - << "Options:\n"; - - ShowOpts(); - cerr << "\n"; -} - - - -/** - * Displays the valid options. Should be extended in base classes to show - * additional options relevant to the current program. - */ -void soft2egg:: -ShowOpts() -{ - cerr << - " -r - Used to provide soft with the resource\n" - " Defaults to 'c:/Softimage/SOFT_3.9.2/3D/test'.\n" - // " Defaults to 'fulufssoft371_mips23Drsrc'.\n" - " -d - Database path.\n" - " -s - Indicates that a scene will be converted.\n" - " -m - Indicates that a model will be converted.\n" - " -t - Specify path to place converted textures.\n" - " -T - Specify filename for texture map listing.\n" - " -S - Specify step for nurbs surface triangulation.\n" - " -M - Specify model output filename. Defaults to scene name.\n" - " -A - Specify anim output filename. Defaults to scene name.\n" - " -N - Specify egg group name.\n" - " -k - Enable soft assignment for geometry.\n" - " -n - Specify egg NURBS representation instead of poly's.\n" - " -p - Specify egg polygon output for geometry.\n" - " -P - Specify frame number for static pose.\n" - " -b - Specify starting frame for animation (default = first).\n" - " -e - Specify ending frame for animation (default = last).\n" - " -f - Specify frame rate for animation playback.\n" - " -a - Compile animation tables if animation present.\n" - " -F - Ignore hierarchy and build a completely flat skeleton.\n" - " -v - Set debug level.\n" - " -x - Shift NURBS parameters to preserve Alias textures.\n" - " -i - Ignore Soft texture uv offsets.\n" - " -u - Use Soft prefix in model names.\n" - " -c - Cancel morph conversion.\n" - " -C - Cancel duv conversion.\n" - " -D - Don't make the output model a character.\n" - " -o - Convert only models with given prefix.\n"; - - EggBase::ShowOpts(); -} - - -/** - * - */ -boolean soft2egg:: -HandleGetopts(char flag, char *optarg, int &optind, int argc, char **argv) -{ - boolean okflag = true; - - switch (flag) - { - case 'r': // Set the resource path for soft. - if ( strcmp( optarg, "" ) ) - { - // Get the path. - rsrc_path = optarg; - fprintf( outStream, "using rsrc path %s\n", rsrc_path ); - } - break; - - case 'd': // Set the database path. - if ( strcmp( optarg, "" ) ) - { - // Get the path. - database_name = optarg; - fprintf( outStream, "using database %s\n", database_name ); - } - break; - - case 's': // Check if its a scene. - if ( strcmp( optarg, "" ) ) - { - // Get scene name. - scene_name = optarg; - fprintf( outStream, "loading scene %s\n", scene_name ); - } - break; - - case 'm': // Check if its a model. - if ( strcmp( optarg, "" ) ) - { - // Get model name. - model_name = optarg; - fprintf( outStream, "loading model %s\n", model_name ); - } - break; - - case 't': // Get converted texture path. - if ( strcmp( optarg, "" ) ) - { - // Get tex path name. - tex_path = optarg; - fprintf( outStream, "texture path: %s\n", tex_path ); - } - break; - - case 'T': // Specify texture list filename. - if ( strcmp( optarg, "") ) - { - // Get the name. - tex_filename = optarg; - fprintf( outStream, "creating texture list file: %s\n", - tex_filename ); - } - break; - case 'S': // Set NURBS step. - if ( strcmp( optarg, "" ) ) - { - nurbs_step = atoi(optarg); - fprintf( outStream, "NURBS step: %d\n", nurbs_step ); - } - break; - - case 'M': // Set model output file name. - if ( strcmp( optarg, "" ) ) - { - eggFileName = optarg; - fprintf( outStream, "Model output filename: %s\n", eggFileName ); - } - break; - - case 'A': // Set anim output file name. - if ( strcmp( optarg, "" ) ) - { - animFileName = optarg; - fprintf( outStream, "Anim output filename: %s\n", animFileName ); - } - break; - - case 'N': // Set egg model name. - if ( strcmp( optarg, "" ) ) - { - eggGroupName = optarg; - fprintf( outStream, "Egg group name: %s\n", eggGroupName ); - } - break; - - case 'o': // Set search_prefix. - if ( strcmp( optarg, "" ) ) - { - search_prefix = optarg; - fprintf( outStream, "Only converting models with prefix: %s\n", - search_prefix ); - } - break; - - case 'h': // print help message - Help(); - exit(1); - break; - - case 'c': // Cancel morph animation conversion - make_morph = FALSE; - fprintf( outStream, "canceling morph conversion\n" ); - break; - - case 'C': // Cancel uv animation conversion - make_duv = FALSE; - fprintf( outStream, "canceling uv animation conversion\n" ); - break; - - case 'D': // Omit the Dart flag - make_dart = FALSE; - fprintf( outStream, "making a non-character model\n" ); - break; - - case 'k': // Enable soft skinning - // make_soft = TRUE; fprintf( outStream, "enabling soft skinning\n" ); - fprintf( outStream, "-k flag no longer necessary\n" ); - break; - - case 'n': // Generate egg NURBS output - make_nurbs = TRUE; - fprintf( outStream, "outputting egg NURBS info\n" ); - break; - - case 'p': // Generate egg polygon output - make_poly = TRUE; - fprintf( outStream, "outputting egg polygon info\n" ); - break; - - case 'P': // Generate static pose from given frame - if ( strcmp( optarg, "" ) ) - { - make_pose = TRUE; - pose_frame = atoi(optarg); - fprintf( outStream, "generating static pose from frame %d\n", - pose_frame ); - } - break; - - case 'a': // Compile animation tables. - make_anim = TRUE; - fprintf( outStream, "attempting to compile anim tables\n" ); - break; - - case 'F': // Build a flat skeleton. - flatten = TRUE; - fprintf( outStream, "building a flat skeleton!!!\n" ); - break; - - case 'x': // Shift NURBS parameters to preserve Alias textures. - shift_textures = TRUE; - fprintf( outStream, "shifting NURBS parameters...\n" ); - break; - - case 'i': // Ignore Soft uv texture offsets - ignore_tex_offsets = TRUE; - fprintf( outStream, "ignoring texture offsets...\n" ); - break; - - case 'u': // Use Soft prefix in model names - use_prefix = TRUE; - fprintf( outStream, "using prefix in model names...\n" ); - break; - - - case 'v': // print debug messages. - if ( strcmp( optarg, "" ) ) - { - verbose = atoi(optarg); - fprintf( outStream, "using debug level %d\n", verbose ); - } - break; - - case 'b': // Set animation start frame. - if ( strcmp( optarg, "" ) ) - { - anim_start = atoi(optarg); - fprintf( outStream, "animation starting at frame: %d\n", - anim_start ); - } - break; - - case 'e': /// Set animation end frame. - if ( strcmp( optarg, "" ) ) - { - anim_end = atoi(optarg); - fprintf( outStream, "animation ending at frame: %d\n", anim_end ); - } - break; - - case 'f': /// Set animation frame rate. - if ( strcmp( optarg, "" ) ) - { - anim_rate = atoi(optarg); - fprintf( outStream, "animation frame rate: %d\n", anim_rate ); - } - break; - - default: - okflag = EggBase::HandleGetopts(flag, optarg, optind, argc, argv); - } - - return (okflag); -} - - - -/** - * Take a float and make sure it is of the body. - */ -int soft2egg:: -isNum( float num ) -{ - return( ( num < HUGE_VAL ) && finite( num ) ); -} - - -/** - * Given a string, return a copy of the string up to the first occurrence of - * '-'. - */ -char *soft2egg:: -GetRootName( const char *name ) -{ - char *hyphen; - char *root; - int len; - - hyphen = strchr( name, '-' ); - len = hyphen-name; - - if ( (hyphen != NULL) && len ) - { - root = (char *)malloc(sizeof(char)*(len+1)); - strncpy( root, name, len ); - root[sizeof(char)*(len)] = '\0'; - } - else - { - root = (char *)malloc( sizeof(char)*(strlen(name)+1)); - strcpy( root, name ); - } - - return( root ); -} - - -/** - * Given a string, return a copy of the string after the last occurence of ' - */ -char *soft2egg:: -RemovePathName( const char *name ) -{ - char *slash; - char *root; - - if ( *name != NULL ) - { - slash = strrchr( name, '/' ); - - root = (char *)malloc( sizeof(char)*(strlen(name)+1)); - - if ( slash != NULL ) - strcpy( root, ++slash ); - else - strcpy( root, name ); - - return( root ); - } - - fprintf( stderr, "Error: RemovePathName received NULL string!\n" ); - return ( (char *)name ); -} - -/** - * Given a string, return that part of the string after the first occurence of - * '-' and before the last occurance of '.' - */ -char *soft2egg:: -GetSliderName( const char *name ) -{ - if ( name != NULL ) - { - strstream newStr; - char *hyphen; - char *end; - - hyphen = strchr( name, '-' ); - - // pull off stuff before first hyphen - if (hyphen != NULL) - { - newStr << ++hyphen; - end = newStr.str(); - } - - char *lastPeriod; - - lastPeriod = strrchr( end, '.' ); - - // ignore stuff after last period - if ( lastPeriod != NULL ) - { - *lastPeriod = '\0'; - } - - if ( verbose >= 1 ) - fprintf( stdout, "slider name: '%s'\n", end ); - - return( end ); - } - - return( (char *)name ); -} - -/** - * Given an element, return a copy of the element's name WITHOUT prefix. - */ -char *soft2egg:: -GetName( SAA_Scene *scene, SAA_Elem *element ) -{ - int nameLen; - char *name; - - // get the name - SAA_elementGetNameLength( scene, element, &nameLen ); - name = (char *)malloc(sizeof(char)*++nameLen); - SAA_elementGetName( scene, element, nameLen, name ); - - return name; -} - -/** - * Given an element, return a copy of the element's name complete with prefix. - */ -char *soft2egg:: -GetFullName( SAA_Scene *scene, SAA_Elem *element ) -{ - int nameLen; - char *name; - - // get the name - SAA_elementGetNameLength( scene, element, &nameLen ); - name = (char *)malloc(sizeof(char)*++nameLen); - SAA_elementGetName( scene, element, nameLen, name ); - - int prefixLen; - char *prefix; - - // get the prefix - SAA_elementGetPrefixLength( scene, element, &prefixLen ); - prefix = (char *)malloc(sizeof(char)*++prefixLen); - SAA_elementGetPrefix( scene, element, prefixLen, prefix ); - - strstream fullNameStrm; - - // add 'em together - fullNameStrm << prefix << "-" << name << ends; - - // free( name ); free( prefix ); - - return fullNameStrm.str(); -} - -/** - * Given an element, return a string containing the contents of its MODEL NOTE - * entry - */ -char *soft2egg:: -GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) -{ - - int size; - char *modelNote = NULL; - SAA_Boolean bigEndian; - - - SAA_elementGetUserDataSize( scene, model, "MNOT", &size ); - - if ( size != 0 ) - { - // allocate modelNote string - modelNote = (char *)malloc(sizeof(char)*(size + 1)); - - // get ModelNote data from this model - SAA_elementGetUserData( scene, model, "MNOT", size, - &bigEndian, (void *)modelNote ); - - // strip off newline, if present - char *eol = strchr( modelNote, '\n' ); - if ( eol != NULL) - *eol = '\0'; - else - modelNote[size] = '\0'; - - if ( verbose >= 1 ) - fprintf( outStream, "\nmodelNote = %s\n", - modelNote ); - } - - return modelNote; -} - - -/** - * Given a string, and a number, return a new string consisting of - * "string.number". - */ -char *soft2egg:: -MakeTableName( const char *name, int number ) -{ - strstream namestrm; - - namestrm << name << "." << number << ends; - return namestrm.str(); -} - -/** - * Given a string, find the model in the scene whose name corresponds to the - * given string. - */ -SAA_Elem *soft2egg:: -FindModelByName( char *name, SAA_Scene *scene, SAA_Elem *models, - int numModels ) -{ - char *foundName; - SAA_Elem *foundModel = NULL; - - for ( int model = 0; model < numModels; model++ ) - { - foundName = GetName( scene, &models[model] ); - - if ( !strcmp( name, foundName ) ) - { - if ( verbose >= 1 ) - fprintf( outStream, "foundModel: '%s' = '%s'\n", - name, foundName ); - - foundModel = &models[model]; - return( foundModel ); - } - } - - fprintf( outStream, "findModelByName: failed to find model named: '%s'\n", - name ); - - return ( foundModel ); -} - - -/** - * Given a string, return the string up to the first period. - */ -char *soft2egg:: -DepointellizeName( char *name ) -{ - char *endPtr; - char *newName; - - newName = (char *)malloc(sizeof(char)*(strlen(name)+1)); - sprintf( newName, "%s", name ); - - endPtr = strchr( newName, '.' ); - if ( endPtr != NULL ) - *endPtr = '\0'; - - return ( newName ); -} - - -/** - * Given a string, return a copy of the string without the leading file path, - * and make an rgb file of the same name in the tex_path directory. - */ -char *soft2egg:: -ConvertTexture( SAA_Scene *scene, SAA_Elem *texture ) -{ - char *fileName = NULL; - int fileNameLen = 0; - - // get the texture's name - SAA_texture2DGetPicNameLength( scene, texture, &fileNameLen); - - if ( fileNameLen ) - { - fileName = (char *)malloc(sizeof(char)*++fileNameLen); - SAA_texture2DGetPicName( scene, texture, fileNameLen, fileName ); - } - - // make sure we are not being passed a NULL image, an empty image string or - // the default image created by egg2soft - if ( (fileName != NULL) && strlen( fileName ) && strcmp( fileName, - "/fat/people/gregw/new_test/PICTURES/default") && - ( strstr( fileName, "noIcon" ) == NULL) ) - { - char *texName = NULL; - char *texNamePath = NULL; - char *tmpName = NULL; - char *fileNameExt = NULL; - - // strip off path and add .rgb - tmpName = strrchr( fileName, '/' ); - - if ( tmpName == NULL ) - tmpName = fileName; - else - tmpName++; - - float transp; - - // check for alpha - SAA_texture2DGetTransparency( scene, texture, &transp ); - - if ( transp != 0.0f ) { - texName = (char *)malloc(sizeof(char)*(strlen(tmpName)+6)); - sprintf( texName, "%s.rgba", tmpName ); - } else { - texName = (char *)malloc(sizeof(char)*(strlen(tmpName)+5)); - sprintf( texName, "%s.rgb", tmpName ); - } - - fileNameExt = (char *)malloc(sizeof(char)*(strlen(fileName)+5)); - sprintf( fileNameExt, "%s.pic", fileName ); - - if ( verbose >= 1 ) - fprintf( outStream, "Looking for texture file: '%s'\n", fileNameExt ); - - // try to make conversion of file - int found_file = ( access( fileNameExt, F_OK ) == 0); - - if ( found_file ) - { - if ( tex_path ) - { - texNamePath = (char *)malloc(sizeof(char)*(strlen(tex_path) + - strlen(texName) + 2)); - - sprintf( texNamePath, "%s/%s", tex_path, texName ); - - if ( texFile ) - texFile << texNamePath << ": " << fileNameExt << "\n"; - - // make sure conversion doesn't already exist - if ( (access( texNamePath, F_OK ) != 0) && !texFile ) - { - char *command = (char *)malloc(sizeof(char)* - (strlen(fileNameExt) + strlen(texNamePath) + 20)); - - sprintf( command, "image-resize -1 %s %s", - fileNameExt, texNamePath ); - - if ( verbose >=1 ) - fprintf( outStream, "executing %s\n", command ); - - system( command ); - - // free( command ); - } - else - if ( verbose >=1 ) - fprintf( outStream, "%s already exists!\n", texNamePath ); - } - else - { - if ( verbose >= 1 ) - { - fprintf( outStream, "Warning: No texture path defined" ); - fprintf( outStream, " - No automatic conversion performed\n" ); - } - } - } - else - { - fprintf( outStream, "Warning: Couldn't find texture file: %s\n", - fileNameExt ); - } - - // free( fileNameExt ); - - if (tex_path) - return( texNamePath ); - else - return( texName ); - } - else - { - fprintf( outStream, "Warning: ConvertTexture received NULL fileName\n" ); - return( NULL ); - } -} - -/** - * Given an egg vertex pool, map each vertex therein to a vertex within an - * array of SAA model vertices of size numVert. Mapping is done by closest - * proximity. - */ -int *soft2egg:: -FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) -{ - int *vertMap = NULL; - int vpoolSize = vpool->NumVertices(); - int i,j; - float thisDist; - float closestDist; - int closest; - - - vertMap = (int *)malloc(sizeof(int)*vpoolSize); - - // for each vertex in vpool - for ( i = 0; i < vpoolSize; i++ ) - { - // find closest model vertex - for ( j = 0; j < numVert-1; j++ ) - { - // calculate distance - thisDist = sqrtf( - powf( vpool->Vertex(i)->position[0] - vertices[j].x , 2 ) + - powf( vpool->Vertex(i)->position[1] - vertices[j].y , 2 ) + - powf( vpool->Vertex(i)->position[2] - vertices[j].z , 2 ) ); - - // remember this if its the closest so far - if ( !j || ( thisDist < closestDist ) ) - { - closest = j; - closestDist = thisDist; - } - } - vertMap[i] = closest; - - if ( verbose >= 2 ) - { - fprintf( outStream, "mapping v %d of %d:( %f, %f, %f )\n", i, - vpoolSize, vpool->Vertex(i)->position[0], - vpool->Vertex(i)->position[1], - vpool->Vertex(i)->position[2] ); - fprintf( outStream, "to cv %d of %d:( %f, %f, %f )\tdelta = %f\n", - closest, numVert-1, vertices[closest].x, vertices[closest].y, - vertices[closest].z, closestDist ); - } - } - - return( vertMap ); -} - - -/** - * Given an array of indices that is a map from one set of vertices to - * another, return an array that performs the reverse mapping of the indices - * array - */ -int *soft2egg:: -MakeIndexMap( int *indices, int numIndices, int mapSize ) -{ - int i, j; - - // allocate map array - int *map = (int *)malloc(sizeof(int)*mapSize); - - if ( map != NULL ) - { - for ( i = 0; i < mapSize; i++ ) - { - j = 0; - int found = 0; - while( j < numIndices ) - { - if ( indices[j] == i ) - { - map[i] = j; - if ( verbose >= 2 ) - fprintf( outStream, "map[%d] = %d\n", i, map[i] ); - found = 1; - break; - } - j++; - } - if ( !found) - { - if ( verbose >= 2 ) - fprintf( outStream, "Warning: orphan vertex (%d)\n", i ); - // default to -1 for now - map[i] = -1; - } - } - } - else - fprintf( outStream, "Not enough Memory for index Map...\n"); - - return( map ); -} - -/** - * given a vertex, find its corresponding shape vertex and return its index. - */ -int soft2egg:: -findShapeVert( SAA_DVector vertex, SAA_DVector *vertices, int numVert ) -{ - int i; - int found = 0; - - for ( i = 0; i < numVert && !found ; i++ ) - { - if ( ( vertex.x == vertices[i].x ) && - ( vertex.y == vertices[i].y ) && - ( vertex.z == vertices[i].z ) ) - { - found = 1; - - if ( verbose >= 2) - fprintf( outStream, "found shape vert at index %d\n", i ); - } - } - - if (!found ) - i = -1; - else - i--; - - return( i ); -} - - -/** - * Open the SI database and grab the scene & model info - */ -void soft2egg:: -LoadSoft() -{ - int i; - - if ( (scene_name == NULL && model_name == NULL) || database_name == NULL ) - { - Usage(); - exit( 1 ); - } - - if ((result = SAA_Init(rsrc_path, FALSE)) != SI_SUCCESS) - { - fprintf( outStream, "Error: Couldn't get resource path!\n"); - exit( 1 ); - } - - if ((result = SAA_databaseLoad(database_name, &database)) != SI_SUCCESS) - { - fprintf( outStream, "Error: Couldn't load database!\n"); - exit( 1 ); - } - - if ((result = SAA_sceneGetCurrent(&scene)) == SI_SUCCESS) - { - // load scene if present - if ( scene_name != NULL ) - { - SAA_sceneLoad( &database, scene_name, &scene ); - - // if no egg filename specified, make up a name - if ( eggFileName == NULL ) - { - eggFileName = (char *)malloc(sizeof(char)* - (strlen( scene_name ) + 14 )); - sprintf( eggFileName, "%s", DepointellizeName(scene_name) ); - if ( make_nurbs ) - strcat( eggFileName, "-nurb" ); - strcat( eggFileName, "-mod.egg" ); - } - - // open an output file for the geometry if necessary - if ( make_poly || make_nurbs ) - { - unlink( eggFileName ); - eggFile.open( eggFileName, ios::out, 0666 ); - - if ( !eggFile ) - { - fprintf( outStream, "Couldn't open output file: %s\n", - eggFileName ); - exit( 1 ); - } - } - - // open an output file for texture list if specified - if ( tex_filename != NULL ) - { - unlink( tex_filename ); - texFile.open( tex_filename, ios::out, 0666 ); - - if ( !texFile ) - { - fprintf( outStream, "Couldn't open output file: %s\n", - tex_filename ); - exit( 1 ); - } - } - - if ( SAA_updatelistGet( &scene ) == SI_SUCCESS ) - { - float time; - - fprintf( outStream, "setting Scene to frame %d...\n", pose_frame ); - // SAA_sceneSetPlayCtrlCurrentFrame( &scene, pose_frame ); - SAA_frame2Seconds( &scene, pose_frame, &time ); - SAA_updatelistEvalScene( &scene, time ); - sginap( 100 ); - SAA_updatelistEvalScene( &scene, time ); - if ( make_pose ) - SAA_sceneFreeze( &scene ); - } - - int numModels; - SAA_Elem *models; - - SAA_sceneGetNbModels( &scene, &numModels ); - fprintf( outStream, "Scene has %d model(s)...\n", numModels ); - - if ( numModels ) - { - // allocate array of models - models = (SAA_Elem *)malloc(sizeof(SAA_Elem)*numModels); - - if ( models != NULL ) - { - char *rootName = GetRootName( eggFileName ); - - if ( eggGroupName == NULL ) - dart = _data.CreateGroup( NULL, rootName ); - else - dart = _data.CreateGroup( NULL, eggGroupName ); - - if (make_dart) - dart->flags |= EF_DART; - - AnimGroup *rootTable; - - rootTable = animData.CreateTable( NULL, eggFileName ); - - if ( eggGroupName == NULL ) - animRoot = animData.CreateBundle( rootTable, rootName ); - else - animRoot = animData.CreateBundle( rootTable, - eggGroupName ); - - // propagate commet to anim data - animData.root_group.children.push_front( - new EggComment( _commandLine ) ); - - if ( verbose >= 1 ) - fprintf( outStream, "made animRoot: %s\n", rootName ); - - SAA_sceneGetModels( &scene, numModels, models ); - - for ( i = 0; i < numModels; i++ ) - { - int level; - - SAA_elementGetHierarchyLevel( &scene, &models[i], &level ); - if ( !level ) - { - if ( verbose >= 1 ) - fprintf( outStream, - "\negging scene model[%d]\n", i ); - - MakeEgg( dart, NULL, NULL, &scene, &models[i] ); - } - } - - if ( make_poly || make_nurbs ) - { - // generate soft skinning assignments if desired disabled 1199 - // to streamline joint assignments. all joint assignments now - // done here. Hard & Soft. if ( make_soft) - { - char *name; - char *fullname; - SAA_Boolean isSkeleton; - - // search through models and look for skeleton parts - for ( i = 0; i < numModels; i++ ) - { - SAA_modelIsSkeleton( &scene, &models[i], &isSkeleton ); - - // get fullname for splitting files, but only use it - // in file if requested - fullname = GetFullName( &scene, &models[i] ); - if ( use_prefix ) - name = fullname; - else - name = GetName( &scene, &models[i] ); - - // split - if ( strstr( fullname, search_prefix ) != NULL ) - { - // for every skel part: get soft skin info - if ( isSkeleton ) - MakeSoftSkin( &scene, &models[i], models, - numModels, name ); - } - - // free( name ); - } - - // make sure all vertices were assigned via soft skinning - // - if not hard assign them - for ( i = 0; i < numModels; i++ ) - { - // get fullname for splitting files, but only use it - // in file if requested - fullname = GetFullName( &scene, &models[i] ); - if ( use_prefix ) - name = fullname; - else - name = GetName( &scene, &models[i] ); - - // split - if ( strstr( fullname, search_prefix ) != NULL ) - CleanUpSoftSkin( &scene, &models[i], name ); - - // free( name ); - } - - } - - - // put the skeleton data into the egg data - dart->StealChildren( *skeleton ); - - // make sure all elements have unique names - _data.UniquifyNames(); - - // write out the geometry data if requested if ( make_poly || - // make_nurbs ) { - eggFile << _data << "\n"; - fprintf( outStream, "\nwriting out %s...\n", eggFileName ); - eggFile.close(); - } - - // close texture list file if opened - if ( texFile ) - texFile.close(); - - // generate animation data if desired - if ( make_anim ) - { - if ( animFileName == NULL ) - { - animFileName = (char *)malloc(sizeof(char)* - (strlen(scene_name)+ 10 )); - sprintf( animFileName, "%s", DepointellizeName(scene_name) ); - strcat( animFileName, "-chan.egg" ); - } - - unlink( animFileName ); - animFile.open( animFileName, ios::out, 0666 ); - - if ( !animFile ) - { - fprintf( outStream, "Couldn't open output file: %s\n", - animFileName ); - exit( 1 ); - } - - int frame; - // int frameStep; - float time; - - // get all the animation frame info if not specified on the - // command line - if (anim_start == -1000) - SAA_sceneGetPlayCtrlStartFrame( &scene, &anim_start ); - - if (anim_end == -1000) - SAA_sceneGetPlayCtrlEndFrame( &scene, &anim_end ); - - // SAA_sceneGetPlayCtrlFrameStep( &scene, &frameStep ); - - fprintf( outStream, "\nframeStart = %d\n", anim_start ); - fprintf( outStream, "frameEnd = %d\n", anim_end ); - // fprintf( outStream, "frameStep = %d\n", frameStep ); - - // start at first frame and go to last - for ( frame = anim_start; frame <= anim_end; - frame += 1) - { - SAA_frame2Seconds( &scene, frame, &time ); - SAA_updatelistEvalScene( &scene, time ); - sginap( 100 ); - SAA_updatelistEvalScene( &scene, time ); - fprintf( outStream, "\n> animating frame %d\n", frame ); - - // for each model - for ( i = 0; i < numModels; i++ ) - { - char *name; - char *fullname; - SAA_Boolean isSkeleton; - SAA_ModelType type; - - SAA_modelIsSkeleton( &scene, &models[i], &isSkeleton ); - - // get fullname for splitting files, but only use it - // in file if requested - fullname = GetFullName( &scene, &models[i] ); - if ( use_prefix ) - name = fullname; - else - name = GetName( &scene, &models[i] ); - - // split - if ( strstr( fullname, search_prefix ) != NULL ) - { - // make the morph table for this critter - if ( make_morph ) - { - MakeMorphTable( &scene, &models[i], models, - numModels, name, time ); - } - } - - // find out what type of node we're dealing with - result = SAA_modelGetType( &scene, &models[i], &type ); - - int size; - - // check for uv texture animation - SAA_elementGetUserDataSize( &scene, &models[i], - "TEX_OFFSETS", &size ); - - // if so, update for this frame if desired - if ( ( size != 0 ) && make_duv ) - MakeTexAnim( &scene, &models[i], name ); - - // if we have a skeleton or something that acts like - // one - build anim tables - if ( isSkeleton || - ( strstr( name, "joint") != NULL ) ) - MakeAnimTable( &scene, &models[i], name ); - - // free( name ); - } - - if ( verbose >= 1 ) - fprintf( outStream, "\n" ); - } - - animFile << animData << "\n"; - fprintf( outStream, "\nwriting out %s...\n", animFileName ); - animFile.close(); - } - - // free( models ); - - } - else - fprintf( outStream, "Error: Not enough Memory for models...\n"); - } - } - // otherwise try to load a model - else if ( model_name != NULL ) - { - - if ( eggFileName == NULL ) - { - eggFileName = - (char *)malloc(sizeof(char)*(strlen( model_name )+13)); - sprintf( eggFileName, "%s", DepointellizeName( model_name ) ); - - if ( make_nurbs ) - strcat( eggFileName, "-nurb" ); - strcat( eggFileName, "-mod.egg" ); - } - - eggFile.open( eggFileName ); - - if ( !eggFile ) - { - fprintf( outStream, "Couldn't open output file: %s\n", - eggFileName ); - exit( 1 ); - } - - if ((result = - SAA_elementLoad(&database, &scene, model_name, &model)) - == SI_SUCCESS) - { - fprintf( outStream, "Loading single model...\n"); - MakeEgg( NULL, NULL, NULL, &scene, &model ); - } - - eggFile << _data << "\n"; - } - } - -} - -/** - * Make egg geometry from a given model. This include textures, tex coords, - * colors, normals, and joints. - */ -void soft2egg:: -MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, - SAA_Scene *scene, SAA_Elem *model ) -{ - char *name; - char *fullname; - SAA_ModelType type; - int id = 0; - int numShapes; - int numTri; - int numVert; - int numTexLoc = 0; - int numTexGlb = 0; - int i, j; - float matrix[4][4]; - float *uScale = NULL; - float *vScale = NULL; - float *uOffset = NULL; - float *vOffset = NULL; - SAA_Boolean uv_swap = FALSE; - void *relinfo; - SAA_SubElem *triangles = NULL; - SAA_Elem *materials = NULL; - SAA_SubElem *cvertices = NULL; - SAA_DVector *cvertPos = NULL; - SAA_DVector *vertices = NULL; - SAA_DVector *normals = NULL; - int *indices = NULL; - int *indexMap = NULL; - int *numTexTri = NULL; - SAA_Elem *textures = NULL; - char **texNameArray; - float *uCoords = NULL; - float *vCoords = NULL; - SAA_GeomType gtype = SAA_GEOM_ORIGINAL; - SAA_Boolean visible; - - // find out what type of node we're dealing with - result = SAA_modelGetType( scene, model, &type ); - - if ( verbose >= 1 ) - { - if ( type == SAA_MNILL ) - fprintf( outStream, "encountered null\n"); - else if ( type == SAA_MPTCH ) - fprintf( outStream, "encountered patch\n" ); - else if ( type == SAA_MFACE ) - fprintf( outStream, "encountered face\n" ); - else if ( type == SAA_MSMSH ) - fprintf( outStream, "encountered mesh\n" ); - else if ( type == SAA_MJNT ) - fprintf( outStream, "encountered joint\n" ); - else if ( type == SAA_MSPLN ) - fprintf( outStream, "encountered spline\n" ); - else if ( type == SAA_MMETA ) - fprintf( outStream, "encountered meta element\n" ); - else if ( type == SAA_MBALL ) - fprintf( outStream, "encountered metaball\n" ); - else if ( type == SAA_MNCRV ) - fprintf( outStream, "encountered nurb curve\n" ); - else if ( type == SAA_MNSRF ) - fprintf( outStream, "encountered nurbs surf\n" ); - else - fprintf( outStream, "encountered unknown type: %d\n", type ); - } - - // Get the name of the model - - // Get the FULL name of the model - fullname = GetFullName( scene, model ); - - if ( use_prefix ) - { - // Get the FULL name of the trim curve - name = fullname; - } - else - { - // Get the name of the trim curve - name = GetName( scene, model ); - } - - if ( verbose >= 1 ) - fprintf( outStream, "element name <%s>\n", name ); - - fflush( outStream ); - - // get the model's matrix - SAA_modelGetMatrix( scene, model, SAA_COORDSYS_GLOBAL, matrix ); - - if ( verbose >= 2 ) - { - fprintf( outStream, "model matrix = %f %f %f %f\n", matrix[0][0], - matrix[0][1], matrix[0][2], matrix[0][3] ); - fprintf( outStream, "model matrix = %f %f %f %f\n", matrix[1][0], - matrix[1][1], matrix[1][2], matrix[1][3] ); - fprintf( outStream, "model matrix = %f %f %f %f\n", matrix[2][0], - matrix[2][1], matrix[2][2], matrix[2][3] ); - fprintf( outStream, "model matrix = %f %f %f %f\n", matrix[3][0], - matrix[3][1], matrix[3][2], matrix[3][3] ); - } - - // check to see if this is a branch we don't want to descend - this will - // prevent creating geometry for animation control structures - if ( (strstr( name, "con-" ) == NULL) && - (strstr( name, "con_" ) == NULL) && - (strstr( name, "fly_" ) == NULL) && - (strstr( name, "fly-" ) == NULL) && - (strstr( name, "camRIG" ) == NULL) && - (strstr( name, "bars" ) == NULL) && - // split - (strstr( fullname, search_prefix ) != NULL) ) - { - - // if making a pose - get deformed geometry - if ( make_pose ) - gtype = SAA_GEOM_DEFORMED; - - // Get the number of key shapes - SAA_modelGetNbShapes( scene, model, &numShapes ); - if ( verbose >= 1 ) - fprintf( outStream, "MakeEgg: num shapes: %d\n", numShapes); - - // if multiple key shapes exist create table entries for each - if ( (numShapes > 0) && make_morph ) - { - has_morph = 1; - - // make sure root morph table exists - if ( morphRoot == NULL ) - morphRoot = animData.CreateTable( animRoot, "morph" ); - - char *tableName; - - // create morph table entry for each key shape (start at second shape - // - as first is the original geometry) - for ( i = 1; i < numShapes; i++ ) - { - tableName = MakeTableName( name, i ); - SAnimTable *table = new SAnimTable( ); - table->name = tableName; - table->fps = anim_rate; - morphRoot->children.push_back( table ); - if ( verbose >= 1 ) - fprintf( outStream, "created table named: '%s'\n", tableName ); - } - - // free( tableName ); - } - - SAA_modelGetNodeVisibility( scene, model, &visible ); - if ( verbose >= 1 ) - fprintf( outStream, "model visibility: %d\n", visible ); - - // Only create egg polygon data if: the node is visible, and its not a - // NULL or a Joint, and we're outputing polys (or if we are outputing - // NURBS and the model is a poly mesh or a face) - if ( visible && - (type != SAA_MNILL) && - (type != SAA_MJNT) && - ((make_poly || - (make_nurbs && ((type == SAA_MSMSH) || (type == SAA_MFACE )) )) - || (!make_poly && !make_nurbs && make_duv && - ((type == SAA_MSMSH) || (type == SAA_MFACE )) )) - ) - { - // If the model is a NURBS in soft, set its step before tesselating - if ( type == SAA_MNSRF ) - SAA_nurbsSurfaceSetStep( scene, model, nurbs_step, nurbs_step ); - - // If the model is a PATCH in soft, set its step before tesselating - else if ( type == SAA_MPTCH ) - SAA_patchSetStep( scene, model, nurbs_step, nurbs_step ); - - // Get the number of triangles - result = SAA_modelGetNbTriangles( scene, model, gtype, id, &numTri); - if ( verbose >= 1 ) - fprintf( outStream, "triangles: %d\n", numTri); - - if ( result != SI_SUCCESS ) - { - if ( verbose >= 1 ) { - fprintf( outStream, - "Error: couldn't get number of triangles!\n" ); - fprintf( outStream, "\tbailing on model: '%s'\n", name ); - } - return; - } - - // check to see if surface is also skeleton... - SAA_Boolean isSkeleton = FALSE; - - SAA_modelIsSkeleton( scene, model, &isSkeleton ); - - // check to see if this surface is used as a skeleton or is animated via - // constraint only ( these nodes are tagged by the animator with the - // keyword "joint" somewhere in the nodes name) - if ( isSkeleton || (strstr( name, "joint" ) != NULL) ) - { - if ( verbose >= 1 ) - fprintf( outStream, "animating Polys as joint!!!\n" ); - - MakeJoint( scene, lastJoint, lastAnim, model, name ); - } - - // model is not a null and has no triangles! - if ( !numTri ) - { - if ( verbose >= 1 ) - fprintf( outStream, "no triangles!\n"); - } - else - { - // allocate array of triangles - triangles = (SAA_SubElem *)malloc(sizeof(SAA_SubElem)*numTri); - if ( triangles != NULL ) - { - // triangulate model and read the triangles into array - SAA_modelGetTriangles( scene, model, gtype, id, numTri, triangles ); - } - else - fprintf( outStream, "Not enough Memory for triangles...\n"); - - // allocate array of materials - materials = (SAA_Elem *)malloc(sizeof(SAA_Elem)*numTri); - if ( materials != NULL ) - { - // read each triangle's material into array - SAA_triangleGetMaterials( scene, model, numTri, triangles, - materials ); - } - else - fprintf( outStream, "Not enough Memory for materials...\n"); - - // allocate array of textures per triangle - numTexTri = (int *)malloc(sizeof(int)*numTri); - - // find out how many local textures per triangle - for ( i = 0; i < numTri; i++ ) - { - result = SAA_materialRelationGetT2DLocNbElements( scene, - &materials[i], FALSE, &relinfo, &numTexTri[i] ); - - // polytex - if ( result == SI_SUCCESS ) - numTexLoc += numTexTri[i]; - } - - // don't need this anymore... free( numTexTri ); - - // get local textures if present - if ( numTexLoc ) - { - // ASSUME only one texture per material - textures = (SAA_Elem *)malloc(sizeof(SAA_Elem)*numTri); - - for ( i = 0; i < numTri; i++ ) - { - // and read all referenced local textures into array - SAA_materialRelationGetT2DLocElements( scene, &materials[i], - TEX_PER_MAT , &textures[i] ); - } - - if ( verbose >= 1 ) - fprintf( outStream, "numTexLoc = %d\n", numTexLoc); - } - // if no local textures, try to get global textures - else - { - SAA_modelRelationGetT2DGlbNbElements( scene, model, - FALSE, &relinfo, &numTexGlb ); - - if ( numTexGlb ) - { - // ASSUME only one texture per model - textures = (SAA_Elem *)malloc(sizeof(SAA_Elem)); - - // get the referenced texture - SAA_modelRelationGetT2DGlbElements( scene, model, - TEX_PER_MAT, textures ); - - if ( verbose >= 1 ) - fprintf( outStream, "numTexGlb = %d\n", numTexGlb); - } - } - - // allocate array of control vertices - cvertices = (SAA_SubElem *)malloc(sizeof(SAA_SubElem)*numTri*3); - if ( cvertices != NULL ) - { - // read each triangle's control vertices into array - SAA_triangleGetCtrlVertices( scene, model, gtype, id, - numTri, triangles, cvertices ); - - if ( verbose >= 2 ) - { - cvertPos = (SAA_DVector *)malloc(sizeof(SAA_DVector)*numTri*3); - SAA_ctrlVertexGetPositions( scene, model, numTri*3, - cvertices, cvertPos); - - for ( i=0; i < numTri*3; i++ ) - { - fprintf( outStream, "cvert[%d] = %f %f %f %f\n", i, - cvertPos[i].x, cvertPos[i].y, cvertPos[i].z, - cvertPos[i].w ); - } - } - } - else - fprintf( outStream, "Not enough Memory for control vertices...\n"); - - // allocate array of control vertex indices this array maps from the - // redundant cvertices array into the unique vertices array - // (cvertices->vertices) - indices = (int *)malloc(sizeof(int)*numTri*3); - if ( indices != NULL ) - { - for ( i=0; i < numTri*3; i++ ) - indices[i] = 0; - - SAA_ctrlVertexGetIndices( scene, model, numTri*3, - cvertices, indices ); - - if ( verbose >= 2 ) - for ( i=0; i < numTri*3; i++ ) - fprintf( outStream, "indices[%d] = %d\n", i, indices[i] ); - } - else - fprintf( outStream, "Not enough Memory for indices...\n"); - - // get number of UNIQUE vertices in model - SAA_modelGetNbTriVertices( scene, model, &numVert ); - - if ( verbose >= 2 ) - fprintf( outStream, "num unique verts = %d\n", numVert ); - - // allocate array of vertices - vertices = (SAA_DVector *)malloc(sizeof(SAA_DVector)*numVert); - - // get the UNIQUE vertices of all triangles in model - SAA_modelGetTriVertices( scene, model, numVert, vertices ); - - if ( verbose >= 2 ) - { - for ( i=0; i < numVert; i++ ) - { - fprintf( outStream, "vertices[%d] = %f ", i, vertices[i].x ); - fprintf( outStream, "%f %f %f\n", vertices[i].y, - vertices[i].z, vertices[i].w ); - } - } - - // allocate indexMap array we contruct this array to map from the - // unique vertices array to the redundant cvertices array - it will - // save us from doing repetitive searches later - indexMap = MakeIndexMap( indices, numTri*3, numVert ); - - // allocate array of normals - normals = (SAA_DVector *)malloc(sizeof(SAA_DVector)*numTri*3); - if ( normals != NULL ) - { - // read each control vertex's normals into an array - SAA_ctrlVertexGetNormals( scene, model, numTri*3, - cvertices, normals ); - } - else - fprintf( outStream, "Not enough Memory for normals...\n"); - - if ( verbose >= 2 ) - { - for ( i=0; i= 2 ) - { - for ( i=0; i= 2 ) - fprintf( outStream, " tritex[%d] named: %s\n", i, - texNameArray[i] ); - - SAA_texture2DGetUVSwap( scene, &textures[i], &uv_swap ); - - if ( verbose >= 2 ) - if ( uv_swap == TRUE ) - fprintf( outStream, " swapping u and v...\n" ); - - SAA_texture2DGetUScale( scene, &textures[i], &uScale[i] ); - SAA_texture2DGetVScale( scene, &textures[i], &vScale[i] ); - SAA_texture2DGetUOffset( scene, &textures[i], &uOffset[i] ); - SAA_texture2DGetVOffset( scene, &textures[i], &vOffset[i] ); - - if ( verbose >= 2 ) - { - fprintf(outStream, "tritex[%d] uScale: %f vScale: %f\n", i, uScale[i], vScale[i] ); - fprintf(outStream, " uOffset: %f vOffset: %f\n", - uOffset[i], vOffset[i] ); - } - - - SAA_texture2DGetRepeats( scene, &textures[i], &uRepeat, - &vRepeat ); - - if ( verbose >= 2 ) - { - fprintf(outStream, "uRepeat = %d, vRepeat = %d\n", - uRepeat, vRepeat ); - } - } - else - { - if ( verbose >= 2 ) - { - fprintf( outStream, "Invalid texture...\n"); - fprintf( outStream, " tritex[%d] named: (null)\n", i ); - } - } - } - -/* - * debug for ( i = 0; i < numTri; i++ ) { if ( texNameArray[i] != NULL ) - * fprintf( outStream, " tritex[%d] named: %s\n", i, texNameArray[i] ); else - * fprintf( outStream, " tritex[%d] named: (null)\n", i ); } - */ - } - // make sure we have textures before we get t-coords - else if ( numTexGlb ) - { - SAA_Boolean valid; - - // check to see if texture is present - SAA_elementIsValid( scene, textures, &valid ); - - // texture present - get the name and uv info - if ( valid ) - { - SAA_texture2DGetUVSwap( scene, textures, &uv_swap ); - - if ( verbose >= 1 ) - if ( uv_swap == TRUE ) - fprintf( outStream, " swapping u and v...\n" ); - - // allocate arrays for u & v coords - uCoords = (float *)malloc(sizeof(float)*numTri*numTexGlb*3); - vCoords = (float *)malloc(sizeof(float)*numTri*numTexGlb*3); - - for ( i = 0; i < numTri*numTexGlb*3; i++ ) - { - uCoords[i] = vCoords[i] = 0.0f; - } - - // read the u & v coords into the arrays - if ( uCoords != NULL && vCoords != NULL) - { - SAA_triCtrlVertexGetGlobalUVTxtCoords( scene, model, - numTri*3, cvertices, numTexGlb, textures, - uCoords, vCoords ); - } - else - fprintf( outStream, "Not enough Memory for texture coords...\n"); - - if ( verbose >= 2 ) - { - for ( i=0; i= 1 ) - fprintf( outStream, " global tex named: %s\n", - texNameArray ); - - // allocate arrays of texture info - uScale = ( float *)malloc(sizeof(float)); - vScale = ( float *)malloc(sizeof(float)); - uOffset = ( float *)malloc(sizeof(float)); - vOffset = ( float *)malloc(sizeof(float)); - - SAA_texture2DGetUScale( scene, textures, uScale ); - SAA_texture2DGetVScale( scene, textures, vScale ); - SAA_texture2DGetUOffset( scene, textures, uOffset ); - SAA_texture2DGetVOffset( scene, textures, vOffset ); - - if ( verbose >= 1 ) - { - fprintf( outStream, " global tex uScale: %f vScale: %f\n", - *uScale, *vScale ); - fprintf( outStream, " uOffset: %f vOffset: %f\n", - *uOffset, *vOffset ); - } - - SAA_texture2DGetRepeats( scene, textures, &uRepeat, - &vRepeat ); - - if ( verbose >= 2 ) - { - fprintf(outStream, "uRepeat = %d, vRepeat = %d\n", - uRepeat, vRepeat ); - } - } - else fprintf( outStream, "Invalid texture...\n"); - } - - // make the egg vertex pool - EggVertexPool *pool = _data.CreateVertexPool( parent, name ); - - for ( i = 0; i < numVert; i++ ) - { - pfVec3 eggVert; - pfVec3 eggNorm; - - // convert to global coords - SAA_DVector local = vertices[i]; - SAA_DVector global; - - _VCT_X_MAT( global, local, matrix ); - - // set vertices array to reflect global coords vertices[i].x = - // global.x; vertices[i].y = global.y; vertices[i].z = global.z; - - // eggVert.set( vertices[i].x, vertices[i].y, vertices[i].z ); - - // we'll preserve original verts for now - eggVert.set( global.x, global.y, global.z ); - - local = normals[indexMap[i]]; - - _VCT_X_MAT( global, local, matrix ); - - eggNorm.set( global.x, global.y, global.z ); - eggNorm.normalize(); - - pool->AddVertex( eggVert, i ); - pool->Vertex(i)->attrib.SetNormal( eggNorm ); - - // translate local uv's to global and add to vertex pool - if ( numTexLoc && (uCoords != NULL && vCoords !=NULL )) - { - float u, v; - - if ( ignore_tex_offsets ) { - u = uCoords[indexMap[i]]; - v = 1.0f - vCoords[indexMap[i]]; - } else { - u = (uCoords[indexMap[i]] - uOffset[indexMap[i]/3]) / - uScale[indexMap[i]/3]; - - v = 1.0f - ((vCoords[indexMap[i]] - vOffset[indexMap[i]/3]) / - vScale[indexMap[i]/3]); - } - - if ( isNum(u) && isNum(v) ) - { - if ( uv_swap == TRUE ) - pool->Vertex(i)->attrib.SetUV( v, u ); - else - pool->Vertex(i)->attrib.SetUV( u, v ); - } - } - else if ( numTexGlb && (uCoords != NULL && vCoords !=NULL ) ) - { - float u, v; - - if ( ignore_tex_offsets ) { - u = uCoords[indexMap[i]]; - v = 1.0f - vCoords[indexMap[i]]; - } else { - u = (uCoords[indexMap[i]] - *uOffset) / *uScale; - v = 1.0f - (( vCoords[indexMap[i]] - *vOffset ) / *vScale); - } - - if ( isNum(u) && isNum(v) ) - { - if ( uv_swap == TRUE ) - pool->Vertex(i)->attrib.SetUV( v, u ); - else - pool->Vertex(i)->attrib.SetUV( u, v ); - } - } - - // if we've encountered textures and we desire duv anims - if (( numTexLoc || numTexGlb ) && make_duv ) - { - int numExp; - SAA_Elem *tex; - - // grab the current texture - if ( numTexLoc ) - tex = &textures[0]; - else - tex = textures; - - // find how many expressions for this shape - SAA_elementGetNbExpressions( scene, tex, NULL, FALSE, - &numExp ); - - // if it has expressions we'll assume its animated - if ( numExp ) - { - // if animated object make base duv's, animtables for the - // duv's and store the original offsets - strstream uName, vName; - - // create duv target names - uName << name << ".u" << ends; - vName << name << ".v" << ends; - - // only create tables and store offsets on a per model - // basis (not per vertex) - if ( !i ) - { - - // make sure root morph table exists - if ( morphRoot == NULL ) - morphRoot = animData.CreateTable( animRoot, - "morph" ); - - // create morph table entry for each duv - SAnimTable *uTable = new SAnimTable( ); - uTable->name = uName.str(); - uTable->fps = anim_rate; - morphRoot->children.push_back( uTable ); - if ( verbose >= 1 ) - fprintf( outStream, "created duv table named: %s\n", uName.str() ); - - SAnimTable *vTable = new SAnimTable( ); - vTable->name = vName.str(); - vTable->fps = anim_rate; - morphRoot->children.push_back( vTable ); - if ( verbose >= 1 ) - fprintf( outStream, "created duv table named: %s\n", vName.str() ); - - float texOffsets[4]; - - if ( numTexGlb ) - { - texOffsets[0] = *uOffset; - texOffsets[1] = *vOffset; - texOffsets[2] = *uScale; - texOffsets[3] = *vScale; - } - else - { - texOffsets[0] = uOffset[indexMap[i]/3]; - texOffsets[1] = vOffset[indexMap[i]/3]; - texOffsets[2] = uScale[indexMap[i]/3]; - texOffsets[3] = vScale[indexMap[i]/3]; - } - - // remember original texture offsets future reference - SAA_elementSetUserData( scene, model, "TEX_OFFSETS", - sizeof( texOffsets ), TRUE, (void **)&texOffsets ); - } - - EggMorphOffset *duvU; - EggMorphOffset *duvV; - - // generate base duv's for this vertex - duvU = new EggMorphOffset( uName.str(), 1.0 , 0.0 ); - pool->Vertex(i)->attrib.uv_morphs.push_back( *duvU ); - - duvV = new EggMorphOffset( vName.str(), 0.0 , 1.0 ); - pool->Vertex(i)->attrib.uv_morphs.push_back( *duvV ); - - } // if ( numExp ) - - } // if ( numTexLoc || numTexGlb ) - - } // for ( i = 0; i < numVert; i++ ) - - // if model has key shapes, generate vertex offsets - if ( has_morph && make_morph ) - MakeVertexOffsets( scene, model, type, numShapes, numVert, - vertices, matrix, name ); - - - // create vertex ref list for all polygons in the model - EggVertexRef *vref; - - vref = new EggVertexRef( pool); - for ( i = 0; i < numVert; i++ ) - { - // add each vert in pool to last joint for hard skinning - vref->indices.push_back( EggVertexIndex( i ) ); - } - -/* - * hard assign poly geometry if no soft-skinning requested disabled 1199 to - * streamline joint assignments. all hard-skinning now done in - * CleanUpSoftSkin. if ( !make_soft ) { if ( lastJoint != NULL ) { - * lastJoint->vrefs.AddUniqueNode( *vref ); - */ - - // if ( verbose >= 1 ) fprintf( outStream, "hard-skinning %s - // (%d vertices)\n", name, i+1 ); } } - - // make an egg group to hold all triangles - EggGroup *group = _data.CreateGroup( parent, name); - - // make this group the current parent - parent = group; - - EggPolygon *poly = NULL; - EggColor *cref = NULL; - EggTexture *tref = NULL; - - // for each triangle - for ( i = 0; i < numTri*3; i+=3 ) - { - float r,g,b,a; - pfVec4 color; - - // make egg poly for each traingle and reference the appropriate - // vertex in the pool - poly = _data.CreatePolygon( group, pool ); - poly->AddVertex(indices[i]); - poly->AddVertex(indices[i+1]); - poly->AddVertex(indices[i+2]); - - // check for back face flag in model note info - char *modelNoteStr = GetModelNoteInfo( scene, model ); - - if ( modelNoteStr != NULL ) - { - if ( strstr( modelNoteStr, "bface" ) != NULL ) - poly->flags |= EG_BFACE; - } - - // check to see if material is present - SAA_Boolean valid; - SAA_elementIsValid( scene, &materials[i/3], &valid ); - - // material present - get the color - if ( valid ) - { - SAA_materialGetDiffuse( scene, &materials[i/3], &r, &g, &b ); - SAA_materialGetTransparency( scene, &materials[i/3], &a ); - color.set( r, g, b, 1.0f - a ); - } - // no material - default to white - else - color.set( 1.0, 1.0, 1.0, 1.0 ); - - cref = _data.CreateColor(color); - poly->attrib.SetCRef(cref); - - strstream uniqueTexName; - - if (numTexLoc) - { - // polytex - if ( (texNameArray[i/3] != NULL) && - (strcmp(texNameArray[i/3], "NULL") != 0) ) - { - // append unique identifier to texname for this particular - // object - uniqueTexName << name << "-" - << RemovePathName(texNameArray[i/3]); - - tref = _data.CreateTexture( texNameArray[i/3], - uniqueTexName.str() ); - - if ( verbose >= 1 ) - fprintf( outStream, " tritex[%d] named: %s\n", i/3, - texNameArray[i/3] ); - } - } - else if ( numTexGlb ) - { - if ( texNameArray != NULL ) - { - // append unique identifier to texname for this particular - // object - uniqueTexName << name << "-" - << RemovePathName(*texNameArray); - - tref = _data.CreateTexture( *texNameArray, - uniqueTexName.str() ); - - if ( verbose >= 1 ) - fprintf( outStream, " tritex named: %s\n", - *texNameArray ); - } - } - - // set the clamp on the texture - if ( tref != NULL ) - { - if ( uRepeat > 0 ) - tref->wrapu = EggTexture::WM_repeat; - else - tref->wrapu = EggTexture::WM_clamp; - - if ( vRepeat > 1 ) - tref->wrapv = EggTexture::WM_repeat; - else - tref->wrapv = EggTexture::WM_clamp; - - poly->attrib.SetTRef(tref); - } - - } - - // we're done - trash triangles... - SAA_modelClearTriangles( scene, model ); - -/* - * free molloc'd memory free( triangles ); free( materials ); free( normals ); - * free( cvertices ); free( vertices ); free( indices ); free( indexMap ); - */ - - // free these only if they were malloc'd for textures - if (numTexLoc || numTexGlb) - { -/* - * free( textures ); free( uCoords ); free( vCoords ); free( texNameArray ); - * free( uScale ); free( vScale ); free( uOffset ); free( vOffset ); - */ - } - } - } - else - { - // check to see if its a nurbs surface - if ( (type == SAA_MNSRF) && ( visible ) && (( make_nurbs ) - || ( !make_nurbs && !make_poly && make_duv )) ) - { - // check to see if NURBS is also skeleton... - SAA_Boolean isSkeleton = FALSE; - - SAA_modelIsSkeleton( scene, model, &isSkeleton ); - - // check to see if this NURBS is used as a skeleton or is animated - // via constraint only ( these nodes are tagged by the animator - // with the keyword "joint" somewhere in the nodes name) - if ( isSkeleton || (strstr( name, "joint" ) != NULL) ) - { - MakeJoint( scene, lastJoint, lastAnim, model, name ); - geom_as_joint = 1; - if ( verbose >= 1 ) - fprintf( outStream, "animating NURBS as joint!!!\n" ); - } - - EggNurbsSurface *eggNurbsSurf = new EggNurbsSurface( name ); - int uDegree, vDegree; - - // create nurbs representation of surface - SAA_nurbsSurfaceGetDegree( scene, model, &uDegree, &vDegree ); - eggNurbsSurf->u_order = uDegree + 1; - eggNurbsSurf->v_order = vDegree + 1; - if ( verbose >= 1 ) - { - fprintf( outStream, "nurbs degree: %d u, %d v\n", - uDegree, vDegree ); - fprintf( outStream, "nurbs order: %d u, %d v\n", - uDegree + 1, vDegree + 1 ); - } - - SAA_Boolean uClosed = FALSE; - SAA_Boolean vClosed = FALSE; - - SAA_nurbsSurfaceGetClosed( scene, model, &uClosed, &vClosed); - - if ( verbose >= 1 ) - { - if ( uClosed ) - fprintf( outStream, "nurbs is closed in u...\n"); - if ( vClosed ) - fprintf( outStream, "nurbs is closed in v...\n"); - } - - int uRows, vRows; - SAA_nurbsSurfaceGetNbVertices( scene, model, &uRows, &vRows ); - if ( verbose >= 1 ) - fprintf( outStream, "nurbs vertices: %d u, %d v\n", - uRows, vRows ); - - int uCurves, vCurves; - SAA_nurbsSurfaceGetNbCurves( scene, model, &uCurves, &vCurves ); - if ( verbose >= 1 ) - fprintf( outStream, "nurbs curves: %d u, %d v\n", - uCurves, vCurves ); - - if ( shift_textures ) - { - if ( uClosed ) - // shift starting point on NURBS surface for correct textures - SAA_nurbsSurfaceShiftParameterization( scene, model, -2, 0 ); - - if ( vClosed ) - // shift starting point on NURBS surface for correct textures - SAA_nurbsSurfaceShiftParameterization( scene, model, 0, -2 ); - } - - SAA_nurbsSurfaceSetStep( scene, model, nurbs_step, nurbs_step ); - - // check for back face flag in model note info - char *modelNoteStr = GetModelNoteInfo( scene, model ); - - if ( modelNoteStr != NULL ) - { - if ( strstr( modelNoteStr, "bface" ) != NULL ) - eggNurbsSurf->flags |= EG_BFACE; - } - - int numKnotsU, numKnotsV; - - SAA_nurbsSurfaceGetNbKnots( scene, model, &numKnotsU, &numKnotsV ); - if ( verbose >= 1 ) - fprintf( outStream, "nurbs knots: %d u, %d v\n", - numKnotsU, numKnotsV ); - - double *knotsU, *knotsV; - knotsU = (double *)malloc(sizeof(double)*numKnotsU); - knotsV = (double *)malloc(sizeof(double)*numKnotsV); - SAA_nurbsSurfaceGetKnots( scene, model, gtype, 0, - numKnotsU, numKnotsV, knotsU, knotsV ); - - if ( verbose >= 2 ) - fprintf( outStream, "u knots:\n" ); - - AddKnots( eggNurbsSurf->u_knots, knotsU, numKnotsU, uClosed, uDegree ); - if ( verbose >= 2 ) - fprintf( outStream, "v knots:\n" ); - - AddKnots( eggNurbsSurf->v_knots, knotsV, numKnotsV, vClosed, vDegree); - - // free( knotsU ); free( knotsV ); - - // set sub_div so we can see it in perfly - eggNurbsSurf->u_subdiv = (uRows-1)*nurbs_step; - eggNurbsSurf->v_subdiv = (vRows-1)*nurbs_step; - - SAA_modelGetNbVertices( scene, model, &numVert ); - - if ( verbose >= 2 ) - fprintf( outStream, "%d CV's\n", numVert ); - - // get the CV's - vertices = (SAA_DVector *)malloc(sizeof(SAA_DVector)*numVert); - SAA_modelGetVertices( scene, model, gtype, 0, - numVert, vertices ); - - // create pool of NURBS vertices - EggVertexPool *pool = _data.CreateVertexPool( parent, name ); - eggNurbsSurf->SetVertexPool( pool ); - - // create vertex ref list for all cv's in the model - EggVertexRef *vref; - - vref = new EggVertexRef( pool); - - for ( int k = 0; k= 2 ) - { - fprintf( outStream, "original cv[%d] = %f %f %f %f\n", k, - vertices[k].x, vertices[k].y, vertices[k].z, - vertices[k].w ); - } - - pfVec4 eggVert; - - // convert to global coords - SAA_DVector global; - - _VCT_X_MAT( global, vertices[k], matrix ); - - // preserve original weight - global.w = vertices[k].w; - - // normalize coords to weight - global.x *= global.w; - global.y *= global.w; - global.z *= global.w; - - // this code is commented out because I am no longer sending - // global data to the other routines (ie makevertexoffset) - - // set vertices array to reflect global coords vertices[k].x = - // global.x; vertices[k].y = global.y; vertices[k].z = - // global.z; vertices[k].w = global.w; - - // if ( verbose >= 2 ) { fprintf( outStream, "global cv[%d] = - // %f %f %f %f\n", k, vertices[k].x, vertices[k].y, - // vertices[k].z, vertices[k].w ); } - - // eggVert.set( vertices[k].x, vertices[k].y, vertices[k].z, - // vertices[k].w ); - - if ( verbose >= 2 ) - { - fprintf( outStream, "global cv[%d] = %f %f %f %f\n", k, - global.x, global.y, global.z, - global.w ); - } - - eggVert.set( global.x, global.y, global.z, - global.w ); - - // populate vertex pool - pool->AddVertex( eggVert, k ); - - // add vref's to NURBS info - eggNurbsSurf->AddVertex( k ); - - // add each vert in pool to vref for hard skinning - vref->indices.push_back( EggVertexIndex( k ) ); - - // check to see if the NURB is closed in u - if ( uClosed ) - { - // add first uDegree verts to end of row - if ( (k % uRows) == ( uRows - 1) ) - for ( int i = 0; i < uDegree; i++ ) - { - // add vref's to NURBS info - eggNurbsSurf->AddVertex( i+((k/uRows)*uRows) ); - - // add each vert to vref - vref->indices.push_back( - EggVertexIndex( i+((k/uRows)*uRows) ) ); - } - } - } - -/* - * if hard skinned or this nurb is also a joint disabled 1199 to streamline - * joint assignments. all hard skinning now done in CleanUpSoftSkin. if - * (!make_soft || geom_as_joint) { add the new cv references to the last joint - * for hard skinning only if ( lastJoint != NULL ) { - * lastJoint->vrefs.AddUniqueNode( *vref ); geom_as_joint = 0; if ( verbose >= - * 1 ) fprintf( outStream, "Doing NURBS hard skinning...\n"); } } - */ - - // check to see if the NURB is closed in v - if ( vClosed && !uClosed ) - { - // add first vDegree rows of verts to end of list - for ( int i = 0; i < vDegree*uRows; i++ ) - eggNurbsSurf->AddVertex( i ); - } - // check to see if the NURB is closed in u and v - else if ( vClosed && uClosed ) - { - // add the first (degree) v verts and a few extra - for good - // measure - for ( i = 0; i < vDegree; i++ ) - { - // add first vDegree rows of verts to end of list - for ( j = 0; j < uRows; j++ ) - eggNurbsSurf->AddVertex( j+(i*uRows) ); - - // if u is closed to we have added uDegree verts onto the - // ends of the rows - add them here too - for ( k = 0; k < uDegree; k++ ) - eggNurbsSurf->AddVertex( k+(i*uRows)+((k/uRows)*uRows) ); - } - - } - - // get the color of the NURBS surface - int numNurbMats; - EggColor *nurbCref; - pfVec4 nurbColor; - - SAA_modelRelationGetMatNbElements( scene, model, FALSE, &relinfo, - &numNurbMats ); - - if ( verbose >= 1 ) - fprintf( outStream, "nurbs surf has %d materials\n", - numNurbMats ); - - if ( numNurbMats ) - { - float r,g,b,a; - - materials = (SAA_Elem *)malloc(sizeof(SAA_Elem)*numNurbMats); - - SAA_modelRelationGetMatElements( scene, model, relinfo, - numNurbMats, materials ); - - SAA_materialGetDiffuse( scene, &materials[0], &r, &g, &b ); - SAA_materialGetTransparency( scene, &materials[0], &a ); - nurbColor.set( r, g, b, 1.0f - a ); - // nurbColor.set( r, g, b, 1.0 ); - - nurbCref = _data.CreateColor(nurbColor); - eggNurbsSurf->attrib.SetCRef(nurbCref); - - // get the texture of the NURBS surface from the material - int numNurbTexLoc = 0; - int numNurbTexGlb = 0; - - // ASSUME only one texture per material - SAA_Elem nurbTex; - - // find out how many local textures per NURBS surface ASSUME - // it only has one material - SAA_materialRelationGetT2DLocNbElements( scene, &materials[0], - FALSE, &relinfo, &numNurbTexLoc ); - - // if present, get local textures - if ( numNurbTexLoc ) - { - if ( verbose >= 1 ) - fprintf( outStream, "%s had %d local tex\n", name, - numNurbTexLoc ); - - // get the referenced texture - SAA_materialRelationGetT2DLocElements( scene, &materials[0], - TEX_PER_MAT, &nurbTex ); - - } - // if no locals, try to get globals - else - { - SAA_modelRelationGetT2DGlbNbElements( scene, model, - FALSE, &relinfo, &numNurbTexGlb ); - - if ( numNurbTexGlb ) - { - if ( verbose >= 1 ) - fprintf( outStream, "%s had %d global tex\n", name, - numNurbTexGlb ); - - // get the referenced texture - SAA_modelRelationGetT2DGlbElements( scene, - model, TEX_PER_MAT, &nurbTex ); - } - } - - // add tex ref's if we found any textures - if ( numNurbTexLoc || numNurbTexGlb) - { - char *texName = NULL; - char *uniqueTexName = NULL; - EggTexture *tref; - pfMatrix nurbTexMat; - - - // convert the texture to .rgb and adjust name - texName = ConvertTexture( scene, &nurbTex ); - - // append unique identifier to texname for this particular - // object - uniqueTexName = (char *)malloc(sizeof(char)* - (strlen(name)+strlen(texName)+3) ); - sprintf( uniqueTexName, "%s-%s", name, - RemovePathName(texName) ); - - if ( verbose >= 1 ) - { - fprintf( outStream, "creating tref %s\n", - uniqueTexName ); - } - - tref = _data.CreateTexture( texName, uniqueTexName ); - - uScale = ( float *)malloc(sizeof(float)); - vScale = ( float *)malloc(sizeof(float)); - uOffset = ( float *)malloc(sizeof(float)); - vOffset = ( float *)malloc(sizeof(float)); - - // get texture offset info - SAA_texture2DGetUScale( scene, &nurbTex, uScale ); - SAA_texture2DGetVScale( scene, &nurbTex, vScale ); - SAA_texture2DGetUOffset( scene, &nurbTex, uOffset ); - SAA_texture2DGetVOffset( scene, &nurbTex, vOffset ); - SAA_texture2DGetUVSwap( scene, &nurbTex, &uv_swap ); - - - if ( verbose >= 1 ) - { - fprintf( outStream, "nurbTex uScale: %f\n", *uScale ); - fprintf( outStream, "nurbTex vScale: %f\n", *vScale ); - fprintf( outStream, "nurbTex uOffset: %f\n", *uOffset ); - fprintf( outStream, "nurbTex vOffset: %f\n", *vOffset ); - if ( uv_swap ) - fprintf( outStream, "nurbTex u & v swapped!\n" ); - else - fprintf( outStream, "nurbTex u & v NOT swapped\n" ); - } - - nurbTexMat.makeIdent(); - - if ( !ignore_tex_offsets ) - { - if ( uv_swap ) - { - nurbTexMat[0][0] = 0.0f; - nurbTexMat[1][1] = 0.0f; - nurbTexMat[0][1] = 1 / *vScale; - nurbTexMat[1][0] = 1 / *uScale; - nurbTexMat[2][1] = -(*uOffset / *uScale); - nurbTexMat[2][0] = -(*vOffset / *vScale); - } - else - { - nurbTexMat[0][0] = 1 / *uScale; - nurbTexMat[1][1] = 1 / *vScale; - nurbTexMat[2][0] = -(*uOffset / *uScale); - nurbTexMat[2][1] = -(*vOffset / *vScale); - } - } - - - // call printMat - if ( verbose >= 2 ) - { - fprintf( outStream, "nurb tex matrix = %f %f %f %f\n", nurbTexMat[0][0], - nurbTexMat[0][1], nurbTexMat[0][2], nurbTexMat[0][3] ); - fprintf( outStream, "nurb tex matrix = %f %f %f %f\n", nurbTexMat[1][0], - nurbTexMat[1][1], nurbTexMat[1][2], nurbTexMat[1][3] ); - fprintf( outStream, "nurb tex matrix = %f %f %f %f\n", nurbTexMat[2][0], - nurbTexMat[2][1], nurbTexMat[2][2], nurbTexMat[2][3] ); - fprintf( outStream, "nurb tex matrix = %f %f %f %f\n", nurbTexMat[3][0], - nurbTexMat[3][1], nurbTexMat[3][2], nurbTexMat[3][3] ); - } - - - tref->tex_mat = nurbTexMat; - tref->flags |= EFT_TRANSFORM; - - eggNurbsSurf->attrib.SetTRef(tref); - - } - - // if we've encountered textures and we desire duv anims - if (( numNurbTexLoc || numNurbTexGlb ) && make_duv ) - { - int numExp; - - // find how many expressions for this shape - SAA_elementGetNbExpressions( scene, &nurbTex, NULL, FALSE, - &numExp ); - - // if it has expressions we'll assume its animated - if ( numExp ) - { - if ( verbose > 1 ) - printf( "nurbTex has %d expressions...\n", numExp ); - - // if animated object make base duv's, animtables for - // the duv's and store the original offsets - strstream uName, vName; - - // create duv target names - uName << name << ".u" << ends; - vName << name << ".v" << ends; - - // make sure root morph table exists - if ( morphRoot == NULL ) - morphRoot = animData.CreateTable( animRoot, - "morph" ); - - // create morph table entry for each duv - SAnimTable *uTable = new SAnimTable( ); - uTable->name = uName.str(); - uTable->fps = anim_rate; - morphRoot->children.push_back( uTable ); - if ( verbose >= 1 ) - fprintf( outStream, "created duv table named: %s\n", uName.str() ); - - SAnimTable *vTable = new SAnimTable( ); - vTable->name = vName.str(); - vTable->fps = anim_rate; - morphRoot->children.push_back( vTable ); - if ( verbose >= 1 ) - fprintf( outStream, "created duv table named: %s\n", vName.str() ); - - float texOffsets[4]; - - texOffsets[0] = *uOffset; - texOffsets[1] = *vOffset; - texOffsets[2] = *uScale; - texOffsets[3] = *vScale; - - // remember original texture offsets future reference - SAA_elementSetUserData( scene, model, "TEX_OFFSETS", - sizeof( texOffsets ), TRUE, (void **)&texOffsets ); - - // create UV's and duv's for each vertex - for( i = 0; i < numVert; i++ ) - { - pfVec2 tmpUV; - EggMorphOffset *duvU; - EggMorphOffset *duvV; - - // create uv's so we can store duv's - eggNurbsSurf->CalcActualUV( i, tmpUV ); - pool->Vertex(i)->attrib.SetUV( tmpUV[0], tmpUV[1] ); - - // generate base duv's for this vertex - duvU = new EggMorphOffset(uName.str(), 1.0 , 0.0); - pool->Vertex(i)->attrib.uv_morphs.push_back(*duvU); - - duvV = new EggMorphOffset(vName.str(), 0.0 , 1.0); - pool->Vertex(i)->attrib.uv_morphs.push_back(*duvV); - } - - } // if ( numExp ) - } // if ( numTexLoc || numTexGlb ) - - // free( uScale ); free( vScale ); free( uOffset ); free( - // vOffset ); - - // free( materials ); - } - else - { - // no material present - default to white - nurbColor.set( 1.0, 1.0, 1.0, 1.0 ); - } - - // check NURBS surface for trim curves - int numTrims; - bool isTrim = TRUE; - SAA_SubElem *trims; - - SAA_nurbsSurfaceGetNbTrimCurves( scene, model, SAA_TRIMTYPE_TRIM, - &numTrims ); - - if ( verbose >= 1 ) - fprintf( outStream, "nurbs surf has %d trim curves\n", - numTrims ); - - if ( numTrims) - { - trims = (SAA_SubElem *)malloc(sizeof(SAA_SubElem)*numTrims); - - if ( trims ) - { - SAA_nurbsSurfaceGetTrimCurves( scene, model, - gtype, 0, SAA_TRIMTYPE_TRIM, numTrims, - trims ); - - MakeSurfaceCurve( scene, model, parent, eggNurbsSurf, - numTrims, trims, isTrim ); - } - - // free( trims ); - } - - // check NURBS surface for surface curves - isTrim = FALSE; - - SAA_nurbsSurfaceGetNbTrimCurves( scene, model, - SAA_TRIMTYPE_PROJECTION, &numTrims ); - - if ( verbose >= 1 ) - fprintf( outStream, "nurbs surf has %d surface curves\n", - numTrims ); - - if ( numTrims) - { - trims = (SAA_SubElem *)malloc(sizeof(SAA_SubElem)*numTrims); - - if ( trims ) - { - SAA_nurbsSurfaceGetTrimCurves( scene, model, - gtype, 0, SAA_TRIMTYPE_PROJECTION, - numTrims, trims ); - - MakeSurfaceCurve( scene, model, parent, eggNurbsSurf, - numTrims, trims, isTrim ); - } - - // free( trims ); - } - - // push the NURBS into the egg data - parent->children.push_back( eggNurbsSurf ); - - // if model has key shapes, generate vertex offsets - if ( has_morph && make_morph ) - MakeVertexOffsets( scene, model, type, numShapes, numVert, - vertices, matrix, name ); - - - // free( vertices ); - - } - - // check to see if its a NURBS curve - else if ( (type == SAA_MNCRV) && ( visible ) && ( make_nurbs ) ) - { - // ignore for now make the NURBS curve and push it into the egg - // data parent->children.push_back( MakeNurbsCurve( scene, model, - // parent, matrix, name ) ); - } - else if ( type == SAA_MJNT ) - { - MakeJoint( scene, lastJoint, lastAnim, model, name ); - if ( verbose >= 1 ) - fprintf( outStream, "encountered IK joint: %s\n", name ); - } - - // it must be a NULL - else - { - SAA_AlgorithmType algo; - - SAA_modelGetAlgorithm( scene, model, &algo ); - if ( verbose >= 1 ) - fprintf( outStream, "null algorithm: %d\n", algo ); - - if ( algo == SAA_ALG_INV_KIN ) - { - MakeJoint( scene, lastJoint, lastAnim, model, name ); - if ( verbose >= 1 ) - fprintf( outStream, "encountered IK root: %s\n", name ); - } - else if ( algo == SAA_ALG_INV_KIN_LEAF ) - { - MakeJoint( scene, lastJoint, lastAnim, model, name ); - if ( verbose >= 1 ) - fprintf( outStream, "encountered IK leaf: %s\n", name ); - } - else if ( algo == SAA_ALG_STANDARD ) - { - SAA_Boolean isSkeleton = FALSE; - - if ( verbose >= 1 ) - fprintf( outStream, "encountered Standard null: %s\n", name); - - SAA_modelIsSkeleton( scene, model, &isSkeleton ); - - // check to see if this NULL is used as a skeleton or is - // animated via constraint only ( these nodes are tagged by - // the animator with the keyword "joint" somewhere in the - // nodes name) - if ( isSkeleton || (strstr( name, "joint" ) != NULL) ) - { - MakeJoint( scene, lastJoint, lastAnim, model, name ); - if ( verbose >= 1 ) - fprintf( outStream, "animating Standard null!!!\n" ); - } - } - else - if ( verbose >= 1 ) - fprintf( outStream, "encountered some other NULL: %d\n", - algo ); - } - } - - - // check for children... - int numChildren; - int thisChild; - SAA_Elem *children; - - SAA_modelGetNbChildren( scene, model, &numChildren ); - if ( verbose >= 1 ) - fprintf( outStream, "Model children: %d\n", numChildren ); - - if ( numChildren ) - { - children = (SAA_Elem *)malloc(sizeof(SAA_Elem)*numChildren); - SAA_modelGetChildren( scene, model, numChildren, children ); - if ( children != NULL ) - { - for ( thisChild = 0; thisChild < numChildren; thisChild++ ) - { - if ( verbose >= 1 ) - fprintf( outStream, "\negging child %d...\n", thisChild); - MakeEgg( parent, lastJoint, lastAnim, scene, - &children[thisChild] ); - } - } - else - fprintf( outStream, "Not enough Memory for children...\n"); - // free( children ); - } - fflush( outStream ); - } - else - if ( verbose >= 1 ) - fprintf( outStream, "Don't descend this branch!\n" ); - - // we are done for the most part - start cleaning up memory free( name ); -} - - -/** - * Given a scene and lists of u and v samples create a an egg NURBS curve of - * degree two from the samples - */ -void soft2egg:: -MakeSurfaceCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, - EggNurbsSurface *&nurbsSurf, int numTrims, SAA_SubElem *trims, - bool isTrim ) -{ - int i; - long totalSamples = 0; - long *numSamples; - double *uSamples; - double *vSamples; - SAA_Elem *trimCurves; - char *name; - - // get UV coord data - numSamples = (long *)malloc(sizeof(long)*numTrims); - - SAA_surfaceCurveGetNbLinearSamples( scene, model, numTrims, trims, - numSamples ); - - for ( i = 0; i < numTrims; i++ ) - { - totalSamples += numSamples[i]; - if ( verbose >= 2 ) - fprintf( outStream, "numSamples[%d] = %d\n", i, numSamples[i] ); - } - - if ( verbose >= 2 ) - fprintf( outStream, "total samples = %ld\n", totalSamples ); - - uSamples = (double *)malloc(sizeof(double)*totalSamples); - vSamples = (double *)malloc(sizeof(double)*totalSamples); - - SAA_surfaceCurveGetLinearSamples( scene, model, numTrims, trims, - numSamples, uSamples, vSamples ); - - if ( verbose >= 2 ) - for ( long li = 0; li < totalSamples; li++ ) - fprintf( outStream, "master list cv[%ld] = %f, %f\n", li, - uSamples[li], vSamples[li] ); - - trimCurves = (SAA_Elem *)malloc(sizeof(SAA_Elem)*numTrims); - - SAA_surfaceCurveExtract( scene, model, numTrims, trims, trimCurves ); - - // if it's a trim create a trim to assign trim curves to - EggNurbsSurface::Trim *eggTrim = new EggNurbsSurface::Trim(); - - // for each trim curve, make an egg curve and add it to the trims of the - // NURBS surface - for ( i = 0; i < numTrims; i++ ) - { - if ( use_prefix ) - { - // Get the FULL name of the trim curve - name = GetFullName( scene, &trimCurves[i] ); - } - else - { - // Get the name of the trim curve - name = GetName( scene, &trimCurves[i] ); - } - - if ( isTrim ) - { - // add to trim list - EggNurbsSurface::Loop *eggLoop = new EggNurbsSurface::Loop(); - eggLoop->push_back( MakeUVNurbsCurve( i, numSamples, uSamples, - vSamples, parent, name ) ); - eggTrim->push_back( *eggLoop ); - } - else - // add to curve list - nurbsSurf->curves.push_back( MakeUVNurbsCurve( i, numSamples, uSamples, vSamples, parent, name ) ); - } - - if ( isTrim ) - // pus trim list onto trims list - nurbsSurf->trims.push_back( *eggTrim ); - - // free( name ); free( trimCurves ); free( uSamples ); free( vSamples ); -} - -/** - * Given a scene and lists of u and v samples create a an egg NURBS curve of - * degree two from the samples - */ -EggNurbsCurve *soft2egg:: -MakeUVNurbsCurve( int numCurve, long *numSamples, double *uSamples, - double *vSamples, EggGroup *parent, char *name ) -{ - EggNurbsCurve *eggNurbsCurve = new EggNurbsCurve( name ); - - eggNurbsCurve->order = 2; - - - if ( verbose >= 2 ) - fprintf( outStream, "nurbs UV curve %s:\n", name ); - - // set sub_div so we can see it in perfly eggNurbsCurve->subdiv = - // numSamples[numCurve]4; perfly chokes on big numbers - keep it - // reasonable - eggNurbsCurve->subdiv = 150; - - // create pool of NURBS vertices - EggVertexPool *pool = _data.CreateVertexPool( parent, name ); - eggNurbsCurve->SetVertexPool( pool ); - - // calculate offset to this curve's samples in list of all curve samples - int offset = 0; - - for ( int o = 0; o < numCurve; o++ ) - offset += numSamples[o]; - - for ( int k = 0; k= 2 ) - fprintf( outStream, "cv[%d] = %f %f %f\n", k, eggVert[0], - eggVert[1], eggVert[2] ); - - // populate vertex pool - pool->AddVertex( eggVert, k ); - - // add vref's to NURBS info - eggNurbsCurve->AddVertex( k ); - } - - // create numSamples[numCurve]+2 knots - eggNurbsCurve->knots.push_back( 0 ); - for ( k = 0; k < numSamples[numCurve]; k++ ) - eggNurbsCurve->knots.push_back( k ); - eggNurbsCurve->knots.push_back( numSamples[numCurve] - 1 ); - - // set color to bright green for now - EggColor *nurbCref; - pfVec4 nurbColor; - - nurbColor.set( 0.5, 1.0, 0.5, 1.0 ); - nurbCref = _data.CreateColor(nurbColor); - eggNurbsCurve->attrib.SetCRef(nurbCref); - - return( eggNurbsCurve ); -} - -/** - * Given a scene and a NURBS curve model create the the appropriate egg - * structures - */ -EggNurbsCurve *soft2egg:: -MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, - float matrix[4][4], char *name ) -{ - EggNurbsCurve *eggNurbsCurve = new EggNurbsCurve( name ); - int degree; - - if ( verbose >= 2 ) - fprintf( outStream, "nurbs curve %s:\n", name ); - - // create nurbs representation of surface - SAA_nurbsCurveGetDegree( scene, model, °ree ); - eggNurbsCurve->order = degree + 1; - if ( verbose >= 2 ) - fprintf( outStream, "nurbs curve order: %d\n", degree + 1 ); - - SAA_nurbsCurveSetStep( scene, model, nurbs_step ); - - SAA_Boolean closed = FALSE; - - SAA_nurbsCurveGetClosed( scene, model, &closed ); - if ( closed ) - if ( verbose >= 2 ) - fprintf( outStream, "nurbs curve is closed...\n"); - - int numKnots; - - SAA_nurbsCurveGetNbKnots( scene, model, &numKnots ); - if ( verbose >= 2 ) - fprintf( outStream, "nurbs curve knots: %d\n", numKnots ); - double *knots; - knots = (double *)malloc(sizeof(double)*numKnots); - SAA_nurbsCurveGetKnots( scene, model, SAA_GEOM_ORIGINAL, 0, - numKnots, knots ); - - AddKnots( eggNurbsCurve->knots, knots, numKnots, closed, degree ); - - // free( knots ); - - int numCV; - - SAA_modelGetNbVertices( scene, model, &numCV ); - if ( verbose >= 2 ) - fprintf( outStream, "%d CV's (=? %d)\n", numCV, (numKnots-(degree+1)) ); - - // set sub_div so we can see it in perfly - eggNurbsCurve->subdiv = (numCV-1)*nurbs_step; - - // get the CV's - SAA_DVector *cvArray; - cvArray = (SAA_DVector *)malloc(sizeof(SAA_DVector)*numCV); - SAA_modelGetVertices( scene, model, SAA_GEOM_ORIGINAL, 0, - numCV, cvArray ); - - // create pool of NURBS vertices - EggVertexPool *pool = _data.CreateVertexPool( parent, name ); - eggNurbsCurve->SetVertexPool( pool ); - - for ( int k = 0; k= 2 ) - fprintf( outStream, "cv[%d] = %f %f %f %f\n", k, cvArray[k].x, - cvArray[k].y, cvArray[k].z, cvArray[k].w ); - - pfVec4 eggVert; - - // convert to global coords - SAA_DVector local = cvArray[k]; - SAA_DVector global; - - _HVCT_X_MAT( global, local, matrix ); - - eggVert.set( global.x, global.y, global.z, global.w ); - - // populate vertex pool - pool->AddVertex( eggVert, k ); - - // add vref's to NURBS info - eggNurbsCurve->AddVertex( k ); - } - - if ( closed ) - { - // need to replicate first (degree) vertices - for ( k = 0; k < degree; k++ ) - { - eggNurbsCurve->AddVertex( k ); - if ( verbose >= 2 ) - fprintf( outStream, "adding cv[%d] = %f %f %f %f\n", k, - cvArray[k].x, cvArray[k].y, cvArray[k].z, cvArray[k].w ); - } - } - - // free( cvArray ); - - // set color to bright green for now - EggColor *nurbCref; - pfVec4 nurbColor; - - nurbColor.set( 0.5, 1.0, 0.5, 1.0 ); - nurbCref = _data.CreateColor(nurbColor); - eggNurbsCurve->attrib.SetCRef(nurbCref); - - return( eggNurbsCurve ); -} - -/** - * Given a parametric surface, and its knots, create the appropriate egg - * structure by filling in Soft's implicit knots and assigning the rest to - * eggKnots. - */ -void soft2egg:: -AddKnots( perf_vector &eggKnots, double *knots, int numKnots, - SAA_Boolean closed, int degree ) -{ - int k = 0; - double lastKnot = knots[0]; - double *newKnots; - - // add initial implicit knot(s) - if ( closed ) - { - int i = 0; - newKnots = (double *)malloc(sizeof(double)*degree); - - // need to add (degree) number of knots - for ( k = numKnots - 1; k >= numKnots - degree; k-- ) - { - // we have to know these in order to calculate next knot value so - // hold them in temp array - newKnots[i] = lastKnot - (knots[k] - knots[k-1]); - lastKnot = newKnots[i]; - i++; - } - for ( k = degree - 1; k >= 0; k-- ) - { - eggKnots.push_back( newKnots[k] ); - if ( verbose >= 2 ) - fprintf( outStream, "knots[%d] = %f\n", k, newKnots[k] ); - } - - // free( newKnots ); - } - else - { - eggKnots.push_back( knots[k] ); - if ( verbose >= 2 ) - fprintf( outStream, "knots[%d] = %f\n", k, knots[k] ); - } - - // add the regular complement of knots - for (k = 0; k < numKnots; k++) - { - eggKnots.push_back( knots[k] ); - if ( verbose >= 2 ) - fprintf( outStream, "knots[%d] = %f\n", k+1, knots[k] ); - } - - lastKnot = knots[numKnots-1]; - - // add trailing implicit knots - if ( closed ) - { - - // need to add (degree) number of knots - for ( k = 1; k <= degree; k++ ) - { - eggKnots.push_back( lastKnot + (knots[k] - knots[k-1]) ); - if ( verbose >= 2 ) - fprintf( outStream, "knots[%d] = %f\n", k, - lastKnot + (knots[k] - knots[k-1]) ); - lastKnot = lastKnot + (knots[k] - knots[k-1]); - } - } - else - { - eggKnots.push_back( knots[k-1] ); - if ( verbose >= 2 ) - fprintf( outStream, "knots[%d] = %f\n", k+1, knots[k-1] ); - } -} - -/** - * Given a name, a parent and a model create a new a new EggJoint for that - * model. - */ -void soft2egg:: -MakeJoint( SAA_Scene *scene, EggJoint *&lastJoint, AnimGroup *&lastAnim, - SAA_Elem *model, char *name ) -{ - float matrix[4][4]; - pfMatrix Matrix; - EggJoint *joint; - SAA_Boolean globalFlag = FALSE; - int scale_joint = 0; - - - // this is a quick fix to make scaled skeletons possible if the parent - // contains the keyword "scale" make this joint a global root joint - // instead of a child... - if (lastJoint != NULL) - { - if ( strstr( lastJoint->name.Str(), "scale" ) != NULL ) - { - scale_joint = 1; - if ( verbose >= 1 ) - fprintf( outStream, "scale joint flag set!\n" ); - } - } - - // if not root, flatten is false, and last joint had no scaling applied to - // it, then create joint in skeleton tree - if ( (lastJoint != NULL) && !flatten && !scale_joint ) - { - if ( verbose >= 1 ) - { - fprintf( outStream, "lastJoint = %s\n", lastJoint->name.Str() ); - fprintf( outStream, "getting local transform\n" ); - } - - SAA_elementSetUserData( scene, model, "GLOBAL", sizeof( SAA_Boolean ), - TRUE, (void **)&globalFlag ); - - // get the local matrix - SAA_modelGetMatrix( scene, model, SAA_COORDSYS_LOCAL, matrix ); - - // make this into a pfMatrix - Matrix[0][0] = matrix[0][0]; - Matrix[0][1] = matrix[0][1]; - Matrix[0][2] = matrix[0][2]; - Matrix[0][3] = matrix[0][3]; - Matrix[1][0] = matrix[1][0]; - Matrix[1][1] = matrix[1][1]; - Matrix[1][2] = matrix[1][2]; - Matrix[1][3] = matrix[1][3]; - Matrix[2][0] = matrix[2][0]; - Matrix[2][1] = matrix[2][1]; - Matrix[2][2] = matrix[2][2]; - Matrix[2][3] = matrix[2][3]; - Matrix[3][0] = matrix[3][0]; - Matrix[3][1] = matrix[3][1]; - Matrix[3][2] = matrix[3][2]; - Matrix[3][3] = matrix[3][3]; - - joint = _data.CreateJoint( lastJoint, name ); - joint->transform = Matrix; - } - // if we already have a root attach this joint to it - else if (foundRoot) - { - if ( verbose >= 1 ) - fprintf( outStream, "getting global transform\n" ); - - globalFlag = TRUE; - - SAA_elementSetUserData( scene, model, "GLOBAL", sizeof( SAA_Boolean ), - TRUE, (void *)&globalFlag ); - - // get the global matrix - SAA_modelGetMatrix( scene, model, SAA_COORDSYS_GLOBAL, matrix ); - - // make this into a pfMatrix - Matrix[0][0] = matrix[0][0]; - Matrix[0][1] = matrix[0][1]; - Matrix[0][2] = matrix[0][2]; - Matrix[0][3] = matrix[0][3]; - Matrix[1][0] = matrix[1][0]; - Matrix[1][1] = matrix[1][1]; - Matrix[1][2] = matrix[1][2]; - Matrix[1][3] = matrix[1][3]; - Matrix[2][0] = matrix[2][0]; - Matrix[2][1] = matrix[2][1]; - Matrix[2][2] = matrix[2][2]; - Matrix[2][3] = matrix[2][3]; - Matrix[3][0] = matrix[3][0]; - Matrix[3][1] = matrix[3][1]; - Matrix[3][2] = matrix[3][2]; - Matrix[3][3] = matrix[3][3]; - - if ( verbose >= 1 ) - fprintf( outStream, "attaching orphan chain to root\n" ); - - joint = _data.CreateJoint( rootJnt, name ); - joint->transform = Matrix; - lastAnim = rootAnim; - } - // if root, make a seperate tree for skeleton and create required Table - // for the Egg heirarchy - else - { - if ( verbose >= 1 ) - fprintf( outStream, "getting global transform\n" ); - - globalFlag = TRUE; - - SAA_elementSetUserData( scene, model, "GLOBAL", sizeof( SAA_Boolean ), - TRUE, (void *)&globalFlag ); - - // get the global matrix - SAA_modelGetMatrix( scene, model, SAA_COORDSYS_GLOBAL, matrix ); - - // make this into a pfMatrix - Matrix[0][0] = matrix[0][0]; - Matrix[0][1] = matrix[0][1]; - Matrix[0][2] = matrix[0][2]; - Matrix[0][3] = matrix[0][3]; - Matrix[1][0] = matrix[1][0]; - Matrix[1][1] = matrix[1][1]; - Matrix[1][2] = matrix[1][2]; - Matrix[1][3] = matrix[1][3]; - Matrix[2][0] = matrix[2][0]; - Matrix[2][1] = matrix[2][1]; - Matrix[2][2] = matrix[2][2]; - Matrix[2][3] = matrix[2][3]; - Matrix[3][0] = matrix[3][0]; - Matrix[3][1] = matrix[3][1]; - Matrix[3][2] = matrix[3][2]; - Matrix[3][3] = matrix[3][3]; - - rootJnt = _data.CreateJoint( skeleton, "root" ); - rootJnt->transform.makeIdent(); - if ( verbose >= 1 ) - fprintf( outStream, "setting skeleton root\n" ); - rootJnt->flags |= EF_TRANSFORM; - - joint = _data.CreateJoint( rootJnt, name ); - joint->transform = Matrix; - foundRoot = TRUE; - if ( verbose >= 1 ) - fprintf( outStream, "found first chain\n" ); - - // make skeleton table - AnimGroup *skeletonTable; - skeletonTable = animData.CreateTable( animRoot, "" ); - rootAnim = animData.CreateTable( skeletonTable, "root" ); - XfmSAnimTable *table = new XfmSAnimTable( ); - table->name = "xform"; - table->fps = anim_rate; - rootAnim->children.push_back( table ); - lastAnim = rootAnim; - } - - joint->flags |= EF_TRANSFORM; - - // if ( make_anim) { - AnimGroup *anim = animData.CreateTable( lastAnim, name ); - XfmSAnimTable *table = new XfmSAnimTable( ); - if ( verbose >= 1 ) - fprintf( outStream, "created anim table: %s\n", "xform" ); - table->name = "xform"; - table->fps = anim_rate; - anim->children.push_back( table ); - lastAnim = anim; - // } - - // make this joint current parent of chain - lastJoint = joint; -} - - -/** - * Given a skeleton part find its envelopes (if any) get the vertices - * associated with the envelopes and their weights and make vertex ref's for - * the joint - */ -void soft2egg:: -MakeSoftSkin( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, - int numModels, char *name ) -{ - int numEnv; - SAA_ModelType type; - SAA_Elem *envelopes; - - if ( verbose >= 1 ) - fprintf( outStream, "\n>found skeleton part( %s )!\n", name ); - - SAA_skeletonGetNbEnvelopes( scene, model, &numEnv ); - - if ( numEnv ) - { - // it's got envelopes - must be soft skinned - if ( verbose >= 1 ) - fprintf( outStream, "numEnv = %d\n", numEnv ); - - // allocate envelope array - envelopes = ( SAA_Elem *)malloc( sizeof( SAA_Elem )*numEnv ); - - if ( envelopes != NULL ) - { - int thisEnv; - SAA_EnvType envType; - bool hasEnvVertices = 0; - - SAA_skeletonGetEnvelopes( scene, model, numEnv, envelopes ); - - for ( thisEnv = 0; thisEnv < numEnv; thisEnv++ ) - { - if ( verbose >= 1 ) - fprintf( outStream, "env[%d]: ", thisEnv ); - - SAA_envelopeGetType( scene, &envelopes[thisEnv], &envType ); - - if ( envType == SAA_ENVTYPE_NONE ) - { - if ( verbose >= 1 ) - fprintf( outStream, "envType = none\n" ); - } - else if ( envType == SAA_ENVTYPE_FLXLCL ) - { - if ( verbose >= 1 ) - fprintf( outStream, "envType = flexible, local\n" ); - hasEnvVertices = 1; - } - else if ( envType == SAA_ENVTYPE_FLXGLB ) - { - if ( verbose >= 1 ) - fprintf( outStream, "envType = flexible, global\n" ); - hasEnvVertices = 1; - } - else if ( envType == SAA_ENVTYPE_RGDGLB ) - { - if ( verbose >= 1 ) - fprintf( outStream, "envType = rigid, global\n" ); - hasEnvVertices = 1; - } - else - { - if ( verbose >= 1 ) - fprintf( outStream, "envType = unknown\n" ); - } - } - - if ( hasEnvVertices) - { - int *numEnvVertices; - SAA_SubElem *envVertices = NULL; - - numEnvVertices = (int *)malloc(sizeof(int)*numEnv); - - SAA_envelopeGetNbCtrlVertices( scene, model, numEnv, - envelopes, numEnvVertices ); - - if ( numEnvVertices != NULL ) - { - int totalEnvVertices = 0; - int i,j,k; - - for( i = 0; i < numEnv; i++ ) - { - totalEnvVertices += numEnvVertices[i]; - if ( verbose >= 1 ) - fprintf( outStream, "numEnvVertices[%d] = %d\n", - i, numEnvVertices[i] ); - } - - - if ( verbose >= 1 ) - fprintf( outStream, "total env verts = %d\n", - totalEnvVertices ); - - if ( totalEnvVertices ) - { - envVertices = (SAA_SubElem *)malloc(sizeof(SAA_SubElem)*totalEnvVertices); - - if ( envVertices != NULL ) - { - - SAA_envelopeGetCtrlVertices( scene, model, - numEnv, envelopes, numEnvVertices, envVertices); - - // loop through for each envelope - for ( i = 0; i < numEnv; i++ ) - { - float *weights = NULL; - int vertArrayOffset = 0; - - if ( verbose >= 2 ) - fprintf( outStream, "\nenvelope[%d]:\n", i ); - - weights = (float *)malloc(sizeof(float)*numEnvVertices[i]); - - if ( weights ) - { - char *envName; - int *vpoolMap = NULL; - - for ( j = 0; j < i; j++ ) - vertArrayOffset += numEnvVertices[j]; - - if ( verbose >= 1 ) - fprintf( outStream, - "envVertArray offset = %d\n", - vertArrayOffset ); - - // get the weights of the envelope vertices - SAA_ctrlVertexGetEnvelopeWeights( - scene, model, &envelopes[i], - numEnvVertices[i], - &envVertices[vertArrayOffset], weights ); - - // Get the name of the envelope model - if ( use_prefix ) - { - // Get the FULL name of the envelope - envName = GetFullName( scene, &envelopes[i] ); - } - else - { - // Get the name of the envelope - envName = GetName( scene, &envelopes[i] ); - } - - if ( verbose >= 1 ) - fprintf( outStream, "envelope name %s\n", envName ); - - // find out if envelope geometry is poly or nurb - // SAA_modelGetType( scene, FindModelByName( - // envName, scene, models, numModels ), &type ); - - SAA_modelGetType( scene, &envelopes[i], &type ); - - if ( verbose >= 1 ) - { - fprintf( outStream, "envelope model type "); - - if ( type == SAA_MSMSH ) - fprintf( outStream, "MESH\n" ); - else if ( type == SAA_MNSRF ) - fprintf( outStream, "NURBS\n" ); - else - fprintf( outStream, "OTHER\n" ); - } - - int *envVtxIndices = NULL; - envVtxIndices = (int *)malloc(sizeof(int)*numEnvVertices[i]); - - // Get the envelope vertex indices - SAA_ctrlVertexGetIndices( scene, &envelopes[i], numEnvVertices[i], - &envVertices[vertArrayOffset], envVtxIndices ); - - // find out how many vertices the model has - int modelNumVert; - - SAA_modelGetNbVertices( scene, &envelopes[i], &modelNumVert ); - - SAA_DVector *modelVertices = NULL; - modelVertices = (SAA_DVector *)malloc(sizeof(SAA_DVector)*modelNumVert); - - // get the model vertices - SAA_modelGetVertices( scene, &envelopes[i], - SAA_GEOM_ORIGINAL, 0, modelNumVert, - modelVertices ); - - // create array of global model coords - SAA_DVector *globalModelVertices = NULL; - globalModelVertices = (SAA_DVector *)malloc(sizeof(SAA_DVector)*modelNumVert); - float matrix[4][4]; - - // tranform local model vert coords to global - - // first get the global matrix - SAA_modelGetMatrix( scene, &envelopes[i], SAA_COORDSYS_GLOBAL, matrix ); - - // populate array of global model verts - for ( j = 0; j < modelNumVert; j++ ) - { - _VCT_X_MAT( globalModelVertices[j], - modelVertices[j], matrix ); - } - - // find the egg vertex pool that corresponds to - // this envelope model - EggVertexPool *envPool = - (EggVertexPool *)(_data.pools.FindName( envName )); - // If we are outputting triangles: create an array - // that maps from a referenced vertex in the - // envelope to a corresponding vertex in the egg - // vertex pool if ( (type == SAA_MNSRF) && - // !make_nurbs ) - if ( !make_nurbs || (type == SAA_MSMSH) ) - { - vpoolMap = FindClosestTriVert( envPool, - globalModelVertices, modelNumVert ); - } - - - if ( envPool != NULL ) - { - - // find the egg joint that corresponds to this - // model - EggJoint *joint = - (EggJoint *)(skeleton->FindDescendent( name )); - - // this doesn't seem to be necessary 4799 EggJoint - // *parent = (EggJoint *)joint->parent; - // assert(parent->IsA(NT_EggJoint)); - - // for every envelope vertex - for (j = 0; j < numEnvVertices[i]; j++) - { - double scaledWeight = weights[j]/ 100.0f; - - // make sure its in legal range - if (( envVtxIndices[j] < modelNumVert ) - && ( envVtxIndices[j] >= 0 )) - { - if ( (type == SAA_MNSRF) && make_nurbs ) - { - // assign all referenced control vertices - joint->AddVertex( envPool->Vertex(envVtxIndices[j]), scaledWeight ); - - if ( verbose >= 2 ) - fprintf( outStream, - "%d: adding vref to cv %d with weight %f\n", - j, envVtxIndices[j], scaledWeight ); - - envPool->Vertex(envVtxIndices[j])->AddJoint( joint, scaledWeight ); - // set flag to show this vertex has been - // assigned - envPool->Vertex(envVtxIndices[j])->multipleJoints = 1; - } - else - { - // assign all the tri verts associated - // with this control vertex to joint - for ( k = 0; k < envPool->NumVertices(); k++ ) - { - if ( vpoolMap[k] == envVtxIndices[j] ) - { - - // add each vert in pool to last joint - // for soft skinning - joint->AddVertex(envPool->Vertex(k), - scaledWeight); - - if ( verbose >= 2 ) - fprintf( outStream, - "%d: adding vref from cv %d to vert %d with weight %f(vpool)\n", - j, envVtxIndices[j], k, scaledWeight ); - - envPool->Vertex(k)->AddJoint( joint, scaledWeight ); - // set flag to show this vertex has - // been assigned - envPool->Vertex(k)->multipleJoints = 1; - } - } - } - } - else - if ( verbose >= 2 ) - fprintf( outStream, - "%d: Omitted vref from cv %d with weight %f (out of range 0 to %d )\n", - j, envVtxIndices[j], scaledWeight, modelNumVert ); - } - - } - else - if ( verbose >= 2 ) - fprintf( outStream, "Couldn't find vpool %s!\n", envName ); - - // free( modelVertices ); free( - // globalModelVertices ); free( envVtxIndices ); - // free( envName ); - } //if (weights) - // free( weights ); - - } // for i - - } // if (envVertices != NULL) - else - fprintf( outStream, "Not enough memory for envelope vertices...\n"); - // free( envVertices ); - } // if (totalEnvVertices) - else - if ( verbose >= 1 ) - fprintf( outStream, "No envelope vertices present...\n"); - - // free( numEnvVertices ); - - } // if (numEnvVertices != NULL) - - } // if (hasEnvVertices) - - } // if (envelopes != NULL) - else - fprintf( outStream, "Not enough memory for envelopes...\n" ); - - // free( envelopes ); - - } //if (numEnv) - - else - if ( verbose >= 1 ) - fprintf( outStream, "Skeleton member has no envelopes...\n" ); -} - - -/** - * Given a model, make sure all its vertices have been soft assigned. If not - * hard assign to the last joint we saw. - */ -void soft2egg:: -CleanUpSoftSkin( SAA_Scene *scene, SAA_Elem *model, char *name ) -{ - static EggJoint *joint; - SAA_Elem parent; - SAA_ModelType type; - SAA_Boolean skel; - - // find out what type of node we're dealing with - SAA_modelGetType( scene, model, &type ); - - char *parentName; - int level; - SAA_Elem *searchNode = model; - - if ( verbose >= 1 ) - fprintf( outStream, "\nCleaning up model %s\n", name ); - - // this step is weird - I think I want it here but it seems to break some - // models. Files like props-props_wh_cookietime.3-0 in - // fulrndpubvrmlchipchips_adventurecharzone1roomswarehouse_final need to - // do the "if (skel)" bit. - - // am I a skeleton too? - SAA_modelIsSkeleton( scene, model, &skel ); - - // if not look for the last skeleton part - if ( skel ) - parentName = name; - else do - { - SAA_elementGetHierarchyLevel( scene, searchNode, &level ); - - // make sure we don't try to get the root's parent - if ( level ) - { - SAA_modelGetParent( scene, searchNode, &parent ); - - if ( use_prefix ) - { - // Get the FULL name of the parent - parentName = GetFullName( scene, &parent ); - } - else - { - // Get the name of the parent - parentName = GetName( scene, &parent ); - } - - SAA_modelGetType( scene, &parent, &type ); - - SAA_modelIsSkeleton( scene, &parent, &skel ); - - if ( verbose >= 1 ) - fprintf( outStream, "model %s, level %d, type %d, skel %d\n", - parentName, level, type, skel ); - - searchNode = &parent; - } - else - { - // we reached the root of the tree - parentName = NULL; - if ( verbose >= 1 ) - fprintf( outStream, "at root of tree! level %d\n", level ); - break; - } - - // look until parent is a joint or acts like one - } while ( !skel && ( strstr( parentName,"joint") == NULL )); - - EggJoint *thisJoint = NULL; - - if ( parentName != NULL ) - { - if ( verbose >= 1 ) - { - fprintf( outStream, "found model parent joint %s\n", parentName); - fprintf( outStream, "looking for joint %s\n", parentName ); - } - thisJoint = (EggJoint *)(skeleton->FindDescendent( parentName )); - } - else - if ( verbose >= 1 ) - fprintf( outStream, "Couldn't find parent joint!\n"); - - if ( thisJoint != NULL ) - { - joint = thisJoint; - if ( verbose >= 1 ) - fprintf( outStream, "setting joint to %s\n", parentName ); - - // find the vpool for this model - EggVertexPool *vPool = - (EggVertexPool *)(_data.pools.FindName( name )); - - if (vPool != NULL) - { - int i; - double membership; - int numVerts = vPool->NumVertices() ; - - - if ( verbose >= 1 ) - fprintf( outStream, "found vpool %s w/ %d verts\n", - name, numVerts ); - - for ( i = 0; i < numVerts; i++ ) - { - if ( vPool->Vertex(i)->multipleJoints != 1 ) - { - if ( verbose >= 1 ) - { - fprintf( outStream, "vpool %s vert %d", name, i ); - fprintf( outStream, " not assigned!\n" ); - } - - // hard skin this vertex - joint->AddVertex( vPool->Vertex(i), 1.0f ); - } - else - { - membership = vPool->Vertex(i)->NetMembership(); - - - if ( verbose >= 1 ) - { - fprintf( outStream, "vpool %s vert %d", name, - i ); - fprintf( outStream, " has membership %f\n", - membership ); - } - - if ( membership == 0 ) - { - if ( verbose >= 1 ) - fprintf( outStream, "adding full weight..\n" ); - - // hard skin this vertex - joint->AddVertex( vPool->Vertex(i), 1.0f ); - } - } - } - } - else - if ( verbose >= 1 ) - fprintf( outStream, "couldn't find vpool %s\n", name ); - } - else - { - if ( parentName != NULL ) - if ( verbose >= 1 ) - fprintf( outStream, "Couldn't find joint %s\n", parentName ); - } -} - -/** - * Given a scene and a skeleton part ,get all the position, rotation, and - * scale for the skeleton part for this frame and write them out as Egg - * animation tables. - */ -void soft2egg:: -MakeAnimTable( SAA_Scene *scene, SAA_Elem *skeletonPart, char *name ) -{ - - if ( skeletonPart != NULL ) - { - float i,j,k; - float h,p,r; - float x,y,z; - int size; - SAA_Boolean globalFlag = FALSE; - SAA_Boolean bigEndian; - - if ( verbose >= 1 ) - fprintf( outStream, "\n\nanimating child %s\n", name ); - - SAA_elementGetUserDataSize( scene, skeletonPart, "GLOBAL", &size ); - - if ( size != 0 ) - SAA_elementGetUserData( scene, skeletonPart, "GLOBAL", - sizeof( SAA_Boolean), &bigEndian, (void *)&globalFlag ); - - if ( globalFlag ) - { - if ( verbose >= 1 ) - fprintf( outStream, " using global matrix\n" ); - - // get SAA orientation - SAA_modelGetRotation( scene, skeletonPart, SAA_COORDSYS_GLOBAL, - &p, &h, &r ); - - // get SAA translation - SAA_modelGetTranslation( scene, skeletonPart, SAA_COORDSYS_GLOBAL, - &x, &y, &z ); - - // get SAA scaling - SAA_modelGetScaling( scene, skeletonPart, SAA_COORDSYS_GLOBAL, - &i, &j, &k ); - } - else - { - if ( verbose >= 1 ) - fprintf( outStream, "using local matrix\n" ); - - // get SAA orientation - SAA_modelGetRotation( scene, skeletonPart, SAA_COORDSYS_LOCAL, - &p, &h, &r ); - - // get SAA translation - SAA_modelGetTranslation( scene, skeletonPart, SAA_COORDSYS_LOCAL, - &x, &y, &z ); - - // get SAA scaling - SAA_modelGetScaling( scene, skeletonPart, SAA_COORDSYS_LOCAL, - &i, &j, &k ); - } - - - if ( verbose >= 2 ) - fprintf( outStream, "\nanim data: %f %f %f\n\t%f %f %f\n\t%f %f %f\n", - i, j, k, h, p, r, x, y, z ); - - // find the appropriate anim table for this skeleton part - AnimGroup *thisGroup; - XfmSAnimTable *thisTable; - - // find the anim table associated with this group - thisGroup = (AnimGroup *)(animRoot->FindDescendent( name )); - if ( verbose >= 2 ) - fprintf( outStream, "\nlooking for anim group %s\n", name ); - if ( thisGroup != NULL ) - { - thisTable = (XfmSAnimTable *)(thisGroup->FindDescendent( "xform" )); - - if ( thisTable != NULL ) - { - thisTable->sub_tables[0].AddElement( i ); - thisTable->sub_tables[1].AddElement( j ); - thisTable->sub_tables[2].AddElement( k ); - thisTable->sub_tables[3].AddElement( p ); - thisTable->sub_tables[4].AddElement( h ); - thisTable->sub_tables[5].AddElement( r ); - thisTable->sub_tables[6].AddElement( x ); - thisTable->sub_tables[7].AddElement( y ); - thisTable->sub_tables[8].AddElement( z ); - } - else - fprintf( outStream, "Couldn't allocate anim table\n" ); - } - else - if ( verbose >= 2 ) - fprintf( outStream, "Couldn't find anim group %s\n", name ); - } - else - { - if ( verbose >= 2 ) - fprintf( outStream, "Cannot build anim table - no skeleton\n" ); - } -} - -/** - * Given a scene, a model , the vertices of its original shape and its name - * find the difference between the geometry of its key shapes and the models - * original geometry and add morph vertices to the egg data to reflect these - * changes. - */ -void soft2egg:: -MakeVertexOffsets( SAA_Scene *scene, SAA_Elem *model, SAA_ModelType type, - int numShapes, int numOrigVert, SAA_DVector *originalVerts, float - matrix[4][4], char *name ) -{ - int i, j; - int offset; - int numCV; - char *mTableName; - SAA_DVector *shapeVerts = NULL; - SAA_DVector *uniqueVerts = NULL; - - if ( (type == SAA_MNSRF) && make_nurbs ) - SAA_nurbsSurfaceSetStep( scene, model, nurbs_step, nurbs_step ); - - SAA_modelGetNbVertices( scene, model, &numCV ); - - // get the shape verts - uniqueVerts = (SAA_DVector *)malloc(sizeof(SAA_DVector)*numCV); - SAA_modelGetVertices( scene, model, SAA_GEOM_ORIGINAL, 0, - numCV, uniqueVerts ); - - if ( verbose >= 2 ) - fprintf( outStream, "%d CV's\n", numCV ); - - if ( verbose >= 2 ) - { - for ( i = 0; i < numCV; i++ ) - fprintf( outStream, "uniqueVerts[%d] = %f %f %f %f\n", i, - uniqueVerts[i].x, uniqueVerts[i].y, - uniqueVerts[i].z, uniqueVerts[i].w ); - } - - // iterate through for each key shape (except original) - for ( i = 1; i < numShapes; i++ ) - { - mTableName = MakeTableName( name, i ); - - if ( verbose >= 1 ) - { - fprintf( outStream, "\nMaking geometry offsets for %s...\n", - mTableName ); - - if ( (type == SAA_MNSRF) && make_nurbs ) - fprintf( outStream, "calculating NURBS morphs...\n" ); - else - fprintf( outStream, "calculating triangle morphs...\n" ); - } - - // get the shape verts - shapeVerts = (SAA_DVector *)malloc(sizeof(SAA_DVector)*numCV); - SAA_modelGetVertices( scene, model, SAA_GEOM_SHAPE, i+1, - numCV, shapeVerts ); - - if ( verbose >= 2 ) - { - for ( j=0; j < numCV; j++ ) - { - fprintf( outStream, "shapeVerts[%d] = %f %f %f\n", j, - shapeVerts[j].x, shapeVerts[j].y, shapeVerts[j].z ); - } - } - - // find the appropriate vertex pool - EggVertexPool *vPool = - (EggVertexPool *)(_data.pools.FindName( name )); - - // for every original vertex, compare to the corresponding key shape - // vertex and see if a vertex offset is needed - for ( j=0; j < numOrigVert; j++ ) - { - double dx, dy, dz; - - if ( (type == SAA_MNSRF) && make_nurbs ) - { - // dx = shapeVerts[j].x - - // (originalVerts[j].xoriginalVerts[j].w); dy = - // shapeVerts[j].y - (originalVerts[j].yoriginalVerts[j].w); - // dz = shapeVerts[j].z - - // (originalVerts[j].zoriginalVerts[j].w); - dx = shapeVerts[j].x - originalVerts[j].x; - dy = shapeVerts[j].y - originalVerts[j].y; - dz = shapeVerts[j].z - originalVerts[j].z; - } - else - { - // we need to map from original vertices to triangle shape - // vertices here - offset = findShapeVert( originalVerts[j], uniqueVerts, - numCV ); - - dx = shapeVerts[offset].x - originalVerts[j].x; - dy = shapeVerts[offset].y - originalVerts[j].y; - dz = shapeVerts[offset].z - originalVerts[j].z; - } - - if ( verbose >= 2 ) - { - fprintf( outStream, "oVert[%d] = %f %f %f %f\n", j, - originalVerts[j].x, originalVerts[j].y, - originalVerts[j].z, originalVerts[j].w ); - - if ( (type == SAA_MNSRF) && make_nurbs ) - { - fprintf( outStream, "global shapeVerts[%d] = %f %f %f %f\n", j, shapeVerts[j].x, shapeVerts[j].y, - shapeVerts[j].z, shapeVerts[j].w ); - } - else - { - fprintf( outStream, - "global shapeVerts[%d] = %f %f %f\n", offset, - shapeVerts[offset].x, - shapeVerts[offset].y, - shapeVerts[offset].z ); - } - - fprintf( outStream, "%d: dx = %f, dy = %f, dz = %f\n", j, - dx, dy, dz ); - } - - // if change isn't negligible, make a morph vertex entry - double total = fabs(dx)+fabs(dy)+fabs(dz); - if ( total > 0.00001 ) - { - if ( vPool != NULL ) - { - // create offset - EggMorphOffset *dxyz = - new EggMorphOffset( mTableName, dx, dy, dz ); - - EggVertex *eggVert; - - // get the appropriate egg vertex - eggVert = vPool->Vertex(j); - - // add the offset to the vertex - eggVert->morphs.push_back( *dxyz ); - } - else - fprintf( outStream, "Error: couldn't find vertex pool %s\n", name ); - } // if total - } //for j - } //for i -} - - -/** - * Given a scene, a model, a name and a frame time, determine what type of - * shape interpolation is used and call the appropriate function to extract - * the shape weight info for this frame... - */ -void soft2egg:: -MakeMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, - int numModels, char *name, float time ) -{ - int numShapes; - SAA_AnimInterpType type; - - // Get the number of key shapes - SAA_modelGetNbShapes( scene, model, &numShapes ); - - if ( numShapes > 0 ) - { - if ( verbose >= 1 ) - fprintf( outStream, "MakeMorphTable: %s: num shapes: %d\n", - name, numShapes); - - SAA_modelGetShapeInterpolation( scene, model, &type ); - - if ( type == SAA_ANIM_LINEAR || type == SAA_ANIM_CARDINAL ) - { - MakeLinearMorphTable( scene, model, numShapes, name, time ); - } - else // must be weighted... - { - // check first for expressions - MakeExpressionMorphTable( scene, model, models, numModels, - numShapes, name, time ); - } - - } -} - - -/** - * Given a scene, a model, its name, and the time, get the shape fcurve for - * the model and determine the shape weights for the given time and use them - * to populate the morph table. - */ -void soft2egg:: -MakeLinearMorphTable( SAA_Scene *scene, SAA_Elem *model, int numShapes, - char *name, float time ) -{ - int i; - SAA_Elem fcurve; - float curveVal; - SAnimTable *thisTable; - char *tableName; - - if ( verbose >= 1 ) - fprintf( outStream, "linear interp, getting fcurve\n" ); - - SAA_modelFcurveGetShape( scene, model, &fcurve ); - - SAA_fcurveEval( scene, &fcurve, time, &curveVal ); - - if ( verbose >= 2 ) - fprintf( outStream, "at time %f, fcurve for %s = %f\n", time, - name, curveVal ); - - float nextVal = 0.0f; - - // populate morph table values for this frame - for ( i = 1; i < numShapes; i++ ) - { - // derive table name from the model name - tableName = MakeTableName( name, i ); - - if ( verbose >= 2 ) - fprintf( outStream, "Linear: looking for table '%s'\n", tableName ); - - // find the morph table associated with this key shape - thisTable = (SAnimTable *)(morphRoot->FindDescendent( tableName )); - - if ( thisTable != NULL ) - { - if ( i == (int)curveVal ) - { - if ( curveVal - i == 0 ) - { - thisTable->AddElement( 1.0f ); - if ( verbose >= 2 ) - fprintf( outStream, "adding element 1.0f\n" ); - } - else - { - thisTable->AddElement( 1.0f - (curveVal - i) ); - nextVal = curveVal - i; - if ( verbose >= 2 ) - fprintf( outStream, "adding element %f\n", 1.0f - (curveVal - i) ); - } - } - else - { - if ( nextVal ) - { - thisTable->AddElement( nextVal ); - nextVal = 0.0f; - if ( verbose >= 2 ) - fprintf( outStream, "adding element %f\n", nextVal ); - } - else - { - thisTable->AddElement( 0.0f ); - if ( verbose >= 2 ) - fprintf( outStream, "adding element 0.0f\n" ); - } - } - - if ( verbose >= 2 ) - fprintf( outStream, " to '%s'\n", tableName ); - } - else - fprintf( outStream, "%d: Couldn't find table '%s'\n", - i, tableName ); - } - -} - -/** - * Given a scene, a model, a list of all models in the scene, the number of - * models in the scece, the number of key shapes for this model, the name of - * the model and the current time, determine what method of controlling the - * shape weights is used and call the appropriate routine. - */ -void soft2egg:: -MakeWeightedMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, - int numModels, int numShapes, char *name, float time ) -{ - SI_Error result; - SAA_Elem *weightCurves; - float curveVal; - SAnimTable *thisTable; - char *tableName; - - // allocate array of weight curves (one for each shape) - weightCurves = ( SAA_Elem *)malloc( sizeof( SAA_Elem ) * numShapes ); - - result = SAA_modelFcurveGetShapeWeights( - scene, model, numShapes, weightCurves ); - - if ( result == SI_SUCCESS ) - { - for ( int i = 1; i < numShapes; i++ ) - { - SAA_fcurveEval( scene, &weightCurves[i], time, &curveVal ); - - // make sure soft gave us a - // reasonable number - if (!isNum(curveVal)) - curveVal = 0.0f; - - if ( verbose >= 2 ) - fprintf( outStream, "at time %f, weightCurve[%d] for %s = %f\n", time, i, name, curveVal ); - - - // derive table name from the model name - tableName = MakeTableName( name, i ); - - // find and populate shape - // table - if ( verbose >= 2 ) - fprintf( outStream, "Weight: looking for table '%s'\n", - tableName ); - - // find the morph table associated with this key shape - thisTable = (SAnimTable *)(morphRoot->FindDescendent( tableName )); - - if ( thisTable != NULL ) - { - thisTable->AddElement( curveVal ); - if ( verbose >= 2 ) - fprintf( outStream, "adding element %f\n", curveVal ); - } - else - fprintf( outStream, "%d: Couldn't find table '%s'\n", - i, tableName ); - } - } -} - - -/** - * Given a scene, a model and its number of key shapes generate a morph table - * describing transitions btwn the key shapes by evaluating the positions of - * the controlling sliders. - */ -void soft2egg:: -MakeExpressionMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, - int numModels, int numShapes, char *name, float time ) -{ - int j; - SAnimTable *thisTable; - char *tableName; - char *sliderName; - char *track; - int numExp; - SAA_Elem *expressions; - float expVal; - float sliderVal; - - // populate morph table values for this frame - - // compose track name - track = NULL; - - // find how many expressions for this shape - SAA_elementGetNbExpressions( scene, model, track, FALSE, &numExp ); - - if ( verbose >= 2 ) - fprintf( outStream, "%s has %d RHS expressions\n", name, numExp ); - - if ( numExp ) - { - // get the expressions for this shape - expressions = (SAA_Elem *)malloc(sizeof(SAA_Elem)*numExp); - - if ( verbose >= 1 ) - fprintf( outStream, "getting %d RHS expressions...\n", numExp ); - - result = SAA_elementGetExpressions( scene, model, track, FALSE, - numExp, expressions ); - - if ( !result ) - { - for ( j = 1; j < numExp; j++ ) - { - if ( verbose >= 2 ) - { - // debug see what we got - int numvars; - - SAA_expressionGetNbVars( scene, &expressions[j], &numvars ); - - int *varnamelen; - int *varstrlen; - int expstrlen; - - varnamelen = (int *)malloc(sizeof(int)*numvars); - varstrlen = (int *)malloc(sizeof(int)*numvars); - - SAA_expressionGetStringLengths( scene, &expressions[j], - numvars, varnamelen, varstrlen, &expstrlen ); - - int *varnamesizes; - int *varstrsizes; - - varnamesizes = (int *)malloc(sizeof(int)*numvars); - varstrsizes = (int *)malloc(sizeof(int)*numvars); - - for ( int k = 0; k < numvars; k++ ) - { - varnamesizes[k] = varnamelen[k] + 1; - varstrsizes[k] = varstrlen[k] + 1; - } - - int expstrsize = expstrlen + 1; - - char **varnames; - char **varstrs; - - varnames = (char **)malloc(sizeof(char *)*numvars); - varstrs = (char **)malloc(sizeof(char *)*numvars); - - for ( k = 0; k < numvars; k++ ) - { - varnames[k] = (char *)malloc(sizeof(char)* - varnamesizes[k]); - - varstrs[k] = (char *)malloc(sizeof(char)* - varstrsizes[k]); - } - - char *expstr = (char *)malloc(sizeof(char)* expstrsize ); - - SAA_expressionGetStrings( scene, &expressions[j], numvars, - varnamesizes, varstrsizes, expstrsize, varnames, - varstrs, expstr ); - - if ( verbose >= 2 ) - { - fprintf( outStream, "expression = '%s'\n", expstr ); - fprintf( outStream, "has %d variables\n", numvars ); - } - } //if verbose - - if ( verbose >= 2 ) - fprintf( outStream, "evaling expression...\n" ); - - SAA_expressionEval( scene, &expressions[j], time, &expVal ); - - if ( verbose >= 2 ) - fprintf( outStream, "time %f: exp val %f\n", - time, expVal ); - - // derive table name from the model name - tableName = MakeTableName( name, j ); - - if ( verbose >= 2 ) - fprintf( outStream, "Exp: looking for table '%s'\n", - tableName ); - - // find the morph table associated with this key shape - thisTable = (SAnimTable *) - (morphRoot->FindDescendent( tableName )); - - if ( thisTable != NULL ) - { - thisTable->AddElement( expVal ); - if ( verbose >= 1 ) - fprintf( outStream, "%d: adding element %f to %s\n", - j, expVal, tableName ); - fflush( outStream ); - } - else - { - fprintf( outStream, "%d: Couldn't find table '%s'", j, - tableName ); - - fprintf( outStream, " for value %f\n", expVal ); - } - } - } - else - fprintf( outStream, "couldn't get expressions!!!\n" ); - } - else - // no expression, use weight curves - MakeWeightedMorphTable( scene, model, models, numModels, - numShapes, name, time ); - -} - - -/** - * Given a scene, a POLYGON model, and the name of the that model, get the u - * and v offsets for the current frame. - */ -void soft2egg:: -MakeTexAnim( SAA_Scene *scene, SAA_Elem *model, char *modelName ) -{ - if ( verbose >= 1 ) - fprintf( outStream, "\n\nmaking texture animation for %s...\n", - modelName ); - - // get the color of the surface - int numMats; - pfVec4 Color; - SAA_Elem *materials; - void *relinfo; - - SAA_modelRelationGetMatNbElements( scene, model, FALSE, &relinfo, - &numMats ); - - if ( verbose >= 2 ) - fprintf( outStream, "surface has %d materials\n", numMats ); - - if ( numMats ) - { - float r,g,b,a; - - materials = (SAA_Elem *)malloc(sizeof(SAA_Elem)*numMats); - - SAA_modelRelationGetMatElements( scene, model, relinfo, - numMats, materials ); - - SAA_materialGetDiffuse( scene, &materials[0], &r, &g, &b ); - SAA_materialGetTransparency( scene, &materials[0], &a ); - Color.set( r, g, b, 1.0f - a ); - - int numTexLoc = 0; - int numTexGlb = 0; - - // ASSUME only one texture per material - SAA_Elem tex; - - // find out how many local textures per surface ASSUME it only has one - // material - SAA_materialRelationGetT2DLocNbElements( scene, &materials[0], - FALSE, &relinfo, &numTexLoc ); - - // if present, get local textures - if ( numTexLoc ) - { - if ( verbose >= 1 ) - fprintf( outStream, "%s had %d local tex\n", modelName, - numTexLoc ); - - // get the referenced texture - SAA_materialRelationGetT2DLocElements( scene, &materials[0], - TEX_PER_MAT, &tex ); - - } - // if no locals, try to get globals - else - { - SAA_modelRelationGetT2DGlbNbElements( scene, model, - FALSE, &relinfo, &numTexGlb ); - - if ( numTexGlb ) - { - if ( verbose >= 1 ) - fprintf( outStream, "%s had %d global tex\n", modelName, numTexGlb ); - - // get the referenced texture - SAA_modelRelationGetT2DGlbElements( scene, - model, TEX_PER_MAT, &tex ); - } - } - - // add tex ref's if we found any textures - if ( numTexLoc || numTexGlb) - { - char *fullTexName = NULL; - char *texName = NULL; - char *uniqueTexName = NULL; - int texNameLen; - - // get its name - SAA_texture2DGetPicNameLength( scene, &tex, &texNameLen); - fullTexName = (char *)malloc(sizeof(char)*++texNameLen); - SAA_texture2DGetPicName( scene, &tex, texNameLen, - fullTexName ); - - // append unique identifier to texname for this particular object - uniqueTexName = (char *)malloc(sizeof(char)* - (strlen(modelName)+strlen(texName)+3) ); - sprintf( uniqueTexName, "%s-%s", modelName, texName ); - if ( verbose >= 2 ) - fprintf( outStream, "referencing tref %s\n", - uniqueTexName ); - - float uScale; - float vScale; - float uOffset; - float vOffset; - SAA_Boolean uv_swap = FALSE; - - // get texture offset info - SAA_texture2DGetUScale( scene, &tex, &uScale ); - SAA_texture2DGetVScale( scene, &tex, &vScale ); - SAA_texture2DGetUOffset( scene, &tex, &uOffset ); - SAA_texture2DGetVOffset( scene, &tex, &vOffset ); - SAA_texture2DGetUVSwap( scene, &tex, &uv_swap ); - - - if ( verbose >= 2 ) - { - fprintf( outStream, "tex uScale: %f\n", uScale ); - fprintf( outStream, "tex vScale: %f\n", vScale ); - fprintf( outStream, "tex uOffset: %f\n", uOffset ); - fprintf( outStream, "tex vOffset: %f\n", vOffset ); - if ( uv_swap ) - fprintf( outStream, "nurbTex u & v swapped!\n" ); - else - fprintf( outStream, "nurbTex u & v NOT swapped\n" ); - } - - - // find the vpool for this model - EggVertexPool *vPool = - (EggVertexPool *)(_data.pools.FindName( modelName )); - - // if we found the pool - if ( vPool != NULL ) - { - // generate duv's for model - float oldOffsets[4]; - double u, v, du, dv; - int size; - SAA_Boolean bigEndian; - - SAA_elementGetUserDataSize( scene, model, "TEX_OFFSETS", &size ); - - if ( size != 0 ) - { - // remember original texture offsets future reference - SAA_elementGetUserData( scene, model, "TEX_OFFSETS", - size, &bigEndian, (void *)&oldOffsets ); - - // get the original scales and offsets - u = oldOffsets[0]; - v = oldOffsets[1]; - - du = u - uOffset; - dv = v - vOffset; - - if ( verbose >= 1 ) - { - fprintf( outStream, "original u = %f, v = %f\n", - u, v ); - fprintf( outStream, "u = %f, v = %f\n", - uOffset, vOffset ); - fprintf( outStream, "du = %f, dv = %f\n", - du, dv ); - } - - strstream uName, vName; - - // create duv target names - uName << modelName << ".u" << ends; - vName << modelName << ".v" << ends; - - // find the appropriate table to store the duv animation - // info into - SAnimTable *thisTable; - - // find the duv U table associated with this model - thisTable = (SAnimTable *)(morphRoot->FindDescendent( - uName.str() )); - - if ( thisTable != NULL ) - { - thisTable->AddElement( du ); - if ( verbose >= 1 ) - fprintf( outStream, "adding element %f to %s\n", - du, uName.str() ); - } - else - fprintf( outStream, "Couldn't find uTable %s\n", - uName.str() ); - - // find the duv V table associated with this model - thisTable = (SAnimTable *)(morphRoot->FindDescendent( - vName.str() )); - - if ( thisTable != NULL ) - { - thisTable->AddElement( dv ); - if ( verbose >= 1 ) - fprintf( outStream, "adding element %f to %s\n", - dv, uName.str() ); - } - else - fprintf( outStream, "Couldn't find vTable %s\n", - uName.str() ); - } - } - else - if ( verbose >= 2 ) - fprintf( outStream, "Couldn't find vpool %s\n", modelName ); - } - - // free( materials ); - } -} -#endif - -/** - * Instantiate converter and process a file - */ -EXPCL_MISC SI_Error soft2egg(int argc, char *argv[]) { - // pass control to the c++ system - init_soft2egg(argc, argv); - return SI_SUCCESS; -} -#ifdef __cplusplus -} -#endif diff --git a/pandatool/src/softegg/softEggGroupUserData.I b/pandatool/src/softegg/softEggGroupUserData.I deleted file mode 100644 index c6d2a5082c..0000000000 --- a/pandatool/src/softegg/softEggGroupUserData.I +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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." - * - * @file softEggGroupUserData.I - * @author masad - * @date 2003-09-25 - */ - -/** - * - */ -INLINE SoftEggGroupUserData:: -SoftEggGroupUserData() { - _vertex_color = false; - _double_sided = false; -} - - -/** - * - */ -INLINE SoftEggGroupUserData:: -SoftEggGroupUserData(const SoftEggGroupUserData ©) : - EggUserData(copy), - _vertex_color(copy._vertex_color), - _double_sided(copy._double_sided) -{ -} - - -/** - * - */ -INLINE void SoftEggGroupUserData:: -operator = (const SoftEggGroupUserData ©) { - EggUserData::operator = (copy); - _vertex_color = copy._vertex_color; - _double_sided = copy._double_sided; -} diff --git a/pandatool/src/softegg/softEggGroupUserData.cxx b/pandatool/src/softegg/softEggGroupUserData.cxx deleted file mode 100644 index 1705b2b285..0000000000 --- a/pandatool/src/softegg/softEggGroupUserData.cxx +++ /dev/null @@ -1,16 +0,0 @@ -/** - * 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." - * - * @file softEggGroupUserData.cxx - * @author masad - * @date 2003-09-25 - */ - -#include "softEggGroupUserData.h" - -TypeHandle SoftEggGroupUserData::_type_handle; diff --git a/pandatool/src/softegg/softEggGroupUserData.h b/pandatool/src/softegg/softEggGroupUserData.h deleted file mode 100644 index b8aa6ca892..0000000000 --- a/pandatool/src/softegg/softEggGroupUserData.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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." - * - * @file softEggGroupUserData.h - * @author masad - * @date 2003-09-25 - */ - -#ifndef SOFTEGGGROUPUSERDATA_H -#define SOFTEGGGROUPUSERDATA_H - -#include "pandatoolbase.h" -#include "eggUserData.h" - -/** - * This class contains extra user data which is piggybacked onto EggGroup - * objects for the purpose of the softimage converter. - */ -class SoftEggGroupUserData : public EggUserData { -public: - INLINE SoftEggGroupUserData(); - INLINE SoftEggGroupUserData(const SoftEggGroupUserData ©); - INLINE void operator = (const SoftEggGroupUserData ©); - - bool _vertex_color; - bool _double_sided; - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - EggUserData::init_type(); - register_type(_type_handle, "SoftEggGroupUserData", - EggUserData::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -#include "softEggGroupUserData.I" - -#endif diff --git a/pandatool/src/softegg/softNodeDesc.cxx b/pandatool/src/softegg/softNodeDesc.cxx deleted file mode 100644 index ff0f624a20..0000000000 --- a/pandatool/src/softegg/softNodeDesc.cxx +++ /dev/null @@ -1,1310 +0,0 @@ -/** - * 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." - * - * @file softNodeDesc.cxx - * @author masad - * @date 2003-10-03 - */ - -#include "softNodeDesc.h" -#include "config_softegg.h" -#include "eggGroup.h" -#include "eggXfmSAnim.h" -#include "eggSAnimData.h" -#include "softToEggConverter.h" -#include "dcast.h" - -using std::endl; - -TypeHandle SoftNodeDesc::_type_handle; - -/** - * - */ -SoftNodeDesc:: -SoftNodeDesc(SoftNodeDesc *parent, const std::string &name) : - Namable(name), - _parent(parent) -{ - _model = nullptr; - _egg_group = nullptr; - _egg_table = nullptr; - _anim = nullptr; - _joint_type = JT_none; - - // Add ourselves to our parent. - if (_parent != nullptr) { - softegg_cat.spam() << "parent name " << _parent->get_name(); - _parent->_children.push_back(this); - } - - // set the _parentJoint to Null - _parentJoint = nullptr; - - fullname = nullptr; - - numTexLoc = 0; - numTexGlb = 0; - - uScale = nullptr; - vScale = nullptr; - uOffset = nullptr; - vOffset = nullptr; - - valid; - uv_swap; - // SAA_Boolean visible; - numTexTri = nullptr; - textures = nullptr; - materials = nullptr; - triangles = nullptr; - gtype = SAA_GEOM_ORIGINAL; -} - -/** - * - */ -SoftNodeDesc:: -~SoftNodeDesc() { - // I think it is a mistake to try to delete this. This was one member of an - // entire array allocated at once; you can't delete individual elements of - // an array. - - // Screw cleanup, anyway--we'll just let the array leak. - /* - if (_model != (SAA_Elem *)NULL) { - delete _model; - } - */ -} - -/** - * Indicates an associated between the SoftNodeDesc and some SAA_Elem - * instance. - */ -void SoftNodeDesc:: -set_model(SAA_Elem *model) { - _model = model; -} - -/** - * Sometimes, parent is not known at node creation As soon as it is known, set - * the parent - */ -void SoftNodeDesc:: -set_parent(SoftNodeDesc *parent) { - if (_parent) { - softegg_cat.spam() << endl; - /* - softegg_cat.spam() << " expected _parent to be null!?\n"; - if (_parent == parent) - softegg_cat.spam() << " parent already set\n"; - else { - softegg_cat.spam() << " current parent " << _parent->get_name() << " new parent " - << parent << endl; - } - */ - return; - } - _parent = parent; - softegg_cat.spam() << " set parent to " << _parent->get_name() << endl; - - // Add ourselves to our parent. - _parent->_children.push_back(this); -} - -/** - * Sometimes, parent is not known at node creation As soon as it is known, set - * the parent - */ -void SoftNodeDesc:: -force_set_parent(SoftNodeDesc *parent) { - if (_parent) - softegg_cat.spam() << " current parent " << _parent->get_name(); - - _parent = parent; - - if (_parent) - softegg_cat.spam() << " new parent " << _parent->get_name() << endl; - - // Add ourselves to our parent. - _parent->_children.push_back(this); -} - -/** - * Returns true if a Soft dag path has been associated with this node, false - * otherwise. - */ -bool SoftNodeDesc:: -has_model() const { - return (_model != nullptr); -} - -/** - * Returns the SAA_Elem * associated with this node. It is an error to call - * this unless has_model() returned true. - */ -SAA_Elem *SoftNodeDesc:: -get_model() const { - nassertr(_model != nullptr, _model); - return _model; -} - -/** - * Returns true if the node should be treated as a joint by the converter. - */ -bool SoftNodeDesc:: -is_joint() const { - // return _joint_type == JT_joint || _joint_type == JT_pseudo_joint; - return _joint_type == JT_joint; -} - -/** - * Returns true if the node should be treated as a junk by the converter. - */ -bool SoftNodeDesc:: -is_junk() const { - return _joint_type == JT_junk; -} - -/** - * sets the _joint_type to JT_joint - */ -void SoftNodeDesc:: -set_joint() { - _joint_type = JT_joint; -} -/** - * Returns true if the node is the parent or ancestor of a joint. - */ -bool SoftNodeDesc:: -is_joint_parent() const { - return _joint_type == JT_joint_parent; -} - -/** - * Recursively clears the egg pointers from this node and all children. - */ -void SoftNodeDesc:: -clear_egg() { - _egg_group = nullptr; - _egg_table = nullptr; - _anim = nullptr; - - Children::const_iterator ci; - for (ci = _children.begin(); ci != _children.end(); ++ci) { - SoftNodeDesc *child = (*ci); - child->clear_egg(); - } -} - -/** - * Indicates that this node has at least one child that is a joint or a - * pseudo-joint. - */ -void SoftNodeDesc:: -mark_joint_parent() { - if (_joint_type == JT_none) { - _joint_type = JT_joint_parent; - softegg_cat.spam() << " marked parent " << get_name(); - } - else - softegg_cat.spam() << " ?parent " << get_name() << " joint type " << _joint_type; - - if (_parent != nullptr) { - _parent->mark_joint_parent(); - } - softegg_cat.spam() << endl; -} - -/** - * Walks the hierarchy, if a node is joint, make sure all its parents are - * marked JT_joint_parent - */ -void SoftNodeDesc:: -check_joint_parent() { - Children::const_iterator ci; - for (ci = _children.begin(); ci != _children.end(); ++ci) { - SoftNodeDesc *child = (*ci); - if (child->is_joint()) { - softegg_cat.spam() << "child " << child->get_name(); - mark_joint_parent(); - } - child->check_joint_parent(); - } -} - -/** - * check to see if this is a branch we don't want to descend - this will - * prevent creating geometry for animation control structures - */ -void SoftNodeDesc:: -check_junk(bool parent_junk) { - const char *name = get_name().c_str(); - - if (parent_junk) { - _joint_type = JT_junk; - softegg_cat.spam() << "junk node " << get_name() << endl; - } - if ( (strstr(name, "con-") != nullptr) || - (strstr(name, "con_") != nullptr) || - (strstr(name, "fly_") != nullptr) || - (strstr(name, "fly-") != nullptr) || - (strstr(name, "camRIG") != nullptr) || - (strstr(name, "cam_rig") != nullptr) || - (strstr(name, "bars") != nullptr) ) - { - _joint_type = JT_junk; - softegg_cat.spam() << "junk node " << get_name() << endl; - parent_junk = true; - Children::const_iterator ci; - for (ci = _children.begin(); ci != _children.end(); ++ci) { - SoftNodeDesc *child = (*ci); - softegg_cat.spam() << child->get_name() << ","; - } - softegg_cat.spam() << endl; - } - Children::const_iterator ci; - for (ci = _children.begin(); ci != _children.end(); ++ci) { - SoftNodeDesc *child = (*ci); - child->check_junk(parent_junk); - } -} - -/** - * check to see if this is a selected branch we want to descend - this will - * prevent creating geometry for other parts - */ -bool SoftNodeDesc:: -is_partial(char *search_prefix) { - const char *name = fullname; - - // if no search prefix then return false - if (!search_prefix) - return false; - // if name is search_prefix, return false - if (strstr(name, search_prefix) != nullptr) { - softegg_cat.debug() << "matched " << name << " "; - return false; - } - // if name is not search_prefix, look in its parent - if (strstr(name, search_prefix) == nullptr) { - softegg_cat.debug() << "node " << name << " "; - if (_parent) - return _parent->is_partial(search_prefix); - } - // neither name nor its parent is search_prefix - return true; -} - -/** - * Go through the ancestors and figure out who is the immediate _parentJoint - * of this node - */ -void SoftNodeDesc:: -set_parentJoint(SAA_Scene *scene, SoftNodeDesc *lastJoint) { - if (is_junk()) - return; - // set its parent joint to the lastJoint - _parentJoint = lastJoint; - softegg_cat.spam() << get_name() << ": parent joint set to :" << lastJoint; - if (lastJoint) - softegg_cat.spam() << "(" << lastJoint->get_name() << ")"; - softegg_cat.spam() << endl; - - // is this node a joint? - SAA_Boolean isSkeleton = false; - if (has_model()) - SAA_modelIsSkeleton( scene, get_model(), &isSkeleton ); - - // if already a joint or name has "joint" in it - const char *name = get_name().c_str(); - if (is_joint() || isSkeleton || strstr(name, "joint") != nullptr) { - lastJoint = this; - } - if ( _parentJoint && strstr( _parentJoint->get_name().c_str(), "scale" ) != nullptr ) { - // make sure _parentJoint didn't have the name "joint" in it - if (strstr(_parentJoint->get_name().c_str(), "joint") == nullptr) { - _parentJoint = nullptr; - // _parentJoint = lastJoint = NULL; - softegg_cat.spam() << "scale joint flag set!\n"; - } - } - - // look in the children - Children::const_iterator ci; - for (ci = _children.begin(); ci != _children.end(); ++ci) { - SoftNodeDesc *child = (*ci); - child->set_parentJoint(scene, lastJoint); - } -} - -/** - * Walks the hierarchy, looking for non-joint nodes that are both children and - * parents of a joint. These nodes are deemed to be pseudo joints, since the - * converter must treat them as joints. - */ -void SoftNodeDesc:: -check_pseudo_joints(bool joint_above) { - if (_joint_type == JT_joint_parent && joint_above) { - // This is one such node: it is the parent of a joint (JT_joint_parent is - // set), and it is the child of a joint (joint_above is set). - _joint_type = JT_pseudo_joint; - softegg_cat.debug() << "pseudo " << get_name() << " case1\n"; - } - - if (_joint_type == JT_joint) { - // If this node is itself a joint, then joint_above is true for all child - // nodes. - joint_above = true; - } - - // Don't bother traversing further if _joint_type is none or junk, since - // that means this node has no joint children. - if (_joint_type != JT_none && _joint_type != JT_junk) { - - bool any_joints = false; - Children::const_iterator ci; - for (ci = _children.begin(); ci != _children.end(); ++ci) { - SoftNodeDesc *child = (*ci); - child->check_pseudo_joints(joint_above); - if (child->is_joint()) { - softegg_cat.spam() << get_name() << " any_joint true by " << child->get_name() << endl; - any_joints = true; - } - } - - // If any children qualify as joints, then any sibling nodes that are - // parents of joints are also elevated to joints. - if (any_joints) { - bool all_joints = true; - for (ci = _children.begin(); ci != _children.end(); ++ci) { - SoftNodeDesc *child = (*ci); - if (child->_joint_type == JT_joint_parent) { - child->_joint_type = JT_pseudo_joint; - softegg_cat.debug() << "pseudo " << child->get_name() << " case2 by parent " << get_name() << "\n"; - } else if (child->_joint_type == JT_none || child->_joint_type == JT_junk) { - all_joints = false; - } - } - - if (all_joints || any_joints) { - // Finally, if all children or at least one is a joint, then we are - // too. - if (_joint_type == JT_joint_parent) { - _joint_type = JT_pseudo_joint; - softegg_cat.debug() << "pseudo " << get_name() << " case3\n"; - } - } - } - } - else - softegg_cat.spam() << "found null joint " << get_name() << endl; -} - -/** - * Extracts the transform on the indicated Soft node, and applies it to the - * corresponding Egg node. - */ -void SoftNodeDesc:: -get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global) { - // Get the model's matrix - int scale_joint = 0; - - if (!global && _parentJoint && !stec.flatten && !scale_joint) { - - SAA_modelGetMatrix( scene, get_model(), SAA_COORDSYS_LOCAL, matrix ); - softegg_cat.debug() << get_name() << " using local matrix :parent "; - - } else { - - SAA_modelGetMatrix( scene, get_model(), SAA_COORDSYS_GLOBAL, matrix ); - softegg_cat.debug() << get_name() << " using global matrix :parent "; - - } - - if (_parentJoint && !stec.flatten) - softegg_cat.debug() << _parentJoint->get_name() << endl; - else - softegg_cat.debug() << _parentJoint << endl; - - - softegg_cat.spam() << "model matrix = " << matrix[0][0] << " " << matrix[0][1] << " " << matrix[0][2] << " " << matrix[0][3] << "\n"; - softegg_cat.spam() << "model matrix = " << matrix[1][0] << " " << matrix[1][1] << " " << matrix[1][2] << " " << matrix[1][3] << "\n"; - softegg_cat.spam() << "model matrix = " << matrix[2][0] << " " << matrix[2][1] << " " << matrix[2][2] << " " << matrix[2][3] << "\n"; - softegg_cat.spam() << "model matrix = " << matrix[3][0] << " " << matrix[3][1] << " " << matrix[3][2] << " " << matrix[3][3] << "\n"; - - if (!global && is_joint()) { - LMatrix4d m4d(matrix[0][0], matrix[0][1], matrix[0][2], matrix[0][3], - matrix[1][0], matrix[1][1], matrix[1][2], matrix[1][3], - matrix[2][0], matrix[2][1], matrix[2][2], matrix[2][3], - matrix[3][0], matrix[3][1], matrix[3][2], matrix[3][3]); - if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) { - egg_group->set_transform3d(m4d); - softegg_cat.spam() << "set transform in egg_group\n"; - } - } - return; -} - -/** - * Extracts the transform on the indicated Soft node, as appropriate for a - * joint in an animated character, and applies it to the indicated node. This - * is different from get_transform() in that it does not respect the - * _transform_type flag, and it does not consider the relative transforms - * within the egg file. more added functionality: now fills in components of - * anim (EffXfmSAnim) class (masad). - */ -void SoftNodeDesc:: -get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, bool global) { - // SI_Error result; - SAA_Elem *skeletonPart = _model; - const char *name = get_name().c_str(); - - if ( skeletonPart != nullptr ) { - PN_stdfloat i,j,k; - PN_stdfloat h,p,r; - PN_stdfloat x,y,z; - int scale_joint = 0; - - softegg_cat.spam() << "\n\nanimating child " << name << endl; - - if (_parentJoint && !stec.flatten && !scale_joint ) { - softegg_cat.debug() << "using local matrix\n"; - - // get SAA orientation - SAA_modelGetRotation( scene, skeletonPart, SAA_COORDSYS_LOCAL, - &p, &h, &r ); - - // get SAA translation - SAA_modelGetTranslation( scene, skeletonPart, SAA_COORDSYS_LOCAL, - &x, &y, &z ); - - // get SAA scaling - SAA_modelGetScaling( scene, skeletonPart, SAA_COORDSYS_LOCAL, - &i, &j, &k ); - } else { - softegg_cat.debug() << " using global matrix\n"; - - // get SAA orientation - SAA_modelGetRotation( scene, skeletonPart, SAA_COORDSYS_GLOBAL, - &p, &h, &r ); - - // get SAA translation - SAA_modelGetTranslation( scene, skeletonPart, SAA_COORDSYS_GLOBAL, - &x, &y, &z ); - - // get SAA scaling - SAA_modelGetScaling( scene, skeletonPart, SAA_COORDSYS_GLOBAL, - &i, &j, &k ); - } - - softegg_cat.spam() << "\nanim data: " << i << " " << j << " " << k << endl; - softegg_cat.spam() << "\t" << p << " " << h << " " << r << endl; - softegg_cat.spam() << "\t" << x << " " << y << " " << z << endl; - - // Encode the component multiplication ordering in the egg file. - // SoftImage always uses this order, regardless of the setting of temp- - // hpr-fix. - anim->set_order("sphrt"); - - // Add each component by their names - anim->add_component_data("i", i); - anim->add_component_data("j", j); - anim->add_component_data("k", k); - anim->add_component_data("p", p); - anim->add_component_data("h", h); - anim->add_component_data("r", r); - anim->add_component_data("x", x); - anim->add_component_data("y", y); - anim->add_component_data("z", z); - } - else { - softegg_cat.debug() << "Cannot build anim table - no skeleton\n"; - } -} - -/** - * Converts the indicated Soft polyset to a bunch of EggPolygons and parents - * them to the indicated egg group. - */ -void SoftNodeDesc:: -load_poly_model(SAA_Scene *scene, SAA_ModelType type) { - SI_Error result; - const char *name = get_name().c_str(); - - int i; - int id = 0; - - // if making a pose - get deformed geometry - if ( stec.make_pose ) - gtype = SAA_GEOM_DEFORMED; - - // If the model is a PATCH in soft, set its step before tesselating - else if ( type == SAA_MPTCH ) - SAA_patchSetStep( scene, _model, stec.nurbs_step, stec.nurbs_step ); - - // Get the number of triangles - result = SAA_modelGetNbTriangles( scene, _model, gtype, id, &numTri); - softegg_cat.spam() << "triangles: " << numTri << "\n"; - - if ( result != SI_SUCCESS ) { - softegg_cat.spam() << "Error: couldn't get number of triangles!\n"; - softegg_cat.debug() << "\tbailing on model: " << name << "\n"; - return; - } - - // check to see if surface is also skeleton... - SAA_Boolean isSkeleton = FALSE; - - SAA_modelIsSkeleton( scene, _model, &isSkeleton ); - - // check to see if this surface is used as a skeleton or is animated via - // constraint only ( these nodes are tagged by the animator with the keyword - // "joint" somewhere in the nodes name) - softegg_cat.spam() << "is Skeleton? " << isSkeleton << "\n"; - - /*************************************************************************************/ - - // model is not a null and has no triangles! - if ( !numTri ) { - softegg_cat.spam() << "no triangles!\n"; - } - else { - // allocate array of triangles - triangles = (SAA_SubElem *) new SAA_SubElem[numTri]; - if (!triangles) { - softegg_cat.info() << "Not enough Memory for triangles...\n"; - exit(1); - } - // triangulate model and read the triangles into array - SAA_modelGetTriangles( scene, _model, gtype, id, numTri, triangles ); - softegg_cat.spam() << "got triangles\n"; - - /***********************************************************************************/ - - // allocate array of materials (Asad: it gives a warning if try to get one - // triangle at a time...investigate later read each triangle's material - // into array - materials = (SAA_Elem*) new SAA_Elem[numTri]; - SAA_triangleGetMaterials( scene, _model, numTri, triangles, materials ); - if (!materials) { - softegg_cat.info() << "Not enough Memory for materials...\n"; - exit(1); - } - softegg_cat.spam() << "got materials\n"; - - /***********************************************************************************/ - - // allocate array of textures per triangle - numTexTri = new int[numTri]; - const void *relinfo; - - // find out how many local textures per triangle - for (i = 0; i < numTri; i++) { - result = SAA_materialRelationGetT2DLocNbElements( scene, &materials[i], FALSE, - &relinfo, &numTexTri[i] ); - // polytex - if ( result == SI_SUCCESS ) - numTexLoc += numTexTri[i]; - } - - // don't need this anymore... free( numTexTri ); - - // get local textures if present - if ( numTexLoc ) { - softegg_cat.spam() << "numTexLoc = " << numTexLoc << endl; - - // allocate arrays of texture info - uScale = new PN_stdfloat[numTri]; - vScale = new PN_stdfloat[numTri]; - uOffset = new PN_stdfloat[numTri]; - vOffset = new PN_stdfloat[numTri]; - texNameArray = new char *[numTri]; - uRepeat = new int[numTri]; - vRepeat = new int[numTri]; - - // ASSUME only one texture per material - textures = new SAA_Elem[numTri]; - - for ( i = 0; i < numTri; i++ ) { - // and read all referenced local textures into array - SAA_materialRelationGetT2DLocElements( scene, &materials[i], - TEX_PER_MAT , &textures[i] ); - - // initialize the array value - texNameArray[i] = nullptr; - // initialize the repeats - uRepeat[i] = vRepeat[i] = 0; - - // see if this triangle has texture info - if (numTexTri[i] == 0) - continue; - - // check to see if texture is present - result = SAA_elementIsValid( scene, &textures[i], &valid ); - - if ( result != SI_SUCCESS ) - softegg_cat.spam() << "SAA_elementIsValid failed!!!!\n"; - - // texture present - get the name and uv info - if ( valid ) { - // according to drose, we don't need to convert .pic files to .rgb, - // panda can now read the .pic files. - texNameArray[i] = stec.GetTextureName(scene, &textures[i]); - - softegg_cat.spam() << " tritex[" << i << "] named: " << texNameArray[i] << endl; - - SAA_texture2DGetUVSwap( scene, &textures[i], &uv_swap ); - - if ( uv_swap == TRUE ) - softegg_cat.spam() << " swapping u and v...\n" ; - - SAA_texture2DGetUScale( scene, &textures[i], &uScale[i] ); - SAA_texture2DGetVScale( scene, &textures[i], &vScale[i] ); - SAA_texture2DGetUOffset( scene, &textures[i], &uOffset[i] ); - SAA_texture2DGetVOffset( scene, &textures[i], &vOffset[i] ); - - softegg_cat.spam() << "tritex[" << i << "] uScale: " << uScale[i] << " vScale: " << vScale[i] << endl; - softegg_cat.spam() << " uOffset: " << uOffset[i] << " vOffset: " << vOffset[i] << endl; - - SAA_texture2DGetRepeats( scene, &textures[i], &uRepeat[i], &vRepeat[i] ); - softegg_cat.spam() << "uRepeat = " << uRepeat[i] << ", vRepeat = " << vRepeat[i] << endl; - } - else { - softegg_cat.spam() << "Invalid texture...\n"; - softegg_cat.spam() << " tritex[" << i << "] named: (null)\n"; - } - } - } - else { // if no local textures, try to get global textures - SAA_modelRelationGetT2DGlbNbElements( scene, _model, - FALSE, &relinfo, &numTexGlb ); - if ( numTexGlb ) { - // ASSUME only one texture per model - textures = new SAA_Elem; - // get the referenced texture - SAA_modelRelationGetT2DGlbElements( scene, _model, - TEX_PER_MAT, textures ); - softegg_cat.spam() << "numTexGlb = " << numTexGlb << endl; - // check to see if texture is present - SAA_elementIsValid( scene, textures, &valid ); - if ( valid ) { // texture present - get the name and uv info - SAA_texture2DGetUVSwap( scene, textures, &uv_swap ); - - if ( uv_swap == TRUE ) - softegg_cat.spam() << " swapping u and v...\n"; - - // according to drose, we don't need to convert .pic files to .rgb, - // panda can now read the .pic files. - texNameArray = new char *[1]; - *texNameArray = stec.GetTextureName(scene, textures); - - uRepeat = new int; - vRepeat = new int; - - softegg_cat.spam() << " global tex named: " << *texNameArray << endl; - - // allocate arrays of texture info - uScale = new PN_stdfloat; - vScale = new PN_stdfloat; - uOffset = new PN_stdfloat; - vOffset = new PN_stdfloat; - - SAA_texture2DGetUScale( scene, textures, uScale ); - SAA_texture2DGetVScale( scene, textures, vScale ); - SAA_texture2DGetUOffset( scene, textures, uOffset ); - SAA_texture2DGetVOffset( scene, textures, vOffset ); - - softegg_cat.spam() << " global tex uScale: " << *uScale << " vScale: " << *vScale << endl; - softegg_cat.spam() << " uOffset: " << *uOffset << " vOffset: " << *vOffset << endl; - - SAA_texture2DGetRepeats( scene, textures, uRepeat, vRepeat ); - softegg_cat.spam() << "uRepeat = " << *uRepeat << ", vRepeat = " << *vRepeat << endl; - } - else { - softegg_cat.spam() << "Invalid Texture...\n"; - } - } - } - } - softegg_cat.spam() << "got textures" << endl; -} - -/** - * Converts the indicated Soft polyset to a bunch of EggPolygons and parents - * them to the indicated egg group. - */ -void SoftNodeDesc:: -load_nurbs_model(SAA_Scene *scene, SAA_ModelType type) { - SI_Error result; - const char *name = get_name().c_str(); - - // if making a pose - get deformed geometry - if ( stec.make_pose ) - gtype = SAA_GEOM_DEFORMED; - - // If the model is a NURBS in soft, set its step before tesselating - if ( type == SAA_MNSRF ) - SAA_nurbsSurfaceSetStep( scene, _model, stec.nurbs_step, stec.nurbs_step ); - - // get the materials - /***********************************************************************************/ - const void *relinfo; - - SAA_modelRelationGetMatNbElements( scene, get_model(), FALSE, &relinfo, - &numNurbMats ); - - softegg_cat.spam() << "nurbs surf has " << numNurbMats << " materials\n"; - - if ( numNurbMats ) { - materials = new SAA_Elem[numNurbMats]; - if (!materials) { - softegg_cat.info() << "Out Of Memory on allocating materials\n"; - exit(1); - } - - SAA_modelRelationGetMatElements( scene, get_model(), relinfo, - numNurbMats, materials ); - - softegg_cat.spam() << "got materials\n"; - - // get the textures - /***********************************************************************************/ - numNurbTexLoc = 0; - numNurbTexGlb = 0; - - // find out how many local textures per NURBS surface ASSUME it only has - // one material - SAA_materialRelationGetT2DLocNbElements( scene, &materials[0], FALSE, &relinfo, &numNurbTexLoc ); - - // if present, get local textures - if ( numNurbTexLoc ) { - softegg_cat.spam() << name << " had " << numNurbTexLoc << " local tex\n"; - nassertv(numNurbTexLoc == 1); - - textures = new SAA_Elem[numNurbTexLoc]; - - // get the referenced texture - SAA_materialRelationGetT2DLocElements( scene, &materials[0], TEX_PER_MAT, &textures[0] ); - - } - // if no locals, try to get globals - else { - SAA_modelRelationGetT2DGlbNbElements( scene, get_model(), FALSE, &relinfo, &numNurbTexGlb ); - - if ( numNurbTexGlb ) { - softegg_cat.spam() << name << " had " << numNurbTexGlb << " global tex\n"; - nassertv(numNurbTexGlb == 1); - - textures = new SAA_Elem[numNurbTexGlb]; - - // get the referenced texture - SAA_modelRelationGetT2DGlbElements( scene, get_model(), TEX_PER_MAT, &textures[0] ); - } - } - - if ( numNurbTexLoc || numNurbTexGlb) { - - // allocate the texture name array - texNameArray = new char *[1]; - // allocate arrays of texture info - uScale = new PN_stdfloat; - vScale = new PN_stdfloat; - uOffset = new PN_stdfloat; - vOffset = new PN_stdfloat; - uRepeat = new int; - vRepeat = new int; - - // check to see if texture is present - result = SAA_elementIsValid( scene, &textures[0], &valid ); - - if ( result != SI_SUCCESS ) - softegg_cat.spam() << "SAA_elementIsValid failed!!!!\n"; - - // texture present - get the name and uv info - if ( valid ) { - // according to drose, we don't need to convert .pic files to .rgb, - // panda can now read the .pic files. - texNameArray[0] = stec.GetTextureName(scene, &textures[0]); - - softegg_cat.spam() << " tritex[0] named: " << texNameArray[0] << endl; - - SAA_texture2DGetUVSwap( scene, &textures[0], &uv_swap ); - - if ( uv_swap == TRUE ) - softegg_cat.spam() << " swapping u and v...\n" ; - - SAA_texture2DGetUScale( scene, &textures[0], uScale ); - SAA_texture2DGetVScale( scene, &textures[0], vScale ); - SAA_texture2DGetUOffset( scene, &textures[0], uOffset ); - SAA_texture2DGetVOffset( scene, &textures[0], vOffset ); - - softegg_cat.spam() << "tritex[0] uScale: " << *uScale << " vScale: " << *vScale << endl; - softegg_cat.spam() << " uOffset: " << *uOffset << " vOffset: " << *vOffset << endl; - - SAA_texture2DGetRepeats( scene, &textures[0], uRepeat, vRepeat ); - softegg_cat.spam() << "uRepeat = " << *uRepeat << ", vRepeat = " << *vRepeat << endl; - } - else { - softegg_cat.spam() << "Invalid texture...\n"; - softegg_cat.spam() << " tritex[0] named: (null)\n"; - } - } - - softegg_cat.spam() << "got textures\n"; - } -} - -/** - * given a vertex, find its corresponding shape vertex and return its index. - */ -int SoftNodeDesc:: -find_shape_vert(LPoint3d p3d, SAA_DVector *vertices, int numVert) { - int i, found = 0; - - for (i = 0; i < numVert && !found ; i++) { - if ((p3d[0] == vertices[i].x) && - (p3d[1] == vertices[i].y) && - (p3d[2] == vertices[i].z)) { - found = 1; - softegg_cat.spam() << "found shape vert at index " << i << endl; - } - } - - if (!found ) - i = -1; - else - i--; - - return i; -} - -/** - * Given a scene, a model , the vertices of its original shape and its name - * find the difference between the geometry of its key shapes and the models - * original geometry and add morph vertices to the egg data to reflect these - * changes. - */ -void SoftNodeDesc:: -make_vertex_offsets(int numShapes) { - int i, j; - int offset; - int numCV; - char tableName[_MAX_PATH]; - SAA_DVector *shapeVerts = nullptr; - SAA_DVector *uniqueVerts = nullptr; - SAA_Elem *model = get_model(); - SAA_Scene *scene = &stec.scene; - - EggVertexPool *vpool = nullptr; - std::string vpool_name = get_name() + ".verts"; - EggNode *t = stec._tree.get_egg_root()->find_child(vpool_name); - if (t) - DCAST_INTO_V(vpool, t); - - int numOrigVert = (int) vpool->size(); - EggVertexPool::iterator vi; - - if ((type == SAA_MNSRF) && stec.make_nurbs) - SAA_nurbsSurfaceSetStep( scene, model, stec.nurbs_step, stec.nurbs_step ); - - SAA_modelGetNbVertices( scene, model, &numCV ); - - // get the shape verts - uniqueVerts = new SAA_DVector[numCV]; - SAA_modelGetVertices( scene, model, SAA_GEOM_ORIGINAL, 0, - numCV, uniqueVerts ); - - softegg_cat.spam() << numCV << " CV's\n"; - - for ( i = 0; i < numCV; i++ ) - // convert vertices to global - _VCT_X_MAT( uniqueVerts[i], uniqueVerts[i], matrix); - softegg_cat.spam() << "uniqueVerts[" << i << "] = " << uniqueVerts[i].x << " " << uniqueVerts[i].y - << " " << uniqueVerts[i].z << " " << uniqueVerts[i].w << endl; - - // iterate through for each key shape (except original) - for ( i = 1; i < numShapes; i++ ) { - - sprintf(tableName, "%s.%d", get_name().c_str(), i); - - softegg_cat.spam() << "\nMaking geometry offsets for " << tableName << "...\n"; - - if ((type == SAA_MNSRF) && stec.make_nurbs) - softegg_cat.spam() << "calculating NURBS morphs...\n"; - else - softegg_cat.spam() << "calculating triangle morphs...\n"; - - // get the shape verts - shapeVerts = new SAA_DVector[numCV]; - SAA_modelGetVertices( scene, model, SAA_GEOM_SHAPE, i+1, numCV, shapeVerts ); - - for ( j=0; j < numCV; j++ ) { - // convert vertices to global - _VCT_X_MAT( shapeVerts[j], shapeVerts[j], matrix); - - softegg_cat.spam() << "shapeVerts[" << j << "] = " << shapeVerts[j].x << " " - << shapeVerts[j].y << " " << shapeVerts[j].z << endl; - } - softegg_cat.spam() << endl; - - // for every original vertex, compare to the corresponding key shape - // vertex and see if a vertex offset is needed - j = 0; - for (vi = vpool->begin(); vi != vpool->end(); ++vi, ++j) { - - double dx, dy, dz; - EggVertex *vert = (*vi); - LPoint3d p3d = vert->get_pos3(); - - softegg_cat.spam() << "oVert[" << j << "] = " << p3d[0] << " " << p3d[1] << " " << p3d[2] << endl; - if ((type == SAA_MNSRF) && stec.make_nurbs) { - dx = shapeVerts[j].x - p3d[0]; - dy = shapeVerts[j].y - p3d[1]; - dz = shapeVerts[j].z - p3d[2]; - - softegg_cat.spam() << "global shapeVerts[" << j << "] = " << shapeVerts[j].x << " " - << shapeVerts[j].y << " " << shapeVerts[j].z << " " << shapeVerts[j].w << endl; - } - else { - // we need to map from original vertices to triangle shape vertices - // here - offset = find_shape_vert(p3d, uniqueVerts, numCV); - - dx = shapeVerts[offset].x - p3d[0]; - dy = shapeVerts[offset].y - p3d[1]; - dz = shapeVerts[offset].z - p3d[2]; - - softegg_cat.spam() << "global shapeVerts[" << offset << "] = " << shapeVerts[offset].x << " " - << shapeVerts[offset].y << " " << shapeVerts[offset].z << endl; - } - - softegg_cat.spam() << j << ": dx = " << dx << ", dy = " << dy << ", dz = " << dz << endl; - - // if change isn't negligible, make a morph vertex entry - double total = fabs(dx)+fabs(dy)+fabs(dz); - if ( total > 0.00001 ) { - if ( vpool != nullptr ) { - // create offset - LVector3d p(dx, dy, dz); - EggMorphVertex *dxyz = new EggMorphVertex(tableName, p); - // add the offset to the vertex - vert->_dxyzs.insert(*dxyz); - } - else - softegg_cat.spam() << "Error: couldn't find vertex pool " << vpool_name << endl; - - } // if total - } //for j - } //for i -} - -/** - * Given a scene, a model, a name and a frame time, determine what type of - * shape interpolation is used and call the appropriate function to extract - * the shape weight info for this frame... - */ -void SoftNodeDesc:: -make_morph_table( PN_stdfloat time ) { - int numShapes; - SAA_Elem *model = nullptr; - SAA_AnimInterpType type; - SAA_Scene *scene = &stec.scene; - - if (has_model()) - model = get_model(); - else - return; - - // Get the number of key shapes - SAA_modelGetNbShapes( scene, model, &numShapes ); - - if ( numShapes <= 0 ) { - return; - } - - stec.has_morph = true; - - softegg_cat.spam() << "make_morph_table: " << get_name() << " : num shapes: " << numShapes << endl; - - SAA_modelGetShapeInterpolation( scene, model, &type ); - - if ( type == SAA_ANIM_LINEAR || type == SAA_ANIM_CARDINAL ) { - softegg_cat.spam() << "linear morph" << endl; - make_linear_morph_table( numShapes, time ); - } - else { // must be weighted... - // check first for expressions - softegg_cat.spam() << "expression morph" << endl; - make_expression_morph_table( numShapes, time ); - } -} - -/** - * Given a scene, a model, its name, and the time, get the shape fcurve for - * the model and determine the shape weights for the given time and use them - * to populate the morph table. - */ -void SoftNodeDesc:: -make_linear_morph_table(int numShapes, PN_stdfloat time) { - int i; - PN_stdfloat curveVal; - char tableName[_MAX_PATH]; - SAA_Elem fcurve; - // SAnimTable *thisTable; - EggSAnimData *anim; - SAA_Elem *model = get_model(); - SAA_Scene *scene = &stec.scene; - - softegg_cat.spam() << "linear interp, getting fcurve\n"; - - SAA_modelFcurveGetShape( scene, model, &fcurve ); - - SAA_fcurveEval( scene, &fcurve, time, &curveVal ); - - softegg_cat.spam() << "at time " << time << ", fcurve for " << get_name() << " = " << curveVal << endl; - - PN_stdfloat nextVal = 0.0f; - - // populate morph table values for this frame - for ( i = 1; i < numShapes; i++ ) { - // derive table name from the model name - sprintf(tableName, "%s.%d", get_name().c_str(), i); - - softegg_cat.spam() << "Linear: looking for table '" << tableName << "'\n"; - - // find the morph table associated with this key shape - anim = stec.find_morph_table(tableName); - - if ( anim != nullptr ) { - if ( i == (int)curveVal ) { - if ( curveVal - i == 0 ) { - anim->add_data(1.0f ); - softegg_cat.spam() << "adding element 1.0f\n"; - } - else { - anim->add_data(1.0f - (curveVal - i)); - nextVal = curveVal - i; - softegg_cat.spam() << "adding element " << 1.0f - (curveVal - i) << endl; - } - } - else { - if ( nextVal ) { - anim->add_data(nextVal ); - nextVal = 0.0f; - softegg_cat.spam() << "adding element " << nextVal << endl; - } - else { - anim->add_data(0.0f); - softegg_cat.spam() << "adding element 0.0f\n"; - } - } - - softegg_cat.spam() <<" to '" << tableName << "'\n"; - } - else - softegg_cat.spam() << i << " : Couldn't find table '" << tableName << "'\n"; - } -} - -/** - * Given a scene, a model, a list of all models in the scene, the number of - * models in the scece, the number of key shapes for this model, the name of - * the model and the current time, determine what method of controlling the - * shape weights is used and call the appropriate routine. - */ -void SoftNodeDesc:: -make_weighted_morph_table(int numShapes, PN_stdfloat time) { - PN_stdfloat curveVal; - SI_Error result; - char tableName[_MAX_PATH]; - SAA_Elem *weightCurves; - // SAnimTable *thisTable; - EggSAnimData *anim; - SAA_Elem *model = get_model(); - SAA_Scene *scene = &stec.scene; - - // allocate array of weight curves (one for each shape) - weightCurves = new SAA_Elem[numShapes]; - - result = SAA_modelFcurveGetShapeWeights(scene, model, numShapes, weightCurves); - - if ( result == SI_SUCCESS ) { - for ( int i = 1; i < numShapes; i++ ) { - SAA_fcurveEval( scene, &weightCurves[i], time, &curveVal ); - - // make sure soft gave us a reasonable number if (!isNum(curveVal)) - // curveVal = 0.0f; - - softegg_cat.spam() << "at time " << time << ", weightCurve[" << i << "] for " << get_name() << " = " << curveVal << endl; - - // derive table name from the model name - sprintf(tableName, "%s.%d", get_name().c_str(), i); - - // find and populate shape table - softegg_cat.spam() << "Weight: looking for table '" << tableName << "'\n"; - - // find the morph table associated with this key shape - anim = stec.find_morph_table(tableName); - - if ( anim != nullptr ) { - anim->add_data(curveVal); - softegg_cat.spam() << "adding element " << curveVal << endl; - } - else - softegg_cat.spam() << i << " : Couldn't find table '" << tableName << "'\n"; - } - } -} - -/** - * Given a scene, a model and its number of key shapes generate a morph table - * describing transitions btwn the key shapes by evaluating the positions of - * the controlling sliders. - */ -void SoftNodeDesc:: -make_expression_morph_table(int numShapes, PN_stdfloat time) -{ - // int j; - int numExp; - char *track; - // PN_stdfloat expVal; PN_stdfloat sliderVal; char *tableName; char - // *sliderName; SAnimTable *thisTable; - SAA_Elem *expressions; - SI_Error result; - - SAA_Elem *model = get_model(); - SAA_Scene *scene = &stec.scene; - - // populate morph table values for this frame - - // compose track name - track = nullptr; - - // find how many expressions for this shape - SAA_elementGetNbExpressions( scene, model, track, FALSE, &numExp ); - - softegg_cat.spam() << get_name() << " has " << numExp << " RHS expressions\n"; - - if ( numExp ) { - // get the expressions for this shape - expressions = new SAA_Elem[numExp]; - softegg_cat.spam() << "getting " << numExp << " RHS expressions...\n"; - - result = SAA_elementGetExpressions( scene, model, track, FALSE, - numExp, expressions ); - /* - if ( !result ) { - for ( j = 1; j < numExp; j++ ) { - if ( verbose >= 2 ) - { - // debug see what we got - int numvars; - - SAA_expressionGetNbVars( scene, &expressions[j], &numvars ); - - int *varnamelen; - int *varstrlen; - int expstrlen; - - varnamelen = (int *)malloc(sizeof(int)*numvars); - varstrlen = (int *)malloc(sizeof(int)*numvars); - - SAA_expressionGetStringLengths( scene, &expressions[j], - numvars, varnamelen, varstrlen, &expstrlen ); - - int *varnamesizes; - int *varstrsizes; - - varnamesizes = (int *)malloc(sizeof(int)*numvars); - varstrsizes = (int *)malloc(sizeof(int)*numvars); - - for ( int k = 0; k < numvars; k++ ) - { - varnamesizes[k] = varnamelen[k] + 1; - varstrsizes[k] = varstrlen[k] + 1; - } - - int expstrsize = expstrlen + 1; - - char **varnames; - char **varstrs; - - varnames = (char **)malloc(sizeof(char *)*numvars); - varstrs = (char **)malloc(sizeof(char *)*numvars); - - for ( k = 0; k < numvars; k++ ) - { - varnames[k] = (char *)malloc(sizeof(char)* - varnamesizes[k]); - - varstrs[k] = (char *)malloc(sizeof(char)* - varstrsizes[k]); - } - - char *expstr = (char *)malloc(sizeof(char)* expstrsize ); - - SAA_expressionGetStrings( scene, &expressions[j], numvars, - varnamesizes, varstrsizes, expstrsize, varnames, - varstrs, expstr ); - - if ( verbose >= 2 ) - { - fprintf( outStream, "expression = '%s'\n", expstr ); - fprintf( outStream, "has %d variables\n", numvars ); - } - } //if verbose - - if ( verbose >= 2 ) - fprintf( outStream, "evaling expression...\n" ); - - SAA_expressionEval( scene, &expressions[j], time, &expVal ); - - if ( verbose >= 2 ) - fprintf( outStream, "time %f: exp val %f\n", - time, expVal ); - - // derive table name from the model name - tableName = MakeTableName( name, j ); - - if ( verbose >= 2 ) - fprintf( outStream, "Exp: looking for table '%s'\n", - tableName ); - - // find the morph table associated with this key shape - anim = (SAnimTable *) - (morphRoot->FindDescendent( tableName )); - - if ( anim != NULL ) - { - anim->AddElement( expVal ); - if ( verbose >= 1 ) - fprintf( outStream, "%d: adding element %f to %s\n", - j, expVal, tableName ); - fflush( outStream ); - } - else - { - fprintf( outStream, "%d: Couldn't find table '%s'", j, - tableName ); - - fprintf( outStream, " for value %f\n", expVal ); - } - } - } - else - fprintf( outStream, "couldn't get expressions!!!\n" ); - */ - } - else { - softegg_cat.spam() << "weighted morph" << endl; - // no expression, use weight curves - make_weighted_morph_table(numShapes, time ); - } -} diff --git a/pandatool/src/softegg/softNodeDesc.h b/pandatool/src/softegg/softNodeDesc.h deleted file mode 100644 index c6512b7dda..0000000000 --- a/pandatool/src/softegg/softNodeDesc.h +++ /dev/null @@ -1,159 +0,0 @@ -/** - * 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." - * - * @file softNodeDesc.h - * @author masad - * @date 2003-10-03 - */ - -#ifndef SOFTNODEDESC_H -#define SOFTNODEDESC_H - -#ifdef _MIN -#undef _MIN -#endif -#ifdef _MAX -#undef _MAX -#endif - -#include "pandatoolbase.h" - -#include "eggVertex.h" -#include "eggVertexPool.h" -#include "referenceCount.h" -#include "pointerTo.h" -#include "namable.h" - -#include - -class EggGroup; -class EggTable; -class EggXfmSAnim; - -/** - * Describes a single instance of a node aka element in the Soft scene graph, - * relating it to the corresponding egg structures (e.g. node, group, or - * table entry) that will be created. - */ -class SoftNodeDesc : public ReferenceCount, public Namable { -public: - SoftNodeDesc(SoftNodeDesc *parent=nullptr, const std::string &name = std::string()); - ~SoftNodeDesc(); - - void set_parent(SoftNodeDesc *parent); - void force_set_parent(SoftNodeDesc *parent); - void set_model(SAA_Elem *model); - bool has_model() const; - SAA_Elem *get_model() const; - - bool is_joint() const; - bool is_junk() const; - void set_joint(); - bool is_joint_parent() const; - bool is_partial(char *search_prefix); - - SoftNodeDesc *_parent; - SoftNodeDesc *_parentJoint; // keep track of who is your parent joint - typedef pvector< PT(SoftNodeDesc) > Children; - Children _children; - -private: - void clear_egg(); - void mark_joint_parent(); - void check_joint_parent(); - void check_junk(bool parent_junk); - void check_pseudo_joints(bool joint_above); - - void set_parentJoint(SAA_Scene *scene, SoftNodeDesc *lastJoint); - - SAA_ModelType type; - - SAA_Elem *_model; - - EggGroup *_egg_group; - EggTable *_egg_table; - EggXfmSAnim *_anim; - - enum JointType { - JT_none, // Not a joint. - JT_joint, // An actual joint in Soft. - JT_pseudo_joint, // Not a joint in Soft, but treated just like a - // joint for the purposes of the converter. - JT_joint_parent, // A parent or ancestor of a joint or pseudo joint. - JT_junk, // originated from con-/fly-/car_rig/bars etc. - }; - JointType _joint_type; - -public: - - char **texNameArray; - int *uRepeat, *vRepeat; - PN_stdfloat matrix[4][4]; - - const char *fullname; - - int numTri; - // int numShapes; - int numTexLoc; - int numTexGlb; - int *numTexTri; - - // if the node is a MNSRF - int numNurbTexLoc; - int numNurbTexGlb; - int numNurbMats; - - PN_stdfloat *uScale; - PN_stdfloat *vScale; - PN_stdfloat *uOffset; - PN_stdfloat *vOffset; - - SAA_Boolean valid; - SAA_Boolean uv_swap; - // SAA_Boolean visible; - SAA_Elem *textures; - SAA_Elem *materials; - SAA_SubElem *triangles; - SAA_GeomType gtype; - - EggGroup *get_egg_group()const {return _egg_group;} - - void get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global); - void get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, bool global); - void load_poly_model(SAA_Scene *scene, SAA_ModelType type); - void load_nurbs_model(SAA_Scene *scene, SAA_ModelType type); - - void make_morph_table(PN_stdfloat time); - void make_linear_morph_table(int numShapes, PN_stdfloat time); - void make_weighted_morph_table(int numShapes, PN_stdfloat time); - void make_expression_morph_table(int numShapes, PN_stdfloat time); - - void make_vertex_offsets(int numShapes); - int find_shape_vert(LPoint3d p3d, SAA_DVector *vertices, int numVert); - - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - ReferenceCount::init_type(); - Namable::init_type(); - register_type(_type_handle, "SoftNodeDesc", - ReferenceCount::get_class_type(), - Namable::get_class_type()); - } - -private: - static TypeHandle _type_handle; - - friend class SoftNodeTree; -}; - -class SoftToEggConverter; -extern SoftToEggConverter stec; - -#endif diff --git a/pandatool/src/softegg/softNodeTree.cxx b/pandatool/src/softegg/softNodeTree.cxx deleted file mode 100644 index 3b5be3252b..0000000000 --- a/pandatool/src/softegg/softNodeTree.cxx +++ /dev/null @@ -1,561 +0,0 @@ -/** - * 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." - * - * @file softNodeTree.cxx - * @author masad - * @date 2003-09-26 - */ - -// Includes - -#include "softNodeTree.h" -#include "softEggGroupUserData.h" -#include "config_softegg.h" -#include "eggGroup.h" -#include "eggTable.h" -#include "eggXfmSAnim.h" -#include "eggData.h" -#include "softToEggConverter.h" -#include "dcast.h" - -#include - -using std::endl; - -/** - * - */ -SoftNodeTree:: -SoftNodeTree() { - _root = new SoftNodeDesc(nullptr, "----root"); - _root->fullname = "----root"; - _fps = 0.0; - _use_prefix = 0; - _search_prefix = nullptr; - _egg_data = nullptr; - _egg_root = nullptr; - _skeleton_node = nullptr; -} -/** - * Given an element, return a copy of the element's name WITHOUT prefix. - */ -char *SoftNodeTree:: -GetName( SAA_Scene *scene, SAA_Elem *element ) { - int nameLen; - char *name; - - // get the name - SAA_elementGetNameLength( scene, element, &nameLen ); - name = new char[++nameLen]; - SAA_elementGetName( scene, element, nameLen, name ); - - return name; -} - -/** - * Given an element, return a copy of the element's name complete with prefix. - */ -char *SoftNodeTree:: -GetFullName( SAA_Scene *scene, SAA_Elem *element ) -{ - int nameLen, prefixLen; - char *name, *prefix; - - // get the name length - SAA_elementGetNameLength( scene, element, &nameLen ); - // get the prefix length - SAA_elementGetPrefixLength( scene, element, &prefixLen ); - // allocate the array to hold name - name = new char[++nameLen]; - // allocate the array to hold prefix and length + hyphen - prefix = new char[++prefixLen + nameLen + 4]; - // get the name - SAA_elementGetName( scene, element, nameLen, name ); - // get the prefix - SAA_elementGetPrefix( scene, element, prefixLen, prefix ); - // add 'em together - strcat(prefix, "-"); - strcat(prefix, name); - - // return string - return prefix; -} - -/** - * Given an element, return a string containing the contents of its MODEL NOTE - * entry - */ -char *SoftNodeTree:: -GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) { - int size; - char *modelNote = nullptr; - SAA_Boolean bigEndian; - - SAA_elementGetUserDataSize( scene, model, "MNOT", &size ); - - if ( size != 0 ) { - // allocate modelNote string - modelNote = new char[size + 1]; - - // get ModelNote data from this model - SAA_elementGetUserData( scene, model, "MNOT", size, - &bigEndian, (void *)modelNote ); - - // strip off newline, if present - char *eol = (char *)memchr( modelNote, '\n', size ); - if ( eol != nullptr) - *eol = '\0'; - else - modelNote[size] = '\0'; - - softegg_cat.spam() << "\nmodelNote = " << modelNote << endl; - } - - return modelNote; -} - -/** - * Given a string, return a copy of the string up to the first occurence of - * '-'. - */ -char *SoftNodeTree:: -GetRootName( const char *name ) { - const char *hyphen; - char *root; - int len; - - hyphen = strchr( name, '-' ); - len = hyphen-name; - - if ( (hyphen != nullptr) && len ) { - root = new char[len+1]; - strncpy( root, name, len ); - root[len] = '\0'; - } - else { - root = new char[strlen(name)+1]; - strcpy( root, name ); - } - return( root ); -} - -/** - * Walks through the complete Soft hierarchy and builds up the corresponding - * tree. - */ -bool SoftNodeTree:: -build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) { - SI_Error status; - SoftNodeDesc *node; - - // Get the entire Soft scene. - int numModels; - SAA_Elem *models; - - SAA_sceneGetNbModels( &scene, &numModels ); - softegg_cat.spam() << "Scene has " << numModels << " model(s)...\n"; - - // This while loop walks through the entire Soft hierarchy, one node at a - // time. - bool all_ok = true; - if ( numModels ) { - // allocate array of models - models = (SAA_Elem *) new SAA_Elem[numModels]; - if ( models != nullptr ) { - if ((status = SAA_sceneGetModels( &scene, numModels, models )) != SI_SUCCESS) { - return false; - } - for ( int i = 0; i < numModels; i++ ) { - int level; - status = SAA_elementGetHierarchyLevel( &scene, &models[i], &level ); - softegg_cat.spam() << "model[" << i << "]" << endl; - softegg_cat.spam() << " level " << level << endl; - softegg_cat.spam() << " status is " << status << "\n"; - - node = build_node(&scene, &models[i]); - if (!level && node) - node->set_parent(_root); - } - } - } - - softegg_cat.spam() << "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\n"; - - // check the nodes that are junk for animationartist control purposes - _root->check_junk(false); - - softegg_cat.spam() << "jpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjp\n"; - - // check the nodes that are parent of ancestors of a joint - _root->check_joint_parent(); - - softegg_cat.spam() << "pppppppppppppppppppppppppppppppppppppppppppppppppppppppp\n"; - - // check the nodes that are pseudo joints - _root->check_pseudo_joints(false); - - softegg_cat.spam() << "========================================================\n"; - - // find _parentJoint for each node - _root->set_parentJoint(&scene, nullptr); - - return all_ok; -} -#if 0 -/** - * Walks through the selected subset of the Soft hierarchy (or the complete - * hierarchy, if nothing is selected) and builds up the corresponding tree. - */ -bool SoftNodeTree:: -build_selected_hierarchy(char *scene_name) { - MStatus status; - - MItDag dag_iterator(MItDag::kDepthFirst, MFn::kTransform, &status); - if (!status) { - status.perror("MItDag constructor"); - return false; - } - - // Get only the selected geometry. - MSelectionList selection; - status = MGlobal::getActiveSelectionList(selection); - if (!status) { - status.perror("MGlobal::getActiveSelectionList"); - return false; - } - - // Get the selected geometry only if the selection is nonempty; otherwise, - // get the whole scene anyway. - if (selection.isEmpty()) { - softegg_cat.info() - << "Selection list is empty.\n"; - return build_complete_hierarchy(); - } - - bool all_ok = true; - unsigned int length = selection.length(); - for (unsigned int i = 0; i < length; i++) { - MDagPath root_path; - status = selection.getDagPath(i, root_path); - if (!status) { - status.perror("MSelectionList::getDagPath"); - } else { - // Now traverse through the selected dag path and all nested dag paths. - dag_iterator.reset(root_path); - while (!dag_iterator.isDone()) { - MDagPath dag_path; - status = dag_iterator.getPath(dag_path); - if (!status) { - status.perror("MItDag::getPath"); - } else { - build_node(dag_path); - } - - dag_iterator.next(); - } - } - } - - if (all_ok) { - _root->check_pseudo_joints(false); - } - - return all_ok; -} -#endif -/** - * Returns the total number of nodes in the hierarchy, not counting the root - * node. - */ -int SoftNodeTree:: -get_num_nodes() const { - return _nodes.size(); -} - -/** - * Returns the nth node in the hierarchy, in an arbitrary ordering. - */ -SoftNodeDesc *SoftNodeTree:: -get_node(int n) const { - nassertr(n >= 0 && n < (int)_nodes.size(), nullptr); - return _nodes[n]; -} - -/** - * Returns the node named 'name' in the hierarchy, in an arbitrary ordering. - */ -SoftNodeDesc *SoftNodeTree:: -get_node(std::string name) const { - NodesByName::const_iterator ni = _nodes_by_name.find(name); - if (ni != _nodes_by_name.end()) - return (*ni).second; - return nullptr; -} - -/** - * Removes all of the references to generated egg structures from the tree, - * and prepares the tree for generating new egg structures. - */ -void SoftNodeTree:: -clear_egg(EggData *egg_data, EggGroupNode *egg_root, - EggGroupNode *skeleton_node) { - _root->clear_egg(); - _egg_data = egg_data; - _egg_root = egg_root; - _skeleton_node = skeleton_node; -} - -/** - * Returns the EggGroupNode corresponding to the group or joint for the - * indicated node. Creates the group node if it has not already been created. - */ -EggGroup *SoftNodeTree:: -get_egg_group(SoftNodeDesc *node_desc) { - nassertr(_egg_root != nullptr, nullptr); - - // lets print some relationship - softegg_cat.spam() << " group " << node_desc->get_name() << "(" << node_desc->_egg_group << ")"; - if (node_desc->_parent) - softegg_cat.spam() << " parent " << node_desc->_parent->get_name() << "(" << node_desc->_parent << ")"; - else - softegg_cat.spam() << " parent " << node_desc->_parent; - softegg_cat.spam() << endl; - - if (node_desc->_egg_group == nullptr) { - // We need to make a new group node. - EggGroup *egg_group; - - egg_group = new EggGroup(node_desc->get_name()); - if (node_desc->is_joint()) { - egg_group->set_group_type(EggGroup::GT_joint); - } - - if (stec.flatten || (!node_desc->_parentJoint || node_desc->_parentJoint == _root)) { - // The parent is the root. - softegg_cat.spam() << "came hereeeee\n"; - _egg_root->add_child(egg_group); - } else { - // The parent is another node. - EggGroup *parent_egg_group = get_egg_group(node_desc->_parentJoint); - parent_egg_group->add_child(egg_group); - } - - node_desc->_egg_group = egg_group; - } - - return node_desc->_egg_group; -} - -/** - * Returns the EggTable corresponding to the joint for the indicated node. - * Creates the table node if it has not already been created. - */ -EggTable *SoftNodeTree:: -get_egg_table(SoftNodeDesc *node_desc) { - nassertr(_skeleton_node != nullptr, nullptr); - nassertr(node_desc->is_joint(), nullptr); - - // lets print some relationship - softegg_cat.spam() << " group " << node_desc->get_name() << "(" << node_desc->_egg_group << ")"; - if (node_desc->_parent) - softegg_cat.spam() << " parent " << node_desc->_parent->get_name() << "(" << node_desc->_parent << ")"; - else - softegg_cat.spam() << " parent " << node_desc->_parent; - softegg_cat.spam() << endl; - - if (node_desc->_egg_table == nullptr) { - softegg_cat.spam() << "creating a new table\n"; - // We need to make a new table node. nassertr(node_desc->_parent != - // (SoftNodeDesc *)NULL, NULL); - - EggTable *egg_table = new EggTable(node_desc->get_name()); - node_desc->_anim = new EggXfmSAnim("xform", _egg_data->get_coordinate_system()); - node_desc->_anim->set_fps(_fps); - egg_table->add_child(node_desc->_anim); - - if (stec.flatten || (!node_desc->_parentJoint || node_desc->_parentJoint == _root)) { - // if (!node_desc->_parent->is_joint()) { The parent is not a joint; put - // it at the top. - _skeleton_node->add_child(egg_table); - } else { - // The parent is another joint. - EggTable *parent_egg_table = get_egg_table(node_desc->_parentJoint); - parent_egg_table->add_child(egg_table); - } - - node_desc->_egg_table = egg_table; - } - - return node_desc->_egg_table; -} - -/** - * Returns the anim table corresponding to the joint for the indicated node. - * Creates the table node if it has not already been created. - */ -EggXfmSAnim *SoftNodeTree:: -get_egg_anim(SoftNodeDesc *node_desc) { - get_egg_table(node_desc); - return node_desc->_anim; -} - -/** - * Sets joint information for MNILL node - */ -void SoftNodeTree:: -handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name) { - const char *name = node_name; - SAA_AlgorithmType algo; - SAA_Elem *model = node_desc->get_model(); - - SAA_modelGetAlgorithm( scene, model, &algo ); - softegg_cat.spam() << " null algorithm: " << algo << endl; - - if ( algo == SAA_ALG_INV_KIN ) { - // MakeJoint( &scene, lastJoint, lastAnim, model, name ); - node_desc->set_joint(); - softegg_cat.spam() << " encountered IK root: " << name << endl; - } - else if ( algo == SAA_ALG_INV_KIN_LEAF ) { - // MakeJoint( &scene, lastJoint, lastAnim, model, name ); - node_desc->set_joint(); - softegg_cat.spam() << " encountered IK leaf: " << name << endl; - } - else if ( algo == SAA_ALG_STANDARD ) { - SAA_Boolean isSkeleton = FALSE; - softegg_cat.spam() << " encountered Standard null: " << name << endl; - - SAA_modelIsSkeleton( scene, model, &isSkeleton ); - - // check to see if this NULL is used as a skeleton or is animated via - // constraint only ( these nodes are tagged by the animator with the - // keyword "joint" somewhere in the nodes name) - if ( isSkeleton || (strstr( name, "joint" ) != nullptr) ) { - // MakeJoint( &scene, lastJoint, lastAnim, model, name ); - node_desc->set_joint(); - softegg_cat.spam() << " animating Standard null!!!\n"; - softegg_cat.spam() << "isSkeleton: " << isSkeleton << endl; - } - } - else - softegg_cat.spam() << " encountered some other NULL: " << algo << endl; -} - -/** - * Returns a pointer to the node corresponding to the indicated dag_path - * object, creating it first if necessary. - */ -SoftNodeDesc *SoftNodeTree:: -build_node(SAA_Scene *scene, SAA_Elem *model) { - char *name, *fullname; - std::string node_name; - int numChildren; - int thisChild; - SAA_Elem *children; - SAA_ModelType type; - SAA_Boolean isSkeleton = FALSE; - - fullname = GetFullName(scene, model); - if (_use_prefix) - name = fullname; - else - name = GetName(scene, model); - - node_name = name; - - SoftNodeDesc *node_desc = r_build_node(nullptr, node_name); - - node_desc->fullname = fullname; - node_desc->set_model(model); - SAA_modelIsSkeleton( scene, model, &isSkeleton ); - - // find out what type of node we're dealing with - SAA_modelGetType( scene, node_desc->get_model(), &type ); - - if (type == SAA_MJNT || isSkeleton || (strstr(node_desc->get_name().c_str(), "joint") != nullptr)) - node_desc->set_joint(); - - // treat the MNILL differently, because it needs to detect and set some - // joints - if (type == SAA_MNILL) - handle_null(scene, node_desc, name); - - if (node_desc->is_joint()) - softegg_cat.spam() << "type: " << type << " isSkeleton: " << isSkeleton << endl; - - // get to the children - SAA_modelGetNbChildren( scene, model, &numChildren ); - softegg_cat.spam() << " Model " << node_name << " children: " << numChildren << endl; - - if ( numChildren ) { - children = new SAA_Elem[numChildren]; - SAA_modelGetChildren( scene, model, numChildren, children ); - if (!children) - softegg_cat.info() << "Not enough Memory for children...\n"; - - for ( thisChild = 0; thisChild < numChildren; thisChild++ ) { - fullname = GetFullName(scene, &children[thisChild]); - if (_use_prefix) - node_name = fullname; - else - node_name = GetName(scene, &children[thisChild]); - - softegg_cat.spam() << " building child " << thisChild << "..."; - - SoftNodeDesc *node_child = r_build_node(node_desc, node_name); - - node_child->fullname = fullname; - node_child->set_model(&children[thisChild]); - SAA_modelIsSkeleton( scene, &children[thisChild], &isSkeleton ); - - // find out what type of node we're dealing with - SAA_modelGetType( scene, node_child->get_model(), &type ); - - if (type == SAA_MJNT || isSkeleton || (strstr(node_child->get_name().c_str(), "joint") != nullptr)) - node_child->set_joint(); - - // treat the MNILL differently, because it needs to detect and set some - // joints - if (type == SAA_MNILL) - handle_null(scene, node_child, node_name.c_str()); - - if (node_child->is_joint()) - softegg_cat.spam() << "type: " << type << " isSkeleton: " << isSkeleton << endl; - } - } - return node_desc; -} - -/** - * The recursive implementation of build_node(). - */ -SoftNodeDesc *SoftNodeTree:: -r_build_node(SoftNodeDesc *parent_node, const std::string &name) { - SoftNodeDesc *node_desc; - - // If we have already encountered this pathname, return the corresponding - // SoftNodeDesc immediately. - NodesByName::const_iterator ni = _nodes_by_name.find(name); - if (ni != _nodes_by_name.end()) { - softegg_cat.spam() << " already built node " << (*ni).first; - node_desc = (*ni).second; - node_desc->set_parent(parent_node); - return node_desc; - } - - // Otherwise, we have to create it. Do this recursively, so we create each - // node along the path. - node_desc = new SoftNodeDesc(parent_node, name); - - softegg_cat.spam() << " node name : " << name << endl; - _nodes.push_back(node_desc); - - _nodes_by_name.insert(NodesByName::value_type(name, node_desc)); - - return node_desc; -} diff --git a/pandatool/src/softegg/softNodeTree.h b/pandatool/src/softegg/softNodeTree.h deleted file mode 100644 index afbef5877b..0000000000 --- a/pandatool/src/softegg/softNodeTree.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * 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." - * - * @file softNodeTree.h - * @author masad - * @date 2003-10-03 - */ - -#ifndef SOFTNODETREE_H -#define SOFTNODETREE_H - -#include "pandatoolbase.h" -#include "softNodeDesc.h" - -#include - -class EggGroup; -class EggTable; -class EggXfmSAnim; -class EggData; -class EggGroupNode; - - -/** - * Describes a complete tree of soft nodes for conversion. - */ -class SoftNodeTree { -public: - SoftNodeTree(); - SoftNodeDesc *build_node(SAA_Scene *scene, SAA_Elem *model); - bool build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database); - void handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name); - // bool build_selected_hierarchy(SAA_Scene *s, SAA_Database *d, char - // *scene_name); - - int get_num_nodes() const; - SoftNodeDesc *get_node(int n) const; - SoftNodeDesc *get_node(std::string name) const; - - char *GetRootName(const char *); - char *GetModelNoteInfo(SAA_Scene *, SAA_Elem *); - char *GetName(SAA_Scene *scene, SAA_Elem *element); - char *GetFullName(SAA_Scene *scene, SAA_Elem *element); - - EggGroupNode *get_egg_root() {return _egg_root;} - EggGroup *get_egg_group(SoftNodeDesc *node_desc); - EggTable *get_egg_table(SoftNodeDesc *node_desc); - EggXfmSAnim *get_egg_anim(SoftNodeDesc *node_desc); - - void clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node); - - PT(SoftNodeDesc) _root; - PN_stdfloat _fps; - int _use_prefix; - char *_search_prefix; - - -private: - - EggData *_egg_data; - EggGroupNode *_egg_root; - EggGroupNode *_skeleton_node; - - SoftNodeDesc *r_build_node(SoftNodeDesc *parent_node, const std::string &path); - - typedef pmap NodesByName; - NodesByName _nodes_by_name; - - typedef pvector Nodes; - Nodes _nodes; -}; - -#endif diff --git a/pandatool/src/softegg/softToEggConverter.cxx b/pandatool/src/softegg/softToEggConverter.cxx deleted file mode 100644 index 44dafefb62..0000000000 --- a/pandatool/src/softegg/softToEggConverter.cxx +++ /dev/null @@ -1,2122 +0,0 @@ -/** - * 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." - * - * @file softToEggConverter.cxx - * @author masad - * @date 2003-09-25 - */ - -#include "softToEggConverter.h" -#include "config_softegg.h" -#include "softEggGroupUserData.h" - -#include "eggData.h" -#include "eggGroup.h" -#include "eggTable.h" -#include "eggVertex.h" -#include "eggComment.h" -#include "eggVertexPool.h" -#include "eggNurbsSurface.h" -#include "eggNurbsCurve.h" -#include "eggPolygon.h" -#include "eggPrimitive.h" -#include "eggTexture.h" -#include "eggTextureCollection.h" -#include "eggXfmSAnim.h" -#include "eggSAnimData.h" -#include "string_utils.h" -#include "dcast.h" - -using std::endl; -using std::string; - -SoftToEggConverter stec; - -const int TEX_PER_MAT = 1; - -/** - * - */ -SoftToEggConverter:: -SoftToEggConverter(const string &program_name) : - _program_name(program_name) -{ - _from_selection = false; - _polygon_output = false; - _polygon_tolerance = 0.01; - /* - _respect_maya_double_sided = maya_default_double_sided; - _always_show_vertex_color = maya_default_vertex_color; - */ - _transform_type = TT_model; - - database_name = nullptr; - scene_name = nullptr; - model_name = nullptr; - animFileName = nullptr; - eggFileName = nullptr; - tex_path = nullptr; - eggGroupName = nullptr; - tex_filename = nullptr; - search_prefix = nullptr; - result = SI_SUCCESS; - - // skeleton = new EggGroup(); - foundRoot = FALSE; - // animRoot = NULL; morphRoot = NULL; - geom_as_joint = 0; - make_anim = 0; - make_nurbs = 0; - make_poly = 0; - make_soft = 0; - make_morph = 1; - make_duv = 1; - make_dart = TRUE; - has_morph = 0; - make_pose = 0; - // animData.is_z_up = FALSE; - nurbs_step = 1; - anim_start = -1000; - anim_end = -1000; - anim_rate = 24; - pose_frame = -1; - verbose = 0; - flatten = 0; - shift_textures = 0; - ignore_tex_offsets = 0; - use_prefix = 0; -} - -/** - * - */ -SoftToEggConverter:: -SoftToEggConverter(const SoftToEggConverter ©) : - _from_selection(copy._from_selection), - /* - _maya(copy._maya), - */ - _polygon_output(copy._polygon_output), - _polygon_tolerance(copy._polygon_tolerance), - /* - _respect_maya_double_sided(copy._respect_maya_double_sided), - _always_show_vertex_color(copy._always_show_vertex_color), - */ - _transform_type(copy._transform_type) -{ -} - -/** - * - */ -SoftToEggConverter:: -~SoftToEggConverter() { - /* - close_api(); - */ -} -/** - * Displays the "what is this program" message, along with the usage message. - * Should be overridden in base classes to describe the current program. - */ -void SoftToEggConverter:: -Help() -{ - softegg_cat.info() << - "soft2egg takes a SoftImage scene or model\n" - "and outputs its contents as an egg file\n"; - - Usage(); -} - -/** - * Displays the usage message. - */ -void SoftToEggConverter:: -Usage() { - softegg_cat.info() - << "\nUsage:\n" - // << _commandName << " [opts] (must specify -m or -s)\n\n" - << "soft" << " [opts] (must specify -m or -s)\n\n" - << "Options:\n"; - - ShowOpts(); - softegg_cat.info() << "\n"; -} - -/** - * Displays the valid options. Should be extended in base classes to show - * additional options relevant to the current program. - */ -void SoftToEggConverter:: -ShowOpts() -{ - softegg_cat.info() << - " -r - Used to provide soft with the resource\n" - " Defaults to '/ful/ufs/soft371_mips2/3D/rsrc'.\n" - " -d - Database path.\n" - " -s - Indicates that a scene will be converted.\n" - " -m - Indicates that a model will be converted.\n" - " -t - Specify path to place converted textures.\n" - " -T - Specify filename for texture map listing.\n" - " -S - Specify step for nurbs surface triangulation.\n" - " -M - Specify model output filename. Defaults to scene name.\n" - " -A - Specify anim output filename. Defaults to scene name.\n" - " -N - Specify egg group name.\n" - " -k - Enable soft assignment for geometry.\n" - " -n - Specify egg NURBS representation instead of poly's.\n" - " -p - Specify egg polygon output for geometry.\n" - " -P - Specify frame number for static pose.\n" - " -b - Specify starting frame for animation (default = first).\n" - " -e - Specify ending frame for animation (default = last).\n" - " -f - Specify frame rate for animation playback.\n" - " -a - Compile animation tables if animation present.\n" - " -F - Ignore hierarchy and build a completely flat skeleton.\n" - " -v - Set debug level.\n" - " -x - Shift NURBS parameters to preserve Alias textures.\n" - " -i - Ignore Soft texture uv offsets.\n" - " -u - Use Soft prefix in model names.\n" - " -c - Cancel morph conversion.\n" - " -C - Cancel duv conversion.\n" - " -D - Don't make the output model a character.\n" - " -o - Convert only models with given prefix.\n"; - - // EggBase::ShowOpts(); -} - -/** - * Calls getopt() to parse the command-line switches. Calls HandleGetopts() - * to interpret each switch. Returns true if the parsing was successful; - * false if there was an error. Adjusts argc and argv to remove the switches - * from the parameter list. - */ -bool SoftToEggConverter:: -DoGetopts(int &argc, char **&argv) { - bool okflag = true; - int i = 0; - softegg_cat.info() << "argc " << argc << "\n"; - if (argc <2) { - Usage(); - okflag = false; - } - while( i < argc ) { - strcat(_commandLine, argv[i]); - strcat(_commandLine, " "); - ++i; - } - softegg_cat.info() << endl << _commandLine << endl; - - i = 1; - while ((i < argc) && (argv[i][0] == '-') && okflag) { - softegg_cat.info() << "arg " << i << " is " << argv[i] << "\n"; - okflag = HandleGetopts(i, argc, argv); - } - return okflag; -} - -/** - * increment idx based on what kind of option parsed Supported options are as - * follows: r:d:s:m:t:P:b:e:f:T:S:M:A:N:v:o:FhknpaxiucCD - */ -bool SoftToEggConverter:: -HandleGetopts(int &idx, int argc, char **argv) -{ - bool okflag = true; - - char flag = argv[idx][1]; // skip the '-' from option - - switch (flag) - { - case 'r': // Set the resource path for soft. - if ( strcmp( argv[idx+1], "" ) ) { - // Get the path. - rsrc_path = argv[idx+1]; - softegg_cat.info() << "using rsrc path " << rsrc_path << "\n"; - } - ++idx; - break; - - case 'd': // Set the database path. - if ( strcmp( argv[idx+1], "" ) ) { - // Get the path. - database_name = argv[idx+1]; - softegg_cat.info() << "using database " << database_name << "\n"; - } - ++idx; - break; - - case 's': // Check if its a scene. - if ( strcmp( argv[idx+1], "" ) ) { - // Get scene name. - scene_name = argv[idx+1]; - softegg_cat.info() << "loading scene " << scene_name << "\n"; - } - ++idx; - break; - - case 'm': // Check if its a model. - if ( strcmp( argv[idx+1], "" ) ) { - // Get model name. - model_name = argv[idx+1]; - softegg_cat.info() << "loading model " << model_name << endl; - } - ++idx; - break; - - case 't': // Get converted texture path. - if ( strcmp( argv[idx+1], "" ) ) { - // Get tex path name. - tex_path = argv[idx+1]; - softegg_cat.info() << "texture path: " << tex_path << endl; - } - ++idx; - break; - - case 'T': // Specify texture list filename. - if ( strcmp( argv[idx+1], "") ) { - // Get the name. - tex_filename = argv[idx+1]; - softegg_cat.info() << "creating texture list file: " << tex_filename << endl; - } - ++idx; - break; - - case 'S': // Set NURBS step. - if ( strcmp( argv[idx+1], "" ) ) { - nurbs_step = atoi(argv[idx+1]); - softegg_cat.info() << "NURBS step: " << nurbs_step << endl; - } - ++idx; - break; - - case 'M': // Set model output file name. - if ( strcmp( argv[idx+1], "" ) ) { - eggFileName = argv[idx+1]; - softegg_cat.info() << "Model output filename: " << eggFileName << endl; - } - ++idx; - break; - - case 'A': // Set anim output file name. - if ( strcmp( argv[idx+1], "" ) ) { - animFileName = argv[idx+1]; - softegg_cat.info() << "Anim output filename: " << animFileName << endl; - } - ++idx; - break; - - case 'N': // Set egg model name. - if ( strcmp( argv[idx+1], "" ) ) { - eggGroupName = argv[idx+1]; - softegg_cat.info() << "Egg group name: " << eggGroupName << endl; - } - ++idx; - break; - - case 'o': // Set search_prefix. - if ( strcmp( argv[idx+1], "" ) ) { - search_prefix = argv[idx+1]; - softegg_cat.info() << "Only converting models with prefix: " << search_prefix << endl; - } - ++idx; - break; - - case 'h': // print help message - Help(); - exit(1); - break; - - case 'c': // Cancel morph animation conversion - make_morph = FALSE; - softegg_cat.info() << "canceling morph conversion\n"; - break; - - case 'C': // Cancel uv animation conversion - make_duv = FALSE; - softegg_cat.info() << "canceling uv animation conversion\n"; - break; - - case 'D': // Omit the Dart flag - make_dart = FALSE; - softegg_cat.info() << "making a non-character model\n"; - break; - - case 'k': // Enable soft skinning - // make_soft = TRUE; fprintf( outStream, "enabling soft skinning\n" ); - softegg_cat.info() << "-k flag no longer necessary\n"; - break; - - case 'n': // Generate egg NURBS output - make_nurbs = TRUE; - softegg_cat.info() << "outputting egg NURBS info\n"; - break; - - case 'p': // Generate egg polygon output - make_poly = TRUE; - softegg_cat.info() << "outputting egg polygon info\n"; - break; - - case 'P': // Generate static pose from given frame - if ( strcmp( argv[idx+1], "" ) ) { - make_pose = TRUE; - pose_frame = atoi(argv[idx+1]); - softegg_cat.info() << "generating static pose from frame " << pose_frame << endl; - } - ++idx; - break; - - case 'a': // Compile animation tables. - make_anim = TRUE; - softegg_cat.info() << "attempting to compile anim tables\n"; - break; - - case 'F': // Build a flat skeleton. - flatten = TRUE; - softegg_cat.info() << "building a flat skeleton!!!\n"; - break; - - case 'x': // Shift NURBS parameters to preserve Alias textures. - shift_textures = TRUE; - softegg_cat.info() << "shifting NURBS parameters...\n"; - break; - - case 'i': // Ignore Soft uv texture offsets - ignore_tex_offsets = TRUE; - softegg_cat.info() << "ignoring texture offsets...\n"; - break; - - case 'u': // Use Soft prefix in model names - use_prefix = TRUE; - softegg_cat.info() << "using prefix in model names...\n"; - break; - - - case 'v': // print debug messages. - if ( strcmp( argv[idx+1], "" ) ) { - verbose = atoi(argv[idx+1]); - softegg_cat.info() << "using debug level " << verbose << endl; - } - ++idx; - break; - - case 'b': // Set animation start frame. - anim_start = atoi(argv[idx]+2); - softegg_cat.info() << "animation starting at frame: " << anim_start << endl; - break; - - case 'e': /// Set animation end frame. - anim_end = atoi(argv[idx]+2); - softegg_cat.info() << "animation ending at frame: " << anim_end << endl; - break; - - case 'f': /// Set animation frame rate. - if ( strcmp( argv[idx+1], "" ) ) { - anim_rate = atoi(argv[idx+1]); - softegg_cat.info() << "animation frame rate: " << anim_rate << endl; - } - ++idx; - break; - - default: - softegg_cat.info() << flag << " flag not supported\n"; - okflag = false; - } - idx++; - return (okflag); -} - -/** - * Allocates and returns a new copy of the converter. - */ -SomethingToEggConverter *SoftToEggConverter:: -make_copy() { - return new SoftToEggConverter(*this); -} - -/** - * Returns the English name of the file type this converter supports. - */ -string SoftToEggConverter:: -get_name() const { - return "Soft"; -} - -/** - * Returns the common extension of the file type this converter supports. - */ -string SoftToEggConverter:: -get_extension() const { - return "mb"; -} - -/** - * Returns the English name of the file type this converter supports. - */ -SoftNodeDesc *SoftToEggConverter:: -find_node(string name) { - return _tree.get_node(name); -} - -/** - * Given a texture element, return texture name with given tex_path - */ -char *SoftToEggConverter:: -GetTextureName( SAA_Scene *scene, SAA_Elem *texture ) { - char *fileName = new char[_MAX_PATH]; - char tempName[_MAX_PATH]; - SAA_texture2DGetPicName( scene, texture, _MAX_PATH, tempName ); - - if (tex_path) { - // softegg_cat.spam() << "tempName :" << tempName << endl; - strcpy(fileName, tex_path); - - // do some processing on the name string - char *tmpName = nullptr; - tmpName = strrchr(tempName, '/'); - if (tmpName) - tmpName++; - else - tmpName = tempName; - - // softegg_cat.spam() << "tmpName : " << tmpName << endl; - strcat(fileName, "/"); - strcat(fileName, tmpName); - } - else { - strcpy(fileName, tempName); - } - - strcat(fileName, ".pic"); - // softegg_cat.spam() << "fileName : " << fileName << endl; - - return fileName; -} - -/** - * Handles the reading of the input file and converting it to egg. Returns - * true if successful, false otherwise. - * - * This is designed to be as generic as possible, generally in support of run- - * time loading. Also see convert_soft(). - */ -bool SoftToEggConverter:: -convert_file(const Filename &filename) { - if (!open_api()) { - softegg_cat.error() - << "Soft is not available.\n"; - return false; - } - if (_character_name.empty()) { - _character_name = filename.get_basename_wo_extension(); - } - return convert_soft(false); -} - -/** - * Fills up the egg_data structure according to the global soft model data. - * Returns true if successful, false if there is an error. If from_selection - * is true, the converted geometry is based on that which is selected; - * otherwise, it is the entire Soft scene. - */ -bool SoftToEggConverter:: -convert_soft(bool from_selection) { - bool all_ok = true; - - _from_selection = from_selection; - _textures.clear(); - - PT(EggData) egg_data = new EggData; - set_egg_data(egg_data); - softegg_cat.spam() << "eggData " << get_egg_data() << "\n"; - - // append the command line - softegg_cat.info() << _commandLine << endl; - get_egg_data()->insert(get_egg_data()->begin(), new EggComment("", _commandLine)); - - if (_egg_data->get_coordinate_system() != CS_default) { - softegg_cat.spam() << "coordinate system is not default\n"; - exit(1); - } - - _tree._use_prefix = use_prefix; - _tree._search_prefix = search_prefix; - all_ok = _tree.build_complete_hierarchy(scene, database); - - // Lets see if we have gotten the hierarchy right _tree.print_hierarchy(); - // exit(1); - - char *root_name = _tree.GetRootName( eggFileName ); - - softegg_cat.debug() << "main group name: " << root_name << endl; - if (root_name) - _character_name = root_name; - - if (make_poly || make_nurbs) { - // Specify that the texture names should be relative to the output file. - Filename output_filename(eggFileName); - _path_replace->_path_store = PS_relative; - _path_replace->_path_directory = output_filename.get_dirname(); - - if (!convert_char_model()) { - all_ok = false; - } - - // generate soft skinning assignments if desired - if (!make_soft_skin()) { - all_ok = false; - } - - // sometimes you need to hard assign some vertices - if (!cleanup_soft_skin()) { - all_ok = false; - } - - // reparent_decals(get_egg_data()); - softegg_cat.info() << "Converted Softimage file\n"; - - // write out the egg model file - _egg_data->write_egg(output_filename); - softegg_cat.info() << "Wrote Egg file " << output_filename << endl; - } - if (make_anim) { - if (!convert_char_chan()) { - all_ok = false; - } - - // reparent_decals(get_egg_data()); - softegg_cat.info() << "Converted Softimage file\n"; - - // write out the egg model file - _egg_data->write_egg(Filename(animFileName)); - softegg_cat.info() << "Wrote Anim file " << animFileName << endl; - } - return all_ok; -} - -/** - * Attempts to open the Soft API if it was not already open, and returns true - * if successful, or false if there is an error. - */ -bool SoftToEggConverter:: -open_api() { - if ((scene_name == nullptr && model_name == nullptr) || database_name == nullptr) { - Usage(); - exit( 1 ); - } - if ((result = SAA_Init(rsrc_path, FALSE)) != SI_SUCCESS) { - softegg_cat.info() << "Error: Couldn't get resource path!\n"; - exit( 1 ); - } - // cout << "got past init" << endl; - if ((result = SAA_databaseLoad(database_name, &database)) != SI_SUCCESS) { - softegg_cat.info() << "Error: Couldn't load database!\n"; - exit( 1 ); - } - // cout << "got past database load" << endl; - if ((result = SAA_sceneGetCurrent(&scene)) != SI_SUCCESS) { - softegg_cat.info() << "Error: Couldn't get current scene!\n"; - exit( 1 ); - } - // cout << "got past get current" << endl; - if ((result = SAA_sceneLoad( &database, scene_name, &scene )) != SI_SUCCESS) { - softegg_cat.info() << "Error: Couldn't load scene " << scene_name << "!\n"; - exit( 1 ); - } - // cout << "got past scene load" << endl; - if ( SAA_updatelistGet( &scene ) == SI_SUCCESS ) { - PN_stdfloat time; - - softegg_cat.info() << "setting Scene to frame " << pose_frame << "...\n"; - // SAA_sceneSetPlayCtrlCurrentFrame( &scene, pose_frame ); - SAA_frame2Seconds( &scene, pose_frame, &time ); - SAA_updatelistEvalScene( &scene, time ); - if ( make_pose ) - SAA_sceneFreeze(&scene); - } - - // if no egg filename specified, make up a name - if ( eggFileName == nullptr ) { - string madeName; - string tempName(scene_name); - string::size_type end = tempName.find(".dsc"); - if (end != string::npos) { - madeName.assign(tempName.substr(0,end)); - if ( make_nurbs ) - madeName.insert(madeName.size(), "-nurb"); - madeName.insert(madeName.size(), ".egg" ); - } - eggFileName = new char[madeName.size()+1]; - strcpy(eggFileName, madeName.c_str()); - - // if no anim filename specified, make up a name - if ( animFileName == nullptr ) { - madeName.assign(tempName.substr(0,end)); - madeName.insert(madeName.size(), "-chan.egg"); - animFileName = new char[strlen(scene_name)+ 10]; - strcpy(animFileName, madeName.c_str()); - } - } - - return true; -} - -/** - * Closes the Soft API, if it was previously opened. Caution! Soft appears - * to call exit() when its API is closed. - */ -void SoftToEggConverter:: -close_api() { - // don't know yet -} - -/** - * Converts the file as an animatable character model, with joints and vertex - * membership. - */ -bool SoftToEggConverter:: -convert_char_model() { - softegg_cat.spam() << "character name " << _character_name << "\n"; - EggGroup *char_node = new EggGroup(eggGroupName); - get_egg_data()->add_child(char_node); - char_node->set_dart_type(EggGroup::DT_default); - - return convert_hierarchy(char_node); -} - -/** - * Given a tablename, it either creates a new eggSAnimData structure (if - * doesn't exist) or locates it. - */ -EggSAnimData *SoftToEggConverter:: -find_morph_table(char *name) { - EggSAnimData *anim = nullptr; - MorphTable::iterator mt; - for (mt = _morph_table.begin(); mt != _morph_table.end(); ++mt) { - anim = (*mt); - if (!strcmp(anim->get_name().c_str(), name)) - return anim; - } - - // create an entry - anim = new EggSAnimData(name); - anim->set_fps(_tree._fps); - _morph_table.push_back(anim); - morph_node->add_child(anim); - return anim; -} - -/** - * Converts the animation as a series of tables to apply to the character - * model, as retrieved earlier via AC_model. - */ -bool SoftToEggConverter:: -convert_char_chan() { - int start_frame = -1; - int end_frame = -1; - int frame_inc, frame; - double output_frame_rate = anim_rate; - - PN_stdfloat time; - - EggTable *root_table_node = new EggTable(); - get_egg_data()->add_child(root_table_node); - EggTable *bundle_node = new EggTable(eggGroupName); - bundle_node->set_table_type(EggTable::TT_bundle); - root_table_node->add_child(bundle_node); - EggTable *skeleton_node = new EggTable(""); - bundle_node->add_child(skeleton_node); - - morph_node = new EggTable("morph"); - - // Set the frame rate before we start asking for anim tables to be created. - SAA_sceneGetPlayCtrlStartFrame(&scene, &start_frame); - SAA_sceneGetPlayCtrlEndFrame(&scene, &end_frame); - SAA_sceneGetPlayCtrlFrameStep( &scene, &frame_inc ); - if (frame_inc != 1) // Hmmm...some files gave me frame_inc of 0, that can't be good - frame_inc = 1; - - softegg_cat.info() << "animation start frame: " << start_frame << " end frame: " << end_frame << endl; - softegg_cat.info() << "animation frame inc: " << frame_inc << endl; - - _tree._fps = output_frame_rate / frame_inc; - // _tree.clear_egg(get_egg_data(), NULL, root_node); - _tree.clear_egg(get_egg_data(), nullptr, skeleton_node); - - // Now we can get the animation data by walking through all of the frames, - // one at a time, and getting the joint angles at each frame. - - // This is just a temporary EggGroup to receive the transform for each joint - // each frame. - PT(EggGroup) tgroup = new EggGroup; - - int num_nodes = _tree.get_num_nodes(); - int i; - - // MTime frame(start_frame, MTime::uiUnit()); MTime frame_stop(end_frame, - // MTime::uiUnit()); start at first frame and go to last - if (make_pose) { - start_frame = pose_frame; - end_frame = pose_frame; - } - if (anim_start > 0) - start_frame = anim_start; - if (anim_end > 0) - end_frame = anim_end; - for ( frame = start_frame; frame <= end_frame; frame += frame_inc) { - SAA_frame2Seconds( &scene, frame, &time ); - // softegg_cat.spam() << "got time " << time << endl; - if (!make_pose) { - SAA_updatelistEvalScene( &scene, time ); - } - softegg_cat.spam() << "\n> animating frame " << frame << endl; - - // if (softegg_cat.is_debug()) { softegg_cat.debug(false) - softegg_cat.info() << "frame " << time << "\n"; - // } else { We have to write to cerr instead of softegg_cat to allow - // flushing without writing a newline. std::cerr << "." << std::flush; } - // MGlobal::viewFrame(frame); - - for (i = 0; i < num_nodes; i++) { - SoftNodeDesc *node_desc = _tree.get_node(i); - - if (node_desc->is_partial(search_prefix)) { - softegg_cat.debug() << endl; - continue; - } - if (make_morph) { - node_desc->make_morph_table(time); - } - if (node_desc->is_joint()) { - softegg_cat.spam() << "-----joint " << node_desc->get_name() << "\n"; - EggXfmSAnim *anim = _tree.get_egg_anim(node_desc); - // following function fills in the anim structure - node_desc->get_joint_transform(&scene, tgroup, anim, TRUE); - } - } - - // frame += frame_inc; - } - - if (has_morph) - bundle_node->add_child(morph_node); - - // Now optimize all of the tables we just filled up, for no real good - // reason, except that it makes the resulting egg file a little easier to - // read. - for (i = 0; i < num_nodes; i++) { - SoftNodeDesc *node_desc = _tree.get_node(i); - if (node_desc->is_partial(search_prefix)) - continue; - - if (node_desc->is_joint()) { - _tree.get_egg_anim(node_desc)->optimize(); - } - } - - softegg_cat.info(false) - << "\n"; - - return true; -} - -/** - * Generates egg structures for each node in the Soft hierarchy. - */ -bool SoftToEggConverter:: -convert_hierarchy(EggGroupNode *egg_root) { - int num_nodes = _tree.get_num_nodes(); - - _tree.clear_egg(get_egg_data(), egg_root, nullptr); - softegg_cat.spam() << "num_nodes = " << num_nodes << endl; - for (int i = 0; i < num_nodes; i++) { - if (!process_model_node(_tree.get_node(i))) { - return false; - } - softegg_cat.debug() << i << endl; - } - return true; -} - -/** - * Converts the indicated Soft node (given a MDagPath, similar in concept to - * Panda's NodePath) to the corresponding Egg structure. Returns true if - * successful, false if an error was encountered. - */ -bool SoftToEggConverter:: -process_model_node(SoftNodeDesc *node_desc) { - EggGroup *egg_group = nullptr; - const char *name = nullptr; - char *fullname = nullptr; - SAA_ModelType type; - - name = node_desc->get_name().c_str(); - softegg_cat.debug() << "element name <" << name << ">\n"; - - if (node_desc->is_junk()) { - softegg_cat.spam() << "no processing, it is junk\n"; - return true; - } - - // split - if (node_desc->is_partial(search_prefix)) { - softegg_cat.debug() << endl; - return true; - } - else - softegg_cat.debug() << endl << name << ":being processed" << endl; - - egg_group = _tree.get_egg_group(node_desc); - - // find out what type of node we're dealing with - SAA_modelGetType( &scene, node_desc->get_model(), &type ); - - softegg_cat.debug() << "encountered "; - switch(type){ - case SAA_MNILL: - softegg_cat.debug() << "null\n"; - break; - case SAA_MPTCH: - softegg_cat.debug() << "patch\n"; - break; - case SAA_MFACE: - softegg_cat.debug() << "face\n"; - // break; - case SAA_MSMSH: - softegg_cat.debug() << "mesh\n"; - node_desc->get_transform(&scene, egg_group, TRUE); - make_polyset(node_desc, egg_group, type); - break; - case SAA_MJNT: - softegg_cat.debug() << "joint"; - softegg_cat.debug() << " joint type " << node_desc->is_joint() << endl; - break; - case SAA_MSPLN: - softegg_cat.debug() << "spline\n"; - break; - case SAA_MMETA: - softegg_cat.debug() << "meta element\n"; - break; - case SAA_MBALL: - softegg_cat.debug() << "meta ball\n"; - break; - case SAA_MNCRV: - softegg_cat.debug() << "nurbs curve\n"; - break; - case SAA_MNSRF: - softegg_cat.debug() << "nurbs surf\n"; - node_desc->get_transform(&scene, egg_group, TRUE); - make_nurb_surface(node_desc, egg_group, type); - break; - default: - softegg_cat.debug() << "unknown type: " << type << "\n"; - } - - if (node_desc->is_joint()) - node_desc->get_transform(&scene, egg_group, FALSE); - - return true; -} - -/** - * Converts the indicated Soft polyset to a bunch of EggPolygons and parents - * them to the indicated egg group. - */ -void SoftToEggConverter:: -make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { - int id = 0; - int i, idx; - int numShapes; - SAA_Boolean valid; - SAA_Boolean visible; - PN_stdfloat *uCoords = nullptr; - PN_stdfloat *vCoords = nullptr; - string name = node_desc->get_name(); - - SAA_modelGetNodeVisibility( &scene, node_desc->get_model(), &visible ); - softegg_cat.spam() << "model visibility: " << visible << endl; - - // Only create egg polygon data if: the node is visible, and its not a NULL - // or a Joint, and we're outputing polys (or if we are outputing NURBS and - // the model is a poly mesh or a face) - if ( visible && - (type != SAA_MNILL) && - (type != SAA_MJNT) && - ((make_poly || - (make_nurbs && ((type == SAA_MSMSH) || (type == SAA_MFACE )) )) || - (!make_poly && !make_nurbs && make_duv && - ((type == SAA_MSMSH) || (type == SAA_MFACE )) )) - ) - { - // Get the number of key shapes - SAA_modelGetNbShapes( &scene, node_desc->get_model(), &numShapes ); - softegg_cat.spam() << "process_model_node: num shapes: " << numShapes << endl; - - // load all node data from soft for this node_desc - node_desc->load_poly_model(&scene, type); - - string vpool_name = name + ".verts"; - EggVertexPool *vpool = new EggVertexPool(vpool_name); - vpool->set_highest_index(0); - - // add the vertices in the _tree._root node, so that they will be - // written out first in egg file. This solves a problem of soft- - // skinning trying to access vertex pool before it is defined. - - _tree.get_egg_root()->insert(_tree.get_egg_root()->begin(), vpool); - - // We will need to transform all vertices from world coordinate space - // into the vertex space appropriate to this node. Usually, this is the - // same thing as world coordinate space, and this matrix will be - // identity; but if the node is under an instance (particularly, for - // instance, a billboard) then the vertex space will be different from - // world space. - LMatrix4d vertex_frame_inv = egg_group->get_vertex_frame_inv(); - - // Asad: change from soft2egg.c. Here I am trying to get one triangles - // vertices not all - for (idx=0; idxnumTri; ++idx) { - EggPolygon *egg_poly = new EggPolygon; - egg_group->add_child(egg_poly); - - softegg_cat.spam() << "processing polygon " << idx << endl; - - // Is this a double sided polygon? meaning check for back face flag - char *modelNoteStr = _tree.GetModelNoteInfo( &scene, node_desc->get_model() ); - if ( modelNoteStr != nullptr ) { - if ( strstr( modelNoteStr, "bface" ) != nullptr ) - egg_poly->set_bface_flag(TRUE); - } - - // read each triangle's control vertices into array - SAA_SubElem cvertices[3]; - SAA_triangleGetCtrlVertices( &scene, node_desc->get_model(), node_desc->gtype, id, 1, node_desc->triangles+idx, cvertices ); - - // read control vertices in this triangle - SAA_DVector cvertPos[3]; - SAA_ctrlVertexGetPositions( &scene, node_desc->get_model(), 3, cvertices, cvertPos); - - // read indices of each vertices in this triangle - int indices[3]; - indices[0] = indices[1] = indices[2] = 0; - SAA_ctrlVertexGetIndices( &scene, node_desc->get_model(), 3, cvertices, indices ); - - // read each control vertex's normals into an array - SAA_DVector normals[3]; - SAA_ctrlVertexGetNormals( &scene, node_desc->get_model(), 3, cvertices, normals ); - for (i=0; i<3; ++i) - softegg_cat.spam() << "normals[" << i <<"] = " << normals[i].x << " " << normals[i].y - << " " << normals[i].z << " " << normals[i].w << "\n"; - - // allocate arrays for u & v coords - if (node_desc->textures) { - if (node_desc->numTexLoc && node_desc->numTexTri[idx]) { - // allocate arrays for u & v coords I think there are one texture - // per triangle hence we need only 3 corrdinates - uCoords = new PN_stdfloat[3]; - vCoords = new PN_stdfloat[3]; - - // read the u & v coords into the arrays - if ( uCoords != nullptr && vCoords != nullptr) { - for ( i = 0; i < 3; i++ ) - uCoords[i] = vCoords[i] = 0.0f; - - // TODO: investigate the coord_cnt parameter... - SAA_ctrlVertexGetUVTxtCoords( &scene, node_desc->get_model(), 3, cvertices, - 3, uCoords, vCoords ); - } - else - softegg_cat.info() << "Not enough Memory for texture coords...\n"; - -#if 1 - for ( i=0; i<3; i++ ) - softegg_cat.spam() << "texcoords[" << i << "] = ( " << uCoords[i] << " , " << vCoords[i] <<" )\n"; -#endif - } - else if (node_desc->numTexGlb) { - // allocate arrays for u & v coords - uCoords = new PN_stdfloat[node_desc->numTexGlb*3]; - vCoords = new PN_stdfloat[node_desc->numTexGlb*3]; - - for ( i = 0; i < node_desc->numTexGlb*3; i++ ) { - uCoords[i] = vCoords[i] = 0.0f; - } - - // read the u & v coords into the arrays - if ( uCoords != nullptr && vCoords != nullptr) { - SAA_triCtrlVertexGetGlobalUVTxtCoords( &scene, node_desc->get_model(), 3, cvertices, - node_desc->numTexGlb, node_desc->textures, uCoords, vCoords ); - } - else - softegg_cat.info() << "Not enough Memory for texture coords...\n"; - } - } - - for ( i=0; i < 3; i++ ) { - EggVertex vert; - - // There are some conversions needed from local matrix to global - // coords - SAA_DVector local = cvertPos[i]; - SAA_DVector global = {0}; - - _VCT_X_MAT( global, local, node_desc->matrix ); - - softegg_cat.spam() << "indices[" << i << "] = " << indices[i] << "\n"; - softegg_cat.spam() << "cvert[" << i << "] = " << cvertPos[i].x << " " << cvertPos[i].y - << " " << cvertPos[i].z << " " << cvertPos[i].w << "\n"; - softegg_cat.spam() << " global cvert[" << i << "] = " << global.x << " " << global.y - << " " << global.z << " " << global.w << "\n"; - - // LPoint3d p3d(cvertPos[i].x, cvertPos[i].y, cvertPos[i].z); - LPoint3d p3d(global.x, global.y, global.z); - p3d = p3d * vertex_frame_inv; - vert.set_pos(p3d); - - local = normals[i]; - _VCT_X_MAT( global, local, node_desc->matrix ); - - softegg_cat.spam() << "normals[" << i <<"] = " << normals[i].x << " " << normals[i].y - << " " << normals[i].z << " " << normals[i].w << "\n"; - softegg_cat.spam() << " global normals[" << i <<"] = " << global.x << " " << global.y - << " " << global.z << " " << global.w << "\n"; - - LVector3d n3d(global.x, global.y, global.z); - n3d = n3d * vertex_frame_inv; - vert.set_normal(n3d); - - // if texture present set the texture coordinates - if (node_desc->textures) { - PN_stdfloat u, v; - - if (uCoords && vCoords) { - u = uCoords[i]; - v = 1.0f - vCoords[i]; - softegg_cat.spam() << "texcoords[" << i << "] = " << u << " " - << v << endl; - - vert.set_uv(LTexCoordd(u, v)); - // vert.set_uv(LTexCoordd(uCoords[i], vCoords[i])); - } - } - vert.set_external_index(indices[i]); - egg_poly->add_vertex(vpool->create_unique_vertex(vert)); - - // check to see if material is present - PN_stdfloat r,g,b,a; - SAA_elementIsValid( &scene, &node_desc->materials[idx], &valid ); - // material present - get the color - if ( valid ) { - SAA_materialGetDiffuse( &scene, &node_desc->materials[idx], &r, &g, &b ); - SAA_materialGetTransparency( &scene, &node_desc->materials[idx], &a ); - egg_poly->set_color(LColor(r, g, b, 1.0f - a)); - softegg_cat.spam() << "color r = " << r << " g = " << g << " b = " << b << " a = " << 1.0f - a << "\n"; - } - else { // no material - default to white - egg_poly->set_color(LColor(1.0, 1.0, 1.0, 1.0)); - softegg_cat.spam() << "default color\n"; - } - - /* - // keep a one to one copy in this node's vpool - EggVertex *t_vert = new EggVertex(vert); - if (!t_vert) { - softegg_cat.spam() << "out of memeory " << endl; - nassertv(t_vert != NULL); - } - node_desc->get_vpool()->add_vertex(t_vert, indices[i]); - */ - - softegg_cat.spam() << "\n"; - } - - // Now apply the shader. - if (node_desc->textures != nullptr) { - if (node_desc->numTexLoc && node_desc->numTexTri[idx]) { - if (!strstr(node_desc->texNameArray[idx], "noIcon")) - set_shader_attributes(node_desc, *egg_poly, idx); - else - softegg_cat.spam() << "texname :" << node_desc->texNameArray[idx] << endl; - } - else { - if (!strstr(node_desc->texNameArray[0], "noIcon")) - set_shader_attributes(node_desc, *egg_poly, 0); - else - softegg_cat.spam() << "texname :" << node_desc->texNameArray[0] << endl; - } - } - } - // if model has key shapes, generate vertex offsets - if ( numShapes > 0 && make_morph ) - node_desc->make_vertex_offsets( numShapes); - } -} - -/** - * Converts the indicated Soft nurbs set to a bunch of EggPolygons and parents - * them to the indicated egg group. - */ -void SoftToEggConverter:: -make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { - int id = 0; - int i, j, k; - int numShapes; - SAA_Boolean valid; - SAA_Boolean visible; - PN_stdfloat *uCoords = nullptr; - PN_stdfloat *vCoords = nullptr; - string name = node_desc->get_name(); - - SAA_modelGetNodeVisibility( &scene, node_desc->get_model(), &visible ); - softegg_cat.spam() << "model visibility: " << visible << endl; - softegg_cat.spam() << "nurbs!!!surface!!!" << endl; - - // check to see if its a nurbs surface - if ( (type == SAA_MNSRF) && ( visible ) && (( make_nurbs ) - || ( !make_nurbs && !make_poly && make_duv )) ) - { - // Get the number of key shapes - SAA_modelGetNbShapes( &scene, node_desc->get_model(), &numShapes ); - softegg_cat.spam() << "process_model_node: num shapes: " << numShapes << endl; - - // load all node data from soft for this node_desc - node_desc->load_nurbs_model(&scene, type); - - string vpool_name = name + ".verts"; - EggVertexPool *vpool = new EggVertexPool(vpool_name); - vpool->set_highest_index(0); - - // add the vertices in the _tree._egg_root node, so that they will be - // written out first in egg file. This solves a problem of soft- - // skinning trying to access vertex pool before it is defined. - - // _tree.get_egg_root()->add_child(vpool); - _tree.get_egg_root()->insert(_tree.get_egg_root()->begin(), vpool); - - // egg_group->add_child(vpool); - - /* - // create a copy of vpool in node_desc which will be used later for - // soft_skinning - node_desc->create_vpool(vpool_name); - */ - - int uRows, vRows; - int uKnots, vKnots; - int uExtra, vExtra; - int uDegree, vDegree; - int uCurves, vCurves; - - vector Knots; - - EggNurbsSurface *eggNurbs = new EggNurbsSurface( name ); - - // create nurbs representation of surface - SAA_nurbsSurfaceGetDegree( &scene, node_desc->get_model(), &uDegree, &vDegree ); - softegg_cat.spam() << "nurbs degree: " << uDegree << " u, " << vDegree << " v\n"; - - SAA_nurbsSurfaceGetNbKnots( &scene, node_desc->get_model(), &uKnots, &vKnots ); - softegg_cat.spam() << "nurbs knots: " << uKnots << " u, " << vKnots << " v\n"; - - SAA_Boolean uClosed = FALSE; - SAA_Boolean vClosed = FALSE; - - SAA_nurbsSurfaceGetClosed( &scene, node_desc->get_model(), &uClosed, &vClosed); - - uExtra = vExtra = 2; - if ( uClosed ) { - softegg_cat.spam() << "nurbs is closed in u...\n"; - uExtra += 4; - } - if ( vClosed ) { - softegg_cat.spam() << "nurbs is closed in v...\n"; - vExtra += 4; - } - eggNurbs->setup(uDegree+1, vDegree+1, - uKnots + uExtra, vKnots + vExtra); - - softegg_cat.spam() << "from eggNurbs: num u knots " << eggNurbs->get_num_u_knots() << endl; - softegg_cat.spam() << "from eggNurbs: num v knots " << eggNurbs->get_num_v_knots() << endl; - softegg_cat.spam() << "from eggNurbs: num u cvs " << eggNurbs->get_num_u_cvs() << endl; - softegg_cat.spam() << "from eggNurbs: num v cvs " << eggNurbs->get_num_v_cvs() << endl; - - SAA_nurbsSurfaceGetNbVertices( &scene, node_desc->get_model(), &uRows, &vRows ); - softegg_cat.spam() << "nurbs vertices: " << uRows << " u, " << vRows << " v\n"; - - SAA_nurbsSurfaceGetNbCurves( &scene, node_desc->get_model(), &uCurves, &vCurves ); - softegg_cat.spam() << "nurbs curves: " << uCurves << " u, " << vCurves << " v\n"; - - if ( shift_textures ) { - if ( uClosed ) - // shift starting point on NURBS surface for correct textures - SAA_nurbsSurfaceShiftParameterization( &scene, node_desc->get_model(), -2, 0 ); - - if ( vClosed ) - // shift starting point on NURBS surface for correct textures - SAA_nurbsSurfaceShiftParameterization( &scene, node_desc->get_model(), 0, -2 ); - } - - SAA_nurbsSurfaceSetStep( &scene, node_desc->get_model(), nurbs_step, nurbs_step ); - - // Is this a double sided polygon? meaning check for back face flag - char *modelNoteStr = _tree.GetModelNoteInfo( &scene, node_desc->get_model() ); - if ( modelNoteStr != nullptr ) { - if ( strstr( modelNoteStr, "bface" ) != nullptr ) { - eggNurbs->set_bface_flag(TRUE); - softegg_cat.spam() << "Set backface flag\n"; - } - } - - double *uKnotArray = new double[uKnots]; - double *vKnotArray = new double[vKnots]; - result = SAA_nurbsSurfaceGetKnots( &scene, node_desc->get_model(), node_desc->gtype, 0, - uKnots, vKnots, uKnotArray, vKnotArray ); - - if (result != SI_SUCCESS) { - softegg_cat.spam() << "Couldn't get knots\n"; - exit(1); - } - - // Lets prepare the softimage knots and then assign to eggKnots - add_knots( Knots, uKnotArray, uKnots, uClosed, uDegree ); - softegg_cat.spam() << "u knots: "; - for (i = 0; i < (int)Knots.size(); i++) { - softegg_cat.spam() << Knots[i] << " "; - eggNurbs->set_u_knot(i, Knots[i]); - } - softegg_cat.spam() << endl; - - Knots.resize(0); - add_knots( Knots, vKnotArray, vKnots, vClosed, vDegree ); - softegg_cat.spam() << "v knots: "; - for (i = 0; i < (int)Knots.size(); i++) { - softegg_cat.spam() << Knots[i] << " "; - eggNurbs->set_v_knot(i, Knots[i]); - } - softegg_cat.spam() << endl; - - // lets get the number of vertices from softimage - int numVert; - SAA_modelGetNbVertices( &scene, node_desc->get_model(), &numVert ); - - softegg_cat.spam() << numVert << " CV's\n"; - - // get the CV's - SAA_DVector *vertices = nullptr; - vertices = new SAA_DVector[numVert]; - - SAA_modelGetVertices( &scene, node_desc->get_model(), node_desc->gtype, 0, numVert, vertices ); - - LMatrix4d vertex_frame_inv = egg_group->get_vertex_frame_inv(); - - // create the buffer for EggVertices - EggVertex *verts = new EggVertex[numVert]; - - softegg_cat.spam() << endl << eggNurbs->get_num_cvs() << endl << endl; - - // for ( i = 0; iget_num_cvs(); i++ ) { - for ( k = 0; kget_u_index(i); - int vi = eggNurbs->get_v_index(i); - - int k = vRows * ui + vi; - - softegg_cat.spam() << i << ": ui " << ui << ", vi " << vi << ", k " << k << endl; - - softegg_cat.spam() << "original cv[" << k << "] = " - << vertices[k].x << " " << vertices[k].y << " " - << vertices[k].z << " " << vertices[k].w << endl; - */ - - // convert to global coords - _VCT_X_MAT( global, vertices[k], node_desc->matrix ); - - // preserve original weight - global.w = vertices[k].w; - - // normalize coords to weight - global.x *= global.w; - global.y *= global.w; - global.z *= global.w; - - /* - softegg_cat.spam() << "global cv[" << k << "] = " - << global.x << " " << global.y << " " - << global.x << " " << global.w << endl; - */ - - LPoint4d p4d(global.x, global.y, global.z, global.w); - p4d = p4d * vertex_frame_inv; - verts[k].set_pos(p4d); - - // check to see if material is present - if (node_desc->numNurbMats) { - PN_stdfloat r,g,b,a; - SAA_elementIsValid( &scene, &node_desc->materials[0], &valid ); - // material present - get the color - if ( valid ) { - SAA_materialGetDiffuse( &scene, &node_desc->materials[0], &r, &g, &b ); - SAA_materialGetTransparency( &scene, &node_desc->materials[0], &a ); - verts[k].set_color(LColor(r, g, b, 1.0f - a)); - // softegg_cat.spam() << "color r = " << r << " g = " << g << " b - // = " << b << " a = " << a << "\n"; - } - else { // no material - default to white - verts[k].set_color(LColor(1.0, 1.0, 1.0, 1.0)); - softegg_cat.spam() << "default color\n"; - } - } - vpool->add_vertex(verts+k, k); - eggNurbs->add_vertex(vpool->get_vertex(k)); - - if ( uClosed ) { - // add first uDegree verts to end of row - if ( (k % uRows) == ( uRows - 1) ) { - for ( i = 0; i < uDegree; i++ ) { - // add vref's to NURBS info - eggNurbs->add_vertex( vpool->get_vertex(i+((k/uRows)*uRows)) ); - } - } - } - } - - // check to see if the NURB is closed in v - if ( vClosed && !uClosed ) { - // add first vDegree rows of verts to end of list - for ( int i = 0; i < vDegree*uRows; i++ ) - eggNurbs->add_vertex( vpool->get_vertex(i) ); - } - // check to see if the NURB is closed in u and v - else if ( vClosed && uClosed ) { - // add the first (degree) v verts and a few extra - for good measure - for ( i = 0; i < vDegree; i++ ) { - // add first vDegree rows of verts to end of list - for ( j = 0; j < uRows; j++ ) - eggNurbs->add_vertex( vpool->get_vertex(j+(i*uRows)) ); - - // if u is closed to we have added uDegree verts onto the ends of - // the rows - add them here too - for ( k = 0; k < uDegree; k++ ) - eggNurbs->add_vertex( vpool->get_vertex(k+(i*uRows)+((k/uRows)*uRows)) ); - } - } - - // We add the NURBS to the group down here, after all of the vpools for - // the trim curves have been added. - egg_group->add_child(eggNurbs); - - // Now apply the shader. - if (node_desc->textures != nullptr) { - if (!strstr(node_desc->texNameArray[0], "noIcon")) - set_shader_attributes(node_desc, *eggNurbs, 0); - else - softegg_cat.spam() << "texname :" << node_desc->texNameArray[0] << endl; - } - - // if model has key shapes, generate vertex offsets - if ( numShapes > 0 && make_morph ) - node_desc->make_vertex_offsets( numShapes); - } -} - -/** - * Given a parametric surface, and its knots, create the appropriate egg - * structure by filling in Soft's implicit knots and assigning the rest to - * eggKnots. - */ -void SoftToEggConverter:: -add_knots( vector &eggKnots, double *knots, int numKnots, SAA_Boolean closed, int degree ) { - - int k = 0; - double lastKnot = knots[0]; - double *newKnots; - - // add initial implicit knot(s) - if ( closed ) { - int i = 0; - newKnots = new double[degree]; - - // need to add (degree) number of knots - for ( k = numKnots - 1; k >= numKnots - degree; k-- ) { - // we have to know these in order to calculate next knot value so hold - // them in temp array - newKnots[i] = lastKnot - (knots[k] - knots[k-1]); - lastKnot = newKnots[i]; - i++; - } - for ( k = degree - 1; k >= 0; k-- ) { - eggKnots.push_back( newKnots[k] ); - softegg_cat.spam() << "knots[" << k << "] = " << newKnots[k] << endl; - } - } - else { - eggKnots.push_back( knots[k] ); - softegg_cat.spam() << "knots[" << k << "] = " << knots[k] << endl; - } - - // add the regular complement of knots - for (k = 0; k < numKnots; k++) { - eggKnots.push_back( knots[k] ); - softegg_cat.spam() << "knots[" << k+1 << "] = " << knots[k] << endl; - } - - lastKnot = knots[numKnots-1]; - - // add trailing implicit knots - if ( closed ) { - // need to add (degree) number of knots - for ( k = 1; k <= degree; k++ ) { - eggKnots.push_back( lastKnot + (knots[k] - knots[k-1]) ); - softegg_cat.spam() << "knots[" << k << "] = " << lastKnot + (knots[k] - knots[k-1]) << endl; - lastKnot = lastKnot + (knots[k] - knots[k-1]); - } - } - else { - eggKnots.push_back( knots[k-1] ); - softegg_cat.spam() << "knots[" << k+1 << "] = " << knots[k-1] << endl; - } -} - -/** - * Given an egg vertex pool, map each vertex therein to a vertex within an - * array of SAA model vertices of size numVert. Mapping is done by closest - * proximity. - */ -int *SoftToEggConverter:: -FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) { - int i,j; - int *vertMap = nullptr; - int vpoolSize = (int)vpool->size(); - PN_stdfloat closestDist; - PN_stdfloat thisDist; - int closest; - - vertMap = new int[vpoolSize]; - i = 0; - EggVertexPool::iterator vi; - for (vi = vpool->begin(); vi != vpool->end(); ++vi, ++i) { - EggVertex *vert = (*vi); - softegg_cat.spam() << "vert external index = " << vert->get_external_index() << endl; - // softegg_cat.spam() << "found vert " << vert << endl; softegg_cat.spam() - // << "vert [" << i << "] " << vpool->get_vertex(i+1); - LPoint3d p3d = vert->get_pos3(); - - // find closest model vertex - for ( j = 0; j < numVert; j++ ) { - // calculate distance - thisDist = sqrtf( - powf( p3d[0] - vertices[j].x , 2 ) + - powf( p3d[1] - vertices[j].y , 2 ) + - powf( p3d[2] - vertices[j].z , 2 ) ); - - // remember this if its the closest so far - if ( !j || ( thisDist < closestDist ) ) { - closest = j; - closestDist = thisDist; - } - } - - vertMap[i] = closest; - softegg_cat.spam() << "mapping v " << i << " of " << vpoolSize-1 << ":( " - << p3d[0] << " " - << p3d[1] << " " - << p3d[2] << ")\n"; - - softegg_cat.spam() << " to cv " << closest << " of " << numVert-1 << ":( " - << vertices[closest].x << " " - << vertices[closest].y << " " - << vertices[closest].z << " )\tdelta = " << closestDist << endl; - } - return vertMap; -} - -/** - * make soft skin assignments to the mesh finally call cleanup_soft_skin to - * clean it up - */ -bool SoftToEggConverter:: -make_soft_skin() { - int num_nodes = _tree.get_num_nodes(); - SoftNodeDesc *node_desc; - SAA_Boolean isSkeleton; - - softegg_cat.spam() << endl << "----------------------------------------------------------------" << endl; - - for (int i = 0; i < num_nodes; i++) { - node_desc = _tree.get_node(i); - SAA_modelIsSkeleton( &scene, node_desc->get_model(), &isSkeleton ); - - softegg_cat.spam() << "??checking node " << node_desc->get_name() << " isSkel " << isSkeleton << " isJoint " << node_desc->is_joint() << endl; - if (isSkeleton && node_desc->is_joint()) { - - if (node_desc->is_partial(search_prefix)) - continue; - - // Now that we've added all the polygons (and created all the vertices), - // go back through the vertex pool and set up the appropriate joint - // membership for each of the vertices. - - // check for envelops - int numEnv; - SAA_ModelType type; - SAA_Elem *envelopes; - SAA_Elem *model = node_desc->get_model(); - EggGroup *joint = nullptr; - EggVertexPool *vpool; - - SAA_skeletonGetNbEnvelopes( &scene, model, &numEnv ); - if ( numEnv == 0 ) { - softegg_cat.spam() << "no soft skinning for joint " << node_desc->get_name() << endl; - continue; - } - - // it's got envelopes - must be soft skinned - softegg_cat.spam() << endl << "found skeleton part( " << node_desc->get_name() << ")!\n"; - softegg_cat.spam() << "numEnv = " << numEnv << endl; - // allocate envelope array - envelopes = new SAA_Elem[numEnv]; - if ( envelopes == nullptr ) { - softegg_cat.info() << "Out Of Memory" << endl; - exit(1); - } - int thisEnv; - SAA_EnvType envType; - bool hasEnvVertices = 0; - - SAA_skeletonGetEnvelopes( &scene, model, numEnv, envelopes ); - for ( thisEnv = 0; thisEnv < numEnv; thisEnv++ ) { - softegg_cat.spam() << "env[" << thisEnv << "]: "; - SAA_envelopeGetType( &scene, &envelopes[thisEnv], &envType ); - - if ( envType == SAA_ENVTYPE_NONE ) { - softegg_cat.spam() << "envType = none\n"; - } - else if ( envType == SAA_ENVTYPE_FLXLCL ) { - softegg_cat.spam() << "envType = flexible, local\n"; - hasEnvVertices = 1; - } - else if ( envType == SAA_ENVTYPE_FLXGLB ) { - softegg_cat.spam() << "envType = flexible, global\n"; - hasEnvVertices = 1; - } - else if ( envType == SAA_ENVTYPE_RGDGLB ) { - softegg_cat.spam() << "envType = rigid, global\n"; - hasEnvVertices = 1; - } - else { - softegg_cat.spam() << "envType = unknown\n"; - } - - } - if ( !hasEnvVertices ) - continue; - - SAA_SubElem *envVertices = nullptr; - int *numEnvVertices; - int i,j,k; - - numEnvVertices = new int[numEnv]; - - if ( numEnvVertices != nullptr ) { - SAA_envelopeGetNbCtrlVertices( &scene, model, numEnv, envelopes, numEnvVertices ); - int totalEnvVertices = 0; - for( i = 0; i < numEnv; i++ ) { - totalEnvVertices += numEnvVertices[i]; - softegg_cat.spam() << "numEnvVertices[" << i << "] = " << numEnvVertices[i] << endl; - } - softegg_cat.spam() << "total env verts = " << totalEnvVertices << endl; - if ( totalEnvVertices == 0 ) - continue; - - envVertices = new SAA_SubElem[totalEnvVertices]; - if ( envVertices != nullptr ) { - result = SAA_envelopeGetCtrlVertices( &scene, model, - numEnv, envelopes, numEnvVertices, envVertices); - if (result != SI_SUCCESS) { - softegg_cat.spam() << "error: GetCtrlVertices\n"; - exit(1); - } - // loop through for each envelope - for ( i = 0; i < numEnv; i++ ) { - PN_stdfloat *weights = nullptr; - int vertArrayOffset = 0; - softegg_cat.spam() << "envelope[" << i << "]: "; - weights = new PN_stdfloat[numEnvVertices[i]]; - if ( weights ) { - char *envName; - int *vpoolMap = nullptr; - for ( j = 0; j < i; j++ ) - vertArrayOffset += numEnvVertices[j]; - softegg_cat.spam() << "envVertArray offset = " << vertArrayOffset; - - /* - if (vertArrayOffset == totalEnvVertices) { - softegg_cat.spam() << endl; vpoolMap = FindClosestTriVert( vpool, globalModelVertices, modelNumVert ); - - break; - } - */ - - // get the weights of the envelope vertices - result = SAA_ctrlVertexGetEnvelopeWeights( &scene, model, &envelopes[i], - numEnvVertices[i], - &envVertices[vertArrayOffset], weights ); - - // Get the name of the envelope model - if ( use_prefix ) { - // Get the FULL name of the envelope - envName = _tree.GetFullName( &scene, &envelopes[i] ); - } - else { - // Get the name of the envelope - envName = _tree.GetName( &scene, &envelopes[i] ); - } - - softegg_cat.spam() << " envelop name is [" << envName << "]" << endl; - - if (result != SI_SUCCESS) { - softegg_cat.spam() << "warning: this envelop doesn't have any weights\n"; - continue; - } - - result = SAA_modelGetType( &scene, &envelopes[i], &type ); - if (result != SI_SUCCESS) { - softegg_cat.debug() << "choked on get type\n"; - exit(1); - } - - softegg_cat.spam() << "envelope model type "; - if ( type == SAA_MSMSH ) - softegg_cat.spam() << "MESH\n"; - else if ( type == SAA_MNSRF ) - softegg_cat.spam() << "NURBS\n"; - else - softegg_cat.spam() << "OTHER\n"; - - int *envVtxIndices = nullptr; - envVtxIndices = new int[numEnvVertices[i]]; - - // Get the envelope vertex indices - result = SAA_ctrlVertexGetIndices( &scene, &envelopes[i], numEnvVertices[i], - &envVertices[vertArrayOffset], envVtxIndices ); - - if (result != SI_SUCCESS) { - softegg_cat.debug() << "error: choked on get indices\n"; - exit(1); - } - - // find out how many vertices the model has - int modelNumVert; - - SAA_modelGetNbVertices( &scene, &envelopes[i], &modelNumVert ); - - SAA_DVector *modelVertices = nullptr; - modelVertices = new SAA_DVector[modelNumVert]; - - // get the model vertices - SAA_modelGetVertices( &scene, &envelopes[i], - SAA_GEOM_ORIGINAL, 0, modelNumVert, - modelVertices ); - - // create array of global model coords - SAA_DVector *globalModelVertices = nullptr; - globalModelVertices = new SAA_DVector[modelNumVert]; - PN_stdfloat matrix[4][4]; - - // tranform local model vert coords to global - - // first get the global matrix - SAA_modelGetMatrix( &scene, &envelopes[i], SAA_COORDSYS_GLOBAL, matrix ); - - // populate array of global model verts - for ( j = 0; j < modelNumVert; j++ ) { - _VCT_X_MAT( globalModelVertices[j], - modelVertices[j], matrix ); - } - - // Get the vpool - string s_name = envName; - SoftNodeDesc *mesh_node = find_node(s_name); - if (!mesh_node) { - softegg_cat.debug() << "error: node " << s_name << " not found in tree\n"; - exit(1); - } - string vpool_name = s_name + ".verts"; - EggNode *t = _tree.get_egg_root()->find_child(vpool_name); - if (t) - DCAST_INTO_R(vpool, t, nullptr); - - // find the mapping of the vertices that match this envelop - if (vpool) { - softegg_cat.spam() << "found vpool of size " << vpool->size() << endl; - if ( !make_nurbs || (type == SAA_MSMSH) ) { - vpoolMap = FindClosestTriVert( vpool, globalModelVertices, modelNumVert ); - } - } - else { - softegg_cat.debug() << "warning: vpool " << vpool_name << " not found\n"; - continue; // could be because of not visible - } - - joint = node_desc->get_egg_group(); - // for every envelope vertex - for (j = 0; j < numEnvVertices[i]; j++) { - double scaledWeight = weights[j]/ 100.0f; - - // make sure its in legal range - if (( envVtxIndices[j] < modelNumVert ) - && ( envVtxIndices[j] >= 0 )) { - if ( (type == SAA_MNSRF) && make_nurbs ) { - // assign all referenced control vertices - EggVertex *vert = vpool->get_vertex(envVtxIndices[j]); - if (!vert) { - softegg_cat.debug() << "possible error: index " << envVtxIndices[j] << ": vert is " << vert << endl; - continue; - } - joint->ref_vertex( vert, scaledWeight ); - softegg_cat.spam() << j << ": adding vref to cv " << envVtxIndices[j] - << " with weight " << scaledWeight << endl; - - /* - envPool->Vertex(envVtxIndices[j])->AddJoint( joint, scaledWeight ); - // set flag to show this vertex has been assigned - envPool->Vertex(envVtxIndices[j])->multipleJoints = 1; - */ - } - else { - // assign all the tri verts associated with this control - // vertex to joint - softegg_cat.spam() << j << "--trying to find " << envVtxIndices[j] << endl; - for ( k = 0; k < (int)vpool->size(); k++ ) { - if ( vpoolMap[k] == envVtxIndices[j] ) { - EggVertex *vert = vpool->get_vertex(k+1); - // EggVertex *vert = - // mesh_node->get_vpool()->get_vertex(vpoolMap[k]+1); - if (!vert) { - softegg_cat.debug() << "possible error: index " << k+1 << ": vert is " << vert << endl; - break; - } - - joint->ref_vertex(vert, scaledWeight); - softegg_cat.spam() << j << ": adding vref from cv " << envVtxIndices[j] - << " to vert " << k+1 << " with weight " << scaledWeight - << "(vpool)\n"; - /* - envPool->Vertex(k)->AddJoint( joint, scaledWeight ); - // set flag to show this vertex has been assigned - envPool->Vertex(k)->multipleJoints = 1; - */ - } - } - } - } - } - } - } - } - } - } - } - return true; -} -/** - * Given a model, make sure all its vertices have been soft assigned. If not - * hard assign to the last joint we saw. - */ -bool SoftToEggConverter:: -cleanup_soft_skin() -{ - int num_nodes = _tree.get_num_nodes(); - SoftNodeDesc *node_desc; - - softegg_cat.spam() << endl << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; - - for (int i = 0; i < num_nodes; i++) { - node_desc = _tree.get_node(i); - if (node_desc->is_partial(search_prefix)) - continue; - - SAA_Elem *model = node_desc->get_model(); - EggGroup *joint = nullptr; - EggVertexPool *vpool = nullptr; - SAA_ModelType type; - - // find out what type of node we're dealing with - - SAA_modelGetType( &scene, model, &type ); - - softegg_cat.debug() << "Cleaning up model------- " << node_desc->get_name() << endl; - - // this step is weird - I think I want it here but it seems to break some - // models. Files like props-props_wh_cookietime.3-0 in - // fulrndpubvrmlchipchips_adventurecharzone1roomswarehouse_final need to - // do the "if (skel)" bit. - - // find the vpool for this model - string vpool_name = node_desc->get_name() + ".verts"; - EggNode *t = _tree.get_egg_root()->find_child(vpool_name); - if (t) - DCAST_INTO_R(vpool, t, nullptr); - - if (!vpool) { - // softegg_cat.spam() << "couldn't find vpool " << vpool_name << endl; - continue; - } - - int numVerts = (int)vpool->size(); - softegg_cat.spam() << "found vpool " << vpool_name << " w/ " << numVerts << " verts\n"; - - // if this node is a joint, then these vertices belong to this joint - if (node_desc->is_joint()) - joint = node_desc->get_egg_group(); - else { - // find the closest _parentJoint - SoftNodeDesc *parentJ = node_desc; - while( parentJ && !parentJ->_parentJoint) { - if ( parentJ->_parent) { - SAA_Boolean isSkeleton; - // softegg_cat.spam() << " checking parent " << - // parentJ->_parent->get_name() << endl; - if (parentJ->_parent->has_model()) - SAA_modelIsSkeleton( &scene, parentJ->_parent->get_model(), &isSkeleton ); - - if (isSkeleton) { - joint = parentJ->_parent->get_egg_group(); - softegg_cat.spam() << "parent to " << parentJ->_parent->get_name() << endl; - break; - } - - parentJ = parentJ->_parent; - } - else - break; - } - if (!joint && (!parentJ || !parentJ->_parentJoint)) { - softegg_cat.spam() << node_desc->get_name() << " has no _parentJoint?!" << endl; - continue; - } - - if (!joint) { - softegg_cat.spam() << "parent joint to " << parentJ->_parentJoint->get_name() << endl; - joint = parentJ->_parentJoint->get_egg_group(); - } - } - EggVertexPool::iterator vi; - double membership = 1.0f; - for ( vi = vpool->begin(); vi != vpool->end(); ++vi) { - EggVertex *vert = (*vi); - - // if this vertex has not been soft assigned, then hard assign it to the - // parentJoint - if ( vert->gref_size() == 0 ) { - - softegg_cat.spam() << "vert " << vert->get_external_index() << " not assigned!\n"; - - // hard skin this vertex - joint->ref_vertex( vert, 1.0f ); - } - } - } - return true; -} - -/** - * Applies the known shader attributes to the indicated egg primitive. - */ -void SoftToEggConverter:: -set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, int idx) { - char *texName = node_desc->texNameArray[idx]; - EggTexture tex(texName, ""); - - Filename filename = Filename::from_os_specific(texName); - Filename fullpath = _path_replace->match_path(filename, get_model_path()); - tex.set_filename(_path_replace->store_path(fullpath)); - tex.set_fullpath(fullpath); - // tex.set_format(EggTexture::F_rgb); - apply_texture_properties(tex, node_desc->uRepeat[idx], node_desc->vRepeat[idx]); - - EggTexture *new_tex = _textures.create_unique_texture(tex, ~EggTexture::E_tref_name); - primitive.set_texture(new_tex); -} - -/** - * Applies all the appropriate texture properties to the EggTexture object, - * including wrap modes and texture matrix. - */ -void SoftToEggConverter:: -apply_texture_properties(EggTexture &tex, int uRepeat, int vRepeat) { - // Let's mipmap all textures by default. - tex.set_minfilter(EggTexture::FT_linear_mipmap_linear); - tex.set_magfilter(EggTexture::FT_linear); - - EggTexture::WrapMode wrap_u = uRepeat > 0 ? EggTexture::WM_repeat : EggTexture::WM_clamp; - EggTexture::WrapMode wrap_v = vRepeat > 0 ? EggTexture::WM_repeat : EggTexture::WM_clamp; - - tex.set_wrap_u(wrap_u); - tex.set_wrap_v(wrap_v); - /* - LMatrix3d mat = color_def.compute_texture_matrix(); - if (!mat.almost_equal(LMatrix3d::ident_mat())) { - tex.set_transform(mat); - } - */ -} -#if 0 -/** - * Compares the texture properties already on the texture (presumably set by a - * previous call to apply_texture_properties()) and returns false if they - * differ from that specified by the indicated color_def object, or true if - * they match. - */ -bool SoftToEggConverter:: -compare_texture_properties(EggTexture &tex, - const SoftShaderColorDef &color_def) { - bool okflag = true; - - EggTexture::WrapMode wrap_u = color_def._wrap_u ? EggTexture::WM_repeat : EggTexture::WM_clamp; - EggTexture::WrapMode wrap_v = color_def._wrap_v ? EggTexture::WM_repeat : EggTexture::WM_clamp; - - if (wrap_u != tex.determine_wrap_u()) { - // Choose the more general of the two. - if (wrap_u == EggTexture::WM_repeat) { - tex.set_wrap_u(wrap_u); - } - okflag = false; - } - if (wrap_v != tex.determine_wrap_v()) { - if (wrap_v == EggTexture::WM_repeat) { - tex.set_wrap_v(wrap_v); - } - okflag = false; - } - - LMatrix3d mat = color_def.compute_texture_matrix(); - if (!mat.almost_equal(tex.get_transform())) { - okflag = false; - } - - return okflag; -} -#endif -/** - * Recursively walks the egg hierarchy, reparenting "decal" type nodes below - * their corresponding "decalbase" type nodes, and setting the flags. - * - * Returns true on success, false if some nodes were incorrect. - */ -bool SoftToEggConverter:: -reparent_decals(EggGroupNode *egg_parent) { - bool okflag = true; - - // First, walk through all children of this node, looking for the one decal - // base, if any. - EggGroup *decal_base = nullptr; - pvector decal_children; - - EggGroupNode::iterator ci; - for (ci = egg_parent->begin(); ci != egg_parent->end(); ++ci) { - EggNode *child = (*ci); - if (child->is_of_type(EggGroup::get_class_type())) { - EggGroup *child_group = DCAST(EggGroup, child); - if (child_group->has_object_type("decalbase")) { - if (decal_base != nullptr) { - softegg_cat.error() - << "Two children of " << egg_parent->get_name() - << " both have decalbase set: " << decal_base->get_name() - << " and " << child_group->get_name() << "\n"; - okflag = false; - } - child_group->remove_object_type("decalbase"); - decal_base = child_group; - - } else if (child_group->has_object_type("decal")) { - child_group->remove_object_type("decal"); - decal_children.push_back(child_group); - } - } - } - - if (decal_base == nullptr) { - if (!decal_children.empty()) { - softegg_cat.warning() - << decal_children.front()->get_name() - << " has decal, but no sibling node has decalbase.\n"; - } - - } else { - if (decal_children.empty()) { - softegg_cat.warning() - << decal_base->get_name() - << " has decalbase, but no sibling nodes have decal.\n"; - - } else { - // All the decal children get moved to be a child of decal base. This - // usually will not affect the vertex positions, but it could if the - // decal base has a transform and the decal child is an instance node. - // So don't do that. - pvector::iterator di; - for (di = decal_children.begin(); di != decal_children.end(); ++di) { - EggGroup *child_group = (*di); - decal_base->add_child(child_group); - } - - // Also set the decal state on the base. - decal_base->set_decal_flag(true); - } - } - - // Now recurse on each of the child nodes. - for (ci = egg_parent->begin(); ci != egg_parent->end(); ++ci) { - EggNode *child = (*ci); - if (child->is_of_type(EggGroupNode::get_class_type())) { - EggGroupNode *child_group = DCAST(EggGroupNode, child); - if (!reparent_decals(child_group)) { - okflag = false; - } - } - } - - return okflag; -} - -/** - * Returns the TransformType value corresponding to the indicated string, or - * TT_invalid. - */ -SoftToEggConverter::TransformType SoftToEggConverter:: -string_transform_type(const string &arg) { - if (cmp_nocase(arg, "all") == 0) { - return TT_all; - } else if (cmp_nocase(arg, "model") == 0) { - return TT_model; - } else if (cmp_nocase(arg, "dcs") == 0) { - return TT_dcs; - } else if (cmp_nocase(arg, "none") == 0) { - return TT_none; - } else { - return TT_invalid; - } -} - -/** - * Invokes the softToEggConverter class - */ -extern "C" int init_soft2egg(int argc, char **argv) { - stec._commandName = argv[0]; - stec.rsrc_path = "c:\\Softimage\\SOFT3D_3.9.2\\3D\\rsrc"; - - if (stec.DoGetopts(argc, argv)) { - // Create a Filename object and convert the file - Filename softFile(argv[1]); - stec.convert_file(softFile); - } - - return 0; -} diff --git a/pandatool/src/softegg/softToEggConverter.h b/pandatool/src/softegg/softToEggConverter.h deleted file mode 100644 index 05c26fa60f..0000000000 --- a/pandatool/src/softegg/softToEggConverter.h +++ /dev/null @@ -1,179 +0,0 @@ -/** - * 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." - * - * @file softToEggConverter.h - * @author masad - * @date 2003-09-25 - */ - -#ifndef SOFTTOEGGCONVERTER_H -#define SOFTTOEGGCONVERTER_H - -#include "pandatoolbase.h" -#include "somethingToEggConverter.h" -#include "softNodeTree.h" - -#include "eggTextureCollection.h" -#include "distanceUnit.h" -#include "coordinateSystem.h" - -#ifdef _MIN -#undef _MIN -#endif -#ifdef _MAX -#undef _MAX -#endif - -#include -#include - -class EggData; -class EggGroup; -class EggTable; -class EggVertexPool; -class EggNurbsCurve; -class EggPrimitive; -class EggXfmSAnim; -class EggSAnimData; - - -/** - * This class supervises the construction of an EggData structure from a - * single Softimage file, or from the data already in th cout << "egg name - * = " << eggFilename << endl;e global Softimage model space. - * - */ -class SoftToEggConverter : public SomethingToEggConverter { -public: - SoftToEggConverter(const std::string &program_name = ""); - SoftToEggConverter(const SoftToEggConverter ©); - virtual ~SoftToEggConverter(); - - void Help(); - void Usage(); - void ShowOpts(); - - bool HandleGetopts(int &idx, int argc, char **argv); - bool DoGetopts(int &argc, char **&argv); - - SoftNodeDesc *find_node(std::string name); - int *FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ); - - virtual SomethingToEggConverter *make_copy(); - virtual std::string get_name() const; - virtual std::string get_extension() const; - - virtual bool convert_file(const Filename &filename); - bool convert_soft(bool from_selection); - bool open_api(); - void close_api(); - -private: - bool convert_flip(double start_frame, double end_frame, - double frame_inc, double output_frame_rate); - - bool make_soft_skin(); - bool cleanup_soft_skin(); - bool convert_char_chan(); - bool convert_char_model(); - bool convert_hierarchy(EggGroupNode *egg_root); - bool process_model_node(SoftNodeDesc *node_desc); - - void make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type); - void make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type); - void add_knots( vector &eggKnots, double *knots, int numKnots, SAA_Boolean closed, int degree ); - - void set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, int idx); - void apply_texture_properties(EggTexture &tex, int uRepeat, int vRepeat); - - bool reparent_decals(EggGroupNode *egg_parent); - - std::string _program_name; - bool _from_selection; - - SI_Error result; - SAA_Elem model; - SAA_Database database; - -public: - - SoftNodeTree _tree; - - SAA_Scene scene; - - char *_getopts; - - // This is argv[0]. - const char *_commandName; - - // This is the entire command line. - char _commandLine[4096]; - - char *rsrc_path; - char *database_name; - char *scene_name; - char *model_name; - char *eggFileName; - char *animFileName; - char *eggGroupName; - char *tex_path; - char *tex_filename; - char *search_prefix; - - int nurbs_step; - int anim_start; - int anim_end; - int anim_rate; - int pose_frame; - int verbose; - int flatten; - int shift_textures; - int ignore_tex_offsets; - int use_prefix; - - bool foundRoot; - bool geom_as_joint; - bool make_anim; - bool make_nurbs; - bool make_poly; - bool make_soft; - bool make_morph; - bool make_duv; - bool make_dart; - bool has_morph; - bool make_pose; - - - char *GetTextureName( SAA_Scene *scene, SAA_Elem *texture ); - - EggTextureCollection _textures; - - bool _polygon_output; - double _polygon_tolerance; - - enum TransformType { - TT_invalid, - TT_all, - TT_model, - TT_dcs, - TT_none, - }; - TransformType _transform_type; - - static TransformType string_transform_type(const std::string &arg); - - typedef pvector MorphTable; - MorphTable _morph_table; - - EggTable *morph_node; - EggSAnimData *find_morph_table(char *name); -}; - -extern const int TEX_PER_MAT; - -#endif diff --git a/pandatool/src/softprogs/softCVS.cxx b/pandatool/src/softprogs/softCVS.cxx deleted file mode 100644 index 478aa682d2..0000000000 --- a/pandatool/src/softprogs/softCVS.cxx +++ /dev/null @@ -1,588 +0,0 @@ -/** - * 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." - * - * @file softCVS.cxx - * @author drose - * @date 2000-11-10 - */ - -#include "softCVS.h" - -#include "pnotify.h" -#include "multifile.h" - -#include - -using std::string; - -/** - * - */ -SoftCVS:: -SoftCVS() { - _cvs_binary = "cvs"; - - set_program_brief("prepare a SoftImage database directory for adding to CVS"); - set_program_description - ("softcvs is designed to prepare a directory hierarchy " - "representing a SoftImage database for adding to CVS. " - "First, it eliminates SoftImage's silly filename-based " - "versioning system by renaming versioned filenames higher " - "than 1-0 back to version 1-0. Then, it rolls up all the " - "files for each scene except the texture images into a Panda " - "multifile, which is added to CVS; the texture images are " - "directly added to CVS where they are.\n\n" - - "The reduction of hundreds of SoftImage files per scene down to one " - "multifile and a handle of texture images should greatly improve " - "the update and commit times of CVS.\n\n" - - "You must run this from within the root of a SoftImage database " - "directory; e.g. the directory that contains SCENES, PICTURES, MODELS, " - "and so on."); - - clear_runlines(); - add_runline("[opts]"); - - add_option - ("nc", "", 80, - "Do not attempt to add newly-created files to CVS. The default " - "is to add them.", - &SoftCVS::dispatch_none, &_no_cvs); - - add_option - ("cvs", "cvs_binary", 80, - "Specify how to run the cvs program for adding newly-created files. " - "The default is simply \"cvs\".", - &SoftCVS::dispatch_string, nullptr, &_cvs_binary); -} - - -/** - * - */ -void SoftCVS:: -run() { - // First, check for the scenes directory. If it doesn't exist, we must not - // be in the root of a soft database. - Filename scenes = "SCENES/."; - if (!scenes.exists()) { - nout << "No SCENES directory found; you are not in the root of a " - "SoftImage database.\n"; - exit(1); - } - - // Also, if we're expecting to use CVS, make sure the CVS directory exists. - Filename cvs_entries = "CVS/Entries"; - if (!_no_cvs && !cvs_entries.exists()) { - nout << "You do not appear to be within a CVS-controlled source " - "directory.\n"; - exit(1); - } - - // Scan all the files in the database. - traverse_root(); - - // Collapse out the higher-versioned scene files. - collapse_scene_files(); - - // Now determine which element files are actually referenced by at least one - // of the scene files. - if (!get_scenes()) { - exit(1); - } - - // Finally, remove all the element files that are no longer referenced by - // any scenes. - remove_unused_elements(); - - // Now do all the cvs adding and removing we need. - if (!_no_cvs) { - cvs_add_or_remove("remove", _cvs_remove); - cvs_add_or_remove("add -kb", _cvs_add); - } -} - -/** - * Reads all of the toplevel directory names, e.g. SCENES, MATERIALS, etc., - * and traverses them. - */ -void SoftCVS:: -traverse_root() { - Filename root("."); - - // Get the list of subdirectories. - vector_string subdirs; - if (!root.scan_directory(subdirs)) { - nout << "Unable to scan directory.\n"; - return; - } - - vector_string::const_iterator di; - for (di = subdirs.begin(); di != subdirs.end(); ++di) { - Filename subdir = (*di); - if (subdir.is_directory() && subdir != "CVS") { - traverse_subdir(subdir); - } - } -} - -/** - * Reads the directory indicated by prefix and identifies all of the SoftImage - * files stored there. - */ -void SoftCVS:: -traverse_subdir(const Filename &directory) { - // Get the list of files in the directory. - vector_string files; - if (!directory.scan_directory(files)) { - nout << "Unable to scan directory " << directory << "\n"; - return; - } - - // We need to know the set of files in this directory that are CVS elements. - pset cvs_elements; - bool in_cvs = false; - if (!_no_cvs) { - in_cvs = scan_cvs(directory, cvs_elements); - } - - bool is_scenes = false; - bool keep_all = false; - bool wants_cvs = false; - - // Now make some special-case behavior based on the particular SoftImage - // subdirectory we're in. - string dirname = directory.get_basename(); - if (dirname == "SCENES") { - is_scenes = true; - - } else if (dirname == "CAMERAS") { - // We don't want anything in the cameras directory. These may change - // arbitrarily and have no bearing on the model or animation that we will - // extract, so avoid them altogether. - return; - - } else if (dirname == "PICTURES") { - // In the pictures directory, we must keep everything, since the scene - // files don't explicitly reference these but they're still important. - // Textures that are no longer used will pile up; we leave this as the - // user's problem. - - // We not only keep the textures, but we also move them into CVS, since - // (again) they're not part of the scene files and thus won't get added to - // the multifiles. Also, some textures are shared between different - // scenes, and it would be wasteful to add them to each scene multifile; - // furthermore, some scenes are used for animation only, and we don't want - // to modify these multifiles when the textures change. - - keep_all = true; - wants_cvs = !_no_cvs; - } - - vector_string::const_iterator fi; - for (fi = files.begin(); fi != files.end(); ++fi) { - const string &filename = (*fi); - if (filename == "CVS") { - // This special filename is not to be considered. - - } else if (filename == "Chapter.rsrc") { - // This special filename should not be considered, except to add it to - // the multifiles. - _global_files.push_back(Filename(directory, filename)); - - } else { - SoftFilename soft(directory, filename); - - if (cvs_elements.count(filename) != 0) { - // This file is known to be in CVS. - soft.set_in_cvs(true); - } - - if (keep_all) { - soft.increment_use_count(); - } - if (wants_cvs && !in_cvs) { - // Try to CVSify the directory. - cvs_add(directory); - in_cvs = true; - } - soft.set_wants_cvs(wants_cvs); - - if (is_scenes && soft.has_version() && soft.get_extension() == ".dsc") { - _scene_files.push_back(soft); - } else { - _element_files.insert(soft); - } - } - } -} - -/** - * Walks through the list of scene files found, and renames the higher- - * versioned ones to version 1-0, removing the intervening versions. - */ -void SoftCVS:: -collapse_scene_files() { - // Get a copy of the scene files vector so we can modify it. Also empty out - // the _scene_files at the same time so we can fill it up again. - SceneFiles versions; - versions.swap(_scene_files); - - // And sort them into order so we can easily compare higher and lower - // versions. - sort(versions.begin(), versions.end()); - - SceneFiles::iterator vi; - vi = versions.begin(); - while (vi != versions.end()) { - SoftFilename &file = (*vi); - - if (!file.is_1_0()) { - // Here's a file that needs to be renamed. But first, identify all the - // other versions of the same file. - SceneFiles::iterator start_vi; - start_vi = vi; - while (vi != versions.end() && (*vi).is_same_file(file)) { - ++vi; - } - - rename_file(start_vi, vi); - - } else { - ++vi; - } - - file.make_1_0(); - _scene_files.push_back(file); - } -} - -/** - * Walks through the list of scene files and looks for the set of element - * files referenced by each one, updating multifile accordingly. - */ -bool SoftCVS:: -get_scenes() { - bool okflag = true; - - // We will be added the multifiles to CVS if they're not already added, so - // we have to know which files are in CVS already. - pset cvs_elements; - if (!_no_cvs) { - scan_cvs(".", cvs_elements); - } - - SceneFiles::const_iterator vi; - for (vi = _scene_files.begin(); vi != _scene_files.end(); ++vi) { - const SoftFilename &sf = (*vi); - Filename file(sf.get_dirname(), sf.get_filename()); - - file.set_text(); - std::ifstream in; - if (!file.open_read(in)) { - nout << "Unable to read " << file << "\n"; - } else { - nout << "Scanning " << file << "\n"; - - Multifile multifile; - Filename multifile_name = sf.get_base() + "mf"; - - if (!multifile.open_read_write(multifile_name)) { - nout << "Unable to open " << multifile_name << " for updating.\n"; - okflag = false; - - } else { - if (!scan_scene_file(in, multifile)) { - okflag = false; - } - - // Add all the global files to the multifile too. These probably - // can't take compression (since in SoftImage they're just the - // Chapter.rsrc files, each very tiny). - vector_string::const_iterator gi; - for (gi = _global_files.begin(); gi != _global_files.end(); ++gi) { - if (multifile.update_subfile((*gi), (*gi), 0).empty()) { - nout << "Unable to add " << (*gi) << "\n"; - okflag = false; - } - } - - // Also add the scene file itself. - if (multifile.update_subfile(file, file, 6).empty()) { - nout << "Unable to add " << file << "\n"; - okflag = false; - } - - bool flushed = false; - if (multifile.needs_repack()) { - flushed = multifile.repack(); - } else { - flushed = multifile.flush(); - } - if (!flushed) { - nout << "Failed to write " << multifile_name << ".\n"; - okflag = false; - } else { - nout << "Wrote " << multifile_name << ".\n"; - - if (!_no_cvs && cvs_elements.count(multifile_name) == 0) { - // Add the multifile to CVS. - _cvs_add.push_back(multifile_name); - } - } - } - } - } - - return okflag; -} - - -/** - * Remove all the element files that weren't referenced by any scene file. - * Also plan to cvs add all those that were referenced. - */ -void SoftCVS:: -remove_unused_elements() { - ElementFiles::const_iterator fi; - for (fi = _element_files.begin(); fi != _element_files.end(); ++fi) { - const SoftFilename &sf = (*fi); - Filename file(sf.get_dirname(), sf.get_filename()); - - if (sf.get_use_count() == 0) { - nout << file << " is unused.\n"; - - if (!file.unlink()) { - nout << "Unable to remove " << file << ".\n"; - - } else if (sf.get_in_cvs()) { - _cvs_remove.push_back(file); - } - - } else if (sf.get_wants_cvs() && !sf.get_in_cvs()) { - _cvs_add.push_back(file); - } - } -} - - -/** - * Renames the first file in the indicated list to a version 1-0 filename, - * superceding all the other files in the list. Returns true if the file is - * renamed, false otherwise. - */ -bool SoftCVS:: -rename_file(SoftCVS::SceneFiles::iterator begin, - SoftCVS::SceneFiles::iterator end) { - int length = end - begin; - nassertr(length > 0, false); - - SoftFilename &orig = (*begin); - - string dirname = orig.get_dirname(); - string source_filename = orig.get_filename(); - string dest_filename = orig.get_1_0_filename(); - - if (length > 2) { - nout << source_filename << " supercedes:\n"; - SceneFiles::const_iterator p; - for (p = begin + 1; p != end; ++p) { - nout << " " << (*p).get_filename() << "\n"; - } - - } else if (length == 2) { - nout << source_filename << " supercedes " - << (*(begin + 1)).get_filename() << ".\n"; - - } else { - nout << source_filename << " renamed.\n"; - } - - // Now remove all of the "wrong" files. - - SceneFiles::const_iterator p; - for (p = begin + 1; p != end; ++p) { - Filename file((*p).get_dirname(), (*p).get_filename()); - if (!file.unlink()) { - nout << "Unable to remove " << file << ".\n"; - } - } - - // And rename the good one. - Filename source(dirname, source_filename); - Filename dest(dirname, dest_filename); - - if (!source.rename_to(dest)) { - nout << "Unable to rename " << source << " to " << dest_filename << ".\n"; - exit(1); - } - - return true; -} - -/** - * Scans the CVS repository in the indicated directory to determine which - * files are already versioned elements. Returns true if the directory is - * CVS-controlled, false otherwise. - */ -bool SoftCVS:: -scan_cvs(const string &dirname, pset &cvs_elements) { - Filename cvs_entries = dirname + "/CVS/Entries"; - if (!cvs_entries.exists()) { - return false; - } - - std::ifstream in; - cvs_entries.set_text(); - if (!cvs_entries.open_read(in)) { - nout << "Unable to read CVS directory.\n"; - return true; - } - - string line; - std::getline(in, line); - while (!in.fail() && !in.eof()) { - if (!line.empty() && line[0] == '/') { - size_t slash = line.find('/', 1); - if (slash != string::npos) { - string filename = line.substr(1, slash - 1); - - if (line.substr(slash + 1, 2) == "-1") { - // If the first number after the slash is -1, the file used to be - // here but was recently cvs removed. It counts as no longer being - // an element. - } else { - cvs_elements.insert(filename); - } - } - } - - std::getline(in, line); - } - - return true; -} - -/** - * Reads a scene file, looking for references to element files. For each - * reference found, increments the appropriate element file's reference count. - */ -bool SoftCVS:: -scan_scene_file(std::istream &in, Multifile &multifile) { - bool okflag = true; - - int c = in.get(); - while (!in.eof() && !in.fail()) { - // Skip whitespace. - while (isspace(c) && !in.eof() && !in.fail()) { - c = in.get(); - } - - // Now begin a word. - string word; - while (!isspace(c) && !in.eof() && !in.fail()) { - word += c; - c = in.get(); - } - - if (!word.empty()) { - SoftFilename v("", word); - - // Increment the use count on all matching elements of the multiset. - std::pair range; - range = _element_files.equal_range(v); - - ElementFiles::iterator ei; - for (ei = range.first; ei != range.second; ++ei) { - // We cheat and get a non-const reference to the filename out of the - // set. We can safely do this because incrementing the use count - // won't change its position in the set. - SoftFilename &sf = (SoftFilename &)(*ei); - sf.increment_use_count(); - - Filename file(sf.get_dirname(), sf.get_filename()); - if (multifile.update_subfile(file, file, 6).empty()) { - nout << "Unable to add " << file << "\n"; - okflag = false; - } - } - } - } - - return okflag; -} - -/** - * Invokes CVS to add just the named file to the repository. Returns true on - * success, false on failure. - */ -bool SoftCVS:: -cvs_add(const string &path) { - string command = _cvs_binary + " add -kb " + path; - nout << command << "\n"; - int result = system(command.c_str()); - - if (result != 0) { - nout << "Failure invoking cvs.\n"; - return false; - } - return true; -} - -/** - * Invokes CVS to add (or remove) all of the files in the indicated vector. - * Returns true on success, false on failure. - */ -bool SoftCVS:: -cvs_add_or_remove(const string &cvs_command, const vector_string &paths) { - static const int max_command = 4096; - - if (!paths.empty()) { - string command = _cvs_binary + " " + cvs_command; - vector_string::const_iterator pi; - pi = paths.begin(); - while (pi != paths.end()) { - const string &path = (*pi); - - if ((int)command.length() + 1 + (int)path.length() >= max_command) { - // Fire off the command now. - nout << command << "\n"; - int result = system(command.c_str()); - - if (result != 0) { - nout << "Failure invoking cvs.\n"; - return false; - } - - command = _cvs_binary + " " + cvs_command; - } - - command += ' '; - command += path; - - ++pi; - } - nout << command << "\n"; - int result = system(command.c_str()); - - if (result != 0) { - nout << "Failure invoking cvs.\n"; - return false; - } - } - return true; -} - - -int main(int argc, char *argv[]) { - SoftCVS prog; - prog.parse_command_line(argc, argv); - prog.run(); - return 0; -} diff --git a/pandatool/src/softprogs/softCVS.h b/pandatool/src/softprogs/softCVS.h deleted file mode 100644 index adbd89efa6..0000000000 --- a/pandatool/src/softprogs/softCVS.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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." - * - * @file softCVS.h - * @author drose - * @date 2000-11-10 - */ - -#ifndef SOFTCVS_H -#define SOFTCVS_H - -#include "pandatoolbase.h" - -#include "softFilename.h" - -#include "programBase.h" -#include "vector_string.h" -#include "filename.h" - -#include "pvector.h" -#include "pset.h" - -class Multifile; - -/** - * This program prepares a SoftImage database for CVS by renaming everything - * to version 1-0, and adding new files to CVS. - */ -class SoftCVS : public ProgramBase { -public: - SoftCVS(); - - void run(); - -private: - typedef pvector SceneFiles; - typedef pmultiset ElementFiles; - - void traverse_root(); - void traverse_subdir(const Filename &directory); - - void collapse_scene_files(); - bool get_scenes(); - void remove_unused_elements(); - - bool rename_file(SceneFiles::iterator begin, SceneFiles::iterator end); - bool scan_cvs(const std::string &dirname, pset &cvs_elements); - bool scan_scene_file(std::istream &in, Multifile &multifile); - - bool cvs_add(const std::string &path); - bool cvs_add_or_remove(const std::string &cvs_command, - const vector_string &paths); - - SceneFiles _scene_files; - ElementFiles _element_files; - vector_string _global_files; - - vector_string _cvs_add; - vector_string _cvs_remove; - - bool _no_cvs; - std::string _cvs_binary; -}; - -#endif diff --git a/pandatool/src/softprogs/softFilename.cxx b/pandatool/src/softprogs/softFilename.cxx deleted file mode 100644 index 4c099c56be..0000000000 --- a/pandatool/src/softprogs/softFilename.cxx +++ /dev/null @@ -1,291 +0,0 @@ -/** - * 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." - * - * @file softFilename.cxx - * @author drose - * @date 2000-11-10 - */ - -#include "softFilename.h" - -#include "pnotify.h" - -using std::string; - -/** - * - */ -SoftFilename:: -SoftFilename(const string &dirname, const string &filename) : - _dirname(dirname), - _filename(filename) -{ - _has_version = false; - _major = 0; - _minor = 0; - _in_cvs = false; - _wants_cvs = false; - _use_count = 0; - - _base = _filename; - - // Scan for a version number and an optional extension after each dot in the - // filename. - size_t dot = _filename.find('.'); - while (dot != string::npos) { - size_t m = dot + 1; - const char *fstr = _filename.c_str(); - char *endptr; - // Check for a numeric version number. - int major = strtol(fstr + m , &endptr, 10); - if (endptr != fstr + m && *endptr == '-') { - // We got a major number, is there a minor number? - m = (endptr - fstr) + 1; - int minor = strtol(fstr + m, &endptr, 10); - if (endptr != fstr + m && (*endptr == '.' || *endptr == '\0')) { - // We got a minor number too! - _has_version = true; - _base = _filename.substr(0, dot + 1); - _major = major; - _minor = minor; - _ext = endptr; - return; - } - } - - // That wasn't a version number. Is there more? - dot = _filename.find('.', dot + 1); - } -} - -/** - * - */ -SoftFilename:: -SoftFilename(const SoftFilename ©) : - _dirname(copy._dirname), - _filename(copy._filename), - _has_version(copy._has_version), - _base(copy._base), - _major(copy._major), - _minor(copy._minor), - _ext(copy._ext), - _in_cvs(copy._in_cvs), - _wants_cvs(copy._wants_cvs), - _use_count(copy._use_count) -{ -} - -/** - * - */ -void SoftFilename:: -operator = (const SoftFilename ©) { - _dirname = copy._dirname; - _filename = copy._filename; - _has_version = copy._has_version; - _base = copy._base; - _major = copy._major; - _minor = copy._minor; - _ext = copy._ext; - _in_cvs = copy._in_cvs; - _wants_cvs = copy._wants_cvs; - _use_count = copy._use_count; -} - -/** - * Returns the name of the directory this file was found in. - */ -const string &SoftFilename:: -get_dirname() const { - return _dirname; -} - -/** - * Returns the actual filename as found in the directory. - */ -const string &SoftFilename:: -get_filename() const { - return _filename; -} - -/** - * Returns true if the filename had a version number, false otherwise. - */ -bool SoftFilename:: -has_version() const { - return _has_version; -} - -/** - * Returns what the filename would be if it were version 1-0. - */ -string SoftFilename:: -get_1_0_filename() const { - nassertr(_has_version, string()); - return _base + "1-0" + _ext; -} - -/** - * Returns the base part of the filename. This is everything before the - * version number. - */ -const string &SoftFilename:: -get_base() const { - nassertr(_has_version, _filename); - return _base; -} - -/** - * Returns the major version number. - */ -int SoftFilename:: -get_major() const { - nassertr(_has_version, 0); - return _major; -} - -/** - * Returns the minor version number. - */ -int SoftFilename:: -get_minor() const { - nassertr(_has_version, 0); - return _minor; -} - -/** - * Returns the extension part of the filename. This is everything after the - * version number. - */ -const string &SoftFilename:: -get_extension() const { - nassertr(_has_version, _ext); - return _ext; -} - -/** - * Returns the filename part, without the extension. - */ -string SoftFilename:: -get_non_extension() const { - nassertr(_has_version, _filename); - nassertr(_ext.length() < _filename.length(), _filename); - return _filename.substr(0, _filename.length() - _ext.length()); -} - -/** - * Returns true if this is a version 1_0 filename, false otherwise. - */ -bool SoftFilename:: -is_1_0() const { - nassertr(_has_version, false); - return (_major == 1 && _minor == 0); -} - -/** - * Makes this a 1_0 filename. - */ -void SoftFilename:: -make_1_0() { - _has_version = true; - _major = 1; - _minor = 0; - _filename = get_1_0_filename(); -} - -/** - * Returns true if this file has the same base and extension as the other, - * disregarding the version number; false otherwise. - */ -bool SoftFilename:: -is_same_file(const SoftFilename &other) const { - return _base == other._base && _ext == other._ext; -} - -/** - * Puts filenames in order such that the files with the same base are sorted - * together, ignoring extension; and within files with the same base, files - * are sorted in decreasing version number order so that the most recent - * version appears first. - */ -bool SoftFilename:: -operator < (const SoftFilename &other) const { - if (_base != other._base) { - return _base < other._base; - } - - if (_has_version != other._has_version) { - // If one has a version and the other one doesn't, the one without a - // version comes first. - return _has_version < other._has_version; - } - - if (_has_version) { - if (_major != other._major) { - return _major > other._major; - } - if (_minor != other._minor) { - return _minor > other._minor; - } - } - - return false; -} - -/** - * Sets the flag that indicates whether this file is known to be entered into - * the CVS database. - */ -void SoftFilename:: -set_in_cvs(bool in_cvs) { - _in_cvs = in_cvs; -} - -/** - * Returns true if this file is known to be entered in the CVS database, false - * if it is not. - */ -bool SoftFilename:: -get_in_cvs() const { - return _in_cvs; -} - -/** - * Sets the flag that indicates whether this file should be entered into the - * CVS database. - */ -void SoftFilename:: -set_wants_cvs(bool wants_cvs) { - _wants_cvs = wants_cvs; -} - -/** - * Returns true if this file should be entered into the CVS database, false - * otherwise. - */ -bool SoftFilename:: -get_wants_cvs() const { - return _wants_cvs; -} - -/** - * Indicates that this filename is referenced by one more scene file. - */ -void SoftFilename:: -increment_use_count() { - _use_count++; -} - -/** - * Returns the number of scene files that referenced this filename. - */ -int SoftFilename:: -get_use_count() const { - return _use_count; -} diff --git a/pandatool/src/softprogs/softFilename.h b/pandatool/src/softprogs/softFilename.h deleted file mode 100644 index 0565eabf89..0000000000 --- a/pandatool/src/softprogs/softFilename.h +++ /dev/null @@ -1,73 +0,0 @@ -/** - * 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." - * - * @file softFilename.h - * @author drose - * @date 2000-11-10 - */ - -#ifndef SOFTFILENAME_H -#define SOFTFILENAME_H - -#include "pandatoolbase.h" - -/** - * This encapsulates a SoftImage versioned filename, of the form base.v-v.ext: - * it consists of a directory name, a base, a major and minor version number, - * and an optional extension. - * - * It also keeps track of whether the named file has been added to CVS, and - * how many scene files it is referenced by, - */ -class SoftFilename { -public: - SoftFilename(const std::string &dirname, const std::string &filename); - SoftFilename(const SoftFilename ©); - void operator = (const SoftFilename ©); - - const std::string &get_dirname() const; - const std::string &get_filename() const; - bool has_version() const; - - std::string get_1_0_filename() const; - - const std::string &get_base() const; - int get_major() const; - int get_minor() const; - const std::string &get_extension() const; - std::string get_non_extension() const; - - bool is_1_0() const; - void make_1_0(); - - bool is_same_file(const SoftFilename &other) const; - bool operator < (const SoftFilename &other) const; - - void set_in_cvs(bool in_cvs); - bool get_in_cvs() const; - - void set_wants_cvs(bool wants_cvs); - bool get_wants_cvs() const; - - void increment_use_count(); - int get_use_count() const; - -private: - std::string _dirname; - std::string _filename; - bool _has_version; - std::string _base; - int _major; - int _minor; - std::string _ext; - bool _in_cvs; - bool _wants_cvs; - int _use_count; -}; - -#endif From 6b00fe79878d2eeb443890b17908810a863c4062 Mon Sep 17 00:00:00 2001 From: Younguk Kim Date: Sun, 28 Oct 2018 00:29:32 +0900 Subject: [PATCH 269/360] makepanda: fix link error of assimp tool Closes #432 --- makepanda/makepanda.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index caa5a164a9..89aec0e0f6 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -680,6 +680,9 @@ if (COMPILER == "MSVC"): IncDirectory("FCOLLADA", GetThirdpartyDir() + "fcollada/include/FCollada") if (PkgSkip("ASSIMP")==0): LibName("ASSIMP", GetThirdpartyDir() + "assimp/lib/assimp.lib") + path = GetThirdpartyDir() + "assimp/lib/IrrXML.lib" + if os.path.isfile(path): + LibName("ASSIMP", GetThirdpartyDir() + "assimp/lib/IrrXML.lib") IncDirectory("ASSIMP", GetThirdpartyDir() + "assimp/include/assimp") if (PkgSkip("SQUISH")==0): if GetOptimize() <= 2: From bb71cd68e1b3879122669d5cd1be93467a689bea Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Oct 2018 11:40:28 +0100 Subject: [PATCH 270/360] makepanda: use /BIGOBJ flag when compiling p3gobj_composite2.cxx --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 89aec0e0f6..1087ce1aff 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3818,7 +3818,7 @@ if (not RUNTIME): if (not RUNTIME): 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') + TargetAdd('p3gobj_composite2.obj', opts=OPTS+['BIGOBJ'], input='p3gobj_composite2.cxx') OPTS=['DIR:panda/src/gobj', 'NVIDIACG', 'ZLIB', 'SQUISH', 'PYTHON'] IGATEFILES=GetDirectoryContents('panda/src/gobj', ["*.h", "*_composite*.cxx"]) From fb52a8e15efd0d358f4b2ba29237b8cc25ddeb54 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Oct 2018 11:41:05 +0100 Subject: [PATCH 271/360] text: fix deadlock in TextNode::write Fixes #431 --- panda/src/text/textNode.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index 5a0c0c7f7f..4a77acd6d3 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -291,8 +291,8 @@ output(std::ostream &out) const { */ void TextNode:: write(std::ostream &out, int indent_level) const { - MutexHolder holder(_lock); PandaNode::write(out, indent_level); + MutexHolder holder(_lock); TextProperties::write(out, indent_level + 2); indent(out, indent_level + 2) << "transform is: " << *TransformState::make_mat(_transform) << "\n"; From 35d095c2cf69faf7ed2a068a092915ec4b5bc46c Mon Sep 17 00:00:00 2001 From: TLOPOOperations Date: Mon, 22 Oct 2018 16:16:17 -0700 Subject: [PATCH 272/360] GSG: Fix symbol name conflict --- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 10 +++++----- panda/src/wgldisplay/wglGraphicsStateGuardian.cxx | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 904f47afc3..b7b0f7d3e7 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -5240,9 +5240,9 @@ calc_fb_properties(DWORD cformat, DWORD dformat, #define GAMMA_1 (255.0 * 256.0) static bool _gamma_table_initialized = false; -static unsigned short _orignial_gamma_table [256 * 3]; +static unsigned short _original_gamma_table [256 * 3]; -void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { +void _create_gamma_table_dx9 (PN_stdfloat gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { int i; double gamma_correction; @@ -5304,7 +5304,7 @@ get_gamma_table(void) { HDC hdc = GetDC(nullptr); if (hdc) { - if (GetDeviceGammaRamp (hdc, (LPVOID) _orignial_gamma_table)) { + if (GetDeviceGammaRamp (hdc, (LPVOID) _original_gamma_table)) { _gamma_table_initialized = true; get = true; } @@ -5329,10 +5329,10 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { unsigned short ramp [256 * 3]; if (restore && _gamma_table_initialized) { - _create_gamma_table (gamma, &_orignial_gamma_table [0], &_orignial_gamma_table [256], &_orignial_gamma_table [512], &ramp [0], &ramp [256], &ramp [512]); + _create_gamma_table_dx9 (gamma, &_original_gamma_table [0], &_original_gamma_table [256], &_original_gamma_table [512], &ramp [0], &ramp [256], &ramp [512]); } else { - _create_gamma_table (gamma, 0, 0, 0, &ramp [0], &ramp [256], &ramp [512]); + _create_gamma_table_dx9 (gamma, 0, 0, 0, &ramp [0], &ramp [256], &ramp [512]); } if (SetDeviceGammaRamp (hdc, ramp)) { diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index 735f7fc409..c98f12cf48 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -778,9 +778,9 @@ register_twindow_class() { #define GAMMA_1 (255.0 * 256.0) static bool _gamma_table_initialized = false; -static unsigned short _orignial_gamma_table [256 * 3]; +static unsigned short _original_gamma_table [256 * 3]; -void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { +void _create_gamma_table_wgl (PN_stdfloat gamma, unsigned short *original_red_table, unsigned short *original_green_table, unsigned short *original_blue_table, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { int i; double gamma_correction; @@ -842,7 +842,7 @@ get_gamma_table(void) { HDC hdc = GetDC(nullptr); if (hdc) { - if (GetDeviceGammaRamp (hdc, (LPVOID) _orignial_gamma_table)) { + if (GetDeviceGammaRamp (hdc, (LPVOID) _original_gamma_table)) { _gamma_table_initialized = true; get = true; } @@ -867,10 +867,10 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { unsigned short ramp [256 * 3]; if (restore && _gamma_table_initialized) { - _create_gamma_table (gamma, &_orignial_gamma_table [0], &_orignial_gamma_table [256], &_orignial_gamma_table [512], &ramp [0], &ramp [256], &ramp [512]); + _create_gamma_table_wgl (gamma, &_original_gamma_table [0], &_original_gamma_table [256], &_original_gamma_table [512], &ramp [0], &ramp [256], &ramp [512]); } else { - _create_gamma_table (gamma, 0, 0, 0, &ramp [0], &ramp [256], &ramp [512]); + _create_gamma_table_wgl (gamma, 0, 0, 0, &ramp [0], &ramp [256], &ramp [512]); } if (SetDeviceGammaRamp (hdc, ramp)) { From e5c3ce19958dedd5d8100875daaae5829097d9da Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Oct 2018 11:44:24 +0100 Subject: [PATCH 273/360] pipeline: fix missing symbols for CycleDataLockedReader --- panda/src/pipeline/cycleDataLockedReader.I | 38 ++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/panda/src/pipeline/cycleDataLockedReader.I b/panda/src/pipeline/cycleDataLockedReader.I index a622b9a2c0..882d8f600e 100644 --- a/panda/src/pipeline/cycleDataLockedReader.I +++ b/panda/src/pipeline/cycleDataLockedReader.I @@ -45,6 +45,19 @@ CycleDataLockedReader(const CycleDataLockedReader ©) : _cycler->increment_read(_pointer); } +/** + * + */ +template +INLINE CycleDataLockedReader:: +CycleDataLockedReader(CycleDataLockedReader &&from) noexcept : + _cycler(from._cycler), + _current_thread(from._current_thread), + _pointer(from._pointer) +{ + from._pointer = nullptr; +} + /** * */ @@ -61,19 +74,6 @@ operator = (const CycleDataLockedReader ©) { _cycler->increment_read(_pointer); } -/** - * - */ -template -INLINE CycleDataLockedReader:: -CycleDataLockedReader(CycleDataLockedReader &&from) noexcept : - _cycler(from._cycler), - _current_thread(from._current_thread), - _pointer(from._pointer) -{ - from._pointer = nullptr; -} - /** * */ @@ -177,6 +177,18 @@ operator = (const CycleDataLockedReader ©) { _pointer = copy._pointer; } +/** + * + */ +template +INLINE void CycleDataLockedReader:: +operator = (CycleDataLockedReader &&from) noexcept { + nassertv(_pointer == nullptr); + + _pointer = from._pointer; + from._pointer = nullptr; +} + /** * */ From da820877357e5242850487b90bc96f7caf214048 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Oct 2018 11:45:14 +0100 Subject: [PATCH 274/360] tests: add unit test for TextNode::write, see #431 --- tests/text/test_textnode.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/text/test_textnode.py b/tests/text/test_textnode.py index e96c9e5371..bedc91b0da 100644 --- a/tests/text/test_textnode.py +++ b/tests/text/test_textnode.py @@ -1,6 +1,13 @@ from panda3d import core +def test_textnode_write(): + out = core.StringStream() + text = core.TextNode("test") + text.write(out, 0) + assert out.data.startswith(b"TextNode test") + + def test_textnode_card_as_margin(): text = core.TextNode("test") text.text = "Test" From afc994b2fb6ed6258be8529e8e9ecd43d11948f7 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Oct 2018 11:47:16 +0100 Subject: [PATCH 275/360] display: fix crash when removing DisplayRegion in pipelined render Maybe not a perfect solution; we should consider keeping the DisplayRegions around until they have gone through the entire pipeline. Fixes #427 --- panda/src/display/graphicsEngine.cxx | 10 +++++----- panda/src/display/graphicsOutput.cxx | 26 +++++++++++++------------- panda/src/display/graphicsOutput.h | 1 + 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 57a592f05d..496a05e273 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -753,7 +753,7 @@ render_frame() { // frames, so we won't have to recompute it each frame. int num_drs = win->get_num_active_display_regions(); for (int i = 0; i < num_drs; ++i) { - DisplayRegion *dr = win->get_active_display_region(i); + PT(DisplayRegion) dr = win->get_active_display_region(i); if (dr != nullptr) { NodePath camera_np = dr->get_camera(current_thread); if (!camera_np.is_empty()) { @@ -1359,7 +1359,7 @@ is_scene_root(const PandaNode *node) { if (win->is_active() && win->get_gsg()->is_active()) { int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { - DisplayRegion *dr = win->get_active_display_region(i); + PT(DisplayRegion) dr = win->get_active_display_region(i); if (dr != nullptr) { NodePath camera = dr->get_camera(); if (camera.is_empty()) { @@ -1435,7 +1435,7 @@ cull_and_draw_together(GraphicsEngine::Windows wlist, int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { - DisplayRegion *dr = win->get_active_display_region(i); + PT(DisplayRegion) dr = win->get_active_display_region(i); if (dr != nullptr) { cull_and_draw_together(win, dr, current_thread); } @@ -1539,7 +1539,7 @@ cull_to_bins(GraphicsEngine::Windows wlist, Thread *current_thread) { PStatTimer timer(win->get_cull_window_pcollector(), current_thread); int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; ++i) { - DisplayRegion *dr = win->get_active_display_region(i); + PT(DisplayRegion) dr = win->get_active_display_region(i); if (dr != nullptr) { PT(SceneSetup) scene_setup; PT(CullResult) cull_result; @@ -1659,7 +1659,7 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { } int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; ++i) { - DisplayRegion *dr = win->get_active_display_region(i); + PT(DisplayRegion) dr = win->get_active_display_region(i); if (dr != nullptr) { do_draw(win, gsg, dr, current_thread); } diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 7c6cef51cb..c8237059b8 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -697,9 +697,6 @@ void GraphicsOutput:: remove_all_display_regions() { LightMutexHolder holder(_lock); - CDWriter cdata(_cycler, true); - cdata->_active_display_regions_stale = true; - TotalDisplayRegions::iterator dri; for (dri = _total_display_regions.begin(); dri != _total_display_regions.end(); @@ -713,6 +710,12 @@ remove_all_display_regions() { } _total_display_regions.clear(); _total_display_regions.push_back(_overlay_display_region); + + OPEN_ITERATE_ALL_STAGES(_cycler) { + CDStageWriter cdata(_cycler, pipeline_stage); + cdata->_active_display_regions_stale = true; + } + CLOSE_ITERATE_ALL_STAGES(_cycler); } /** @@ -740,13 +743,8 @@ set_overlay_display_region(DisplayRegion *display_region) { */ int GraphicsOutput:: get_num_display_regions() const { - determine_display_regions(); - int result; - { - LightMutexHolder holder(_lock); - result = _total_display_regions.size(); - } - return result; + LightMutexHolder holder(_lock); + return _total_display_regions.size(); } /** @@ -1504,13 +1502,15 @@ do_remove_display_region(DisplayRegion *display_region) { find(_total_display_regions.begin(), _total_display_regions.end(), drp); if (dri != _total_display_regions.end()) { // Let's aggressively clean up the display region too. - CDWriter cdata(_cycler, true); display_region->cleanup(); display_region->_window = nullptr; _total_display_regions.erase(dri); - cdata->_active_display_regions_stale = true; - + OPEN_ITERATE_ALL_STAGES(_cycler) { + CDStageWriter cdata(_cycler, pipeline_stage); + cdata->_active_display_regions_stale = true; + } + CLOSE_ITERATE_ALL_STAGES(_cycler); return true; } diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index acd41e8289..f426b41bee 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -394,6 +394,7 @@ protected: typedef CycleDataLockedReader CDLockedReader; typedef CycleDataReader CDReader; typedef CycleDataWriter CDWriter; + typedef CycleDataStageWriter CDStageWriter; protected: int _creation_flags; From 99aa598de00e7c1d748fa6f20dc85d031ea1622c Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Oct 2018 11:51:25 +0100 Subject: [PATCH 276/360] makepanda: don't try to link static libs into static library --- makepanda/makepanda.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 1087ce1aff..7573e89606 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1598,6 +1598,8 @@ def CompileLib(lib, obj, opts): else: cmd = GetAR() + ' cru ' + BracketNameWithQuotes(lib) for x in obj: + if GetLinkAllStatic() and x.endswith('.a'): + continue cmd += ' ' + BracketNameWithQuotes(x) oscmd(cmd) From e92777619cf33895b3faa56352d4d245b131eb58 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Oct 2018 11:53:55 +0100 Subject: [PATCH 277/360] doc: remove two outdated documents --- doc/INSTALLING-PLUGINS.TXT | 20 ---- doc/InstallerNotes | 183 ------------------------------------- 2 files changed, 203 deletions(-) delete mode 100644 doc/INSTALLING-PLUGINS.TXT delete mode 100644 doc/InstallerNotes diff --git a/doc/INSTALLING-PLUGINS.TXT b/doc/INSTALLING-PLUGINS.TXT deleted file mode 100644 index 994e164936..0000000000 --- a/doc/INSTALLING-PLUGINS.TXT +++ /dev/null @@ -1,20 +0,0 @@ -HOW TO INSTALL MAX PANDA PLUGINS. - -Step 1. Install the visual studio 2008 runtime by -running "vcredist_x86-sp1.exe" as administrator. -As a convenience, this installer is included with panda. - -Step 2. Make sure that there is only one copy of panda -in your system PATH. If you only have one copy of panda -installed, you can skip this step. - -Step 3. Copy the relevant DLLs for your version -of max from the panda plugins directory to the -max plugins directory. For instance, if you are -using Max 9, copy maxegg9.dlo and maxeggimport9.dlo - -HOW TO INSTALL MAYA PANDA PLUGINS. - -(To be written) - - diff --git a/doc/InstallerNotes b/doc/InstallerNotes deleted file mode 100644 index cf57b15cc1..0000000000 --- a/doc/InstallerNotes +++ /dev/null @@ -1,183 +0,0 @@ ------------------------- RELEASE 1.0.0 --------------------------------- - - * We now have working exporters for Max5, Max6, Max7, Maya5, Maya6 - - * The Max exporter is dramatically improved: - - - it now includes support for character studio. - - the polygon winding bug has been fixed. - - * Panda no longer requires any registry keys or environment - variables. This means it is now possible to: - - - run panda directly from a compact disc - - install multiple copies of panda on a single machine - - install panda by copying the tree from another computer - - Note that the installer does add the panda 'bin' directory to - your PATH, and it does store an uninstall key in the registry, - but neither of these is needed for panda to function. - - * The 'makepanda' build system is now capable of building - prepackaged games for Windows. These prepackaged games are simply - copies of panda with the game code included, some of the - unnecessary stuff stripped out, and some changes to the start - menu. See "Airblade - Installer" on the panda downloads page - for an example. - - * All of the sample programs have been tested. The ones that didn't - work have been removed, the ones that do work have been (lightly) - documented. - - * This is the first release to include not just a binary installer - for windows, but: - - - a binary installer (RPM) for Fedora 2 - - a binary installer (RPM) for Fedora 3 - - a binary installer (RPM) for Redhat 9 - - a binary installer for windows, as always - - a source tar-ball for linux - - a source zip-file for windows - ------------------------- RELEASE 2004-12-13 --------------------------------- - - * Basic server-client networking support is back in Panda3D. There is a - networking sample in the samples directory. This uses the Panda3d - distributed object system.The README file will explain how to run this. - Documentation of this if forthcoming. - - * Panda3d now reduces the number of environment variables such that only 2 - are needed now - PRC_PATH and PLAYER. - - * GraphicsChannel and GraphicsLayer class have been removed from the - panda/src/display directory. Most Panda applications won't need to be - changed, since most applications simply use ShowBase.py (which has been - adjustedappropriately) to open a window and do the initial setup. For - those rare applications where you need to create your own DisplayRegions, - the makeDisplayRegion() interface has been moved from GraphicsLayer to - GraphicsWindow (actually, to GraphicsOutput, which is the base class of - GraphicsWindow). You can modify your application to call - base.win.makeDisplayRegion() accordingly. If you have something like - displayRegion.getLayer(), replace it with displayRegion.getWindow() - instead. - - * Effective with the current version of Panda, the way that HPR angles are - calculated will be changing. The change will make a difference to existing - code or databases that store a hard-coded rotation as a HPR, but only when - R is involved, or both H and P are involved together. That is to say more - precisely, HPR angles with (R != 0 || (H != 0 && P != 0)) now represent a - different rotation than they used to. If you find some legacy code that no - longer works correctly (e.g. it introduces crazy rotations), try putting - the following in your Config.prc file: - - temp-hpr-fix 0 - - To turn off the correct behavior and return to the old, broken behavior. - Note that a longer-term solution will be to represent the HPR angles - correctly in all legacy code. The function oldToNewHpr() is provided to - aid this transition. - - * PandaNode definition has been changed to support setting an - into_collide_mask for any arbitrary node, in particular for any GeomNode. - It used to be that only CollisionNodes had an into_collide_mask. This - change obviates the need for CollisionNode::set_collide_geom(), which is - now a deprecated interface and will be removed at some point in the future. - - Details: - There's now a NodePath::set_collide_mask() and - NodePath::get_collide_mask(), which operate on all CollisionNodes and - GeomNodes at and below the current node. By default, set_collide_mask() - will replace the entire collide mask, but you may also specify (via a - second parameter) the subset of bits that are to be changed; other bits - will be left alone. You can also specify a particular type of node to - modify via a third parameter, e.g. you can adjust the masks for GeomNodes - or CollisionNodes only. - - The NodePath set_collide_mask() interface changes the into_collide_mask. - Those familiar with the collision system will recall that a CollisionNode - (but only a CollisionNode) also has a from_collide_mask. The - from_collide_mask of the active mover is compared with the into_collide_mask - of each object in the world; a collision is only possible if there are some - bits in common. - - It used to be that only other CollisionNodes had an into_collide_mask. A - mover would only test for collisions with CollisionNodes that matched its - collide_mask. If you wanted to make your mover detect collisions with - visible geometry which had no into_collide_mask, you had to call - set_collide_geom(1). This allowed the mover to detect collisions with *all* - visible geometry; it was either an all-or-none thing. - - Now that GeomNodes also have an into_collide_mask, there's no longer a need - for set_collide_geom(). A mover will detect collisions with any - CollisionNodes or GeomNodes that match its collide_mask. This means, for - the purposes of collision detection, you can use CollisionNodes and - GeomNodes pretty much interchangeably; simply set the appropriate bits on - the objects you want to collide with, regardless of whether they are - invisible collision solids or visible geometry. - - (This should not be taken as a license to avoid using CollisionNodes - altogether. The intersection computation with visible geometry is still - less efficient than the same computation with collision solids. And visible - geometry tends to be many times more complex than is strictly necessary for - collisions.) - - There's one more detail: every GeomNode, by default, has one bit set on in - its collide_mask, unless it is explicitly turned off. This bit is - GeomNode::get_default_collide_mask(). This bit is provided for the - convenience of programmers who still want the old behavior of - set_collide_geom(): it allows you to easily create a CollisionNode that - will collide with all visible geometry in the world. - - Along the same lines, there's also CollisionNode::get_default_collide_mask(), - which is 0x000fffff. This is the default mask that is created for a new - CollisionNode (and it does not include the bit reserved for GeomNodes, - above). Previously, a new CollisionNode would have all bits on by default. - - - ------------------------- RELEASE 2004-11-11 ----------------------------------- - - * Multiple mice can now be used with Panda3D. showbase has a list called - pointerWatcherNodes. The first mouse on this list is the system mouse. The - getMouseX() and getMouseY() will return coordinates relative to the - application window. The rest of the mice on the list will give raw mouse - positions and will change when they are moved on the screen. - - In addition there are new events for mouse buttons. Each mouse will be have - a corresponding event. mouse1 will send mousedev1-mouse1, mousedev1-mouse2 - and mousedev1-mouse3 events. mouse2 and any other mouse attached - will send similar events mousedev2-mouse1 etc. - - The old mouse buttons work too. mouse1, mouse2, mouse3 events will be - triggered if that button is pressed on any mouse - ------------------------- RELEASE 2004-10-13 ----------------------------------- - -General - - * Release notes: Each release will now have an entry associated with - it in this document. This will be updated in reverse-chronological order. - -Panda3D - * Distributed with this release is a working version of the SceneEditor - created in Spring 2004 at the ETC. Documentation will be forthcoming on the - website. This can be found in /SceneEditor - - * The latest version of FMOD is distributed with this release. The latest - version is 3.73. - - * AudioSound object now allows more types of sound. These include wma and - ogg vorbis formats. This is valid when using the fmod sound system. Midi, - Mod, s3m, it, xm and such sequencer type file formats are not supported. - Exception - Midi files can be played. This is not fully implemented. - - * A bug in SoundInterval is fixed. SoundInterval looping would incorrectly - add a minimum of 1.5 seconds to the sound. This has been fixed. Sound - looping problems in general should be fixed. Midi's still don't support - looping through the AudioSound object. They should loop through - SoundIntervals though. - - * Cg support has been added to Panda3D. Documentation for this is - forthcoming. - - From 733c7f2352ba269f712e211fc770e5789c3ca4bb Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Oct 2018 11:59:18 +0100 Subject: [PATCH 278/360] makepanda: remove mention of removed softprogs/softcvs --- makepanda/makepanda.py | 16 ---------------- makepanda/makepanda.vcproj | 20 -------------------- 2 files changed, 36 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 7573e89606..7f82da5b80 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3299,7 +3299,6 @@ if (PkgSkip("PANDATOOL")==0): CopyAllHeaders('pandatool/src/ptloader') CopyAllHeaders('pandatool/src/miscprogs') CopyAllHeaders('pandatool/src/pstatserver') - CopyAllHeaders('pandatool/src/softprogs') CopyAllHeaders('pandatool/src/text-stats') CopyAllHeaders('pandatool/src/vrmlprogs') CopyAllHeaders('pandatool/src/win-stats') @@ -6352,21 +6351,6 @@ if (PkgSkip("PANDATOOL")==0): TargetAdd('p3pstatserver_composite1.obj', opts=OPTS, input='p3pstatserver_composite1.cxx') TargetAdd('libp3pstatserver.lib', input='p3pstatserver_composite1.obj') -# -# DIRECTORY: pandatool/src/softprogs/ -# - -if (PkgSkip("PANDATOOL")==0): - OPTS=['DIR:pandatool/src/softprogs', 'OPENSSL'] - TargetAdd('softcvs_softCVS.obj', opts=OPTS, input='softCVS.cxx') - TargetAdd('softcvs_softFilename.obj', opts=OPTS, input='softFilename.cxx') - TargetAdd('softcvs.exe', input='softcvs_softCVS.obj') - TargetAdd('softcvs.exe', input='softcvs_softFilename.obj') - TargetAdd('softcvs.exe', input='libp3progbase.lib') - TargetAdd('softcvs.exe', input='libp3pandatoolbase.lib') - TargetAdd('softcvs.exe', input=COMMON_PANDA_LIBS) - TargetAdd('softcvs.exe', opts=['ADVAPI']) - # # DIRECTORY: pandatool/src/text-stats/ # diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj index 6be22d7d1a..c4c34db4e3 100644 --- a/makepanda/makepanda.vcproj +++ b/makepanda/makepanda.vcproj @@ -4770,12 +4770,6 @@ - - - - - - @@ -5305,20 +5299,6 @@ - - - - - - - - - - - - - - From ed96a5270333c5344c9757393939c1a02a4dd1cc Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 28 Oct 2018 20:40:55 +0100 Subject: [PATCH 279/360] cocoa: cautiously enable sRGB framebuffers on macOS [skip ci] --- panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index 26d4dbdf71..b584d02a2c 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm @@ -134,6 +134,12 @@ get_properties(FrameBufferProperties &properties, NSOpenGLPixelFormat* pixel_for if (accelerated) { properties.set_force_hardware(1); } + + // Cautiously setting this to true. It appears that macOS framebuffers are + // sRGB-capable, but I don't really know how to verify this. + if (color_size == 32 && !color_float) { + properties.set_srgb_color(true); + } } /** From 33385facfbf469817fcdd80e8de0eddc6989fd88 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 29 Oct 2018 15:29:41 -0600 Subject: [PATCH 280/360] dxgsg9: Delete dead dxInput9.{cxx,h} files This file isn't compiled, and I'm pretty sure never has been compiled. The dependence on "config_wdxdisplay9.h" (which has never existed) and absence of any commits that address its functionality reinforce the idea that this is actually just dead code. This seems like an artifact copied over from the DX8 code, that nobody cared enough to get working or delete. --- panda/src/dxgsg9/dxInput9.cxx | 269 -------------------------- panda/src/dxgsg9/dxInput9.h | 40 ---- panda/src/dxgsg9/wdxGraphicsWindow9.h | 1 - 3 files changed, 310 deletions(-) delete mode 100644 panda/src/dxgsg9/dxInput9.cxx delete mode 100644 panda/src/dxgsg9/dxInput9.h diff --git a/panda/src/dxgsg9/dxInput9.cxx b/panda/src/dxgsg9/dxInput9.cxx deleted file mode 100644 index 17d5b2f88e..0000000000 --- a/panda/src/dxgsg9/dxInput9.cxx +++ /dev/null @@ -1,269 +0,0 @@ -/** - * 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." - * - * @file dxInput9.cxx - * @author angelina jolie - * @date 1999-10-07 - */ - -#include "config_wdxdisplay9.h" -#include "dxInput9.h" - -#define AXIS_RESOLUTION 2000 // use this many levels of resolution by default (could be more if needed and device supported it) -#define AXIS_RANGE_CENTERED // if defined, axis range is centered on 0, instead of starting on 0 - -using std::endl; - -BOOL CALLBACK EnumGameCtrlsCallback( const DIDEVICEINSTANCE* pdidInstance, - VOID* pContext ) { - DI_DeviceInfos *pDevInfos = (DI_DeviceInfos *)pContext; - - (*pDevInfos).push_back(*pdidInstance); - - if(wdxdisplay_cat.is_debug()) - wdxdisplay_cat.debug() << "Found DevType 0x" << (void*)pdidInstance->dwDevType << ": " << pdidInstance->tszInstanceName << ": " << pdidInstance->tszProductName <Unacquire(); - SAFE_RELEASE(_DeviceList[i]); - } - - // bugbug: need to handle this if(_JoystickPollTimer!=NULL) KillTimer(...) - - SAFE_RELEASE(_pDInput9); - if(_hDInputDLL) { - FreeLibrary(_hDInputDLL); - _hDInputDLL=nullptr; - } -} - -bool DInput9Info::InitDirectInput() { - HRESULT hr; - - // assumes dx9 exists use dynamic load so non-dinput programs don't have - // to load dinput - #define DLLNAME "dinput9.dll" - #define DINPUTCREATE "DirectInput9Create" - - HINSTANCE _hDInputDLL = LoadLibrary(DLLNAME); - if(_hDInputDLL == 0) { - wdxdisplay_cat.fatal() << "LoadLibrary(" << DLLNAME <<") failed!, error=" << GetLastError() << endl; - exit(1); - } - - typedef HRESULT (WINAPI * LPDIRECTINPUT9CREATE)(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); - LPDIRECTINPUT9CREATE pDInputCreate9; - - pDInputCreate9 = (LPDIRECTINPUT9CREATE) GetProcAddress(_hDInputDLL,DINPUTCREATE); - if(pDInputCreate9 == nullptr) { - wdxdisplay_cat.fatal() << "GetProcAddr failed for " << DINPUTCREATE << endl; - exit(1); - } - - // Register with the DirectInput subsystem and get a pointer to a - // IDirectInput interface we can use. Create a DInput object - if( FAILED( hr = (*pDInputCreate9)(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, - IID_IDirectInput9, (VOID**)&_pDInput9, nullptr ) ) ) { - wdxdisplay_cat.error() << DINPUTCREATE << "failed" << D3DERRORSTRING(hr); - return false; - } - - // enum all the joysticks,etc (but not keybdmouse) - if( FAILED( hr = _pDInput9->EnumDevices(DI9DEVCLASS_GAMECTRL, - EnumGameCtrlsCallback, - (LPVOID)&_DevInfos, DIEDFL_ATTACHEDONLY ) ) ) { - wdxdisplay_cat.error() << "EnumDevices failed" << D3DERRORSTRING(hr); - return false; - } - - return true; -} - -bool DInput9Info::CreateJoystickOrPad(HWND _window) { - bool bFoundDev = false; - UINT devnum=0; - char *errstr=nullptr; - - // look through the list for the first joystick or gamepad - for(;devnum<_DevInfos.size();devnum++) { - DWORD devType = GET_DIDEVICE_TYPE(_DevInfos[devnum].dwDevType); - if((devType==DI9DEVTYPE_GAMEPAD) ||(devType==DI9DEVTYPE_JOYSTICK)) { - bFoundDev=true; - break; - } - } - - if(!bFoundDev) { - wdxdisplay_cat.error() << "Cant find an attached Joystick or GamePad!\n"; - return false; - } - - LPDIRECTINPUTDEVICE9 pJoyDevice; - - // Obtain an interface to the enumerated joystick. - HRESULT hr = _pDInput9->CreateDevice(_DevInfos[devnum].guidInstance, &pJoyDevice, nullptr ); - if(FAILED(hr)) { - errstr="CreateDevice"; - goto handle_error; - } - - assert(pJoyDevice!=nullptr); - _DeviceList.push_back(pJoyDevice); - - // Set the data format to "simple joystick" - a predefined data format A - // data format specifies which controls on a device we are interested in, - // and how they should be reported. This tells DInput that we will be - // passing a DIJOYSTATE2 structure to - // IDirectInputDevice::GetDeviceState(). - hr = pJoyDevice->SetDataFormat(&c_dfDIJoystick2); - if(FAILED(hr)) { - errstr="SetDataFormat"; - goto handle_error; - } - - // must be called AFTER SetDataFormat to get all the proper flags - DX_DECLARE_CLEAN(DIDEVCAPS, DIDevCaps); - hr = pJoyDevice->GetCapabilities(&DIDevCaps); - assert(SUCCEEDED(hr)); - - _DevCaps.push_back(DIDevCaps); - - if(wdxdisplay_cat.is_debug()) - wdxdisplay_cat.debug() << "Joy/Pad has " << DIDevCaps.dwAxes << " Axes, " << DIDevCaps.dwButtons << " Buttons, " << DIDevCaps.dwPOVs << " POVs" << endl; - - // Set the cooperative level to let DInput know how this device should - // interact with the system and with other DInput applications. - hr = pJoyDevice->SetCooperativeLevel( _window, DISCL_EXCLUSIVE | DISCL_FOREGROUND); - if(FAILED(hr)) { - errstr="SetCooperativeLevel"; - goto handle_error; - } - - // set the minmax values property for discovered axes. - hr = pJoyDevice->EnumObjects(EnumObjectsCallbackJoystick, (LPVOID)pJoyDevice, DIDFT_AXIS); - if(FAILED(hr)) { - errstr="EnumObjects"; - goto handle_error; - } - - return true; - - handle_error: - wdxdisplay_cat.error() << errstr << " failed for (" << _DevInfos[devnum].tszInstanceName << ":" << _DevInfos[devnum].tszProductName << ")" << D3DERRORSTRING(hr); - return false; -} - -// --------------------------------------------------------------------------- -// -- Name: EnumObjectsCallback() Desc: Callback function for enumerating -// objects (axes, buttons, POVs) on a joystick. This function enables user -// interface elements for objects that are found to exist, and scales axes -// minmax values. ----------------------------------------------------------- -// ------------------ -BOOL CALLBACK EnumObjectsCallbackJoystick( const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext ) { - - LPDIRECTINPUTDEVICE9 pJoyDevice = (LPDIRECTINPUTDEVICE9) pContext; - HRESULT hr; - - // For axes that are returned, set the DIPROP_RANGE property for the - // enumerated axis in order to scale minmax values. - if( pdidoi->dwType & DIDFT_AXIS ) { - DIPROPRANGE diprg; - diprg.diph.dwSize = sizeof(DIPROPRANGE); - diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); - diprg.diph.dwHow = DIPH_BYID; - diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis - - #ifdef AXIS_RANGE_CENTERED - diprg.lMin = -AXIS_RESOLUTION/2; - diprg.lMax = +AXIS_RESOLUTION/2; - #else - diprg.lMin = 0; - diprg.lMax = +AXIS_RESOLUTION; - #endif - - // Set the range for the axis - hr = pJoyDevice->SetProperty( DIPROP_RANGE, &diprg.diph); - if(FAILED(hr)) { - wdxdisplay_cat.error() << "SetProperty on axis failed" << D3DERRORSTRING(hr); - return DIENUM_STOP; - } - } - - return DIENUM_CONTINUE; -} - -bool DInput9Info::ReadJoystick(int devnum, DIJOYSTATE2 &js) { - LPDIRECTINPUTDEVICE9 pJoystick = _DeviceList[devnum]; - assert(pJoystick!=nullptr); - HRESULT hr; - char *errstr; - - // Poll the device to read the current state - - hr = pJoystick->Poll(); - - if( FAILED(hr) ) { - // DInput is telling us that the input stream has been interrupted. - // We aren't tracking any state between polls, so we don't have any - // special reset that needs to be done. We just re-acquire and try - // again. - - if((hr==DIERR_NOTACQUIRED)||(hr == DIERR_INPUTLOST)) { - hr = pJoystick->Acquire(); - - if(FAILED(hr)) { - if(wdxdisplay_cat.is_spam()) - wdxdisplay_cat.spam() << "Acquire failed" << D3DERRORSTRING(hr); - - // hr may be DIERR_OTHERAPPHASPRIO or other errors. This may - // occur when the app is minimized or in the process of - // switching, so just try again later - return false; - } - - hr = pJoystick->Poll(); - if(FAILED(hr)) { - // should never happen! - errstr = "Poll after successful Acquire failed"; - goto handle_error; - } - } else { - errstr = "Unknown Poll failure"; - goto handle_error; - } - } - - // should we make a vector of devstate dataformats to generalize this fn - // for all device types? - - // Get the input's device state - hr = pJoystick->GetDeviceState( sizeof(DIJOYSTATE2), &js); - if(FAILED(hr)) { - errstr = "GetDeviceState failed"; - goto handle_error; - } - - return true; - - handle_error: - wdxdisplay_cat.fatal() << errstr << D3DERRORSTRING(hr); - return false; -} diff --git a/panda/src/dxgsg9/dxInput9.h b/panda/src/dxgsg9/dxInput9.h deleted file mode 100644 index 9614a2627d..0000000000 --- a/panda/src/dxgsg9/dxInput9.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * 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." - * - * @file dxInput9.h - * @author blllyjo - * @date 1999-10-07 - */ - -#ifndef DXINPUT9_H -#define DXINPUT9_H - -#define DIRECTINPUT_VERSION 0x900 -#include -typedef std::vector DI_DeviceInfos; -typedef std::vector DI_DeviceObjInfos; - -class DInput9Info { -public: - DInput9Info(); - ~DInput9Info(); - bool InitDirectInput(); - bool CreateJoystickOrPad(HWND _window); - bool ReadJoystick(int devnum, DIJOYSTATE2 &js); - - HINSTANCE _hDInputDLL; - UINT_PTR _JoystickPollTimer; - LPDIRECTINPUT8 _pDInput9; - DI_DeviceInfos _DevInfos; - // arrays for all created devices. Should probably put these together in a - // struct, along with the data fmt info - std::vector _DeviceList; - std::vector _DevCaps; -}; - -#endif diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.h b/panda/src/dxgsg9/wdxGraphicsWindow9.h index 391fb9d7e9..42a6fe6763 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.h +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.h @@ -17,7 +17,6 @@ #include "pandabase.h" #include "winGraphicsWindow.h" #include "dxGraphicsStateGuardian9.h" -#include "dxInput9.h" #include "wdxGraphicsPipe9.h" class wdxGraphicsPipe9; From 2ed4cd7ce6359e608f3bbd3a3a348ab88d1f7bff Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 29 Oct 2018 22:38:00 +0100 Subject: [PATCH 281/360] cppparser: fix CPPStructType::is_trivial() for eg. ButtonHandle --- dtool/src/cppparser/cppStructType.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dtool/src/cppparser/cppStructType.cxx b/dtool/src/cppparser/cppStructType.cxx index d0707c4404..745abab586 100644 --- a/dtool/src/cppparser/cppStructType.cxx +++ b/dtool/src/cppparser/cppStructType.cxx @@ -306,7 +306,6 @@ is_trivial() const { } // Now look for functions that are virtual or con/destructors. - bool is_default_constructible = true; CPPScope::Functions::const_iterator fi; for (fi = _scope->_functions.begin(); fi != _scope->_functions.end(); ++fi) { CPPFunctionGroup *fgroup = (*fi).second; @@ -343,9 +342,6 @@ is_trivial() const { // Same for the default constructor. return false; } - // The presence of a non-default constructor makes the class not - // default-constructible. - is_default_constructible = false; } if (fgroup->_name == "operator =") { @@ -356,7 +352,7 @@ is_trivial() const { } // Finally, the class must be default-constructible. - return is_default_constructible; + return is_default_constructible(V_public); } /** From ad3b145951654a76c90bd001c0b1e10dc02d3e87 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 29 Oct 2018 22:39:17 +0100 Subject: [PATCH 282/360] interrogate: generated property getter should copy in some cases This is to fix eg. public ButtonHandle members from being returned as const reference, which means they won't outlive the struct they are accessed on, a recipe for obscure crashes. The is_trivial() criterium for this to apply is admittedly really arbitrary; I haven't really figured out what the right criterium should be, but it's better than hardcoding ButtonHandle. --- dtool/src/interrogate/interrogateBuilder.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 15607c95ea..b740d59e1a 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -1389,7 +1389,8 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, // We can only generate a getter and a setter if we can talk about the // type it is. - if (parameter_type->as_struct_type() != nullptr) { + if (parameter_type->as_struct_type() != nullptr && + !parameter_type->is_trivial()) { // Wrap the type in a const reference. parameter_type = TypeManager::wrap_const_reference(parameter_type); } From b45f6fbbed3534e0c0c79f4fd783e5169809e414 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 29 Oct 2018 17:50:22 -0600 Subject: [PATCH 283/360] dxgsg9: Remove DirectX 9.1 "detection" code This method of checking for pnhpast.dll was actually for DirectX 8.1 (see a16fe56c7) and its presence in the DX9 code is largely due to the copy-and-paste nature of how the DX9 GSG was created from the DX8 code. --- panda/src/dxgsg9/dxgsg9base.h | 1 - panda/src/dxgsg9/wdxGraphicsPipe9.cxx | 24 ++---------------------- panda/src/dxgsg9/wdxGraphicsPipe9.h | 1 - panda/src/dxgsg9/wdxGraphicsWindow9.cxx | 3 +-- 4 files changed, 3 insertions(+), 26 deletions(-) diff --git a/panda/src/dxgsg9/dxgsg9base.h b/panda/src/dxgsg9/dxgsg9base.h index b0e2b9dfef..430876dff5 100644 --- a/panda/src/dxgsg9/dxgsg9base.h +++ b/panda/src/dxgsg9/dxgsg9base.h @@ -211,7 +211,6 @@ struct DXScreenData { bool _is_tnl_device; bool _can_use_hw_vertex_shaders; bool _can_use_pixel_shaders; - bool _is_dx9_1; UINT _supported_screen_depths_mask; UINT _supported_tex_formats_mask; bool _supports_rgba16f_texture_format; diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index 6c85c6652f..ce8d33165f 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -193,30 +193,10 @@ init() { } // Create a Direct3D object. + __d3d9 = (*_Direct3DCreate9)(D3D_SDK_VERSION); - // these were taken from the 8.0 and 8.1 d3d8.h SDK headers - __is_dx9_1 = false; - -#define D3D_SDK_VERSION_9_0 D3D_SDK_VERSION -#define D3D_SDK_VERSION_9_1 D3D_SDK_VERSION - - // are we using 9.0 or 9.1? - WIN32_FIND_DATA TempFindData; - HANDLE hFind; - char tmppath[_MAX_PATH + 128]; - GetSystemDirectory(tmppath, MAX_PATH); - strcat(tmppath, "\\dpnhpast.dll"); - hFind = FindFirstFile (tmppath, &TempFindData); - if (hFind != INVALID_HANDLE_VALUE) { - FindClose(hFind); -// ??? This was from DX8 __is_dx9_1 = true; - __d3d9 = (*_Direct3DCreate9)(D3D_SDK_VERSION_9_1); - } else { - __is_dx9_1 = false; - __d3d9 = (*_Direct3DCreate9)(D3D_SDK_VERSION_9_0); - } if (__d3d9 == nullptr) { - wdxdisplay9_cat.error() << "Direct3DCreate9(9." << (__is_dx9_1 ? "1" : "0") << ") failed!, error = " << GetLastError() << endl; + wdxdisplay9_cat.error() << "Direct3DCreate9 failed!, error = " << GetLastError() << endl; // release_gsg(); goto error; } diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.h b/panda/src/dxgsg9/wdxGraphicsPipe9.h index 2d9eea18b0..ff25433e79 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.h +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.h @@ -93,7 +93,6 @@ private: typedef pvector CardIDs; CardIDs _card_ids; - bool __is_dx9_1; public: static TypeHandle get_class_type() { diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index 3207c81189..07a265a97c 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -878,7 +878,7 @@ choose_device() { LARGE_INTEGER *DrvVer = &adapter_info.DriverVersion; wdxdisplay9_cat.info() - << "D3D9." << (dxpipe->__is_dx9_1 ?"1":"0") << " Adapter[" << i << "]: " << adapter_info.Description + << "D3D9 Adapter[" << i << "]: " << adapter_info.Description << ", Driver: " << adapter_info.Driver << ", DriverVersion: (" << HIWORD(DrvVer->HighPart) << "." << LOWORD(DrvVer->HighPart) << "." << HIWORD(DrvVer->LowPart) << "." << LOWORD(DrvVer->LowPart) @@ -979,7 +979,6 @@ consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { nassertr(_dxgsg != nullptr, false); _wcontext._d3d9 = _d3d9; - _wcontext._is_dx9_1 = dxpipe->__is_dx9_1; _wcontext._card_id = device_info->cardID; // could this change by end? bool bWantStencil = (_fb_properties.get_stencil_bits() > 0); From 8d3576607ead02f5479b89994711cadd62c55364 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 30 Oct 2018 14:10:10 +0100 Subject: [PATCH 284/360] makepanda: remove INSTALLING-PLUGINS.TXT from installer.nsi [skip ci] --- makepanda/installer.nsi | 2 -- 1 file changed, 2 deletions(-) diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index 976bfd84f5..1dab5196da 100644 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -589,7 +589,6 @@ Section "3ds Max plug-ins" SecMaxPlugins File /nonfatal /r "${BUILT}\plugins\*.dle" File /nonfatal /r "${BUILT}\plugins\*.dlo" File /nonfatal /r "${BUILT}\plugins\*.ms" - File "${SOURCE}\doc\INSTALLING-PLUGINS.TXT" SectionEnd !endif @@ -604,7 +603,6 @@ Section "Maya plug-ins" SecMayaPlugins SetOutPath $INSTDIR\plugins File /nonfatal /r "${BUILT}\plugins\*.mll" File /nonfatal /r "${BUILT}\plugins\*.mel" - File "${SOURCE}\doc\INSTALLING-PLUGINS.TXT" SectionEnd !endif From 63484c83cbd667949ef8af03a53e84479b76b100 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 31 Oct 2018 21:25:03 +0100 Subject: [PATCH 285/360] pipeline: CycleData should always inherit from MemoryBase We need to guarantee that CData classes are aligned properly, even if DO_PIPELINING is not enabled. --- panda/src/pipeline/cycleData.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/pipeline/cycleData.h b/panda/src/pipeline/cycleData.h index ef21ad7a33..c2bcef4073 100644 --- a/panda/src/pipeline/cycleData.h +++ b/panda/src/pipeline/cycleData.h @@ -44,7 +44,7 @@ class EXPCL_PANDA_PIPELINE CycleData : public NodeReferenceCount // If we are *not* compiling in pipelining support, the CycleData object is // stored directly within its containing classes, and hence should not be a // ReferenceCount object. -class EXPCL_PANDA_PIPELINE CycleData +class EXPCL_PANDA_PIPELINE CycleData : public MemoryBase #endif // DO_PIPELINING { From 14411f592eac2af241cce8ca1fa7874bb3406cfe Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 1 Nov 2018 16:24:06 +0100 Subject: [PATCH 286/360] Remove obsolete .init files in configfiles directories These look like they were part of some now-defunct Disney tool. --- direct/src/configfiles/direct.init | 9 --------- panda/src/configfiles/panda.init | 10 ---------- pandatool/src/configfiles/pandatool.init | 1 - 3 files changed, 20 deletions(-) delete mode 100644 direct/src/configfiles/direct.init delete mode 100644 panda/src/configfiles/panda.init delete mode 100644 pandatool/src/configfiles/pandatool.init diff --git a/direct/src/configfiles/direct.init b/direct/src/configfiles/direct.init deleted file mode 100644 index 16eb87325c..0000000000 --- a/direct/src/configfiles/direct.init +++ /dev/null @@ -1,9 +0,0 @@ -ATTACH dmodels -ATTACH panda -MODREL ETC_PATH etc -DOCSH set parent=`dirname $DIRECT` -DOCSH if ( ${?PANDA_ROOT} ) then -DOCSH setenv PYTHONPATH "${PYTHONPATH};"`cygpath -w "$parent"` -DOCSH else -DOCSH setenv PYTHONPATH "${PYTHONPATH}:$parent" -DOCSH endif diff --git a/panda/src/configfiles/panda.init b/panda/src/configfiles/panda.init deleted file mode 100644 index 6256527d14..0000000000 --- a/panda/src/configfiles/panda.init +++ /dev/null @@ -1,10 +0,0 @@ -SETABS PANDA_VER 0.8 -MODREL ETC_PATH built/etc -DOCSH if ( ! $?CFG_PATH ) then -DOCSH setenv CFG_PATH ~ -DOCSH setenv CFG_PATH ". ${CFG_PATH} /usr/local/etc" -DOCSH endif -DOSH if [ -z "$CFG_PATH" ]; then -DOSH CFG_PATH=". $HOME /usr/local/etc" -DOSH export CFG_PATH -DOSH fi diff --git a/pandatool/src/configfiles/pandatool.init b/pandatool/src/configfiles/pandatool.init deleted file mode 100644 index 615e010d42..0000000000 --- a/pandatool/src/configfiles/pandatool.init +++ /dev/null @@ -1 +0,0 @@ -ATTACH panda From 604366aaa74259d32d54d2530bac3810ad35d687 Mon Sep 17 00:00:00 2001 From: loblao Date: Tue, 30 Oct 2018 12:13:58 -0300 Subject: [PATCH 287/360] CollisionEntrySorter: Check if entry has surface point Fixes #435 --- panda/src/collide/collisionHandlerQueue.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/panda/src/collide/collisionHandlerQueue.cxx b/panda/src/collide/collisionHandlerQueue.cxx index 75761362bd..0f6acaba52 100644 --- a/panda/src/collide/collisionHandlerQueue.cxx +++ b/panda/src/collide/collisionHandlerQueue.cxx @@ -22,10 +22,15 @@ class CollisionEntrySorter { public: CollisionEntrySorter(CollisionEntry *entry) { _entry = entry; - LVector3 vec = - entry->get_surface_point(entry->get_from_node_path()) - - entry->get_from()->get_collision_origin(); - _dist2 = vec.length_squared(); + if (entry->has_surface_point()) { + LVector3 vec = + entry->get_surface_point(entry->get_from_node_path()) - + entry->get_from()->get_collision_origin(); + _dist2 = vec.length_squared(); + } + else { + _dist2 = make_inf((PN_stdfloat)0); + } } bool operator < (const CollisionEntrySorter &other) const { return _dist2 < other._dist2; From 763049ac81345da33362e354a0af27f3d85c5d12 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 1 Nov 2018 17:05:33 +0100 Subject: [PATCH 288/360] event: fix incorrect include in asyncFuture_ext.h --- panda/src/event/asyncFuture_ext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/event/asyncFuture_ext.h b/panda/src/event/asyncFuture_ext.h index 21786ee17b..94f0b3d60b 100644 --- a/panda/src/event/asyncFuture_ext.h +++ b/panda/src/event/asyncFuture_ext.h @@ -16,7 +16,7 @@ #include "extension.h" #include "py_panda.h" -#include "modelLoadRequest.h" +#include "asyncFuture.h" #ifdef HAVE_PYTHON From bc22f5781b77eb85f0dda10c638ac1f8667c9732 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 1 Nov 2018 20:33:08 +0100 Subject: [PATCH 289/360] shader: supports preprocessed GLSL shaders in Shader.make() Fixes #436 --- panda/src/gobj/shader.cxx | 317 +++++++++++++++++++++++++++++--------- panda/src/gobj/shader.h | 13 +- 2 files changed, 254 insertions(+), 76 deletions(-) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 220bd56ed2..4c79745e85 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -2468,6 +2468,96 @@ read(const ShaderFile &sfile, BamCacheRecord *record) { return true; } +/** + * Loads the shader from the given string(s). Returns a boolean indicating + * success or failure. + */ +bool Shader:: +load(const ShaderFile &sbody, BamCacheRecord *record) { + _filename = ShaderFile("created-shader"); + _fullpath = Filename(); + _text._separate = sbody._separate; + + if (sbody._separate) { + if (_language == SL_none) { + shader_cat.error() + << "No shader language was specified!\n"; + return false; + } + + if (!sbody._vertex.empty() && + !do_load_source(_text._vertex, sbody._vertex, record)) { + return false; + } + if (!sbody._fragment.empty() && + !do_load_source(_text._fragment, sbody._fragment, record)) { + return false; + } + if (!sbody._geometry.empty() && + !do_load_source(_text._geometry, sbody._geometry, record)) { + return false; + } + if (!sbody._tess_control.empty() && + !do_load_source(_text._tess_control, sbody._tess_control, record)) { + return false; + } + if (!sbody._tess_evaluation.empty() && + !do_load_source(_text._tess_evaluation, sbody._tess_evaluation, record)) { + return false; + } + if (!sbody._compute.empty() && + !do_load_source(_text._compute, sbody._compute, record)) { + return false; + } + + } else { + if (!do_load_source(_text._shared, sbody._shared, record)) { + return false; + } + + // Determine which language the shader is written in. + if (_language == SL_none) { + string header; + parse_init(); + parse_line(header, true, true); + if (header == "//Cg") { + _language = SL_Cg; + } else { + shader_cat.error() + << "Unable to determine shader language of " << sbody._shared << "\n"; + return false; + } + } else if (_language == SL_GLSL) { + shader_cat.error() + << "GLSL shaders must have separate shader bodies!\n"; + return false; + } + + // Determine which language the shader is written in. + if (_language == SL_Cg) { +#ifdef HAVE_CG + cg_get_profile_from_header(_default_caps); + + if (!cg_analyze_shader(_default_caps)) { + shader_cat.error() + << "Shader encountered an error.\n"; + return false; + } +#else + shader_cat.error() + << "Tried to load Cg shader, but no Cg support is enabled.\n"; +#endif + } else { + shader_cat.error() + << "Shader is not in a supported shader-language.\n"; + return false; + } + } + + _loaded = true; + return true; +} + /** * Reads the shader file from the given path into the given string. * @@ -2476,37 +2566,85 @@ read(const ShaderFile &sfile, BamCacheRecord *record) { */ bool Shader:: do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { + VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); + PT(VirtualFile) vf = vfs->find_file(fn, get_model_path()); + if (vf == nullptr) { + shader_cat.error() + << "Could not find shader file: " << fn << "\n"; + return false; + } + if (_language == SL_GLSL && glsl_preprocess) { - // Preprocess the GLSL file as we read it. - std::set open_files; - ostringstream sstr; - if (!r_preprocess_source(sstr, fn, Filename(), open_files, record)) { + istream *source = vf->open_read_file(true); + if (source == nullptr) { + shader_cat.error() + << "Could not open shader file: " << fn << "\n"; return false; } + + // Preprocess the GLSL file as we read it. + shader_cat.info() + << "Preprocessing shader file: " << fn << "\n"; + + std::set open_files; + ostringstream sstr; + if (!r_preprocess_source(sstr, *source, fn, vf->get_filename(), open_files, record)) { + vf->close_read_file(source); + return false; + } + vf->close_read_file(source); into = sstr.str(); } else { shader_cat.info() << "Reading shader file: " << fn << "\n"; - VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - PT(VirtualFile) vf = vfs->find_file(fn, get_model_path()); - if (vf == nullptr) { - shader_cat.error() - << "Could not find shader file: " << fn << "\n"; - return false; - } - if (!vf->read_file(into, true)) { shader_cat.error() << "Could not read shader file: " << fn << "\n"; return false; } + } - if (record != nullptr) { - record->add_dependent_file(vf); + if (record != nullptr) { + record->add_dependent_file(vf); + } + + _last_modified = std::max(_last_modified, vf->get_timestamp()); + _source_files.push_back(vf->get_filename()); + + // Strip trailing whitespace. + while (!into.empty() && isspace(into[into.size() - 1])) { + into.resize(into.size() - 1); + } + + // Except add back a newline at the end, which is needed by Intel drivers. + into += "\n"; + + return true; +} + +/** + * Loads the shader file from the given string into the given string, + * performing any pre-processing on it that may be necessary. + * + * Returns false if there was an error with this shader bad enough to consider + * it 'invalid'. + */ +bool Shader:: +do_load_source(string &into, const std::string &source, BamCacheRecord *record) { + if (_language == SL_GLSL && glsl_preprocess) { + // Preprocess the GLSL file as we read it. + std::set open_files; + std::ostringstream sstr; + std::istringstream in(source); + if (!r_preprocess_source(sstr, in, Filename("created-shader"), Filename(), + open_files, record)) { + return false; } - _last_modified = std::max(_last_modified, vf->get_timestamp()); - _source_files.push_back(vf->get_filename()); + into = sstr.str(); + + } else { + into = source; } // Strip trailing whitespace. @@ -2528,10 +2666,10 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { * recursive includes. */ bool Shader:: -r_preprocess_source(ostream &out, const Filename &fn, - const Filename &source_dir, - std::set &once_files, - BamCacheRecord *record, int depth) { +r_preprocess_include(ostream &out, const Filename &fn, + const Filename &source_dir, + std::set &once_files, + BamCacheRecord *record, int depth) { if (depth > glsl_include_recursion_limit) { shader_cat.error() @@ -2549,7 +2687,7 @@ r_preprocess_source(ostream &out, const Filename &fn, PT(VirtualFile) vf = vfs->find_file(fn, path); if (vf == nullptr) { shader_cat.error() - << "Could not find shader file: " << fn << "\n"; + << "Could not find shader include: " << fn << "\n"; return false; } @@ -2562,7 +2700,7 @@ r_preprocess_source(ostream &out, const Filename &fn, istream *source = vf->open_read_file(true); if (source == nullptr) { shader_cat.error() - << "Could not open shader file: " << fn << "\n"; + << "Could not open shader include: " << fn << "\n"; return false; } @@ -2578,30 +2716,43 @@ r_preprocess_source(ostream &out, const Filename &fn, // than that, unfortunately. Don't do this for the top-level file, though. // We don't want anything to get in before a potential #version directive. int fileno = 0; - if (depth > 0) { - fileno = 2048 + _included_files.size(); - // Write it into the vector so that we can substitute it later when we are - // parsing the GLSL error log. Don't store the full filename because it - // would just be too long to display. - _included_files.push_back(fn); + fileno = 2048 + _included_files.size(); - out << "#line 1 " << fileno << " // " << fn << "\n"; - if (shader_cat.is_debug()) { - shader_cat.debug() - << "Preprocessing shader include " << fileno << ": " << fn << "\n"; - } - } else { - shader_cat.info() - << "Preprocessing shader file: " << fn << "\n"; + // Write it into the vector so that we can substitute it later when we are + // parsing the GLSL error log. Don't store the full filename because it + // would just be too long to display. + _included_files.push_back(fn); + + out << "#line 1 " << fileno << " // " << fn << "\n"; + if (shader_cat.is_debug()) { + shader_cat.debug() + << "Preprocessing shader include " << fileno << ": " << fn << "\n"; } + bool result = r_preprocess_source(out, *source, fn, full_fn, once_files, record, fileno, depth); + vf->close_read_file(source); + return result; +} + +/** + * Loads a given GLSL stream line by line, processing any #pragma include and + * once statements, as well as removing any comments. + * + * The set keeps track of which files we have already included, for checking + * recursive includes. + */ +bool Shader:: +r_preprocess_source(ostream &out, istream &in, const Filename &fn, + const Filename &full_fn, std::set &once_files, + BamCacheRecord *record, int fileno, int depth) { + // Iterate over the lines for things we may need to preprocess. string line; int ext_google_include = 0; // 1 = warn, 2 = enable int ext_google_line = 0; bool had_include = false; int lineno = 0; - while (std::getline(*source, line)) { + while (std::getline(in, line)) { ++lineno; if (line.empty()) { @@ -2615,7 +2766,7 @@ r_preprocess_source(ostream &out, const Filename &fn, line.resize(line.size() - 1); string line2; - if (std::getline(*source, line2)) { + if (std::getline(in, line2)) { line += line2; out.put('\n'); ++lineno; @@ -2644,7 +2795,7 @@ r_preprocess_source(ostream &out, const Filename &fn, size_t block_end = line2.find("*/"); while (block_end == string::npos) { // Didn't find it - look in the next line. - if (std::getline(*source, line2)) { + if (std::getline(in, line2)) { out.put('\n'); ++lineno; block_end = line2.find("*/"); @@ -2703,7 +2854,7 @@ r_preprocess_source(ostream &out, const Filename &fn, } // OK, great. Process the include. - if (!r_preprocess_source(out, incfn, source_dir, once_files, record, depth + 1)) { + if (!r_preprocess_include(out, incfn, source_dir, once_files, record, depth + 1)) { // An error occurred. Pass on the failure. shader_cat.error(false) << "included at line " << lineno << " of file " << fn << ":\n " << line << "\n"; @@ -2724,8 +2875,19 @@ r_preprocess_source(ostream &out, const Filename &fn, return false; } - once_files.insert(full_fn); + if (fileno == 0) { + shader_cat.warning() + << "#pragma once in main file at line " + << lineno << " of file " << fn +#ifndef NDEBUG + << ":\n " << line +#endif + << "\n"; + } + if (!full_fn.empty()) { + once_files.insert(full_fn); + } } else { // Forward it, the driver will ignore it if it doesn't know it. out << line << "\n"; @@ -2821,7 +2983,7 @@ r_preprocess_source(ostream &out, const Filename &fn, // OK, great. Process the include. Filename source_dir = full_fn.get_dirname(); - if (!r_preprocess_source(out, incfn, source_dir, once_files, record, depth + 1)) { + if (!r_preprocess_include(out, incfn, source_dir, once_files, record, depth + 1)) { // An error occurred. Pass on the failure. shader_cat.error(false) << "included at line " << lineno << " of file " << fn << ":\n " << line << "\n"; @@ -2865,7 +3027,6 @@ r_preprocess_source(ostream &out, const Filename &fn, } } - vf->close_read_file(source); return true; } @@ -3227,28 +3388,26 @@ make(string body, ShaderLanguage lang) { if (cache_generated_shaders) { ShaderTable::const_iterator i = _make_table.find(sbody); if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { - return i->second; + // But check that someone hasn't modified its includes in the meantime. + if (!i->second->check_modified()) { + return i->second; + } } } PT(Shader) shader = new Shader(lang); - shader->_filename = ShaderFile("created-shader"); - shader->_text = move(sbody); - -#ifdef HAVE_CG - if (lang == SL_Cg) { - shader->cg_get_profile_from_header(_default_caps); - - if (!shader->cg_analyze_shader(_default_caps)) { - shader_cat.error() - << "Shader encountered an error.\n"; - return nullptr; - } + if (!shader->load(sbody)) { + return nullptr; } -#endif if (cache_generated_shaders) { - _make_table[shader->_text] = shader; + ShaderTable::const_iterator i = _make_table.find(shader->_text); + if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { + shader = i->second; + } else { + _make_table[shader->_text] = shader; + } + _make_table[std::move(sbody)] = shader; } if (dump_generated_shaders) { @@ -3290,26 +3449,27 @@ make(ShaderLanguage lang, string vertex, string fragment, string geometry, if (cache_generated_shaders) { ShaderTable::const_iterator i = _make_table.find(sbody); if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { - return i->second; + // But check that someone hasn't modified its includes in the meantime. + if (!i->second->check_modified()) { + return i->second; + } } } PT(Shader) shader = new Shader(lang); shader->_filename = ShaderFile("created-shader"); - shader->_text = move(sbody); - -#ifdef HAVE_CG - if (lang == SL_Cg) { - if (!shader->cg_analyze_shader(_default_caps)) { - shader_cat.error() - << "Shader encountered an error.\n"; - return nullptr; - } + if (!shader->load(sbody)) { + return nullptr; } -#endif if (cache_generated_shaders) { - _make_table[shader->_text] = shader; + ShaderTable::const_iterator i = _make_table.find(shader->_text); + if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { + shader = i->second; + } else { + _make_table[shader->_text] = shader; + } + _make_table[std::move(sbody)] = shader; } return shader; @@ -3333,16 +3493,27 @@ make_compute(ShaderLanguage lang, string body) { if (cache_generated_shaders) { ShaderTable::const_iterator i = _make_table.find(sbody); if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { - return i->second; + // But check that someone hasn't modified its includes in the meantime. + if (!i->second->check_modified()) { + return i->second; + } } } PT(Shader) shader = new Shader(lang); shader->_filename = ShaderFile("created-shader"); - shader->_text = move(sbody); + if (!shader->load(sbody)) { + return nullptr; + } if (cache_generated_shaders) { - _make_table[shader->_text] = shader; + ShaderTable::const_iterator i = _make_table.find(shader->_text); + if (i != _make_table.end() && (lang == SL_none || lang == i->second->_language)) { + shader = i->second; + } else { + _make_table[shader->_text] = shader; + } + _make_table[std::move(sbody)] = shader; } return shader; diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 67906210f6..35971b243b 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -616,11 +616,18 @@ private: Shader(ShaderLanguage lang); bool read(const ShaderFile &sfile, BamCacheRecord *record = nullptr); + bool load(const ShaderFile &sbody, BamCacheRecord *record = nullptr); bool do_read_source(std::string &into, const Filename &fn, BamCacheRecord *record); - bool r_preprocess_source(std::ostream &out, const Filename &fn, - const Filename &source_dir, + bool do_load_source(std::string &into, const std::string &source, BamCacheRecord *record); + bool r_preprocess_include(std::ostream &out, const Filename &fn, + const Filename &source_dir, + std::set &open_files, + BamCacheRecord *record, int depth); + bool r_preprocess_source(std::ostream &out, std::istream &in, + const Filename &fn, const Filename &full_fn, std::set &open_files, - BamCacheRecord *record, int depth = 0); + BamCacheRecord *record, + int fileno = 0, int depth = 0); bool check_modified() const; From be464b61b3c10053be3ae65f1dfd0dedacb3429a Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 1 Nov 2018 22:02:45 +0100 Subject: [PATCH 290/360] shader: do not require whitespace around : in #extension directive --- panda/src/gobj/shader.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 4c79745e85..9a4153a5e3 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -2905,7 +2905,7 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, // Check for special preprocessing extensions. char extension[256]; char behavior[9]; - if (sscanf(line.c_str(), " # extension%*[ \t]%255s%*[ \t]:%*[ \t]%8s", extension, behavior) == 2) { + if (sscanf(line.c_str(), " # extension%*[ \t]%255[^: \t] : %8s", extension, behavior) == 2) { // Parse the behavior string. int mode; if (strcmp(behavior, "require") == 0 || strcmp(behavior, "enable") == 0) { From f4a8e923f7c08cd9d398a6081c295c721c41720b Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 1 Nov 2018 22:03:10 +0100 Subject: [PATCH 291/360] dxgsg9: fix startup freeze when VRAM is 4GiB or higher --- panda/src/dxgsg9/wdxGraphicsPipe9.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index ce8d33165f..8cb8b9782f 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -341,11 +341,13 @@ find_all_card_memavails() { if (!ISPOW2(dwVidMemTotal)) { // assume they wont return a proper max value, so round up to next pow // of 2 - UINT count = 0; - while ((dwVidMemTotal >> count) != 0x0) { - count++; + int count = get_next_higher_bit((uint32_t)(dwVidMemTotal - 1u)); + if (count >= 32u) { + // Maximum value that fits in a UINT. + dwVidMemTotal = 0xffffffffu; + } else { + dwVidMemTotal = (1u << count); } - dwVidMemTotal = (1 << count); } } From c4f5ed308f1bd621916fea223719f7ea961aaf0b Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 1 Nov 2018 23:25:17 +0100 Subject: [PATCH 292/360] shader: reduce unnecessary newlines and #line in preprocessed GLSL This is done by only writing out a #line when the first non-whitespace line is encountered; any blank lines before that are trimmed. This cuts down the size of the preprocessed shaders for a large project with many shader includes, such as the RenderPipeline. --- panda/src/gobj/shader.cxx | 66 +++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 9a4153a5e3..4b635b00e7 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -2723,7 +2723,6 @@ r_preprocess_include(ostream &out, const Filename &fn, // would just be too long to display. _included_files.push_back(fn); - out << "#line 1 " << fileno << " // " << fn << "\n"; if (shader_cat.is_debug()) { shader_cat.debug() << "Preprocessing shader include " << fileno << ": " << fn << "\n"; @@ -2752,11 +2751,17 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, int ext_google_line = 0; bool had_include = false; int lineno = 0; + bool write_line_directive = (fileno != 0); + while (std::getline(in, line)) { ++lineno; if (line.empty()) { - out.put('\n'); + // We still write a newline to make sure the line numbering remains + // consistent, unless we are about to write a #line directive anyway. + if (!write_line_directive) { + out.put('\n'); + } continue; } @@ -2768,7 +2773,9 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, if (std::getline(in, line2)) { line += line2; - out.put('\n'); + if (!write_line_directive) { + out.put('\n'); + } ++lineno; } else { break; @@ -2796,7 +2803,9 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, while (block_end == string::npos) { // Didn't find it - look in the next line. if (std::getline(in, line2)) { - out.put('\n'); + if (!write_line_directive) { + out.put('\n'); + } ++lineno; block_end = line2.find("*/"); } else { @@ -2814,10 +2823,21 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, line.resize(line.size() - 1); } + if (line.empty()) { + if (!write_line_directive) { + out.put('\n'); + } + continue; + } + // Check if this line contains a #directive. char directive[64]; if (line.size() < 8 || sscanf(line.c_str(), " # %63s", directive) != 1) { // Nope. Just pass the line through unmodified. + if (write_line_directive) { + out << "#line " << lineno << " " << fileno << " // " << fn << "\n"; + write_line_directive = false; + } out << line << "\n"; continue; } @@ -2862,8 +2882,9 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, } // Restore the line counter. - out << "#line " << (lineno + 1) << " " << fileno << " // " << fn << "\n"; + write_line_directive = true; had_include = true; + continue; } else if (strcmp(pragma, "once") == 0) { // Do a stricter syntax check, just to be extra safe. @@ -2888,17 +2909,15 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, if (!full_fn.empty()) { once_files.insert(full_fn); } - } else { - // Forward it, the driver will ignore it if it doesn't know it. - out << line << "\n"; + continue; } + // Otherwise, just pass it through to the driver. } else if (strcmp(directive, "endif") == 0) { // Check for an #endif after an include. We have to restore the line // number in case the include happened under an #if block. - out << line << "\n"; if (had_include) { - out << "#line " << (lineno + 1) << " " << fileno << "\n"; + write_line_directive = true; } } else if (strcmp(directive, "extension") == 0) { @@ -2931,7 +2950,8 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, } ext_google_include = mode; ext_google_line = mode; - out << line << "\n"; + // Still pass it through to the driver, so it can enable other + // extensions. } else if (strcmp(extension, "GL_GOOGLE_include_directive") == 0) { // Enable the Google extension support for #include statements. @@ -2939,14 +2959,12 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, // This matches the behavior of Khronos' glslang reference compiler. ext_google_include = mode; ext_google_line = mode; + continue; } else if (strcmp(extension, "GL_GOOGLE_cpp_style_line_directive") == 0) { // Enables strings in #line statements. ext_google_line = mode; - - } else { - // It's an extension the driver should worry about. - out << line << "\n"; + continue; } } else { shader_cat.error() @@ -2954,6 +2972,7 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, << lineno << " of file " << fn << ":\n " << line << "\n"; return false; } + } else if (ext_google_include > 0 && strcmp(directive, "include") == 0) { // Warn about extension use if requested. if (ext_google_include == 1) { @@ -2991,8 +3010,9 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, } // Restore the line counter. - out << "#line " << (lineno + 1) << " " << fileno << " // " << fn << "\n"; + write_line_directive = true; had_include = true; + continue; } else if (ext_google_line > 0 && strcmp(directive, "line") == 0) { // It's a #line directive. See if it uses a string instead of number. @@ -3016,15 +3036,15 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn, _included_files.push_back(Filename(filestr)); out << "#line " << lineno << " " << fileno << " // " << filestr << "\n"; - - } else { - // We couldn't parse the #line directive. Pass it through unmodified. - out << line << "\n"; + continue; } - } else { - // Different directive (eg. #version). Leave it untouched. - out << line << "\n"; } + + if (write_line_directive) { + out << "#line " << lineno << " " << fileno << " // " << fn << "\n"; + write_line_directive = false; + } + out << line << "\n"; } return true; From a246acc64046fd6d4f0582b749f192710bd48c39 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 1 Nov 2018 16:03:58 -0600 Subject: [PATCH 293/360] windisplay: Undefine Configure before including d3d9.h This is for consistency with fbbc5bb9e63 which introduced the same `#undef Configure` in dxgsg9. This prevents dtool's own Configure() macro from conflicting with the declaration of D3D9's Configure function in d3d9.h. --- panda/src/windisplay/winDetectDx9.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/windisplay/winDetectDx9.cxx b/panda/src/windisplay/winDetectDx9.cxx index 2e293950f6..4be10f0492 100644 --- a/panda/src/windisplay/winDetectDx9.cxx +++ b/panda/src/windisplay/winDetectDx9.cxx @@ -18,6 +18,7 @@ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif +#undef Configure #include #include "graphicsStateGuardian.h" #include "graphicsPipe.h" From 5ac3cf3fc65c6bf447e570a8ad11766af080a49c Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 2 Nov 2018 22:33:16 +0100 Subject: [PATCH 294/360] Eliminate C++ DConfig; replace it with a Python compatibility shim --- .../src/distributed/DistributedSmoothNode.py | 3 +- direct/src/showbase/DConfig.py | 25 ++++++ direct/src/showbase/ShowBase.py | 7 +- direct/src/showbase/ShowBaseGlobal.py | 3 +- direct/src/showbase/showBase.cxx | 8 -- direct/src/showbase/showBase.h | 1 - dtool/src/dconfig/config_dconfig.cxx | 21 ----- dtool/src/dconfig/config_dconfig.h | 29 ------- dtool/src/dconfig/dconfig.I | 42 --------- dtool/src/dconfig/dconfig.cxx | 14 --- dtool/src/dconfig/dconfig.h | 27 +----- dtool/src/dconfig/p3dconfig_composite1.cxx | 3 - dtool/src/dconfig/test_config.cxx | 35 -------- dtool/src/dconfig/test_expand.cxx | 87 ------------------- dtool/src/dconfig/test_pfstream.cxx | 32 ------- dtool/src/dconfig/test_searchpath.cxx | 48 ---------- makepanda/makepanda.py | 25 +++--- panda/src/express/config_express.cxx | 8 -- panda/src/express/config_express.h | 5 -- panda/src/express/virtualFileSystem.cxx | 2 + panda/src/pgraph/config_pgraph.h | 1 + panda/src/putil/config_putil.h | 2 + pandatool/src/progbase/programBase.cxx | 1 - 23 files changed, 51 insertions(+), 378 deletions(-) create mode 100644 direct/src/showbase/DConfig.py delete mode 100644 dtool/src/dconfig/config_dconfig.cxx delete mode 100644 dtool/src/dconfig/config_dconfig.h delete mode 100644 dtool/src/dconfig/dconfig.I delete mode 100644 dtool/src/dconfig/dconfig.cxx delete mode 100644 dtool/src/dconfig/p3dconfig_composite1.cxx delete mode 100644 dtool/src/dconfig/test_config.cxx delete mode 100644 dtool/src/dconfig/test_expand.cxx delete mode 100644 dtool/src/dconfig/test_pfstream.cxx delete mode 100644 dtool/src/dconfig/test_searchpath.cxx diff --git a/direct/src/distributed/DistributedSmoothNode.py b/direct/src/distributed/DistributedSmoothNode.py index 9bc75c1da1..282ec5b88d 100644 --- a/direct/src/distributed/DistributedSmoothNode.py +++ b/direct/src/distributed/DistributedSmoothNode.py @@ -6,8 +6,7 @@ from .ClockDelta import * from . import DistributedNode from . import DistributedSmoothNodeBase from direct.task.Task import cont - -config = get_config_showbase() +from direct.showbase import DConfig as config # This number defines our tolerance for out-of-sync telemetry packets. # If a packet appears to have originated from more than MaxFuture diff --git a/direct/src/showbase/DConfig.py b/direct/src/showbase/DConfig.py new file mode 100644 index 0000000000..54c90d1566 --- /dev/null +++ b/direct/src/showbase/DConfig.py @@ -0,0 +1,25 @@ +"This module contains a deprecated shim emulating the old DConfig API." + +__all__ = [] + +from panda3d.core import (ConfigFlags, ConfigVariableBool, ConfigVariableInt, + ConfigVariableDouble, ConfigVariableString) + + +def GetBool(sym, default=False): + return ConfigVariableBool(sym, default, "DConfig", ConfigFlags.F_dconfig).value + + +def GetInt(sym, default=0): + return ConfigVariableInt(sym, default, "DConfig", ConfigFlags.F_dconfig).value + + +def GetDouble(sym, default=0.0): + return ConfigVariableDouble(sym, default, "DConfig", ConfigFlags.F_dconfig).value + + +def GetString(sym, default=""): + return ConfigVariableString(sym, default, "DConfig", ConfigFlags.F_dconfig).value + + +GetFloat = GetDouble diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 13b9839255..fcd790e0bf 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -10,8 +10,9 @@ __all__ = ['ShowBase', 'WindowControls'] #import VerboseImport from panda3d.core import * -from panda3d.direct import get_config_showbase, throw_new_frame, init_app_for_gui +from panda3d.direct import throw_new_frame, init_app_for_gui from panda3d.direct import storeAccessibilityShortcutKeys, allowAccessibilityShortcutKeys +from . import DConfig # Register the extension methods for NodePath. from direct.extensions_native import NodePath_extensions @@ -22,7 +23,7 @@ if sys.version_info >= (3, 0): import builtins else: import __builtin__ as builtins -builtins.config = get_config_showbase() +builtins.config = DConfig from direct.directnotify.DirectNotifyGlobal import directNotify, giveNotify from .MessengerGlobal import messenger @@ -57,7 +58,7 @@ def exitfunc(): # *seem* to cause anyone any problems. class ShowBase(DirectObject.DirectObject): - config = get_config_showbase() + config = DConfig notify = directNotify.newCategory("ShowBase") def __init__(self, fStartDirect = True, windowType = None): diff --git a/direct/src/showbase/ShowBaseGlobal.py b/direct/src/showbase/ShowBaseGlobal.py index 459d5f708f..487524dd6a 100644 --- a/direct/src/showbase/ShowBaseGlobal.py +++ b/direct/src/showbase/ShowBaseGlobal.py @@ -12,9 +12,8 @@ from direct.directnotify.DirectNotifyGlobal import directNotify, giveNotify from panda3d.core import VirtualFileSystem, Notify, ClockObject, PandaSystem from panda3d.core import ConfigPageManager, ConfigVariableManager from panda3d.core import NodePath, PGTop -from panda3d.direct import get_config_showbase +from . import DConfig as config -config = get_config_showbase() __dev__ = config.GetBool('want-dev', __debug__) vfs = VirtualFileSystem.getGlobalPtr() diff --git a/direct/src/showbase/showBase.cxx b/direct/src/showbase/showBase.cxx index 7d8973996f..588dbb6540 100644 --- a/direct/src/showbase/showBase.cxx +++ b/direct/src/showbase/showBase.cxx @@ -61,14 +61,6 @@ throw_new_frame() { throw_event("NewFrame"); } -// Returns the configure object for accessing config variables from a -// scripting language. -DConfig & -get_config_showbase() { - static DConfig config_showbase; - return config_showbase; -} - // Initialize the application for making a Gui-based app, such as wx. At the // moment, this is a no-op except on Mac. void diff --git a/direct/src/showbase/showBase.h b/direct/src/showbase/showBase.h index a38a791d3b..b6b90eedd0 100644 --- a/direct/src/showbase/showBase.h +++ b/direct/src/showbase/showBase.h @@ -38,7 +38,6 @@ EXPCL_DIRECT_SHOWBASE ConfigVariableSearchPath &get_particle_path(); EXPCL_DIRECT_SHOWBASE void throw_new_frame(); -EXPCL_DIRECT_SHOWBASE DConfig &get_config_showbase(); EXPCL_DIRECT_SHOWBASE void init_app_for_gui(); // klunky interface since we cant pass array from python->C++ diff --git a/dtool/src/dconfig/config_dconfig.cxx b/dtool/src/dconfig/config_dconfig.cxx deleted file mode 100644 index f828fc8f7d..0000000000 --- a/dtool/src/dconfig/config_dconfig.cxx +++ /dev/null @@ -1,21 +0,0 @@ -/** - * 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." - * - * @file config_dconfig.cxx - * @author drose - * @date 2000-05-15 - */ - -#include "config_dconfig.h" - -#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_DTOOL_DCONFIG) - #error Buildsystem error: BUILDING_DTOOL_DCONFIG not defined -#endif - -NotifyCategoryDef(dconfig, ""); -NotifyCategoryDef(microconfig, "dconfig"); diff --git a/dtool/src/dconfig/config_dconfig.h b/dtool/src/dconfig/config_dconfig.h deleted file mode 100644 index e01fdcf441..0000000000 --- a/dtool/src/dconfig/config_dconfig.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * 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." - * - * @file config_dconfig.h - * @author drose - * @date 2000-05-15 - */ - -#ifndef CONFIG_DCONFIG_H -#define CONFIG_DCONFIG_H - -#ifdef WIN32_VC -/* C4231: extern before template instantiation */ -/* MPG - For some reason, this one only works if it's here */ -#pragma warning (disable : 4231) -#endif - -#include "dtoolbase.h" -#include "notifyCategoryProxy.h" - -NotifyCategoryDecl(dconfig, EXPCL_DTOOL_DCONFIG, EXPTP_DTOOL_DCONFIG); -NotifyCategoryDecl(microconfig, EXPCL_DTOOL_DCONFIG, EXPTP_DTOOL_DCONFIG); - -#endif diff --git a/dtool/src/dconfig/dconfig.I b/dtool/src/dconfig/dconfig.I deleted file mode 100644 index e40db3c2b0..0000000000 --- a/dtool/src/dconfig/dconfig.I +++ /dev/null @@ -1,42 +0,0 @@ -/** - * 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." - * - * @file dconfig.I - * @author cary - * @date 2000-03-20 - */ - -bool DConfig:: -GetBool(const std::string &sym, bool def) { - ConfigVariableBool var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); -} - -int DConfig:: -GetInt(const std::string &sym, int def) { - ConfigVariableInt var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); -} - -float DConfig:: -GetFloat(const std::string &sym, float def) { - ConfigVariableDouble var(sym, (double)def, "DConfig", ConfigFlags::F_dconfig); - return (float)var.get_value(); -} - -double DConfig:: -GetDouble(const std::string &sym, double def) { - ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); -} - -std::string DConfig:: -GetString(const std::string &sym, const std::string &def) { - ConfigVariableString var(sym, def, "DConfig", ConfigFlags::F_dconfig); - return var.get_value(); -} diff --git a/dtool/src/dconfig/dconfig.cxx b/dtool/src/dconfig/dconfig.cxx deleted file mode 100644 index b57f5b70f4..0000000000 --- a/dtool/src/dconfig/dconfig.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/** - * 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." - * - * @file dconfig.cxx - * @author drose - * @date 1999-02-08 - */ - -#include "dconfig.h" diff --git a/dtool/src/dconfig/dconfig.h b/dtool/src/dconfig/dconfig.h index fca35685ed..fe195bf400 100644 --- a/dtool/src/dconfig/dconfig.h +++ b/dtool/src/dconfig/dconfig.h @@ -15,32 +15,7 @@ #define DCONFIG_H #include "dtoolbase.h" - -#include "config_dconfig.h" -#include "configVariableString.h" -#include "configVariableBool.h" -#include "configVariableInt.h" -#include "configVariableDouble.h" -#include "configVariableList.h" -#include "configFlags.h" - -/** - * This class emulates the old dconfig-style interface to our Panda config - * system. It exists only to provide backward-compatible support, and it is - * used primarily by Python code. For modern code, use the new - * ConfigVariable* interface instead of this deprecated interface. - */ -class EXPCL_DTOOL_DCONFIG DConfig { -PUBLISHED: - static INLINE bool GetBool(const std::string &sym, bool def = false); - static INLINE int GetInt(const std::string &sym, int def = 0); - static INLINE float GetFloat(const std::string &sym, float def = 0.); - static INLINE double GetDouble(const std::string &sym, double def = 0.); - static INLINE std::string GetString(const std::string &sym, const std::string &def = ""); -}; - -#include "dconfig.I" - +#include "notifyCategoryProxy.h" // These macros are used in each directory to call an initialization function // at static-init time. These macros may eventually be phased out in favor of diff --git a/dtool/src/dconfig/p3dconfig_composite1.cxx b/dtool/src/dconfig/p3dconfig_composite1.cxx deleted file mode 100644 index f35232700b..0000000000 --- a/dtool/src/dconfig/p3dconfig_composite1.cxx +++ /dev/null @@ -1,3 +0,0 @@ - -#include "config_dconfig.cxx" -#include "dconfig.cxx" diff --git a/dtool/src/dconfig/test_config.cxx b/dtool/src/dconfig/test_config.cxx deleted file mode 100644 index 2374bd775e..0000000000 --- a/dtool/src/dconfig/test_config.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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." - * - * @file test_config.cxx - * @author cary - * @date 1998-09-10 - */ - -#include "dconfig.h" - -using std::cout; -using std::endl; - -#define SNARF -Configure(test); - -std::string foo = test.GetString("user"); -std::string path = test.GetString("LD_LIBRARY_PATH"); - -ConfigureFn(test) -{ - cout << "AIEE! Doing work before main()! The sky is falling!" << endl; -} - -main() -{ - cout << "Testing Configuration functionality:" << endl; - cout << "foo = " << foo << endl; - cout << "path = " << path << endl; -} diff --git a/dtool/src/dconfig/test_expand.cxx b/dtool/src/dconfig/test_expand.cxx deleted file mode 100644 index 334bf2593d..0000000000 --- a/dtool/src/dconfig/test_expand.cxx +++ /dev/null @@ -1,87 +0,0 @@ -/** - * 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." - * - * @file test_expand.cxx - * @author cary - * @date 1998-08-31 - */ - -#include "expand.h" -#include - -using std::cout; -using std::endl; - -void TestExpandFunction() -{ - std::string line; - - line = "foo"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << Expand::Expand(line) << "'" << endl; - line = "'foo'"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << Expand::Expand(line) << "'" << endl; - line = "'$USER'"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << Expand::Expand(line) << "'" << endl; - line = "$USER"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << Expand::Expand(line) << "'" << endl; - line = "\"$USER\""; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << Expand::Expand(line) << "'" << endl; - line = "`ls -l`"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << Expand::Expand(line) << "'" << endl; - line = "~"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << Expand::Expand(line) << "'" << endl; - line = "~cary"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << Expand::Expand(line) << "'" << endl; -} - -void TestExpandClass() -{ - std::string line; - - line = "foo"; - Expand::Expander ex(line); - cout << "input: '" << line << "'" << endl; - cout << "output: '" << ex() << "'" << endl; - line = "'foo'"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << ex(line) << "'" << endl; - line = "'$USER'"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << ex(line) << "'" << endl; - line = "$USER"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << ex(line) << "'" << endl; - line = "\"$USER\""; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << ex(line) << "'" << endl; - line = "`ls -l`"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << ex(line) << "'" << endl; - line = "~"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << ex(line) << "'" << endl; - line = "~cary"; - cout << "input: '" << line << "'" << endl; - cout << "output: '" << ex(line) << "'" << endl; -} - -main() -{ - cout << endl << "Testing shell expansion (function version):" << endl; - TestExpandFunction(); - cout << endl << "Testing shell expansion (class version):" << endl; - TestExpandClass(); -} diff --git a/dtool/src/dconfig/test_pfstream.cxx b/dtool/src/dconfig/test_pfstream.cxx deleted file mode 100644 index 9b211c2381..0000000000 --- a/dtool/src/dconfig/test_pfstream.cxx +++ /dev/null @@ -1,32 +0,0 @@ -/** - * 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." - * - * @file test_pfstream.cxx - * @author cary - * @date 1998-08-31 - */ - -#include "pfstream.h" -#include - -void ReadIt(std::istream& ifs) { - std::string line; - - while (!ifs.eof()) { - std::getline(ifs, line); - if (line.length() != 0) - std::cout << line << std::endl; - } -} - -main() -{ - IPipeStream ipfs("ls -l"); - - ReadIt(ipfs); -} diff --git a/dtool/src/dconfig/test_searchpath.cxx b/dtool/src/dconfig/test_searchpath.cxx deleted file mode 100644 index 4abf1f71bd..0000000000 --- a/dtool/src/dconfig/test_searchpath.cxx +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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." - * - * @file test_searchpath.cxx - * @author cary - * @date 1998-09-01 - */ - -#include "dSearchPath.h" -// #include "expand.h" -#include - -using std::cout; -using std::endl; - -void TestSearch() -{ - std::string line, path; - -// path = ".:~ etc"; - path = ". /etc"; -// path = Expand::Expand(path); - line = "searchpath.h"; - cout << "looking for file '" << line << "' in path '" << path << "': '"; - line = DSearchPath::search_path(line, path); - cout << line << "'" << endl; - - line = ".cshrc"; - cout << "looking for file '" << line << "' in path '" << path << "': '"; - line = DSearchPath::search_path(line, path); - cout << line << "'" << endl; - - line = "passwd"; - cout << "looking for file '" << line << "' in path '" << path << "': '"; - line = DSearchPath::search_path(line, path); - cout << line << "'" << endl; -} - -main() -{ - cout << "Testing search path:" << endl; - TestSearch(); -} diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 7f82da5b80..96effc4c43 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2862,6 +2862,20 @@ except ImportError as err: if "No module named %s" not in str(err): raise""" % (module, module) +panda_modules_code += """ + +from direct.showbase import DConfig + +def get_config_showbase(): + return DConfig + +def get_config_express(): + return DConfig + +getConfigShowbase = get_config_showbase +getConfigExpress = get_config_express +""" + exthelpers_code = """ "This module is deprecated. Import from direct.extensions_native.extension_native_helpers instead." from direct.extensions_native.extension_native_helpers import * @@ -3412,13 +3426,6 @@ OPTS=['DIR:dtool/src/prc', 'BUILDING:DTOOLCONFIG', 'OPENSSL'] TargetAdd('p3prc_composite1.obj', opts=OPTS, input='p3prc_composite1.cxx') TargetAdd('p3prc_composite2.obj', opts=OPTS, input='p3prc_composite2.cxx') -# -# DIRECTORY: dtool/src/dconfig/ -# - -OPTS=['DIR:dtool/src/dconfig', 'BUILDING:DTOOLCONFIG'] -TargetAdd('p3dconfig_composite1.obj', opts=OPTS, input='p3dconfig_composite1.cxx') - # # DIRECTORY: dtool/metalibs/dtoolconfig/ # @@ -3426,7 +3433,6 @@ TargetAdd('p3dconfig_composite1.obj', opts=OPTS, input='p3dconfig_composite1.cxx OPTS=['DIR:dtool/metalibs/dtoolconfig', 'BUILDING:DTOOLCONFIG'] TargetAdd('p3dtoolconfig_dtoolconfig.obj', opts=OPTS, input='dtoolconfig.cxx') TargetAdd('libp3dtoolconfig.dll', input='p3dtoolconfig_dtoolconfig.obj') -TargetAdd('libp3dtoolconfig.dll', input='p3dconfig_composite1.obj') TargetAdd('libp3dtoolconfig.dll', input='p3prc_composite1.obj') TargetAdd('libp3dtoolconfig.dll', input='p3prc_composite2.obj') TargetAdd('libp3dtoolconfig.dll', input='libp3dtool.dll') @@ -5640,7 +5646,6 @@ if (RTDIST): TargetAdd('plugin_standalone_dtoolutil_filename_assist.obj', opts=OPTS, input='filename_assist.mm') TargetAdd('plugin_standalone_prc_composite1.obj', opts=OPTS, input='p3prc_composite1.cxx') TargetAdd('plugin_standalone_prc_composite2.obj', opts=OPTS, input='p3prc_composite2.cxx') - TargetAdd('plugin_standalone_dconfig_composite1.obj', opts=OPTS, input='p3dconfig_composite1.cxx') TargetAdd('plugin_standalone_express_composite1.obj', opts=OPTS, input='p3express_composite1.cxx') TargetAdd('plugin_standalone_express_composite2.obj', opts=OPTS, input='p3express_composite2.cxx') TargetAdd('plugin_standalone_downloader_composite1.obj', opts=OPTS, input='p3downloader_composite1.cxx') @@ -5659,7 +5664,6 @@ if (RTDIST): TargetAdd('p3dembed.exe', input='plugin_standalone_dtoolutil_filename_assist.obj') TargetAdd('p3dembed.exe', input='plugin_standalone_prc_composite1.obj') TargetAdd('p3dembed.exe', input='plugin_standalone_prc_composite2.obj') - TargetAdd('p3dembed.exe', input='plugin_standalone_dconfig_composite1.obj') TargetAdd('p3dembed.exe', input='plugin_standalone_express_composite1.obj') TargetAdd('p3dembed.exe', input='plugin_standalone_express_composite2.obj') TargetAdd('p3dembed.exe', input='plugin_standalone_downloader_composite1.obj') @@ -5688,7 +5692,6 @@ if (RTDIST): TargetAdd('p3dembedw.exe', input='plugin_standalone_dtoolutil_composite2.obj') TargetAdd('p3dembedw.exe', input='plugin_standalone_prc_composite1.obj') TargetAdd('p3dembedw.exe', input='plugin_standalone_prc_composite2.obj') - TargetAdd('p3dembedw.exe', input='plugin_standalone_dconfig_composite1.obj') TargetAdd('p3dembedw.exe', input='plugin_standalone_express_composite1.obj') TargetAdd('p3dembedw.exe', input='plugin_standalone_express_composite2.obj') TargetAdd('p3dembedw.exe', input='plugin_standalone_downloader_composite1.obj') diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index c9e664db34..c147a1ce8f 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -190,11 +190,3 @@ get_verify_dcast() { return *verify_dcast; } - -// Returns the configure object for accessing config variables from a -// scripting language. -DConfig & -get_config_express() { - static DConfig config_express; - return config_express; -} diff --git a/panda/src/express/config_express.h b/panda/src/express/config_express.h index 13719ad8a3..7ec19749f0 100644 --- a/panda/src/express/config_express.h +++ b/panda/src/express/config_express.h @@ -54,11 +54,6 @@ extern ConfigVariableBool multifile_always_binary; extern EXPCL_PANDA_EXPRESS ConfigVariableBool collect_tcp; extern EXPCL_PANDA_EXPRESS ConfigVariableDouble collect_tcp_interval; -// Expose the Config variable for Python access. -BEGIN_PUBLISH -EXPCL_PANDA_EXPRESS DConfig &get_config_express(); -END_PUBLISH - extern EXPCL_PANDA_EXPRESS void init_libexpress(); #endif /* __CONFIG_UTIL_H__ */ diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index eb915b566c..84b6f67224 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -22,6 +22,8 @@ #include "dSearchPath.h" #include "dcast.h" #include "config_express.h" +#include "configVariableList.h" +#include "configVariableString.h" #include "executionEnvironment.h" #include "pset.h" diff --git a/panda/src/pgraph/config_pgraph.h b/panda/src/pgraph/config_pgraph.h index 988c9b1d2b..22050bd75e 100644 --- a/panda/src/pgraph/config_pgraph.h +++ b/panda/src/pgraph/config_pgraph.h @@ -21,6 +21,7 @@ #include "configVariableInt.h" #include "configVariableDouble.h" #include "configVariableList.h" +#include "configVariableString.h" class DSearchPath; diff --git a/panda/src/putil/config_putil.h b/panda/src/putil/config_putil.h index ec9f683378..dc8681b43c 100644 --- a/panda/src/putil/config_putil.h +++ b/panda/src/putil/config_putil.h @@ -16,9 +16,11 @@ #include "pandabase.h" #include "notifyCategoryProxy.h" +#include "configVariableBool.h" #include "configVariableSearchPath.h" #include "configVariableEnum.h" #include "configVariableDouble.h" +#include "configVariableInt.h" #include "bamEnums.h" #include "dconfig.h" diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index 9cdb70263d..a509e93edf 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -19,7 +19,6 @@ #include "dSearchPath.h" #include "coordinateSystem.h" #include "dconfig.h" -#include "config_dconfig.h" #include "string_utils.h" #include "vector_string.h" #include "configVariableInt.h" From b5bf6cd73c0d43f2caf32046143786d874e7227c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 3 Nov 2018 22:40:13 -0600 Subject: [PATCH 295/360] vision: Fix missing includes/declarations --- panda/src/vision/webcamVideoCursorOpenCV.cxx | 7 ++++++- panda/src/vision/webcamVideoCursorOpenCV.h | 1 + panda/src/vision/webcamVideoCursorV4L.cxx | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/panda/src/vision/webcamVideoCursorOpenCV.cxx b/panda/src/vision/webcamVideoCursorOpenCV.cxx index 444557fde8..629cd927ae 100644 --- a/panda/src/vision/webcamVideoCursorOpenCV.cxx +++ b/panda/src/vision/webcamVideoCursorOpenCV.cxx @@ -11,12 +11,17 @@ * @date 2010-10-20 */ -#include "webcamVideoOpenCV.h" +#include "webcamVideoCursorOpenCV.h" #ifdef HAVE_OPENCV +#include "webcamVideoOpenCV.h" +#include "movieVideoCursor.h" + #include "pStatTimer.h" +#include + TypeHandle WebcamVideoCursorOpenCV::_type_handle; /** diff --git a/panda/src/vision/webcamVideoCursorOpenCV.h b/panda/src/vision/webcamVideoCursorOpenCV.h index 6f7e0758f6..3ef1145bc2 100644 --- a/panda/src/vision/webcamVideoCursorOpenCV.h +++ b/panda/src/vision/webcamVideoCursorOpenCV.h @@ -22,6 +22,7 @@ #include "movieVideoCursor.h" class WebcamVideoOpenCV; +struct CvCapture; /** * The Video4Linux implementation of webcams. diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index 95565f9428..8bb77658f6 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -11,8 +11,13 @@ * @date 2010-06-11 */ +#include "webcamVideoCursorV4L.h" + +#include "config_vision.h" #include "webcamVideoV4L.h" +#include "movieVideoCursor.h" + #if defined(HAVE_VIDEO4LINUX) && !defined(CPPPARSER) #include From 0b91b3eeb3b0b74e85aa3c7aaf396994e960bf49 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 3 Nov 2018 22:45:34 -0600 Subject: [PATCH 296/360] vrpn: Add VRPN headers to parser-inc, remove CPPPARSER workarounds --- dtool/src/parser-inc/vrpn_Analog.h | 4 ++++ dtool/src/parser-inc/vrpn_Button.h | 4 ++++ dtool/src/parser-inc/vrpn_Configure.h | 3 +++ dtool/src/parser-inc/vrpn_Connection.h | 3 +++ dtool/src/parser-inc/vrpn_Dial.h | 4 ++++ dtool/src/parser-inc/vrpn_Tracker.h | 6 ++++++ panda/src/vrpn/vrpn_interface.h | 10 ---------- 7 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 dtool/src/parser-inc/vrpn_Analog.h create mode 100644 dtool/src/parser-inc/vrpn_Button.h create mode 100644 dtool/src/parser-inc/vrpn_Configure.h create mode 100644 dtool/src/parser-inc/vrpn_Connection.h create mode 100644 dtool/src/parser-inc/vrpn_Dial.h create mode 100644 dtool/src/parser-inc/vrpn_Tracker.h diff --git a/dtool/src/parser-inc/vrpn_Analog.h b/dtool/src/parser-inc/vrpn_Analog.h new file mode 100644 index 0000000000..f8951d032a --- /dev/null +++ b/dtool/src/parser-inc/vrpn_Analog.h @@ -0,0 +1,4 @@ +#pragma once + +class vrpn_Analog_Remote; +typedef void vrpn_ANALOGCB; diff --git a/dtool/src/parser-inc/vrpn_Button.h b/dtool/src/parser-inc/vrpn_Button.h new file mode 100644 index 0000000000..433c282a44 --- /dev/null +++ b/dtool/src/parser-inc/vrpn_Button.h @@ -0,0 +1,4 @@ +#pragma once + +class vrpn_Button_Remote; +typedef void vrpn_BUTTONCB; diff --git a/dtool/src/parser-inc/vrpn_Configure.h b/dtool/src/parser-inc/vrpn_Configure.h new file mode 100644 index 0000000000..9e4a950e73 --- /dev/null +++ b/dtool/src/parser-inc/vrpn_Configure.h @@ -0,0 +1,3 @@ +#pragma once + +#define VRPN_CALLBACK diff --git a/dtool/src/parser-inc/vrpn_Connection.h b/dtool/src/parser-inc/vrpn_Connection.h new file mode 100644 index 0000000000..c35b54de38 --- /dev/null +++ b/dtool/src/parser-inc/vrpn_Connection.h @@ -0,0 +1,3 @@ +#pragma once + +class vrpn_Connection; diff --git a/dtool/src/parser-inc/vrpn_Dial.h b/dtool/src/parser-inc/vrpn_Dial.h new file mode 100644 index 0000000000..34ae1269a7 --- /dev/null +++ b/dtool/src/parser-inc/vrpn_Dial.h @@ -0,0 +1,4 @@ +#pragma once + +class vrpn_Dial_Remote; +typedef void vrpn_DIALCB; diff --git a/dtool/src/parser-inc/vrpn_Tracker.h b/dtool/src/parser-inc/vrpn_Tracker.h new file mode 100644 index 0000000000..2fe1eecd9a --- /dev/null +++ b/dtool/src/parser-inc/vrpn_Tracker.h @@ -0,0 +1,6 @@ +#pragma once + +class vrpn_Tracker_Remote; +typedef void vrpn_TRACKERCB; +typedef void vrpn_TRACKERACCCB; +typedef void vrpn_TRACKERVELCB; diff --git a/panda/src/vrpn/vrpn_interface.h b/panda/src/vrpn/vrpn_interface.h index a788d7ae73..c85c05e31b 100644 --- a/panda/src/vrpn/vrpn_interface.h +++ b/panda/src/vrpn/vrpn_interface.h @@ -16,16 +16,6 @@ #include "pandabase.h" -#ifdef CPPPARSER - // For correct interrogate parsing of UNC's vrpn library. - #if defined(WIN32_VC) || defined(WIN64_VC) - #define SOCKET int - #else - #define linux - typedef struct timeval timeval; - #endif -#endif - // VPRN misses an include to this in vrpn_Shared.h. #include From 842667fd1a80fd6dfc74b8804756784b1012a21b Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 4 Nov 2018 15:22:54 +0100 Subject: [PATCH 297/360] physx: fix missing include [skip ci] --- panda/src/physx/config_physx.h | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/physx/config_physx.h b/panda/src/physx/config_physx.h index f17af252b6..3c3925ec92 100644 --- a/panda/src/physx/config_physx.h +++ b/panda/src/physx/config_physx.h @@ -19,6 +19,7 @@ #include "configVariableBool.h" #include "configVariableEnum.h" #include "configVariableInt.h" +#include "configVariableString.h" #include "dconfig.h" #include "physxEnums.h" From b13c4fb8d19294d76ecfa0f104f906998ec78597 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 5 Nov 2018 21:14:21 +0100 Subject: [PATCH 298/360] pystub: add a few more calls --- dtool/src/pystub/pystub.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index b2e9d4d62f..299da8fa0f 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -27,6 +27,8 @@ extern "C" { EXPCL_PYSTUB int PyCFunction_New(...); EXPCL_PYSTUB int PyCFunction_NewEx(...); EXPCL_PYSTUB int PyCallable_Check(...); + EXPCL_PYSTUB int PyCapsule_GetPointer(...); + EXPCL_PYSTUB int PyCapsule_New(...); EXPCL_PYSTUB int PyDict_DelItem(...); EXPCL_PYSTUB int PyDict_DelItemString(...); EXPCL_PYSTUB int PyDict_GetItem(...); @@ -133,6 +135,7 @@ extern "C" { EXPCL_PYSTUB int PyString_InternInPlace(...); EXPCL_PYSTUB int PyString_Size(...); EXPCL_PYSTUB int PySys_GetObject(...); + EXPCL_PYSTUB int PySys_SetObject(...); EXPCL_PYSTUB int PyThreadState_Clear(...); EXPCL_PYSTUB int PyThreadState_Delete(...); EXPCL_PYSTUB int PyThreadState_Get(...); @@ -216,6 +219,7 @@ extern "C" { EXPCL_PYSTUB extern void *PyExc_ImportError; EXPCL_PYSTUB extern void *PyExc_IndexError; EXPCL_PYSTUB extern void *PyExc_KeyError; + EXPCL_PYSTUB extern void *PyExc_NameError; EXPCL_PYSTUB extern void *PyExc_OSError; EXPCL_PYSTUB extern void *PyExc_OverflowError; EXPCL_PYSTUB extern void *PyExc_RuntimeError; @@ -257,6 +261,8 @@ int PyBytes_Size(...) { return 0; } int PyCFunction_New(...) { return 0; }; int PyCFunction_NewEx(...) { return 0; }; int PyCallable_Check(...) { return 0; } +int PyCapsule_GetPointer(...) { return 0; } +int PyCapsule_New(...) { return 0; } int PyDict_DelItem(...) { return 0; } int PyDict_DelItemString(...) { return 0; } int PyDict_GetItem(...) { return 0; } @@ -363,6 +369,7 @@ int PyString_FromStringAndSize(...) { return 0; } int PyString_InternFromString(...) { return 0; } int PyString_InternInPlace(...) { return 0; } int PySys_GetObject(...) { return 0; } +int PySys_SetObject(...) { return 0; } int PyThreadState_Clear(...) { return 0; } int PyThreadState_Delete(...) { return 0; } int PyThreadState_Get(...) { return 0; } @@ -452,6 +459,7 @@ void *PyExc_FutureWarning = nullptr; void *PyExc_ImportError = nullptr; void *PyExc_IndexError = nullptr; void *PyExc_KeyError = nullptr; +void *PyExc_NameError = nullptr; void *PyExc_OSError = nullptr; void *PyExc_OverflowError = nullptr; void *PyExc_RuntimeError = nullptr; From da05ef1f5c2250cc9dc8e24ed8b7c32eec1bbc19 Mon Sep 17 00:00:00 2001 From: Brian Lach Date: Mon, 5 Nov 2018 21:16:33 +0100 Subject: [PATCH 299/360] glgsg: send fog parameters to GLSL shaders Closes #438 --- panda/src/glstuff/glShaderContext_src.cxx | 72 +++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 64a5e77553..b3a608d068 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -1145,6 +1145,78 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { } return; } + if (size > 4 && noprefix.substr(0, 4) == "Fog.") { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._func = Shader::SMF_first; + bind._arg[0] = nullptr; + bind._dep[0] = Shader::SSD_general | Shader::SSD_fog; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = nullptr; + bind._dep[1] = Shader::SSD_NONE; + + if (noprefix == "Fog.color") { + bind._part[0] = Shader::SMO_attr_fogcolor; + + if (param_type == GL_FLOAT_VEC3) { + bind._piece = Shader::SMP_row3x3; + } else if (param_type == GL_FLOAT_VEC4) { + bind._piece = Shader::SMP_row3; + } else { + GLCAT.error() + << "p3d_Fog.color should be vec3 or vec4\n"; + return; + } + + } else if (noprefix == "Fog.density") { + bind._part[0] = Shader::SMO_attr_fog; + + if (param_type == GL_FLOAT) { + bind._piece = Shader::SMP_row3x1; + } else { + GLCAT.error() + << "p3d_Fog.density should be float\n"; + return; + } + + } else if (noprefix == "Fog.start") { + bind._part[0] = Shader::SMO_attr_fog; + + if (param_type == GL_FLOAT) { + bind._piece = Shader::SMP_cell13; + } else { + GLCAT.error() + << "p3d_Fog.start should be float\n"; + return; + } + + } else if (noprefix == "Fog.end") { + bind._part[0] = Shader::SMO_attr_fog; + + if (param_type == GL_FLOAT) { + bind._piece = Shader::SMP_cell14; + } else { + GLCAT.error() + << "p3d_Fog.end should be float\n"; + return; + } + + } else if (noprefix == "Fog.scale") { + bind._part[0] = Shader::SMO_attr_fog; + + if (param_type == GL_FLOAT) { + bind._piece = Shader::SMP_cell15; + } else { + GLCAT.error() + << "p3d_Fog.scale should be float\n"; + return; + } + } + + _shader->_mat_spec.push_back(bind); + _shader->_mat_deps |= bind._dep[0]; + return; + } if (noprefix == "LightModel.ambient") { Shader::ShaderMatSpec bind; bind._id = arg_id; From e6f870ece6f973fd57ecf57c62ec96a4a898cc6c Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 5 Nov 2018 21:48:50 +0100 Subject: [PATCH 300/360] Remove Python type tables from interrogatedb --- dtool/src/dtoolbase/typeHandle.cxx | 13 ++ dtool/src/dtoolbase/typeHandle.h | 2 + dtool/src/dtoolbase/typeRegistry.cxx | 16 ++ dtool/src/dtoolbase/typeRegistry.h | 1 + dtool/src/dtoolbase/typeRegistryNode.I | 13 ++ dtool/src/dtoolbase/typeRegistryNode.cxx | 23 +++ dtool/src/dtoolbase/typeRegistryNode.h | 5 + .../interfaceMakerPythonNative.cxx | 114 +++++++++----- dtool/src/interrogate/interrogate_module.cxx | 13 +- dtool/src/interrogatedb/py_panda.I | 10 +- dtool/src/interrogatedb/py_panda.cxx | 149 ++++++------------ dtool/src/interrogatedb/py_panda.h | 20 ++- 12 files changed, 216 insertions(+), 163 deletions(-) diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index 15fac6b60f..30d499bf01 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -153,6 +153,19 @@ deallocate_array(void *ptr) { PANDA_FREE_ARRAY(ptr); } +/** + * Returns the internal void pointer that is stored for interrogate's benefit. + */ +PyObject *TypeHandle:: +get_python_type() const { + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + if (rnode != nullptr) { + return rnode->get_python_type(); + } else { + return nullptr; + } +} + /** * Return the Index of the BEst fit Classs from a set */ diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index 97dc445443..ed5ab3f586 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -138,6 +138,8 @@ PUBLISHED: MAKE_SEQ_PROPERTY(child_classes, get_num_child_classes, get_child_class); public: + PyObject *get_python_type() const; + void *allocate_array(size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); void *reallocate_array(void *ptr, size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); void deallocate_array(void *ptr); diff --git a/dtool/src/dtoolbase/typeRegistry.cxx b/dtool/src/dtoolbase/typeRegistry.cxx index 23cdb5ebfb..d18ca61244 100644 --- a/dtool/src/dtoolbase/typeRegistry.cxx +++ b/dtool/src/dtoolbase/typeRegistry.cxx @@ -207,6 +207,22 @@ record_alternate_name(TypeHandle type, const string &name) { _lock->unlock(); } +/** + * Records the given Python type pointer in the type registry for the benefit + * of interrogate. + */ +void TypeRegistry:: +record_python_type(TypeHandle type, PyObject *python_type) { + _lock->lock(); + + TypeRegistryNode *rnode = look_up(type, nullptr); + if (rnode != nullptr) { + rnode->_python_type = python_type; + } + + _lock->unlock(); +} + /** * Looks for a previously-registered type of the given name. Returns its * TypeHandle if it exists, or TypeHandle::none() if there is no such type. diff --git a/dtool/src/dtoolbase/typeRegistry.h b/dtool/src/dtoolbase/typeRegistry.h index dc7df60541..4a6bd5d1e0 100644 --- a/dtool/src/dtoolbase/typeRegistry.h +++ b/dtool/src/dtoolbase/typeRegistry.h @@ -45,6 +45,7 @@ PUBLISHED: void record_derivation(TypeHandle child, TypeHandle parent); void record_alternate_name(TypeHandle type, const std::string &name); + void record_python_type(TypeHandle type, PyObject *python_type); TypeHandle find_type(const std::string &name) const; TypeHandle find_type_by_id(int id) const; diff --git a/dtool/src/dtoolbase/typeRegistryNode.I b/dtool/src/dtoolbase/typeRegistryNode.I index 4328a47d79..1556e63847 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.I +++ b/dtool/src/dtoolbase/typeRegistryNode.I @@ -11,6 +11,19 @@ * @date 2001-08-06 */ +/** + * Returns the Python type object associated with this node. + */ +INLINE PyObject *TypeRegistryNode:: +get_python_type() const { + if (_python_type != nullptr || _parent_classes.empty()) { + return _python_type; + } else { + // Recurse through parent classes. + return r_get_python_type(); + } +} + /** * */ diff --git a/dtool/src/dtoolbase/typeRegistryNode.cxx b/dtool/src/dtoolbase/typeRegistryNode.cxx index f809ddcc0b..19b4629236 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.cxx +++ b/dtool/src/dtoolbase/typeRegistryNode.cxx @@ -308,6 +308,29 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, } } +/** + * Recurses through the parent nodes to find the best Python type object to + * represent objects of this type. + */ +PyObject *TypeRegistryNode:: +r_get_python_type() const { + Classes::const_iterator ni; + for (ni = _parent_classes.begin(); ni != _parent_classes.end(); ++ni) { + const TypeRegistryNode *parent = *ni; + if (parent->_python_type != nullptr) { + return parent->_python_type; + + } else if (!parent->_parent_classes.empty()) { + PyObject *py_type = parent->r_get_python_type(); + if (py_type != nullptr) { + return py_type; + } + } + } + + return nullptr; +} + /** * A recursive function to double-check the result of is_derived_from(). This * is the slow, examine-the-whole-graph approach, as opposed to the clever and diff --git a/dtool/src/dtoolbase/typeRegistryNode.h b/dtool/src/dtoolbase/typeRegistryNode.h index dd888cbf59..7dd7f387cc 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.h +++ b/dtool/src/dtoolbase/typeRegistryNode.h @@ -37,6 +37,8 @@ public: static TypeHandle get_parent_towards(const TypeRegistryNode *child, const TypeRegistryNode *base); + INLINE PyObject *get_python_type() const; + void clear_subtree(); void define_subtree(); @@ -46,6 +48,7 @@ public: typedef std::vector Classes; Classes _parent_classes; Classes _child_classes; + PyObject *_python_type = nullptr; AtomicAdjust::Integer _memory_usage[TypeHandle::MC_limit]; @@ -77,6 +80,8 @@ private: void r_build_subtrees(TypeRegistryNode *top, int bit_count, SubtreeMaskType bits); + PyObject *r_get_python_type() const; + static bool check_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base); diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 8d2b0f2288..60d2dd6466 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -821,10 +821,54 @@ write_prototypes(ostream &out_code, ostream *out_h) { } } + out_code << "/**\n"; + out_code << " * Declarations for exported classes\n"; + out_code << " */\n"; + + out_code << "static const Dtool_TypeDef exports[] = {\n"; + + for (oi = _objects.begin(); oi != _objects.end(); ++oi) { + Object *object = (*oi).second; + + if (object->_itype.is_class() || object->_itype.is_struct()) { + CPPType *type = object->_itype._cpptype; + + if (isExportThisRun(type) && is_cpp_type_legal(type)) { + string class_name = type->get_local_name(&parser); + string safe_name = make_safe_name(class_name); + + out_code << " {\"" << class_name << "\", &Dtool_" << safe_name << "},\n"; + } + } + } + + out_code << " {nullptr, nullptr},\n"; + out_code << "};\n\n"; + out_code << "/**\n"; out_code << " * Extern declarations for imported classes\n"; out_code << " */\n"; + // Write out a table of the externally imported types that will be filled in + // upon module initialization. + if (!_external_imports.empty()) { + out_code << "#ifndef LINK_ALL_STATIC\n"; + out_code << "static Dtool_TypeDef imports[] = {\n"; + + int idx = 0; + for (CPPType *type : _external_imports) { + string class_name = type->get_local_name(&parser); + string safe_name = make_safe_name(class_name); + + out_code << " {\"" << class_name << "\", nullptr},\n"; + out_code << "#define Dtool_Ptr_" << safe_name << " (imports[" << idx << "].type)\n"; + ++idx; + } + out_code << " {nullptr, nullptr},\n"; + out_code << "};\n"; + out_code << "#endif\n\n"; + } + for (CPPType *type : _external_imports) { string class_name = type->get_local_name(&parser); string safe_name = make_safe_name(class_name); @@ -834,7 +878,9 @@ write_prototypes(ostream &out_code, ostream *out_h) { out_code << "#ifndef LINK_ALL_STATIC\n"; // out_code << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << // safe_name << ";\n"; - out_code << "static struct Dtool_PyTypedObject *Dtool_Ptr_" << safe_name << ";\n"; + //if (has_get_class_type_function(type)) { + // out_code << "static struct Dtool_PyTypedObject *Dtool_Ptr_" << safe_name << ";\n"; + //} // out_code << "#define Dtool_Ptr_" << safe_name << " &Dtool_" << // safe_name << "\n"; out_code << "IMPORT_THIS void // Dtool_PyModuleClassInit_" << safe_name << "(PyObject *module);\n"; @@ -1258,36 +1304,36 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { Objects::iterator oi; - out << "void Dtool_" << def->library_name << "_RegisterTypes() {\n"; + out << "void Dtool_" << def->library_name << "_RegisterTypes() {\n" + " TypeRegistry *registry = TypeRegistry::ptr();\n" + " nassertv(registry != nullptr);\n"; + for (oi = _objects.begin(); oi != _objects.end(); ++oi) { Object *object = (*oi).second; - if (object->_itype.is_class() || - object->_itype.is_struct()) { - if (is_cpp_type_legal(object->_itype._cpptype) && - isExportThisRun(object->_itype._cpptype)) { - string class_name = make_safe_name(object->_itype.get_scoped_name()); - bool is_typed = has_get_class_type_function(object->_itype._cpptype); + if (object->_itype.is_class() || object->_itype.is_struct()) { + CPPType *type = object->_itype._cpptype; + if (is_cpp_type_legal(type) && isExportThisRun(type)) { + string class_name = object->_itype.get_scoped_name(); + string safe_name = make_safe_name(class_name); + bool is_typed = has_get_class_type_function(type); if (is_typed) { - if (has_init_type_function(object->_itype._cpptype)) { + out << " {\n"; + if (has_init_type_function(type)) { // Call the init_type function. This isn't necessary for all // types as many of them are automatically initialized at static // init type, but for some extension classes it's useful. - out << " " << object->_itype._cpptype->get_local_name(&parser) + out << " " << type->get_local_name(&parser) << "::init_type();\n"; } - out << " Dtool_" << class_name << "._type = " - << object->_itype._cpptype->get_local_name(&parser) - << "::get_class_type();\n" - << " RegisterRuntimeTypedClass(Dtool_" << class_name << ");\n"; - + out << " TypeHandle handle = " << type->get_local_name(&parser) + << "::get_class_type();\n"; + out << " Dtool_" << safe_name << "._type = handle;\n"; + out << " registry->record_python_type(handle, " + "(PyObject *)&Dtool_" << safe_name << ");\n"; + out << " }\n"; } else { - out << "#ifndef LINK_ALL_STATIC\n" - << " RegisterNamedClass(\"" << object->_itype.get_scoped_name() - << "\", Dtool_" << class_name << ");\n" - << "#endif\n"; - - if (IsPandaTypedObject(object->_itype._cpptype->as_struct_type())) { + if (IsPandaTypedObject(type->as_struct_type())) { nout << object->_itype.get_scoped_name() << " derives from TypedObject, " << "but does not define a get_class_type() function.\n"; } @@ -1297,23 +1343,6 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { } out << "}\n\n"; - out << "void Dtool_" << def->library_name << "_ResolveExternals() {\n"; - out << "#ifndef LINK_ALL_STATIC\n"; - out << " // Resolve externally imported types.\n"; - - for (CPPType *type : _external_imports) { - string class_name = type->get_local_name(&parser); - string safe_name = make_safe_name(class_name); - - if (has_get_class_type_function(type)) { - out << " Dtool_Ptr_" << safe_name << " = LookupRuntimeTypedClass(" << class_name << "::get_class_type());\n"; - } else { - out << " Dtool_Ptr_" << safe_name << " = LookupNamedClass(\"" << class_name << "\");\n"; - } - } - out << "#endif\n"; - out << "}\n\n"; - out << "void Dtool_" << def->library_name << "_BuildInstants(PyObject *module) {\n"; out << " (void) module;\n"; @@ -1466,9 +1495,14 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << " {nullptr, nullptr, 0, nullptr}\n" << "};\n\n"; - out << "struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs};\n"; + out << "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, "; + if (_external_imports.empty()) { + out << "nullptr};\n"; + } else { + out << "imports};\n"; + } if (out_h != nullptr) { - *out_h << "extern struct LibraryDef " << def->library_name << "_moddef;\n"; + *out_h << "extern const struct LibraryDef " << def->library_name << "_moddef;\n"; } } diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 5c5cc9d9ab..986033fd3c 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -286,9 +286,8 @@ int write_python_table_native(std::ostream &out) { vector_string::const_iterator ii; for (ii = libraries.begin(); ii != libraries.end(); ++ii) { printf("Referencing Library %s\n", (*ii).c_str()); - out << "extern LibraryDef " << *ii << "_moddef;\n"; + out << "extern const struct LibraryDef " << *ii << "_moddef;\n"; out << "extern void Dtool_" << *ii << "_RegisterTypes();\n"; - out << "extern void Dtool_" << *ii << "_ResolveExternals();\n"; out << "extern void Dtool_" << *ii << "_BuildInstants(PyObject *module);\n"; } @@ -339,12 +338,9 @@ int write_python_table_native(std::ostream &out) { for (ii = libraries.begin(); ii != libraries.end(); ii++) { out << " Dtool_" << *ii << "_RegisterTypes();\n"; } - for (ii = libraries.begin(); ii != libraries.end(); ii++) { - out << " Dtool_" << *ii << "_ResolveExternals();\n"; - } out << "\n"; - out << " LibraryDef *defs[] = {"; + out << " const LibraryDef *defs[] = {"; for(ii = libraries.begin(); ii != libraries.end(); ii++) { out << "&" << *ii << "_moddef, "; } @@ -386,12 +382,9 @@ int write_python_table_native(std::ostream &out) { for (ii = libraries.begin(); ii != libraries.end(); ii++) { out << " Dtool_" << *ii << "_RegisterTypes();\n"; } - for (ii = libraries.begin(); ii != libraries.end(); ii++) { - out << " Dtool_" << *ii << "_ResolveExternals();\n"; - } out << "\n"; - out << " LibraryDef *defs[] = {"; + out << " const LibraryDef *defs[] = {"; for(ii = libraries.begin(); ii != libraries.end(); ii++) { out << "&" << *ii << "_moddef, "; } diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index 69f8961463..f5f504ca97 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -26,7 +26,7 @@ template INLINE bool DtoolInstance_GetPointer(PyObject *self, T *&into) { if (DtoolInstance_Check(self)) { - Dtool_PyTypedObject *target_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); + Dtool_PyTypedObject *target_class = (Dtool_PyTypedObject *)get_type_handle(T).get_python_type(); if (target_class != nullptr) { if (_IS_FINAL(T)) { if (DtoolInstance_TYPE(self) == target_class) { @@ -116,28 +116,28 @@ INLINE long Dtool_EnumValue_AsLong(PyObject *value) { */ template INLINE PyObject * DTool_CreatePyInstance(const T *obj, bool memory_rules) { - Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); + Dtool_PyTypedObject *known_class = (Dtool_PyTypedObject *)get_type_handle(T).get_python_type(); nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, true); } template INLINE PyObject * DTool_CreatePyInstance(T *obj, bool memory_rules) { - Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); + Dtool_PyTypedObject *known_class = (Dtool_PyTypedObject *)get_type_handle(T).get_python_type(); nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, false); } template INLINE PyObject * DTool_CreatePyInstanceTyped(const T *obj, bool memory_rules) { - Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); + Dtool_PyTypedObject *known_class = (Dtool_PyTypedObject *)get_type_handle(T).get_python_type(); nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, true, obj->get_type().get_index()); } template INLINE PyObject * DTool_CreatePyInstanceTyped(T *obj, bool memory_rules) { - Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); + Dtool_PyTypedObject *known_class = (Dtool_PyTypedObject *)get_type_handle(T).get_python_type(); nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, false, obj->get_type().get_index()); } diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index c29796def6..68264daf0b 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -29,10 +29,6 @@ PyMemberDef standard_type_members[] = { {nullptr} /* Sentinel */ }; -static RuntimeTypeMap runtime_type_map; -static RuntimeTypeSet runtime_type_set; -static NamedTypeMap named_type_map; - /** */ @@ -431,7 +427,7 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & // IF the class is possibly a run time typed object if (type_index > 0) { // get best fit class... - Dtool_PyTypedObject *target_class = Dtool_RuntimeTypeDtoolType(type_index); + Dtool_PyTypedObject *target_class = (Dtool_PyTypedObject *)TypeHandle::from_index(type_index).get_python_type(); if (target_class != nullptr) { // cast to the type... void *new_local_this = target_class->_Dtool_DowncastInterface(local_this_in, &known_class_type); @@ -507,109 +503,30 @@ void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) { } } -// ** HACK ** alert.. Need to keep a runtime type dictionary ... that is -// forward declared of typed object. We rely on the fact that typed objects -// are uniquly defined by an integer. -void -RegisterNamedClass(const string &name, Dtool_PyTypedObject &otype) { - std::pair result = - named_type_map.insert(NamedTypeMap::value_type(name, &otype)); - - if (!result.second) { - // There was already a class with this name in the dictionary. - interrogatedb_cat.warning() - << "Double definition for class " << name << "\n"; - } -} - -void -RegisterRuntimeTypedClass(Dtool_PyTypedObject &otype) { - int type_index = otype._type.get_index(); - - if (type_index == 0) { - interrogatedb_cat.warning() - << "Class " << otype._PyType.tp_name - << " has a zero TypeHandle value; check that init_type() is called.\n"; - - } else if (type_index < 0 || type_index >= TypeRegistry::ptr()->get_num_typehandles()) { - interrogatedb_cat.warning() - << "Class " << otype._PyType.tp_name - << " has an illegal TypeHandle value; check that init_type() is called.\n"; - +/** + * Returns a borrowed reference to the global type dictionary. + */ +Dtool_TypeMap *Dtool_GetGlobalTypeMap() { + PyObject *capsule = PySys_GetObject("_interrogate_types"); + if (capsule != nullptr) { + return (Dtool_TypeMap *)PyCapsule_GetPointer(capsule, nullptr); } else { - std::pair result = - runtime_type_map.insert(RuntimeTypeMap::value_type(type_index, &otype)); - if (!result.second) { - // There was already an entry in the dictionary for type_index. - Dtool_PyTypedObject *other_type = (*result.first).second; - interrogatedb_cat.warning() - << "Classes " << otype._PyType.tp_name - << " and " << other_type->_PyType.tp_name - << " share the same TypeHandle value (" << type_index - << "); check class definitions.\n"; - - } else { - runtime_type_set.insert(type_index); - } - } -} - -Dtool_PyTypedObject * -LookupNamedClass(const string &name) { - NamedTypeMap::const_iterator it; - it = named_type_map.find(name); - - if (it == named_type_map.end()) { - // Find a type named like this in the type registry. - TypeHandle handle = TypeRegistry::ptr()->find_type(name); - if (handle.get_index() > 0) { - RuntimeTypeMap::const_iterator it2; - it2 = runtime_type_map.find(handle.get_index()); - if (it2 != runtime_type_map.end()) { - return it2->second; - } - } - - interrogatedb_cat.error() - << "Attempt to use type " << name << " which has not yet been defined!\n"; - return nullptr; - } else { - return it->second; - } -} - -Dtool_PyTypedObject * -LookupRuntimeTypedClass(TypeHandle handle) { - RuntimeTypeMap::const_iterator it; - it = runtime_type_map.find(handle.get_index()); - - if (it == runtime_type_map.end()) { - interrogatedb_cat.error() - << "Attempt to use type " << handle << " which has not yet been defined!\n"; - return nullptr; - } else { - return it->second; + Dtool_TypeMap *type_map = new Dtool_TypeMap; + capsule = PyCapsule_New((void *)type_map, nullptr, nullptr); + PySys_SetObject("_interrogate_types", capsule); + Py_DECREF(capsule); + return type_map; } } Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type) { - RuntimeTypeMap::iterator di = runtime_type_map.find(type); - if (di != runtime_type_map.end()) { - return di->second; - } else { - int type2 = get_best_parent_from_Set(type, runtime_type_set); - di = runtime_type_map.find(type2); - if (di != runtime_type_map.end()) { - return di->second; - } - } - return nullptr; + return (Dtool_PyTypedObject *)TypeHandle::from_index(type).get_python_type(); } #if PY_MAJOR_VERSION >= 3 -PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], PyModuleDef *module_def) { +PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], PyModuleDef *module_def) { #else -PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { +PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], const char *modulename) { #endif // Check the version so we can print a helpful error if it doesn't match. string version = Py_GetVersion(); @@ -672,10 +589,40 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(nullptr); } + Dtool_TypeMap *type_map = Dtool_GetGlobalTypeMap(); + // the module level function inits.... MethodDefmap functions; - for (int xx = 0; defs[xx] != nullptr; xx++) { - Dtool_Accum_MethDefs(defs[xx]->_methods, functions); + for (size_t i = 0; defs[i] != nullptr; i++) { + const LibraryDef &def = *defs[i]; + Dtool_Accum_MethDefs(def._methods, functions); + + // Define exported types. + const Dtool_TypeDef *types = def._types; + if (types != nullptr) { + while (types->name != nullptr) { + (*type_map)[std::string(types->name)] = types->type; + ++types; + } + } + } + + // Resolve external types, in a second pass. + for (size_t i = 0; defs[i] != nullptr; i++) { + const LibraryDef &def = *defs[i]; + + Dtool_TypeDef *types = def._external_types; + if (types != nullptr) { + while (types->name != nullptr) { + auto it = type_map->find(std::string(types->name)); + if (it != type_map->end()) { + types->type = it->second; + } else { + return PyErr_Format(PyExc_NameError, "name '%s' is not defined", types->name); + } + ++types; + } + } } PyMethodDef *newdef = new PyMethodDef[functions.size() + 1]; diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 7916147e4d..f850f0c859 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -190,11 +190,9 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ // forward declared of typed object. We rely on the fact that typed objects // are uniquly defined by an integer. -EXPCL_INTERROGATEDB void RegisterNamedClass(const std::string &name, Dtool_PyTypedObject &otype); -EXPCL_INTERROGATEDB void RegisterRuntimeTypedClass(Dtool_PyTypedObject &otype); +typedef std::map Dtool_TypeMap; -EXPCL_INTERROGATEDB Dtool_PyTypedObject *LookupNamedClass(const std::string &name); -EXPCL_INTERROGATEDB Dtool_PyTypedObject *LookupRuntimeTypedClass(TypeHandle handle); +EXPCL_INTERROGATEDB Dtool_TypeMap *Dtool_GetGlobalTypeMap(); EXPCL_INTERROGATEDB Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type); @@ -326,14 +324,22 @@ EXPCL_INTERROGATEDB void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &th // We need a way to runtime merge compile units into a python "Module" .. this // is done with the fallowing structors and code.. along with the support of // interigate_module + +struct Dtool_TypeDef { + const char *const name; + Dtool_PyTypedObject *type; +}; + struct LibraryDef { - PyMethodDef *_methods; + PyMethodDef *const _methods; + const Dtool_TypeDef *const _types; + Dtool_TypeDef *const _external_types; }; #if PY_MAJOR_VERSION >= 3 -EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], PyModuleDef *module_def); +EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], PyModuleDef *module_def); #else -EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename); +EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], const char *modulename); #endif // HACK.... Be carefull Dtool_BorrowThisReference This function can be used to From 49b72fb1985a40515eab9a1783d2a9d1bb7d8a47 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Nov 2018 14:22:08 +0100 Subject: [PATCH 301/360] Move Python support code from libp3interrogatedb to generated module This prevents libp3interrogatedb from having a dependency on the Python library. See #387 --- dtool/src/dtoolbase/typeHandle_ext.cxx | 3 +- .../interfaceMakerPythonNative.cxx | 2 +- dtool/src/interrogate/interrogate_module.cxx | 7 +- dtool/src/interrogatedb/dtool_super_base.cxx | 194 +-- .../p3interrogatedb_composite1.cxx | 1 - .../p3interrogatedb_composite2.cxx | 3 - dtool/src/interrogatedb/py_compat.cxx | 7 - dtool/src/interrogatedb/py_compat.h | 9 +- dtool/src/interrogatedb/py_panda.I | 19 +- dtool/src/interrogatedb/py_panda.cxx | 93 +- dtool/src/interrogatedb/py_panda.h | 81 +- dtool/src/interrogatedb/py_wrappers.cxx | 1439 +++++++++-------- dtool/src/interrogatedb/py_wrappers.h | 29 +- makepanda/makepanda.py | 11 +- makepanda/makepandacore.py | 42 + panda/src/event/asyncFuture_ext.cxx | 9 +- 16 files changed, 977 insertions(+), 972 deletions(-) diff --git a/dtool/src/dtoolbase/typeHandle_ext.cxx b/dtool/src/dtoolbase/typeHandle_ext.cxx index 2064e42844..c52b04aabd 100644 --- a/dtool/src/dtoolbase/typeHandle_ext.cxx +++ b/dtool/src/dtoolbase/typeHandle_ext.cxx @@ -22,7 +22,8 @@ */ TypeHandle Extension:: make(PyTypeObject *tp) { - if (!PyType_IsSubtype(tp, &Dtool_DTOOL_SUPER_BASE._PyType)) { + Dtool_PyTypedObject *super_base = Dtool_GetSuperBase(); + if (!PyType_IsSubtype(tp, (PyTypeObject *)super_base)) { PyErr_SetString(PyExc_TypeError, "a Panda type is required"); return TypeHandle::none(); } diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 60d2dd6466..c0316ee5c4 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -3097,7 +3097,7 @@ write_module_class(ostream &out, Object *obj) { out << " Dtool_" << ClassName << "._PyType.tp_bases = PyTuple_Pack(" << bases.size() << baseargs << ");\n"; } else { - out << " Dtool_" << ClassName << "._PyType.tp_base = (PyTypeObject *)&Dtool_DTOOL_SUPER_BASE;\n"; + out << " Dtool_" << ClassName << "._PyType.tp_base = (PyTypeObject *)Dtool_GetSuperBase();\n"; } int num_nested = obj->_itype.number_of_nested_types(); diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 986033fd3c..586889ed77 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -30,6 +30,9 @@ using std::cerr; using std::string; +// This contains a big source string determined at compile time. +extern const char interrogate_preamble_python_native[]; + Filename output_code_filename; string module_name; string library_name; @@ -635,8 +638,10 @@ int main(int argc, char *argv[]) { if (build_python_native_wrappers) { write_python_table_native(output_code); - } + // Output the support code. + output_code << interrogate_preamble_python_native << "\n"; + } } } diff --git a/dtool/src/interrogatedb/dtool_super_base.cxx b/dtool/src/interrogatedb/dtool_super_base.cxx index 9170af9d4f..01dcdef077 100644 --- a/dtool/src/interrogatedb/dtool_super_base.cxx +++ b/dtool/src/interrogatedb/dtool_super_base.cxx @@ -15,120 +15,132 @@ #ifdef HAVE_PYTHON -class EmptyClass { -}; -Define_Module_Class_Private(dtoolconfig, DTOOL_SUPER_BASE, EmptyClass, DTOOL_SUPER_BASE111); - static PyObject *GetSuperBase(PyObject *self) { - Py_INCREF((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE); // order is important .. this is used for static functions - return (PyObject *) &Dtool_DTOOL_SUPER_BASE; + Dtool_PyTypedObject *super_base = Dtool_GetSuperBase(); + Py_XINCREF((PyTypeObject *)super_base); // order is important .. this is used for static functions + return (PyObject *)super_base; }; -PyMethodDef Dtool_Methods_DTOOL_SUPER_BASE[] = { - { "DtoolGetSuperBase", (PyCFunction) &GetSuperBase, METH_NOARGS, "Will Return SUPERbase Class"}, - { nullptr, nullptr, 0, nullptr } -}; - -EXPCL_INTERROGATEDB void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module) { - static bool initdone = false; - if (!initdone) { - - initdone = true; - Dtool_DTOOL_SUPER_BASE._PyType.tp_dict = PyDict_New(); - PyDict_SetItemString(Dtool_DTOOL_SUPER_BASE._PyType.tp_dict, "DtoolClassDict", Dtool_DTOOL_SUPER_BASE._PyType.tp_dict); - - if (PyType_Ready((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE) < 0) { - PyErr_SetString(PyExc_TypeError, "PyType_Ready(Dtool_DTOOL_SUPER_BASE)"); - return; - } - Py_INCREF((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE); - - PyDict_SetItemString(Dtool_DTOOL_SUPER_BASE._PyType.tp_dict, "DtoolGetSuperBase", PyCFunction_New(&Dtool_Methods_DTOOL_SUPER_BASE[0], (PyObject *)&Dtool_DTOOL_SUPER_BASE)); - } - +static void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module) { if (module != nullptr) { - Py_INCREF((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE); - PyModule_AddObject(module, "DTOOL_SUPER_BASE", (PyObject *)&Dtool_DTOOL_SUPER_BASE); + Dtool_PyTypedObject *super_base = Dtool_GetSuperBase(); + Py_INCREF((PyTypeObject *)&super_base); + PyModule_AddObject(module, "DTOOL_SUPER_BASE", (PyObject *)&super_base); } } -inline void *Dtool_DowncastInterface_DTOOL_SUPER_BASE(void *from_this, Dtool_PyTypedObject *from_type) { +static void *Dtool_DowncastInterface_DTOOL_SUPER_BASE(void *from_this, Dtool_PyTypedObject *from_type) { return nullptr; } -inline void *Dtool_UpcastInterface_DTOOL_SUPER_BASE(PyObject *self, Dtool_PyTypedObject *requested_type) { +static void *Dtool_UpcastInterface_DTOOL_SUPER_BASE(PyObject *self, Dtool_PyTypedObject *requested_type) { return nullptr; } -int Dtool_Init_DTOOL_SUPER_BASE(PyObject *self, PyObject *args, PyObject *kwds) { +static int Dtool_Init_DTOOL_SUPER_BASE(PyObject *self, PyObject *args, PyObject *kwds) { assert(self != nullptr); PyErr_Format(PyExc_TypeError, "cannot init constant class %s", Py_TYPE(self)->tp_name); return -1; } -EXPORT_THIS Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE = { - { - PyVarObject_HEAD_INIT(nullptr, 0) - "dtoolconfig.DTOOL_SUPER_BASE", - sizeof(Dtool_PyInstDef), - 0, // tp_itemsize - &Dtool_FreeInstance_DTOOL_SUPER_BASE, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr +static void Dtool_FreeInstance_DTOOL_SUPER_BASE(PyObject *self) { + Py_TYPE(self)->tp_free(self); +} + +/** + * Returns a pointer to the DTOOL_SUPER_BASE class that is the base class of + * all Panda types. This pointer is shared by all modules. + */ +Dtool_PyTypedObject *Dtool_GetSuperBase() { + Dtool_TypeMap *type_map = Dtool_GetGlobalTypeMap(); + auto it = type_map->find("DTOOL_SUPER_BASE"); + if (it != type_map->end()) { + return it->second; + } + + static PyMethodDef methods[] = { + { "DtoolGetSuperBase", (PyCFunction)&GetSuperBase, METH_NOARGS, "Will Return SUPERbase Class"}, + { nullptr, nullptr, 0, nullptr } + }; + + static Dtool_PyTypedObject super_base_type = { + { + PyVarObject_HEAD_INIT(nullptr, 0) + "dtoolconfig.DTOOL_SUPER_BASE", + sizeof(Dtool_PyInstDef), + 0, // tp_itemsize + &Dtool_FreeInstance_DTOOL_SUPER_BASE, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr #if PY_MAJOR_VERSION >= 3 - nullptr, // tp_compare + nullptr, // tp_compare #else - &DtoolInstance_ComparePointers, + &DtoolInstance_ComparePointers, #endif - nullptr, // tp_repr - nullptr, // tp_as_number - nullptr, // tp_as_sequence - nullptr, // tp_as_mapping - &DtoolInstance_HashPointer, - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - PyObject_GenericSetAttr, - nullptr, // tp_as_buffer - (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES), - nullptr, // tp_doc - nullptr, // tp_traverse - nullptr, // tp_clear + nullptr, // tp_repr + nullptr, // tp_as_number + nullptr, // tp_as_sequence + nullptr, // tp_as_mapping + &DtoolInstance_HashPointer, + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + nullptr, // tp_as_buffer + (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES), + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear #if PY_MAJOR_VERSION >= 3 - &DtoolInstance_RichComparePointers, + &DtoolInstance_RichComparePointers, #else - nullptr, // tp_richcompare + nullptr, // tp_richcompare #endif - 0, // tp_weaklistoffset - nullptr, // tp_iter - nullptr, // tp_iternext - Dtool_Methods_DTOOL_SUPER_BASE, - standard_type_members, - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - nullptr, // tp_descr_get - nullptr, // tp_descr_set - 0, // tp_dictoffset - Dtool_Init_DTOOL_SUPER_BASE, - PyType_GenericAlloc, - Dtool_new_DTOOL_SUPER_BASE, - PyObject_Del, - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del - }, - TypeHandle::none(), - Dtool_PyModuleClassInit_DTOOL_SUPER_BASE, - Dtool_UpcastInterface_DTOOL_SUPER_BASE, - Dtool_DowncastInterface_DTOOL_SUPER_BASE, - nullptr, - nullptr, -}; + 0, // tp_weaklistoffset + nullptr, // tp_iter + nullptr, // tp_iternext + methods, + standard_type_members, + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset + Dtool_Init_DTOOL_SUPER_BASE, + PyType_GenericAlloc, + nullptr, // tp_new + PyObject_Del, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }, + TypeHandle::none(), + Dtool_PyModuleClassInit_DTOOL_SUPER_BASE, + Dtool_UpcastInterface_DTOOL_SUPER_BASE, + Dtool_DowncastInterface_DTOOL_SUPER_BASE, + nullptr, + nullptr, + }; + + super_base_type._PyType.tp_dict = PyDict_New(); + PyDict_SetItemString(super_base_type._PyType.tp_dict, "DtoolClassDict", super_base_type._PyType.tp_dict); + + if (PyType_Ready((PyTypeObject *)&super_base_type) < 0) { + PyErr_SetString(PyExc_TypeError, "PyType_Ready(Dtool_DTOOL_SUPER_BASE)"); + return nullptr; + } + Py_INCREF((PyTypeObject *)&super_base_type); + + PyDict_SetItemString(super_base_type._PyType.tp_dict, "DtoolGetSuperBase", PyCFunction_New(&methods[0], (PyObject *)&super_base_type)); + + (*type_map)["DTOOL_SUPER_BASE"] = &super_base_type; + return &super_base_type; +} #endif // HAVE_PYTHON diff --git a/dtool/src/interrogatedb/p3interrogatedb_composite1.cxx b/dtool/src/interrogatedb/p3interrogatedb_composite1.cxx index d663e9e0e5..4e54cee5a9 100644 --- a/dtool/src/interrogatedb/p3interrogatedb_composite1.cxx +++ b/dtool/src/interrogatedb/p3interrogatedb_composite1.cxx @@ -1,5 +1,4 @@ #include "config_interrogatedb.cxx" -#include "dtool_super_base.cxx" #include "indexRemapper.cxx" #include "interrogateComponent.cxx" #include "interrogateDatabase.cxx" diff --git a/dtool/src/interrogatedb/p3interrogatedb_composite2.cxx b/dtool/src/interrogatedb/p3interrogatedb_composite2.cxx index fda72f2ce8..41453e5f3e 100644 --- a/dtool/src/interrogatedb/p3interrogatedb_composite2.cxx +++ b/dtool/src/interrogatedb/p3interrogatedb_composite2.cxx @@ -4,6 +4,3 @@ #include "interrogate_datafile.cxx" #include "interrogate_interface.cxx" #include "interrogate_request.cxx" -#include "py_panda.cxx" -#include "py_compat.cxx" -#include "py_wrappers.cxx" diff --git a/dtool/src/interrogatedb/py_compat.cxx b/dtool/src/interrogatedb/py_compat.cxx index 0c1383f983..722bc8300b 100644 --- a/dtool/src/interrogatedb/py_compat.cxx +++ b/dtool/src/interrogatedb/py_compat.cxx @@ -1,11 +1,4 @@ /** - * 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." - * * @file py_compat.cxx * @author rdb * @date 2017-12-03 diff --git a/dtool/src/interrogatedb/py_compat.h b/dtool/src/interrogatedb/py_compat.h index f87c73cf3d..fbe49a5287 100644 --- a/dtool/src/interrogatedb/py_compat.h +++ b/dtool/src/interrogatedb/py_compat.h @@ -1,11 +1,4 @@ /** - * 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." - * * @file py_compat.h * @author rdb * @date 2017-12-02 @@ -106,7 +99,7 @@ typedef int Py_ssize_t; // PyInt_FromSize_t automatically picks the right type. # define PyLongOrInt_AS_LONG PyInt_AsLong -EXPCL_INTERROGATEDB size_t PyLongOrInt_AsSize_t(PyObject *); +size_t PyLongOrInt_AsSize_t(PyObject *); #endif // Which character to use in PyArg_ParseTuple et al for a byte string. diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index f5f504ca97..12f20f1f1e 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -1,11 +1,4 @@ /** - * 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." - * * @file py_panda.I * @author rdb * @date 2016-06-06 @@ -142,6 +135,18 @@ DTool_CreatePyInstanceTyped(T *obj, bool memory_rules) { return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, false, obj->get_type().get_index()); } +/** + * Finishes initializing the Dtool_PyInstDef. + */ +INLINE int +DTool_PyInit_Finalize(PyObject *self, void *local_this, Dtool_PyTypedObject *type, bool memory_rules, bool is_const) { + ((Dtool_PyInstDef *)self)->_My_Type = type; + ((Dtool_PyInstDef *)self)->_ptr_to_object = local_this; + ((Dtool_PyInstDef *)self)->_memory_rules = memory_rules; + ((Dtool_PyInstDef *)self)->_is_const = is_const; + return 0; +} + /** * Checks that the tuple is empty. */ diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 68264daf0b..bb7b5717f4 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -1,11 +1,4 @@ /** - * 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." - * * @file py_panda.cxx * @author drose * @date 2005-07-04 @@ -480,49 +473,22 @@ PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_class return (PyObject *)self; } -// Th Finalizer for simple instances.. -int DTool_PyInit_Finalize(PyObject *self, void *local_this, Dtool_PyTypedObject *type, bool memory_rules, bool is_const) { - // lets put some code in here that checks to see the memory is properly - // configured.. prior to my call .. - - ((Dtool_PyInstDef *)self)->_My_Type = type; - ((Dtool_PyInstDef *)self)->_ptr_to_object = local_this; - ((Dtool_PyInstDef *)self)->_memory_rules = memory_rules; - ((Dtool_PyInstDef *)self)->_is_const = is_const; - return 0; -} - -// A helper function to glue method definition together .. that can not be -// done at code generation time because of multiple generation passes in -// interrogate.. -void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) { - for (; in->ml_name != nullptr; in++) { - if (themap.find(in->ml_name) == themap.end()) { - themap[in->ml_name] = in; - } - } -} - /** * Returns a borrowed reference to the global type dictionary. */ Dtool_TypeMap *Dtool_GetGlobalTypeMap() { - PyObject *capsule = PySys_GetObject("_interrogate_types"); + PyObject *capsule = PySys_GetObject((char *)"_interrogate_types"); if (capsule != nullptr) { return (Dtool_TypeMap *)PyCapsule_GetPointer(capsule, nullptr); } else { Dtool_TypeMap *type_map = new Dtool_TypeMap; capsule = PyCapsule_New((void *)type_map, nullptr, nullptr); - PySys_SetObject("_interrogate_types", capsule); + PySys_SetObject((char *)"_interrogate_types", capsule); Py_DECREF(capsule); return type_map; } } -Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type) { - return (Dtool_PyTypedObject *)TypeHandle::from_index(type).get_python_type(); -} - #if PY_MAJOR_VERSION >= 3 PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], PyModuleDef *module_def) { #else @@ -544,58 +510,19 @@ PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], const char *modulen return nullptr; } - // Initialize the types we define in py_panda. - static bool dtool_inited = false; - if (!dtool_inited) { - dtool_inited = true; - - if (PyType_Ready(&Dtool_SequenceWrapper_Type) < 0) { - return Dtool_Raise_TypeError("PyType_Ready(Dtool_SequenceWrapper)"); - } - - if (PyType_Ready(&Dtool_MutableSequenceWrapper_Type) < 0) { - return Dtool_Raise_TypeError("PyType_Ready(Dtool_MutableSequenceWrapper)"); - } - - if (PyType_Ready(&Dtool_MappingWrapper_Type) < 0) { - return Dtool_Raise_TypeError("PyType_Ready(Dtool_MappingWrapper)"); - } - - if (PyType_Ready(&Dtool_MutableMappingWrapper_Type) < 0) { - return Dtool_Raise_TypeError("PyType_Ready(Dtool_MutableMappingWrapper)"); - } - - if (PyType_Ready(&Dtool_MappingWrapper_Keys_Type) < 0) { - return Dtool_Raise_TypeError("PyType_Ready(Dtool_MappingWrapper_Keys)"); - } - - if (PyType_Ready(&Dtool_MappingWrapper_Values_Type) < 0) { - return Dtool_Raise_TypeError("PyType_Ready(Dtool_MappingWrapper_Values)"); - } - - if (PyType_Ready(&Dtool_MappingWrapper_Items_Type) < 0) { - return Dtool_Raise_TypeError("PyType_Ready(Dtool_MappingWrapper_Items)"); - } - - if (PyType_Ready(&Dtool_GeneratorWrapper_Type) < 0) { - return Dtool_Raise_TypeError("PyType_Ready(Dtool_GeneratorWrapper)"); - } - - if (PyType_Ready(&Dtool_StaticProperty_Type) < 0) { - return Dtool_Raise_TypeError("PyType_Ready(Dtool_StaticProperty_Type)"); - } - - // Initialize the base class of everything. - Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(nullptr); - } - Dtool_TypeMap *type_map = Dtool_GetGlobalTypeMap(); // the module level function inits.... MethodDefmap functions; for (size_t i = 0; defs[i] != nullptr; i++) { const LibraryDef &def = *defs[i]; - Dtool_Accum_MethDefs(def._methods, functions); + + // Accumulate method definitions. + for (PyMethodDef *meth = def._methods; meth->ml_name != nullptr; meth++) { + if (functions.find(meth->ml_name) == functions.end()) { + functions[meth->ml_name] = meth; + } + } // Define exported types. const Dtool_TypeDef *types = def._types; @@ -746,7 +673,7 @@ PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args) { // We do expose a dictionay for dtool classes .. this should be removed at // some point.. -EXPCL_INTERROGATEDB PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { +PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { PyObject *self; PyObject *subject; PyObject *key; diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index f850f0c859..34693e8b90 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -1,11 +1,4 @@ /** - * 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." - * * @file py_panda.h */ @@ -43,9 +36,6 @@ using namespace std; #endif struct Dtool_PyTypedObject; -typedef std::map RuntimeTypeMap; -typedef std::set RuntimeTypeSet; -typedef std::map NamedTypeMap; // used to stamp dtool instance.. #define PY_PANDA_SIGNATURE 0xbeaf @@ -78,7 +68,7 @@ struct Dtool_PyInstDef { }; // A Offset Dictionary Defining How to read the Above Object.. -extern EXPCL_INTERROGATEDB PyMemberDef standard_type_members[]; +extern PyMemberDef standard_type_members[]; // The Class Definition Structor For a Dtool python type. struct Dtool_PyTypedObject { @@ -192,21 +182,19 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ typedef std::map Dtool_TypeMap; -EXPCL_INTERROGATEDB Dtool_TypeMap *Dtool_GetGlobalTypeMap(); - -EXPCL_INTERROGATEDB Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type); +Dtool_TypeMap *Dtool_GetGlobalTypeMap(); /** */ -EXPCL_INTERROGATEDB void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *classdef, void **answer); +void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *classdef, void **answer); -EXPCL_INTERROGATEDB void *DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const std::string &function_name, bool const_ok, bool report_errors); +void *DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const std::string &function_name, bool const_ok, bool report_errors); -EXPCL_INTERROGATEDB bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef, void **answer); +bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef, void **answer); -EXPCL_INTERROGATEDB bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject &classdef, - void **answer, const char *method_name); +bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject &classdef, + void **answer, const char *method_name); template INLINE bool DtoolInstance_GetPointer(PyObject *self, T *&into); template INLINE bool DtoolInstance_GetPointer(PyObject *self, T *&into, Dtool_PyTypedObject &classdef); @@ -216,7 +204,7 @@ INLINE int DtoolInstance_ComparePointers(PyObject *v1, PyObject *v2); INLINE PyObject *DtoolInstance_RichComparePointers(PyObject *v1, PyObject *v2, int op); // Functions related to error reporting. -EXPCL_INTERROGATEDB bool _Dtool_CheckErrorOccurred(); +bool _Dtool_CheckErrorOccurred(); #ifdef NDEBUG #define Dtool_CheckErrorOccurred() (UNLIKELY(_PyErr_OCCURRED() != nullptr)) @@ -224,12 +212,12 @@ EXPCL_INTERROGATEDB bool _Dtool_CheckErrorOccurred(); #define Dtool_CheckErrorOccurred() (UNLIKELY(_Dtool_CheckErrorOccurred())) #endif -EXPCL_INTERROGATEDB PyObject *Dtool_Raise_AssertionError(); -EXPCL_INTERROGATEDB PyObject *Dtool_Raise_TypeError(const char *message); -EXPCL_INTERROGATEDB PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *function_name, const char *type_name); -EXPCL_INTERROGATEDB PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute); +PyObject *Dtool_Raise_AssertionError(); +PyObject *Dtool_Raise_TypeError(const char *message); +PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *function_name, const char *type_name); +PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute); -EXPCL_INTERROGATEDB PyObject *_Dtool_Raise_BadArgumentsError(); +PyObject *_Dtool_Raise_BadArgumentsError(); #ifdef NDEBUG // Define it to a function that just prints a generic message. #define Dtool_Raise_BadArgumentsError(x) _Dtool_Raise_BadArgumentsError() @@ -241,9 +229,9 @@ EXPCL_INTERROGATEDB PyObject *_Dtool_Raise_BadArgumentsError(); // These functions are similar to Dtool_WrapValue, except that they also // contain code for checking assertions and exceptions when compiling with // NDEBUG mode on. -EXPCL_INTERROGATEDB PyObject *_Dtool_Return_None(); -EXPCL_INTERROGATEDB PyObject *Dtool_Return_Bool(bool value); -EXPCL_INTERROGATEDB PyObject *_Dtool_Return(PyObject *value); +PyObject *_Dtool_Return_None(); +PyObject *Dtool_Return_Bool(bool value); +PyObject *_Dtool_Return(PyObject *value); #ifdef NDEBUG #define Dtool_Return_None() (LIKELY(_PyErr_OCCURRED() == nullptr) ? (Py_INCREF(Py_None), Py_None) : nullptr) @@ -256,19 +244,19 @@ EXPCL_INTERROGATEDB PyObject *_Dtool_Return(PyObject *value); /** * Wrapper around Python 3.4's enum library, which does not have a C API. */ -EXPCL_INTERROGATEDB PyTypeObject *Dtool_EnumType_Create(const char *name, PyObject *names, +PyTypeObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *module = nullptr); -EXPCL_INTERROGATEDB INLINE long Dtool_EnumValue_AsLong(PyObject *value); +INLINE long Dtool_EnumValue_AsLong(PyObject *value); /** */ -EXPCL_INTERROGATEDB PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject &known_class_type, bool memory_rules, bool is_const, int RunTimeType); +PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject &known_class_type, bool memory_rules, bool is_const, int RunTimeType); // DTool_CreatePyInstance .. wrapper function to finalize the existance of a // general dtool py instance.. -EXPCL_INTERROGATEDB PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_classdef, bool memory_rules, bool is_const); +PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_classdef, bool memory_rules, bool is_const); // These template methods allow use when the Dtool_PyTypedObject is not known. // They require a get_class_type() to be defined for the class. @@ -312,15 +300,13 @@ Define_Dtool_FreeInstanceRef(CLASS_NAME,CNAME)\ Define_Dtool_Class(MODULE_NAME,CLASS_NAME,PUBLIC_NAME) // The finalizer for simple instances. -EXPCL_INTERROGATEDB int DTool_PyInit_Finalize(PyObject *self, void *This, Dtool_PyTypedObject *type, bool memory_rules, bool is_const); +INLINE int DTool_PyInit_Finalize(PyObject *self, void *This, Dtool_PyTypedObject *type, bool memory_rules, bool is_const); // A heler function to glu methed definition together .. that can not be done // at code generation time becouse of multiple generation passes in // interigate.. typedef std::map MethodDefmap; -EXPCL_INTERROGATEDB void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap); - // We need a way to runtime merge compile units into a python "Module" .. this // is done with the fallowing structors and code.. along with the support of // interigate_module @@ -337,26 +323,26 @@ struct LibraryDef { }; #if PY_MAJOR_VERSION >= 3 -EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], PyModuleDef *module_def); +PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], PyModuleDef *module_def); #else -EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], const char *modulename); +PyObject *Dtool_PyModuleInitHelper(const LibraryDef *defs[], const char *modulename); #endif // HACK.... Be carefull Dtool_BorrowThisReference This function can be used to // grab the "THIS" pointer from an object and use it Required to support fom // historical inharatence in the for of "is this instance of".. -EXPCL_INTERROGATEDB PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args); +PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args); #define DTOOL_PyObject_HashPointer DtoolInstance_HashPointer #define DTOOL_PyObject_ComparePointers DtoolInstance_ComparePointers -EXPCL_INTERROGATEDB PyObject * +PyObject * copy_from_make_copy(PyObject *self, PyObject *noargs); -EXPCL_INTERROGATEDB PyObject * +PyObject * copy_from_copy_constructor(PyObject *self, PyObject *noargs); -EXPCL_INTERROGATEDB PyObject * +PyObject * map_deepcopy_to_copy(PyObject *self, PyObject *args); /** @@ -365,13 +351,13 @@ map_deepcopy_to_copy(PyObject *self, PyObject *args); */ ALWAYS_INLINE bool Dtool_CheckNoArgs(PyObject *args); ALWAYS_INLINE bool Dtool_CheckNoArgs(PyObject *args, PyObject *kwds); -EXPCL_INTERROGATEDB bool Dtool_ExtractArg(PyObject **result, PyObject *args, +bool Dtool_ExtractArg(PyObject **result, PyObject *args, PyObject *kwds, const char *keyword); -EXPCL_INTERROGATEDB bool Dtool_ExtractArg(PyObject **result, PyObject *args, +bool Dtool_ExtractArg(PyObject **result, PyObject *args, PyObject *kwds); -EXPCL_INTERROGATEDB bool Dtool_ExtractOptionalArg(PyObject **result, PyObject *args, +bool Dtool_ExtractOptionalArg(PyObject **result, PyObject *args, PyObject *kwds, const char *keyword); -EXPCL_INTERROGATEDB bool Dtool_ExtractOptionalArg(PyObject **result, PyObject *args, +bool Dtool_ExtractOptionalArg(PyObject **result, PyObject *args, PyObject *kwds); /** @@ -407,10 +393,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(Py_buffer *value); template ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::pair &value); -EXPCL_INTERROGATEDB extern struct Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE; -EXPCL_INTERROGATEDB extern void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module); - -#define Dtool_Ptr_DTOOL_SUPER_BASE (&Dtool_DTOOL_SUPER_BASE) +Dtool_PyTypedObject *Dtool_GetSuperBase(); #include "py_panda.I" diff --git a/dtool/src/interrogatedb/py_wrappers.cxx b/dtool/src/interrogatedb/py_wrappers.cxx index 71a5a38ffd..0b8a751cad 100644 --- a/dtool/src/interrogatedb/py_wrappers.cxx +++ b/dtool/src/interrogatedb/py_wrappers.cxx @@ -1,11 +1,4 @@ /** - * 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." - * * @file py_wrappers.cxx * @author rdb * @date 2017-11-26 @@ -494,6 +487,24 @@ static PyObject *Dtool_MappingWrapper_get(PyObject *self, PyObject *args) { } } +/** + * This is returned by mapping.keys(). + */ +static PyObject *Dtool_MappingWrapper_Keys_repr(PyObject *self) { + Dtool_WrapperBase *wrap = (Dtool_WrapperBase *)self; + nassertr(wrap, nullptr); + + PyObject *repr = PyObject_Repr(wrap->_self); + PyObject *result; +#if PY_MAJOR_VERSION >= 3 + result = PyUnicode_FromFormat("<%s.keys() of %s>", wrap->_name, PyUnicode_AsUTF8(repr)); +#else + result = PyString_FromFormat("<%s.keys() of %s>", wrap->_name, PyString_AS_STRING(repr)); +#endif + Py_DECREF(repr); + return result; +} + /** * Implementation of property.keys(...) that returns a view of all the keys. */ @@ -510,14 +521,81 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) { return PyErr_NoMemory(); } - // If the collections.abc module is loaded, register this as a subclass. + static PySequenceMethods seq_methods = { + Dtool_SequenceWrapper_length, + nullptr, // sq_concat + nullptr, // sq_repeat + Dtool_SequenceWrapper_getitem, + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice + Dtool_SequenceWrapper_contains, + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat + }; + + static PyTypeObject wrapper_type = { + PyVarObject_HEAD_INIT(nullptr, 0) + "sequence wrapper", + sizeof(Dtool_SequenceWrapper), + 0, // tp_itemsize + Dtool_WrapperBase_dealloc, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + Dtool_MappingWrapper_Keys_repr, + nullptr, // tp_as_number + &seq_methods, + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + nullptr, // tp_as_buffer + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare + 0, // tp_weaklistoffset + PySeqIter_New, + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset + nullptr, // tp_init + PyType_GenericAlloc, + nullptr, // tp_new + PyObject_Del, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }; + static bool registered = false; if (!registered) { registered = true; - _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Keys_Type, "MappingView"); + + if (PyType_Ready(&wrapper_type) < 0) { + return nullptr; + } + + // If the collections.abc module is loaded, register this as a subclass. + _register_collection((PyTypeObject *)&wrapper_type, "MappingView"); } - (void)PyObject_INIT(keys, &Dtool_MappingWrapper_Keys_Type); + (void)PyObject_INIT(keys, &wrapper_type); Py_XINCREF(wrap->_base._self); keys->_base._self = wrap->_base._self; keys->_base._name = wrap->_base._name; @@ -528,6 +606,38 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) { return (PyObject *)keys; } +/** + * This is returned by mapping.values(). + */ +static PyObject *Dtool_MappingWrapper_Values_repr(PyObject *self) { + Dtool_WrapperBase *wrap = (Dtool_WrapperBase *)self; + nassertr(wrap, nullptr); + + PyObject *repr = PyObject_Repr(wrap->_self); + PyObject *result; +#if PY_MAJOR_VERSION >= 3 + result = PyUnicode_FromFormat("<%s.values() of %s>", wrap->_name, PyUnicode_AsUTF8(repr)); +#else + result = PyString_FromFormat("<%s.values() of %s>", wrap->_name, PyString_AS_STRING(repr)); +#endif + Py_DECREF(repr); + return result; +} + +static PyObject *Dtool_MappingWrapper_Values_getitem(PyObject *self, Py_ssize_t index) { + Dtool_MappingWrapper *wrap = (Dtool_MappingWrapper *)self; + nassertr(wrap, nullptr); + nassertr(wrap->_keys._getitem_func, nullptr); + + PyObject *key = wrap->_keys._getitem_func(wrap->_base._self, index); + if (key != nullptr) { + PyObject *value = wrap->_getitem_func(wrap->_base._self, key); + Py_DECREF(key); + return value; + } + return nullptr; +} + /** * Implementation of property.values(...) that returns a view of the values. */ @@ -545,14 +655,81 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) { return PyErr_NoMemory(); } - // If the collections.abc module is loaded, register this as a subclass. + static PySequenceMethods seq_methods = { + Dtool_SequenceWrapper_length, + nullptr, // sq_concat + nullptr, // sq_repeat + Dtool_MappingWrapper_Values_getitem, + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice + Dtool_MappingWrapper_contains, + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat + }; + + static PyTypeObject wrapper_type = { + PyVarObject_HEAD_INIT(nullptr, 0) + "sequence wrapper", + sizeof(Dtool_MappingWrapper), + 0, // tp_itemsize + Dtool_WrapperBase_dealloc, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + Dtool_MappingWrapper_Values_repr, + nullptr, // tp_as_number + &seq_methods, + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + nullptr, // tp_as_buffer + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare + 0, // tp_weaklistoffset + PySeqIter_New, + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset + nullptr, // tp_init + PyType_GenericAlloc, + nullptr, // tp_new + PyObject_Del, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }; + static bool registered = false; if (!registered) { registered = true; - _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Values_Type, "ValuesView"); + + if (PyType_Ready(&wrapper_type) < 0) { + return nullptr; + } + + // If the collections.abc module is loaded, register this as a subclass. + _register_collection((PyTypeObject *)&wrapper_type, "ValuesView"); } - (void)PyObject_INIT(values, &Dtool_MappingWrapper_Values_Type); + (void)PyObject_INIT(values, &wrapper_type); Py_XINCREF(wrap->_base._self); values->_base._self = wrap->_base._self; values->_base._name = wrap->_base._name; @@ -563,6 +740,45 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) { return (PyObject *)values; } +/** + * This is returned by mapping.items(). + */ +static PyObject *Dtool_MappingWrapper_Items_repr(PyObject *self) { + Dtool_WrapperBase *wrap = (Dtool_WrapperBase *)self; + nassertr(wrap, nullptr); + + PyObject *repr = PyObject_Repr(wrap->_self); + PyObject *result; +#if PY_MAJOR_VERSION >= 3 + result = PyUnicode_FromFormat("<%s.items() of %s>", wrap->_name, PyUnicode_AsUTF8(repr)); +#else + result = PyString_FromFormat("<%s.items() of %s>", wrap->_name, PyString_AS_STRING(repr)); +#endif + Py_DECREF(repr); + return result; +} + +static PyObject *Dtool_MappingWrapper_Items_getitem(PyObject *self, Py_ssize_t index) { + Dtool_MappingWrapper *wrap = (Dtool_MappingWrapper *)self; + nassertr(wrap, nullptr); + nassertr(wrap->_keys._getitem_func, nullptr); + + PyObject *key = wrap->_keys._getitem_func(wrap->_base._self, index); + if (key != nullptr) { + PyObject *value = wrap->_getitem_func(wrap->_base._self, key); + if (value != nullptr) { + // PyTuple_SET_ITEM steals the reference. + PyObject *item = PyTuple_New(2); + PyTuple_SET_ITEM(item, 0, key); + PyTuple_SET_ITEM(item, 1, value); + return item; + } else { + Py_DECREF(key); + } + } + return nullptr; +} + /** * Implementation of property.items(...) that returns an iterable yielding a * `(key, value)` tuple for every item. @@ -581,14 +797,81 @@ static PyObject *Dtool_MappingWrapper_items(PyObject *self, PyObject *) { return PyErr_NoMemory(); } - // If the collections.abc module is loaded, register this as a subclass. + static PySequenceMethods seq_methods = { + Dtool_SequenceWrapper_length, + nullptr, // sq_concat + nullptr, // sq_repeat + Dtool_MappingWrapper_Items_getitem, + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice + Dtool_MappingWrapper_contains, + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat + }; + + static PyTypeObject wrapper_type = { + PyVarObject_HEAD_INIT(nullptr, 0) + "sequence wrapper", + sizeof(Dtool_MappingWrapper), + 0, // tp_itemsize + Dtool_WrapperBase_dealloc, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + Dtool_MappingWrapper_Items_repr, + nullptr, // tp_as_number + &seq_methods, + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + nullptr, // tp_as_buffer + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare + 0, // tp_weaklistoffset + PySeqIter_New, + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset + nullptr, // tp_init + PyType_GenericAlloc, + nullptr, // tp_new + PyObject_Del, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }; + static bool registered = false; if (!registered) { registered = true; - _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Items_Type, "MappingView"); + + if (PyType_Ready(&wrapper_type) < 0) { + return nullptr; + } + + // If the collections.abc module is loaded, register this as a subclass. + _register_collection((PyTypeObject *)&wrapper_type, "MappingView"); } - (void)PyObject_INIT(items, &Dtool_MappingWrapper_Items_Type); + (void)PyObject_INIT(items, &wrapper_type); Py_XINCREF(wrap->_base._self); items->_base._self = wrap->_base._self; items->_base._name = wrap->_base._name; @@ -792,566 +1075,6 @@ static PyObject *Dtool_MutableMappingWrapper_update(PyObject *self, PyObject *ar return Py_None; } -/** - * This variant defines only a sequence interface. - */ -static PySequenceMethods Dtool_SequenceWrapper_SequenceMethods = { - Dtool_SequenceWrapper_length, - nullptr, // sq_concat - nullptr, // sq_repeat - Dtool_SequenceWrapper_getitem, - nullptr, // sq_slice - nullptr, // sq_ass_item - nullptr, // sq_ass_slice - Dtool_SequenceWrapper_contains, - nullptr, // sq_inplace_concat - nullptr, // sq_inplace_repeat -}; - -static PyMethodDef Dtool_SequenceWrapper_Methods[] = { - {"index", &Dtool_SequenceWrapper_index, METH_O, nullptr}, - {"count", &Dtool_SequenceWrapper_count, METH_O, nullptr}, - {nullptr, nullptr, 0, nullptr} -}; - -PyTypeObject Dtool_SequenceWrapper_Type = { - PyVarObject_HEAD_INIT(nullptr, 0) - "sequence wrapper", - sizeof(Dtool_SequenceWrapper), - 0, // tp_itemsize - Dtool_WrapperBase_dealloc, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr - nullptr, // tp_compare - Dtool_SequenceWrapper_repr, - nullptr, // tp_as_number - &Dtool_SequenceWrapper_SequenceMethods, - nullptr, // tp_as_mapping - nullptr, // tp_hash - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - PyObject_GenericSetAttr, - nullptr, // tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - nullptr, // tp_doc - nullptr, // tp_traverse - nullptr, // tp_clear - nullptr, // tp_richcompare - 0, // tp_weaklistoffset - PySeqIter_New, - nullptr, // tp_iternext - Dtool_SequenceWrapper_Methods, - nullptr, // tp_members - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - nullptr, // tp_descr_get - nullptr, // tp_descr_set - 0, // tp_dictoffset - nullptr, // tp_init - PyType_GenericAlloc, - nullptr, // tp_new - PyObject_Del, - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del -}; - -/** - * This is a variant on SequenceWrapper that also has an insert() method. - */ -static PySequenceMethods Dtool_MutableSequenceWrapper_SequenceMethods = { - Dtool_SequenceWrapper_length, - nullptr, // sq_concat - nullptr, // sq_repeat - Dtool_SequenceWrapper_getitem, - nullptr, // sq_slice - Dtool_MutableSequenceWrapper_setitem, - nullptr, // sq_ass_slice - Dtool_SequenceWrapper_contains, - Dtool_MutableSequenceWrapper_extend, - nullptr, // sq_inplace_repeat -}; - -static PyMethodDef Dtool_MutableSequenceWrapper_Methods[] = { - {"index", &Dtool_SequenceWrapper_index, METH_O, nullptr}, - {"count", &Dtool_SequenceWrapper_count, METH_O, nullptr}, - {"clear", &Dtool_MutableSequenceWrapper_clear, METH_NOARGS, nullptr}, - {"pop", &Dtool_MutableSequenceWrapper_pop, METH_VARARGS, nullptr}, - {"remove", &Dtool_MutableSequenceWrapper_remove, METH_O, nullptr}, - {"append", &Dtool_MutableSequenceWrapper_append, METH_O, nullptr}, - {"insert", &Dtool_MutableSequenceWrapper_insert, METH_VARARGS, nullptr}, - {"extend", &Dtool_MutableSequenceWrapper_extend, METH_O, nullptr}, - {nullptr, nullptr, 0, nullptr} -}; - -PyTypeObject Dtool_MutableSequenceWrapper_Type = { - PyVarObject_HEAD_INIT(nullptr, 0) - "sequence wrapper", - sizeof(Dtool_MutableSequenceWrapper), - 0, // tp_itemsize - Dtool_WrapperBase_dealloc, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr - nullptr, // tp_compare - Dtool_SequenceWrapper_repr, - nullptr, // tp_as_number - &Dtool_MutableSequenceWrapper_SequenceMethods, - nullptr, // tp_as_mapping - nullptr, // tp_hash - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - PyObject_GenericSetAttr, - nullptr, // tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - nullptr, // tp_doc - nullptr, // tp_traverse - nullptr, // tp_clear - nullptr, // tp_richcompare - 0, // tp_weaklistoffset - PySeqIter_New, - nullptr, // tp_iternext - Dtool_MutableSequenceWrapper_Methods, - nullptr, // tp_members - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - nullptr, // tp_descr_get - nullptr, // tp_descr_set - 0, // tp_dictoffset - nullptr, // tp_init - PyType_GenericAlloc, - nullptr, // tp_new - PyObject_Del, - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del -}; - -/** - * This variant defines only a mapping interface. - */ -static PySequenceMethods Dtool_MappingWrapper_SequenceMethods = { - Dtool_SequenceWrapper_length, - nullptr, // sq_concat - nullptr, // sq_repeat - nullptr, // sq_item - nullptr, // sq_slice - nullptr, // sq_ass_item - nullptr, // sq_ass_slice - Dtool_MappingWrapper_contains, - nullptr, // sq_inplace_concat - nullptr, // sq_inplace_repeat -}; - -static PyMappingMethods Dtool_MappingWrapper_MappingMethods = { - Dtool_SequenceWrapper_length, - Dtool_MappingWrapper_getitem, - nullptr, // mp_ass_subscript -}; - -static PyMethodDef Dtool_MappingWrapper_Methods[] = { - {"get", &Dtool_MappingWrapper_get, METH_VARARGS, nullptr}, - {"keys", &Dtool_MappingWrapper_keys, METH_NOARGS, nullptr}, - {"values", &Dtool_MappingWrapper_values, METH_NOARGS, nullptr}, - {"items", &Dtool_MappingWrapper_items, METH_NOARGS, nullptr}, - {nullptr, nullptr, 0, nullptr} -}; - -PyTypeObject Dtool_MappingWrapper_Type = { - PyVarObject_HEAD_INIT(nullptr, 0) - "mapping wrapper", - sizeof(Dtool_MappingWrapper), - 0, // tp_itemsize - Dtool_WrapperBase_dealloc, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr - nullptr, // tp_compare - Dtool_WrapperBase_repr, - nullptr, // tp_as_number - &Dtool_MappingWrapper_SequenceMethods, - &Dtool_MappingWrapper_MappingMethods, - nullptr, // tp_hash - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - PyObject_GenericSetAttr, - nullptr, // tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - nullptr, // tp_doc - nullptr, // tp_traverse - nullptr, // tp_clear - nullptr, // tp_richcompare - 0, // tp_weaklistoffset - Dtool_MappingWrapper_iter, - nullptr, // tp_iternext - Dtool_MappingWrapper_Methods, - nullptr, // tp_members - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - nullptr, // tp_descr_get - nullptr, // tp_descr_set - 0, // tp_dictoffset - nullptr, // tp_init - PyType_GenericAlloc, - nullptr, // tp_new - PyObject_Del, - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del -}; - -/** - * This variant defines only a mutable mapping interface. - */ -static PyMappingMethods Dtool_MutableMappingWrapper_MappingMethods = { - Dtool_SequenceWrapper_length, - Dtool_MappingWrapper_getitem, - Dtool_MutableMappingWrapper_setitem, -}; - -static PyMethodDef Dtool_MutableMappingWrapper_Methods[] = { - {"get", &Dtool_MappingWrapper_get, METH_VARARGS, nullptr}, - {"pop", &Dtool_MutableMappingWrapper_pop, METH_VARARGS, nullptr}, - {"popitem", &Dtool_MutableMappingWrapper_popitem, METH_NOARGS, nullptr}, - {"clear", &Dtool_MutableMappingWrapper_clear, METH_VARARGS, nullptr}, - {"setdefault", &Dtool_MutableMappingWrapper_setdefault, METH_VARARGS, nullptr}, - {"update", (PyCFunction) &Dtool_MutableMappingWrapper_update, METH_VARARGS | METH_KEYWORDS, nullptr}, - {"keys", &Dtool_MappingWrapper_keys, METH_NOARGS, nullptr}, - {"values", &Dtool_MappingWrapper_values, METH_NOARGS, nullptr}, - {"items", &Dtool_MappingWrapper_items, METH_NOARGS, nullptr}, - {nullptr, nullptr, 0, nullptr} -}; - -PyTypeObject Dtool_MutableMappingWrapper_Type = { - PyVarObject_HEAD_INIT(nullptr, 0) - "mapping wrapper", - sizeof(Dtool_MappingWrapper), - 0, // tp_itemsize - Dtool_WrapperBase_dealloc, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr - nullptr, // tp_compare - Dtool_WrapperBase_repr, - nullptr, // tp_as_number - &Dtool_MappingWrapper_SequenceMethods, - &Dtool_MutableMappingWrapper_MappingMethods, - nullptr, // tp_hash - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - PyObject_GenericSetAttr, - nullptr, // tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - nullptr, // tp_doc - nullptr, // tp_traverse - nullptr, // tp_clear - nullptr, // tp_richcompare - 0, // tp_weaklistoffset - Dtool_MappingWrapper_iter, - nullptr, // tp_iternext - Dtool_MutableMappingWrapper_Methods, - nullptr, // tp_members - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - nullptr, // tp_descr_get - nullptr, // tp_descr_set - 0, // tp_dictoffset - nullptr, // tp_init - PyType_GenericAlloc, - nullptr, // tp_new - PyObject_Del, - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del -}; - -/** - * This is returned by mapping.items(). - */ -static PyObject *Dtool_MappingWrapper_Items_repr(PyObject *self) { - Dtool_WrapperBase *wrap = (Dtool_WrapperBase *)self; - nassertr(wrap, nullptr); - - PyObject *repr = PyObject_Repr(wrap->_self); - PyObject *result; -#if PY_MAJOR_VERSION >= 3 - result = PyUnicode_FromFormat("<%s.items() of %s>", wrap->_name, PyUnicode_AsUTF8(repr)); -#else - result = PyString_FromFormat("<%s.items() of %s>", wrap->_name, PyString_AS_STRING(repr)); -#endif - Py_DECREF(repr); - return result; -} - -static PyObject *Dtool_MappingWrapper_Items_getitem(PyObject *self, Py_ssize_t index) { - Dtool_MappingWrapper *wrap = (Dtool_MappingWrapper *)self; - nassertr(wrap, nullptr); - nassertr(wrap->_keys._getitem_func, nullptr); - - PyObject *key = wrap->_keys._getitem_func(wrap->_base._self, index); - if (key != nullptr) { - PyObject *value = wrap->_getitem_func(wrap->_base._self, key); - if (value != nullptr) { - // PyTuple_SET_ITEM steals the reference. - PyObject *item = PyTuple_New(2); - PyTuple_SET_ITEM(item, 0, key); - PyTuple_SET_ITEM(item, 1, value); - return item; - } else { - Py_DECREF(key); - } - } - return nullptr; -} - -static PySequenceMethods Dtool_MappingWrapper_Items_SequenceMethods = { - Dtool_SequenceWrapper_length, - nullptr, // sq_concat - nullptr, // sq_repeat - Dtool_MappingWrapper_Items_getitem, - nullptr, // sq_slice - nullptr, // sq_ass_item - nullptr, // sq_ass_slice - Dtool_MappingWrapper_contains, - nullptr, // sq_inplace_concat - nullptr, // sq_inplace_repeat -}; - -PyTypeObject Dtool_MappingWrapper_Items_Type = { - PyVarObject_HEAD_INIT(nullptr, 0) - "sequence wrapper", - sizeof(Dtool_MappingWrapper), - 0, // tp_itemsize - Dtool_WrapperBase_dealloc, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr - nullptr, // tp_compare - Dtool_MappingWrapper_Items_repr, - nullptr, // tp_as_number - &Dtool_MappingWrapper_Items_SequenceMethods, - nullptr, // tp_as_mapping - nullptr, // tp_hash - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - PyObject_GenericSetAttr, - nullptr, // tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - nullptr, // tp_doc - nullptr, // tp_traverse - nullptr, // tp_clear - nullptr, // tp_richcompare - 0, // tp_weaklistoffset - PySeqIter_New, - nullptr, // tp_iternext - nullptr, // tp_methods - nullptr, // tp_members - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - nullptr, // tp_descr_get - nullptr, // tp_descr_set - 0, // tp_dictoffset - nullptr, // tp_init - PyType_GenericAlloc, - nullptr, // tp_new - PyObject_Del, - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del -}; - -/** - * This is returned by mapping.keys(). - */ -static PyObject *Dtool_MappingWrapper_Keys_repr(PyObject *self) { - Dtool_WrapperBase *wrap = (Dtool_WrapperBase *)self; - nassertr(wrap, nullptr); - - PyObject *repr = PyObject_Repr(wrap->_self); - PyObject *result; -#if PY_MAJOR_VERSION >= 3 - result = PyUnicode_FromFormat("<%s.keys() of %s>", wrap->_name, PyUnicode_AsUTF8(repr)); -#else - result = PyString_FromFormat("<%s.keys() of %s>", wrap->_name, PyString_AS_STRING(repr)); -#endif - Py_DECREF(repr); - return result; -} - -PyTypeObject Dtool_MappingWrapper_Keys_Type = { - PyVarObject_HEAD_INIT(nullptr, 0) - "sequence wrapper", - sizeof(Dtool_SequenceWrapper), - 0, // tp_itemsize - Dtool_WrapperBase_dealloc, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr - nullptr, // tp_compare - Dtool_MappingWrapper_Keys_repr, - nullptr, // tp_as_number - &Dtool_SequenceWrapper_SequenceMethods, - nullptr, // tp_as_mapping - nullptr, // tp_hash - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - PyObject_GenericSetAttr, - nullptr, // tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - nullptr, // tp_doc - nullptr, // tp_traverse - nullptr, // tp_clear - nullptr, // tp_richcompare - 0, // tp_weaklistoffset - PySeqIter_New, - nullptr, // tp_iternext - nullptr, // tp_methods - nullptr, // tp_members - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - nullptr, // tp_descr_get - nullptr, // tp_descr_set - 0, // tp_dictoffset - nullptr, // tp_init - PyType_GenericAlloc, - nullptr, // tp_new - PyObject_Del, - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del -}; - -/** - * This is returned by mapping.values(). - */ -static PyObject *Dtool_MappingWrapper_Values_repr(PyObject *self) { - Dtool_WrapperBase *wrap = (Dtool_WrapperBase *)self; - nassertr(wrap, nullptr); - - PyObject *repr = PyObject_Repr(wrap->_self); - PyObject *result; -#if PY_MAJOR_VERSION >= 3 - result = PyUnicode_FromFormat("<%s.values() of %s>", wrap->_name, PyUnicode_AsUTF8(repr)); -#else - result = PyString_FromFormat("<%s.values() of %s>", wrap->_name, PyString_AS_STRING(repr)); -#endif - Py_DECREF(repr); - return result; -} - -static PyObject *Dtool_MappingWrapper_Values_getitem(PyObject *self, Py_ssize_t index) { - Dtool_MappingWrapper *wrap = (Dtool_MappingWrapper *)self; - nassertr(wrap, nullptr); - nassertr(wrap->_keys._getitem_func, nullptr); - - PyObject *key = wrap->_keys._getitem_func(wrap->_base._self, index); - if (key != nullptr) { - PyObject *value = wrap->_getitem_func(wrap->_base._self, key); - Py_DECREF(key); - return value; - } - return nullptr; -} - -static PySequenceMethods Dtool_MappingWrapper_Values_SequenceMethods = { - Dtool_SequenceWrapper_length, - nullptr, // sq_concat - nullptr, // sq_repeat - Dtool_MappingWrapper_Values_getitem, - nullptr, // sq_slice - nullptr, // sq_ass_item - nullptr, // sq_ass_slice - Dtool_MappingWrapper_contains, - nullptr, // sq_inplace_concat - nullptr, // sq_inplace_repeat -}; - -PyTypeObject Dtool_MappingWrapper_Values_Type = { - PyVarObject_HEAD_INIT(nullptr, 0) - "sequence wrapper", - sizeof(Dtool_MappingWrapper), - 0, // tp_itemsize - Dtool_WrapperBase_dealloc, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr - nullptr, // tp_compare - Dtool_MappingWrapper_Values_repr, - nullptr, // tp_as_number - &Dtool_MappingWrapper_Values_SequenceMethods, - nullptr, // tp_as_mapping - nullptr, // tp_hash - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - PyObject_GenericSetAttr, - nullptr, // tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - nullptr, // tp_doc - nullptr, // tp_traverse - nullptr, // tp_clear - nullptr, // tp_richcompare - 0, // tp_weaklistoffset - PySeqIter_New, - nullptr, // tp_iternext - nullptr, // tp_methods - nullptr, // tp_members - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - nullptr, // tp_descr_get - nullptr, // tp_descr_set - 0, // tp_dictoffset - nullptr, // tp_init - PyType_GenericAlloc, - nullptr, // tp_new - PyObject_Del, - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del -}; - /** * This variant defines only a generator interface. */ @@ -1362,55 +1085,6 @@ static PyObject *Dtool_GeneratorWrapper_iternext(PyObject *self) { return wrap->_iternext_func(wrap->_base._self); } -PyTypeObject Dtool_GeneratorWrapper_Type = { - PyVarObject_HEAD_INIT(nullptr, 0) - "generator wrapper", - sizeof(Dtool_GeneratorWrapper), - 0, // tp_itemsize - Dtool_WrapperBase_dealloc, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr - nullptr, // tp_compare - nullptr, // tp_repr - nullptr, // tp_as_number - nullptr, // tp_as_sequence - nullptr, // tp_as_mapping - nullptr, // tp_hash - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - PyObject_GenericSetAttr, - nullptr, // tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - nullptr, // tp_doc - nullptr, // tp_traverse - nullptr, // tp_clear - nullptr, // tp_richcompare - 0, // tp_weaklistoffset - PyObject_SelfIter, - Dtool_GeneratorWrapper_iternext, - nullptr, // tp_methods - nullptr, // tp_members - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - nullptr, // tp_descr_get - nullptr, // tp_descr_set - 0, // tp_dictoffset - nullptr, // tp_init - PyType_GenericAlloc, - nullptr, // tp_new - PyObject_Del, - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del -}; - /** * This is a variant of the Python getset mechanism that permits static * properties. @@ -1479,55 +1153,6 @@ Dtool_StaticProperty_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *va } } -PyTypeObject Dtool_StaticProperty_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - "getset_descriptor", - sizeof(PyGetSetDescrObject), - 0, // tp_itemsize - (destructor)Dtool_StaticProperty_dealloc, - nullptr, // tp_print - nullptr, // tp_getattr - nullptr, // tp_setattr - nullptr, // tp_reserved - (reprfunc)Dtool_StaticProperty_repr, - nullptr, // tp_as_number - nullptr, // tp_as_sequence - nullptr, // tp_as_mapping - nullptr, // tp_hash - nullptr, // tp_call - nullptr, // tp_str - PyObject_GenericGetAttr, - nullptr, // tp_setattro - nullptr, // tp_as_buffer - Py_TPFLAGS_DEFAULT, - nullptr, // tp_doc - Dtool_StaticProperty_traverse, - nullptr, // tp_clear - nullptr, // tp_richcompare - 0, // tp_weaklistoffset - nullptr, // tp_iter - nullptr, // tp_iternext - nullptr, // tp_methods - nullptr, // tp_members - nullptr, // tp_getset - nullptr, // tp_base - nullptr, // tp_dict - (descrgetfunc)Dtool_StaticProperty_get, - (descrsetfunc)Dtool_StaticProperty_set, - 0, // tp_dictoffset - nullptr, // tp_init - nullptr, // tp_alloc - nullptr, // tp_new - nullptr, // tp_del - nullptr, // tp_is_gc - nullptr, // tp_bases - nullptr, // tp_mro - nullptr, // tp_cache - nullptr, // tp_subclasses - nullptr, // tp_weaklist - nullptr, // tp_del -}; - /** * This wraps around a property that exposes a sequence interface. */ @@ -1537,14 +1162,87 @@ Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name return (Dtool_SequenceWrapper *)PyErr_NoMemory(); } - // If the collections.abc module is loaded, register this as a subclass. + static PySequenceMethods seq_methods = { + Dtool_SequenceWrapper_length, + nullptr, // sq_concat + nullptr, // sq_repeat + Dtool_SequenceWrapper_getitem, + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice + Dtool_SequenceWrapper_contains, + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat + }; + + static PyMethodDef methods[] = { + {"index", &Dtool_SequenceWrapper_index, METH_O, nullptr}, + {"count", &Dtool_SequenceWrapper_count, METH_O, nullptr}, + {nullptr, nullptr, 0, nullptr} + }; + + static PyTypeObject wrapper_type = { + PyVarObject_HEAD_INIT(nullptr, 0) + "sequence wrapper", + sizeof(Dtool_SequenceWrapper), + 0, // tp_itemsize + Dtool_WrapperBase_dealloc, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + Dtool_SequenceWrapper_repr, + nullptr, // tp_as_number + &seq_methods, + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + nullptr, // tp_as_buffer + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare + 0, // tp_weaklistoffset + PySeqIter_New, + nullptr, // tp_iternext + methods, + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset + nullptr, // tp_init + PyType_GenericAlloc, + nullptr, // tp_new + PyObject_Del, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }; + static bool registered = false; if (!registered) { registered = true; - _register_collection((PyTypeObject *)&Dtool_MutableSequenceWrapper_Type, "Sequence"); + + if (PyType_Ready(&wrapper_type) < 0) { + return nullptr; + } + + // If the collections.abc module is loaded, register this as a subclass. + _register_collection((PyTypeObject *)&wrapper_type, "Sequence"); } - (void)PyObject_INIT(wrap, &Dtool_SequenceWrapper_Type); + (void)PyObject_INIT(wrap, &wrapper_type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1562,14 +1260,93 @@ Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, co return (Dtool_MutableSequenceWrapper *)PyErr_NoMemory(); } - // If the collections.abc module is loaded, register this as a subclass. + static PySequenceMethods seq_methods = { + Dtool_SequenceWrapper_length, + nullptr, // sq_concat + nullptr, // sq_repeat + Dtool_SequenceWrapper_getitem, + nullptr, // sq_slice + Dtool_MutableSequenceWrapper_setitem, + nullptr, // sq_ass_slice + Dtool_SequenceWrapper_contains, + Dtool_MutableSequenceWrapper_extend, + nullptr, // sq_inplace_repeat + }; + + static PyMethodDef methods[] = { + {"index", &Dtool_SequenceWrapper_index, METH_O, nullptr}, + {"count", &Dtool_SequenceWrapper_count, METH_O, nullptr}, + {"clear", &Dtool_MutableSequenceWrapper_clear, METH_NOARGS, nullptr}, + {"pop", &Dtool_MutableSequenceWrapper_pop, METH_VARARGS, nullptr}, + {"remove", &Dtool_MutableSequenceWrapper_remove, METH_O, nullptr}, + {"append", &Dtool_MutableSequenceWrapper_append, METH_O, nullptr}, + {"insert", &Dtool_MutableSequenceWrapper_insert, METH_VARARGS, nullptr}, + {"extend", &Dtool_MutableSequenceWrapper_extend, METH_O, nullptr}, + {nullptr, nullptr, 0, nullptr} + }; + + static PyTypeObject wrapper_type = { + PyVarObject_HEAD_INIT(nullptr, 0) + "sequence wrapper", + sizeof(Dtool_MutableSequenceWrapper), + 0, // tp_itemsize + Dtool_WrapperBase_dealloc, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + Dtool_SequenceWrapper_repr, + nullptr, // tp_as_number + &seq_methods, + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + nullptr, // tp_as_buffer + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare + 0, // tp_weaklistoffset + PySeqIter_New, + nullptr, // tp_iternext + methods, + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset + nullptr, // tp_init + PyType_GenericAlloc, + nullptr, // tp_new + PyObject_Del, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }; + static bool registered = false; if (!registered) { registered = true; - _register_collection((PyTypeObject *)&Dtool_MutableSequenceWrapper_Type, "MutableSequence"); + + if (PyType_Ready(&wrapper_type) < 0) { + return nullptr; + } + + // If the collections.abc module is loaded, register this as a subclass. + _register_collection((PyTypeObject *)&wrapper_type, "MutableSequence"); } - (void)PyObject_INIT(wrap, &Dtool_MutableSequenceWrapper_Type); + (void)PyObject_INIT(wrap, &wrapper_type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1589,14 +1366,95 @@ Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name) return (Dtool_MappingWrapper *)PyErr_NoMemory(); } - // If the collections.abc module is loaded, register this as a subclass. + static PySequenceMethods seq_methods = { + Dtool_SequenceWrapper_length, + nullptr, // sq_concat + nullptr, // sq_repeat + nullptr, // sq_item + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice + Dtool_MappingWrapper_contains, + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat + }; + + static PyMappingMethods map_methods = { + Dtool_SequenceWrapper_length, + Dtool_MappingWrapper_getitem, + nullptr, // mp_ass_subscript + }; + + static PyMethodDef methods[] = { + {"get", &Dtool_MappingWrapper_get, METH_VARARGS, nullptr}, + {"keys", &Dtool_MappingWrapper_keys, METH_NOARGS, nullptr}, + {"values", &Dtool_MappingWrapper_values, METH_NOARGS, nullptr}, + {"items", &Dtool_MappingWrapper_items, METH_NOARGS, nullptr}, + {nullptr, nullptr, 0, nullptr} + }; + + static PyTypeObject wrapper_type = { + PyVarObject_HEAD_INIT(nullptr, 0) + "mapping wrapper", + sizeof(Dtool_MappingWrapper), + 0, // tp_itemsize + Dtool_WrapperBase_dealloc, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + Dtool_WrapperBase_repr, + nullptr, // tp_as_number + &seq_methods, + &map_methods, + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + nullptr, // tp_as_buffer + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare + 0, // tp_weaklistoffset + Dtool_MappingWrapper_iter, + nullptr, // tp_iternext + methods, + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset + nullptr, // tp_init + PyType_GenericAlloc, + nullptr, // tp_new + PyObject_Del, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }; + static bool registered = false; if (!registered) { registered = true; - _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Type, "Mapping"); + + if (PyType_Ready(&wrapper_type) < 0) { + return nullptr; + } + + // If the collections.abc module is loaded, register this as a subclass. + _register_collection((PyTypeObject *)&wrapper_type, "Mapping"); } - (void)PyObject_INIT(wrap, &Dtool_MappingWrapper_Type); + (void)PyObject_INIT(wrap, &wrapper_type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1616,14 +1474,100 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char return (Dtool_MappingWrapper *)PyErr_NoMemory(); } - // If the collections.abc module is loaded, register this as a subclass. + static PySequenceMethods seq_methods = { + Dtool_SequenceWrapper_length, + nullptr, // sq_concat + nullptr, // sq_repeat + nullptr, // sq_item + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice + Dtool_MappingWrapper_contains, + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat + }; + + static PyMappingMethods map_methods = { + Dtool_SequenceWrapper_length, + Dtool_MappingWrapper_getitem, + Dtool_MutableMappingWrapper_setitem, + }; + + static PyMethodDef methods[] = { + {"get", &Dtool_MappingWrapper_get, METH_VARARGS, nullptr}, + {"pop", &Dtool_MutableMappingWrapper_pop, METH_VARARGS, nullptr}, + {"popitem", &Dtool_MutableMappingWrapper_popitem, METH_NOARGS, nullptr}, + {"clear", &Dtool_MutableMappingWrapper_clear, METH_VARARGS, nullptr}, + {"setdefault", &Dtool_MutableMappingWrapper_setdefault, METH_VARARGS, nullptr}, + {"update", (PyCFunction) &Dtool_MutableMappingWrapper_update, METH_VARARGS | METH_KEYWORDS, nullptr}, + {"keys", &Dtool_MappingWrapper_keys, METH_NOARGS, nullptr}, + {"values", &Dtool_MappingWrapper_values, METH_NOARGS, nullptr}, + {"items", &Dtool_MappingWrapper_items, METH_NOARGS, nullptr}, + {nullptr, nullptr, 0, nullptr} + }; + + static PyTypeObject wrapper_type = { + PyVarObject_HEAD_INIT(nullptr, 0) + "mapping wrapper", + sizeof(Dtool_MappingWrapper), + 0, // tp_itemsize + Dtool_WrapperBase_dealloc, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + Dtool_WrapperBase_repr, + nullptr, // tp_as_number + &seq_methods, + &map_methods, + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + nullptr, // tp_as_buffer + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare + 0, // tp_weaklistoffset + Dtool_MappingWrapper_iter, + nullptr, // tp_iternext + methods, + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset + nullptr, // tp_init + PyType_GenericAlloc, + nullptr, // tp_new + PyObject_Del, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }; + static bool registered = false; if (!registered) { registered = true; - _register_collection((PyTypeObject *)&Dtool_MutableMappingWrapper_Type, "MutableMapping"); + + if (PyType_Ready(&wrapper_type) < 0) { + return nullptr; + } + + // If the collections.abc module is loaded, register this as a subclass. + _register_collection((PyTypeObject *)&wrapper_type, "MutableMapping"); } - (void)PyObject_INIT(wrap, &Dtool_MutableMappingWrapper_Type); + (void)PyObject_INIT(wrap, &wrapper_type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1634,14 +1578,135 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char return wrap; } +/** + * Creates a generator that invokes a given function with the given self arg. + */ +PyObject * +Dtool_NewGenerator(PyObject *self, iternextfunc gen_next) { + static PyTypeObject wrapper_type = { + PyVarObject_HEAD_INIT(nullptr, 0) + "generator wrapper", + sizeof(Dtool_GeneratorWrapper), + 0, // tp_itemsize + Dtool_WrapperBase_dealloc, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + nullptr, // tp_repr + nullptr, // tp_as_number + nullptr, // tp_as_sequence + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + nullptr, // tp_as_buffer + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare + 0, // tp_weaklistoffset + PyObject_SelfIter, + Dtool_GeneratorWrapper_iternext, + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset + nullptr, // tp_init + PyType_GenericAlloc, + nullptr, // tp_new + PyObject_Del, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }; + + if (PyType_Ready(&wrapper_type) < 0) { + return nullptr; + } + + Dtool_GeneratorWrapper *gen; + gen = (Dtool_GeneratorWrapper *)PyType_GenericAlloc(&wrapper_type, 0); + if (gen != nullptr) { + Py_INCREF(self); + gen->_base._self = self; + gen->_iternext_func = gen_next; + } + return (PyObject *)gen; +} + /** * This is a variant of the Python getset mechanism that permits static * properties. */ PyObject * Dtool_NewStaticProperty(PyTypeObject *type, const PyGetSetDef *getset) { + static PyTypeObject wrapper_type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "getset_descriptor", + sizeof(PyGetSetDescrObject), + 0, // tp_itemsize + (destructor)Dtool_StaticProperty_dealloc, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_reserved + (reprfunc)Dtool_StaticProperty_repr, + nullptr, // tp_as_number + nullptr, // tp_as_sequence + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str + PyObject_GenericGetAttr, + nullptr, // tp_setattro + nullptr, // tp_as_buffer + Py_TPFLAGS_DEFAULT, + nullptr, // tp_doc + Dtool_StaticProperty_traverse, + nullptr, // tp_clear + nullptr, // tp_richcompare + 0, // tp_weaklistoffset + nullptr, // tp_iter + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + (descrgetfunc)Dtool_StaticProperty_get, + (descrsetfunc)Dtool_StaticProperty_set, + 0, // tp_dictoffset + nullptr, // tp_init + nullptr, // tp_alloc + nullptr, // tp_new + nullptr, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del + }; + + if (PyType_Ready(&wrapper_type) < 0) { + return nullptr; + } + PyGetSetDescrObject *descr; - descr = (PyGetSetDescrObject *)PyType_GenericAlloc(&Dtool_StaticProperty_Type, 0); + descr = (PyGetSetDescrObject *)PyType_GenericAlloc(&wrapper_type, 0); if (descr != nullptr) { Py_XINCREF(type); descr->d_getset = (PyGetSetDef *)getset; diff --git a/dtool/src/interrogatedb/py_wrappers.h b/dtool/src/interrogatedb/py_wrappers.h index 7bf2c2e19f..96375d3598 100644 --- a/dtool/src/interrogatedb/py_wrappers.h +++ b/dtool/src/interrogatedb/py_wrappers.h @@ -1,11 +1,4 @@ /** - * 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." - * * @file py_wrappers.h * @author rdb * @date 2017-11-26 @@ -56,22 +49,12 @@ struct Dtool_GeneratorWrapper { iternextfunc _iternext_func; }; -EXPCL_INTERROGATEDB extern PyTypeObject Dtool_SequenceWrapper_Type; -EXPCL_INTERROGATEDB extern PyTypeObject Dtool_MutableSequenceWrapper_Type; -EXPCL_INTERROGATEDB extern PyTypeObject Dtool_MappingWrapper_Type; -EXPCL_INTERROGATEDB extern PyTypeObject Dtool_MutableMappingWrapper_Type; -EXPCL_INTERROGATEDB extern PyTypeObject Dtool_MappingWrapper_Items_Type; -EXPCL_INTERROGATEDB extern PyTypeObject Dtool_MappingWrapper_Keys_Type; -EXPCL_INTERROGATEDB extern PyTypeObject Dtool_MappingWrapper_Values_Type; -EXPCL_INTERROGATEDB extern PyTypeObject Dtool_GeneratorWrapper_Type; -EXPCL_INTERROGATEDB extern PyTypeObject Dtool_StaticProperty_Type; - -EXPCL_INTERROGATEDB Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name); -EXPCL_INTERROGATEDB Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, const char *name); -EXPCL_INTERROGATEDB Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name); -EXPCL_INTERROGATEDB Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char *name); -EXPCL_INTERROGATEDB PyObject *Dtool_NewGenerator(PyObject *self, const char *name, iternextfunc func); -EXPCL_INTERROGATEDB PyObject *Dtool_NewStaticProperty(PyTypeObject *obj, const PyGetSetDef *getset); +Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name); +Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, const char *name); +Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name); +Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char *name); +PyObject *Dtool_NewGenerator(PyObject *self, iternextfunc func); +PyObject *Dtool_NewStaticProperty(PyTypeObject *obj, const PyGetSetDef *getset); #endif // HAVE_PYTHON diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 96effc4c43..eae006b2ec 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3442,14 +3442,13 @@ TargetAdd('libp3dtoolconfig.dll', opts=['ADVAPI', 'OPENSSL', 'WINGDI', 'WINUSER' # DIRECTORY: dtool/src/interrogatedb/ # -OPTS=['DIR:dtool/src/interrogatedb', 'BUILDING:INTERROGATEDB', 'PYTHON'] +OPTS=['DIR:dtool/src/interrogatedb', 'BUILDING:INTERROGATEDB'] TargetAdd('p3interrogatedb_composite1.obj', opts=OPTS, input='p3interrogatedb_composite1.cxx') TargetAdd('p3interrogatedb_composite2.obj', opts=OPTS, input='p3interrogatedb_composite2.cxx') TargetAdd('libp3interrogatedb.dll', input='p3interrogatedb_composite1.obj') TargetAdd('libp3interrogatedb.dll', input='p3interrogatedb_composite2.obj') TargetAdd('libp3interrogatedb.dll', input='libp3dtool.dll') TargetAdd('libp3interrogatedb.dll', input='libp3dtoolconfig.dll') -TargetAdd('libp3interrogatedb.dll', opts=['PYTHON']) if not PkgSkip("PYTHON"): # This used to be called dtoolconfig.pyd, but it just contains the interrogatedb @@ -3489,8 +3488,16 @@ if (not RUNTIME): TargetAdd('interrogate.exe', input='libp3pystub.lib') TargetAdd('interrogate.exe', opts=['ADVAPI', 'OPENSSL', 'WINSHELL', 'WINGDI', 'WINUSER']) + preamble = WriteEmbeddedStringFile('interrogate_preamble_python_native', inputs=[ + 'dtool/src/interrogatedb/py_panda.cxx', + 'dtool/src/interrogatedb/py_compat.cxx', + 'dtool/src/interrogatedb/py_wrappers.cxx', + 'dtool/src/interrogatedb/dtool_super_base.cxx', + ]) + TargetAdd('interrogate_module_preamble_python_native.obj', opts=OPTS, input=preamble) TargetAdd('interrogate_module_interrogate_module.obj', opts=OPTS, input='interrogate_module.cxx') TargetAdd('interrogate_module.exe', input='interrogate_module_interrogate_module.obj') + TargetAdd('interrogate_module.exe', input='interrogate_module_preamble_python_native.obj') TargetAdd('interrogate_module.exe', input='libp3cppParser.ilb') TargetAdd('interrogate_module.exe', input=COMMON_DTOOL_LIBS) TargetAdd('interrogate_module.exe', input='libp3interrogatedb.dll') diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 76dec39406..cf89b85e59 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -3190,6 +3190,48 @@ def WriteResourceFile(basename, **kwargs): ConditionalWriteFile(basename, GenerateResourceFile(**kwargs)) return basename + +def WriteEmbeddedStringFile(basename, inputs, string_name=None): + if os.path.splitext(basename)[1] not in SUFFIX_INC: + basename += '.cxx' + target = GetOutputDir() + "/tmp/" + basename + + if string_name is None: + string_name = os.path.basename(os.path.splitext(target)[0]) + string_name = string_name.replace('-', '_') + + data = bytearray() + for input in inputs: + fp = open(input, 'rb') + + # Insert a #line so that we get meaningful compile/assert errors when + # the result is inserted by interrogate_module into generated code. + if os.path.splitext(input)[1] in SUFFIX_INC: + line = '#line 1 "%s"\n' % (input) + data += bytearray(line.encode('ascii', 'replace')) + + data += bytearray(fp.read()) + fp.close() + + data.append(0) + + output = 'extern const char %s[] = {\n' % (string_name) + + i = 0 + for byte in data: + if i == 0: + output += ' ' + + output += ' 0x%02x,' % (byte) + i += 1 + if i >= 12: + output += '\n' + i = 0 + + output += '\n};\n' + ConditionalWriteFile(target, output) + return target + ######################################################################## ## ## FindLocation diff --git a/panda/src/event/asyncFuture_ext.cxx b/panda/src/event/asyncFuture_ext.cxx index 00ee3516b1..5bf7cb3c94 100644 --- a/panda/src/event/asyncFuture_ext.cxx +++ b/panda/src/event/asyncFuture_ext.cxx @@ -168,14 +168,7 @@ static PyObject *gen_next(PyObject *self) { */ PyObject *Extension:: __await__(PyObject *self) { - Dtool_GeneratorWrapper *gen; - gen = (Dtool_GeneratorWrapper *)PyType_GenericAlloc(&Dtool_GeneratorWrapper_Type, 0); - if (gen != nullptr) { - Py_INCREF(self); - gen->_base._self = self; - gen->_iternext_func = &gen_next; - } - return (PyObject *)gen; + return Dtool_NewGenerator(self, &gen_next); } /** From 82459fa21b47e89a301f5d7e394d868bb254f503 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Nov 2018 17:22:41 +0100 Subject: [PATCH 302/360] ode: remove dependency on Python.h from odeBody.h --- panda/src/ode/odeBody.I | 4 +-- panda/src/ode/odeBody.cxx | 27 +++---------------- panda/src/ode/odeBody.h | 15 ++++++----- panda/src/ode/odeBody_ext.I | 13 ++++++++++ panda/src/ode/odeBody_ext.cxx | 37 +++++++++++++++++++++++++++ panda/src/ode/odeBody_ext.h | 3 +++ panda/src/ode/p3ode_ext_composite.cxx | 1 + 7 files changed, 67 insertions(+), 33 deletions(-) create mode 100644 panda/src/ode/odeBody_ext.cxx diff --git a/panda/src/ode/odeBody.I b/panda/src/ode/odeBody.I index ab241fb455..72ecafd754 100644 --- a/panda/src/ode/odeBody.I +++ b/panda/src/ode/odeBody.I @@ -89,12 +89,10 @@ set_data(void *data) { dBodySetData(_id, data); } -#ifndef HAVE_PYTHON -INLINE void* OdeBody:: +INLINE void *OdeBody:: get_data() const { return dBodyGetData(_id); } -#endif INLINE void OdeBody:: set_position(dReal x, dReal y, dReal z) { diff --git a/panda/src/ode/odeBody.cxx b/panda/src/ode/odeBody.cxx index 70ad46169d..3f8e5d671a 100644 --- a/panda/src/ode/odeBody.cxx +++ b/panda/src/ode/odeBody.cxx @@ -15,10 +15,6 @@ #include "odeBody.h" #include "odeJoint.h" -#ifdef HAVE_PYTHON -#include "py_panda.h" -#endif - TypeHandle OdeBody::_type_handle; OdeBody:: @@ -38,29 +34,14 @@ OdeBody:: void OdeBody:: destroy() { -#ifdef HAVE_PYTHON - Py_XDECREF((PyObject*) dBodyGetData(_id)); -#endif + if (_destroy_callback != nullptr) { + _destroy_callback(*this); + _destroy_callback = nullptr; + } nassertv(_id); dBodyDestroy(_id); } -#ifdef HAVE_PYTHON -void OdeBody:: -set_data(PyObject *data) { - Py_XDECREF((PyObject*) dBodyGetData(_id)); - Py_XINCREF(data); - dBodySetData(_id, data); -} - -PyObject* OdeBody:: -get_data() const { - PyObject* data = (PyObject*) dBodyGetData(_id); - Py_XINCREF(data); - return data; -} -#endif - OdeJoint OdeBody:: get_joint(int index) const { nassertr(_id != nullptr, OdeJoint(nullptr)); diff --git a/panda/src/ode/odeBody.h b/panda/src/ode/odeBody.h index 8e27dd8802..f1cd9dae68 100644 --- a/panda/src/ode/odeBody.h +++ b/panda/src/ode/odeBody.h @@ -51,9 +51,7 @@ PUBLISHED: INLINE void set_auto_disable_flag(int do_auto_disable); INLINE void set_auto_disable_defaults(); INLINE void set_data(void *data); -#ifdef HAVE_PYTHON - void set_data(PyObject *data); -#endif + EXTENSION(void set_data(PyObject *data)); INLINE void set_position(dReal x, dReal y, dReal z); INLINE void set_position(const LVecBase3f &pos); @@ -71,11 +69,10 @@ PUBLISHED: INLINE int get_auto_disable_steps() const; INLINE dReal get_auto_disable_time() const; INLINE int get_auto_disable_flag() const; -#ifdef HAVE_PYTHON - PyObject* get_data() const; -#else - INLINE void* get_data() const; +#ifndef CPPPARSER + INLINE void *get_data() const; #endif + EXTENSION(PyObject *get_data() const); INLINE LVecBase3f get_position() const; INLINE LMatrix3f get_rotation() const; @@ -150,6 +147,10 @@ PUBLISHED: private: dBodyID _id; +public: + typedef void (*DestroyCallback)(OdeBody &body); + DestroyCallback _destroy_callback = nullptr; + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/ode/odeBody_ext.I b/panda/src/ode/odeBody_ext.I index a26eba5b41..5535b900dd 100644 --- a/panda/src/ode/odeBody_ext.I +++ b/panda/src/ode/odeBody_ext.I @@ -13,6 +13,19 @@ #include "odeJoint_ext.h" +/** + * Returns the custom data associated with the OdeBody. + */ +INLINE PyObject *Extension:: +get_data() const { + PyObject *data = (PyObject *)_this->get_data(); + if (data == nullptr) { + data = Py_None; + } + Py_INCREF(data); + return data; +} + /** * Equivalent to get_joint().convert() */ diff --git a/panda/src/ode/odeBody_ext.cxx b/panda/src/ode/odeBody_ext.cxx new file mode 100644 index 0000000000..59361c5fa1 --- /dev/null +++ b/panda/src/ode/odeBody_ext.cxx @@ -0,0 +1,37 @@ +/** + * 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." + * + * @file odeBody_ext.cxx + * @author rdb + * @date 2018-11-06 + */ + +#include "odeBody_ext.h" + +static void destroy_callback(OdeBody &body) { + Py_XDECREF((PyObject *)body.get_data()); +} + +/** + * Sets custom data to be associated with the OdeBody. + */ +void Extension:: +set_data(PyObject *data) { + void *old_data = _this->get_data(); + + if (data != nullptr && data != Py_None) { + Py_INCREF(data); + _this->set_data((void *)data); + _this->_destroy_callback = &destroy_callback; + } else { + _this->set_data(nullptr); + _this->_destroy_callback = nullptr; + } + + Py_XDECREF((PyObject *)old_data); +} diff --git a/panda/src/ode/odeBody_ext.h b/panda/src/ode/odeBody_ext.h index 04c2244324..125c7fe509 100644 --- a/panda/src/ode/odeBody_ext.h +++ b/panda/src/ode/odeBody_ext.h @@ -30,6 +30,9 @@ template<> class Extension : public ExtensionBase { public: + void set_data(PyObject *); + INLINE PyObject *get_data() const; + INLINE PyObject *get_converted_joint(int i) const; }; diff --git a/panda/src/ode/p3ode_ext_composite.cxx b/panda/src/ode/p3ode_ext_composite.cxx index 02ebaec64c..ac054bdc49 100644 --- a/panda/src/ode/p3ode_ext_composite.cxx +++ b/panda/src/ode/p3ode_ext_composite.cxx @@ -1,3 +1,4 @@ +#include "odeBody_ext.cxx" #include "odeGeom_ext.cxx" #include "odeJoint_ext.cxx" #include "odeSpace_ext.cxx" From f43bd1a40962b07b543b0fc9835435b71c7743fa Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Nov 2018 18:08:48 +0100 Subject: [PATCH 303/360] gobj: remove use of PY_MAJOR_VERSION in internalName.h We should not use this symbol in the interrogated headers as it means we cannot reuse the output of interrogate with different versions of Python. --- panda/src/gobj/internalName.h | 6 +----- panda/src/gobj/internalName_ext.cxx | 14 ++++++++++++-- panda/src/gobj/internalName_ext.h | 6 +----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/panda/src/gobj/internalName.h b/panda/src/gobj/internalName.h index 729ec15ab8..5e61e81916 100644 --- a/panda/src/gobj/internalName.h +++ b/panda/src/gobj/internalName.h @@ -96,11 +96,7 @@ PUBLISHED: #ifdef HAVE_PYTHON // These versions are exposed to Python, which have additional logic to map // from Python interned strings. -#if PY_MAJOR_VERSION >= 3 - EXTENSION(static PT(InternalName) make(PyUnicodeObject *str)); -#else - EXTENSION(static PT(InternalName) make(PyStringObject *str)); -#endif + EXTENSION(static PT(InternalName) make(PyObject *str)); #endif public: diff --git a/panda/src/gobj/internalName_ext.cxx b/panda/src/gobj/internalName_ext.cxx index f1cdf0a725..4821880677 100644 --- a/panda/src/gobj/internalName_ext.cxx +++ b/panda/src/gobj/internalName_ext.cxx @@ -24,7 +24,12 @@ using std::string; */ #if PY_MAJOR_VERSION >= 3 PT(InternalName) Extension:: -make(PyUnicodeObject *str) { +make(PyObject *str) { + if (!PyUnicode_Check(str)) { + Dtool_Raise_ArgTypeError(str, 0, "InternalName.make", "str"); + return nullptr; + } + if (!PyUnicode_CHECK_INTERNED(str)) { // Not an interned string; don't bother. Py_ssize_t len = 0; @@ -50,7 +55,12 @@ make(PyUnicodeObject *str) { #else PT(InternalName) Extension:: -make(PyStringObject *str) { +make(PyObject *str) { + if (!PyString_Check(str)) { + Dtool_Raise_ArgTypeError(str, 0, "InternalName.make", "str"); + return nullptr; + } + if (!PyString_CHECK_INTERNED(str)) { // Not an interned string; don't bother. string name(PyString_AS_STRING(str), PyString_GET_SIZE(str)); diff --git a/panda/src/gobj/internalName_ext.h b/panda/src/gobj/internalName_ext.h index 20016abd60..8637eae16e 100644 --- a/panda/src/gobj/internalName_ext.h +++ b/panda/src/gobj/internalName_ext.h @@ -29,11 +29,7 @@ template<> class Extension : public ExtensionBase { public: -#if PY_MAJOR_VERSION >= 3 - static PT(InternalName) make(PyUnicodeObject *str); -#else - static PT(InternalName) make(PyStringObject *str); -#endif + static PT(InternalName) make(PyObject *str); }; #endif // HAVE_PYTHON From 995ba28650e6f1e346552a4a6e8894f69006bf20 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Nov 2018 18:43:51 +0100 Subject: [PATCH 304/360] makepanda: allow building multiple Python versions in one built dir This is done by adding a PyTargetAdd function, which builds the target into a Python ABI-specific temporary directory, allowing multiple Python versions to be built into the same built dir side-by-side. This could greatly speed up buildbot builds. It also paves the way for building multiple Python versions in the same makepanda call / installer by changing PyTargetAdd to add one target per enabled Python version. --- makepanda/installer.nsi | 21 +- makepanda/installpanda.py | 7 +- makepanda/makepanda.py | 798 +++++++++++++++++-------------------- makepanda/makepandacore.py | 95 ++++- makepanda/makewheel.py | 2 +- 5 files changed, 473 insertions(+), 450 deletions(-) diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index 1dab5196da..7b1d6ea25e 100644 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -331,13 +331,24 @@ SectionGroup "Python support" SetOutPath $INSTDIR\panda3d File /r "${BUILT}\panda3d\*.py" - File /r /x bullet.pyd /x ode.pyd /x physx.pyd /x rocket.pyd "${BUILT}\panda3d\*.pyd" + File /nonfatal /r "${BUILT}\panda3d\core${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\ai${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\awesomium${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\direct${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\egg${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\fx${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\interrogatedb${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\physics${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\_rplight${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\skel${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\vision${EXT_SUFFIX}" + File /nonfatal /r "${BUILT}\panda3d\vrpn${EXT_SUFFIX}" !ifdef HAVE_BULLET SectionGetFlags ${SecBullet} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCmp $R0 ${SF_SELECTED} 0 SkipBulletPyd - File /nonfatal /r "${BUILT}\panda3d\bullet.pyd" + File /nonfatal /r "${BUILT}\panda3d\bullet${EXT_SUFFIX}" SkipBulletPyd: !endif @@ -345,7 +356,7 @@ SectionGroup "Python support" SectionGetFlags ${SecODE} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCmp $R0 ${SF_SELECTED} 0 SkipODEPyd - File /nonfatal /r "${BUILT}\panda3d\ode.pyd" + File /nonfatal /r "${BUILT}\panda3d\ode${EXT_SUFFIX}" SkipODEPyd: !endif @@ -353,7 +364,7 @@ SectionGroup "Python support" SectionGetFlags ${SecPhysX} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCmp $R0 ${SF_SELECTED} 0 SkipPhysXPyd - File /nonfatal /r "${BUILT}\panda3d\physx.pyd" + File /nonfatal /r "${BUILT}\panda3d\physx${EXT_SUFFIX}" SkipPhysXPyd: !endif @@ -361,7 +372,7 @@ SectionGroup "Python support" SectionGetFlags ${SecRocket} $R0 IntOp $R0 $R0 & ${SF_SELECTED} StrCmp $R0 ${SF_SELECTED} 0 SkipRocketPyd - File /nonfatal /r "${BUILT}\panda3d\rocket.pyd" + File /nonfatal /r "${BUILT}\panda3d\rocket${EXT_SUFFIX}" SkipRocketPyd: !endif diff --git a/makepanda/installpanda.py b/makepanda/installpanda.py index 63a4601ee6..410847efc7 100644 --- a/makepanda/installpanda.py +++ b/makepanda/installpanda.py @@ -175,6 +175,7 @@ def InstallPanda(destdir="", prefix="/usr", outputdir="built", libdir=GetLibDir( oscmd("mkdir -m 0755 -p "+destdir+prefix+"/share/applications") oscmd("mkdir -m 0755 -p "+destdir+libdir+"/panda3d") oscmd("mkdir -m 0755 -p "+destdir+PPATH) + oscmd("mkdir -m 0755 -p "+destdir+PPATH+"/panda3d") if (sys.platform.startswith("freebsd")): oscmd("mkdir -m 0755 -p "+destdir+prefix+"/etc") @@ -194,13 +195,17 @@ def InstallPanda(destdir="", prefix="/usr", outputdir="built", libdir=GetLibDir( oscmd("cp -R "+outputdir+"/include "+destdir+prefix+"/include/panda3d") oscmd("cp -R "+outputdir+"/pandac "+destdir+prefix+"/share/panda3d/") - oscmd("cp -R "+outputdir+"/panda3d "+destdir+PPATH+"/") oscmd("cp -R "+outputdir+"/models "+destdir+prefix+"/share/panda3d/") if os.path.isdir("samples"): oscmd("cp -R samples "+destdir+prefix+"/share/panda3d/") if os.path.isdir(outputdir+"/direct"): oscmd("cp -R "+outputdir+"/direct "+destdir+prefix+"/share/panda3d/") if os.path.isdir(outputdir+"/Pmw"): oscmd("cp -R "+outputdir+"/Pmw "+destdir+prefix+"/share/panda3d/") if os.path.isdir(outputdir+"/plugins"): oscmd("cp -R "+outputdir+"/plugins "+destdir+prefix+"/share/panda3d/") + suffix = GetExtensionSuffix() + for base in os.listdir(outputdir + "/panda3d"): + if base.endswith(".py") or (base.endswith(suffix) and '.' not in base[:-len(suffix)]): + oscmd("cp "+outputdir+"/panda3d/"+base+" "+destdir+PPATH+"/panda3d/"+base) + WriteMimeFile(destdir+prefix+"/share/mime-info/panda3d.mime", MIME_INFO) WriteKeysFile(destdir+prefix+"/share/mime-info/panda3d.keys", MIME_INFO) WriteMimeXMLFile(destdir+prefix+"/share/mime/packages/panda3d.xml", MIME_INFO) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index eae006b2ec..2689205461 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1448,7 +1448,6 @@ def CompileFlex(wobj,wsrc,opts): def CompileIgate(woutd,wsrc,opts): outbase = os.path.basename(woutd)[:-3] woutc = GetOutputDir()+"/tmp/"+outbase+"_igate.cxx" - wobj = FindLocation(outbase + "_igate.obj", []) srcdir = GetValueOption(opts, "SRCDIR:") module = GetValueOption(opts, "IMOD:") library = GetValueOption(opts, "ILIB:") @@ -1457,7 +1456,7 @@ def CompileIgate(woutd,wsrc,opts): WriteFile(woutc, "") WriteFile(woutd, "") ConditionalWriteFile(woutd, "") - return (wobj, woutc, opts) + return if not CrossCompiling(): # If we're compiling for this platform, we can use the one we've built. @@ -1524,8 +1523,6 @@ def CompileIgate(woutd,wsrc,opts): cmd += ' ' + BracketNameWithQuotes(os.path.basename(x)) oscmd(cmd) - return (wobj, woutc, opts) - ######################################################################## ## ## CompileImod @@ -2198,9 +2195,7 @@ def CompileAnything(target, inputs, opts, progress = None): return CompileLink(target, inputs, opts) elif (origsuffix==".in"): ProgressOutput(progress, "Building Interrogate database", target) - args = CompileIgate(target, inputs, opts) - ProgressOutput(progress, "Building C++ object", args[0]) - return CompileCxx(*args) + return CompileIgate(target, inputs, opts) elif (origsuffix==".plugin" and GetTarget() == "darwin"): ProgressOutput(progress, "Building plugin bundle", target) return CompileBundle(target, inputs, opts) @@ -3450,16 +3445,14 @@ TargetAdd('libp3interrogatedb.dll', input='p3interrogatedb_composite2.obj') TargetAdd('libp3interrogatedb.dll', input='libp3dtool.dll') TargetAdd('libp3interrogatedb.dll', input='libp3dtoolconfig.dll') -if not PkgSkip("PYTHON"): - # This used to be called dtoolconfig.pyd, but it just contains the interrogatedb - # stuff, so it has been renamed appropriately. - OPTS=['DIR:dtool/metalibs/dtoolconfig', 'PYTHON'] - TargetAdd('interrogatedb_pydtool.obj', opts=OPTS, input="pydtool.cxx") - TargetAdd('interrogatedb.pyd', input='interrogatedb_pydtool.obj') - TargetAdd('interrogatedb.pyd', input='libp3dtool.dll') - TargetAdd('interrogatedb.pyd', input='libp3dtoolconfig.dll') - TargetAdd('interrogatedb.pyd', input='libp3interrogatedb.dll') - TargetAdd('interrogatedb.pyd', opts=['PYTHON']) +# This used to be called dtoolconfig.pyd, but it just contains the interrogatedb +# stuff, so it has been renamed appropriately. +OPTS=['DIR:dtool/metalibs/dtoolconfig'] +PyTargetAdd('interrogatedb_pydtool.obj', opts=OPTS, input="pydtool.cxx") +PyTargetAdd('interrogatedb.pyd', input='interrogatedb_pydtool.obj') +PyTargetAdd('interrogatedb.pyd', input='libp3dtool.dll') +PyTargetAdd('interrogatedb.pyd', input='libp3dtoolconfig.dll') +PyTargetAdd('interrogatedb.pyd', input='libp3interrogatedb.dll') # # DIRECTORY: dtool/src/pystub/ @@ -3541,7 +3534,7 @@ if (not RTDIST and not RUNTIME): # DIRECTORY: dtool/src/dtoolbase/ # -OPTS=['DIR:dtool/src/dtoolbase', 'PYTHON'] +OPTS=['DIR:dtool/src/dtoolbase'] IGATEFILES=GetDirectoryContents('dtool/src/dtoolbase', ["*_composite*.cxx"]) IGATEFILES += [ "typeHandle.h", @@ -3552,14 +3545,13 @@ IGATEFILES += [ ] TargetAdd('libp3dtoolbase.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3dtoolbase.in', opts=['IMOD:panda3d.core', 'ILIB:libp3dtoolbase', 'SRCDIR:dtool/src/dtoolbase']) -TargetAdd('libp3dtoolbase_igate.obj', input='libp3dtoolbase.in', opts=["DEPENDENCYONLY"]) -TargetAdd('p3dtoolbase_typeHandle_ext.obj', opts=OPTS, input='typeHandle_ext.cxx') +PyTargetAdd('p3dtoolbase_typeHandle_ext.obj', opts=OPTS, input='typeHandle_ext.cxx') # # DIRECTORY: dtool/src/dtoolutil/ # -OPTS=['DIR:dtool/src/dtoolutil', 'PYTHON'] +OPTS=['DIR:dtool/src/dtoolutil'] IGATEFILES=GetDirectoryContents('dtool/src/dtoolutil', ["*_composite*.cxx"]) IGATEFILES += [ "config_dtoolutil.h", @@ -3577,19 +3569,17 @@ IGATEFILES += [ ] TargetAdd('libp3dtoolutil.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3dtoolutil.in', opts=['IMOD:panda3d.core', 'ILIB:libp3dtoolutil', 'SRCDIR:dtool/src/dtoolutil']) -TargetAdd('libp3dtoolutil_igate.obj', input='libp3dtoolutil.in', opts=["DEPENDENCYONLY"]) -TargetAdd('p3dtoolutil_ext_composite.obj', opts=OPTS, input='p3dtoolutil_ext_composite.cxx') +PyTargetAdd('p3dtoolutil_ext_composite.obj', opts=OPTS, input='p3dtoolutil_ext_composite.cxx') # # DIRECTORY: dtool/src/prc/ # -OPTS=['DIR:dtool/src/prc', 'PYTHON'] +OPTS=['DIR:dtool/src/prc'] IGATEFILES=GetDirectoryContents('dtool/src/prc', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3prc.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3prc.in', opts=['IMOD:panda3d.core', 'ILIB:libp3prc', 'SRCDIR:dtool/src/prc']) -TargetAdd('libp3prc_igate.obj', input='libp3prc.in', opts=["DEPENDENCYONLY"]) -TargetAdd('p3prc_ext_composite.obj', opts=OPTS, input='p3prc_ext_composite.cxx') +PyTargetAdd('p3prc_ext_composite.obj', opts=OPTS, input='p3prc_ext_composite.cxx') # # DIRECTORY: panda/src/pandabase/ @@ -3606,12 +3596,11 @@ 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') -OPTS=['DIR:panda/src/express', 'OPENSSL', 'ZLIB', 'PYTHON'] +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') +PyTargetAdd('p3express_ext_composite.obj', opts=OPTS, input='p3express_ext_composite.cxx') # # DIRECTORY: panda/src/downloader/ @@ -3621,12 +3610,11 @@ 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', 'PYTHON'] +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']) -TargetAdd('libp3downloader_igate.obj', input='libp3downloader.in', opts=["DEPENDENCYONLY"]) -TargetAdd('p3downloader_stringStream_ext.obj', opts=OPTS, input='stringStream_ext.cxx') +PyTargetAdd('p3downloader_stringStream_ext.obj', opts=OPTS, input='stringStream_ext.cxx') # # DIRECTORY: panda/metalibs/pandaexpress/ @@ -3653,12 +3641,11 @@ if (not RUNTIME): TargetAdd('p3pipeline_composite2.obj', opts=OPTS, input='p3pipeline_composite2.cxx') TargetAdd('p3pipeline_contextSwitch.obj', opts=OPTS, input='contextSwitch.c') - OPTS=['DIR:panda/src/pipeline', 'PYTHON'] + 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']) - TargetAdd('libp3pipeline_igate.obj', input='libp3pipeline.in', opts=["DEPENDENCYONLY"]) - TargetAdd('p3pipeline_pythonThread.obj', opts=OPTS, input='pythonThread.cxx') + PyTargetAdd('p3pipeline_pythonThread.obj', opts=OPTS, input='pythonThread.cxx') # # DIRECTORY: panda/src/linmath/ @@ -3669,7 +3656,7 @@ if (not RUNTIME): 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', 'PYTHON'] + OPTS=['DIR:panda/src/linmath'] IGATEFILES=GetDirectoryContents('panda/src/linmath', ["*.h", "*_composite*.cxx"]) for ifile in IGATEFILES[:]: if "_src." in ifile: @@ -3679,7 +3666,6 @@ if (not RUNTIME): IGATEFILES.remove('cast_to_float.h') TargetAdd('libp3linmath.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3linmath.in', opts=['IMOD:panda3d.core', 'ILIB:libp3linmath', 'SRCDIR:panda/src/linmath']) - TargetAdd('libp3linmath_igate.obj', input='libp3linmath.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/putil/ @@ -3690,14 +3676,13 @@ if (not RUNTIME): 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', 'PYTHON'] + OPTS=['DIR:panda/src/putil', 'ZLIB'] IGATEFILES=GetDirectoryContents('panda/src/putil', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("test_bam.h") IGATEFILES.remove("config_util.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_ext_composite.obj', opts=OPTS, input='p3putil_ext_composite.cxx') + PyTargetAdd('p3putil_ext_composite.obj', opts=OPTS, input='p3putil_ext_composite.cxx') # # DIRECTORY: panda/src/audio/ @@ -3707,11 +3692,10 @@ 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', 'PYTHON'] + 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']) - TargetAdd('libp3audio_igate.obj', input='libp3audio.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/event/ @@ -3722,13 +3706,12 @@ if (not RUNTIME): 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', 'PYTHON'] - TargetAdd('p3event_asyncFuture_ext.obj', opts=OPTS, input='asyncFuture_ext.cxx') - TargetAdd('p3event_pythonTask.obj', opts=OPTS, input='pythonTask.cxx') + OPTS=['DIR:panda/src/event'] + PyTargetAdd('p3event_asyncFuture_ext.obj', opts=OPTS, input='asyncFuture_ext.cxx') + PyTargetAdd('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']) - TargetAdd('libp3event_igate.obj', input='libp3event.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/mathutil/ @@ -3739,14 +3722,13 @@ if (not RUNTIME): 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', 'PYTHON'] + OPTS=['DIR:panda/src/mathutil', 'FFTW'] IGATEFILES=GetDirectoryContents('panda/src/mathutil', ["*.h", "*_composite*.cxx"]) for ifile in IGATEFILES[:]: if "_src." in ifile: IGATEFILES.remove(ifile) TargetAdd('libp3mathutil.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3mathutil.in', opts=['IMOD:panda3d.core', 'ILIB:libp3mathutil', 'SRCDIR:panda/src/mathutil']) - TargetAdd('libp3mathutil_igate.obj', input='libp3mathutil.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/gsgbase/ @@ -3756,11 +3738,10 @@ 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', 'PYTHON'] + 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']) - TargetAdd('libp3gsgbase_igate.obj', input='libp3gsgbase.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/pnmimage/ @@ -3772,12 +3753,11 @@ if (not RUNTIME): TargetAdd('p3pnmimage_composite2.obj', opts=OPTS, input='p3pnmimage_composite2.cxx') TargetAdd('p3pnmimage_convert_srgb_sse2.obj', opts=OPTS+['SSE2'], input='convert_srgb_sse2.cxx') - OPTS=['DIR:panda/src/pnmimage', 'ZLIB', 'PYTHON'] + 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']) - TargetAdd('libp3pnmimage_igate.obj', input='libp3pnmimage.in', opts=["DEPENDENCYONLY"]) - TargetAdd('p3pnmimage_pfmFile_ext.obj', opts=OPTS, input='pfmFile_ext.cxx') + PyTargetAdd('p3pnmimage_pfmFile_ext.obj', opts=OPTS, input='pfmFile_ext.cxx') # # DIRECTORY: panda/src/nativenet/ @@ -3787,11 +3767,10 @@ 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', 'PYTHON'] + 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']) - TargetAdd('libp3nativenet_igate.obj', input='libp3nativenet.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/net/ @@ -3802,12 +3781,11 @@ if (not RUNTIME): 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', 'PYTHON'] + 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) TargetAdd('libp3net.in', opts=['IMOD:panda3d.core', 'ILIB:libp3net', 'SRCDIR:panda/src/net']) - TargetAdd('libp3net_igate.obj', input='libp3net.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/pstatclient/ @@ -3818,12 +3796,11 @@ if (not RUNTIME): 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', 'PYTHON'] + OPTS=['DIR:panda/src/pstatclient'] IGATEFILES=GetDirectoryContents('panda/src/pstatclient', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("config_pstats.h") TargetAdd('libp3pstatclient.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3pstatclient.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pstatclient', 'SRCDIR:panda/src/pstatclient']) - TargetAdd('libp3pstatclient_igate.obj', input='libp3pstatclient.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/gobj/ @@ -3834,13 +3811,12 @@ if (not RUNTIME): TargetAdd('p3gobj_composite1.obj', opts=OPTS, input='p3gobj_composite1.cxx') TargetAdd('p3gobj_composite2.obj', opts=OPTS+['BIGOBJ'], input='p3gobj_composite2.cxx') - OPTS=['DIR:panda/src/gobj', 'NVIDIACG', 'ZLIB', 'SQUISH', 'PYTHON'] + 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_ext_composite.obj', opts=OPTS, input='p3gobj_ext_composite.cxx') + PyTargetAdd('p3gobj_ext_composite.obj', opts=OPTS, input='p3gobj_ext_composite.cxx') # # DIRECTORY: panda/src/pgraphnodes/ @@ -3851,11 +3827,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3pgraphnodes_igate.obj', input='libp3pgraphnodes.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/pgraph/ @@ -3869,12 +3844,11 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3pgraph_igate.obj', input='libp3pgraph.in', opts=["DEPENDENCYONLY","BIGOBJ"]) - TargetAdd('p3pgraph_ext_composite.obj', opts=OPTS, input='p3pgraph_ext_composite.cxx') + PyTargetAdd('p3pgraph_ext_composite.obj', opts=OPTS, input='p3pgraph_ext_composite.cxx') # # DIRECTORY: panda/src/cull/ @@ -3885,11 +3859,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3cull_igate.obj', input='libp3cull.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/display/ @@ -3901,15 +3874,14 @@ if (not RUNTIME): 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', 'PYTHON'] + OPTS=['DIR:panda/src/display'] IGATEFILES=GetDirectoryContents('panda/src/display', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("renderBuffer.h") TargetAdd('libp3display.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3display.in', opts=['IMOD:panda3d.core', 'ILIB:libp3display', 'SRCDIR:panda/src/display']) - 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') + PyTargetAdd('p3display_graphicsStateGuardian_ext.obj', opts=OPTS, input='graphicsStateGuardian_ext.cxx') + PyTargetAdd('p3display_graphicsWindow_ext.obj', opts=OPTS, input='graphicsWindow_ext.cxx') + PyTargetAdd('p3display_pythonGraphicsWindowProc.obj', opts=OPTS, input='pythonGraphicsWindowProc.cxx') if RTDIST and GetTarget() == 'darwin': OPTS=['DIR:panda/src/display'] @@ -3925,13 +3897,12 @@ if (not RUNTIME): 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', 'PYTHON'] + OPTS=['DIR:panda/src/chan'] IGATEFILES=GetDirectoryContents('panda/src/chan', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove('movingPart.h') IGATEFILES.remove('animChannelFixed.h') TargetAdd('libp3chan.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3chan.in', opts=['IMOD:panda3d.core', 'ILIB:libp3chan', 'SRCDIR:panda/src/chan']) - TargetAdd('libp3chan_igate.obj', input='libp3chan.in', opts=["DEPENDENCYONLY"]) # DIRECTORY: panda/src/char/ @@ -3942,11 +3913,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3char_igate.obj', input='libp3char.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/dgraph/ @@ -3957,11 +3927,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3dgraph_igate.obj', input='libp3dgraph.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/device/ @@ -3972,11 +3941,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3device_igate.obj', input='libp3device.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/pnmtext/ @@ -3986,11 +3954,10 @@ 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', 'PYTHON'] + 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']) - TargetAdd('libp3pnmtext_igate.obj', input='libp3pnmtext.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/text/ @@ -4004,11 +3971,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3text_igate.obj', input='libp3text.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/movies/ @@ -4018,11 +3984,10 @@ if (not RUNTIME): OPTS=['DIR:panda/src/movies', 'BUILDING:PANDA', 'VORBIS', 'OPUS'] TargetAdd('p3movies_composite1.obj', opts=OPTS, input='p3movies_composite1.cxx') - OPTS=['DIR:panda/src/movies', 'VORBIS', 'OPUS', 'PYTHON'] + OPTS=['DIR:panda/src/movies', 'VORBIS', 'OPUS'] 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']) - TargetAdd('libp3movies_igate.obj', input='libp3movies.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/grutil/ @@ -4034,12 +3999,11 @@ if (not RUNTIME): 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', 'PYTHON'] + 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) TargetAdd('libp3grutil.in', opts=['IMOD:panda3d.core', 'ILIB:libp3grutil', 'SRCDIR:panda/src/grutil']) - TargetAdd('libp3grutil_igate.obj', input='libp3grutil.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/tform/ @@ -4050,11 +4014,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3tform_igate.obj', input='libp3tform.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/collide/ @@ -4065,11 +4028,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3collide_igate.obj', input='libp3collide.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/parametrics/ @@ -4080,11 +4042,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3parametrics_igate.obj', input='libp3parametrics.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/pgui/ @@ -4095,11 +4056,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3pgui_igate.obj', input='libp3pgui.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/pnmimagetypes/ @@ -4119,11 +4079,10 @@ if (not RUNTIME): 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', 'PYTHON'] + 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']) - TargetAdd('libp3recorder_igate.obj', input='libp3recorder.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/dxml/ @@ -4139,11 +4098,10 @@ 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', 'PYTHON'] + 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']) - TargetAdd('libp3dxml_igate.obj', input='libp3dxml.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/metalibs/panda/ @@ -4230,110 +4188,109 @@ if (not RUNTIME): TargetAdd('libpanda.dll', dep='dtool_have_freetype.dat') TargetAdd('libpanda.dll', opts=OPTS) - TargetAdd('core_module.obj', input='libp3dtoolbase.in') - TargetAdd('core_module.obj', input='libp3dtoolutil.in') - TargetAdd('core_module.obj', input='libp3prc.in') + PyTargetAdd('core_module.obj', input='libp3dtoolbase.in') + PyTargetAdd('core_module.obj', input='libp3dtoolutil.in') + PyTargetAdd('core_module.obj', input='libp3prc.in') - TargetAdd('core_module.obj', input='libp3downloader.in') - TargetAdd('core_module.obj', input='libp3express.in') + PyTargetAdd('core_module.obj', input='libp3downloader.in') + PyTargetAdd('core_module.obj', input='libp3express.in') - TargetAdd('core_module.obj', input='libp3recorder.in') - TargetAdd('core_module.obj', input='libp3pgraphnodes.in') - TargetAdd('core_module.obj', input='libp3pgraph.in') - TargetAdd('core_module.obj', input='libp3cull.in') - TargetAdd('core_module.obj', input='libp3grutil.in') - TargetAdd('core_module.obj', input='libp3chan.in') - TargetAdd('core_module.obj', input='libp3pstatclient.in') - TargetAdd('core_module.obj', input='libp3char.in') - TargetAdd('core_module.obj', input='libp3collide.in') - TargetAdd('core_module.obj', input='libp3device.in') - TargetAdd('core_module.obj', input='libp3dgraph.in') - TargetAdd('core_module.obj', input='libp3display.in') - TargetAdd('core_module.obj', input='libp3pipeline.in') - TargetAdd('core_module.obj', input='libp3event.in') - TargetAdd('core_module.obj', input='libp3gobj.in') - TargetAdd('core_module.obj', input='libp3gsgbase.in') - TargetAdd('core_module.obj', input='libp3linmath.in') - TargetAdd('core_module.obj', input='libp3mathutil.in') - TargetAdd('core_module.obj', input='libp3parametrics.in') - TargetAdd('core_module.obj', input='libp3pnmimage.in') - TargetAdd('core_module.obj', input='libp3text.in') - TargetAdd('core_module.obj', input='libp3tform.in') - TargetAdd('core_module.obj', input='libp3putil.in') - TargetAdd('core_module.obj', input='libp3audio.in') - TargetAdd('core_module.obj', input='libp3nativenet.in') - TargetAdd('core_module.obj', input='libp3net.in') - TargetAdd('core_module.obj', input='libp3pgui.in') - TargetAdd('core_module.obj', input='libp3movies.in') - TargetAdd('core_module.obj', input='libp3dxml.in') + PyTargetAdd('core_module.obj', input='libp3recorder.in') + PyTargetAdd('core_module.obj', input='libp3pgraphnodes.in') + PyTargetAdd('core_module.obj', input='libp3pgraph.in') + PyTargetAdd('core_module.obj', input='libp3cull.in') + PyTargetAdd('core_module.obj', input='libp3grutil.in') + PyTargetAdd('core_module.obj', input='libp3chan.in') + PyTargetAdd('core_module.obj', input='libp3pstatclient.in') + PyTargetAdd('core_module.obj', input='libp3char.in') + PyTargetAdd('core_module.obj', input='libp3collide.in') + PyTargetAdd('core_module.obj', input='libp3device.in') + PyTargetAdd('core_module.obj', input='libp3dgraph.in') + PyTargetAdd('core_module.obj', input='libp3display.in') + PyTargetAdd('core_module.obj', input='libp3pipeline.in') + PyTargetAdd('core_module.obj', input='libp3event.in') + PyTargetAdd('core_module.obj', input='libp3gobj.in') + PyTargetAdd('core_module.obj', input='libp3gsgbase.in') + PyTargetAdd('core_module.obj', input='libp3linmath.in') + PyTargetAdd('core_module.obj', input='libp3mathutil.in') + PyTargetAdd('core_module.obj', input='libp3parametrics.in') + PyTargetAdd('core_module.obj', input='libp3pnmimage.in') + PyTargetAdd('core_module.obj', input='libp3text.in') + PyTargetAdd('core_module.obj', input='libp3tform.in') + PyTargetAdd('core_module.obj', input='libp3putil.in') + PyTargetAdd('core_module.obj', input='libp3audio.in') + PyTargetAdd('core_module.obj', input='libp3nativenet.in') + PyTargetAdd('core_module.obj', input='libp3net.in') + PyTargetAdd('core_module.obj', input='libp3pgui.in') + PyTargetAdd('core_module.obj', input='libp3movies.in') + PyTargetAdd('core_module.obj', input='libp3dxml.in') if PkgSkip("FREETYPE")==0: - TargetAdd('core_module.obj', input='libp3pnmtext.in') + PyTargetAdd('core_module.obj', input='libp3pnmtext.in') - TargetAdd('core_module.obj', opts=['PYTHON']) - TargetAdd('core_module.obj', opts=['IMOD:panda3d.core', 'ILIB:core']) + PyTargetAdd('core_module.obj', opts=['IMOD:panda3d.core', 'ILIB:core']) - TargetAdd('core.pyd', input='libp3dtoolbase_igate.obj') - TargetAdd('core.pyd', input='p3dtoolbase_typeHandle_ext.obj') - TargetAdd('core.pyd', input='libp3dtoolutil_igate.obj') - TargetAdd('core.pyd', input='p3dtoolutil_ext_composite.obj') - TargetAdd('core.pyd', input='libp3prc_igate.obj') - TargetAdd('core.pyd', input='p3prc_ext_composite.obj') + PyTargetAdd('core.pyd', input='libp3dtoolbase_igate.obj') + PyTargetAdd('core.pyd', input='p3dtoolbase_typeHandle_ext.obj') + PyTargetAdd('core.pyd', input='libp3dtoolutil_igate.obj') + PyTargetAdd('core.pyd', input='p3dtoolutil_ext_composite.obj') + PyTargetAdd('core.pyd', input='libp3prc_igate.obj') + PyTargetAdd('core.pyd', input='p3prc_ext_composite.obj') - TargetAdd('core.pyd', input='libp3downloader_igate.obj') - TargetAdd('core.pyd', input='p3downloader_stringStream_ext.obj') - TargetAdd('core.pyd', input='p3express_ext_composite.obj') - TargetAdd('core.pyd', input='libp3express_igate.obj') + PyTargetAdd('core.pyd', input='libp3downloader_igate.obj') + PyTargetAdd('core.pyd', input='p3downloader_stringStream_ext.obj') + PyTargetAdd('core.pyd', input='p3express_ext_composite.obj') + PyTargetAdd('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') + PyTargetAdd('core.pyd', input='libp3recorder_igate.obj') + PyTargetAdd('core.pyd', input='libp3pgraphnodes_igate.obj') + PyTargetAdd('core.pyd', input='libp3pgraph_igate.obj') + PyTargetAdd('core.pyd', input='libp3movies_igate.obj') + PyTargetAdd('core.pyd', input='libp3grutil_igate.obj') + PyTargetAdd('core.pyd', input='libp3chan_igate.obj') + PyTargetAdd('core.pyd', input='libp3pstatclient_igate.obj') + PyTargetAdd('core.pyd', input='libp3char_igate.obj') + PyTargetAdd('core.pyd', input='libp3collide_igate.obj') + PyTargetAdd('core.pyd', input='libp3device_igate.obj') + PyTargetAdd('core.pyd', input='libp3dgraph_igate.obj') + PyTargetAdd('core.pyd', input='libp3display_igate.obj') + PyTargetAdd('core.pyd', input='libp3pipeline_igate.obj') + PyTargetAdd('core.pyd', input='libp3event_igate.obj') + PyTargetAdd('core.pyd', input='libp3gobj_igate.obj') + PyTargetAdd('core.pyd', input='libp3gsgbase_igate.obj') + PyTargetAdd('core.pyd', input='libp3linmath_igate.obj') + PyTargetAdd('core.pyd', input='libp3mathutil_igate.obj') + PyTargetAdd('core.pyd', input='libp3parametrics_igate.obj') + PyTargetAdd('core.pyd', input='libp3pnmimage_igate.obj') + PyTargetAdd('core.pyd', input='libp3text_igate.obj') + PyTargetAdd('core.pyd', input='libp3tform_igate.obj') + PyTargetAdd('core.pyd', input='libp3putil_igate.obj') + PyTargetAdd('core.pyd', input='libp3audio_igate.obj') + PyTargetAdd('core.pyd', input='libp3pgui_igate.obj') + PyTargetAdd('core.pyd', input='libp3net_igate.obj') + PyTargetAdd('core.pyd', input='libp3nativenet_igate.obj') + PyTargetAdd('core.pyd', input='libp3dxml_igate.obj') if PkgSkip("FREETYPE")==0: - TargetAdd('core.pyd', input="libp3pnmtext_igate.obj") + PyTargetAdd('core.pyd', input="libp3pnmtext_igate.obj") - TargetAdd('core.pyd', input='p3pipeline_pythonThread.obj') - TargetAdd('core.pyd', input='p3putil_ext_composite.obj') - TargetAdd('core.pyd', input='p3pnmimage_pfmFile_ext.obj') - TargetAdd('core.pyd', input='p3event_asyncFuture_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') + PyTargetAdd('core.pyd', input='p3pipeline_pythonThread.obj') + PyTargetAdd('core.pyd', input='p3putil_ext_composite.obj') + PyTargetAdd('core.pyd', input='p3pnmimage_pfmFile_ext.obj') + PyTargetAdd('core.pyd', input='p3event_asyncFuture_ext.obj') + PyTargetAdd('core.pyd', input='p3event_pythonTask.obj') + PyTargetAdd('core.pyd', input='p3gobj_ext_composite.obj') + PyTargetAdd('core.pyd', input='p3pgraph_ext_composite.obj') + PyTargetAdd('core.pyd', input='p3display_graphicsStateGuardian_ext.obj') + PyTargetAdd('core.pyd', input='p3display_graphicsWindow_ext.obj') + PyTargetAdd('core.pyd', input='p3display_pythonGraphicsWindowProc.obj') - TargetAdd('core.pyd', input='core_module.obj') + PyTargetAdd('core.pyd', input='core_module.obj') if not GetLinkAllStatic() and GetTarget() != 'emscripten': - TargetAdd('core.pyd', input='libp3tinyxml.ilb') - TargetAdd('core.pyd', input='libp3interrogatedb.dll') - TargetAdd('core.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('core.pyd', opts=['PYTHON', 'WINSOCK2']) + PyTargetAdd('core.pyd', input='libp3tinyxml.ilb') + PyTargetAdd('core.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('core.pyd', input=COMMON_PANDA_LIBS) + PyTargetAdd('core.pyd', opts=['WINSOCK2']) # # DIRECTORY: panda/src/vision/ @@ -4359,22 +4316,21 @@ if (PkgSkip("VISION") == 0) and (not RUNTIME): TargetAdd('libp3vision.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3vision.dll', opts=OPTS) - OPTS=['DIR:panda/src/vision', 'ARTOOLKIT', 'OPENCV', 'DX9', 'DIRECTCAM', 'JPEG', 'EXCEPTIONS', 'PYTHON'] + OPTS=['DIR:panda/src/vision', 'ARTOOLKIT', 'OPENCV', 'DX9', 'DIRECTCAM', 'JPEG', 'EXCEPTIONS'] IGATEFILES=GetDirectoryContents('panda/src/vision', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3vision.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3vision.in', opts=['IMOD:panda3d.vision', 'ILIB:libp3vision', 'SRCDIR:panda/src/vision']) - TargetAdd('libp3vision_igate.obj', input='libp3vision.in', opts=["DEPENDENCYONLY"]) - TargetAdd('vision_module.obj', input='libp3vision.in') - TargetAdd('vision_module.obj', opts=OPTS) - TargetAdd('vision_module.obj', opts=['IMOD:panda3d.vision', 'ILIB:vision', 'IMPORT:panda3d.core']) - TargetAdd('vision.pyd', input='vision_module.obj') - TargetAdd('vision.pyd', input='libp3vision_igate.obj') - TargetAdd('vision.pyd', input='libp3vision.dll') - TargetAdd('vision.pyd', input='libp3interrogatedb.dll') - TargetAdd('vision.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('vision.pyd', opts=['PYTHON']) + PyTargetAdd('vision_module.obj', input='libp3vision.in') + PyTargetAdd('vision_module.obj', opts=OPTS) + PyTargetAdd('vision_module.obj', opts=['IMOD:panda3d.vision', 'ILIB:vision', 'IMPORT:panda3d.core']) + + PyTargetAdd('vision.pyd', input='vision_module.obj') + PyTargetAdd('vision.pyd', input='libp3vision_igate.obj') + PyTargetAdd('vision.pyd', input='libp3vision.dll') + PyTargetAdd('vision.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('vision.pyd', input=COMMON_PANDA_LIBS) # # DIRECTORY: panda/src/rocket/ @@ -4388,25 +4344,25 @@ if (PkgSkip("ROCKET") == 0) and (not RUNTIME): TargetAdd('libp3rocket.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3rocket.dll', opts=OPTS) - OPTS=['DIR:panda/src/rocket', 'ROCKET', 'RTTI', 'EXCEPTIONS', 'PYTHON'] + OPTS=['DIR:panda/src/rocket', 'ROCKET', 'RTTI', 'EXCEPTIONS'] IGATEFILES=GetDirectoryContents('panda/src/rocket', ["rocketInputHandler.h", "rocketInputHandler.cxx", "rocketRegion.h", "rocketRegion.cxx", "rocketRegion_ext.h"]) TargetAdd('libp3rocket.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3rocket.in', opts=['IMOD:panda3d.rocket', 'ILIB:libp3rocket', 'SRCDIR:panda/src/rocket']) - TargetAdd('libp3rocket_igate.obj', input='libp3rocket.in', opts=["DEPENDENCYONLY"]) - TargetAdd('p3rocket_rocketRegion_ext.obj', opts=OPTS, input='rocketRegion_ext.cxx') - TargetAdd('rocket_module.obj', input='libp3rocket.in') - TargetAdd('rocket_module.obj', opts=OPTS) - TargetAdd('rocket_module.obj', opts=['IMOD:panda3d.rocket', 'ILIB:rocket', 'IMPORT:panda3d.core']) + PyTargetAdd('p3rocket_rocketRegion_ext.obj', opts=OPTS, input='rocketRegion_ext.cxx') - TargetAdd('rocket.pyd', input='rocket_module.obj') - TargetAdd('rocket.pyd', input='libp3rocket_igate.obj') - TargetAdd('rocket.pyd', input='p3rocket_rocketRegion_ext.obj') - TargetAdd('rocket.pyd', input='libp3rocket.dll') - TargetAdd('rocket.pyd', input='libp3interrogatedb.dll') - TargetAdd('rocket.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('rocket.pyd', opts=['PYTHON', 'ROCKET']) + PyTargetAdd('rocket_module.obj', input='libp3rocket.in') + PyTargetAdd('rocket_module.obj', opts=OPTS) + PyTargetAdd('rocket_module.obj', opts=['IMOD:panda3d.rocket', 'ILIB:rocket', 'IMPORT:panda3d.core']) + + PyTargetAdd('rocket.pyd', input='rocket_module.obj') + PyTargetAdd('rocket.pyd', input='libp3rocket_igate.obj') + PyTargetAdd('rocket.pyd', input='p3rocket_rocketRegion_ext.obj') + PyTargetAdd('rocket.pyd', input='libp3rocket.dll') + PyTargetAdd('rocket.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('rocket.pyd', input=COMMON_PANDA_LIBS) + PyTargetAdd('rocket.pyd', opts=['ROCKET']) # # DIRECTORY: panda/src/p3awesomium @@ -4418,22 +4374,21 @@ if PkgSkip("AWESOMIUM") == 0 and not RUNTIME: TargetAdd('libp3awesomium.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3awesomium.dll', opts=OPTS) - OPTS=['DIR:panda/src/awesomium', 'AWESOMIUM', 'PYTHON'] + OPTS=['DIR:panda/src/awesomium', 'AWESOMIUM'] IGATEFILES=GetDirectoryContents('panda/src/awesomium', ["*.h", "*_composite1.cxx"]) TargetAdd('libp3awesomium.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3awesomium.in', opts=['IMOD:panda3d.awesomium', 'ILIB:libp3awesomium', 'SRCDIR:panda/src/awesomium']) - TargetAdd('libp3awesomium_igate.obj', input='libp3awesomium.in', opts=["DEPENDENCYONLY"]) - TargetAdd('awesomium_module.obj', input='libp3awesomium.in') - TargetAdd('awesomium_module.obj', opts=OPTS) - TargetAdd('awesomium_module.obj', opts=['IMOD:panda3d.awesomium', 'ILIB:awesomium', 'IMPORT:panda3d.core']) - TargetAdd('awesomium.pyd', input='awesomium_module.obj') - TargetAdd('awesomium.pyd', input='libp3awesomium_igate.obj') - TargetAdd('awesomium.pyd', input='libp3awesomium.dll') - TargetAdd('awesomium.pyd', input='libp3interrogatedb.dll') - TargetAdd('awesomium.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('awesomium.pyd', opts=['PYTHON']) + PyTargetAdd('awesomium_module.obj', input='libp3awesomium.in') + PyTargetAdd('awesomium_module.obj', opts=OPTS) + PyTargetAdd('awesomium_module.obj', opts=['IMOD:panda3d.awesomium', 'ILIB:awesomium', 'IMPORT:panda3d.core']) + + PyTargetAdd('awesomium.pyd', input='awesomium_module.obj') + PyTargetAdd('awesomium.pyd', input='libp3awesomium_igate.obj') + PyTargetAdd('awesomium.pyd', input='libp3awesomium.dll') + PyTargetAdd('awesomium.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('awesomium.pyd', input=COMMON_PANDA_LIBS) # # DIRECTORY: panda/src/p3skel @@ -4443,11 +4398,10 @@ if (PkgSkip('SKEL')==0) and (not RUNTIME): OPTS=['DIR:panda/src/skel', 'BUILDING:PANDASKEL', 'ADVAPI'] TargetAdd('p3skel_composite1.obj', opts=OPTS, input='p3skel_composite1.cxx') - OPTS=['DIR:panda/src/skel', 'ADVAPI', 'PYTHON'] + OPTS=['DIR:panda/src/skel', 'ADVAPI'] IGATEFILES=GetDirectoryContents("panda/src/skel", ["*.h", "*_composite*.cxx"]) TargetAdd('libp3skel.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3skel.in', opts=['IMOD:panda3d.skel', 'ILIB:libp3skel', 'SRCDIR:panda/src/skel']) - TargetAdd('libp3skel_igate.obj', input='libp3skel.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/p3skel @@ -4459,17 +4413,14 @@ if (PkgSkip('SKEL')==0) and (not RUNTIME): TargetAdd('libpandaskel.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaskel.dll', opts=OPTS) - OPTS=['PYTHON'] - TargetAdd('skel_module.obj', input='libp3skel.in') - TargetAdd('skel_module.obj', opts=OPTS) - TargetAdd('skel_module.obj', opts=['IMOD:panda3d.skel', 'ILIB:skel', 'IMPORT:panda3d.core']) + PyTargetAdd('skel_module.obj', input='libp3skel.in') + PyTargetAdd('skel_module.obj', opts=['IMOD:panda3d.skel', 'ILIB:skel', 'IMPORT:panda3d.core']) - TargetAdd('skel.pyd', input='skel_module.obj') - TargetAdd('skel.pyd', input='libp3skel_igate.obj') - TargetAdd('skel.pyd', input='libpandaskel.dll') - TargetAdd('skel.pyd', input='libp3interrogatedb.dll') - TargetAdd('skel.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('skel.pyd', opts=['PYTHON']) + PyTargetAdd('skel.pyd', input='skel_module.obj') + PyTargetAdd('skel.pyd', input='libp3skel_igate.obj') + PyTargetAdd('skel.pyd', input='libpandaskel.dll') + PyTargetAdd('skel.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('skel.pyd', input=COMMON_PANDA_LIBS) # # DIRECTORY: panda/src/distort/ @@ -4479,11 +4430,10 @@ if (PkgSkip('PANDAFX')==0) and (not RUNTIME): OPTS=['DIR:panda/src/distort', 'BUILDING:PANDAFX'] TargetAdd('p3distort_composite1.obj', opts=OPTS, input='p3distort_composite1.cxx') - OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'NVIDIACG', 'PYTHON'] + OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'NVIDIACG'] IGATEFILES=GetDirectoryContents('panda/src/distort', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3distort.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3distort.in', opts=['IMOD:panda3d.fx', 'ILIB:libp3distort', 'SRCDIR:panda/src/distort']) - TargetAdd('libp3distort_igate.obj', input='libp3distort.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/metalibs/pandafx/ @@ -4498,17 +4448,16 @@ if (PkgSkip('PANDAFX')==0) and (not RUNTIME): TargetAdd('libpandafx.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandafx.dll', opts=['ADVAPI', 'NVIDIACG']) - OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'NVIDIACG', 'PYTHON'] - TargetAdd('fx_module.obj', input='libp3distort.in') - TargetAdd('fx_module.obj', opts=OPTS) - TargetAdd('fx_module.obj', opts=['IMOD:panda3d.fx', 'ILIB:fx', 'IMPORT:panda3d.core']) + OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'NVIDIACG'] + PyTargetAdd('fx_module.obj', input='libp3distort.in') + PyTargetAdd('fx_module.obj', opts=OPTS) + PyTargetAdd('fx_module.obj', opts=['IMOD:panda3d.fx', 'ILIB:fx', 'IMPORT:panda3d.core']) - TargetAdd('fx.pyd', input='fx_module.obj') - TargetAdd('fx.pyd', input='libp3distort_igate.obj') - TargetAdd('fx.pyd', input='libpandafx.dll') - TargetAdd('fx.pyd', input='libp3interrogatedb.dll') - TargetAdd('fx.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('fx.pyd', opts=['PYTHON']) + PyTargetAdd('fx.pyd', input='fx_module.obj') + PyTargetAdd('fx.pyd', input='libp3distort_igate.obj') + PyTargetAdd('fx.pyd', input='libpandafx.dll') + PyTargetAdd('fx.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('fx.pyd', input=COMMON_PANDA_LIBS) # # DIRECTORY: panda/src/vrpn/ @@ -4521,22 +4470,21 @@ if (PkgSkip("VRPN")==0 and not RUNTIME): TargetAdd('libp3vrpn.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3vrpn.dll', opts=['VRPN']) - OPTS=['DIR:panda/src/vrpn', 'VRPN', 'PYTHON'] + OPTS=['DIR:panda/src/vrpn', 'VRPN'] IGATEFILES=GetDirectoryContents('panda/src/vrpn', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3vrpn.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3vrpn.in', opts=['IMOD:panda3d.vrpn', 'ILIB:libp3vrpn', 'SRCDIR:panda/src/vrpn']) - TargetAdd('libp3vrpn_igate.obj', input='libp3vrpn.in', opts=["DEPENDENCYONLY"]) - TargetAdd('vrpn_module.obj', input='libp3vrpn.in') - TargetAdd('vrpn_module.obj', opts=OPTS) - TargetAdd('vrpn_module.obj', opts=['IMOD:panda3d.vrpn', 'ILIB:vrpn', 'IMPORT:panda3d.core']) - TargetAdd('vrpn.pyd', input='vrpn_module.obj') - TargetAdd('vrpn.pyd', input='libp3vrpn_igate.obj') - TargetAdd('vrpn.pyd', input='libp3vrpn.dll') - TargetAdd('vrpn.pyd', input='libp3interrogatedb.dll') - TargetAdd('vrpn.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('vrpn.pyd', opts=['PYTHON']) + PyTargetAdd('vrpn_module.obj', input='libp3vrpn.in') + PyTargetAdd('vrpn_module.obj', opts=OPTS) + PyTargetAdd('vrpn_module.obj', opts=['IMOD:panda3d.vrpn', 'ILIB:vrpn', 'IMPORT:panda3d.core']) + + PyTargetAdd('vrpn.pyd', input='vrpn_module.obj') + PyTargetAdd('vrpn.pyd', input='libp3vrpn_igate.obj') + PyTargetAdd('vrpn.pyd', input='libp3vrpn.dll') + PyTargetAdd('vrpn.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('vrpn.pyd', input=COMMON_PANDA_LIBS) # # DIRECTORY: panda/src/ffmpeg @@ -4686,13 +4634,12 @@ if not RUNTIME and not PkgSkip("EGG"): TargetAdd('p3egg_composite1.obj', opts=OPTS, input='p3egg_composite1.cxx') TargetAdd('p3egg_composite2.obj', opts=OPTS, input='p3egg_composite2.cxx') - OPTS=['DIR:panda/src/egg', 'ZLIB', 'PYTHON'] + OPTS=['DIR:panda/src/egg', 'ZLIB'] IGATEFILES=GetDirectoryContents('panda/src/egg', ["*.h", "*_composite*.cxx"]) if "parser.h" in IGATEFILES: IGATEFILES.remove("parser.h") TargetAdd('libp3egg.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3egg.in', opts=['IMOD:panda3d.egg', 'ILIB:libp3egg', 'SRCDIR:panda/src/egg']) - TargetAdd('libp3egg_igate.obj', input='libp3egg.in', opts=["DEPENDENCYONLY"]) - TargetAdd('p3egg_eggGroupNode_ext.obj', opts=OPTS, input='eggGroupNode_ext.cxx') + PyTargetAdd('p3egg_eggGroupNode_ext.obj', opts=OPTS, input='eggGroupNode_ext.cxx') # # DIRECTORY: panda/src/egg2pg/ @@ -4703,11 +4650,10 @@ if not RUNTIME and not PkgSkip("EGG"): TargetAdd('p3egg2pg_composite1.obj', opts=OPTS, input='p3egg2pg_composite1.cxx') TargetAdd('p3egg2pg_composite2.obj', opts=OPTS, input='p3egg2pg_composite2.cxx') - OPTS=['DIR:panda/src/egg2pg', 'PYTHON'] + OPTS=['DIR:panda/src/egg2pg'] IGATEFILES=['load_egg_file.h'] TargetAdd('libp3egg2pg.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3egg2pg.in', opts=['IMOD:panda3d.egg', 'ILIB:libp3egg2pg', 'SRCDIR:panda/src/egg2pg']) - TargetAdd('libp3egg2pg_igate.obj', input='libp3egg2pg.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/framework/ @@ -4776,20 +4722,19 @@ if not RUNTIME and not PkgSkip("EGG"): TargetAdd('libpandaegg.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaegg.dll', opts=['ADVAPI']) - OPTS=['DIR:panda/metalibs/pandaegg', 'DIR:panda/src/egg', 'PYTHON'] - TargetAdd('egg_module.obj', input='libp3egg2pg.in') - TargetAdd('egg_module.obj', input='libp3egg.in') - TargetAdd('egg_module.obj', opts=OPTS) - TargetAdd('egg_module.obj', opts=['IMOD:panda3d.egg', 'ILIB:egg', 'IMPORT:panda3d.core']) + OPTS=['DIR:panda/metalibs/pandaegg', 'DIR:panda/src/egg'] + PyTargetAdd('egg_module.obj', input='libp3egg2pg.in') + PyTargetAdd('egg_module.obj', input='libp3egg.in') + PyTargetAdd('egg_module.obj', opts=OPTS) + PyTargetAdd('egg_module.obj', opts=['IMOD:panda3d.egg', 'ILIB:egg', 'IMPORT:panda3d.core']) - TargetAdd('egg.pyd', input='egg_module.obj') - TargetAdd('egg.pyd', input='p3egg_eggGroupNode_ext.obj') - TargetAdd('egg.pyd', input='libp3egg_igate.obj') - TargetAdd('egg.pyd', input='libp3egg2pg_igate.obj') - TargetAdd('egg.pyd', input='libpandaegg.dll') - TargetAdd('egg.pyd', input='libp3interrogatedb.dll') - TargetAdd('egg.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('egg.pyd', opts=['PYTHON']) + PyTargetAdd('egg.pyd', input='egg_module.obj') + PyTargetAdd('egg.pyd', input='p3egg_eggGroupNode_ext.obj') + PyTargetAdd('egg.pyd', input='libp3egg_igate.obj') + PyTargetAdd('egg.pyd', input='libp3egg2pg_igate.obj') + PyTargetAdd('egg.pyd', input='libpandaegg.dll') + PyTargetAdd('egg.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('egg.pyd', input=COMMON_PANDA_LIBS) # # DIRECTORY: panda/src/x11display/ @@ -4913,20 +4858,19 @@ if (PkgSkip("EGL")==0 and PkgSkip("GLES2")==0 and PkgSkip("X11")==0 and not RUNT # DIRECTORY: panda/src/ode/ # if (PkgSkip("ODE")==0 and not RUNTIME): - OPTS=['DIR:panda/src/ode', 'BUILDING:PANDAODE', 'ODE', 'PYTHON'] + OPTS=['DIR:panda/src/ode', 'BUILDING:PANDAODE', 'ODE'] TargetAdd('p3ode_composite1.obj', opts=OPTS, input='p3ode_composite1.cxx') TargetAdd('p3ode_composite2.obj', opts=OPTS, input='p3ode_composite2.cxx') TargetAdd('p3ode_composite3.obj', opts=OPTS, input='p3ode_composite3.cxx') - OPTS=['DIR:panda/src/ode', 'ODE', 'PYTHON'] + OPTS=['DIR:panda/src/ode', 'ODE'] IGATEFILES=GetDirectoryContents('panda/src/ode', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("odeConvexGeom.h") IGATEFILES.remove("odeHeightFieldGeom.h") IGATEFILES.remove("odeHelperStructs.h") TargetAdd('libpandaode.in', opts=OPTS, input=IGATEFILES) TargetAdd('libpandaode.in', opts=['IMOD:panda3d.ode', 'ILIB:libpandaode', 'SRCDIR:panda/src/ode']) - TargetAdd('libpandaode_igate.obj', input='libpandaode.in', opts=["DEPENDENCYONLY"]) - TargetAdd('p3ode_ext_composite.obj', opts=OPTS, input='p3ode_ext_composite.cxx') + PyTargetAdd('p3ode_ext_composite.obj', opts=OPTS, input='p3ode_ext_composite.cxx') # # DIRECTORY: panda/metalibs/pandaode/ @@ -4942,18 +4886,18 @@ if (PkgSkip("ODE")==0 and not RUNTIME): TargetAdd('libpandaode.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaode.dll', opts=['WINUSER', 'ODE']) - OPTS=['DIR:panda/metalibs/pandaode', 'ODE', 'PYTHON'] - TargetAdd('ode_module.obj', input='libpandaode.in') - TargetAdd('ode_module.obj', opts=OPTS) - TargetAdd('ode_module.obj', opts=['IMOD:panda3d.ode', 'ILIB:ode', 'IMPORT:panda3d.core']) + OPTS=['DIR:panda/metalibs/pandaode', 'ODE'] + PyTargetAdd('ode_module.obj', input='libpandaode.in') + PyTargetAdd('ode_module.obj', opts=OPTS) + PyTargetAdd('ode_module.obj', opts=['IMOD:panda3d.ode', 'ILIB:ode', 'IMPORT:panda3d.core']) - TargetAdd('ode.pyd', input='ode_module.obj') - TargetAdd('ode.pyd', input='libpandaode_igate.obj') - TargetAdd('ode.pyd', input='p3ode_ext_composite.obj') - TargetAdd('ode.pyd', input='libpandaode.dll') - TargetAdd('ode.pyd', input='libp3interrogatedb.dll') - TargetAdd('ode.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('ode.pyd', opts=['PYTHON', 'WINUSER', 'ODE']) + PyTargetAdd('ode.pyd', input='ode_module.obj') + PyTargetAdd('ode.pyd', input='libpandaode_igate.obj') + PyTargetAdd('ode.pyd', input='p3ode_ext_composite.obj') + PyTargetAdd('ode.pyd', input='libpandaode.dll') + PyTargetAdd('ode.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('ode.pyd', input=COMMON_PANDA_LIBS) + PyTargetAdd('ode.pyd', opts=['WINUSER', 'ODE']) # # DIRECTORY: panda/src/bullet/ @@ -4962,11 +4906,10 @@ if (PkgSkip("BULLET")==0 and not RUNTIME): OPTS=['DIR:panda/src/bullet', 'BUILDING:PANDABULLET', 'BULLET'] TargetAdd('p3bullet_composite.obj', opts=OPTS, input='p3bullet_composite.cxx') - OPTS=['DIR:panda/src/bullet', 'BULLET', 'PYTHON'] + OPTS=['DIR:panda/src/bullet', 'BULLET'] IGATEFILES=GetDirectoryContents('panda/src/bullet', ["*.h", "*_composite*.cxx"]) TargetAdd('libpandabullet.in', opts=OPTS, input=IGATEFILES) TargetAdd('libpandabullet.in', opts=['IMOD:panda3d.bullet', 'ILIB:libpandabullet', 'SRCDIR:panda/src/bullet']) - TargetAdd('libpandabullet_igate.obj', input='libpandabullet.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/metalibs/pandabullet/ @@ -4980,56 +4923,55 @@ if (PkgSkip("BULLET")==0 and not RUNTIME): TargetAdd('libpandabullet.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandabullet.dll', opts=['WINUSER', 'BULLET']) - OPTS=['DIR:panda/metalibs/pandabullet', 'BULLET', 'PYTHON'] - TargetAdd('bullet_module.obj', input='libpandabullet.in') - TargetAdd('bullet_module.obj', opts=OPTS) - TargetAdd('bullet_module.obj', opts=['IMOD:panda3d.bullet', 'ILIB:bullet', 'IMPORT:panda3d.core']) + OPTS=['DIR:panda/metalibs/pandabullet', 'BULLET'] + PyTargetAdd('bullet_module.obj', input='libpandabullet.in') + PyTargetAdd('bullet_module.obj', opts=OPTS) + PyTargetAdd('bullet_module.obj', opts=['IMOD:panda3d.bullet', 'ILIB:bullet', 'IMPORT:panda3d.core']) - TargetAdd('bullet.pyd', input='bullet_module.obj') - TargetAdd('bullet.pyd', input='libpandabullet_igate.obj') - TargetAdd('bullet.pyd', input='libpandabullet.dll') - TargetAdd('bullet.pyd', input='libp3interrogatedb.dll') - TargetAdd('bullet.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('bullet.pyd', opts=['PYTHON', 'WINUSER', 'BULLET']) + PyTargetAdd('bullet.pyd', input='bullet_module.obj') + PyTargetAdd('bullet.pyd', input='libpandabullet_igate.obj') + PyTargetAdd('bullet.pyd', input='libpandabullet.dll') + PyTargetAdd('bullet.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('bullet.pyd', input=COMMON_PANDA_LIBS) + PyTargetAdd('bullet.pyd', opts=['WINUSER', 'BULLET']) # # DIRECTORY: panda/src/physx/ # if (PkgSkip("PHYSX")==0): - OPTS=['DIR:panda/src/physx', 'BUILDING:PANDAPHYSX', 'PHYSX', 'NOARCH:PPC', 'PYTHON'] + OPTS=['DIR:panda/src/physx', 'BUILDING:PANDAPHYSX', 'PHYSX', 'NOARCH:PPC'] TargetAdd('p3physx_composite.obj', opts=OPTS, input='p3physx_composite.cxx') - OPTS=['DIR:panda/src/physx', 'PHYSX', 'NOARCH:PPC', 'PYTHON'] + OPTS=['DIR:panda/src/physx', 'PHYSX', 'NOARCH:PPC'] IGATEFILES=GetDirectoryContents('panda/src/physx', ["*.h", "*_composite*.cxx"]) TargetAdd('libpandaphysx.in', opts=OPTS, input=IGATEFILES) TargetAdd('libpandaphysx.in', opts=['IMOD:panda3d.physx', 'ILIB:libpandaphysx', 'SRCDIR:panda/src/physx']) - TargetAdd('libpandaphysx_igate.obj', input='libpandaphysx.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/metalibs/pandaphysx/ # if (PkgSkip("PHYSX")==0): - OPTS=['DIR:panda/metalibs/pandaphysx', 'BUILDING:PANDAPHYSX', 'PHYSX', 'NOARCH:PPC'] + OPTS=['DIR:panda/metalibs/pandaphysx', 'BUILDING:PANDAPHYSX', 'PHYSX', 'NOARCH:PPC', 'PYTHON'] TargetAdd('pandaphysx_pandaphysx.obj', opts=OPTS, input='pandaphysx.cxx') TargetAdd('libpandaphysx.dll', input='pandaphysx_pandaphysx.obj') TargetAdd('libpandaphysx.dll', input='p3physx_composite.obj') TargetAdd('libpandaphysx.dll', input=COMMON_PANDA_LIBS) - TargetAdd('libpandaphysx.dll', opts=['WINUSER', 'PHYSX', 'NOARCH:PPC', 'PYTHON']) + TargetAdd('libpandaphysx.dll', opts=['WINUSER', 'PHYSX', 'NOARCH:PPC']) - OPTS=['DIR:panda/metalibs/pandaphysx', 'PHYSX', 'NOARCH:PPC', 'PYTHON'] - TargetAdd('physx_module.obj', input='libpandaphysx.in') - TargetAdd('physx_module.obj', opts=OPTS) - TargetAdd('physx_module.obj', opts=['IMOD:panda3d.physx', 'ILIB:physx', 'IMPORT:panda3d.core']) + OPTS=['DIR:panda/metalibs/pandaphysx', 'PHYSX', 'NOARCH:PPC'] + PyTargetAdd('physx_module.obj', input='libpandaphysx.in') + PyTargetAdd('physx_module.obj', opts=OPTS) + PyTargetAdd('physx_module.obj', opts=['IMOD:panda3d.physx', 'ILIB:physx', 'IMPORT:panda3d.core']) - TargetAdd('physx.pyd', input='physx_module.obj') - TargetAdd('physx.pyd', input='libpandaphysx_igate.obj') - TargetAdd('physx.pyd', input='libpandaphysx.dll') - TargetAdd('physx.pyd', input='libp3interrogatedb.dll') - TargetAdd('physx.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('physx.pyd', opts=['PYTHON', 'WINUSER', 'PHYSX', 'NOARCH:PPC']) + PyTargetAdd('physx.pyd', input='physx_module.obj') + PyTargetAdd('physx.pyd', input='libpandaphysx_igate.obj') + PyTargetAdd('physx.pyd', input='libpandaphysx.dll') + PyTargetAdd('physx.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('physx.pyd', input=COMMON_PANDA_LIBS) + PyTargetAdd('physx.pyd', opts=['WINUSER', 'PHYSX', 'NOARCH:PPC']) # # DIRECTORY: panda/src/physics/ @@ -5040,12 +4982,11 @@ if (PkgSkip("PANDAPHYSICS")==0) and (not RUNTIME): TargetAdd('p3physics_composite1.obj', opts=OPTS, input='p3physics_composite1.cxx') TargetAdd('p3physics_composite2.obj', opts=OPTS, input='p3physics_composite2.cxx') - OPTS=['DIR:panda/src/physics', 'PYTHON'] + OPTS=['DIR:panda/src/physics'] IGATEFILES=GetDirectoryContents('panda/src/physics', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("forces.h") TargetAdd('libp3physics.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3physics.in', opts=['IMOD:panda3d.physics', 'ILIB:libp3physics', 'SRCDIR:panda/src/physics']) - TargetAdd('libp3physics_igate.obj', input='libp3physics.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/src/particlesystem/ @@ -5056,7 +4997,7 @@ if (PkgSkip("PANDAPHYSICS")==0) and (PkgSkip("PANDAPARTICLESYSTEM")==0) and (not TargetAdd('p3particlesystem_composite1.obj', opts=OPTS, input='p3particlesystem_composite1.cxx') TargetAdd('p3particlesystem_composite2.obj', opts=OPTS, input='p3particlesystem_composite2.cxx') - OPTS=['DIR:panda/src/particlesystem', 'PYTHON'] + OPTS=['DIR:panda/src/particlesystem'] IGATEFILES=GetDirectoryContents('panda/src/particlesystem', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove('orientedParticle.h') IGATEFILES.remove('orientedParticleFactory.h') @@ -5065,7 +5006,6 @@ if (PkgSkip("PANDAPHYSICS")==0) and (PkgSkip("PANDAPARTICLESYSTEM")==0) and (not IGATEFILES.remove('particles.h') TargetAdd('libp3particlesystem.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3particlesystem.in', opts=['IMOD:panda3d.physics', 'ILIB:libp3particlesystem', 'SRCDIR:panda/src/particlesystem']) - TargetAdd('libp3particlesystem_igate.obj', input='libp3particlesystem.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: panda/metalibs/pandaphysics/ @@ -5083,38 +5023,37 @@ if (PkgSkip("PANDAPHYSICS")==0) and (not RUNTIME): TargetAdd('libpandaphysics.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaphysics.dll', opts=['ADVAPI']) - OPTS=['DIR:panda/metalibs/pandaphysics', 'PYTHON'] - TargetAdd('physics_module.obj', input='libp3physics.in') + OPTS=['DIR:panda/metalibs/pandaphysics'] + PyTargetAdd('physics_module.obj', input='libp3physics.in') if (PkgSkip("PANDAPARTICLESYSTEM")==0): - TargetAdd('physics_module.obj', input='libp3particlesystem.in') - TargetAdd('physics_module.obj', opts=OPTS) - TargetAdd('physics_module.obj', opts=['IMOD:panda3d.physics', 'ILIB:physics', 'IMPORT:panda3d.core']) + PyTargetAdd('physics_module.obj', input='libp3particlesystem.in') + PyTargetAdd('physics_module.obj', opts=OPTS) + PyTargetAdd('physics_module.obj', opts=['IMOD:panda3d.physics', 'ILIB:physics', 'IMPORT:panda3d.core']) - TargetAdd('physics.pyd', input='physics_module.obj') - TargetAdd('physics.pyd', input='libp3physics_igate.obj') + PyTargetAdd('physics.pyd', input='physics_module.obj') + PyTargetAdd('physics.pyd', input='libp3physics_igate.obj') if (PkgSkip("PANDAPARTICLESYSTEM")==0): - TargetAdd('physics.pyd', input='libp3particlesystem_igate.obj') - TargetAdd('physics.pyd', input='libpandaphysics.dll') - TargetAdd('physics.pyd', input='libp3interrogatedb.dll') - TargetAdd('physics.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('physics.pyd', opts=['PYTHON']) + PyTargetAdd('physics.pyd', input='libp3particlesystem_igate.obj') + PyTargetAdd('physics.pyd', input='libpandaphysics.dll') + PyTargetAdd('physics.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('physics.pyd', input=COMMON_PANDA_LIBS) # # DIRECTORY: panda/src/speedtree/ # if (PkgSkip("SPEEDTREE")==0): - OPTS=['DIR:panda/src/speedtree', 'BUILDING:PANDASPEEDTREE', 'SPEEDTREE', 'PYTHON'] + OPTS=['DIR:panda/src/speedtree', 'BUILDING:PANDASPEEDTREE', 'SPEEDTREE'] TargetAdd('pandaspeedtree_composite1.obj', opts=OPTS, input='pandaspeedtree_composite1.cxx') IGATEFILES=GetDirectoryContents('panda/src/speedtree', ["*.h", "*_composite*.cxx"]) TargetAdd('libpandaspeedtree.in', opts=OPTS, input=IGATEFILES) TargetAdd('libpandaspeedtree.in', opts=['IMOD:libpandaspeedtree', 'ILIB:libpandaspeedtree', 'SRCDIR:panda/src/speedtree']) - TargetAdd('libpandaspeedtree_igate.obj', input='libpandaspeedtree.in', opts=["DEPENDENCYONLY"]) - TargetAdd('libpandaspeedtree_module.obj', input='libpandaspeedtree.in') - TargetAdd('libpandaspeedtree_module.obj', opts=OPTS) - TargetAdd('libpandaspeedtree_module.obj', opts=['IMOD:libpandaspeedtree', 'ILIB:libpandaspeedtree']) + + PyTargetAdd('libpandaspeedtree_module.obj', input='libpandaspeedtree.in') + PyTargetAdd('libpandaspeedtree_module.obj', opts=OPTS) + PyTargetAdd('libpandaspeedtree_module.obj', opts=['IMOD:libpandaspeedtree', 'ILIB:libpandaspeedtree']) TargetAdd('libpandaspeedtree.dll', input='pandaspeedtree_composite1.obj') - TargetAdd('libpandaspeedtree.dll', input='libpandaspeedtree_igate.obj') + PyTargetAdd('libpandaspeedtree.dll', input='libpandaspeedtree_igate.obj') TargetAdd('libpandaspeedtree.dll', input='libpandaspeedtree_module.obj') TargetAdd('libpandaspeedtree.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaspeedtree.dll', opts=['SPEEDTREE']) @@ -5177,7 +5116,7 @@ if (not RUNTIME and GetTarget() == 'android'): TargetAdd('libppython.dll', input='libp3framework.dll') TargetAdd('libppython.dll', input='libp3android.dll') TargetAdd('libppython.dll', input=COMMON_PANDA_LIBS) - TargetAdd('libppython.dll', opts=['MODULE', 'ANDROID', 'PYTHON']) + TargetAdd('libppython.dll', opts=['MODULE', 'ANDROID']) # # DIRECTORY: panda/src/androiddisplay/ @@ -5234,7 +5173,7 @@ if (not RUNTIME and (GetTarget() in ('windows', 'darwin') or PkgSkip("X11")==0) # if (PkgSkip("DIRECT")==0): - OPTS=['DIR:direct/src/directbase', 'PYTHON'] + OPTS=['DIR:direct/src/directbase'] TargetAdd('p3directbase_directbase.obj', opts=OPTS+['BUILDING:DIRECT'], input='directbase.cxx') # @@ -5242,21 +5181,20 @@ if (PkgSkip("DIRECT")==0): # if (PkgSkip("DIRECT")==0): - OPTS=['DIR:direct/src/dcparser', 'BUILDING:DIRECT_DCPARSER', 'WITHINPANDA', 'BISONPREFIX_dcyy', 'PYTHON'] + OPTS=['DIR:direct/src/dcparser', 'BUILDING:DIRECT_DCPARSER', 'WITHINPANDA', 'BISONPREFIX_dcyy'] CreateFile(GetOutputDir()+"/include/dcParser.h") - TargetAdd('p3dcparser_dcParser.obj', opts=OPTS, input='dcParser.yxx') - TargetAdd('dcParser.h', input='p3dcparser_dcParser.obj', opts=['DEPENDENCYONLY']) - 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') + PyTargetAdd('p3dcparser_dcParser.obj', opts=OPTS, input='dcParser.yxx') + #TargetAdd('dcParser.h', input='p3dcparser_dcParser.obj', opts=['DEPENDENCYONLY']) + PyTargetAdd('p3dcparser_dcLexer.obj', opts=OPTS, input='dcLexer.lxx') + PyTargetAdd('p3dcparser_composite1.obj', opts=OPTS, input='p3dcparser_composite1.cxx') + PyTargetAdd('p3dcparser_composite2.obj', opts=OPTS, input='p3dcparser_composite2.cxx') - OPTS=['DIR:direct/src/dcparser', 'WITHINPANDA', 'PYTHON'] + 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') TargetAdd('libp3dcparser.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3dcparser.in', opts=['IMOD:panda3d.direct', 'ILIB:libp3dcparser', 'SRCDIR:direct/src/dcparser']) - TargetAdd('libp3dcparser_igate.obj', input='libp3dcparser.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: direct/src/deadrec/ @@ -5266,27 +5204,25 @@ 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', 'PYTHON'] + 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']) - TargetAdd('libp3deadrec_igate.obj', input='libp3deadrec.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: direct/src/distributed/ # if (PkgSkip("DIRECT")==0): - OPTS=['DIR:direct/src/distributed', 'DIR:direct/src/dcparser', 'WITHINPANDA', 'BUILDING:DIRECT', 'OPENSSL', 'PYTHON'] + OPTS=['DIR:direct/src/distributed', 'DIR:direct/src/dcparser', 'WITHINPANDA', 'BUILDING:DIRECT', 'OPENSSL'] 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') + PyTargetAdd('p3distributed_cConnectionRepository.obj', opts=OPTS, input='cConnectionRepository.cxx') + PyTargetAdd('p3distributed_cDistributedSmoothNodeBase.obj', opts=OPTS, input='cDistributedSmoothNodeBase.cxx') - OPTS=['DIR:direct/src/distributed', 'WITHINPANDA', 'OPENSSL', 'PYTHON'] + 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']) - TargetAdd('libp3distributed_igate.obj', input='libp3distributed.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: direct/src/interval/ @@ -5296,11 +5232,10 @@ 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', 'PYTHON'] + 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']) - TargetAdd('libp3interval_igate.obj', input='libp3interval.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: direct/src/showbase/ @@ -5312,11 +5247,10 @@ if (PkgSkip("DIRECT")==0): if GetTarget() == 'darwin': TargetAdd('p3showbase_showBase_assist.obj', opts=OPTS, input='showBase_assist.mm') - OPTS=['DIR:direct/src/showbase', 'PYTHON'] + 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']) - TargetAdd('libp3showbase_igate.obj', input='libp3showbase.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: direct/src/motiontrail/ @@ -5327,11 +5261,10 @@ if (PkgSkip("DIRECT")==0): TargetAdd('p3motiontrail_cMotionTrail.obj', opts=OPTS, input='cMotionTrail.cxx') TargetAdd('p3motiontrail_config_motiontrail.obj', opts=OPTS, input='config_motiontrail.cxx') - OPTS=['DIR:direct/src/motiontrail', 'PYTHON'] + OPTS=['DIR:direct/src/motiontrail'] IGATEFILES=GetDirectoryContents('direct/src/motiontrail', ["*.h", "cMotionTrail.cxx"]) TargetAdd('libp3motiontrail.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3motiontrail.in', opts=['IMOD:panda3d.direct', 'ILIB:libp3motiontrail', 'SRCDIR:direct/src/motiontrail']) - TargetAdd('libp3motiontrail_igate.obj', input='libp3motiontrail.in', opts=["DEPENDENCYONLY"]) # # DIRECTORY: direct/metalibs/direct/ @@ -5349,56 +5282,54 @@ if (PkgSkip("DIRECT")==0): TargetAdd('libp3direct.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3direct.dll', opts=['ADVAPI', 'OPENSSL', 'WINUSER', 'WINGDI']) - OPTS=['PYTHON'] - TargetAdd('direct_module.obj', input='libp3dcparser.in') - TargetAdd('direct_module.obj', input='libp3showbase.in') - TargetAdd('direct_module.obj', input='libp3deadrec.in') - TargetAdd('direct_module.obj', input='libp3interval.in') - TargetAdd('direct_module.obj', input='libp3distributed.in') - TargetAdd('direct_module.obj', input='libp3motiontrail.in') - TargetAdd('direct_module.obj', opts=OPTS) - TargetAdd('direct_module.obj', opts=['IMOD:panda3d.direct', 'ILIB:direct', 'IMPORT:panda3d.core']) + PyTargetAdd('direct_module.obj', input='libp3dcparser.in') + PyTargetAdd('direct_module.obj', input='libp3showbase.in') + PyTargetAdd('direct_module.obj', input='libp3deadrec.in') + PyTargetAdd('direct_module.obj', input='libp3interval.in') + PyTargetAdd('direct_module.obj', input='libp3distributed.in') + PyTargetAdd('direct_module.obj', input='libp3motiontrail.in') + PyTargetAdd('direct_module.obj', opts=['IMOD:panda3d.direct', 'ILIB:direct', 'IMPORT:panda3d.core']) - 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='libp3motiontrail_igate.obj') + PyTargetAdd('direct.pyd', input='libp3dcparser_igate.obj') + PyTargetAdd('direct.pyd', input='libp3showbase_igate.obj') + PyTargetAdd('direct.pyd', input='libp3deadrec_igate.obj') + PyTargetAdd('direct.pyd', input='libp3interval_igate.obj') + PyTargetAdd('direct.pyd', input='libp3distributed_igate.obj') + PyTargetAdd('direct.pyd', input='libp3motiontrail_igate.obj') # These are part of direct.pyd, not libp3direct.dll, because they rely on # the Python libraries. If a C++ user needs these modules, we can move them # back and filter out the Python-specific code. - TargetAdd('direct.pyd', input='p3dcparser_composite1.obj') - TargetAdd('direct.pyd', input='p3dcparser_composite2.obj') - TargetAdd('direct.pyd', input='p3dcparser_dcParser.obj') - TargetAdd('direct.pyd', input='p3dcparser_dcLexer.obj') - TargetAdd('direct.pyd', input='p3distributed_config_distributed.obj') - TargetAdd('direct.pyd', input='p3distributed_cConnectionRepository.obj') - TargetAdd('direct.pyd', input='p3distributed_cDistributedSmoothNodeBase.obj') + PyTargetAdd('direct.pyd', input='p3dcparser_composite1.obj') + PyTargetAdd('direct.pyd', input='p3dcparser_composite2.obj') + PyTargetAdd('direct.pyd', input='p3dcparser_dcParser.obj') + PyTargetAdd('direct.pyd', input='p3dcparser_dcLexer.obj') + PyTargetAdd('direct.pyd', input='p3distributed_config_distributed.obj') + PyTargetAdd('direct.pyd', input='p3distributed_cConnectionRepository.obj') + PyTargetAdd('direct.pyd', input='p3distributed_cDistributedSmoothNodeBase.obj') - TargetAdd('direct.pyd', input='direct_module.obj') - TargetAdd('direct.pyd', input='libp3direct.dll') - TargetAdd('direct.pyd', input='libp3interrogatedb.dll') - TargetAdd('direct.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('direct.pyd', opts=['PYTHON', 'OPENSSL', 'WINUSER', 'WINGDI', 'WINSOCK2']) + PyTargetAdd('direct.pyd', input='direct_module.obj') + PyTargetAdd('direct.pyd', input='libp3direct.dll') + PyTargetAdd('direct.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('direct.pyd', input=COMMON_PANDA_LIBS) + PyTargetAdd('direct.pyd', opts=['OPENSSL', 'WINUSER', 'WINGDI', 'WINSOCK2']) # # DIRECTORY: direct/src/dcparse/ # if (PkgSkip("PYTHON")==0 and PkgSkip("DIRECT")==0 and not RTDIST and not RUNTIME): - OPTS=['DIR:direct/src/dcparse', 'DIR:direct/src/dcparser', 'WITHINPANDA', 'ADVAPI', 'PYTHON'] - TargetAdd('dcparse_dcparse.obj', opts=OPTS, input='dcparse.cxx') - TargetAdd('p3dcparse.exe', input='p3dcparser_composite1.obj') - TargetAdd('p3dcparse.exe', input='p3dcparser_composite2.obj') - TargetAdd('p3dcparse.exe', input='p3dcparser_dcParser.obj') - TargetAdd('p3dcparse.exe', input='p3dcparser_dcLexer.obj') - TargetAdd('p3dcparse.exe', input='dcparse_dcparse.obj') - TargetAdd('p3dcparse.exe', input='libp3direct.dll') - TargetAdd('p3dcparse.exe', input=COMMON_PANDA_LIBS) - TargetAdd('p3dcparse.exe', input='libp3pystub.lib') - TargetAdd('p3dcparse.exe', opts=['ADVAPI', 'PYTHON']) + OPTS=['DIR:direct/src/dcparse', 'DIR:direct/src/dcparser', 'WITHINPANDA', 'ADVAPI'] + PyTargetAdd('dcparse_dcparse.obj', opts=OPTS, input='dcparse.cxx') + PyTargetAdd('p3dcparse.exe', input='p3dcparser_composite1.obj') + PyTargetAdd('p3dcparse.exe', input='p3dcparser_composite2.obj') + PyTargetAdd('p3dcparse.exe', input='p3dcparser_dcParser.obj') + PyTargetAdd('p3dcparse.exe', input='p3dcparser_dcLexer.obj') + PyTargetAdd('p3dcparse.exe', input='dcparse_dcparse.obj') + PyTargetAdd('p3dcparse.exe', input='libp3direct.dll') + PyTargetAdd('p3dcparse.exe', input=COMMON_PANDA_LIBS) + PyTargetAdd('p3dcparse.exe', input='libp3pystub.lib') + PyTargetAdd('p3dcparse.exe', opts=['ADVAPI']) # # DIRECTORY: direct/src/plugin/ @@ -5447,7 +5378,7 @@ if (RTDIST or RUNTIME): if (PkgSkip("PYTHON")==0 and RTDIST): # Freeze VFSImporter and its dependency modules into p3dpython. # Mark panda3d.core as a dependency to make sure to build that first. - TargetAdd('p3dpython_frozen.obj', input='VFSImporter.py', opts=['DIR:direct/src/showbase', 'FREEZE_STARTUP', 'PYTHON']) + TargetAdd('p3dpython_frozen.obj', input='VFSImporter.py', opts=['DIR:direct/src/showbase', 'FREEZE_STARTUP']) TargetAdd('p3dpython_frozen.obj', dep='core.pyd') OPTS += ['PYTHON'] @@ -5479,7 +5410,7 @@ if (RTDIST or RUNTIME): TargetAdd('p3dpythonw.exe', input=COMMON_PANDA_LIBS) TargetAdd('p3dpythonw.exe', input='libp3tinyxml.ilb') TargetAdd('p3dpythonw.exe', input='libp3interrogatedb.dll') - TargetAdd('p3dpythonw.exe', opts=['SUBSYSTEM:WINDOWS', 'PYTHON', 'WINUSER']) + TargetAdd('p3dpythonw.exe', opts=['SUBSYSTEM:WINDOWS', 'WINUSER']) if (PkgSkip("OPENSSL")==0 and RTDIST and False): OPTS=['DIR:direct/src/plugin', 'DIR:panda/src/express', 'OPENSSL'] @@ -6570,45 +6501,41 @@ if (PkgSkip("CONTRIB")==0 and not RUNTIME): TargetAdd('libpandaai.dll', input='p3ai_composite1.obj') TargetAdd('libpandaai.dll', input=COMMON_PANDA_LIBS) - OPTS=['DIR:contrib/src/ai', 'PYTHON'] + OPTS=['DIR:contrib/src/ai'] IGATEFILES=GetDirectoryContents('contrib/src/ai', ["*.h", "*_composite*.cxx"]) TargetAdd('libpandaai.in', opts=OPTS, input=IGATEFILES) TargetAdd('libpandaai.in', opts=['IMOD:panda3d.ai', 'ILIB:libpandaai', 'SRCDIR:contrib/src/ai']) - TargetAdd('libpandaai_igate.obj', input='libpandaai.in', opts=["DEPENDENCYONLY"]) - TargetAdd('ai_module.obj', input='libpandaai.in') - TargetAdd('ai_module.obj', opts=OPTS) - TargetAdd('ai_module.obj', opts=['IMOD:panda3d.ai', 'ILIB:ai', 'IMPORT:panda3d.core']) + PyTargetAdd('ai_module.obj', input='libpandaai.in') + PyTargetAdd('ai_module.obj', opts=OPTS) + PyTargetAdd('ai_module.obj', opts=['IMOD:panda3d.ai', 'ILIB:ai', 'IMPORT:panda3d.core']) - TargetAdd('ai.pyd', input='ai_module.obj') - TargetAdd('ai.pyd', input='libpandaai_igate.obj') - TargetAdd('ai.pyd', input='libpandaai.dll') - TargetAdd('ai.pyd', input='libp3interrogatedb.dll') - TargetAdd('ai.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('ai.pyd', opts=['PYTHON']) + PyTargetAdd('ai.pyd', input='ai_module.obj') + PyTargetAdd('ai.pyd', input='libpandaai_igate.obj') + PyTargetAdd('ai.pyd', input='libpandaai.dll') + PyTargetAdd('ai.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('ai.pyd', input=COMMON_PANDA_LIBS) # # DIRECTORY: contrib/src/rplight/ # if not PkgSkip("CONTRIB") and not PkgSkip("PYTHON") and not RUNTIME: - OPTS=['DIR:contrib/src/rplight', 'BUILDING:RPLIGHT', 'PYTHON'] + OPTS=['DIR:contrib/src/rplight', 'BUILDING:RPLIGHT'] TargetAdd('p3rplight_composite1.obj', opts=OPTS, input='p3rplight_composite1.cxx') IGATEFILES=GetDirectoryContents('contrib/src/rplight', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3rplight.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3rplight.in', opts=['IMOD:panda3d._rplight', 'ILIB:libp3rplight', 'SRCDIR:contrib/src/rplight']) - TargetAdd('libp3rplight_igate.obj', input='libp3rplight.in', opts=["DEPENDENCYONLY"]) - TargetAdd('rplight_module.obj', input='libp3rplight.in') - TargetAdd('rplight_module.obj', opts=OPTS) - TargetAdd('rplight_module.obj', opts=['IMOD:panda3d._rplight', 'ILIB:_rplight', 'IMPORT:panda3d.core']) + PyTargetAdd('rplight_module.obj', input='libp3rplight.in') + PyTargetAdd('rplight_module.obj', opts=OPTS) + PyTargetAdd('rplight_module.obj', opts=['IMOD:panda3d._rplight', 'ILIB:_rplight', 'IMPORT:panda3d.core']) - TargetAdd('_rplight.pyd', input='rplight_module.obj') - TargetAdd('_rplight.pyd', input='libp3rplight_igate.obj') - TargetAdd('_rplight.pyd', input='p3rplight_composite1.obj') - TargetAdd('_rplight.pyd', input='libp3interrogatedb.dll') - TargetAdd('_rplight.pyd', input=COMMON_PANDA_LIBS) - TargetAdd('_rplight.pyd', opts=['PYTHON']) + PyTargetAdd('_rplight.pyd', input='rplight_module.obj') + PyTargetAdd('_rplight.pyd', input='libp3rplight_igate.obj') + PyTargetAdd('_rplight.pyd', input='p3rplight_composite1.obj') + PyTargetAdd('_rplight.pyd', input='libp3interrogatedb.dll') + PyTargetAdd('_rplight.pyd', input=COMMON_PANDA_LIBS) # # Generate the models directory and samples directory @@ -6876,6 +6803,7 @@ def MakeInstallerNSIS(file, title, installdir): 'SOURCE' : '..', 'PYVER' : SDK["PYTHONVERSION"][6:9], 'REGVIEW' : regview, + 'EXT_SUFFIX' : GetExtensionSuffix(), } if GetHost() == 'windows': @@ -6887,7 +6815,7 @@ def MakeInstallerNSIS(file, title, installdir): for item in nsis_defs.items(): cmd += ' -D%s="%s"' % item - cmd += ' "makepanda\installer.nsi"' + cmd += ' "makepanda\\installer.nsi"' oscmd(cmd) def MakeDebugSymbolArchive(zipname, dirname): @@ -7288,8 +7216,9 @@ def MakeInstallerOSX(): if ((base != "extensions") and (base != "extensions_native")): compileall.compile_dir("dstroot/pythoncode/Developer/Panda3D/direct/"+base) + suffix = GetExtensionSuffix() for base in os.listdir(GetOutputDir()+"/panda3d"): - if base.endswith('.py') or base.endswith('.so'): + if base.endswith('.py') or (base.endswith(suffix) and '.' not in base[:-len(suffix)]): libname = "dstroot/pythoncode/Developer/Panda3D/panda3d/" + base # We really need to specify -R in order not to follow symlinks # On OSX, just specifying -P is not enough to do that. @@ -7577,8 +7506,9 @@ def MakeInstallerAndroid(): if not base.endswith(suffix): continue modname = base[:-len(suffix)] - source = os.path.join(source_dir, base) - copy_library(source, "libpy.panda3d.{}.so".format(modname)) + if '.' not in modname: + source = os.path.join(source_dir, base) + copy_library(source, "libpy.panda3d.{}.so".format(modname)) # Same for standard Python modules. import _ctypes diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index cf89b85e59..7d19a00a19 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -3239,6 +3239,8 @@ def WriteEmbeddedStringFile(basename, inputs, string_name=None): ######################################################################## ORIG_EXT = {} +PYABI_SPECIFIC = set() +WARNED_FILES = set() def GetOrigExt(x): return ORIG_EXT[x] @@ -3249,14 +3251,42 @@ def SetOrigExt(x, v): def GetExtensionSuffix(): if sys.version_info >= (3, 0): suffix = sysconfig.get_config_var('EXT_SUFFIX') - if suffix: + if suffix == '.so': + # On my FreeBSD system, this is not set correctly, but SOABI is. + soabi = sysconfig.get_config_var('SOABI') + if soabi: + return '.%s.so' % (soabi) + elif suffix: return suffix + target = GetTarget() if target == 'windows': return '.pyd' else: return '.so' +def GetPythonABI(): + soabi = sysconfig.get_config_var('SOABI') + if soabi: + return soabi + + soabi = 'cpython-%d%d' % (sys.version_info[:2]) + + debug_flag = sysconfig.get_config_var('Py_DEBUG') + if (debug_flag is None and hasattr(sys, 'gettotalrefcount')) or debug_flag: + soabi += 'd' + + malloc_flag = sysconfig.get_config_var('WITH_PYMALLOC') + if malloc_flag is None or malloc_flag: + soabi += 'm' + + if sys.version_info < (3, 3): + usize = sysconfig.get_config_var('Py_UNICODE_SIZE') + if (usize is None and sys.maxunicode == 0x10ffff) or usize == 4: + soabi += 'u' + + return soabi + def CalcLocation(fn, ipath): if fn.startswith("panda3d/") and fn.endswith(".py"): return OUTPUTDIR + "/" + fn @@ -3327,11 +3357,25 @@ def CalcLocation(fn, ipath): return fn -def FindLocation(fn, ipath): +def FindLocation(fn, ipath, pyabi=None): if (GetLinkAllStatic() and fn.endswith(".dll")): fn = fn[:-4] + ".lib" loc = CalcLocation(fn, ipath) base, ext = os.path.splitext(fn) + + # If this is a target created with PyTargetAdd, we need to make sure it + # it put in a Python-version-specific directory. + if loc in PYABI_SPECIFIC: + if loc.startswith(OUTPUTDIR + "/tmp"): + if pyabi is not None: + loc = OUTPUTDIR + "/tmp/" + pyabi + loc[len(OUTPUTDIR) + 4:] + else: + raise RuntimeError("%s is a Python-specific target, use PyTargetAdd instead of TargetAdd" % (fn)) + + elif ext != ".pyd" and loc not in WARNED_FILES: + WARNED_FILES.add(loc) + print("%sWARNING:%s file depends on Python but is not in an ABI-specific directory: %s%s%s" % (GetColor("red"), GetColor(), GetColor("green"), loc, GetColor())) + ORIG_EXT[loc] = ext return loc @@ -3377,6 +3421,11 @@ def FindLocation(fn, ipath): ## be inserted: bison generates an OBJ and a secondary header ## file, interrogate generates an IN and a secondary IGATE.OBJ. ## +## PyTargetAdd is a special version for targets that depend on Python. +## It will create a target for each Python version we are building with, +## ensuring that builds with different Python versions won't conflict +## when we build for multiple Python ABIs side-by-side. +## ######################################################################## class Target: @@ -3385,7 +3434,7 @@ class Target: TARGET_LIST = [] TARGET_TABLE = {} -def TargetAdd(target, dummy=0, opts=[], input=[], dep=[], ipath=None, winrc=None): +def TargetAdd(target, dummy=0, opts=[], input=[], dep=[], ipath=None, winrc=None, pyabi=None): if (dummy != 0): exit("Syntax error in TargetAdd "+target) if ipath is None: ipath = opts @@ -3393,11 +3442,10 @@ def TargetAdd(target, dummy=0, opts=[], input=[], dep=[], ipath=None, winrc=None if (type(input) == str): input = [input] if (type(dep) == str): dep = [dep] - if os.path.splitext(target)[1] == '.pyd' and PkgSkip("PYTHON"): - # It makes no sense to build Python modules with python disabled. - return + if target.endswith(".pyd") and not pyabi: + raise RuntimeError("Use PyTargetAdd to build .pyd targets") - full = FindLocation(target, [OUTPUTDIR + "/include"]) + full = FindLocation(target, [OUTPUTDIR + "/include"], pyabi=pyabi) if (full not in TARGET_TABLE): t = Target() @@ -3416,7 +3464,7 @@ def TargetAdd(target, dummy=0, opts=[], input=[], dep=[], ipath=None, winrc=None ipath = [OUTPUTDIR + "/tmp"] + GetListOption(ipath, "DIR:") + [OUTPUTDIR+"/include"] for x in input: - fullinput = FindLocation(x, ipath) + fullinput = FindLocation(x, ipath, pyabi=pyabi) t.inputs.append(fullinput) # Don't re-link a library or binary if just its dependency dlls have been altered. # This should work out fine in most cases, and often reduces recompilation time. @@ -3455,7 +3503,7 @@ def TargetAdd(target, dummy=0, opts=[], input=[], dep=[], ipath=None, winrc=None t.deps[fulln] = 1 for x in dep: - fulldep = FindLocation(x, ipath) + fulldep = FindLocation(x, ipath, pyabi=pyabi) t.deps[fulldep] = 1 if winrc and GetTarget() == 'windows': @@ -3472,3 +3520,32 @@ def TargetAdd(target, dummy=0, opts=[], input=[], dep=[], ipath=None, winrc=None if target.endswith(".pz") and not CrossCompiling(): t.deps[FindLocation("pzip.exe", [])] = 1 + + if target.endswith(".in"): + # Also add a target to compile the _igate.cxx file into an _igate.obj. + outbase = os.path.basename(target)[:-3] + woutc = OUTPUTDIR + "/tmp/" + outbase + "_igate.cxx" + CxxDependencyCache[woutc] = [] + PyTargetAdd(outbase + "_igate.obj", opts=opts+['PYTHON','BIGOBJ'], input=woutc, dep=target) + + +def PyTargetAdd(target, opts=[], **kwargs): + if PkgSkip("PYTHON"): + return + + if 'PYTHON' not in opts: + opts = opts + ['PYTHON'] + + abi = GetPythonABI() + + MakeDirectory(OUTPUTDIR + "/tmp/" + abi) + + # Mark this target as being a Python-specific target. + orig = CalcLocation(target, [OUTPUTDIR + "/include"]) + PYABI_SPECIFIC.add(orig) + + if orig.startswith(OUTPUTDIR + "/tmp/") and os.path.exists(orig): + print("Removing file %s" % (orig)) + os.unlink(orig) + + TargetAdd(target, opts=opts, pyabi=abi, **kwargs) diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index 74ee15d7f1..b74ad0116d 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -498,7 +498,7 @@ __version__ = '{0}' for file in os.listdir(panda3d_dir): if file == '__init__.py': pass - elif file.endswith(ext_suffix) or file.endswith('.py'): + elif file.endswith('.py') or (file.endswith(ext_suffix) and '.' not in file[:-len(ext_suffix)]): source_path = os.path.join(panda3d_dir, file) if file.endswith('.pyd') and platform.startswith('cygwin'): From 6e8cb98861c28110e065cc4e1709d90f98708a39 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Nov 2018 20:32:37 +0100 Subject: [PATCH 305/360] dtoolbase: fix compile errors with --no-python --- dtool/src/dtoolbase/dtoolbase.h | 2 -- dtool/src/dtoolbase/typeHandle.cxx | 2 ++ dtool/src/dtoolbase/typeHandle.h | 2 ++ dtool/src/dtoolbase/typeRegistry.cxx | 2 ++ dtool/src/dtoolbase/typeRegistry.h | 2 ++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 2f8e7ca05d..66142427cc 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -138,12 +138,10 @@ #endif #endif -#ifdef HAVE_PYTHON // Instead of including the Python headers, which will implicitly add a linker // flag to link in Python, we'll just excerpt the forward declaration of // PyObject. typedef struct _object PyObject; -#endif #ifndef HAVE_EIGEN // If we don't have the Eigen library, don't define LINMATH_ALIGN. diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index 30d499bf01..c72c3f9d99 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -153,6 +153,7 @@ deallocate_array(void *ptr) { PANDA_FREE_ARRAY(ptr); } +#ifdef HAVE_PYTHON /** * Returns the internal void pointer that is stored for interrogate's benefit. */ @@ -165,6 +166,7 @@ get_python_type() const { return nullptr; } } +#endif /** * Return the Index of the BEst fit Classs from a set diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index ed5ab3f586..094d4abf4a 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -138,7 +138,9 @@ PUBLISHED: MAKE_SEQ_PROPERTY(child_classes, get_num_child_classes, get_child_class); public: +#ifdef HAVE_PYTHON PyObject *get_python_type() const; +#endif void *allocate_array(size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); void *reallocate_array(void *ptr, size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); diff --git a/dtool/src/dtoolbase/typeRegistry.cxx b/dtool/src/dtoolbase/typeRegistry.cxx index d18ca61244..360dfcd9e4 100644 --- a/dtool/src/dtoolbase/typeRegistry.cxx +++ b/dtool/src/dtoolbase/typeRegistry.cxx @@ -207,6 +207,7 @@ record_alternate_name(TypeHandle type, const string &name) { _lock->unlock(); } +#ifdef HAVE_PYTHON /** * Records the given Python type pointer in the type registry for the benefit * of interrogate. @@ -222,6 +223,7 @@ record_python_type(TypeHandle type, PyObject *python_type) { _lock->unlock(); } +#endif /** * Looks for a previously-registered type of the given name. Returns its diff --git a/dtool/src/dtoolbase/typeRegistry.h b/dtool/src/dtoolbase/typeRegistry.h index 4a6bd5d1e0..43b1b8e41f 100644 --- a/dtool/src/dtoolbase/typeRegistry.h +++ b/dtool/src/dtoolbase/typeRegistry.h @@ -45,7 +45,9 @@ PUBLISHED: void record_derivation(TypeHandle child, TypeHandle parent); void record_alternate_name(TypeHandle type, const std::string &name); +#ifdef HAVE_PYTHON void record_python_type(TypeHandle type, PyObject *python_type); +#endif TypeHandle find_type(const std::string &name) const; TypeHandle find_type_by_id(int id) const; From cb2329b3f1c3094fed5122bc05003d31984b8a43 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Nov 2018 20:32:52 +0100 Subject: [PATCH 306/360] travis: add build with --no-python --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 728367f785..64cc557d5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,8 @@ matrix: before_install: - export CC=gcc-4.7 - export CXX=g++-4.7 + - compiler: clang + env: PYTHONV=python3 FLAGS=--no-python SKIP_TESTS=1 addons: apt: sources: @@ -42,8 +44,8 @@ install: - $PYTHONV -m pip install pytest script: - $PYTHONV makepanda/makepanda.py --everything --git-commit $TRAVIS_COMMIT $FLAGS --threads 4 - - LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV makepanda/test_imports.py - - LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV -m pytest -v tests + - test -n "$SKIP_TESTS" || LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV makepanda/test_imports.py + - test -n "$SKIP_TESTS" || LD_LIBRARY_PATH=built/lib PYTHONPATH=built $PYTHONV -m pytest -v tests notifications: irc: channels: From 98e767c3709e406f5ada64463578cc69c6cc9495 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Nov 2018 20:33:56 +0100 Subject: [PATCH 307/360] fmod: fix FmodAudioSound::get_speaker_mix() --- panda/src/audiotraits/fmodAudioSound.cxx | 2 +- panda/src/audiotraits/fmodAudioSound.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/audiotraits/fmodAudioSound.cxx b/panda/src/audiotraits/fmodAudioSound.cxx index dd060844e9..d8560658a7 100644 --- a/panda/src/audiotraits/fmodAudioSound.cxx +++ b/panda/src/audiotraits/fmodAudioSound.cxx @@ -651,7 +651,7 @@ get_3d_max_distance() const { * a balance [pan] function what is the point? */ PN_stdfloat FmodAudioSound:: -get_speaker_mix(AudioManager::SpeakerId speaker) { +get_speaker_mix(int speaker) { ReMutexHolder holder(FmodAudioManager::_lock); if (_channel == 0) { return 0.0; diff --git a/panda/src/audiotraits/fmodAudioSound.h b/panda/src/audiotraits/fmodAudioSound.h index 40de00823d..922ee976b7 100644 --- a/panda/src/audiotraits/fmodAudioSound.h +++ b/panda/src/audiotraits/fmodAudioSound.h @@ -126,7 +126,7 @@ public: AudioSound::SoundStatus status() const; - virtual PN_stdfloat get_speaker_mix(AudioManager::SpeakerId speaker); + virtual PN_stdfloat get_speaker_mix(int speaker); virtual void set_speaker_mix(PN_stdfloat frontleft, PN_stdfloat frontright, PN_stdfloat center, PN_stdfloat sub, PN_stdfloat backleft, PN_stdfloat backright, PN_stdfloat sideleft, PN_stdfloat sideright); void set_active(bool active=true); From b8ed9b1275a6aad914d9790f4e2cc2aa8b2d36f1 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Nov 2018 21:49:17 +0100 Subject: [PATCH 308/360] Remove pystub dependency from interrogate and friends --- dtool/src/interrogate/interrogate.cxx | 3 --- dtool/src/interrogate/interrogate_module.cxx | 3 --- dtool/src/interrogate/parse_file.cxx | 3 --- dtool/src/test_interrogate/test_interrogate.cxx | 3 --- makepanda/makepanda.py | 5 ----- 5 files changed, 17 deletions(-) diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index 964d38020c..ef06833324 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -19,7 +19,6 @@ #include "pnotify.h" #include "panda_getopt_long.h" #include "preprocess_argv.h" -#include "pystub.h" #include using std::cerr; @@ -309,8 +308,6 @@ predefine_macro(CPPParser& parser, const string& inoption) { int main(int argc, char **argv) { - pystub(); - preprocess_argv(argc, argv); string command_line; int i; diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 586889ed77..6f7bc4bfeb 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -19,7 +19,6 @@ #include "interrogate_interface.h" #include "interrogate_request.h" #include "load_dso.h" -#include "pystub.h" #include "pnotify.h" #include "panda_getopt_long.h" #include "preprocess_argv.h" @@ -541,8 +540,6 @@ int main(int argc, char *argv[]) { extern int optind; int flag; - pystub(); - preprocess_argv(argc, argv); flag = getopt_long_only(argc, argv, short_options, long_options, nullptr); while (flag != EOF) { diff --git a/dtool/src/interrogate/parse_file.cxx b/dtool/src/interrogate/parse_file.cxx index aa903407d1..0b8ff924ec 100644 --- a/dtool/src/interrogate/parse_file.cxx +++ b/dtool/src/interrogate/parse_file.cxx @@ -22,7 +22,6 @@ #include "cppGlobals.h" #include "panda_getopt_long.h" #include "preprocess_argv.h" -#include "pystub.h" #include using std::cerr; @@ -206,8 +205,6 @@ show_nested_types(const string &str) { int main(int argc, char **argv) { - pystub(); - extern char *optarg; extern int optind; const char *optstr = "I:S:D:o:l:vp"; diff --git a/dtool/src/test_interrogate/test_interrogate.cxx b/dtool/src/test_interrogate/test_interrogate.cxx index 590b8ac873..426de102de 100644 --- a/dtool/src/test_interrogate/test_interrogate.cxx +++ b/dtool/src/test_interrogate/test_interrogate.cxx @@ -17,7 +17,6 @@ #include "interrogate_request.h" #include "load_dso.h" #include "filename.h" -#include "pystub.h" #include "panda_getopt.h" #include "preprocess_argv.h" @@ -526,8 +525,6 @@ main(int argc, char **argv) { extern int optind; const char *optstr = "p:ftqh"; - pystub(); - bool all_functions = false; bool all_types = false; bool quick_load = false; diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 2689205461..2983b845e3 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3478,7 +3478,6 @@ if (not RUNTIME): TargetAdd('interrogate.exe', input='libp3cppParser.ilb') TargetAdd('interrogate.exe', input=COMMON_DTOOL_LIBS) TargetAdd('interrogate.exe', input='libp3interrogatedb.dll') - TargetAdd('interrogate.exe', input='libp3pystub.lib') TargetAdd('interrogate.exe', opts=['ADVAPI', 'OPENSSL', 'WINSHELL', 'WINGDI', 'WINUSER']) preamble = WriteEmbeddedStringFile('interrogate_preamble_python_native', inputs=[ @@ -3494,7 +3493,6 @@ if (not RUNTIME): TargetAdd('interrogate_module.exe', input='libp3cppParser.ilb') TargetAdd('interrogate_module.exe', input=COMMON_DTOOL_LIBS) TargetAdd('interrogate_module.exe', input='libp3interrogatedb.dll') - TargetAdd('interrogate_module.exe', input='libp3pystub.lib') TargetAdd('interrogate_module.exe', opts=['ADVAPI', 'OPENSSL', 'WINSHELL', 'WINGDI', 'WINUSER']) if (not RTDIST): @@ -3503,7 +3501,6 @@ if (not RUNTIME): TargetAdd('parse_file.exe', input='libp3cppParser.ilb') TargetAdd('parse_file.exe', input=COMMON_DTOOL_LIBS) TargetAdd('parse_file.exe', input='libp3interrogatedb.dll') - TargetAdd('parse_file.exe', input='libp3pystub.lib') TargetAdd('parse_file.exe', opts=['ADVAPI', 'OPENSSL', 'WINSHELL', 'WINGDI', 'WINUSER']) # @@ -3527,7 +3524,6 @@ if (not RTDIST and not RUNTIME): TargetAdd('test_interrogate.exe', input='test_interrogate_test_interrogate.obj') TargetAdd('test_interrogate.exe', input='libp3interrogatedb.dll') TargetAdd('test_interrogate.exe', input=COMMON_DTOOL_LIBS) - TargetAdd('test_interrogate.exe', input='libp3pystub.lib') TargetAdd('test_interrogate.exe', opts=['ADVAPI', 'OPENSSL', 'WINSHELL', 'WINGDI', 'WINUSER']) # @@ -6280,7 +6276,6 @@ if not PkgSkip("PANDATOOL") and not PkgSkip("EGG"): # TargetAdd('bin2c.exe', input='libp3progbase.lib') # TargetAdd('bin2c.exe', input='libp3pandatoolbase.lib') # TargetAdd('bin2c.exe', input=COMMON_PANDA_LIBS) -# TargetAdd('bin2c.exe', input='libp3pystub.lib') # TargetAdd('bin2c.exe', opts=['ADVAPI']) # From cd2ea97b1ffb65512f5ee8ba0665f46345ef7795 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Nov 2018 15:38:20 +0100 Subject: [PATCH 309/360] openal: fix issues with uncache_sound not uncaching sound: * Previously it only looked for the resolved path, but sounds are not stored with resolved path in the cache (possibly a different bug?) * It only uncached samples, not streams Fixes #428 --- panda/src/audiotraits/openalAudioManager.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index a6ac7ba06d..c205f55402 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -534,6 +534,9 @@ uncache_sound(const Filename &file_name) { vfs->resolve_filename(path, get_model_path()); SampleCache::iterator sci = _sample_cache.find(path); + if (sci == _sample_cache.end()) { + sci = _sample_cache.find(file_name); + } if (sci != _sample_cache.end()) { SoundData *sd = (*sci).second; if (sd->_client_count == 0) { @@ -542,6 +545,19 @@ uncache_sound(const Filename &file_name) { delete sd; } } + + ExpirationQueue::iterator exqi; + for (exqi = _expiring_streams.begin(); exqi != _expiring_streams.end();) { + SoundData *sd = (SoundData *)(*exqi); + if (sd->_client_count == 0) { + if (sd->_movie->get_filename() == path || + sd->_movie->get_filename() == file_name) { + exqi = _expiring_streams.erase(exqi); + continue; + } + } + ++exqi; + } } /** From 61dbe478841149fa5ec31a93addf605cabb107d2 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Nov 2018 15:48:12 +0100 Subject: [PATCH 310/360] makepanda: fix PhysX linker error on Windows --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 2983b845e3..8b6de2ae0d 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -4955,7 +4955,7 @@ if (PkgSkip("PHYSX")==0): TargetAdd('libpandaphysx.dll', input='pandaphysx_pandaphysx.obj') TargetAdd('libpandaphysx.dll', input='p3physx_composite.obj') TargetAdd('libpandaphysx.dll', input=COMMON_PANDA_LIBS) - TargetAdd('libpandaphysx.dll', opts=['WINUSER', 'PHYSX', 'NOARCH:PPC']) + TargetAdd('libpandaphysx.dll', opts=['WINUSER', 'PHYSX', 'NOARCH:PPC', 'PYTHON']) OPTS=['DIR:panda/metalibs/pandaphysx', 'PHYSX', 'NOARCH:PPC'] PyTargetAdd('physx_module.obj', input='libpandaphysx.in') From 87c453fc08d34fb46c2f34e36b2b621b30f8d8a6 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Nov 2018 15:49:06 +0100 Subject: [PATCH 311/360] makepanda: refactor code to emit errors/warnings --- makepanda/makepanda.py | 8 +++---- makepanda/makepandacore.py | 46 +++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 8b6de2ae0d..85e4639364 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2573,9 +2573,9 @@ WriteConfigSettings() WarnConflictingFiles() if SystemLibraryExists("dtoolbase"): - print("%sWARNING:%s Found conflicting Panda3D libraries from other ppremake build!" % (GetColor("red"), GetColor())) + Warn("Found conflicting Panda3D libraries from other ppremake build!") if SystemLibraryExists("p3dtoolconfig"): - print("%sWARNING:%s Found conflicting Panda3D libraries from other makepanda build!" % (GetColor("red"), GetColor())) + Warn("Found conflicting Panda3D libraries from other makepanda build!") ########################################################################################## # @@ -3061,7 +3061,7 @@ if tp_dir is not None: pattern = os.path.join('C:' + os.sep, 'Windows', 'WinSxS', 'Manifests', sxs_name + '_*.manifest') manifests = glob.glob(pattern) if not manifests: - print("%sWARNING:%s Could not locate manifest %s. You may need to reinstall the Visual C++ Redistributable." % (GetColor("red"), GetColor(), pattern)) + Warn("Could not locate manifest %s. You may need to reinstall the Visual C++ Redistributable." % (pattern)) continue CopyFile(GetOutputDir() + "/python/" + ident.get('name') + ".manifest", manifests[0]) @@ -7008,7 +7008,7 @@ def MakeInstallerLinux(): rpmbuild_present = True if dpkg_present and rpmbuild_present: - print("Warning: both dpkg and rpmbuild present.") + Warn("both dpkg and rpmbuild present.") if dpkg_present: # Invoke installpanda.py to install it into a temporary dir diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 7d19a00a19..a8c578e258 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -150,7 +150,7 @@ CONFLICTING_FILES=["dtool/src/dtoolutil/pandaVersion.h", def WarnConflictingFiles(delete = False): for cfile in CONFLICTING_FILES: if os.path.exists(cfile): - print("%sWARNING:%s file may conflict with build: %s%s%s" % (GetColor("red"), GetColor(), GetColor("green"), cfile, GetColor())) + Warn("file may conflict with build:", cfile) if delete: os.unlink(cfile) print("Deleted.") @@ -284,6 +284,20 @@ def exit(msg = ""): print(msg) raise "initiate-exit" +def Warn(msg, extra=None): + if extra is not None: + print("%sWARNING:%s %s %s%s%s" % (GetColor("red"), GetColor(), msg, GetColor("green"), extra, GetColor())) + else: + print("%sWARNING:%s %s" % (GetColor("red"), GetColor(), msg)) + sys.stdout.flush() + +def Error(msg, extra=None): + if extra is not None: + print("%sERROR:%s %s %s%s%s" % (GetColor("red"), GetColor(), msg, GetColor("green"), extra, GetColor())) + else: + print("%sERROR:%s %s" % (GetColor("red"), GetColor(), msg)) + exit() + ######################################################################## ## ## SetTarget, GetTarget, GetHost @@ -723,7 +737,7 @@ def NeedsBuild(files, others): print(" dependency changed: %s" % (key)) if VERBOSE and frozenset(cached) != frozenset(dates): - print("%sWARNING:%s file dependencies changed: %s%s%s" % (GetColor("red"), GetColor(), GetColor("green"), files, GetColor())) + Warn("file dependencies changed:", files) return True @@ -1298,7 +1312,7 @@ def GetThirdpartyDir(): THIRDPARTYDIR = GetThirdpartyBase()+"/android-libs-%s/" % (GetTargetArch()) else: - print("%s Unsupported platform: %s" % (ColorText("red", "WARNING:"), target)) + Warn("Unsupported platform:", target) return if (GetVerbose()): @@ -1744,11 +1758,10 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None, if not custom_loc and pkgconfig is not None and not libs: # pkg-config is all we can do, abort if it wasn't found. if pkg in PkgListGet(): - print("%sWARNING:%s Could not locate pkg-config package %s, excluding from build" % (GetColor("red"), GetColor(), pkgconfig)) + Warn("Could not locate pkg-config package %s, excluding from build" % (pkgconfig)) PkgDisable(pkg) else: - print("%sERROR:%s Could not locate pkg-config package %s, aborting build" % (GetColor("red"), GetColor(), pkgconfig)) - exit() + Error("Could not locate pkg-config package %s, aborting build" % (pkgconfig)) else: # Okay, our pkg-config attempts failed. Let's try locating the libs by ourselves. @@ -1812,14 +1825,12 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None, if not have_pkg: if custom_loc: - print("%sERROR:%s Could not locate thirdparty package %s in specified directory, aborting build" % (GetColor("red"), GetColor(), pkg.lower())) - exit() + Error("Could not locate thirdparty package %s in specified directory, aborting build" % (pkg.lower())) elif pkg in PkgListGet(): - print("%sWARNING:%s Could not locate thirdparty package %s, excluding from build" % (GetColor("red"), GetColor(), pkg.lower())) + Warn("Could not locate thirdparty package %s, excluding from build" % (pkg.lower())) PkgDisable(pkg) else: - print("%sERROR:%s Could not locate thirdparty package %s, aborting build" % (GetColor("red"), GetColor(), pkg.lower())) - exit() + Error("Could not locate thirdparty package %s, aborting build" % (pkg.lower())) ######################################################################## ## @@ -2100,7 +2111,7 @@ def SdkLocatePython(prefer_thirdparty_python=False): os.environ["PYTHONHOME"] = SDK["PYTHON"] if sys.version[:3] != ver: - print("Warning: running makepanda with Python %s, but building Panda3D with Python %s." % (sys.version[:3], ver)) + Warn("running makepanda with Python %s, but building Panda3D with Python %s." % (sys.version[:3], ver)) elif CrossCompiling() or (prefer_thirdparty_python and os.path.isdir(os.path.join(GetThirdpartyDir(), "python"))): tp_python = os.path.join(GetThirdpartyDir(), "python") @@ -2743,12 +2754,11 @@ def LibName(opt, name): WARNINGS.append(name + " not found. Skipping Package " + opt) if (opt in PkgListGet()): if not PkgSkip(opt): - print("%sWARNING:%s Could not locate thirdparty package %s, excluding from build" % (GetColor("red"), GetColor(), opt.lower())) + Warn("Could not locate thirdparty package %s, excluding from build" % (opt.lower())) PkgDisable(opt) return else: - print("%sERROR:%s Could not locate thirdparty package %s, aborting build" % (GetColor("red"), GetColor(), opt.lower())) - exit() + Error("Could not locate thirdparty package %s, aborting build" % (opt.lower())) LIBNAMES.append((opt, name)) def DefSymbol(opt, sym, val=""): @@ -2831,7 +2841,7 @@ def SetupBuildEnvironment(compiler): returnval = handle.close() if returnval != None and returnval != 0: - print("%sWARNING:%s %s failed" % (GetColor("red"), GetColor(), cmd)) + Warn("%s failed" % (cmd)) SYS_LIB_DIRS += [SDK.get("SYSROOT", "") + "/usr/lib"] # Now extract the preprocessor's include directories. @@ -2860,7 +2870,7 @@ def SetupBuildEnvironment(compiler): print("Ignoring non-existent include directory %s" % (line)) if handle.returncode != 0 or not SYS_INC_DIRS: - print("%sWARNING:%s %s failed or did not produce the expected result" % (GetColor("red"), GetColor(), cmd)) + Warn("%s failed or did not produce the expected result" % (cmd)) sysroot = SDK.get("SYSROOT", "") # Add some sensible directories as a fallback. SYS_INC_DIRS = [ @@ -3374,7 +3384,7 @@ def FindLocation(fn, ipath, pyabi=None): elif ext != ".pyd" and loc not in WARNED_FILES: WARNED_FILES.add(loc) - print("%sWARNING:%s file depends on Python but is not in an ABI-specific directory: %s%s%s" % (GetColor("red"), GetColor(), GetColor("green"), loc, GetColor())) + Warn("file depends on Python but is not in an ABI-specific directory:", loc) ORIG_EXT[loc] = ext return loc From dfbe728badaad72d2108e12bb70e7e6dd7a2f081 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Nov 2018 15:50:44 +0100 Subject: [PATCH 312/360] glgsg: fix shader point sprites when not using core-only profile --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 19594750c8..3da843c94a 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -11759,8 +11759,6 @@ do_issue_tex_gen() { _tex_gen_modifies_mat = false; - bool got_point_sprites = false; - for (int i = 0; i < _num_active_texture_stages; i++) { set_active_texture_stage(i); if (_supports_point_sprite) { @@ -11953,7 +11951,6 @@ do_issue_tex_gen() { #else glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); #endif - got_point_sprites = true; } break; @@ -11991,6 +11988,9 @@ do_issue_tex_gen() { #endif // OPENGLES } + bool got_point_sprites = _supports_point_sprite && + (_target_tex_gen->get_geom_rendering(Geom::GR_point) & GeomEnums::GR_point_sprite) != 0; + if (got_point_sprites != _tex_gen_point_sprite) { _tex_gen_point_sprite = got_point_sprites; #ifdef OPENGLES From e5f398a8614145f4ccfb7a70c0dd0e1a3d85b367 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Nov 2018 15:51:30 +0100 Subject: [PATCH 313/360] makepanda: tweaks to .deb files; don't suggest panda3d-runtime --- makepanda/makepanda.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 85e4639364..1a5b200849 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -6843,17 +6843,16 @@ Architecture: ARCH Essential: no Depends: DEPENDS Recommends: RECOMMENDS -Suggests: panda3d-runtime -Provides: panda3d -Conflicts: panda3d -Replaces: panda3d +Provides: panda3d, pythonPV-panda3d +Conflicts: panda3d, pythonPV-panda3d +Replaces: panda3d, pythonPV-panda3d Maintainer: rdb Installed-Size: INSTSIZE Description: Panda3D free 3D engine SDK Panda3D is a game engine which includes graphics, audio, I/O, collision detection, and other abilities relevant to the creation of 3D games. Panda3D is open source and free software under the revised BSD license, and can be used for both free and commercial game development at no financial cost. Panda3D's intended game-development language is Python. The engine itself is written in C++, and utilizes an automatic wrapper-generator to expose the complete functionality of the engine in a Python interface. . - This package contains the SDK for development with Panda3D, install panda3d-runtime for the runtime files. + This package contains the SDK for development with Panda3D. """ From 6051e6f3050ec4a9813ba4af06078d8f2b7f0bde Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Nov 2018 15:53:34 +0100 Subject: [PATCH 314/360] ShaderGenerator: normalize tangent/binormal/normal after interpolation Also changes l_eye_normal interpolant from float4 to float3. --- panda/src/pgraphnodes/shaderGenerator.cxx | 41 +++++++++++------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 1b08e921b0..cf8f0783d4 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -850,7 +850,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { if (need_eye_normal) { eye_normal_freg = alloc_freg(); text << "\t uniform float4x4 tpose_view_to_model,\n"; - text << "\t out float4 l_eye_normal : " << eye_normal_freg << ",\n"; + text << "\t out float3 l_eye_normal : " << eye_normal_freg << ",\n"; } if ((key._texture_flags & ShaderKey::TF_map_height) != 0 || need_world_normal || need_eye_normal) { text << "\t in float3 vtx_normal : " << normal_vreg << ",\n"; @@ -937,8 +937,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t l_eye_position = mul(trans_model_to_view, vtx_position);\n"; } if (need_eye_normal) { - text << "\t l_eye_normal.xyz = normalize(mul((float3x3)tpose_view_to_model, vtx_normal));\n"; - text << "\t l_eye_normal.w = 0;\n"; + text << "\t l_eye_normal = normalize(mul((float3x3)tpose_view_to_model, vtx_normal));\n"; } pmap::const_iterator it; for (it = texcoord_fregs.begin(); it != texcoord_fregs.end(); ++it) { @@ -987,7 +986,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t in float4 l_eye_position : " << eye_position_freg << ",\n"; } if (need_eye_normal) { - text << "\t in float4 l_eye_normal : " << eye_normal_freg << ",\n"; + text << "\t in float3 l_eye_normal : " << eye_normal_freg << ",\n"; } for (it = texcoord_fregs.begin(); it != texcoord_fregs.end(); ++it) { text << "\t in float4 l_" << it->first->join("_") << " : " << it->second << ",\n"; @@ -1096,8 +1095,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t float4 texcoord" << i << " = l_eye_position;\n"; break; case TexGenAttrib::M_eye_normal: - text << "\t float4 texcoord" << i << " = l_eye_normal;\n"; - text << "\t texcoord" << i << ".w = 1.0f;\n"; + text << "\t float4 texcoord" << i << " = float4(l_eye_normal, 1.0f);\n"; break; default: text << "\t float4 texcoord" << i << " = float4(0, 0, 0, 0);\n"; @@ -1187,6 +1185,10 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << ");\n"; } } + if (need_eye_normal) { + text << "\t // Correct the surface normal for interpolation effects\n"; + text << "\t l_eye_normal = normalize(l_eye_normal);\n"; + } if (key._texture_flags & ShaderKey::TF_map_normal) { text << "\t // Translate tangent-space normal in map to view-space.\n"; @@ -1196,7 +1198,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { const ShaderKey::TextureInfo &tex = key._textures[i]; if (tex._flags & ShaderKey::TF_map_normal) { if (is_first) { - text << "\t float3 tsnormal = (tex" << i << ".xyz * 2) - 1;\n"; + text << "\t float3 tsnormal = normalize((tex" << i << ".xyz * 2) - 1);\n"; is_first = false; continue; } @@ -1205,17 +1207,14 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t tsnormal = normalize(tsnormal * dot(tsnormal, tmp" << i << ") - tmp" << i << " * tsnormal.z);\n"; } } - text << "\t l_eye_normal.xyz *= tsnormal.z;\n"; - text << "\t l_eye_normal.xyz += l_tangent * tsnormal.x;\n"; - text << "\t l_eye_normal.xyz += l_binormal * tsnormal.y;\n"; - } - if (need_eye_normal) { - text << "\t // Correct the surface normal for interpolation effects\n"; - text << "\t l_eye_normal.xyz = normalize(l_eye_normal.xyz);\n"; + text << "\t l_eye_normal *= tsnormal.z;\n"; + text << "\t l_eye_normal += normalize(l_tangent) * tsnormal.x;\n"; + text << "\t l_eye_normal += normalize(l_binormal) * tsnormal.y;\n"; + text << "\t l_eye_normal = normalize(l_eye_normal);\n"; } if (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) { text << "\t // Output the camera-space surface normal\n"; - text << "\t o_aux.rgb = (l_eye_normal.xyz*0.5) + float3(0.5,0.5,0.5);\n"; + text << "\t o_aux.rgb = (l_eye_normal*0.5) + float3(0.5,0.5,0.5);\n"; } if (key._lighting) { text << "\t // Begin view-space light calculations\n"; @@ -1251,7 +1250,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t lspec = lcolor;\n"; } text << "\t lvec = attr_light" << i << "[3].xyz;\n"; - text << "\t lcolor *= saturate(dot(l_eye_normal.xyz, lvec.xyz));\n"; + text << "\t lcolor *= saturate(dot(l_eye_normal, lvec.xyz));\n"; if (light._flags & ShaderKey::LF_has_shadows) { if (_use_shadow_filter) { text << "\t lshad = shadow2DProj(shadow_" << i << ", l_lightcoord" << i << ").r;\n"; @@ -1268,7 +1267,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { } else { text << "\t lhalf = normalize(lvec - float3(0, 1, 0));\n"; } - text << "\t lspec *= pow(saturate(dot(l_eye_normal.xyz, lhalf)), shininess);\n"; + text << "\t lspec *= pow(saturate(dot(l_eye_normal, lhalf)), shininess);\n"; text << "\t tot_specular += lspec;\n"; } } else if (light._type.is_derived_from(PointLight::get_class_type())) { @@ -1288,7 +1287,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t ldist = max(ldist, attr_light" << i << "[2].w);\n"; } text << "\t lattenv = 1/(latten.x + latten.y*ldist + latten.z*ldist*ldist);\n"; - text << "\t lcolor *= lattenv * saturate(dot(l_eye_normal.xyz, lvec));\n"; + text << "\t lcolor *= lattenv * saturate(dot(l_eye_normal, lvec));\n"; if (light._flags & ShaderKey::LF_has_shadows) { text << "\t ldist = max(abs(l_lightcoord" << i << ".x), max(abs(l_lightcoord" << i << ".y), abs(l_lightcoord" << i << ".z)));\n"; text << "\t ldist = ((latten.w+lpoint.w)/(latten.w-lpoint.w))+((-2*latten.w*lpoint.w)/(ldist * (latten.w-lpoint.w)));\n"; @@ -1304,7 +1303,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t lhalf = normalize(lvec - float3(0, 1, 0));\n"; } text << "\t lspec *= lattenv;\n"; - text << "\t lspec *= pow(saturate(dot(l_eye_normal.xyz, lhalf)), shininess);\n"; + text << "\t lspec *= pow(saturate(dot(l_eye_normal, lhalf)), shininess);\n"; text << "\t tot_specular += lspec;\n"; } } else if (light._type.is_derived_from(Spotlight::get_class_type())) { @@ -1325,7 +1324,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t lattenv = 1/(latten.x + latten.y*ldist + latten.z*ldist*ldist);\n"; text << "\t lattenv *= pow(langle, latten.w);\n"; text << "\t if (langle < ldir.w) lattenv = 0;\n"; - text << "\t lcolor *= lattenv * saturate(dot(l_eye_normal.xyz, lvec));\n"; + text << "\t lcolor *= lattenv * saturate(dot(l_eye_normal, lvec));\n"; if (light._flags & ShaderKey::LF_has_shadows) { if (_use_shadow_filter) { text << "\t lshad = shadow2DProj(shadow_" << i << ", l_lightcoord" << i << ").r;\n"; @@ -1344,7 +1343,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { text << "\t lhalf = normalize(lvec - float3(0,1,0));\n"; } text << "\t lspec *= lattenv;\n"; - text << "\t lspec *= pow(saturate(dot(l_eye_normal.xyz, lhalf)), shininess);\n"; + text << "\t lspec *= pow(saturate(dot(l_eye_normal, lhalf)), shininess);\n"; text << "\t tot_specular += lspec;\n"; } } From 52b2df4ebb340e3a7f0b5507e1bf6cce1c00a378 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Nov 2018 22:46:52 +0100 Subject: [PATCH 315/360] makepanda: test_wheel.py should upgrade pip to latest version [skip ci] --- makepanda/test_wheel.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/makepanda/test_wheel.py b/makepanda/test_wheel.py index 00555a5e60..f4491964a9 100755 --- a/makepanda/test_wheel.py +++ b/makepanda/test_wheel.py @@ -23,11 +23,16 @@ def test_wheel(wheel, verbose=False): else: subprocess.call([sys.executable, "-m", "virtualenv", "--clear", envdir]) - # Install pytest into the environment, as well as our wheel. + # Make sure pip is up-to-date first. if sys.platform == "win32": pip = os.path.join(envdir, "Scripts", "pip.exe") else: pip = os.path.join(envdir, "bin", "pip") + if subprocess.call([pip, "install", "-U", "pip"]) != 0: + shutil.rmtree(envdir) + sys.exit(1) + + # Install pytest into the environment, as well as our wheel. if subprocess.call([pip, "install", "pytest", wheel]) != 0: shutil.rmtree(envdir) sys.exit(1) From 6c5da232a400e9217608d21f3bf49a0e8a1cde64 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 9 Nov 2018 00:30:10 -0700 Subject: [PATCH 316/360] general: Add a couple of missing EXPCLs Although these aren't used outside of libpanda(express), they are used by their neighboring component libraries, which means they should be exported so that this works correctly when the metalibs feature is disabled. --- panda/src/express/config_express.h | 2 +- panda/src/pgraph/config_pgraph.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/express/config_express.h b/panda/src/express/config_express.h index 7ec19749f0..a3a16a51fa 100644 --- a/panda/src/express/config_express.h +++ b/panda/src/express/config_express.h @@ -48,7 +48,7 @@ extern ConfigVariableInt patchfile_increment_size; extern ConfigVariableInt patchfile_buffer_size; extern ConfigVariableInt patchfile_zone_size; -extern ConfigVariableBool keep_temporary_files; +extern EXPCL_PANDA_EXPRESS ConfigVariableBool keep_temporary_files; extern ConfigVariableBool multifile_always_binary; extern EXPCL_PANDA_EXPRESS ConfigVariableBool collect_tcp; diff --git a/panda/src/pgraph/config_pgraph.h b/panda/src/pgraph/config_pgraph.h index 22050bd75e..11094b9d16 100644 --- a/panda/src/pgraph/config_pgraph.h +++ b/panda/src/pgraph/config_pgraph.h @@ -48,7 +48,7 @@ extern ConfigVariableDouble garbage_collect_states_rate; extern ConfigVariableBool transform_cache; extern ConfigVariableBool state_cache; extern ConfigVariableBool uniquify_transforms; -extern ConfigVariableBool uniquify_states; +extern EXPCL_PANDA_PGRAPH ConfigVariableBool uniquify_states; extern ConfigVariableBool uniquify_attribs; extern ConfigVariableBool retransform_sprites; extern ConfigVariableBool depth_offset_decals; From 5ba09ec5a0c36bc75a875dfc2ec6dbfe2a049479 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Nov 2018 11:38:41 +0100 Subject: [PATCH 317/360] interrogate: fix compile error when building with LINK_ALL_STATIC Fixes #442 --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index c0316ee5c4..1a2282d83f 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -1495,11 +1495,15 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << " {nullptr, nullptr, 0, nullptr}\n" << "};\n\n"; - out << "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, "; if (_external_imports.empty()) { - out << "nullptr};\n"; + out << "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, nullptr};\n"; } else { - out << "imports};\n"; + out << + "#ifdef LINK_ALL_STATIC\n" + "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, nullptr};\n" + "#else\n" + "extern const struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs, exports, imports};\n" + "#endif\n"; } if (out_h != nullptr) { *out_h << "extern const struct LibraryDef " << def->library_name << "_moddef;\n"; From 0581e414a42f5389de8a6f3f103c6011321ac48c Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Nov 2018 11:40:11 +0100 Subject: [PATCH 318/360] parser-inc: remove patchlevel.h include from Python.h --- dtool/src/parser-inc/Python.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/dtool/src/parser-inc/Python.h b/dtool/src/parser-inc/Python.h index 5f1a98a825..5fa71246a5 100644 --- a/dtool/src/parser-inc/Python.h +++ b/dtool/src/parser-inc/Python.h @@ -47,9 +47,6 @@ PyObject _Py_FalseStruct; #define Py_False ((PyObject *) &_Py_FalseStruct) #endif -// This file defines PY_VERSION_HEX, which is used in some places. -#include "patchlevel.h" - typedef void *visitproc; #endif // PYTHON_H From 223c532ce7235978671c70f46e85f6f5169664c5 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Nov 2018 11:42:18 +0100 Subject: [PATCH 319/360] makepanda: link libpandagl into pview when using --static --- makepanda/makepanda.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 1a5b200849..1387d2e11f 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -5072,6 +5072,9 @@ if (not RTDIST and not RUNTIME and PkgSkip("PVIEW")==0): TargetAdd('pview.exe', input=COMMON_PANDA_LIBS) TargetAdd('pview.exe', opts=['ADVAPI', 'WINSOCK2', 'WINSHELL']) + if GetLinkAllStatic() and not PkgSkip("GL"): + TargetAdd('pview.exe', input='libpandagl.dll') + # # DIRECTORY: panda/src/android/ # From 38c2382ba637b820d4269ad22a9558f86f9a47c8 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Nov 2018 11:44:43 +0100 Subject: [PATCH 320/360] test_wheel: fix upgrading pip on Windows pip can only be upgraded by running `python -m pip` on Windows. [skip ci] --- makepanda/test_wheel.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/makepanda/test_wheel.py b/makepanda/test_wheel.py index f4491964a9..09b0727fe7 100755 --- a/makepanda/test_wheel.py +++ b/makepanda/test_wheel.py @@ -24,15 +24,15 @@ def test_wheel(wheel, verbose=False): subprocess.call([sys.executable, "-m", "virtualenv", "--clear", envdir]) # Make sure pip is up-to-date first. - if sys.platform == "win32": - pip = os.path.join(envdir, "Scripts", "pip.exe") - else: - pip = os.path.join(envdir, "bin", "pip") - if subprocess.call([pip, "install", "-U", "pip"]) != 0: + if subprocess.call([sys.executable, "-m", "pip", "install", "-U", "pip"]) != 0: shutil.rmtree(envdir) sys.exit(1) # Install pytest into the environment, as well as our wheel. + if sys.platform == "win32": + pip = os.path.join(envdir, "Scripts", "pip.exe") + else: + pip = os.path.join(envdir, "bin", "pip") if subprocess.call([pip, "install", "pytest", wheel]) != 0: shutil.rmtree(envdir) sys.exit(1) From 412f5ecc2a7ed36e1653d634afaf7dd5a846d982 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Nov 2018 17:35:47 +0100 Subject: [PATCH 321/360] makepanda: more reliable way to get extension suffix --- makepanda/makepandacore.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index a8c578e258..435b45a023 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -3260,14 +3260,8 @@ def SetOrigExt(x, v): def GetExtensionSuffix(): if sys.version_info >= (3, 0): - suffix = sysconfig.get_config_var('EXT_SUFFIX') - if suffix == '.so': - # On my FreeBSD system, this is not set correctly, but SOABI is. - soabi = sysconfig.get_config_var('SOABI') - if soabi: - return '.%s.so' % (soabi) - elif suffix: - return suffix + import _imp + return _imp.extension_suffixes()[0] target = GetTarget() if target == 'windows': From b37cfd65736619ff6b7644f6489e353b399e5663 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Nov 2018 17:50:17 +0100 Subject: [PATCH 322/360] makepanda: use correct Registry key for 32-bit Python 3.5+ --- makepanda/makepanda.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 1387d2e11f..694681db00 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -6763,10 +6763,13 @@ def MakeInstallerNSIS(file, title, installdir): elif (os.path.isdir(file)): shutil.rmtree(file) + pyver = SDK["PYTHONVERSION"][6:9] if GetTargetArch() == 'x64': regview = '64' else: regview = '32' + if int(pyver[0]) == 3 and int(pyver[2]) >= 5: + pyver += '-32' if (RUNTIME): # Invoke the make_installer script. @@ -6799,7 +6802,7 @@ def MakeInstallerNSIS(file, title, installdir): 'OUTFILE' : '..\\' + file, 'BUILT' : '..\\' + GetOutputDir(), 'SOURCE' : '..', - 'PYVER' : SDK["PYTHONVERSION"][6:9], + 'PYVER' : pyver, 'REGVIEW' : regview, 'EXT_SUFFIX' : GetExtensionSuffix(), } From 62ae624a95ad51dd5f49f274c3138c786d6b8c3b Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Nov 2018 18:17:53 +0100 Subject: [PATCH 323/360] makepanda: installer uses registry to add Panda3D to Python path --- makepanda/installer.nsi | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index 7b1d6ea25e..fc10ce927c 100644 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -385,26 +385,36 @@ SectionGroup "Python support" SetRegView ${REGVIEW} !endif - ; Check for a system-wide Python installation. - ; We could check for a user installation of Python as well, but there - ; is no distinction between 64-bit and 32-bit regviews in HKCU, so we - ; can't guess whether it might be a compatible version. + ; Check for a non-Panda3D system-wide Python installation. ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" + StrCmp $0 "$INSTDIR\python" UserExternalPthCheck 0 + StrCmp $0 "" UserExternalPthCheck 0 + IfFileExists "$0\ppython.exe" UserExternalPthCheck 0 + IfFileExists "$0\python.exe" AskExternalPth UserExternalPthCheck + + ; Check for a non-Panda3D user installation of Python. + UserExternalPthCheck: + ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" "" StrCmp $0 "$INSTDIR\python" SkipExternalPth 0 StrCmp $0 "" SkipExternalPth 0 IfFileExists "$0\ppython.exe" SkipExternalPth 0 - IfFileExists "$0\python.exe" 0 SkipExternalPth + IfFileExists "$0\python.exe" AskExternalPth SkipExternalPth ; We're pretty sure this Python build is of the right architecture. + AskExternalPth: MessageBox MB_YESNO|MB_ICONQUESTION \ "Your system already has a copy of Python ${PYVER} installed in:$\r$\n$0$\r$\nWould you like to configure it to be able to use the Panda3D libraries?$\r$\nIf you choose no, you will only be able to use Panda3D's own copy of Python." \ IDYES WriteExternalPth IDNO SkipExternalPth WriteExternalPth: - FileOpen $1 "$0\Lib\site-packages\panda.pth" w - FileWrite $1 "$INSTDIR$\r$\n" - FileWrite $1 "$INSTDIR\bin$\r$\n" - FileClose $1 + ;FileOpen $1 "$0\Lib\site-packages\panda.pth" w + ;FileWrite $1 "$INSTDIR$\r$\n" + ;FileWrite $1 "$INSTDIR\bin$\r$\n" + ;FileClose $1 + + ; Actually, it looks like we can just do this instead: + WriteRegStr HKCU "Software\Python\PythonCore\${PYVER}\PythonPath\Panda3D" "" "$INSTDIR" + SkipExternalPth: SectionEnd @@ -736,6 +746,10 @@ Section Uninstall StrCmp $0 "$INSTDIR\python" 0 +2 DeleteRegKey HKCU "Software\Python\PythonCore\${PYVER}" + ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\PythonPath\Panda3D" "" + StrCmp $0 "$INSTDIR" 0 +2 + DeleteRegKey HKCU "Software\Python\PythonCore\${PYVER}\PythonPath\Panda3D" + SetDetailsPrint both DetailPrint "Deleting files..." SetDetailsPrint listonly From f629a5df1a55c4f913b83c1c325fb39bdcbb30b0 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Nov 2018 18:25:07 +0100 Subject: [PATCH 324/360] cocoa: don't enable sRGB unless it was explicitly requested Fixes #443 --- panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index b584d02a2c..d0dbd37c16 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm @@ -254,6 +254,11 @@ choose_pixel_format(const FrameBufferProperties &properties, "Pixel format has " << [format numberOfVirtualScreens] << " virtual screens.\n"; get_properties(_fbprops, format, 0); + // Don't enable sRGB unless it was explicitly requested. + if (!properties.get_srgb_color()) { + _fbprops.set_srgb_color(false); + } + // TODO: print out renderer _context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:_share_context]; From 37e265cb63af0e009505134f3d799ea776a4a73e Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 10 Nov 2018 17:12:06 -0700 Subject: [PATCH 325/360] ode: Delete unused odeHeightFieldGeom.h file --- makepanda/makepanda.py | 1 - panda/src/ode/odeHeightFieldGeom.h | 119 ----------------------------- 2 files changed, 120 deletions(-) delete mode 100644 panda/src/ode/odeHeightFieldGeom.h diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 694681db00..60006096e3 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -4862,7 +4862,6 @@ if (PkgSkip("ODE")==0 and not RUNTIME): OPTS=['DIR:panda/src/ode', 'ODE'] IGATEFILES=GetDirectoryContents('panda/src/ode', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("odeConvexGeom.h") - IGATEFILES.remove("odeHeightFieldGeom.h") IGATEFILES.remove("odeHelperStructs.h") TargetAdd('libpandaode.in', opts=OPTS, input=IGATEFILES) TargetAdd('libpandaode.in', opts=['IMOD:panda3d.ode', 'ILIB:libpandaode', 'SRCDIR:panda/src/ode']) diff --git a/panda/src/ode/odeHeightFieldGeom.h b/panda/src/ode/odeHeightFieldGeom.h deleted file mode 100644 index 2093ebe55b..0000000000 --- a/panda/src/ode/odeHeightFieldGeom.h +++ /dev/null @@ -1,119 +0,0 @@ -/** - * 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." - * - * @file odeHeightFieldGeom.h - * @author joswilso - * @date 2006-12-27 - */ - -#ifndef ODEHEIGHTFIELDGEOM_H -#define ODEHEIGHTFIELDGEOM_H - -#include "pandabase.h" -#include "typedObject.h" -#include "luse.h" - -#include "ode_includes.h" -#include "odeGeom.h" - -/** - * - */ -class EXPCL_PANDAODE OdeHeightfieldGeom : public OdeGeom { - friend class OdeGeom; - -public: - OdeHeightfieldGeom(dGeomID id); - -PUBLISHED: - OdeHeightfieldGeom(); - virtual ~OdeHeightfieldGeom(); - - INLINE dHeightfieldDataID heightfield_data_create(); - INLINE void heightfield_data_destroy(dHeightfieldDataID d); - INLINE void heightfield_data_build_callback(dHeightfieldDataID d, - void* p_user_data, - dHeightfieldGetHeight* p_callback, - dReal width, - dReal depth, - int width_samples, - int depth_samples, - dReal scale, - dReal offset, - dReal thickness, - int b_wrap); - INLINE void heightfield_data_build_byte(dHeightfieldDataID d, - const unsigned char* p_height_data, - int b_copy_height_data, - dReal width, - dReal depth, - int width_samples, - int depth_samples, - dReal scale, - dReal offset, - dReal thickness, - int b_wrap); - INLINE void heightfield_data_build_short(dHeightfieldDataID d, - const short* p_height_data, - int b_copy_height_data, - dReal width, - dReal depth, - int width_samples, - int depth_samples, - dReal scale, - dReal offset, - dReal thickness, - int b_wrap); - INLINE void heightfield_data_build_single(dHeightfieldDataID d, - const float* p_height_data, - int b_copy_height_data, - dReal width, - dReal depth, - int width_samples, - int depth_samples, - dReal scale, - dReal offset, - dReal thickness, - int b_wrap); - INLINE void heightfield_data_build_double(dHeightfieldDataID d, - const double* p_height_data, - int b_copy_height_data, - dReal width, - dReal depth, - int width_samples, - int depth_samples, - dReal scale, - dReal offset, - dReal thickness, - int b_wrap); - INLINE void heightfield_data_set_bounds(dHeightfieldDataID d, - dReal min_height, - dReal max_height); - INLINE void heightfield_set_heightfield_data(dHeightfieldDataID d); - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - OdeGeom::init_type(); - register_type(_type_handle, "OdeHeightfieldGeom", - OdeGeom::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -#include "odeHeightfieldGeom.I" - -#endif From 29beb0f04309a376e9bca9bff3fc9af9e3c585b0 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 10 Nov 2018 17:19:18 -0700 Subject: [PATCH 326/360] assimp: Update include path This changes the Assimp include path to point to the directory containing assimp/ instead of inside assimp/ directly. This is for consistency with how the Assimp project defines their "include path" and keeps the actual inclusions themselves unambiguous (since Assimp's headers have fairly generic filenames). --- makepanda/makepanda.py | 4 ++-- pandatool/src/assimp/assimpLoader.cxx | 2 +- pandatool/src/assimp/assimpLoader.h | 4 ++-- pandatool/src/assimp/pandaIOStream.h | 2 +- pandatool/src/assimp/pandaIOSystem.h | 2 +- pandatool/src/assimp/pandaLogger.cxx | 2 +- pandatool/src/assimp/pandaLogger.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 60006096e3..895b306d38 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -683,7 +683,7 @@ if (COMPILER == "MSVC"): path = GetThirdpartyDir() + "assimp/lib/IrrXML.lib" if os.path.isfile(path): LibName("ASSIMP", GetThirdpartyDir() + "assimp/lib/IrrXML.lib") - IncDirectory("ASSIMP", GetThirdpartyDir() + "assimp/include/assimp") + IncDirectory("ASSIMP", GetThirdpartyDir() + "assimp/include") if (PkgSkip("SQUISH")==0): if GetOptimize() <= 2: LibName("SQUISH", GetThirdpartyDir() + "squish/lib/squishd.lib") @@ -828,7 +828,7 @@ if (COMPILER=="GCC"): SmartPkgEnable("EIGEN", "eigen3", (), ("Eigen/Dense",), target_pkg = 'ALWAYS') SmartPkgEnable("ARTOOLKIT", "", ("AR"), "AR/ar.h") SmartPkgEnable("FCOLLADA", "", ChooseLib(fcollada_libs, "FCOLLADA"), ("FCollada", "FCollada/FCollada.h")) - SmartPkgEnable("ASSIMP", "", ("assimp"), "assimp") + SmartPkgEnable("ASSIMP", "", ("assimp"), "assimp/Importer.hpp") SmartPkgEnable("FFMPEG", ffmpeg_libs, ffmpeg_libs, ("libavformat/avformat.h", "libavcodec/avcodec.h", "libavutil/avutil.h")) SmartPkgEnable("SWSCALE", "libswscale", "libswscale", ("libswscale/swscale.h"), target_pkg = "FFMPEG", thirdparty_dir = "ffmpeg") SmartPkgEnable("SWRESAMPLE","libswresample", "libswresample", ("libswresample/swresample.h"), target_pkg = "FFMPEG", thirdparty_dir = "ffmpeg") diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index d04c1d55ad..8533fbaa64 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -39,7 +39,7 @@ #include "pandaIOSystem.h" #include "pandaLogger.h" -#include "postprocess.h" +#include using std::ostringstream; using std::stringstream; diff --git a/pandatool/src/assimp/assimpLoader.h b/pandatool/src/assimp/assimpLoader.h index 35a9bb6947..3133fee377 100644 --- a/pandatool/src/assimp/assimpLoader.h +++ b/pandatool/src/assimp/assimpLoader.h @@ -20,8 +20,8 @@ #include "texture.h" #include "pmap.h" -#include "scene.h" -#include "Importer.hpp" +#include +#include class Character; class CharacterJointBundle; diff --git a/pandatool/src/assimp/pandaIOStream.h b/pandatool/src/assimp/pandaIOStream.h index fa5cc2bb1e..18c24b1475 100644 --- a/pandatool/src/assimp/pandaIOStream.h +++ b/pandatool/src/assimp/pandaIOStream.h @@ -16,7 +16,7 @@ #include "config_assimp.h" -#include "IOStream.hpp" +#include class PandaIOSystem; diff --git a/pandatool/src/assimp/pandaIOSystem.h b/pandatool/src/assimp/pandaIOSystem.h index f38223381c..be8ad2dd91 100644 --- a/pandatool/src/assimp/pandaIOSystem.h +++ b/pandatool/src/assimp/pandaIOSystem.h @@ -17,7 +17,7 @@ #include "config_assimp.h" #include "virtualFileSystem.h" -#include "IOSystem.hpp" +#include /** * Custom implementation of Assimp::IOSystem. diff --git a/pandatool/src/assimp/pandaLogger.cxx b/pandatool/src/assimp/pandaLogger.cxx index b6432e132e..2b92cfbc17 100644 --- a/pandatool/src/assimp/pandaLogger.cxx +++ b/pandatool/src/assimp/pandaLogger.cxx @@ -13,7 +13,7 @@ #include "pandaLogger.h" -#include "DefaultLogger.hpp" +#include PandaLogger *PandaLogger::_ptr = nullptr; diff --git a/pandatool/src/assimp/pandaLogger.h b/pandatool/src/assimp/pandaLogger.h index a9bcbb40af..dbd2165ce6 100644 --- a/pandatool/src/assimp/pandaLogger.h +++ b/pandatool/src/assimp/pandaLogger.h @@ -16,7 +16,7 @@ #include "config_assimp.h" -#include "Logger.hpp" +#include /** * Custom implementation of Assimp::Logger. It simply wraps around the From a9dfd8352e93f4602eb4f61cba23742677c9b12e Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 10 Nov 2018 17:37:28 -0700 Subject: [PATCH 327/360] general: Distinguish local/system includes This changes includes so that local includes are consistently #include "localFile.h" while system and third-party includes are consistently #include This commit mostly converts the former to the latter; the two exceptions are in android_main.cxx and fmodAudioSound.h, where the reverse was necessary. --- contrib/src/rplight/gpuCommand.I | 2 +- direct/src/plugin/fileSpec.cxx | 2 +- direct/src/plugin/get_twirl_data.cxx | 2 +- direct/src/plugin/load_plugin.cxx | 2 +- direct/src/plugin/p3dCert.h | 6 ++-- direct/src/plugin/p3dCert_wx.cxx | 4 +-- direct/src/plugin/p3dCert_wx.h | 8 ++--- direct/src/plugin/p3dHost.cxx | 2 +- direct/src/plugin/p3dInstanceManager.h | 6 ++-- direct/src/plugin/p3dPackage.cxx | 2 +- direct/src/plugin_activex/P3DActiveX.cpp | 6 ++-- direct/src/plugin_activex/P3DActiveXCtrl.cpp | 6 ++-- direct/src/plugin_activex/P3DActiveXCtrl.h | 2 +- direct/src/plugin_activex/PPInstance.h | 2 +- direct/src/plugin_activex/PPInterface.cpp | 2 +- direct/src/plugin_activex/PPLogger.cpp | 3 +- direct/src/plugin_npapi/nppanda3d_common.h | 2 +- direct/src/showutil/FreezeTool.py | 8 ++--- dtool/metalibs/dtoolconfig/pydtool.cxx | 2 +- .../interfaceMakerPythonNative.cxx | 6 ++-- .../interrogate/interfaceMakerPythonNative.h | 4 +-- dtool/src/interrogatedb/py_compat.h | 2 +- dtool/src/interrogatedb/py_panda.h | 2 +- dtool/src/prc/configPage.cxx | 2 +- dtool/src/prc/encryptStreamBuf.cxx | 4 +-- dtool/src/prc/prcKeyRegistry.cxx | 4 +-- dtool/src/prckeys/makePrcKey.cxx | 10 +++--- dtool/src/prckeys/signPrcFile_src.cxx | 10 +++--- panda/src/android/android_main.cxx | 3 +- panda/src/audiotraits/fmodAudioSound.h | 2 +- panda/src/audiotraits/globalMilesManager.h | 3 +- panda/src/audiotraits/milesAudioManager.h | 3 +- panda/src/audiotraits/milesAudioSample.h | 3 +- panda/src/audiotraits/milesAudioSequence.h | 3 +- panda/src/audiotraits/milesAudioSound.h | 3 +- panda/src/audiotraits/milesAudioStream.h | 3 +- panda/src/awesomium/awWebCore.cxx | 3 +- panda/src/awesomium/awesomium_includes.h | 6 ++-- panda/src/bullet/bullet_includes.h | 30 ++++++++-------- panda/src/device/clientBase.h | 2 +- panda/src/downloader/bioPtr.cxx | 2 +- panda/src/downloader/httpCookie.cxx | 3 +- .../downloader/httpDigestAuthorization.cxx | 4 +-- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 2 +- panda/src/express/hashVal.cxx | 2 +- panda/src/express/openSSLWrapper.h | 10 +++--- panda/src/express/password_hash.cxx | 2 +- panda/src/express/patchfile.cxx | 2 +- panda/src/ffmpeg/config_ffmpeg.cxx | 6 ++-- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 10 +++--- panda/src/ffmpeg/ffmpegAudioCursor.h | 2 +- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 8 ++--- panda/src/ffmpeg/ffmpegVirtualFile.cxx | 4 +-- panda/src/ffmpeg/ffmpegVirtualFile.h | 2 +- .../glstuff/glGraphicsStateGuardian_src.cxx | 2 +- panda/src/grutil/movieTexture.cxx | 3 +- panda/src/mathutil/fftCompressor.cxx | 2 +- panda/src/ode/ode_includes.h | 2 +- panda/src/physx/physxFileStream.cxx | 2 +- panda/src/physx/physx_includes.h | 20 +++++------ panda/src/speedtree/speedTreeNode.cxx | 2 +- panda/src/speedtree/speedtree_api.h | 8 ++--- panda/src/tinydisplay/tinySDLGraphicsWindow.h | 3 +- panda/src/tinydisplay/vertex.cxx | 2 +- panda/src/vision/arToolKit.cxx | 2 +- panda/src/vrpn/vrpn_interface.h | 12 +++---- panda/src/windisplay/winGraphicsPipe.cxx | 4 +-- pandatool/src/daeegg/daeCharacter.cxx | 18 +++++----- pandatool/src/daeegg/daeCharacter.h | 10 +++--- pandatool/src/daeegg/daeMaterials.cxx | 12 +++---- pandatool/src/daeegg/daeMaterials.h | 12 +++---- pandatool/src/daeegg/daeToEggConverter.cxx | 34 +++++++++---------- pandatool/src/daeegg/daeToEggConverter.h | 18 +++++----- pandatool/src/daeegg/fcollada_utils.h | 2 +- pandatool/src/daeprogs/eggToDAE.cxx | 6 ++-- pandatool/src/daeprogs/eggToDAE.h | 4 +-- pandatool/src/maxegg/maxEgg.h | 29 ++++++++-------- pandatool/src/maxegg/maxEggLoader.cxx | 18 +++++----- pandatool/src/maxprogs/maxEggImport.cxx | 8 +++-- 79 files changed, 242 insertions(+), 229 deletions(-) diff --git a/contrib/src/rplight/gpuCommand.I b/contrib/src/rplight/gpuCommand.I index 0171442b08..e344b44817 100644 --- a/contrib/src/rplight/gpuCommand.I +++ b/contrib/src/rplight/gpuCommand.I @@ -24,7 +24,7 @@ * */ -#include "stdint.h" +#include /** * @brief Appends an integer to the GPUCommand. diff --git a/direct/src/plugin/fileSpec.cxx b/direct/src/plugin/fileSpec.cxx index c291bfc14a..fd7169c4d1 100644 --- a/direct/src/plugin/fileSpec.cxx +++ b/direct/src/plugin/fileSpec.cxx @@ -13,7 +13,7 @@ #include "fileSpec.h" #include "wstring_encode.h" -#include "openssl/md5.h" +#include #include #include diff --git a/direct/src/plugin/get_twirl_data.cxx b/direct/src/plugin/get_twirl_data.cxx index 1022790978..8d1bbd73fd 100644 --- a/direct/src/plugin/get_twirl_data.cxx +++ b/direct/src/plugin/get_twirl_data.cxx @@ -12,7 +12,7 @@ */ #include "get_twirl_data.h" -#include "string.h" +#include struct twirl_flip { int _index; diff --git a/direct/src/plugin/load_plugin.cxx b/direct/src/plugin/load_plugin.cxx index 75def4fc10..a1575ff087 100644 --- a/direct/src/plugin/load_plugin.cxx +++ b/direct/src/plugin/load_plugin.cxx @@ -16,7 +16,7 @@ #include "is_pathsep.h" #include "wstring_encode.h" -#include "assert.h" +#include #include diff --git a/direct/src/plugin/p3dCert.h b/direct/src/plugin/p3dCert.h index 3c856c6ec3..c17c8129e8 100644 --- a/direct/src/plugin/p3dCert.h +++ b/direct/src/plugin/p3dCert.h @@ -18,9 +18,9 @@ #include #define OPENSSL_NO_KRB5 -#include "openssl/x509.h" -#include "openssl/x509_vfy.h" -#include "openssl/pem.h" +#include +#include +#include #include #include diff --git a/direct/src/plugin/p3dCert_wx.cxx b/direct/src/plugin/p3dCert_wx.cxx index 125732adda..e7002db46a 100644 --- a/direct/src/plugin/p3dCert_wx.cxx +++ b/direct/src/plugin/p3dCert_wx.cxx @@ -15,8 +15,8 @@ #include "wstring_encode.h" #include "mkdir_complete.h" -#include "wx/cmdline.h" -#include "wx/filename.h" +#include +#include #include "ca_bundle_data_src.c" diff --git a/direct/src/plugin/p3dCert_wx.h b/direct/src/plugin/p3dCert_wx.h index 1ea8765a17..b0b3dda12e 100644 --- a/direct/src/plugin/p3dCert_wx.h +++ b/direct/src/plugin/p3dCert_wx.h @@ -14,12 +14,12 @@ #ifndef P3DCERT_WX_H #define P3DCERT_WX_H -#include "wx/wx.h" +#include #define OPENSSL_NO_KRB5 -#include "openssl/x509.h" -#include "openssl/x509_vfy.h" -#include "openssl/pem.h" +#include +#include +#include #include #include diff --git a/direct/src/plugin/p3dHost.cxx b/direct/src/plugin/p3dHost.cxx index 991a66df3e..db189e14c4 100644 --- a/direct/src/plugin/p3dHost.cxx +++ b/direct/src/plugin/p3dHost.cxx @@ -17,7 +17,7 @@ #include "mkdir_complete.h" #include "wstring_encode.h" #include "xml_helpers.h" -#include "openssl/md5.h" +#include #include diff --git a/direct/src/plugin/p3dInstanceManager.h b/direct/src/plugin/p3dInstanceManager.h index f175e90aeb..08591e14cc 100644 --- a/direct/src/plugin/p3dInstanceManager.h +++ b/direct/src/plugin/p3dInstanceManager.h @@ -26,9 +26,9 @@ #endif #define OPENSSL_NO_KRB5 -#include "openssl/x509.h" -#include "openssl/pem.h" -#include "openssl/md5.h" +#include +#include +#include class P3DInstance; class P3DSession; diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index fad2dd97f2..4ea29f339d 100644 --- a/direct/src/plugin/p3dPackage.cxx +++ b/direct/src/plugin/p3dPackage.cxx @@ -20,7 +20,7 @@ #include "mkdir_complete.h" #include "wstring_encode.h" -#include "zlib.h" +#include #include #include diff --git a/direct/src/plugin_activex/P3DActiveX.cpp b/direct/src/plugin_activex/P3DActiveX.cpp index c5c718c78e..500effc38f 100644 --- a/direct/src/plugin_activex/P3DActiveX.cpp +++ b/direct/src/plugin_activex/P3DActiveX.cpp @@ -16,9 +16,9 @@ #include "stdafx.h" #include "P3DActiveX.h" -#include "comcat.h" -#include "strsafe.h" -#include "objsafe.h" +#include +#include +#include #ifdef _DEBUG diff --git a/direct/src/plugin_activex/P3DActiveXCtrl.cpp b/direct/src/plugin_activex/P3DActiveXCtrl.cpp index 78c5125a62..a446bacbfb 100644 --- a/direct/src/plugin_activex/P3DActiveXCtrl.cpp +++ b/direct/src/plugin_activex/P3DActiveXCtrl.cpp @@ -20,9 +20,9 @@ #include "P3DActiveXPropPage.h" #include "PPBrowserObject.h" -#include "Mshtml.h" -#include "atlconv.h" -#include "comutil.h" +#include +#include +#include #include diff --git a/direct/src/plugin_activex/P3DActiveXCtrl.h b/direct/src/plugin_activex/P3DActiveXCtrl.h index 133ce29d27..dc1bd9df39 100644 --- a/direct/src/plugin_activex/P3DActiveXCtrl.h +++ b/direct/src/plugin_activex/P3DActiveXCtrl.h @@ -19,7 +19,7 @@ #include "PPPandaObject.h" #include "PPInterface.h" #include "get_twirl_data.h" -#include "Mshtml.h" +#include #include diff --git a/direct/src/plugin_activex/PPInstance.h b/direct/src/plugin_activex/PPInstance.h index 8b59b6a3ac..c8da8ca650 100644 --- a/direct/src/plugin_activex/PPInstance.h +++ b/direct/src/plugin_activex/PPInstance.h @@ -16,7 +16,7 @@ #include #include #include -#include "afxmt.h" +#include #include "p3d_plugin.h" #include "PPDownloadCallback.h" diff --git a/direct/src/plugin_activex/PPInterface.cpp b/direct/src/plugin_activex/PPInterface.cpp index 25a8750c30..01eee14d08 100644 --- a/direct/src/plugin_activex/PPInterface.cpp +++ b/direct/src/plugin_activex/PPInterface.cpp @@ -20,7 +20,7 @@ #include "P3DActiveXCtrl.h" #include -#include "Mshtml.h" +#include PPInterface::PPInterface( ) { diff --git a/direct/src/plugin_activex/PPLogger.cpp b/direct/src/plugin_activex/PPLogger.cpp index 6dbfa01768..a49f85829d 100644 --- a/direct/src/plugin_activex/PPLogger.cpp +++ b/direct/src/plugin_activex/PPLogger.cpp @@ -13,11 +13,12 @@ #include "stdafx.h" -#include "windows.h" #include "PPLogger.h" #include "mkdir_complete.h" #include "wstring_encode.h" +#include + std::ofstream PPLogger::m_logfile; bool PPLogger::m_isOpen = false; diff --git a/direct/src/plugin_npapi/nppanda3d_common.h b/direct/src/plugin_npapi/nppanda3d_common.h index c1b7cd61af..e6eeca6d99 100644 --- a/direct/src/plugin_npapi/nppanda3d_common.h +++ b/direct/src/plugin_npapi/nppanda3d_common.h @@ -64,7 +64,7 @@ extern bool has_plugin_thread_async_call; #include "npapi.h" #if NP_VERSION_MAJOR == 0 && NP_VERSION_MINOR <= 19 - #include "npupp.h" + #include #else // Somewhere between version 0.19 and 0.22, Mozilla renamed npupp.h to // npfunctions.h. diff --git a/direct/src/showutil/FreezeTool.py b/direct/src/showutil/FreezeTool.py index c734c56101..aafbc24124 100644 --- a/direct/src/showutil/FreezeTool.py +++ b/direct/src/showutil/FreezeTool.py @@ -246,7 +246,7 @@ class CompilationEnvironment: frozenMainCode = """ /* Python interpreter main program for frozen scripts */ -#include "Python.h" +#include #if PY_MAJOR_VERSION >= 3 #include @@ -386,7 +386,7 @@ error: # The code from frozen_dllmain.c in the Python source repository. # Windows only. frozenDllMainCode = """ -#include "windows.h" +#include static char *possibleModules[] = { "pywintypes", @@ -555,9 +555,9 @@ static PyMethodDef nullMethods[] = { """ programFile = """ -#include "Python.h" +#include #ifdef _WIN32 -#include "malloc.h" +#include #endif %(moduleDefs)s diff --git a/dtool/metalibs/dtoolconfig/pydtool.cxx b/dtool/metalibs/dtoolconfig/pydtool.cxx index b83fb05e11..7f2e0185f6 100644 --- a/dtool/metalibs/dtoolconfig/pydtool.cxx +++ b/dtool/metalibs/dtoolconfig/pydtool.cxx @@ -17,7 +17,7 @@ #if PYTHON_FRAMEWORK #include #else - #include "Python.h" + #include #endif static PyObject *_inP07yttbRf(PyObject *self, PyObject *args); diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 1a2282d83f..425a61a1ae 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -31,13 +31,13 @@ #include "cppSimpleType.h" #include "cppStructType.h" #include "cppExpression.h" -#include "vector" #include "cppParameterList.h" -#include "algorithm" #include "lineStream.h" -#include +#include #include +#include +#include using std::dec; using std::hex; diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.h b/dtool/src/interrogate/interfaceMakerPythonNative.h index 00374397c9..8b18ef1957 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.h +++ b/dtool/src/interrogate/interfaceMakerPythonNative.h @@ -11,8 +11,8 @@ #ifndef INTERFACEMAKERPYTHONNATIVE_H #define INTERFACEMAKERPYTHONNATIVE_H -#include "map" -#include "set" +#include +#include #include "dtoolbase.h" #include "interfaceMakerPython.h" diff --git a/dtool/src/interrogatedb/py_compat.h b/dtool/src/interrogatedb/py_compat.h index fbe49a5287..4872faedc7 100644 --- a/dtool/src/interrogatedb/py_compat.h +++ b/dtool/src/interrogatedb/py_compat.h @@ -29,7 +29,7 @@ // See PEP 353 #define PY_SSIZE_T_CLEAN 1 -#include "Python.h" +#include /* Python 2.4 */ diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 34693e8b90..fa7981697b 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -21,7 +21,7 @@ // py_compat.h includes Python.h. #include "py_compat.h" -#include "structmember.h" +#include using namespace std; diff --git a/dtool/src/prc/configPage.cxx b/dtool/src/prc/configPage.cxx index b7f1d06bd9..af53f66122 100644 --- a/dtool/src/prc/configPage.cxx +++ b/dtool/src/prc/configPage.cxx @@ -22,7 +22,7 @@ #include #ifdef HAVE_OPENSSL -#include "openssl/evp.h" +#include #endif using std::istream; diff --git a/dtool/src/prc/encryptStreamBuf.cxx b/dtool/src/prc/encryptStreamBuf.cxx index 192c1181c6..fe562e59e6 100644 --- a/dtool/src/prc/encryptStreamBuf.cxx +++ b/dtool/src/prc/encryptStreamBuf.cxx @@ -20,8 +20,8 @@ #ifdef HAVE_OPENSSL -#include "openssl/rand.h" -#include "openssl/evp.h" +#include +#include // The iteration count is scaled by this factor for writing to the stream. static const int iteration_count_factor = 1000; diff --git a/dtool/src/prc/prcKeyRegistry.cxx b/dtool/src/prc/prcKeyRegistry.cxx index e505b96ecc..c498d074d1 100644 --- a/dtool/src/prc/prcKeyRegistry.cxx +++ b/dtool/src/prc/prcKeyRegistry.cxx @@ -19,8 +19,8 @@ #ifdef HAVE_OPENSSL -#include "openssl/evp.h" -#include "openssl/pem.h" +#include +#include // Some versions of OpenSSL appear to define this as a macro. Yucky. #undef set_key diff --git a/dtool/src/prckeys/makePrcKey.cxx b/dtool/src/prckeys/makePrcKey.cxx index a6ee834b04..23bf0914b0 100644 --- a/dtool/src/prckeys/makePrcKey.cxx +++ b/dtool/src/prckeys/makePrcKey.cxx @@ -24,11 +24,11 @@ #include PRC_PUBLIC_KEYS_INCLUDE #endif -#include "openssl/rsa.h" -#include "openssl/err.h" -#include "openssl/pem.h" -#include "openssl/rand.h" -#include "openssl/bio.h" +#include +#include +#include +#include +#include using std::cerr; using std::string; diff --git a/dtool/src/prckeys/signPrcFile_src.cxx b/dtool/src/prckeys/signPrcFile_src.cxx index 5e9d04a1b4..f349626ec1 100644 --- a/dtool/src/prckeys/signPrcFile_src.cxx +++ b/dtool/src/prckeys/signPrcFile_src.cxx @@ -24,11 +24,11 @@ #include -#include "openssl/err.h" -#include "openssl/pem.h" -#include "openssl/rand.h" -#include "openssl/bio.h" -#include "openssl/evp.h" +#include +#include +#include +#include +#include using std::cerr; using std::string; diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index 626111ed83..2f7d7e3dcc 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -19,10 +19,11 @@ #include "thread.h" #include "urlSpec.h" +#include "android_native_app_glue.h" + #include "config_display.h" // #define OPENGLES_1 #include "config_androiddisplay.h" -#include #include #include diff --git a/panda/src/audiotraits/fmodAudioSound.h b/panda/src/audiotraits/fmodAudioSound.h index 922ee976b7..112a078138 100644 --- a/panda/src/audiotraits/fmodAudioSound.h +++ b/panda/src/audiotraits/fmodAudioSound.h @@ -61,7 +61,7 @@ #ifndef __FMOD_AUDIO_SOUND_H__ #define __FMOD_AUDIO_SOUND_H__ -#include +#include "pandabase.h" #include "audioSound.h" #include "reMutex.h" diff --git a/panda/src/audiotraits/globalMilesManager.h b/panda/src/audiotraits/globalMilesManager.h index 3e9f2f0084..c48d48e5ba 100644 --- a/panda/src/audiotraits/globalMilesManager.h +++ b/panda/src/audiotraits/globalMilesManager.h @@ -17,11 +17,12 @@ #include "pandabase.h" #ifdef HAVE_RAD_MSS //[ -#include "mss.h" #include "pset.h" #include "lightMutex.h" #include "lightMutexHolder.h" +#include + #ifndef UINTa #define UINTa U32 #endif diff --git a/panda/src/audiotraits/milesAudioManager.h b/panda/src/audiotraits/milesAudioManager.h index 0ff36dbb91..b3df5adad8 100644 --- a/panda/src/audiotraits/milesAudioManager.h +++ b/panda/src/audiotraits/milesAudioManager.h @@ -19,7 +19,6 @@ #ifdef HAVE_RAD_MSS //[ #include "audioManager.h" -#include "mss.h" #include "pset.h" #include "pmap.h" #include "pdeque.h" @@ -30,6 +29,8 @@ #include "conditionVar.h" #include "vector_uchar.h" +#include + class MilesAudioSound; class EXPCL_MILES_AUDIO MilesAudioManager: public AudioManager { diff --git a/panda/src/audiotraits/milesAudioSample.h b/panda/src/audiotraits/milesAudioSample.h index 22f5e5d457..d61f4de553 100644 --- a/panda/src/audiotraits/milesAudioSample.h +++ b/panda/src/audiotraits/milesAudioSample.h @@ -20,7 +20,8 @@ #include "milesAudioSound.h" #include "milesAudioManager.h" -#include "mss.h" + +#include /** * A sound file, such as a WAV or MP3 file, that is preloaded into memory and diff --git a/panda/src/audiotraits/milesAudioSequence.h b/panda/src/audiotraits/milesAudioSequence.h index 2386c6d17b..4ab1fe6d90 100644 --- a/panda/src/audiotraits/milesAudioSequence.h +++ b/panda/src/audiotraits/milesAudioSequence.h @@ -19,7 +19,8 @@ #include "milesAudioSound.h" #include "milesAudioManager.h" -#include "mss.h" + +#include /** * A MIDI file, preloaded and played from a memory buffer. MIDI files cannot diff --git a/panda/src/audiotraits/milesAudioSound.h b/panda/src/audiotraits/milesAudioSound.h index c44584d69a..db5c4118b2 100644 --- a/panda/src/audiotraits/milesAudioSound.h +++ b/panda/src/audiotraits/milesAudioSound.h @@ -19,7 +19,8 @@ #include "audioSound.h" #include "milesAudioManager.h" -#include "mss.h" + +#include /** * The base class for both MilesAudioStream and MilesAudioSample. diff --git a/panda/src/audiotraits/milesAudioStream.h b/panda/src/audiotraits/milesAudioStream.h index 42bda6b6ab..15eac4f285 100644 --- a/panda/src/audiotraits/milesAudioStream.h +++ b/panda/src/audiotraits/milesAudioStream.h @@ -19,7 +19,8 @@ #include "milesAudioSound.h" #include "milesAudioManager.h" -#include "mss.h" + +#include /** * This represents a sound file played by the Miles Sound System, similar to diff --git a/panda/src/awesomium/awWebCore.cxx b/panda/src/awesomium/awWebCore.cxx index 7b1e28f778..adc5989367 100644 --- a/panda/src/awesomium/awWebCore.cxx +++ b/panda/src/awesomium/awWebCore.cxx @@ -13,7 +13,8 @@ #include "config_awesomium.h" #include "awWebCore.h" -#include "WebCore.h" + +#include TypeHandle AwWebCore::_type_handle; diff --git a/panda/src/awesomium/awesomium_includes.h b/panda/src/awesomium/awesomium_includes.h index f892ac06d5..27b8b9b9b0 100644 --- a/panda/src/awesomium/awesomium_includes.h +++ b/panda/src/awesomium/awesomium_includes.h @@ -14,8 +14,8 @@ #ifndef _AWESOMIUM_INCLUDES_H_ #define _AWESOMIUM_INCLUDES_H_ -#include "WebCore.h" -#include "WebView.h" -#include "WebViewListener.h" +#include +#include +#include #endif diff --git a/panda/src/bullet/bullet_includes.h b/panda/src/bullet/bullet_includes.h index 4c11b5f0b7..3b7589469b 100644 --- a/panda/src/bullet/bullet_includes.h +++ b/panda/src/bullet/bullet_includes.h @@ -16,23 +16,23 @@ #include "pandabase.h" -#include "btBulletDynamicsCommon.h" +#include #ifndef CPPPARSER -#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" -#include "BulletCollision/CollisionDispatch/btGhostObject.h" -#include "BulletCollision/CollisionDispatch/btManifoldResult.h" -#include "BulletCollision/CollisionShapes/btConvexPointCloudShape.h" -#include "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h" -#include "BulletCollision/CollisionShapes/btMinkowskiSumShape.h" -#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h" -#include "BulletCollision/Gimpact/btGImpactShape.h" -#include "BulletDynamics/Character/btKinematicCharacterController.h" -#include "BulletDynamics/Vehicle/btRaycastVehicle.h" -#include "BulletSoftBody/btSoftBodyHelpers.h" -#include "BulletSoftBody/btSoftBodyInternals.h" -#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" -#include "BulletSoftBody/btSoftRigidDynamicsWorld.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif #endif // __BULLET_INCLUDES_H__ diff --git a/panda/src/device/clientBase.h b/panda/src/device/clientBase.h index f32b526172..6a3106a385 100644 --- a/panda/src/device/clientBase.h +++ b/panda/src/device/clientBase.h @@ -27,7 +27,7 @@ #include "coordinateSystem.h" #ifdef OLD_HAVE_IPC -#include "ipc_thread.h" +#include #endif #include "pmap.h" diff --git a/panda/src/downloader/bioPtr.cxx b/panda/src/downloader/bioPtr.cxx index eb12b2bd8b..56a288987b 100644 --- a/panda/src/downloader/bioPtr.cxx +++ b/panda/src/downloader/bioPtr.cxx @@ -19,7 +19,7 @@ #include "config_downloader.h" #include "openSSLWrapper.h" // must be included before any other openssl. -#include "openssl/ssl.h" +#include #ifdef _WIN32 #include diff --git a/panda/src/downloader/httpCookie.cxx b/panda/src/downloader/httpCookie.cxx index d09f12b856..6ba75d1abd 100644 --- a/panda/src/downloader/httpCookie.cxx +++ b/panda/src/downloader/httpCookie.cxx @@ -15,9 +15,10 @@ #ifdef HAVE_OPENSSL -#include "ctype.h" #include "httpChannel.h" +#include + using std::string; /** diff --git a/panda/src/downloader/httpDigestAuthorization.cxx b/panda/src/downloader/httpDigestAuthorization.cxx index 1e59ea560c..9b2af25e00 100644 --- a/panda/src/downloader/httpDigestAuthorization.cxx +++ b/panda/src/downloader/httpDigestAuthorization.cxx @@ -17,8 +17,8 @@ #include "httpChannel.h" #include "openSSLWrapper.h" // must be included before any other openssl. -#include "openssl/ssl.h" -#include "openssl/md5.h" +#include +#include #include using std::ostream; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index b7b0f7d3e7..e39e246841 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -66,7 +66,7 @@ #include "config_pgraph.h" #include "shaderGenerator.h" #ifdef HAVE_CG -#include "Cg/cgD3D9.h" +#include #endif #include diff --git a/panda/src/express/hashVal.cxx b/panda/src/express/hashVal.cxx index 3d2e6f42f5..5d74f1dac4 100644 --- a/panda/src/express/hashVal.cxx +++ b/panda/src/express/hashVal.cxx @@ -17,7 +17,7 @@ #ifdef HAVE_OPENSSL #include "openSSLWrapper.h" // must be included before any other openssl. -#include "openssl/md5.h" +#include #endif // HAVE_OPENSSL using std::istream; diff --git a/panda/src/express/openSSLWrapper.h b/panda/src/express/openSSLWrapper.h index 1be8eabb2f..5baabc24c5 100644 --- a/panda/src/express/openSSLWrapper.h +++ b/panda/src/express/openSSLWrapper.h @@ -27,11 +27,11 @@ #define OPENSSL_NO_KRB5 #endif -#include "openssl/ssl.h" -#include "openssl/rand.h" -#include "openssl/err.h" -#include "openssl/x509.h" -#include "openssl/x509v3.h" +#include +#include +#include +#include +#include // Windows may define this macro inappropriately. #ifdef X509_NAME diff --git a/panda/src/express/password_hash.cxx b/panda/src/express/password_hash.cxx index b061904965..06c7571340 100644 --- a/panda/src/express/password_hash.cxx +++ b/panda/src/express/password_hash.cxx @@ -18,7 +18,7 @@ #ifdef HAVE_OPENSSL #include "pnotify.h" -#include "openssl/evp.h" +#include #include "memoryHook.h" using std::string; diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index a527d78a02..5aef4416d1 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -27,7 +27,7 @@ #include // for strstr #ifdef HAVE_TAR -#include "libtar.h" +#include #include // for O_RDONLY #endif // HAVE_TAR diff --git a/panda/src/ffmpeg/config_ffmpeg.cxx b/panda/src/ffmpeg/config_ffmpeg.cxx index 27270757a8..0dbe147d27 100644 --- a/panda/src/ffmpeg/config_ffmpeg.cxx +++ b/panda/src/ffmpeg/config_ffmpeg.cxx @@ -21,9 +21,9 @@ #include "movieTypeRegistry.h" extern "C" { - #include "libavcodec/avcodec.h" - #include "libavformat/avformat.h" - #include "libavutil/avutil.h" + #include + #include + #include } #if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_FFMPEG) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index 621de7fe8a..809797fb85 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -16,15 +16,15 @@ #include "ffmpegAudio.h" extern "C" { - #include "libavutil/dict.h" - #include "libavutil/opt.h" - #include "libavcodec/avcodec.h" - #include "libavformat/avformat.h" + #include + #include + #include + #include } #ifdef HAVE_SWRESAMPLE extern "C" { - #include "libswresample/swresample.h" + #include } #endif diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.h b/panda/src/ffmpeg/ffmpegAudioCursor.h index ff37fa8bc6..f3963ff527 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.h +++ b/panda/src/ffmpeg/ffmpegAudioCursor.h @@ -23,7 +23,7 @@ #include "ffmpegVirtualFile.h" extern "C" { - #include "libavcodec/avcodec.h" + #include } class FfmpegAudio; diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index f8c2163b73..47c6a54ae2 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -20,11 +20,11 @@ #include "ffmpegVideo.h" #include "bamReader.h" extern "C" { - #include "libavcodec/avcodec.h" - #include "libavformat/avformat.h" - #include "libavutil/pixdesc.h" + #include + #include + #include #ifdef HAVE_SWSCALE - #include "libswscale/swscale.h" + #include #endif } diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index 3fd88f640f..8ca576cd90 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -21,8 +21,8 @@ using std::streampos; using std::streamsize; extern "C" { - #include "libavcodec/avcodec.h" - #include "libavformat/avformat.h" + #include + #include } #ifndef AVSEEK_SIZE diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.h b/panda/src/ffmpeg/ffmpegVirtualFile.h index 3e7bd4f796..14514e4f32 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.h +++ b/panda/src/ffmpeg/ffmpegVirtualFile.h @@ -21,7 +21,7 @@ #include extern "C" { - #include "libavformat/avio.h" + #include } struct URLContext; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 3da843c94a..6ce88525f5 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -68,7 +68,7 @@ #include "displayInformation.h" #if defined(HAVE_CG) && !defined(OPENGLES) -#include "Cg/cgGL.h" +#include #endif #include diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index 36f4913085..2942a47467 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -25,9 +25,10 @@ #include "bamCacheRecord.h" #include "bamReader.h" #include "bamWriter.h" -#include "math.h" #include "audioSound.h" +#include + TypeHandle MovieTexture::_type_handle; /** diff --git a/panda/src/mathutil/fftCompressor.cxx b/panda/src/mathutil/fftCompressor.cxx index b8a9764d8f..76d5f52d01 100644 --- a/panda/src/mathutil/fftCompressor.cxx +++ b/panda/src/mathutil/fftCompressor.cxx @@ -29,7 +29,7 @@ #undef howmany #endif -#include "fftw3.h" +#include // These FFTW support objects can only be defined if we actually have the FFTW // library available. diff --git a/panda/src/ode/ode_includes.h b/panda/src/ode/ode_includes.h index 3d3ec15132..fbf670dd13 100644 --- a/panda/src/ode/ode_includes.h +++ b/panda/src/ode/ode_includes.h @@ -35,7 +35,7 @@ #define int32 ode_int32 #define uint32 ode_uint32 -#include "ode/ode.h" +#include // These are the ones that conflict with other defines in Panda. It may be // necessary to add to this list at a later time. diff --git a/panda/src/physx/physxFileStream.cxx b/panda/src/physx/physxFileStream.cxx index a93444148b..61ee73c1c9 100644 --- a/panda/src/physx/physxFileStream.cxx +++ b/panda/src/physx/physxFileStream.cxx @@ -13,7 +13,7 @@ #include "physxFileStream.h" -#include "stdio.h" +#include #include "virtualFileSystem.h" diff --git a/panda/src/physx/physx_includes.h b/panda/src/physx/physx_includes.h index b4dac0da9a..fb46a62fae 100644 --- a/panda/src/physx/physx_includes.h +++ b/panda/src/physx/physx_includes.h @@ -15,7 +15,7 @@ #define PHYSX_INCLUDES_H // This one is safe to include -#include "NxVersionNumber.h" +#include // Platform-specific defines #if defined(_WIN64) @@ -49,15 +49,15 @@ // PhysX headers -#include "Nxp.h" -#include "NxPhysics.h" -#include "NxExtended.h" -#include "NxStream.h" -#include "NxCooking.h" -#include "NxController.h" -#include "NxControllerManager.h" -#include "NxBoxController.h" -#include "NxCapsuleController.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // PHYSX_INCLUDES_H diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index 48cda1204b..b00af199bb 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -35,7 +35,7 @@ #include "pStatTimer.h" #ifdef SPEEDTREE_OPENGL -#include "glew/glew.h" +#include #endif // SPEEDTREE_OPENGL #ifdef SPEEDTREE_DIRECTX9 diff --git a/panda/src/speedtree/speedtree_api.h b/panda/src/speedtree/speedtree_api.h index 54252ed163..29761a97a4 100644 --- a/panda/src/speedtree/speedtree_api.h +++ b/panda/src/speedtree/speedtree_api.h @@ -18,14 +18,14 @@ // headers from the SpeedTree API, needed in this directory. #include "speedtree_parameters.h" -#include "Core/Core.h" -#include "Forest/Forest.h" +#include +#include #if defined(SPEEDTREE_OPENGL) - #include "Renderers/OpenGL/OpenGLRenderer.h" + #include #elif defined(SPEEDTREE_DIRECTX9) #undef Configure - #include "Renderers/DirectX9/DirectX9Renderer.h" + #include #else #error Unexpected graphics API. #endif diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.h b/panda/src/tinydisplay/tinySDLGraphicsWindow.h index b1be27b557..8073663ce5 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.h +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.h @@ -21,9 +21,10 @@ #include "tinySDLGraphicsPipe.h" #include "graphicsWindow.h" #include "buttonHandle.h" -#include "SDL.h" #include "zbuffer.h" +#include + /** * This graphics window class is implemented via SDL. */ diff --git a/panda/src/tinydisplay/vertex.cxx b/panda/src/tinydisplay/vertex.cxx index 5410f963bd..03eb032e3e 100644 --- a/panda/src/tinydisplay/vertex.cxx +++ b/panda/src/tinydisplay/vertex.cxx @@ -1,5 +1,5 @@ #include "zgl.h" -#include "string.h" +#include void gl_eval_viewport(GLContext * c) { GLViewport *v = &c->viewport; diff --git a/panda/src/vision/arToolKit.cxx b/panda/src/vision/arToolKit.cxx index cb9a73508d..4208ba6eee 100644 --- a/panda/src/vision/arToolKit.cxx +++ b/panda/src/vision/arToolKit.cxx @@ -22,7 +22,7 @@ #include "compose_matrix.h" #include "config_vision.h" extern "C" { - #include "AR/ar.h" + #include }; ARToolKit::PatternTable ARToolKit::_pattern_table; diff --git a/panda/src/vrpn/vrpn_interface.h b/panda/src/vrpn/vrpn_interface.h index c85c05e31b..a16c899aaf 100644 --- a/panda/src/vrpn/vrpn_interface.h +++ b/panda/src/vrpn/vrpn_interface.h @@ -21,14 +21,14 @@ // Prevent VRPN from defining this function, which we don't need, // and cause compilation errors in MSVC 2015. -#include "vrpn_Configure.h" +#include #undef VRPN_EXPORT_GETTIMEOFDAY -#include "vrpn_Connection.h" -#include "vrpn_Tracker.h" -#include "vrpn_Analog.h" -#include "vrpn_Button.h" -#include "vrpn_Dial.h" +#include +#include +#include +#include +#include #ifdef sleep #undef sleep diff --git a/panda/src/windisplay/winGraphicsPipe.cxx b/panda/src/windisplay/winGraphicsPipe.cxx index 6f19ca2f14..7da40c64f1 100644 --- a/panda/src/windisplay/winGraphicsPipe.cxx +++ b/panda/src/windisplay/winGraphicsPipe.cxx @@ -18,8 +18,8 @@ #include "dtool_config.h" #include "pbitops.h" -#include "psapi.h" -#include "powrprof.h" +#include +#include #include TypeHandle WinGraphicsPipe::_type_handle; diff --git a/pandatool/src/daeegg/daeCharacter.cxx b/pandatool/src/daeegg/daeCharacter.cxx index 39aee067bd..a73071d9d4 100644 --- a/pandatool/src/daeegg/daeCharacter.cxx +++ b/pandatool/src/daeegg/daeCharacter.cxx @@ -21,16 +21,16 @@ #include "eggExternalReference.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDSceneNodeTools.h" +#include +#include +#include +#include -#include "FCDocument/FCDSceneNode.h" -#include "FCDocument/FCDTransform.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDAnimationCurve.h" -#include "FCDocument/FCDAnimationKey.h" +#include +#include +#include +#include +#include TypeHandle DaeCharacter::_type_handle; diff --git a/pandatool/src/daeegg/daeCharacter.h b/pandatool/src/daeegg/daeCharacter.h index 25378b684d..97b8aea384 100644 --- a/pandatool/src/daeegg/daeCharacter.h +++ b/pandatool/src/daeegg/daeCharacter.h @@ -21,11 +21,11 @@ #include "epvector.h" #include "pre_fcollada_include.h" -#include "FCollada.h" -#include "FCDocument/FCDSceneNode.h" -#include "FCDocument/FCDControllerInstance.h" -#include "FCDocument/FCDSkinController.h" -#include "FCDocument/FCDGeometryMesh.h" +#include +#include +#include +#include +#include class DAEToEggConverter; diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx index 6aab105cc7..36bf6fd895 100644 --- a/pandatool/src/daeegg/daeMaterials.cxx +++ b/pandatool/src/daeegg/daeMaterials.cxx @@ -15,12 +15,12 @@ #include "config_daeegg.h" #include "fcollada_utils.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDMaterial.h" -#include "FCDocument/FCDEffect.h" -#include "FCDocument/FCDTexture.h" -#include "FCDocument/FCDEffectParameterSampler.h" -#include "FCDocument/FCDImage.h" +#include +#include +#include +#include +#include +#include #include "filename.h" #include "string_utils.h" diff --git a/pandatool/src/daeegg/daeMaterials.h b/pandatool/src/daeegg/daeMaterials.h index c18e631535..08cfed03d3 100644 --- a/pandatool/src/daeegg/daeMaterials.h +++ b/pandatool/src/daeegg/daeMaterials.h @@ -24,12 +24,12 @@ #include "pt_EggMaterial.h" #include "pre_fcollada_include.h" -#include "FCollada.h" -#include "FCDocument/FCDGeometryInstance.h" -#include "FCDocument/FCDMaterialInstance.h" -#include "FCDocument/FCDEffectStandard.h" -#include "FCDocument/FCDEffectParameterSampler.h" -#include "FCDocument/FCDExtra.h" +#include +#include +#include +#include +#include +#include /** * This class is seperated from the converter file because otherwise it would diff --git a/pandatool/src/daeegg/daeToEggConverter.cxx b/pandatool/src/daeegg/daeToEggConverter.cxx index 00c20a36da..a923a67264 100644 --- a/pandatool/src/daeegg/daeToEggConverter.cxx +++ b/pandatool/src/daeegg/daeToEggConverter.cxx @@ -28,24 +28,24 @@ #include "eggSAnimData.h" #include "pt_EggVertex.h" -#include "FCDocument/FCDAsset.h" -#include "FCDocument/FCDocumentTools.h" -#include "FCDocument/FCDSceneNode.h" -#include "FCDocument/FCDSceneNodeTools.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometryInstance.h" -#include "FCDocument/FCDGeometryPolygons.h" -#include "FCDocument/FCDGeometrySource.h" -#include "FCDocument/FCDSkinController.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDControllerInstance.h" -#include "FCDocument/FCDMorphController.h" -#include "FCDocument/FCDMaterialInstance.h" -#include "FCDocument/FCDExtra.h" -#include "FCDocument/FCDEffect.h" -#include "FCDocument/FCDEffectStandard.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if FCOLLADA_VERSION >= 0x00030005 - #include "FCDocument/FCDGeometryPolygonsInput.h" + #include #endif using std::endl; diff --git a/pandatool/src/daeegg/daeToEggConverter.h b/pandatool/src/daeegg/daeToEggConverter.h index a1203c2f2c..bb3b6f550b 100644 --- a/pandatool/src/daeegg/daeToEggConverter.h +++ b/pandatool/src/daeegg/daeToEggConverter.h @@ -23,15 +23,15 @@ #include "eggNurbsCurve.h" #include "pre_fcollada_include.h" -#include "FCollada.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDTransform.h" -#include "FCDocument/FCDEntityInstance.h" -#include "FCDocument/FCDControllerInstance.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometrySpline.h" -#include "FCDocument/FCDMaterial.h" -#include "FMath/FMMatrix44.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "daeMaterials.h" #include "daeCharacter.h" diff --git a/pandatool/src/daeegg/fcollada_utils.h b/pandatool/src/daeegg/fcollada_utils.h index cf1a3069f3..3a8ae692e4 100644 --- a/pandatool/src/daeegg/fcollada_utils.h +++ b/pandatool/src/daeegg/fcollada_utils.h @@ -18,7 +18,7 @@ #define FCOLLADA_UTILS_H #include "pre_fcollada_include.h" -#include "FCollada.h" +#include // Useful conversion stuff inline LVecBase3d TO_VEC3(FMVector3 v) { diff --git a/pandatool/src/daeprogs/eggToDAE.cxx b/pandatool/src/daeprogs/eggToDAE.cxx index b9652e698f..d3c616c3c4 100644 --- a/pandatool/src/daeprogs/eggToDAE.cxx +++ b/pandatool/src/daeprogs/eggToDAE.cxx @@ -15,9 +15,9 @@ #include "dcast.h" #include "pandaVersion.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAsset.h" -#include "FCDocument/FCDTransform.h" +#include +#include +#include // Useful conversion stuff #define TO_VEC3(v) (LVecBase3d(v[0], v[1], v[2])) diff --git a/pandatool/src/daeprogs/eggToDAE.h b/pandatool/src/daeprogs/eggToDAE.h index 5a13546485..c7782a421e 100644 --- a/pandatool/src/daeprogs/eggToDAE.h +++ b/pandatool/src/daeprogs/eggToDAE.h @@ -20,8 +20,8 @@ #include "eggTransform.h" #include "pre_fcollada_include.h" -#include "FCollada.h" -#include "FCDocument/FCDSceneNode.h" +#include +#include /** * A program to read an egg file and write a DAE file. diff --git a/pandatool/src/maxegg/maxEgg.h b/pandatool/src/maxegg/maxEgg.h index 2d9765ee01..97d9b1dea4 100644 --- a/pandatool/src/maxegg/maxEgg.h +++ b/pandatool/src/maxegg/maxEgg.h @@ -18,12 +18,11 @@ #include #include #include -#include "errno.h" +#include using std::min; using std::max; -#include "Max.h" #include "eggGroup.h" #include "eggTable.h" #include "eggXfmSAnim.h" @@ -31,26 +30,25 @@ using std::max; #include "referenceCount.h" #include "pointerTo.h" #include "namable.h" -#include "modstack.h" #include #include #include #define WIN32_LEAN_AND_MEAN -#include "windef.h" -#include "windows.h" +#include +#include -#include "Max.h" -#include "iparamb2.h" -#include "iparamm2.h" -#include "istdplug.h" -#include "iskin.h" -#include "maxResource.h" -#include "stdmat.h" -#include "phyexp.h" -#include "surf_api.h" -#include "bipexp.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "eggCoordinateSystem.h" #include "eggGroup.h" @@ -67,6 +65,7 @@ using std::max; #include "maxNodeDesc.h" #include "maxNodeTree.h" #include "maxOptionsDialog.h" +#include "maxResource.h" #include "maxToEggConverter.h" #define MaxEggPlugin_CLASS_ID Class_ID(0x7ac0d6b7, 0x55731ef6) diff --git a/pandatool/src/maxegg/maxEggLoader.cxx b/pandatool/src/maxegg/maxEggLoader.cxx index a6855657e6..09970789c3 100644 --- a/pandatool/src/maxegg/maxEggLoader.cxx +++ b/pandatool/src/maxegg/maxEggLoader.cxx @@ -30,15 +30,15 @@ using std::min; using std::max; #include -#include "Max.h" -#include "istdplug.h" -#include "stdmat.h" -#include "decomp.h" -#include "shape.h" -#include "simpobj.h" -#include "iparamb2.h" -#include "iskin.h" -#include "modstack.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "maxEggLoader.h" diff --git a/pandatool/src/maxprogs/maxEggImport.cxx b/pandatool/src/maxprogs/maxEggImport.cxx index 08a0184a8e..3776da2097 100644 --- a/pandatool/src/maxprogs/maxEggImport.cxx +++ b/pandatool/src/maxprogs/maxEggImport.cxx @@ -25,11 +25,13 @@ using std::min; using std::max; -// MAX includes +// local includes #include "maxEggLoader.h" -#include "Max.h" #include "maxImportRes.h" -#include "istdplug.h" + +// MAX includes +#include +#include // panda includes. #include "notifyCategoryProxy.h" From d62c2bf132b4cf67261170406a70943bd292c94c Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 12 Nov 2018 12:01:56 +0100 Subject: [PATCH 328/360] Remove unfinished native COLLADA loader --- panda/src/collada/colladaBindMaterial.cxx | 93 ---- panda/src/collada/colladaBindMaterial.h | 41 -- panda/src/collada/colladaInput.I | 28 -- panda/src/collada/colladaInput.cxx | 265 ---------- panda/src/collada/colladaInput.h | 77 --- panda/src/collada/colladaLoader.I | 12 - panda/src/collada/colladaLoader.cxx | 549 --------------------- panda/src/collada/colladaLoader.h | 76 --- panda/src/collada/colladaPrimitive.I | 40 -- panda/src/collada/colladaPrimitive.cxx | 293 ----------- panda/src/collada/colladaPrimitive.h | 71 --- panda/src/collada/config_collada.cxx | 87 ---- panda/src/collada/config_collada.h | 36 -- panda/src/collada/load_collada_file.cxx | 92 ---- panda/src/collada/load_collada_file.h | 36 -- panda/src/collada/loaderFileTypeDae.cxx | 74 --- panda/src/collada/loaderFileTypeDae.h | 54 -- panda/src/collada/p3collada_composite1.cxx | 3 - panda/src/collada/pre_collada_include.h | 28 -- 19 files changed, 1955 deletions(-) delete mode 100644 panda/src/collada/colladaBindMaterial.cxx delete mode 100644 panda/src/collada/colladaBindMaterial.h delete mode 100644 panda/src/collada/colladaInput.I delete mode 100644 panda/src/collada/colladaInput.cxx delete mode 100644 panda/src/collada/colladaInput.h delete mode 100644 panda/src/collada/colladaLoader.I delete mode 100644 panda/src/collada/colladaLoader.cxx delete mode 100644 panda/src/collada/colladaLoader.h delete mode 100644 panda/src/collada/colladaPrimitive.I delete mode 100644 panda/src/collada/colladaPrimitive.cxx delete mode 100644 panda/src/collada/colladaPrimitive.h delete mode 100644 panda/src/collada/config_collada.cxx delete mode 100644 panda/src/collada/config_collada.h delete mode 100644 panda/src/collada/load_collada_file.cxx delete mode 100644 panda/src/collada/load_collada_file.h delete mode 100644 panda/src/collada/loaderFileTypeDae.cxx delete mode 100644 panda/src/collada/loaderFileTypeDae.h delete mode 100644 panda/src/collada/p3collada_composite1.cxx delete mode 100644 panda/src/collada/pre_collada_include.h diff --git a/panda/src/collada/colladaBindMaterial.cxx b/panda/src/collada/colladaBindMaterial.cxx deleted file mode 100644 index 90ea8a21cf..0000000000 --- a/panda/src/collada/colladaBindMaterial.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/** - * 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." - * - * @file colladaBindMaterial.cxx - * @author rdb - * @date 2011-05-26 - */ - -#include "colladaBindMaterial.h" -#include "colladaPrimitive.h" - -// Collada DOM includes. No other includes beyond this point. -#include "pre_collada_include.h" -#include -#include -#include -#include -#include - -#if PANDA_COLLADA_VERSION >= 15 -#include -#else -#include -#define domFx_profile domFx_profile_abstract -#define domFx_profile_Array domFx_profile_abstract_Array -#define getFx_profile_array getFx_profile_abstract_array -#endif - -/** - * Returns the material to be applied to the given primitive, or NULL if there - * was none bound. - */ -CPT(RenderState) ColladaBindMaterial:: -get_material(const ColladaPrimitive *prim) const { - if (prim == nullptr || _states.count(prim->get_material()) == 0) { - return nullptr; - } - return _states.find(prim->get_material())->second; -} - -/** - * Returns the bound material with the indicated symbol, or NULL if it was not - * found. - */ -CPT(RenderState) ColladaBindMaterial:: -get_material(const std::string &symbol) const { - if (_states.count(symbol) == 0) { - return nullptr; - } - return _states.find(symbol)->second; -} - -/** - * Loads a bind_material object. - */ -void ColladaBindMaterial:: -load_bind_material(domBind_material &bind_mat) { - domInstance_material_Array &mat_instances - = bind_mat.getTechnique_common()->getInstance_material_array(); - - for (size_t i = 0; i < mat_instances.getCount(); ++i) { - load_instance_material(*mat_instances[i]); - } -} - -/** - * Loads an instance_material object. - */ -void ColladaBindMaterial:: -load_instance_material(domInstance_material &inst) { - domMaterialRef mat = daeSafeCast (inst.getTarget().getElement()); - nassertv(mat != nullptr); - - domInstance_effectRef einst = mat->getInstance_effect(); - nassertv(einst != nullptr); - - domInstance_effect::domSetparam_Array &setparams = einst->getSetparam_array(); - - domEffectRef effect = daeSafeCast - (mat->getInstance_effect()->getUrl().getElement()); - - // TODO: read params - - const domFx_profile_Array &profiles = effect->getFx_profile_array(); - for (size_t i = 0; i < profiles.getCount(); ++i) { - // profiles[i]-> - } -} diff --git a/panda/src/collada/colladaBindMaterial.h b/panda/src/collada/colladaBindMaterial.h deleted file mode 100644 index 2c56f77c78..0000000000 --- a/panda/src/collada/colladaBindMaterial.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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." - * - * @file colladaBindMaterial.h - * @author rdb - * @date 2011-05-25 - */ - -#ifndef COLLADABINDMATERIAL_H -#define COLLADABINDMATERIAL_H - -#include "config_collada.h" -#include "renderState.h" -#include "pmap.h" - -class ColladaPrimitive; - -class domBind_material; -class domInstance_material; - -/** - * Class that deals with binding materials to COLLADA geometry. - */ -class ColladaBindMaterial { -public: - CPT(RenderState) get_material(const ColladaPrimitive *prim) const; - CPT(RenderState) get_material(const std::string &symbol) const; - - void load_bind_material(domBind_material &bind_mat); - void load_instance_material(domInstance_material &inst); - -private: - pmap _states; -}; - -#endif diff --git a/panda/src/collada/colladaInput.I b/panda/src/collada/colladaInput.I deleted file mode 100644 index 15177ed8fe..0000000000 --- a/panda/src/collada/colladaInput.I +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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." - * - * @file colladaInput.I - * @author rdb - * @date 2011-05-23 - */ - -/** - * Returns true if this has a element as source. - */ -bool ColladaInput:: -is_vertex_source() const { - return (_semantic == "VERTEX"); -} - -/** - * Returns the offset associated with this input. - */ -unsigned int ColladaInput:: -get_offset() const { - return _offset; -} diff --git a/panda/src/collada/colladaInput.cxx b/panda/src/collada/colladaInput.cxx deleted file mode 100644 index 09ce788655..0000000000 --- a/panda/src/collada/colladaInput.cxx +++ /dev/null @@ -1,265 +0,0 @@ -/** - * 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." - * - * @file colladaInput.cxx - * @author rdb - * @date 2011-05-23 - */ - -#include "colladaInput.h" -#include "string_utils.h" -#include "geomVertexArrayFormat.h" -#include "geomVertexWriter.h" - -// Collada DOM includes. No other includes beyond this point. -#include "pre_collada_include.h" -#include -#include -#include -#include - -#if PANDA_COLLADA_VERSION >= 15 -#include -#include -#else -#include -#include -#define domList_of_floats domListOfFloats -#define domList_of_uints domListOfUInts -#endif - -/** - * Pretty obvious what this does. - */ -ColladaInput:: -ColladaInput(const std::string &semantic) : - _column_name (nullptr), - _semantic (semantic), - _offset (0), - _have_set (false), - _set (0) { - - if (semantic == "POSITION") { - _column_name = InternalName::get_vertex(); - _column_contents = GeomEnums::C_point; - } else if (semantic == "COLOR") { - _column_name = InternalName::get_color(); - _column_contents = GeomEnums::C_color; - } else if (semantic == "NORMAL") { - _column_name = InternalName::get_normal(); - _column_contents = GeomEnums::C_vector; - } else if (semantic == "TEXCOORD") { - _column_name = InternalName::get_texcoord(); - _column_contents = GeomEnums::C_texcoord; - } else if (semantic == "TEXBINORMAL") { - _column_name = InternalName::get_binormal(); - _column_contents = GeomEnums::C_vector; - } else if (semantic == "TEXTANGENT") { - _column_name = InternalName::get_tangent(); - _column_contents = GeomEnums::C_vector; - } -} - -/** - * Pretty obvious what this does. - */ -ColladaInput:: -ColladaInput(const std::string &semantic, unsigned int set) : - _column_name (nullptr), - _semantic (semantic), - _offset (0), - _have_set (true), - _set (set) { - - std::ostringstream setstr; - setstr << _set; - - if (semantic == "POSITION") { - _column_name = InternalName::get_vertex(); - _column_contents = GeomEnums::C_point; - } else if (semantic == "COLOR") { - _column_name = InternalName::get_color(); - _column_contents = GeomEnums::C_color; - } else if (semantic == "NORMAL") { - _column_name = InternalName::get_normal(); - _column_contents = GeomEnums::C_vector; - } else if (semantic == "TEXCOORD") { - _column_name = InternalName::get_texcoord_name(setstr.str()); - _column_contents = GeomEnums::C_texcoord; - } else if (semantic == "TEXBINORMAL") { - _column_name = InternalName::get_binormal_name(setstr.str()); - _column_contents = GeomEnums::C_vector; - } else if (semantic == "TEXTANGENT") { - _column_name = InternalName::get_tangent_name(setstr.str()); - _column_contents = GeomEnums::C_vector; - } -} - -/** - * Returns the ColladaInput object that represents the provided DOM input - * element. - */ -ColladaInput *ColladaInput:: -from_dom(domInput_local_offset &input) { - // If we already loaded it before, use that. - if (input.getUserData() != nullptr) { - return (ColladaInput *) input.getUserData(); - } - - ColladaInput *new_input = new ColladaInput(input.getSemantic(), input.getSet()); - new_input->_offset = input.getOffset(); - - // If this has the VERTEX semantic, it points to a element. - if (new_input->is_vertex_source()) { - domVertices *verts = daeSafeCast (input.getSource().getElement()); - nassertr(verts != nullptr, nullptr); - daeTArray &inputs = verts->getInput_array(); - - // Iterate over the elements in . - for (size_t i = 0; i < inputs.getCount(); ++i) { - PT(ColladaInput) vtx_input = ColladaInput::from_dom(*inputs[i]); - new_input->_vertex_inputs.push_back(vtx_input); - } - } else { - domSource *source = daeSafeCast (input.getSource().getElement()); - nassertr(source != nullptr, nullptr); - new_input->read_data(*source); - } - - return new_input; -} - -/** - * Returns the ColladaInput object that represents the provided DOM input - * element. - */ -ColladaInput *ColladaInput:: -from_dom(domInput_local &input) { - // If we already loaded it before, use that. - if (input.getUserData() != nullptr) { - return (ColladaInput *) input.getUserData(); - } - - ColladaInput *new_input = new ColladaInput(input.getSemantic()); - new_input->_offset = 0; - - nassertr (!new_input->is_vertex_source(), nullptr); - - domSource *source = daeSafeCast (input.getSource().getElement()); - nassertr(source != nullptr, nullptr); - new_input->read_data(*source); - - return new_input; -} - -/** - * Takes a semantic and source URI, and adds a new column to the format. If - * this is a vertex source, adds all of the inputs from the corresponding - * element. Returns the number of columns added to the format. - */ -int ColladaInput:: -make_vertex_columns(GeomVertexArrayFormat *format) const { - - if (is_vertex_source()) { - int counter = 0; - Inputs::const_iterator it; - for (it = _vertex_inputs.begin(); it != _vertex_inputs.end(); ++it) { - counter += (*it)->make_vertex_columns(format); - } - return counter; - } - - nassertr(_column_name != nullptr, 0); - - format->add_column(_column_name, _num_bound_params, GeomEnums::NT_stdfloat, _column_contents); - return 1; -} - -/** - * Reads the data from the source and fills in _data. - */ -bool ColladaInput:: -read_data(domSource &source) { - _data.clear(); - - // Get this, get that - domFloat_array* float_array = source.getFloat_array(); - if (float_array == nullptr) { - return false; - } - - domList_of_floats &floats = float_array->getValue(); - domAccessor &accessor = *source.getTechnique_common()->getAccessor(); - domParam_Array ¶ms = accessor.getParam_array(); - - // Count the number of params that have a name attribute. - _num_bound_params = 0; - for (size_t p = 0; p < params.getCount(); ++p) { - if (params[p]->getName()) { - ++_num_bound_params; - } - } - - _data.reserve(accessor.getCount()); - - domUint pos = accessor.getOffset(); - for (domUint a = 0; a < accessor.getCount(); ++a) { - domUint c = 0; - // Yes, the last component defaults to 1 to work around a perspective - // divide that Panda3D does internally for points. - LVecBase4f v (0, 0, 0, 1); - for (domUint p = 0; p < params.getCount(); ++p) { - if (params[c]->getName()) { - v[c++] = floats[pos + p]; - } - } - _data.push_back(v); - pos += accessor.getStride(); - } - - return true; -} - -/** - * Writes data to the indicated GeomVertexData using the given indices. - */ -void ColladaInput:: -write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride) const { - if (is_vertex_source()) { - Inputs::const_iterator it; - for (it = _vertex_inputs.begin(); it != _vertex_inputs.end(); ++it) { - (*it)->write_data(vdata, start_row, p, stride, _offset); - } - - } else { - write_data(vdata, start_row, p, stride, _offset); - } -} - -/** - * Called internally by the other write_data. - */ -void ColladaInput:: -write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride, unsigned int offset) const { - nassertv(_column_name != nullptr); - GeomVertexWriter writer (vdata, _column_name); - writer.set_row_unsafe(start_row); - - domList_of_uints &indices = p.getValue(); - - // Allocate space for all the rows we're going to write. - int min_length = start_row + indices.getCount() / stride; - if (vdata->get_num_rows() < min_length) { - vdata->unclean_set_num_rows(start_row); - } - - for (size_t i = 0; i < indices.getCount(); i += stride) { - size_t index = indices[i + offset]; - writer.add_data4f(_data[index]); - } -} diff --git a/panda/src/collada/colladaInput.h b/panda/src/collada/colladaInput.h deleted file mode 100644 index 7df605c73c..0000000000 --- a/panda/src/collada/colladaInput.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * 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." - * - * @file colladaInput.h - * @author rdb - * @date 2011-05-23 - */ - -#ifndef COLLADAINPUT_H -#define COLLADAINPUT_H - -#include "config_collada.h" -#include "referenceCount.h" -#include "pvector.h" -#include "pta_LVecBase4.h" -#include "internalName.h" -#include "geomEnums.h" - -class GeomPrimitive; -class GeomVertexArrayFormat; -class GeomVertexData; - -#if PANDA_COLLADA_VERSION < 15 -#define domInput_local domInputLocal -#define domInput_localRef domInputLocalRef -#define domInput_local_offset domInputLocalOffset -#define domInput_local_offsetRef domInputLocalOffsetRef -#endif - -class domInput_local; -class domInput_local_offset; -class domP; -class domSource; - -/** - * Class that deals with COLLADA data sources. - */ -class ColladaInput : public ReferenceCount { -public: - static ColladaInput *from_dom(domInput_local_offset &input); - static ColladaInput *from_dom(domInput_local &input); - - int make_vertex_columns(GeomVertexArrayFormat *fmt) const; - void write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride) const; - - INLINE bool is_vertex_source() const; - INLINE unsigned int get_offset() const; - -private: - ColladaInput(const std::string &semantic); - ColladaInput(const std::string &semantic, unsigned int set); - bool read_data(domSource &source); - void write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride, unsigned int offset) const; - - typedef pvector Inputs; - Inputs _vertex_inputs; - PTA_LVecBase4f _data; - - // Only filled in when appropriate. - PT(InternalName) _column_name; - GeomEnums::Contents _column_contents; - - unsigned int _num_bound_params; - unsigned int _offset; - std::string _semantic; - bool _have_set; - unsigned int _set; -}; - -#include "colladaInput.I" - -#endif diff --git a/panda/src/collada/colladaLoader.I b/panda/src/collada/colladaLoader.I deleted file mode 100644 index 2c03d60d16..0000000000 --- a/panda/src/collada/colladaLoader.I +++ /dev/null @@ -1,12 +0,0 @@ -/** - * 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." - * - * @file colladaLoader.I - * @author rdb - * @date 2011-03-16 - */ diff --git a/panda/src/collada/colladaLoader.cxx b/panda/src/collada/colladaLoader.cxx deleted file mode 100644 index 1347d492a1..0000000000 --- a/panda/src/collada/colladaLoader.cxx +++ /dev/null @@ -1,549 +0,0 @@ -/** - * 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." - * - * @file colladaLoader.cxx - * @author Xidram - * @date 2010-12-21 - */ - -#include "colladaLoader.h" -#include "virtualFileSystem.h" -#include "luse.h" -#include "string_utils.h" -#include "geomNode.h" -#include "geomVertexWriter.h" -#include "geomTriangles.h" -#include "lightNode.h" -#include "lightAttrib.h" -#include "ambientLight.h" -#include "directionalLight.h" -#include "pointLight.h" -#include "spotlight.h" - -#include "colladaBindMaterial.h" -#include "colladaPrimitive.h" - -// Collada DOM includes. No other includes beyond this point. -#include "pre_collada_include.h" -#include -#include -#include -#include -#include -#include - -#if PANDA_COLLADA_VERSION >= 15 -#include -#else -#include -#define domInstance_with_extra domInstanceWithExtra -#define domTargetable_floatRef domTargetableFloatRef -#endif - -#define TOSTRING(x) (x == nullptr ? "" : x) - -/** - * - */ -ColladaLoader:: -ColladaLoader() : - _record (nullptr), - _cs (CS_default), - _error (false), - _root (nullptr), - _collada (nullptr) { - - _dae = new DAE; -} - -/** - * - */ -ColladaLoader:: -~ColladaLoader() { - delete _dae; -} - -/** - * Reads from the indicated file. - */ -bool ColladaLoader:: -read(const Filename &filename) { - _filename = filename; - - std::string data; - VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - - if (!vfs->read_file(_filename, data, true)) { - collada_cat.error() - << "Error reading " << _filename << "\n"; - _error = true; - return false; - } - - _collada = _dae->openFromMemory(_filename.to_os_specific(), data.c_str()); - _error = (_collada == nullptr); - return !_error; -} - -/** - * Converts scene graph structures into a Panda3D scene graph, with _root - * being the root node. - */ -void ColladaLoader:: -build_graph() { - nassertv(_collada); // read() must be called first - nassertv(!_error); // and have succeeded - - _root = new ModelRoot(_filename.get_basename()); - - domCOLLADA::domScene* scene = _collada->getScene(); - domInstance_with_extra* inst = scene->getInstance_visual_scene(); - domVisual_scene* vscene = daeSafeCast (inst->getUrl().getElement()); - if (vscene) { - load_visual_scene(*vscene, _root); - } -} - -/** - * Loads a visual scene structure. - */ -void ColladaLoader:: -load_visual_scene(domVisual_scene& scene, PandaNode *parent) { - // If we already loaded it before, instantiate the stored node. - if (scene.getUserData() != nullptr) { - parent->add_child((PandaNode *) scene.getUserData()); - return; - } - - PT(PandaNode) pnode = new PandaNode(TOSTRING(scene.getName())); - scene.setUserData((void *) pnode); - parent->add_child(pnode); - - // Load in any tags. - domExtra_Array &extras = scene.getExtra_array(); - for (size_t i = 0; i < extras.getCount(); ++i) { - load_tags(*extras[i], pnode); - } - - // Now load in the child nodes. - domNode_Array &nodes = scene.getNode_array(); - for (size_t i = 0; i < nodes.getCount(); ++i) { - load_node(*nodes[i], pnode); - } - - // Apply any lights we've encountered to the visual scene. - if (_lights.size() > 0) { - CPT(LightAttrib) lattr = DCAST(LightAttrib, LightAttrib::make()); - pvector::iterator it; - for (it = _lights.begin(); it != _lights.end(); ++it) { - lattr = DCAST(LightAttrib, lattr->add_on_light(*it)); - } - pnode->set_state(RenderState::make(lattr)); - - _lights.clear(); - } -} - -/** - * Loads a COLLADA . - */ -void ColladaLoader:: -load_node(domNode& node, PandaNode *parent) { - // If we already loaded it before, instantiate the stored node. - if (node.getUserData() != nullptr) { - parent->add_child((PandaNode *) node.getUserData()); - return; - } - - // Create the node. - PT(PandaNode) pnode; - pnode = new PandaNode(TOSTRING(node.getName())); - node.setUserData((void *) pnode); - parent->add_child(pnode); - - // Apply the transformation elements in reverse order. - LMatrix4f transform (LMatrix4f::ident_mat()); - - daeElementRefArray &elements = node.getContents(); - for (size_t i = elements.getCount(); i > 0; --i) { - daeElementRef &elem = elements[i - 1]; - - switch (elem->getElementType()) { - case COLLADA_TYPE::LOOKAT: { - // Didn't test this, but *should* be right. - domFloat3x3 &l = (daeSafeCast(elem))->getValue(); - LPoint3f eye (l[0], l[1], l[2]); - LVector3f up (l[6], l[7], l[8]); - LVector3f forward = LPoint3f(l[3], l[4], l[5]) - eye; - forward.normalize(); - LVector3f side = forward.cross(up); - side.normalize(); - up = side.cross(forward); - LMatrix4f mat (LMatrix4f::ident_mat()); - mat.set_col(0, side); - mat.set_col(1, up); - mat.set_col(2, -forward); - transform *= mat; - transform *= LMatrix4f::translate_mat(-eye); - break; - } - case COLLADA_TYPE::MATRIX: { - domFloat4x4 &m = (daeSafeCast(elem))->getValue(); - transform *= LMatrix4f( - m[0], m[4], m[ 8], m[12], - m[1], m[5], m[ 9], m[13], - m[2], m[6], m[10], m[14], - m[3], m[7], m[11], m[15]); - break; - } - case COLLADA_TYPE::ROTATE: { - domFloat4 &r = (daeSafeCast(elem))->getValue(); - transform *= LMatrix4f::rotate_mat(r[3], LVecBase3f(r[0], r[1], r[2])); - break; - } - case COLLADA_TYPE::SCALE: { - domFloat3 &s = (daeSafeCast(elem))->getValue(); - transform *= LMatrix4f::scale_mat(s[0], s[1], s[2]); - break; - } - case COLLADA_TYPE::SKEW: - // FIXME: implement skew - collada_cat.error() << " not supported yet\n"; - break; - case COLLADA_TYPE::TRANSLATE: { - domFloat3 &t = (daeSafeCast(elem))->getValue(); - transform *= LMatrix4f::translate_mat(t[0], t[1], t[2]); - break; - } - } - } - // TODO: convert coordinate systems transform *= LMatrix4f::convert_mat(XXX, - // _cs); - - // If there's a transform, set it. - if (transform != LMatrix4f::ident_mat()) { - pnode->set_transform(TransformState::make_mat(transform)); - } - - // See if this node instantiates any cameras. - domInstance_camera_Array &caminst = node.getInstance_camera_array(); - for (size_t i = 0; i < caminst.getCount(); ++i) { - domCamera* target = daeSafeCast (caminst[i]->getUrl().getElement()); - load_camera(*target, pnode); - } - - // See if this node instantiates any controllers. - domInstance_controller_Array &ctrlinst = node.getInstance_controller_array(); - for (size_t i = 0; i < ctrlinst.getCount(); ++i) { - domController* target = daeSafeCast (ctrlinst[i]->getUrl().getElement()); - // TODO: implement controllers. For now, let's just read the geometry - if (target->getSkin() != nullptr) { - domGeometry* geom = daeSafeCast (target->getSkin()->getSource().getElement()); - // TODO load_geometry(*geom, ctrlinst[i]->getBind_material(), pnode); - } - } - - // See if this node instantiates any geoms. - domInstance_geometry_Array &ginst = node.getInstance_geometry_array(); - for (size_t i = 0; i < ginst.getCount(); ++i) { - load_instance_geometry(*ginst[i], pnode); - } - - // See if this node instantiates any lights. - domInstance_light_Array &linst = node.getInstance_light_array(); - for (size_t i = 0; i < linst.getCount(); ++i) { - domLight* target = daeSafeCast (linst[i]->getUrl().getElement()); - load_light(*target, pnode); - } - - // And instantiate any elements. - domInstance_node_Array &ninst = node.getInstance_node_array(); - for (size_t i = 0; i < ninst.getCount(); ++i) { - domNode* target = daeSafeCast (ninst[i]->getUrl().getElement()); - load_node(*target, pnode); - } - - // Now load in the child nodes. - domNode_Array &nodes = node.getNode_array(); - for (size_t i = 0; i < nodes.getCount(); ++i) { - load_node(*nodes[i], pnode); - } - - // Load in any tags. - domExtra_Array &extras = node.getExtra_array(); - for (size_t i = 0; i < extras.getCount(); ++i) { - load_tags(*extras[i], pnode); - // TODO: load SI_Visibility under XSI profile TODO: support - // OpenSceneGraph's switch nodes - } -} - -/** - * Loads tags specified in an element. - */ -void ColladaLoader:: -load_tags(domExtra &extra, PandaNode *node) { - domTechnique_Array &techniques = extra.getTechnique_array(); - - for (size_t t = 0; t < techniques.getCount(); ++t) { - if (cmp_nocase(techniques[t]->getProfile(), "PANDA3D") == 0) { - const daeElementRefArray &children = techniques[t]->getChildren(); - - for (size_t c = 0; c < children.getCount(); ++c) { - daeElement &child = *children[c]; - - if (cmp_nocase(child.getElementName(), "tag") == 0) { - const std::string &name = child.getAttribute("name"); - if (name.size() > 0) { - node->set_tag(name, child.getCharData()); - } else { - collada_cat.warning() << "Ignoring without name attribute\n"; - } - } else if (cmp_nocase(child.getElementName(), "param") == 0) { - collada_cat.error() << - "Unknown attribute in PANDA3D technique. " - "Did you mean to use instead?\n"; - } - } - } - } -} - -/** - * Loads a COLLADA as a Camera object. - */ -void ColladaLoader:: -load_camera(domCamera &cam, PandaNode *parent) { - // If we already loaded it before, instantiate the stored node. - if (cam.getUserData() != nullptr) { - parent->add_child((PandaNode *) cam.getUserData()); - return; - } - - // TODO -} - -/** - * Loads a COLLADA as a GeomNode object. - */ -void ColladaLoader:: -load_instance_geometry(domInstance_geometry &inst, PandaNode *parent) { - // If we already loaded it before, instantiate the stored node. - if (inst.getUserData() != nullptr) { - parent->add_child((PandaNode *) inst.getUserData()); - return; - } - - domGeometry* geom = daeSafeCast (inst.getUrl().getElement()); - nassertv(geom != nullptr); - - // Create the node. - PT(GeomNode) gnode = new GeomNode(TOSTRING(geom->getName())); - inst.setUserData((void *) gnode); - parent->add_child(gnode); - - domBind_materialRef bind_mat = inst.getBind_material(); - ColladaBindMaterial cbm; - if (bind_mat != nullptr) { - cbm.load_bind_material(*bind_mat); - } - - load_geometry(*geom, gnode, cbm); - - // Load in any tags. - domExtra_Array &extras = geom->getExtra_array(); - for (size_t i = 0; i < extras.getCount(); ++i) { - load_tags(*extras[i], gnode); - } -} - -/** - * Loads a COLLADA and adds the primitives to the given GeomNode - * object. - */ -void ColladaLoader:: -load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) { - domMesh* mesh = geom.getMesh(); - if (mesh == nullptr) { - // TODO: support non-mesh geometry. - return; - } - - // TODO: support other than just triangles. - domLines_Array &lines_array = mesh->getLines_array(); - for (size_t i = 0; i < lines_array.getCount(); ++i) { - PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*lines_array[i]); - if (prim != nullptr) { - gnode->add_geom(prim->get_geom()); - } - } - - domLinestrips_Array &linestrips_array = mesh->getLinestrips_array(); - for (size_t i = 0; i < linestrips_array.getCount(); ++i) { - PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*linestrips_array[i]); - if (prim != nullptr) { - gnode->add_geom(prim->get_geom()); - } - } - - domPolygons_Array &polygons_array = mesh->getPolygons_array(); - for (size_t i = 0; i < polygons_array.getCount(); ++i) { - PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*polygons_array[i]); - if (prim != nullptr) { - gnode->add_geom(prim->get_geom()); - } - } - - domPolylist_Array &polylist_array = mesh->getPolylist_array(); - for (size_t i = 0; i < polylist_array.getCount(); ++i) { - PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*polylist_array[i]); - if (prim != nullptr) { - gnode->add_geom(prim->get_geom()); - } - } - - domTriangles_Array &triangles_array = mesh->getTriangles_array(); - for (size_t i = 0; i < triangles_array.getCount(); ++i) { - PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*triangles_array[i]); - if (prim != nullptr) { - gnode->add_geom(prim->get_geom()); - } - } - - domTrifans_Array &trifans_array = mesh->getTrifans_array(); - for (size_t i = 0; i < trifans_array.getCount(); ++i) { - PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*trifans_array[i]); - if (prim != nullptr) { - gnode->add_geom(prim->get_geom()); - } - } - - domTristrips_Array &tristrips_array = mesh->getTristrips_array(); - for (size_t i = 0; i < tristrips_array.getCount(); ++i) { - PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*tristrips_array[i]); - if (prim != nullptr) { - gnode->add_geom(prim->get_geom()); - } - } -} - -/** - * Loads a COLLADA as a LightNode object. - */ -void ColladaLoader:: -load_light(domLight &light, PandaNode *parent) { - // If we already loaded it before, instantiate the stored node. - if (light.getUserData() != nullptr) { - parent->add_child((PandaNode *) light.getUserData()); - return; - } - - PT(LightNode) lnode; - domLight::domTechnique_common &tc = *light.getTechnique_common(); - - // Check for an ambient light. - domLight::domTechnique_common::domAmbientRef ambient = tc.getAmbient(); - if (ambient != nullptr) { - PT(AmbientLight) alight = new AmbientLight(TOSTRING(light.getName())); - lnode = DCAST(LightNode, alight); - - domFloat3 &color = ambient->getColor()->getValue(); - alight->set_color(LColor(color[0], color[1], color[2], 1.0)); - } - - // Check for a directional light. - domLight::domTechnique_common::domDirectionalRef directional = tc.getDirectional(); - if (directional != nullptr) { - PT(DirectionalLight) dlight = new DirectionalLight(TOSTRING(light.getName())); - lnode = DCAST(LightNode, dlight); - - domFloat3 &color = directional->getColor()->getValue(); - dlight->set_color(LColor(color[0], color[1], color[2], 1.0)); - dlight->set_direction(LVector3f(0, 0, -1)); - } - - // Check for a point light. - domLight::domTechnique_common::domPointRef point = tc.getPoint(); - if (point != nullptr) { - PT(PointLight) plight = new PointLight(TOSTRING(light.getName())); - lnode = DCAST(LightNode, plight); - - domFloat3 &color = point->getColor()->getValue(); - plight->set_color(LColor(color[0], color[1], color[2], 1.0)); - - LVecBase3f atten (1.0f, 0.0f, 0.0f); - domTargetable_floatRef fval = point->getConstant_attenuation(); - if (fval != nullptr) { - atten[0] = fval->getValue(); - } - fval = point->getLinear_attenuation(); - if (fval != nullptr) { - atten[1] = fval->getValue(); - } - fval = point->getQuadratic_attenuation(); - if (fval != nullptr) { - atten[2] = fval->getValue(); - } - - plight->set_attenuation(atten); - } - - // Check for a spot light. - domLight::domTechnique_common::domSpotRef spot = tc.getSpot(); - if (spot != nullptr) { - PT(Spotlight) slight = new Spotlight(TOSTRING(light.getName())); - lnode = DCAST(LightNode, slight); - - domFloat3 &color = spot->getColor()->getValue(); - slight->set_color(LColor(color[0], color[1], color[2], 1.0)); - - LVecBase3f atten (1.0f, 0.0f, 0.0f); - domTargetable_floatRef fval = spot->getConstant_attenuation(); - if (fval != nullptr) { - atten[0] = fval->getValue(); - } - fval = spot->getLinear_attenuation(); - if (fval != nullptr) { - atten[1] = fval->getValue(); - } - fval = spot->getQuadratic_attenuation(); - if (fval != nullptr) { - atten[2] = fval->getValue(); - } - - slight->set_attenuation(atten); - - fval = spot->getFalloff_angle(); - if (fval != nullptr) { - slight->get_lens()->set_fov(fval->getValue()); - } else { - slight->get_lens()->set_fov(180.0f); - } - - fval = spot->getFalloff_exponent(); - if (fval != nullptr) { - slight->set_exponent(fval->getValue()); - } else { - slight->set_exponent(0.0f); - } - } - - if (lnode == nullptr) { - return; - } - parent->add_child(lnode); - _lights.push_back(lnode); - light.setUserData((void*) lnode); - - // Load in any tags. - domExtra_Array &extras = light.getExtra_array(); - for (size_t i = 0; i < extras.getCount(); ++i) { - load_tags(*extras[i], lnode); - } -} diff --git a/panda/src/collada/colladaLoader.h b/panda/src/collada/colladaLoader.h deleted file mode 100644 index e5f894ccba..0000000000 --- a/panda/src/collada/colladaLoader.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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." - * - * @file colladaLoader.h - * @author Xidram - * @date 2010-12-21 - */ - -#ifndef COLLADALOADER_H -#define COLLADALOADER_H - -#include "pandabase.h" -#include "config_collada.h" -#include "typedReferenceCount.h" -#include "pandaNode.h" -#include "modelRoot.h" -#include "pvector.h" -#include "pta_LVecBase4.h" - -class ColladaBindMaterial; -class BamCacheRecord; -class GeomNode; -class LightNode; - -class domBind_material; -class domCOLLADA; -class domNode; -class domVisual_scene; -class domExtra; -class domGeometry; -class domInstance_geometry; -class domLight; -class domCamera; -class domSource; -class DAE; - -/** - * Object that interfaces with the COLLADA DOM library and loads the COLLADA - * structures into Panda nodes. - */ -class ColladaLoader { -public: - ColladaLoader(); - virtual ~ColladaLoader(); - - bool _error; - PT(ModelRoot) _root; - BamCacheRecord *_record; - CoordinateSystem _cs; - Filename _filename; - - bool read(const Filename &filename); - void build_graph(); - -private: - const domCOLLADA* _collada; - DAE* _dae; - pvector _lights; - - void load_visual_scene(domVisual_scene &scene, PandaNode *parent); - void load_node(domNode &node, PandaNode *parent); - void load_tags(domExtra &extra, PandaNode *node); - void load_camera(domCamera &cam, PandaNode *parent); - void load_instance_geometry(domInstance_geometry &inst, PandaNode *parent); - void load_geometry(domGeometry &geom, GeomNode *parent, ColladaBindMaterial &bind_mat); - void load_light(domLight &light, PandaNode *parent); -}; - -#include "colladaLoader.I" - -#endif diff --git a/panda/src/collada/colladaPrimitive.I b/panda/src/collada/colladaPrimitive.I deleted file mode 100644 index e97263f280..0000000000 --- a/panda/src/collada/colladaPrimitive.I +++ /dev/null @@ -1,40 +0,0 @@ -/** - * 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." - * - * @file colladaPrimitive.I - * @author rdb - * @date 2011-05-23 - */ - -/** - * Adds a new ColladaInput to this primitive. - */ -INLINE void ColladaPrimitive:: -add_input(ColladaInput *input) { - if (input->get_offset() >= _stride) { - _stride = input->get_offset() + 1; - } - _inputs.push_back(input); -} - -/** - * Returns the Geom associated with this primitive. - */ -INLINE PT(Geom) ColladaPrimitive:: -get_geom() const { - return _geom; -} - -/** - * Returns the name of this primitive's material, or the empty string if none - * was assigned. - */ -INLINE const std::string &ColladaPrimitive:: -get_material() const { - return _material; -} diff --git a/panda/src/collada/colladaPrimitive.cxx b/panda/src/collada/colladaPrimitive.cxx deleted file mode 100644 index 04433b72e4..0000000000 --- a/panda/src/collada/colladaPrimitive.cxx +++ /dev/null @@ -1,293 +0,0 @@ -/** - * 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." - * - * @file colladaPrimitive.cxx - * @author rdb - * @date 2011-05-23 - */ - -#include "colladaPrimitive.h" -#include "geomLines.h" -#include "geomLinestrips.h" -#include "geomTriangles.h" -#include "geomTrifans.h" -#include "geomTristrips.h" - -// Collada DOM includes. No other includes beyond this point. -#include "pre_collada_include.h" -#include -#include -#include -#include -#include -#include -#include - -#if PANDA_COLLADA_VERSION < 15 -#define domInput_local_offsetRef domInputLocalOffsetRef -#endif - -/** - * Why do I even bother documenting the simplest of constructors? A private - * one at that. - */ -ColladaPrimitive:: -ColladaPrimitive(GeomPrimitive *prim, daeTArray &inputs) - : _stride (1), _gprim (prim) { - - PT(GeomVertexArrayFormat) aformat = new GeomVertexArrayFormat; - - // Add the inputs one by one. - for (size_t in = 0; in < inputs.getCount(); ++in) { - PT(ColladaInput) input = ColladaInput::from_dom(*inputs[in]); - add_input(input); - - input->make_vertex_columns(aformat); - } - - // Create the vertex data. - PT(GeomVertexFormat) format = new GeomVertexFormat(); - format->add_array(aformat); - _vdata = new GeomVertexData("", GeomVertexFormat::register_format(format), GeomEnums::UH_static); - _geom = new Geom(_vdata); - _geom->add_primitive(_gprim); -} - -/** - * Returns the ColladaPrimitive object that represents the provided DOM input - * element. - */ -ColladaPrimitive *ColladaPrimitive:: -from_dom(domLines &prim) { - // If we already loaded it before, use that. - if (prim.getUserData() != nullptr) { - return (ColladaPrimitive *) prim.getUserData(); - } - - ColladaPrimitive *new_prim = - new ColladaPrimitive(new GeomLines(GeomEnums::UH_static), - prim.getInput_array()); - new_prim->_material = prim.getMaterial(); - - prim.setUserData(new_prim); - - domPRef p = prim.getP(); - if (p != nullptr) { - new_prim->load_primitive(*p); - } - - return new_prim; -} - -/** - * Returns the ColladaPrimitive object that represents the provided DOM input - * element. - */ -ColladaPrimitive *ColladaPrimitive:: -from_dom(domLinestrips &prim) { - // If we already loaded it before, use that. - if (prim.getUserData() != nullptr) { - return (ColladaPrimitive *) prim.getUserData(); - } - - ColladaPrimitive *new_prim = - new ColladaPrimitive(new GeomLinestrips(GeomEnums::UH_static), - prim.getInput_array()); - new_prim->_material = prim.getMaterial(); - - prim.setUserData(new_prim); - - new_prim->load_primitives(prim.getP_array()); - - return new_prim; -} - -/** - * Returns the ColladaPrimitive object that represents the provided DOM input - * element. - */ -ColladaPrimitive *ColladaPrimitive:: -from_dom(domPolygons &prim) { - // If we already loaded it before, use that. - if (prim.getUserData() != nullptr) { - return (ColladaPrimitive *) prim.getUserData(); - } - - // We use trifans to represent polygons, seems to be easiest. I tried using - // tristrips instead, but for some reason, this resulted in a few flipped - // polygons. Weird. - ColladaPrimitive *new_prim = - new ColladaPrimitive(new GeomTrifans(GeomEnums::UH_static), - prim.getInput_array()); - new_prim->_material = prim.getMaterial(); - - prim.setUserData(new_prim); - - new_prim->load_primitives(prim.getP_array()); - - if (prim.getPh_array().getCount() > 0) { - collada_cat.error() - << "Polygons with holes are not supported!\n"; - } - - return new_prim; -} - -/** - * Returns the ColladaPrimitive object that represents the provided DOM input - * element. - */ -ColladaPrimitive *ColladaPrimitive:: -from_dom(domPolylist &prim) { - // If we already loaded it before, use that. - if (prim.getUserData() != nullptr) { - return (ColladaPrimitive *) prim.getUserData(); - } - - // We use trifans to represent polygons, seems to be easiest. I tried using - // tristrips instead, but for some reason, this resulted in a few flipped - // polygons. Weird. - PT(GeomPrimitive) gprim = new GeomTrifans(GeomEnums::UH_static); - - ColladaPrimitive *new_prim = - new ColladaPrimitive(gprim, prim.getInput_array()); - new_prim->_material = prim.getMaterial(); - - prim.setUserData(new_prim); - - domPRef p = prim.getP(); - domPolylist::domVcountRef vcounts = prim.getVcount(); - if (p == nullptr || vcounts == nullptr) { - return new_prim; - } - - new_prim->write_data(new_prim->_vdata, 0, *p); - - daeTArray &values = vcounts->getValue(); - for (size_t i = 0; i < values.getCount(); ++i) { - unsigned int vcount = values[i]; - gprim->add_next_vertices(vcount); - gprim->close_primitive(); - } - - return new_prim; -} - -/** - * Returns the ColladaPrimitive object that represents the provided DOM input - * element. - */ -ColladaPrimitive *ColladaPrimitive:: -from_dom(domTriangles &prim) { - // If we already loaded it before, use that. - if (prim.getUserData() != nullptr) { - return (ColladaPrimitive *) prim.getUserData(); - } - - ColladaPrimitive *new_prim = - new ColladaPrimitive(new GeomTriangles(GeomEnums::UH_static), - prim.getInput_array()); - new_prim->_material = prim.getMaterial(); - - prim.setUserData(new_prim); - - domPRef p = prim.getP(); - if (p != nullptr) { - new_prim->load_primitive(*p); - } - - return new_prim; -} - -/** - * Returns the ColladaPrimitive object that represents the provided DOM input - * element. - */ -ColladaPrimitive *ColladaPrimitive:: -from_dom(domTrifans &prim) { - // If we already loaded it before, use that. - if (prim.getUserData() != nullptr) { - return (ColladaPrimitive *) prim.getUserData(); - } - - ColladaPrimitive *new_prim = - new ColladaPrimitive(new GeomTrifans(GeomEnums::UH_static), - prim.getInput_array()); - new_prim->_material = prim.getMaterial(); - - prim.setUserData(new_prim); - - new_prim->load_primitives(prim.getP_array()); - - return new_prim; -} - -/** - * Returns the ColladaPrimitive object that represents the provided DOM input - * element. - */ -ColladaPrimitive *ColladaPrimitive:: -from_dom(domTristrips &prim) { - // If we already loaded it before, use that. - if (prim.getUserData() != nullptr) { - return (ColladaPrimitive *) prim.getUserData(); - } - - ColladaPrimitive *new_prim = - new ColladaPrimitive(new GeomTristrips(GeomEnums::UH_static), - prim.getInput_array()); - new_prim->_material = prim.getMaterial(); - - prim.setUserData(new_prim); - - new_prim->load_primitives(prim.getP_array()); - - return new_prim; -} - -/** - * Writes the vertex data to the GeomVertexData. Returns the number of rows - * written. - */ -unsigned int ColladaPrimitive:: -write_data(GeomVertexData *vdata, int start_row, domP &p) { - unsigned int num_vertices = p.getValue().getCount() / _stride; - - Inputs::iterator it; - for (it = _inputs.begin(); it != _inputs.end(); ++it) { - (*it)->write_data(vdata, start_row, p, _stride); - } - - return num_vertices; -} - -/** - * Adds the given indices to the primitive, and writes the relevant data to - * the geom. - */ -void ColladaPrimitive:: -load_primitive(domP &p) { - _gprim->add_next_vertices(write_data(_vdata, 0, p)); - _gprim->close_primitive(); -} - -/** - * Adds the given indices to the primitive, and writes the relevant data to - * the geom. - */ -void ColladaPrimitive:: -load_primitives(domP_Array &p_array) { - int start_row = 0; - - for (size_t i = 0; i < p_array.getCount(); ++i) { - unsigned int num_vertices = write_data(_vdata, start_row, *p_array[i]); - _gprim->add_next_vertices(num_vertices); - _gprim->close_primitive(); - start_row += num_vertices; - } -} diff --git a/panda/src/collada/colladaPrimitive.h b/panda/src/collada/colladaPrimitive.h deleted file mode 100644 index 075bce7f73..0000000000 --- a/panda/src/collada/colladaPrimitive.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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." - * - * @file colladaPrimitive.h - * @author rdb - * @date 2011-05-23 - */ - -#ifndef COLLADAPRIMITIVE_H -#define COLLADAPRIMITIVE_H - -#include "config_collada.h" -#include "referenceCount.h" -#include "geomVertexData.h" -#include "geom.h" -#include "geomPrimitive.h" - -#include "colladaInput.h" - -class domP; -class domLines; -class domLinestrips; -class domPolygons; -class domPolylist; -class domTriangles; -class domTrifans; -class domTristrips; - -/** - * Class that deals with COLLADA primitive structures, such as and - * . - */ -class ColladaPrimitive : public ReferenceCount { -public: - static ColladaPrimitive *from_dom(domLines &lines); - static ColladaPrimitive *from_dom(domLinestrips &linestrips); - static ColladaPrimitive *from_dom(domPolygons &polygons); - static ColladaPrimitive *from_dom(domPolylist &polylist); - static ColladaPrimitive *from_dom(domTriangles &triangles); - static ColladaPrimitive *from_dom(domTrifans &trifans); - static ColladaPrimitive *from_dom(domTristrips &tristrips); - - unsigned int write_data(GeomVertexData *vdata, int start_row, domP &p); - - INLINE PT(Geom) get_geom() const; - INLINE const std::string &get_material() const; - -private: - ColladaPrimitive(GeomPrimitive *prim, daeTArray > &inputs); - void load_primitive(domP &p); - void load_primitives(daeTArray > &p_array); - INLINE void add_input(ColladaInput *input); - - typedef pvector Inputs; - Inputs _inputs; - - unsigned int _stride; - PT(Geom) _geom; - PT(GeomVertexData) _vdata; - PT(GeomPrimitive) _gprim; - std::string _material; -}; - -#include "colladaPrimitive.I" - -#endif diff --git a/panda/src/collada/config_collada.cxx b/panda/src/collada/config_collada.cxx deleted file mode 100644 index 1fec2da68e..0000000000 --- a/panda/src/collada/config_collada.cxx +++ /dev/null @@ -1,87 +0,0 @@ -/** - * 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." - * - * @file config_collada.cxx - * @author Xidram - * @date 2010-12-21 - */ - -#include "config_collada.h" - -#include "dconfig.h" -#include "loaderFileTypeDae.h" -#include "loaderFileTypeRegistry.h" - -#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_COLLADA) - #error Buildsystem error: BUILDING_COLLADA not defined -#endif - -ConfigureDef(config_collada); -NotifyCategoryDef(collada, ""); - -ConfigVariableBool collada_flatten -("collada-flatten", false, - PRC_DESC("This is normally true to flatten out useless nodes after loading " - "a collada file. Set it false if you want to see the complete " - "and true hierarchy as specified in the file (although the " - "extra nodes may have a small impact on render performance).")); - -ConfigVariableDouble collada_flatten_radius -("collada-flatten-radius", 0.0, - PRC_DESC("This specifies the minimum cull radius in the egg file. Nodes " - "whose bounding volume is smaller than this radius will be " - "flattened tighter than nodes larger than this radius, to " - "reduce the node count even further. The idea is that small " - "objects will not need to have their individual components " - "culled separately, but large environments should. This allows " - "the user to specify what should be considered \"small\". Set " - "it to 0.0 to disable this feature.")); - -ConfigVariableBool collada_unify -("collada-unify", true, - PRC_DESC("When this is true, then in addition to flattening the scene graph " - "nodes, the collada loader will also combine as many Geoms as " - "possible within " - "a given node into a single Geom. This has theoretical performance " - "benefits, especially on higher-end graphics cards, but it also " - "slightly slows down collada loading.")); - -ConfigVariableBool collada_combine_geoms -("collada-combine-geoms", false, - PRC_DESC("Set this true to combine sibling GeomNodes into a single GeomNode, " - "when possible.")); - -ConfigVariableBool collada_accept_errors -("collada-accept-errors", true, - PRC_DESC("When this is true, certain kinds of recoverable errors (not syntax " - "errors) in a collada file will be allowed and ignored when a " - "collada file is loaded. When it is false, only perfectly pristine " - "collada files may be loaded.")); - -ConfigureFn(config_collada) { - init_libcollada(); -} - -/** - * Initializes the library. This must be called at least once before any of - * the functions or classes in this library can be used. Normally it will be - * called by the static initializers and need not be called explicitly, but - * special cases exist. - */ -void -init_libcollada() { - static bool initialized = false; - if (initialized) { - return; - } - initialized = true; - - LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr(); - - reg->register_type(new LoaderFileTypeDae); -} diff --git a/panda/src/collada/config_collada.h b/panda/src/collada/config_collada.h deleted file mode 100644 index 966f497038..0000000000 --- a/panda/src/collada/config_collada.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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." - * - * @file config_collada.h - * @author Xidram - * @date 2010-12-21 - */ - -#ifndef CONFIG_COLLADA_H -#define CONFIG_COLLADA_H - -#include "pandabase.h" - -#include "notifyCategoryProxy.h" -#include "dconfig.h" - -template class daeTArray; -template class daeSmartRef; - -ConfigureDecl(config_collada, EXPCL_COLLADA, EXPTP_COLLADA); -NotifyCategoryDecl(collada, EXPCL_COLLADA, EXPTP_COLLADA); - -extern EXPCL_COLLADA ConfigVariableBool collada_flatten; -extern EXPCL_COLLADA ConfigVariableBool collada_unify; -extern EXPCL_COLLADA ConfigVariableDouble collada_flatten_radius; -extern EXPCL_COLLADA ConfigVariableBool collada_combine_geoms; -extern EXPCL_COLLADA ConfigVariableBool collada_accept_errors; - -extern EXPCL_COLLADA void init_libcollada(); - -#endif diff --git a/panda/src/collada/load_collada_file.cxx b/panda/src/collada/load_collada_file.cxx deleted file mode 100644 index 2ebdd2c340..0000000000 --- a/panda/src/collada/load_collada_file.cxx +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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." - * - * @file load_collada_file.cxx - * @author rdb - * @date 2011-03-16 - */ - -#include "load_collada_file.h" -#include "colladaLoader.h" -#include "config_collada.h" -#include "sceneGraphReducer.h" -#include "virtualFileSystem.h" -#include "config_putil.h" -#include "bamCacheRecord.h" - -static PT(PandaNode) -load_from_loader(ColladaLoader &loader) { - loader.build_graph(); - - if (loader._error && !collada_accept_errors) { - collada_cat.error() - << "Errors in collada file.\n"; - return nullptr; - } - - if (loader._root != nullptr && collada_flatten) { - SceneGraphReducer gr; - - int combine_siblings_bits = 0; - if (collada_combine_geoms) { - combine_siblings_bits |= SceneGraphReducer::CS_geom_node; - } - if (collada_flatten_radius > 0.0) { - combine_siblings_bits |= SceneGraphReducer::CS_within_radius; - gr.set_combine_radius(collada_flatten_radius); - } - - int num_reduced = gr.flatten(loader._root, combine_siblings_bits); - collada_cat.info() << "Flattened " << num_reduced << " nodes.\n"; - - if (collada_unify) { - // We want to premunge before unifying, since otherwise we risk - // needlessly duplicating vertices. - if (premunge_data) { - gr.premunge(loader._root, RenderState::make_empty()); - } - gr.collect_vertex_data(loader._root); - gr.unify(loader._root, true); - if (collada_cat.is_debug()) { - collada_cat.debug() << "Unified.\n"; - } - } - } - - return DCAST(ModelRoot, loader._root); -} - -/** - * A convenience function. Loads up the indicated dae file, and returns the - * root of a scene graph. Returns NULL if the file cannot be read for some - * reason. Does not search along the model path for the filename first. - */ -PT(PandaNode) -load_collada_file(const Filename &filename, CoordinateSystem cs, - BamCacheRecord *record) { - - VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - - if (record != nullptr) { - record->add_dependent_file(filename); - } - - ColladaLoader loader; - loader._filename = filename; - loader._cs = cs; - loader._record = record; - - collada_cat.info() - << "Reading " << filename << "\n"; - - if (!loader.read(filename)) { - return nullptr; - } - - return load_from_loader(loader); -} diff --git a/panda/src/collada/load_collada_file.h b/panda/src/collada/load_collada_file.h deleted file mode 100644 index 8217b11063..0000000000 --- a/panda/src/collada/load_collada_file.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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." - * - * @file load_collada_file.h - * @author rdb - * @date 2011-03-16 - */ - -#ifndef LOAD_COLLADA_FILE_H -#define LOAD_COLLADA_FILE_H - -#include "pandabase.h" - -#include "pandaNode.h" -#include "filename.h" -#include "coordinateSystem.h" - -class BamCacheRecord; - -BEGIN_PUBLISH -/** - * A convenience function; the primary interface to this package. Loads up - * the indicated DAE file, and returns the root of a scene graph. Returns - * NULL if the file cannot be read for some reason. - */ -EXPCL_COLLADA PT(PandaNode) -load_collada_file(const Filename &filename, CoordinateSystem cs = CS_default, - BamCacheRecord *record = nullptr); -END_PUBLISH - -#endif diff --git a/panda/src/collada/loaderFileTypeDae.cxx b/panda/src/collada/loaderFileTypeDae.cxx deleted file mode 100644 index a35223f30c..0000000000 --- a/panda/src/collada/loaderFileTypeDae.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/** - * 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." - * - * @file loaderFileTypeDae.cxx - * @author rdb - * @date 2009-08-23 - */ - -#include "loaderFileTypeDae.h" -#include "load_collada_file.h" - -TypeHandle LoaderFileTypeDae::_type_handle; - -/** - * - */ -LoaderFileTypeDae:: -LoaderFileTypeDae() { -} - -/** - * - */ -std::string LoaderFileTypeDae:: -get_name() const { -#if PANDA_COLLADA_VERSION == 14 - return "COLLADA 1.4"; -#elif PANDA_COLLADA_VERSION == 15 - return "COLLADA 1.5"; -#else - return "COLLADA"; -#endif -} - -/** - * - */ -std::string LoaderFileTypeDae:: -get_extension() const { - return "dae"; -} - -/** - * Returns a space-separated list of extension, in addition to the one - * returned by get_extension(), that are recognized by this loader. - */ -std::string LoaderFileTypeDae:: -get_additional_extensions() const { - return "zae"; -} - -/** - * Returns true if this file type can transparently load compressed files - * (with a .pz or .gz extension), false otherwise. - */ -bool LoaderFileTypeDae:: -supports_compressed() const { - return true; -} - -/** - * - */ -PT(PandaNode) LoaderFileTypeDae:: -load_file(const Filename &path, const LoaderOptions &, - BamCacheRecord *record) const { - PT(PandaNode) result = load_collada_file(path, CS_default, record); - return result; -} diff --git a/panda/src/collada/loaderFileTypeDae.h b/panda/src/collada/loaderFileTypeDae.h deleted file mode 100644 index e762564b86..0000000000 --- a/panda/src/collada/loaderFileTypeDae.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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." - * - * @file loaderFileTypeDae.h - * @author rdb - * @date 2009-08-23 - */ - -#ifndef LOADERFILETYPEDAE_H -#define LOADERFILETYPEDAE_H - -#include "pandabase.h" - -#include "loaderFileType.h" - -/** - * This defines the Loader interface to read Dae files. - */ -class EXPCL_COLLADA LoaderFileTypeDae : public LoaderFileType { -public: - LoaderFileTypeDae(); - - virtual std::string get_name() const; - virtual std::string get_extension() const; - virtual std::string get_additional_extensions() const; - virtual bool supports_compressed() const; - - virtual PT(PandaNode) load_file(const Filename &path, const LoaderOptions &options, - BamCacheRecord *record) const; - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - LoaderFileType::init_type(); - register_type(_type_handle, "LoaderFileTypeDae", - LoaderFileType::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -#endif diff --git a/panda/src/collada/p3collada_composite1.cxx b/panda/src/collada/p3collada_composite1.cxx deleted file mode 100644 index ea53a40374..0000000000 --- a/panda/src/collada/p3collada_composite1.cxx +++ /dev/null @@ -1,3 +0,0 @@ -#include "config_collada.cxx" -#include "load_collada_file.cxx" -#include "loaderFileTypeDae.cxx" diff --git a/panda/src/collada/pre_collada_include.h b/panda/src/collada/pre_collada_include.h deleted file mode 100644 index 53b576a773..0000000000 --- a/panda/src/collada/pre_collada_include.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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." - * - * @file pre_collada_include.h - * @author rdb - * @date 2011-05-23 - */ - -// This header file should be included before including any of the COLLADA DOM -// headers. It should only be included in a .cxx file (not in a header file) -// and no Panda3D headers should be included after the pre_collada_include.h -// include. - -#ifdef PRE_COLLADA_INCLUDE_H -#error Don't include any Panda headers after including pre_collada_include.h! -#endif -#define PRE_COLLADA_INCLUDE_H - -// Undef some macros that conflict with COLLADA. -#undef INLINE -#undef tolower - -#include From 598664ab80d64d3d2f6b159676d412519fb51367 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 12 Nov 2018 16:31:54 +0100 Subject: [PATCH 329/360] interrogate: disambiguate case where static method shadows a property While it becomes possible to do this now, it should not become standard practice, and we should deprecate cases where we already do it by renaming either the static method or the property. Fixes #444 --- .../interfaceMakerPythonNative.cxx | 72 +++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 425a61a1ae..fd8b5432cd 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -1648,6 +1648,16 @@ write_module_class(ostream &out, Object *obj) { if (!func->_has_this) { flags += " | METH_STATIC"; + + // Skip adding this entry if we also have a property with the same name. + // In that case, we will use a Dtool_StaticProperty to disambiguate + // access to this method. See GitHub issue #444. + for (const Property *property : obj->_properties) { + if (property->_has_this && + property->_ielement.get_name() == func->_ifunc.get_name()) { + continue; + } + } } bool has_nonslotted = false; @@ -2665,6 +2675,14 @@ write_module_class(ostream &out, Object *obj) { continue; } + // Actually, if we have a conflicting static method with the same name, + // we will need to use Dtool_StaticProperty instead. + for (const Function *func : obj->_methods) { + if (!func->_has_this && func->_ifunc.get_name() == ielem.get_name()) { + continue; + } + } + if (num_getset == 0) { out << "static PyGetSetDef Dtool_Properties_" << ClassName << "[] = {\n"; } @@ -3240,9 +3258,23 @@ write_module_class(ostream &out, Object *obj) { // Also add the static properties, which can't be added via getset. for (Property *property : obj->_properties) { const InterrogateElement &ielem = property->_ielement; - if (property->_has_this || property->_getter_remaps.empty()) { + if (property->_getter_remaps.empty()) { continue; } + if (property->_has_this) { + // Actually, continue if we have a conflicting static method with the + // same name, which may still require use of Dtool_StaticProperty. + bool have_shadow = false; + for (const Function *func : obj->_methods) { + if (!func->_has_this && func->_ifunc.get_name() == ielem.get_name()) { + have_shadow = true; + break; + } + } + if (!have_shadow) { + continue; + } + } string name1 = methodNameFromCppName(ielem.get_name(), "", false); // string name2 = methodNameFromCppName(ielem.get_name(), "", true); @@ -6896,8 +6928,42 @@ write_getset(ostream &out, Object *obj, Property *property) { // Now write the actual getter wrapper. It will be a different wrapper // depending on whether it's a mapping or a sequence. + out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n"; + + // Is this property shadowing a static method with the same name? This is a + // special case to handle WindowProperties::make -- see GH #444. + if (property->_has_this) { + for (const Function *func : obj->_methods) { + if (!func->_has_this && func->_ifunc.get_name() == ielem.get_name()) { + string flags; + string fptr = "&" + func->_name; + switch (func->_args_type) { + case AT_keyword_args: + flags = "METH_VARARGS | METH_KEYWORDS"; + fptr = "(PyCFunction) " + fptr; + break; + case AT_varargs: + flags = "METH_VARARGS"; + break; + case AT_single_arg: + flags = "METH_O"; + break; + default: + flags = "METH_NOARGS"; + break; + } + out << " if (self == nullptr) {\n" + << " static PyMethodDef def = {\"" << ielem.get_name() << "\", " + << fptr << ", " << flags << " | METH_STATIC, (const char *)" + << func->_name << "_comment};\n" + << " return PyCFunction_New(&def, nullptr);\n" + << " }\n\n"; + break; + } + } + } + if (ielem.is_mapping()) { - out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n"; if (property->_has_this) { out << " nassertr(self != nullptr, nullptr);\n"; } @@ -6924,7 +6990,6 @@ write_getset(ostream &out, Object *obj, Property *property) { "}\n\n"; } else if (ielem.is_sequence()) { - out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n"; if (property->_has_this) { out << " nassertr(self != nullptr, nullptr);\n"; } @@ -6955,7 +7020,6 @@ write_getset(ostream &out, Object *obj, Property *property) { } else { // Write out a regular, unwrapped getter. - out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n"; FunctionRemap *remap = property->_getter_remaps.front(); if (remap->_has_this) { From 074c5187b02a04e97663e353f5152d713a2ddb80 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 12 Nov 2018 16:58:01 +0100 Subject: [PATCH 330/360] Adopt new WindowProperties(size=(x, y), ...) short-hand This is intended as replacement for WindowProperties.size(x, y), which is deprecated since it conflicts with the `size` property. See #444. --- dtool/src/interrogate/functionRemap.cxx | 9 +- makepanda/makepanda.py | 8 +- panda/src/display/p3display_ext_composite.cxx | 4 + panda/src/display/windowProperties.cxx | 2 + panda/src/display/windowProperties.h | 9 +- panda/src/display/windowProperties_ext.cxx | 82 +++++++++++++++++++ panda/src/display/windowProperties_ext.h | 37 +++++++++ samples/shadows/advanced.py | 2 +- 8 files changed, 142 insertions(+), 11 deletions(-) create mode 100644 panda/src/display/p3display_ext_composite.cxx create mode 100644 panda/src/display/windowProperties_ext.cxx create mode 100644 panda/src/display/windowProperties_ext.h diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index 9836a23bfc..fabbb8a311 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -960,8 +960,13 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } else if (!_has_this && _parameters.size() > 0 && (_cppfunc->_storage_class & CPPInstance::SC_explicit) == 0) { - // A non-explicit non-copy constructor might be eligible for coercion. - _flags |= F_coerce_constructor; + // A non-explicit non-copy constructor might be eligible for coercion, + // as long as it does not require explicit keyword args. + if ((_flags & F_explicit_args) == 0 || + _args_type != InterfaceMaker::AT_keyword_args) { + + _flags |= F_coerce_constructor; + } } // Constructors always take varargs, and possibly keyword args. diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 895b306d38..736434fb92 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3875,9 +3875,7 @@ if (not RUNTIME): IGATEFILES.remove("renderBuffer.h") TargetAdd('libp3display.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3display.in', opts=['IMOD:panda3d.core', 'ILIB:libp3display', 'SRCDIR:panda/src/display']) - PyTargetAdd('p3display_graphicsStateGuardian_ext.obj', opts=OPTS, input='graphicsStateGuardian_ext.cxx') - PyTargetAdd('p3display_graphicsWindow_ext.obj', opts=OPTS, input='graphicsWindow_ext.cxx') - PyTargetAdd('p3display_pythonGraphicsWindowProc.obj', opts=OPTS, input='pythonGraphicsWindowProc.cxx') + PyTargetAdd('p3display_ext_composite.obj', opts=OPTS, input='p3display_ext_composite.cxx') if RTDIST and GetTarget() == 'darwin': OPTS=['DIR:panda/src/display'] @@ -4277,9 +4275,7 @@ if (not RUNTIME): PyTargetAdd('core.pyd', input='p3event_pythonTask.obj') PyTargetAdd('core.pyd', input='p3gobj_ext_composite.obj') PyTargetAdd('core.pyd', input='p3pgraph_ext_composite.obj') - PyTargetAdd('core.pyd', input='p3display_graphicsStateGuardian_ext.obj') - PyTargetAdd('core.pyd', input='p3display_graphicsWindow_ext.obj') - PyTargetAdd('core.pyd', input='p3display_pythonGraphicsWindowProc.obj') + PyTargetAdd('core.pyd', input='p3display_ext_composite.obj') PyTargetAdd('core.pyd', input='core_module.obj') if not GetLinkAllStatic() and GetTarget() != 'emscripten': diff --git a/panda/src/display/p3display_ext_composite.cxx b/panda/src/display/p3display_ext_composite.cxx new file mode 100644 index 0000000000..b3147c4e3f --- /dev/null +++ b/panda/src/display/p3display_ext_composite.cxx @@ -0,0 +1,4 @@ +#include "graphicsStateGuardian_ext.cxx" +#include "graphicsWindow_ext.cxx" +#include "pythonGraphicsWindowProc.cxx" +#include "windowProperties_ext.cxx" diff --git a/panda/src/display/windowProperties.cxx b/panda/src/display/windowProperties.cxx index 93cd0a7144..3d6ebeb91b 100644 --- a/panda/src/display/windowProperties.cxx +++ b/panda/src/display/windowProperties.cxx @@ -135,6 +135,8 @@ clear_default() { /** * Returns a WindowProperties structure with only the size specified. The * size is the only property that matters to buffers. + * + * @deprecated in the Python API, use WindowProperties(size=(x, y)) instead. */ WindowProperties WindowProperties:: size(const LVecBase2i &size) { diff --git a/panda/src/display/windowProperties.h b/panda/src/display/windowProperties.h index 68ba4e7f1d..0d9b162c6c 100644 --- a/panda/src/display/windowProperties.h +++ b/panda/src/display/windowProperties.h @@ -27,6 +27,10 @@ * properties for a window after it has been opened. */ class EXPCL_PANDA_DISPLAY WindowProperties { +public: + WindowProperties(); + INLINE WindowProperties(const WindowProperties ©); + PUBLISHED: enum ZOrder { Z_bottom, @@ -40,8 +44,9 @@ PUBLISHED: M_confined, }; - WindowProperties(); - INLINE WindowProperties(const WindowProperties ©); + EXTENSION(WindowProperties(PyObject *self, PyObject *args, PyObject *kwds)); + +PUBLISHED: void operator = (const WindowProperties ©); INLINE ~WindowProperties(); diff --git a/panda/src/display/windowProperties_ext.cxx b/panda/src/display/windowProperties_ext.cxx new file mode 100644 index 0000000000..5c8a711415 --- /dev/null +++ b/panda/src/display/windowProperties_ext.cxx @@ -0,0 +1,82 @@ +/** + * 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." + * + * @file windowProperties_ext.cxx + * @author rdb + * @date 2018-11-12 + */ + +#include "windowProperties_ext.h" + +#ifdef HAVE_PYTHON + +extern struct Dtool_PyTypedObject Dtool_WindowProperties; + +/** + * Creates a new WindowProperties initialized with the given properties. + */ +void Extension:: +__init__(PyObject *self, PyObject *args, PyObject *kwds) { + nassertv_always(_this != nullptr); + + // We need to initialize the self object before we can use it. + DtoolInstance_INIT_PTR(self, _this); + + // Support copy constructor by extracting the one positional argument. + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + if (nargs != 0) { + if (nargs != 1) { + PyErr_Format(PyExc_TypeError, + "WindowProperties() takes at most 1 positional argument (%d given)", + (int)nargs); + return; + } + + PyObject *arg = PyTuple_GET_ITEM(args, 0); + const WindowProperties *copy_from; + if (DtoolInstance_GetPointer(arg, copy_from, Dtool_WindowProperties)) { + *_this = *copy_from; + } else { + Dtool_Raise_ArgTypeError(arg, 0, "WindowProperties", "WindowProperties"); + return; + } + } + + // Now iterate over the keyword arguments, which define the default values + // for the different properties. + if (kwds != nullptr) { + PyTypeObject *type = Py_TYPE(self); + PyObject *key, *value; + Py_ssize_t pos = 0; + + while (PyDict_Next(kwds, &pos, &key, &value)) { + // Look for a writable property on the type by this name. + PyObject *descr = _PyType_Lookup(type, key); + + if (descr != nullptr && Py_TYPE(descr)->tp_descr_set != nullptr) { + if (Py_TYPE(descr)->tp_descr_set(descr, self, value) < 0) { + return; + } + } else { + PyObject *key_repr = PyObject_Repr(key); + PyErr_Format(PyExc_TypeError, + "%.100s is an invalid keyword argument for WindowProperties()", +#if PY_MAJOR_VERSION >= 3 + PyUnicode_AsUTF8(key_repr) +#else + PyString_AsString(key_repr) +#endif + ); + Py_DECREF(key_repr); + return; + } + } + } +} + +#endif // HAVE_PYTHON diff --git a/panda/src/display/windowProperties_ext.h b/panda/src/display/windowProperties_ext.h new file mode 100644 index 0000000000..093bd49036 --- /dev/null +++ b/panda/src/display/windowProperties_ext.h @@ -0,0 +1,37 @@ +/** + * 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." + * + * @file windowProperties_ext.h + * @author rdb + * @date 2018-11-12 + */ + +#ifndef WINDOWPROPERTIES_EXT_H +#define WINDOWPROPERTIES_EXT_H + +#include "dtoolbase.h" + +#ifdef HAVE_PYTHON + +#include "extension.h" +#include "windowProperties.h" +#include "py_panda.h" + +/** + * This class defines the extension methods for WindowProperties, which are + * called instead of any C++ methods with the same prototype. + */ +template<> +class Extension : public ExtensionBase { +public: + void __init__(PyObject *self, PyObject *args, PyObject *kwds); +}; + +#endif // HAVE_PYTHON + +#endif // WINDOWPROPERTIES_EXT_H diff --git a/samples/shadows/advanced.py b/samples/shadows/advanced.py index e11ed2645a..4091192d00 100755 --- a/samples/shadows/advanced.py +++ b/samples/shadows/advanced.py @@ -40,7 +40,7 @@ class World(DirectObject): # creating the offscreen buffer. - winprops = WindowProperties.size(512, 512) + winprops = WindowProperties(size=(512, 512)) props = FrameBufferProperties() props.setRgbColor(1) props.setAlphaBits(1) From 0e7302e86ae71e89950360822b824e6690276c73 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 12 Nov 2018 17:18:19 +0100 Subject: [PATCH 331/360] tests: add a few basic unit tests for WindowProperties class --- tests/display/test_winprops.py | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/display/test_winprops.py diff --git a/tests/display/test_winprops.py b/tests/display/test_winprops.py new file mode 100644 index 0000000000..4634e54c04 --- /dev/null +++ b/tests/display/test_winprops.py @@ -0,0 +1,68 @@ +from panda3d.core import WindowProperties + +import pytest + + +def test_winprops_ctor(): + props = WindowProperties() + assert not props.is_any_specified() + + +def test_winprops_copy_ctor(): + props = WindowProperties() + props.set_size(1, 2) + + props2 = WindowProperties(props) + assert props == props2 + assert props2.get_size() == (1, 2) + + with pytest.raises(TypeError): + WindowProperties(None) + + +def test_winprops_ctor_kwargs(): + props = WindowProperties(size=(1, 2), origin=3) + + assert props.has_size() + assert props.get_size() == (1, 2) + + assert props.has_origin() + assert props.get_origin() == (3, 3) + + # Invalid property should throw + with pytest.raises(TypeError): + WindowProperties(swallow_type="african") + + # Invalid value should throw + with pytest.raises(TypeError): + WindowProperties(size="invalid") + + +def test_winprops_size_staticmethod(): + props = WindowProperties.size(1, 2) + assert props.has_size() + assert props.get_size() == (1, 2) + + props = WindowProperties.size((1, 2)) + assert props.has_size() + assert props.get_size() == (1, 2) + + +def test_winprops_size_property(): + props = WindowProperties() + + # Test get + props.set_size(1, 2) + assert props.size == (1, 2) + + # Test has + props.clear_size() + assert props.size is None + + # Test set + props.size = (4, 5) + assert props.get_size() == (4, 5) + + # Test clear + props.size = None + assert not props.has_size() From c3d52eeee1a5daacc374e09f54ca2b1cb269d77c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 12 Nov 2018 17:24:15 -0700 Subject: [PATCH 332/360] express: Fix compiler error with HAVE_TAR --- panda/src/express/patchfile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index 5aef4416d1..c7e212c260 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -32,7 +32,7 @@ #endif // HAVE_TAR #ifdef HAVE_TAR -istream *Patchfile::_tar_istream = nullptr; +std::istream *Patchfile::_tar_istream = nullptr; #endif // HAVE_TAR using std::endl; From 8f73f95e79e9927067a4ece7b42527dd466beb08 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 19 Nov 2018 20:00:59 +0100 Subject: [PATCH 333/360] display: make PStats clear collectors per-window --- panda/src/display/graphicsEngine.cxx | 13 +++++++++++-- panda/src/display/graphicsOutput.I | 9 +++++++++ panda/src/display/graphicsOutput.cxx | 1 + panda/src/display/graphicsOutput.h | 2 ++ panda/src/display/graphicsStateGuardian.cxx | 1 - panda/src/display/graphicsStateGuardian.h | 1 - panda/src/glstuff/glGraphicsBuffer_src.cxx | 2 -- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 1 - panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx | 2 -- 9 files changed, 23 insertions(+), 9 deletions(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 496a05e273..c79b470c28 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -1431,7 +1431,11 @@ cull_and_draw_together(GraphicsEngine::Windows wlist, } if (win->begin_frame(GraphicsOutput::FM_render, current_thread)) { - win->clear(current_thread); + if (win->is_any_clear_active()) { + GraphicsStateGuardian *gsg = win->get_gsg(); + PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); + win->clear(current_thread); + } int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { @@ -1476,6 +1480,7 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, gsg->prepare_display_region(&dr_reader); if (dr_reader.is_any_clear_active()) { + PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); gsg->clear(dr); } @@ -1651,7 +1656,10 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { // a current context for PStatGPUTimer to work. { PStatGPUTimer timer(gsg, win->get_draw_window_pcollector(), current_thread); - win->clear(current_thread); + if (win->is_any_clear_active()) { + PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); + win->clear(current_thread); + } if (display_cat.is_spam()) { display_cat.spam() @@ -2015,6 +2023,7 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre win->change_scenes(&dr_reader); gsg->prepare_display_region(&dr_reader); if (dr_reader.is_any_clear_active()) { + PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); gsg->clear(dr_reader.get_object()); } diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index c94c83f54c..992f634dd9 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -703,6 +703,15 @@ get_draw_window_pcollector() { return _draw_window_pcollector; } +/** + * Returns a PStatCollector for timing the clear operation for just this + * GraphicsOutput. + */ +INLINE PStatCollector &GraphicsOutput:: +get_clear_window_pcollector() { + return _clear_window_pcollector; +} + /** * Display the spam message associated with begin_frame */ diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index c8237059b8..33bfddb79f 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -77,6 +77,7 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, _lock("GraphicsOutput"), _cull_window_pcollector(_cull_pcollector, name), _draw_window_pcollector(_draw_pcollector, name), + _clear_window_pcollector(_draw_window_pcollector, "Clear"), _size(0, 0) { #ifdef DO_MEMORY_USAGE diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index f426b41bee..49c257e17e 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -289,6 +289,7 @@ public: INLINE PStatCollector &get_cull_window_pcollector(); INLINE PStatCollector &get_draw_window_pcollector(); + INLINE PStatCollector &get_clear_window_pcollector(); protected: virtual void pixel_factor_changed(); @@ -409,6 +410,7 @@ protected: static PStatCollector _draw_pcollector; PStatCollector _cull_window_pcollector; PStatCollector _draw_window_pcollector; + PStatCollector _clear_window_pcollector; public: static TypeHandle get_class_type() { diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 0e82a23f88..93c732e5d7 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -92,7 +92,6 @@ PStatCollector GraphicsStateGuardian::_transform_state_pcollector("State changes PStatCollector GraphicsStateGuardian::_texture_state_pcollector("State changes:Textures"); PStatCollector GraphicsStateGuardian::_draw_primitive_pcollector("Draw:Primitive:Draw"); PStatCollector GraphicsStateGuardian::_draw_set_state_pcollector("Draw:Set State"); -PStatCollector GraphicsStateGuardian::_clear_pcollector("Draw:Clear"); PStatCollector GraphicsStateGuardian::_flush_pcollector("Draw:Flush"); PStatCollector GraphicsStateGuardian::_compute_dispatch_pcollector("Draw:Compute dispatch"); diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index c64bbe692a..e1c9435fef 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -685,7 +685,6 @@ public: static PStatCollector _texture_state_pcollector; static PStatCollector _draw_primitive_pcollector; static PStatCollector _draw_set_state_pcollector; - static PStatCollector _clear_pcollector; static PStatCollector _flush_pcollector; static PStatCollector _compute_dispatch_pcollector; static PStatCollector _wait_occlusion_pcollector; diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index d5a8763fc8..3a65317c5e 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -113,8 +113,6 @@ clear(Thread *current_thread) { << get_name() << " " << (void *)this << "\n"; } - PStatGPUTimer timer(glgsg, glgsg->_clear_pcollector); - // Disable the scissor test, so we can clear the whole buffer. glDisable(GL_SCISSOR_TEST); glgsg->_scissor_enabled = false; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 6ce88525f5..efa5592539 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -3405,7 +3405,6 @@ finish() { */ void CLP(GraphicsStateGuardian):: clear(DrawableRegion *clearable) { - PStatGPUTimer timer(this, _clear_pcollector); report_my_gl_errors(); if (!clearable->is_any_clear_active()) { diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index fd3c44c917..4adc287cb4 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -202,8 +202,6 @@ make_geom_munger(const RenderState *state, Thread *current_thread) { */ void TinyGraphicsStateGuardian:: clear(DrawableRegion *clearable) { - PStatTimer timer(_clear_pcollector); - if ((!clearable->get_clear_color_active())&& (!clearable->get_clear_depth_active())&& (!clearable->get_clear_stencil_active())) { From e759a1b6052be122eb9f9985e099f76f1ff6573a Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 19 Nov 2018 21:01:43 +0100 Subject: [PATCH 334/360] display: give DisplayRegions a more recognisable name in PStats --- panda/src/display/displayRegion.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index e1765861e1..6946ce6832 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -679,7 +679,24 @@ void DisplayRegion:: set_active_index(int index) { #ifdef DO_PSTATS std::ostringstream strm; - strm << "dr_" << index; + + // To make a more useful name for PStats and debug output, we add the scene + // graph name and camera name. + NodePath camera = get_camera(); + if (!camera.is_empty()) { + Camera *camera_node = DCAST(Camera, camera.node()); + if (camera_node != nullptr) { + NodePath scene_root = camera_node->get_scene(); + if (scene_root.is_empty()) { + scene_root = camera.get_top(); + } + strm << scene_root.get_name(); + } + } + + // And add the index in case we have two scene graphs with the same name. + strm << "#" << index; + string name = strm.str(); _cull_region_pcollector = PStatCollector(_window->get_cull_window_pcollector(), name); From d902ea5ce4e084c8dd39d2bd781a463893ba12fa Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 19 Nov 2018 22:13:07 +0100 Subject: [PATCH 335/360] display: don't render window if all its DRs are inactive This is an optimization, which will skip begin_frame/end_frame for a buffer that isn't going to have anything rendered to it. Affects the RenderPipeline. --- panda/src/display/graphicsOutput.cxx | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 33bfddb79f..d473b4bee2 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -412,15 +412,38 @@ is_active() const { return false; } - CDReader cdata(_cycler); + CDLockedReader cdata(_cycler); + if (!cdata->_active) { + return false; + } + if (cdata->_one_shot_frame != -1) { // If one_shot is in effect, then we are active only for the one indicated // frame. if (cdata->_one_shot_frame != ClockObject::get_global_clock()->get_frame_count()) { return false; + } else { + return true; } } - return cdata->_active; + + // If the window has a clear value set, it is active. + if (is_any_clear_active()) { + return true; + } + + // If we triggered a copy operation, it is also active. + if (_trigger_copy) { + return true; + } + + // The window is active if at least one display region is active. + if (cdata->_active_display_regions_stale) { + CDWriter cdataw(((GraphicsOutput *)this)->_cycler, cdata, false); + ((GraphicsOutput *)this)->do_determine_display_regions(cdataw); + } + + return !cdata->_active_display_regions.empty(); } /** From b1eec5fae04b02f2c7fd7fbb71cd7b2f8163e6bb Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 19 Nov 2018 22:15:31 +0100 Subject: [PATCH 336/360] CommonFilters: give passes a unique name for debugging/PStats --- direct/src/filter/CommonFilters.py | 26 +++++++++++++------------- direct/src/filter/FilterManager.py | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/direct/src/filter/CommonFilters.py b/direct/src/filter/CommonFilters.py index 894b57c321..9e54cb82b8 100644 --- a/direct/src/filter/CommonFilters.py +++ b/direct/src/filter/CommonFilters.py @@ -184,8 +184,8 @@ class CommonFilters: if ("BlurSharpen" in configuration): blur0=self.textures["blur0"] blur1=self.textures["blur1"] - self.blur.append(self.manager.renderQuadInto(colortex=blur0,div=2)) - self.blur.append(self.manager.renderQuadInto(colortex=blur1)) + self.blur.append(self.manager.renderQuadInto("filter-blur0", colortex=blur0,div=2)) + self.blur.append(self.manager.renderQuadInto("filter-blur1", colortex=blur1)) self.blur[0].setShaderInput("src", self.textures["color"]) self.blur[0].setShader(self.loadShader("filter-blurx.sha")) self.blur[1].setShaderInput("src", blur0) @@ -195,9 +195,9 @@ class CommonFilters: ssao0=self.textures["ssao0"] ssao1=self.textures["ssao1"] ssao2=self.textures["ssao2"] - self.ssao.append(self.manager.renderQuadInto(colortex=ssao0)) - self.ssao.append(self.manager.renderQuadInto(colortex=ssao1,div=2)) - self.ssao.append(self.manager.renderQuadInto(colortex=ssao2)) + self.ssao.append(self.manager.renderQuadInto("filter-ssao0", colortex=ssao0)) + self.ssao.append(self.manager.renderQuadInto("filter-ssao1", colortex=ssao1,div=2)) + self.ssao.append(self.manager.renderQuadInto("filter-ssao2", colortex=ssao2)) self.ssao[0].setShaderInput("depth", self.textures["depth"]) self.ssao[0].setShaderInput("normal", self.textures["aux"]) self.ssao[0].setShaderInput("random", loader.loadTexture("maps/random.rgb")) @@ -215,21 +215,21 @@ class CommonFilters: bloom3=self.textures["bloom3"] if (bloomconf.size == "large"): scale=8 - downsampler="filter-down4.sha" + downsampler="filter-down4" elif (bloomconf.size == "medium"): scale=4 - downsampler="filter-copy.sha" + downsampler="filter-copy" else: scale=2 - downsampler="filter-copy.sha" - self.bloom.append(self.manager.renderQuadInto(colortex=bloom0, div=2, align=scale)) - self.bloom.append(self.manager.renderQuadInto(colortex=bloom1, div=scale, align=scale)) - self.bloom.append(self.manager.renderQuadInto(colortex=bloom2, div=scale, align=scale)) - self.bloom.append(self.manager.renderQuadInto(colortex=bloom3, div=scale, align=scale)) + downsampler="filter-copy" + self.bloom.append(self.manager.renderQuadInto("filter-bloomi", colortex=bloom0, div=2, align=scale)) + self.bloom.append(self.manager.renderQuadInto(downsampler, colortex=bloom1, div=scale, align=scale)) + self.bloom.append(self.manager.renderQuadInto("filter-bloomx", colortex=bloom2, div=scale, align=scale)) + self.bloom.append(self.manager.renderQuadInto("filter-bloomy", colortex=bloom3, div=scale, align=scale)) self.bloom[0].setShaderInput("src", self.textures["color"]) self.bloom[0].setShader(self.loadShader("filter-bloomi.sha")) self.bloom[1].setShaderInput("src", bloom0) - self.bloom[1].setShader(self.loadShader(downsampler)) + self.bloom[1].setShader(self.loadShader(downsampler + ".sha")) self.bloom[2].setShaderInput("src", bloom1) self.bloom[2].setShader(self.loadShader("filter-bloomx.sha")) self.bloom[3].setShaderInput("src", bloom2) diff --git a/direct/src/filter/FilterManager.py b/direct/src/filter/FilterManager.py index 1de63c702d..4150cba568 100644 --- a/direct/src/filter/FilterManager.py +++ b/direct/src/filter/FilterManager.py @@ -236,7 +236,7 @@ class FilterManager(DirectObject): return quad - def renderQuadInto(self, mul=1, div=1, align=1, depthtex=None, colortex=None, auxtex0=None, auxtex1=None): + def renderQuadInto(self, name="filter-stage", mul=1, div=1, align=1, depthtex=None, colortex=None, auxtex0=None, auxtex1=None): """ Creates an offscreen buffer for an intermediate computation. Installs a quad into the buffer. Returns @@ -250,7 +250,7 @@ class FilterManager(DirectObject): depthbits = bool(depthtex != None) - buffer = self.createBuffer("filter-stage", winx, winy, texgroup, depthbits) + buffer = self.createBuffer(name, winx, winy, texgroup, depthbits) if (buffer == None): return None From c18cdcf36ef238cf0979f21c1205fd56d16c81bd Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 19 Nov 2018 22:57:56 +0100 Subject: [PATCH 337/360] display: add support for debug markers, to help with debugging This is useful when running Panda in a tool like apitrace, so that the different calls in a frame are ordered in a neat hierarchy. --- panda/src/display/displayRegion.I | 8 +++++ panda/src/display/displayRegion.cxx | 10 +++--- panda/src/display/displayRegion.h | 3 ++ panda/src/display/graphicsEngine.cxx | 33 ++++++++++++++----- panda/src/glstuff/glGraphicsBuffer_src.cxx | 6 ++++ .../src/glstuff/glGraphicsStateGuardian_src.I | 24 ++++++++++++++ .../glstuff/glGraphicsStateGuardian_src.cxx | 18 ++++++++++ .../src/glstuff/glGraphicsStateGuardian_src.h | 8 +++++ panda/src/glxdisplay/glxGraphicsWindow.cxx | 29 ++++++++++++++++ panda/src/glxdisplay/glxGraphicsWindow.h | 1 + panda/src/gsgbase/graphicsStateGuardianBase.h | 3 ++ panda/src/pgraph/cullResult.cxx | 3 ++ panda/src/wgldisplay/wglGraphicsWindow.cxx | 5 +++ 13 files changed, 139 insertions(+), 12 deletions(-) diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index 96f2383bf9..71b3a069cf 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -523,6 +523,14 @@ get_draw_region_pcollector() { return _draw_region_pcollector; } +/** + * Returns a unique name used for debugging. + */ +INLINE const std::string &DisplayRegion:: +get_debug_name() const { + return _debug_name; +} + /** * */ diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index 6946ce6832..4629a38f75 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -677,7 +677,7 @@ do_compute_pixels(int i, int x_size, int y_size, CData *cdata) { */ void DisplayRegion:: set_active_index(int index) { -#ifdef DO_PSTATS +#if defined(DO_PSTATS) || !defined(NDEBUG) std::ostringstream strm; // To make a more useful name for PStats and debug output, we add the scene @@ -697,10 +697,12 @@ set_active_index(int index) { // And add the index in case we have two scene graphs with the same name. strm << "#" << index; - string name = strm.str(); + _debug_name = strm.str(); +#endif - _cull_region_pcollector = PStatCollector(_window->get_cull_window_pcollector(), name); - _draw_region_pcollector = PStatCollector(_window->get_draw_window_pcollector(), name); +#ifdef DO_PSTATS + _cull_region_pcollector = PStatCollector(_window->get_cull_window_pcollector(), _debug_name); + _draw_region_pcollector = PStatCollector(_window->get_draw_window_pcollector(), _debug_name); #endif // DO_PSTATS } diff --git a/panda/src/display/displayRegion.h b/panda/src/display/displayRegion.h index e97829be2c..280edaa333 100644 --- a/panda/src/display/displayRegion.h +++ b/panda/src/display/displayRegion.h @@ -184,6 +184,8 @@ public: INLINE PStatCollector &get_cull_region_pcollector(); INLINE PStatCollector &get_draw_region_pcollector(); + INLINE const std::string &get_debug_name() const; + struct Region { INLINE Region(); @@ -277,6 +279,7 @@ private: PStatCollector _cull_region_pcollector; PStatCollector _draw_region_pcollector; + std::string _debug_name; public: static TypeHandle get_class_type() { diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index c79b470c28..dd160d55b5 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -1174,7 +1174,8 @@ extract_texture_data(Texture *tex, GraphicsStateGuardian *gsg) { */ void GraphicsEngine:: dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, GraphicsStateGuardian *gsg) { - nassertv(sattr->get_shader() != nullptr); + const Shader *shader = sattr->get_shader(); + nassertv(shader != nullptr); nassertv(gsg != nullptr); ReMutexHolder holder(_lock); @@ -1184,8 +1185,10 @@ dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, Graph string draw_name = gsg->get_threading_model().get_draw_name(); if (draw_name.empty()) { // A single-threaded environment. No problem. + gsg->push_group_marker(std::string("Compute ") + shader->get_filename(Shader::ST_compute).get_basename()); gsg->set_state_and_transform(state, TransformState::make_identity()); gsg->dispatch_compute(work_groups[0], work_groups[1], work_groups[2]); + gsg->pop_group_marker(); } else { // A multi-threaded environment. We have to wait until the draw thread @@ -1434,7 +1437,9 @@ cull_and_draw_together(GraphicsEngine::Windows wlist, if (win->is_any_clear_active()) { GraphicsStateGuardian *gsg = win->get_gsg(); PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); + gsg->push_group_marker("Clear"); win->clear(current_thread); + gsg->pop_group_marker(); } int num_display_regions = win->get_num_active_display_regions(); @@ -1472,6 +1477,8 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, GraphicsStateGuardian *gsg = win->get_gsg(); nassertv(gsg != nullptr); + gsg->push_group_marker(dr->get_debug_name()); + PT(SceneSetup) scene_setup; { @@ -1517,6 +1524,8 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, gsg->end_scene(); } } + + gsg->pop_group_marker(); } /** @@ -1658,7 +1667,9 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { PStatGPUTimer timer(gsg, win->get_draw_window_pcollector(), current_thread); if (win->is_any_clear_active()) { PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); + win->get_gsg()->push_group_marker("Clear"); win->clear(current_thread); + win->get_gsg()->pop_group_marker(); } if (display_cat.is_spam()) { @@ -2008,6 +2019,8 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre // Statistics PStatGPUTimer timer(gsg, dr->get_draw_region_pcollector(), current_thread); + gsg->push_group_marker(dr->get_debug_name()); + PT(CullResult) cull_result; PT(SceneSetup) scene_setup; { @@ -2043,11 +2056,7 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre // We don't trust the state the callback may have left us in. gsg->clear_state_and_transform(); - // The callback has taken care of the drawing. - return; - } - - if (cull_result == nullptr || scene_setup == nullptr) { + } else if (cull_result == nullptr || scene_setup == nullptr) { // Nothing to see here. } else if (dr->is_stereo()) { @@ -2068,6 +2077,8 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre gsg->end_scene(); } } + + gsg->pop_group_marker(); } /** @@ -2677,8 +2688,14 @@ thread_main() { case TS_do_compute: nassertd(_gsg != nullptr && _state != nullptr) break; - _gsg->set_state_and_transform(_state, TransformState::make_identity()); - _gsg->dispatch_compute(_work_groups[0], _work_groups[1], _work_groups[2]); + { + const ShaderAttrib *sattr; + _state->get_attrib(sattr); + _gsg->push_group_marker(std::string("Compute ") + sattr->get_shader()->get_filename(Shader::ST_compute).get_basename()); + _gsg->set_state_and_transform(_state, TransformState::make_identity()); + _gsg->dispatch_compute(_work_groups[0], _work_groups[1], _work_groups[2]); + _gsg->pop_group_marker(); + } break; case TS_do_extract: diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 3a65317c5e..06c26a590d 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -230,6 +230,9 @@ begin_frame(FrameMode mode, Thread *current_thread) { } } + CLP(GraphicsStateGuardian) *glgsg = (CLP(GraphicsStateGuardian) *)_gsg.p(); + glgsg->push_group_marker(std::string(CLASSPREFIX_QUOTED "GraphicsBuffer ") + get_name()); + // Figure out the desired size of the buffer. if (mode == FM_render) { clear_cube_map_selection(); @@ -255,6 +258,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { if (_needs_rebuild) { // If we still need rebuild, something went wrong with // rebuild_bitplanes(). + glgsg->pop_group_marker(); return false; } @@ -1314,6 +1318,8 @@ end_frame(FrameMode mode, Thread *current_thread) { clear_cube_map_selection(); } report_my_gl_errors(); + + glgsg->pop_group_marker(); } /** diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.I b/panda/src/glstuff/glGraphicsStateGuardian_src.I index bdb9db6eb5..5cb8d8db10 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.I +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.I @@ -11,6 +11,30 @@ * @date 1999-02-02 */ +/** + * If debug markers are enabled, pushes the beginning of a group marker. + */ +INLINE void CLP(GraphicsStateGuardian):: +push_group_marker(const std::string &marker) { +#if !defined(NDEBUG) && !defined(OPENGLES_1) + if (_glPushGroupMarker != nullptr) { + _glPushGroupMarker(marker.size(), marker.data()); + } +#endif +} + +/** + * If debug markers are enabled, closes a group debug marker. + */ +INLINE void CLP(GraphicsStateGuardian):: +pop_group_marker() { +#if !defined(NDEBUG) && !defined(OPENGLES_1) + if (_glPopGroupMarker != nullptr) { + _glPopGroupMarker(); + } +#endif +} + /** * Checks for any outstanding error codes and outputs them, if found. If * NDEBUG is defined, this function does nothing. The return value is true if diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index efa5592539..c7f8d51f88 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -616,6 +616,22 @@ reset() { // Print out a list of all extensions. report_extensions(); + // Check if we are running under a profiling tool such as apitrace. +#if !defined(NDEBUG) && !defined(OPENGLES_1) + if (has_extension("GL_EXT_debug_marker")) { + _glPushGroupMarker = (PFNGLPUSHGROUPMARKEREXTPROC) + get_extension_func("glPushGroupMarkerEXT"); + _glPopGroupMarker = (PFNGLPOPGROUPMARKEREXTPROC) + get_extension_func("glPopGroupMarkerEXT"); + + // Start a group right away. + push_group_marker("reset"); + } else { + _glPushGroupMarker = nullptr; + _glPopGroupMarker = nullptr; + } +#endif + // Initialize OpenGL debugging output first, if enabled and supported. _supports_debug = false; _use_object_labels = false; @@ -3373,6 +3389,8 @@ reset() { } #endif + pop_group_marker(); + // Now that the GSG has been initialized, make it available for // optimizations. add_gsg(this); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 99c8296336..9abce60cd5 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -275,6 +275,9 @@ public: static void APIENTRY debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam); + INLINE virtual void push_group_marker(const std::string &marker) final; + INLINE virtual void pop_group_marker() final; + virtual void reset(); virtual void prepare_display_region(DisplayRegionPipelineReader *dr); @@ -1091,6 +1094,11 @@ public: GLuint _white_texture; #ifndef NDEBUG +#ifndef OPENGLES_1 + PFNGLPUSHGROUPMARKEREXTPROC _glPushGroupMarker; + PFNGLPOPGROUPMARKEREXTPROC _glPopGroupMarker; +#endif + bool _show_texture_usage; int _show_texture_usage_max_size; int _show_texture_usage_index; diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index a7a2472a84..5e9a670cff 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -89,6 +89,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { glxgsg->reset_if_new(); if (mode == FM_render) { + glxgsg->push_group_marker(std::string("glxGraphicsWindow ") + get_name()); // begin_render_texture(); clear_cube_map_selection(); } @@ -97,6 +98,34 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } + +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ +void glxGraphicsWindow:: +end_frame(FrameMode mode, Thread *current_thread) { + end_frame_spam(mode); + nassertv(_gsg != nullptr); + + if (mode == FM_render) { + // end_render_texture(); + copy_to_textures(); + } + + _gsg->end_frame(current_thread); + + if (mode == FM_render) { + trigger_flip(); + clear_cube_map_selection(); + + glxGraphicsStateGuardian *glxgsg; + DCAST_INTO_V(glxgsg, _gsg); + glxgsg->pop_group_marker(); + } +} + /** * This function will be called within the draw thread after begin_flip() has * been called on all windows, to finish the exchange of the front and back diff --git a/panda/src/glxdisplay/glxGraphicsWindow.h b/panda/src/glxdisplay/glxGraphicsWindow.h index 4c583c186c..53ebc9133c 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.h +++ b/panda/src/glxdisplay/glxGraphicsWindow.h @@ -36,6 +36,7 @@ public: virtual ~glxGraphicsWindow() {}; virtual bool begin_frame(FrameMode mode, Thread *current_thread); + virtual void end_frame(FrameMode mode, Thread *current_thread); virtual void end_flip(); protected: diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.h b/panda/src/gsgbase/graphicsStateGuardianBase.h index e993b74de2..1dd7def8a2 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.h +++ b/panda/src/gsgbase/graphicsStateGuardianBase.h @@ -235,6 +235,9 @@ public: #endif } + virtual void push_group_marker(const std::string &marker) {} + virtual void pop_group_marker() {} + PUBLISHED: static GraphicsStateGuardianBase *get_default_gsg(); static void set_default_gsg(GraphicsStateGuardianBase *default_gsg); diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index faee06ee53..65c9555bff 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -295,7 +295,10 @@ draw(Thread *current_thread) { nassertv(bin_index >= 0); if (bin_index < (int)_bins.size() && _bins[bin_index] != nullptr) { + + _gsg->push_group_marker(_bins[bin_index]->get_name()); _bins[bin_index]->draw(force, current_thread); + _gsg->pop_group_marker(); } } } diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index 6ff5b88c36..1c4fbe9773 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -87,6 +87,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { wglgsg->reset_if_new(); if (mode == FM_render) { + wglgsg->push_group_marker(std::string("wglGraphicsWindow ") + get_name()); clear_cube_map_selection(); } @@ -114,6 +115,10 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_render) { trigger_flip(); clear_cube_map_selection(); + + wglGraphicsStateGuardian *wglgsg; + DCAST_INTO_V(wglgsg, _gsg); + wglgsg->pop_group_marker(); } } From 53cec96c07db3ccb03f2fa54bbbc930de0272ee0 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 19 Nov 2018 22:59:35 +0100 Subject: [PATCH 338/360] Fix draw calls being listed under Primitive Setup in PStats, etc. Previously, all draw calls would be grouped under "Primitive Setup", rather than under the appropriate bin collector. This commit fixes that and adds a few other useful collectors as well. --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 7 +++++-- panda/src/glstuff/glGraphicsStateGuardian_src.h | 1 + panda/src/gobj/geom.cxx | 7 +++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index c7f8d51f88..0aaada58a1 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -91,6 +91,7 @@ PStatCollector CLP(GraphicsStateGuardian)::_vertex_array_update_pcollector("Draw PStatCollector CLP(GraphicsStateGuardian)::_texture_update_pcollector("Draw:Update texture"); PStatCollector CLP(GraphicsStateGuardian)::_fbo_bind_pcollector("Draw:Bind FBO"); PStatCollector CLP(GraphicsStateGuardian)::_check_error_pcollector("Draw:Check errors"); +PStatCollector CLP(GraphicsStateGuardian)::_check_residency_pcollector("*:PStats:Check residency"); // The following noop functions are assigned to the corresponding glext // function pointers in the class, in case the functions are not defined by @@ -3949,6 +3950,7 @@ end_frame(Thread *current_thread) { // connects PStats, at which point it will then correct the assessment. No // harm done. if (has_fixed_function_pipeline() && PStatClient::is_connected()) { + PStatTimer timer(_check_residency_pcollector); check_nonresident_texture(_prepared_objects->_texture_residency.get_inactive_resident()); check_nonresident_texture(_prepared_objects->_texture_residency.get_active_resident()); @@ -7208,6 +7210,8 @@ do_issue_shade_model() { */ void CLP(GraphicsStateGuardian):: do_issue_shader() { + PStatTimer timer(_draw_set_state_shader_pcollector); + ShaderContext *context = 0; Shader *shader = (Shader *)_target_shader->get_shader(); @@ -10919,7 +10923,6 @@ set_state_and_transform(const RenderState *target, _instance_count = _target_shader->get_instance_count(); if (_target_shader != _state_shader) { - // PStatGPUTimer timer(this, _draw_set_state_shader_pcollector); do_issue_shader(); _state_shader = _target_shader; _state_mask.clear_bit(TextureAttrib::get_class_slot()); @@ -11075,7 +11078,7 @@ set_state_and_transform(const RenderState *target, int texture_slot = TextureAttrib::get_class_slot(); if (_target_rs->get_attrib(texture_slot) != _state_rs->get_attrib(texture_slot) || !_state_mask.get_bit(texture_slot)) { - // PStatGPUTimer timer(this, _draw_set_state_texture_pcollector); + PStatGPUTimer timer(this, _draw_set_state_texture_pcollector); determine_target_texture(); do_issue_texture(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 9abce60cd5..f4fda4ab9e 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -1126,6 +1126,7 @@ public: static PStatCollector _texture_update_pcollector; static PStatCollector _fbo_bind_pcollector; static PStatCollector _check_error_pcollector; + static PStatCollector _check_residency_pcollector; public: virtual TypeHandle get_type() const { diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index bafe523e0f..03409b4220 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -1844,8 +1844,11 @@ check_valid(const GeomVertexDataPipelineReader *data_reader) const { bool GeomPipelineReader:: draw(GraphicsStateGuardianBase *gsg, const GeomVertexDataPipelineReader *data_reader, bool force) const { - PStatTimer timer(Geom::_draw_primitive_setup_pcollector); - bool all_ok = gsg->begin_draw_primitives(this, data_reader, force); + bool all_ok; + { + PStatTimer timer(Geom::_draw_primitive_setup_pcollector); + all_ok = gsg->begin_draw_primitives(this, data_reader, force); + } if (all_ok) { Geom::Primitives::const_iterator pi; for (pi = _cdata->_primitives.begin(); From ec4b0825e99bbe2c898b8f63c07a62927a16c17f Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 20 Nov 2018 12:41:43 +0100 Subject: [PATCH 339/360] glgsg: restore more OpenGL state after draw callback --- .../glstuff/glGraphicsStateGuardian_src.cxx | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 0aaada58a1..c9a22615bf 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -10661,6 +10661,71 @@ reissue_transforms() { _current_vertex_format.clear(); memset(_vertex_attrib_columns, 0, sizeof(const GeomVertexColumn *) * 32); #endif + + // Since this is called by clear_state_and_transform(), we also should reset + // the states that won't automatically be respecified when clearing the + // state mask. + _active_color_write_mask = ColorWriteAttrib::C_all; + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + + if (_dithering_enabled) { + glEnable(GL_DITHER); + } else { + glDisable(GL_DITHER); + } + if (_depth_test_enabled) { + glEnable(GL_DEPTH_TEST); + } else { + glDisable(GL_DEPTH_TEST); + } + if (_stencil_test_enabled) { + glEnable(GL_STENCIL_TEST); + } else { + glDisable(GL_STENCIL_TEST); + } + if (_blend_enabled) { + glEnable(GL_BLEND); + } else { + glDisable(GL_BLEND); + } + +#ifndef OPENGLES_2 + if (_multisample_mode != 0) { + glEnable(GL_MULTISAMPLE); + } else { + glDisable(GL_MULTISAMPLE); + glDisable(GL_SAMPLE_ALPHA_TO_ONE); + glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); + } + if (_line_smooth_enabled) { + glEnable(GL_LINE_SMOOTH); + } else { + glDisable(GL_LINE_SMOOTH); + } +#endif + +#ifndef OPENGLES + if (_polygon_smooth_enabled) { + glEnable(GL_POLYGON_SMOOTH); + } else { + glDisable(GL_POLYGON_SMOOTH); + } +#endif + +#ifdef SUPPORT_FIXED_FUNCTION + if (has_fixed_function_pipeline()) { + if (_alpha_test_enabled) { + glEnable(GL_ALPHA_TEST); + } else { + glDisable(GL_ALPHA_TEST); + } + if (_point_smooth_enabled) { + glEnable(GL_POINT_SMOOTH); + } else { + glDisable(GL_POINT_SMOOTH); + } + } +#endif } #ifdef SUPPORT_FIXED_FUNCTION From 02979fa106ada9b8f311a1aa698d63129d958a7d Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 20 Nov 2018 14:49:44 +0100 Subject: [PATCH 340/360] makepanda: use pkg-config for locating assimp --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 736434fb92..c29fe10389 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -828,7 +828,7 @@ if (COMPILER=="GCC"): SmartPkgEnable("EIGEN", "eigen3", (), ("Eigen/Dense",), target_pkg = 'ALWAYS') SmartPkgEnable("ARTOOLKIT", "", ("AR"), "AR/ar.h") SmartPkgEnable("FCOLLADA", "", ChooseLib(fcollada_libs, "FCOLLADA"), ("FCollada", "FCollada/FCollada.h")) - SmartPkgEnable("ASSIMP", "", ("assimp"), "assimp/Importer.hpp") + SmartPkgEnable("ASSIMP", "assimp", ("assimp"), "assimp/Importer.hpp") SmartPkgEnable("FFMPEG", ffmpeg_libs, ffmpeg_libs, ("libavformat/avformat.h", "libavcodec/avcodec.h", "libavutil/avutil.h")) SmartPkgEnable("SWSCALE", "libswscale", "libswscale", ("libswscale/swscale.h"), target_pkg = "FFMPEG", thirdparty_dir = "ffmpeg") SmartPkgEnable("SWRESAMPLE","libswresample", "libswresample", ("libswresample/swresample.h"), target_pkg = "FFMPEG", thirdparty_dir = "ffmpeg") From 356b604627edc333c766d8cfb92b2cf58c579864 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 20 Nov 2018 14:50:40 +0100 Subject: [PATCH 341/360] makepanda: link with IrrXML when using static assimp library Same fix as #432 but for Linux --- makepanda/makepanda.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index c29fe10389..c6a01e7cd5 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -872,6 +872,13 @@ if (COMPILER=="GCC"): else: PkgDisable("OPENCV") + if not PkgSkip("ASSIMP") and \ + os.path.isfile(GetThirdpartyDir() + "assimp/lib/libassimp.a"): + # Also pick up IrrXML, which is needed when linking statically. + irrxml = GetThirdpartyDir() + "assimp/lib/libIrrXML.a" + if os.path.isfile(irrxml): + LibName("ASSIMP", irrxml) + rocket_libs = ("RocketCore", "RocketControls") if (GetOptimize() <= 3): rocket_libs += ("RocketDebugger",) From d093cbbb90f6c726f912d23962f5c1cab435d507 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 22 Nov 2018 23:05:40 +0100 Subject: [PATCH 342/360] grutil: apply FPS meter improvements to scene graph analyzer too This fixes the aspect ratio scaling issue in particular. Fixes #456 --- panda/src/grutil/sceneGraphAnalyzerMeter.cxx | 42 +++++++++++++++++--- panda/src/grutil/sceneGraphAnalyzerMeter.h | 3 ++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx index 02d6ed3709..7b64422699 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx @@ -19,6 +19,7 @@ #include "depthTestAttrib.h" #include "depthWriteAttrib.h" #include "pStatTimer.h" +#include "omniBoundingVolume.h" #include // For sprintf/snprintf PStatCollector SceneGraphAnalyzerMeter::_show_analyzer_pcollector("*:Show scene graph analysis"); @@ -29,9 +30,16 @@ TypeHandle SceneGraphAnalyzerMeter::_type_handle; * */ SceneGraphAnalyzerMeter:: -SceneGraphAnalyzerMeter(const std::string &name, PandaNode *node) : TextNode(name) { +SceneGraphAnalyzerMeter(const std::string &name, PandaNode *node) : + TextNode(name), + _last_aspect_ratio(-1) { + set_cull_callback(); + // Don't do frustum culling, as the text will always be in view. + set_bounds(new OmniBoundingVolume()); + set_final(true); + Thread *current_thread = Thread::get_current_thread(); _update_interval = scene_graph_analyzer_meter_update_interval; @@ -41,7 +49,7 @@ SceneGraphAnalyzerMeter(const std::string &name, PandaNode *node) : TextNode(nam set_align(A_left); set_transform(LMatrix4::scale_mat(scene_graph_analyzer_meter_scale) * - LMatrix4::translate_mat(LVector3::rfu(-1.0f + scene_graph_analyzer_meter_side_margins * scene_graph_analyzer_meter_scale, 0.0f, 1.0f - scene_graph_analyzer_meter_scale))); + LMatrix4::translate_mat(LVector3::rfu(scene_graph_analyzer_meter_side_margins * scene_graph_analyzer_meter_scale, 0.0f, -scene_graph_analyzer_meter_scale))); set_card_color(0.0f, 0.0f, 0.0f, 0.4); set_card_as_margin(scene_graph_analyzer_meter_side_margins, scene_graph_analyzer_meter_side_margins, 0.1f, 0.0f); set_usage_hint(Geom::UH_client); @@ -77,6 +85,11 @@ setup_window(GraphicsOutput *window) { _root.set_material_off(1); _root.set_two_sided(1, 1); + // If we don't set this explicitly, Panda will cause it to be rendered + // in a back-to-front cull bin, which will cause the bounding volume + // to be computed unnecessarily. Saves a little bit of overhead. + _root.set_bin("unsorted", 0); + // Create a display region that covers the entire window. _display_region = _window->make_display_region(); _display_region->set_sort(scene_graph_analyzer_meter_layer_sort); @@ -87,10 +100,11 @@ setup_window(GraphicsOutput *window) { PT(Lens) lens = new OrthographicLens; - static const PN_stdfloat left = -1.0f; - static const PN_stdfloat right = 1.0f; - static const PN_stdfloat bottom = -1.0f; - static const PN_stdfloat top = 1.0f; + // We choose these values such that we can place the text against (0, 0). + static const PN_stdfloat left = 0.0f; + static const PN_stdfloat right = 2.0f; + static const PN_stdfloat bottom = -2.0f; + static const PN_stdfloat top = 0.0f; lens->set_film_size(right - left, top - bottom); lens->set_film_offset((right + left) * 0.5, (top + bottom) * 0.5); lens->set_near_far(-1000, 1000); @@ -138,6 +152,22 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // Statistics PStatTimer timer(_show_analyzer_pcollector, current_thread); + // This is probably a good time to check if the aspect ratio on the window + // has changed. + int width = _display_region->get_pixel_width(); + int height = _display_region->get_pixel_height(); + PN_stdfloat aspect_ratio = 1; + if (width != 0 && height != 0) { + aspect_ratio = (PN_stdfloat)height / (PN_stdfloat)width; + } + + // Scale the transform by the calculated aspect ratio. + if (aspect_ratio != _last_aspect_ratio) { + _aspect_ratio_transform = TransformState::make_scale(LVecBase3(aspect_ratio, 1, 1)); + _last_aspect_ratio = aspect_ratio; + } + data._net_transform = data._net_transform->compose(_aspect_ratio_transform); + // Check to see if it's time to update. double now = _clock_object->get_frame_time(current_thread); double elapsed = now - _last_update; diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.h b/panda/src/grutil/sceneGraphAnalyzerMeter.h index 148aa37022..e7c184e81b 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.h +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.h @@ -72,6 +72,9 @@ private: PandaNode *_node; ClockObject *_clock_object; + PN_stdfloat _last_aspect_ratio; + CPT(TransformState) _aspect_ratio_transform; + static PStatCollector _show_analyzer_pcollector; public: From 254cea63bb325c500dcf5f53be89491354fa4d7b Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 22 Nov 2018 23:13:58 +0100 Subject: [PATCH 343/360] display: fix assertion in threaded pipeline --- panda/src/display/graphicsOutput.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index d473b4bee2..daf9b217b1 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -441,9 +441,10 @@ is_active() const { if (cdata->_active_display_regions_stale) { CDWriter cdataw(((GraphicsOutput *)this)->_cycler, cdata, false); ((GraphicsOutput *)this)->do_determine_display_regions(cdataw); + return !cdataw->_active_display_regions.empty(); + } else { + return !cdata->_active_display_regions.empty(); } - - return !cdata->_active_display_regions.empty(); } /** From 0a1b6df648683b815fd8c0ea960dbc49762a23fb Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 22 Nov 2018 23:14:29 +0100 Subject: [PATCH 344/360] glxdisplay: grab X11 lock around various GLX calls --- panda/src/glxdisplay/glxGraphicsBuffer.cxx | 8 +++++++- panda/src/glxdisplay/glxGraphicsPixmap.cxx | 7 ++++++- panda/src/glxdisplay/glxGraphicsStateGuardian.cxx | 6 ++++++ panda/src/glxdisplay/glxGraphicsWindow.cxx | 4 ++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.cxx b/panda/src/glxdisplay/glxGraphicsBuffer.cxx index d777f7a239..6ede9a3e36 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.cxx +++ b/panda/src/glxdisplay/glxGraphicsBuffer.cxx @@ -71,7 +71,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { glxGraphicsStateGuardian *glxgsg; DCAST_INTO_R(glxgsg, _gsg, false); - glXMakeCurrent(_display, _pbuffer, glxgsg->_context); + { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); + glXMakeCurrent(_display, _pbuffer, glxgsg->_context); + } // Now that we have made the context current to a window, we can reset the // GSG state if this is the first time it has been used. (We can't just @@ -125,6 +128,7 @@ end_frame(FrameMode mode, Thread *current_thread) { void glxGraphicsBuffer:: close_buffer() { if (_gsg != nullptr) { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); glXMakeCurrent(_display, None, nullptr); if (_pbuffer != None) { @@ -179,6 +183,8 @@ open_buffer() { nassertr(glxgsg->_supports_pbuffer, false); + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); + static const int max_attrib_list = 32; int attrib_list[max_attrib_list]; int n = 0; diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.cxx b/panda/src/glxdisplay/glxGraphicsPixmap.cxx index 7f551b8d4f..770a7d3d26 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.cxx +++ b/panda/src/glxdisplay/glxGraphicsPixmap.cxx @@ -74,7 +74,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { glxGraphicsStateGuardian *glxgsg; DCAST_INTO_R(glxgsg, _gsg, false); - glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context); + { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); + glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context); + } // Now that we have made the context current to a window, we can reset the // GSG state if this is the first time it has been used. (We can't just @@ -127,6 +130,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void glxGraphicsPixmap:: close_buffer() { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); if (_gsg != nullptr) { glXMakeCurrent(_display, None, nullptr); _gsg.clear(); @@ -197,6 +201,7 @@ open_buffer() { } } + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); _x_pixmap = XCreatePixmap(_display, _drawable, get_x_size(), get_y_size(), visual_info->depth); if (_x_pixmap == None) { diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 76c66d817e..86ddeac589 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -64,6 +64,7 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, */ glxGraphicsStateGuardian:: ~glxGraphicsStateGuardian() { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); destroy_temp_xwindow(); if (_visuals != nullptr) { XFree(_visuals); @@ -224,6 +225,7 @@ choose_pixel_format(const FrameBufferProperties &properties, X11_Display *display, int screen, bool need_pbuffer, bool need_pixmap) { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); _display = display; _screen = screen; _context = nullptr; @@ -457,6 +459,7 @@ gl_get_error() const { */ void glxGraphicsStateGuardian:: query_gl_version() { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); PosixGraphicsStateGuardian::query_gl_version(); show_glx_client_string("GLX_VENDOR", GLX_VENDOR); @@ -483,6 +486,7 @@ query_gl_version() { */ void glxGraphicsStateGuardian:: get_extra_extensions() { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); save_extensions(glXQueryExtensionsString(_display, _screen)); } @@ -497,6 +501,8 @@ do_get_extension_func(const char *name) { nassertr(name != nullptr, nullptr); if (glx_get_proc_address) { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); + // First, check if we have glXGetProcAddress available. This will be // superior if we can get it. diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 5e9a670cff..85757f2faa 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -154,6 +154,8 @@ end_flip() { */ void glxGraphicsWindow:: close_window() { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); + if (_gsg != nullptr) { glXMakeCurrent(_display, None, nullptr); _gsg.clear(); @@ -204,6 +206,8 @@ open_window() { return false; } + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); + if (glxgsg->_fbconfig != None) { setup_colormap(glxgsg->_fbconfig); } else { From 8ad0cb6b57073c763ada3e1718932c7e9625bff2 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 22 Nov 2018 23:52:18 +0100 Subject: [PATCH 345/360] glgsg: add support for p3d_FragData fragment output This is necessary for GLSL 1.30 which deprecates gl_FragData but does not yet support layout(location=) specifiers Also fix some function pointer checks for pre-GL 3.0 Fixes #455 --- .../glstuff/glGraphicsStateGuardian_src.cxx | 42 +++++++++++++++---- .../src/glstuff/glGraphicsStateGuardian_src.h | 2 + panda/src/glstuff/glShaderContext_src.cxx | 5 +++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index c9a22615bf..4a80e7044a 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1754,14 +1754,6 @@ reset() { get_extension_func("glUniform3iv"); _glUniform4iv = (PFNGLUNIFORM4IVPROC) get_extension_func("glUniform4iv"); - _glUniform1uiv = (PFNGLUNIFORM1UIVPROC) - get_extension_func("glUniform1uiv"); - _glUniform2uiv = (PFNGLUNIFORM2UIVPROC) - get_extension_func("glUniform2uiv"); - _glUniform3uiv = (PFNGLUNIFORM3UIVPROC) - get_extension_func("glUniform3uiv"); - _glUniform4uiv = (PFNGLUNIFORM4UIVPROC) - get_extension_func("glUniform4uiv"); _glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) get_extension_func("glUniformMatrix3fv"); _glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) @@ -1776,9 +1768,35 @@ reset() { get_extension_func("glVertexAttribPointer"); if (is_at_least_gl_version(3, 0)) { + _glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) + get_extension_func("glBindFragDataLocation"); _glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) get_extension_func("glVertexAttribIPointer"); + _glUniform1uiv = (PFNGLUNIFORM1UIVPROC) + get_extension_func("glUniform1uiv"); + _glUniform2uiv = (PFNGLUNIFORM2UIVPROC) + get_extension_func("glUniform2uiv"); + _glUniform3uiv = (PFNGLUNIFORM3UIVPROC) + get_extension_func("glUniform3uiv"); + _glUniform4uiv = (PFNGLUNIFORM4UIVPROC) + get_extension_func("glUniform4uiv"); + + } else if (has_extension("GL_EXT_gpu_shader4")) { + _glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) + get_extension_func("glBindFragDataLocationEXT"); + _glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) + get_extension_func("glVertexAttribIPointerEXT"); + _glUniform1uiv = (PFNGLUNIFORM1UIVPROC) + get_extension_func("glUniform1uivEXT"); + _glUniform2uiv = (PFNGLUNIFORM2UIVPROC) + get_extension_func("glUniform2uivEXT"); + _glUniform3uiv = (PFNGLUNIFORM3UIVPROC) + get_extension_func("glUniform3uivEXT"); + _glUniform4uiv = (PFNGLUNIFORM4UIVPROC) + get_extension_func("glUniform4uivEXT"); + } else { + _glBindFragDataLocation = nullptr; _glVertexAttribIPointer = nullptr; } if (is_at_least_gl_version(4, 1) || @@ -1807,6 +1825,7 @@ reset() { _glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) get_extension_func("glVertexAttribPointerARB"); + _glBindFragDataLocation = nullptr; _glVertexAttribIPointer = nullptr; _glVertexAttribLPointer = nullptr; } @@ -1858,6 +1877,13 @@ reset() { } else { _glVertexAttribIPointer = nullptr; } + + if (has_extension("GL_EXT_blend_func_extended")) { + _glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) + get_extension_func("glBindFragDataLocationEXT"); + } else { + _glBindFragDataLocation = nullptr; + } #endif #ifndef OPENGLES_1 diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index f4fda4ab9e..4329938d06 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -146,6 +146,7 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum d // GLSL shader functions typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); @@ -963,6 +964,7 @@ public: // GLSL functions PFNGLATTACHSHADERPROC _glAttachShader; PFNGLBINDATTRIBLOCATIONPROC _glBindAttribLocation; + PFNGLBINDFRAGDATALOCATIONPROC _glBindFragDataLocation; PFNGLCOMPILESHADERPROC _glCompileShader; PFNGLCREATEPROGRAMPROC _glCreateProgram; PFNGLCREATESHADERPROC _glCreateShader; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index b3a608d068..bf6c6097fa 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -3219,6 +3219,11 @@ glsl_compile_and_link() { _glgsg->_glBindAttribLocation(_glsl_program, 8, "texcoord"); } + // Also bind the p3d_FragData array to the first index always. + if (_glgsg->_glBindFragDataLocation != nullptr) { + _glgsg->_glBindFragDataLocation(_glsl_program, 0, "p3d_FragData"); + } + // If we requested to retrieve the shader, we should indicate that before // linking. bool retrieve_binary = false; From bafb0ac3dbe7683737081b70dcc70ee876e78e9e Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 23 Nov 2018 00:12:22 +0100 Subject: [PATCH 346/360] x11display: add x-init-threads var to call XInitThreads() This is off by default, but could be used if you stumble upon a race condition issue with X11 and threading. --- panda/src/x11display/config_x11display.cxx | 5 +++++ panda/src/x11display/config_x11display.h | 1 + panda/src/x11display/x11GraphicsPipe.cxx | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/panda/src/x11display/config_x11display.cxx b/panda/src/x11display/config_x11display.cxx index 4a633303ba..d31c4c1c23 100644 --- a/panda/src/x11display/config_x11display.cxx +++ b/panda/src/x11display/config_x11display.cxx @@ -40,6 +40,11 @@ ConfigVariableBool x_error_abort "of an error from the X window system. This can make it easier " "to discover where these errors are generated.")); +ConfigVariableBool x_init_threads +("x-init-threads", false, + PRC_DESC("Set this true to ask Panda3D to call XInitThreads() upon loading " + "the display module, which may help with some threading issues.")); + ConfigVariableInt x_wheel_up_button ("x-wheel-up-button", 4, PRC_DESC("This is the mouse button index of the wheel_up event: which " diff --git a/panda/src/x11display/config_x11display.h b/panda/src/x11display/config_x11display.h index bc40aad627..157f09c5fc 100644 --- a/panda/src/x11display/config_x11display.h +++ b/panda/src/x11display/config_x11display.h @@ -26,6 +26,7 @@ extern EXPCL_PANDAX11 void init_libx11display(); extern ConfigVariableString display_cfg; extern ConfigVariableBool x_error_abort; +extern ConfigVariableBool x_init_threads; extern ConfigVariableInt x_wheel_up_button; extern ConfigVariableInt x_wheel_down_button; diff --git a/panda/src/x11display/x11GraphicsPipe.cxx b/panda/src/x11display/x11GraphicsPipe.cxx index 2348d58706..479b3fde0c 100644 --- a/panda/src/x11display/x11GraphicsPipe.cxx +++ b/panda/src/x11display/x11GraphicsPipe.cxx @@ -66,6 +66,12 @@ x11GraphicsPipe(const std::string &display) : _im = (XIM)nullptr; _hidden_cursor = None; + // According to the documentation, we should call this before making any + // other Xlib calls if we wish to use the Xlib locking system. + if (x_init_threads) { + XInitThreads(); + } + install_error_handlers(); _display = XOpenDisplay(display_spec.c_str()); From 3f91615a2263f95fda40ae5cc427bcf67e2064f5 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 23 Nov 2018 00:22:34 +0100 Subject: [PATCH 347/360] glgsg: reset color write mask before calling draw callback --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 4a80e7044a..8e9105de1c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -3754,6 +3754,10 @@ clear_before_callback() { _glClientActiveTexture(GL_TEXTURE0); #endif + // It's also quite reasonable to presume there aren't any funny color write + // mask settings active. + clear_color_write_mask(); + // Clear the bound sampler object, so that we do not inadvertently override // the callback's desired sampler settings. #ifndef OPENGLES_1 From e32388c2f83e79dadf8b2b8b23fd34649eb1f7ce Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 24 Nov 2018 22:44:09 +0100 Subject: [PATCH 348/360] interrogate: fix crash reading static property --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index fd8b5432cd..59575668d4 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -6975,7 +6975,11 @@ write_getset(ostream &out, Object *obj, Property *property) { out << " if (wrap != nullptr) {\n" " wrap->_getitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Mapping_Getitem;\n"; if (!property->_setter_remaps.empty()) { - out << " if (!DtoolInstance_IS_CONST(self)) {\n"; + if (property->_has_this) { + out << " if (!DtoolInstance_IS_CONST(self)) {\n"; + } else { + out << " {\n"; + } out << " wrap->_setitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Mapping_Setitem;\n"; out << " }\n"; } @@ -7006,7 +7010,11 @@ write_getset(ostream &out, Object *obj, Property *property) { " wrap->_len_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Len;\n" " wrap->_getitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Sequence_Getitem;\n"; if (!property->_setter_remaps.empty()) { - out << " if (!DtoolInstance_IS_CONST(self)) {\n"; + if (property->_has_this) { + out << " if (!DtoolInstance_IS_CONST(self)) {\n"; + } else { + out << " {\n"; + } out << " wrap->_setitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Sequence_Setitem;\n"; if (property->_inserter != nullptr) { out << " wrap->_insert_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Sequence_insert;\n"; From 544ef137ee927ea51c3ed697578732d965668512 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 24 Nov 2018 22:44:55 +0100 Subject: [PATCH 349/360] x11display: fix crash with multithreading and NVIDIA driver --- panda/src/x11display/x11GraphicsWindow.cxx | 17 +++++++++++++++++ panda/src/x11display/x11GraphicsWindow.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 17f6ca0a2a..9a1555c27e 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -218,6 +218,23 @@ move_pointer(int device, int x, int y) { } } +/** + * Clears the entire framebuffer before rendering, according to the settings + * of get_color_clear_active() and get_depth_clear_active() (inherited from + * DrawableRegion). + * + * This function is called only within the draw thread. + */ +void x11GraphicsWindow:: +clear(Thread *current_thread) { + if (is_any_clear_active()) { + // Evidently the NVIDIA driver may call glXCreateNewContext inside + // prepare_display_region, so we need to hold the X11 lock. + LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); + GraphicsOutput::clear(current_thread); + } +} + /** * This function will be called within the draw thread before beginning * rendering for a given frame. It should do whatever setup is required, and diff --git a/panda/src/x11display/x11GraphicsWindow.h b/panda/src/x11display/x11GraphicsWindow.h index 078b016262..906a64b623 100644 --- a/panda/src/x11display/x11GraphicsWindow.h +++ b/panda/src/x11display/x11GraphicsWindow.h @@ -36,6 +36,8 @@ public: virtual MouseData get_pointer(int device) const; virtual bool move_pointer(int device, int x, int y); + + virtual void clear(Thread *current_thread); virtual bool begin_frame(FrameMode mode, Thread *current_thread); virtual void end_frame(FrameMode mode, Thread *current_thread); From 7c0a77af78cbdba4b6e136ee9775c4e1259d3377 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 24 Nov 2018 22:45:41 +0100 Subject: [PATCH 350/360] display: disable depth test before DisplayRegion draw callback Having depth test disabled is the default OpenGL state, and callbacks may quite reasonably expect to see the default state. Kivy seems to expect this, for one. --- panda/src/display/graphicsEngine.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index dd160d55b5..c06c2b207f 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -47,6 +47,7 @@ #include "displayRegionCullCallbackData.h" #include "displayRegionDrawCallbackData.h" #include "callbackGraphicsWindow.h" +#include "depthTestAttrib.h" #if defined(WIN32) #define WINDOWS_LEAN_AND_MEAN @@ -2046,9 +2047,12 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre if (cbobj != nullptr) { // Issue the draw callback on this DisplayRegion. - // Set the GSG to the initial state. + // Set the GSG to the initial state. We disable depth testing since that + // is the default OpenGL state, and some libraries (eg. Kivy) expect that. + static CPT(RenderState) state = RenderState::make( + DepthTestAttrib::make(DepthTestAttrib::M_none)); gsg->clear_before_callback(); - gsg->set_state_and_transform(RenderState::make_empty(), TransformState::make_identity()); + gsg->set_state_and_transform(state, TransformState::make_identity()); DisplayRegionDrawCallbackData cbdata(cull_result, scene_setup); cbobj->do_callback(&cbdata); From 272f13023e24dfd84ebc6f9ba3240bd471537ac0 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 25 Nov 2018 15:26:12 +0100 Subject: [PATCH 351/360] glgsg: unbind buffers after draw callback Some libraries (eg. Kivy) leave their buffers bound, so this takes care of that. --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 8e9105de1c..9118366a93 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -10692,6 +10692,20 @@ reissue_transforms() { memset(_vertex_attrib_columns, 0, sizeof(const GeomVertexColumn *) * 32); #endif + // Some libraries (Kivy) leave their buffers bound. How clumsy of them. + if (_supports_buffers) { + _glBindBuffer(GL_ARRAY_BUFFER, 0); + _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + _current_vbuffer_index = 0; + _current_ibuffer_index = 0; + } +#ifndef OPENGLES + if (_supports_glsl) { + _glDisableVertexAttribArray(0); + _glDisableVertexAttribArray(1); + } +#endif + // Since this is called by clear_state_and_transform(), we also should reset // the states that won't automatically be respecified when clearing the // state mask. From c427357db9910839982f5a11112f872b54792cf9 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Nov 2018 17:09:22 +0100 Subject: [PATCH 352/360] pnmimage: fix PixelSpec coercion, add PixelSpec unit test --- panda/src/pnmimage/pnmImageHeader.I | 23 ----------------------- panda/src/pnmimage/pnmImageHeader.h | 5 +++-- tests/pnmimage/test_pnmimage.py | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 25 deletions(-) create mode 100644 tests/pnmimage/test_pnmimage.py diff --git a/panda/src/pnmimage/pnmImageHeader.I b/panda/src/pnmimage/pnmImageHeader.I index 0e4adbaf11..630e41ff2a 100644 --- a/panda/src/pnmimage/pnmImageHeader.I +++ b/panda/src/pnmimage/pnmImageHeader.I @@ -295,29 +295,6 @@ PixelSpec(const xel &rgb, xelval alpha) : { } -/** - * - */ -INLINE PNMImageHeader::PixelSpec:: -PixelSpec(const PixelSpec ©) : - _red(copy._red), - _green(copy._green), - _blue(copy._blue), - _alpha(copy._alpha) -{ -} - -/** - * - */ -INLINE void PNMImageHeader::PixelSpec:: -operator = (const PixelSpec ©) { - _red = copy._red; - _green = copy._green; - _blue = copy._blue; - _alpha = copy._alpha; -} - /** * */ diff --git a/panda/src/pnmimage/pnmImageHeader.h b/panda/src/pnmimage/pnmImageHeader.h index 162dd21784..7030e06d2e 100644 --- a/panda/src/pnmimage/pnmImageHeader.h +++ b/panda/src/pnmimage/pnmImageHeader.h @@ -113,6 +113,9 @@ PUBLISHED: // make_histogram(). Note that pixels are stored by integer value, not by // floating-point scaled value. class EXPCL_PANDA_PNMIMAGE PixelSpec { + public: + INLINE PixelSpec() = default; + PUBLISHED: INLINE PixelSpec(xelval gray_value); INLINE PixelSpec(xelval gray_value, xelval alpha); @@ -120,8 +123,6 @@ PUBLISHED: INLINE PixelSpec(xelval red, xelval green, xelval blue, xelval alpha); INLINE PixelSpec(const xel &rgb); INLINE PixelSpec(const xel &rgb, xelval alpha); - INLINE PixelSpec(const PixelSpec ©); - INLINE void operator = (const PixelSpec ©); INLINE bool operator < (const PixelSpec &other) const; INLINE bool operator == (const PixelSpec &other) const; diff --git a/tests/pnmimage/test_pnmimage.py b/tests/pnmimage/test_pnmimage.py new file mode 100644 index 0000000000..0826e4f0b8 --- /dev/null +++ b/tests/pnmimage/test_pnmimage.py @@ -0,0 +1,21 @@ +from panda3d.core import PNMImage, PNMImageHeader + + +def test_pixelspec_ctor(): + assert tuple(PNMImage.PixelSpec(1)) == (1, 1, 1, 0) + assert tuple(PNMImage.PixelSpec(1, 2)) == (1, 1, 1, 2) + assert tuple(PNMImage.PixelSpec(1, 2, 3)) == (1, 2, 3, 0) + assert tuple(PNMImage.PixelSpec(1, 2, 3, 4)) == (1, 2, 3, 4) + + assert tuple(PNMImage.PixelSpec((1, 2, 3))) == (1, 2, 3, 0) + assert tuple(PNMImage.PixelSpec((1, 2, 3), 4)) == (1, 2, 3, 4) + + # Copy constructor + spec = PNMImage.PixelSpec(1, 2, 3, 4) + assert tuple(PNMImage.PixelSpec(spec)) == (1, 2, 3, 4) + + +def test_pixelspec_coerce(): + img = PNMImage(1, 1, 4) + img.set_pixel(0, 0, (1, 2, 3, 4)) + assert img.get_pixel(0, 0) == (1, 2, 3, 4) From da079c5ffea85c110627044a920a3ffcd147bba0 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Nov 2018 17:09:46 +0100 Subject: [PATCH 353/360] glxdisplay: remove lock in dtor, which causes crash on shutdown --- panda/src/glxdisplay/glxGraphicsStateGuardian.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 86ddeac589..d620427afa 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -64,7 +64,9 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, */ glxGraphicsStateGuardian:: ~glxGraphicsStateGuardian() { - LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); + // Actually, the lock might have already destructed, so we can't reliably + // grab the X11 lock here. + //LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); destroy_temp_xwindow(); if (_visuals != nullptr) { XFree(_visuals); From 5dd0db300b78dcc652908c84952b07fb643f4516 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Nov 2018 20:59:51 +0100 Subject: [PATCH 354/360] flac: fix leak; properly close stream upon closing FlacAudioCursor --- panda/src/movies/flacAudioCursor.cxx | 6 +++++- panda/src/movies/flacAudioCursor.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/panda/src/movies/flacAudioCursor.cxx b/panda/src/movies/flacAudioCursor.cxx index 19eb71cbc9..0e3bbb163a 100644 --- a/panda/src/movies/flacAudioCursor.cxx +++ b/panda/src/movies/flacAudioCursor.cxx @@ -59,7 +59,8 @@ FlacAudioCursor:: FlacAudioCursor(FlacAudio *src, std::istream *stream) : MovieAudioCursor(src), _is_valid(false), - _drflac(nullptr) + _drflac(nullptr), + _stream(stream) { nassertv(stream != nullptr); nassertv(stream->good()); @@ -91,6 +92,9 @@ FlacAudioCursor:: if (_drflac != nullptr) { drflac_close(_drflac); } + if (_stream != nullptr) { + VirtualFileSystem::close_read_file(_stream); + } } /** diff --git a/panda/src/movies/flacAudioCursor.h b/panda/src/movies/flacAudioCursor.h index 55d59d5488..1de46bad01 100644 --- a/panda/src/movies/flacAudioCursor.h +++ b/panda/src/movies/flacAudioCursor.h @@ -41,6 +41,7 @@ public: protected: drflac *_drflac; + std::istream *_stream; public: static TypeHandle get_class_type() { From 7ed9655e06c3e65847493246fb4f09851e0919d9 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Nov 2018 21:11:57 +0100 Subject: [PATCH 355/360] openal: fix leak of sound data when uncache_sound on stream This is an addendum to cd2ea97b1ffb65512f5ee8ba0665f46345ef7795 (fix for #428) which did not properly delete the SoundData when uncaching sounds that were loaded as streams. --- panda/src/audiotraits/openalAudioManager.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index c205f55402..edf7dfe222 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -553,6 +553,7 @@ uncache_sound(const Filename &file_name) { if (sd->_movie->get_filename() == path || sd->_movie->get_filename() == file_name) { exqi = _expiring_streams.erase(exqi); + delete sd; continue; } } From 32df05b5286d3e798576c4ea2ff026c94dce90fa Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Nov 2018 21:16:03 +0100 Subject: [PATCH 356/360] Fix crash when unmounting/closing multifile while streams are open It's not really reasonable to expect a user to find every occurrence of a cached resource that might be using an open stream and remove it or crash otherwise. This is fixed by keeping the multifile stream open as long as any substreams are still pointing to it, using a simplified reference counting (care is taken not to fully make StreamWrapper reference-counted, since it's not in express and existing uses should not be broken). Fixes #449 Also see #428 --- dtool/src/prc/streamWrapper.I | 18 ++++++++++++++++++ dtool/src/prc/streamWrapper.h | 10 ++++++++++ panda/src/express/multifile.cxx | 5 ++++- panda/src/express/subStreamBuf.cxx | 13 +++++++++++++ panda/src/express/subStreamBuf.h | 1 + 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/dtool/src/prc/streamWrapper.I b/dtool/src/prc/streamWrapper.I index 0f9d65d414..6d2578262c 100644 --- a/dtool/src/prc/streamWrapper.I +++ b/dtool/src/prc/streamWrapper.I @@ -58,6 +58,24 @@ release() { _lock.unlock(); } +/** + * Increments the reference count. Only has impact if the class that manages + * this StreamWrapper's lifetime (eg. Multifile) respects it. + */ +INLINE void StreamWrapperBase:: +ref() const { + AtomicAdjust::inc(_ref_count); +} + +/** + * Decrements the reference count. Only has impact if the class that manages + * this StreamWrapper's lifetime (eg. Multifile) respects it. + */ +INLINE bool StreamWrapperBase:: +unref() const { + return AtomicAdjust::dec(_ref_count); +} + /** * */ diff --git a/dtool/src/prc/streamWrapper.h b/dtool/src/prc/streamWrapper.h index b5a4d5bf72..a837540129 100644 --- a/dtool/src/prc/streamWrapper.h +++ b/dtool/src/prc/streamWrapper.h @@ -16,6 +16,7 @@ #include "dtoolbase.h" #include "mutexImpl.h" +#include "atomicAdjust.h" /** * The base class for both IStreamWrapper and OStreamWrapper, this provides @@ -30,8 +31,17 @@ PUBLISHED: INLINE void acquire(); INLINE void release(); +public: + INLINE void ref() const; + INLINE bool unref() const; + private: MutexImpl _lock; + + // This isn't really designed as a reference counted class, but it is useful + // to treat it as one when dealing with substreams created by Multifile. + mutable AtomicAdjust::Integer _ref_count = 1; + #ifdef SIMPLE_THREADS // In the SIMPLE_THREADS case, we need to use a bool flag, because MutexImpl // defines to nothing in this case--but we still need to achieve a form of diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index e625861f87..cdb1c56ec8 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -333,7 +333,10 @@ close() { if (_owns_stream) { // We prefer to delete the IStreamWrapper over the ostream, if possible. if (_read != nullptr) { - delete _read; + // Only delete it if no SubStream is still referencing it. + if (!_read->unref()) { + delete _read; + } } else if (_write != nullptr) { delete _write; } diff --git a/panda/src/express/subStreamBuf.cxx b/panda/src/express/subStreamBuf.cxx index 4d773e359f..14a05f1bfb 100644 --- a/panda/src/express/subStreamBuf.cxx +++ b/panda/src/express/subStreamBuf.cxx @@ -88,6 +88,13 @@ open(IStreamWrapper *source, OStreamWrapper *dest, streampos start, streampos en _append = append; _gpos = _start; _ppos = _start; + + if (source != nullptr) { + source->ref(); + } + if (dest != nullptr) { + dest->ref(); + } } /** @@ -98,6 +105,12 @@ close() { // Make sure the write buffer is flushed. sync(); + if (_source != nullptr && !_source->unref()) { + delete _source; + } + if (_dest != nullptr && !_dest->unref()) { + delete _dest; + } _source = nullptr; _dest = nullptr; _start = 0; diff --git a/panda/src/express/subStreamBuf.h b/panda/src/express/subStreamBuf.h index 779f43d94c..1f0c511e51 100644 --- a/panda/src/express/subStreamBuf.h +++ b/panda/src/express/subStreamBuf.h @@ -23,6 +23,7 @@ class EXPCL_PANDA_EXPRESS SubStreamBuf : public std::streambuf { public: SubStreamBuf(); + SubStreamBuf(const SubStreamBuf ©) = delete; virtual ~SubStreamBuf(); void open(IStreamWrapper *source, OStreamWrapper *dest, std::streampos start, std::streampos end, bool append); From 85cb742f79bf718f2086070f86f5dde6e2b1d504 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 28 Nov 2018 16:14:45 +0100 Subject: [PATCH 357/360] ffmpeg: drain avcodec contexts on close, fixes leak Fixes #398 --- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 27 ++++++++++++++++---------- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 9 ++++++++- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index 809797fb85..4b17800c2b 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -210,6 +210,23 @@ FfmpegAudioCursor:: */ void FfmpegAudioCursor:: cleanup() { + if (_audio_ctx && _audio_ctx->codec) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 100) + // We need to drain the codec to prevent a memory leak. + avcodec_send_packet(_audio_ctx, nullptr); + while (avcodec_receive_frame(_audio_ctx, _frame) == 0) {} + avcodec_flush_buffers(_audio_ctx); +#endif + + avcodec_close(_audio_ctx); +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 52, 0) + avcodec_free_context(&_audio_ctx); +#else + delete _audio_ctx; +#endif + } + _audio_ctx = nullptr; + if (_frame) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 45, 101) av_frame_free(&_frame); @@ -237,16 +254,6 @@ cleanup() { _buffer = nullptr; } - if ((_audio_ctx)&&(_audio_ctx->codec)) { - avcodec_close(_audio_ctx); -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 52, 0) - avcodec_free_context(&_audio_ctx); -#else - delete _audio_ctx; -#endif - } - _audio_ctx = nullptr; - if (_format_ctx) { _ffvfile.close(); _format_ctx = nullptr; diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 47c6a54ae2..ef23a9414e 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -595,7 +595,14 @@ close_stream() { // Hold the global lock while we free avcodec objects. ReMutexHolder av_holder(_av_lock); - if ((_video_ctx)&&(_video_ctx->codec)) { + if (_video_ctx && _video_ctx->codec) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 100) + // We need to drain the codec to prevent a memory leak. + avcodec_send_packet(_video_ctx, nullptr); + while (avcodec_receive_frame(_video_ctx, _frame) == 0) {} + avcodec_flush_buffers(_video_ctx); +#endif + avcodec_close(_video_ctx); #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 52, 0) avcodec_free_context(&_video_ctx); From 69f8f8b7b74a8930de6915d43fa411f30d3ca8e8 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 28 Nov 2018 16:22:27 +0100 Subject: [PATCH 358/360] ffmpeg: remove call deprecated in ffmpeg's libavformat 58.9.100 --- panda/src/ffmpeg/ffmpegVirtualFile.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index 8ca576cd90..09c5092844 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -189,7 +189,10 @@ register_protocol() { } // Here's a good place to call this global ffmpeg initialization function. + // However, ffmpeg (but not libav) deprecated this, hence this check. +#if LIBAVFORMAT_VERSION_MICRO < 100 || LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100) av_register_all(); +#endif // And this one. avformat_network_init(); From 594e6b394b199c9295e6c0ed728b2c82c6f94e47 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 28 Nov 2018 16:46:49 +0100 Subject: [PATCH 359/360] chan: add various property interfaces to animation system --- panda/src/chan/animBundle.h | 3 +++ panda/src/chan/animBundleNode.h | 2 ++ panda/src/chan/animChannelMatrixDynamic.h | 2 ++ panda/src/chan/animChannelMatrixXfmTable.h | 2 ++ panda/src/chan/animChannelScalarDynamic.I | 22 +++++++++++++++++++++ panda/src/chan/animChannelScalarDynamic.cxx | 13 +++++------- panda/src/chan/animChannelScalarDynamic.h | 5 +++++ panda/src/chan/animChannelScalarTable.h | 2 ++ 8 files changed, 43 insertions(+), 8 deletions(-) diff --git a/panda/src/chan/animBundle.h b/panda/src/chan/animBundle.h index 659f15e58c..77c07e26d7 100644 --- a/panda/src/chan/animBundle.h +++ b/panda/src/chan/animBundle.h @@ -38,6 +38,9 @@ PUBLISHED: INLINE double get_base_frame_rate() const; INLINE int get_num_frames() const; + MAKE_PROPERTY(base_frame_rate, get_base_frame_rate); + MAKE_PROPERTY(num_frames, get_num_frames); + virtual void output(std::ostream &out) const; protected: diff --git a/panda/src/chan/animBundleNode.h b/panda/src/chan/animBundleNode.h index fbf9dcbbe2..6152d37707 100644 --- a/panda/src/chan/animBundleNode.h +++ b/panda/src/chan/animBundleNode.h @@ -41,6 +41,8 @@ public: PUBLISHED: INLINE AnimBundle *get_bundle() const; + MAKE_PROPERTY(bundle, get_bundle); + static AnimBundle *find_anim_bundle(PandaNode *root); private: diff --git a/panda/src/chan/animChannelMatrixDynamic.h b/panda/src/chan/animChannelMatrixDynamic.h index 589b2e7a10..5602f027c6 100644 --- a/panda/src/chan/animChannelMatrixDynamic.h +++ b/panda/src/chan/animChannelMatrixDynamic.h @@ -57,6 +57,8 @@ PUBLISHED: INLINE const TransformState *get_value_transform() const; INLINE PandaNode *get_value_node() const; + MAKE_PROPERTY(value_node, get_value_node, set_value_node); + protected: virtual AnimGroup *make_copy(AnimGroup *parent) const; diff --git a/panda/src/chan/animChannelMatrixXfmTable.h b/panda/src/chan/animChannelMatrixXfmTable.h index a5923e59c0..047f145453 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.h +++ b/panda/src/chan/animChannelMatrixXfmTable.h @@ -59,6 +59,8 @@ PUBLISHED: INLINE bool has_table(char table_id) const; INLINE void clear_table(char table_id); + MAKE_MAP_PROPERTY(tables, has_table, get_table, set_table, clear_table); + public: virtual void write(std::ostream &out, int indent_level) const; diff --git a/panda/src/chan/animChannelScalarDynamic.I b/panda/src/chan/animChannelScalarDynamic.I index e165b58b44..549b9bfad7 100644 --- a/panda/src/chan/animChannelScalarDynamic.I +++ b/panda/src/chan/animChannelScalarDynamic.I @@ -10,3 +10,25 @@ * @author drose * @date 2003-10-20 */ + +/** + * Gets the value of the channel. This will return the value explicitly + * specified by set_value() unless a value node was specified using + * set_value_node(). + */ +INLINE PN_stdfloat AnimChannelScalarDynamic:: +get_value() const { + if (_value_node != nullptr) { + return _value->get_pos()[0]; + } else { + return _float_value; + } +} + +/** + * Returns the node that was set via set_value_node(), if any. + */ +INLINE PandaNode *AnimChannelScalarDynamic:: +get_value_node() const { + return _value_node; +} diff --git a/panda/src/chan/animChannelScalarDynamic.cxx b/panda/src/chan/animChannelScalarDynamic.cxx index 8a9835a550..c69ad0e6b9 100644 --- a/panda/src/chan/animChannelScalarDynamic.cxx +++ b/panda/src/chan/animChannelScalarDynamic.cxx @@ -84,16 +84,12 @@ has_changed(int, double, int, double) { */ void AnimChannelScalarDynamic:: get_value(int, PN_stdfloat &value) { - if (_value_node != nullptr) { - value = _value->get_pos()[0]; - - } else { - value = _float_value; - } + value = get_value(); } /** - * Explicitly sets the value. + * Explicitly sets the value. This will remove any node assigned via + * set_value_node(). */ void AnimChannelScalarDynamic:: set_value(PN_stdfloat value) { @@ -104,7 +100,8 @@ set_value(PN_stdfloat value) { /** * Specifies a node whose transform will be queried each frame to implicitly - * specify the transform of this joint. + * specify the transform of this joint. This will override the values set by + * set_value(). */ void AnimChannelScalarDynamic:: set_value_node(PandaNode *value_node) { diff --git a/panda/src/chan/animChannelScalarDynamic.h b/panda/src/chan/animChannelScalarDynamic.h index ab009a4f1f..7455adb4b9 100644 --- a/panda/src/chan/animChannelScalarDynamic.h +++ b/panda/src/chan/animChannelScalarDynamic.h @@ -41,11 +41,16 @@ public: virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); virtual void get_value(int frame, PN_stdfloat &value); + INLINE PN_stdfloat get_value() const; + INLINE PandaNode *get_value_node() const; PUBLISHED: void set_value(PN_stdfloat value); void set_value_node(PandaNode *node); + MAKE_PROPERTY(value, get_value, set_value); + MAKE_PROPERTY(value_node, get_value_node, set_value_node); + protected: virtual AnimGroup *make_copy(AnimGroup *parent) const; diff --git a/panda/src/chan/animChannelScalarTable.h b/panda/src/chan/animChannelScalarTable.h index e150d8d82e..10e54815e3 100644 --- a/panda/src/chan/animChannelScalarTable.h +++ b/panda/src/chan/animChannelScalarTable.h @@ -44,6 +44,8 @@ PUBLISHED: INLINE bool has_table() const; INLINE void clear_table(); + MAKE_PROPERTY2(table, has_table, get_table, set_table, clear_table); + public: virtual void write(std::ostream &out, int indent_level) const; From 97d4e32a067839130fabc0e3341db56a13127c27 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 28 Nov 2018 17:35:20 +0100 Subject: [PATCH 360/360] general: use nassert_raise instead of nassertv(false) et al Even a brief error message in the assertion is infinitely more useful to a user who is not at home in the source code, especially for assertions that may reasonably be triggered by honest user mistakes. --- direct/src/dcparser/dcClass.cxx | 2 +- dtool/src/prc/notifyCategory.cxx | 2 +- panda/src/chan/animChannelMatrixXfmTable.cxx | 2 +- panda/src/chan/animChannelScalarTable.cxx | 2 +- panda/src/display/graphicsStateGuardian.cxx | 2 +- panda/src/egg/eggGroup.cxx | 3 ++- panda/src/egg/eggVertexPool.cxx | 3 ++- panda/src/egg/eggXfmAnimData.cxx | 3 ++- panda/src/egg/eggXfmSAnim.cxx | 3 ++- panda/src/event/asyncFuture.cxx | 2 +- panda/src/event/pointerEvent.cxx | 4 ++-- panda/src/glstuff/glGeomContext_src.cxx | 2 +- .../glstuff/glGraphicsStateGuardian_src.cxx | 4 ++-- panda/src/gobj/geom.cxx | 2 +- panda/src/gobj/geomCacheManager.cxx | 2 +- panda/src/gobj/geomPrimitive.cxx | 8 +++---- panda/src/gobj/geomTrifans.cxx | 2 +- panda/src/gobj/geomVertexArrayData.cxx | 2 +- panda/src/gobj/geomVertexData.cxx | 3 ++- panda/src/gobj/shader.cxx | 2 +- panda/src/gobj/texture.cxx | 13 ++++++---- .../src/gsgbase/graphicsStateGuardianBase.cxx | 2 +- panda/src/nativenet/socket_address.I | 6 ++--- panda/src/nativenet/socket_address.cxx | 4 ++-- panda/src/net/connection.cxx | 3 ++- panda/src/net/datagramTCPHeader.cxx | 3 ++- .../parametrics/parametricCurveCollection.cxx | 2 +- panda/src/pgraph/clipPlaneAttrib.cxx | 8 +++---- panda/src/pgraph/cullBinManager.cxx | 2 +- panda/src/pgraph/lightAttrib.cxx | 8 +++---- panda/src/pgraph/nodePath.cxx | 9 ++++--- panda/src/pgraph/pandaNode.cxx | 3 ++- panda/src/pgraph/renderAttribRegistry.cxx | 2 +- panda/src/pgraph/sceneGraphReducer.cxx | 3 ++- panda/src/pgraphnodes/ambientLight.cxx | 2 +- panda/src/pipeline/pythonThread.cxx | 3 ++- panda/src/pnmimage/pfmFile.cxx | 24 ++++++++++++------- panda/src/pnmimage/pnmImage.cxx | 18 +++++++------- panda/src/pnmimagetypes/pnmFileTypePfm.cxx | 3 ++- .../pnmimagetypes/pnmFileTypeSGIWriter.cxx | 3 ++- panda/src/putil/sparseArray.I | 2 +- panda/src/text/textAssembler.cxx | 2 +- panda/src/vision/webcamVideoCursorV4L.cxx | 3 ++- pandatool/src/assimp/pandaIOSystem.cxx | 2 +- pandatool/src/eggcharbase/eggBackPointer.cxx | 2 +- 45 files changed, 108 insertions(+), 79 deletions(-) diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 4c428db595..374ed47d3c 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -1240,7 +1240,7 @@ shadow_inherited_field(const string &name) { } // If we get here, the named field wasn't in the list. Huh. - nassertv(false); + nassert_raise("named field not in list"); } /** diff --git a/dtool/src/prc/notifyCategory.cxx b/dtool/src/prc/notifyCategory.cxx index 11a3c52587..3d856ceb08 100644 --- a/dtool/src/prc/notifyCategory.cxx +++ b/dtool/src/prc/notifyCategory.cxx @@ -110,7 +110,7 @@ out(NotifySeverity severity, bool prefix) const { nout << *this << "(" << severity << "): "; } if (assert_abort) { - nassertr(false, nout); + nassert_raise("unprotected debug statement"); } return nout; diff --git a/panda/src/chan/animChannelMatrixXfmTable.cxx b/panda/src/chan/animChannelMatrixXfmTable.cxx index c6c27b8b7a..5370a9833e 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.cxx +++ b/panda/src/chan/animChannelMatrixXfmTable.cxx @@ -239,7 +239,7 @@ set_table(char table_id, const CPTA_stdfloat &table) { if (table.size() > 1 && (int)table.size() < num_frames) { // The new table has an invalid number of frames--it doesn't match the // bundle's requirement. - nassertv(false); + nassert_raise("mismatched number of frames"); return; } diff --git a/panda/src/chan/animChannelScalarTable.cxx b/panda/src/chan/animChannelScalarTable.cxx index 54953164e7..ae95b3d1ea 100644 --- a/panda/src/chan/animChannelScalarTable.cxx +++ b/panda/src/chan/animChannelScalarTable.cxx @@ -104,7 +104,7 @@ set_table(const CPTA_stdfloat &table) { if (table.size() > 1 && (int)table.size() < num_frames) { // The new table has an invalid number of frames--it doesn't match the // bundle's requirement. - nassertv(false); + nassert_raise("mismatched number of frames"); return; } diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 93c732e5d7..1b0caeabd0 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -743,7 +743,7 @@ issue_timer_query(int pstats_index) { */ void GraphicsStateGuardian:: dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) { - nassertv(false /* Compute shaders not supported by GSG */); + nassert_raise("Compute shaders not supported by GSG"); } /** diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index a5ff1dee06..6bc6f152f0 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -192,7 +192,8 @@ write(ostream &out, int indent_level) const { default: // invalid group type - nassertv(false); + nassert_raise("invalid EggGroup type"); + return; } if (is_of_type(EggBin::get_class_type())) { diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index 6f2768599e..65d5f747bf 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -445,7 +445,8 @@ add_vertex(EggVertex *vertex, int index) { } // Oops, you duplicated a vertex index. - nassertr(false, nullptr); + nassert_raise("duplicate vertex index"); + return nullptr; } _unique_vertices.insert(vertex); diff --git a/panda/src/egg/eggXfmAnimData.cxx b/panda/src/egg/eggXfmAnimData.cxx index 73a7128036..0216ea1bdd 100644 --- a/panda/src/egg/eggXfmAnimData.cxx +++ b/panda/src/egg/eggXfmAnimData.cxx @@ -142,7 +142,8 @@ get_value(int row, LMatrix4d &mat) const { default: // The contents string contained an invalid letter. - nassertv(false); + nassert_raise("invalid letter in contents string"); + return; } } diff --git a/panda/src/egg/eggXfmSAnim.cxx b/panda/src/egg/eggXfmSAnim.cxx index 43a784b33f..4158d46491 100644 --- a/panda/src/egg/eggXfmSAnim.cxx +++ b/panda/src/egg/eggXfmSAnim.cxx @@ -368,7 +368,8 @@ get_value(int row, LMatrix4d &mat) const { default: // One of the child tables had an invalid name. - nassertv(false); + nassert_raise("invalid name in child table"); + return; } } } diff --git a/panda/src/event/asyncFuture.cxx b/panda/src/event/asyncFuture.cxx index 16540954ed..4805650260 100644 --- a/panda/src/event/asyncFuture.cxx +++ b/panda/src/event/asyncFuture.cxx @@ -298,7 +298,7 @@ wake_task(AsyncTask *task) { return; default: - nassertv(false); + nassert_raise("unexpected task state"); return; } } diff --git a/panda/src/event/pointerEvent.cxx b/panda/src/event/pointerEvent.cxx index 7ee7d3621c..752210cf86 100644 --- a/panda/src/event/pointerEvent.cxx +++ b/panda/src/event/pointerEvent.cxx @@ -29,7 +29,7 @@ output(std::ostream &out) const { */ void PointerEvent:: write_datagram(Datagram &dg) const { - nassertv(false && "This function not implemented yet."); + nassert_raise("This function not implemented yet."); } /** @@ -37,5 +37,5 @@ write_datagram(Datagram &dg) const { */ void PointerEvent:: read_datagram(DatagramIterator &scan) { - nassertv(false && "This function not implemented yet."); + nassert_raise("This function not implemented yet."); } diff --git a/panda/src/glstuff/glGeomContext_src.cxx b/panda/src/glstuff/glGeomContext_src.cxx index 2640c1d855..f798dedb36 100644 --- a/panda/src/glstuff/glGeomContext_src.cxx +++ b/panda/src/glstuff/glGeomContext_src.cxx @@ -32,7 +32,7 @@ get_display_list(GLuint &index, const CLP(GeomMunger) *munger, UpdateSeq modified) { #if defined(OPENGLES) || !defined(SUPPORT_FIXED_FUNCTION) // Display lists not supported by OpenGL ES. - nassertr(false, false); + nassert_raise("OpenGL ES does not support display lists"); return false; #else diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 9118366a93..14fec5d146 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -14144,8 +14144,8 @@ extract_texture_image(PTA_uchar &image, size_t &page_size, Texture::ComponentType type, Texture::CompressionMode compression, int n) { #ifdef OPENGLES // Extracting texture data unsupported in OpenGL ES. - nassertr(false, false); - return false; + nassert_raise("OpenGL ES does not support extracting texture data"); + return false; #else // Make sure the GL driver does not align textures, otherwise we get corrupt diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 03409b4220..8bede7327b 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -1504,7 +1504,7 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { } else { // If this assertion fails, clear_prepared() was given a prepared_objects // that the geom didn't know about. - nassertv(false); + nassert_raise("unknown PreparedGraphicsObjects"); } } diff --git a/panda/src/gobj/geomCacheManager.cxx b/panda/src/gobj/geomCacheManager.cxx index 4eb06a25b4..4911a981c6 100644 --- a/panda/src/gobj/geomCacheManager.cxx +++ b/panda/src/gobj/geomCacheManager.cxx @@ -47,7 +47,7 @@ GeomCacheManager() : GeomCacheManager:: ~GeomCacheManager() { // Shouldn't be deleting this global object. - nassertv(false); + nassert_raise("attempt to delete GeomCacheManager"); } /** diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index da3c10dffd..011d66b132 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -221,7 +221,7 @@ add_vertex(int vertex) { ((uint32_t *)ptr)[num_rows] = vertex; break; default: - nassertv(false); + nassert_raise("unsupported index type"); break; } } @@ -1510,7 +1510,7 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { } else { // If this assertion fails, clear_prepared() was given a prepared_objects // which the data array didn't know about. - nassertv(false); + nassert_raise("unknown PreparedGraphicsObjects"); } } @@ -2230,7 +2230,7 @@ get_vertex(int i) const { return ((uint32_t *)ptr)[i]; break; default: - nassertr(false, -1); + nassert_raise("unsupported index type"); return -1; } @@ -2296,7 +2296,7 @@ get_referenced_vertices(BitArray &bits) const { } break; default: - nassertv(false); + nassert_raise("unsupported index type"); break; } } else { diff --git a/panda/src/gobj/geomTrifans.cxx b/panda/src/gobj/geomTrifans.cxx index a99481e92e..5a6c518867 100644 --- a/panda/src/gobj/geomTrifans.cxx +++ b/panda/src/gobj/geomTrifans.cxx @@ -139,7 +139,7 @@ CPT(GeomVertexArrayData) GeomTrifans:: rotate_impl() const { // Actually, we can't rotate fans without chaging the winding order. It's // an error to define a flat shade model for a GeomTrifan. - nassertr(false, nullptr); + nassert_raise("GeomTrifans cannot have flat shading model"); return nullptr; } diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index 998ca1ad14..f6d04beac5 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -351,7 +351,7 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { } else { // If this assertion fails, clear_prepared() was given a prepared_objects // which the data array didn't know about. - nassertv(false); + nassert_raise("unknown PreparedGraphicsObjects"); } } diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index d97197e25c..45522427c2 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -1121,7 +1121,8 @@ do_set_color(GeomVertexData *vdata, const LColor &color) { const GeomVertexColumn *column; int array_index; if (!format->get_array_info(InternalName::get_color(), array_index, column)) { - nassertv(false); + nassert_raise("no color column"); + return; } size_t stride = format->get_array(array_index)->get_stride(); diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 4b635b00e7..4a1092eb9c 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -3705,7 +3705,7 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { } else { // If this assertion fails, clear_prepared() was given a prepared_objects // which the texture didn't know about. - nassertv(false); + nassert_raise("unknown PreparedGraphicsObjects"); } } diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index c0cd14db0a..1ba5b891e3 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -4897,8 +4897,8 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } break; default: - nassertr(false, false); - break; + nassert_raise("unexpected channel count"); + return false; } } @@ -6591,8 +6591,9 @@ do_reconsider_image_properties(CData *cdata, int x_size, int y_size, int num_com default: // Eh? - nassertr(false, false); + nassert_raise("unexpected channel count"); cdata->_format = F_rgb; + return false; } } @@ -7989,7 +7990,8 @@ convert_from_pfm(PTA_uchar &image, size_t page_size, int z, break; default: - nassertv(false); + nassert_raise("unexpected channel count"); + return; } nassertv((unsigned char *)p == &image[idx] + page_size); @@ -8199,7 +8201,8 @@ convert_to_pfm(PfmFile &pfm, int x_size, int y_size, break; default: - nassertr(false, false); + nassert_raise("unexpected channel count"); + return false; } nassertr((unsigned char *)p == &image[idx] + page_size, false); diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.cxx b/panda/src/gsgbase/graphicsStateGuardianBase.cxx index 5ac46dd4af..d8da758ee8 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.cxx +++ b/panda/src/gsgbase/graphicsStateGuardianBase.cxx @@ -54,7 +54,7 @@ set_default_gsg(GraphicsStateGuardianBase *default_gsg) { LightMutexHolder holder(gsg_list->_lock); if (find(gsg_list->_gsgs.begin(), gsg_list->_gsgs.end(), default_gsg) == gsg_list->_gsgs.end()) { // The specified GSG doesn't exist or it has already destructed. - nassertv(false); + nassert_raise("GSG not found or already destructed"); return; } diff --git a/panda/src/nativenet/socket_address.I b/panda/src/nativenet/socket_address.I index 87213df01d..3fbc5c82d0 100644 --- a/panda/src/nativenet/socket_address.I +++ b/panda/src/nativenet/socket_address.I @@ -43,7 +43,7 @@ Socket_Address(const struct sockaddr &inaddr) { _addr6 = (const sockaddr_in6 &)inaddr; } else { - nassertv(false); + nassert_raise("unsupported address family"); clear(); } } @@ -106,7 +106,7 @@ operator == (const Socket_Address &in) const { } // Unsupported address family. - nassertr(false, false); + nassert_raise("unsupported address family"); return false; } @@ -224,7 +224,7 @@ operator < (const Socket_Address &in) const { } // Unsupported address family. - nassertr(false, false); + nassert_raise("unsupported address family"); return false; } diff --git a/panda/src/nativenet/socket_address.cxx b/panda/src/nativenet/socket_address.cxx index 3d7882aeed..3b8c19d3dd 100644 --- a/panda/src/nativenet/socket_address.cxx +++ b/panda/src/nativenet/socket_address.cxx @@ -98,7 +98,7 @@ get_ip() const { getnameinfo(&_addr, sizeof(sockaddr_in6), buf, sizeof(buf), nullptr, 0, NI_NUMERICHOST); } else { - nassertr(false, std::string()); + nassert_raise("unsupported address family"); } return std::string(buf); @@ -124,7 +124,7 @@ get_ip_port() const { sprintf(buf + strlen(buf), "]:%hu", get_port()); } else { - nassertr(false, std::string()); + nassert_raise("unsupported address family"); } return std::string(buf); diff --git a/panda/src/net/connection.cxx b/panda/src/net/connection.cxx index 27f5c8bb24..e98f53cc79 100644 --- a/panda/src/net/connection.cxx +++ b/panda/src/net/connection.cxx @@ -478,7 +478,8 @@ check_send_error(bool okflag) { if (!okflag) { static ConfigVariableBool abort_send_error("abort-send-error", false); if (abort_send_error) { - nassertr(false, false); + nassert_raise("send error"); + return false; } // Assume any error means the connection has been reset; tell our manager diff --git a/panda/src/net/datagramTCPHeader.cxx b/panda/src/net/datagramTCPHeader.cxx index 44db216b3d..3cdbcc9fc0 100644 --- a/panda/src/net/datagramTCPHeader.cxx +++ b/panda/src/net/datagramTCPHeader.cxx @@ -46,7 +46,8 @@ DatagramTCPHeader(const NetDatagram &datagram, int header_size) { break; default: - nassertv(false); + nassert_raise("invalid header size"); + return; } nassertv((int)_header.get_length() == header_size); diff --git a/panda/src/parametrics/parametricCurveCollection.cxx b/panda/src/parametrics/parametricCurveCollection.cxx index 96ce9bd503..7d7581732c 100644 --- a/panda/src/parametrics/parametricCurveCollection.cxx +++ b/panda/src/parametrics/parametricCurveCollection.cxx @@ -276,7 +276,7 @@ get_timewarp_curve(int n) const { n--; } } - nassertr(false, nullptr); + nassert_raise("index out of range"); return nullptr; } diff --git a/panda/src/pgraph/clipPlaneAttrib.cxx b/panda/src/pgraph/clipPlaneAttrib.cxx index de3f1183c9..c17a17b272 100644 --- a/panda/src/pgraph/clipPlaneAttrib.cxx +++ b/panda/src/pgraph/clipPlaneAttrib.cxx @@ -72,7 +72,7 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane) { return attrib; } - nassertr(false, make()); + nassert_raise("invalid operation"); return make(); } @@ -110,7 +110,7 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2) { return attrib; } - nassertr(false, make()); + nassert_raise("invalid operation"); return make(); } @@ -152,7 +152,7 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2, return attrib; } - nassertr(false, make()); + nassert_raise("invalid operation"); return make(); } @@ -197,7 +197,7 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2, return attrib; } - nassertr(false, make()); + nassert_raise("invalid operation"); return make(); } diff --git a/panda/src/pgraph/cullBinManager.cxx b/panda/src/pgraph/cullBinManager.cxx index 5826905c89..cfacd85a03 100644 --- a/panda/src/pgraph/cullBinManager.cxx +++ b/panda/src/pgraph/cullBinManager.cxx @@ -199,7 +199,7 @@ make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg, } // Hmm, unknown (or unregistered) bin type. - nassertr(false, nullptr); + nassert_raise("unknown bin type"); return nullptr; } diff --git a/panda/src/pgraph/lightAttrib.cxx b/panda/src/pgraph/lightAttrib.cxx index 1d6fce8cf7..bdd1553a5e 100644 --- a/panda/src/pgraph/lightAttrib.cxx +++ b/panda/src/pgraph/lightAttrib.cxx @@ -116,7 +116,7 @@ make(LightAttrib::Operation op, Light *light) { return attrib; } - nassertr(false, make()); + nassert_raise("invalid operation"); return make(); } @@ -154,7 +154,7 @@ make(LightAttrib::Operation op, Light *light1, Light *light2) { return attrib; } - nassertr(false, make()); + nassert_raise("invalid operation"); return make(); } @@ -196,7 +196,7 @@ make(LightAttrib::Operation op, Light *light1, Light *light2, return attrib; } - nassertr(false, make()); + nassert_raise("invalid operation"); return make(); } @@ -241,7 +241,7 @@ make(LightAttrib::Operation op, Light *light1, Light *light2, return attrib; } - nassertr(false, make()); + nassert_raise("invalid operation"); return make(); } diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index a21df38d19..0f2639bccc 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -718,7 +718,8 @@ get_state(const NodePath &other, Thread *current_thread) const { } else { pgraph_cat.error() << *this << " is not related to " << other << "\n"; - nassertr(false, RenderState::make_empty()); + nassert_raise("unrelated nodes"); + return RenderState::make_empty(); } } @@ -792,7 +793,8 @@ get_transform(const NodePath &other, Thread *current_thread) const { } else { pgraph_cat.error() << *this << " is not related to " << other << "\n"; - nassertr(false, TransformState::make_identity()); + nassert_raise("unrelated nodes"); + return TransformState::make_identity(); } } @@ -877,7 +879,8 @@ get_prev_transform(const NodePath &other, Thread *current_thread) const { } else { pgraph_cat.error() << *this << " is not related to " << other << "\n"; - nassertr(false, TransformState::make_identity()); + nassert_raise("unrelated nodes"); + return TransformState::make_identity(); } } diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 6994e643f8..7d53cbcaf7 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -2383,7 +2383,8 @@ r_copy_subgraph(PandaNode::InstanceMap &inst_map, Thread *current_thread) const << "Don't know how to copy nodes of type " << get_type() << "\n"; if (no_unsupported_copy) { - nassertr(false, nullptr); + nassert_raise("unsupported copy"); + return nullptr; } } diff --git a/panda/src/pgraph/renderAttribRegistry.cxx b/panda/src/pgraph/renderAttribRegistry.cxx index 939f9753f7..7919d75799 100644 --- a/panda/src/pgraph/renderAttribRegistry.cxx +++ b/panda/src/pgraph/renderAttribRegistry.cxx @@ -78,7 +78,7 @@ register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib) { pgraph_cat->error() << "Too many registered RenderAttribs; not registering " << type_handle << "\n"; - nassertr(false, 0); + nassert_raise("out of RenderAttrib slots"); return 0; } diff --git a/panda/src/pgraph/sceneGraphReducer.cxx b/panda/src/pgraph/sceneGraphReducer.cxx index 03179d38dd..06a80e5a4d 100644 --- a/panda/src/pgraph/sceneGraphReducer.cxx +++ b/panda/src/pgraph/sceneGraphReducer.cxx @@ -333,7 +333,8 @@ r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, << child_node->get_type() << "\n"; if (no_unsupported_copy) { - nassertv(false); + nassert_raise("unsupported copy"); + return; } resist_copy = true; diff --git a/panda/src/pgraphnodes/ambientLight.cxx b/panda/src/pgraphnodes/ambientLight.cxx index deb6eed6cc..f072f1ba6f 100644 --- a/panda/src/pgraphnodes/ambientLight.cxx +++ b/panda/src/pgraphnodes/ambientLight.cxx @@ -85,7 +85,7 @@ void AmbientLight:: bind(GraphicsStateGuardianBase *, const NodePath &, int) { // AmbientLights aren't bound to light id's; this function should never be // called. - nassertv(false); + nassert_raise("cannot bind AmbientLight"); } /** diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index 53a811401e..13b31e0539 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -161,7 +161,8 @@ call_python_func(PyObject *function, PyObject *args) { #ifndef HAVE_THREADS // Shouldn't be possible to come here without having some kind of // threading support enabled. - nassertr(false, nullptr); + nassert_raise("threading support disabled"); + return nullptr; #else #ifdef SIMPLE_THREADS diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index 57b9671d1a..23ba55a44d 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -346,7 +346,8 @@ load(const PNMImage &pnmimage) { break; default: - nassertr(false, false); + nassert_raise("unexpected channel count"); + return false; } return true; } @@ -410,7 +411,8 @@ store(PNMImage &pnmimage) const { break; default: - nassertr(false, false); + nassert_raise("unexpected channel count"); + return false; } return true; } @@ -877,7 +879,8 @@ set_no_data_nan(int num_channels) { _has_point = has_point_nan_4; break; default: - nassertv(false); + nassert_raise("unexpected channel count"); + break; } } else { clear_no_data_value(); @@ -909,7 +912,8 @@ set_no_data_value(const LPoint4f &no_data_value) { _has_point = has_point_4; break; default: - nassertv(false); + nassert_raise("unexpected channel count"); + break; } } @@ -938,7 +942,8 @@ set_no_data_threshold(const LPoint4f &no_data_value) { _has_point = has_point_threshold_4; break; default: - nassertv(false); + nassert_raise("unexpected channel count"); + break; } } @@ -1121,7 +1126,8 @@ quick_filter_from(const PfmFile &from) { break; default: - nassertv(false); + nassert_raise("unexpected channel count"); + return; } new_data.push_back(0.0); @@ -1826,7 +1832,8 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 break; default: - nassertr(false, nullptr); + nassert_raise("invalid coordinate system"); + return nullptr; } // Rotate the bounding volume back into the original space of the screen. @@ -1879,7 +1886,8 @@ compute_sample_point(LPoint3f &result, break; default: - nassertv(false); + nassert_raise("unexpected channel count"); + break; } } diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index 9c6c3a68d9..a26528f99a 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -596,8 +596,8 @@ set_color_space(ColorSpace color_space) { break; default: - nassertv(false); - break; + nassert_raise("invalid color space"); + return; } // Initialize the new encoding settings. @@ -852,7 +852,7 @@ get_channel_val(int x, int y, int channel) const { pnmimage_cat.error() << "Invalid request for channel " << channel << " in " << get_num_channels() << "-channel image.\n"; - nassertr(false, 0); + nassert_raise("unexpected channel count"); return 0; } } @@ -888,7 +888,8 @@ set_channel_val(int x, int y, int channel, xelval value) { break; default: - nassertv(false); + nassert_raise("unexpected channel count"); + break; } } @@ -918,7 +919,7 @@ get_channel(int x, int y, int channel) const { pnmimage_cat.error() << "Invalid request for channel " << channel << " in " << get_num_channels() << "-channel image.\n"; - nassertr(false, 0); + nassert_raise("unexpected channel count"); return 0; } } @@ -954,7 +955,8 @@ set_channel(int x, int y, int channel, float value) { break; default: - nassertv(false); + nassert_raise("unexpected channel count"); + break; } } @@ -2126,7 +2128,7 @@ setup_encoding() { break; default: - nassertv(false); + nassert_raise("invalid color space"); break; } } else { @@ -2153,7 +2155,7 @@ setup_encoding() { break; default: - nassertv(false); + nassert_raise("invalid color space"); break; } } diff --git a/panda/src/pnmimagetypes/pnmFileTypePfm.cxx b/panda/src/pnmimagetypes/pnmFileTypePfm.cxx index 89324f3c61..1303cc9c6c 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePfm.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePfm.cxx @@ -283,7 +283,8 @@ write_pfm(const PfmFile &pfm) { break; default: - nassertr(false, false); + nassert_raise("unexpected channel count"); + return false; } (*_file) << pfm.get_x_size() << " " << pfm.get_y_size() << "\n"; diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx index f5b143e867..4bec4292d5 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx @@ -135,7 +135,8 @@ write_header() { break; default: - nassertr(false, false); + nassert_raise("unexpected channel count"); + return false; } // For some reason, we have problems with SGI image files whose pixmax value diff --git a/panda/src/putil/sparseArray.I b/panda/src/putil/sparseArray.I index 682d5f93be..ccfd90b5ab 100644 --- a/panda/src/putil/sparseArray.I +++ b/panda/src/putil/sparseArray.I @@ -93,7 +93,7 @@ has_max_num_bits() { */ INLINE int SparseArray:: get_max_num_bits() { - nassertr(false, 0); + nassert_raise("SparseArray has no maximum bit count"); return 0; } diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 3925715c6d..32cf41eb89 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -2536,7 +2536,7 @@ get_primitive(TypeHandle prim_type) { return _points; } - nassertr(false, nullptr); + nassert_raise("unexpected primitive type"); return nullptr; } diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index 8bb77658f6..197bda3228 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -487,7 +487,8 @@ fetch_buffer() { block[i + 2] = ex; } #else - nassertr(false /* Not compiled with JPEG support*/, nullptr); + nassert_raise("JPEG support not compiled-in"); + return nullptr; #endif break; } diff --git a/pandatool/src/assimp/pandaIOSystem.cxx b/pandatool/src/assimp/pandaIOSystem.cxx index 87dea240d2..241790f646 100644 --- a/pandatool/src/assimp/pandaIOSystem.cxx +++ b/pandatool/src/assimp/pandaIOSystem.cxx @@ -79,7 +79,7 @@ Open(const char *file, const char *mode) { return new PandaIOStream(*stream); } else { - nassertr(false, nullptr); // Not implemented on purpose. + nassert_raise("write mode not implemented"); return nullptr; } } diff --git a/pandatool/src/eggcharbase/eggBackPointer.cxx b/pandatool/src/eggcharbase/eggBackPointer.cxx index b1e269624a..cc6110d075 100644 --- a/pandatool/src/eggcharbase/eggBackPointer.cxx +++ b/pandatool/src/eggcharbase/eggBackPointer.cxx @@ -40,7 +40,7 @@ get_frame_rate() const { void EggBackPointer:: extend_to(int num_frames) { // Whoops, can't extend this kind of table! - nassertv(false); + nassert_raise("can't extend this kind of table"); } /**