Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit08311e8

Browse files
committed
finally fix wasd keys on player; add deferred prepass and replace msaa with taa to camera
1 parent393eb35 commit08311e8

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

‎src/game/camera/mod.rs‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
use bevy::{
2+
core_pipeline::{
3+
experimental::taa::TemporalAntiAliasing, fxaa::Fxaa, prepass::DeferredPrepass,
4+
},
5+
pbr::DefaultOpaqueRendererMethod,
6+
};
7+
18
usesuper::*;
29

310
#[cfg(feature ="third_person")]
@@ -6,7 +13,8 @@ mod third_person;
613
mod top_down;
714

815
pubfnplugin(app:&mutApp){
9-
app.add_systems(Startup, spawn_camera)
16+
app.insert_resource(DefaultOpaqueRendererMethod::deferred())
17+
.add_systems(Startup, spawn_camera)
1018
.add_systems(OnEnter(Screen::Title), add_skybox_to_camera);
1119

1220
#[cfg(feature ="third_person")]
@@ -25,7 +33,9 @@ pub fn spawn_camera(mut commands: Commands) {
2533
hdr:true,
2634
..Default::default()
2735
},
28-
Msaa::Sample4,
36+
DeferredPrepass,
2937
Transform::from_xyz(100.,50.,100.).looking_at(Vec3::ZERO,Vec3::Y),
38+
TemporalAntiAliasing::default(),
39+
Fxaa::default(),
3040
));
3141
}

‎src/main.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ fn main() {
5252
meta_check:AssetMetaCheck::Never,
5353
..default()
5454
};
55+
// DEBUG
56+
// let filter = "info,symphonia=off,naga=off,wgpu=warn,bevy_enhanced_input=debug".to_string();
57+
let filter ="info,calloop=off,symphonia=off,naga=off,wgpu=warn".to_string();
5558
let log_level = log::LogPlugin{
5659
level: log::Level::TRACE,
57-
filter:"info,symphonia=off,naga=off,wgpu=warn".to_string(),
60+
filter,
5861
..Default::default()
5962
};
6063

‎src/models/input.rs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn spawn_ctx(mut cmds: Commands) {
1515
cmds.spawn(ModalCtx);
1616
}
1717

18-
#[derive(InputAction,Component)]
18+
#[derive(InputAction)]
1919
#[action_output(Vec2)]
2020
pubstructNavigate;
2121

@@ -49,7 +49,7 @@ pub struct Sprint;
4949
#[action_output(bool)]
5050
pubstructDash;
5151

52-
#[derive(InputAction,Component)]
52+
#[derive(InputAction)]
5353
#[action_output(bool)]
5454
pubstructCrouch;
5555

@@ -146,7 +146,7 @@ pub fn add_player_ctx(
146146
),
147147
]));
148148

149-
//#[cfg(feature = "top_down")]
149+
#[cfg(feature ="top_down")]
150150
e.insert(actions!(ModalCtx[
151151
(
152152
Action::<ScrollZoom>::new(),
@@ -166,7 +166,6 @@ pub fn add_player_ctx(
166166
fnrm_player_ctx(on:Trigger<OnRemove,PlayerCtx>,mutcommands:Commands){
167167
commands
168168
.entity(on.target())
169-
.remove_with_requires::<PlayerCtx>()
170169
.despawn_related::<Actions<PlayerCtx>>();
171170
}
172171

@@ -181,7 +180,6 @@ fn add_modal_ctx(on: Trigger<OnAdd, ModalCtx>, mut commands: Commands) {
181180
..Default::default()
182181
},
183182
Bindings::spawn((
184-
Cardinal::wasd_keys(),
185183
Spawn((Binding::mouse_motion(),Scale::splat(0.1),Negate::all())),
186184
Axial::right_stick().with((Scale::splat(2.0),Negate::x())),
187185
)),
@@ -213,6 +211,5 @@ fn add_modal_ctx(on: Trigger<OnAdd, ModalCtx>, mut commands: Commands) {
213211
fnrm_modal_ctx(on:Trigger<OnRemove,ModalCtx>,mutcommands:Commands){
214212
commands
215213
.entity(on.target())
216-
.remove_with_requires::<ModalCtx>()
217214
.despawn_related::<Actions<ModalCtx>>();
218215
}

‎src/player/control.rs‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn movement(
3030
mutplayer_query:Query<(&mutPlayer,&mutTnuaController,&mutStepTimer)>,
3131
) ->Result{
3232
let(navigate, crouch) =(*navigate.into_inner(),*crouch.into_inner());
33-
info!("{}, {}",*navigate,*crouch);
33+
3434
for(player,mut controller,mut step_timer)in player_query.iter_mut(){
3535
let cam_transform = camera.single()?;
3636
let direction = cam_transform.movement_direction(*navigate);
@@ -89,10 +89,10 @@ fn handle_sprint_in(
8989
mutplayer_query:Query<&mutPlayer,With<PlayerCtx>>,
9090
) ->Result{
9191
let entity = on.target();
92-
ifletOk(mut player) = player_query.get_mut(entity){
93-
if player.speed <= cfg.player.movement.speed{
94-
player.speed *= cfg.player.movement.sprint_factor;
95-
}
92+
ifletOk(mut player) = player_query.get_mut(entity)
93+
&& player.speed <= cfg.player.movement.speed
94+
{
95+
player.speed *= cfg.player.movement.sprint_factor;
9696
info!("Sprint started for entity: {entity}");
9797
}
9898

@@ -105,11 +105,10 @@ fn handle_sprint_out(
105105
mutplayer_query:Query<&mutPlayer,With<PlayerCtx>>,
106106
){
107107
let entity = on.target();
108-
match player_query.get_mut(entity){
109-
Ok(mut player)if player.speed > cfg.player.movement.speed =>{
110-
player.speed = cfg.player.movement.speed;
111-
}
112-
_ =>{}
108+
ifletOk(mut player) = player_query.get_mut(entity)
109+
&& player.speed > cfg.player.movement.speed
110+
{
111+
player.speed = cfg.player.movement.speed;
113112
}
114113
}
115114

@@ -192,7 +191,6 @@ pub fn crouch_in(
192191
Ok(())
193192
}
194193

195-
#[allow(clippy::type_complexity)]
196194
pubfncrouch_out(
197195
on:Trigger<Completed<Crouch>>,
198196
cfg:Res<Config>,

‎src/scene/skybox.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ pub fn add_skybox_to_camera(
2929
.build();
3030

3131
commands.spawn((
32-
StateScoped(Screen::Gameplay),
3332
Sun,
33+
StateScoped(Screen::Gameplay),
3434
DirectionalLight{
3535
color:SUN,
3636
shadows_enabled:true,
3737
illuminance: lux::FULL_DAYLIGHT,
3838
..Default::default()
3939
},
40-
Transform::from_translation(Vec3::new(0.0,0.0,200.0)),
40+
//Transform::from_translation(Vec3::new(0.0, 0.0, 200.0)),
4141
cascade_shadow_config.clone(),
4242
));
4343

4444
commands.spawn((
45-
StateScoped(Screen::Gameplay),
4645
Moon,
46+
StateScoped(Screen::Gameplay),
4747
DirectionalLight{
4848
color:MOON,
4949
shadows_enabled:true,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp