mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Use Vector for storing areas
This commit is contained in:
parent
ba194115bc
commit
4b3b5eba86
2 changed files with 13 additions and 5 deletions
|
@ -149,7 +149,16 @@ public:
|
||||||
sort_custom<_DefaultComparator<T> >();
|
sort_custom<_DefaultComparator<T> >();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ordered_insert(const T& p_val) {
|
||||||
|
int i;
|
||||||
|
for (i=0; i<size(); i++) {
|
||||||
|
|
||||||
|
if (p_val < operator[](i)) {
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
insert(i, p_val);
|
||||||
|
}
|
||||||
|
|
||||||
void operator=(const Vector& p_from);
|
void operator=(const Vector& p_from);
|
||||||
Vector(const Vector& p_from);
|
Vector(const Vector& p_from);
|
||||||
|
|
|
@ -84,13 +84,13 @@ class BodySW : public CollisionObjectSW {
|
||||||
struct AreaCMP {
|
struct AreaCMP {
|
||||||
|
|
||||||
AreaSW *area;
|
AreaSW *area;
|
||||||
_FORCE_INLINE_ bool operator<(const AreaCMP& p_cmp) const { return area->get_self() < p_cmp.area->get_self() ; }
|
_FORCE_INLINE_ bool operator==(const AreaCMP& p_cmp) const { return area->get_self() == p_cmp.area->get_self();}
|
||||||
|
_FORCE_INLINE_ bool operator<(const AreaCMP a) const { return area->get_priority() < a.area->get_priority();}
|
||||||
_FORCE_INLINE_ AreaCMP() {}
|
_FORCE_INLINE_ AreaCMP() {}
|
||||||
_FORCE_INLINE_ AreaCMP(AreaSW *p_area) { area=p_area;}
|
_FORCE_INLINE_ AreaCMP(AreaSW *p_area) { area=p_area;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Vector<AreaCMP> areas;
|
||||||
VSet<AreaCMP> areas;
|
|
||||||
|
|
||||||
struct Contact {
|
struct Contact {
|
||||||
|
|
||||||
|
@ -134,8 +134,7 @@ public:
|
||||||
|
|
||||||
void set_force_integration_callback(ObjectID p_id,const StringName& p_method,const Variant& p_udata=Variant());
|
void set_force_integration_callback(ObjectID p_id,const StringName& p_method,const Variant& p_udata=Variant());
|
||||||
|
|
||||||
|
_FORCE_INLINE_ void add_area(AreaSW *p_area) { areas.ordered_insert(AreaCMP(p_area)); }
|
||||||
_FORCE_INLINE_ void add_area(AreaSW *p_area) { areas.insert(AreaCMP(p_area)); }
|
|
||||||
_FORCE_INLINE_ void remove_area(AreaSW *p_area) { areas.erase(AreaCMP(p_area)); }
|
_FORCE_INLINE_ void remove_area(AreaSW *p_area) { areas.erase(AreaCMP(p_area)); }
|
||||||
|
|
||||||
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) { contacts.resize(p_size); contact_count=0; if (mode==PhysicsServer::BODY_MODE_KINEMATIC && p_size) set_active(true);}
|
_FORCE_INLINE_ void set_max_contacts_reported(int p_size) { contacts.resize(p_size); contact_count=0; if (mode==PhysicsServer::BODY_MODE_KINEMATIC && p_size) set_active(true);}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue