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/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 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/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/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index c0316ee5c4..59575668d4 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; @@ -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"; @@ -1644,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; @@ -2661,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"; } @@ -3236,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); @@ -6892,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"; } @@ -6905,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"; } @@ -6920,7 +6994,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"; } @@ -6937,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"; @@ -6951,7 +7028,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) { 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/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 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/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 diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index b7776d4971..608648d5a1 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -684,7 +684,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") @@ -829,7 +829,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"), "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") @@ -873,6 +873,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",) @@ -2575,9 +2582,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!") ########################################################################################## # @@ -3063,7 +3070,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]) @@ -3905,9 +3912,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'] @@ -4280,9 +4285,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': @@ -4865,7 +4868,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']) @@ -4958,7 +4960,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') @@ -5075,6 +5077,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/ # @@ -6763,10 +6768,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 +6807,7 @@ def MakeInstallerNSIS(file, title, installdir): 'OUTFILE' : '..\\' + file, 'BUILT' : '..\\' + GetOutputDir(), 'SOURCE' : '..', - 'PYVER' : SDK["PYTHONVERSION"][6:9], + 'PYVER' : pyver, 'REGVIEW' : regview, 'EXT_SUFFIX' : GetExtensionSuffix(), } @@ -6846,17 +6854,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. """ @@ -7011,7 +7018,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..435b45a023 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 = [ @@ -3250,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': @@ -3374,7 +3378,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 diff --git a/makepanda/test_wheel.py b/makepanda/test_wheel.py index 00555a5e60..09b0727fe7 100755 --- a/makepanda/test_wheel.py +++ b/makepanda/test_wheel.py @@ -23,6 +23,11 @@ def test_wheel(wheel, verbose=False): else: subprocess.call([sys.executable, "-m", "virtualenv", "--clear", envdir]) + # Make sure pip is up-to-date first. + 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") 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/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; + } } /** 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/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]; 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 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/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 e1765861e1..4629a38f75 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -677,13 +677,32 @@ 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; - strm << "dr_" << index; - string name = strm.str(); - _cull_region_pcollector = PStatCollector(_window->get_cull_window_pcollector(), name); - _draw_region_pcollector = PStatCollector(_window->get_draw_window_pcollector(), name); + // 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; + + _debug_name = strm.str(); +#endif + +#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 496a05e273..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 @@ -1174,7 +1175,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 +1186,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 @@ -1431,7 +1435,13 @@ 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); + gsg->push_group_marker("Clear"); + win->clear(current_thread); + gsg->pop_group_marker(); + } int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { @@ -1468,6 +1478,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; { @@ -1476,6 +1488,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); } @@ -1512,6 +1525,8 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, gsg->end_scene(); } } + + gsg->pop_group_marker(); } /** @@ -1651,7 +1666,12 @@ 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->get_gsg()->push_group_marker("Clear"); + win->clear(current_thread); + win->get_gsg()->pop_group_marker(); + } if (display_cat.is_spam()) { display_cat.spam() @@ -2000,6 +2020,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; { @@ -2015,6 +2037,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()); } @@ -2024,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); @@ -2034,11 +2060,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()) { @@ -2059,6 +2081,8 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre gsg->end_scene(); } } + + gsg->pop_group_marker(); } /** @@ -2668,8 +2692,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/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..daf9b217b1 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 @@ -411,15 +412,39 @@ 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 !cdataw->_active_display_regions.empty(); + } else { + return !cdata->_active_display_regions.empty(); + } } /** 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/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/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/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/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..c7e212c260 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -27,12 +27,12 @@ #include // for strstr #ifdef HAVE_TAR -#include "libtar.h" +#include #include // for O_RDONLY #endif // HAVE_TAR #ifdef HAVE_TAR -istream *Patchfile::_tar_istream = nullptr; +std::istream *Patchfile::_tar_istream = nullptr; #endif // HAVE_TAR using std::endl; 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/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index d5a8763fc8..06c26a590d 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; @@ -232,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(); @@ -257,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; } @@ -1316,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 19594750c8..9118366a93 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 @@ -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 @@ -616,6 +617,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; @@ -1737,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) @@ -1759,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) || @@ -1790,6 +1825,7 @@ reset() { _glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) get_extension_func("glVertexAttribPointerARB"); + _glBindFragDataLocation = nullptr; _glVertexAttribIPointer = nullptr; _glVertexAttribLPointer = nullptr; } @@ -1841,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 @@ -3373,6 +3416,8 @@ reset() { } #endif + pop_group_marker(); + // Now that the GSG has been initialized, make it available for // optimizations. add_gsg(this); @@ -3405,7 +3450,6 @@ finish() { */ void CLP(GraphicsStateGuardian):: clear(DrawableRegion *clearable) { - PStatGPUTimer timer(this, _clear_pcollector); report_my_gl_errors(); if (!clearable->is_any_clear_active()) { @@ -3710,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 @@ -3932,6 +3980,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()); @@ -7191,6 +7240,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(); @@ -10640,6 +10691,85 @@ reissue_transforms() { _current_vertex_format.clear(); 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. + _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 @@ -10902,7 +11032,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()); @@ -11058,7 +11187,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(); @@ -11759,8 +11888,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 +12080,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 +12117,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 diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 99c8296336..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); @@ -275,6 +276,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); @@ -960,6 +964,7 @@ public: // GLSL functions PFNGLATTACHSHADERPROC _glAttachShader; PFNGLBINDATTRIBLOCATIONPROC _glBindAttribLocation; + PFNGLBINDFRAGDATALOCATIONPROC _glBindFragDataLocation; PFNGLCOMPILESHADERPROC _glCompileShader; PFNGLCREATEPROGRAMPROC _glCreateProgram; PFNGLCREATESHADERPROC _glCreateShader; @@ -1091,6 +1096,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; @@ -1118,6 +1128,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/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; 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 a7a2472a84..85757f2faa 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 @@ -125,6 +154,8 @@ end_flip() { */ void glxGraphicsWindow:: close_window() { + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); + if (_gsg != nullptr) { glXMakeCurrent(_display, None, nullptr); _gsg.clear(); @@ -175,6 +206,8 @@ open_window() { return false; } + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); + if (glxgsg->_fbconfig != None) { setup_colormap(glxgsg->_fbconfig); } else { 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/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(); 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/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: 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/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/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 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/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; 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/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"; } } 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/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())) { 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/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(); } } 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/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()); diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 6297e38758..b6af0a9219 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -207,6 +207,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 0046b95c4d..f512b16a19 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); 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 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" 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) 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()