summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2021-08-09 17:15:17 -0500
committerAaron Franke <arnfranke@yahoo.com>2021-08-09 17:43:48 -0500
commit430ad75963a0e6837ef460e78fb99565714b4418 (patch)
treed5b98ae003fd64fb76a77def411c6a51d97c48ee /servers
parentc68b109f270a2bf1c42c3f083b53e7bc26dadfd6 (diff)
Some work on double support
Diffstat (limited to 'servers')
-rw-r--r--servers/physics_3d/shape_3d_sw.cpp18
-rw-r--r--servers/physics_3d/shape_3d_sw.h8
-rw-r--r--servers/rendering/renderer_scene_cull.cpp4
-rw-r--r--servers/rendering/renderer_scene_occlusion_cull.h2
-rw-r--r--servers/rendering_server.cpp2
-rw-r--r--servers/rendering_server.h2
6 files changed, 22 insertions, 14 deletions
diff --git a/servers/physics_3d/shape_3d_sw.cpp b/servers/physics_3d/shape_3d_sw.cpp
index 04a174f9c8..5b3721861e 100644
--- a/servers/physics_3d/shape_3d_sw.cpp
+++ b/servers/physics_3d/shape_3d_sw.cpp
@@ -1635,7 +1635,7 @@ ConcavePolygonShape3DSW::ConcavePolygonShape3DSW() {
/* HEIGHT MAP SHAPE */
-Vector<float> HeightMapShape3DSW::get_heights() const {
+Vector<real_t> HeightMapShape3DSW::get_heights() const {
return heights;
}
@@ -1932,7 +1932,7 @@ Vector3 HeightMapShape3DSW::get_moment_of_inertia(real_t p_mass) const {
(p_mass / 3.0) * (extents.x * extents.x + extents.y * extents.y));
}
-void HeightMapShape3DSW::_setup(const Vector<float> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
+void HeightMapShape3DSW::_setup(const Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height) {
heights = p_heights;
width = p_width;
depth = p_depth;
@@ -1966,8 +1966,12 @@ void HeightMapShape3DSW::set_data(const Variant &p_data) {
ERR_FAIL_COND(depth <= 0.0);
Variant heights_variant = d["heights"];
- Vector<float> heights_buffer;
+ Vector<real_t> heights_buffer;
+#ifdef REAL_T_IS_DOUBLE
+ if (heights_variant.get_type() == Variant::PACKED_FLOAT64_ARRAY) {
+#else
if (heights_variant.get_type() == Variant::PACKED_FLOAT32_ARRAY) {
+#endif
// Ready-to-use heights can be passed.
heights_buffer = heights_variant;
} else if (heights_variant.get_type() == Variant::OBJECT) {
@@ -1980,13 +1984,17 @@ void HeightMapShape3DSW::set_data(const Variant &p_data) {
PackedByteArray im_data = image->get_data();
heights_buffer.resize(image->get_width() * image->get_height());
- float *w = heights_buffer.ptrw();
- float *rp = (float *)im_data.ptr();
+ real_t *w = heights_buffer.ptrw();
+ real_t *rp = (real_t *)im_data.ptr();
for (int i = 0; i < heights_buffer.size(); ++i) {
w[i] = rp[i];
}
} else {
+#ifdef REAL_T_IS_DOUBLE
+ ERR_FAIL_MSG("Expected PackedFloat64Array or float Image.");
+#else
ERR_FAIL_MSG("Expected PackedFloat32Array or float Image.");
+#endif
}
// Compute min and max heights or use precomputed values.
diff --git a/servers/physics_3d/shape_3d_sw.h b/servers/physics_3d/shape_3d_sw.h
index 0d1b7cc3d7..72be34b788 100644
--- a/servers/physics_3d/shape_3d_sw.h
+++ b/servers/physics_3d/shape_3d_sw.h
@@ -389,12 +389,12 @@ public:
};
struct HeightMapShape3DSW : public ConcaveShape3DSW {
- Vector<float> heights;
+ Vector<real_t> heights;
int width = 0;
int depth = 0;
Vector3 local_origin;
- _FORCE_INLINE_ float _get_height(int p_x, int p_z) const {
+ _FORCE_INLINE_ real_t _get_height(int p_x, int p_z) const {
return heights[(p_z * width) + p_x];
}
@@ -406,10 +406,10 @@ struct HeightMapShape3DSW : public ConcaveShape3DSW {
void _get_cell(const Vector3 &p_point, int &r_x, int &r_y, int &r_z) const;
- void _setup(const Vector<float> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
+ void _setup(const Vector<real_t> &p_heights, int p_width, int p_depth, real_t p_min_height, real_t p_max_height);
public:
- Vector<float> get_heights() const;
+ Vector<real_t> get_heights() const;
int get_width() const;
int get_depth() const;
diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp
index 83d1b33bf2..6357a6f4c2 100644
--- a/servers/rendering/renderer_scene_cull.cpp
+++ b/servers/rendering/renderer_scene_cull.cpp
@@ -1866,7 +1866,7 @@ void RendererSceneCull::_update_instance_lightmap_captures(Instance *p_instance)
//rotate it
Basis rot = lightmap->transform.basis.orthonormalized();
for (int i = 0; i < 3; i++) {
- float csh[9];
+ real_t csh[9];
for (int j = 0; j < 9; j++) {
csh[j] = sh[j][i];
}
@@ -1878,7 +1878,7 @@ void RendererSceneCull::_update_instance_lightmap_captures(Instance *p_instance)
Vector3 inner_pos = ((lm_pos - bounds.position) / bounds.size) * 2.0 - Vector3(1.0, 1.0, 1.0);
- float blend = MAX(inner_pos.x, MAX(inner_pos.y, inner_pos.z));
+ real_t blend = MAX(inner_pos.x, MAX(inner_pos.y, inner_pos.z));
//make blend more rounded
blend = Math::lerp(inner_pos.length(), blend, blend);
blend *= blend;
diff --git a/servers/rendering/renderer_scene_occlusion_cull.h b/servers/rendering/renderer_scene_occlusion_cull.h
index 1d0f53c0bf..e06b3ba153 100644
--- a/servers/rendering/renderer_scene_occlusion_cull.h
+++ b/servers/rendering/renderer_scene_occlusion_cull.h
@@ -60,7 +60,7 @@ public:
void update_mips();
- _FORCE_INLINE_ bool is_occluded(const float p_bounds[6], const Vector3 &p_cam_position, const Transform3D &p_cam_inv_transform, const CameraMatrix &p_cam_projection, float p_near) const {
+ _FORCE_INLINE_ bool is_occluded(const real_t p_bounds[6], const Vector3 &p_cam_position, const Transform3D &p_cam_inv_transform, const CameraMatrix &p_cam_projection, real_t p_near) const {
if (is_empty()) {
return false;
}
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index 9dd0a2ec31..2da8e0f297 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -242,7 +242,7 @@ RID RenderingServer::_make_test_cube() {
return test_cube;
}
-RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
+RID RenderingServer::make_sphere_mesh(int p_lats, int p_lons, real_t p_radius) {
Vector<Vector3> vertices;
Vector<Vector3> normals;
const double lat_step = Math_TAU / p_lats;
diff --git a/servers/rendering_server.h b/servers/rendering_server.h
index 550d17a7e3..6b789a6121 100644
--- a/servers/rendering_server.h
+++ b/servers/rendering_server.h
@@ -1457,7 +1457,7 @@ public:
virtual void sdfgi_set_debug_probe_select(const Vector3 &p_position, const Vector3 &p_dir) = 0;
- virtual RID make_sphere_mesh(int p_lats, int p_lons, float p_radius);
+ virtual RID make_sphere_mesh(int p_lats, int p_lons, real_t p_radius);
virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry3D::MeshData &p_mesh_data);
virtual void mesh_add_surface_from_planes(RID p_mesh, const Vector<Plane> &p_planes);