feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -6,4 +6,9 @@ Import("env")
env.add_source_files(env.scene_sources, "*.cpp")
# Chain load SCsubs
SConscript("physics/SCsub")
if not env["disable_physics_3d"]:
SConscript("physics/SCsub")
if not env["disable_navigation_3d"]:
SConscript("navigation/SCsub")
if not env["disable_xr"]:
SConscript("xr/SCsub")

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_LISTENER_3D_H
#define AUDIO_LISTENER_3D_H
#pragma once
#include "scene/3d/node_3d.h"
@ -66,5 +65,3 @@ public:
AudioListener3D();
~AudioListener3D();
};
#endif // AUDIO_LISTENER_3D_H

View file

@ -34,12 +34,15 @@
#include "core/config/project_settings.h"
#include "scene/3d/audio_listener_3d.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/physics/area_3d.h"
#include "scene/3d/velocity_tracker_3d.h"
#include "scene/audio/audio_stream_player_internal.h"
#include "scene/main/viewport.h"
#include "servers/audio/audio_stream.h"
#ifndef PHYSICS_3D_DISABLED
#include "scene/3d/physics/area_3d.h"
#endif // PHYSICS_3D_DISABLED
// Based on "A Novel Multichannel Panning Method for Standard and Arbitrary Loudspeaker Configurations" by Ramy Sadek and Chris Kyriakakis (2004)
// Speaker-Placement Correction Amplitude Panning (SPCAP)
class Spcap {
@ -60,6 +63,8 @@ public:
w[speaker_num].direction = speaker_directions[speaker_num];
w[speaker_num].squared_gain = 0.0;
w[speaker_num].effective_number_of_speakers = 0.0;
}
for (unsigned int speaker_num = 0; speaker_num < speaker_count; speaker_num++) {
for (unsigned int other_speaker_num = 0; other_speaker_num < speaker_count; other_speaker_num++) {
w[speaker_num].effective_number_of_speakers += 0.5 * (1.0 + w[speaker_num].direction.dot(w[other_speaker_num].direction));
}
@ -141,6 +146,19 @@ void AudioStreamPlayer3D::_calc_output_vol(const Vector3 &source_dir, real_t tig
}
}
// Set the volume to cosine of half horizontal the angle from the source to the left/right speaker direction ignoring elevation.
// Then scale `cosx` so that greatest ratio of the speaker volumes is `1-panning_strength`.
// See https://github.com/godotengine/godot/issues/103989 for evidence that this is the most standard implementation.
AudioFrame AudioStreamPlayer3D::_calc_output_vol_stereo(const Vector3 &source_dir, real_t panning_strength) {
double flatrad = sqrt(source_dir.x * source_dir.x + source_dir.z * source_dir.z);
double g = CLAMP((1.0 - panning_strength) * (1.0 - panning_strength), 0.0, 1.0);
double f = (1.0 - g) / (1.0 + g);
double cosx = CLAMP(source_dir.x / (flatrad == 0.0 ? 1.0 : flatrad), -1.0, 1.0);
double fcosx = cosx * f;
return AudioFrame(sqrt((-fcosx + 1.0) / 2.0), sqrt((fcosx + 1.0) / 2.0));
}
#ifndef PHYSICS_3D_DISABLED
void AudioStreamPlayer3D::_calc_reverb_vol(Area3D *area, Vector3 listener_area_pos, Vector<AudioFrame> direct_path_vol, Vector<AudioFrame> &reverb_vol) {
reverb_vol.resize(4);
reverb_vol.write[0] = AudioFrame(0, 0);
@ -209,6 +227,7 @@ void AudioStreamPlayer3D::_calc_reverb_vol(Area3D *area, Vector3 listener_area_p
}
}
}
#endif // PHYSICS_3D_DISABLED
float AudioStreamPlayer3D::_get_attenuation_db(float p_distance) const {
float att = 0;
@ -283,6 +302,7 @@ void AudioStreamPlayer3D::_notification(int p_what) {
}
}
#ifndef PHYSICS_3D_DISABLED
// Interacts with PhysicsServer3D, so can only be called during _physics_process
Area3D *AudioStreamPlayer3D::_get_overriding_area() {
//check if any area is diverting sound into a bus
@ -321,13 +341,16 @@ Area3D *AudioStreamPlayer3D::_get_overriding_area() {
}
return nullptr;
}
#endif // PHYSICS_3D_DISABLED
// Interacts with PhysicsServer3D, so can only be called during _physics_process.
StringName AudioStreamPlayer3D::_get_actual_bus() {
#ifndef PHYSICS_3D_DISABLED
Area3D *overriding_area = _get_overriding_area();
if (overriding_area && overriding_area->is_overriding_audio_bus() && !overriding_area->is_using_reverb_bus()) {
return overriding_area->get_audio_bus_name();
}
#endif // PHYSICS_3D_DISABLED
return internal->bus;
}
@ -358,7 +381,9 @@ Vector<AudioFrame> AudioStreamPlayer3D::_update_panning() {
HashSet<Camera3D *> cameras = world_3d->get_cameras();
cameras.insert(get_viewport()->get_camera_3d());
#ifndef PHYSICS_3D_DISABLED
PhysicsDirectSpaceState3D *space_state = PhysicsServer3D::get_singleton()->space_get_direct_state(world_3d->get_space());
#endif // PHYSICS_3D_DISABLED
for (Camera3D *camera : cameras) {
if (!camera) {
@ -388,19 +413,22 @@ Vector<AudioFrame> AudioStreamPlayer3D::_update_panning() {
Vector3 area_sound_pos;
Vector3 listener_area_pos;
#ifndef PHYSICS_3D_DISABLED
Area3D *area = _get_overriding_area();
if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) {
area_sound_pos = space_state->get_closest_point_to_object_volume(area->get_rid(), listener_node->get_global_transform().origin);
listener_area_pos = listener_node->get_global_transform().affine_inverse().xform(area_sound_pos);
}
#endif // PHYSICS_3D_DISABLED
if (max_distance > 0) {
float total_max = max_distance;
#ifndef PHYSICS_3D_DISABLED
if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) {
total_max = MAX(total_max, listener_area_pos.length());
}
#endif // PHYSICS_3D_DISABLED
if (dist > total_max || total_max > max_distance) {
if (!was_further_than_max_distance_last_frame) {
HashMap<StringName, Vector<AudioFrame>> bus_volumes;
@ -435,16 +463,25 @@ Vector<AudioFrame> AudioStreamPlayer3D::_update_panning() {
for (Ref<AudioStreamPlayback> &playback : internal->stream_playbacks) {
AudioServer::get_singleton()->set_playback_highshelf_params(playback, linear_attenuation, attenuation_filter_cutoff_hz);
}
// Bake in a constant factor here to allow the project setting defaults for 2d and 3d to be normalized to 1.0.
float tightness = cached_global_panning_strength * 2.0f;
tightness *= panning_strength;
_calc_output_vol(local_pos.normalized(), tightness, output_volume_vector);
if (AudioServer::get_singleton()->get_speaker_mode() == AudioServer::SPEAKER_MODE_STEREO) {
output_volume_vector.write[0] = _calc_output_vol_stereo(local_pos, cached_global_panning_strength * panning_strength);
output_volume_vector.write[1] = AudioFrame(0, 0);
output_volume_vector.write[2] = AudioFrame(0, 0);
output_volume_vector.write[3] = AudioFrame(0, 0);
} else {
// Bake in a constant factor here to allow the project setting defaults for 2d and 3d to be normalized to 1.0.
float tightness = cached_global_panning_strength * 2.0f;
tightness *= panning_strength;
_calc_output_vol(local_pos.normalized(), tightness, output_volume_vector);
}
for (unsigned int k = 0; k < 4; k++) {
output_volume_vector.write[k] = multiplier * output_volume_vector[k];
}
HashMap<StringName, Vector<AudioFrame>> bus_volumes;
#ifndef PHYSICS_3D_DISABLED
if (area) {
if (area->is_overriding_audio_bus()) {
//override audio bus
@ -457,7 +494,9 @@ Vector<AudioFrame> AudioStreamPlayer3D::_update_panning() {
_calc_reverb_vol(area, listener_area_pos, output_volume_vector, reverb_vol);
bus_volumes[reverb_bus_name] = reverb_vol;
}
} else {
} else
#endif // PHYSICS_3D_DISABLED
{
bus_volumes[internal->bus] = output_volume_vector;
}

View file

@ -28,13 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_STREAM_PLAYER_3D_H
#define AUDIO_STREAM_PLAYER_3D_H
#pragma once
#include "scene/3d/node_3d.h"
#include "servers/audio_server.h"
#ifndef PHYSICS_3D_DISABLED
class Area3D;
#endif // PHYSICS_3D_DISABLED
struct AudioFrame;
class AudioStream;
class AudioStreamPlayback;
@ -80,15 +81,20 @@ private:
bool force_update_panning = false;
static void _calc_output_vol(const Vector3 &source_dir, real_t tightness, Vector<AudioFrame> &output);
static AudioFrame _calc_output_vol_stereo(const Vector3 &source_dir, real_t panning_strength);
#ifndef PHYSICS_3D_DISABLED
void _calc_reverb_vol(Area3D *area, Vector3 listener_area_pos, Vector<AudioFrame> direct_path_vol, Vector<AudioFrame> &reverb_vol);
#endif // PHYSICS_3D_DISABLED
static void _listener_changed_cb(void *self) { reinterpret_cast<AudioStreamPlayer3D *>(self)->force_update_panning = true; }
void _set_playing(bool p_enable);
bool _is_active() const;
StringName _get_actual_bus();
#ifndef PHYSICS_3D_DISABLED
Area3D *_get_overriding_area();
#endif // PHYSICS_3D_DISABLED
Vector<AudioFrame> _update_panning();
uint32_t area_mask = 1;
@ -208,5 +214,3 @@ public:
VARIANT_ENUM_CAST(AudioStreamPlayer3D::AttenuationModel)
VARIANT_ENUM_CAST(AudioStreamPlayer3D::DopplerTracking)
#endif // AUDIO_STREAM_PLAYER_3D_H

View file

@ -37,7 +37,7 @@ void BoneAttachment3D::_validate_property(PropertyInfo &p_property) const {
const Skeleton3D *parent = nullptr;
if (use_external_skeleton) {
if (external_skeleton_node_cache.is_valid()) {
parent = Object::cast_to<Skeleton3D>(ObjectDB::get_instance(external_skeleton_node_cache));
parent = ObjectDB::get_instance<Skeleton3D>(external_skeleton_node_cache);
}
} else {
parent = Object::cast_to<Skeleton3D>(get_parent());
@ -151,11 +151,11 @@ void BoneAttachment3D::_check_bind() {
Skeleton3D *BoneAttachment3D::get_skeleton() {
if (use_external_skeleton) {
if (external_skeleton_node_cache.is_valid()) {
return Object::cast_to<Skeleton3D>(ObjectDB::get_instance(external_skeleton_node_cache));
return ObjectDB::get_instance<Skeleton3D>(external_skeleton_node_cache);
} else {
_update_external_skeleton_cache();
if (external_skeleton_node_cache.is_valid()) {
return Object::cast_to<Skeleton3D>(ObjectDB::get_instance(external_skeleton_node_cache));
return ObjectDB::get_instance<Skeleton3D>(external_skeleton_node_cache);
}
}
} else {
@ -341,7 +341,7 @@ void BoneAttachment3D::notify_skeleton_bones_renamed(Node *p_base_scene, Skeleto
const Skeleton3D *parent = nullptr;
if (use_external_skeleton) {
if (external_skeleton_node_cache.is_valid()) {
parent = Object::cast_to<Skeleton3D>(ObjectDB::get_instance(external_skeleton_node_cache));
parent = ObjectDB::get_instance<Skeleton3D>(external_skeleton_node_cache);
}
} else {
parent = Object::cast_to<Skeleton3D>(get_parent());

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef BONE_ATTACHMENT_3D_H
#define BONE_ATTACHMENT_3D_H
#pragma once
#include "scene/3d/skeleton_3d.h"
@ -99,5 +98,3 @@ public:
BoneAttachment3D();
};
#endif // BONE_ATTACHMENT_3D_H

View file

@ -691,7 +691,9 @@ void Camera3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_frustum"), &Camera3D::_get_frustum);
ClassDB::bind_method(D_METHOD("is_position_in_frustum", "world_point"), &Camera3D::is_position_in_frustum);
ClassDB::bind_method(D_METHOD("get_camera_rid"), &Camera3D::get_camera);
#ifndef PHYSICS_3D_DISABLED
ClassDB::bind_method(D_METHOD("get_pyramid_shape_rid"), &Camera3D::get_pyramid_shape_rid);
#endif // PHYSICS_3D_DISABLED
ClassDB::bind_method(D_METHOD("set_cull_mask_value", "layer_number", "value"), &Camera3D::set_cull_mask_value);
ClassDB::bind_method(D_METHOD("get_cull_mask_value", "layer_number"), &Camera3D::get_cull_mask_value);
@ -854,6 +856,7 @@ Vector3 Camera3D::get_doppler_tracked_velocity() const {
}
}
#ifndef PHYSICS_3D_DISABLED
RID Camera3D::get_pyramid_shape_rid() {
ERR_FAIL_COND_V_MSG(!is_inside_tree(), RID(), "Camera is not inside scene.");
if (pyramid_shape == RID()) {
@ -881,6 +884,7 @@ RID Camera3D::get_pyramid_shape_rid() {
return pyramid_shape;
}
#endif // PHYSICS_3D_DISABLED
Camera3D::Camera3D() {
camera = RenderingServer::get_singleton()->camera_create();
@ -895,8 +899,10 @@ Camera3D::Camera3D() {
Camera3D::~Camera3D() {
ERR_FAIL_NULL(RenderingServer::get_singleton());
RenderingServer::get_singleton()->free(camera);
#ifndef PHYSICS_3D_DISABLED
if (pyramid_shape.is_valid()) {
ERR_FAIL_NULL(PhysicsServer3D::get_singleton());
PhysicsServer3D::get_singleton()->free(pyramid_shape);
}
#endif // PHYSICS_3D_DISABLED
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CAMERA_3D_H
#define CAMERA_3D_H
#pragma once
#include "scene/3d/node_3d.h"
#include "scene/3d/velocity_tracker_3d.h"
@ -95,8 +94,10 @@ private:
DopplerTracking doppler_tracking = DOPPLER_TRACKING_DISABLED;
Ref<VelocityTracker3D> velocity_tracker;
#ifndef PHYSICS_3D_DISABLED
RID pyramid_shape;
Vector<Vector3> pyramid_shape_points;
#endif // PHYSICS_3D_DISABLED
///////////////////////////////////////////////////////
// INTERPOLATION FUNCTIONS
@ -218,7 +219,9 @@ public:
Vector3 get_doppler_tracked_velocity() const;
#ifndef PHYSICS_3D_DISABLED
RID get_pyramid_shape_rid();
#endif // PHYSICS_3D_DISABLED
Camera3D();
~Camera3D();
@ -227,5 +230,3 @@ public:
VARIANT_ENUM_CAST(Camera3D::ProjectionType);
VARIANT_ENUM_CAST(Camera3D::KeepAspect);
VARIANT_ENUM_CAST(Camera3D::DopplerTracking);
#endif // CAMERA_3D_H

View file

@ -647,7 +647,7 @@ static real_t rand_from_seed(uint32_t &seed) {
}
void CPUParticles3D::_update_internal() {
if (particles.size() == 0 || !is_visible_in_tree()) {
if (particles.is_empty() || !is_visible_in_tree()) {
_set_redraw(false);
return;
}
@ -886,14 +886,14 @@ void CPUParticles3D::_particles_process(double p_delta) {
} break;
case EMISSION_SHAPE_SPHERE: {
real_t s = 2.0 * rng->randf() - 1.0;
real_t t = Math_TAU * rng->randf();
real_t t = Math::TAU * rng->randf();
real_t x = rng->randf();
real_t radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
p.transform.origin = Vector3(0, 0, 0).lerp(Vector3(radius * Math::cos(t), radius * Math::sin(t), emission_sphere_radius * s), x);
} break;
case EMISSION_SHAPE_SPHERE_SURFACE: {
real_t s = 2.0 * rng->randf() - 1.0;
real_t t = Math_TAU * rng->randf();
real_t t = Math::TAU * rng->randf();
real_t radius = emission_sphere_radius * Math::sqrt(1.0 - s * s);
p.transform.origin = Vector3(radius * Math::cos(t), radius * Math::sin(t), emission_sphere_radius * s);
} break;
@ -945,7 +945,7 @@ void CPUParticles3D::_particles_process(double p_delta) {
real_t y_pos = rng->randf();
real_t skew = MAX(MIN(radius_clamped, top_radius) / MAX(radius_clamped, top_radius), 0.5);
y_pos = radius_clamped < top_radius ? Math::pow(y_pos, skew) : 1.0 - Math::pow(y_pos, skew);
real_t ring_random_angle = rng->randf() * Math_TAU;
real_t ring_random_angle = rng->randf() * Math::TAU;
real_t ring_random_radius = Math::sqrt(rng->randf() * (radius_clamped * radius_clamped - emission_ring_inner_radius * emission_ring_inner_radius) + emission_ring_inner_radius * emission_ring_inner_radius);
ring_random_radius = Math::lerp(ring_random_radius, ring_random_radius * (top_radius / radius_clamped), y_pos);
Vector3 axis = emission_ring_axis == Vector3(0.0, 0.0, 0.0) ? Vector3(0.0, 0.0, 1.0) : emission_ring_axis.normalized();
@ -1064,7 +1064,7 @@ void CPUParticles3D::_particles_process(double p_delta) {
if (particle_flags[PARTICLE_FLAG_DISABLE_Z]) {
real_t orbit_amount = tex_orbit_velocity * Math::lerp(parameters_min[PARAM_ORBIT_VELOCITY], parameters_max[PARAM_ORBIT_VELOCITY], rand_from_seed(alt_seed));
if (orbit_amount != 0.0) {
real_t ang = orbit_amount * local_delta * Math_TAU;
real_t ang = orbit_amount * local_delta * Math::TAU;
// Not sure why the ParticleProcessMaterial code uses a clockwise rotation matrix,
// but we use -ang here to reproduce its behavior.
Transform2D rot = Transform2D(-ang, Vector2());
@ -1126,7 +1126,7 @@ void CPUParticles3D::_particles_process(double p_delta) {
tex_hue_variation = curve_parameters[PARAM_HUE_VARIATION]->sample(tv);
}
real_t hue_rot_angle = (tex_hue_variation)*Math_TAU * Math::lerp(parameters_min[PARAM_HUE_VARIATION], parameters_max[PARAM_HUE_VARIATION], p.hue_rot_rand);
real_t hue_rot_angle = (tex_hue_variation)*Math::TAU * Math::lerp(parameters_min[PARAM_HUE_VARIATION], parameters_max[PARAM_HUE_VARIATION], p.hue_rot_rand);
real_t hue_rot_c = Math::cos(hue_rot_angle);
real_t hue_rot_s = Math::sin(hue_rot_angle);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CPU_PARTICLES_3D_H
#define CPU_PARTICLES_3D_H
#pragma once
#include "scene/3d/visual_instance_3d.h"
@ -345,5 +344,3 @@ VARIANT_ENUM_CAST(CPUParticles3D::DrawOrder)
VARIANT_ENUM_CAST(CPUParticles3D::Parameter)
VARIANT_ENUM_CAST(CPUParticles3D::ParticleFlags)
VARIANT_ENUM_CAST(CPUParticles3D::EmissionShape)
#endif // CPU_PARTICLES_3D_H

View file

@ -179,7 +179,7 @@ void Decal::_validate_property(PropertyInfo &p_property) const {
PackedStringArray Decal::get_configuration_warnings() const {
PackedStringArray warnings = VisualInstance3D::get_configuration_warnings();
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" || OS::get_singleton()->get_current_rendering_method() == "dummy") {
warnings.push_back(RTR("Decals are only available when using the Forward+ or Mobile renderers."));
return warnings;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef DECAL_H
#define DECAL_H
#pragma once
#include "scene/3d/visual_instance_3d.h"
@ -114,5 +113,3 @@ public:
};
VARIANT_ENUM_CAST(Decal::DecalTexture);
#endif // DECAL_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef FOG_VOLUME_H
#define FOG_VOLUME_H
#pragma once
#include "core/templates/rid.h"
#include "scene/3d/visual_instance_3d.h"
@ -69,5 +68,3 @@ public:
FogVolume();
~FogVolume();
};
#endif // FOG_VOLUME_H

View file

@ -421,12 +421,12 @@ PackedStringArray GPUParticles3D::get_configuration_warnings() const {
if ((dp_count || skin.is_valid()) && (missing_trails || no_materials)) {
warnings.push_back(RTR("Trails enabled, but one or more mesh materials are either missing or not set for trails rendering."));
}
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" || OS::get_singleton()->get_current_rendering_method() == "dummy") {
warnings.push_back(RTR("Particle trails are only available when using the Forward+ or Mobile renderers."));
}
}
if (sub_emitter != NodePath() && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
if (sub_emitter != NodePath() && (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" || OS::get_singleton()->get_current_rendering_method() == "dummy")) {
warnings.push_back(RTR("Particle sub-emitters are only available when using the Forward+ or Mobile renderers."));
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GPU_PARTICLES_3D_H
#define GPU_PARTICLES_3D_H
#pragma once
#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/3d/skin.h"
@ -211,5 +210,3 @@ public:
VARIANT_ENUM_CAST(GPUParticles3D::DrawOrder)
VARIANT_ENUM_CAST(GPUParticles3D::TransformAlign)
VARIANT_ENUM_CAST(GPUParticles3D::EmitFlags)
#endif // GPU_PARTICLES_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GPU_PARTICLES_COLLISION_3D_H
#define GPU_PARTICLES_COLLISION_3D_H
#pragma once
#include "core/templates/local_vector.h"
#include "scene/3d/visual_instance_3d.h"
@ -364,5 +363,3 @@ public:
GPUParticlesAttractorVectorField3D();
~GPUParticlesAttractorVectorField3D();
};
#endif // GPU_PARTICLES_COLLISION_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef IMPORTER_MESH_INSTANCE_3D_H
#define IMPORTER_MESH_INSTANCE_3D_H
#pragma once
#include "scene/3d/node_3d.h"
#include "scene/3d/visual_instance_3d.h"
@ -89,5 +88,3 @@ public:
void set_visibility_range_fade_mode(GeometryInstance3D::VisibilityRangeFadeMode p_mode);
GeometryInstance3D::VisibilityRangeFadeMode get_visibility_range_fade_mode() const;
};
#endif // IMPORTER_MESH_INSTANCE_3D_H

View file

@ -86,6 +86,9 @@ void Label3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_autowrap_mode", "autowrap_mode"), &Label3D::set_autowrap_mode);
ClassDB::bind_method(D_METHOD("get_autowrap_mode"), &Label3D::get_autowrap_mode);
ClassDB::bind_method(D_METHOD("set_autowrap_trim_flags", "autowrap_trim_flags"), &Label3D::set_autowrap_trim_flags);
ClassDB::bind_method(D_METHOD("get_autowrap_trim_flags"), &Label3D::get_autowrap_trim_flags);
ClassDB::bind_method(D_METHOD("set_justification_flags", "justification_flags"), &Label3D::set_justification_flags);
ClassDB::bind_method(D_METHOD("get_justification_flags"), &Label3D::get_justification_flags);
@ -154,6 +157,7 @@ void Label3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "uppercase"), "set_uppercase", "is_uppercase");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "line_spacing", PROPERTY_HINT_NONE, "suffix:px"), "set_line_spacing", "get_line_spacing");
ADD_PROPERTY(PropertyInfo(Variant::INT, "autowrap_mode", PROPERTY_HINT_ENUM, "Off,Arbitrary,Word,Word (Smart)"), "set_autowrap_mode", "get_autowrap_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "autowrap_trim_flags", PROPERTY_HINT_FLAGS, vformat("Trim Spaces After Break:%d,Trim Spaces Before Break:%d", TextServer::BREAK_TRIM_START_EDGE_SPACES, TextServer::BREAK_TRIM_END_EDGE_SPACES)), "set_autowrap_trim_flags", "get_autowrap_trim_flags");
ADD_PROPERTY(PropertyInfo(Variant::INT, "justification_flags", PROPERTY_HINT_FLAGS, "Kashida Justification:1,Word Justification:2,Justify Only After Last Tab:8,Skip Last Line:32,Skip Last Line With Visible Characters:64,Do Not Skip Single Line:128"), "set_justification_flags", "get_justification_flags");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width", PROPERTY_HINT_NONE, "suffix:px"), "set_width", "get_width");
@ -519,7 +523,7 @@ void Label3D::_shape() {
case TextServer::AUTOWRAP_OFF:
break;
}
autowrap_flags = autowrap_flags | TextServer::BREAK_TRIM_EDGE_SPACES;
autowrap_flags = autowrap_flags | autowrap_flags_trim;
PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(text_rid, width, 0, autowrap_flags);
float max_line_w = 0.0;
@ -891,6 +895,18 @@ TextServer::AutowrapMode Label3D::get_autowrap_mode() const {
return autowrap_mode;
}
void Label3D::set_autowrap_trim_flags(BitField<TextServer::LineBreakFlag> p_flags) {
if (autowrap_flags_trim != (p_flags & TextServer::BREAK_TRIM_MASK)) {
autowrap_flags_trim = (p_flags & TextServer::BREAK_TRIM_MASK);
dirty_lines = true;
_queue_update();
}
}
BitField<TextServer::LineBreakFlag> Label3D::get_autowrap_trim_flags() const {
return autowrap_flags_trim;
}
void Label3D::set_justification_flags(BitField<TextServer::JustificationFlag> p_flags) {
if (jst_flags != p_flags) {
jst_flags = p_flags;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LABEL_3D_H
#define LABEL_3D_H
#pragma once
#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/font.h"
@ -112,6 +111,7 @@ private:
bool uppercase = false;
TextServer::AutowrapMode autowrap_mode = TextServer::AUTOWRAP_OFF;
BitField<TextServer::LineBreakFlag> autowrap_flags_trim = TextServer::BREAK_TRIM_START_EDGE_SPACES | TextServer::BREAK_TRIM_END_EDGE_SPACES;
BitField<TextServer::JustificationFlag> jst_flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA | TextServer::JUSTIFICATION_SKIP_LAST_LINE | TextServer::JUSTIFICATION_DO_NOT_SKIP_SINGLE_LINE;
float width = 500.0;
@ -216,6 +216,9 @@ public:
void set_autowrap_mode(TextServer::AutowrapMode p_mode);
TextServer::AutowrapMode get_autowrap_mode() const;
void set_autowrap_trim_flags(BitField<TextServer::LineBreakFlag> p_flags);
BitField<TextServer::LineBreakFlag> get_autowrap_trim_flags() const;
void set_justification_flags(BitField<TextServer::JustificationFlag> p_flags);
BitField<TextServer::JustificationFlag> get_justification_flags() const;
@ -261,5 +264,3 @@ public:
VARIANT_ENUM_CAST(Label3D::DrawFlags);
VARIANT_ENUM_CAST(Label3D::AlphaCutMode);
#endif // LABEL_3D_H

View file

@ -166,7 +166,7 @@ AABB Light3D::get_aabb() const {
real_t cone_slant_height = param[PARAM_RANGE];
real_t cone_angle_rad = Math::deg_to_rad(param[PARAM_SPOT_ANGLE]);
if (cone_angle_rad > Math_PI / 2.0) {
if (cone_angle_rad > Math::PI / 2.0) {
// Just return the AABB of an omni light if the spot angle is above 90 degrees.
return AABB(Vector3(-1, -1, -1) * cone_slant_height, Vector3(2, 2, 2) * cone_slant_height);
}
@ -632,7 +632,7 @@ PackedStringArray OmniLight3D::get_configuration_warnings() const {
warnings.push_back(RTR("Projector texture only works with shadows active."));
}
if (get_projector().is_valid() && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
if (get_projector().is_valid() && (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" || OS::get_singleton()->get_current_rendering_method() == "dummy")) {
warnings.push_back(RTR("Projector textures are not supported when using the Compatibility renderer yet. Support will be added in a future release."));
}
@ -668,7 +668,7 @@ PackedStringArray SpotLight3D::get_configuration_warnings() const {
warnings.push_back(RTR("Projector texture only works with shadows active."));
}
if (get_projector().is_valid() && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
if (get_projector().is_valid() && (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility" || OS::get_singleton()->get_current_rendering_method() == "dummy")) {
warnings.push_back(RTR("Projector textures are not supported when using the Compatibility renderer yet. Support will be added in a future release."));
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LIGHT_3D_H
#define LIGHT_3D_H
#pragma once
#include "scene/3d/visual_instance_3d.h"
@ -239,5 +238,3 @@ public:
SpotLight3D();
};
#endif // LIGHT_3D_H

View file

@ -293,8 +293,7 @@ Dictionary LightmapGIData::_get_probe_data() const {
#ifndef DISABLE_DEPRECATED
void LightmapGIData::set_light_texture(const Ref<TextureLayered> &p_light_texture) {
TypedArray<TextureLayered> arr;
arr.append(p_light_texture);
TypedArray<TextureLayered> arr = { p_light_texture };
set_lightmap_textures(arr);
}
@ -699,7 +698,7 @@ int32_t LightmapGI::_compute_bsp_tree(const Vector<Vector3> &p_points, const Loc
BSPNode node;
node.plane = best_plane;
if (indices_under.size() == 0) {
if (indices_under.is_empty()) {
//nothing to do here
node.under = BSPNode::EMPTY_LEAF;
} else if (indices_under.size() == 1) {
@ -708,7 +707,7 @@ int32_t LightmapGI::_compute_bsp_tree(const Vector<Vector3> &p_points, const Loc
node.under = _compute_bsp_tree(p_points, p_planes, planes_tested, p_simplices, indices_under, bsp_nodes);
}
if (indices_over.size() == 0) {
if (indices_over.is_empty()) {
//nothing to do here
node.over = BSPNode::EMPTY_LEAF;
} else if (indices_over.size() == 1) {
@ -917,7 +916,7 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
Vector<MeshesFound> meshes_found;
_find_meshes_and_lights(p_from_node ? p_from_node : get_parent(), meshes_found, lights_found, probes_found);
if (meshes_found.size() == 0) {
if (meshes_found.is_empty()) {
return BAKE_ERROR_NO_MESHES;
}
// create mesh data for insert
@ -1024,8 +1023,8 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
const Vector3 *nr = nullptr;
Vector<int> index = a[Mesh::ARRAY_INDEX];
ERR_CONTINUE(uv.size() == 0);
ERR_CONTINUE(normals.size() == 0);
ERR_CONTINUE(uv.is_empty());
ERR_CONTINUE(normals.is_empty());
uvr = uv.ptr();
nr = normals.ptr();
@ -1194,13 +1193,13 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
} else if (Object::cast_to<OmniLight3D>(light)) {
OmniLight3D *l = Object::cast_to<OmniLight3D>(light);
if (use_physical_light_units) {
energy *= (1.0 / (Math_PI * 4.0));
energy *= (1.0 / (Math::PI * 4.0));
}
lightmapper->add_omni_light(light->get_name(), light->get_bake_mode() == Light3D::BAKE_STATIC, xf.origin, linear_color, energy, indirect_energy, l->get_param(Light3D::PARAM_RANGE), l->get_param(Light3D::PARAM_ATTENUATION), l->get_param(Light3D::PARAM_SIZE), l->get_param(Light3D::PARAM_SHADOW_BLUR));
} else if (Object::cast_to<SpotLight3D>(light)) {
SpotLight3D *l = Object::cast_to<SpotLight3D>(light);
if (use_physical_light_units) {
energy *= (1.0 / Math_PI);
energy *= (1.0 / Math::PI);
}
lightmapper->add_spot_light(light->get_name(), light->get_bake_mode() == Light3D::BAKE_STATIC, xf.origin, -xf.basis.get_column(Vector3::AXIS_Z).normalized(), linear_color, energy, indirect_energy, l->get_param(Light3D::PARAM_RANGE), l->get_param(Light3D::PARAM_ATTENUATION), l->get_param(Light3D::PARAM_SPOT_ANGLE), l->get_param(Light3D::PARAM_SPOT_ATTENUATION), l->get_param(Light3D::PARAM_SIZE), l->get_param(Light3D::PARAM_SHADOW_BLUR));
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LIGHTMAP_GI_H
#define LIGHTMAP_GI_H
#pragma once
#include "core/templates/local_vector.h"
#include "scene/3d/light_3d.h"
@ -361,5 +360,3 @@ VARIANT_ENUM_CAST(LightmapGI::BakeQuality);
VARIANT_ENUM_CAST(LightmapGI::GenerateProbes);
VARIANT_ENUM_CAST(LightmapGI::BakeError);
VARIANT_ENUM_CAST(LightmapGI::EnvironmentMode);
#endif // LIGHTMAP_GI_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LIGHTMAP_PROBE_H
#define LIGHTMAP_PROBE_H
#pragma once
#include "scene/3d/node_3d.h"
@ -38,5 +37,3 @@ class LightmapProbe : public Node3D {
public:
LightmapProbe();
};
#endif // LIGHTMAP_PROBE_H

View file

@ -28,23 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LIGHTMAPPER_H
#define LIGHTMAPPER_H
#pragma once
#include "core/object/ref_counted.h"
class Image;
#if !defined(__aligned)
#if defined(_WIN32) && defined(_MSC_VER)
#define __aligned(...) __declspec(align(__VA_ARGS__))
#else
#define __aligned(...) __attribute__((aligned(__VA_ARGS__)))
#endif
#endif
class LightmapDenoiser : public RefCounted {
GDCLASS(LightmapDenoiser, RefCounted)
protected:
@ -62,7 +51,7 @@ protected:
public:
// Compatible with embree4 rays.
struct __aligned(16) Ray {
struct alignas(16) Ray {
const static unsigned int INVALID_GEOMETRY_ID = ((unsigned int)-1); // from rtcore_common.h
/*! Default construction does nothing. */
@ -74,7 +63,7 @@ public:
_FORCE_INLINE_ Ray(const Vector3 &p_org,
const Vector3 &p_dir,
float p_tnear = 0.0f,
float p_tfar = INFINITY) :
float p_tfar = Math::INF) :
org(p_org),
tnear(p_tnear),
dir(p_dir),
@ -200,5 +189,3 @@ public:
Lightmapper();
};
#endif // LIGHTMAPPER_H

View file

@ -487,7 +487,7 @@ void LookAtModifier3D::_bind_methods() {
BIND_ENUM_CONSTANT(ORIGIN_FROM_EXTERNAL_NODE);
}
void LookAtModifier3D::_process_modification() {
void LookAtModifier3D::_process_modification(double p_delta) {
if (!is_inside_tree()) {
return;
}
@ -502,10 +502,10 @@ void LookAtModifier3D::_process_modification() {
int parent_bone = skeleton->get_bone_parent(bone);
if (parent_bone < 0) {
bone_rest_space = skeleton->get_global_transform();
bone_rest_space.origin += skeleton->get_bone_rest(bone).origin;
bone_rest_space.translate_local(skeleton->get_bone_rest(bone).origin);
} else {
bone_rest_space = skeleton->get_global_transform() * skeleton->get_bone_global_pose(parent_bone);
bone_rest_space.origin += skeleton->get_bone_rest(bone).origin;
bone_rest_space.translate_local(skeleton->get_bone_rest(bone).origin);
}
// Calculate forward_vector and destination.
@ -554,13 +554,13 @@ void LookAtModifier3D::_process_modification() {
Vector3 prev_forward_vector_nrm = forward_vector.normalized();
Vector3 rest_forward_vector = get_vector_from_bone_axis(forward_axis);
if (symmetry_limitation) {
if ((is_not_max_influence || !Math::is_equal_approx(primary_limit_angle, (float)Math_TAU)) &&
if ((is_not_max_influence || !Math::is_equal_approx(primary_limit_angle, (float)Math::TAU)) &&
prev_forward_vector_nrm.dot(rest_forward_vector) < 0 &&
forward_vector_nrm.dot(rest_forward_vector) < 0) {
init_transition();
}
} else {
if ((is_not_max_influence || !Math::is_equal_approx(primary_positive_limit_angle + primary_negative_limit_angle, (float)Math_TAU)) &&
if ((is_not_max_influence || !Math::is_equal_approx(primary_positive_limit_angle + primary_negative_limit_angle, (float)Math::TAU)) &&
prev_forward_vector_nrm.dot(rest_forward_vector) < 0 &&
forward_vector_nrm.dot(rest_forward_vector) < 0) {
init_transition();
@ -570,13 +570,7 @@ void LookAtModifier3D::_process_modification() {
// Do time-based interpolation.
if (remaining > 0) {
double delta = 0.0;
if (skeleton->get_modifier_callback_mode_process() == Skeleton3D::MODIFIER_CALLBACK_MODE_PROCESS_IDLE) {
delta = get_process_delta_time();
} else {
delta = get_physics_process_delta_time();
}
remaining = MAX(0, remaining - time_step * delta);
remaining = MAX(0, remaining - time_step * p_delta);
if (is_flippable) {
// Interpolate through the rest same as AnimationTree blending for preventing to penetrate the bone into the body.
Quaternion rest = skeleton->get_bone_rest(bone).basis.get_rotation_quaternion();
@ -666,7 +660,7 @@ float LookAtModifier3D::remap_damped(float p_from, float p_to, float p_damp_thre
return sign * CLAMP(abs_value, p_from, p_to);
}
double limit = Math_PI;
double limit = Math::PI;
double inv_to = 1.0 / p_to;
double end_x = limit * inv_to;
double position = abs_value * inv_to;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LOOK_AT_MODIFIER_3D_H
#define LOOK_AT_MODIFIER_3D_H
#pragma once
#include "scene/3d/skeleton_modifier_3d.h"
#include "scene/animation/tween.h"
@ -72,18 +71,18 @@ private:
bool use_angle_limitation = false;
bool symmetry_limitation = true;
float primary_limit_angle = Math_TAU;
float primary_limit_angle = Math::TAU;
float primary_damp_threshold = 1.0f;
float primary_positive_limit_angle = Math_PI;
float primary_positive_limit_angle = Math::PI;
float primary_positive_damp_threshold = 1.0f;
float primary_negative_limit_angle = Math_PI;
float primary_negative_limit_angle = Math::PI;
float primary_negative_damp_threshold = 1.0f;
float secondary_limit_angle = Math_TAU;
float secondary_limit_angle = Math::TAU;
float secondary_damp_threshold = 1.0f;
float secondary_positive_limit_angle = Math_PI;
float secondary_positive_limit_angle = Math::PI;
float secondary_positive_damp_threshold = 1.0f;
float secondary_negative_limit_angle = Math_PI;
float secondary_negative_limit_angle = Math::PI;
float secondary_negative_damp_threshold = 1.0f;
bool is_within_limitations = false;
@ -108,7 +107,7 @@ protected:
static void _bind_methods();
virtual void _process_modification() override;
virtual void _process_modification(double p_delta) override;
public:
void set_bone_name(const String &p_bone_name);
@ -190,5 +189,3 @@ public:
};
VARIANT_ENUM_CAST(LookAtModifier3D::OriginFrom);
#endif // LOOK_AT_MODIFIER_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MARKER_3D_H
#define MARKER_3D_H
#pragma once
#include "scene/3d/node_3d.h"
@ -47,5 +46,3 @@ public:
Marker3D();
};
#endif // MARKER_3D_H

View file

@ -30,18 +30,23 @@
#include "mesh_instance_3d.h"
#include "scene/3d/skeleton_3d.h"
#ifndef PHYSICS_3D_DISABLED
#include "scene/3d/physics/collision_shape_3d.h"
#include "scene/3d/physics/static_body_3d.h"
#include "scene/3d/skeleton_3d.h"
#include "scene/resources/3d/concave_polygon_shape_3d.h"
#include "scene/resources/3d/convex_polygon_shape_3d.h"
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "scene/resources/navigation_mesh.h"
#include "servers/navigation_server_3d.h"
Callable MeshInstance3D::_navmesh_source_geometry_parsing_callback;
RID MeshInstance3D::_navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
//this is not _too_ bad performance wise, really. it only arrives here if the property was not set anywhere else.
@ -230,6 +235,7 @@ AABB MeshInstance3D::get_aabb() const {
return AABB();
}
#ifndef PHYSICS_3D_DISABLED
Node *MeshInstance3D::create_trimesh_collision_node() {
if (mesh.is_null()) {
return nullptr;
@ -331,6 +337,7 @@ void MeshInstance3D::create_multiple_convex_collisions(const Ref<MeshConvexDecom
}
}
}
#endif // PHYSICS_3D_DISABLED
void MeshInstance3D::_notification(int p_what) {
switch (p_what) {
@ -430,11 +437,11 @@ MeshInstance3D *MeshInstance3D::create_debug_tangents_node() {
Vector<Vector3> verts = arrays[Mesh::ARRAY_VERTEX];
Vector<Vector3> norms = arrays[Mesh::ARRAY_NORMAL];
if (norms.size() == 0) {
if (norms.is_empty()) {
continue;
}
Vector<float> tangents = arrays[Mesh::ARRAY_TANGENT];
if (tangents.size() == 0) {
if (tangents.is_empty()) {
continue;
}
@ -849,6 +856,7 @@ Ref<TriangleMesh> MeshInstance3D::generate_triangle_mesh() const {
return Ref<TriangleMesh>();
}
#ifndef NAVIGATION_3D_DISABLED
void MeshInstance3D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -874,6 +882,7 @@ void MeshInstance3D::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_
}
}
}
#endif // NAVIGATION_3D_DISABLED
void MeshInstance3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MeshInstance3D::set_mesh);
@ -889,12 +898,14 @@ void MeshInstance3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_surface_override_material", "surface"), &MeshInstance3D::get_surface_override_material);
ClassDB::bind_method(D_METHOD("get_active_material", "surface"), &MeshInstance3D::get_active_material);
#ifndef PHYSICS_3D_DISABLED
ClassDB::bind_method(D_METHOD("create_trimesh_collision"), &MeshInstance3D::create_trimesh_collision);
ClassDB::set_method_flags("MeshInstance3D", "create_trimesh_collision", METHOD_FLAGS_DEFAULT);
ClassDB::bind_method(D_METHOD("create_convex_collision", "clean", "simplify"), &MeshInstance3D::create_convex_collision, DEFVAL(true), DEFVAL(false));
ClassDB::set_method_flags("MeshInstance3D", "create_convex_collision", METHOD_FLAGS_DEFAULT);
ClassDB::bind_method(D_METHOD("create_multiple_convex_collisions", "settings"), &MeshInstance3D::create_multiple_convex_collisions, DEFVAL(Ref<MeshConvexDecompositionSettings>()));
ClassDB::set_method_flags("MeshInstance3D", "create_multiple_convex_collisions", METHOD_FLAGS_DEFAULT);
#endif // PHYSICS_3D_DISABLED
ClassDB::bind_method(D_METHOD("get_blend_shape_count"), &MeshInstance3D::get_blend_shape_count);
ClassDB::bind_method(D_METHOD("find_blend_shape_by_name", "name"), &MeshInstance3D::find_blend_shape_by_name);

View file

@ -28,14 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MESH_INSTANCE_3D_H
#define MESH_INSTANCE_3D_H
#pragma once
#include "core/templates/local_vector.h"
#include "scene/3d/visual_instance_3d.h"
#ifndef NAVIGATION_3D_DISABLED
class NavigationMesh;
class NavigationMeshSourceGeometryData3D;
#endif // NAVIGATION_3D_DISABLED
class Skin;
class SkinReference;
@ -90,6 +91,7 @@ public:
Ref<Material> get_surface_override_material(int p_surface) const;
Ref<Material> get_active_material(int p_surface) const;
#ifndef PHYSICS_3D_DISABLED
Node *create_trimesh_collision_node();
void create_trimesh_collision();
@ -98,6 +100,7 @@ public:
Node *create_multiple_convex_collisions_node(const Ref<MeshConvexDecompositionSettings> &p_settings = Ref<MeshConvexDecompositionSettings>());
void create_multiple_convex_collisions(const Ref<MeshConvexDecompositionSettings> &p_settings = Ref<MeshConvexDecompositionSettings>());
#endif // PHYSICS_3D_DISABLED
MeshInstance3D *create_debug_tangents_node();
void create_debug_tangents();
@ -109,16 +112,18 @@ public:
virtual Ref<TriangleMesh> generate_triangle_mesh() const override;
#ifndef NAVIGATION_3D_DISABLED
private:
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
public:
#ifndef NAVIGATION_3D_DISABLED
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_3D_DISABLED
MeshInstance3D();
~MeshInstance3D();
};
#endif // MESH_INSTANCE_3D_H

View file

@ -30,12 +30,14 @@
#include "multimesh_instance_3d.h"
#ifndef NAVIGATION_3D_DISABLED
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "scene/resources/navigation_mesh.h"
#include "servers/navigation_server_3d.h"
Callable MultiMeshInstance3D::_navmesh_source_geometry_parsing_callback;
RID MultiMeshInstance3D::_navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
void MultiMeshInstance3D::_refresh_interpolated() {
if (is_inside_tree() && multimesh.is_valid()) {
@ -103,6 +105,7 @@ AABB MultiMeshInstance3D::get_aabb() const {
}
}
#ifndef NAVIGATION_3D_DISABLED
void MultiMeshInstance3D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -137,6 +140,7 @@ void MultiMeshInstance3D::navmesh_parse_source_geometry(const Ref<NavigationMesh
}
}
}
#endif // NAVIGATION_3D_DISABLED
MultiMeshInstance3D::MultiMeshInstance3D() {
}

View file

@ -28,14 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MULTIMESH_INSTANCE_3D_H
#define MULTIMESH_INSTANCE_3D_H
#pragma once
#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/multimesh.h"
#ifndef NAVIGATION_3D_DISABLED
class NavigationMesh;
class NavigationMeshSourceGeometryData3D;
#endif // NAVIGATION_3D_DISABLED
class MultiMeshInstance3D : public GeometryInstance3D {
GDCLASS(MultiMeshInstance3D, GeometryInstance3D);
@ -58,15 +59,17 @@ public:
virtual AABB get_aabb() const override;
private:
#ifndef NAVIGATION_3D_DISABLED
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
public:
#ifndef NAVIGATION_3D_DISABLED
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_3D_DISABLED
MultiMeshInstance3D();
~MultiMeshInstance3D();
};
#endif // MULTIMESH_INSTANCE_3D_H

View file

@ -0,0 +1,6 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *
Import("env")
env.add_source_files(env.scene_sources, "*.cpp")

View file

@ -30,7 +30,7 @@
#include "navigation_agent_3d.h"
#include "scene/3d/navigation_link_3d.h"
#include "scene/3d/navigation/navigation_link_3d.h"
#include "servers/navigation_server_3d.h"
void NavigationAgent3D::_bind_methods() {
@ -658,7 +658,7 @@ Vector3 NavigationAgent3D::get_next_path_position() {
_update_navigation();
const Vector<Vector3> &navigation_path = navigation_result->get_path();
if (navigation_path.size() == 0) {
if (navigation_path.is_empty()) {
ERR_FAIL_NULL_V_MSG(agent_parent, Vector3(), "The agent has no parent.");
return agent_parent->get_global_position();
} else {
@ -696,7 +696,7 @@ Vector3 NavigationAgent3D::get_final_position() {
Vector3 NavigationAgent3D::_get_final_position() const {
const Vector<Vector3> &navigation_path = navigation_result->get_path();
if (navigation_path.size() == 0) {
if (navigation_path.is_empty()) {
return Vector3();
}
return navigation_path[navigation_path.size() - 1] - Vector3(0, path_height_offset, 0);
@ -751,19 +751,18 @@ void NavigationAgent3D::_update_navigation() {
if (NavigationServer3D::get_singleton()->agent_is_map_changed(agent)) {
reload_path = true;
} else if (navigation_result->get_path().size() == 0) {
} else if (navigation_result->get_path().is_empty()) {
reload_path = true;
} else {
// Check if too far from the navigation path
if (navigation_path_index > 0) {
const Vector<Vector3> &navigation_path = navigation_result->get_path();
Vector3 segment[2];
segment[0] = navigation_path[navigation_path_index - 1];
segment[1] = navigation_path[navigation_path_index];
segment[0].y -= path_height_offset;
segment[1].y -= path_height_offset;
Vector3 p = Geometry3D::get_closest_point_to_segment(origin, segment);
Vector3 segment_a = navigation_path[navigation_path_index - 1];
Vector3 segment_b = navigation_path[navigation_path_index];
segment_a.y -= path_height_offset;
segment_b.y -= path_height_offset;
Vector3 p = Geometry3D::get_closest_point_to_segment(origin, segment_a, segment_b);
if (origin.distance_to(p) >= path_max_distance) {
// To faraway, reload path
reload_path = true;
@ -793,7 +792,7 @@ void NavigationAgent3D::_update_navigation() {
emit_signal(SNAME("path_changed"));
}
if (navigation_result->get_path().size() == 0) {
if (navigation_result->get_path().is_empty()) {
return;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_AGENT_3D_H
#define NAVIGATION_AGENT_3D_H
#pragma once
#include "scene/main/node.h"
#include "servers/navigation/navigation_path_query_parameters_3d.h"
@ -278,5 +277,3 @@ private:
void _update_debug_path();
#endif // DEBUG_ENABLED
};
#endif // NAVIGATION_AGENT_3D_H

View file

@ -262,6 +262,12 @@ void NavigationLink3D::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
_link_exit_navigation_map();
} break;
#ifdef DEBUG_ENABLED
case NOTIFICATION_VISIBILITY_CHANGED: {
_update_debug_mesh();
} break;
#endif // DEBUG_ENABLED
}
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_LINK_3D_H
#define NAVIGATION_LINK_3D_H
#pragma once
#include "scene/3d/node_3d.h"
@ -110,5 +109,3 @@ private:
void _link_exit_navigation_map();
void _link_update_transform();
};
#endif // NAVIGATION_LINK_3D_H

View file

@ -464,7 +464,7 @@ void NavigationObstacle3D::navmesh_parse_source_geometry(const Ref<NavigationMes
obstruction_circle_vertices.resize(circle_points);
Vector3 *circle_vertices_ptrw = obstruction_circle_vertices.ptrw();
const real_t circle_point_step = Math_TAU / circle_points;
const real_t circle_point_step = Math::TAU / circle_points;
for (int i = 0; i < circle_points; i++) {
const float angle = i * circle_point_step;
@ -581,15 +581,15 @@ void NavigationObstacle3D::_update_fake_agent_radius_debug() {
float w;
v /= (rings + 1);
w = sin(Math_PI * v);
y = (radius)*cos(Math_PI * v);
w = sin(Math::PI * v);
y = (radius)*cos(Math::PI * v);
for (i = 0; i <= radial_segments; i++) {
float u = i;
u /= radial_segments;
x = sin(u * Math_TAU);
z = cos(u * Math_TAU);
x = sin(u * Math::TAU);
z = cos(u * Math::TAU);
Vector3 p = Vector3(x * radius * w, y, z * radius * w);
face_vertex_array.push_back(p);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_OBSTACLE_3D_H
#define NAVIGATION_OBSTACLE_3D_H
#pragma once
#include "scene/3d/node_3d.h"
@ -141,5 +140,3 @@ private:
void _update_transform();
void _update_use_3d_avoidance(bool p_use_3d_avoidance);
};
#endif // NAVIGATION_OBSTACLE_3D_H

View file

@ -30,6 +30,7 @@
#include "navigation_region_3d.h"
#include "core/math/random_pcg.h"
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "servers/navigation_server_3d.h"
@ -193,30 +194,7 @@ void NavigationRegion3D::set_navigation_mesh(const Ref<NavigationMesh> &p_naviga
navigation_mesh->connect_changed(callable_mp(this, &NavigationRegion3D::_navigation_mesh_changed));
}
_update_bounds();
NavigationServer3D::get_singleton()->region_set_navigation_mesh(region, p_navigation_mesh);
#ifdef DEBUG_ENABLED
if (is_inside_tree() && NavigationServer3D::get_singleton()->get_debug_navigation_enabled()) {
if (navigation_mesh.is_valid()) {
_update_debug_mesh();
_update_debug_edge_connections_mesh();
} else {
if (debug_instance.is_valid()) {
RS::get_singleton()->instance_set_visible(debug_instance, false);
}
if (debug_edge_connections_instance.is_valid()) {
RS::get_singleton()->instance_set_visible(debug_edge_connections_instance, false);
}
}
}
#endif // DEBUG_ENABLED
emit_signal(SNAME("navigation_mesh_changed"));
update_gizmos();
update_configuration_warnings();
_navigation_mesh_changed();
}
Ref<NavigationMesh> NavigationRegion3D::get_navigation_mesh() const {
@ -252,19 +230,18 @@ void NavigationRegion3D::bake_navigation_mesh(bool p_on_thread) {
NavigationServer3D::get_singleton()->parse_source_geometry_data(navigation_mesh, source_geometry_data, this);
if (p_on_thread) {
NavigationServer3D::get_singleton()->bake_from_source_geometry_data_async(navigation_mesh, source_geometry_data, callable_mp(this, &NavigationRegion3D::_bake_finished).bind(navigation_mesh));
NavigationServer3D::get_singleton()->bake_from_source_geometry_data_async(navigation_mesh, source_geometry_data, callable_mp(this, &NavigationRegion3D::_bake_finished));
} else {
NavigationServer3D::get_singleton()->bake_from_source_geometry_data(navigation_mesh, source_geometry_data, callable_mp(this, &NavigationRegion3D::_bake_finished).bind(navigation_mesh));
NavigationServer3D::get_singleton()->bake_from_source_geometry_data(navigation_mesh, source_geometry_data, callable_mp(this, &NavigationRegion3D::_bake_finished));
}
}
void NavigationRegion3D::_bake_finished(Ref<NavigationMesh> p_navigation_mesh) {
void NavigationRegion3D::_bake_finished() {
if (!Thread::is_main_thread()) {
callable_mp(this, &NavigationRegion3D::_bake_finished).call_deferred(p_navigation_mesh);
callable_mp(this, &NavigationRegion3D::_bake_finished).call_deferred();
return;
}
set_navigation_mesh(p_navigation_mesh);
emit_signal(SNAME("bake_finished"));
}
@ -349,12 +326,32 @@ bool NavigationRegion3D::_get(const StringName &p_name, Variant &r_ret) const {
#endif // DISABLE_DEPRECATED
void NavigationRegion3D::_navigation_mesh_changed() {
update_gizmos();
update_configuration_warnings();
_update_bounds();
NavigationServer3D::get_singleton()->region_set_navigation_mesh(region, navigation_mesh);
#ifdef DEBUG_ENABLED
if (is_inside_tree() && NavigationServer3D::get_singleton()->get_debug_navigation_enabled()) {
if (navigation_mesh.is_valid()) {
_update_debug_mesh();
_update_debug_edge_connections_mesh();
} else {
if (debug_instance.is_valid()) {
RS::get_singleton()->instance_set_visible(debug_instance, false);
}
if (debug_edge_connections_instance.is_valid()) {
RS::get_singleton()->instance_set_visible(debug_edge_connections_instance, false);
}
}
}
_update_debug_edge_connections_mesh();
#endif // DEBUG_ENABLED
emit_signal(SNAME("navigation_mesh_changed"));
update_gizmos();
update_configuration_warnings();
}
#ifdef DEBUG_ENABLED
@ -503,7 +500,7 @@ void NavigationRegion3D::_update_debug_mesh() {
debug_mesh->clear_surfaces();
Vector<Vector3> vertices = navigation_mesh->get_vertices();
if (vertices.size() == 0) {
if (vertices.is_empty()) {
return;
}
@ -719,7 +716,7 @@ void NavigationRegion3D::_update_debug_edge_connections_mesh() {
vertex_array_ptrw[vertex_array_index++] = right_end_pos;
}
if (vertex_array.size() == 0) {
if (vertex_array.is_empty()) {
return;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_REGION_3D_H
#define NAVIGATION_REGION_3D_H
#pragma once
#include "scene/3d/node_3d.h"
#include "scene/resources/navigation_mesh.h"
@ -107,7 +106,7 @@ public:
/// Bakes the navigation mesh; once done, automatically
/// sets the new navigation mesh and emits a signal
void bake_navigation_mesh(bool p_on_thread);
void _bake_finished(Ref<NavigationMesh> p_navigation_mesh);
void _bake_finished();
bool is_baking() const;
PackedStringArray get_configuration_warnings() const override;
@ -123,5 +122,3 @@ private:
void _region_exit_navigation_map();
void _region_update_transform();
};
#endif // NAVIGATION_REGION_3D_H

View file

@ -131,6 +131,13 @@ void Node3D::_propagate_transform_changed(Node3D *p_origin) {
void Node3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
RID ae = get_accessibility_element();
ERR_FAIL_COND(ae.is_null());
DisplayServer::get_singleton()->accessibility_update_set_role(ae, DisplayServer::AccessibilityRole::ROLE_CONTAINER);
} break;
case NOTIFICATION_ENTER_TREE: {
ERR_MAIN_THREAD_GUARD;
ERR_FAIL_NULL(get_tree());

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NODE_3D_H
#define NODE_3D_H
#pragma once
#include "scene/main/node.h"
#include "scene/resources/3d/world_3d.h"
@ -305,5 +304,3 @@ public:
};
VARIANT_ENUM_CAST(Node3D::RotationEditMode)
#endif // NODE_3D_H

View file

@ -321,13 +321,13 @@ void SphereOccluder3D::_update_arrays(PackedVector3Array &r_vertices, PackedInt3
int point = 0;
for (int j = 0; j <= (RINGS + 1); j++) {
float v = j / float(RINGS + 1);
float w = Math::sin(Math_PI * v);
float y = Math::cos(Math_PI * v);
float w = Math::sin(Math::PI * v);
float y = Math::cos(Math::PI * v);
for (int i = 0; i <= RADIAL_SEGMENTS; i++) {
float u = i / float(RADIAL_SEGMENTS);
float x = Math::cos(u * Math_TAU);
float z = Math::sin(u * Math_TAU);
float x = Math::cos(u * Math::TAU);
float z = Math::sin(u * Math::TAU);
vertex_ptr[vertex_i++] = Vector3(x * w, y, z * w) * radius;
if (i > 0 && j > 0) {
@ -521,7 +521,7 @@ void OccluderInstance3D::_bake_surface(const Transform3D &p_transform, Array p_s
PackedVector3Array vertices = p_surface_arrays[Mesh::ARRAY_VERTEX];
PackedInt32Array indices = p_surface_arrays[Mesh::ARRAY_INDEX];
if (vertices.size() == 0 || indices.size() == 0) {
if (vertices.is_empty() || indices.is_empty()) {
return;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef OCCLUDER_INSTANCE_3D_H
#define OCCLUDER_INSTANCE_3D_H
#pragma once
#include "scene/3d/visual_instance_3d.h"
@ -209,5 +208,3 @@ public:
OccluderInstance3D();
~OccluderInstance3D();
};
#endif // OCCLUDER_INSTANCE_3D_H

View file

@ -154,13 +154,15 @@ void Path3D::_update_debug_mesh() {
bone_array.resize(Mesh::ARRAY_MAX);
bone_array[Mesh::ARRAY_VERTEX] = bones;
_update_debug_path_material();
debug_mesh->clear_surfaces();
debug_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINE_STRIP, ribbon_array);
debug_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_LINES, bone_array);
debug_mesh->surface_set_material(0, debug_material);
debug_mesh->surface_set_material(1, debug_material);
RS::get_singleton()->instance_set_base(debug_instance, debug_mesh->get_rid());
RS::get_singleton()->mesh_surface_set_material(debug_mesh->get_rid(), 0, st->get_debug_paths_material()->get_rid());
RS::get_singleton()->mesh_surface_set_material(debug_mesh->get_rid(), 1, st->get_debug_paths_material()->get_rid());
if (is_inside_tree()) {
RS::get_singleton()->instance_set_scenario(debug_instance, get_world_3d()->get_scenario());
RS::get_singleton()->instance_set_transform(debug_instance, get_global_transform());
@ -168,6 +170,42 @@ void Path3D::_update_debug_mesh() {
}
}
void Path3D::set_debug_custom_color(const Color &p_color) {
debug_custom_color = p_color;
_update_debug_path_material();
}
Ref<StandardMaterial3D> Path3D::get_debug_material() {
return debug_material;
}
const Color &Path3D::get_debug_custom_color() const {
return debug_custom_color;
}
void Path3D::_update_debug_path_material() {
SceneTree *st = SceneTree::get_singleton();
if (!debug_material.is_valid()) {
Ref<StandardMaterial3D> material = memnew(StandardMaterial3D);
debug_material = material;
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
}
Color color = debug_custom_color;
if (color == Color(0.0, 0.0, 0.0)) {
// Use the default debug path color defined in the Project Settings.
color = st->get_debug_paths_color();
}
get_debug_material()->set_albedo(color);
emit_signal(SNAME("debug_color_changed"));
}
void Path3D::_curve_changed() {
if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
update_gizmos();
@ -214,9 +252,16 @@ void Path3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path3D::set_curve);
ClassDB::bind_method(D_METHOD("get_curve"), &Path3D::get_curve);
ClassDB::bind_method(D_METHOD("set_debug_custom_color", "debug_custom_color"), &Path3D::set_debug_custom_color);
ClassDB::bind_method(D_METHOD("get_debug_custom_color"), &Path3D::get_debug_custom_color);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_curve", "get_curve");
ADD_GROUP("Debug Shape", "debug_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_custom_color"), "set_debug_custom_color", "get_debug_custom_color");
ADD_SIGNAL(MethodInfo("curve_changed"));
ADD_SIGNAL(MethodInfo("debug_color_changed"));
}
void PathFollow3D::update_transform() {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PATH_3D_H
#define PATH_3D_H
#pragma once
#include "scene/3d/node_3d.h"
#include "scene/resources/curve.h"
@ -40,11 +39,14 @@ class Path3D : public Node3D {
private:
Ref<Curve3D> curve;
RID debug_instance;
Color debug_custom_color;
Ref<ArrayMesh> debug_mesh;
Ref<Material> debug_material;
Callable update_callback; // Used only by CSG currently.
void _update_debug_mesh();
void _update_debug_path_material();
void _curve_changed();
protected:
@ -58,6 +60,14 @@ public:
void set_curve(const Ref<Curve3D> &p_curve);
Ref<Curve3D> get_curve() const;
const Color &get_debug_custom_color() const;
void set_debug_custom_color(const Color &p_color);
bool get_debug_show() const;
void set_debug_show(bool p_show);
Ref<StandardMaterial3D> get_debug_material();
Path3D();
~Path3D();
};
@ -131,5 +141,3 @@ public:
};
VARIANT_ENUM_CAST(PathFollow3D::RotationMode);
#endif // PATH_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef ANIMATABLE_BODY_3D_H
#define ANIMATABLE_BODY_3D_H
#pragma once
#include "scene/3d/physics/static_body_3d.h"
@ -63,5 +62,3 @@ private:
void set_sync_to_physics(bool p_enable);
bool is_sync_to_physics_enabled() const;
};
#endif // ANIMATABLE_BODY_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AREA_3D_H
#define AREA_3D_H
#pragma once
#include "core/templates/vset.h"
#include "scene/3d/physics/collision_object_3d.h"
@ -231,5 +230,3 @@ public:
};
VARIANT_ENUM_CAST(Area3D::SpaceOverride);
#endif // AREA_3D_H

View file

@ -219,7 +219,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
// Avoid to move forward on a wall if floor_block_on_wall is true.
// Applies only when the motion angle is under 90 degrees,
// in order to avoid blocking lateral motion along a wall.
if (motion_angle < .5 * Math_PI) {
if (motion_angle < .5 * Math::PI) {
apply_default_sliding = false;
if (p_was_on_floor && !vel_dir_facing_up) {
// Cancel the motion.
@ -569,7 +569,7 @@ void CharacterBody3D::_set_collision_direction(const PhysicsServer3D::MotionResu
wall_normal = collision.normal;
// Don't apply wall velocity when the collider is a CharacterBody3D.
if (Object::cast_to<CharacterBody3D>(ObjectDB::get_instance(collision.collider_id)) == nullptr) {
if (ObjectDB::get_instance<CharacterBody3D>(collision.collider_id) == nullptr) {
_set_platform_data(collision);
}
}
@ -717,7 +717,7 @@ Ref<KinematicCollision3D> CharacterBody3D::_get_slide_collision(int p_bounce) {
}
Ref<KinematicCollision3D> CharacterBody3D::_get_last_slide_collision() {
if (motion_results.size() == 0) {
if (motion_results.is_empty()) {
return Ref<KinematicCollision3D>();
}
return _get_slide_collision(motion_results.size() - 1);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CHARACTER_BODY_3D_H
#define CHARACTER_BODY_3D_H
#pragma once
#include "scene/3d/physics/kinematic_collision_3d.h"
#include "scene/3d/physics/physics_body_3d.h"
@ -185,5 +184,3 @@ protected:
VARIANT_ENUM_CAST(CharacterBody3D::MotionMode);
VARIANT_ENUM_CAST(CharacterBody3D::PlatformOnLeave);
#endif // CHARACTER_BODY_3D_H

View file

@ -519,7 +519,7 @@ uint32_t CollisionObject3D::create_shape_owner(Object *p_owner) {
ShapeData sd;
uint32_t id;
if (shapes.size() == 0) {
if (shapes.is_empty()) {
id = 0;
} else {
id = shapes.back()->key() + 1;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COLLISION_OBJECT_3D_H
#define COLLISION_OBJECT_3D_H
#pragma once
#include "scene/3d/camera_3d.h"
#include "scene/3d/node_3d.h"
@ -180,5 +179,3 @@ public:
};
VARIANT_ENUM_CAST(CollisionObject3D::DisableMode);
#endif // COLLISION_OBJECT_3D_H

View file

@ -41,12 +41,12 @@ void CollisionPolygon3D::_build_polygon() {
collision_object->shape_owner_clear_shapes(owner_id);
if (polygon.size() == 0) {
if (polygon.is_empty()) {
return;
}
Vector<Vector<Vector2>> decomp = Geometry2D::decompose_polygon_in_convex(polygon);
if (decomp.size() == 0) {
if (decomp.is_empty()) {
return;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COLLISION_POLYGON_3D_H
#define COLLISION_POLYGON_3D_H
#pragma once
#include "scene/3d/node_3d.h"
@ -94,5 +93,3 @@ public:
CollisionPolygon3D();
};
#endif // COLLISION_POLYGON_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COLLISION_SHAPE_3D_H
#define COLLISION_SHAPE_3D_H
#pragma once
#include "scene/3d/node_3d.h"
#include "scene/resources/3d/shape_3d.h"
@ -90,5 +89,3 @@ public:
CollisionShape3D();
~CollisionShape3D();
};
#endif // COLLISION_SHAPE_3D_H

View file

@ -87,8 +87,8 @@ void ConeTwistJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, Phys
}
ConeTwistJoint3D::ConeTwistJoint3D() {
params[PARAM_SWING_SPAN] = Math_PI * 0.25;
params[PARAM_TWIST_SPAN] = Math_PI;
params[PARAM_SWING_SPAN] = Math::PI * 0.25;
params[PARAM_TWIST_SPAN] = Math::PI;
params[PARAM_BIAS] = 0.3;
params[PARAM_SOFTNESS] = 0.8;
params[PARAM_RELAXATION] = 1.0;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CONE_TWIST_JOINT_3D_H
#define CONE_TWIST_JOINT_3D_H
#pragma once
#include "scene/3d/physics/joints/joint_3d.h"
@ -59,5 +58,3 @@ public:
};
VARIANT_ENUM_CAST(ConeTwistJoint3D::Param);
#endif // CONE_TWIST_JOINT_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GENERIC_6DOF_JOINT_3D_H
#define GENERIC_6DOF_JOINT_3D_H
#pragma once
#include "scene/3d/physics/joints/joint_3d.h"
@ -108,5 +107,3 @@ public:
VARIANT_ENUM_CAST(Generic6DOFJoint3D::Param);
VARIANT_ENUM_CAST(Generic6DOFJoint3D::Flag);
#endif // GENERIC_6DOF_JOINT_3D_H

View file

@ -122,8 +122,8 @@ void HingeJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsB
HingeJoint3D::HingeJoint3D() {
params[PARAM_BIAS] = 0.3;
params[PARAM_LIMIT_UPPER] = Math_PI * 0.5;
params[PARAM_LIMIT_LOWER] = -Math_PI * 0.5;
params[PARAM_LIMIT_UPPER] = Math::PI * 0.5;
params[PARAM_LIMIT_LOWER] = -Math::PI * 0.5;
params[PARAM_LIMIT_BIAS] = 0.3;
params[PARAM_LIMIT_SOFTNESS] = 0.9;
params[PARAM_LIMIT_RELAXATION] = 1.0;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef HINGE_JOINT_3D_H
#define HINGE_JOINT_3D_H
#pragma once
#include "scene/3d/physics/joints/joint_3d.h"
@ -73,5 +72,3 @@ public:
VARIANT_ENUM_CAST(HingeJoint3D::Param);
VARIANT_ENUM_CAST(HingeJoint3D::Flag);
#endif // HINGE_JOINT_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef JOINT_3D_H
#define JOINT_3D_H
#pragma once
#include "scene/3d/node_3d.h"
#include "scene/3d/physics/physics_body_3d.h"
@ -81,5 +80,3 @@ public:
Joint3D();
~Joint3D();
};
#endif // JOINT_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PIN_JOINT_3D_H
#define PIN_JOINT_3D_H
#pragma once
#include "scene/3d/physics/joints/joint_3d.h"
@ -56,5 +55,3 @@ public:
};
VARIANT_ENUM_CAST(PinJoint3D::Param);
#endif // PIN_JOINT_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SLIDER_JOINT_3D_H
#define SLIDER_JOINT_3D_H
#pragma once
#include "scene/3d/physics/joints/joint_3d.h"
@ -78,5 +77,3 @@ public:
};
VARIANT_ENUM_CAST(SliderJoint3D::Param);
#endif // SLIDER_JOINT_3D_H

View file

@ -66,7 +66,7 @@ real_t KinematicCollision3D::get_angle(int p_collision_index, const Vector3 &p_u
Object *KinematicCollision3D::get_local_shape(int p_collision_index) const {
ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, nullptr);
PhysicsBody3D *owner = Object::cast_to<PhysicsBody3D>(ObjectDB::get_instance(owner_id));
PhysicsBody3D *owner = ObjectDB::get_instance<PhysicsBody3D>(owner_id);
if (!owner) {
return nullptr;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef KINEMATIC_COLLISION_3D_H
#define KINEMATIC_COLLISION_3D_H
#pragma once
#include "core/object/ref_counted.h"
#include "servers/physics_server_3d.h"
@ -61,5 +60,3 @@ public:
int get_collider_shape_index(int p_collision_index = 0) const;
Vector3 get_collider_velocity(int p_collision_index = 0) const;
};
#endif // KINEMATIC_COLLISION_3D_H

View file

@ -30,7 +30,7 @@
#include "physical_bone_3d.h"
#include "scene/3d/physical_bone_simulator_3d.h"
#include "scene/3d/physics/physical_bone_simulator_3d.h"
#ifndef DISABLE_DEPRECATED
#include "scene/3d/skeleton_3d.h"
#endif //_DISABLE_DEPRECATED
@ -752,8 +752,9 @@ void PhysicalBone3D::_get_property_list(List<PropertyInfo> *p_list) const {
void PhysicalBone3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_PARENTED:
// We need to wait until the bone has finished being added to the tree
// or none of the global transform calls will work correctly.
case NOTIFICATION_POST_ENTER_TREE:
_update_simulator_path();
update_bone_id();
reset_to_rest_position();
@ -763,6 +764,9 @@ void PhysicalBone3D::_notification(int p_what) {
}
break;
// If we're detached from the skeleton we need to
// clear our references to it.
case NOTIFICATION_UNPARENTED:
case NOTIFICATION_EXIT_TREE: {
PhysicalBoneSimulator3D *simulator = get_simulator();
if (simulator) {
@ -1052,7 +1056,7 @@ void PhysicalBone3D::_update_simulator_path() {
}
PhysicalBoneSimulator3D *PhysicalBone3D::get_simulator() const {
return Object::cast_to<PhysicalBoneSimulator3D>(ObjectDB::get_instance(simulator_id));
return ObjectDB::get_instance<PhysicalBoneSimulator3D>(simulator_id);
}
Skeleton3D *PhysicalBone3D::get_skeleton() const {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICAL_BONE_3D_H
#define PHYSICAL_BONE_3D_H
#pragma once
#include "scene/3d/physics/physics_body_3d.h"
#include "scene/3d/skeleton_3d.h"
@ -84,8 +83,8 @@ public:
virtual bool _get(const StringName &p_name, Variant &r_ret) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
real_t swing_span = Math_PI * 0.25;
real_t twist_span = Math_PI;
real_t swing_span = Math::PI * 0.25;
real_t twist_span = Math::PI;
real_t bias = 0.3;
real_t softness = 0.8;
real_t relaxation = 1.;
@ -99,8 +98,8 @@ public:
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
bool angular_limit_enabled = false;
real_t angular_limit_upper = Math_PI * 0.5;
real_t angular_limit_lower = -Math_PI * 0.5;
real_t angular_limit_upper = Math::PI * 0.5;
real_t angular_limit_lower = -Math::PI * 0.5;
real_t angular_limit_bias = 0.3;
real_t angular_limit_softness = 0.9;
real_t angular_limit_relaxation = 1.;
@ -307,5 +306,3 @@ private:
VARIANT_ENUM_CAST(PhysicalBone3D::JointType);
VARIANT_ENUM_CAST(PhysicalBone3D::DampMode);
#endif // PHYSICAL_BONE_3D_H

View file

@ -73,9 +73,14 @@ void PhysicalBoneSimulator3D::_pose_updated() {
if (!skeleton || simulating) {
return;
}
ERR_FAIL_COND(skeleton->get_bone_count() != bones.size());
for (int i = 0; i < skeleton->get_bone_count(); i++) {
_bone_pose_updated(skeleton, i);
// If this triggers that means that we likely haven't rebuilt the bone list yet.
if (skeleton->get_bone_count() != bones.size()) {
// NOTE: this is re-entrant and will call _pose_updated again.
_bone_list_changed();
} else {
for (int i = 0; i < skeleton->get_bone_count(); i++) {
_bone_pose_updated(skeleton, i);
}
}
}
@ -359,7 +364,7 @@ void PhysicalBoneSimulator3D::set_bone_global_pose(int p_bone, const Transform3D
bones.write[p_bone].global_pose = p_pose;
}
void PhysicalBoneSimulator3D::_process_modification() {
void PhysicalBoneSimulator3D::_process_modification(double p_delta) {
Skeleton3D *skeleton = get_skeleton();
if (!skeleton) {
return;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICAL_BONE_SIMULATOR_3D_H
#define PHYSICAL_BONE_SIMULATOR_3D_H
#pragma once
#include "scene/3d/skeleton_modifier_3d.h"
@ -73,7 +72,7 @@ protected:
void _pose_updated();
void _bone_pose_updated(Skeleton3D *skeleton, int p_bone_id);
virtual void _process_modification() override;
virtual void _process_modification(double p_delta) override;
virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new) override;
@ -104,5 +103,3 @@ public:
PhysicalBoneSimulator3D();
};
#endif // PHYSICAL_BONE_SIMULATOR_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_BODY_3D_H
#define PHYSICS_BODY_3D_H
#pragma once
#include "scene/3d/physics/collision_object_3d.h"
#include "scene/3d/physics/kinematic_collision_3d.h"
@ -65,5 +64,3 @@ public:
void add_collision_exception_with(Node *p_node); //must be physicsbody
void remove_collision_exception_with(Node *p_node);
};
#endif // PHYSICS_BODY_3D_H

View file

@ -413,7 +413,7 @@ void RayCast3D::_update_debug_shape_vertices() {
int vertices_strip_order[14] = { 4, 5, 0, 1, 2, 5, 6, 4, 7, 0, 3, 2, 7, 6 };
for (int v = 0; v < 14; v++) {
Vector3 vertex = vertices_strip_order[v] < 4 ? normal : normal / 3.0 + target_position;
debug_shape_vertices.push_back(vertex.rotated(dir, Math_PI * (0.5 * (vertices_strip_order[v] % 4) + 0.25)));
debug_shape_vertices.push_back(vertex.rotated(dir, Math::PI * (0.5 * (vertices_strip_order[v] % 4) + 0.25)));
}
}
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RAY_CAST_3D_H
#define RAY_CAST_3D_H
#pragma once
#include "scene/3d/node_3d.h"
@ -135,5 +134,3 @@ public:
RayCast3D();
};
#endif // RAY_CAST_3D_H

View file

@ -521,6 +521,7 @@ bool RigidBody3D::is_sleeping() const {
}
void RigidBody3D::set_max_contacts_reported(int p_amount) {
ERR_FAIL_INDEX_MSG(p_amount, MAX_CONTACTS_REPORTED_3D_MAX, "Max contacts reported allocates memory (about 80 bytes each), and therefore must not be set too high.");
max_contacts_reported = p_amount;
PhysicsServer3D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
}
@ -662,7 +663,7 @@ PackedStringArray RigidBody3D::get_configuration_warnings() const {
PackedStringArray warnings = PhysicsBody3D::get_configuration_warnings();
Vector3 scale = get_transform().get_basis().get_scale();
if (ABS(scale.x - 1.0) > 0.05 || ABS(scale.y - 1.0) > 0.05 || ABS(scale.z - 1.0) > 0.05) {
if (Math::abs(scale.x - 1.0) > 0.05 || Math::abs(scale.y - 1.0) > 0.05 || Math::abs(scale.z - 1.0) > 0.05) {
warnings.push_back(RTR("Scale changes to RigidBody3D will be overridden by the physics engine when running.\nPlease change the size in children collision shapes instead."));
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RIGID_BODY_3D_H
#define RIGID_BODY_3D_H
#pragma once
#include "core/templates/vset.h"
#include "scene/3d/physics/physics_body_3d.h"
@ -245,5 +244,3 @@ private:
VARIANT_ENUM_CAST(RigidBody3D::FreezeMode);
VARIANT_ENUM_CAST(RigidBody3D::CenterOfMassMode);
VARIANT_ENUM_CAST(RigidBody3D::DampMode);
#endif // RIGID_BODY_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SHAPE_CAST_3D_H
#define SHAPE_CAST_3D_H
#pragma once
#include "scene/3d/node_3d.h"
#include "scene/resources/3d/shape_3d.h"
@ -143,5 +142,3 @@ public:
virtual PackedStringArray get_configuration_warnings() const override;
};
#endif // SHAPE_CAST_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SOFT_BODY_3D_H
#define SOFT_BODY_3D_H
#pragma once
#include "scene/3d/mesh_instance_3d.h"
#include "servers/physics_server_3d.h"
@ -206,5 +205,3 @@ private:
};
VARIANT_ENUM_CAST(SoftBody3D::DisableMode);
#endif // SOFT_BODY_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPRING_ARM_3D_H
#define SPRING_ARM_3D_H
#pragma once
#include "scene/3d/node_3d.h"
@ -67,5 +66,3 @@ public:
private:
void process_spring();
};
#endif // SPRING_ARM_3D_H

View file

@ -30,6 +30,7 @@
#include "static_body_3d.h"
#ifndef NAVIGATION_3D_DISABLED
#include "core/math/convex_hull.h"
#include "scene/resources/3d/box_shape_3d.h"
#include "scene/resources/3d/capsule_shape_3d.h"
@ -47,6 +48,7 @@
Callable StaticBody3D::_navmesh_source_geometry_parsing_callback;
RID StaticBody3D::_navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
void StaticBody3D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) {
@ -95,6 +97,7 @@ void StaticBody3D::_reload_physics_characteristics() {
}
}
#ifndef NAVIGATION_3D_DISABLED
void StaticBody3D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -226,6 +229,7 @@ void StaticBody3D::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_na
}
}
}
#endif // NAVIGATION_3D_DISABLED
void StaticBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "vel"), &StaticBody3D::set_constant_linear_velocity);

View file

@ -28,13 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef STATIC_BODY_3D_H
#define STATIC_BODY_3D_H
#pragma once
#include "scene/3d/physics/physics_body_3d.h"
#ifndef NAVIGATION_3D_DISABLED
class NavigationMesh;
class NavigationMeshSourceGeometryData3D;
#endif // NAVIGATION_3D_DISABLED
class StaticBody3D : public PhysicsBody3D {
GDCLASS(StaticBody3D, PhysicsBody3D);
@ -63,12 +64,12 @@ public:
private:
void _reload_physics_characteristics();
#ifndef NAVIGATION_3D_DISABLED
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
public:
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_3D_DISABLED
};
#endif // STATIC_BODY_3D_H

View file

@ -852,18 +852,26 @@ void VehicleBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
for (int i = 0; i < wheels.size(); i++) {
VehicleWheel3D &wheel = *wheels[i];
Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - p_state->get_transform().origin;
Vector3 vel = p_state->get_linear_velocity() + (p_state->get_angular_velocity()).cross(relpos); // * mPos);
Vector3 vel = p_state->get_linear_velocity() + (p_state->get_angular_velocity()).cross(relpos);
if (wheel.m_raycastInfo.m_isInContact) {
const Transform3D &chassisWorldTransform = p_state->get_transform();
// Get forward vector.
Vector3 fwd(
chassisWorldTransform.basis[0][Vector3::AXIS_Z],
chassisWorldTransform.basis[1][Vector3::AXIS_Z],
chassisWorldTransform.basis[2][Vector3::AXIS_Z]);
// Apply steering rotation to forward vector for steerable wheels.
if (wheel.steers) {
Basis steering_mat(Vector3(0, 1, 0), wheel.m_steering);
fwd = steering_mat.xform(fwd);
}
real_t proj = fwd.dot(wheel.m_raycastInfo.m_contactNormalWS);
fwd -= wheel.m_raycastInfo.m_contactNormalWS * proj;
fwd.normalize();
real_t proj2 = fwd.dot(vel);
@ -871,7 +879,7 @@ void VehicleBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
}
wheel.m_rotation += wheel.m_deltaRotation;
wheel.m_rpm = ((wheel.m_deltaRotation / step) * 60) / Math_TAU;
wheel.m_rpm = ((wheel.m_deltaRotation / step) * 60) / Math::TAU;
wheel.m_deltaRotation *= real_t(0.99); //damping of rotation when not in contact
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef VEHICLE_BODY_3D_H
#define VEHICLE_BODY_3D_H
#pragma once
#include "scene/3d/physics/physics_body_3d.h"
#include "scene/3d/physics/rigid_body_3d.h"
@ -214,5 +213,3 @@ public:
VehicleBody3D();
};
#endif // VEHICLE_BODY_3D_H

View file

@ -105,7 +105,7 @@ void ReflectionProbe::set_size(const Vector3 &p_size) {
half_size = 0.01;
}
if (half_size - 0.01 < ABS(origin_offset[i])) {
if (half_size - 0.01 < Math::abs(origin_offset[i])) {
origin_offset[i] = SIGN(origin_offset[i]) * (half_size - 0.01);
}
}
@ -125,7 +125,7 @@ void ReflectionProbe::set_origin_offset(const Vector3 &p_offset) {
for (int i = 0; i < 3; i++) {
float half_size = size[i] / 2;
if (half_size - 0.01 < ABS(origin_offset[i])) {
if (half_size - 0.01 < Math::abs(origin_offset[i])) {
origin_offset[i] = SIGN(origin_offset[i]) * (half_size - 0.01);
}
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef REFLECTION_PROBE_H
#define REFLECTION_PROBE_H
#pragma once
#include "scene/3d/visual_instance_3d.h"
@ -132,5 +131,3 @@ public:
VARIANT_ENUM_CAST(ReflectionProbe::AmbientMode);
VARIANT_ENUM_CAST(ReflectionProbe::UpdateMode);
#endif // REFLECTION_PROBE_H

View file

@ -51,58 +51,50 @@ void RemoteTransform3D::_update_remote() {
return;
}
Node3D *n = Object::cast_to<Node3D>(ObjectDB::get_instance(cache));
if (!n) {
Node3D *target_node = ObjectDB::get_instance<Node3D>(cache);
if (!target_node) {
return;
}
if (!n->is_inside_tree()) {
if (!target_node->is_inside_tree()) {
return;
}
//todo make faster
if (use_global_coordinates) {
if (update_remote_position && update_remote_rotation && update_remote_scale) {
n->set_global_transform(get_global_transform());
Transform3D our_trans = use_global_coordinates ? get_global_transform() : get_transform();
if (update_remote_position && update_remote_rotation && update_remote_scale) {
if (use_global_coordinates) {
target_node->set_global_transform(our_trans);
} else {
Transform3D our_trans = get_global_transform();
target_node->set_transform(our_trans);
}
} else {
Transform3D target_trans = use_global_coordinates ? target_node->get_global_transform() : target_node->get_transform();
if (update_remote_rotation) {
n->set_rotation(our_trans.basis.get_euler_normalized(EulerOrder(n->get_rotation_order())));
if (update_remote_rotation && update_remote_scale) {
target_trans.basis = our_trans.basis;
} else if (update_remote_rotation) {
for (int i = 0; i < 3; i++) {
Vector3 our_col = our_trans.basis.get_column(i);
Vector3 target_col = target_trans.basis.get_column(i);
target_trans.basis.set_column(i, our_col.normalized() * target_col.length());
}
if (update_remote_scale) {
n->set_scale(our_trans.basis.get_scale());
}
if (update_remote_position) {
Transform3D n_trans = n->get_global_transform();
n_trans.set_origin(our_trans.get_origin());
n->set_global_transform(n_trans);
} else if (update_remote_scale) {
for (int i = 0; i < 3; i++) {
Vector3 our_col = our_trans.basis.get_column(i);
Vector3 target_col = target_trans.basis.get_column(i);
target_trans.basis.set_column(i, target_col.normalized() * our_col.length());
}
}
} else {
if (update_remote_position && update_remote_rotation && update_remote_scale) {
n->set_transform(get_transform());
if (update_remote_position) {
target_trans.origin = our_trans.origin;
}
if (use_global_coordinates) {
target_node->set_global_transform(target_trans);
} else {
Transform3D our_trans = get_transform();
if (update_remote_rotation) {
n->set_rotation(our_trans.basis.get_euler_normalized(EulerOrder(n->get_rotation_order())));
}
if (update_remote_scale) {
n->set_scale(our_trans.basis.get_scale());
}
if (update_remote_position) {
Transform3D n_trans = n->get_transform();
n_trans.set_origin(our_trans.get_origin());
n->set_transform(n_trans);
}
target_node->set_transform(target_trans);
}
}
}
@ -116,7 +108,7 @@ void RemoteTransform3D::_notification(int p_what) {
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
if (cache.is_valid()) {
_update_remote();
Node3D *n = Object::cast_to<Node3D>(ObjectDB::get_instance(cache));
Node3D *n = ObjectDB::get_instance<Node3D>(cache);
if (n) {
n->reset_physics_interpolation();
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef REMOTE_TRANSFORM_3D_H
#define REMOTE_TRANSFORM_3D_H
#pragma once
#include "scene/3d/node_3d.h"
@ -74,5 +73,3 @@ public:
RemoteTransform3D();
};
#endif // REMOTE_TRANSFORM_3D_H

View file

@ -161,7 +161,7 @@ Vector<RetargetModifier3D::RetargetBoneInfo> RetargetModifier3D::cache_bone_rest
void RetargetModifier3D::_update_child_skeleton_rests(int p_child_skeleton_idx) {
ERR_FAIL_INDEX(p_child_skeleton_idx, child_skeletons.size());
Skeleton3D *c = Object::cast_to<Skeleton3D>(ObjectDB::get_instance(child_skeletons[p_child_skeleton_idx].skeleton_id));
Skeleton3D *c = ObjectDB::get_instance<Skeleton3D>(child_skeletons[p_child_skeleton_idx].skeleton_id);
if (!c) {
return;
}
@ -192,7 +192,7 @@ void RetargetModifier3D::_update_child_skeletons() {
void RetargetModifier3D::_reset_child_skeleton_poses() {
for (const RetargetInfo &E : child_skeletons) {
Skeleton3D *c = Object::cast_to<Skeleton3D>(ObjectDB::get_instance(E.skeleton_id));
Skeleton3D *c = ObjectDB::get_instance<Skeleton3D>(E.skeleton_id);
if (!c) {
continue;
}
@ -216,7 +216,7 @@ void RetargetModifier3D::_reset_child_skeletons() {
#ifdef TOOLS_ENABLED
void RetargetModifier3D::_force_update_child_skeletons() {
for (const RetargetInfo &E : child_skeletons) {
Skeleton3D *c = Object::cast_to<Skeleton3D>(ObjectDB::get_instance(E.skeleton_id));
Skeleton3D *c = ObjectDB::get_instance<Skeleton3D>(E.skeleton_id);
if (!c) {
continue;
}
@ -304,7 +304,7 @@ void RetargetModifier3D::_retarget_global_pose() {
}
for (const RetargetInfo &E : child_skeletons) {
Skeleton3D *target_skeleton = Object::cast_to<Skeleton3D>(ObjectDB::get_instance(E.skeleton_id));
Skeleton3D *target_skeleton = ObjectDB::get_instance<Skeleton3D>(E.skeleton_id);
if (!target_skeleton) {
continue;
}
@ -338,7 +338,7 @@ void RetargetModifier3D::_retarget_pose() {
}
for (const RetargetInfo &E : child_skeletons) {
Skeleton3D *target_skeleton = Object::cast_to<Skeleton3D>(ObjectDB::get_instance(E.skeleton_id));
Skeleton3D *target_skeleton = ObjectDB::get_instance<Skeleton3D>(E.skeleton_id);
if (!target_skeleton) {
continue;
}
@ -370,7 +370,7 @@ void RetargetModifier3D::_retarget_pose() {
}
}
void RetargetModifier3D::_process_modification() {
void RetargetModifier3D::_process_modification(double p_delta) {
if (use_global_pose) {
_retarget_global_pose();
} else {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RETARGET_MODIFIER_3D_H
#define RETARGET_MODIFIER_3D_H
#pragma once
#include "scene/3d/skeleton_modifier_3d.h"
#include "scene/resources/skeleton_profile.h"
@ -97,7 +96,7 @@ protected:
virtual void remove_child_notify(Node *p_child) override;
virtual void _set_active(bool p_active) override;
virtual void _process_modification() override;
virtual void _process_modification(double p_delta) override;
public:
virtual PackedStringArray get_configuration_warnings() const override;
@ -126,5 +125,3 @@ public:
};
VARIANT_BITFIELD_CAST(RetargetModifier3D::TransformFlag);
#endif // RETARGET_MODIFIER_3D_H

View file

@ -32,9 +32,9 @@
#include "skeleton_3d.compat.inc"
#include "scene/3d/skeleton_modifier_3d.h"
#ifndef DISABLE_DEPRECATED
#include "scene/3d/physical_bone_simulator_3d.h"
#endif // _DISABLE_DEPRECATED
#if !defined(DISABLE_DEPRECATED) && !defined(PHYSICS_3D_DISABLED)
#include "scene/3d/physics/physical_bone_simulator_3d.h"
#endif // _DISABLE_DEPRECATED && PHYSICS_3D_DISABLED
void SkinReference::_skin_changed() {
if (skeleton_node) {
@ -67,12 +67,12 @@ SkinReference::~SkinReference() {
///////////////////////////////////////
bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
#ifndef DISABLE_DEPRECATED
#if !defined(DISABLE_DEPRECATED) && !defined(PHYSICS_3D_DISABLED)
if (p_path == SNAME("animate_physical_bones")) {
set_animate_physical_bones(p_value);
return true;
}
#endif
#endif // _DISABLE_DEPRECATED && PHYSICS_3D_DISABLED
String path = p_path;
if (!path.begins_with("bones/")) {
@ -139,12 +139,12 @@ bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) {
}
bool Skeleton3D::_get(const StringName &p_path, Variant &r_ret) const {
#ifndef DISABLE_DEPRECATED
#if !defined(DISABLE_DEPRECATED) && !defined(PHYSICS_3D_DISABLED)
if (p_path == SNAME("animate_physical_bones")) {
r_ret = get_animate_physical_bones();
return true;
}
#endif
#endif // _DISABLE_DEPRECATED && PHYSICS_3D_DISABLED
String path = p_path;
if (!path.begins_with("bones/")) {
@ -297,7 +297,7 @@ StringName Skeleton3D::get_concatenated_bone_names() const {
return concatenated_bone_names;
}
#ifndef DISABLE_DEPRECATED
#if !defined(DISABLE_DEPRECATED) && !defined(PHYSICS_3D_DISABLED)
void Skeleton3D::setup_simulator() {
if (simulator && simulator->get_parent() == this) {
remove_child(simulator);
@ -310,7 +310,7 @@ void Skeleton3D::setup_simulator() {
add_child(simulator, false, INTERNAL_MODE_BACK);
set_animate_physical_bones(animate_physical_bones);
}
#endif // _DISABLE_DEPRECATED
#endif // _DISABLE_DEPRECATED && PHYSICS_3D_DISABLED
void Skeleton3D::_notification(int p_what) {
switch (p_what) {
@ -319,9 +319,9 @@ void Skeleton3D::_notification(int p_what) {
_make_dirty();
_make_modifiers_dirty();
force_update_all_dirty_bones();
#ifndef DISABLE_DEPRECATED
#if !defined(DISABLE_DEPRECATED) && !defined(PHYSICS_3D_DISABLED)
setup_simulator();
#endif // _DISABLE_DEPRECATED
#endif // _DISABLE_DEPRECATED && PHYSICS_3D_DISABLED
update_flags = UPDATE_FLAG_POSE;
_notification(NOTIFICATION_UPDATE_SKELETON);
} break;
@ -357,7 +357,9 @@ void Skeleton3D::_notification(int p_what) {
// Store dirty flags for global bone poses.
bone_global_pose_dirty_backup = bone_global_pose_dirty;
_process_modifiers();
if (update_flags & UPDATE_FLAG_MODIFIER) {
_process_modifiers();
}
}
// Abort if pose is not changed.
@ -438,13 +440,20 @@ void Skeleton3D::_notification(int p_what) {
updating = false;
update_flags = UPDATE_FLAG_NONE;
} break;
case NOTIFICATION_INTERNAL_PROCESS:
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
_find_modifiers();
if (!modifiers.is_empty()) {
_update_deferred(UPDATE_FLAG_MODIFIER);
}
case NOTIFICATION_INTERNAL_PROCESS: {
advance(get_process_delta_time());
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
advance(get_physics_process_delta_time());
} break;
}
}
void Skeleton3D::advance(double p_delta) {
_find_modifiers();
if (!modifiers.is_empty()) {
update_delta += p_delta; // Accumulate delta for manual advance as it needs to process in deferred update.
_update_deferred(UPDATE_FLAG_MODIFIER);
}
}
@ -467,6 +476,9 @@ void Skeleton3D::_process_changed() {
} else if (modifier_callback_mode_process == MODIFIER_CALLBACK_MODE_PROCESS_PHYSICS) {
set_process_internal(false);
set_physics_process_internal(true);
} else {
set_process_internal(false);
set_physics_process_internal(false);
}
}
@ -838,6 +850,13 @@ bool Skeleton3D::is_show_rest_only() const {
void Skeleton3D::clear_bones() {
bones.clear();
name_to_bone_index.clear();
// All these structures contain references to now invalid bone indices.
skin_bindings.clear();
bone_global_pose_dirty.clear();
parentless_bones.clear();
nested_set_offset_to_bone_index.clear();
process_order_dirty = true;
version++;
_make_dirty();
@ -1091,6 +1110,8 @@ void Skeleton3D::_force_update_bone_children_transforms(int p_bone_idx) const {
const int bone_size = bones.size();
ERR_FAIL_INDEX(p_bone_idx, bone_size);
_update_process_order();
Bone *bonesptr = bones.ptr();
// Loop through nested set.
@ -1185,7 +1206,7 @@ void Skeleton3D::_process_modifiers() {
for (int i = 0; i < get_bone_count(); i++) {
old_poses.push_back(get_bone_pose(i));
}
mod->process_modification();
mod->process_modification(update_delta);
LocalVector<Transform3D> new_poses;
for (int i = 0; i < get_bone_count(); i++) {
new_poses.push_back(get_bone_pose(i));
@ -1197,10 +1218,11 @@ void Skeleton3D::_process_modifiers() {
set_bone_pose(i, old_poses[i].interpolate_with(new_poses[i], influence));
}
} else {
mod->process_modification();
mod->process_modification(update_delta);
}
force_update_all_dirty_bones();
}
update_delta = 0; // Reset accumulated delta.
}
void Skeleton3D::add_child_notify(Node *p_child) {
@ -1288,11 +1310,13 @@ void Skeleton3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_modifier_callback_mode_process", "mode"), &Skeleton3D::set_modifier_callback_mode_process);
ClassDB::bind_method(D_METHOD("get_modifier_callback_mode_process"), &Skeleton3D::get_modifier_callback_mode_process);
ClassDB::bind_method(D_METHOD("advance", "delta"), &Skeleton3D::advance);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "motion_scale", PROPERTY_HINT_RANGE, "0.001,10,0.001,or_greater"), "set_motion_scale", "get_motion_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_rest_only"), "set_show_rest_only", "is_show_rest_only");
ADD_GROUP("Modifier", "modifier_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "modifier_callback_mode_process", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_modifier_callback_mode_process", "get_modifier_callback_mode_process");
ADD_PROPERTY(PropertyInfo(Variant::INT, "modifier_callback_mode_process", PROPERTY_HINT_ENUM, "Physics,Idle,Manual"), "set_modifier_callback_mode_process", "get_modifier_callback_mode_process");
ADD_SIGNAL(MethodInfo("rest_updated"));
ADD_SIGNAL(MethodInfo("pose_updated"));
@ -1304,6 +1328,7 @@ void Skeleton3D::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_UPDATE_SKELETON);
BIND_ENUM_CONSTANT(MODIFIER_CALLBACK_MODE_PROCESS_PHYSICS);
BIND_ENUM_CONSTANT(MODIFIER_CALLBACK_MODE_PROCESS_IDLE);
BIND_ENUM_CONSTANT(MODIFIER_CALLBACK_MODE_PROCESS_MANUAL);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("clear_bones_global_pose_override"), &Skeleton3D::clear_bones_global_pose_override);
@ -1311,6 +1336,7 @@ void Skeleton3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_bone_global_pose_override", "bone_idx"), &Skeleton3D::get_bone_global_pose_override);
ClassDB::bind_method(D_METHOD("get_bone_global_pose_no_override", "bone_idx"), &Skeleton3D::get_bone_global_pose_no_override);
#ifndef PHYSICS_3D_DISABLED
ClassDB::bind_method(D_METHOD("set_animate_physical_bones", "enabled"), &Skeleton3D::set_animate_physical_bones);
ClassDB::bind_method(D_METHOD("get_animate_physical_bones"), &Skeleton3D::get_animate_physical_bones);
ClassDB::bind_method(D_METHOD("physical_bones_stop_simulation"), &Skeleton3D::physical_bones_stop_simulation);
@ -1320,6 +1346,7 @@ void Skeleton3D::_bind_methods() {
ADD_GROUP("Deprecated", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "animate_physical_bones"), "set_animate_physical_bones", "get_animate_physical_bones");
#endif // PHYSICS_3D_DISABLED
#endif // _DISABLE_DEPRECATED
}
@ -1356,6 +1383,7 @@ Transform3D Skeleton3D::get_bone_global_pose_no_override(int p_bone) const {
return bones[p_bone].pose_global_no_override;
}
#ifndef PHYSICS_3D_DISABLED
Node *Skeleton3D::get_simulator() {
return simulator;
}
@ -1406,6 +1434,7 @@ void Skeleton3D::physical_bones_remove_collision_exception(RID p_exception) {
}
sim->physical_bones_remove_collision_exception(p_exception);
}
#endif // PHYSICS_3D_DISABLED
#endif // _DISABLE_DEPRECATED
Skeleton3D::Skeleton3D() {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SKELETON_3D_H
#define SKELETON_3D_H
#pragma once
#include "core/templates/a_hash_map.h"
#include "scene/3d/node_3d.h"
@ -70,16 +69,17 @@ class Skeleton3D : public Node3D {
bool saving = false;
#endif //TOOLS_ENABLED
#ifndef DISABLE_DEPRECATED
#if !defined(DISABLE_DEPRECATED) && !defined(PHYSICS_3D_DISABLED)
bool animate_physical_bones = true;
Node *simulator = nullptr;
void setup_simulator();
#endif // _DISABLE_DEPRECATED
#endif // _DISABLE_DEPRECATED && PHYSICS_3D_DISABLED
public:
enum ModifierCallbackModeProcess {
MODIFIER_CALLBACK_MODE_PROCESS_PHYSICS,
MODIFIER_CALLBACK_MODE_PROCESS_IDLE,
MODIFIER_CALLBACK_MODE_PROCESS_MANUAL,
};
private:
@ -94,6 +94,7 @@ private:
void _update_deferred(UpdateFlag p_update_flag = UPDATE_FLAG_POSE);
uint8_t update_flags = UPDATE_FLAG_NONE;
bool updating = false; // Is updating now?
double update_delta = 0.0;
struct Bone {
String name;
@ -295,6 +296,8 @@ public:
void set_modifier_callback_mode_process(ModifierCallbackModeProcess p_mode);
ModifierCallbackModeProcess get_modifier_callback_mode_process() const;
void advance(double p_delta);
#ifndef DISABLE_DEPRECATED
Transform3D get_bone_global_pose_no_override(int p_bone) const;
void clear_bones_global_pose_override();
@ -302,12 +305,14 @@ public:
void set_bone_global_pose_override(int p_bone, const Transform3D &p_pose, real_t p_amount, bool p_persistent = false);
Node *get_simulator();
#ifndef PHYSICS_3D_DISABLED
void set_animate_physical_bones(bool p_enabled);
bool get_animate_physical_bones() const;
void physical_bones_stop_simulation();
void physical_bones_start_simulation_on(const TypedArray<StringName> &p_bones);
void physical_bones_add_collision_exception(RID p_exception);
void physical_bones_remove_collision_exception(RID p_exception);
#endif // PHYSICS_3D_DISABLED
#endif // _DISABLE_DEPRECATED
public:
@ -316,5 +321,3 @@ public:
};
VARIANT_ENUM_CAST(Skeleton3D::ModifierCallbackModeProcess);
#endif // SKELETON_3D_H

View file

@ -366,7 +366,7 @@ void SkeletonIK3D::_bind_methods() {
#endif
}
void SkeletonIK3D::_process_modification() {
void SkeletonIK3D::_process_modification(double p_delta) {
if (!internal_active) {
return;
}
@ -485,7 +485,7 @@ bool SkeletonIK3D::is_running() {
void SkeletonIK3D::start(bool p_one_time) {
if (p_one_time) {
internal_active = true;
SkeletonModifier3D::process_modification();
SkeletonModifier3D::process_modification(0);
internal_active = false;
} else {
internal_active = true;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SKELETON_IK_3D_H
#define SKELETON_IK_3D_H
#pragma once
#include "scene/3d/skeleton_modifier_3d.h"
@ -145,7 +144,7 @@ protected:
static void _bind_methods();
virtual void _notification(int p_what);
virtual void _process_modification() override;
virtual void _process_modification(double p_delta) override;
public:
SkeletonIK3D();
@ -191,5 +190,3 @@ private:
void reload_goal();
void _solve_chain();
};
#endif // SKELETON_IK_3D_H

View file

@ -45,7 +45,7 @@ PackedStringArray SkeletonModifier3D::get_configuration_warnings() const {
/* Skeleton3D */
Skeleton3D *SkeletonModifier3D::get_skeleton() const {
return Object::cast_to<Skeleton3D>(ObjectDB::get_instance(skeleton_id));
return ObjectDB::get_instance<Skeleton3D>(skeleton_id);
}
void SkeletonModifier3D::_update_skeleton_path() {
@ -113,16 +113,23 @@ real_t SkeletonModifier3D::get_influence() const {
return influence;
}
void SkeletonModifier3D::process_modification() {
void SkeletonModifier3D::process_modification(double p_delta) {
if (!active) {
return;
}
_process_modification();
_process_modification(p_delta);
emit_signal(SNAME("modification_processed"));
}
void SkeletonModifier3D::_process_modification() {
GDVIRTUAL_CALL(_process_modification);
void SkeletonModifier3D::_process_modification(double p_delta) {
if (GDVIRTUAL_CALL(_process_modification_with_delta, p_delta)) {
return;
}
#ifndef DISABLE_DEPRECATED
if (GDVIRTUAL_CALL(_process_modification)) {
return;
}
#endif // DISABLE_DEPRECATED
}
void SkeletonModifier3D::_notification(int p_what) {
@ -151,7 +158,10 @@ void SkeletonModifier3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "influence", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_influence", "get_influence");
ADD_SIGNAL(MethodInfo("modification_processed"));
GDVIRTUAL_BIND(_process_modification_with_delta, "delta");
#ifndef DISABLE_DEPRECATED
GDVIRTUAL_BIND(_process_modification);
#endif
BIND_ENUM_CONSTANT(BONE_AXIS_PLUS_X);
BIND_ENUM_CONSTANT(BONE_AXIS_MINUS_X);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SKELETON_MODIFIER_3D_H
#define SKELETON_MODIFIER_3D_H
#pragma once
#include "scene/3d/node_3d.h"
@ -69,8 +68,12 @@ protected:
virtual void _set_active(bool p_active);
virtual void _process_modification();
virtual void _process_modification(double p_delta);
// TODO: In Godot 5, should obsolete old GDVIRTUAL0(_process_modification); and replace it with _process_modification_with_delta as GDVIRTUAL1(_process_modification, double).
GDVIRTUAL1(_process_modification_with_delta, double);
#ifndef DISABLE_DEPRECATED
GDVIRTUAL0(_process_modification);
#endif
public:
virtual PackedStringArray get_configuration_warnings() const override;
@ -84,7 +87,7 @@ public:
Skeleton3D *get_skeleton() const;
void process_modification();
void process_modification(double p_delta);
// Utility APIs.
static Vector3 get_vector_from_bone_axis(BoneAxis p_axis);
@ -99,5 +102,3 @@ public:
};
VARIANT_ENUM_CAST(SkeletonModifier3D::BoneAxis);
#endif // SKELETON_MODIFIER_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPRING_BONE_COLLISION_3D_H
#define SPRING_BONE_COLLISION_3D_H
#pragma once
#include "scene/3d/skeleton_3d.h"
@ -68,5 +67,3 @@ public:
Vector3 collide(const Transform3D &p_center, float p_bone_radius, float p_bone_length, const Vector3 &p_current) const;
};
#endif // SPRING_BONE_COLLISION_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPRING_BONE_COLLISION_CAPSULE_3D_H
#define SPRING_BONE_COLLISION_CAPSULE_3D_H
#pragma once
#include "scene/3d/spring_bone_collision_3d.h"
@ -56,5 +55,3 @@ public:
// Helper.
Pair<Vector3, Vector3> get_head_and_tail(const Transform3D &p_center) const;
};
#endif // SPRING_BONE_COLLISION_CAPSULE_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPRING_BONE_COLLISION_PLANE_3D_H
#define SPRING_BONE_COLLISION_PLANE_3D_H
#pragma once
#include "scene/3d/spring_bone_collision_3d.h"
@ -39,5 +38,3 @@ class SpringBoneCollisionPlane3D : public SpringBoneCollision3D {
protected:
virtual Vector3 _collide(const Transform3D &p_center, float p_bone_radius, float p_bone_length, const Vector3 &p_current) const override;
};
#endif // SPRING_BONE_COLLISION_PLANE_3D_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPRING_BONE_COLLISION_SPHERE_3D_H
#define SPRING_BONE_COLLISION_SPHERE_3D_H
#pragma once
#include "scene/3d/spring_bone_collision_3d.h"
@ -55,5 +54,3 @@ public:
void set_inside(bool p_enabled);
bool is_inside() const;
};
#endif // SPRING_BONE_COLLISION_SPHERE_3D_H

Some files were not shown because too many files have changed in this diff Show more