2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2021 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2021-06-22 17:00:18 +02:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup bli
|
|
|
|
|
*/
|
|
|
|
|
|
Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).
However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.
This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.
Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).
Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.
Pull Request #110944
2023-08-09 11:39:20 +03:00
|
|
|
#include "BLI_math_base.h"
|
|
|
|
|
#include "BLI_math_time.h"
|
2021-06-22 17:00:18 +02:00
|
|
|
|
|
|
|
|
void BLI_math_time_seconds_decompose(double seconds,
|
|
|
|
|
double *r_days,
|
|
|
|
|
double *r_hours,
|
|
|
|
|
double *r_minutes,
|
|
|
|
|
double *r_seconds,
|
|
|
|
|
double *r_milliseconds)
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(r_days != NULL || r_hours != NULL || r_minutes != NULL || r_seconds != NULL ||
|
|
|
|
|
r_milliseconds != NULL);
|
|
|
|
|
|
|
|
|
|
if (r_days != NULL) {
|
|
|
|
|
seconds = modf(seconds / SECONDS_IN_DAY, r_days) * SECONDS_IN_DAY;
|
|
|
|
|
}
|
|
|
|
|
if (r_hours != NULL) {
|
|
|
|
|
seconds = modf(seconds / SECONDS_IN_HOUR, r_hours) * SECONDS_IN_HOUR;
|
|
|
|
|
}
|
|
|
|
|
if (r_minutes != NULL) {
|
|
|
|
|
seconds = modf(seconds / SECONDS_IN_MINUTE, r_minutes) * SECONDS_IN_MINUTE;
|
|
|
|
|
}
|
|
|
|
|
if (r_seconds != NULL) {
|
|
|
|
|
seconds = modf(seconds, r_seconds);
|
|
|
|
|
}
|
|
|
|
|
if (r_milliseconds != NULL) {
|
|
|
|
|
*r_milliseconds = seconds / SECONDS_IN_MILLISECONDS;
|
|
|
|
|
}
|
|
|
|
|
else if (r_seconds != NULL) {
|
|
|
|
|
*r_seconds += seconds;
|
|
|
|
|
}
|
|
|
|
|
else if (r_minutes != NULL) {
|
|
|
|
|
*r_minutes += seconds / SECONDS_IN_MINUTE;
|
|
|
|
|
}
|
|
|
|
|
else if (r_hours != NULL) {
|
|
|
|
|
*r_hours += seconds / SECONDS_IN_HOUR;
|
|
|
|
|
}
|
|
|
|
|
else if (r_days != NULL) {
|
|
|
|
|
*r_days = seconds / SECONDS_IN_DAY;
|
|
|
|
|
}
|
|
|
|
|
}
|