paint: save mesh physics
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
char *manifest_title = "ArmorPaint";
|
char *manifest_title = "ArmorPaint";
|
||||||
char *manifest_version = "1.0 rc2";
|
char *manifest_version = "1.0 rc2";
|
||||||
char *manifest_version_project = "11";
|
char *manifest_version_project = "12";
|
||||||
char *manifest_version_config = "1";
|
char *manifest_version_config = "1";
|
||||||
char *manifest_url = "https://armorpaint.org";
|
char *manifest_url = "https://armorpaint.org";
|
||||||
char *manifest_url_android = "https://play.google.com/store/apps/details?id=org.armorpaint";
|
char *manifest_url_android = "https://play.google.com/store/apps/details?id=org.armorpaint";
|
||||||
|
|||||||
@@ -305,6 +305,16 @@ void export_arm_run_project() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_project->mesh_physics_shapes != NULL) {
|
||||||
|
g_project->mesh_physics_shapes = i32_array_create(g_project->_->paint_objects->length);
|
||||||
|
g_project->mesh_physics_masses = f32_array_create(g_project->_->paint_objects->length);
|
||||||
|
for (i32 i = 0; i < g_project->mesh_physics_shapes->length; ++i) {
|
||||||
|
asim_body_t *pb = g_project->_->paint_objects->buffer[i]->base->_->body;
|
||||||
|
g_project->mesh_physics_shapes->buffer[i] = pb != NULL ? pb->shape : -1; // No physics
|
||||||
|
g_project->mesh_physics_masses->buffer[i] = pb != NULL ? pb->mass : 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_project->material_nodes = mnodes;
|
g_project->material_nodes = mnodes;
|
||||||
g_project->brush_nodes = bnodes;
|
g_project->brush_nodes = bnodes;
|
||||||
g_project->layer_datas = ld;
|
g_project->layer_datas = ld;
|
||||||
|
|||||||
@@ -655,6 +655,17 @@ void import_arm_run_project(char *path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_project->mesh_physics_shapes != NULL) {
|
||||||
|
for (i32 i = 0; i < g_project->_->paint_objects->length && i < g_project->mesh_physics_shapes->length; ++i) {
|
||||||
|
i32 shape = g_project->mesh_physics_shapes->buffer[i];
|
||||||
|
if (shape < 0) {
|
||||||
|
continue; // No physics
|
||||||
|
}
|
||||||
|
f32 mass = g_project->mesh_physics_masses != NULL && i < g_project->mesh_physics_masses->length ? g_project->mesh_physics_masses->buffer[i] : 0.0;
|
||||||
|
sim_add_body(g_project->_->paint_objects->buffer[i]->base, (asim_shape_t)shape, mass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tab_timeline_import(g_project);
|
tab_timeline_import(g_project);
|
||||||
|
|
||||||
// Select the first stage
|
// Select the first stage
|
||||||
|
|||||||
@@ -243,6 +243,8 @@ project_t *import_arm_from_map_to_arm(any_map_t *old) {
|
|||||||
project->mesh_transforms = any_map_get(old, "mesh_transforms");
|
project->mesh_transforms = any_map_get(old, "mesh_transforms");
|
||||||
project->mesh_materials = any_map_get(old, "mesh_materials");
|
project->mesh_materials = any_map_get(old, "mesh_materials");
|
||||||
project->mesh_parents = any_map_get(old, "mesh_parents");
|
project->mesh_parents = any_map_get(old, "mesh_parents");
|
||||||
|
project->mesh_physics_shapes = any_map_get(old, "mesh_physics_shapes");
|
||||||
|
project->mesh_physics_masses = any_map_get(old, "mesh_physics_masses");
|
||||||
project->atlas_objects = any_map_get(old, "atlas_objects");
|
project->atlas_objects = any_map_get(old, "atlas_objects");
|
||||||
project->atlas_names = any_map_get(old, "atlas_names");
|
project->atlas_names = any_map_get(old, "atlas_names");
|
||||||
project->script_datas = any_map_get(old, "script_datas");
|
project->script_datas = any_map_get(old, "script_datas");
|
||||||
@@ -300,9 +302,15 @@ project_t *import_arm_from_map_to_arm(any_map_t *old) {
|
|||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
project_t *import_arm_from_version_11(any_map_t *old) {
|
||||||
|
any_map_set(old, "mesh_physics_shapes", NULL);
|
||||||
|
any_map_set(old, "mesh_physics_masses", NULL);
|
||||||
|
return import_arm_from_map_to_arm(old);
|
||||||
|
}
|
||||||
|
|
||||||
project_t *import_arm_from_version_10(any_map_t *old) {
|
project_t *import_arm_from_version_10(any_map_t *old) {
|
||||||
any_map_set(old, "sound_assets", NULL);
|
any_map_set(old, "sound_assets", NULL);
|
||||||
return import_arm_from_map_to_arm(old);
|
return import_arm_from_version_11(old);
|
||||||
}
|
}
|
||||||
|
|
||||||
project_t *import_arm_from_version_9(any_map_t *old) {
|
project_t *import_arm_from_version_9(any_map_t *old) {
|
||||||
@@ -420,7 +428,7 @@ project_t *import_arm_from_old(buffer_t *b) {
|
|||||||
project_t *(*fns[])(any_map_t *) = {
|
project_t *(*fns[])(any_map_t *) = {
|
||||||
import_arm_from_version_0, import_arm_from_version_1, import_arm_from_version_2, import_arm_from_version_3,
|
import_arm_from_version_0, import_arm_from_version_1, import_arm_from_version_2, import_arm_from_version_3,
|
||||||
import_arm_from_version_4, import_arm_from_version_5, import_arm_from_version_6, import_arm_from_version_7,
|
import_arm_from_version_4, import_arm_from_version_5, import_arm_from_version_6, import_arm_from_version_7,
|
||||||
import_arm_from_version_8, import_arm_from_version_9, import_arm_from_version_10,
|
import_arm_from_version_8, import_arm_from_version_9, import_arm_from_version_10, import_arm_from_version_11,
|
||||||
};
|
};
|
||||||
for (i32 v = sizeof(fns) / sizeof(fns[0]) - 1; v >= 0; --v) {
|
for (i32 v = sizeof(fns) / sizeof(fns[0]) - 1; v >= 0; --v) {
|
||||||
if (import_arm_is_version(b, i32_to_string(v))) {
|
if (import_arm_is_version(b, i32_to_string(v))) {
|
||||||
|
|||||||
@@ -569,6 +569,8 @@ typedef struct project {
|
|||||||
struct f32_array_t_array *mesh_transforms;
|
struct f32_array_t_array *mesh_transforms;
|
||||||
struct i32_array *mesh_materials;
|
struct i32_array *mesh_materials;
|
||||||
struct i32_array *mesh_parents;
|
struct i32_array *mesh_parents;
|
||||||
|
struct i32_array *mesh_physics_shapes; // -1 = no physics
|
||||||
|
struct f32_array *mesh_physics_masses;
|
||||||
struct i32_array *atlas_objects;
|
struct i32_array *atlas_objects;
|
||||||
struct string_array *atlas_names;
|
struct string_array *atlas_names;
|
||||||
struct string_array *script_datas;
|
struct string_array *script_datas;
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ buffer_t *util_encode_project(project_t *raw) {
|
|||||||
buffer_t *encoded = buffer_create(size);
|
buffer_t *encoded = buffer_create(size);
|
||||||
|
|
||||||
armpack_encode_start(encoded->buffer);
|
armpack_encode_start(encoded->buffer);
|
||||||
armpack_encode_map(36);
|
armpack_encode_map(38);
|
||||||
|
|
||||||
armpack_encode_string("version");
|
armpack_encode_string("version");
|
||||||
armpack_encode_string(raw->version);
|
armpack_encode_string(raw->version);
|
||||||
@@ -478,6 +478,12 @@ buffer_t *util_encode_project(project_t *raw) {
|
|||||||
armpack_encode_string("mesh_parents");
|
armpack_encode_string("mesh_parents");
|
||||||
armpack_encode_array_i32(raw->mesh_parents);
|
armpack_encode_array_i32(raw->mesh_parents);
|
||||||
|
|
||||||
|
armpack_encode_string("mesh_physics_shapes");
|
||||||
|
armpack_encode_array_i32(raw->mesh_physics_shapes);
|
||||||
|
|
||||||
|
armpack_encode_string("mesh_physics_masses");
|
||||||
|
armpack_encode_array_f32(raw->mesh_physics_masses);
|
||||||
|
|
||||||
armpack_encode_string("atlas_objects");
|
armpack_encode_string("atlas_objects");
|
||||||
armpack_encode_array_i32(raw->atlas_objects);
|
armpack_encode_array_i32(raw->atlas_objects);
|
||||||
armpack_encode_string("atlas_names");
|
armpack_encode_string("atlas_names");
|
||||||
|
|||||||
Reference in New Issue
Block a user