Compare commits
1 Commits
master
...
fix-fixtur
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbd853bc17 |
@ -435,7 +435,7 @@ export class Body {
|
||||
// Touch the proxies so that new contacts will be created (when appropriate)
|
||||
const broadPhase = this.m_world.m_broadPhase;
|
||||
for (let f = this.m_fixtureList; f; f = f.m_next) {
|
||||
for (let i = 0; i < f.m_proxies.length; ++i) {
|
||||
for (let i = 0; i < f.m_proxyCount; ++i) {
|
||||
broadPhase.touchProxy(f.m_proxies[i].proxyId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,6 +128,8 @@ export class Fixture {
|
||||
/** @internal */ m_shape: Shape;
|
||||
/** @internal */ m_next: Fixture | null;
|
||||
/** @internal */ m_proxies: FixtureProxy[];
|
||||
// 0 indicates inactive state, this is not the same as m_proxies.length
|
||||
/** @internal */ m_proxyCount: number;
|
||||
/** @internal */ m_userData: unknown;
|
||||
|
||||
constructor(body: Body, def: FixtureDef);
|
||||
@ -162,7 +164,10 @@ export class Fixture {
|
||||
this.m_next = null;
|
||||
|
||||
this.m_proxies = [];
|
||||
this.m_proxyCount = 0;
|
||||
|
||||
// fixture proxies are created here,
|
||||
// but they are activate in when a fixture is added to body
|
||||
const childCount = this.m_shape.getChildCount();
|
||||
for (let i = 0; i < childCount; ++i) {
|
||||
this.m_proxies[i] = new FixtureProxy(this, i);
|
||||
@ -367,12 +372,12 @@ export class Fixture {
|
||||
* These support body activation/deactivation.
|
||||
*/
|
||||
createProxies(broadPhase: BroadPhase, xf: TransformValue): void {
|
||||
_ASSERT && console.assert(this.m_proxies.length == 0);
|
||||
_ASSERT && console.assert(this.m_proxyCount == 0);
|
||||
|
||||
// Create proxies in the broad-phase.
|
||||
const childCount = this.m_shape.getChildCount();
|
||||
this.m_proxyCount = this.m_shape.getChildCount();
|
||||
|
||||
for (let i = 0; i < childCount; ++i) {
|
||||
for (let i = 0; i < this.m_proxyCount; ++i) {
|
||||
const proxy = this.m_proxies[i];
|
||||
this.m_shape.computeAABB(proxy.aabb, xf, i);
|
||||
proxy.proxyId = broadPhase.createProxy(proxy.aabb, proxy);
|
||||
@ -381,14 +386,13 @@ export class Fixture {
|
||||
|
||||
destroyProxies(broadPhase: BroadPhase): void {
|
||||
// Destroy proxies in the broad-phase.
|
||||
for (let i = 0; i < this.m_proxies.length; ++i) {
|
||||
for (let i = 0; i < this.m_proxyCount; ++i) {
|
||||
const proxy = this.m_proxies[i];
|
||||
broadPhase.destroyProxy(proxy.proxyId);
|
||||
proxy.proxyId = null;
|
||||
proxy.fixture = null;
|
||||
}
|
||||
|
||||
this.m_proxies.length = 0;
|
||||
this.m_proxyCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -396,7 +400,7 @@ export class Fixture {
|
||||
* next transformation).
|
||||
*/
|
||||
synchronize(broadPhase: BroadPhase, xf1: TransformValue, xf2: TransformValue): void {
|
||||
for (let i = 0; i < this.m_proxies.length; ++i) {
|
||||
for (let i = 0; i < this.m_proxyCount; ++i) {
|
||||
const proxy = this.m_proxies[i];
|
||||
// Compute an AABB that covers the swept shape (may miss some rotation
|
||||
// effect).
|
||||
@ -477,7 +481,7 @@ export class Fixture {
|
||||
|
||||
// Touch each proxy so that new pairs may be created
|
||||
const broadPhase = world.m_broadPhase;
|
||||
for (let i = 0; i < this.m_proxies.length; ++i) {
|
||||
for (let i = 0; i < this.m_proxyCount; ++i) {
|
||||
broadPhase.touchProxy(this.m_proxies[i].proxyId);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user