aboutsummaryrefslogtreecommitdiff
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/fparkan-render-vulkan/src/asset_mesh.rs40
-rw-r--r--adapters/fparkan-render-vulkan/src/ffi.rs7
2 files changed, 43 insertions, 4 deletions
diff --git a/adapters/fparkan-render-vulkan/src/asset_mesh.rs b/adapters/fparkan-render-vulkan/src/asset_mesh.rs
index bbe538fe..fa2105b6 100644
--- a/adapters/fparkan-render-vulkan/src/asset_mesh.rs
+++ b/adapters/fparkan-render-vulkan/src/asset_mesh.rs
@@ -526,6 +526,36 @@ pub fn project_cockpit_msh(
)
}
+/// Projects an animated model at the authored LOD used by the targeter.
+pub fn project_instrument_msh(
+ model: &ModelAsset,
+ transform: LegacyIron3dEulerTransform,
+ scale: [f32; 3],
+ node_poses: Option<&NodePoseBuffer>,
+ mount_pose: Option<VulkanNodePose>,
+) -> Result<VulkanStaticMesh, VulkanAssetMeshError> {
+ // AniMesh+0x14c15 reads the forced HUD LOD (1 in the GOG build).
+ let group = if model.node_stride == 38 && model.node_count != 0 && model.animation.is_some() {
+ Group(1)
+ } else {
+ Group(0)
+ };
+ project_msh_to_static_mesh_in_world_space_with_node_poses(
+ model,
+ transform,
+ scale,
+ node_poses
+ .cloned()
+ .or_else(|| node38_fallback_hierarchy(model)),
+ mount_pose.map(|mount| Pose {
+ translation: mount.translation,
+ rotation: mount.rotation,
+ }),
+ mount_pose.is_some(),
+ group,
+ )
+}
+
/// Evaluates one Node38 node pose for a unit mount socket.
#[must_use]
pub fn node38_pose(
@@ -1633,7 +1663,7 @@ mod tests {
}
#[test]
- fn cockpit_and_damage_stage_use_distinct_node_slots() {
+ fn cockpit_instrument_and_damage_stage_use_their_authored_node_slots() {
let mut source = model(
vec![[0.0; 3], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]],
vec![0, 1, 2, 2, 1, 0, 1, 2, 0],
@@ -1655,6 +1685,7 @@ mod tests {
source.nodes_raw[0..8].fill(0);
source.nodes_raw[2..4].copy_from_slice(&u16::MAX.to_le_bytes());
source.nodes_raw[8..10].copy_from_slice(&0_u16.to_le_bytes());
+ source.nodes_raw[10..12].copy_from_slice(&2_u16.to_le_bytes());
source.nodes_raw[16..18].copy_from_slice(&1_u16.to_le_bytes());
source.nodes_raw[18..20].copy_from_slice(&2_u16.to_le_bytes());
source.slots = [0, 1, 2]
@@ -1693,6 +1724,13 @@ mod tests {
assert_eq!(exterior.draw_ranges[0].material_index, 0);
assert_eq!(cockpit.draw_ranges.len(), 1);
assert_eq!(cockpit.draw_ranges[0].material_index, 7);
+ let instrument = project_instrument_msh(&source, transform, [1.0; 3], Some(&poses), None)
+ .expect("instrument");
+ assert_eq!(instrument.draw_ranges[0].material_index, 9);
+ source.nodes_raw[10..12].copy_from_slice(&u16::MAX.to_le_bytes());
+ let hidden = project_instrument_msh(&source, transform, [1.0; 3], Some(&poses), None)
+ .expect("empty authored instrument LOD");
+ assert!(hidden.draw_ranges.is_empty());
let stages = append_msh_damage_stages(
&mut exterior,
&source,
diff --git a/adapters/fparkan-render-vulkan/src/ffi.rs b/adapters/fparkan-render-vulkan/src/ffi.rs
index 6d48ba61..152336ec 100644
--- a/adapters/fparkan-render-vulkan/src/ffi.rs
+++ b/adapters/fparkan-render-vulkan/src/ffi.rs
@@ -28,9 +28,10 @@ const FRAME_VIEWS_PER_SLOT: usize = 3 + MODEL_PREVIEWS_PER_FRAME;
pub use self::asset_mesh::{
append_msh_damage_stages, node38_pose, node38_pose_from_hierarchy,
node38_pose_relative_to_root, node38_pose_relative_to_root_from_hierarchy, project_cockpit_msh,
- project_land_msh_lod_to_static_mesh_in_world_space, project_land_msh_to_static_mesh,
- project_land_msh_to_static_mesh_in_world_space, project_land_msh_to_static_mesh_in_xy_frame,
- project_msh_to_static_mesh, project_msh_to_static_mesh_in_world_space,
+ project_instrument_msh, project_land_msh_lod_to_static_mesh_in_world_space,
+ project_land_msh_to_static_mesh, project_land_msh_to_static_mesh_in_world_space,
+ project_land_msh_to_static_mesh_in_xy_frame, project_msh_to_static_mesh,
+ project_msh_to_static_mesh_in_world_space,
project_msh_to_static_mesh_in_world_space_with_node_fallback_poses,
project_msh_to_static_mesh_in_world_space_with_node_fallback_poses_and_mount,
project_msh_to_static_mesh_in_world_space_with_node_pose_buffer,