载入中...
搜索中...
未找到
ClimbingCodec.cpp
浏览该文件的文档.
2#include "common/ValueRead.h"
3
4#include <algorithm>
5#include <cmath>
6#include <limits>
7#include <unordered_set>
8#include <utility>
9
10namespace eve::climbing {
11namespace {
12
13const eve::Value* field(const eve::Value::Object& object, std::string_view name) {
14 const auto found = object.find(std::string(name));
15 return found == object.end() ? nullptr : &found->second;
16}
17
18bool finite(float value) { return std::isfinite(value); }
19
20bool readString(const eve::Value::Object& object, std::string_view name, std::string& output) {
21 auto text = eve::readStringMember(object, name);
22 if (!text) return false;
23 output = std::move(text.value());
24 return true;
25}
26
27bool readInt64(const eve::Value::Object& object, std::string_view name, std::int64_t& output) {
28 const auto* value = field(object, name);
29 if (!value) return false;
30 auto parsed = eve::readInt64Value(*value);
31 if (!parsed) return false;
32 output = parsed.value();
33 return true;
34}
35
36bool readBool(const eve::Value::Object& object, std::string_view name, bool& output) {
37 const auto* value = field(object, name);
38 if (!value) return false;
39 auto parsed = eve::readBoolValue(*value);
40 if (!parsed) return false;
41 output = parsed.value();
42 return true;
43}
44
45bool readFloat(const eve::Value::Object& object, std::string_view name, float& output) {
46 const auto* value = field(object, name);
47 if (!value) return false;
48 auto parsed = eve::readFiniteFloatValue(*value);
49 if (!parsed) return false;
50 output = parsed.value();
51 return true;
52}
53
54bool readOptionalFloat(const eve::Value::Object& object, std::string_view name, float& output) {
55 return !field(object, name) || readFloat(object, name, output);
56}
57
58bool readOptionalInt64(const eve::Value::Object& object, std::string_view name, std::int64_t& output) {
59 return !field(object, name) || readInt64(object, name, output);
60}
61
62template <class Enum>
63bool readOptionalEnum(const eve::Value::Object& object, std::string_view name, Enum& output,
64 std::int64_t maximumInclusive) {
65 std::int64_t value = static_cast<std::int64_t>(output);
66 if (!readOptionalInt64(object, name, value) || value < 0 || value > maximumInclusive) return false;
67 output = static_cast<Enum>(value);
68 return true;
69}
70
71eve::Value stringArray(const std::vector<std::string>& values) {
73 result.reserve(values.size());
74 for (const std::string& value : values) result.emplace_back(value);
75 return eve::Value(std::move(result));
76}
77
78bool readOptionalStringArray(const eve::Value::Object& object, std::string_view name,
79 std::vector<std::string>& output) {
80 const eve::Value* value = field(object, name);
81 if (!value) return true;
82 const auto* array = value->getIf<eve::Value::Array>();
83 if (!array) return false;
84 std::vector<std::string> candidate;
85 candidate.reserve(array->size());
86 for (const eve::Value& item : *array) {
87 const auto* text = item.getIf<std::string>();
88 if (!text) return false;
89 candidate.push_back(*text);
90 }
91 output = std::move(candidate);
92 return true;
93}
94
95bool readOptionalString(const eve::Value::Object& object, std::string_view name, std::string& output) {
96 return !field(object, name) || readString(object, name, output);
97}
98
99bool uniqueNonEmpty(const std::vector<std::string>& values) {
100 std::vector<std::string_view> sorted;
101 sorted.reserve(values.size());
102 for (const std::string& value : values) {
103 if (value.empty()) return false;
104 sorted.push_back(value);
105 }
106 std::sort(sorted.begin(), sorted.end());
107 return std::adjacent_find(sorted.begin(), sorted.end()) == sorted.end();
108}
109
110std::string_view kindName(ClimbingActionKind kind) {
111 switch (kind) {
112 case ClimbingActionKind::Vault: return "vault";
113 case ClimbingActionKind::Mantle: return "mantle";
114 case ClimbingActionKind::LedgeGrab: return "ledge_grab";
115 case ClimbingActionKind::ClimbUp: return "climb_up";
116 case ClimbingActionKind::Shimmy: return "shimmy";
117 case ClimbingActionKind::CornerInner: return "corner_inner";
118 case ClimbingActionKind::CornerOuter: return "corner_outer";
119 case ClimbingActionKind::LedgeJump: return "ledge_jump";
120 case ClimbingActionKind::ClimbDown: return "climb_down";
121 case ClimbingActionKind::LadderMount: return "ladder_mount";
122 case ClimbingActionKind::LadderClimb: return "ladder_climb";
123 case ClimbingActionKind::LadderDismount: return "ladder_dismount";
124 case ClimbingActionKind::WallRun: return "wall_run";
125 case ClimbingActionKind::Slide: return "slide";
126 case ClimbingActionKind::BeamBalance: return "beam_balance";
127 case ClimbingActionKind::PoleSwing: return "pole_swing";
128 case ClimbingActionKind::BarSwing: return "bar_swing";
129 }
130 return "unknown";
131}
132
133bool readKind(std::string_view text, ClimbingActionKind& output) {
134 if (text == "vault")
136 else if (text == "mantle")
138 else if (text == "ledge_grab")
140 else if (text == "climb_up")
142 else if (text == "shimmy")
144 else if (text == "corner_inner")
146 else if (text == "corner_outer")
148 else if (text == "ledge_jump")
150 else if (text == "climb_down")
152 else if (text == "ladder_mount")
154 else if (text == "ladder_climb")
156 else if (text == "ladder_dismount")
158 else if (text == "wall_run")
160 else if (text == "slide")
162 else if (text == "beam_balance")
164 else if (text == "pole_swing")
166 else if (text == "bar_swing")
168 else
169 return false;
170 return true;
171}
172
173eve::Result<const eve::Value::Object*> readRoot(const eve::Value& value, std::string_view schemaId,
174 std::int64_t schemaVersion) {
175 const auto* object = value.getIf<eve::Value::Object>();
176 if (!object)
178 eve::DiagnosticCode::ParseError, "climbing definition must be an object", {}, {}, "climbing.codec"));
179 std::string actualSchema;
180 std::int64_t actualVersion = 0;
181 if (!readString(*object, "schemaId", actualSchema) || actualSchema != schemaId)
183 eve::DiagnosticCode::ParseError, "climbing definition schemaId is missing or mismatched", "schemaId", {},
184 "climbing.codec"));
185 if (!readInt64(*object, "schemaVersion", actualVersion))
187 eve::DiagnosticCode::ParseError, "climbing definition schemaVersion must be an integer", "schemaVersion",
188 {}, "climbing.codec"));
189 if (actualVersion != schemaVersion && actualVersion != schemaVersion - 1)
191 eve::DiagnosticCode::UnknownVersion, "climbing definition schema version is unsupported", "schemaVersion",
192 {}, "climbing.codec"));
194}
195
196eve::Value::Object unknownFields(const eve::Value::Object& object, std::initializer_list<std::string_view> knownNames) {
197 std::unordered_set<std::string_view> known(knownNames.begin(), knownNames.end());
199 for (const auto& [name, value] : object)
200 if (!known.contains(name)) result.emplace(name, value);
201 return result;
202}
203
204void writeActionFields(eve::Value::Object& object, const ClimbingActionDefinition& action) {
205 eve::Value::Array notifyValues;
206 notifyValues.reserve(action.requiredNotifies.size());
207 for (const std::string& notify : action.requiredNotifies) notifyValues.emplace_back(notify);
208 eve::Value::Array warpWindowValues;
209 warpWindowValues.reserve(action.warpWindows.size());
210 for (const ClimbingWarpWindow& window : action.warpWindows) {
211 warpWindowValues.push_back(eve::Value::object({{"start", window.start},
212 {"end", window.end},
213 {"horizontal", window.horizontal},
214 {"vertical", window.vertical},
215 {"facing", window.facing}}));
216 }
217 object["schemaId"] = eve::Value(std::string(ClimbingActionDefinition::SchemaId));
218 object["schemaVersion"] = eve::Value(ClimbingActionDefinition::SchemaVersion);
219 object["id"] = eve::Value(action.id);
220 object["kind"] = eve::Value(std::string(kindName(action.kind)));
221 object["minHeight"] = eve::Value(action.minHeight);
222 object["maxHeight"] = eve::Value(action.maxHeight);
223 object["minSpeed"] = eve::Value(action.minSpeed);
224 object["durationNs"] = eve::Value(action.duration.nanoseconds());
225 object["landingForward"] = eve::Value(action.landingForward);
226 object["apexHeight"] = eve::Value(action.apexHeight);
227 object["selectionBias"] = eve::Value(action.selectionBias);
228 object["hangBodyOffset"] = eve::Value(action.hangBodyOffset);
229 object["hangFeetBelowLedge"] = eve::Value(action.hangFeetBelowLedge);
230 object["handSpacing"] = eve::Value(action.handSpacing);
231 object["cancelWindowStart"] = eve::Value(action.cancelWindowStart);
232 object["cancelWindowEnd"] = eve::Value(action.cancelWindowEnd);
233 object["rootMotionScaleMin"] = eve::Value(action.rootMotionScaleMin);
234 object["rootMotionScaleMax"] = eve::Value(action.rootMotionScaleMax);
235 object["maxTranslationWarpPerTick"] = eve::Value(action.maxTranslationWarpPerTick);
236 object["maxYawWarpRadiansPerTick"] = eve::Value(action.maxYawWarpRadiansPerTick);
237 object["horizontalWarpBudget"] = eve::Value(action.horizontalWarpBudget);
238 object["verticalWarpBudget"] = eve::Value(action.verticalWarpBudget);
239 object["facingWarpBudgetRadians"] = eve::Value(action.facingWarpBudgetRadians);
240 object["warpWindows"] = eve::Value(std::move(warpWindowValues));
241 object["requiredNotifies"] = eve::Value(std::move(notifyValues));
242 object["tags"] = stringArray(action.tags);
243 object["sourceModes"] = eve::Value(static_cast<std::int64_t>(action.sourceModes));
244 object["requiredCommand"] = eve::Value(static_cast<std::int64_t>(action.requiredCommand));
245 object["probeRecipe"] = eve::Value(static_cast<std::int64_t>(action.probeRecipe));
246 object["minDepth"] = eve::Value(action.minDepth);
247 object["maxDepth"] = eve::Value(action.maxDepth);
248 object["minDistance"] = eve::Value(action.minDistance);
249 object["maxDistance"] = eve::Value(action.maxDistance);
250 object["minSurfaceNormalY"] = eve::Value(action.minSurfaceNormalY);
251 object["maxSlopeRadians"] = eve::Value(action.maxSlopeRadians);
252 object["maxCurvature"] = eve::Value(action.maxCurvature);
253 object["requiredSupportTags"] = stringArray(action.requiredSupportTags);
254 object["trajectory"] = eve::Value(static_cast<std::int64_t>(action.trajectory));
255 object["animation"] = eve::Value::object({{"clipId", action.animation.clipId},
256 {"graphNodeId", action.animation.graphNodeId},
257 {"rootBone", action.animation.rootBone},
258 {"mirrored", action.animation.mirrored}});
259 eve::Value::Array branchValues;
260 branchValues.reserve(action.branchWindows.size());
261 for (const ClimbingBranchWindow& window : action.branchWindows)
262 branchValues.push_back(eve::Value::object(
263 {{"start", window.start}, {"end", window.end}, {"comboTag", window.comboTag}}));
264 object["branchWindows"] = eve::Value(std::move(branchValues));
265 eve::Value::Array contactValues;
266 contactValues.reserve(action.contactConstraints.size());
267 for (const ClimbingContactConstraint& contact : action.contactConstraints)
268 contactValues.push_back(eve::Value::object({{"target", static_cast<std::int64_t>(contact.target)},
269 {"start", contact.start},
270 {"end", contact.end},
271 {"maxWeight", contact.maxWeight}}));
272 object["contactConstraints"] = eve::Value(std::move(contactValues));
273 object["landingPolicy"] = eve::Value(static_cast<std::int64_t>(action.landingPolicy));
274 object["terminalVelocityPolicy"] = eve::Value(static_cast<std::int64_t>(action.terminalVelocityPolicy));
275 object["comboTags"] = stringArray(action.comboTags);
276 object["repetitionPenalty"] = eve::Value(static_cast<std::int64_t>(action.repetitionPenalty));
277 object["requiredConditionTags"] = stringArray(action.requiredConditionTags);
278 object["staminaCost"] = eve::Value(action.staminaCost);
279 object["cameraCue"] = eve::Value(action.cameraCue);
280 object["eventMetadata"] = stringArray(action.eventMetadata);
281}
282
283} // namespace
284
286 if (action.id.empty())
288 eve::DiagnosticCode::InvalidArgument, "action id must not be empty", "id", {}, "climbing.codec"));
289 if (!finite(action.minHeight) || !finite(action.maxHeight) || action.minHeight < 0.f ||
290 action.maxHeight < action.minHeight)
292 eve::DiagnosticCode::InvalidArgument, "action height range must be finite, non-negative, and ordered",
293 "height", {}, "climbing.codec"));
294 if (!finite(action.minSpeed) || action.minSpeed < 0.f || !finite(action.landingForward) ||
295 action.landingForward < 0.f || !finite(action.apexHeight) || action.apexHeight < 0.f)
298 "action speed, landing distance, and apex must be finite and non-negative", {}, {}, "climbing.codec"));
299 if (action.duration.nanoseconds() <= 0)
301 "action duration must be positive", "durationNs", {},
302 "climbing.codec"));
303 if (!finite(action.hangBodyOffset) || action.hangBodyOffset < 0.f || !finite(action.hangFeetBelowLedge) ||
304 action.hangFeetBelowLedge <= 0.f || !finite(action.handSpacing) || action.handSpacing <= 0.f ||
305 !finite(action.cancelWindowStart) || !finite(action.cancelWindowEnd) || action.cancelWindowStart < 0.f ||
306 action.cancelWindowEnd > 1.f || action.cancelWindowEnd < action.cancelWindowStart)
308 eve::DiagnosticCode::InvalidArgument, "hang geometry and cancel window must be finite and ordered", {}, {},
309 "climbing.codec"));
310 if (!finite(action.rootMotionScaleMin) || !finite(action.rootMotionScaleMax) || action.rootMotionScaleMin <= 0.f ||
311 action.rootMotionScaleMax < action.rootMotionScaleMin || action.rootMotionScaleMax > 4.f ||
312 !finite(action.maxTranslationWarpPerTick) || action.maxTranslationWarpPerTick <= 0.f ||
313 !finite(action.maxYawWarpRadiansPerTick) || action.maxYawWarpRadiansPerTick <= 0.f ||
314 !finite(action.horizontalWarpBudget) || action.horizontalWarpBudget < 0.f ||
315 !finite(action.verticalWarpBudget) || action.verticalWarpBudget < 0.f ||
316 !finite(action.facingWarpBudgetRadians) || action.facingWarpBudgetRadians < 0.f)
319 "root-motion scale and warp budgets must be finite, positive, and bounded", "warp", {}, "climbing.codec"));
320 float previousEnd = 0.f;
321 for (std::size_t index = 0; index < action.warpWindows.size(); ++index) {
322 const ClimbingWarpWindow& window = action.warpWindows[index];
323 if (!finite(window.start) || !finite(window.end) || window.start < 0.f || window.end > 1.f ||
324 window.end <= window.start || window.start < previousEnd ||
325 (!window.horizontal && !window.vertical && !window.facing))
328 "warp windows must be ordered, non-overlapping, and enable a channel",
329 "warpWindows." + std::to_string(index), {}, "climbing.codec"));
330 previousEnd = window.end;
331 }
332 std::vector<std::string> notifyNames = action.requiredNotifies;
333 std::sort(notifyNames.begin(), notifyNames.end());
334 if (std::any_of(notifyNames.begin(), notifyNames.end(), [](const std::string& name) { return name.empty(); }) ||
335 std::adjacent_find(notifyNames.begin(), notifyNames.end()) != notifyNames.end())
337 eve::DiagnosticCode::InvalidArgument, "required animation notifies must be non-empty and unique",
338 "requiredNotifies", {}, "climbing.codec"));
339 const auto sourceBits = static_cast<std::uint8_t>(action.sourceModes);
340 if (sourceBits == 0 || (sourceBits & ~static_cast<std::uint8_t>(ClimbingSourceMode::Any)) != 0)
342 "sourceModes must contain a known mode", "sourceModes",
343 {}, "climbing.codec"));
344 if (!finite(action.minDepth) || !finite(action.maxDepth) || action.minDepth < 0.f ||
345 action.maxDepth < action.minDepth || !finite(action.minDistance) || !finite(action.maxDistance) ||
346 action.minDistance < 0.f || action.maxDistance < action.minDistance ||
347 !finite(action.minSurfaceNormalY) || action.minSurfaceNormalY < -1.f || action.minSurfaceNormalY > 1.f ||
348 !finite(action.maxSlopeRadians) || action.maxSlopeRadians < 0.f || action.maxSlopeRadians > 3.1415927f ||
349 !finite(action.maxCurvature) || action.maxCurvature < 0.f)
351 "action geometry constraints are invalid", "geometry",
352 {}, "climbing.codec"));
353 if (!uniqueNonEmpty(action.tags) || !uniqueNonEmpty(action.requiredSupportTags) ||
354 !uniqueNonEmpty(action.comboTags) || !uniqueNonEmpty(action.requiredConditionTags) ||
355 !uniqueNonEmpty(action.eventMetadata))
357 "action tags and event metadata must be unique",
358 "metadata", {}, "climbing.codec"));
359 if (action.animation.rootBone.empty())
361 "animation rootBone must not be empty",
362 "animation.rootBone", {}, "climbing.codec"));
363 for (std::size_t index = 0; index < action.branchWindows.size(); ++index) {
364 const auto& window = action.branchWindows[index];
365 if (!finite(window.start) || !finite(window.end) || window.start < 0.f || window.end > 1.f ||
366 window.end <= window.start || window.comboTag.empty())
369 "branchWindows." + std::to_string(index), {}, "climbing.codec"));
370 if (std::find(action.comboTags.begin(), action.comboTags.end(), window.comboTag) == action.comboTags.end())
372 eve::DiagnosticCode::InvalidArgument, "branch window comboTag must be declared by the action",
373 "branchWindows." + std::to_string(index) + ".comboTag", {}, "climbing.codec"));
374 }
375 for (std::size_t index = 0; index < action.contactConstraints.size(); ++index) {
376 const auto& contact = action.contactConstraints[index];
377 if (!finite(contact.start) || !finite(contact.end) || !finite(contact.maxWeight) || contact.start < 0.f ||
378 contact.end > 1.f || contact.end <= contact.start || contact.maxWeight < 0.f || contact.maxWeight > 1.f)
380 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "contact constraint is invalid",
381 "contactConstraints." + std::to_string(index), {}, "climbing.codec"));
382 }
383 if (action.repetitionPenalty < 0 || !finite(action.staminaCost) || action.staminaCost < 0.f)
385 eve::DiagnosticCode::InvalidArgument, "action cost metadata is invalid", "cost", {}, "climbing.codec"));
387}
388
390 if (!finite(profile.capsuleRadius) || !finite(profile.capsuleHeight) || profile.capsuleRadius <= 0.f ||
391 profile.capsuleHeight <= profile.capsuleRadius * 2.f)
393 "capsule height must exceed twice its positive radius",
394 "capsule", {}, "climbing.codec"));
395 if (!finite(profile.compactCapsuleHeight) ||
396 profile.compactCapsuleHeight <= profile.capsuleRadius * 2.f ||
397 profile.compactCapsuleHeight > profile.capsuleHeight)
400 "compact capsule height must exceed the diameter and not exceed standing height",
401 "compactCapsuleHeight", {}, "climbing.codec"));
402 if (!finite(profile.skin) || profile.skin < 0.f || !finite(profile.maxProbeDistance) ||
403 profile.maxProbeDistance <= 0.f || !finite(profile.maxObstacleHeight) || profile.maxObstacleHeight <= 0.f ||
404 !finite(profile.minTopNormalY) || profile.minTopNormalY < 0.f || profile.minTopNormalY > 1.f ||
405 !finite(profile.maxWarpResidual) || profile.maxWarpResidual < 0.f)
407 eve::DiagnosticCode::InvalidArgument, "profile probe, surface, skin, and warp limits are invalid", {}, {},
408 "climbing.codec"));
409 if (!finite(profile.maxPlatformSpeed) || profile.maxPlatformSpeed <= 0.f || !finite(profile.dropInitialSpeed) ||
410 profile.dropInitialSpeed < 0.f)
412 "platform and drop speed limits must be finite", {},
413 {}, "climbing.codec"));
414 if (profile.inputBufferTicks == 0 || profile.inputBufferTicks > 1000000 || profile.coyoteTicks > 1000000)
416 eve::DiagnosticCode::InvalidArgument, "input buffer must be non-zero and tick windows must be bounded",
417 "inputTicks", {}, "climbing.codec"));
418 if (profile.pathValidationSegments < 2 || profile.pathValidationSegments > 64 ||
419 !finite(profile.maxPelvisDeviation) || profile.maxPelvisDeviation < 0.f)
421 eve::DiagnosticCode::InvalidArgument, "path validation samples and pelvis deviation are invalid",
422 "motionValidation", {}, "climbing.codec"));
423 if (!finite(profile.groundAcceleration) || profile.groundAcceleration < 0.f || !finite(profile.groundBraking) ||
424 profile.groundBraking < 0.f || !finite(profile.airControl) || profile.airControl < 0.f ||
425 profile.airControl > 1.f || !finite(profile.gravity) || profile.gravity <= 0.f ||
426 !finite(profile.jumpSpeed) || profile.jumpSpeed <= 0.f || profile.probeSectors == 0 ||
427 profile.probeSectors > 64 || profile.maxCandidates == 0 || profile.maxCandidates > 8 ||
428 !finite(profile.autoAssistStrength) || profile.autoAssistStrength < 0.f || profile.autoAssistStrength > 1.f ||
429 !finite(profile.maxTotalWarpBudget) || profile.maxTotalWarpBudget < 0.f)
431 "profile locomotion and probe policies are invalid",
432 "policies", {}, "climbing.codec"));
433 if (!uniqueNonEmpty(profile.defaultActionIds) || !uniqueNonEmpty(profile.allowedActionTags) ||
434 !uniqueNonEmpty(profile.deniedActionTags))
436 "profile action ids and tags must be unique",
437 "actionPolicy", {}, "climbing.codec"));
439 if (weights.direction < 0 || weights.approachSpeed < 0 || weights.height < 0 || weights.distance < 0 ||
440 weights.warpTranslation < 0 || weights.warpRotation < 0 || weights.intentMismatch < 0)
442 "score weights must be non-negative", "scoreWeights",
443 {}, "climbing.codec"));
446 eve::DiagnosticCode::InvalidArgument, "RequireProvider stamina policy needs a stable adapter id",
447 "staminaAdapter", {}, "climbing.codec"));
448 std::unordered_set<std::string> ids;
449 for (const ClimbingActionDefinition& action : profile.actions) {
451 if (!valid) return eve::Result<void>::failure(valid.status());
452 if (std::max(action.horizontalWarpBudget, action.verticalWarpBudget) >
453 profile.maxTotalWarpBudget + 0.0001f)
455 eve::DiagnosticCode::InvalidArgument, "action translation warp budgets exceed profile maximum",
456 "actions." + action.id, {}, "climbing.codec"));
457 if (!ids.emplace(action.id).second)
459 "profile contains duplicate action id",
460 "actions." + action.id, {}, "climbing.codec"));
461 }
462 for (const std::string& id : profile.defaultActionIds)
463 if (!ids.contains(id))
465 eve::DiagnosticCode::NotFound, "default action id is not registered in the profile",
466 "defaultActionIds." + id, {}, "climbing.codec"));
468}
469
472 if (!valid) return eve::Result<eve::Value>::failure(valid.status());
473 eve::Value::Object object = action.extensionMetadata;
474 writeActionFields(object, action);
475 return eve::Result<eve::Value>::success(eve::Value(std::move(object)));
476}
477
481 const eve::Value::Object& object = *root.value();
482 ClimbingActionDefinition candidate;
483 std::string kind;
484 std::int64_t durationNs = 0;
485 std::int64_t selectionBias = 0;
486 const eve::Value* notifiesValue = field(object, "requiredNotifies");
487 const auto* notifies = notifiesValue ? notifiesValue->getIf<eve::Value::Array>() : nullptr;
488 const eve::Value* warpWindowsValue = field(object, "warpWindows");
489 const auto* warpWindows = warpWindowsValue ? warpWindowsValue->getIf<eve::Value::Array>() : nullptr;
490 if (!readString(object, "id", candidate.id) || !readString(object, "kind", kind) ||
491 !readKind(kind, candidate.kind) || !readFloat(object, "minHeight", candidate.minHeight) ||
492 !readFloat(object, "maxHeight", candidate.maxHeight) || !readFloat(object, "minSpeed", candidate.minSpeed) ||
493 !readInt64(object, "durationNs", durationNs) ||
494 !readFloat(object, "landingForward", candidate.landingForward) ||
495 !readFloat(object, "apexHeight", candidate.apexHeight) || !readInt64(object, "selectionBias", selectionBias) ||
496 selectionBias < std::numeric_limits<int>::min() || selectionBias > std::numeric_limits<int>::max() ||
497 !readFloat(object, "hangBodyOffset", candidate.hangBodyOffset) ||
498 !readFloat(object, "hangFeetBelowLedge", candidate.hangFeetBelowLedge) ||
499 !readFloat(object, "handSpacing", candidate.handSpacing) ||
500 !readFloat(object, "cancelWindowStart", candidate.cancelWindowStart) ||
501 !readFloat(object, "cancelWindowEnd", candidate.cancelWindowEnd) ||
502 !readOptionalFloat(object, "rootMotionScaleMin", candidate.rootMotionScaleMin) ||
503 !readOptionalFloat(object, "rootMotionScaleMax", candidate.rootMotionScaleMax) ||
504 !readOptionalFloat(object, "maxTranslationWarpPerTick", candidate.maxTranslationWarpPerTick) ||
505 !readOptionalFloat(object, "maxYawWarpRadiansPerTick", candidate.maxYawWarpRadiansPerTick) ||
506 !readOptionalFloat(object, "horizontalWarpBudget", candidate.horizontalWarpBudget) ||
507 !readOptionalFloat(object, "verticalWarpBudget", candidate.verticalWarpBudget) ||
508 !readOptionalFloat(object, "facingWarpBudgetRadians", candidate.facingWarpBudgetRadians) ||
509 (warpWindowsValue && !warpWindows) || !notifies)
512 "climbing action has missing or invalid known fields", {}, {}, "climbing.codec"));
513 candidate.duration = eve::Duration::fromNanoseconds(durationNs);
514 candidate.selectionBias = static_cast<int>(selectionBias);
515 candidate.requiredNotifies.reserve(notifies->size());
516 for (std::size_t index = 0; index < notifies->size(); ++index) {
517 const auto* notify = (*notifies)[index].getIf<std::string>();
518 if (!notify)
520 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "animation notify must be a string",
521 "requiredNotifies." + std::to_string(index), {}, "climbing.codec"));
522 candidate.requiredNotifies.push_back(*notify);
523 }
524 if (warpWindows) candidate.warpWindows.reserve(warpWindows->size());
525 for (std::size_t index = 0; warpWindows && index < warpWindows->size(); ++index) {
526 const auto* valueObject = (*warpWindows)[index].getIf<eve::Value::Object>();
527 ClimbingWarpWindow window;
528 if (!valueObject || !readFloat(*valueObject, "start", window.start) ||
529 !readFloat(*valueObject, "end", window.end) || !readBool(*valueObject, "horizontal", window.horizontal) ||
530 !readBool(*valueObject, "vertical", window.vertical) || !readBool(*valueObject, "facing", window.facing))
532 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "warp window has missing or invalid fields",
533 "warpWindows." + std::to_string(index), {}, "climbing.codec"));
534 candidate.warpWindows.push_back(window);
535 }
536 std::int64_t repetitionPenalty = candidate.repetitionPenalty;
537 if (!readOptionalStringArray(object, "tags", candidate.tags) ||
538 !readOptionalEnum(object, "sourceModes", candidate.sourceModes,
539 static_cast<std::int64_t>(ClimbingSourceMode::Any)) ||
540 !readOptionalEnum(object, "requiredCommand", candidate.requiredCommand,
541 static_cast<std::int64_t>(ClimbingCommandRequirement::Crouch)) ||
542 !readOptionalEnum(object, "probeRecipe", candidate.probeRecipe,
543 static_cast<std::int64_t>(ClimbingProbeRecipe::AnchorGraph)) ||
544 !readOptionalFloat(object, "minDepth", candidate.minDepth) ||
545 !readOptionalFloat(object, "maxDepth", candidate.maxDepth) ||
546 !readOptionalFloat(object, "minDistance", candidate.minDistance) ||
547 !readOptionalFloat(object, "maxDistance", candidate.maxDistance) ||
548 !readOptionalFloat(object, "minSurfaceNormalY", candidate.minSurfaceNormalY) ||
549 !readOptionalFloat(object, "maxSlopeRadians", candidate.maxSlopeRadians) ||
550 !readOptionalFloat(object, "maxCurvature", candidate.maxCurvature) ||
551 !readOptionalStringArray(object, "requiredSupportTags", candidate.requiredSupportTags) ||
552 !readOptionalEnum(object, "trajectory", candidate.trajectory,
553 static_cast<std::int64_t>(ClimbingTrajectoryKind::AnchorToAnchor)) ||
554 !readOptionalEnum(object, "landingPolicy", candidate.landingPolicy,
555 static_cast<std::int64_t>(ClimbingLandingPolicy::Stop)) ||
556 !readOptionalEnum(object, "terminalVelocityPolicy", candidate.terminalVelocityPolicy,
557 static_cast<std::int64_t>(ClimbingTerminalVelocityPolicy::Zero)) ||
558 !readOptionalStringArray(object, "comboTags", candidate.comboTags) ||
559 !readOptionalInt64(object, "repetitionPenalty", repetitionPenalty) ||
560 repetitionPenalty < std::numeric_limits<std::int32_t>::min() ||
561 repetitionPenalty > std::numeric_limits<std::int32_t>::max() ||
562 !readOptionalStringArray(object, "requiredConditionTags", candidate.requiredConditionTags) ||
563 !readOptionalFloat(object, "staminaCost", candidate.staminaCost) ||
564 !readOptionalString(object, "cameraCue", candidate.cameraCue) ||
565 !readOptionalStringArray(object, "eventMetadata", candidate.eventMetadata))
567 eve::DiagnosticCode::ParseError, "climbing action has invalid v4 metadata", {}, {}, "climbing.codec"));
568 candidate.repetitionPenalty = static_cast<std::int32_t>(repetitionPenalty);
569 if (const eve::Value* animationValue = field(object, "animation")) {
570 const auto* animation = animationValue->getIf<eve::Value::Object>();
571 if (!animation || !readString(*animation, "clipId", candidate.animation.clipId) ||
572 !readString(*animation, "graphNodeId", candidate.animation.graphNodeId) ||
573 !readString(*animation, "rootBone", candidate.animation.rootBone) ||
574 !readBool(*animation, "mirrored", candidate.animation.mirrored))
576 eve::DiagnosticCode::ParseError, "animation binding has missing or invalid fields", "animation", {},
577 "climbing.codec"));
578 }
579 if (const eve::Value* branchValue = field(object, "branchWindows")) {
580 const auto* branches = branchValue->getIf<eve::Value::Array>();
581 if (!branches)
583 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "branchWindows must be an array",
584 "branchWindows", {}, "climbing.codec"));
585 candidate.branchWindows.reserve(branches->size());
586 for (std::size_t index = 0; index < branches->size(); ++index) {
587 const auto* valueObject = (*branches)[index].getIf<eve::Value::Object>();
589 if (!valueObject || !readFloat(*valueObject, "start", window.start) ||
590 !readFloat(*valueObject, "end", window.end) ||
591 !readString(*valueObject, "comboTag", window.comboTag))
593 eve::DiagnosticCode::ParseError, "branch window has missing or invalid fields",
594 "branchWindows." + std::to_string(index), {}, "climbing.codec"));
595 candidate.branchWindows.push_back(std::move(window));
596 }
597 }
598 if (const eve::Value* contactsValue = field(object, "contactConstraints")) {
599 const auto* contacts = contactsValue->getIf<eve::Value::Array>();
600 if (!contacts)
602 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "contactConstraints must be an array",
603 "contactConstraints", {}, "climbing.codec"));
604 candidate.contactConstraints.reserve(contacts->size());
605 for (std::size_t index = 0; index < contacts->size(); ++index) {
606 const auto* valueObject = (*contacts)[index].getIf<eve::Value::Object>();
608 if (!valueObject ||
609 !readOptionalEnum(*valueObject, "target", contact.target,
610 static_cast<std::int64_t>(ClimbingContactTarget::Pelvis)) ||
611 !field(*valueObject, "target") || !readFloat(*valueObject, "start", contact.start) ||
612 !readFloat(*valueObject, "end", contact.end) ||
613 !readFloat(*valueObject, "maxWeight", contact.maxWeight))
615 eve::DiagnosticCode::ParseError, "contact constraint has missing or invalid fields",
616 "contactConstraints." + std::to_string(index), {}, "climbing.codec"));
617 candidate.contactConstraints.push_back(contact);
618 }
619 }
620 candidate.extensionMetadata = unknownFields(object, {"schemaId",
621 "schemaVersion",
622 "id",
623 "kind",
624 "minHeight",
625 "maxHeight",
626 "minSpeed",
627 "durationNs",
628 "landingForward",
629 "apexHeight",
630 "selectionBias",
631 "hangBodyOffset",
632 "hangFeetBelowLedge",
633 "handSpacing",
634 "cancelWindowStart",
635 "cancelWindowEnd",
636 "rootMotionScaleMin",
637 "rootMotionScaleMax",
638 "maxTranslationWarpPerTick",
639 "maxYawWarpRadiansPerTick",
640 "horizontalWarpBudget",
641 "verticalWarpBudget",
642 "facingWarpBudgetRadians",
643 "warpWindows",
644 "requiredNotifies",
645 "tags",
646 "sourceModes",
647 "requiredCommand",
648 "probeRecipe",
649 "minDepth",
650 "maxDepth",
651 "minDistance",
652 "maxDistance",
653 "minSurfaceNormalY",
654 "maxSlopeRadians",
655 "maxCurvature",
656 "requiredSupportTags",
657 "trajectory",
658 "animation",
659 "branchWindows",
660 "contactConstraints",
661 "landingPolicy",
662 "terminalVelocityPolicy",
663 "comboTags",
664 "repetitionPenalty",
665 "requiredConditionTags",
666 "staminaCost",
667 "cameraCue",
668 "eventMetadata"});
669 auto valid = validateClimbingActionDefinition(candidate);
671 return eve::Result<ClimbingActionDefinition>::success(std::move(candidate));
672}
673
676 if (!valid) return eve::Result<eve::Value>::failure(valid.status());
678 actions.reserve(profile.actions.size());
679 for (const ClimbingActionDefinition& action : profile.actions) {
681 if (!encoded) return eve::Result<eve::Value>::failure(encoded.status());
682 actions.push_back(std::move(encoded).takeValue());
683 }
684 eve::Value::Object filter{{"categoryBits", eve::Value(static_cast<std::int64_t>(profile.queryFilter.categoryBits))},
685 {"maskBits", eve::Value(static_cast<std::int64_t>(profile.queryFilter.maskBits))},
686 {"ignoredBodyId", eve::Value(profile.queryFilter.ignoredBodyId)},
687 {"ignoredShapeId", eve::Value(profile.queryFilter.ignoredShapeId)}};
688 eve::Value::Object object = profile.extensionMetadata;
689 object["schemaId"] = eve::Value(std::string(ClimbingProfileDefinition::SchemaId));
690 object["schemaVersion"] = eve::Value(ClimbingProfileDefinition::SchemaVersion);
691 object["capsuleRadius"] = eve::Value(profile.capsuleRadius);
692 object["capsuleHeight"] = eve::Value(profile.capsuleHeight);
693 object["compactCapsuleHeight"] = eve::Value(profile.compactCapsuleHeight);
694 object["skin"] = eve::Value(profile.skin);
695 object["maxProbeDistance"] = eve::Value(profile.maxProbeDistance);
696 object["maxObstacleHeight"] = eve::Value(profile.maxObstacleHeight);
697 object["minTopNormalY"] = eve::Value(profile.minTopNormalY);
698 object["maxWarpResidual"] = eve::Value(profile.maxWarpResidual);
699 object["maxPlatformSpeed"] = eve::Value(profile.maxPlatformSpeed);
700 object["dropInitialSpeed"] = eve::Value(profile.dropInitialSpeed);
701 object["inputBufferTicks"] = eve::Value(static_cast<std::int64_t>(profile.inputBufferTicks));
702 object["coyoteTicks"] = eve::Value(static_cast<std::int64_t>(profile.coyoteTicks));
703 object["pathValidationSegments"] = eve::Value(static_cast<std::int64_t>(profile.pathValidationSegments));
704 object["maxPelvisDeviation"] = eve::Value(profile.maxPelvisDeviation);
705 object["groundAcceleration"] = eve::Value(profile.groundAcceleration);
706 object["groundBraking"] = eve::Value(profile.groundBraking);
707 object["airControl"] = eve::Value(profile.airControl);
708 object["gravity"] = eve::Value(profile.gravity);
709 object["jumpSpeed"] = eve::Value(profile.jumpSpeed);
710 object["probeSectors"] = eve::Value(static_cast<std::int64_t>(profile.probeSectors));
711 object["maxCandidates"] = eve::Value(static_cast<std::int64_t>(profile.maxCandidates));
712 object["autoAssistStrength"] = eve::Value(profile.autoAssistStrength);
713 object["scoreWeights"] = eve::Value::object({{"direction", profile.scoreWeights.direction},
714 {"approachSpeed", profile.scoreWeights.approachSpeed},
715 {"height", profile.scoreWeights.height},
716 {"distance", profile.scoreWeights.distance},
717 {"warpTranslation", profile.scoreWeights.warpTranslation},
718 {"warpRotation", profile.scoreWeights.warpRotation},
719 {"intentMismatch", profile.scoreWeights.intentMismatch}});
720 object["maxTotalWarpBudget"] = eve::Value(profile.maxTotalWarpBudget);
721 object["defaultActionIds"] = stringArray(profile.defaultActionIds);
722 object["allowedActionTags"] = stringArray(profile.allowedActionTags);
723 object["deniedActionTags"] = stringArray(profile.deniedActionTags);
724 object["staminaPolicy"] = eve::Value(static_cast<std::int64_t>(profile.staminaPolicy));
725 object["staminaAdapter"] = eve::Value(profile.staminaAdapter);
726 object["cameraCueProfile"] = eve::Value(profile.cameraCueProfile);
727 object["queryFilter"] = eve::Value(std::move(filter));
728 object["actions"] = eve::Value(std::move(actions));
729 return eve::Result<eve::Value>::success(eve::Value(std::move(object)));
730}
731
735 const eve::Value::Object& object = *root.value();
737 const eve::Value* actionsValue = field(object, "actions");
738 const auto* actions = actionsValue ? actionsValue->getIf<eve::Value::Array>() : nullptr;
739 const eve::Value* filterValue = field(object, "queryFilter");
740 const auto* filter = filterValue ? filterValue->getIf<eve::Value::Object>() : nullptr;
741 std::int64_t categoryBits = 0;
742 std::int64_t maskBits = 0;
743 std::int64_t ignoredBodyId = 0;
744 std::int64_t ignoredShapeId = 0;
745 std::int64_t inputBufferTicks = 0;
746 std::int64_t coyoteTicks = 0;
747 std::int64_t pathValidationSegments = candidate.pathValidationSegments;
748 std::int64_t probeSectors = candidate.probeSectors;
749 std::int64_t maxCandidates = candidate.maxCandidates;
750 if (!readFloat(object, "capsuleRadius", candidate.capsuleRadius) ||
751 !readFloat(object, "capsuleHeight", candidate.capsuleHeight) ||
752 !readOptionalFloat(object, "compactCapsuleHeight", candidate.compactCapsuleHeight) ||
753 !readFloat(object, "skin", candidate.skin) ||
754 !readFloat(object, "maxProbeDistance", candidate.maxProbeDistance) ||
755 !readFloat(object, "maxObstacleHeight", candidate.maxObstacleHeight) ||
756 !readFloat(object, "minTopNormalY", candidate.minTopNormalY) ||
757 !readFloat(object, "maxWarpResidual", candidate.maxWarpResidual) ||
758 !readFloat(object, "maxPlatformSpeed", candidate.maxPlatformSpeed) ||
759 !readFloat(object, "dropInitialSpeed", candidate.dropInitialSpeed) ||
760 !readInt64(object, "inputBufferTicks", inputBufferTicks) || inputBufferTicks <= 0 ||
761 !readInt64(object, "coyoteTicks", coyoteTicks) || coyoteTicks < 0 ||
762 !readOptionalInt64(object, "pathValidationSegments", pathValidationSegments) || pathValidationSegments < 0 ||
763 pathValidationSegments > std::numeric_limits<std::uint32_t>::max() ||
764 !readOptionalFloat(object, "maxPelvisDeviation", candidate.maxPelvisDeviation) ||
765 !readOptionalFloat(object, "groundAcceleration", candidate.groundAcceleration) ||
766 !readOptionalFloat(object, "groundBraking", candidate.groundBraking) ||
767 !readOptionalFloat(object, "airControl", candidate.airControl) ||
768 !readOptionalFloat(object, "gravity", candidate.gravity) ||
769 !readOptionalFloat(object, "jumpSpeed", candidate.jumpSpeed) ||
770 !readOptionalInt64(object, "probeSectors", probeSectors) || probeSectors < 0 ||
771 probeSectors > std::numeric_limits<std::uint32_t>::max() ||
772 !readOptionalInt64(object, "maxCandidates", maxCandidates) || maxCandidates < 0 ||
773 maxCandidates > std::numeric_limits<std::uint32_t>::max() ||
774 !readOptionalFloat(object, "autoAssistStrength", candidate.autoAssistStrength) ||
775 !readOptionalFloat(object, "maxTotalWarpBudget", candidate.maxTotalWarpBudget) ||
776 !readOptionalStringArray(object, "defaultActionIds", candidate.defaultActionIds) ||
777 !readOptionalStringArray(object, "allowedActionTags", candidate.allowedActionTags) ||
778 !readOptionalStringArray(object, "deniedActionTags", candidate.deniedActionTags) ||
779 !readOptionalEnum(object, "staminaPolicy", candidate.staminaPolicy,
780 static_cast<std::int64_t>(ClimbingStaminaPolicy::UseWhenPresent)) ||
781 !readOptionalString(object, "staminaAdapter", candidate.staminaAdapter) ||
782 !readOptionalString(object, "cameraCueProfile", candidate.cameraCueProfile) || !actions || !filter ||
783 !readInt64(*filter, "categoryBits", categoryBits) || !readInt64(*filter, "maskBits", maskBits) ||
784 categoryBits < 0 || categoryBits > std::numeric_limits<std::uint32_t>::max() || maskBits < 0 ||
785 maskBits > std::numeric_limits<std::uint32_t>::max() || !readInt64(*filter, "ignoredBodyId", ignoredBodyId) ||
786 ignoredBodyId < std::numeric_limits<int>::min() || ignoredBodyId > std::numeric_limits<int>::max() ||
787 !readInt64(*filter, "ignoredShapeId", ignoredShapeId) || ignoredShapeId < std::numeric_limits<int>::min() ||
788 ignoredShapeId > std::numeric_limits<int>::max())
791 "climbing profile has missing or invalid known fields", {}, {}, "climbing.codec"));
792 candidate.queryFilter.categoryBits = static_cast<std::uint32_t>(categoryBits);
793 candidate.queryFilter.maskBits = static_cast<std::uint32_t>(maskBits);
794 candidate.queryFilter.ignoredBodyId = static_cast<int>(ignoredBodyId);
795 candidate.queryFilter.ignoredShapeId = static_cast<int>(ignoredShapeId);
796 candidate.inputBufferTicks = static_cast<std::uint64_t>(inputBufferTicks);
797 candidate.coyoteTicks = static_cast<std::uint64_t>(coyoteTicks);
798 candidate.pathValidationSegments = static_cast<std::uint32_t>(pathValidationSegments);
799 candidate.probeSectors = static_cast<std::uint32_t>(probeSectors);
800 candidate.maxCandidates = static_cast<std::uint32_t>(maxCandidates);
801 if (const eve::Value* weightsValue = field(object, "scoreWeights")) {
802 const auto* weights = weightsValue->getIf<eve::Value::Object>();
803 std::int64_t direction = 0, approachSpeed = 0, height = 0, distance = 0;
804 std::int64_t warpTranslation = 0, warpRotation = 0, intentMismatch = 0;
805 if (!weights || !readInt64(*weights, "direction", direction) ||
806 !readInt64(*weights, "approachSpeed", approachSpeed) || !readInt64(*weights, "height", height) ||
807 !readInt64(*weights, "distance", distance) ||
808 !readInt64(*weights, "warpTranslation", warpTranslation) ||
809 !readInt64(*weights, "warpRotation", warpRotation) ||
810 !readInt64(*weights, "intentMismatch", intentMismatch))
812 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "scoreWeights has missing or invalid fields",
813 "scoreWeights", {}, "climbing.codec"));
814 const auto inRange = [](std::int64_t value) {
815 return value >= std::numeric_limits<std::int32_t>::min() &&
816 value <= std::numeric_limits<std::int32_t>::max();
817 };
818 if (!inRange(direction) || !inRange(approachSpeed) || !inRange(height) || !inRange(distance) ||
819 !inRange(warpTranslation) || !inRange(warpRotation) || !inRange(intentMismatch))
821 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "scoreWeights exceeds int32 range",
822 "scoreWeights", {}, "climbing.codec"));
823 candidate.scoreWeights = {static_cast<std::int32_t>(direction),
824 static_cast<std::int32_t>(approachSpeed),
825 static_cast<std::int32_t>(height),
826 static_cast<std::int32_t>(distance),
827 static_cast<std::int32_t>(warpTranslation),
828 static_cast<std::int32_t>(warpRotation),
829 static_cast<std::int32_t>(intentMismatch)};
830 }
831 candidate.actions.reserve(actions->size());
832 for (std::size_t index = 0; index < actions->size(); ++index) {
833 auto decoded = decodeClimbingActionDefinition((*actions)[index]);
834 if (!decoded)
836 decoded.error()->code(), decoded.error()->message(),
837 "actions." + std::to_string(index) + "." + decoded.error()->path(), {}, "climbing.codec"));
838 candidate.actions.push_back(std::move(decoded).takeValue());
839 }
840 candidate.extensionMetadata =
841 unknownFields(object, {"schemaId", "schemaVersion", "capsuleRadius", "capsuleHeight",
842 "compactCapsuleHeight", "skin",
843 "maxProbeDistance", "maxObstacleHeight", "minTopNormalY", "maxWarpResidual",
844 "maxPlatformSpeed", "dropInitialSpeed", "inputBufferTicks", "coyoteTicks",
845 "pathValidationSegments", "maxPelvisDeviation", "groundAcceleration",
846 "groundBraking", "airControl", "gravity", "jumpSpeed", "probeSectors",
847 "maxCandidates", "autoAssistStrength", "scoreWeights", "maxTotalWarpBudget",
848 "defaultActionIds", "allowedActionTags", "deniedActionTags", "staminaPolicy",
849 "staminaAdapter", "cameraCueProfile", "queryFilter", "actions"});
852 return eve::Result<ClimbingProfileDefinition>::success(std::move(candidate));
853}
854
855} // namespace eve::climbing
int root
Definition AnimSmr.cpp:119
std::string output
Versioned, lossless codecs for climbing definitions.
std::string name
Definition ECS.cpp:154
std::uint32_t height
Poco::JSON::Object::Ptr result
bool valid
float distance
bool finite
std::string action
Definition PlayHost.cpp:118
std::vector< ActionSpec > actions
Definition PlayHost.cpp:127
std::set< std::string > values
Object::Ptr value
RoadLaneDirection direction
bool found
std::string filter
std::string text
std::string kind
float weights[3]
Json object
uint32_t index
Contact contact
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
static constexpr Duration fromNanoseconds(std::int64_t nanoseconds) noexcept
Construct an exact duration from nanoseconds.
Definition Time.h:55
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
std::map< std::string, Value > Object
Definition Value.h:34
std::vector< Value > Array
Definition Value.h:33
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:209
static Value object(Object value)
Compatibility factory for an object value.
Definition Value.cpp:129
std::unordered_map< const void *, size_t > ids
Definition Snapshot.cpp:109
Result< float > readFloat(const Accessor &accessor, std::uint32_t element, std::uint32_t component)
Read one bounded finite FLOAT component.
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
Value stringArray(const std::vector< std::string > &values)
eve::Result< ClimbingActionDefinition > decodeClimbingActionDefinition(const eve::Value &value)
Decode and validate one action without partially mutating a registry.
eve::Result< eve::Value > encodeClimbingProfileDefinition(const ClimbingProfileDefinition &profile)
Encode one validated profile and all nested actions into canonical schema v4 data.
eve::Result< ClimbingProfileDefinition > decodeClimbingProfileDefinition(const eve::Value &value)
Decode and validate an owning profile candidate transactionally.
eve::Result< eve::Value > encodeClimbingActionDefinition(const ClimbingActionDefinition &action)
Encode one validated action into canonical schema v4 data.
eve::Result< void > validateClimbingActionDefinition(const ClimbingActionDefinition &action)
Validate every known field of one action definition.
ClimbingActionKind
Data-driven action family; stable action identity remains the definition id.
Definition Climbing.h:46
eve::Result< void > validateClimbingProfileDefinition(const ClimbingProfileDefinition &profile)
Validate every known field and nested action of one profile definition.
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:27
bool readString(const eve::Value::Object &object, const char *name, std::string &output)
Result< std::int64_t > readInt64(const Value::Object &object, std::string_view name)
Reads a required signed decimal integer string.
Result< bool > readBool(const Value::Object &object, std::string_view name)
Reads a required boolean.
WidgetDesc window(std::string title, std::vector< WidgetDesc > children, std::string id)
Top-level window widget with a title bar.
Definition Widget.cpp:326
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
Result< float > readFiniteFloatValue(const Value &value)
Convert an Integer or Double to a finite Float after validating its source range.
Definition Value.cpp:81
Result< bool > readBoolValue(const Value &value)
Read a Bool without coercing integers, strings or other kinds.
Definition Value.cpp:50
Result< std::string > readStringMember(const Value::Object &object, std::string_view name)
Read a required string field, including an empty string, as an owning value.
Definition Value.cpp:25
Result< std::int64_t > readInt64Value(const Value &value)
Read an Int64 without narrowing or numeric coercion.
Definition Value.cpp:57
Definition of one geometry-compatible climbing action.
Definition Climbing.h:160
ClimbingCommandRequirement requiredCommand
Definition Climbing.h:191
ClimbingTrajectoryKind trajectory
Definition Climbing.h:201
std::vector< ClimbingContactConstraint > contactConstraints
Definition Climbing.h:204
std::vector< ClimbingBranchWindow > branchWindows
Definition Climbing.h:203
static constexpr std::int64_t SchemaVersion
Current action schema version.
Definition Climbing.h:164
ClimbingAnimationBinding animation
Definition Climbing.h:202
std::vector< std::string > requiredSupportTags
Definition Climbing.h:200
eve::Value::Object extensionMetadata
Unknown schema fields retained across decode and encode.
Definition Climbing.h:214
ClimbingTerminalVelocityPolicy terminalVelocityPolicy
Definition Climbing.h:206
std::vector< std::string > tags
Definition Climbing.h:189
std::vector< std::string > requiredConditionTags
Definition Climbing.h:209
std::vector< std::string > comboTags
Definition Climbing.h:207
std::vector< std::string > requiredNotifies
Definition Climbing.h:188
std::vector< std::string > eventMetadata
Definition Climbing.h:212
std::vector< ClimbingWarpWindow > warpWindows
Definition Climbing.h:187
static constexpr std::string_view SchemaId
Schema id emitted by the canonical action codec.
Definition Climbing.h:162
ClimbingLandingPolicy landingPolicy
Definition Climbing.h:205
Normalized branch interval advertising one stable combo tag.
Definition Climbing.h:108
Normalized contact interval and maximum constraint weight.
Definition Climbing.h:118
Runtime profile controlling capsule geometry and probe limits.
Definition Climbing.h:218
static constexpr std::string_view SchemaId
Schema id emitted by the canonical profile codec.
Definition Climbing.h:220
std::vector< std::string > deniedActionTags
Definition Climbing.h:250
eve::Value::Object extensionMetadata
Unknown schema fields retained across decode and encode.
Definition Climbing.h:257
std::vector< std::string > defaultActionIds
Definition Climbing.h:248
physics::QueryFilter3D queryFilter
Definition Climbing.h:254
static constexpr std::int64_t SchemaVersion
Current profile schema version.
Definition Climbing.h:222
std::vector< ClimbingActionDefinition > actions
Definition Climbing.h:255
std::vector< std::string > allowedActionTags
Definition Climbing.h:249
ClimbingStaminaPolicy staminaPolicy
Definition Climbing.h:251
Quantized selection-cost weights stored with a profile.
Definition Climbing.h:126
Normalized action interval selecting which motion-warp channels may correct authored motion.
Definition Climbing.h:151