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


C++ CollisionObject2D::get_shape_count方法代码示例

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


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

示例1: memnew

void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) {

	if (unparenting)
		return;

	CollisionObject2D *co = p_obj->cast_to<CollisionObject2D>();
	ERR_FAIL_COND(!co);

	if (polygon.size()==0)
		return;

	bool solids=build_mode==BUILD_SOLIDS;

	if (solids) {

		//here comes the sun, lalalala
		//decompose concave into multiple convex polygons and add them
		Vector< Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon);
		for(int i=0;i<decomp.size();i++) {
			Ref<ConvexPolygonShape2D> convex = memnew( ConvexPolygonShape2D );
			convex->set_points(decomp[i]);
			co->add_shape(convex,get_transform());
			if (trigger)
				co->set_shape_as_trigger(co->get_shape_count()-1,true);

		}

	} else {

		Ref<ConcavePolygonShape2D> concave = memnew( ConcavePolygonShape2D );

		DVector<Vector2> segments;
		segments.resize(polygon.size()*2);
		DVector<Vector2>::Write w=segments.write();

		for(int i=0;i<polygon.size();i++) {
			w[(i<<1)+0]=polygon[i];
			w[(i<<1)+1]=polygon[(i+1)%polygon.size()];
		}

		w=DVector<Vector2>::Write();
		concave->set_segments(segments);

		co->add_shape(concave,get_transform());
		if (trigger)
			co->set_shape_as_trigger(co->get_shape_count()-1,true);

	}


	//co->add_shape(shape,get_transform());
}
开发者ID:Martho42,项目名称:godot,代码行数:52,代码来源:collision_polygon_2d.cpp

示例2:

void CollisionShape2D::_add_to_collision_object(Object *p_obj) {

    if (unparenting)
        return;

    CollisionObject2D *co = p_obj->cast_to<CollisionObject2D>();
    ERR_FAIL_COND(!co);
    update_shape_index=co->get_shape_count();
    co->add_shape(shape,get_transform());
    if (trigger)
        co->set_shape_as_trigger(co->get_shape_count()-1,true);


}
开发者ID:93i,项目名称:godot,代码行数:14,代码来源:collision_shape_2d.cpp


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