Skip to content

Commit dd5a276

Browse files
committed
Sync PP
1 parent 56297a2 commit dd5a276

File tree

47 files changed

+789
-509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+789
-509
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.1"
18+
"wle-pp": "0.7.2"
1919
},
2020
"devDependencies": {
2121
"eslint": "^9.13.0",

wle_pplaygrounds/wle_pplayground/wle_pplayground/src/playground/components/particles_spawner_component.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class ParticlesSpawnerComponent extends Component {
1010
};
1111

1212
start() {
13-
this._myFirstUpdate = true;
13+
this._myStartFrameCountdown = 1;
1414
}
1515

1616
_start() {
@@ -39,22 +39,26 @@ export class ParticlesSpawnerComponent extends Component {
3939
}
4040

4141
update(dt) {
42-
if (this._myFirstUpdate) {
43-
this._start();
44-
this._myFirstUpdate = false;
42+
if (this._myStartFrameCountdown > 0) {
43+
this._myStartFrameCountdown--;
44+
if (this._myStartFrameCountdown == 0) {
45+
this._start();
46+
}
4547
}
4648
}
4749

4850
spawn(position) {
49-
let amount = Math.pp_randomInt(15, 30);
51+
if (this._myStartFrameCountdown == 0) {
52+
let amount = Math.pp_randomInt(15, 30);
5053

51-
for (let i = 0; i < amount; i++) {
52-
let particle = Globals.getObjectPoolManager(this.engine).get(this._getParticlePoolID(Math.pp_randomInt(0, this._myParticles.length - 1)));
53-
particle.pp_getComponent(ParticleComponent).onDone(this._onParticleDone.bind(this, particle));
54+
for (let i = 0; i < amount; i++) {
55+
let particle = Globals.getObjectPoolManager(this.engine).get(this._getParticlePoolID(Math.pp_randomInt(0, this._myParticles.length - 1)));
56+
particle.pp_getComponent(ParticleComponent).onDone(this._onParticleDone.bind(this, particle));
5457

55-
particle.pp_setPosition(position.vec3_add(particle.pp_getComponent(ParticleComponent)._myHorizontalSpeed.vec3_normalize().vec3_scale(Math.pp_random(0, this._myRadius))));
58+
particle.pp_setPosition(position.vec3_add(particle.pp_getComponent(ParticleComponent)._myHorizontalSpeed.vec3_normalize().vec3_scale(Math.pp_random(0, this._myRadius))));
5659

57-
particle.pp_setActive(true);
60+
particle.pp_setActive(true);
61+
}
5862
}
5963
}
6064

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/playground/components/particles_spawner_component.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class ParticlesSpawnerComponent extends Component {
1010
};
1111

1212
start() {
13-
this._myFirstUpdate = true;
13+
this._myStartFrameCountdown = 1;
1414
}
1515

1616
_start() {
@@ -39,22 +39,26 @@ export class ParticlesSpawnerComponent extends Component {
3939
}
4040

4141
update(dt) {
42-
if (this._myFirstUpdate) {
43-
this._start();
44-
this._myFirstUpdate = false;
42+
if (this._myStartFrameCountdown > 0) {
43+
this._myStartFrameCountdown--;
44+
if (this._myStartFrameCountdown == 0) {
45+
this._start();
46+
}
4547
}
4648
}
4749

4850
spawn(position) {
49-
let amount = Math.pp_randomInt(15, 30);
51+
if (this._myStartFrameCountdown == 0) {
52+
let amount = Math.pp_randomInt(15, 30);
5053

51-
for (let i = 0; i < amount; i++) {
52-
let particle = Globals.getObjectPoolManager(this.engine).get(this._getParticlePoolID(Math.pp_randomInt(0, this._myParticles.length - 1)));
53-
particle.pp_getComponent(ParticleComponent).onDone(this._onParticleDone.bind(this, particle));
54+
for (let i = 0; i < amount; i++) {
55+
let particle = Globals.getObjectPoolManager(this.engine).get(this._getParticlePoolID(Math.pp_randomInt(0, this._myParticles.length - 1)));
56+
particle.pp_getComponent(ParticleComponent).onDone(this._onParticleDone.bind(this, particle));
5457

55-
particle.pp_setPosition(position.vec3_add(particle.pp_getComponent(ParticleComponent)._myHorizontalSpeed.vec3_normalize().vec3_scale(Math.pp_random(0, this._myRadius))));
58+
particle.pp_setPosition(position.vec3_add(particle.pp_getComponent(ParticleComponent)._myHorizontalSpeed.vec3_normalize().vec3_scale(Math.pp_random(0, this._myRadius))));
5659

57-
particle.pp_setActive(true);
60+
particle.pp_setActive(true);
61+
}
5862
}
5963
}
6064

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/pp/cauldron/visual/visual_manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ export class VisualManager {
4141

4242
public setActive(active: boolean): void {
4343
if (this._myActive != active) {
44-
this._myActive = active;
45-
46-
if (!this._myActive) {
44+
if (!active) {
4745
this.clearAllVisualElements();
4846
} else {
4947
this._myVisualElementsParent = Globals.getSceneObjects(this._myEngine)?.myVisualElements ?? null;
5048
}
49+
50+
this._myActive = active;
5151
}
5252
}
5353

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/pp/debug/components/debug_manager_component.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ export class DebugManagerComponent extends Component {
2121
this._myInitDone = true;
2222
}
2323

24-
start() {
24+
update(dt) {
2525
if (!this._myInitDone && Globals.isDebugEnabled(this.engine)) {
2626
this._init();
27+
28+
if (this._myDebugManager != null && !Globals.hasDebugManager(this.engine)) {
29+
Globals.setDebugManager(this._myDebugManager, this.engine);
30+
}
31+
} else if (this._myDebugManager != null && !Globals.hasDebugManager(this.engine) &&
32+
Globals.isDebugEnabled(this.engine) && this._myCurrentActive != Globals.isDebugEnabled(this.engine)) {
33+
Globals.setDebugManager(this._myDebugManager, this.engine);
2734
}
28-
}
2935

30-
update(dt) {
3136
if (this._myDebugManager != null && Globals.getDebugManager(this.engine) == this._myDebugManager) {
3237
if (this._myCurrentActive != Globals.isDebugEnabled(this.engine)) {
3338
this._myCurrentActive = Globals.isDebugEnabled(this.engine);
@@ -46,14 +51,6 @@ export class DebugManagerComponent extends Component {
4651
}
4752

4853
this._myDebugManager.update(dt);
49-
} else if (!this._myInitDone && Globals.isDebugEnabled(this.engine)) {
50-
this._init();
51-
}
52-
}
53-
54-
onActivate() {
55-
if (this._myDebugManager != null && !Globals.hasDebugManager(this.engine)) {
56-
Globals.setDebugManager(this._myDebugManager, this.engine);
5754
}
5855
}
5956

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/pp/debug/components/enable_debug_component.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ export class EnableDebugComponent extends Component {
77
_myEnable: Property.bool(true)
88
};
99

10-
init() {
10+
start() {
11+
this._myHasDebugEnabled = this._myEnable;
1112
this._myDebugEnabled = this._myEnable;
1213
}
1314

1415
onActivate() {
15-
if (!Globals.hasDebugEnabled(this.engine)) {
16+
if (this._myHasDebugEnabled) {
1617
Globals.setDebugEnabled(this._myDebugEnabled, this.engine);
1718
}
1819
}
1920

2021
onDeactivate() {
21-
if (Globals.isDebugEnabled(this.engine) == this._myDebugEnabled) {
22-
Globals.removeDebugEnabled(this.engine);
23-
}
22+
this._myHasDebugEnabled = Globals.hasDebugEnabled();
23+
this._myDebugEnabled = Globals.isDebugEnabled();
24+
Globals.removeDebugEnabled(this.engine);
2425
}
2526
}

wle_pplaygrounds/wle_pplayground/wle_pplayground_pipo/src/pp/debug/components/show_fps_component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class ShowFPSComponent extends Component {
3030
}
3131

3232
update(dt) {
33-
if (Globals.isDebugEnabled(this.engine)) {
33+
if (Globals.isDebugEnabled(this.engine) && Globals.getDebugVisualManager(this.engine) != null) {
3434
this._myTotalDT += dt;
3535
this._myFrames++;
3636

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export class CharacterColliderSetupSimplifiedCreationParams {
3939

4040

4141
public myCollectGroundInfo: boolean = false;
42-
public myShouldSnapOnGround: boolean = false;
4342
public myMaxDistanceToSnapOnGround: number = 0;
43+
public myMaxDistanceToPopOutGround: number = 0;
4444
public myMaxWalkableGroundAngle: number = 0;
4545
public myMaxWalkableGroundStepHeight: number = 0;
4646

@@ -86,11 +86,10 @@ export function createSimplified(simplifiedCreationParams: Readonly<CharacterCol
8686

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

89-
outCharacterColliderSetup.myGroundParams.mySurfaceSnapEnabled = simplifiedCreationParams.myShouldSnapOnGround;
89+
outCharacterColliderSetup.myGroundParams.mySurfaceSnapEnabled = simplifiedCreationParams.myMaxDistanceToSnapOnGround > 0;
9090
outCharacterColliderSetup.myGroundParams.mySurfaceSnapMaxDistance = simplifiedCreationParams.myMaxDistanceToSnapOnGround;
91-
outCharacterColliderSetup.myGroundParams.mySurfacePopOutEnabled = true;
92-
outCharacterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance = simplifiedCreationParams.myMaxDistanceToSnapOnGround > 0 ?
93-
simplifiedCreationParams.myMaxDistanceToSnapOnGround : (simplifiedCreationParams.myRadius > 0.1) ? 0.1 : 0.01;
91+
outCharacterColliderSetup.myGroundParams.mySurfacePopOutEnabled = simplifiedCreationParams.myMaxDistanceToPopOutGround > 0;
92+
outCharacterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance = simplifiedCreationParams.myMaxDistanceToPopOutGround;
9493
outCharacterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance = Math.max(outCharacterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance, outCharacterColliderSetup.myHorizontalCheckParams.myHorizontalCheckFeetDistanceToIgnore);
9594

9695
outCharacterColliderSetup.myGroundParams.myHorizontalMovementSurfaceAngleToIgnoreMaxHorizontalMovementLeft = simplifiedCreationParams.myRadius * 0.75;
@@ -121,7 +120,7 @@ export function createSimplified(simplifiedCreationParams: Readonly<CharacterCol
121120

122121
if (simplifiedCreationParams.myCheckCeilings) {
123122
outCharacterColliderSetup.myCeilingParams.mySurfacePopOutEnabled = outCharacterColliderSetup.myGroundParams.mySurfacePopOutEnabled;
124-
outCharacterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance = outCharacterColliderSetup.myGroundParams.mySurfacePopOutMaxDistance;
123+
outCharacterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance = simplifiedCreationParams.myMaxDistanceToPopOutGround;
125124
outCharacterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance = Math.max(outCharacterColliderSetup.myCeilingParams.mySurfacePopOutMaxDistance, outCharacterColliderSetup.myHorizontalCheckParams.myHorizontalCheckHeadDistanceToIgnore);
126125

127126
outCharacterColliderSetup.myCeilingParams.myHorizontalMovementSurfaceAngleToIgnoreMaxHorizontalMovementLeft = outCharacterColliderSetup.myGroundParams.myHorizontalMovementSurfaceAngleToIgnoreMaxHorizontalMovementLeft;

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

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export class PlayerLocomotionComponent extends Component {
2626
@property.bool(true)
2727
private readonly _mySwitchLocomotionTypeShortcutEnabled!: boolean;
2828

29+
@property.bool(false)
30+
private readonly _myStartIdle!: boolean;
31+
2932
@property.string("0, 0, 0, 0, 0, 0, 0, 0")
3033
private readonly _myPhysicsBlockLayerFlags!: string;
3134

@@ -211,12 +214,11 @@ export class PlayerLocomotionComponent extends Component {
211214

212215
/**
213216
* To avoid occlusion issues when moving when touching a tilted ceiling (which is not commong anyway),
214-
* this would be better to be less or equal than the feet radius of the character (usually half of {@link _myCharacterRadius})
215-
* Increasing {@link _myColliderExtraHeight} can help reducing the view occlusion
217+
* this value should be a bit lower than {@link _myCharacterFeetRadius}
216218
*
217219
* If you have a high camera near value, you might need to increase this value, even though the view occlusion might become more aggressive
218220
*/
219-
@property.float(0.15)
221+
@property.float(0.145)
220222
private readonly _myViewOcclusionHeadRadius!: number;
221223

222224
/**
@@ -295,6 +297,9 @@ export class PlayerLocomotionComponent extends Component {
295297
@property.float(0.1)
296298
private readonly _myColliderMaxDistanceToSnapOnGround!: number;
297299

300+
@property.float(0.2)
301+
private readonly _myColliderMaxDistanceToPopOutGround!: number;
302+
298303
@property.float(0.1)
299304
private readonly _myColliderMaxWalkableGroundStepHeight!: number;
300305

@@ -371,7 +376,7 @@ export class PlayerLocomotionComponent extends Component {
371376

372377

373378

374-
private readonly _myPlayerLocomotion!: PlayerLocomotion;
379+
private readonly _myPlayerLocomotion: PlayerLocomotion | null = null;
375380

376381
private _myRegisterToPostPoseUpdateOnNextUpdate: boolean = false;
377382
private _myActivateOnNextPostPoseUpdate: boolean = false;
@@ -388,6 +393,7 @@ export class PlayerLocomotionComponent extends Component {
388393
params.myDefaultLocomotionType = this._myDefaultLocomotionType;
389394
params.myAlwaysSmoothForNonVR = this._myAlwaysSmoothForNonVR;
390395
params.mySwitchLocomotionTypeShortcutEnabled = this._mySwitchLocomotionTypeShortcutEnabled;
396+
params.myStartIdle = this._myStartIdle;
391397

392398
params.myDefaultHeight = this._myDefaultHeight;
393399
params.myMinHeight = this._myMinHeight;
@@ -464,6 +470,7 @@ export class PlayerLocomotionComponent extends Component {
464470
params.myColliderMaxTeleportableGroundAngle = this._myColliderMaxTeleportableGroundAngle < 0 ? null : this._myColliderMaxTeleportableGroundAngle;
465471
params.myColliderSnapOnGround = this._myColliderSnapOnGround;
466472
params.myColliderMaxDistanceToSnapOnGround = this._myColliderMaxDistanceToSnapOnGround;
473+
params.myColliderMaxDistanceToPopOutGround = this._myColliderMaxDistanceToPopOutGround;
467474
params.myColliderMaxWalkableGroundStepHeight = this._myColliderMaxWalkableGroundStepHeight;
468475
params.myColliderMaxWalkableCeilingStepHeight = this._myColliderMaxWalkableCeilingStepHeight;
469476
params.myColliderPreventFallingFromEdges = this._myColliderPreventFallingFromEdges;
@@ -504,13 +511,14 @@ export class PlayerLocomotionComponent extends Component {
504511

505512
if (manualUpdate) return;
506513

514+
let setPlayerLocomotionOnGlobals = false;
507515
if (this._myActivateOnNextPostPoseUpdate) {
508-
this._onActivate();
516+
setPlayerLocomotionOnGlobals = this._onActivate();
509517

510518
this._myActivateOnNextPostPoseUpdate = false;
511519
}
512520

513-
if (Globals.getPlayerLocomotion(this.engine) != this._myPlayerLocomotion) return;
521+
if (!setPlayerLocomotionOnGlobals && Globals.hasPlayerLocomotion(this.engine) && Globals.getPlayerLocomotion(this.engine) != this._myPlayerLocomotion) return;
514522

515523
let startTime = 0;
516524
if (this._myPerformanceLogEnabled && Globals.isDebugEnabled(this.engine)) {
@@ -527,11 +535,11 @@ export class PlayerLocomotionComponent extends Component {
527535
PhysicsUtils.resetRaycastCount(this.engine.physics!);
528536
}
529537

530-
if (!this._myPlayerLocomotion.isStarted()) {
531-
this._myPlayerLocomotion.start();
538+
if (!this._myPlayerLocomotion!.isStarted()) {
539+
this._myPlayerLocomotion!.start();
532540
}
533541

534-
this._myPlayerLocomotion.update(dt);
542+
this._myPlayerLocomotion!.update(dt);
535543

536544
if (this._myPerformanceLogEnabled && Globals.isDebugEnabled(this.engine)) {
537545
const endTime = window.performance.now();
@@ -559,9 +567,17 @@ export class PlayerLocomotionComponent extends Component {
559567
console.log("Raycast count: " + PhysicsUtils.getRaycastCount(this.engine.physics!));
560568
PhysicsUtils.resetRaycastCount(this.engine.physics!);
561569
}
570+
571+
if (setPlayerLocomotionOnGlobals && !Globals.hasPlayerLocomotion(this.engine)) {
572+
// This is done to only set the global when the locomotion is active and updated, so "ready"
573+
Globals.setPlayerLocomotion(this._myPlayerLocomotion!, this.engine);
574+
} else if (setPlayerLocomotionOnGlobals && Globals.getPlayerLocomotion(this.engine) != this._myPlayerLocomotion) {
575+
// If someone in some way managed to set the globals, just deactivate this one, which was just being activated since the flag is true
576+
this._myPlayerLocomotion!.setActive(false);
577+
}
562578
}
563579

564-
public getPlayerLocomotion(): PlayerLocomotion {
580+
public getPlayerLocomotion(): PlayerLocomotion | null {
565581
return this._myPlayerLocomotion;
566582
}
567583

@@ -582,15 +598,19 @@ export class PlayerLocomotionComponent extends Component {
582598
}
583599
}
584600

585-
private _onActivate(): void {
601+
private _onActivate(): boolean {
602+
let setPlayerLocomotionOnGlobals = false;
603+
586604
if (this._myPlayerLocomotion == null) {
587605
this._start();
588606
}
589607

590608
if (!Globals.hasPlayerLocomotion(this.engine)) {
591-
this._myPlayerLocomotion.setActive(true);
592-
Globals.setPlayerLocomotion(this._myPlayerLocomotion, this.engine);
609+
this._myPlayerLocomotion!.setActive(true);
610+
setPlayerLocomotionOnGlobals = true;
593611
}
612+
613+
return setPlayerLocomotionOnGlobals;
594614
}
595615

596616
private _getPhysicsBlockLayersFlags(): PhysicsLayerFlags {

0 commit comments

Comments
 (0)