Переглянути джерело

resource: move resource access functions to .inl files

Daniele Bartolini 3 тижнів тому
батько
коміт
104f519f97
35 змінених файлів з 515 додано та 383 видалено
  1. 1 1
      src/lua/lua_environment.cpp
  2. 3 20
      src/resource/font_resource.cpp
  3. 28 0
      src/resource/font_resource.inl
  4. 4 28
      src/resource/level_resource.cpp
  5. 36 0
      src/resource/level_resource.inl
  6. 3 11
      src/resource/lua_resource.cpp
  7. 19 0
      src/resource/lua_resource.inl
  8. 0 56
      src/resource/material_resource.cpp
  9. 66 0
      src/resource/material_resource.inl
  10. 4 16
      src/resource/mesh_animation_resource.cpp
  11. 24 0
      src/resource/mesh_animation_resource.inl
  12. 4 21
      src/resource/mesh_skeleton_resource.cpp
  13. 29 0
      src/resource/mesh_skeleton_resource.inl
  14. 3 18
      src/resource/package_resource.cpp
  15. 27 0
      src/resource/package_resource.inl
  16. 3 54
      src/resource/physics_resource.cpp
  17. 62 0
      src/resource/physics_resource.inl
  18. 1 1
      src/resource/resource_package.cpp
  19. 3 16
      src/resource/sound_resource.cpp
  20. 24 0
      src/resource/sound_resource.inl
  21. 0 21
      src/resource/sprite_resource.cpp
  22. 29 0
      src/resource/sprite_resource.inl
  23. 0 84
      src/resource/state_machine_resource.cpp
  24. 94 0
      src/resource/state_machine_resource.inl
  25. 0 28
      src/resource/unit_resource.cpp
  26. 38 0
      src/resource/unit_resource.inl
  27. 2 1
      src/world/animation_state_machine.cpp
  28. 1 1
      src/world/gui.cpp
  29. 1 1
      src/world/level.cpp
  30. 1 1
      src/world/material_manager.cpp
  31. 1 0
      src/world/mesh_animation_player.cpp
  32. 1 1
      src/world/physics_world_bullet.cpp
  33. 1 1
      src/world/render_world.cpp
  34. 1 1
      src/world/sound_world_al.cpp
  35. 1 1
      src/world/world.cpp

+ 1 - 1
src/lua/lua_environment.cpp

@@ -15,7 +15,7 @@
 #include "device/log.h"
 #include "lua/lua_environment.h"
 #include "lua/lua_stack.inl"
-#include "resource/lua_resource.h"
+#include "resource/lua_resource.inl"
 #include "resource/resource_manager.h"
 #include <stdarg.h>
 

+ 3 - 20
src/resource/font_resource.cpp

@@ -4,6 +4,8 @@
  */
 
 #include "config.h"
+
+#if CROWN_CAN_COMPILE
 #include "core/containers/array.inl"
 #include "core/filesystem/file.h"
 #include "core/filesystem/filesystem.h"
@@ -19,25 +21,6 @@
 
 namespace crown
 {
-namespace font_resource
-{
-	const GlyphData *glyph(const FontResource *fr, CodePoint cp, const GlyphData *deffault)
-	{
-		const CodePoint *codes  = (CodePoint *)&fr[1];
-		const GlyphData *glyphs = (GlyphData *)(codes + fr->num_glyphs);
-
-		// FIXME: Can do binary search
-		for (u32 i = 0; i < fr->num_glyphs; ++i) {
-			if (codes[i] == cp)
-				return &glyphs[i];
-		}
-
-		return deffault;
-	}
-
-} // namespace font_resource
-
-#if CROWN_CAN_COMPILE
 namespace font_resource_internal
 {
 	struct GlyphInfo
@@ -120,6 +103,6 @@ namespace font_resource_internal
 	}
 
 } // namespace font_resource_internal
-#endif // if CROWN_CAN_COMPILE
 
 } // namespace crown
+#endif // if CROWN_CAN_COMPILE

+ 28 - 0
src/resource/font_resource.inl

@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/font_resource.h"
+
+namespace crown
+{
+namespace font_resource
+{
+	const GlyphData *glyph(const FontResource *fr, CodePoint cp, const GlyphData *deffault)
+	{
+		const CodePoint *codes  = (CodePoint *)&fr[1];
+		const GlyphData *glyphs = (GlyphData *)(codes + fr->num_glyphs);
+
+		// FIXME: Can do binary search
+		for (u32 i = 0; i < fr->num_glyphs; ++i) {
+			if (codes[i] == cp)
+				return &glyphs[i];
+		}
+
+		return deffault;
+	}
+
+} // namespace font_resource
+
+} // namespace crown

+ 4 - 28
src/resource/level_resource.cpp

