diff options
Diffstat (limited to 'scene/resources/concave_polygon_shape.cpp')
-rw-r--r-- | scene/resources/concave_polygon_shape.cpp | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/scene/resources/concave_polygon_shape.cpp b/scene/resources/concave_polygon_shape.cpp index 3945ade215..0031580153 100644 --- a/scene/resources/concave_polygon_shape.cpp +++ b/scene/resources/concave_polygon_shape.cpp @@ -34,87 +34,79 @@ Vector<Vector3> ConcavePolygonShape::_gen_debug_mesh_lines() { Set<DrawEdge> edges; - PoolVector<Vector3> data=get_faces(); - int datalen=data.size(); - ERR_FAIL_COND_V( (datalen%3)!=0,Vector<Vector3>() ); + PoolVector<Vector3> data = get_faces(); + int datalen = data.size(); + ERR_FAIL_COND_V((datalen % 3) != 0, Vector<Vector3>()); - PoolVector<Vector3>::Read r=data.read(); + PoolVector<Vector3>::Read r = data.read(); - for(int i=0;i<datalen;i+=3) { + for (int i = 0; i < datalen; i += 3) { - for(int j=0;j<3;j++) { + for (int j = 0; j < 3; j++) { - DrawEdge de(r[i+j],r[i+((j+1)%3)]); + DrawEdge de(r[i + j], r[i + ((j + 1) % 3)]); edges.insert(de); } - } Vector<Vector3> points; - points.resize(edges.size()*2); - int idx=0; - for (Set<DrawEdge>::Element*E=edges.front();E;E=E->next()) { + points.resize(edges.size() * 2); + int idx = 0; + for (Set<DrawEdge>::Element *E = edges.front(); E; E = E->next()) { - points[idx+0]=E->get().a; - points[idx+1]=E->get().b; - idx+=2; + points[idx + 0] = E->get().a; + points[idx + 1] = E->get().b; + idx += 2; } return points; - } -bool ConcavePolygonShape::_set(const StringName& p_name, const Variant& p_value) { +bool ConcavePolygonShape::_set(const StringName &p_name, const Variant &p_value) { - if (p_name=="data") - PhysicsServer::get_singleton()->shape_set_data(get_shape(),p_value); + if (p_name == "data") + PhysicsServer::get_singleton()->shape_set_data(get_shape(), p_value); else return false; return true; - } -bool ConcavePolygonShape::_get(const StringName& p_name,Variant &r_ret) const { +bool ConcavePolygonShape::_get(const StringName &p_name, Variant &r_ret) const { - if (p_name=="data") - r_ret=PhysicsServer::get_singleton()->shape_get_data(get_shape()); + if (p_name == "data") + r_ret = PhysicsServer::get_singleton()->shape_get_data(get_shape()); else return false; return true; - } -void ConcavePolygonShape::_get_property_list( List<PropertyInfo> *p_list) const { +void ConcavePolygonShape::_get_property_list(List<PropertyInfo> *p_list) const { - p_list->push_back( PropertyInfo(Variant::ARRAY,"data") ); + p_list->push_back(PropertyInfo(Variant::ARRAY, "data")); } - void ConcavePolygonShape::_update_shape() { - } -void ConcavePolygonShape::set_faces(const PoolVector<Vector3>& p_faces) { +void ConcavePolygonShape::set_faces(const PoolVector<Vector3> &p_faces) { - PhysicsServer::get_singleton()->shape_set_data(get_shape(),p_faces); + PhysicsServer::get_singleton()->shape_set_data(get_shape(), p_faces); notify_change_to_owners(); } PoolVector<Vector3> ConcavePolygonShape::get_faces() const { return PhysicsServer::get_singleton()->shape_get_data(get_shape()); - } - - void ConcavePolygonShape::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_faces","faces"),&ConcavePolygonShape::set_faces); - ClassDB::bind_method(D_METHOD("get_faces"),&ConcavePolygonShape::get_faces); + ClassDB::bind_method(D_METHOD("set_faces", "faces"), &ConcavePolygonShape::set_faces); + ClassDB::bind_method(D_METHOD("get_faces"), &ConcavePolygonShape::get_faces); } -ConcavePolygonShape::ConcavePolygonShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) { +ConcavePolygonShape::ConcavePolygonShape() + : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) { //set_planes(Vector3(1,1,1)); } |