0.16 support
This commit is contained in:
@@ -2,15 +2,15 @@ use core::panic;
|
||||
|
||||
use bevy::app::{App, Plugin, PostUpdate};
|
||||
use bevy::core_pipeline::core_3d::Camera3d;
|
||||
use bevy::ecs::component::{Component, StorageType};
|
||||
use bevy::ecs::component::{Component, HookContext, Mutable, StorageType};
|
||||
use bevy::ecs::reflect::ReflectComponent;
|
||||
use bevy::ecs::schedule::IntoSystemConfigs;
|
||||
use bevy::ecs::world::DeferredWorld;
|
||||
use bevy::math::{Mat4, Vec3A, Vec4};
|
||||
use bevy::pbr::{PbrPlugin, PbrProjectionPlugin};
|
||||
use bevy::prelude::{Projection, SystemSet};
|
||||
use bevy::reflect::std_traits::ReflectDefault;
|
||||
use bevy::reflect::Reflect;
|
||||
use bevy::render::camera::{CameraProjection, CameraProjectionPlugin};
|
||||
use bevy::render::camera::{CameraProjection, CameraProjectionPlugin, CustomProjection};
|
||||
use bevy::render::extract_component::{ExtractComponent, ExtractComponentPlugin};
|
||||
use bevy::render::view::{update_frusta, VisibilitySystems};
|
||||
use bevy::transform::TransformSystem;
|
||||
@@ -21,7 +21,7 @@ pub struct XrCameraPlugin;
|
||||
|
||||
impl Plugin for XrCameraPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins(CameraProjectionPlugin::<XrProjection>::default());
|
||||
/*app.add_plugins(CameraProjectionPlugin::<XrProjection>::default());
|
||||
app.add_systems(
|
||||
PostUpdate,
|
||||
update_frusta::<XrProjection>
|
||||
@@ -30,31 +30,23 @@ impl Plugin for XrCameraPlugin {
|
||||
);
|
||||
if app.is_plugin_added::<PbrPlugin>() {
|
||||
app.add_plugins(PbrProjectionPlugin::<XrProjection>::default());
|
||||
}
|
||||
app.add_plugins((
|
||||
ExtractComponentPlugin::<XrProjection>::default(),
|
||||
ExtractComponentPlugin::<XrCamera>::default(),
|
||||
));
|
||||
}*/
|
||||
app.add_plugins((ExtractComponentPlugin::<XrCamera>::default(),));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Default, PartialEq, Eq, Debug, Hash, SystemSet)]
|
||||
pub struct XrViewInit;
|
||||
|
||||
#[derive(Debug, Clone, Reflect, ExtractComponent)]
|
||||
#[reflect(Component, Default)]
|
||||
#[derive(Debug, Clone, Reflect)]
|
||||
#[reflect(Default)]
|
||||
pub struct XrProjection {
|
||||
pub projection_matrix: Mat4,
|
||||
pub near: f32,
|
||||
}
|
||||
impl Component for XrProjection {
|
||||
const STORAGE_TYPE: StorageType = StorageType::Table;
|
||||
|
||||
fn register_component_hooks(hooks: &mut bevy::ecs::component::ComponentHooks) {
|
||||
hooks.on_add(|mut world, entity, _| {
|
||||
world.commands().entity(entity).remove::<Projection>();
|
||||
});
|
||||
}
|
||||
fn on_projection_add(mut world: DeferredWorld, HookContext { entity, .. }: HookContext) {
|
||||
world.commands().entity(entity).remove::<Projection>();
|
||||
}
|
||||
|
||||
impl Default for XrProjection {
|
||||
@@ -68,7 +60,7 @@ impl Default for XrProjection {
|
||||
|
||||
/// Marker component for an XR view. It is the backends responsibility to update this.
|
||||
#[derive(Clone, Copy, Component, ExtractComponent, Debug, Default)]
|
||||
#[require(Camera3d, XrProjection, XrTracker)]
|
||||
#[require(Camera3d, XrTracker)]
|
||||
pub struct XrCamera(pub u32);
|
||||
|
||||
impl CameraProjection for XrProjection {
|
||||
|
||||
Reference in New Issue
Block a user