Merge branch 'release/1.10.x'

This commit is contained in:
rdb 2022-11-21 19:02:50 +01:00
commit 9bd66baa1c
14 changed files with 145 additions and 49 deletions

View File

@ -1710,3 +1710,14 @@ class bdist_apps(setuptools.Command):
continue
self.installer_functions[installer](self, basename, build_dir)
def finalize_distribution_options(dist):
"""Entry point for compatibility with setuptools>=61, see #1394."""
options = dist.get_option_dict('build_apps')
if options.get('gui_apps') or options.get('console_apps'):
# Make sure this is set to avoid auto-discovery taking place.
if getattr(dist.metadata, 'py_modules', None) is None and \
getattr(dist.metadata, 'packages', None) is None:
dist.py_modules = []

View File

@ -2885,6 +2885,9 @@ Author-email: etc-panda3d@lists.andrew.cmu.edu
ENTRY_POINTS = """[distutils.commands]
build_apps = direct.dist.commands:build_apps
bdist_apps = direct.dist.commands:bdist_apps
[setuptools.finalize_distribution_options]
build_apps = direct.dist.commands:finalize_distribution_options
"""
if not PkgSkip("DIRECT"):

View File

@ -887,6 +887,8 @@ if __debug__:
entry_points += '[distutils.commands]\n'
entry_points += 'build_apps = direct.dist.commands:build_apps\n'
entry_points += 'bdist_apps = direct.dist.commands:bdist_apps\n'
entry_points += '[setuptools.finalize_distribution_options]\n'
entry_points += 'build_apps = direct.dist.commands:finalize_distribution_options\n'
whl.write_file_data('panda3d_tools/__init__.py', PANDA3D_TOOLS_INIT.format(tools_init))

View File

