Commit graph

1115 commits

Author SHA1 Message Date
Marcel Admiraal ea4ee986b5 Normalise p_up_direction vector in move_and_slide() and
move_and_slide_with_snap() and fix tolerance in
move_and_slide_with_snap() max floor angle.
2020-06-16 10:11:54 +01:00
Ranoller 616fb219db
(3.2) Fix bad position in Camera2D offset and camera rotation if smothing enabled
Fix https://github.com/godotengine/godot/issues/16323 in 3.2 branch. Apply same solution of https://github.com/godotengine/godot/issues/2074 in rotation and offset.
2020-06-15 16:34:03 +02:00
Rémi Verschelde 7bf9787921 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.

(cherry picked from commit cd4e46ee65)
2020-06-10 15:30:52 +02:00
Marcel Admiraal dac3504cc3 Fix C4724: potential mod by 0 warnings. 2020-05-21 11:28:01 +01:00
Tomasz Chabora 0200db15cc Fix VisibilityEnabler2D behavior on start
(cherry picked from commit d0c5d91032)
2020-05-11 10:33:38 +02:00
Mateo Kuruk Miccino 1cba7fb180 GUI: Touch screen button click area now is synced with its draw 2020-05-07 11:04:59 -03:00
Juan Linietsky 7f61710183 Implement Skew in Node2D
Skew is x-axis only, because it must be bidirectionally convertible to a 2x3 matrix, but you can subtract it  to the rotation to get the effect on y-axis

(cherry picked from commit efb1f7d76b)
2020-05-04 16:10:22 +02:00
Thomas Riedmair 7e669123f9 Fix performance issue in update_bitmask_region fallback
(cherry picked from commit e0f084b924)
2020-05-04 16:10:22 +02:00
lawnjelly 9af4c09d1b Fix uninitialized memory in CPUParticles2D
Calls to set_amount can increase the size of the particle array, but do not zero the memory, they only set the active flag to false. This uninitialized memory can be sent to the GPU, possibly as NaNs.
2020-05-01 13:49:53 +01:00
MickeMakaron e3ca6d87ad Handle huge offset values in Path2D and Path3D set_offset
(cherry picked from commit 2edb59ec88)
2020-04-16 11:45:40 +02:00
Waridley 219ce2f149 Fix volume interpolation in positional audio nodes
Fixes #22016

(cherry picked from commit ff1fbd2bc5)
2020-04-16 11:43:58 +02:00
Rémi Verschelde acd14e645a Remove unused classes and stray headers
Found by reviewing headers with 1 or less matching includes:
```
find -name thirdparty -prune -o -name "*.h" -exec basename {} \; | sort -u > headers
for header in $(cat headers); do echo "$header: "; rg -l "#include \"(.*/)?$header\"" | wc -l; done > list-includes
```

(cherry picked from commit 9d24541597)
2020-03-25 11:38:54 +01:00
Tomasz Chabora 8fd7efef84 Fix visibility enabler flag toggling
(cherry picked from commit 2ccd1a7805)
2020-03-25 11:38:53 +01:00
Eevee e70e0d24d9 Fix inverted use of Camera2D.offset_v
The code above for horizontal movement uses the right margin (_positive_ x direction) when the offset is negative, but vertical movement uses the top margin (_negative_ y direction) when the offset is negative.

The resulting problem is easily seen in the editor — set the drag margins to be asymmetrical, turn on drawing the drag margins, and slide the offsets from -1 to 1 and back.  The horizontal offset moves the camera's center between the left and right margins, but the vertical offset gets them backwards and will move the camera outside the margins entirely.

(cherry picked from commit 40816574ac)
2020-03-04 09:50:21 +01:00
WARIO-MDMA 707d1a38ec Reduce AudioStreamPlayer's pitch_scale max value
(cherry picked from commit 61d20b1f56)
2020-02-18 14:19:51 +01:00
bitstopper 7cb3a20418 Fixes broken CPUParticles2D AtlasTextures usage
(cherry picked from commit 36d9906d6a)
2020-02-14 16:14:13 +01:00
Haoyu Qiu dc20acd4fc Updates Path2D in debugging if navigation is visible
(cherry picked from commit 00d578ba3e)
2020-02-06 13:02:07 +01:00
Tomasz Chabora 9ad7fc3405 Allow greater values in unit_offset 2020-01-24 14:40:33 +01:00
Rémi Verschelde ba177ccaec doc: Misc updates for AnimationNode* and others
- Add some missing descriptions.
- Add links to tutorials for ARVR and AnimationTree.
- Style fixes.
- Engine changes:
  * Make `AnimationNodeTransition.input_<number>` properties internal
    so that they don't appear in the docs. They still appear in the
    inspector based on the actual number of inputs requested.
  * Drop unimplemented `CPUParticles.flatness`. It's only used for 3D
    particles in `ParticlesMaterial`, and thus only relevant for
    `CPUParticles3D`.
