2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-08-28 23:24:34 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup RNA
|
2011-08-28 23:24:34 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-07-22 11:27:25 +10:00
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <cstring>
|
2011-08-28 23:24:34 +00:00
|
|
|
|
2013-03-04 18:36:37 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2011-08-28 23:24:34 +00:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_define.hh"
|
2011-08-28 23:24:34 +00:00
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
#include "rna_internal.h" /* own include */
|
|
|
|
|
|
2011-08-28 23:24:34 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
|
|
|
|
# include "BKE_context.h"
|
|
|
|
|
# include "BKE_global.h"
|
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_vector.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
# include "DNA_scene_types.h"
|
|
|
|
|
# include "IMB_imbuf.h"
|
|
|
|
|
# include "IMB_imbuf_types.h"
|
2011-08-28 23:24:34 +00:00
|
|
|
# include "RE_pipeline.h"
|
2020-11-09 15:42:38 +01:00
|
|
|
# include "RE_texture.h"
|
2011-08-28 23:24:34 +00:00
|
|
|
|
2023-08-01 16:46:17 +10:00
|
|
|
static void texture_evaluate(Tex *tex, const float value[3], float r_color[4])
|
2011-09-06 10:49:55 +00:00
|
|
|
{
|
2022-01-28 13:28:31 +01:00
|
|
|
TexResult texres = {0.0f};
|
Fix #36058: Displace Modifier errors using a baked Image and displace baking inconsistency between 2.67/2.68RC and previous versions
This was in fact really nasty bug, caused by multitex_nodes
function using global variable R (which is a copy of current
renderer). this variable is not initialized to anything
meaningful for until first rendering (preview or final)
happened.
Since multitex_nodes might be used outside of render pipeline,
made it so whether CM is on or off as an argument to functions
multitex_ext_safe and multitex_ext. Now multitex_nodes() is
only shall be used for stuff happening from render pipeline!
Also needed to make some changes to other places, so all the
usages of texture sampling knows for the fact whether CM is
on or off.
And one more change is related on behavior of dispalcement,
wave, warp, weightvg modifiers and smoke. They'll be always
using CM off since texture is used for influence, not for
color.
It's rather bigger patch, but it's mostly straightforward
changes, which we really need to be done.
Reviewed by Brecht, thanks!
2013-07-15 14:47:58 +00:00
|
|
|
|
2021-06-24 15:56:58 +10:00
|
|
|
/* TODO(sergey): always use color management now. */
|
2023-07-01 16:38:46 +02:00
|
|
|
multitex_ext(tex, value, nullptr, nullptr, 1, &texres, 0, nullptr, true, false);
|
2011-09-06 10:49:55 +00:00
|
|
|
|
2022-01-28 13:28:31 +01:00
|
|
|
copy_v3_v3(r_color, texres.trgba);
|
2014-03-16 03:24:05 +11:00
|
|
|
r_color[3] = texres.tin;
|
2011-09-06 10:49:55 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-28 23:24:34 +00:00
|
|
|
#else
|
|
|
|
|
|
2011-09-06 10:49:55 +00:00
|
|
|
void RNA_api_texture(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "evaluate", "texture_evaluate");
|
2021-08-05 13:04:59 -04:00
|
|
|
RNA_def_function_ui_description(
|
|
|
|
|
func, "Evaluate the texture at the a given coordinate and returns the result");
|
|
|
|
|
|
|
|
|
|
parm = RNA_def_float_vector(
|
|
|
|
|
func,
|
|
|
|
|
"value",
|
|
|
|
|
3,
|
2023-07-01 16:38:46 +02:00
|
|
|
nullptr,
|
2021-08-05 13:04:59 -04:00
|
|
|
-FLT_MAX,
|
|
|
|
|
FLT_MAX,
|
|
|
|
|
"The coordinates (x,y,z) of the texture, in case of a 3D texture, the z value is the slice "
|
|
|
|
|
"of the texture that is evaluated. For 2D textures such as images, the z value is ignored",
|
|
|
|
|
"",
|
|
|
|
|
-1e4,
|
|
|
|
|
1e4);
|
2023-07-01 16:38:46 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2021-08-05 13:04:59 -04:00
|
|
|
|
2011-09-06 10:49:55 +00:00
|
|
|
/* return location and normal */
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_float_vector(
|
2021-08-04 19:26:01 -04:00
|
|
|
func,
|
|
|
|
|
"result",
|
|
|
|
|
4,
|
2023-07-01 16:38:46 +02:00
|
|
|
nullptr,
|
2021-08-04 19:26:01 -04:00
|
|
|
-FLT_MAX,
|
|
|
|
|
FLT_MAX,
|
2021-12-16 11:38:09 +11:00
|
|
|
"The result of the texture where (x,y,z,w) are (red, green, blue, intensity). "
|
|
|
|
|
"For grayscale textures, often intensity only will be used",
|
2023-07-01 16:38:46 +02:00
|
|
|
nullptr,
|
2021-08-04 19:26:01 -04:00
|
|
|
-1e4,
|
|
|
|
|
1e4);
|
2023-07-01 16:38:46 +02:00
|
|
|
RNA_def_parameter_flags(parm, PROP_THICK_WRAP, ParameterFlag(0));
|
2011-09-06 10:49:55 +00:00
|
|
|
RNA_def_function_output(func, parm);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-28 23:24:34 +00:00
|
|
|
#endif
|