载入中...
搜索中...
未找到
Shape3DContactSnapshot.cpp
浏览该文件的文档.
12 return Result<T>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, message, "payload.shapes.contact"));
15 return Value(Value::Object{{"values", Value(Value::Array{Value(m.friction), Value(m.restitution),
27 if (values.value().size() != 6 || values.value()[0] < 0 || values.value()[1] < 0 || values.value()[2] < 0)
39bool finite(b3Matrix3 m) { return b3IsValidVec3(m.cx) && b3IsValidVec3(m.cy) && b3IsValidVec3(m.cz); }
45 for (int i = 0; shape.geometry_.kind == Shape3D::Kind::TriangleMesh && i < b3Shape_GetMeshMaterialCount(id); ++i)
67Result<float> WorldSnapshotAccess::restoreShapeContact(Shape3D& shape, const Value::Object& source) {
71 if (!o || !hasExactFields(*o, {"density", "surface", "sensor", "category", "mask", "group", "tag", "explosionScale",
91 if (group.value() < INT32_MIN || group.value() > INT32_MAX || tag.value() < INT32_MIN || tag.value() > INT32_MAX)
96 {"sensor", "sensorEvents", "contactEvents", "preSolveEvents", "hitEvents", "contactOverride", "oneWay"}) {
122 if (parsed.value() < 0 || parsed.value() > 254) return invalid<float>("Mesh material index out of range");
132 // Candidate geometry still uses construction density. All density assignments are deferred until every recreation
181 if (!std::isfinite(data.mass) || data.mass < 0 || !b3IsValidVec3(data.center) || !finite(data.inertia))
185 if (!std::isfinite(mass) || !b3IsValidVec3(center)) return invalid<void>("Body mass accumulation overflow");
196 inertia = b3AddMM(inertia, b3AddMM(data.inertia, b3Steiner(data.mass, b3Sub(center, data.center))));
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:209
3D shape (box/sphere/capsule) attached to a Body3D with material settings. Created via Body3D::new*Sh...
Definition Shape3D.h:34
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:47
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
Result< float > readFloat(const Value::Object &object, std::string_view name)
Reads a required finite number representable by float.
Definition WorldSnapshotParsing.cpp:66
const Value * field(const Value::Object &object, std::string_view name)
Borrow an optional field only during the current synchronous codec call. @ownership Object owns the r...
Definition WorldSnapshotParsing.cpp:17
bool hasExactFields(const Value::Object &object, std::initializer_list< std::string_view > expected)
Internal exact-field schema predicate.
Definition WorldSnapshotParsing.cpp:9
Result< std::uint64_t > readUint64(const Value::Object &object, std::string_view name)
Reads a required unsigned decimal integer string.
Definition WorldSnapshotParsing.cpp:30
Result< std::int64_t > readInt64(const Value::Object &object, std::string_view name)
Reads a required signed decimal integer string.
Definition WorldSnapshotParsing.cpp:42
Result< bool > readBool(const Value::Object &object, std::string_view name)
Reads a required boolean.
Definition WorldSnapshotParsing.cpp:75
eve::Result< std::vector< float > > readFloatArray(const eve::Value::Object &object, std::string_view name)
Read a finite float array, rejecting missing or malformed elements.
Definition WorldSnapshotCodec.cpp:558
@ InvalidArgument
static Value shapeContact(const Shape3D &shape)
Capture native shape contact state and wrapper-owned collision settings.
Definition Shape3DContactSnapshot.cpp:41
static Result< float > restoreShapeContact(Shape3D &shape, const Value::Object &source)
Restore validated candidate contact state; return density for deferred mass preparation.
Definition Shape3DContactSnapshot.cpp:67
static b3BodyId bodyId(const Body3D &body)
Borrows the native identifier synchronously; facade must belong to a Box3D world.
Definition Box3DBody.cpp:649
static b3ShapeId shapeId(const Shape3D &shape)
Borrows a Box3D shape identifier for a synchronous native operation.
Definition Box3DShape.cpp:328