2020-01-23 12:37:33 +01:00
Rémi Verschelde 4faaf6089a Remove unused #if 0'ed code 2020-01-21 21:41:54 +01:00
Rémi Verschelde 1de633205f Validate input in (CPU)Particles set_emission_shape()
Fixes #29777.

Co-authored-by: Cameron Reikes <cameronreikes@gmail.com>
2020-01-16 11:08:51 +01:00
Marcel Admiraal 907adb37ce Fixes get_floor_normal() returning the user defined floor_normal.
When there is no collision with a floor the get_floor_normal() function
should return the zero vector to be consistent with get_floor_velocity().

Renames floor_normal to up_direction in all bindings.

Updates the documentation of get_floor_normal() and get_floor_velocity()
to make it clear when the values are valid. Updates the documentation for
move_and_slide() and move_and_slide_with_snap() to use the new up_direction
parameter name.
2020-01-15 10:13:35 +01:00
Rémi Verschelde 100f50b7df Control/Light2D: Preventing setting 0 as scale as for Node2D
Triggers errors in `Transform2D::affine_invert()`.

Fixes #26510.
Fixes https://github.com/godotengine/godot/issues/24997#issuecomment-457951639.
2020-01-13 12:20:15 +01:00
Andrea Catania 9f1f4620e0 Added function to expose floor normal, useful to correctly calculate player velocity.
This work has been kindly sponsored by IMVU.
2020-01-10 14:58:19 +01:00
Gilles Roudière b5251eb00f Don't compile editor-only function when tools=no 2020-01-09 22:15:48 +01:00
Rémi Verschelde fa82664419
Merge pull request #34726 from nekomatata/polygon2d-antialiasing-fix
Fixed antialiasing option for Polygon2D with concave/hollow shapes
2020-01-03 14:17:05 +01:00
Александр Растриженков d8dbcbe066 Fix wrong disconnect in callback in VisibilityNotifier 3D 2020-01-02 15:09:26 +01:00
PouleyKetchoupp 1591677eb8 Fixed antialiasing option for Polygon2D
Some cases were not handled properly for Polygon2D after making changes in common code to fix Line2D antialiasing. Added an option for drawing polygons to differentiate the two use cases.

Fixes #34568
2020-01-01 11:40:14 +01:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Hugo Locurcio 0a5b30b14a
Add a range property hint for the number of contacts reported
This closes #34505.
2019-12-21 22:27:10 +01:00
Tyler Greenwood e4a0abdd93 Fixed a bug within sprite.cpp that caused nan values to appear when a texture had zero area 2019-12-16 13:53:35 +01:00
Rémi Verschelde 2845e6a21a
Merge pull request #34040 from qarmin/unused_variable_more_precise_numbers
Removed unused variables, add some constants numbers
2019-12-10 08:25:31 +01:00
Rafał Mikrut ed1c4bc77d Removed unused variables, add some constants numbers 2019-12-10 05:13:02 +01:00
Rémi Verschelde 10bae7c05b
Merge pull request #33857 from nekomatata/polygon-2d-antialiasing
Fixed antialiased option for Polygon2D
2019-12-03 07:51:16 +01:00
Marcel Admiraal 750f343e4a Ensure move_and_slide() is consistent between the 2D and 3D versions.
In the 3D version:
- Partially revert #20908 that was reverted in the 2D version as part
  of #21653. This ensures that the Vector returned is always perpendicular
  to the surface collided with; and not the floor_normal Vector passed to
  the function when on a floor.
- Include an update of the floor velocity before multiplying by the time
  delta, which was added to the 2D version as part of commit 13a8014.

In the 2D version:
- Use the Vector2.slide() function instead of Vector2.tangent() to adjust
  the amount of motion the stop_on_slope undoes to ensure that it is in the
  right direction. This is a implementation of the 3D approach from #30588.
- Combine the !found_collision and motion == Vector2() checks for break.
- Other minor formating changes to make the functions look identical.