@ -148,6 +148,9 @@ from .interrogatedb import *
set(entry_points_file "[distutils.commands]
build_apps = direct.dist.commands:build_apps
bdist_apps = direct.dist.commands:bdist_apps
[setuptools.finalize_distribution_options]
build_apps = direct.dist.commands:finalize_distribution_options
")
configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/METADATA.in"

View File

@ -1582,6 +1582,12 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) {
}
_enqueued_index_buffers.clear();
for (ShaderBuffer *buffer : _enqueued_shader_buffers) {
buffer->prepare_now(this, gsg);
}
_enqueued_shader_buffers.clear();
}
/**

View File

@ -2943,7 +2943,7 @@ r_preprocess_source(ostream &out, istream &in, const Filename &fn,
source_dir = full_fn.get_dirname();
incfn = incfile;
} else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\>]> %zn", incfile, &nread) == 1
} else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^>]> %zn", incfile, &nread) == 1
&& nread == line.size()) {
// Angled includes are also OK, but we don't search in the directory
// of the source file.

View File

@ -71,8 +71,8 @@ INLINE void Light::
set_color(const LColor &color) {
CDWriter cdata(_cycler);
cdata->_color = color;
cdata->_viz_geom_stale = true;
_has_color_temperature = false;
mark_viz_stale();
}
/**

View File

@ -125,7 +125,7 @@ set_color_temperature(PN_stdfloat temperature) {
CDWriter cdata(_cycler);
cdata->_color = color;
mark_viz_stale();
cdata->_viz_geom_stale = true;
}
/**

View File

@ -357,6 +357,42 @@ add_cycler(PipelineCyclerTrueImpl *cycler) {
}
#endif // THREADED_PIPELINE
#ifdef THREADED_PIPELINE
/**
* Adds the indicated cycler to the list of cyclers associated with the
* pipeline. This method only exists when true pipelining is configured on.
*
* If the dirty flag is true, it will be marked as dirty in addition, as though
* add_dirty_cycler() were called immediately afterward.
*/
void Pipeline::
add_cycler(PipelineCyclerTrueImpl *cycler, bool dirty) {
// It's safe to add it to the list while cycling, since the _clean list is
// not touched during the cycle loop.
MutexHolder holder(_lock);
nassertv(!cycler->_dirty);
if (!dirty) {
cycler->insert_before(&_clean);
}
else {
nassertv(_num_stages != 1);
cycler->insert_before(&_dirty);
cycler->_dirty = _next_cycle_seq;
++_num_dirty_cyclers;
#ifdef DEBUG_THREADS
inc_cycler_type(_dirty_cycler_types, cycler->get_parent_type(), 1);
#endif
}
++_num_cyclers;
#ifdef DEBUG_THREADS
inc_cycler_type(_all_cycler_types, cycler->get_parent_type(), 1);
#endif
}
#endif // THREADED_PIPELINE
#ifdef THREADED_PIPELINE
/**
* Marks the indicated cycler as "dirty", meaning it will need to be cycled

View File

@ -50,6 +50,7 @@ public:
#ifdef THREADED_PIPELINE
void add_cycler(PipelineCyclerTrueImpl *cycler);
void add_cycler(PipelineCyclerTrueImpl *cycler, bool dirty);
void add_dirty_cycler(PipelineCyclerTrueImpl *cycler);
void remove_cycler(PipelineCyclerTrueImpl *cycler);

View File

@ -56,24 +56,26 @@ PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl &copy) :
nassertv(_num_stages == copy._num_stages);
_data = new CycleDataNode[_num_stages];
// It's no longer critically important that we preserve pointerwise
// equivalence between different stages in the copy, but it doesn't cost
// much and might be a little more efficient, so we do it anyway.
typedef pmap<CycleData *, PT(CycleData) > Pointers;
Pointers pointers;
if (_num_stages == 1) {
_data[0]._cdata = copy._data[0]._cdata->make_copy();
}
else {
// It's no longer critically important that we preserve pointerwise
// equivalence between different stages in the copy, but it doesn't cost
// much and might be a little more efficient, so we do it anyway.
typedef pmap<CycleData *, PT(CycleData) > Pointers;
Pointers pointers;
for (int i = 0; i < _num_stages; ++i) {
PT(CycleData) &new_pt = pointers[copy._data[i]._cdata];
if (new_pt == nullptr) {
new_pt = copy._data[i]._cdata->make_copy();
for (int i = 0; i < _num_stages; ++i) {
PT(CycleData) &new_pt = pointers[copy._data[i]._cdata];
if (new_pt == nullptr) {
new_pt = copy._data[i]._cdata->make_copy();
}
_data[i]._cdata = new_pt.p();
}
_data[i]._cdata = new_pt.p();
}
_pipeline->add_cycler(this);
if (copy._dirty) {
_pipeline->add_dirty_cycler(this);
}
_pipeline->add_cycler(this, copy._dirty != 0);
}
/**

View File

@ -423,7 +423,7 @@ analyze(Texture *tex, bool do_flip_texture) {
if (arDetectMarker(data, _threshold * 256, &marker_info, &marker_num) < 0) {
vision_cat.error() << "ARToolKit detection error.\n";
delete data;
delete[] data;
return;
}

View File

@ -215,9 +215,7 @@ build_graph() {
}
// And then the meshes.
_geoms = new PT(Geom)[_scene->mNumMeshes];
_geom_matindices = new unsigned int[_scene->mNumMeshes];
_characters = new PT(Character)[_scene->mNumMeshes];
_geoms = new Geoms[_scene->mNumMeshes];
for (size_t i = 0; i < _scene->mNumMeshes; ++i) {
load_mesh(i);
}
@ -235,8 +233,6 @@ build_graph() {
delete[] _textures;
delete[] _mat_states;
delete[] _geoms;
delete[] _geom_matindices;
delete[] _characters;
}
/**
@ -1022,25 +1018,35 @@ load_mesh(size_t index) {
}
// Create a geom and add the primitives to it.
PT(Geom) geom = new Geom(vdata);
Geoms &geoms = _geoms[index];
geoms._mat_index = mesh.mMaterialIndex;
if (points->get_num_primitives() > 0) {
geom->add_primitive(points);
geoms._points = new Geom(vdata);
geoms._points->add_primitive(points);
}
if (lines->get_num_primitives() > 0) {
geom->add_primitive(lines);
geoms._lines = new Geom(vdata);
geoms._lines->add_primitive(lines);
}
if (triangles->get_num_primitives() > 0) {
geom->add_primitive(triangles);
geoms._triangles = new Geom(vdata);
geoms._triangles->add_primitive(triangles);
}
_geoms[index] = geom;
_geom_matindices[index] = mesh.mMaterialIndex;
if (character) {
_characters[index] = character;
geoms._character = character;
PT(GeomNode) gnode = new GeomNode("");
gnode->add_geom(geom);
if (geoms._points != nullptr) {
gnode->add_geom(geoms._points);
}
if (geoms._lines != nullptr) {
gnode->add_geom(geoms._lines);
}
if (geoms._triangles != nullptr) {
gnode->add_geom(geoms._triangles);
}
gnode->set_state(_mat_states[mesh.mMaterialIndex]);
character->add_child(gnode);
}
@ -1081,21 +1087,32 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) {
}
else if (node.mNumMeshes == 1) {
size_t meshIndex = node.mMeshes[0];
const Geoms &geoms = _geoms[meshIndex];
Character *character = _characters[meshIndex];
if (character != nullptr) {
if (geoms._character != nullptr) {
pnode = new PandaNode(name);
pnode->add_child(character);
} else {
const RenderState *state = _mat_states[_geom_matindices[meshIndex]];
pnode->add_child(geoms._character);
}
else {
PT(GeomNode) gnode = new GeomNode(name);
gnode->add_geom(_geoms[meshIndex]);
const RenderState *state = _mat_states[geoms._mat_index];
if (geoms._points != nullptr) {
gnode->add_geom(geoms._points);
}
if (geoms._lines != nullptr) {
gnode->add_geom(geoms._lines);
}
if (geoms._triangles != nullptr) {
gnode->add_geom(geoms._triangles);
}
if (state != nullptr) {
// Only set the state on the GeomNode if there are no child nodes.
if (node.mNumChildren == 0) {
gnode->set_state(state);
} else {
gnode->set_geom_state(0, state);
for (int i = 0; i < gnode->get_num_geoms(); ++i) {
gnode->set_geom_state(i, state);
}
}
}
pnode = gnode;
@ -1109,7 +1126,7 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) {
for (size_t i = 0; i < node.mNumMeshes; ++i) {
size_t meshIndex = node.mMeshes[i];
if (_characters[meshIndex] == nullptr) {
if (_geoms[meshIndex]._character == nullptr) {
character_only = false;
break;
}
@ -1125,16 +1142,25 @@ load_node(const aiNode &node, PandaNode *parent, bool under_joint) {
for (size_t i = 0; i < node.mNumMeshes; ++i) {
size_t meshIndex = node.mMeshes[i];
const Geoms &geoms = _geoms[meshIndex];
Character *character = _characters[meshIndex];
if (character != nullptr) {
if (geoms._character != nullptr) {
// An animated mesh, which already is converted as Character with an
// attached GeomNode.
pnode->add_child(character);
} else {
pnode->add_child(geoms._character);
}
else {
// A non-animated mesh.
gnode->add_geom(_geoms[node.mMeshes[i]],
_mat_states[_geom_matindices[meshIndex]]);
const RenderState *state = _mat_states[geoms._mat_index];
if (geoms._points != nullptr) {
gnode->add_geom(geoms._points, state);
}
if (geoms._lines != nullptr) {
gnode->add_geom(geoms._lines, state);
}
if (geoms._triangles != nullptr) {
gnode->add_geom(geoms._triangles, state);
}
}
}
}

View File

@ -61,13 +61,19 @@ private:
Assimp::Importer _importer;
const aiScene *_scene;
struct Geoms {
PT(Geom) _points;
PT(Geom) _lines;
PT(Geom) _triangles;
PT(Character) _character;
unsigned int _mat_index = 0;
};
// These arrays are temporarily used during the build_graph run.
PT(Texture) *_textures;
CPT(RenderState) *_mat_states;
PT(Geom) *_geoms;
unsigned int *_geom_matindices;
Geoms *_geoms;
BoneMap _bonemap;
PT(Character) *_characters;
const aiNode *find_node(const aiNode &root, const aiString &name);