Skip to content

Commit 1f637b8

Browse files
committed
Fixing merge conflict again
1 parent af5dd35 commit 1f637b8

File tree

11 files changed

+51
-39
lines changed

11 files changed

+51
-39
lines changed

crates/bevy_gltf/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ use bevy_app::prelude::*;
103103
use bevy_asset::AssetApp;
104104
use bevy_image::CompressedImageFormats;
105105
use bevy_render::{
106-
mesh::{MeshVertexAttribute, TangentStrategy},
106+
mesh::{MeshVertexAttribute, TangentCalculationStrategy},
107107
renderer::RenderDevice,
108108
};
109109

@@ -121,8 +121,8 @@ pub use {assets::*, label::GltfAssetLabel, loader::*};
121121
#[derive(Default)]
122122
pub struct GltfPlugin {
123123
custom_vertex_attributes: HashMap<Box<str>, MeshVertexAttribute>,
124-
/// The strategy to use when computing mesh tangents.
125-
pub computed_tangent_strategy: TangentStrategy,
124+
/// The strategy to use when computing tangents for meshes without them.
125+
pub tangent_calculation_strategy: TangentCalculationStrategy,
126126
}
127127

128128
impl GltfPlugin {
@@ -141,8 +141,11 @@ impl GltfPlugin {
141141
}
142142

143143
/// The strategy to use when computing mesh tangents.
144-
pub fn with_computed_tangent_strategy(mut self, tangent_strategy: TangentStrategy) -> Self {
145-
self.computed_tangent_strategy = tangent_strategy;
144+
pub fn with_tangent_calculation_strategy(
145+
mut self,
146+
tangent_strategy: TangentCalculationStrategy,
147+
) -> Self {
148+
self.tangent_calculation_strategy = tangent_strategy;
146149
self
147150
}
148151
}
@@ -170,7 +173,7 @@ impl Plugin for GltfPlugin {
170173
app.register_asset_loader(GltfLoader {
171174
supported_compressed_formats,
172175
custom_vertex_attributes: self.custom_vertex_attributes.clone(),
173-
computed_tangent_strategy: self.computed_tangent_strategy,
176+
tangent_calculation_strategy: self.tangent_calculation_strategy,
174177
});
175178
}
176179
}

