| 658 | namespace physics_config_resource_internal |
| 659 | { |
| 660 | s32 parse_materials(const char *json, Array<PhysicsMaterial> &objects, CompileOptions &opts) |
| 661 | { |
| 662 | CE_UNUSED(opts); |
| 663 | |
| 664 | TempAllocator4096 ta; |
| 665 | JsonObject obj(ta); |
| 666 | RETURN_IF_ERROR(sjson::parse(obj, json)); |
| 667 | |
| 668 | auto cur = json_object::begin(obj); |
| 669 | auto end = json_object::end(obj); |
| 670 | for (; cur != end; ++cur) { |
| 671 | JSON_OBJECT_SKIP_HOLE(obj, cur); |
| 672 | |
| 673 | const StringView key = cur->first; |
| 674 | const char *value = cur->second; |
| 675 | |
| 676 | JsonObject material(ta); |
| 677 | RETURN_IF_ERROR(sjson::parse_object(material, value)); |
| 678 | |
| 679 | PhysicsMaterial mat; |
| 680 | mat.name = StringId32(key.data(), key.length()); |
| 681 | mat.friction = RETURN_IF_ERROR(sjson::parse_float(material["friction"])); |
| 682 | mat.rolling_friction = RETURN_IF_ERROR(sjson::parse_float(material["rolling_friction"])); |
| 683 | mat.restitution = RETURN_IF_ERROR(sjson::parse_float(material["restitution"])); |
| 684 | if (json_object::has(material, "spinning_friction")) { |
| 685 | mat.spinning_friction = RETURN_IF_ERROR(sjson::parse_float(material["spinning_friction"])); |
| 686 | } else { |
| 687 | mat.spinning_friction = 0.5f; |
| 688 | } |
| 689 | |
| 690 | array::push_back(objects, mat); |
| 691 | } |
| 692 | |
| 693 | return 0; |
| 694 | } |
| 695 | |
| 696 | s32 parse_actors(const char *json, Array<PhysicsActor> &objects, CompileOptions &opts) |
| 697 | { |
no test coverage detected