Commit graph

1148 commits

Author SHA1 Message Date
Raul Santos 102ec1042b Fix Path3D initial forward calculation 2021-08-07 12:40:14 +02:00
lawnjelly 770d9f8220 Portals - add gizmo handles for editing portals and rooms
Gizmo handles are added for much more user friendly editing of portals and room bounds.
2021-08-06 07:53:22 +01:00
Rémi Verschelde 28b5f07355
Merge pull request #51277 from lawnjelly/portals_debug_collision_shapes 2021-08-05 16:39:03 +02:00
lawnjelly 258831c12e Portals - fix showing debug collision shapes
Set the portal_mode to GLOBAL on creation.
2021-08-05 13:28:11 +01:00
lawnjelly f4c5092027 Portals - rooms_set_active needs Editor check
Calling rooms_set_active with TOOLS_ENABLED from a running project resulted in a crash because the Spatial Editor is not available. Wrapped it in an is_editor_hint.
2021-08-05 13:14:00 +01:00
Raul Santos d46d66020e
Fix forward calculation in PathFollow3D for the position at the end of the curve
(cherry picked from commit e23f6a5bba)
2021-08-03 10:18:04 +02:00
Rémi Verschelde 73c6ab0215
Merge pull request #51152 from lawnjelly/portals_improve_ui 2021-08-02 14:40:18 +02:00
lawnjelly 2eae35693e Portals - change import naming convention to postfix
In response to user demand, the naming convention for importing levels from blender etc is changed from prefixes `Room_` and `Portal_` to postfixes `-room`, `-roomgroup`, `-portal`.
2021-08-02 11:04:02 +01:00
lawnjelly 8c4c6a93b0 Portals - Remove node naming restrictions
The use of special prefixes is only actually required during the import phase - the first conversion of rooms, roomgroups, and portals from Spatials and MeshInstances (based on the workflow of importing from blender).

Once converted to the native Godot nodes there is no longer a need for the naming requirements.

This PR removes the requirements except for the import. Manual portal linking after the initial conversion is now done exclusively using the `linked_room` nodepath property of the Portal.
2021-08-01 20:04:58 +01:00
lawnjelly 776623d56b Portals - Improve UI and add shortcuts
This PR makes the 'convert rooms' button permanently on the toolbar and accessible whichever node is selected, so you can convert rooms without having to select the RoomManager first.

It also adds a togglable item 'view portal culling' to the 'View' menu which is a simple way of setting the RoomManager 'active' setting without the RoomManager being the selected node.

Both of these have keyboard shortcuts, which should make it much faster to reconvert rooms and edit.

In addition there the string in the 'Perspective' Listbox is modified to show [portals active] when portal culling is operational, for visual feedback. This is updated when you change modes, and when the rooms are invalidated.
2021-08-01 19:54:16 +01:00
Marcel Admiraal e2d0dfe3c7 Ensure node's area tree signals are disconnected when clearing monitoring,
even if nodes are no longer in the tree.
2021-07-31 07:14:03 +01:00
Rémi Verschelde 9735f2803c
Merge pull request #46800 from The-O-King/normal_compression
[3.x] Implement Octahedral Map Normal/Tangent Attribute Compression
2021-07-30 17:34:47 +02:00
Omar El Sheikh d274284069 Octahedral Normal/Tangent Compression
Implement Octahedral Compression for normal/tangent vectors
*Oct32 for uncompressed vectors
*Oct16 for compressed vectors

Reduces vertex size for each attribute by
*Uncompressed: 12 bytes, vec4<float32> -> vec2<unorm16>
*Compressed: 2 bytes, vec4<unorm8> -> vec2<unorm8>

Binormal sign is encoded in the y coordinate of the encoded tangent

Added conversion functions to go from octahedral mapping to cartesian
for normal and tangent vectors

sprite_3d and soft_body meshes write to their vertex buffer memory
directly and need to convert their normals and tangents to the new oct
format before writing

Created a new mesh flag to specify whether a mesh is using octahedral
compression or not
Updated documentation to discuss new flag/defaults

Created shader flags to specify whether octahedral or cartesian vectors
are being used

Updated importers to use octahedral representation as the default format
for importing meshes

Updated ShaderGLES2 to support 64 bit version codes as we hit the limit
of the 32-bit integer that was previously used as a bitset to store
enabled/disabled flags
2021-07-30 10:29:09 -04:00
lawnjelly d578ea99b9 Portals - fix gizmo margin scaling
If the user changed the portal Z scale in the editor the portal margin display could become incorrectly sized.

This is because the portal margin is measured in world space units, and has to be back calculated into model space using the inverse global transform of the portal node. The model space size of the margin is thus tied to the current scale of the node.

This PR forces updating the gizmo each time the transform is changed. This isn't super efficient, but as this is an editor only feature it should be okay, and it is unlikely to be a performance problem.
2021-07-29 18:58:19 +01:00
Rémi Verschelde 7a35eec705
Merge pull request #50979 from lawnjelly/portals_autoplace_priority_setting 2021-07-29 15:46:01 +02:00
lawnjelly e06cd3042f Portals - Fix CSG updates on room conversion
Due to a quirk in CSG Shapes, updating is usually deferred to the next frame. This is problematic as we need to read back the geometry on the first frame when converting levels.

