Skip to content

Commit df11c31

Browse files
committed
v0.2
1 parent b68a923 commit df11c31

10 files changed

Lines changed: 459 additions & 555 deletions

File tree

Cargo.toml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
[package]
22
name = "boimp"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66

77
[dependencies]
8-
# bevy = { git = "https://github.com/robtfm/bevy", branch = "0.14.2-plus-16188" }
9-
bevy = "0.14"
10-
# bevy = { git = "https://github.com/robtfm/bevy", branch = "release-0.14-dcl-cosmic-noimage" }
11-
wgpu = "0.20"
12-
crossbeam-channel = "0.5.13"
13-
async-channel = "2.2.0"
14-
image = "0.25.2"
15-
bytemuck = "1.7"
8+
bevy = "0.15"
9+
wgpu = "23"
10+
crossbeam-channel = "0.5"
11+
async-channel = "2"
12+
image = { version = "0.25.2", default-features = false }
13+
bytemuck = "1"
1614

1715
# asset loader
1816
zip = { version = "2", default-features = false }
@@ -22,6 +20,3 @@ serde = { version = "1", features = ["derive"] }
2220
# examples
2321
pico-args = "0.5.0"
2422
rand = "0.8.5"
25-
26-
[patch.crates-io]
27-
bevy = { git = "https://github.com/robtfm/bevy", branch = "0.14.2-plus-16188" }

examples/custom_mesh.rs

Lines changed: 0 additions & 143 deletions
This file was deleted.

examples/dynamic.rs

Lines changed: 46 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::f32::consts::{FRAC_PI_4, PI};
66

