Huge Amount of BugFix

-=-=-=-=-=-=-=-=-=-=-

-Fixes to Collada Exporter (avoid crash situtions)
-Fixed to Collada Importer (Fixed Animation Optimizer Bugs)
-Fixes to RigidBody/RigidBody2D body_enter/body_exit, was buggy
-Fixed ability for RigidBody/RigidBody2D to get contacts reported and bodyin/out in Kinematic mode.
-Added proper trigger support for 3D Physics shapes
-Changed proper value for Z-Offset in OmniLight
-Fixed spot attenuation bug in SpotLight
-Fixed some 3D and 2D spatial soudn bugs related to distance attenuation.
-Fixed bugs in EventPlayer (channels were muted by default)
-Fix in ButtonGroup (get nodes in group are now returned in order)
-Fixed Linear->SRGB Conversion, previous algo sucked, new algo works OK
-Changed SRGB->Linear conversion to use hardware if supported, improves texture quality a lot
-Fixed options for Y-Fov and X-Fov in camera, should be more intuitive.
-Fixed bugs related to viewports and transparency

Huge Amount of New Stuff:
-=-=-=-=-=-=-=-==-=-=-=-

-Ability to manually advance an AnimationPlayer that is inactive (with advance() function)
-More work in WinRT platform
-Added XY normalmap support, imports on this format by default. Reduces normlmap size and enables much nice compression using LATC
-Added Anisotropic filter support to textures, can be specified on import
-Added support for Non-Square, Isometric and Hexagonal tilemaps in TileMap.
-Added Isometric Dungeon demo.
-Added simple hexagonal map demo.
-Added Truck-Town demo. Shows how most types of joints and vehicles are used. Please somebody make a nicer town, this one is too hardcore.
-Added an Object-Picking API to both RigidBody and Area! (and relevant demo)
This commit is contained in:
Juan Linietsky
2014-10-03 00:10:51 -03:00
parent 870c075ebf
commit b24fe3dd20
84 changed files with 1660 additions and 344 deletions

View File

@@ -1004,3 +1004,134 @@ DVector<Plane> Geometry::build_capsule_planes(float p_radius, float p_height, in
}
struct _AtlasWorkRect {
Size2i s;
Point2i p;
int idx;
_FORCE_INLINE_ bool operator<(const _AtlasWorkRect& p_r) const { return s.width > p_r.s.width; };
};
struct _AtlasWorkRectResult {
Vector<_AtlasWorkRect> result;
int max_w;
int max_h;
};
void Geometry::make_atlas(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, Size2i& r_size) {
//super simple, almost brute force scanline stacking fitter
//it's pretty basic for now, but it tries to make sure that the aspect ratio of the
//resulting atlas is somehow square. This is necesary because video cards have limits
//on texture size (usually 2048 or 4096), so the more square a texture, the more chances
//it will work in every hardware.
// for example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a
// 256x8192 atlas (won't work anywhere).
ERR_FAIL_COND(p_rects.size()==0);
Vector<_AtlasWorkRect> wrects;
wrects.resize(p_rects.size());
for(int i=0;i<p_rects.size();i++) {
wrects[i].s=p_rects[i];
wrects[i].idx=i;
}
wrects.sort();
int widest = wrects[0].s.width;
Vector<_AtlasWorkRectResult> results;
for(int i=0;i<=12;i++) {
int w = 1<<i;
int max_h=0;
int max_w=0;
if ( w < widest )
continue;
Vector<int> hmax;
hmax.resize(w);
for(int j=0;j<w;j++)
hmax[j]=0;
//place them
int ofs=0;
int limit_h=0;
for(int j=0;j<wrects.size();j++) {
if (ofs+wrects[j].s.width > w) {
ofs=0;
}
int from_y=0;
for(int k=0;k<wrects[j].s.width;k++) {
if (hmax[ofs+k] > from_y)
from_y=hmax[ofs+k];
}
wrects[j].p.x=ofs;
wrects[j].p.y=from_y;
int end_h = from_y+wrects[j].s.height;
int end_w = ofs+wrects[j].s.width;
if (ofs==0)
limit_h=end_h;
for(int k=0;k<wrects[j].s.width;k++) {
hmax[ofs+k]=end_h;
}
if (end_h > max_h)
max_h=end_h;
if (end_w > max_w)
max_w=end_w;
if (ofs==0 || end_h>limit_h ) //while h limit not reched, keep stacking
ofs+=wrects[j].s.width;
}
_AtlasWorkRectResult result;
result.result=wrects;
result.max_h=max_h;
result.max_w=max_w;
results.push_back(result);
}
//find the result with the best aspect ratio
int best=-1;
float best_aspect=1e20;
for(int i=0;i<results.size();i++) {
float h = nearest_power_of_2(results[i].max_h);
float w = nearest_power_of_2(results[i].max_w);
float aspect = h>w ? h/w : w/h;
if (aspect < best_aspect) {
best=i;
best_aspect=aspect;
}
}
r_result.resize(p_rects.size());
for(int i=0;i<p_rects.size();i++) {
r_result[ results[best].result[i].idx ]=results[best].result[i].p;
}
r_size=Size2(results[best].max_w,results[best].max_h );
}