mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
A bit of everything:
-IMA-ADPCM support for samples, this means that sound effects can be compressed and use 4 timess less RAM. -New 3D import workflow based on Wavefront OBJ. Import single objects as mesh resources instead of full scenes. Many people prefers to work this way. Just like the rest of the imported resources, these are updated in realtime if modified externally. -Mesh resources now support naming surfaces. This helps reimporting to identify which user-created materials must be kept. -Several fixes and improvements to SurfaceTool. -Anti Aliasing added to WorldEnvironment effects (using FXAA) -2D Physics bodies (RigidBody, KinematicBody, etc), Raycasts, Tilemap, etc support collision layers. This makes easy to group which objects collide against which. -2D Trigger shapes can now also trigger collision reporting in other 2D bodies (it used to be in Area2D before) -Viewport render target textures can now be filtered. -Few fixes in GDscript make it easier to work with static functions and class members. -Several and many bugfixes.
This commit is contained in:
@@ -479,11 +479,55 @@ void _OS::print_all_textures_by_size() {
|
||||
print_line(E->get().path+" - "+String::humanize_size(E->get().vram)+" ("+E->get().size+") - total:"+String::humanize_size(total) );
|
||||
total-=E->get().vram;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void _OS::print_resources_by_type(const Vector<String>& p_types) {
|
||||
|
||||
Map<String,int> type_count;
|
||||
|
||||
List<Ref<Resource> > resources;
|
||||
ResourceCache::get_cached_resources(&resources);
|
||||
|
||||
List<Ref<Resource> > rsrc;
|
||||
ResourceCache::get_cached_resources(&rsrc);
|
||||
|
||||
for (List<Ref<Resource> >::Element *E=rsrc.front();E;E=E->next()) {
|
||||
|
||||
Ref<Resource> r = E->get();
|
||||
|
||||
bool found = false;
|
||||
|
||||
for (int i=0; i<p_types.size(); i++) {
|
||||
if (r->is_type(p_types[i]))
|
||||
found = true;
|
||||
}
|
||||
if (!found)
|
||||
continue;
|
||||
|
||||
if (!type_count.has(r->get_type())) {
|
||||
type_count[r->get_type()]=0;
|
||||
}
|
||||
|
||||
|
||||
type_count[r->get_type()]++;
|
||||
|
||||
print_line(r->get_type()+": "+r->get_path());
|
||||
|
||||
List<String> metas;
|
||||
r->get_meta_list(&metas);
|
||||
for (List<String>::Element* me = metas.front(); me; me = me->next()) {
|
||||
print_line(" "+String(me->get()) + ": " + r->get_meta(me->get()));
|
||||
};
|
||||
}
|
||||
|
||||
for(Map<String,int>::Element *E=type_count.front();E;E=E->next()) {
|
||||
|
||||
print_line(E->key()+" count: "+itos(E->get()));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
void _OS::print_all_resources(const String& p_to_file ) {
|
||||
|
||||
OS::get_singleton()->print_all_resources(p_to_file);
|
||||
@@ -509,9 +553,9 @@ float _OS::get_frames_per_second() const {
|
||||
return OS::get_singleton()->get_frames_per_second();
|
||||
}
|
||||
|
||||
Error _OS::native_video_play(String p_path) {
|
||||
Error _OS::native_video_play(String p_path, float p_volume) {
|
||||
|
||||
return OS::get_singleton()->native_video_play(p_path);
|
||||
return OS::get_singleton()->native_video_play(p_path, p_volume);
|
||||
};
|
||||
|
||||
bool _OS::native_video_is_playing() {
|
||||
@@ -614,6 +658,7 @@ void _OS::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("get_frames_per_second"),&_OS::get_frames_per_second);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("print_all_textures_by_size"),&_OS::print_all_textures_by_size);
|
||||
ObjectTypeDB::bind_method(_MD("print_resources_by_type"),&_OS::print_resources_by_type);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("native_video_play"),&_OS::native_video_play);
|
||||
ObjectTypeDB::bind_method(_MD("native_video_is_playing"),&_OS::native_video_is_playing);
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
bool is_video_mode_resizable(int p_screen=0) const;
|
||||
Array get_fullscreen_mode_list(int p_screen=0) const;
|
||||
|
||||
Error native_video_play(String p_path);
|
||||
Error native_video_play(String p_path, float p_volume);
|
||||
bool native_video_is_playing();
|
||||
void native_video_pause();
|
||||
void native_video_stop();
|
||||
@@ -139,6 +139,7 @@ public:
|
||||
void print_resources_in_use(bool p_short=false);
|
||||
void print_all_resources(const String& p_to_file);
|
||||
void print_all_textures_by_size();
|
||||
void print_resources_by_type(const Vector<String>& p_types);
|
||||
|
||||
bool has_touchscreen_ui_hint() const;
|
||||
|
||||
|
||||
@@ -285,14 +285,12 @@ public:
|
||||
}
|
||||
|
||||
void set( const Pair& p_pair ) {
|
||||
|
||||
|
||||
Entry *e=NULL;
|
||||
if (!hash_table)
|
||||
make_hash_table(); // if no table, make one
|
||||
else
|
||||
check_hash_table(); // perform mantenience routine
|
||||
|
||||
/* As said, i want to have only one get_entry */
|
||||
Entry *e = const_cast<Entry*>( get_entry(p_pair.key) );
|
||||
e = const_cast<Entry*>( get_entry(p_pair.key) );
|
||||
|
||||
/* if we made it up to here, the pair doesn't exist, create and assign */
|
||||
|
||||
@@ -301,6 +299,7 @@ public:
|
||||
e=create_entry(p_pair.key);
|
||||
if (!e)
|
||||
return;
|
||||
check_hash_table(); // perform mantenience routine
|
||||
}
|
||||
|
||||
e->pair.data = p_pair.data;
|
||||
@@ -478,12 +477,11 @@ public:
|
||||
}
|
||||
inline TData& operator[](const TKey& p_key ) { //assignment
|
||||
|
||||
Entry *e=NULL;
|
||||
if (!hash_table)
|
||||
make_hash_table(); // if no table, make one
|
||||
else
|
||||
check_hash_table(); // perform mantenience routine
|
||||
|
||||
Entry *e = const_cast<Entry*>( get_entry(p_key) );
|
||||
e = const_cast<Entry*>( get_entry(p_key) );
|
||||
|
||||
/* if we made it up to here, the pair doesn't exist, create */
|
||||
if (!e) {
|
||||
@@ -491,6 +489,7 @@ public:
|
||||
e=create_entry(p_key);
|
||||
if (!e)
|
||||
return *(TData*)NULL; /* panic! */
|
||||
check_hash_table(); // perform mantenience routine
|
||||
}
|
||||
|
||||
return e->pair.data;
|
||||
|
||||
@@ -54,9 +54,9 @@ static inline uint32_t hash_djb2(const char *p_cstr) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
static inline uint32_t hash_djb2_buffer(uint8_t *p_buff, int p_len) {
|
||||
static inline uint32_t hash_djb2_buffer(const uint8_t *p_buff, int p_len,uint32_t p_prev=5381) {
|
||||
|
||||
uint32_t hash = 5381;
|
||||
uint32_t hash = p_prev;
|
||||
|
||||
for(int i=0;i<p_len;i++)
|
||||
hash = ((hash << 5) + hash) + p_buff[i]; /* hash * 33 + c */
|
||||
|
||||
@@ -695,6 +695,86 @@ public:
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline Vector<Vector3> clip_polygon(const Vector<Vector3>& polygon,const Plane& p_plane) {
|
||||
|
||||
enum LocationCache {
|
||||
LOC_INSIDE=1,
|
||||
LOC_BOUNDARY=0,
|
||||
LOC_OUTSIDE=-1
|
||||
};
|
||||
|
||||
if (polygon.size()==0)
|
||||
return polygon;
|
||||
|
||||
int *location_cache = (int*)alloca(sizeof(int)*polygon.size());
|
||||
int inside_count = 0;
|
||||
int outside_count = 0;
|
||||
|
||||
for (int a = 0; a < polygon.size(); a++) {
|
||||
//float p_plane.d = (*this) * polygon[a];
|
||||
float dist = p_plane.distance_to(polygon[a]);
|
||||
if (dist <-CMP_POINT_IN_PLANE_EPSILON) {
|
||||
location_cache[a] = LOC_INSIDE;
|
||||
inside_count++;
|
||||
} else {
|
||||
if (dist > CMP_POINT_IN_PLANE_EPSILON) {
|
||||
location_cache[a] = LOC_OUTSIDE;
|
||||
outside_count++;
|
||||
} else {
|
||||
location_cache[a] = LOC_BOUNDARY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outside_count == 0) {
|
||||
|
||||
return polygon; // no changes
|
||||
|
||||
} else if (inside_count == 0) {
|
||||
|
||||
return Vector<Vector3>(); //empty
|
||||
}
|
||||
|
||||
// long count = 0;
|
||||
long previous = polygon.size() - 1;
|
||||
|
||||
Vector<Vector3> clipped;
|
||||
|
||||
for (int index = 0; index < polygon.size(); index++) {
|
||||
int loc = location_cache[index];
|
||||
if (loc == LOC_OUTSIDE) {
|
||||
if (location_cache[previous] == LOC_INSIDE) {
|
||||
const Vector3& v1 = polygon[previous];
|
||||
const Vector3& v2 = polygon[index];
|
||||
|
||||
Vector3 segment= v1 - v2;
|
||||
double den=p_plane.normal.dot( segment );
|
||||
double dist=p_plane.distance_to( v1 ) / den;
|
||||
dist=-dist;
|
||||
clipped.push_back( v1 + segment * dist );
|
||||
}
|
||||
} else {
|
||||
const Vector3& v1 = polygon[index];
|
||||
if ((loc == LOC_INSIDE) && (location_cache[previous] == LOC_OUTSIDE)) {
|
||||
const Vector3& v2 = polygon[previous];
|
||||
Vector3 segment= v1 - v2;
|
||||
double den=p_plane.normal.dot( segment );
|
||||
double dist=p_plane.distance_to( v1 ) / den;
|
||||
dist=-dist;
|
||||
clipped.push_back( v1 + segment * dist );
|
||||
}
|
||||
|
||||
clipped.push_back(v1);
|
||||
}
|
||||
|
||||
previous = index;
|
||||
}
|
||||
|
||||
return clipped;
|
||||
}
|
||||
|
||||
|
||||
static Vector<int> triangulate_polygon(const Vector<Vector2>& p_polygon) {
|
||||
|
||||
Vector<int> triangles;
|
||||
|
||||
@@ -50,7 +50,8 @@ public:
|
||||
NOTIFICATION_WM_FOCUS_IN = 5,
|
||||
NOTIFICATION_WM_FOCUS_OUT = 6,
|
||||
NOTIFICATION_WM_QUIT_REQUEST = 7,
|
||||
NOTIFICATION_WM_UNFOCUS_REQUEST = 8
|
||||
NOTIFICATION_WM_UNFOCUS_REQUEST = 8,
|
||||
NOTIFICATION_OS_MEMORY_WARNING = 9,
|
||||
};
|
||||
|
||||
virtual void input_event( const InputEvent& p_event );
|
||||
|
||||
@@ -225,7 +225,7 @@ void OS::print_all_resources(String p_to_file) {
|
||||
void OS::print_resources_in_use(bool p_short) {
|
||||
|
||||
|
||||
//ResourceCache::dump(NULL,p_short);
|
||||
ResourceCache::dump(NULL,p_short);
|
||||
}
|
||||
|
||||
void OS::dump_resources_to_file(const char* p_file) {
|
||||
@@ -438,7 +438,7 @@ int OS::get_processor_count() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Error OS::native_video_play(String p_path) {
|
||||
Error OS::native_video_play(String p_path, float p_volume) {
|
||||
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
|
||||
virtual String get_unique_ID() const;
|
||||
|
||||
virtual Error native_video_play(String p_path);
|
||||
virtual Error native_video_play(String p_path, float p_volume);
|
||||
virtual bool native_video_is_playing() const;
|
||||
virtual void native_video_pause();
|
||||
virtual void native_video_stop();
|
||||
|
||||
@@ -1337,6 +1337,10 @@ Variant::operator Matrix3() const {
|
||||
|
||||
if (type==MATRIX3)
|
||||
return *_data._matrix3;
|
||||
else if (type==QUAT)
|
||||
return *reinterpret_cast<const Quat*>(_data._mem);
|
||||
else if (type==TRANSFORM)
|
||||
return _data._transform->basis;
|
||||
else
|
||||
return Matrix3();
|
||||
}
|
||||
@@ -1345,6 +1349,10 @@ Variant::operator Quat() const {
|
||||
|
||||
if (type==QUAT)
|
||||
return *reinterpret_cast<const Quat*>(_data._mem);
|
||||
else if (type==MATRIX3)
|
||||
return *_data._matrix3;
|
||||
else if (type==TRANSFORM)
|
||||
return _data._transform->basis;
|
||||
else
|
||||
return Quat();
|
||||
}
|
||||
@@ -1357,6 +1365,8 @@ Variant::operator Transform() const {
|
||||
return *_data._transform;
|
||||
else if (type==MATRIX3)
|
||||
return Transform(*_data._matrix3,Vector3());
|
||||
else if (type==QUAT)
|
||||
return Transform(Matrix3(*reinterpret_cast<const Quat*>(_data._mem)),Vector3());
|
||||
else
|
||||
return Transform();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user