当前位置: 首页>>代码示例>>C++>>正文


C++ Fixture::GetNext方法代码示例

本文整理汇总了C++中Fixture::GetNext方法的典型用法代码示例。如果您正苦于以下问题:C++ Fixture::GetNext方法的具体用法?C++ Fixture::GetNext怎么用?C++ Fixture::GetNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fixture的用法示例。


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

示例1: FindAllCollisions

void PhysicsWorld::FindAllCollisions() {
	contactManager.numOldContacts = contactManager.numContacts;
	assert(contactManager.numOldContacts < MaxNumContacts );
	memcpy(contactManager.oldContacts, contactManager.contacts, contactManager.numOldContacts * sizeof(Contact));
	contactManager.numContacts = 0;
	/*
		O(n^2) collsion detection ( or worse LOL )
		Check all fixtures vs all fixtures for collisions, 
		We dont collide fixtures that are from the same body
	*/ 
	for ( size_t i = 0; i < numBodies; i++ ) {
		for ( size_t j = i + 1; j < numBodies; j++ ) {
			if ( (bodies[i]->type != eDynamic && bodies[j]->type != eDynamic) ) {
				continue;
			}
			if ( contactManager.contactFilter && !contactManager.contactFilter->ShouldCollide(bodies[i], bodies[j]) ) {
				continue;
			}
			Fixture *fi = bodies[i]->GetFixtureList();
			while ( fi ) {
				Fixture *fj = bodies[j]->GetFixtureList();
				while ( fj ) {
					if ( fi->IsSensor( ) || fj->IsSensor( ) ) {
						if ( CheckOverlap(fi->GetShape(), bodies[i]->GetPosition(), fj->GetShape(), bodies[j]->GetPosition()) )	{
							contactManager.contactListener->OnSensor(fi, fj);
						}
					} else {
						// check collision and add to the contact list if they intersect
						contactManager.AddPair(fi, fj);
					}
					fj = fj->GetNext();
				}
				fi = fi->GetNext();
			}
		}
	}
	contactManager.MergeContacts();
}		
开发者ID:robert-porter,项目名称:SideScroller,代码行数:38,代码来源:PhysicsWorld.cpp

示例2:

Fixture * World::QueryPoint(const Vector2 &point) const
{
	for(int i = 0; i < entities.size(); i++)
	{
		for(Fixture *f = entities[i]->body.GetFixtureList(); f != 0; f = f->GetNext()) 
		{
			if(f->GetShape()->TestPoint(point, entities[i]->body.GetPosition()))
			{
				return f;
			}
		}
	}
	return 0;
}
开发者ID:robert-porter,项目名称:SideScroller,代码行数:14,代码来源:World.cpp

示例3: Draw

void Graphics::Draw(Renderer *renderer)
{
	Fixture *fixture =  owner->body.GetFixtureList();

	while ( fixture )
	{
		if(visible)
		{
		if ( fixture->GetType() == eCircle )
		{
			renderer->DrawTexturedQuad(
				texture, 
				owner->body.GetPosition() + static_cast<Circle*>(fixture->GetShape())->localPos,
				static_cast<Circle*>(fixture->GetShape())->radius * 2.0f, 
				static_cast<Circle*>(fixture->GetShape())->radius * 2.0f, 
				angle, 
				Vector2(0.0f, 0.0f), //owner->body.GetPosition() + static_cast<Circle*>(fixture->GetShape())->localPos,
				flipX, 
				flipY, 
				color
				);
		}
		else if ( fixture->GetType() == eAABox )
		{
			Vector2 minExt = static_cast<AABox*>(fixture->GetShape())->minExt;
			Vector2 maxExt = static_cast<AABox*>(fixture->GetShape())->maxExt;
			Vector2 boxSize = maxExt - minExt;


			renderer->DrawTexturedQuad(
				texture, 
				owner->body.GetPosition() + boxSize/2.0f,
				boxSize.x, 
				boxSize.y, 
				0.0f, 
				owner->body.GetPosition() + boxSize/2.0f,
				flipX, 
				flipY, 
				color
				);

		}
		else if ( fixture->GetType() == eCapsule )
		{

			Vector2 pos0 = static_cast<Capsule*>(fixture->GetShape())->localPos0 + owner->body.GetPosition();
			Vector2 pos1 = static_cast<Capsule*>(fixture->GetShape())->localPos1 + owner->body.GetPosition();
			float radius = static_cast<Capsule*>(fixture->GetShape())->radius;

			Vector2 normal = normalize(pos1-pos0);
			Vector2 tangent = Vector2(-normal.y, normal.x);
			
			Vector2 verts[4];
			verts[0] = pos0 - normal * radius - tangent * radius; 
			verts[1] = pos1 + normal * radius - tangent * radius; 
			verts[2] = pos1 + normal * radius + tangent * radius; 
			verts[3] = pos0 - normal * radius + tangent * radius; 


			Vector2 texCoords[4];
			if ( !flipX )
			{
			texCoords[0] = Vector2(0.0f, 0.0f);
			texCoords[1] = Vector2(1.0f, 0.0f);
			texCoords[2] = Vector2(1.0f, 1.0f);
			texCoords[3] = Vector2(0.0f, 1.0f);
			}
			else
			{
				texCoords[2] = Vector2(0.0f, 0.0f);
				texCoords[0] = Vector2(1.0f, 0.0f);
				texCoords[1] = Vector2(1.0f, 1.0f);
				texCoords[3] = Vector2(0.0f, 1.0f);
			}
			glColor4f(color.r, color.g, color.b, color.a);
			renderer->DrawTexturedQuad(texture, verts, texCoords);
		}
		
		}
		if ( drawShape )
		{
			fixture->GetShape()->Draw(*renderer, owner->body.GetPosition());
		}
		fixture = fixture->GetNext();
		}

}
开发者ID:robert-porter,项目名称:SideScroller,代码行数:87,代码来源:Render.cpp

示例4: drawBody

void BoxScreen::drawBody (const BodyP &b) {
    for (Fixture *f = b->GetFixtureList(); f; f = f->GetNext()) {
	drawShape (b,f->GetShape());
    }
}
开发者ID:mconnor2,项目名称:NEATlegs,代码行数:5,代码来源:BoxScreen.cpp


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