81 float **r_data_velocity,
91 if (r_data_velocity) {
92 *r_data_velocity = data + offset;
94 offset += 3 * totpoint;
97 if (r_data_velocity) {
98 *r_data_velocity =
nullptr;
104 *r_data_life = data + offset;
110 *r_data_life =
nullptr;
116 *r_data_color = data + offset;
118 offset += 3 * totpoint;
122 *r_data_color =
nullptr;
151 MEM_callocN(
sizeof(
float) * data_size * totpoints,
"particle point data"));
167 float *data_vel, *data_life;
200 for (i = 0, pa = psys->
particles; i < total_particles; i++, pa++) {
204 if (i < psys->totpart && psys->
pathcache) {
229 if (i < psys->totpart) {
234 float pa_birthtime, pa_dietime;
244 mul_m4_v3(ob->world_to_object().ptr(), partco);
256 data_vel[i * 3 + 0] =
state.vel[0];
257 data_vel[i * 3 + 1] =
state.vel[1];
258 data_vel[i * 3 + 2] =
state.vel[2];
261 data_life[i] =
state.time;
276 const int totloop = mesh->corners_num;
294 int *mcorners =
static_cast<int *
>(
297 for (i = 0; i < totloop; i++) {
298 int v = corner_verts[i];
300 if (mcorners[
v] == 0) {
316 if (mcorners[i] > 0) {
317 mul_v3_fl(&data_color[i * 3], 1.0f / mcorners[i]);
329 const int totvert = mesh->verts_num;
341 if (mdef_index < 0) {
344 if (mdef_index < 0) {
349 for (i = 0, dv = mdef; i < totvert; i++, dv++, data_color += 3) {
353 for (j = 0, dw = dv->
dw; j < dv->
totweight; j++, dw++) {
354 if (dw->
def_nr == mdef_index) {
366 memcpy(data_color, normals.data(),
sizeof(
float[3]) * mesh->verts_num);
407 mul_m4_v3(ob->object_to_world().ptr(), co);
412 mul_m4_v3(ob->object_to_world().ptr(), co);
449 if (!ob || !pd->
psys) {
502 float density = 0.0f;
509 density = 3.0f * dist * dist - 2.0f * dist * dist * dist;
518 density =
sqrtf(dist);
546static void accum_density(
void *userdata,
int index,
const float co[3],
float squared_dist)
549 float density = 0.0f;
594 const float texvec[3],
602 float density = 0.0f, age = 0.0f;
603 float vec[3] = {0.0f, 0.0f, 0.0f},
col[3] = {0.0f, 0.0f, 0.0f}, co[3];
604 float turb, noise_fac;
650 co[0] = texvec[0] + noise_fac *
turb;
651 co[1] = texvec[1] + noise_fac *
turb;
652 co[2] = texvec[2] + noise_fac *
turb;
664 texres->
tin = density;
665 if (r_age !=
nullptr) {
668 if (r_vec !=
nullptr) {
671 if (r_col !=
nullptr) {
692 texres->
tin *= rgba[3];
704 texres->
tin *= rgba[3];
733 texres->
tin *= rgba[3];
754 memset(values, 0,
sizeof(
float[4]) * resolution * resolution * resolution);
765 const float size[3] = {radius, radius, radius};
772 float mat[4][4], imat[4][4];
792 for (i = 0, pa = psys->
particles; i < total_particles; i++, pa++) {
793 float co_object[3], co_min[3], co_max[3];
827 if (
object ==
nullptr) {
841 if (psys ==
nullptr) {
879 const int resolution2 = resolution * resolution;
880 const float *
min = data->min, *dim = data->dim;
882 float *values = data->values;
888 size_t z = size_t(iter);
889 for (
size_t y = 0; y < resolution; y++) {
890 for (
size_t x = 0; x < resolution; x++) {
891 size_t index =
z * resolution2 + y * resolution +
x;
893 float age, vec[3],
col[3];
897 texvec[0] += dim[0] *
float(x) /
float(resolution);
898 texvec[1] += dim[1] *
float(y) /
float(resolution);
899 texvec[2] += dim[2] *
float(
z) /
float(resolution);
905 values[index * 4 + 3] = texres.
tin;
912 const int resolution,
916 float min[3], max[3], dim[3];
922 if (
object ==
nullptr) {
931 if (dim[0] <= 0.0f || dim[1] <= 0.0f || dim[2] <= 0.0f) {
938 data.resolution = resolution;
941 data.values = values;
944 settings.use_threading = (resolution > 32);
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
CustomData interface, see also DNA_customdata_types.h.
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
const void * CustomData_get_layer_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
void CustomData_validate_layer_name(const CustomData *data, eCustomDataType type, blender::StringRef name, char *outname)
const CustomData_MeshMasks CD_MASK_BAREMESH
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
General operations, lookup, etc. for blender objects.
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_get(const Object *ob)
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, bool use_render_params)
float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime)
void psys_sim_data_free(struct ParticleSimulationData *sim)
void psys_sim_data_init(struct ParticleSimulationData *sim)
bool psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, bool always)
float BKE_scene_ctime_get(const Scene *scene)
BVHTree * BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
void BLI_bvhtree_balance(BVHTree *tree)
void BLI_bvhtree_free(BVHTree *tree)
void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
int BLI_bvhtree_range_query(const BVHTree *tree, const float co[3], float radius, BVHTree_RangeQuery callback, void *userdata)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
void unit_m4(float m[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE void copy_v4_fl(float r[4], float f)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
float BLI_noise_generic_turbulence(float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
void BLI_mutex_lock(ThreadMutex *mutex)
void BLI_mutex_unlock(ThreadMutex *mutex)
pthread_mutex_t ThreadMutex
#define INIT_MINMAX(min, max)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
#define MAX_CUSTOMDATA_LAYER_NAME
#define CD_MASK_PROP_BYTE_COLOR
#define CD_MASK_MDEFORMVERT
Object is a sort of wrapper for general info.
@ TEX_PD_FALLOFF_PARTICLE_VEL
@ TEX_PD_FALLOFF_PARTICLE_AGE
@ TEX_PD_FALLOFF_CONSTANT
@ TEX_PD_COLOR_VERTWEIGHT
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
const Depsgraph * depsgraph
draw_view in_light_buf[] float
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
static float turb(float x, float y, float z, int oct, int hard, int nb, float ampscale, float freqscale)
ObjectRuntimeHandle * runtime
struct Depsgraph * depsgraph
struct ParticleSystemModifierData * psmd
struct ParticleSystem * psys
struct ParticleCacheKey ** childcache
struct ParticleCacheKey ** pathcache
CurveMapping * density_curve
float * point_data_velocity
float falloff_speed_scale
struct CurveMapping * falloff_curve
char vertex_attribute_name[68]
static void sample_dummy_point_density(int resolution, float *values)
void RE_point_density_free(PointDensity *pd)
void RE_point_density_minmax(Depsgraph *depsgraph, PointDensity *pd, float r_min[3], float r_max[3])
void RE_point_density_sample(Depsgraph *depsgraph, PointDensity *pd, const int resolution, float *values)
void RE_point_density_fix_linking()
static ThreadMutex sample_mutex
static void pointdensity_cache_object(PointDensity *pd, Object *ob)
static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData *pdr, float *density, float *vec, float *age, float *col, CurveMapping *density_curve, float velscale)
static void accum_density(void *userdata, int index, const float co[3], float squared_dist)
static void pointdensity_cache_vertex_weight(PointDensity *pd, Object *ob, Mesh *mesh, float *data_color)
static void point_data_pointers(PointDensity *pd, float **r_data_velocity, float **r_data_life, float **r_data_color)
static void particle_system_minmax(Depsgraph *depsgraph, Scene *scene, Object *object, ParticleSystem *psys, float radius, float min[3], float max[3])
static int pointdensity(PointDensity *pd, const float texvec[3], TexResult *texres, float r_vec[3], float *r_age, float r_col[3])
void RE_point_density_cache(Depsgraph *depsgraph, PointDensity *pd)
static void pointdensity_cache_psys(Depsgraph *depsgraph, Scene *scene, PointDensity *pd, Object *ob, ParticleSystem *psys)
static void pointdensity_color(PointDensity *pd, TexResult *texres, float age, const float vec[3], const float col[3])
static float density_falloff(PointDensityRangeData *pdr, int index, float squared_dist)
static void alloc_point_data(PointDensity *pd)
static void pointdensity_cache_vertex_normal(Mesh *mesh, float *data_color)
static void cache_pointdensity(Depsgraph *depsgraph, Scene *scene, PointDensity *pd)
static void pointdensity_cache_vertex_color(PointDensity *pd, Object *, Mesh *mesh, float *data_color)
static int point_data_used(PointDensity *pd)
static void free_pointdensity(PointDensity *pd)
static void point_density_sample_func(void *__restrict data_v, const int iter, const TaskParallelTLS *__restrict)