@woosh/meep-engine 2.126.51 → 2.126.53
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
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.126.
|
|
8
|
+
"version": "2.126.53",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute_tight_near_far_clipping_planes.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compute_tight_near_far_clipping_planes.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,+DAPW,MAAM,EAAE,iBACR,MAAM,cACN,MAAM,OACN,GAAG,WACH,MAAM,EAAE,GAAC,SAAS,CAAC,MAAM,CAAC,GAAC,YAAY,GACrC,OAAO,CA4MnB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assert } from "../../../assert.js";
|
|
1
2
|
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
2
3
|
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
3
4
|
import { v3_distance_above_plane } from "../../../geom/vec3/v3_distance_above_plane.js";
|
|
@@ -10,7 +11,6 @@ const scratch_aabb = [];
|
|
|
10
11
|
const scratch_frustum = new Float32Array(24);
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
14
|
* @param {number[]} result
|
|
15
15
|
* @param {number} result_offset
|
|
16
16
|
* @param {number} plane_mask if bit is set to 0, that plane is not allowed to move
|
|
@@ -25,6 +25,8 @@ export function compute_tight_near_far_clipping_planes(
|
|
|
25
25
|
bvh,
|
|
26
26
|
frustum
|
|
27
27
|
) {
|
|
28
|
+
assert.isNonNegativeInteger(result_offset, 'result_offset');
|
|
29
|
+
assert.isNonNegativeInteger(plane_mask, 'plane_mask');
|
|
28
30
|
|
|
29
31
|
// initialize result
|
|
30
32
|
array_copy(frustum, 0, scratch_frustum, 0, 24);
|
|
@@ -79,12 +81,12 @@ export function compute_tight_near_far_clipping_planes(
|
|
|
79
81
|
const _y1 = scratch_aabb[4];
|
|
80
82
|
const _z1 = scratch_aabb[5];
|
|
81
83
|
|
|
84
|
+
// bitset of relaxed planes affected by this node
|
|
85
|
+
// lets us discard intermediate nodes that would not affect any planes
|
|
86
|
+
let collision_mask = 0;
|
|
87
|
+
|
|
82
88
|
for (let plane_index = 0; plane_index < 6; plane_index++) {
|
|
83
89
|
|
|
84
|
-
if (((plane_mask >> plane_index) & 1) === 1) {
|
|
85
|
-
// plane is not fixed, we're done here
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
90
|
|
|
89
91
|
const plane_address = plane_index * 4;
|
|
90
92
|
|
|
@@ -120,24 +122,43 @@ export function compute_tight_near_far_clipping_planes(
|
|
|
120
122
|
z1 = _z0;
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
plane_normal_x, plane_normal_y, plane_normal_z, plane_offset
|
|
126
|
-
);
|
|
125
|
+
if (((plane_mask >> plane_index) & 1) === 1) {
|
|
126
|
+
// plane is not fixed, we're done here
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
const distance_above_plane = v3_distance_above_plane(
|
|
129
|
+
x0, y0, z0,
|
|
130
|
+
plane_normal_x, plane_normal_y, plane_normal_z, 0
|
|
131
|
+
);
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
if (distance_above_plane < plane_offset) {
|
|
134
|
+
collision_mask |= (1 << plane_index);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
} else {
|
|
138
|
+
|
|
139
|
+
// fixed plane
|
|
140
|
+
const distance_above_plane = v3_distance_above_plane(
|
|
141
|
+
x1, y1, z1,
|
|
142
|
+
plane_normal_x, plane_normal_y, plane_normal_z, plane_offset
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
if (distance_above_plane < 0) {
|
|
146
|
+
// below plane, reject this branch
|
|
147
|
+
continue node_loop;
|
|
148
|
+
}
|
|
134
149
|
|
|
150
|
+
}
|
|
151
|
+
}
|
|
135
152
|
|
|
136
153
|
|
|
137
154
|
const node_is_leaf = bvh.node_is_leaf(node);
|
|
138
155
|
|
|
139
156
|
if (!node_is_leaf) {
|
|
140
|
-
|
|
157
|
+
|
|
158
|
+
if (collision_mask === 0) {
|
|
159
|
+
// does not affect any planes, skip
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
141
162
|
|
|
142
163
|
// inside
|
|
143
164
|
// read in-order
|
|
@@ -152,9 +173,9 @@ export function compute_tight_near_far_clipping_planes(
|
|
|
152
173
|
|
|
153
174
|
// leaf node
|
|
154
175
|
|
|
155
|
-
//
|
|
176
|
+
// expand planes
|
|
156
177
|
for (let i = 0; i < 6; i++) {
|
|
157
|
-
if (((
|
|
178
|
+
if (((collision_mask >> i) & 1) === 1) {
|
|
158
179
|
|
|
159
180
|
const plane_address = i * 4;
|
|
160
181
|
|
|
@@ -162,43 +183,32 @@ export function compute_tight_near_far_clipping_planes(
|
|
|
162
183
|
const plane_normal_x = scratch_frustum[plane_address];
|
|
163
184
|
const plane_normal_y = scratch_frustum[plane_address + 1];
|
|
164
185
|
const plane_normal_z = scratch_frustum[plane_address + 2];
|
|
165
|
-
const plane_offset = scratch_frustum[plane_address + 3];
|
|
166
186
|
|
|
167
|
-
|
|
168
|
-
// construct nearest and farthest corners along the plane normal
|
|
187
|
+
// get the nearest corner along the plane normal
|
|
169
188
|
if (plane_normal_x > 0) {
|
|
170
189
|
x0 = _x0;
|
|
171
|
-
x1 = _x1;
|
|
172
190
|
} else {
|
|
173
191
|
x0 = _x1;
|
|
174
|
-
x1 = _x0;
|
|
175
192
|
}
|
|
176
193
|
|
|
177
194
|
if (plane_normal_y > 0) {
|
|
178
195
|
y0 = _y0;
|
|
179
|
-
y1 = _y1;
|
|
180
196
|
} else {
|
|
181
197
|
y0 = _y1;
|
|
182
|
-
y1 = _y0;
|
|
183
198
|
}
|
|
184
199
|
|
|
185
200
|
if (plane_normal_z > 0) {
|
|
186
201
|
z0 = _z0;
|
|
187
|
-
z1 = _z1;
|
|
188
202
|
} else {
|
|
189
203
|
z0 = _z1;
|
|
190
|
-
z1 = _z0;
|
|
191
204
|
}
|
|
192
205
|
|
|
193
|
-
|
|
206
|
+
// move plane
|
|
207
|
+
scratch_frustum[plane_address + 3] = v3_distance_above_plane(
|
|
194
208
|
x0, y0, z0,
|
|
195
209
|
plane_normal_x, plane_normal_y, plane_normal_z, 0
|
|
196
210
|
);
|
|
197
211
|
|
|
198
|
-
if (distance_above_plane < plane_offset) {
|
|
199
|
-
// move plane
|
|
200
|
-
scratch_frustum[plane_address + 3] = distance_above_plane;
|
|
201
|
-
}
|
|
202
212
|
}
|
|
203
213
|
}
|
|
204
214
|
|