This PR adds a function to CSGShape to force immediate updating (if dirty), and calls it during room conversion.
2021-07-29 12:41:23 +01:00
lawnjelly d0ba355520 Portals - add autoplace priority setting to CullInstance
The default autoplace algorithm places instances in the highest priority Room. It became apparent that there are some situations in which users will want to override this and force placement in a Room from a particular RoomGroup, especially an "outside" RoomGroup.

This setting allows the user to specify a preference for Room priority. When set to 0, the setting is ignored and the highest priority Room is chosen.
2021-07-28 17:23:20 +01:00
lawnjelly d7d7abf057 Portals - fix autolink portals to detect internal
Although explicit portals did a check to detect internal portals, this check was missing from autolinked portals. This meant they were incorrectly clipping the room bounds of the enclosing outer room.

This PR adds a check for internal rooms during the autolinking and sets the internal flag where needed.
2021-07-28 15:54:45 +01:00
Rémi Verschelde 717ba8f9d8
Merge pull request #50932 from lawnjelly/portals_fix_margin_loading
Portals - Fix default portal margin loading
2021-07-27 13:09:01 +02:00
lawnjelly d012a26e6a Portals - Fix default portal margin loading
The default portal margin is stored in the RoomManager. Previously this was propagated to Portals when the value was changed, and Portals each stored this default value.

This caused a bug during loading, if the RoomManager was loaded before Portals, the value was never propagated.

This PR makes the default margin a static value stored in the RoomManager, and the Portals now read directly from the static value when required, and do not store locally. This gets around the problem.
2021-07-27 11:48:34 +01:00
Haoyu Qiu eb31a39e82
Add check to internal methods to prevent crash
(cherry picked from commit 448295cd51)
2021-07-27 12:17:14 +02:00
Hugo Locurcio 974d3aa9cd
Add a property to control the bounce indirect energy in BakedLightmap
Higher values will make indirect lighting brighter.
A value of 1.0 represents physically accurate behavior, but higher values
can be used to make indirect lighting propagate more visibly when using
a low number of bounces.

This can be used to speed up bake times by lowering the number of bounces
then increasing the bounce indirect energy. Unlike BakedLightmapData's
energy property, this property does not affect direct lighting
emitted by light nodes or emissive materials.
2021-07-25 03:04:40 +02:00
lawnjelly 5e59f7ce3a Portals - Config warning for Rooms with too many planes
Just a small addition, a config warning if the user creates a Room with a large number of bounding planes, letting them know to simplify it.
2021-07-23 10:19:09 +01:00
lawnjelly c2dd51a85e Portals - fix adding statics twice
Due to an oversight in the autoplace recursive search for static objects, static objects were getting added twice to the portal renderer, which meant they were being rendered twice, lowering performance.

This PR corrects this horrendous error.
2021-07-22 20:23:57 +01:00
lawnjelly 83f1377a8f Portals - lift roomlist restrictions and fix link bug
Allows users to have the RoomManager as the roomlist.

Fixes a couple of bugs dealing with situations where users attempt to link Portals to Rooms outside the roomlist.

Adds a PortalEditorPlugin allowing you to flip individual portals.
2021-07-20 19:05:16 +01:00
lawnjelly 06d66488c2 Portals - Add the ability to autoplace static objects
In order to make level building easier, the system can now support STATIC and DYNAMIC objects in the roomlist that are not placed in rooms. The system will automatically place them in the appropriate room.
2021-07-20 13:24:30 +01:00
Rémi Verschelde 2ee38416a4
Merge pull request #50507 from Calinou/light-tweak-property-hints
Tweak Light property hints for greater flexibility
2021-07-20 11:13:16 +02:00
PouleyKetchoupp beeebb4c2f More accurate unsafe motion calculation
* Safe and unsafe motion are calculated by dichotomy with a limited
number of steps. It's good for performance, but on long motions that
either collide near the beginning or near the end, the result can be
very imprecise.
* Now a factor 0.25 or 0.75 is used to converge faster when this case
happens, which allows longer motions to get more accurate collision
detection.
* Makes snap collision more precise, and helps with cases where diagonal collision on the border of a platform can lead to the character being stuck.

Additional improvements to move_and_slide:
* Handle slide canceling in move_and_collide with 0 velocity instead of
not applying it.
* Better handling of snap with custom logic to cancel sliding.
* Remove small jittering when using stop on slope, by canceling the
motion completely when the resulting motion is less than margin instead
of always projecting to the up direction (in both body motion and snap).

Co-authored-by: fabriceci <fabricecipolla@gmail.com>
2021-07-19 08:09:17 -07:00
PouleyKetchoupp 2fbb6fff4e Fix move_and_collide causing sliding on slopes
Make sure the direction of the motion is preserved, unless the depth is
higher than the margin, which means the body needs depenetration in any
direction.

Also changed move_and_slide to avoid sliding on the first motion, in
order to avoid issues with unstable position on ground when jumping.

