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


C++ string::GetType方法代码示例

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


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

示例1:

void GB2ShapeCache::addFixturesToBody(b2Body *body, const std::string &shape,float scale) {
	/*if(scale == 1.0f)
	{
		addFixturesToBody(body,shape);
		return;
	}*/

	std::map<std::string, BodyDef *>::iterator pos = shapeObjects.find(shape);
	assert(pos != shapeObjects.end());

	BodyDef *so = (*pos).second;

	FixtureDef *fix = so->fixtures;
	
	while (fix) {
		const b2Shape* shape = fix->fixture.shape;
		b2FixtureDef fixtureDef;
		b2FixtureDef oldFixtureDef = fix->fixture;
		if(shape->GetType() == b2Shape::e_circle )
		{
			b2CircleShape* oldCircle = (b2CircleShape*)fix->fixture.shape;
			b2CircleShape newCircle;
			newCircle.m_radius = oldCircle->m_radius * scale;
			newCircle.m_p = scale * oldCircle->m_p;
			fixtureDef.shape = &newCircle;
			fixtureDef.density = oldFixtureDef.density;
			fixtureDef.filter = oldFixtureDef.filter;
			fixtureDef.friction = oldFixtureDef.friction;
			fixtureDef.isSensor = oldFixtureDef.isSensor;
			fixtureDef.restitution = oldFixtureDef.restitution;
			fixtureDef.userData = oldFixtureDef.userData;
			body->CreateFixture(&fixtureDef);
		}
		if(shape->GetType() == b2Shape::e_polygon)
		{
			b2PolygonShape* polygon = (b2PolygonShape*)fix->fixture.shape;
			int count = polygon->GetVertexCount();
			b2Vec2 *m_newVertices = new b2Vec2[count];

			for(int i = 0;i<count;i++)
			{
				m_newVertices[i] = scale * polygon->GetVertex(i);
			}

			b2PolygonShape newPolygon;
			newPolygon.Set(m_newVertices, count);

			fixtureDef.shape = &newPolygon;
			fixtureDef.density = oldFixtureDef.density;
			fixtureDef.filter = oldFixtureDef.filter;
			fixtureDef.friction = oldFixtureDef.friction;
			fixtureDef.isSensor = oldFixtureDef.isSensor;
			fixtureDef.restitution = oldFixtureDef.restitution;
			fixtureDef.userData = oldFixtureDef.userData;
			body->CreateFixture(&fixtureDef);
		}
		fix = fix->next;
	}
}
开发者ID:mengtest,项目名称:Radial-Gravity,代码行数:59,代码来源:GB2ShapeCache-x.cpp


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