summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/Particles.xml16
-rw-r--r--doc/classes/Particles2D.xml20
-rw-r--r--doc/classes/ParticlesMaterial.xml68
-rw-r--r--doc/classes/Performance.xml39
-rw-r--r--editor/editor_node.cpp3
-rw-r--r--editor/project_manager.cpp3
-rw-r--r--modules/mono/SCsub5
-rw-r--r--platform/osx/os_osx.h7
-rw-r--r--platform/osx/os_osx.mm106
-rw-r--r--servers/physics/physics_server_sw.cpp15
-rw-r--r--servers/physics/physics_server_sw.h3
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp15
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h3
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.h7
-rw-r--r--servers/physics_2d_server.cpp2
-rw-r--r--servers/physics_2d_server.h3
-rw-r--r--servers/physics_server.cpp2
-rw-r--r--servers/physics_server.h3
18 files changed, 258 insertions, 62 deletions
diff --git a/doc/classes/Particles.xml b/doc/classes/Particles.xml
index e17e60f2bc..1e89d2194c 100644
--- a/doc/classes/Particles.xml
+++ b/doc/classes/Particles.xml
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Particles" inherits="GeometryInstance" category="Core" version="3.0.alpha.custom_build">
<brief_description>
+ 3D particle emitter.
</brief_description>
<description>
+ 3D particle node used to create a variety of particle systems and effects. [code]Particles[/code] features an emitter that generates some number of particles at a given rate.
+ Use the [code]process_material[/code] property to add a [ParticlesMaterial] to configure particle appearance and behavior. Alternatively, you can add a [ShaderMaterial] which will be applied to all particles.
</description>
<tutorials>
</tutorials>
@@ -252,8 +255,10 @@
</methods>
<members>
<member name="amount" type="int" setter="set_amount" getter="get_amount">
+ Number of particles to emit.
</member>
<member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="Particles.DrawOrder">
+ Particle draw order. Uses [code]DRAW_ORDER_*[/code] values. Default value: [code]DRAW_ORDER_INDEX[/code].
</member>
<member name="draw_pass_1" type="Mesh" setter="set_draw_pass_mesh" getter="get_draw_pass_mesh">
</member>
@@ -266,36 +271,47 @@
<member name="draw_passes" type="int" setter="set_draw_passes" getter="get_draw_passes">
</member>
<member name="emitting" type="bool" setter="set_emitting" getter="is_emitting">
+ If [code]true[/code] particles are being emitted. Default value: [code]true[/code].
</member>
<member name="explosiveness" type="float" setter="set_explosiveness_ratio" getter="get_explosiveness_ratio">
+ Time ratio between each emission. If [code]0[/code] particles are emitted continuously. If [code]1[/code] all particles are emitted simultaneously. Default value: [code]0[/code].
</member>
<member name="fixed_fps" type="int" setter="set_fixed_fps" getter="get_fixed_fps">
</member>
<member name="fract_delta" type="bool" setter="set_fractional_delta" getter="get_fractional_delta">
</member>
<member name="lifetime" type="float" setter="set_lifetime" getter="get_lifetime">
+ Amount of time each particle will exist. Default value: [code]1[/code].
</member>
<member name="local_coords" type="bool" setter="set_use_local_coordinates" getter="get_use_local_coordinates">
+ If [code]true[/code] particles use the parent node's coordinate space. If [code]false[/code] they use global coordinates. Default value: [code]true[/code].
</member>
<member name="one_shot" type="bool" setter="set_one_shot" getter="get_one_shot">
+ If [code]true[/code] only [code]amount[/code] particles will be emitted. Default value: [code]false[/code].
</member>
<member name="preprocess" type="float" setter="set_pre_process_time" getter="get_pre_process_time">
</member>
<member name="process_material" type="Material" setter="set_process_material" getter="get_process_material">
+ [Material] for processing particles. Can be a [ParticlesMaterial] or a [ShaderMaterial].
</member>
<member name="randomness" type="float" setter="set_randomness_ratio" getter="get_randomness_ratio">
+ Emission randomness ratio. Default value: [code]0[/code].
</member>
<member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale">
+ Speed scaling ratio. Default value: [code]1[/code].
</member>
<member name="visibility_aabb" type="Rect3" setter="set_visibility_aabb" getter="get_visibility_aabb">
</member>
</members>
<constants>
<constant name="DRAW_ORDER_INDEX" value="0">
+ Particles are drawn in the order emitted.
</constant>
<constant name="DRAW_ORDER_LIFETIME" value="1">
+ Particles are drawn in order of remaining lifetime.
</constant>
<constant name="DRAW_ORDER_VIEW_DEPTH" value="2">
+ Particles are drawn in order of depth.
</constant>
<constant name="MAX_DRAW_PASSES" value="4" enum="">
</constant>
diff --git a/doc/classes/Particles2D.xml b/doc/classes/Particles2D.xml
index d837d6eb62..b2c63ea0c3 100644
--- a/doc/classes/Particles2D.xml
+++ b/doc/classes/Particles2D.xml
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Particles2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build">
<brief_description>
- 2D Particle emitter
+ 2D particle emitter.
</brief_description>
<description>
- Particles2D is a particle system 2D [Node] that is used to simulate several types of particle effects, such as explosions, rain, snow, fireflies, or other magical-like shinny sparkles. Particles are drawn using impostors, and given their dynamic behavior, the user must provide a visibility bounding box (although helpers to create one automatically exist).
+ 2D particle node used to create a variety of particle systems and effects. [code]Particles2D[/code] features an emitter that generates some number of particles at a given rate.
+ Use the [code]process_material[/code] property to add a [ParticlesMaterial] to configure particle appearance and behavior. Alternatively, you can add a [ShaderMaterial] which will be applied to all particles.
</description>
<tutorials>
</tutorials>
@@ -285,46 +286,61 @@
</methods>
<members>
<member name="amount" type="int" setter="set_amount" getter="get_amount">
+ Number of particles to emit.
</member>
<member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="Particles2D.DrawOrder">
+ Particle draw order. Uses [code]DRAW_ORDER_*[/code] values. Default value: [code]DRAW_ORDER_INDEX[/code].
</member>
<member name="emitting" type="bool" setter="set_emitting" getter="is_emitting">
+ If [code]true[/code] particles are being emitted. Default value: [code]true[/code].
</member>
<member name="explosiveness" type="float" setter="set_explosiveness_ratio" getter="get_explosiveness_ratio">
+ Time ratio between each emission. If [code]0[/code] particles are emitted continuously. If [code]1[/code] all particles are emitted simultaneously. Default value: [code]0[/code].
</member>
<member name="fixed_fps" type="int" setter="set_fixed_fps" getter="get_fixed_fps">
</member>
<member name="fract_delta" type="bool" setter="set_fractional_delta" getter="get_fractional_delta">
</member>
<member name="h_frames" type="int" setter="set_h_frames" getter="get_h_frames">
+ Number of horizontal frames in [code]texture[/code].
</member>
<member name="lifetime" type="float" setter="set_lifetime" getter="get_lifetime">
+ Amount of time each particle will exist. Default value: [code]1[/code].
</member>
<member name="local_coords" type="bool" setter="set_use_local_coordinates" getter="get_use_local_coordinates">
+ If [code]true[/code] particles use the parent node's coordinate space. If [code]false[/code] they use global coordinates. Default value: [code]true[/code].
</member>
<member name="normal_map" type="Texture" setter="set_normal_map" getter="get_normal_map">
</member>
<member name="one_shot" type="bool" setter="set_one_shot" getter="get_one_shot">
+ If [code]true[/code] only [code]amount[/code] particles will be emitted. Default value: [code]false[/code].
</member>
<member name="preprocess" type="float" setter="set_pre_process_time" getter="get_pre_process_time">
</member>
<member name="process_material" type="Material" setter="set_process_material" getter="get_process_material">
+ [Material] for processing particles. Can be a [ParticlesMaterial] or a [ShaderMaterial].
</member>
<member name="randomness" type="float" setter="set_randomness_ratio" getter="get_randomness_ratio">
+ Emission randomness ratio. Default value: [code]0[/code].
</member>
<member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale">
+ Speed scaling ratio. Default value: [code]1[/code].
</member>
<member name="texture" type="Texture" setter="set_texture" getter="get_texture">
+ Particle texture. If [code]null[/code] particles will be squares.
</member>
<member name="v_frames" type="int" setter="set_v_frames" getter="get_v_frames">
+ Number of vertical frames in [code]texture[/code].
</member>
<member name="visibility_rect" type="Rect2" setter="set_visibility_rect" getter="get_visibility_rect">
</member>
</members>
<constants>
<constant name="DRAW_ORDER_INDEX" value="0">
+ Particles are drawn in the order emitted.
</constant>
<constant name="DRAW_ORDER_LIFETIME" value="1">
+ Particles are drawn in order of remaining lifetime.
</constant>
</constants>
</class>
diff --git a/doc/classes/ParticlesMaterial.xml b/doc/classes/ParticlesMaterial.xml
index 1767a19a9f..bebdc44b69 100644
--- a/doc/classes/ParticlesMaterial.xml
+++ b/doc/classes/ParticlesMaterial.xml
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ParticlesMaterial" inherits="Material" category="Core" version="3.0.alpha.custom_build">
<brief_description>
+ Particle properties for [Particles] and [Particles2D] nodes.
</brief_description>
<description>
+ ParticlesMaterial defines particle properties and behavior. It is used in the [code]process_material[/code] of [Particles] and [Particles2D] emitter nodes.
+ Some of this material's properties are applied to each particle when emitted, while others can have a [CurveTexture] applied to vary values over the lifetime of the particle.
</description>
<tutorials>
</tutorials>
@@ -294,152 +297,217 @@
</methods>
<members>
<member name="angle" type="float" setter="set_param" getter="get_param">
+ Initial rotation applied to each particle.
</member>
<member name="angle_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's rotation will be animated along this [CurveTexture].
</member>
<member name="angle_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Rotation randomness ratio. Default value: [code]0[/code].
</member>
<member name="angular_velocity" type="float" setter="set_param" getter="get_param">
+ Initial angular velocity applied to each particle.
</member>
<member name="angular_velocity_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's angular velocity will vary along this [CurveTexture].
</member>
<member name="angular_velocity_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Angular velocity randomness ratio. Default value: [code]0[/code].
</member>
<member name="anim_loop" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] animation will loop. Default value: [code]false[/code].
</member>
<member name="anim_offset" type="float" setter="set_param" getter="get_param">
+ Particle animation offset.
</member>
<member name="anim_offset_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's animation offset will vary along this [CurveTexture].
</member>
<member name="anim_offset_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Animation offset randomness ratio. Default value: [code]0[/code].
</member>
<member name="anim_speed" type="float" setter="set_param" getter="get_param">
+ Particle animation speed.
</member>
<member name="anim_speed_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's animation speed will vary along this [CurveTexture].
</member>
<member name="anim_speed_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Animation speed randomness ratio. Default value: [code]0[/code].
</member>
<member name="color" type="Color" setter="set_color" getter="get_color">
+ Each particle's initial color. If the [Particle2D]'s [code]texture[/code] is defined, it will be multiplied by this color.
</member>
<member name="color_ramp" type="Texture" setter="set_color_ramp" getter="get_color_ramp">
+ Each particle's color will vary along this [GradientTexture].
</member>
<member name="damping" type="float" setter="set_param" getter="get_param">
+ The rate at which particles lose velocity.
</member>
<member name="damping_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Damping will vary along this [CurveTexture].
</member>
<member name="damping_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Damping randomness ratio. Default value: [code]0[/code].
</member>
<member name="emission_box_extents" type="Vector3" setter="set_emission_box_extents" getter="get_emission_box_extents">
+ The box's extents if [code]emission_shape[/code] is set to [code]EMISSION_SHAPE_BOX[/code].
</member>
<member name="emission_color_texture" type="Texture" setter="set_emission_color_texture" getter="get_emission_color_texture">
</member>
<member name="emission_normal_texture" type="Texture" setter="set_emission_normal_texture" getter="get_emission_normal_texture">
</member>
<member name="emission_point_count" type="int" setter="set_emission_point_count" getter="get_emission_point_count">
+ The number of emission points if [code]emission_shape[/code] is set to [code]EMISSION_SHAPE_POINTS[/code] or [code]EMISSION_SHAPE_DIRECTED_POINTS[/code].
</member>
<member name="emission_point_texture" type="Texture" setter="set_emission_point_texture" getter="get_emission_point_texture">
</member>
<member name="emission_shape" type="int" setter="set_emission_shape" getter="get_emission_shape" enum="ParticlesMaterial.EmissionShape">
+ Particles will be emitted inside this region. Use [code]EMISSION_SHAPE_*[/code] constants for values. Default value: [code]EMISSION_SHAPE_POINT[/code].
</member>
<member name="emission_sphere_radius" type="float" setter="set_emission_sphere_radius" getter="get_emission_sphere_radius">
+ The sphere's radius if [code]emission_shape[/code] is set to [code]EMISSION_SHAPE_SPHERE[/code].
</member>
<member name="flag_align_y" type="bool" setter="set_flag" getter="get_flag">
</member>
<member name="flag_disable_z" type="bool" setter="set_flag" getter="get_flag">
+ If [code]true[/code] particles will not move on the z axis. Default value: [code]true[/code] for [Particles2D], [code]false[/code] for [Particles].
</member>
<member name="flag_rotate_y" type="bool" setter="set_flag" getter="get_flag">
</member>
<member name="flatness" type="float" setter="set_flatness" getter="get_flatness">
</member>
<member name="gravity" type="Vector3" setter="set_gravity" getter="get_gravity">
+ Gravity applied to every particle. Default value: [code](0, 98, 0)[/code].
</member>
<member name="hue_variation" type="float" setter="set_param" getter="get_param">
+ Initial hue variation applied to each particle.
</member>
<member name="hue_variation_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's hue will vary along this [CurveTexture].
</member>
<member name="hue_variation_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Hue variation randomness ratio. Default value: [code]0[/code].
</member>
<member name="initial_velocity" type="float" setter="set_param" getter="get_param">
+ Initial velocity for each particle.
</member>
<member name="initial_velocity_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Initial velocity randomness ratio. Default value: [code]0[/code].
</member>
<member name="linear_accel" type="float" setter="set_param" getter="get_param">
+ Linear acceleration applied to each particle.
</member>
<member name="linear_accel_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's linear acceleration will vary along this [CurveTexture].
</member>
<member name="linear_accel_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Linear acceleration randomness ratio. Default value: [code]0[/code].
</member>
<member name="orbit_velocity" type="float" setter="set_param" getter="get_param">
+ Orbital velocity applied to each particle.
</member>
<member name="orbit_velocity_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's orbital velocity will vary along this [CurveTexture].
</member>
<member name="orbit_velocity_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Orbital velocity randomness ratio. Default value: [code]0[/code].
</member>
<member name="radial_accel" type="float" setter="set_param" getter="get_param">
+ Linear acceleration applied to each particle.
</member>
<member name="radial_accel_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's radial acceleration will vary along this [CurveTexture].
</member>
<member name="radial_accel_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Radial acceleration randomness ratio. Default value: [code]0[/code].
</member>
<member name="scale" type="float" setter="set_param" getter="get_param">
+ Initial scale applied to each particle.
</member>
<member name="scale_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's scale will vary along this [CurveTexture].
</member>
<member name="scale_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Scale randomness ratio. Default value: [code]0[/code].
</member>
<member name="spread" type="float" setter="set_spread" getter="get_spread">
+ Each particle's initial direction range from [code]+spread[/code] to [code]-spread[/code] degrees. Default value: [code]45[/code].
</member>
<member name="tangential_accel" type="float" setter="set_param" getter="get_param">
+ Tangential acceleration applied to each particle. Tangential acceleration is perpendicular to the particle's velocity.
</member>
<member name="tangential_accel_curve" type="Texture" setter="set_param_texture" getter="get_param_texture">
+ Each particle's tangential acceleration will vary along this [CurveTexture].
</member>
<member name="tangential_accel_random" type="float" setter="set_param_randomness" getter="get_param_randomness">
+ Tangential acceleration randomness ratio. Default value: [code]0[/code].
</member>
<member name="trail_color_modifier" type="GradientTexture" setter="set_trail_color_modifier" getter="get_trail_color_modifier">
+ Trail particles' color will vary along this [GradientTexture].
</member>
<member name="trail_divisor" type="int" setter="set_trail_divisor" getter="get_trail_divisor">
+ Emitter will emit [code]amount[/code] divided by [code]trail_divisor[/code] particles. The remaining particles will be used as trail(s).
</member>
<member name="trail_size_modifier" type="CurveTexture" setter="set_trail_size_modifier" getter="get_trail_size_modifier">
+ Trail particles' size will vary along this [CurveTexture].
</member>
</members>
<constants>
<constant name="PARAM_INITIAL_LINEAR_VELOCITY" value="0">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set initial velocity properties.
</constant>
<constant name="PARAM_ANGULAR_VELOCITY" value="1">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set angular velocity properties.
</constant>
<constant name="PARAM_ORBIT_VELOCITY" value="2">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set orbital_velocity properties.
</constant>
<constant name="PARAM_LINEAR_ACCEL" value="3">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set linear acceleration properties.
</constant>
<constant name="PARAM_RADIAL_ACCEL" value="4">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set radial acceleration properties.
</constant>
<constant name="PARAM_TANGENTIAL_ACCEL" value="5">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set tangential acceleration properties.
</constant>
<constant name="PARAM_DAMPING" value="6">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set damping properties.
</constant>
<constant name="PARAM_ANGLE" value="7">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set angle properties.
</constant>
<constant name="PARAM_SCALE" value="8">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set scale properties.
</constant>
<constant name="PARAM_HUE_VARIATION" value="9">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set hue_variation properties.
</constant>
<constant name="PARAM_ANIM_SPEED" value="10">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set animation speed properties.
</constant>
<constant name="PARAM_ANIM_OFFSET" value="11">
+ Use with [method set_param], [method set_param_randomness], and [method set_param_texture] to set animation offset properties.
</constant>
<constant name="PARAM_MAX" value="12">
</constant>
<constant name="FLAG_ALIGN_Y_TO_VELOCITY" value="0">
+ Use with [method set_flag] to set [member flag_align_y].
</constant>
<constant name="FLAG_ROTATE_Y" value="1">
+ Use with [method set_flag] to set [member flag_rotate_y]
</constant>
<constant name="FLAG_MAX" value="4">
</constant>
<constant name="EMISSION_SHAPE_POINT" value="0">
+ All particles will be emitted from a single point.
</constant>
<constant name="EMISSION_SHAPE_SPHERE" value="1">
+ Particles will be emitted in the volume of a sphere.
</constant>
<constant name="EMISSION_SHAPE_BOX" value="2">
+ Particles will be emitted in the volume of a box.
</constant>
<constant name="EMISSION_SHAPE_POINTS" value="3">
</constant>
diff --git a/doc/classes/Performance.xml b/doc/classes/Performance.xml
index 71987ace9e..82ee3531f1 100644
--- a/doc/classes/Performance.xml
+++ b/doc/classes/Performance.xml
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="Performance" inherits="Object" category="Core" version="3.0.alpha.custom_build">
<brief_description>
+ Exposes performance related data.
</brief_description>
<description>
+ This class provides access to a number of different monitors related to performance, such as memory usage, draw calls, and FPS. These are the same as the values displayed in the [i]Monitor[/i] tab in the editor's [i]Debugger[/i] panel. By using the [method get_monitor] method of this class, you can access this data from your code. Note that a few of these monitors are only available in debug mode and will always return 0 when used in a release build.
+ Many of these monitors are not updated in real-time, so there may be a short delay between changes.
</description>
<tutorials>
</tutorials>
@@ -15,63 +18,93 @@
<argument index="0" name="monitor" type="int" enum="Performance.Monitor">
</argument>
<description>
+ Returns the value of one of the available monitors. You should provide one of this class's constants as the argument, like this:
+ [codeblock]
+ print(Performance.get_monitor(Performance.TIME_FPS)) # Prints the FPS to the console
+ [/codeblock]
</description>
</method>
</methods>
<constants>
<constant name="TIME_FPS" value="0">
+ Frames per second.
</constant>
<constant name="TIME_PROCESS" value="1">
+ Time it took to complete one frame.
</constant>
- <constant name="TIME_FIXED_PROCESS" value="2">
+ <constant name="TIME_PHYSICS_PROCESS" value="2">
+ Time it took to complete one physics frame.
</constant>
<constant name="MEMORY_STATIC" value="3">
+ Static memory currently used, in bytes. Not available in release builds.
</constant>
<constant name="MEMORY_DYNAMIC" value="4">
+ Dynamic memory currently used, in bytes. Not available in release builds.
</constant>
<constant name="MEMORY_STATIC_MAX" value="5">
+ Available static memory. Not available in release builds.
</constant>
<constant name="MEMORY_DYNAMIC_MAX" value="6">
+ Available dynamic memory. Not available in release builds.
</constant>
<constant name="MEMORY_MESSAGE_BUFFER_MAX" value="7">
+ Largest amount of memory the message queue buffer has used, in bytes. The message queue is used for deferred functions calls and notifications.
</constant>
<constant name="OBJECT_COUNT" value="8">
+ Number of objects currently instanced (including nodes).
</constant>
<constant name="OBJECT_RESOURCE_COUNT" value="9">
+ Number of resources currently used.
</constant>
<constant name="OBJECT_NODE_COUNT" value="10">
+ Number of nodes currently instanced. This also includes the root node, as well as any nodes not in the scene tree.
</constant>
<constant name="RENDER_OBJECTS_IN_FRAME" value="11">
+ 3D objects drawn per frame.
</constant>
<constant name="RENDER_VERTICES_IN_FRAME" value="12">
+ Vertices drawn per frame. 3D only.
</constant>
<constant name="RENDER_MATERIAL_CHANGES_IN_FRAME" value="13">
+ Material changes per frame. 3D only
</constant>
<constant name="RENDER_SHADER_CHANGES_IN_FRAME" value="14">
+ Shader changes per frame. 3D only.
</constant>
<constant name="RENDER_SURFACE_CHANGES_IN_FRAME" value="15">
+ Render surface changes per frame. 3D only.
</constant>
<constant name="RENDER_DRAW_CALLS_IN_FRAME" value="16">
- </constant>
- <constant name="RENDER_USAGE_VIDEO_MEM_TOTAL" value="20">
+ Draw calls per frame. 3D only.
</constant>
<constant name="RENDER_VIDEO_MEM_USED" value="17">
+ Video memory used. Includes both texture and vertex memory.
</constant>
<constant name="RENDER_TEXTURE_MEM_USED" value="18">
+ Texture memory used.
</constant>
<constant name="RENDER_VERTEX_MEM_USED" value="19">
+ Vertex memory used.
+ </constant>
+ <constant name="RENDER_USAGE_VIDEO_MEM_TOTAL" value="20">
</constant>
<constant name="PHYSICS_2D_ACTIVE_OBJECTS" value="21">
+ Number of active [RigidBody2D] nodes in the game.
</constant>
<constant name="PHYSICS_2D_COLLISION_PAIRS" value="22">
+ Number of collision pairs in the 2D physics engine.
</constant>
<constant name="PHYSICS_2D_ISLAND_COUNT" value="23">
+ Number of islands in the 2D physics engine.
</constant>
<constant name="PHYSICS_3D_ACTIVE_OBJECTS" value="24">
+ Number of active [RigidBody] and [VehicleBody] nodes in the game.
</constant>
<constant name="PHYSICS_3D_COLLISION_PAIRS" value="25">
+ Number of collision pairs in the 3D physics engine.
</constant>
<constant name="PHYSICS_3D_ISLAND_COUNT" value="26">
+ Number of islands in the 3D physics engine.
</constant>
<constant name="MONITOR_MAX" value="27">
</constant>
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 4e0ad38320..ff415c83f1 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -4588,7 +4588,8 @@ EditorNode::EditorNode() {
{
int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode");
if (dpi_mode == 0) {
- editor_set_scale(OS::get_singleton()->get_screen_dpi(0) >= 192 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x > 2000 ? 2.0 : 1.0);
+ const int screen = OS::get_singleton()->get_current_screen();
+ editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
} else if (dpi_mode == 1) {
editor_set_scale(0.75);
} else if (dpi_mode == 2) {
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 1fb3fb2ed1..9f23df5c03 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1420,7 +1420,8 @@ ProjectManager::ProjectManager() {
{
int dpi_mode = EditorSettings::get_singleton()->get("interface/editor/hidpi_mode");
if (dpi_mode == 0) {
- editor_set_scale(OS::get_singleton()->get_screen_dpi(0) >= 192 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x > 2000 ? 2.0 : 1.0);
+ const int screen = OS::get_singleton()->get_current_screen();
+ editor_set_scale(OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000 ? 2.0 : 1.0);
} else if (dpi_mode == 1) {
editor_set_scale(0.75);
} else if (dpi_mode == 2) {
diff --git a/modules/mono/SCsub b/modules/mono/SCsub
index 0af2056c5c..caf4fdb3ca 100644
--- a/modules/mono/SCsub
+++ b/modules/mono/SCsub
@@ -2,9 +2,10 @@
Import('env')
+from compat import byte_to_str
def make_cs_files_header(src, dst):
- with open(dst, 'wb') as header:
+ with open(dst, 'w') as header:
header.write('/* This is an automatically generated file; DO NOT EDIT! OK THX */\n')
header.write('#ifndef _CS_FILES_DATA_H\n')
header.write('#define _CS_FILES_DATA_H\n\n')
@@ -26,7 +27,7 @@ def make_cs_files_header(src, dst):
for i, buf_idx in enumerate(range(len(buf))):
if i > 0:
header.write(', ')
- header.write(str(ord(buf[buf_idx])))
+ header.write(byte_to_str(buf[buf_idx]))
inserted_files += '\tr_files.insert(\"' + file + '\", ' \
'CompressedFile(_cs_' + name + '_compressed_size, ' \
'_cs_' + name + '_uncompressed_size, ' \
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index eb8c0566b4..05adfeb0f5 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -112,15 +112,16 @@ public:
CrashHandler crash_handler;
float _mouse_scale(float p_scale) {
- if (display_scale > 1.0)
+ if (_display_scale() > 1.0)
return p_scale;
else
return 1.0;
}
- void _update_window();
+ float _display_scale() const;
+ float _display_scale(id screen) const;
- float display_scale;
+ void _update_window();
protected:
virtual int get_video_driver_count() const;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 8323aa84a8..2c81a02014 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -180,13 +180,13 @@ static bool mouse_down_control = false;
if (newBackingScaleFactor != oldBackingScaleFactor) {
//Set new display scale and window size
- OS_OSX::singleton->display_scale = newBackingScaleFactor;
+ float newDisplayScale = OS_OSX::singleton->is_hidpi_allowed() ? newBackingScaleFactor : 1.0;
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
const NSRect fbRect = contentRect; //convertRectToBacking(contentRect);
- OS_OSX::singleton->window_size.width = fbRect.size.width * OS_OSX::singleton->display_scale;
- OS_OSX::singleton->window_size.height = fbRect.size.height * OS_OSX::singleton->display_scale;
+ OS_OSX::singleton->window_size.width = fbRect.size.width * newDisplayScale;
+ OS_OSX::singleton->window_size.height = fbRect.size.height * newDisplayScale;
//Update context
if (OS_OSX::singleton->main_loop) {
@@ -206,8 +206,9 @@ static bool mouse_down_control = false;
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
const NSRect fbRect = contentRect; //convertRectToBacking(contentRect);
- OS_OSX::singleton->window_size.width = fbRect.size.width * OS_OSX::singleton->display_scale;
- OS_OSX::singleton->window_size.height = fbRect.size.height * OS_OSX::singleton->display_scale;
+ float displayScale = OS_OSX::singleton->_display_scale();
+ OS_OSX::singleton->window_size.width = fbRect.size.width * displayScale;
+ OS_OSX::singleton->window_size.height = fbRect.size.height * displayScale;
if (OS_OSX::singleton->main_loop) {
Main::force_redraw();
@@ -352,7 +353,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange {
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- NSRect pointInWindowRect = NSMakeRect(OS_OSX::singleton->im_position.x / OS_OSX::singleton->display_scale, contentRect.size.height - (OS_OSX::singleton->im_position.y / OS_OSX::singleton->display_scale) - 1, 0, 0);
+ float displayScale = OS_OSX::singleton->_display_scale();
+ NSRect pointInWindowRect = NSMakeRect(OS_OSX::singleton->im_position.x / displayScale, contentRect.size.height - (OS_OSX::singleton->im_position.y / displayScale) - 1, 0, 0);
NSPoint pointOnScreen = [[OS_OSX::singleton->window_view window] convertRectToScreen:pointInWindowRect].origin;
return NSMakeRect(pointOnScreen.x, pointOnScreen.y, 0, 0);
@@ -940,15 +942,6 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
kTISNotifySelectedKeyboardInputSourceChanged, NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
- if (is_hidpi_allowed() && [[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) {
- for (NSScreen *screen in [NSScreen screens]) {
- float s = [screen backingScaleFactor];
- if (s > display_scale) {
- display_scale = s;
- }
- }
- }
-
window_delegate = [[GodotWindowDelegate alloc] init];
// Don't use accumulation buffer support; it's not accelerated
@@ -972,10 +965,19 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
window_view = [[GodotContentView alloc] init];
- window_size.width = p_desired.width * display_scale;
- window_size.height = p_desired.height * display_scale;
+ float displayScale = 1.0;
+ if (is_hidpi_allowed()) {
+ // note that mainScreen is not screen #0 but the one with the keyboard focus.
+ NSScreen *screen = [NSScreen mainScreen];
+ if ([screen respondsToSelector:@selector(backingScaleFactor)]) {
+ displayScale = fmax(displayScale, [screen backingScaleFactor]);
+ }
+ }
+
+ window_size.width = p_desired.width * displayScale;
+ window_size.height = p_desired.height * displayScale;
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && display_scale > 1) {
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && displayScale > 1.0) {
[window_view setWantsBestResolutionOpenGLSurface:YES];
//if (current_videomode.resizable)
[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
@@ -1274,7 +1276,8 @@ void OS_OSX::warp_mouse_position(const Point2 &p_to) {
//local point in window coords
const NSRect contentRect = [window_view frame];
- NSRect pointInWindowRect = NSMakeRect(p_to.x / display_scale, contentRect.size.height - (p_to.y / display_scale) - 1, 0, 0);
+ float displayScale = _display_scale();
+ NSRect pointInWindowRect = NSMakeRect(p_to.x / displayScale, contentRect.size.height - (p_to.y / displayScale) - 1, 0, 0);
NSPoint pointOnScreen = [[window_view window] convertRectToScreen:pointInWindowRect].origin;
//point in scren coords
@@ -1475,17 +1478,17 @@ int OS_OSX::get_screen_count() const {
return [screenArray count];
};
+static int get_screen_index(NSScreen *screen) {
+ const NSUInteger index = [[NSScreen screens] indexOfObject:screen];
+ return index == NSNotFound ? 0 : index;
+}
+
int OS_OSX::get_current_screen() const {
- Vector2 wpos = get_window_position();
-
- int count = get_screen_count();
- for (int i = 0; i < count; i++) {
- Point2 pos = get_screen_position(i);
- Size2 size = get_screen_size(i);
- if ((wpos.x >= pos.x && wpos.x < pos.x + size.width) && (wpos.y >= pos.y && wpos.y < pos.y + size.height))
- return i;
+ if (window_object) {
+ return get_screen_index([window_object screen]);
+ } else {
+ return get_screen_index([NSScreen mainScreen]);
}
- return 0;
};
void OS_OSX::set_current_screen(int p_screen) {
@@ -1500,12 +1503,7 @@ Point2 OS_OSX::get_screen_position(int p_screen) const {
NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
- float displayScale = 1.0;
-
- if (display_scale > 1.0 && [[screenArray objectAtIndex:p_screen] respondsToSelector:@selector(backingScaleFactor)]) {
- displayScale = [[screenArray objectAtIndex:p_screen] backingScaleFactor];
- }
-
+ float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
return Point2(nsrect.origin.x, nsrect.origin.y) * displayScale;
}
@@ -1520,12 +1518,7 @@ int OS_OSX::get_screen_dpi(int p_screen) const {
NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
- float displayScale = 1.0;
-
- if (display_scale > 1.0 && [[screenArray objectAtIndex:p_screen] respondsToSelector:@selector(backingScaleFactor)]) {
- displayScale = [[screenArray objectAtIndex:p_screen] backingScaleFactor];
- }
-
+ float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
NSDictionary *description = [[screenArray objectAtIndex:p_screen] deviceDescription];
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize displayPhysicalSize = CGDisplayScreenSize(
@@ -1544,12 +1537,7 @@ Size2 OS_OSX::get_screen_size(int p_screen) const {
NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
- float displayScale = 1.0;
-
- if (display_scale > 1.0 && [[screenArray objectAtIndex:p_screen] respondsToSelector:@selector(backingScaleFactor)]) {
- displayScale = [[screenArray objectAtIndex:p_screen] backingScaleFactor];
- }
-
+ float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
// Note: Use frame to get the whole screen size
NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
return Size2(nsrect.size.width, nsrect.size.height) * displayScale;
@@ -1583,10 +1571,28 @@ void OS_OSX::_update_window() {
}
}
+float OS_OSX::_display_scale() const {
+ if (window_object) {
+ return _display_scale([window_object screen]);
+ } else {
+ return _display_scale([NSScreen mainScreen]);
+ }
+}
+
+float OS_OSX::_display_scale(id screen) const {
+ if (is_hidpi_allowed()) {
+ if ([screen respondsToSelector:@selector(backingScaleFactor)]) {
+ return fmax(1.0, [screen backingScaleFactor]);
+ }
+ } else {
+ return 1.0;
+ }
+}
+
Point2 OS_OSX::get_window_position() const {
Size2 wp([window_object frame].origin.x, [window_object frame].origin.y);
- wp *= display_scale;
+ wp *= _display_scale();
return wp;
};
@@ -1594,10 +1600,11 @@ void OS_OSX::set_window_position(const Point2 &p_position) {
Size2 scr = get_screen_size();
NSPoint pos;
+ float displayScale = _display_scale();
- pos.x = p_position.x / display_scale;
+ pos.x = p_position.x / displayScale;
// For OS X the y starts at the bottom
- pos.y = (scr.height - p_position.y) / display_scale;
+ pos.y = (scr.height - p_position.y) / displayScale;
[window_object setFrameTopLeftPoint:pos];
@@ -2039,7 +2046,6 @@ OS_OSX::OS_OSX() {
minimized = false;
window_size = Vector2(1024, 600);
zoomed = false;
- display_scale = 1.0;
_set_logger(memnew(OSXTerminalLogger));
}
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index 1553c3c8e6..a7c31cf16c 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -914,6 +914,21 @@ bool PhysicsServerSW::body_test_motion(RID p_body, const Transform &p_from, cons
return body->get_space()->test_body_motion(body, p_from, p_motion, p_margin, r_result);
}
+PhysicsDirectBodyState *PhysicsServerSW::body_get_direct_state(RID p_body) {
+
+ BodySW *body = body_owner.get(p_body);
+ ERR_FAIL_COND_V(!body, NULL);
+
+ if (!doing_sync || body->get_space()->is_locked()) {
+
+ ERR_EXPLAIN("Body state is inaccessible right now, wait for iteration or physics process notification.");
+ ERR_FAIL_V(NULL);
+ }
+
+ direct_state->body = body;
+ return direct_state;
+}
+
/* JOINT API */
RID PhysicsServerSW::joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B) {
diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h
index aea3e150b0..f9eb8fa454 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics/physics_server_sw.h
@@ -223,6 +223,9 @@ public:
virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin = 0.001, MotionResult *r_result = NULL);
+ // this function only works on physics process, errors and returns null otherwise
+ virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body);
+
/* JOINT API */
virtual RID joint_create_pin(RID p_body_A, const Vector3 &p_local_A, RID p_body_B, const Vector3 &p_local_B);
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index 2b7505169a..df3bf72a31 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -954,6 +954,21 @@ bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from,
return body->get_space()->test_body_motion(body, p_from, p_motion, p_margin, r_result);
}
+Physics2DDirectBodyState *Physics2DServerSW::body_get_direct_state(RID p_body) {
+
+ Body2DSW *body = body_owner.get(p_body);
+ ERR_FAIL_COND_V(!body, NULL);
+
+ if ((using_threads && !doing_sync) || body->get_space()->is_locked()) {
+
+ ERR_EXPLAIN("Body state is inaccessible right now, wait for iteration or physics process notification.");
+ ERR_FAIL_V(NULL);
+ }
+
+ direct_state->body = body;
+ return direct_state;
+}
+
/* JOINT API */
void Physics2DServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index 0ebd43be53..c40cf0e3e0 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -222,6 +222,9 @@ public:
virtual bool body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, real_t p_margin = 0.001, MotionResult *r_result = NULL);
+ // this function only works on physics process, errors and returns null otherwise
+ virtual Physics2DDirectBodyState *body_get_direct_state(RID p_body);
+
/* JOINT API */
virtual void joint_set_param(RID p_joint, JointParam p_param, real_t p_value);
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h
index 5bec2f7cbd..50e9ab1005 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.h
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.h
@@ -253,6 +253,13 @@ public:
return physics_2d_server->body_test_motion(p_body, p_from, p_motion, p_margin, r_result);
}
+ // this function only works on physics process, errors and returns null otherwise
+ Physics2DDirectBodyState *body_get_direct_state(RID p_body) {
+
+ ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), NULL);
+ return physics_2d_server->body_get_direct_state(p_body);
+ }
+
/* JOINT API */
FUNC3(joint_set_param, RID, JointParam, real_t);
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp
index b42b85b1be..671c31e6a3 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_2d_server.cpp
@@ -579,6 +579,8 @@ void Physics2DServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("body_test_motion", "body", "from", "motion", "margin", "result"), &Physics2DServer::_body_test_motion, DEFVAL(0.08), DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &Physics2DServer::body_get_direct_state);
+
/* JOINT API */
ClassDB::bind_method(D_METHOD("joint_set_param", "joint", "param", "value"), &Physics2DServer::joint_set_param);
diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h
index 34f885db1d..18f4f460b6 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_2d_server.h
@@ -468,6 +468,9 @@ public:
virtual void body_set_pickable(RID p_body, bool p_pickable) = 0;
+ // this function only works on physics process, errors and returns null otherwise
+ virtual Physics2DDirectBodyState *body_get_direct_state(RID p_body) = 0;
+
struct MotionResult {
Vector2 motion;
diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp
index 0e54867ee1..6d192886a5 100644
--- a/servers/physics_server.cpp
+++ b/servers/physics_server.cpp
@@ -504,6 +504,8 @@ void PhysicsServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("body_set_ray_pickable", "body", "enable"), &PhysicsServer::body_set_ray_pickable);
ClassDB::bind_method(D_METHOD("body_is_ray_pickable", "body"), &PhysicsServer::body_is_ray_pickable);
+ ClassDB::bind_method(D_METHOD("body_get_direct_state", "body"), &PhysicsServer::body_get_direct_state);
+
/* JOINT API */
BIND_ENUM_CONSTANT(JOINT_PIN);
diff --git a/servers/physics_server.h b/servers/physics_server.h
index 7012caeae6..8cec125646 100644
--- a/servers/physics_server.h
+++ b/servers/physics_server.h
@@ -464,6 +464,9 @@ public:
virtual void body_set_ray_pickable(RID p_body, bool p_enable) = 0;
virtual bool body_is_ray_pickable(RID p_body) const = 0;
+ // this function only works on physics process, errors and returns null otherwise
+ virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body) = 0;
+
struct MotionResult {
Vector3 motion;