Skip to content

Commit

Permalink
Add more options for liquids
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMiguel211 committed Jul 19, 2024
1 parent 1e32c4c commit f5a4e06
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 274 deletions.
38 changes: 37 additions & 1 deletion schema/randomprime.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2861,7 +2861,7 @@
"default": false
},
"liquids": {
"description": "Add liquid volumes to this room.",
"description": "Add liquid volumes to this room. The bigger their size, the bigger the `tileSize` and `tileSubdivisions` values must be in order for the liquid to render properly.",
"type": "array",
"items": {
"type": "object",
Expand Down Expand Up @@ -2894,6 +2894,42 @@
"scale": {
"description": "The extent of the liquid volume.",
"$ref": "#/$defs/vector3Positive"
},
"morphInTime": {
"description": "Duration in which the water will be traveling to it's destination.",
"type": "number",
"minimum": 0.0,
"default": 3.0
},
"morphOutTime": {
"description": "Duration in which the water will be traveling back to it's source position.",
"type": "number",
"minimum": 0.0,
"default": 3.0
},
"tileSize": {
"description": "Specify the size of the water tiles.",
"type": "number",
"minimum": 0.0,
"default": 2.4
},
"tileSubdivisions": {
"description": "Specify the amount of tile subdivisions on the liquid.",
"type": "integer",
"minimum": 0,
"default": 6
},
"alphaInTime": {
"description": "Duration in which the water will be fading back in view.",
"type": "number",
"minimum": 0.0,
"default": 3.0
},
"alphaOutTime": {
"description": "Duration in which the water will be fading out of view.",
"type": "number",
"minimum": 0.0,
"default": 3.0
}
},
"required": [
Expand Down
12 changes: 12 additions & 0 deletions src/add_modify_obj_patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@ pub fn patch_add_liquid<'r>(
.as_mut_vec();
water_obj.property_data.as_water_mut().unwrap().active =
config.active.unwrap_or(true) as u8;
water_obj.property_data.as_water_mut().unwrap().morph_in_time =
config.morph_in_time.unwrap_or(1.0) as f32;
water_obj.property_data.as_water_mut().unwrap().morph_out_time =
config.morph_out_time.unwrap_or(1.0) as f32;
water_obj.property_data.as_water_mut().unwrap().tile_size =
config.tile_size.unwrap_or(2.4) as f32;
water_obj.property_data.as_water_mut().unwrap().tile_subdivisions =
config.tile_subdivisions.unwrap_or(6) as u32;
water_obj.property_data.as_water_mut().unwrap().alpha_in_time =
config.alpha_in_time.unwrap_or(3.0) as f32;
water_obj.property_data.as_water_mut().unwrap().alpha_out_time =
config.alpha_out_time.unwrap_or(3.0) as f32;
let property_data: structs::SclyProperty = water_obj.property_data;

assert!(property_data.object_type() == structs::Water::OBJECT_TYPE);
Expand Down
6 changes: 6 additions & 0 deletions src/patch_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ pub struct WaterConfig {
pub liquid_type: String,
pub position: [f32; 3],
pub scale: [f32; 3],
pub morph_in_time: Option<f32>,
pub morph_out_time: Option<f32>,
pub tile_size: Option<f32>,
pub tile_subdivisions: Option<u32>,
pub alpha_in_time: Option<f32>,
pub alpha_out_time: Option<f32>,
}

#[derive(PartialEq, Debug, Serialize, Deserialize, Copy, Clone)]
Expand Down
Loading

0 comments on commit f5a4e06

Please sign in to comment.