Also renamed some variables to align with their use.
2019-12-02 08:35:50 +01:00
Tomasz Chabora 7e6fa6c7a8 Remove unnecessary bounded_offset from PathFollow2D 2019-11-30 03:16:33 +01:00
PouleyKetchoupp e6ebc43d72 Fixed antialiased option for Polygon2D / Line2D
Polygon2D:
The property wasn't used anymore after switching from canvas_item_add_polygon() to canvas_item_add_triangle_array() for drawing.

Line2D:
Added the same property as for Polygon2D & fixed smooth line drawing to use indices correctly.

Fixes #26823
2019-11-28 22:57:27 +01:00
Rémi Verschelde 5ef5e6a7e4
Merge pull request #32274 from raphael10241024/fix_sync_physics_jitter
fix kinematicBody2D jitters when sync_to_physics is turned on
2019-11-21 08:53:24 +01:00
Rafał Mikrut 99d8626f4a Fix some overflows and unitialized variables 2019-11-20 16:22:16 +01:00
Rémi Verschelde 3c0c8f26f9 Revert "Fixed TouchScreenButton::shape_centered having no effect"
This reverts commit 127c2d75ad.

This was a misunderstanding as #32725 is not a bug but expected
behavior.

Reverts #32927.
Supersedes and closes #33436.
2019-11-08 10:54:36 +01:00
Rémi Verschelde 77816fea8b
Merge pull request #32477 from aaronfranke/equal-approx-separate
Make is_equal_approx separate and make == exact again
2019-11-07 14:54:15 +01:00
Rémi Verschelde 9e1be8f8aa
Merge pull request #32934 from ajweeks/fix-scale-origin
Fix 2D scale gizmo placement
2019-10-30 12:04:10 +01:00
Mikolaj Kaczmarek a245bab78d Fixed disconnecting not connected signal 2019-10-29 00:53:48 +01:00
Rémi Verschelde 2416fbb4e2
Merge pull request #31943 from codecustard/Fixes_invalid_frames_on_reverse_anim
Fixes Reverse Animation Starting on First Frame
2019-10-27 09:55:44 +01:00
Rémi Verschelde 3eb8bd08ec
Merge pull request #32657 from ptrojahn/lines
Fix draw_rect
2019-10-26 23:09:24 +02:00
PouleyKetchoupp 1e0f37a70f Fixed emitting not initialized correctly in cpu particles 2d/3d
Fixes uninitialized variable caused by PR #32921
2019-10-24 21:38:01 +02:00
Rémi Verschelde 19fa163d9a
Merge pull request #32992 from KoBeWi/AUTOVECTORZ
Auto-increment frame_coords when keying
2019-10-23 07:42:52 +02:00
Rémi Verschelde 72dfa67dd3
Merge pull request #32924 from ajweeks/add-ruler-arcs
Draw arcs to indicate angles being measured by ruler
2019-10-22 22:44:50 +02:00
Tomasz Chabora 6c0ef9f729 Auto-increment frame_coords when keying 2019-10-22 20:12:55 +02:00
AJ Weeks fb7a4ce63e Fix canvas scale gizmo placement 2019-10-22 18:17:54 +01:00
Rémi Verschelde 4ecc30cc5e
Merge pull request #32927 from Muller-Castro/ShapeCenteredFix
Fixed TouchScreenButton::shape_centered having no effect
2019-10-22 15:53:29 +02:00
Rémi Verschelde 17a7da3b85
Merge pull request #32921 from nekomatata/fix-cpu-particle-delay
Fixed delay when CPUParticles & CPUParticles2D start being emitted
2019-10-22 14:28:04 +02:00
Rémi Verschelde bd23cce055
Merge pull request #32896 from nekomatata/joint-reset-collision
Properly reset collision exception when releasing Joint2D
2019-10-22 12:52:12 +02:00
PouleyKetchoupp 5bf516a062 Fixed delay when CPUParticles & CPUParticles2D start being emitted
Particles were processed only on the next frame after the emission started, causing a one frame delay in rendering. Now the first process cycle is started during the same frame, which makes them consistent with Particles & Particles2D.

Fixes #32890
2019-10-20 09:50:00 +02:00
Muller-Castro 127c2d75ad Fixed TouchScreenButton::shape_centered having no effect
The problem was that the shape_centered depended on TouchScreenButton::texture having a Texture
2019-10-19 18:16:47 -03:00
AJ Weeks 59d2c71227 Add arcs to indicate angle being measured by ruler 2019-10-19 19:45:56 +01:00
PouleyKetchoupp 0de76cc647 Properly reset collision exception when releasing Joint2D
Now using joint_disable_collisions_between_bodies() to reset the exception, because body_remove_collision_exception() was doing only a part of the work.