crates/bevy_gltf/src/loader/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ use bevy_render::{
3535
mesh::{
3636
morph::{MeshMorphWeights, MorphAttributes, MorphTargetImage, MorphWeights},
3737
skinning::{SkinnedMesh, SkinnedMeshInverseBindposes},
38-
Indices, Mesh, Mesh3d, MeshVertexAttribute, TangentStrategy, VertexAttributeValues,
38+
Indices, Mesh, Mesh3d, MeshVertexAttribute, TangentCalculationStrategy,
39+
VertexAttributeValues,
3940
},
4041
primitives::Aabb,
4142
render_asset::RenderAssetUsages,
@@ -146,7 +147,7 @@ pub struct GltfLoader {
146147
/// for additional details on custom attributes.
147148
pub custom_vertex_attributes: HashMap<Box<str>, MeshVertexAttribute>,
148149
/// The strategy to use when computing mesh tangents.
149-
pub computed_tangent_strategy: TangentStrategy,
150+
pub tangent_calculation_strategy: TangentCalculationStrategy,
150151
}
151152

152153
/// Specifies optional settings for processing gltfs at load time. By default, all recognized contents of
@@ -687,16 +688,16 @@ async fn load_gltf<'a, 'b, 'c>(
687688
{
688689
tracing::debug!(
689690
"Missing vertex tangents for {}, computing them using the {:?} strategy. Consider using a tool such as Blender to pre-compute the tangents.",
690-
file_name, loader.computed_tangent_strategy
691+
file_name, loader.tangent_calculation_strategy
691692
);
692693

693694
let generate_tangents_span = info_span!("compute_tangents", name = file_name);
694695

695696
generate_tangents_span.in_scope(|| {
696-
if let Err(err) = mesh.compute_tangents(loader.computed_tangent_strategy) {
697+
if let Err(err) = mesh.compute_tangents(loader.tangent_calculation_strategy) {
697698
warn!(
698699
"Failed to generate vertex tangents using {:?}: {}",
699-
loader.computed_tangent_strategy, err
700+
loader.tangent_calculation_strategy, err
700701
);
701702
}
702703
});

crates/bevy_mesh/src/gramschmidt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ pub(crate) fn generate_tangents_for_mesh(
133133
mod tests {
134134
use bevy_math::{primitives::*, Vec2, Vec3, Vec3A};
135135

136-
use crate::{Mesh, TangentStrategy};
136+
use crate::{Mesh, TangentCalculationStrategy};
137137

138138
// The tangents should be very close for simple shapes
139139
fn compare_tangents(mut mesh: Mesh) {
140140
let hq_tangents: Vec<[f32; 4]> = {
141141
mesh.remove_attribute(Mesh::ATTRIBUTE_TANGENT);
142-
mesh.compute_tangents(TangentStrategy::HighQuality)
142+
mesh.compute_tangents(TangentCalculationStrategy::HighQuality)
143143
.expect("compute_tangents(HighQuality)");
144144
mesh.attribute(Mesh::ATTRIBUTE_TANGENT)
145145
.expect("hq_tangents.attribute(tangent)")
@@ -150,7 +150,7 @@ mod tests {
150150

151151
let fa_tangents: Vec<[f32; 4]> = {
152152
mesh.remove_attribute(Mesh::ATTRIBUTE_TANGENT);
153-
mesh.compute_tangents(TangentStrategy::FastApproximation)
153+
mesh.compute_tangents(TangentCalculationStrategy::FastApproximation)
154154
.expect("compute_tangents(FastApproximation)");
155155
mesh.attribute(Mesh::ATTRIBUTE_TANGENT)
156156
.expect("fa_tangents.attribute(tangent)")

crates/bevy_mesh/src/mesh.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -776,22 +776,26 @@ impl Mesh {
776776
/// Requires a [`PrimitiveTopology::TriangleList`] topology and the [`Mesh::ATTRIBUTE_POSITION`], [`Mesh::ATTRIBUTE_NORMAL`] and [`Mesh::ATTRIBUTE_UV_0`] attributes set.
777777
#[deprecated(since = "0.16.0", note = "use compute_tangents")]
778778
pub fn generate_tangents(&mut self) -> Result<(), GenerateTangentsError> {
779-
self.compute_tangents(TangentStrategy::HighQuality)?;
779+
self.compute_tangents(TangentCalculationStrategy::HighQuality)?;
780780
Ok(())
781781
}
782782

783783
/// Generate tangents for the mesh using the given algorithm.
784784
///
785785
/// Sets the [`Mesh::ATTRIBUTE_TANGENT`] attribute if successful.
786786
///
787-
/// See [`TangentStrategy`] for mesh topology and attribute requirements.
787+
/// See [`TangentCalculationStrategy`] for mesh topology and attribute requirements.
788788
pub fn compute_tangents(
789789
&mut self,
790-
tangent_strategy: TangentStrategy,
790+
strategy: TangentCalculationStrategy,
791791
) -> Result<(), GenerateTangentsError> {
792-
let tangents = match tangent_strategy {
793-
TangentStrategy::HighQuality => mikktspace::generate_tangents_for_mesh(self)?,
794-
TangentStrategy::FastApproximation => gramschmidt::generate_tangents_for_mesh(self)?,
792+
let tangents = match strategy {
793+
TangentCalculationStrategy::HighQuality => {
794+
mikktspace::generate_tangents_for_mesh(self)?
795+
}
796+
TangentCalculationStrategy::FastApproximation => {
797+
gramschmidt::generate_tangents_for_mesh(self)?
798+
}
795799
};
796800
self.insert_attribute(Mesh::ATTRIBUTE_TANGENT, tangents);
797801
Ok(())
@@ -817,12 +821,12 @@ impl Mesh {
817821
///
818822
/// (Alternatively, you can use [`Mesh::compute_tangents`] to mutate an existing mesh in-place)
819823
///
820-
/// See [`TangentStrategy`] for mesh topology and attribute requirements.
824+
/// See [`TangentCalculationStrategy`] for mesh topology and attribute requirements.
821825
pub fn with_computed_tangents(
822826
mut self,
823-
tangent_strategy: TangentStrategy,
827+
strategy: TangentCalculationStrategy,
824828
) -> Result<Mesh, GenerateTangentsError> {
825-
self.compute_tangents(tangent_strategy)?;
829+
self.compute_tangents(strategy)?;
826830
Ok(self)
827831
}
828832

@@ -1272,7 +1276,7 @@ impl core::ops::Mul<Mesh> for Transform {
12721276

12731277
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)]
12741278
/// The strategy to use when computing mesh tangents. Defaults to `HighQuality`.
1275-
pub enum TangentStrategy {
1279+
pub enum TangentCalculationStrategy {
12761280
/// Uses the Morten S. Mikkelsen "mikktspace" algorithm. Produces potentially higher quality tangents, but much slower.
12771281
///
12781282
/// Requires a [`PrimitiveTopology::TriangleList`] topology and the [`Mesh::ATTRIBUTE_POSITION`], [`Mesh::ATTRIBUTE_NORMAL`] and [`Mesh::ATTRIBUTE_UV_0`] attributes set.

crates/bevy_pbr/src/decal/forward.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ use bevy_math::{prelude::Rectangle, Quat, Vec2, Vec3};
99
use bevy_reflect::{Reflect, TypePath};
1010
use bevy_render::{
1111
alpha::AlphaMode,
12-
mesh::{Mesh, Mesh3d, MeshBuilder, MeshVertexBufferLayoutRef, Meshable, TangentStrategy},
12+
mesh::{
13+
Mesh, Mesh3d, MeshBuilder, MeshVertexBufferLayoutRef, Meshable, TangentCalculationStrategy,
14+
},
1315
render_resource::{
1416
AsBindGroup, CompareFunction, RenderPipelineDescriptor, Shader,
1517
SpecializedMeshPipelineError,
@@ -42,7 +44,7 @@ impl Plugin for ForwardDecalPlugin {
4244
.mesh()
4345
.build()
4446
.rotated_by(Quat::from_rotation_arc(Vec3::Z, Vec3::Y))
45-
.with_computed_tangents(TangentStrategy::HighQuality)
47+
.with_computed_tangents(TangentCalculationStrategy::HighQuality)
4648
.unwrap(),
4749
);
4850

examples/3d/anisotropy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bevy::{
77
core_pipeline::Skybox,
88
math::vec3,
99
prelude::*,
10-
render::mesh::TangentStrategy,
10+
render::mesh::TangentCalculationStrategy,
1111
time::Stopwatch,
1212
};
1313

@@ -116,7 +116,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_status: Res
116116
Mesh3d(
117117
asset_server.add(
118118
Mesh::from(Sphere::new(0.1))
119-
.with_computed_tangents(TangentStrategy::HighQuality)
119+
.with_computed_tangents(TangentCalculationStrategy::HighQuality)
120120
.unwrap(),
121121
),
122122
),

examples/3d/clearcoat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use bevy::{
2525
image::ImageLoaderSettings,
2626
math::vec3,
2727
prelude::*,
28-
render::mesh::TangentStrategy,
28+
render::mesh::TangentCalculationStrategy,
2929
};
3030

3131
/// The size of each sphere.
@@ -84,7 +84,7 @@ fn create_sphere_mesh(meshes: &mut Assets<Mesh>) -> Handle<Mesh> {
8484

8585
let mut sphere_mesh = Sphere::new(1.0).mesh().build();
8686
sphere_mesh
87-
.compute_tangents(TangentStrategy::HighQuality)
87+
.compute_tangents(TangentCalculationStrategy::HighQuality)
8888
.expect("Failed to generate tangents");
8989
meshes.add(sphere_mesh)
9090
}

examples/3d/deferred_rendering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use bevy::{
1212
NotShadowCaster, NotShadowReceiver, OpaqueRendererMethod,
1313
},
1414
prelude::*,
15-
render::mesh::TangentStrategy,
15+
render::mesh::TangentCalculationStrategy,
1616
};
1717

1818
fn main() {
@@ -234,7 +234,7 @@ fn setup_parallax(
234234

235235
// NOTE: for normal maps and depth maps to work, the mesh
236236
// needs tangents generated.
237-
cube.compute_tangents(TangentStrategy::FastApproximation)
237+
cube.compute_tangents(TangentCalculationStrategy::FastApproximation)
238238
.unwrap();
239239

240240
let parallax_material = materials.add(StandardMaterial {

examples/3d/parallax_mapping.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
44
use std::fmt;
55

6-
use bevy::{image::ImageLoaderSettings, math::ops, prelude::*, render::mesh::TangentStrategy};
6+
use bevy::{
7+
image::ImageLoaderSettings, math::ops, prelude::*, render::mesh::TangentCalculationStrategy,
8+
};
79

810
fn main() {
911
App::new()
@@ -267,7 +269,7 @@ fn setup(
267269
// NOTE: for normal maps and depth maps to work, the mesh
268270
// needs tangents generated.
269271
Mesh::from(Cuboid::default())
270-
.with_computed_tangents(TangentStrategy::HighQuality)
272+
.with_computed_tangents(TangentCalculationStrategy::HighQuality)
271273
.unwrap(),
272274
),
273275
),
@@ -277,7 +279,7 @@ fn setup(
277279

278280
let background_cube = meshes.add(
279281
Mesh::from(Cuboid::new(40.0, 40.0, 40.0))
280-
.with_computed_tangents(TangentStrategy::HighQuality)
282+
.with_computed_tangents(TangentCalculationStrategy::HighQuality)
281283
.unwrap(),
282284
);
283285

examples/3d/rotate_environment_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bevy::{
77
core_pipeline::{tonemapping::Tonemapping::AcesFitted, Skybox},
88
image::ImageLoaderSettings,
99
prelude::*,
10-
render::mesh::TangentStrategy,
10+
render::mesh::TangentCalculationStrategy,
1111
};
1212

1313
/// Entry point.
@@ -52,7 +52,7 @@ fn create_sphere_mesh(meshes: &mut Assets<Mesh>) -> Handle<Mesh> {
5252

5353
let mut sphere_mesh = Sphere::new(1.0).mesh().build();
5454
sphere_mesh
55-
.compute_tangents(TangentStrategy::HighQuality)
55+
.compute_tangents(TangentCalculationStrategy::HighQuality)
5656
.expect("Failed to generate tangents");
5757
meshes.add(sphere_mesh)
5858
}

0 commit comments

Comments
 (0)