@@ -3,6 +3,9 @@
  * SPDX-License-Identifier: MIT
  */
 
+#include "config.h"
+
+#if CROWN_CAN_COMPILE
 #include "core/containers/array.inl"
 #include "core/filesystem/file.h"
 #include "core/filesystem/filesystem.h"
@@ -18,33 +21,6 @@
 
 namespace crown
 {
-namespace level_resource
-{
-	const StringId32 *unit_names(const LevelResource *lr)
-	{
-		return (StringId32 *)((char *)lr + lr->unit_names_offset);
-	}
-
-	const UnitResource *unit_resource(const LevelResource *lr)
-	{
-		return (UnitResource *)((char *)lr + lr->units_offset);
-	}
-
-	u32 num_sounds(const LevelResource *lr)
-	{
-		return lr->num_sounds;
-	}
-
-	const LevelSound *get_sound(const LevelResource *lr, u32 i)
-	{
-		CE_ASSERT(i < num_sounds(lr), "Index out of bounds");
-		const LevelSound *begin = (LevelSound *)((char *)lr + lr->sounds_offset);
-		return &begin[i];
-	}
-
-} // namespace level_resource
-
-#if CROWN_CAN_COMPILE
 namespace level_resource_internal
 {
 	s32 compile(CompileOptions &opts)
@@ -155,6 +131,6 @@ namespace level_resource_internal
 	}
 
 } // namespace level_resource_internal
-#endif // if CROWN_CAN_COMPILE
 
 } // namespace crown
+#endif // if CROWN_CAN_COMPILE

+ 36 - 0
src/resource/level_resource.inl

@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/level_resource.h"
+
+namespace crown
+{
+namespace level_resource
+{
+	const StringId32 *unit_names(const LevelResource *lr)
+	{
+		return (StringId32 *)((char *)lr + lr->unit_names_offset);
+	}
+
+	const UnitResource *unit_resource(const LevelResource *lr)
+	{
+		return (UnitResource *)((char *)lr + lr->units_offset);
+	}
+
+	u32 num_sounds(const LevelResource *lr)
+	{
+		return lr->num_sounds;
+	}
+
+	const LevelSound *get_sound(const LevelResource *lr, u32 i)
+	{
+		CE_ASSERT(i < num_sounds(lr), "Index out of bounds");
+		const LevelSound *begin = (LevelSound *)((char *)lr + lr->sounds_offset);
+		return &begin[i];
+	}
+
+} // namespace level_resource
+
+} // namespace crown

+ 3 - 11
src/resource/lua_resource.cpp

@@ -4,6 +4,8 @@
  */
 
 #include "config.h"
+
+#if CROWN_CAN_COMPILE
 #include "core/containers/array.inl"
 #include "core/containers/hash_set.inl"
 #include "core/filesystem/file.h"
@@ -17,16 +19,6 @@
 
 namespace crown
 {
-namespace lua_resource
-{
-	const char *program(const LuaResource *lr)
-	{
-		return (char *)&lr[1];
-	}
-
-} // namespace lua_resource
-
-#if CROWN_CAN_COMPILE
 namespace lua_resource_internal
 {
 	static const char *skip_blanks(const char *lua)
@@ -180,6 +172,6 @@ namespace lua_resource_internal
 	}
 
 } // namespace lua_resource_internal
-#endif // if CROWN_CAN_COMPILE
 
 } // namespace crown
+#endif // if CROWN_CAN_COMPILE

+ 19 - 0
src/resource/lua_resource.inl

@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/lua_resource.h"
+
+namespace crown
+{
+namespace lua_resource
+{
+	const char *program(const LuaResource *lr)
+	{
+		return (char *)&lr[1];
+	}
+
+} // namespace lua_resource
+
+} // namespace crown

+ 0 - 56
src/resource/material_resource.cpp

@@ -22,62 +22,6 @@
 
 namespace crown
 {
-namespace material_resource
-{
-	UniformData *uniform_data_array(const MaterialResource *mr)
-	{
-		return (UniformData *)((char *)mr + mr->uniform_data_offset);
-	}
-
-	u32 uniform_data_index(const MaterialResource *mr, const UniformData *ud, StringId32 name)
-	{
-		for (u32 i = 0, n = mr->num_uniforms; i < n; ++i) {
-			if (ud[i].name == name)
-				return i;
-		}
-
-		CE_FATAL("Unknown uniform name");
-		return UINT32_MAX;
-	}
-
-	const char *uniform_name(const MaterialResource *mr, const UniformData *ud, u32 i)
-	{
-		return (char *)mr + mr->names_data_offset + ud[i].name_offset;
-	}
-
-	TextureData *texture_data_array(const MaterialResource *mr)
-	{
-		return (TextureData *)((char *)mr + mr->texture_data_offset);
-	}
-
-	u32 texture_data_index(const MaterialResource *mr, const TextureData *td, StringId32 name)
-	{
-		for (u32 i = 0, n = mr->num_textures; i < n; ++i) {
-			if (td[i].name == name)
-				return i;
-		}
-
-		CE_FATAL("Unknown texture name");
-		return UINT32_MAX;
-	}
-
-	const char *texture_name(const MaterialResource *mr, const TextureData *td, u32 i)
-	{
-		return (char *)mr + mr->names_data_offset + td[i].sampler_name_offset;
-	}
-
-	UniformHandle *uniform_handle(const UniformData *ud, u32 i, char *dynamic)
-	{
-		return (UniformHandle *)(dynamic + ud[i].data_offset);
-	}
-
-	TextureHandle *texture_handle(const TextureData *td, u32 i, char *dynamic)
-	{
-		return (TextureHandle *)(dynamic + td[i].data_offset);
-	}
-
-} // namespace material_resource
-
 namespace material_resource_internal
 {
 	void online(StringId64 id, ResourceManager &rm)

+ 66 - 0
src/resource/material_resource.inl

@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/material_resource.h"
+
+namespace crown
+{
+namespace material_resource
+{
+	UniformData *uniform_data_array(const MaterialResource *mr)
+	{
+		return (UniformData *)((char *)mr + mr->uniform_data_offset);
+	}
+
+	u32 uniform_data_index(const MaterialResource *mr, const UniformData *ud, StringId32 name)
+	{
+		for (u32 i = 0, n = mr->num_uniforms; i < n; ++i) {
+			if (ud[i].name == name)
+				return i;
+		}
+
+		CE_FATAL("Unknown uniform name");
+		return UINT32_MAX;
+	}
+
+	const char *uniform_name(const MaterialResource *mr, const UniformData *ud, u32 i)
+	{
+		return (char *)mr + mr->names_data_offset + ud[i].name_offset;
+	}
+
+	TextureData *texture_data_array(const MaterialResource *mr)
+	{
+		return (TextureData *)((char *)mr + mr->texture_data_offset);
+	}
+
+	u32 texture_data_index(const MaterialResource *mr, const TextureData *td, StringId32 name)
+	{
+		for (u32 i = 0, n = mr->num_textures; i < n; ++i) {
+			if (td[i].name == name)
+				return i;
+		}
+
+		CE_FATAL("Unknown texture name");
+		return UINT32_MAX;
+	}
+
+	const char *texture_name(const MaterialResource *mr, const TextureData *td, u32 i)
+	{
+		return (char *)mr + mr->names_data_offset + td[i].sampler_name_offset;
+	}
+
+	UniformHandle *uniform_handle(const UniformData *ud, u32 i, char *dynamic)
+	{
+		return (UniformHandle *)(dynamic + ud[i].data_offset);
+	}
+
+	TextureHandle *texture_handle(const TextureData *td, u32 i, char *dynamic)
+	{
+		return (TextureHandle *)(dynamic + td[i].data_offset);
+	}
+
+} // namespace material_resource
+
+} // namespace crown

+ 4 - 16
src/resource/mesh_animation_resource.cpp

@@ -3,6 +3,9 @@
  * SPDX-License-Identifier: MIT
  */
 
+#include "config.h"
+
+#if CROWN_CAN_COMPILE
 #include "resource/mesh_animation_resource.h"
 #include "core/json/json_object.inl"
 #include "core/json/sjson.h"
@@ -15,7 +18,6 @@
 
 namespace crown
 {
-#if CROWN_CAN_COMPILE
 namespace mesh_animation_resource_internal
 {
 	static s32 write(MeshAnimation &ma, CompileOptions &opts)
@@ -61,20 +63,6 @@ namespace mesh_animation_resource_internal
 	}
 
 } // namespace mesh_animation_resource_internal
-#endif // if CROWN_CAN_COMPILE
-
-namespace mesh_animation_resource
-{
-	const AnimationKey *animation_keys(const MeshAnimationResource *mar)
-	{
-		return (AnimationKey *)((char *)mar + mar->keys_offset);
-	}
-
-	const u16 *bone_ids(const MeshAnimationResource *mar)
-	{
-		return (u16 *)((char *)mar + mar->bone_ids_offset);
-	}
-
-} // namespace mesh_animation_resource
 
 } // namespace crown
+#endif // if CROWN_CAN_COMPILE

+ 24 - 0
src/resource/mesh_animation_resource.inl

@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/mesh_animation_resource.h"
+
+namespace crown
+{
+namespace mesh_animation_resource
+{
+	const AnimationKey *animation_keys(const MeshAnimationResource *mar)
+	{
+		return (AnimationKey *)((char *)mar + mar->keys_offset);
+	}
+
+	const u16 *bone_ids(const MeshAnimationResource *mar)
+	{
+		return (u16 *)((char *)mar + mar->bone_ids_offset);
+	}
+
+} // namespace mesh_animation_resource
+
+} // namespace crown

+ 4 - 21
src/resource/mesh_skeleton_resource.cpp

@@ -3,6 +3,9 @@
  * SPDX-License-Identifier: MIT
  */
 
+#include "config.h"
+
+#if CROWN_CAN_COMPILE
 #include "resource/mesh_skeleton_resource.h"
 #include "core/containers/array.inl"
 #include "core/json/json_object.inl"
@@ -13,7 +16,6 @@
 
 namespace crown
 {
-#if CROWN_CAN_COMPILE
 namespace mesh_skeleton_resource_internal
 {
 	s32 write(AnimationSkeleton &s, CompileOptions &opts)
@@ -52,25 +54,6 @@ namespace mesh_skeleton_resource_internal
 	}
 
 } // namespace mesh_skeleton_resource_internal
-#endif // if CROWN_CAN_COMPILE
-
-namespace mesh_skeleton_resource
-{
-	const BoneTransform *local_transforms(const MeshSkeletonResource *asr)
-	{
-		return (BoneTransform *)((char *)asr + asr->local_transforms_offset);
-	}
-
-	const u32 *parents(const MeshSkeletonResource *asr)
-	{
-		return (u32 *)((char *)asr + asr->parents_offset);
-	}
-
-	const Matrix4x4 *binding_matrices(const MeshSkeletonResource *asr)
-	{
-		return (Matrix4x4 *)((char *)asr + asr->binding_matrices_offset);
-	}
-
-} // namespace mesh_skeleton_resource
 
 } // namespace crown
