Skip to content

Commit

Permalink
resource: add optional transform name
Browse files Browse the repository at this point in the history
Will become useful when introducing animation skeletons in later commits.

Part-of: crownengine#276
  • Loading branch information
dbartolini committed Feb 20, 2025
1 parent 9743245 commit e81b8dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/resource/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct Platform
#define RESOURCE_VERSION_STATE_MACHINE RESOURCE_VERSION(6)
#define RESOURCE_VERSION_CONFIG RESOURCE_VERSION(1)
#define RESOURCE_VERSION_FONT RESOURCE_VERSION(1)
#define RESOURCE_VERSION_UNIT RESOURCE_VERSION(11)
#define RESOURCE_VERSION_UNIT RESOURCE_VERSION(12)
#define RESOURCE_VERSION_LEVEL (RESOURCE_VERSION_UNIT + 4) //!< Level embeds UnitResource
#define RESOURCE_VERSION_MATERIAL RESOURCE_VERSION(6)
#define RESOURCE_VERSION_MESH RESOURCE_VERSION(6)
Expand Down
3 changes: 3 additions & 0 deletions src/resource/unit_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,15 @@ static s32 compile_transform(Buffer &output, const char *json, CompileOptions &o
td.position = RETURN_IF_ERROR(sjson::parse_vector3 (obj["position"]), opts);
td.rotation = RETURN_IF_ERROR(sjson::parse_quaternion(obj["rotation"]), opts);
td.scale = RETURN_IF_ERROR(sjson::parse_vector3 (obj["scale"]), opts);
if (json_object::has(obj, "name"))
td.name = RETURN_IF_ERROR(sjson::parse_string_id(obj["name"]), opts);

FileBuffer fb(output);
BinaryWriter bw(fb);
bw.write(td.position);
bw.write(td.rotation);
bw.write(td.scale);
bw.write(td.name);
return 0;
}

Expand Down
1 change: 1 addition & 0 deletions src/world/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ struct TransformDesc
Vector3 position;
Quaternion rotation;
Vector3 scale;
StringId32 name;
};

/// Camera description.
Expand Down

0 comments on commit e81b8dd

Please sign in to comment.