perf(editor): fewer kernel round trips per settle, background tessellation, vectorised edge keys
A settle lists the cells in the call that publishes the preview (one call into the kernel, not three), the boot's duplicate settle is dropped, the debounce is 0.12 s, parts are tessellated on a background thread while the next cell computes (cached_mesh releases the GIL; a failure is recorded on the shape under the GIL), and the edge position keys are computed with numpy (byte-identical). Six-axis arm, last cell to preview event: ~0.83 s -> ~0.36 s. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -222,8 +222,21 @@ void bind_mesh(py::module_& m) {
|
||||
internal.def(
|
||||
"cached_mesh",
|
||||
[](const Shape& solid, double linear_tolerance, double angular_tolerance) {
|
||||
// Meshing works on a topology copy (see meshed_copy) and touches no Python object, so it runs without the GIL:
|
||||
// the editor tessellates parts on a background thread while the next cell computes. A failure is recorded on
|
||||
// the shape here, with the GIL back.
|
||||
std::shared_ptr<const io::TriMesh> mesh;
|
||||
std::string error;
|
||||
{
|
||||
py::gil_scoped_release release;
|
||||
mesh = io::cached_mesh_detached(solid, linear_tolerance, angular_tolerance, &error);
|
||||
}
|
||||
if (!mesh && !error.empty()) {
|
||||
Shape handle = solid;
|
||||
handle.set_runtime("mesh.error", Value(error));
|
||||
}
|
||||
// The mesh is shared with the cache and exposed read-only, so handing it out un-const is safe.
|
||||
return std::const_pointer_cast<io::TriMesh>(io::cached_mesh(solid, linear_tolerance, angular_tolerance));
|
||||
return std::const_pointer_cast<io::TriMesh>(mesh);
|
||||
},
|
||||
py::arg("solid"), py::kw_only(), py::arg("linear_tolerance") = io::kDefaultLinearDeflection,
|
||||
py::arg("angular_tolerance") = io::kDefaultAngularDeflection);
|
||||
|
||||
Reference in New Issue
Block a user