77
use bevy::{
88
animation::AnimationTarget,
9-
asset::LoadState,
109
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
1110
ecs::entity::EntityHashMap,
1211
math::FloatOrd,
@@ -19,8 +18,8 @@ use bevy::{
1918
utils::hashbrown::HashMap,
2019
};
2120
use boimp::{
22-
render::DummyIndicesImage, GridMode, Imposter, ImposterBakeBundle, ImposterBakeCamera,
23-
ImposterBakePlugin, ImposterData,
21+
render::DummyIndicesImage, GridMode, Imposter, ImposterBakeCamera, ImposterBakePlugin,
22+
ImposterData,
2423
};
2524
use camera_controller::{CameraController, CameraControllerPlugin};
2625
use rand::{thread_rng, Rng};
@@ -116,8 +115,8 @@ impl SceneHandle {
116115

117116
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
118117
let mut args = pico_args::Arguments::from_env();
119-
let grid_size = args.value_from_str("--grid").unwrap_or(9);
120-
let tile_size = args.value_from_str("--tile").unwrap_or(64);
118+
let grid_size = args.value_from_str("--grid").unwrap_or(15);
119+
let tile_size = args.value_from_str("--tile").unwrap_or(128);
121120
let mode = match args
122121
.value_from_str("--mode")
123122
.unwrap_or("h".to_owned())
@@ -172,7 +171,10 @@ fn scene_load_check(
172171
) {
173172
match scene_handle.instance_id {
174173
None => {
175-
if asset_server.load_state(&scene_handle.gltf_handle) == LoadState::Loaded {
174+
if asset_server
175+
.load_state(&scene_handle.gltf_handle)
176+
.is_loaded()
177+
{
176178
let gltf = gltf_assets.get(&scene_handle.gltf_handle).unwrap();
177179
if gltf.scenes.len() > 1 {
178180
info!(
@@ -205,10 +207,10 @@ fn scene_load_check(
205207
});
206208

207209
let root = commands
208-
.spawn(SpatialBundle {
209-
transform: Transform::from_scale(Vec3::splat(1.0)),
210-
..Default::default()
211-
})
210+
.spawn((
211+
Transform::from_scale(Vec3::splat(1.0)),
212+
Visibility::default(),
213+
))
212214
.id();
213215
scene_handle.instance_id =
214216
Some(scene_spawner.spawn_as_child(gltf_scene_handle.clone_weak(), root));
@@ -321,15 +323,17 @@ fn setup_anim_after_load(
321323
};
322324
let graph = graphs.add(graph);
323325
player.play(clips[0]).repeat();
324-
commands.entity(player_entity).insert(graph);
326+
commands
327+
.entity(player_entity)
328+
.insert(AnimationGraphHandle(graph));
325329
}
326330
}
327331

328332
fn setup_scene_after_load(
329333
mut commands: Commands,
330334
mut setup: Local<bool>,
331335
mut scene_handle: ResMut<SceneHandle>,
332-
meshes: Query<(&GlobalTransform, Option<&Aabb>), With<Handle<Mesh>>>,
336+
meshes: Query<(&GlobalTransform, Option<&Aabb>), With<Mesh3d>>,
333337
scene_spawner: Res<SceneSpawner>,
334338
) {
335339
if scene_handle.is_loaded && !*setup {
@@ -399,18 +403,10 @@ fn setup_scene_after_load(
399403
info!("{:?}", *scene_handle);
400404

401405
commands.spawn((
402-
Camera3dBundle {
403-
projection: projection.into(),
404-
transform: Transform::from_translation(
405-
Vec3::from(aabb.center) + size * Vec3::new(0.5, 0.25, 0.5),
406-
)
406+
Camera3d::default(),
407+
Projection::from(projection),
408+
Transform::from_translation(Vec3::from(aabb.center) + size * Vec3::new(0.5, 0.25, 0.5))
407409
.looking_at(Vec3::from(aabb.center), Vec3::Y),
408-
camera: Camera {
409-
is_active: true,
410-
..default()
411-
},
412-
..default()
413-
},
414410
camera_controller,
415411
RenderLayers::default().with(1), // we keep imposters off the primary renderlayer to avoid imposterception
416412
));
@@ -419,10 +415,8 @@ fn setup_scene_after_load(
419415
if !scene_handle.has_light {
420416
info!("Spawning a directional light");
421417
commands.spawn((
422-
DirectionalLightBundle {
423-
transform: Transform::from_xyz(1.0, 1.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
424-
..default()
425-
},
418+
DirectionalLight::default(),
419+
Transform::from_xyz(1.0, 1.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
426420
RenderLayers::default().with(1),
427421
));
428422

@@ -485,46 +479,40 @@ fn impost(
485479
rng.gen_range(rotate_range.clone()) * hemi_mult,
486480
);
487481
commands.spawn((
488-
MaterialMeshBundle {
489-
mesh: meshes.add(Plane3d::new(Vec3::Z, Vec2::splat(0.5))),
490-
transform: Transform::from_translation(
491-
translation + Vec3::from(scene_handle.sphere.center),
492-
)
482+
Mesh3d(meshes.add(Plane3d::new(Vec3::Z, Vec2::splat(0.5)))),
483+
Transform::from_translation(translation + Vec3::from(scene_handle.sphere.center))
493484
.with_rotation(Quat::from_euler(
494485
EulerRot::XYZ,
495486
rotation.x,
496487
rotation.y,
497488
rotation.z,
498489
)),
499-
material: materials.add(Imposter {
500-
data: ImposterData::new(
501-
Vec3::ZERO,
502-
scene_handle.sphere.radius,
503-
settings.grid_size,
504-
settings.tile_size,
505-
UVec2::ZERO,
506-
UVec2::splat(settings.tile_size),
507-
settings.mode,
508-
settings.multisample_target,
509-
false,
510-
1.0,
511-
),
512-
pixels: camera.target.clone().unwrap(),
513-
indices: dummy_indices.0.clone(),
514-
alpha_mode: AlphaMode::Blend,
515-
vram_bytes: 0,
516-
}),
517-
..Default::default()
518-
},
490+
MeshMaterial3d(materials.add(Imposter {
491+
data: ImposterData::new(
492+
Vec3::ZERO,
493+
scene_handle.sphere.radius,
494+
settings.grid_size,
495+
settings.tile_size,
496+
UVec2::ZERO,
497+
UVec2::splat(settings.tile_size),
498+
settings.mode,
499+
settings.multisample_target,
500+
false,
501+
1.0,
502+
),
503+
pixels: camera.target.clone().unwrap(),
504+
indices: dummy_indices.0.clone(),
505+
alpha_mode: AlphaMode::Blend,
506+
vram_bytes: 0,
507+
})),
519508
RenderLayers::layer(1),
520509
));
521510
}
522511

523-
commands.spawn(ImposterBakeBundle {
512+
commands.spawn((
524513
camera,
525-
transform: Transform::from_translation(scene_handle.sphere.center.into()),
526-
..Default::default()
527-
});
514+
Transform::from_translation(scene_handle.sphere.center.into()),
515+
));
528516
}
529517
}
530518

@@ -548,7 +536,7 @@ fn update_lights(
548536
transform.rotation = Quat::from_euler(
549537
EulerRot::ZYX,
550538
0.0,
551-
time.elapsed_seconds() * PI / 15.0,
539+
time.elapsed_secs() * PI / 15.0,
552540
-FRAC_PI_4,
553541
);
554542
}
@@ -560,7 +548,7 @@ pub struct Rotate;
560548

561549
fn rotate(mut q: Query<&mut Transform, With<Rotate>>, time: Res<Time>) {
562550
for mut t in q.iter_mut() {
563-
t.rotation = Quat::from_rotation_y(time.elapsed_seconds());
551+
t.rotation = Quat::from_rotation_y(time.elapsed_secs());
564552
}
565553
}
566554

0 commit comments

Comments
 (0)