Pārlūkot izejas kodu

resource: stop copying the entire file each time

Fixes: #286
Daniele Bartolini 1 gadu atpakaļ
vecāks
revīzija
cf0794c52e
2 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. 2 1
      docs/changelog.rst
  2. 1 1
      src/resource/unit_compiler.cpp

+ 2 - 1
docs/changelog.rst

@@ -19,8 +19,9 @@ Changelog
 * Fixed a crash when moving many objects simultaneusly.
 * Fixed a crash when moving many objects simultaneusly.
 * Fixed a crash when reloading unloaded or unsupported resources.
 * Fixed a crash when reloading unloaded or unsupported resources.
 * Added support to shaders and materials hot-reloading.
 * Added support to shaders and materials hot-reloading.
-* Data Compiler: #defines are now correctly exposed in vs_input_output and fs_input_output.
 * Fixed setting kinematic actor's position and rotation.
 * Fixed setting kinematic actor's position and rotation.
+* Data Compiler: #defines are now correctly exposed in vs_input_output and fs_input_output.
+* Data Compiler: fixed and issue that caused OOM when compiling levels with many units.
 * Lua API: fixed ``Math.ray_obb_intersection()`` with scaled OBBs.
 * Lua API: fixed ``Math.ray_obb_intersection()`` with scaled OBBs.
 * Lua API: added ``Math.obb_merge()``.
 * Lua API: added ``Math.obb_merge()``.
 * Lua API: added ``SceneGraph.parent()``.
 * Lua API: added ``SceneGraph.parent()``.

+ 1 - 1
src/resource/unit_compiler.cpp

@@ -360,7 +360,7 @@ namespace unit_compiler
 
 
 		if (append_data) {
 		if (append_data) {
 			u32 prefab_offset = array::size(c._prefab_data);
 			u32 prefab_offset = array::size(c._prefab_data);
-			array::push(c._prefab_data, unit_json, strlen32(unit_json));
+			array::push(c._prefab_data, unit_json, prefab._end - unit_json);
 			array::push_back(c._prefab_data, '\0');
 			array::push_back(c._prefab_data, '\0');
 			array::push_back(c._prefab_offsets, prefab_offset);
 			array::push_back(c._prefab_offsets, prefab_offset);
 			array::push_back(c._prefab_names, unit_name);
 			array::push_back(c._prefab_names, unit_name);