Co-authored-by: fabriceci <fabricecipolla@gmail.com>
2021-07-19 08:09:16 -07:00
Rémi Verschelde 4d3c11e85e
Merge pull request #49446 from nekomatata/sync-to-physics-3d-3.x
[3.x] Support for 3D sync to physics
2021-07-16 07:15:17 +02:00
Hugo Locurcio 0fe771dfe5
Tweak Light property hints for greater flexibility
- Specular can now be set above 1.0.
- Some properties now allow more precise values.
- The Bake Mode property hint was changed to be more descriptive.
- The maximum shadow bias values were adjusted to follow the property
  hints in `master`.
2021-07-16 04:12:10 +02:00
lawnjelly 44f9a0f961 Portals - fix autolink sprawling, refine logs
It turned out the new autolinking feature was linking portals AFTER the static meshes had been added to rooms in the PortalRenderer. This meant that large meshes weren't being sprawled across these portals. The fix involves doing the autolinking BEFORE adding the static meshes.

Fixes a bug in the warning for portals being in the wrong direction, they should have only been checkout for outgoing portals. This was resulting in erroneous warnings.

Also the room conversion logs are refined to be more compact and informative.

A warning icon is also added in the gizmo for portals where autolink fails.
2021-07-15 13:04:05 +01:00
Rémi Verschelde bc40546406
Merge pull request #50457 from lawnjelly/portals_config_warn 2021-07-15 12:30:33 +02:00
Hendrik Brucker fe616d443a
Fix color properties of particle nodes/material
(cherry picked from commit 3a4a2198ed)
2021-07-15 10:25:35 +02:00
lawnjelly b663acef93 Portals - Add configuration warnings for nodes
Checks for invalid children / grandchildren etc.
2021-07-15 08:01:42 +01:00
Rémi Verschelde 041115ca41
RoomManager: Fix build with CSG module disabled
Fixes #50462.
2021-07-15 08:51:15 +02:00
Rémi Verschelde a3310c1da2
Merge pull request #46130 from lawnjelly/portals
Portal occlusion culling [3.4]
2021-07-14 13:38:01 +02:00
lawnjelly eb6f98ec55 Portal occlusion culling
Adds support for occlusion culling via rooms and portals.
2021-07-14 11:43:23 +01:00
Rémi Verschelde aa3a5c9f6a
Merge pull request #50184 from JFonS/cpu_lightmapper_soft_shadows
[3.x] Add soft shadows to the CPU lightmapper
2021-07-14 12:18:08 +02:00
PouleyKetchoupp 240c33708c Options to clean/simplify convex hull generated from mesh
Clean: remove duplicate and interior vertices (uses Bullet algorithm)
Simplify: modify the geometry for further simplification (uses VHACD
algorithm)

In the editor, single convex hull now uses the clean option.
Added a new editor entry to create a simplified convex hull, can be
useful for creating convex hull from highly tessellated triangle meshes.

Specific change for 3.x:
Add support for Vector<Vector3> and PoolVector<Vector3> in the convex hull generator.
2021-07-09 17:45:59 -07:00
JFonS a2ba7910ba Add soft shadows to the CPU lightmapper
Adds the "light_size" property to Lights. It's only considered in baked
lightmaps for soft shadowing purposes.
2021-07-05 19:02:35 +02:00
Rémi Verschelde ef3c346df2
Merge pull request #49835 from nekomatata/soft-body-disable-physics-3.x
[3.x] Support for disabling physics on SoftBody
2021-07-01 10:01:33 +02:00
Rafał Mikrut cb5faca39a
Prevent setting too big or too small Collision Mask and Layer 2021-06-27 17:40:07 +02:00
PouleyKetchoupp 4694b2b3e4 Support for disabling physics on SoftBody
New property physics_enabled, can be useful for optimization purpose.
2021-06-22 11:38:17 -07:00
Hugo Locurcio 3143f5fcc5
Use double-sided material for RayCast
This makes RayCasts visible if the camera is fully inside one
(e.g. a RayCast parented to the current Camera).
2021-06-19 09:16:42 +02:00
Hugo Locurcio a6a6ad5c08
Add custom debug shape thickness and color options to RayCast
This backports the improved RayCast debug drawing functionality
from the `master` branch.

`ArrayMesh.clear_surfaces()` was also backported from the `master`
branch and exposed because the new debug drawing code requires it.
2021-06-19 06:01:25 +02:00
Marcel Admiraal 7e03bd1671 Remove duplicate WARN_PRINTS macro 2021-06-18 12:57:59 +01:00
Rémi Verschelde fc95c4d84c
Merge pull request #49476 from nekomatata/kinematic-collision-rid-3.x
[3.x] Expose collider RID in 2D/3D kinematic collision
2021-06-18 12:32:42 +02:00
Marcel Admiraal 5a58516231 Remove duplicate ERR_PRINTS macro 2021-06-16 11:56:25 +01:00
PouleyKetchoupp a146e79758 Expose collider RID in 2D/3D kinematic collision
Can be useful to access the colliding body information for bodies
created with the physics server directly.
2021-06-09 18:26:16 -07:00