+#endif // if CROWN_CAN_COMPILE

+ 29 - 0
src/resource/mesh_skeleton_resource.inl

@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/mesh_skeleton_resource.h"
+
+namespace crown
+{
+namespace mesh_skeleton_resource
+{
+	const BoneTransform *local_transforms(const MeshSkeletonResource *asr)
+	{
+		return (BoneTransform *)((char *)asr + asr->local_transforms_offset);
+	}
+
+	const u32 *parents(const MeshSkeletonResource *asr)
+	{
+		return (u32 *)((char *)asr + asr->parents_offset);
+	}
+
+	const Matrix4x4 *binding_matrices(const MeshSkeletonResource *asr)
+	{
+		return (Matrix4x4 *)((char *)asr + asr->binding_matrices_offset);
+	}
+
+} // namespace mesh_skeleton_resource
+
+} // namespace crown

+ 3 - 18
src/resource/package_resource.cpp

@@ -4,6 +4,8 @@
  */
 
 #include "config.h"
+
+#if CROWN_CAN_COMPILE
 #include "core/containers/array.inl"
 #include "core/containers/hash_map.inl"
 #include "core/containers/hash_set.inl"
@@ -44,7 +46,6 @@ bool operator==(const ResourceOffset &a, const ResourceOffset &b)
 		;
 }
 
-#if CROWN_CAN_COMPILE
 namespace package_resource_internal
 {
 	s32 bring_in_requirements(HashSet<ResourceOffset> &output
@@ -308,22 +309,6 @@ namespace package_resource_internal
 	}
 
 } // namespace package_resource_internal
-#endif // if CROWN_CAN_COMPILE
-
-namespace package_resource
-{
-	const ResourceOffset *resource_offset(const PackageResource *pr, u32 index)
-	{
-		const ResourceOffset *ro = (ResourceOffset *)(pr + 1);
-		return ro + index;
-	}
-
-	const u8 *data(const PackageResource *pr)
-	{
-		const u8 *data_offset = (u8 *)resource_offset(pr, pr->num_resources);
-		return (u8 *)memory::align_top(data_offset, 16);
-	}
-
-} // namespace package_resource
 
 } // namespace crown
+#endif // if CROWN_CAN_COMPILE

+ 27 - 0
src/resource/package_resource.inl

@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "core/memory/memory.inl"
+#include "resource/package_resource.h"
+
+namespace crown
+{
+namespace package_resource
+{
+	const ResourceOffset *resource_offset(const PackageResource *pr, u32 index)
+	{
+		const ResourceOffset *ro = (ResourceOffset *)(pr + 1);
+		return ro + index;
+	}
+
+	const u8 *data(const PackageResource *pr)
+	{
+		const u8 *data_offset = (u8 *)resource_offset(pr, pr->num_resources);
+		return (u8 *)memory::align_top(data_offset, 16);
+	}
+
+} // namespace package_resource
+
+} // namespace crown

+ 3 - 54
src/resource/physics_resource.cpp

@@ -4,6 +4,8 @@
  */
 
 #include "config.h"