Fixes #32733
2019-10-17 19:22:59 +02:00
Emmanuel Barroga 94a00cd9c7 Fixes Reverse Animation Starting on First Frame
When playing an animation in reverse, the animation initially starts on frame 0. If it loops, it'll play normally by going to the last frame of the animation, but if it does not... it prematurely stops, since it is already on the last frame (for reversed animation) by starting on frame 0.
2019-10-16 04:26:26 -07:00
Marcel Admiraal f34deabd10 Correct change made to joints_2d.cpp by 072e403. 2019-10-15 17:55:35 +02:00
Aaron Franke aeb7075628
Replace vector == and is_zero_approx(distance) with is_equal_approx
Internal changes only
2019-10-14 16:47:42 -04:00
Gilles Roudiere b27ec4aea7 Fixes Sprite frame_coords 2019-10-13 08:44:44 +02:00
Paul Trojahn bdaedb601c Fix draw_rect
OpenGL uses the diamond exit rule to rasterize lines. If we don't shift
the points down and to the right by 0.5, the line can sometimes miss a
pixel when it shouldn't. The final fragment of a line isn't drawn. By
drawing the lines clockwise, we can avoid a missing pixel in the rectangle.
See section 3.4.1 in the OpenGL 1.5 specification.
Fixes #32279
2019-10-11 10:26:53 +02:00
qarmin bb685147f9 Fix crash in TileMap::update_cell_bitmask 2019-10-08 15:46:38 +02:00
Rémi Verschelde f84bf7e8a8
Merge pull request #32351 from nekomatata/texture-rect-size-update
Update TextureRect when its Texture is modified directly
2019-10-07 08:57:17 +02:00
PouleyKetchoupp c7834ee566 Update TextureRect and Sprite when their Texture is modified directly.
Modified Sprite to use "changed" signal instead of _changed_callback to make it work when tool is disabled (change receptors are editor only).

Fixes #32349
2019-10-05 17:32:46 +02:00
qarmin f435a6f0b6 Fix crash in TileMap::fix_invalid_tiles 2019-10-05 11:37:38 +02:00
Rémi Verschelde 9327eb226a
Revert "Fixes CPUParticles2D not making use of AtlasTextures" 2019-10-02 09:44:06 +02:00
Rémi Verschelde 09bf1b35c0
Merge pull request #32459 from bitstopper/master
Fixes CPUParticles2D not making use of AtlasTextures
2019-10-02 08:48:19 +02:00
bitstopper 9f21fcf879 Fixes CPUParticles2D not making use of AtlasTextures
Fixes CPUParticles2D not making use of AtlasTextures #2
2019-10-01 14:04:37 +02:00
Soumya Lahiri a1b2364dba Altered rotation_degrees range 2019-09-30 20:43:57 +05:30
bob 943471dd02 Fix TileMap world_to_map rounding issue for negative integers
The previous code would fail for negative integer values like -3.0
(would return -4 instead of -3).

Fixes #31468.
2019-09-26 08:47:24 +02:00
Rémi Verschelde 076dc9803a
Merge pull request #32119 from Calinou/unify-axis-colors
Use the same axis colors consistently in the 2D and 3D editors
2019-09-25 13:03:47 +02:00
Rémi Verschelde dec10dd776
Merge pull request #32051 from qarmin/some_error_explanation
Added some obvious errors explanations
2019-09-25 11:51:54 +02:00
qarmin 17732fe698 Added some obvious errors explanations 2019-09-25 10:28:50 +02:00
Rémi Verschelde 0c3335d1f3
Merge pull request #32309 from clayjohn/particles_tex_scale
Fix particles scale randomization
2019-09-24 18:05:44 +02:00
clayjohn bc94203add fix particles scale randomization 2019-09-24 08:03:53 -07:00
RaphaelHunter 101f1b802b fix kinematicBody2D jitters when sync_to_physics is turned on, closes #28181 2019-09-23 20:01:01 +08:00
qarmin 50be65bf43 Changed some code found by Clang Tidy and Coverity 2019-09-22 18:45:08 +02:00
luz.paz 91ecd7b6a6 Fix misc. source comment typos
Found using `codespell -q 3 -S ./thirdparty,*.po -L ang,ba,cas,dof,doubleclick,fave,hist,leapyear,lod,nd,numer,ois,paket,seeked,sinc,switchs,te,uint -D ~/Projects/codespell/codespell_lib/data/dictionary.txt `
2019-09-19 14:36:52 -04:00
Hugo Locurcio c2bcc3f700
Use the same axis colors consistently in the 2D and 3D editors 2019-09-13 14:08:41 +02:00
Rémi Verschelde 720065c721
Merge pull request #31476 from SoulForMachine/fix-move-and-slide-error
Prevent move_and_slide() to generate an error.
2019-09-03 12:51:42 +02:00
Rémi Verschelde 7e731bbce2
Merge pull request #31878 from aole/Initialize-TileMap-Custom-Transform
Initialize TileMap Custom Transform
2019-09-02 10:35:56 +02:00
Bhupendra Aole 0b5a600564 Initialize TileMap Custom Transform
Initialize TileMap Custom Transform to same as Cell Size (64).
Fixes #30948.
2019-09-01 19:33:45 -04:00
Hugo Locurcio 8c8dc6f026
Call some CanvasItem property setters only if needed
The CanvasItem property setters `set_modulate`, `set_self_modulate`
and `set_light_mask` have some side effects that don't need to be run
if the value hasn't changed.

