• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ B2_NOT_USED函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中B2_NOT_USED函数的典型用法代码示例。如果您正苦于以下问题:C++ B2_NOT_USED函数的具体用法?C++ B2_NOT_USED怎么用?C++ B2_NOT_USED使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了B2_NOT_USED函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ProcessThree

// Possible regions:
// - points[2]
// - edge points[0]-points[2]
// - edge points[1]-points[2]
// - inside the triangle
static int32 ProcessThree(b2Vec2* x1, b2Vec2* x2, b2Vec2* p1s, b2Vec2* p2s, b2Vec2* points)
{
	b2Vec2 a = points[0];
	b2Vec2 b = points[1];
	b2Vec2 c = points[2];

	b2Vec2 ab = b - a;
	b2Vec2 ac = c - a;
	b2Vec2 bc = c - b;

	float32 sn = -b2Dot(a, ab), sd = b2Dot(b, ab);
	float32 tn = -b2Dot(a, ac), td = b2Dot(c, ac);
	float32 un = -b2Dot(b, bc), ud = b2Dot(c, bc);

	// In vertex c region?
	if (td <= 0.0f && ud <= 0.0f)
	{
		// Single point
		*x1 = p1s[2];
		*x2 = p2s[2];
		p1s[0] = p1s[2];
		p2s[0] = p2s[2];
		points[0] = points[2];
		return 1;
	}

	// Should not be in vertex a or b region.
	B2_NOT_USED(sd);
	B2_NOT_USED(sn);
	b2Assert(sn > 0.0f || tn > 0.0f);
	b2Assert(sd > 0.0f || un > 0.0f);

	float32 n = b2Cross(ab, ac);

#ifdef TARGET_FLOAT32_IS_FIXED
	n = (n < 0.0)? -1.0 : ((n > 0.0)? 1.0 : 0.0);
#endif

	// Should not be in edge ab region.
	float32 vc = n * b2Cross(a, b);
	b2Assert(vc > 0.0f || sn > 0.0f || sd > 0.0f);

	// In edge bc region?
	float32 va = n * b2Cross(b, c);
	if (va <= 0.0f && un >= 0.0f && ud >= 0.0f && (un+ud) > 0.0f)
	{
		b2Assert(un + ud > 0.0f);
		float32 lambda = un / (un + ud);
		*x1 = p1s[1] + lambda * (p1s[2] - p1s[1]);
		*x2 = p2s[1] + lambda * (p2s[2] - p2s[1]);
		p1s[0] = p1s[2];
		p2s[0] = p2s[2];
		points[0] = points[2];
		return 2;
	}

	// In edge ac region?
	float32 vb = n * b2Cross(c, a);
	if (vb <= 0.0f && tn >= 0.0f && td >= 0.0f && (tn+td) > 0.0f)
	{
		b2Assert(tn + td > 0.0f);
		float32 lambda = tn / (tn + td);
		*x1 = p1s[0] + lambda * (p1s[2] - p1s[0]);
		*x2 = p2s[0] + lambda * (p2s[2] - p2s[0]);
		p1s[1] = p1s[2];
		p2s[1] = p2s[2];
		points[1] = points[2];
		return 2;
	}

	// Inside the triangle, compute barycentric coordinates
	float32 denom = va + vb + vc;
	b2Assert(denom > 0.0f);
	denom = 1.0f / denom;

#ifdef TARGET_FLOAT32_IS_FIXED
	*x1 = denom * (va * p1s[0] + vb * p1s[1] + vc * p1s[2]);
	*x2 = denom * (va * p2s[0] + vb * p2s[1] + vc * p2s[2]);
#else
	float32 u = va * denom;
	float32 v = vb * denom;
	float32 w = 1.0f - u - v;
	*x1 = u * p1s[0] + v * p1s[1] + w * p1s[2];
	*x2 = u * p2s[0] + v * p2s[1] + w * p2s[2];
#endif
	return 3;
}
开发者ID:6301158,项目名称:KinectHacks,代码行数:92,代码来源:b2Distance.cpp


示例2: B2_NOT_USED

