Skip to content

Commit 574b110

Browse files
committed
contact authority checking + clear network props on move/rebuild
1 parent 55513fc commit 574b110

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

packages/website/verse/Entity.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export class Entity {
3939
return prop.box
4040
}
4141

42+
destroyNetworkProp(key) {
43+
delete this.props[key]
44+
}
45+
4246
sendNetworkUpdate() {
4347
const data = {
4448
id: this.id,

packages/website/verse/Object.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ export class Object extends Entity {
211211
this.decHot(this.hotEvents)
212212
this.hotEvents = 0
213213
// clear script vars
214-
// for (let i = 0; i < this.scriptVarIds; i++) {
215-
// this.destroyVar(`$${i}`)
216-
// }
214+
for (let i = 0; i < this.scriptVarIds; i++) {
215+
this.destroyNetworkProp(`__${i}`)
216+
}
217217
this.scriptVarIds = 0
218218
// reconstruct
219219
if (this.isUploading()) {

packages/website/verse/Physics.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,28 @@ export class Physics extends System {
9090
}
9191
const result = this.contactsResult.get()
9292
if (!handle0.contactedHandles.has(handle1)) {
93-
result.entityId = handle1.entityId
9493
result.tag = handle1.tag
94+
result.isAuthority = handle1.isAuthority
9595
handle0.onContactStart?.(result)
9696
handle0.contactedHandles.add(handle1)
9797
}
9898
if (!handle1.contactedHandles.has(handle0)) {
99-
result.entityId = handle0.entityId
10099
result.tag = handle0.tag
100+
result.isAuthority = handle0.isAuthority
101101
handle1.onContactStart?.(result)
102102
handle1.contactedHandles.add(handle0)
103103
}
104104
} else if (pair.events.isSet(PHYSX.PxPairFlagEnum.eNOTIFY_TOUCH_LOST)) {
105105
const result = this.contactsResult.get()
106106
if (handle0.contactedHandles.has(handle1)) {
107107
result.tag = handle1.tag
108+
result.isAuthority = handle1.isAuthority
108109
handle0.onContactEnd?.(result)
109110
handle0.contactedHandles.delete(handle1)
110111
}
111112
if (handle1.contactedHandles.has(handle0)) {
112113
result.tag = handle0.tag
114+
result.isAuthority = handle0.isAuthority
113115
handle1.onContactEnd?.(result)
114116
handle1.contactedHandles.delete(handle0)
115117
}

packages/website/verse/nodes/RigidBody.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ export class RigidBody extends Node {
6868
const self = this
6969
this.removeActor = this.ctx.world.physics.addActor(this.actor, {
7070
onInterpolate: this.type === 'kinematic' || this.type === 'dynamic' ? this.onInterpolate : null,
71+
7172
get tag() {
7273
return self.tag
7374
},
75+
get isAuthority() {
76+
return self.ctx.entity.isAuthority()
77+
},
7478
get onContactStart() {
7579
return self.onContactStart
7680
},

0 commit comments

Comments
 (0)