Bastien Montagne
dd3222d2f8
BLI math: Do not use BLI_ASSERT_ C-style checks in modern cpp code.
...
The old C-style `BLI_ASSERT_UNIT_V...` assert macros have a few issues:
* They are named `unit`, but also consider a zero-length vector as valid.
* They use a fairly high epsilon value, which was defined because
vertex normals used to be stored as shorts.
Fortunately, these are used only in one place in the modern BLI_math C++
code AFAICS, which is `math::rotate_direction_around_axis`.
This commit adds some utils to check for vectors being (almost) unit
or zero length, using more modern bases for epsilon values (from
`std::numeric_limits`).
* `is_zero` keeps its existing default arror of `0` (i.e. strictly null
vector by default). That way, current behavior is not changed, and in
most cases null vectors are explicitely created as exactly null.
* `is_unit` uses a default 10 times the type's epsilon, as a zero
epsilon would virtually never succeed here.
And it modifies `rotate_direction_around_axis` to:
* Assert that `axis` is a unit vector.
* Early-out in case given `direction` is a null vector, or rotating
angle is zero.
* Assert about `direction` being a unit vector otherwise.
Note that this will make `rotate_direction_around_axis` use much
stricter epsilon error factors. This does not seem to affect any of the
files that triggered asserts prior to recent fix in e18dd894b8 though.
Pull Request: https://projects.blender.org/blender/blender/pulls/122482
2024-05-31 10:58:19 +02:00
..
2024-04-03 10:22:05 +11:00
2024-04-20 13:46:14 +10:00
2024-03-28 22:57:57 +11:00
2024-01-12 14:30:34 +01:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-11-07 15:42:52 +11:00
2023-08-16 09:51:37 +02:00
2024-03-06 14:47:29 +11:00
2023-05-31 16:19:06 +02:00
2024-03-28 20:57:50 +11:00
2023-08-16 00:20:26 +10:00
2024-02-19 15:59:59 +01:00
2023-08-16 09:51:37 +02:00
2023-08-16 00:20:26 +10:00
2023-07-03 17:01:32 +10:00
2024-04-15 09:50:47 +10:00
2024-02-19 15:59:59 +01:00
2024-04-23 16:09:45 +10:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2024-04-04 14:49:01 -04:00
2024-02-19 15:59:59 +01:00
2024-04-23 16:09:45 +10:00
2024-04-15 09:50:47 +10:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2024-05-07 13:07:02 +10:00
2024-04-23 16:09:45 +10:00
2024-04-15 09:50:47 +10:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2024-04-15 09:50:47 +10:00
2023-08-16 00:20:26 +10:00
2024-04-14 13:20:32 +02:00
2024-04-09 13:52:41 +10:00
2023-11-07 15:42:52 +11:00
2023-08-16 00:20:26 +10:00
2024-05-04 15:06:46 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 09:51:37 +02:00
2024-01-08 11:32:49 +11:00
2024-02-19 15:59:59 +01:00
2023-08-16 00:20:26 +10:00
2024-04-20 12:41:23 +10:00
2024-05-20 10:29:22 +10:00
2024-05-07 13:07:02 +10:00
2023-10-30 21:40:35 +01:00
2023-10-10 15:36:15 +02:00
2023-10-10 15:36:15 +02:00
2023-10-30 21:40:35 +01:00
2024-02-19 15:59:59 +01:00
2024-01-08 11:31:43 +11:00
2023-08-16 00:20:26 +10:00
2024-02-19 15:59:59 +01:00
2023-08-16 00:20:26 +10:00
2024-02-19 15:59:59 +01:00
2024-03-09 23:40:57 +11:00
2024-02-19 15:59:59 +01:00
2024-02-02 19:55:06 +01:00
2023-11-07 15:42:52 +11:00
2023-08-16 00:20:26 +10:00
2024-03-21 10:02:53 +11:00
2024-04-30 13:03:26 -04:00
2023-11-07 15:42:52 +11:00
2024-02-19 15:59:59 +01:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-02-19 15:59:59 +01:00
2024-03-05 11:29:04 -05:00
2023-08-16 00:20:26 +10:00
2024-05-07 13:07:02 +10:00
2023-08-16 00:20:26 +10:00
2024-05-07 13:07:02 +10:00
2024-01-25 11:45:24 +01:00
2024-01-22 15:58:18 +01:00
2024-02-19 15:59:59 +01:00
2023-11-07 15:42:52 +11:00
2023-08-16 00:20:26 +10:00
2024-02-19 15:59:59 +01:00
2024-04-27 11:58:02 +10:00
2024-05-03 12:05:56 +02:00
2024-05-28 14:09:40 +10:00
2023-11-07 21:16:47 +02:00
2024-05-07 13:07:02 +10:00
2024-05-02 16:22:19 +02:00
2024-05-28 14:09:40 +10:00
2024-05-02 16:22:19 +02:00
2024-04-17 11:36:38 +10:00
2024-05-31 10:58:19 +02:00
2024-04-11 20:47:07 +10:00
2024-02-19 15:59:59 +01:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-01-31 21:12:16 -05:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2024-05-04 15:06:46 +10:00
2024-04-15 09:50:47 +10:00
2024-01-03 13:38:14 +01:00
2024-05-27 12:48:15 +02:00
2024-03-19 18:23:56 +01:00
2023-11-27 16:10:43 +01:00
2024-04-25 12:09:31 +10:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2024-03-28 20:57:50 +11:00
2023-07-07 15:42:07 +10:00
2023-08-16 00:20:26 +10:00
2024-03-07 16:23:35 -05:00
2024-04-04 10:55:10 +11:00
2024-03-13 14:52:57 -04:00
2024-02-19 15:59:59 +01:00
2023-05-31 16:19:06 +02:00
2023-08-16 00:20:26 +10:00
2024-03-27 10:25:31 +11:00
2024-02-19 15:59:59 +01:00
2024-05-11 14:42:34 +03:00
2024-02-02 10:43:18 +11:00
2024-02-19 15:59:59 +01:00
2023-11-07 15:42:52 +11:00
2024-04-12 14:34:17 +02:00
2024-02-19 15:59:59 +01:00
2024-05-04 15:06:46 +10:00
2024-05-07 13:07:02 +10:00
2024-03-06 16:14:34 +01:00
2024-04-11 17:44:27 +10:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2024-04-26 13:55:38 +10:00
2024-04-30 12:12:02 +10:00
2023-08-16 00:20:26 +10:00
2024-03-05 09:54:49 +11:00
2024-03-06 16:14:34 +01:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2024-05-18 15:41:12 +02:00
2024-02-20 15:20:11 +01:00
2024-03-08 17:15:08 +11:00
2023-11-07 15:42:52 +11:00
2023-11-07 15:42:52 +11:00
2024-02-19 15:59:59 +01:00
2023-10-30 21:40:35 +01:00
2023-11-15 18:32:45 +01:00
2023-10-31 18:51:26 -06:00