Skip to content

Commit b90ce2f

Browse files
committed
Merge branch '3dmath' into devel
* Implementation of 3D mathematics using AVX instruction set.
2 parents 8fa49eb + 20b9391 commit b90ce2f

38 files changed

+7575
-1362
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*******************************************************************************
44

55
=== 1.0.31 ===
6+
* Implementation of 3D mathematics using AVX instruction set.
67
* Fixed improper AVX-512 optimization for lanczos kernel genration function.
78
* Fixed Mid/Side transformation functions bug for 32-bit and 64-bit ARM processors.
89
* Added MacOS CI builds.

include/lsp-plug.in/dsp/common/3dmath.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,25 +403,29 @@ LSP_DSP_LIB_SYMBOL(float, check_triplet3d_vvn, const LSP_DSP_LIB_TYPE(vector3d_t
403403
*/
404404
LSP_DSP_LIB_SYMBOL(float, check_triplet3d_vv, const LSP_DSP_LIB_TYPE(vector3d_t) *v);
405405

406-
/** Analyze point location relative to the triangle of three points
406+
/**
407+
* Analyze point location relative to the triangle of three points.
408+
* All points should be considered being co-planar.
407409
*
408410
* @param t array of three triangle points
409411
* @param p point
410-
* @return value > 0 if point is candidate to be inside the triangle,
411-
* value < 0 if point is candidate to be outside the triangle,
412-
* value = 0 if point is on the edge of triangle
412+
* @return value > 0 if point is inside of the triangle,
413+
* value < 0 if point is outside of the triangle,
414+
* value = 0 if point is on the edge of the triangle
413415
*/
414416
LSP_DSP_LIB_SYMBOL(float, check_point3d_on_triangle_pvp, const LSP_DSP_LIB_TYPE(point3d_t) *t, const LSP_DSP_LIB_TYPE(point3d_t) *p);
415417

416-
/** Analyze point location relative to the triangle of three points
418+
/**
419+
* Analyze point location relative to the triangle of three points.
420+
* All points should be considered being co-planar.
417421
*
418422
* @param p1 triangle point 1
419423
* @param p2 triangle point 2
420424
* @param p3 triangle point 3
421425
* @param p point
422-
* @return value > 0 if point is candidate to be inside the triangle,
423-
* value < 0 if point is candidate to be outside the triangle,
424-
* value = 0 if point is on the edge of triangle
426+
* @return value > 0 if point is inside of the triangle,
427+
* value < 0 if point is outside of the triangle,
428+
* value = 0 if point is on the edge of the triangle
425429
*/
426430
LSP_DSP_LIB_SYMBOL(float, check_point3d_on_triangle_p3p, const LSP_DSP_LIB_TYPE(point3d_t) *p1, const LSP_DSP_LIB_TYPE(point3d_t) *p2, const LSP_DSP_LIB_TYPE(point3d_t) *p3, const LSP_DSP_LIB_TYPE(point3d_t) *p);
427431

@@ -437,7 +441,7 @@ LSP_DSP_LIB_SYMBOL(size_t, longest_edge3d_p3, const LSP_DSP_LIB_TYPE(point3d_t)
437441

438442
/** Return the index of longest edge between three points
439443
*
440-
* @param p array of points
444+
* @param p array of three points (0, 1, 2)
441445
* @return 0 if edge between points 0 and 1 is longest, 1 if between points 1 and 2, 2 if between ponts 2 and 0
442446
*/
443447
LSP_DSP_LIB_SYMBOL(size_t, longest_edge3d_pv, const LSP_DSP_LIB_TYPE(point3d_t) *p);

include/private/dsp/arch/generic/3dmath.h

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,17 @@ namespace lsp
400400
M[1] = 0.0f;
401401
M[2] = 0.0f;
402402
M[3] = 0.0f;
403+
403404
M[4] = 0.0f;
404405
M[5] = c;
405406
M[6] = s;
406407
M[7] = 0.0f;
408+
407409
M[8] = 0.0f;
408410
M[9] = -s;
409411
M[10] = c;
410412
M[11] = 0.0f;
413+
411414
M[12] = 0.0f;
412415
M[13] = 0.0f;
413416
M[14] = 0.0f;
@@ -424,14 +427,17 @@ namespace lsp
424427
M[1] = 0.0f;
425428
M[2] = -s;
426429
M[3] = 0.0f;
430+
427431
M[4] = 0.0f;
428432
M[5] = 1.0f;
429433
M[6] = 0.0f;
430434
M[7] = 0.0f;
435+
431436
M[8] = s;
432437
M[9] = 0.0f;
433438
M[10] = c;
434439
M[11] = 0.0f;
440+
435441
M[12] = 0.0f;
436442
M[13] = 0.0f;
437443
M[14] = 0.0f;
@@ -448,14 +454,17 @@ namespace lsp
448454
M[1] = s;
449455
M[2] = 0.0f;
450456
M[3] = 0.0f;
457+
451458
M[4] = -s;
452459
M[5] = c;
453460
M[6] = 0.0f;
454461
M[7] = 0.0f;
462+
455463
M[8] = 0.0f;
456464
M[9] = 0.0f;
457465
M[10] = 1.0f;
458466
M[11] = 0.0f;
467+
459468
M[12] = 0.0f;
460469
M[13] = 0.0f;
461470
M[14] = 0.0f;
@@ -1103,16 +1112,7 @@ namespace lsp
11031112
if (r[2] < 0.0f)
11041113
return r[2];
11051114

1106-
// Check 4
1107-
r[2] = r[0]*r[1]*r[2];
1108-
if (r[2] != 0.0f)
1109-
return r[2];
1110-
1111-
// Edge check: 3 scalar multiplications
1112-
r[0] = v[0].dx * v[1].dx + v[0].dy * v[1].dy + v[0].dz * v[1].dz;
1113-
r[1] = v[1].dx * v[2].dx + v[1].dy * v[2].dy + v[1].dz * v[2].dz;
1114-
r[2] = v[2].dx * v[0].dx + v[2].dy * v[0].dy + v[2].dz * v[0].dz;
1115-
1115+
// The point may be located on the edge or on the vertex
11161116
return r[0]*r[1]*r[2];
11171117
}
11181118

@@ -1163,16 +1163,7 @@ namespace lsp
11631163
if (r[2] < 0.0f)
11641164
return r[2];
11651165

1166-
// Check 4
1167-
r[2] = r[0]*r[1]*r[2];
1168-
if (r[2] != 0.0f)
1169-
return r[2];
1170-
1171-
// Edge check: 3 scalar multiplications
1172-
r[0] = v[0].dx * v[1].dx + v[0].dy * v[1].dy + v[0].dz * v[1].dz;
1173-
r[1] = v[1].dx * v[2].dx + v[1].dy * v[2].dy + v[1].dz * v[2].dz;
1174-
r[2] = v[2].dx * v[0].dx + v[2].dy * v[0].dy + v[2].dz * v[0].dz;
1175-
1166+
// The point may be located on the edge or on the vertex
11761167
return r[0]*r[1]*r[2];
11771168
}
11781169

@@ -1242,9 +1233,9 @@ namespace lsp
12421233
r[1] = v[1].dx * v[1].dx + v[1].dy * v[1].dy + v[1].dz * v[1].dz;
12431234
r[2] = v[2].dx * v[2].dx + v[2].dy * v[2].dy + v[2].dz * v[2].dz;
12441235

1245-
if (r[0] > r[1])
1246-
return (r[0] > r[2]) ? 0 : 2;
1247-
return (r[1] > r[2]) ? 1 : 2;
1236+
if (r[0] >= r[1])
1237+
return (r[0] >= r[2]) ? 0 : 2;
1238+
return (r[1] >= r[2]) ? 1 : 2;
12481239
}
12491240

12501241
size_t longest_edge3d_pv(const point3d_t *p)
@@ -1267,9 +1258,9 @@ namespace lsp
12671258
r[1] = v[1].dx * v[1].dx + v[1].dy * v[1].dy + v[1].dz * v[1].dz;
12681259
r[2] = v[2].dx * v[2].dx + v[2].dy * v[2].dy + v[2].dz * v[2].dz;
12691260

1270-
if (r[0] > r[1])
1271-
return (r[0] > r[2]) ? 0 : 2;
1272-
return (r[1] > r[2]) ? 1 : 2;
1261+
if (r[0] >= r[1])
1262+
return (r[0] >= r[2]) ? 0 : 2;
1263+
return (r[1] >= r[2]) ? 1 : 2;
12731264
}
12741265

12751266
float calc_angle3d_v2(const vector3d_t *v1, const vector3d_t *v2)

0 commit comments

Comments
 (0)