-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
features - `AvatarAttach` - `Visibility` - `PointerResults`: - add normal - add position - add scene entity to hit result for events sent to scene roots - collisions - add DisableCollisions marker, apply to `AvatarAttach`ed items - mock js modules bugfixes - animations - fix path bug (inc bevy patch [#9407](bevyengine/bevy#9407)) that caused anims to play on the wrong nodes - play gltf first animation if no animator present - play animation resets the anim (only if not looping) - fix main.crdt buffer overrun - fix collider pipeline use-before-init crash - system log chat tab now updates live without forcing reload - chat tab wraps correctly - send transform updates to scene only if they are changed - don't validate the `main_file` for texture wearables, just look for pngs - AudioSource - only plays in current scene - use manual spatial calc to preserve requested volume tweaks - increase base move speed - vsync off by default - update to latest protobuf messages
- Loading branch information
Showing
68 changed files
with
2,066 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use bevy::prelude::*; | ||
|
||
use common::{ | ||
sets::SceneSets, | ||
structs::{AttachPoints, PrimaryUser}, | ||
util::TryInsertEx, | ||
}; | ||
use dcl::interface::ComponentPosition; | ||
use dcl_component::{ | ||
proto_components::sdk::components::{AvatarAnchorPointType, PbAvatarAttach}, | ||
SceneComponentId, | ||
}; | ||
use scene_runner::update_world::{ | ||
mesh_collider::DisableCollisions, transform_and_parent::ParentPositionSync, AddCrdtInterfaceExt, | ||
}; | ||
|
||
pub struct AttachPlugin; | ||
|
||
impl Plugin for AttachPlugin { | ||
fn build(&self, app: &mut App) { | ||
app.add_crdt_lww_component::<PbAvatarAttach, AvatarAttachment>( | ||
SceneComponentId::AVATAR_ATTACHMENT, | ||
ComponentPosition::Any, | ||
); | ||
app.add_systems(Update, update_attached.in_set(SceneSets::PostLoop)); | ||
} | ||
} | ||
|
||
#[derive(Component, Debug)] | ||
pub struct AvatarAttachment(pub PbAvatarAttach); | ||
|
||
impl From<PbAvatarAttach> for AvatarAttachment { | ||
fn from(value: PbAvatarAttach) -> Self { | ||
Self(value) | ||
} | ||
} | ||
|
||
pub fn update_attached( | ||
mut commands: Commands, | ||
attachments: Query<(Entity, &AvatarAttachment), Changed<AvatarAttachment>>, | ||
mut removed_attachments: RemovedComponents<AvatarAttachment>, | ||
primary_user: Query<&AttachPoints, With<PrimaryUser>>, | ||
) { | ||
for removed in removed_attachments.iter() { | ||
if let Some(mut commands) = commands.get_entity(removed) { | ||
commands.remove::<(ParentPositionSync, DisableCollisions)>(); | ||
} | ||
} | ||
|
||
for (ent, attach) in attachments.iter() { | ||
let attach_points = if attach.0.avatar_id.is_none() { | ||
let Ok(data) = primary_user.get_single() else { | ||
warn!("no primary user"); | ||
continue; | ||
}; | ||
data | ||
} else { | ||
warn!("nope"); | ||
continue; | ||
}; | ||
|
||
let sync_entity = match attach.0.anchor_point_id() { | ||
AvatarAnchorPointType::AaptPosition => attach_points.position, | ||
AvatarAnchorPointType::AaptNameTag => attach_points.nametag, | ||
AvatarAnchorPointType::AaptLeftHand => attach_points.left_hand, | ||
AvatarAnchorPointType::AaptRightHand => attach_points.right_hand, | ||
}; | ||
|
||
commands | ||
.entity(ent) | ||
.try_insert((ParentPositionSync(sync_entity), DisableCollisions)); | ||
debug!("syncing {ent:?} to {sync_entity:?}"); | ||
} | ||
} |
Oops, something went wrong.