kingBook

导航

CocosCreator 提前计算刚体位置

b2Body.prototype.ApplyLinearImpulseToCenter = function (impulse, wake) {
	if (wake === void 0) { wake = true; }
	if (this.m_type !== exports.b2BodyType.b2_dynamicBody) {
		return;
	}
	if (wake && !this.m_awakeFlag) {
		this.SetAwake(true);
	}
	// Don't accumulate a force if the body is sleeping.
	if (this.m_awakeFlag) {
		this.m_linearVelocity.x += this.m_invMass * impulse.x;
		this.m_linearVelocity.y += this.m_invMass * impulse.y;
	}
};

b2Body.prototype.ApplyLinearImpulse = function (impulse, point, wake) {
	if (wake === void 0) { wake = true; }
	if (this.m_type !== exports.b2BodyType.b2_dynamicBody) {
		return;
	}
	if (wake && !this.m_awakeFlag) {
		this.SetAwake(true);
	}
	// Don't accumulate a force if the body is sleeping.
	if (this.m_awakeFlag) {
		this.m_linearVelocity.x += this.m_invMass * impulse.x;
		this.m_linearVelocity.y += this.m_invMass * impulse.y;
		this.m_angularVelocity += this.m_invI * ((point.x - this.m_sweep.c.x) * impulse.y - (point.y - this.m_sweep.c.y) * impulse.x);
	}
};

posted on 2020-08-07 16:51  kingBook  阅读(457)  评论(0编辑  收藏  举报