summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/tests/test_math.cpp1
-rw-r--r--core/math/math_funcs.cpp36
-rw-r--r--core/math/math_funcs.h2
-rw-r--r--doc/base/classes.xml6
-rw-r--r--main/input_default.cpp1
-rw-r--r--modules/gdscript/gd_functions.cpp2
-rw-r--r--scene/3d/baked_light_instance.cpp10
-rw-r--r--scene/3d/baked_light_instance.h2
-rw-r--r--scene/gui/spin_box.cpp2
-rw-r--r--scene/gui/tree.cpp8
-rw-r--r--tools/editor/plugins/baked_light_baker.cpp4
-rw-r--r--tools/editor/plugins/baked_light_editor_plugin.cpp6
12 files changed, 52 insertions, 28 deletions
diff --git a/bin/tests/test_math.cpp b/bin/tests/test_math.cpp
index 8e08969fa4..4b686e8af8 100644
--- a/bin/tests/test_math.cpp
+++ b/bin/tests/test_math.cpp
@@ -113,6 +113,7 @@ uint32_t ihash3( uint32_t a)
MainLoop* test() {
+ print_line(itos(Math::step_decimals( 0.0001 )));
return NULL;
{
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 0fbd031214..64615fe6b4 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -206,25 +206,29 @@ double Math::ceil(double p_x) {
return ::ceil(p_x);
}
-int Math::decimals(double p_step) {
-
- int max=4;
- double llimit = Math::pow(0.1,max);
- double ulimit = 1.0-llimit;
- int i=0;
- while( max) {
-
- float d = absf(p_step) - Math::floor(absf(p_step));
+int Math::step_decimals(double p_step) {
+
+ static const int maxn=9;
+ static const double sd[maxn]={
+ 0.9999, // somehow compensate for floating point error
+ 0.09999,
+ 0.009999,
+ 0.0009999,
+ 0.00009999,
+ 0.000009999,
+ 0.0000009999,
+ 0.00000009999,
+ 0.000000009999
+ };
- if (d<llimit || d>ulimit)
- break;
- p_step*=10.0;
- max--;
- i++;
+ double as=absf(p_step);
+ for(int i=0;i<maxn;i++) {
+ if (as>=sd[i]) {
+ return i;
+ }
}
- return i;
-
+ return maxn;
}
double Math::ease(double p_x, double p_c) {
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 2e1b9c989e..fc76d96b2e 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -66,7 +66,7 @@ public:
static double floor(double p_x);
static double ceil(double p_x);
static double ease(double p_x, double p_c);
- static int decimals(double p_step);
+ static int step_decimals(double p_step);
static double stepify(double p_value,double p_step);
static void seed(uint32_t x=0);
static void randomize();
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index d70b11b5ae..d741dbbb65 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -12264,7 +12264,7 @@
file.open("user://save_game.dat", file.WRITE)
file.store_string(content)
file.close()
-
+
func load():
var file = File.new()
file.open("user://save_game.dat", file.READ)
@@ -15692,7 +15692,7 @@
</brief_description>
<description>
</description>
- ImmediateGeometry is a node used for displaying simple geometry created from code, very similar to how glBegin() and glEnd() worked in old versions of OpenGL (1.x).
+ ImmediateGeometry is a node used for displaying simple geometry created from code, very similar to how glBegin() and glEnd() worked in old versions of OpenGL (1.x).
Simply call [method begin()], and add vertices. For custom vertex colors, uvs, normal, etc. call one of the set_ functions below before adding each vertex. When done, call [method end]
Calls to begin/end are accumulative and all geometry is added together. To clear all the geometry, call [method clear].
If a material override is set, and this material contains a texture, it's possible to override the texture used in this material for every begin/end set of calls.
@@ -42401,7 +42401,7 @@
Because it is easy to get it wrong, here is a quick usage example:
[codeblock]
var tween = get_node("Tween")
- tween.interpolate_property(get_node("Node2D_to_move"), "transform/pos", Vector2(0,0), Vector2(100,100), Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
+ tween.interpolate_property(get_node("Node2D_to_move"), "transform/pos", Vector2(0,0), Vector2(100,100), 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
[/codeblock]
Some of the methods of this class require a property name. You can get the property name by hovering over the property in the inspector of the editor.
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 5e66a8b585..618d0d4f7d 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -588,6 +588,7 @@ static const char *s_ControllerMappings [] =
"030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a5,",
"030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),x:b3,a:b0,b:b1,y:b4,back:b6,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b5,lefttrigger:a2,rightshoulder:b2,righttrigger:a5,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a3,righty:a4,",
+ "030000005e0400008e02000001000000,Microsoft X-Box 360 pad,leftx:a0,lefty:a1,dpdown:h0.1,rightstick:b10,rightshoulder:b5,rightx:a3,start:b7,righty:a4,dpleft:h0.2,lefttrigger:a2,x:b2,dpup:h0.4,back:b6,leftshoulder:b4,y:b3,a:b0,dpright:h0.8,righttrigger:a5,b:b1,",
"030000005e0400008e02000004010000,Microsoft X-Box 360 pad,a:b0,b:b1,x:b2,y:b3,back:b6,start:b7,guide:b8,leftshoulder:b4,rightshoulder:b5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,",
"030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index b9815a5efd..a565e866d0 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -304,7 +304,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
case MATH_DECIMALS: {
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
- r_ret=Math::decimals(*p_args[0]);
+ r_ret=Math::step_decimals(*p_args[0]);
} break;
case MATH_STEPIFY: {
VALIDATE_ARG_COUNT(2);
diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp
index fafa62866f..ca3a309568 100644
--- a/scene/3d/baked_light_instance.cpp
+++ b/scene/3d/baked_light_instance.cpp
@@ -60,6 +60,8 @@ void BakedLightInstance::set_baked_light(const Ref<BakedLight>& p_baked_light) {
// VS::get_singleton()->instance_geometry_set_baked_light(E->get()->get_instance(),baked_light.is_valid()?get_instance():RID());
// }
}
+
+ update_configuration_warning();
}
Ref<BakedLight> BakedLightInstance::get_baked_light() const{
@@ -77,6 +79,14 @@ DVector<Face3> BakedLightInstance::get_faces(uint32_t p_usage_flags) const {
}
+String BakedLightInstance::get_configuration_warning() const {
+ if (get_baked_light().is_null()) {
+ return TTR("BakedLightInstance does not contain a BakedLight resource.");
+ }
+ return String();
+}
+
+
void BakedLightInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_baked_light","baked_light"),&BakedLightInstance::set_baked_light);
diff --git a/scene/3d/baked_light_instance.h b/scene/3d/baked_light_instance.h
index 92c2d50986..002e55df1d 100644
--- a/scene/3d/baked_light_instance.h
+++ b/scene/3d/baked_light_instance.h
@@ -55,6 +55,8 @@ public:
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
+ String get_configuration_warning() const;
+
BakedLightInstance();
};
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 2b64d36a81..98e1a32aef 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -39,7 +39,7 @@ Size2 SpinBox::get_minimum_size() const {
void SpinBox::_value_changed(double) {
- String value = String::num(get_val(),Math::decimals(get_step()));
+ String value = String::num(get_val(),Math::step_decimals(get_step()));
if (prefix!="")
value=prefix+" "+value;
if (suffix!="")
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 82459ba0ab..487f62ed44 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1179,8 +1179,8 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
Ref<Texture> updown = cache.updown;
- //String valtext = String::num( p_item->cells[i].val, Math::decimals( p_item->cells[i].step ) );
- String valtext = rtos( p_item->cells[i].val );
+ String valtext = String::num( p_item->cells[i].val, Math::step_decimals( p_item->cells[i].step ) );
+ //String valtext = rtos( p_item->cells[i].val );
font->draw( ci, text_pos, valtext, col, item_rect.size.x-updown->get_width());
if (!p_item->cells[i].editable)
@@ -1746,7 +1746,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
} else {
- editor_text=String::num( p_item->cells[col].val, Math::decimals( p_item->cells[col].step ) );
+ editor_text=String::num( p_item->cells[col].val, Math::step_decimals( p_item->cells[col].step ) );
if (select_mode==SELECT_MULTI && get_tree()->get_last_event_id() == focus_in_id)
bring_up_editor=false;
@@ -2521,7 +2521,7 @@ bool Tree::edit_selected() {
text_editor->set_pos( textedpos );
text_editor->set_size( rect.size);
text_editor->clear();
- text_editor->set_text( c.mode==TreeItem::CELL_MODE_STRING?c.text:rtos(c.val) );
+ text_editor->set_text( c.mode==TreeItem::CELL_MODE_STRING?c.text:String::num( c.val, Math::step_decimals( c.step ) ) );
text_editor->select_all();
if (c.mode==TreeItem::CELL_MODE_RANGE || c.mode==TreeItem::CELL_MODE_RANGE_EXPRESSION ) {
diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp
index 6a88ba4cbe..a2e94e8855 100644
--- a/tools/editor/plugins/baked_light_baker.cpp
+++ b/tools/editor/plugins/baked_light_baker.cpp
@@ -1772,6 +1772,10 @@ void BakedLightBaker::bake(const Ref<BakedLight> &p_light, Node* p_node) {
mat_map.clear();
tex_map.clear();
print_line("\ttotal triangles: "+itos(triangles.size()));
+ // no geometry
+ if (triangles.size() == 0) {
+ return;
+ }
ep.step(TTR("Fixing Lights"),1);
_fix_lights();
ep.step(TTR("Making BVH"),2);
diff --git a/tools/editor/plugins/baked_light_editor_plugin.cpp b/tools/editor/plugins/baked_light_editor_plugin.cpp
index df76f28ae0..a58a0c25e2 100644
--- a/tools/editor/plugins/baked_light_editor_plugin.cpp
+++ b/tools/editor/plugins/baked_light_editor_plugin.cpp
@@ -206,8 +206,9 @@ void BakedLightEditor::_menu_option(int p_option) {
void BakedLightEditor::_bake_pressed() {
ERR_FAIL_COND(!node);
- if (node->get_baked_light().is_null()) {
- err_dialog->set_text(TTR("BakedLightInstance does not contain a BakedLight resource."));
+ const String conf_warning = node->get_configuration_warning();
+ if (!conf_warning.empty()) {
+ err_dialog->set_text(conf_warning);
err_dialog->popup_centered_minsize();
button_bake->set_pressed(false);
return;
@@ -236,6 +237,7 @@ void BakedLightEditor::_bake_pressed() {
update_timeout=0;
last_rays_time=0;
+ button_bake->set_pressed(false);
set_process(true);
}