feat(web): bind physics manifests to Blender Main
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-08-29 11:39:36 +08:00
parent 450daff23a
commit b1ec8d29f6
57 changed files with 3660 additions and 20 deletions

View File

@@ -42,6 +42,7 @@
#include "BKE_object_deform.h"
#include "BKE_packedFile.hh"
#include "BKE_scene.hh"
#include "BKE_rigidbody.h"
#include "BKE_text.h"
#include "BKE_vfont.hh"
#include "BKE_volume.hh"
@@ -4913,6 +4914,29 @@ bool web_engine_blend_main_set_physics_simulation(WebBlendMainState *state,
error = "PHYSICS_MANIFEST_INVALID: physics metadata could not be written to Object";
return false;
}
if (system.value("family", "") == "RIGID_BODY" && owner->rigidbody_object != nullptr) {
const json &settings = system["settings"];
const auto number = [&](const char *key, const float current, const float minimum, const float maximum, float &target) {
if (!settings.contains(key)) return true;
if (!settings[key].is_number()) return false;
const float value = settings[key].get<float>();
if (!std::isfinite(value) || value < minimum || value > maximum) return false;
target = value;
(void)current;
return true;
};
RigidBodyOb &body = *owner->rigidbody_object;
if (!number("mass", body.mass, 0.0f, 1000000.0f, body.mass) ||
!number("friction", body.friction, 0.0f, 1000000.0f, body.friction) ||
!number("restitution", body.restitution, 0.0f, 1000000.0f, body.restitution) ||
!number("margin", body.margin, 0.0f, 1000000.0f, body.margin) ||
!number("linearDamping", body.lin_damping, 0.0f, 1000000.0f, body.lin_damping) ||
!number("angularDamping", body.ang_damping, 0.0f, 1000000.0f, body.ang_damping)) {
error = "PHYSICS_MANIFEST_INVALID: rigid body settings are outside the bounded range";
return false;
}
owner->id.recalc |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
}
}
}
state->physics_simulation_override = manifest_text;