Skip to content

Commit 66ba215

Browse files
committed
Sync PP
1 parent dd5a276 commit 66ba215

File tree

28 files changed

+253
-229
lines changed

28 files changed

+253
-229
lines changed

wle_pplaygrounds/wle_pplayground/wle_pplayground/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wle_pplaygrounds/wle_pplayground/wle_pplayground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@wonderlandengine/components": "~1.1.5",
1616
"gl-matrix": "^3.4.3",
1717
"howler": "^2.2.4",
18-
"wle-pp": "0.7.2"
18+
"wle-pp": "0.7.3"
1919
},
2020
"devDependencies": {
2121
"eslint": "^9.13.0",

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/pp/gameplay/experimental/character_controller/collision/character_collider_setup.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,7 @@ export class CharacterColliderWallSlideParams {
211211
export class CharacterColliderSurfaceParams {
212212

213213
constructor() {
214-
this.mySurfaceSnapEnabled = false;
215214
this.mySurfaceSnapMaxDistance = 0;
216-
217-
this.mySurfacePopOutEnabled = false;
218215
this.mySurfacePopOutMaxDistance = 0;
219216

220217
this.mySurfaceAngleToIgnore = 0;
@@ -507,10 +504,7 @@ CharacterColliderWallSlideParams.prototype.copy = function copy(other) {
507504
};
508505

509506
CharacterColliderSurfaceParams.prototype.copy = function copy(other) {
510-
this.mySurfaceSnapEnabled = other.mySurfaceSnapEnabled;
511507
this.mySurfaceSnapMaxDistance = other.mySurfaceSnapMaxDistance;
512-
513-
this.mySurfacePopOutEnabled = other.mySurfacePopOutEnabled;
514508
this.mySurfacePopOutMaxDistance = other.mySurfacePopOutMaxDistance;
515509

516510
this.mySurfaceAngleToIgnore = other.mySurfaceAngleToIgnore;

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/pp/gameplay/experimental/character_controller/collision/character_collider_setup_utils.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@ export function createSimplified(simplifiedCreationParams: Readonly<CharacterCol
8686

8787
outCharacterColliderSetup.myHorizontalCheckParams.myHorizontalCheckFeetDistanceToIgnore = simplifiedCreationParams.myMaxWalkableGroundStepHeight;
8888

89-
outCharacterColliderSetup.myGroundParams.mySurfaceSnapEnabled = simplifiedCreationParams.myMaxDistanceToSnapOnGround > 0;
9089
outCharacterColliderSetup.myGroundParams.mySurfaceSnapMaxDistance = simplifiedCreationParams.myMaxDistanceToSnapOnGround;
91-
outCharacterColliderSetup.myGroundParams.mySurfacePopOutEnabled = simplifiedCreationParams.myMaxDistanceToPopOutGround > 0;
92-
outCharacterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance = simplifiedCreationParams.myMaxDistanceToPopOutGround;
93-
outCharacterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance = Math.max(outCharacterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance, outCharacterColliderSetup.myHorizontalCheckParams.myHorizontalCheckFeetDistanceToIgnore);
90+
outCharacterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance = Math.max(simplifiedCreationParams.myMaxDistanceToPopOutGround, outCharacterColliderSetup.myHorizontalCheckParams.myHorizontalCheckFeetDistanceToIgnore);
9491

9592
outCharacterColliderSetup.myGroundParams.myHorizontalMovementSurfaceAngleToIgnoreMaxHorizontalMovementLeft = simplifiedCreationParams.myRadius * 0.75;
9693

@@ -119,9 +116,7 @@ export function createSimplified(simplifiedCreationParams: Readonly<CharacterCol
119116
outCharacterColliderSetup.myHorizontalCheckParams.myHorizontalCheckHeadDistanceToIgnore = simplifiedCreationParams.myMaxWalkableCeilingStepHeight;
120117

121118
if (simplifiedCreationParams.myCheckCeilings) {
122-
outCharacterColliderSetup.myCeilingParams.mySurfacePopOutEnabled = outCharacterColliderSetup.myGroundParams.mySurfacePopOutEnabled;
123-
outCharacterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance = simplifiedCreationParams.myMaxDistanceToPopOutGround;
124-
outCharacterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance = Math.max(outCharacterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance, outCharacterColliderSetup.myHorizontalCheckParams.myHorizontalCheckHeadDistanceToIgnore);
119+
outCharacterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance = Math.max(simplifiedCreationParams.myMaxDistanceToPopOutGround, outCharacterColliderSetup.myHorizontalCheckParams.myHorizontalCheckHeadDistanceToIgnore);
125120

126121
outCharacterColliderSetup.myCeilingParams.myHorizontalMovementSurfaceAngleToIgnoreMaxHorizontalMovementLeft = outCharacterColliderSetup.myGroundParams.myHorizontalMovementSurfaceAngleToIgnoreMaxHorizontalMovementLeft;
127122

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/pp/gameplay/experimental/character_controller/collision/collision_check_bridge.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,14 @@ export let convertCharacterColliderSetupToCollisionCheckParams = function () {
425425
outCollisionCheckParams.myHorizontalBlockColliderType = characterColliderSetup.myHorizontalCheckParams.myHorizontalBlockColliderType;
426426
outCollisionCheckParams.myVerticalBlockColliderType = characterColliderSetup.myVerticalCheckParams.myVerticalBlockColliderType;
427427

428-
outCollisionCheckParams.mySnapOnGroundEnabled = characterColliderSetup.myGroundParams.mySurfaceSnapEnabled;
428+
outCollisionCheckParams.mySnapOnGroundEnabled = characterColliderSetup.myGroundParams.mySurfaceSnapMaxDistance > 0;
429429
outCollisionCheckParams.mySnapOnGroundExtraDistance = characterColliderSetup.myGroundParams.mySurfaceSnapMaxDistance;
430-
outCollisionCheckParams.mySnapOnCeilingEnabled = characterColliderSetup.myCeilingParams.mySurfaceSnapEnabled;
430+
outCollisionCheckParams.mySnapOnCeilingEnabled = characterColliderSetup.myCeilingParams.mySurfaceSnapMaxDistance > 0;
431431
outCollisionCheckParams.mySnapOnCeilingExtraDistance = characterColliderSetup.myCeilingParams.mySurfaceSnapMaxDistance;
432432

433-
outCollisionCheckParams.myGroundPopOutEnabled = characterColliderSetup.myGroundParams.mySurfacePopOutEnabled;
433+
outCollisionCheckParams.myGroundPopOutEnabled = characterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance > 0;
434434
outCollisionCheckParams.myGroundPopOutExtraDistance = characterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance;
435-
outCollisionCheckParams.myCeilingPopOutEnabled = characterColliderSetup.myCeilingParams.mySurfacePopOutEnabled;
435+
outCollisionCheckParams.myCeilingPopOutEnabled = characterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance > 0;
436436
outCollisionCheckParams.myCeilingPopOutExtraDistance = characterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance;
437437

438438
outCollisionCheckParams.myGroundAngleToIgnore = characterColliderSetup.myGroundParams.mySurfaceAngleToIgnore;

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/pp/gameplay/experimental/locomotion/legacy/locomotion/components/player_locomotion_component.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ import { PlayerLocomotion, PlayerLocomotionParams } from "../player_locomotion.j
99

1010
/**
1111
* Tips
12-
* - Be sure that your colliders has faces on both sides of the mesh, this helps the collision check which otherise might be able to move through walls
12+
* - Be sure that your colliders have faces on both sides of the mesh, this helps the collision check which otherise might be able to move through walls
1313
*/
1414
export class PlayerLocomotionComponent extends Component {
1515
public static override TypeName = "pp-player-locomotion";
1616

17-
18-
1917
@property.enum(["Smooth", "Teleport"], "Smooth")
2018
private readonly _myDefaultLocomotionType!: number;
2119

@@ -518,6 +516,10 @@ export class PlayerLocomotionComponent extends Component {
518516
this._myActivateOnNextPostPoseUpdate = false;
519517
}
520518

519+
if (!this._myPlayerLocomotion!.isStarted()) {
520+
this._myPlayerLocomotion!.start();
521+
}
522+
521523
if (!setPlayerLocomotionOnGlobals && Globals.hasPlayerLocomotion(this.engine) && Globals.getPlayerLocomotion(this.engine) != this._myPlayerLocomotion) return;
522524

523525
let startTime = 0;
@@ -535,10 +537,6 @@ export class PlayerLocomotionComponent extends Component {
535537
PhysicsUtils.resetRaycastCount(this.engine.physics!);
536538
}
537539

538-
if (!this._myPlayerLocomotion!.isStarted()) {
539-
this._myPlayerLocomotion!.start();
540-
}
541-
542540
this._myPlayerLocomotion!.update(dt);
543541

544542
if (this._myPerformanceLogEnabled && Globals.isDebugEnabled(this.engine)) {

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/pp/gameplay/experimental/locomotion/legacy/locomotion/player_locomotion.ts

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ export enum PlayerLocomotionType {
3636
export class PlayerLocomotionParams {
3737

3838
public myDefaultLocomotionType: number = PlayerLocomotionType.SMOOTH;
39-
public myAlwaysSmoothForNonVR: boolean = true;
39+
public myAlwaysSmoothForNonVR: boolean = false;
4040

4141
/** Double press main hand thumbstick (default: left) to switch */
42-
public mySwitchLocomotionTypeShortcutEnabled: boolean = true;
42+
public mySwitchLocomotionTypeShortcutEnabled: boolean = false;
4343

4444
public myStartIdle: boolean = false;
4545

@@ -59,7 +59,7 @@ export class PlayerLocomotionParams {
5959

6060
public myMaxSpeed: number = 0;
6161
public myMaxRotationSpeed: number = 0;
62-
public mySpeedSlowDownPercentageOnWallSlid: number = 1;
62+
public mySpeedSlowDownPercentageOnWallSlid: number = 0;
6363

6464

6565
public myGravityAcceleration: number = 0;
@@ -84,7 +84,7 @@ export class PlayerLocomotionParams {
8484

8585

8686
public myMainHand: Handedness = Handedness.LEFT;
87-
public myDirectionInvertForwardWhenUpsideDown: boolean = true;
87+
public myDirectionInvertForwardWhenUpsideDown: boolean = false;
8888
public myVRDirectionReferenceType: PlayerLocomotionDirectionReferenceType = PlayerLocomotionDirectionReferenceType.HEAD;
8989
public myVRDirectionReferenceObject: Readonly<Object3D> | null = null;
9090

@@ -101,7 +101,7 @@ export class PlayerLocomotionParams {
101101
public myTeleportParableStartReferenceObject: Readonly<Object3D> | null = null;
102102

103103

104-
public myResetRealOnStart: boolean = true;
104+
public myResetRealOnStart: boolean = false;
105105

106106
/**
107107
* #WARN With `_myResetRealOnStartFramesAmount` at `1` it can happen that you enter the session like 1 frame before the game load
@@ -115,7 +115,7 @@ export class PlayerLocomotionParams {
115115
* For example, if u have a total fade at start and nothing can be seen aside the clear color for at least, let's say, 10 frames,
116116
* you can set this to `3` safely, since there will be no visible stutter to be seen (beside the clear color)
117117
*/
118-
public myResetRealOnStartFramesAmount: number = 1;
118+
public myResetRealOnStartFramesAmount: number = 0;
119119

120120
/** Can fix some head through floor issues, when you can move your head completely to the other side of the floor
121121
If the floors are thick enough that this can't happen, you can leave this to false */
@@ -127,15 +127,15 @@ export class PlayerLocomotionParams {
127127

128128

129129
/** Valid means, for example, that the real player has not moved inside a wall by moving in the real space */
130-
public mySyncWithRealWorldPositionOnlyIfValid: boolean = true;
130+
public mySyncWithRealWorldPositionOnlyIfValid: boolean = false;
131131

132132
/** Valid means, for example, that the real player has not moved inside a wall by moving in the real space */
133-
public mySyncWithRealHeightOnlyIfValid: boolean = true;
133+
public mySyncWithRealHeightOnlyIfValid: boolean = false;
134134

135135
public mySnapRealPositionToGround: boolean = false;
136136
public myPreventRealFromColliding: boolean = false;
137137

138-
public myViewOcclusionInsideWallsEnabled: boolean = true;
138+
public myViewOcclusionInsideWallsEnabled: boolean = false;
139139
public myViewOcclusionLayerFlags: Readonly<PhysicsLayerFlags> = new PhysicsLayerFlags();
140140

141141
/**
@@ -227,7 +227,7 @@ export class PlayerLocomotionParams {
227227
/** Main hand (default: left) select + thumbstick press, auto switch to smooth */
228228
public myDebugFlyShortcutEnabled: boolean = false;
229229

230-
public myDebugFlyMaxSpeedMultiplier: number = 5;
230+
public myDebugFlyMaxSpeedMultiplier: number = 0;
231231

232232
/** Main hand (default: left) thumbstick pressed while moving */
233233
public myMoveThroughCollisionShortcutEnabled: boolean = false;
@@ -247,6 +247,7 @@ export class PlayerLocomotionParams {
247247
public myEngine: Readonly<WonderlandEngine>;
248248

249249

250+
250251
constructor(engine: Readonly<WonderlandEngine> = Globals.getMainEngine()!) {
251252
this.myEngine = engine;
252253
}
@@ -256,9 +257,10 @@ export class PlayerLocomotionParams {
256257
// #TODO Add lerped snap on vertical over like half a second to avoid the "snap effect"
257258
// This could be done by detatching the actual vertical position of the player from the collision real one when a snap is detected above a certain threshold
258259
// with a timer, after which the vertical position is just copied, while during the detatching is lerped toward the collision vertical one
260+
259261
/**
260262
* Tips
261-
* - Be sure that your colliders has faces on both sides of the mesh, this helps the collision check which otherise might be able to move through walls
263+
* - Be sure that your colliders have faces on both sides of the mesh, this helps the collision check which otherise might be able to move through walls
262264
*/
263265
export class PlayerLocomotion {
264266

@@ -333,6 +335,36 @@ export class PlayerLocomotion {
333335
params.myTeleportCollisionCheckParamsCheck360 = true;
334336
params.myTeleportCollisionCheckParamsGroundAngleToIgnore = this._myParams.myColliderMaxTeleportableGroundAngle;
335337

338+
params.mySyncEnabledFlagMap.set(PlayerTransformManagerSyncFlag.BODY_COLLIDING, true);
339+
params.mySyncEnabledFlagMap.set(PlayerTransformManagerSyncFlag.HEAD_COLLIDING, true);
340+
params.mySyncEnabledFlagMap.set(PlayerTransformManagerSyncFlag.FAR, true);
341+
params.mySyncEnabledFlagMap.set(PlayerTransformManagerSyncFlag.FLOATING, true);
342+
params.mySyncEnabledFlagMap.set(PlayerTransformManagerSyncFlag.HEIGHT_COLLIDING, true);
343+
344+
params.mySyncPositionFlagMap.set(PlayerTransformManagerSyncFlag.BODY_COLLIDING, true);
345+
params.mySyncPositionFlagMap.set(PlayerTransformManagerSyncFlag.HEAD_COLLIDING, false);
346+
params.mySyncPositionFlagMap.set(PlayerTransformManagerSyncFlag.FAR, true);
347+
params.mySyncPositionFlagMap.set(PlayerTransformManagerSyncFlag.FLOATING, true);
348+
params.mySyncPositionFlagMap.set(PlayerTransformManagerSyncFlag.HEIGHT_COLLIDING, false);
349+
350+
params.mySyncPositionHeadFlagMap.set(PlayerTransformManagerSyncFlag.BODY_COLLIDING, false);
351+
params.mySyncPositionHeadFlagMap.set(PlayerTransformManagerSyncFlag.HEAD_COLLIDING, true);
352+
params.mySyncPositionHeadFlagMap.set(PlayerTransformManagerSyncFlag.FAR, false);
353+
params.mySyncPositionHeadFlagMap.set(PlayerTransformManagerSyncFlag.FLOATING, false);
354+
params.mySyncPositionHeadFlagMap.set(PlayerTransformManagerSyncFlag.HEIGHT_COLLIDING, false);
355+
356+
params.mySyncRotationFlagMap.set(PlayerTransformManagerSyncFlag.BODY_COLLIDING, false);
357+
params.mySyncRotationFlagMap.set(PlayerTransformManagerSyncFlag.HEAD_COLLIDING, false);
358+
params.mySyncRotationFlagMap.set(PlayerTransformManagerSyncFlag.FAR, false);
359+
params.mySyncRotationFlagMap.set(PlayerTransformManagerSyncFlag.FLOATING, false);
360+
params.mySyncRotationFlagMap.set(PlayerTransformManagerSyncFlag.HEIGHT_COLLIDING, false);
361+
362+
params.mySyncHeightFlagMap.set(PlayerTransformManagerSyncFlag.BODY_COLLIDING, false);
363+
params.mySyncHeightFlagMap.set(PlayerTransformManagerSyncFlag.HEAD_COLLIDING, false);
364+
params.mySyncHeightFlagMap.set(PlayerTransformManagerSyncFlag.FAR, false);
365+
params.mySyncHeightFlagMap.set(PlayerTransformManagerSyncFlag.FLOATING, false);
366+
params.mySyncHeightFlagMap.set(PlayerTransformManagerSyncFlag.HEIGHT_COLLIDING, true);
367+
336368
params.myHeadCollisionBlockLayerFlags.copy(this._myParams.myViewOcclusionLayerFlags);
337369
params.myHeadCollisionObjectsToIgnore.pp_copy(params.myMovementCollisionCheckParams.myHorizontalObjectsToIgnore as any);
338370
const objectsEqualCallback = (first: Readonly<Object3D>, second: Readonly<Object3D>): boolean => first == second;
@@ -360,11 +392,9 @@ export class PlayerLocomotion {
360392

361393
if (!this._myParams.myViewOcclusionInsideWallsEnabled) {
362394
params.mySyncEnabledFlagMap.set(PlayerTransformManagerSyncFlag.HEAD_COLLIDING, false);
363-
364395
params.myAlwaysSyncHeadPositionWithReal = true;
365-
366-
params.myUpdatePositionHeadValid = false;
367-
params.myUpdateRealPositionHeadValid = false;
396+
} else {
397+
params.myUpdatePositionHeadValid = true;
368398
}
369399

370400
params.myApplyRealToValidAdjustmentsToRealPositionToo = this._myParams.mySnapRealPositionToGround;
@@ -427,6 +457,10 @@ export class PlayerLocomotion {
427457
params.myNeverResetRealRotationVR = false;
428458
params.myNeverResetRealHeightVR = true;
429459

460+
params.myResetRealResetRotationIfUpChanged = true;
461+
params.myResetHeadToFeetMoveTowardReal = true;
462+
params.myResetHeadToFeetUpOffset = 0.25;
463+
430464
params.myDebugEnabled = false;
431465

432466
this._myPlayerTransformManager = new PlayerTransformManager(params);

0 commit comments

Comments
 (0)