+
+#if CROWN_CAN_COMPILE
 #include "core/containers/array.inl"
 #include "core/containers/hash_map.inl"
 #include "core/filesystem/file.h"
@@ -27,59 +29,6 @@
 
 namespace crown
 {
-namespace physics_config_resource
-{
-	const PhysicsMaterial *materials_array(const PhysicsConfigResource *pcr)
-	{
-		return (const PhysicsMaterial *)((char *)pcr + pcr->materials_offset);
-	}
-
-	u32 material_index(const PhysicsMaterial *materials, u32 num, StringId32 name)
-	{
-		for (u32 i = 0; i < num; ++i) {
-			if (materials[i].name == name)
-				return i;
-		}
-
-		CE_FATAL("Material not found");
-		return UINT32_MAX;
-	}
-
-	const PhysicsActor *actors_array(const PhysicsConfigResource *pcr)
-	{
-		return (const PhysicsActor *)((char *)pcr + pcr->actors_offset);
-	}
-
-	u32 actor_index(const PhysicsActor *actors, u32 num, StringId32 name)
-	{
-		for (u32 i = 0; i < num; ++i) {
-			if (actors[i].name == name)
-				return i;
-		}
-
-		CE_FATAL("Actor not found");
-		return UINT32_MAX;
-	}
-
-	const PhysicsCollisionFilter *filters_array(const PhysicsConfigResource *pcr)
-	{
-		return (const PhysicsCollisionFilter *)((char *)pcr + pcr->filters_offset);
-	}
-
-	u32 filter_index(const PhysicsCollisionFilter *filters, u32 num, StringId32 name)
-	{
-		for (u32 i = 0; i < num; ++i) {
-			if (filters[i].name == name)
-				return i;
-		}
-
-		CE_FATAL("Filter not found");
-		return UINT32_MAX;
-	}
-
-} // namespace physics_config_resource
-
-#if CROWN_CAN_COMPILE
 namespace physics_resource_internal
 {
 	struct ColliderInfo
@@ -697,6 +646,6 @@ namespace physics_config_resource_internal
 	}
 
 } // namespace physics_config_resource_internal
-#endif // if CROWN_CAN_COMPILE
 
 } // namespace crown
+#endif // if CROWN_CAN_COMPILE

+ 62 - 0
src/resource/physics_resource.inl

@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/physics_resource.h"
+
+namespace crown
+{
+namespace physics_config_resource
+{
+	const PhysicsMaterial *materials_array(const PhysicsConfigResource *pcr)
+	{
+		return (const PhysicsMaterial *)((char *)pcr + pcr->materials_offset);
+	}
+
+	u32 material_index(const PhysicsMaterial *materials, u32 num, StringId32 name)
+	{
+		for (u32 i = 0; i < num; ++i) {
+			if (materials[i].name == name)
+				return i;
+		}
+
+		CE_FATAL("Material not found");
+		return UINT32_MAX;
+	}
+
+	const PhysicsActor *actors_array(const PhysicsConfigResource *pcr)
+	{
+		return (const PhysicsActor *)((char *)pcr + pcr->actors_offset);
+	}
+
+	u32 actor_index(const PhysicsActor *actors, u32 num, StringId32 name)
+	{
+		for (u32 i = 0; i < num; ++i) {
+			if (actors[i].name == name)
+				return i;
+		}
+
+		CE_FATAL("Actor not found");
+		return UINT32_MAX;
+	}
+
+	const PhysicsCollisionFilter *filters_array(const PhysicsConfigResource *pcr)
+	{
+		return (const PhysicsCollisionFilter *)((char *)pcr + pcr->filters_offset);
+	}
+
+	u32 filter_index(const PhysicsCollisionFilter *filters, u32 num, StringId32 name)
+	{
+		for (u32 i = 0; i < num; ++i) {
+			if (filters[i].name == name)
+				return i;
+		}
+
+		CE_FATAL("Filter not found");
+		return UINT32_MAX;
+	}
+
+} // namespace physics_config_resource
+
+} // namespace crown

+ 1 - 1
src/resource/resource_package.cpp

@@ -6,7 +6,7 @@
 #include "core/containers/array.inl"
 #include "core/os.h"
 #include "core/strings/string_id.inl"
-#include "resource/package_resource.h"
+#include "resource/package_resource.inl"
 #include "resource/resource_id.inl"
 #include "resource/resource_manager.h"
 #include "resource/resource_package.h"

+ 3 - 16
src/resource/sound_resource.cpp

@@ -4,6 +4,8 @@
  */
 
 #include "config.h"
+
+#if CROWN_CAN_COMPILE
 #include "core/containers/array.inl"
 #include "core/filesystem/file.h"
 #include "core/json/json_object.inl"