bool b2PulleyJoint::SolvePositionConstraints(float32 baumgarte)
{
	B2_NOT_USED(baumgarte);

	b2Body* b1 = m_bodyA;
	b2Body* b2 = m_bodyB;

	b2Vec2 s1 = m_groundAnchor1;
	b2Vec2 s2 = m_groundAnchor2;

	b2Vec2 r1 = b2Mul(b1->m_xf.R, m_localAnchor1 - b1->GetLocalCenter());
	b2Vec2 r2 = b2Mul(b2->m_xf.R, m_localAnchor2 - b2->GetLocalCenter());

	b2Vec2 p1 = b1->m_sweep.c + r1;
	b2Vec2 p2 = b2->m_sweep.c + r2;

	// Get the pulley axes.
	b2Vec2 u1 = p1 - s1;
	b2Vec2 u2 = p2 - s2;

	float32 length1 = u1.Length();
	float32 length2 = u2.Length();

	if (length1 > 10.0f * b2_linearSlop)
	{
		u1 *= 1.0f / length1;
	}
	else
	{
		u1.SetZero();
	}

	if (length2 > 10.0f * b2_linearSlop)
	{
		u2 *= 1.0f / length2;
	}
	else
	{
		u2.SetZero();
	}

	// Compute effective mass.
	float32 cr1u1 = b2Cross(r1, u1);
	float32 cr2u2 = b2Cross(r2, u2);

	float32 m1 = b1->m_invMass + b1->m_invI * cr1u1 * cr1u1;
	float32 m2 = b2->m_invMass + b2->m_invI * cr2u2 * cr2u2;

	float32 mass = m1 + m_ratio * m_ratio * m2;

	if (mass > 0.0f)
	{
		mass = 1.0f / mass;
	}

	float32 C = m_constant - length1 - m_ratio * length2;
	float32 linearError = b2Abs(C);

	float32 impulse = -mass * C;

	b2Vec2 P1 = -impulse * u1;
	b2Vec2 P2 = -m_ratio * impulse * u2;

	b1->m_sweep.c += b1->m_invMass * P1;
	b1->m_sweep.a += b1->m_invI * b2Cross(r1, P1);
	b2->m_sweep.c += b2->m_invMass * P2;
	b2->m_sweep.a += b2->m_invI * b2Cross(r2, P2);

	b1->SynchronizeTransform();
	b2->SynchronizeTransform();

	return linearError < b2_linearSlop;
}
开发者ID:brigosx,项目名称:pybox2d-android,代码行数:73,代码来源:b2PulleyJoint.cpp


示例3: b2AllocDefault

// Default implementation of b2AllocFunction.
static void* b2AllocDefault(int32 size, void* callbackData)
{
	B2_NOT_USED(callbackData);
	return malloc(size);
}
开发者ID:SweedRaver,项目名称:FluidAnimations,代码行数:6,代码来源:b2Settings.cpp


示例4: post_solve

 virtual void post_solve(const b2Contact* contact, const b2ContactImpulse* impulse)
 {
   B2_NOT_USED(contact);
   B2_NOT_USED(impulse);
 }
开发者ID:navneetagarwal,项目名称:Box2d-Project,代码行数:5,代码来源:cs251_base.hpp


示例5: B2_NOT_USED

bool b2EdgeShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
{
	B2_NOT_USED(xf);
	B2_NOT_USED(p);
	return false;
}
开发者ID:AbePralle,项目名称:Plasmacore,代码行数:6,代码来源:b2EdgeShape.cpp


示例6: mouse_move

 void mouse_move(const b2Vec2& p) { B2_NOT_USED(p); }
开发者ID:navneetagarwal,项目名称:Box2d-Project,代码行数:1,代码来源:cs251_base.hpp


示例7: begin_contact

 // Callbacks for derived classes.
 virtual void begin_contact(b2Contact* contact) { B2_NOT_USED(contact); }
开发者ID:navneetagarwal,项目名称:Box2d-Project,代码行数:2,代码来源:cs251_base.hpp


示例8: B2_NOT_USED

float32 b2ElasticRopeJoint::GetReactionTorque(float32 inv_dt) const
{
    B2_NOT_USED(inv_dt);
    return 0.0f;
}
开发者ID:InPieces,项目名称:b2ElasticRopeJoint,代码行数:5,代码来源:b2ElasticRopeJoint.cpp