This closes #31777.
2019-08-31 21:53:02 +02:00
Michael Alexsander Silva Dias c902066bb5 Remove some unneeded checks in CollisionObject(2D) 2019-08-30 14:22:46 -03:00
Milan Davidovic c12ce2b4dd Prevent move_and_slide() to generate an error.
When moving KinematicBody2D from one scene to another and not freeing
the old scene, the first call to move_and_slide() in the new scene will
generate an error because KinematicBody2D keeps internaly a
RID on_floor_body of a body resource in the old scene which no more has
a space assigned.

To fix this, on_floor_body is set to empty RID in response to
NOTIFICATION_ENTER_TREE notification of KinematicBody2D and
KinematicBody. Also all other data related to move_and_slide() is reset:
floor, ceiling, wall flags, colliders vector, floor_velocity.

This fixes #31416.
2019-08-26 15:10:15 +02:00
Rémi Verschelde bfed4b6a97
Merge pull request #31014 from DavidSichma/kinematic_angle
Fix floor_max_angle comparison for impossible angles
2019-08-23 09:10:38 +02:00
RaphaelHunter 74713fe970 Fix custom inertia in physics2d, closes#30838 2019-08-22 20:30:03 +08:00
Rémi Verschelde a8db4c848d
Merge pull request #31395 from ptrojahn/floatsarenasty
Replace is_zero_approx(A.distance_to(B)) with A==B
2019-08-20 12:54:40 +02:00
Paul Trojahn 7c9c6df7e4 Replace is_zero_approx(A.distance_to(B)) with A==B
Related to #22988 (Fixes the holes in the shape of
the first comment)
2019-08-19 18:16:58 +02:00
Hugo Locurcio 558e93f069
Improve the appearance of 2D path editors
- Add new handle icons for path/polygon editors
- Add smooth path point icons and curve tangent icons
- Use a gray color for tangent lines in the Path2D and Path editors
- Use antialiasing for Path2D lines
2019-08-18 22:27:01 +02:00
Rémi Verschelde 5f44ee30ec
Merge pull request #31360 from nekomatata/fix-error-parallax-mirroring
Fixed error in ParallaxLayer when set_mirroring is called before entering the tree
2019-08-14 13:48:22 +02:00
PouleyKetchoupp 927a7916f6 Fixed error in ParallaxLayer when set_mirroring is called before entering the tree
Fixes #31300
2019-08-14 13:21:22 +02:00
IAmActuallyCthulhu 82b9557803
Remove redundant author doc comments 2019-08-12 04:26:38 -05:00
Tomasz Chabora af5e0fff66 Remove ERR_EXPLAIN from scene/* code 2019-08-09 13:54:52 +02:00
Rémi Verschelde 5becb2e322
Merge pull request #31194 from bojidar-bg/29312-corrupt-initial-tilemap
Fix corrupted TileMap saves due to missing/wrong format
2019-08-08 11:20:06 +02:00
Bojidar Marinov 141ee27dad
Fix corrupted TileMap saves due to missing/wrong format
Fixes #29312
2019-08-08 09:30:55 +03:00
Rémi Verschelde ba541bceca
Merge pull request #31077 from qarmin/coverity_bugs
Change some code proposed by Coverity and Cppcheck
2019-08-07 13:49:33 +02:00
qarmin e0b5b21863 Add some code changes/fixes proposed by Coverity and Clang Tidy 2019-08-07 12:54:30 +02:00
Tomasz Chabora 459f5cb75e Tweaks related to Camera2D drag margins 2019-08-06 16:19:02 +02:00