@@ -17,21 +19,6 @@
 
 namespace crown
 {
-namespace sound_resource
-{
-	const u8 *stream_metadata(const SoundResource *sr)
-	{
-		return (u8 *)&sr[1];
-	}
-
-	const u8 *pcm_data(const SoundResource *sr)
-	{
-		return (u8 *)sr + sr->pcm_offset;
-	}
-
-} // namespace sound_resource
-
-#if CROWN_CAN_COMPILE
 namespace sound_resource_internal
 {
 	s32 compile(CompileOptions &opts)
@@ -43,6 +30,6 @@ namespace sound_resource_internal
 	}
 
 } // namespace sound_resource_internal
-#endif // if CROWN_CAN_COMPILE
 
 } // namespace crown
+#endif // if CROWN_CAN_COMPILE

+ 24 - 0
src/resource/sound_resource.inl

@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/sound_resource.h"
+
+namespace crown
+{
+namespace sound_resource
+{
+	const u8 *stream_metadata(const SoundResource *sr)
+	{
+		return (u8 *)&sr[1];
+	}
+
+	const u8 *pcm_data(const SoundResource *sr)
+	{
+		return (u8 *)sr + sr->pcm_offset;
+	}
+
+} // namespace sound_resource
+
+} // namespace crown

+ 0 - 21
src/resource/sprite_resource.cpp

@@ -25,16 +25,6 @@ LOG_SYSTEM(SPRITE_ANIMATION_RESOURCE, "sprite_animation_resource")
 
 namespace crown
 {
-namespace sprite_resource
-{
-	const f32 *frame_data(const SpriteResource *sr, u32 i)
-	{
-		CE_ENSURE(i < sr->num_frames);
-		return ((f32 *)&sr[1]) + 20*i;
-	}
-
-} // namespace sprite_resource
-
 #if CROWN_CAN_COMPILE
 namespace sprite_resource_internal
 {
@@ -184,18 +174,7 @@ namespace sprite_resource_internal
 	}
 
 } // namespace sprite_resource_internal
-#endif // if CROWN_CAN_COMPILE
 