示例9: main

int main(int argc, char *argv[])
{
	
	QApplication a(argc, argv);
	
	// Set up the scene
	QGraphicsScene scene;
	QRect sceneRect(0,0,740,540);
	scene.setSceneRect(sceneRect);
	scene.setItemIndexMethod(QGraphicsScene::NoIndex);

	Team A(5,QColor(0,0,255));
	Team B(5,QColor(255,255,0),50);
	A.addToScene(scene);
	B.addToScene(scene);
	
	// Set up the view port
	MyGraphicsView v;
	v.setRenderHint(QPainter::Antialiasing);
	v.setCacheMode(QGraphicsView::CacheBackground);
	v.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
	v.setDragMode(QGraphicsView::ScrollHandDrag);
    	v.setScene(&scene);
   	v.show();
   	
   	// Call circle advance for every time interval of 1000/33
	QTimer timer;
     	QObject::connect(&timer, SIGNAL(timeout()), &scene, SLOT(advance()));
     	timer.start(1000 / 33);

	a.exec();
	
#ifndef __NO_BOX2D__
	B2_NOT_USED(argc);
	B2_NOT_USED(argv);

    // Define the ground body.
    b2BodyDef groundBodyDef[4];
    groundBodyDef[0].position.Set(0.0f, 2.7f);      //top
    groundBodyDef[1].position.Set(0.0f, -2.7f);     //bottom
    groundBodyDef[2].position.Set(-3.7f, 0.0f);     //left
    groundBodyDef[3].position.Set(3.7f, 0.0f);      //right

    // Call the body factory which allocates memory for the ground body
    // from a pool and creates the ground box shape (also from a pool).
    // The body is also added to the world.
    b2Body* groundBody[4];
    for(unsigned int i = 0; i < 4; i += 1){
        groundBody[i] = m_world->CreateBody(&groundBodyDef[i]);
    }

    // Define the ground box shape.
    b2PolygonShape groundBox[4];

    // The extents are the half-widths of the box.
    groundBox[0].SetAsBox(3.7f, 0.003f);
    groundBox[1].SetAsBox(3.7f, 0.003f);
    groundBox[2].SetAsBox(0.003f, 2.7f);
    groundBox[3].SetAsBox(0.003f, 2.7f);

    // Add the ground fixture to the ground body.
    for(unsigned int i = 0; i < 4; i += 1){
        groundBody[i]->CreateFixture(&groundBox[i], 0.0f);
    }

    // Define the dynamic body. We set its position and call the body factory.
    b2BodyDef bodyDef[6];
    for(unsigned int i = 0; i < 6; i += 1){
        bodyDef[i].type = b2_dynamicBody;
    }

    bodyDef[0].position.Set(1.0f, 2.0f);
    bodyDef[1].position.Set(1.0f, 0.0f);
    bodyDef[2].position.Set(1.0f, -2.0f);
    bodyDef[3].position.Set(2.0f, 1.0f);
    bodyDef[4].position.Set(2.0f, -1.0f);
    bodyDef[5].position.Set(3.0f, 0.0f);

    b2Body* body[6];
    for(unsigned int i = 0; i < 6; i += 1){
        body[i] = m_world->CreateBody(&bodyDef[i]);
        b2Vec2 pos = body[i]->GetPosition();
        body[i]->SetTransform(pos, 90.0);
    }

    // Define another box shape for our dynamic body.
    b2PolygonShape dynamicBox;
    dynamicBox.SetAsBox(0.09f, 0.09f);
    
    b2Vec2 vertices[19];
    vertices[0].Set(-0.090000f, 0.000000f);
    vertices[1].Set(-0.087385f, -0.021538f);
    vertices[2].Set(-0.079691f, -0.041825f);
    vertices[3].Set(-0.067366f, -0.059681f);
    vertices[4].Set(-0.051126f, -0.074069f);
    vertices[5].Set(-0.031914f, -0.084151f);
    vertices[6].Set(-0.010848f, -0.089344f);
    vertices[7].Set(0.010848f, -0.089344f);
    vertices[8].Set(0.031914f, -0.084151f);
    vertices[9].Set(0.051126f, -0.074069f);
//.........这里部分代码省略.........
开发者ID:uWaterloo-IEEE-StudentBranch,项目名称:WarBots-SSL,代码行数:101,代码来源:main.cpp


示例10: B2_NOT_USED

qreal b2RopeJoint::GetReactionTorque(qreal inv_dt) const
{
	B2_NOT_USED(inv_dt);
	return 0.0f;
}
开发者ID:KDE,项目名称:kolf,代码行数:5,代码来源:b2RopeJoint.cpp


示例11: B2_NOT_USED

bool b2RevoluteJoint::SolvePositionConstraints(float32 baumgarte)
{
	// TODO_ERIN block solve with limit.

	B2_NOT_USED(baumgarte);

	b2Body* b1 = m_bodyA;
	b2Body* b2 = m_bodyB;

	float32 angularError = 0.0f;
	float32 positionError = 0.0f;

	// Solve angular limit constraint.
	if (m_enableLimit && m_limitState != e_inactiveLimit)
	{
		float32 angle = b2->m_sweep.a - b1->m_sweep.a - m_referenceAngle;
		float32 limitImpulse = 0.0f;

		if (m_limitState == e_equalLimits)
		{
			// Prevent large angular corrections
			float32 C = b2Clamp(angle - m_lowerAngle, -b2_maxAngularCorrection, b2_maxAngularCorrection);
			limitImpulse = -m_motorMass * C;
			angularError = b2Abs(C);
		}
		else if (m_limitState == e_atLowerLimit)
		{
			float32 C = angle - m_lowerAngle;
			angularError = -C;

			// Prevent large angular corrections and allow some slop.
			C = b2Clamp(C + b2_angularSlop, -b2_maxAngularCorrection, 0.0f);
			limitImpulse = -m_motorMass * C;
		}
		else if (m_limitState == e_atUpperLimit)
		{
			float32 C = angle - m_upperAngle;
			angularError = C;

			// Prevent large angular corrections and allow some slop.
			C = b2Clamp(C - b2_angularSlop, 0.0f, b2_maxAngularCorrection);
			limitImpulse = -m_motorMass * C;
		}

		b1->m_sweep.a -= b1->m_invI * limitImpulse;
		b2->m_sweep.a += b2->m_invI * limitImpulse;

		b1->SynchronizeTransform();
		b2->SynchronizeTransform();
	}

	// Solve point-to-point constraint.
	{
		b2Vec2 r1 = b2Mul(b1->GetTransform().R, m_localAnchor1 - b1->GetLocalCenter());
		b2Vec2 r2 = b2Mul(b2->GetTransform().R, m_localAnchor2 - b2->GetLocalCenter());

		b2Vec2 C = b2->m_sweep.c + r2 - b1->m_sweep.c - r1;
		positionError = C.Length();

		float32 invMass1 = b1->m_invMass, invMass2 = b2->m_invMass;
		float32 invI1 = b1->m_invI, invI2 = b2->m_invI;

		// Handle large detachment.
		const float32 k_allowedStretch = 10.0f * b2_linearSlop;
		if (C.LengthSquared() > k_allowedStretch * k_allowedStretch)
		{
			// Use a particle solution (no rotation).
			b2Vec2 u = C; u.Normalize();
			float32 k = invMass1 + invMass2;
			b2Assert(k > B2_FLT_EPSILON);
			float32 m = 1.0f / k;
			b2Vec2 impulse = m * (-C);
			const float32 k_beta = 0.5f;
			b1->m_sweep.c -= k_beta * invMass1 * impulse;
			b2->m_sweep.c += k_beta * invMass2 * impulse;

			C = b2->m_sweep.c + r2 - b1->m_sweep.c - r1;
		}

		b2Mat22 K1;
		K1.col1.x = invMass1 + invMass2;	K1.col2.x = 0.0f;
		K1.col1.y = 0.0f;					K1.col2.y = invMass1 + invMass2;

		b2Mat22 K2;
		K2.col1.x =  invI1 * r1.y * r1.y;	K2.col2.x = -invI1 * r1.x * r1.y;
		K2.col1.y = -invI1 * r1.x * r1.y;	K2.col2.y =  invI1 * r1.x * r1.x;

		b2Mat22 K3;
		K3.col1.x =  invI2 * r2.y * r2.y;	K3.col2.x = -invI2 * r2.x * r2.y;
		K3.col1.y = -invI2 * r2.x * r2.y;	K3.col2.y =  invI2 * r2.x * r2.x;

		b2Mat22 K = K1 + K2 + K3;
		b2Vec2 impulse = K.Solve(-C);

		b1->m_sweep.c -= b1->m_invMass * impulse;
		b1->m_sweep.a -= b1->m_invI * b2Cross(r1, impulse);

		b2->m_sweep.c += b2->m_invMass * impulse;
		b2->m_sweep.a += b2->m_invI * b2Cross(r2, impulse);

//.........这里部分代码省略.........
开发者ID:HieuLsw,项目名称:cocos-svg,代码行数:101,代码来源:b2RevoluteJoint.cpp


示例12: PreSolve

	virtual void PreSolve(b2Contact *contact, const b2Manifold *oldManifold)
	{
		B2_NOT_USED(contact);
		B2_NOT_USED(oldManifold);
	}
开发者ID:chengstory,项目名称:CocoStudioSamples,代码行数:5,代码来源:TestColliderDetector.cpp


示例13: EndContact

	virtual void EndContact(b2Contact *contact)
	{
        //! clear list at end
		contact_list.clear();
		B2_NOT_USED(contact);
	}
开发者ID:chengstory,项目名称:CocoStudioSamples,代码行数:6,代码来源:TestColliderDetector.cpp


示例14: main

// This is a simple example of building and running a simulation
// using Box2D. Here we create a large ground box and a small dynamic
// box.
int main(int argc, char** argv)
{
	B2_NOT_USED(argc);
	B2_NOT_USED(argv);

	// Define the size of the world. Simulation will still work
	// if bodies reach the end of the world, but it will be slower.
	b2AABB worldAABB;
	worldAABB.lowerBound.Set(-100.0f, -100.0f);
	worldAABB.upperBound.Set(100.0f, 100.0f);

	// Define the gravity vector.
	b2Vec2 gravity(0.0f, -10.0f);

	// Do we want to let bodies sleep?
	bool doSleep = true;

	// Construct a world object, which will hold and simulate the rigid bodies.
	b2World world(worldAABB, gravity, doSleep);

	// Define the ground body.
	b2BodyDef groundBodyDef;
	groundBodyDef.position.Set(0.0f, -10.0f);

	// Call the body factory which allocates memory for the ground body
	// from a pool and creates the ground box shape (also from a pool).
	// The body is also added to the world.
	b2Body* groundBody = world.CreateBody(&groundBodyDef);

	// Define the ground box shape.
	b2PolygonDef groundShapeDef;

	// The extents are the half-widths of the box.
	groundShapeDef.SetAsBox(50.0f, 10.0f);

	// Add the ground shape to the ground body.
	groundBody->CreateFixture(&groundShapeDef);

	// Define the dynamic body. We set its position and call the body factory.
	b2BodyDef bodyDef;
	bodyDef.position.Set(0.0f, 4.0f);
	b2Body* body = world.CreateBody(&bodyDef);

	// Define another box shape for our dynamic body.
	b2PolygonDef shapeDef;
	shapeDef.SetAsBox(1.0f, 1.0f);

	// Set the box density to be non-zero, so it will be dynamic.
	shapeDef.density = 1.0f;

	// Override the default friction.
	shapeDef.friction = 0.3f;

	// Add the shape to the body.
	body->CreateFixture(&shapeDef);

	// Now tell the dynamic body to compute it's mass properties base
	// on its shape.
	body->SetMassFromShapes();

	// Prepare for simulation. Typically we use a time step of 1/60 of a
	// second (60Hz) and 10 iterations. This provides a high quality simulation
	// in most game scenarios.
	float32 timeStep = 1.0f / 60.0f;
	int32 velocityIterations = 8;
	int32 positionIterations = 1;

	// This is our little game loop.
	for (int32 i = 0; i < 60; ++i)
	{
		// Instruct the world to perform a single step of simulation. It is
		// generally best to keep the time step and iterations fixed.
		world.Step(timeStep, velocityIterations, positionIterations);

		// Now print the position and angle of the body.
		b2Vec2 position = body->GetPosition();
		float32 angle = body->GetAngle();

		printf("%4.2f %4.2f %4.2f\n", position.x, position.y, angle);
	}

	// When the world destructor is called, all bodies and joints are freed. This can
	// create orphaned pointers, so be careful about your world management.

	return 0;
}
开发者ID:SoylentGraham,项目名称:Tootle,代码行数:89,代码来源:HelloWorld.cpp


示例15: shift_mouse_down

 void shift_mouse_down(const b2Vec2& p) { B2_NOT_USED(p); }
开发者ID:navneetagarwal,项目名称:Box2d-Project,代码行数:1,代码来源:cs251_base.hpp


示例16: B2_NOT_USED

bool b2MotorJoint::SolvePositionConstraints(const b2SolverData& data)
{
	B2_NOT_USED(data);

	return true;
}
开发者ID:reworks,项目名称:REngine3,代码行数:6,代码来源:b2MotorJoint.cpp


示例17: mouse_up

 virtual void mouse_up(const b2Vec2& p) { B2_NOT_USED(p); }
开发者ID:navneetagarwal,项目名称:Box2d-Project,代码行数:1,代码来源:cs251_base.hpp


示例18: B2_NOT_USED

bool b2PolygonShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
								const b2Transform& xf, int32 childIndex) const
{
	B2_NOT_USED(childIndex);

	// Put the ray into the polygon's frame of reference.
	b2Vec2 p1 = b2MulT(xf.q, input.p1 - xf.p);
	b2Vec2 p2 = b2MulT(xf.q, input.p2 - xf.p);
	b2Vec2 d = p2 - p1;

	float32 lower = 0.0f, upper = input.maxFraction;

	int32 index = -1;

	for (int32 i = 0; i < m_vertexCount; ++i)
	{
		// p = p1 + a * d
		// dot(normal, p - v) = 0
		// dot(normal, p1 - v) + a * dot(normal, d) = 0
		float32 numerator = b2Dot(m_normals[i], m_vertices[i] - p1);
		float32 denominator = b2Dot(m_normals[i], d);

		if (denominator == 0.0f)
		{	
			if (numerator < 0.0f)
			{
				return false;
			}
		}
		else
		{
			// Note: we want this predicate without division:
			// lower < numerator / denominator, where denominator < 0
			// Since denominator < 0, we have to flip the inequality:
			// lower < numerator / denominator <==> denominator * lower > numerator.
			if (denominator < 0.0f && numerator < lower * denominator)
			{
				// Increase lower.
				// The segment enters this half-space.
				lower = numerator / denominator;
				index = i;
			}
			else if (denominator > 0.0f && numerator < upper * denominator)
			{
				// Decrease upper.
				// The segment exits this half-space.
				upper = numerator / denominator;
			}
		}

		// The use of epsilon here causes the assert on lower to trip
		// in some cases. Apparently the use of epsilon was to make edge
		// shapes work, but now those are handled separately.
		//if (upper < lower - b2_epsilon)
		if (upper < lower)
		{
			return false;
		}
	}

	b2Assert(0.0f <= lower && lower <= input.maxFraction);

	if (index >= 0)
	{
		output->fraction = lower;
		output->normal = b2Mul(xf.q, m_normals[index]);
		return true;
	}

	return false;
}
开发者ID:Ethanthecrazy,项目名称:ATHEngine,代码行数:71,代码来源:b2PolygonShape.cpp


示例19: joint_destroyed

 // Let derived tests know that a joint was destroyed.
 virtual void joint_destroyed(b2Joint* joint) { B2_NOT_USED(joint); }
开发者ID:navneetagarwal,项目名称:Box2d-Project,代码行数:2,代码来源:cs251_base.hpp


示例20: B2_NOT_USED

bool b2PrismaticJoint::SolvePositionConstraints(float32 baumgarte)
{
	B2_NOT_USED(baumgarte);

	b2Body* b1 = m_body1;
	b2Body* b2 = m_body2;

	b2Vec2 c1 = b1->m_sweep.c;
	float32 a1 = b1->m_sweep.a;

	b2Vec2 c2 = b2->m_sweep.c;
	float32 a2 = b2->m_sweep.a;

	// Solve linear limit constraint.
	float32 linearError = 0.0f, angularError = 0.0f;
	bool active = false;
	float32 C2 = 0.0f;

	b2Mat22 R1(a1), R2(a2);

	b2Vec2 r1 = b2Mul(R1, m_localAnchor1 - m_localCenter1);
	b2Vec2 r2 = b2Mul(R2, m_localAnchor2 - m_localCenter2);
	b2Vec2 d = c2 + r2 - c1 - r1;

	if (m_enableLimit)
	{
		m_axis = b2Mul(R1, m_localXAxis1);

		m_a1 = b2Cross(d + r1, m_axis);
		m_a2 = b2Cross(r2, m_axis);

		float32 translation = b2Dot(m_axis, d);
		if (b2Abs(m_upperTranslation - m_lowerTranslation) < 2.0f * b2_linearSlop)
		{
			// Prevent large angular corrections
			C2 = b2Clamp(translation, -b2_maxLinearCorrection, b2_maxLinearCorrection);
			linearError = b2Abs(translation);
			active = true;
		}
		else if (translation <= m_lowerTranslation)
		{
			// Prevent large linear corrections and allow some slop.
			C2 = b2Clamp(translation - m_lowerTranslation + b2_linearSlop, -b2_maxLinearCorrection, 0.0f);
			linearError = m_lowerTranslation - translation;
			active = true;
		}
		else if (translation >= m_upperTranslation)
		{
			// Prevent large linear corrections and allow some slop.
			C2 = b2Clamp(translation - m_upperTranslation - b2_linearSlop, 0.0f, b2_maxLinearCorrection);
			linearError = translation - m_upperTranslation;
			active = true;
		}
	}

	m_perp = b2Mul(R1, m_localYAxis1);

	m_s1 = b2Cross(d + r1, m_perp);
	m_s2 = b2Cross(r2, m_perp);

	b2Vec3 impulse;
	b2Vec2 C1;
	C1.x = b2Dot(m_perp, d);
	C1.y = a2 - a1 - m_refAngle;

	linearError = b2Max(linearError, b2Abs(C1.x));
	angularError = b2Abs(C1.y);

	if (active)
	{
		float32 m1 = m_invMass1, m2 = m_invMass2;
		float32 i1 = m_invI1, i2 = m_invI2;

		float32 k11 = m1 + m2 + i1 * m_s1 * m_s1 + i2 * m_s2 * m_s2;
		float32 k12 = i1 * m_s1 + i2 * m_s2;
		float32 k13 = i1 * m_s1 * m_a1 + i2 * m_s2 * m_a2;
		float32 k22 = i1 + i2;
		float32 k23 = i1 * m_a1 + i2 * m_a2;
		float32 k33 = m1 + m2 + i1 * m_a1 * m_a1 + i2 * m_a2 * m_a2;

		m_K.col1.Set(k11, k12, k13);
		m_K.col2.Set(k12, k22, k23);
		m_K.col3.Set(k13, k23, k33);

		b2Vec3 C;
		C.x = C1.x;
		C.y = C1.y;
		C.z = C2;

		impulse = m_K.Solve33(-C);
	}
	else
	{
		float32 m1 = m_invMass1, m2 = m_invMass2;
		float32 i1 = m_invI1, i2 = m_invI2;

		float32 k11 = m1 + m2 + i1 * m_s1 * m_s1 + i2 * m_s2 * m_s2;
		float32 k12 = i1 * m_s1 + i2 * m_s2;
		float32 k22 = i1 + i2;

//.........这里部分代码省略.........
开发者ID:DarthMike,项目名称:Hydro,代码行数:101,代码来源:b2PrismaticJoint.cpp



注:本文中的B2_NOT_USED函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ B43_WARN_ON函数代码示例发布时间:2022-05-30
下一篇:
C++ B2函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap