mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Merge commit godotengine/godot@1f47e4c4e3
This commit is contained in:
@@ -336,10 +336,10 @@ void RaycastOcclusionCull::Scenario::_update_dirty_instance(int p_idx, RID *p_in
|
||||
int vertices_size = occ->vertices.size();
|
||||
|
||||
// Embree requires the last element to be readable by a 16-byte SSE load instruction, so we add padding to be safe.
|
||||
occ_inst->xformed_vertices.resize(vertices_size + 1);
|
||||
occ_inst->xformed_vertices.resize(3 * vertices_size + 3);
|
||||
|
||||
const Vector3 *read_ptr = occ->vertices.ptr();
|
||||
Vector3 *write_ptr = occ_inst->xformed_vertices.ptr();
|
||||
float *write_ptr = occ_inst->xformed_vertices.ptr();
|
||||
|
||||
if (vertices_size > 1024) {
|
||||
TransformThreadData td;
|
||||
@@ -367,9 +367,14 @@ void RaycastOcclusionCull::Scenario::_transform_vertices_thread(uint32_t p_threa
|
||||
_transform_vertices_range(p_data->read, p_data->write, p_data->xform, from, to);
|
||||
}
|
||||
|
||||
void RaycastOcclusionCull::Scenario::_transform_vertices_range(const Vector3 *p_read, Vector3 *p_write, const Transform3D &p_xform, int p_from, int p_to) {
|
||||
void RaycastOcclusionCull::Scenario::_transform_vertices_range(const Vector3 *p_read, float *p_write, const Transform3D &p_xform, int p_from, int p_to) {
|
||||
float *floats_w = p_write;
|
||||
for (int i = p_from; i < p_to; i++) {
|
||||
p_write[i] = p_xform.xform(p_read[i]);
|
||||
const Vector3 p = p_xform.xform(p_read[i]);
|
||||
floats_w[0] = p.x;
|
||||
floats_w[1] = p.y;
|
||||
floats_w[2] = p.z;
|
||||
floats_w += 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +465,7 @@ void RaycastOcclusionCull::Scenario::update() {
|
||||
}
|
||||
|
||||
RTCGeometry geom = rtcNewGeometry(raycast_singleton->ebr_device, RTC_GEOMETRY_TYPE_TRIANGLE);
|
||||
rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, occ_inst->xformed_vertices.ptr(), 0, sizeof(Vector3), occ_inst->xformed_vertices.size());
|
||||
rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, occ_inst->xformed_vertices.ptr(), 0, sizeof(float) * 3, occ_inst->xformed_vertices.size() / 3);
|
||||
rtcSetSharedGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, occ_inst->indices.ptr(), 0, sizeof(uint32_t) * 3, occ_inst->indices.size() / 3);
|
||||
rtcCommitGeometry(geom);
|
||||
rtcAttachGeometry(next_scene, geom);
|
||||
@@ -533,8 +538,6 @@ Projection RaycastOcclusionCull::_jitter_projection(const Projection &p_cam_proj
|
||||
return p_cam_projection;
|
||||
}
|
||||
|
||||
Projection p = p_cam_projection;
|
||||
|
||||
int32_t frame = Engine::get_singleton()->get_frames_drawn();
|
||||
frame %= 9;
|
||||
|
||||
@@ -574,11 +577,11 @@ Projection RaycastOcclusionCull::_jitter_projection(const Projection &p_cam_proj
|
||||
// Higher divergence gives fewer false hidden, but more false shown.
|
||||
// False hidden is obvious to viewer, false shown is not.
|
||||
// False shown can lower percentage that are occluded, and therefore performance.
|
||||
jitter *= Vector2(1 / (float)p_viewport_size.x, 1 / (float)p_viewport_size.y) * 0.05f;
|
||||
jitter *= Vector2(1 / (float)p_viewport_size.x, 1 / (float)p_viewport_size.y) * 0.9f;
|
||||
|
||||
p.add_jitter_offset(jitter);
|
||||
|
||||
return p;
|
||||
Projection correction;
|
||||
correction.add_jitter_offset(jitter);
|
||||
return correction * p_cam_projection;
|
||||
}
|
||||
|
||||
void RaycastOcclusionCull::buffer_update(RID p_buffer, const Transform3D &p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal) {
|
||||
|
||||
Reference in New Issue
Block a user