-namespace sprite_animation_resource
-{
-	const u32 *frames(const SpriteAnimationResource *sar)
-	{
-		return (u32 *)&sar[1];
-	}
-
-} // namespace sprite_animation_resource
-
-#if CROWN_CAN_COMPILE
 struct SpriteAnimationFrame
 {
 	u32 frame; // Sprite frame.

+ 29 - 0
src/resource/sprite_resource.inl

@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/sprite_resource.h"
+
+namespace crown
+{
+namespace sprite_resource
+{
+	const f32 *frame_data(const SpriteResource *sr, u32 i)
+	{
+		CE_ENSURE(i < sr->num_frames);
+		return ((f32 *)&sr[1]) + 20*i;
+	}
+
+} // namespace sprite_resource
+
+namespace sprite_animation_resource
+{
+	const u32 *frames(const SpriteAnimationResource *sar)
+	{
+		return (u32 *)&sar[1];
+	}
+
+} // namespace sprite_animation_resource
+
+} // namespace crown

+ 0 - 84
src/resource/state_machine_resource.cpp

@@ -23,90 +23,6 @@
 
 namespace crown
 {
-namespace state_machine
-{
-	const State *initial_state(const StateMachineResource *smr)
-	{
-		return (State *)((char *)smr + smr->initial_state_offset);
-	}
-
-	const State *state(const StateMachineResource *smr, const Transition *t)
-	{
-		return (State *)((char *)smr + t->state_offset);
-	}
-
-	const State *trigger(const StateMachineResource *smr, const State *s, StringId32 event, const Transition **transition_out)
-	{
-		const TransitionArray *ta = state_transitions(s);
-
-		for (u32 i = 0; i < ta->num; ++i) {
-			const Transition *transition_i = transition(ta, i);
-
-			if (transition_i->event == event) {
-				*transition_out = transition_i;
-				return state(smr, transition_i);
-			}
-		}
-
-		*transition_out = NULL;
-		return s;
-	}
-
-	const TransitionArray *state_transitions(const State *s)
-	{
-		return &s->ta;
-	}
-
-	const Transition *transition(const TransitionArray *ta, u32 index)
-	{
-		CE_ASSERT(index < ta->num, "Index out of bounds");
-		const Transition *first = (Transition *)(&ta[1]);
-		return &first[index];
-	}
-
-	const AnimationArray *state_animations(const State *s)
-	{
-		const TransitionArray *ta = state_transitions(s);
-		const Transition *first = (Transition *)(&ta[1]);
-		return (AnimationArray *)(first + ta->num);
-	}
-
-	const Animation *animation(const AnimationArray *aa, u32 index)
-	{
-		CE_ASSERT(index < aa->num, "Index out of bounds");
-		Animation *first = (Animation *)(memory::align_top((void *)&aa[1], alignof(Animation)));
-		return &first[index];
-	}
-
-	static inline const StringId32 *variables_names(const StateMachineResource *smr)
-	{
-		return (StringId32 *)((char *)smr + smr->variables_offset);
-	}
-
-	const f32 *variables(const StateMachineResource *smr)
-	{
-		const StringId32 *names = variables_names(smr);
-		return (f32 *)(names + smr->num_variables);
-	}
-
-	u32 variable_index(const StateMachineResource *smr, StringId32 name)
-	{
-		const StringId32 *names = variables_names(smr);
-		for (u32 i = 0; i < smr->num_variables; ++i) {
-			if (names[i] == name)
-				return i;
-		}
-
-		return UINT32_MAX;
-	}
-
-	const u32 *byte_code(const StateMachineResource *smr)
-	{
-		return (u32 *)((char *)smr + smr->bytecode_offset);
-	}
-
-} // namespace state_machine
-
 #if CROWN_CAN_COMPILE
 namespace state_machine_resource_internal
 {

+ 94 - 0
src/resource/state_machine_resource.inl

@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/state_machine_resource.h"
+
+namespace crown
+{
+namespace state_machine
+{
+	const State *initial_state(const StateMachineResource *smr)
+	{
+		return (State *)((char *)smr + smr->initial_state_offset);
+	}
+
+	const State *state(const StateMachineResource *smr, const Transition *t)
+	{
+		return (State *)((char *)smr + t->state_offset);
+	}
+
+	const State *trigger(const StateMachineResource *smr, const State *s, StringId32 event, const Transition **transition_out)
+	{
+		const TransitionArray *ta = state_transitions(s);
+
+		for (u32 i = 0; i < ta->num; ++i) {
+			const Transition *transition_i = transition(ta, i);
+
+			if (transition_i->event == event) {
+				*transition_out = transition_i;
+				return state(smr, transition_i);
+			}
+		}
+
+		*transition_out = NULL;
+		return s;
+	}
+
+	const TransitionArray *state_transitions(const State *s)
+	{
+		return &s->ta;
+	}
+
+	const Transition *transition(const TransitionArray *ta, u32 index)
+	{
+		CE_ASSERT(index < ta->num, "Index out of bounds");
+		const Transition *first = (Transition *)(&ta[1]);
+		return &first[index];
+	}
+
+	const AnimationArray *state_animations(const State *s)
+	{
+		const TransitionArray *ta = state_transitions(s);
+		const Transition *first = (Transition *)(&ta[1]);
+		return (AnimationArray *)(first + ta->num);
+	}
+
+	const Animation *animation(const AnimationArray *aa, u32 index)
+	{
+		CE_ASSERT(index < aa->num, "Index out of bounds");
+		Animation *first = (Animation *)(memory::align_top((void *)&aa[1], alignof(Animation)));
+		return &first[index];
+	}
+
+	static inline const StringId32 *variables_names(const StateMachineResource *smr)
+	{
+		return (StringId32 *)((char *)smr + smr->variables_offset);
+	}
+
+	const f32 *variables(const StateMachineResource *smr)
+	{
+		const StringId32 *names = variables_names(smr);
+		return (f32 *)(names + smr->num_variables);
+	}
+
+	u32 variable_index(const StateMachineResource *smr, StringId32 name)
+	{
+		const StringId32 *names = variables_names(smr);
+		for (u32 i = 0; i < smr->num_variables; ++i) {
+			if (names[i] == name)
+				return i;
+		}
+
+		return UINT32_MAX;
+	}
+
+	const u32 *byte_code(const StateMachineResource *smr)
+	{
+		return (u32 *)((char *)smr + smr->bytecode_offset);
+	}
+
+} // namespace state_machine
+
+} // namespace crown

+ 0 - 28
src/resource/unit_resource.cpp

@@ -31,32 +31,4 @@ namespace unit_resource_internal
 } // namespace unit_resource_internal
 #endif
 
-namespace unit_resource
-{
-	const u32 *parents(const UnitResource *ur)
-	{
-		return (u32 *)&ur[1];
-	}
-
-	const ComponentData *component_type_data(const UnitResource *ur, const ComponentData *component)
-	{
-		if (component == NULL)
-			return (ComponentData *)(parents(ur) + ur->num_units);
-		else
-			return (ComponentData *)memory::align_top(component_payload(component) + component->data_size, alignof(ComponentData));
-	}
-
-	const u32 *component_unit_index(const ComponentData *component)
-	{
-		return (u32 *)(&component[1]);
-	}
-
-	const char *component_payload(const ComponentData *component)
-	{
-		const u32 *unit_index = component_unit_index(component);
-		return (char *)memory::align_top(unit_index + component->num_instances, 16);
-	}
-
-} // namespace unit_resource
-
 } // namespace crown

+ 38 - 0
src/resource/unit_resource.inl

@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012-2026 Daniele Bartolini et al.
+ * SPDX-License-Identifier: MIT
+ */
+
+#include "resource/unit_resource.h"
+
+namespace crown
+{
+namespace unit_resource
+{
+	const u32 *parents(const UnitResource *ur)
+	{
+		return (u32 *)&ur[1];
+	}
+
+	const ComponentData *component_type_data(const UnitResource *ur, const ComponentData *component)
+	{
+		if (component == NULL)
+			return (ComponentData *)(parents(ur) + ur->num_units);
+		else
+			return (ComponentData *)memory::align_top(component_payload(component) + component->data_size, alignof(ComponentData));
+	}
+
+	const u32 *component_unit_index(const ComponentData *component)
+	{
+		return (u32 *)(&component[1]);
+	}
+
+	const char *component_payload(const ComponentData *component)
+	{
+		const u32 *unit_index = component_unit_index(component);
+		return (char *)memory::align_top(unit_index + component->num_instances, 16);
+	}
+
+} // namespace unit_resource
+
+} // namespace crown

+ 2 - 1
src/world/animation_state_machine.cpp

@@ -14,7 +14,8 @@
 #include "resource/expression_language.h"
 #include "resource/resource_manager.h"
 #include "resource/sprite_resource.h"
-#include "resource/state_machine_resource.h"
+#include "resource/mesh_skeleton_resource.inl"
+#include "resource/state_machine_resource.inl"
 #include "world/animation_state_machine.h"
 #include "world/event_stream.inl"
 #include "world/render_world.h"

+ 1 - 1
src/world/gui.cpp

@@ -12,7 +12,7 @@
 #include "core/strings/string.inl"
 #include "core/strings/string_id.inl"
 #include "core/strings/utf8.h"
-#include "resource/font_resource.h"
+#include "resource/font_resource.inl"
 #include "resource/material_resource.h"
 #include "resource/resource_manager.h"
 #include "world/gui.h"

+ 1 - 1
src/world/level.cpp

@@ -7,7 +7,7 @@
 #include "core/math/constants.h"
 #include "core/memory/memory.inl"
 #include "core/strings/string_id.inl"
-#include "resource/level_resource.h"
+#include "resource/level_resource.inl"
 #include "world/level.h"
 
 namespace crown

+ 1 - 1
src/world/material_manager.cpp

@@ -7,7 +7,7 @@
 #include "core/containers/hash_map.inl"
 #include "core/filesystem/file.h"
 #include "core/strings/string_id.inl"
-#include "resource/material_resource.h"
+#include "resource/material_resource.inl"
 #include "resource/resource_manager.h"
 #include "resource/texture_resource.h"
 #include "world/material_manager.h"

+ 1 - 0
src/world/mesh_animation_player.cpp

@@ -12,6 +12,7 @@
 #include "core/profiler.h"
 #include "core/strings/string_id.inl"
 #include "device/device.h"
+#include "resource/mesh_animation_resource.inl"
 #include "resource/resource_manager.h"
 #include "world/mesh_animation_player.h"
 #include "world/scene_graph.h"

+ 1 - 1
src/world/physics_world_bullet.cpp

@@ -18,7 +18,7 @@
 #include "core/profiler.h"
 #include "core/strings/string_id.inl"
 #include "device/log.h"
-#include "resource/physics_resource.h"
+#include "resource/physics_resource.inl"
 #include "resource/resource_manager.h"
 #include "world/debug_line.h"
 #include "world/event_stream.inl"

+ 1 - 1
src/world/render_world.cpp

@@ -18,7 +18,7 @@
 #include "resource/mesh_resource.h"
 #include "resource/render_config_resource.h"
 #include "resource/resource_manager.h"
-#include "resource/sprite_resource.h"
+#include "resource/sprite_resource.inl"
 #include "world/debug_line.h"
 #include "world/material.h"
 #include "world/material_manager.h"

+ 1 - 1
src/world/sound_world_al.cpp

@@ -15,7 +15,7 @@
 #include "core/memory/temp_allocator.inl"
 #include "device/log.h"
 #include "resource/resource_manager.h"
-#include "resource/sound_resource.h"
+#include "resource/sound_resource.inl"
 #include "resource/sound_ogg.h"
 #include "world/sound_world.h"
 #include <AL/al.h>

+ 1 - 1
src/world/world.cpp

@@ -16,7 +16,7 @@
 #include "lua/lua_environment.h"
 #include "resource/level_resource.h"
 #include "resource/resource_manager.h"
-#include "resource/unit_resource.h"
+#include "resource/unit_resource.inl"
 #include "world/animation_state_machine.h"
 #include "world/debug_line.h"
 #include "world/event_stream.inl"