@woosh/meep-engine 2.46.25 → 2.46.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +9 -12
- package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +60 -0
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -0
- package/src/core/collection/HashMap.js +21 -5
- package/src/core/events/signal/Signal.js +3 -3
- package/src/core/geom/3d/cone/computeConeBoundingBox.js +7 -10
- package/src/core/geom/3d/ray/ray3_array_apply_matrix4.js +15 -13
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +6 -24
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +4 -25
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +2 -6
- package/src/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +1 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.d.ts +1 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +10 -43
- package/src/engine/graphics/render/forward_plus/LightManager.js +164 -56
- package/src/engine/graphics/render/forward_plus/{PointLightData.js → LightRenderMetadata.js} +18 -11
- package/src/engine/graphics/render/forward_plus/cluster/compute_light_data_hash.js +1 -1
- package/src/engine/graphics/render/forward_plus/model/AbstractLight.js +1 -1
- package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -4
- package/src/engine/graphics/render/forward_plus/model/PointLight.js +6 -12
- package/src/engine/graphics/render/forward_plus/model/SpotLight.js +0 -4
- package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.d.ts +3 -0
- package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +12 -0
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +3 -2
- package/src/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +1 -1
- package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +3 -3
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +1 -1
- package/src/engine/graphics/texture/atlas/CachingTextureAtlas.js +0 -1
- package/src/engine/intelligence/behavior/util/BranchBehavior.js +102 -0
- package/src/engine/intelligence/behavior/util/SelectorBehavior.js +0 -83
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PointLightData } from "./PointLightData.js";
|
|
1
|
+
import { LightRenderMetadata } from "./LightRenderMetadata.js";
|
|
3
2
|
import {
|
|
4
3
|
ClampToEdgeWrapping,
|
|
5
4
|
DataTexture,
|
|
@@ -14,7 +13,6 @@ import {
|
|
|
14
13
|
UnsignedShortType
|
|
15
14
|
} from "three";
|
|
16
15
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
17
|
-
import { query_bvh_frustum_from_objects } from "./query/query_bvh_frustum_from_objects.js";
|
|
18
16
|
import { IncrementalDeltaSet } from "../visibility/IncrementalDeltaSet.js";
|
|
19
17
|
import { computeFrustumCorners } from "./computeFrustumCorners.js";
|
|
20
18
|
import { read_plane_pair } from "./cluster/read_plane_pair.js";
|
|
@@ -42,10 +40,19 @@ import { array_copy } from "../../../../core/collection/array/copyArray.js";
|
|
|
42
40
|
import { arrayQuickSort } from "../../../../core/collection/array/arrayQuickSort.js";
|
|
43
41
|
import { frustum_from_camera } from "../../ecs/camera/frustum_from_camera.js";
|
|
44
42
|
import { arraySwapElements } from "../../../../core/collection/array/arraySwapElements.js";
|
|
45
|
-
import { compareObjectsByNumericId } from "../../../../core/model/object/compareObjectsByNumericId.js";
|
|
46
43
|
import { slice_frustum_linear_to_points } from "../../../../core/geom/3d/frustum/slice_frustum_linear_to_points.js";
|
|
47
44
|
import { read_cluster_frustum_corners } from "../../../../core/geom/3d/frustum/read_cluster_frustum_corners.js";
|
|
48
45
|
import { assign_cluster, LOOKUP_CACHE, scratch_corners, scratch_frustum_planes } from "./assign_cluster.js";
|
|
46
|
+
import {
|
|
47
|
+
ExplicitBinaryBoundingVolumeHierarchy
|
|
48
|
+
} from "../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
49
|
+
import {
|
|
50
|
+
bvh_query_user_data_overlaps_frustum
|
|
51
|
+
} from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js";
|
|
52
|
+
import { point_light_inside_volume } from "./query/point_light_inside_volume.js";
|
|
53
|
+
import { bvh_query_leaves_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
|
|
54
|
+
import { ray3_array_apply_matrix4 } from "../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
|
|
55
|
+
import { aabb3_intersects_ray } from "../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
|
|
49
56
|
|
|
50
57
|
|
|
51
58
|
/**
|
|
@@ -82,7 +89,7 @@ function encode_light_descriptor(address, light) {
|
|
|
82
89
|
|
|
83
90
|
/**
|
|
84
91
|
*
|
|
85
|
-
* @param {IncrementalDeltaSet<
|
|
92
|
+
* @param {IncrementalDeltaSet<LightRenderMetadata>} data_set
|
|
86
93
|
* @param {BinaryUint32BVH} bvh
|
|
87
94
|
*/
|
|
88
95
|
function build_light_data_bvh(data_set, bvh) {
|
|
@@ -96,18 +103,18 @@ function build_light_data_bvh(data_set, bvh) {
|
|
|
96
103
|
|
|
97
104
|
/**
|
|
98
105
|
*
|
|
99
|
-
* @type {
|
|
106
|
+
* @type {LightRenderMetadata}
|
|
100
107
|
*/
|
|
101
108
|
const datum = elements[i];
|
|
102
109
|
|
|
103
|
-
const bb = datum.
|
|
110
|
+
const bb = datum.bvh_leaf.bounds;
|
|
104
111
|
|
|
105
112
|
const payload = encode_light_descriptor(datum.address, datum.light);
|
|
106
113
|
|
|
107
114
|
bvh.setLeafData(
|
|
108
115
|
i, payload,
|
|
109
|
-
bb
|
|
110
|
-
bb
|
|
116
|
+
bb[0], bb[1], bb[2],
|
|
117
|
+
bb[3], bb[4], bb[5],
|
|
111
118
|
);
|
|
112
119
|
}
|
|
113
120
|
|
|
@@ -117,22 +124,32 @@ function build_light_data_bvh(data_set, bvh) {
|
|
|
117
124
|
bvh.build();
|
|
118
125
|
}
|
|
119
126
|
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @param {LightRenderMetadata} a
|
|
130
|
+
* @param {LightRenderMetadata} b
|
|
131
|
+
* @returns {number}
|
|
132
|
+
*/
|
|
133
|
+
function compareLRMByLightId(a, b) {
|
|
134
|
+
return b.light.id - a.light.id;
|
|
135
|
+
}
|
|
136
|
+
|
|
120
137
|
export class LightManager {
|
|
121
138
|
|
|
122
|
-
|
|
139
|
+
/**
|
|
140
|
+
* @readonly
|
|
141
|
+
* @type {ExplicitBinaryBoundingVolumeHierarchy}
|
|
142
|
+
*/
|
|
143
|
+
#light_data_bvh = new ExplicitBinaryBoundingVolumeHierarchy();
|
|
123
144
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Mapping from a light/decal object ID internal metadata
|
|
147
|
+
* @type {Map<number,LightRenderMetadata>}
|
|
148
|
+
*/
|
|
149
|
+
#metadata_map = new Map();
|
|
129
150
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
* @type {Map<AbstractLight, PointLightData>}
|
|
133
|
-
* @private
|
|
134
|
-
*/
|
|
135
|
-
this.__light_data_map = new Map();
|
|
151
|
+
|
|
152
|
+
constructor() {
|
|
136
153
|
|
|
137
154
|
/**
|
|
138
155
|
* Number of cluster slices along each dimension
|
|
@@ -235,22 +252,22 @@ export class LightManager {
|
|
|
235
252
|
|
|
236
253
|
/**
|
|
237
254
|
*
|
|
238
|
-
* @type {IncrementalDeltaSet<
|
|
255
|
+
* @type {IncrementalDeltaSet<LightRenderMetadata>}
|
|
239
256
|
* @readonly
|
|
240
257
|
* @private
|
|
241
258
|
*/
|
|
242
|
-
this.__visible_lights = new IncrementalDeltaSet(
|
|
259
|
+
this.__visible_lights = new IncrementalDeltaSet(compareLRMByLightId);
|
|
243
260
|
/**
|
|
244
261
|
*
|
|
245
|
-
* @type {IncrementalDeltaSet<
|
|
262
|
+
* @type {IncrementalDeltaSet<LightRenderMetadata>}
|
|
246
263
|
* @readonly
|
|
247
264
|
* @private
|
|
248
265
|
*/
|
|
249
|
-
this.__visible_decals = new IncrementalDeltaSet(
|
|
266
|
+
this.__visible_decals = new IncrementalDeltaSet(compareLRMByLightId);
|
|
250
267
|
|
|
251
268
|
/**
|
|
252
269
|
*
|
|
253
|
-
* @type {
|
|
270
|
+
* @type {LightRenderMetadata[]}
|
|
254
271
|
* @private
|
|
255
272
|
*/
|
|
256
273
|
this.__sorted_visible_lights = [];
|
|
@@ -487,7 +504,7 @@ export class LightManager {
|
|
|
487
504
|
|
|
488
505
|
/**
|
|
489
506
|
*
|
|
490
|
-
* @param {
|
|
507
|
+
* @param {LightRenderMetadata} data
|
|
491
508
|
* @private
|
|
492
509
|
*/
|
|
493
510
|
__handle_visible_decal_added(data) {
|
|
@@ -519,7 +536,7 @@ export class LightManager {
|
|
|
519
536
|
|
|
520
537
|
/**
|
|
521
538
|
*
|
|
522
|
-
* @param {
|
|
539
|
+
* @param {LightRenderMetadata} data
|
|
523
540
|
* @private
|
|
524
541
|
*/
|
|
525
542
|
__handle_visible_decal_removed(data) {
|
|
@@ -556,7 +573,7 @@ export class LightManager {
|
|
|
556
573
|
|
|
557
574
|
/**
|
|
558
575
|
*
|
|
559
|
-
* @param {
|
|
576
|
+
* @param {LightRenderMetadata} data
|
|
560
577
|
* @private
|
|
561
578
|
*/
|
|
562
579
|
__handle_visible_light_added(data) {
|
|
@@ -569,7 +586,7 @@ export class LightManager {
|
|
|
569
586
|
|
|
570
587
|
/**
|
|
571
588
|
*
|
|
572
|
-
* @param {
|
|
589
|
+
* @param {LightRenderMetadata} data
|
|
573
590
|
* @private
|
|
574
591
|
*/
|
|
575
592
|
__handle_visible_light_removed(data) {
|
|
@@ -581,7 +598,7 @@ export class LightManager {
|
|
|
581
598
|
|
|
582
599
|
/**
|
|
583
600
|
*
|
|
584
|
-
* @param {
|
|
601
|
+
* @param {LightRenderMetadata} light
|
|
585
602
|
* @returns {number}
|
|
586
603
|
* @protected
|
|
587
604
|
*/
|
|
@@ -599,7 +616,7 @@ export class LightManager {
|
|
|
599
616
|
|
|
600
617
|
/**
|
|
601
618
|
* DEBUG method
|
|
602
|
-
* @param {
|
|
619
|
+
* @param {LightRenderMetadata} lights
|
|
603
620
|
* @param {number} count
|
|
604
621
|
* @returns {number} lower = better sorting score
|
|
605
622
|
* @private
|
|
@@ -696,7 +713,7 @@ export class LightManager {
|
|
|
696
713
|
|
|
697
714
|
/**
|
|
698
715
|
*
|
|
699
|
-
* @type {IncrementalDeltaSet<
|
|
716
|
+
* @type {IncrementalDeltaSet<LightRenderMetadata>}
|
|
700
717
|
*/
|
|
701
718
|
const visible_lights = this.__visible_lights;
|
|
702
719
|
|
|
@@ -710,20 +727,54 @@ export class LightManager {
|
|
|
710
727
|
|
|
711
728
|
read_frustum_planes_to_array(this.__view_frustum.planes, scratch_frustum_planes)
|
|
712
729
|
|
|
713
|
-
|
|
730
|
+
/*
|
|
731
|
+
Search is done in 2 phases:
|
|
732
|
+
1) broad phase using bounding boxes
|
|
733
|
+
2) granular phase where we use object-specific shape to check against frustum
|
|
734
|
+
*/
|
|
735
|
+
|
|
736
|
+
const broad_match_count = bvh_query_user_data_overlaps_frustum(nodes, 0, this.#light_data_bvh, scratch_frustum_planes);
|
|
737
|
+
|
|
738
|
+
for (let i = 0; i < broad_match_count; i++) {
|
|
714
739
|
|
|
715
|
-
|
|
740
|
+
const light_id = nodes[i];
|
|
716
741
|
|
|
717
742
|
/**
|
|
718
743
|
*
|
|
719
|
-
* @type {
|
|
744
|
+
* @type {LightRenderMetadata}
|
|
720
745
|
*/
|
|
721
|
-
const light_data =
|
|
746
|
+
const light_data = this.#metadata_map.get(light_id);
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
*
|
|
750
|
+
* @type {PointLight|Decal}
|
|
751
|
+
*/
|
|
752
|
+
const light = light_data.light;
|
|
753
|
+
|
|
754
|
+
if (light.isDecal === true) {
|
|
755
|
+
|
|
722
756
|
|
|
723
|
-
if (light_data.light instanceof Decal) {
|
|
724
757
|
// decals go into a separate bucket
|
|
725
758
|
visible_decals.push(light_data);
|
|
726
|
-
|
|
759
|
+
|
|
760
|
+
} else if (light.isPointLight === true) {
|
|
761
|
+
// perform granular check
|
|
762
|
+
|
|
763
|
+
const light_position = light.position;
|
|
764
|
+
|
|
765
|
+
const light_x = light_position.x;
|
|
766
|
+
const light_y = light_position.y;
|
|
767
|
+
const light_z = light_position.z;
|
|
768
|
+
|
|
769
|
+
const radius = light.radius.getValue();
|
|
770
|
+
|
|
771
|
+
if (!point_light_inside_volume(light_x, light_y, light_z, radius, this.__view_frustum_points, scratch_frustum_planes)) {
|
|
772
|
+
// outside of view frustum
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
// register as visible
|
|
727
778
|
visible_lights.push(light_data);
|
|
728
779
|
}
|
|
729
780
|
|
|
@@ -738,7 +789,7 @@ export class LightManager {
|
|
|
738
789
|
|
|
739
790
|
/**
|
|
740
791
|
*
|
|
741
|
-
* @type {
|
|
792
|
+
* @type {LightRenderMetadata[]}
|
|
742
793
|
*/
|
|
743
794
|
const visible_lights = this.__sorted_visible_lights;
|
|
744
795
|
|
|
@@ -1082,17 +1133,17 @@ export class LightManager {
|
|
|
1082
1133
|
* @param {number} z
|
|
1083
1134
|
*/
|
|
1084
1135
|
setTileMapResolution(x, y, z) {
|
|
1085
|
-
assert.isNumber(x,'x');
|
|
1086
|
-
assert.isNonNegativeInteger(x,'x');
|
|
1087
|
-
assert.isFiniteNumber(x,'x');
|
|
1136
|
+
assert.isNumber(x, 'x');
|
|
1137
|
+
assert.isNonNegativeInteger(x, 'x');
|
|
1138
|
+
assert.isFiniteNumber(x, 'x');
|
|
1088
1139
|
|
|
1089
|
-
assert.isNumber(y,'y');
|
|
1090
|
-
assert.isNonNegativeInteger(y,'y');
|
|
1091
|
-
assert.isFiniteNumber(y,'y');
|
|
1140
|
+
assert.isNumber(y, 'y');
|
|
1141
|
+
assert.isNonNegativeInteger(y, 'y');
|
|
1142
|
+
assert.isFiniteNumber(y, 'y');
|
|
1092
1143
|
|
|
1093
|
-
assert.isNumber(z,'z');
|
|
1094
|
-
assert.isNonNegativeInteger(z,'z');
|
|
1095
|
-
assert.isFiniteNumber(z,'z');
|
|
1144
|
+
assert.isNumber(z, 'z');
|
|
1145
|
+
assert.isNonNegativeInteger(z, 'z');
|
|
1146
|
+
assert.isFiniteNumber(z, 'z');
|
|
1096
1147
|
|
|
1097
1148
|
const r = this.__tiles_resolution;
|
|
1098
1149
|
|
|
@@ -1126,13 +1177,11 @@ export class LightManager {
|
|
|
1126
1177
|
* @param {AbstractLight} light
|
|
1127
1178
|
*/
|
|
1128
1179
|
addLight(light) {
|
|
1129
|
-
const lightData = new
|
|
1130
|
-
|
|
1131
|
-
lightData.link();
|
|
1180
|
+
const lightData = new LightRenderMetadata(light);
|
|
1132
1181
|
|
|
1133
|
-
|
|
1182
|
+
lightData.link(this.#light_data_bvh);
|
|
1134
1183
|
|
|
1135
|
-
this.
|
|
1184
|
+
this.#metadata_map.set(light.id, lightData);
|
|
1136
1185
|
}
|
|
1137
1186
|
|
|
1138
1187
|
/**
|
|
@@ -1142,7 +1191,9 @@ export class LightManager {
|
|
|
1142
1191
|
*/
|
|
1143
1192
|
removeLight(light) {
|
|
1144
1193
|
|
|
1145
|
-
const
|
|
1194
|
+
const light_id = light.id;
|
|
1195
|
+
|
|
1196
|
+
const data = this.#metadata_map.get(light_id);
|
|
1146
1197
|
|
|
1147
1198
|
if (data === undefined) {
|
|
1148
1199
|
return false;
|
|
@@ -1150,8 +1201,65 @@ export class LightManager {
|
|
|
1150
1201
|
|
|
1151
1202
|
data.unlink();
|
|
1152
1203
|
|
|
1153
|
-
this.
|
|
1204
|
+
this.#metadata_map.delete(light_id);
|
|
1154
1205
|
|
|
1155
1206
|
return true;
|
|
1156
1207
|
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
*
|
|
1211
|
+
* @param {Decal[]} result
|
|
1212
|
+
* @param {number} result_offset
|
|
1213
|
+
* @param {number[]} query
|
|
1214
|
+
* @param {number} query_offset
|
|
1215
|
+
* @returns {number} number of elements added to the result
|
|
1216
|
+
*/
|
|
1217
|
+
query_decals_by_ray(result, result_offset, query, query_offset) {
|
|
1218
|
+
|
|
1219
|
+
const leaves = [];
|
|
1220
|
+
const local_ray = new Float32Array(6);
|
|
1221
|
+
|
|
1222
|
+
const hit_count = bvh_query_leaves_ray(this.#light_data_bvh, leaves, 0,
|
|
1223
|
+
query[query_offset], query[query_offset + 1], query[query_offset + 2],
|
|
1224
|
+
query[query_offset + 3], query[query_offset + 4], query[query_offset + 5]
|
|
1225
|
+
);
|
|
1226
|
+
|
|
1227
|
+
let result_count = 0;
|
|
1228
|
+
|
|
1229
|
+
for (let i = 0; i < hit_count; i++) {
|
|
1230
|
+
const node = leaves[i];
|
|
1231
|
+
const light_id = this.#light_data_bvh.node_get_user_data(node);
|
|
1232
|
+
|
|
1233
|
+
const metadata = this.#metadata_map.get(light_id);
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
*
|
|
1237
|
+
* @type {Decal}
|
|
1238
|
+
*/
|
|
1239
|
+
const prop = metadata.light;
|
|
1240
|
+
|
|
1241
|
+
if (prop.isDecal !== true) {
|
|
1242
|
+
// wrong prop type
|
|
1243
|
+
continue;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
// transform ray into decal's local space
|
|
1247
|
+
ray3_array_apply_matrix4(local_ray, 0, query, query_offset, prop.transform_inverse);
|
|
1248
|
+
|
|
1249
|
+
if (aabb3_intersects_ray(
|
|
1250
|
+
-0.5, -0.5, -0.5,
|
|
1251
|
+
0.5, 0.5, 0.5,
|
|
1252
|
+
|
|
1253
|
+
local_ray[0], local_ray[1], local_ray[2],
|
|
1254
|
+
local_ray[3], local_ray[4], local_ray[5],
|
|
1255
|
+
)) {
|
|
1256
|
+
result[result_offset + result_count] = prop;
|
|
1257
|
+
|
|
1258
|
+
result_count++;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
return result_count;
|
|
1264
|
+
}
|
|
1157
1265
|
}
|
package/src/engine/graphics/render/forward_plus/{PointLightData.js → LightRenderMetadata.js}
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EBBVHLeafProxy } from "../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
|
|
2
|
+
|
|
3
|
+
export class LightRenderMetadata {
|
|
4
|
+
|
|
2
5
|
|
|
3
|
-
export class PointLightData {
|
|
4
6
|
/**
|
|
5
7
|
*
|
|
6
8
|
* @param {AbstractLight} light
|
|
@@ -18,12 +20,12 @@ export class PointLightData {
|
|
|
18
20
|
*/
|
|
19
21
|
this.address = 0;
|
|
20
22
|
|
|
21
|
-
this.
|
|
23
|
+
this.bvh_leaf = new EBBVHLeafProxy();
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
*
|
|
26
|
-
* @param {
|
|
28
|
+
* @param {LightRenderMetadata} other
|
|
27
29
|
* @returns {number}
|
|
28
30
|
*/
|
|
29
31
|
compare(other) {
|
|
@@ -31,17 +33,22 @@ export class PointLightData {
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
update() {
|
|
36
|
+
const leaf = this.bvh_leaf;
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
this.light.getAABB(leaf.bounds);
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (leaf.parentNode !== null) {
|
|
40
|
-
leaf.parentNode.bubbleRefit();
|
|
40
|
+
if (leaf.is_linked) {
|
|
41
|
+
leaf.write_bounds();
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param {ExplicitBinaryBoundingVolumeHierarchy} bvh
|
|
48
|
+
*/
|
|
49
|
+
link(bvh) {
|
|
50
|
+
this.bvh_leaf.link(bvh, this.light.id);
|
|
51
|
+
|
|
45
52
|
this.update();
|
|
46
53
|
|
|
47
54
|
this.light.onDimensionChanged(this.update, this);
|
|
@@ -52,6 +59,6 @@ export class PointLightData {
|
|
|
52
59
|
this.light.offDimensionChanged(this.update, this);
|
|
53
60
|
|
|
54
61
|
// disconnect from bvh
|
|
55
|
-
this.
|
|
62
|
+
this.bvh_leaf.unlink();
|
|
56
63
|
}
|
|
57
64
|
}
|
|
@@ -6,7 +6,6 @@ import { mat4 } from "gl-matrix";
|
|
|
6
6
|
import Signal from "../../../../../core/events/signal/Signal.js";
|
|
7
7
|
|
|
8
8
|
const corners = [];
|
|
9
|
-
const aabb_array = new Float32Array(6);
|
|
10
9
|
|
|
11
10
|
export class Decal extends AbstractLight {
|
|
12
11
|
constructor() {
|
|
@@ -89,9 +88,7 @@ export class Decal extends AbstractLight {
|
|
|
89
88
|
getAABB(result) {
|
|
90
89
|
aabb3_build_corners(corners, 0, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5);
|
|
91
90
|
|
|
92
|
-
aabb3_matrix4_project_by_corners(
|
|
93
|
-
|
|
94
|
-
result.readFromArray(aabb_array, 0);
|
|
91
|
+
aabb3_matrix4_project_by_corners(result, corners, this.transform);
|
|
95
92
|
}
|
|
96
93
|
|
|
97
94
|
toArray(destination, address) {
|
|
@@ -36,10 +36,6 @@ export class PointLight extends AbstractLight {
|
|
|
36
36
|
this.position.writeToArray(result, 0);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {AABB3} result
|
|
42
|
-
*/
|
|
43
39
|
getAABB(result) {
|
|
44
40
|
const r = this.radius.getValue();
|
|
45
41
|
const p = this.position;
|
|
@@ -48,15 +44,13 @@ export class PointLight extends AbstractLight {
|
|
|
48
44
|
const center_y = p.y;
|
|
49
45
|
const center_z = p.z;
|
|
50
46
|
|
|
51
|
-
result
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
center_z - r,
|
|
47
|
+
result[0] = center_x - r;
|
|
48
|
+
result[1] = center_y - r;
|
|
49
|
+
result[2] = center_z - r;
|
|
55
50
|
|
|
56
|
-
center_x + r
|
|
57
|
-
center_y + r
|
|
58
|
-
center_z + r
|
|
59
|
-
);
|
|
51
|
+
result[3] = center_x + r;
|
|
52
|
+
result[4] = center_y + r;
|
|
53
|
+
result[5] = center_z + r;
|
|
60
54
|
}
|
|
61
55
|
|
|
62
56
|
onDimensionChanged(listener, context) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {EnginePlugin} from "../../../../plugin/EnginePlugin";
|
|
2
|
+
import {Decal} from "../../../ecs/decal/v2/Decal";
|
|
2
3
|
|
|
3
4
|
export class ForwardPlusRenderingPlugin extends EnginePlugin {
|
|
4
5
|
setClusterResolution(x: number, y: number, z: number): void
|
|
6
|
+
|
|
7
|
+
queryDecalsByRay(result: Decal[], result_offset: number, query: ArrayLike<number>, query_offset?: number): number
|
|
5
8
|
}
|
|
@@ -88,4 +88,16 @@ export class ForwardPlusRenderingPlugin extends EnginePlugin {
|
|
|
88
88
|
getLightManager() {
|
|
89
89
|
return this.__light_manager;
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @param {Decal[]} result
|
|
95
|
+
* @param {number} result_offset
|
|
96
|
+
* @param {number[]} query
|
|
97
|
+
* @param {number} query_offset
|
|
98
|
+
* @returns {number} number of elements added to the result
|
|
99
|
+
*/
|
|
100
|
+
queryDecalsByRay(result, result_offset, query, query_offset=0){
|
|
101
|
+
return this.__light_manager.query_decals_by_ray(result,result_offset, query,query_offset);
|
|
102
|
+
}
|
|
91
103
|
}
|
|
@@ -1559,11 +1559,12 @@ function draw_camera_view_planes() {
|
|
|
1559
1559
|
}
|
|
1560
1560
|
|
|
1561
1561
|
// prepare_scene_2();
|
|
1562
|
-
prepare_scene_decal_0();
|
|
1562
|
+
// prepare_scene_decal_0();
|
|
1563
1563
|
// prepare_scene_decal_1();
|
|
1564
1564
|
// prepare_scene_decal_2();
|
|
1565
1565
|
// prepare_scene_9();
|
|
1566
|
-
// prepare_scene_0();
|
|
1566
|
+
// prepare_scene_0(); // stress test
|
|
1567
|
+
prepare_scene_4(); // sponza
|
|
1567
1568
|
animate();
|
|
1568
1569
|
|
|
1569
1570
|
// draw_camera_view_planes();
|
|
@@ -6,7 +6,7 @@ import { detailed_sphere_frustum_intersection_test } from "./detailed_sphere_fru
|
|
|
6
6
|
* @param {number} light_y
|
|
7
7
|
* @param {number} light_z
|
|
8
8
|
* @param {number} radius
|
|
9
|
-
* @param {number[]} points
|
|
9
|
+
* @param {number[]|Float32Array} points
|
|
10
10
|
* @param {number[]|Float32Array|Float64Array} planes
|
|
11
11
|
* @returns {boolean}
|
|
12
12
|
*/
|
|
@@ -14,9 +14,9 @@ let stackPointer = 0;
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Most of the data is in flat continuous array for cache coherence
|
|
17
|
-
* @param {
|
|
17
|
+
* @param {LightRenderMetadata[]} destination
|
|
18
18
|
* @param {number} destination_offset
|
|
19
|
-
* @param {BinaryNode<
|
|
19
|
+
* @param {BinaryNode<LightRenderMetadata>} root
|
|
20
20
|
* @param {number[]|Float32Array|Float64Array} planes
|
|
21
21
|
* @param {number[]|Float32Array|Float64Array} points
|
|
22
22
|
* @returns {number} number of items added to the destination, non-negative integer
|
|
@@ -84,7 +84,7 @@ export function query_bvh_frustum_from_objects(
|
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
*
|
|
87
|
-
* @type {
|
|
87
|
+
* @type {LightRenderMetadata}
|
|
88
88
|
*/
|
|
89
89
|
const light_data = n.object;
|
|
90
90
|
|
|
@@ -69,7 +69,7 @@ export class PathTracedMesh {
|
|
|
69
69
|
hit(out, ray, min_distance, max_distance) {
|
|
70
70
|
//transform ray
|
|
71
71
|
const m4 = this.__transform_inverse;
|
|
72
|
-
ray3_array_apply_matrix4(local_ray, ray, m4);
|
|
72
|
+
ray3_array_apply_matrix4(local_ray,0, ray,0, m4);
|
|
73
73
|
|
|
74
74
|
const scale_d = this.__local_scale_inverse;
|
|
75
75
|
|