UI: uiBut Indeterminate State #108210

Merged
Julian Eisel merged 15 commits from Harley/blender:Indeterminate into main 2023-07-17 19:37:24 +02:00
157 changed files with 3837 additions and 2925 deletions
Showing only changes of commit 9172fe602f - Show all commits

View File

@ -666,7 +666,7 @@ if(WITH_CYCLES_DEVICE_HIPRT AND WITH_CYCLES_HIP_BINARIES)
${SRC_UTIL_HEADERS})
set(bitcode_file ${CMAKE_CURRENT_BINARY_DIR}/kernel_rt_gfx.bc)
set(hiprt_file ${CMAKE_CURRENT_BINARY_DIR}/kernel_rt_gfx.hipfb)
set(kernel_sources ${sources})
set(kernel_sources ${hiprt_sources})
set(hiprt_kernel_src "/device/hiprt/kernel.cpp")
if(WIN32)
set(hiprt_compile_command ${CMAKE_COMMAND})

View File

@ -1706,7 +1706,7 @@ enum KernelFeatureFlag : uint32_t {
KERNEL_FEATURE_TRANSPARENT = (1U << 19U),
/* Use shadow catcher. */
KERNEL_FEATURE_SHADOW_CATCHER = (1U << 29U),
KERNEL_FEATURE_SHADOW_CATCHER = (1U << 20U),
/* Light render passes. */
KERNEL_FEATURE_LIGHT_PASSES = (1U << 21U),

View File

@ -114,6 +114,9 @@ class DATA_PT_lightprobe_eevee_next(DataButtonsPanel, Panel):
elif probe.type == 'CUBEMAP':
col = layout.column()
col.prop(probe, "resolution")
sub = layout.column(align=True)
sub.prop(probe, "clip_start", text="Clipping Start")
sub.prop(probe, "clip_end", text="End")
elif probe.type == 'PLANAR':
# Currently unsupported

View File

@ -18,6 +18,7 @@
#include "DNA_customdata_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_bit_vector.hh"
#include "BLI_bitmap.h"
#include "BLI_color.hh"
#include "BLI_endian_switch.h"
@ -61,6 +62,7 @@
/* only for customdata_data_transfer_interp_normal_normals */
#include "data_transfer_intern.h"
using blender::BitVector;
using blender::float2;
using blender::ImplicitSharingInfo;
using blender::IndexRange;
@ -3909,16 +3911,17 @@ void CustomData_bmesh_set_default(CustomData *data, void **block)
}
}
static bool customdata_layer_copy_check(const CustomDataLayer &source, const CustomDataLayer &dest)
{
return source.type == dest.type && STREQ(source.name, dest.name);
}
void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
CustomData *dest,
void *src_block,
void **dest_block,
const eCustomDataMask mask_exclude)
{
/* Note that having a version of this function without a 'mask_exclude'
* would cause too much duplicate code, so add a check instead. */
const bool no_mask = (mask_exclude == 0);
if (*dest_block == nullptr) {
CustomData_bmesh_alloc_block(dest, dest_block);
if (*dest_block) {
@ -3926,51 +3929,41 @@ void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
}
}
/* copies a layer at a time */
int dest_i = 0;
for (int src_i = 0; src_i < source->totlayer; src_i++) {
BitVector<> copied_layers(dest->totlayer);
/* find the first dest layer with type >= the source type
* (this should work because layers are ordered by type)
*/
while (dest_i < dest->totlayer && dest->layers[dest_i].type < source->layers[src_i].type) {
CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
dest_i++;
for (int layer_src_i : IndexRange(source->totlayer)) {
const CustomDataLayer &layer_src = source->layers[layer_src_i];
if (CD_TYPE_AS_MASK(layer_src.type) & mask_exclude) {
continue;
}
/* if there are no more dest layers, we're done */
if (dest_i >= dest->totlayer) {
return;
}
for (int layer_dst_i : IndexRange(dest->totlayer)) {
CustomDataLayer &layer_dst = dest->layers[layer_dst_i];
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type &&
STREQ(dest->layers[dest_i].name, source->layers[src_i].name))
{
if (no_mask || ((CD_TYPE_AS_MASK(dest->layers[dest_i].type) & mask_exclude) == 0)) {
const void *src_data = POINTER_OFFSET(src_block, source->layers[src_i].offset);
void *dest_data = POINTER_OFFSET(*dest_block, dest->layers[dest_i].offset);
const LayerTypeInfo *typeInfo = layerType_getInfo(
eCustomDataType(source->layers[src_i].type));
if (typeInfo->copy) {
typeInfo->copy(src_data, dest_data, 1);
}
else {
memcpy(dest_data, src_data, typeInfo->size);
}
if (!customdata_layer_copy_check(layer_src, layer_dst)) {
continue;
}
/* if there are multiple source & dest layers of the same type,
* we don't want to copy all source layers to the same dest, so
* increment dest_i
*/
dest_i++;
copied_layers[layer_dst_i].set(true);
const void *src_data = POINTER_OFFSET(src_block, layer_src.offset);
void *dest_data = POINTER_OFFSET(*dest_block, layer_dst.offset);
const LayerTypeInfo *typeInfo = layerType_getInfo(eCustomDataType(layer_src.type));
if (typeInfo->copy) {
typeInfo->copy(src_data, dest_data, 1);
}
else {
memcpy(dest_data, src_data, typeInfo->size);
}
}
}
while (dest_i < dest->totlayer) {
CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
dest_i++;
/* Initialize dest layers that weren't in source. */
for (int layer_dst_i : IndexRange(dest->totlayer)) {
if (!copied_layers[layer_dst_i]) {
CustomData_bmesh_set_default_n(dest, dest_block, layer_dst_i);
}
}
}

View File

@ -782,8 +782,8 @@ static void surfaceGenerateGrid(DynamicPaintSurface *surface)
volume = td[0] * td[1] * td[2];
/* determine final grid size by trying to fit average 10.000 points per grid cell */
dim_factor = (float)pow(double(volume) / (double(sData->total_points) / 10000.0),
1.0 / double(axis));
dim_factor = float(
pow(double(volume) / (double(sData->total_points) / 10000.0), 1.0 / double(axis)));
/* define final grid size using dim_factor, use min 3 for active axes */
for (i = 0; i < 3; i++) {
@ -3184,7 +3184,7 @@ int dynamicPaint_createUVSurface(Scene *scene,
/* green color shows pixel face index hash */
if (uvPoint->tri_index != -1) {
pPoint->color[0] = 1.0f;
pPoint->color[1] = (float)(uvPoint->tri_index % 255) / 256.0f;
pPoint->color[1] = float(uvPoint->tri_index % 255) / 256.0f;
}
}
#endif
@ -5186,7 +5186,7 @@ static int dynamicPaint_prepareEffectStep(Depsgraph *depsgraph,
/* calculate average values (single thread) */
for (int index = 0; index < sData->total_points; index++) {
average_force += (double)(*force)[index * 4 + 3];
average_force += double((*force)[index * 4 + 3]);
}
average_force /= sData->total_points;
}
@ -5765,8 +5765,8 @@ static void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescal
average_dist *= double(wave_scale) / sData->adj_data->total_targets;
/* determine number of required steps */
steps = (int)ceil(double(WAVE_TIME_FAC * timescale * surface->wave_timescale) /
(average_dist / double(wave_speed) / 3));
steps = int(ceil(double(WAVE_TIME_FAC * timescale * surface->wave_timescale) /
(average_dist / double(wave_speed) / 3)));
CLAMP(steps, 1, 20);
timescale /= steps;

View File

@ -204,14 +204,14 @@ std::optional<Bounds<float3>> GeometrySet::compute_boundbox_without_instances()
}
if (const Mesh *mesh = this->get_mesh_for_read()) {
Bounds<float3> mesh_bounds{float3(std::numeric_limits<float>::max()),
float3(std::numeric_limits<float>::min())};
float3(std::numeric_limits<float>::lowest())};
if (BKE_mesh_wrapper_minmax(mesh, mesh_bounds.min, mesh_bounds.max)) {
bounds = bounds::merge(bounds, {mesh_bounds});
}
}
if (const Volume *volume = this->get_volume_for_read()) {
Bounds<float3> volume_bounds{float3(std::numeric_limits<float>::max()),
float3(std::numeric_limits<float>::min())};
float3(std::numeric_limits<float>::lowest())};
if (BKE_volume_min_max(volume, volume_bounds.min, volume_bounds.max)) {
bounds = bounds::merge(bounds, {volume_bounds});
}

View File

@ -851,7 +851,7 @@ void BKE_mask_layer_evaluate_animation(MaskLayer *masklay, const float ctime)
#if 0
printf("%s: exact %d %d (%d)\n",
__func__,
(int)ctime,
int(ctime),
BLI_listbase_count(&masklay->splines_shapes),
masklay_shape_a->frame);
#endif
@ -862,7 +862,7 @@ void BKE_mask_layer_evaluate_animation(MaskLayer *masklay, const float ctime)
#if 0
printf("%s: tween %d %d (%d %d)\n",
__func__,
(int)ctime,
int(ctime),
BLI_listbase_count(&masklay->splines_shapes),
masklay_shape_a->frame,
masklay_shape_b->frame);

View File

@ -3855,7 +3855,7 @@ bool BKE_object_boundbox_calc_from_evaluated_geometry(Object *ob)
}
else if (const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob)) {
Bounds<float3> mesh_bounds{float3(std::numeric_limits<float>::max()),
float3(std::numeric_limits<float>::min())};
float3(std::numeric_limits<float>::lowest())};
if (BKE_mesh_wrapper_minmax(mesh_eval, mesh_bounds.min, mesh_bounds.max)) {
bounds = bounds::merge(bounds, {mesh_bounds});
}

View File

@ -12,6 +12,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_brush_types.h"
#include "DNA_defaults.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@ -1131,13 +1132,10 @@ bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint)
}
else if ((Sculpt **)r_paint == &ts->sculpt) {
Sculpt *data = MEM_cnew<Sculpt>(__func__);
*data = *DNA_struct_default_get(Sculpt);
paint = &data->paint;
/* Turn on X plane mirror symmetry by default. */
paint->symmetry_flags |= PAINT_SYMM_X;
/* Make sure at least dyntopo subdivision is enabled. */
data->flags |= SCULPT_DYNTOPO_SUBDIVIDE | SCULPT_DYNTOPO_COLLAPSE;
}
else if ((GpPaint **)r_paint == &ts->gp_paint) {
GpPaint *data = MEM_cnew<GpPaint>(__func__);
@ -2115,22 +2113,29 @@ void BKE_sculpt_toolsettings_data_ensure(Scene *scene)
BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->sculpt);
Sculpt *sd = scene->toolsettings->sculpt;
if (!sd->detail_size) {
sd->detail_size = 12;
const Sculpt *defaults = DNA_struct_default_get(Sculpt);
/* We have file versioning code here for historical
* reasons. Don't add more checks here, do it properly
* in blenloader.
*/
if (sd->automasking_start_normal_limit == 0.0f) {
sd->automasking_start_normal_limit = defaults->automasking_start_normal_limit;
sd->automasking_start_normal_falloff = defaults->automasking_start_normal_falloff;
sd->automasking_view_normal_limit = defaults->automasking_view_normal_limit;
sd->automasking_view_normal_falloff = defaults->automasking_view_normal_limit;
}
if (!sd->detail_percent) {
sd->detail_percent = 25;
if (sd->detail_percent == 0.0f) {
sd->detail_percent = defaults->detail_percent;
}
if (sd->constant_detail == 0.0f) {
sd->constant_detail = 3.0f;
sd->constant_detail = defaults->constant_detail;
}
if (!sd->automasking_start_normal_limit) {
sd->automasking_start_normal_limit = 20.0f / 180.0f * M_PI;
sd->automasking_start_normal_falloff = 0.25f;
sd->automasking_view_normal_limit = 90.0f / 180.0f * M_PI;
sd->automasking_view_normal_falloff = 0.25f;
if (sd->detail_size == 0.0f) {
sd->detail_size = defaults->detail_size;
}
/* Set sane default tiling offsets. */
@ -2143,6 +2148,7 @@ void BKE_sculpt_toolsettings_data_ensure(Scene *scene)
if (!sd->paint.tile_offset[2]) {
sd->paint.tile_offset[2] = 1.0f;
}
if (!sd->automasking_cavity_curve || !sd->automasking_cavity_curve_op) {
BKE_sculpt_check_cavity_curves(sd);
}

View File

@ -896,7 +896,7 @@ template<typename T> static std::optional<T> deserialize_int(const io::serialize
return std::nullopt;
}
const int64_t value = io_int->value();
if (value < std::numeric_limits<T>::min()) {
if (value < std::numeric_limits<T>::lowest()) {
return std::nullopt;
}
if (value > std::numeric_limits<T>::max()) {

View File

@ -44,7 +44,7 @@ using ePolyFill2DTestFlag = enum ePolyFill2DTestFlag {
/* -------------------------------------------------------------------- */
/* test utility functions */
#define TRI_ERROR_VALUE (uint) - 1
#define TRI_ERROR_VALUE uint(-1)
static void test_valid_polyfill_prepare(uint tris[][3], uint tris_num)
{

View File

@ -163,10 +163,10 @@ static void do_versions_image_settings_2_60(Scene *sce)
ImageFormatData *imf = &sce->r.im_format;
/* we know no data loss happens here, the old values were in char range */
imf->imtype = (char)rd->imtype;
imf->planes = (char)rd->planes;
imf->compress = (char)rd->quality;
imf->quality = (char)rd->quality;
imf->imtype = char(rd->imtype);
imf->planes = char(rd->planes);
imf->compress = char(rd->quality);
imf->quality = char(rd->quality);
/* default, was stored in multiple places, may override later */
imf->depth = R_IMF_CHAN_DEPTH_8;
@ -1348,8 +1348,8 @@ if (!MAIN_VERSION_ATLEAST(bmain, 263, 17)) {
if (node->storage == nullptr) {
NodeMask *data = MEM_cnew<NodeMask>(__func__);
/* move settings into own struct */
data->size_x = (int)node->custom3;
data->size_y = (int)node->custom4;
data->size_x = int(node->custom3);
data->size_y = int(node->custom4);
node->custom3 = 0.5f; /* default shutter */
node->storage = data;
}

View File

@ -20,6 +20,7 @@
#include "DNA_scene_types.h"
#include "DNA_world_types.h"
#include "DNA_defaults.h"
#include "DNA_genfile.h"
#include "BLI_assert.h"

View File

@ -24,6 +24,7 @@
#include "DNA_camera_types.h"
#include "DNA_curveprofile_types.h"
#include "DNA_defaults.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_light_types.h"
#include "DNA_mask_types.h"
@ -348,7 +349,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene)
}
if (ts->sculpt) {
ts->sculpt->paint.symmetry_flags |= PAINT_SYMMETRY_FEATHER;
ts->sculpt->flags = static_cast<const Sculpt *>(DNA_struct_default_get(Sculpt))->flags;
}
/* Correct default startup UVs. */

View File

@ -495,6 +495,7 @@ set(GLSL_SRC
engines/eevee_next/shaders/eevee_geom_curves_vert.glsl
engines/eevee_next/shaders/eevee_geom_gpencil_vert.glsl
engines/eevee_next/shaders/eevee_geom_mesh_vert.glsl
engines/eevee_next/shaders/eevee_geom_point_cloud_vert.glsl
engines/eevee_next/shaders/eevee_geom_world_vert.glsl
engines/eevee_next/shaders/eevee_hiz_debug_frag.glsl
engines/eevee_next/shaders/eevee_hiz_update_comp.glsl

View File

@ -74,7 +74,7 @@ void Film::init_aovs()
for (ViewLayerAOV *aov : aovs) {
bool is_value = (aov->type == AOV_TYPE_VALUE);
uint &index = is_value ? aovs_info.value_len : aovs_info.color_len;
int &index = is_value ? aovs_info.value_len : aovs_info.color_len;
uint &hash = is_value ? aovs_info.hash_value[index].x : aovs_info.hash_color[index].x;
hash = BLI_hash_string(aov->name);
index++;

View File

@ -23,6 +23,8 @@
#include "eevee_engine.h"
#include "eevee_instance.hh"
#include "DNA_particle_types.h"
namespace blender::eevee {
/* -------------------------------------------------------------------- */
@ -175,7 +177,7 @@ void Instance::scene_sync()
void Instance::object_sync(Object *ob)
{
const bool is_renderable_type = ELEM(
ob->type, OB_CURVES, OB_GPENCIL_LEGACY, OB_MESH, OB_LAMP, OB_LIGHTPROBE);
ob->type, OB_CURVES, OB_GPENCIL_LEGACY, OB_MESH, OB_POINTCLOUD, OB_LAMP, OB_LIGHTPROBE);
const int ob_visibility = DRW_object_visibility_in_active_context(ob);
const bool partsys_is_visible = (ob_visibility & OB_VISIBLE_PARTICLES) != 0 &&
(ob->type == OB_MESH);
@ -193,9 +195,24 @@ void Instance::object_sync(Object *ob)
ObjectHandle &ob_handle = sync.sync_object(ob);
if (partsys_is_visible && ob != DRW_context_state_get()->object_edit) {
int sub_key = 1;
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_ParticleSystem) {
sync.sync_curves(ob, ob_handle, res_handle, md);
ParticleSystem *particle_sys = reinterpret_cast<ParticleSystemModifierData *>(md)->psys;
ParticleSettings *part_settings = particle_sys->part;
const int draw_as = (part_settings->draw_as == PART_DRAW_REND) ? part_settings->ren_as :
part_settings->draw_as;
if (draw_as != PART_DRAW_PATH ||
!DRW_object_is_visible_psys_in_active_context(ob, particle_sys)) {
continue;
}
ObjectHandle _ob_handle = {0};
_ob_handle.object_key = ObjectKey(ob_handle.object_key.ob, sub_key++);
_ob_handle.recalc = particle_sys->recalc;
ResourceHandle _res_handle = manager->resource_handle(float4x4(ob->object_to_world));
sync.sync_curves(ob, _ob_handle, _res_handle, md, particle_sys);
}
}
}
@ -208,6 +225,8 @@ void Instance::object_sync(Object *ob)
case OB_MESH:
sync.sync_mesh(ob, ob_handle, res_handle, ob_ref);
break;
case OB_POINTCLOUD:
sync.sync_point_cloud(ob, ob_handle, res_handle, ob_ref);
case OB_VOLUME:
break;
case OB_CURVES:
@ -268,9 +287,18 @@ void Instance::render_sync()
/* TODO: Remove old draw manager calls. */
DRW_render_instance_buffer_finish();
/* Also we weed to have a correct FBO bound for #DRW_hair_update */
// GPU_framebuffer_bind();
// DRW_hair_update();
DRW_curves_update();
}
bool Instance::do_probe_sync() const
{
if (materials.queued_shaders_count > 0) {
return false;
}
if (!reflection_probes.update_probes_this_sample_) {
return false;
}
return true;
}
/** \} */
@ -297,7 +325,9 @@ void Instance::render_sample()
sampling.step();
capture_view.render();
capture_view.render_world();
capture_view.render_probes();
main_view.render();
motion_blur.step();
@ -379,6 +409,12 @@ void Instance::render_read_result(RenderLayer *render_layer, const char *view_na
void Instance::render_frame(RenderLayer *render_layer, const char *view_name)
{
/* TODO(jbakker): should we check on the subtype as well? Now it also populates even when there
* are other light probes in the scene. */
if (DEG_id_type_any_exists(this->depsgraph, ID_LP)) {
reflection_probes.update_probes_next_sample_ = true;
}
while (!sampling.finished()) {
this->render_sample();
@ -523,7 +559,7 @@ void Instance::light_bake_irradiance(
render_sync();
manager->end_sync();
capture_view.render();
capture_view.render_world();
irradiance_cache.bake.surfels_create(probe);
irradiance_cache.bake.surfels_lights_eval();

View File

@ -147,6 +147,11 @@ class Instance {
void object_sync(Object *ob);
void end_sync();
/**
* Return true when probe pipeline is used during this sample.
*/
bool do_probe_sync() const;
/* Render. */
void render_sync();

View File

@ -158,7 +158,8 @@ void MaterialModule::begin_sync()
MaterialPass MaterialModule::material_pass_get(Object *ob,
::Material *blender_mat,
eMaterialPipeline pipeline_type,
eMaterialGeometry geometry_type)
eMaterialGeometry geometry_type,
bool probe_capture)
{
bNodeTree *ntree = (blender_mat->use_nodes && blender_mat->nodetree != nullptr) ?
blender_mat->nodetree :
@ -205,11 +206,13 @@ MaterialPass MaterialModule::material_pass_get(Object *ob,
matpass.sub_pass = nullptr;
}
else {
ShaderKey shader_key(matpass.gpumat, geometry_type, pipeline_type, blender_mat->blend_flag);
ShaderKey shader_key(
matpass.gpumat, geometry_type, pipeline_type, blender_mat->blend_flag, probe_capture);
PassMain::Sub *shader_sub = shader_map_.lookup_or_add_cb(shader_key, [&]() {
/* First time encountering this shader. Create a sub that will contain materials using it. */
return inst_.pipelines.material_add(ob, blender_mat, matpass.gpumat, pipeline_type);
return inst_.pipelines.material_add(
ob, blender_mat, matpass.gpumat, pipeline_type, probe_capture);
});
if (shader_sub != nullptr) {
@ -248,12 +251,23 @@ Material &MaterialModule::material_sync(Object *ob,
* to avoid this shader compilation in another context. */
mat.shading = material_pass_get(ob, blender_mat, surface_pipe, geometry_type);
mat.capture = material_pass_get(ob, blender_mat, MAT_PIPE_CAPTURE, geometry_type);
mat.probe_prepass = MaterialPass();
mat.probe_shading = MaterialPass();
}
else {
/* Order is important for transparent. */
mat.prepass = material_pass_get(ob, blender_mat, prepass_pipe, geometry_type);
mat.shading = material_pass_get(ob, blender_mat, surface_pipe, geometry_type);
mat.capture = MaterialPass();
mat.probe_prepass = MaterialPass();
mat.probe_shading = MaterialPass();
if (inst_.do_probe_sync()) {
mat.probe_prepass = material_pass_get(
ob, blender_mat, MAT_PIPE_DEFERRED_PREPASS, geometry_type, true);
mat.probe_shading = material_pass_get(
ob, blender_mat, MAT_PIPE_DEFERRED, geometry_type, true);
}
}
if (blender_mat->blend_shadow == MA_BS_NONE) {

View File

@ -39,6 +39,7 @@ enum eMaterialPipeline {
enum eMaterialGeometry {
MAT_GEOM_MESH = 0,
MAT_GEOM_POINT_CLOUD,
MAT_GEOM_CURVES,
MAT_GEOM_GPENCIL,
MAT_GEOM_VOLUME,
@ -102,6 +103,8 @@ static inline eMaterialGeometry to_material_geometry(const Object *ob)
return MAT_GEOM_VOLUME;
case OB_GPENCIL_LEGACY:
return MAT_GEOM_GPENCIL;
case OB_POINTCLOUD:
return MAT_GEOM_POINT_CLOUD;
default:
return MAT_GEOM_MESH;
}
@ -149,12 +152,14 @@ struct ShaderKey {
ShaderKey(GPUMaterial *gpumat,
eMaterialGeometry geometry,
eMaterialPipeline pipeline,
char blend_flags)
char blend_flags,
bool probe_capture)
{
shader = GPU_material_get_shader(gpumat);
options = blend_flags;
options = (options << 6u) | shader_uuid_from_material_type(pipeline, geometry);
options = (options << 16u) | shader_closure_bits_from_flag(gpumat);
options = (options << 1u) | probe_capture;
}
uint64_t hash() const
@ -214,7 +219,7 @@ struct MaterialPass {
struct Material {
bool is_alpha_blend_transparent;
MaterialPass shadow, shading, prepass, capture;
MaterialPass shadow, shading, prepass, capture, probe_prepass, probe_shading;
};
struct MaterialArray {
@ -268,7 +273,8 @@ class MaterialModule {
MaterialPass material_pass_get(Object *ob,
::Material *blender_mat,
eMaterialPipeline pipeline_type,
eMaterialGeometry geometry_type);
eMaterialGeometry geometry_type,
bool probe_capture = false);
};
/** \} */

View File

@ -63,7 +63,8 @@ void BackgroundPipeline::render(View &view)
void WorldPipeline::sync(GPUMaterial *gpumat)
{
const int2 extent(1);
constexpr eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_WRITE;
constexpr eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_WRITE |
GPU_TEXTURE_USAGE_SHADER_READ;
dummy_cryptomatte_tx_.ensure_2d(GPU_RGBA32F, extent, usage);
dummy_renderpass_tx_.ensure_2d(GPU_RGBA16F, extent, usage);
dummy_aov_color_tx_.ensure_2d_array(GPU_RGBA16F, extent, 1, usage);
@ -557,6 +558,201 @@ void DeferredPipeline::render(View &view,
/** \} */
/* -------------------------------------------------------------------- */
/** \name Deferred Probe Layer
* \{ */
void DeferredProbeLayer::begin_sync()
{
{
prepass_ps_.init();
{
/* Common resources. */
/* Textures. */
prepass_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
/* Uniform Buffer. */
prepass_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get());
inst_.velocity.bind_resources(&prepass_ps_);
inst_.sampling.bind_resources(&prepass_ps_);
}
DRWState state_depth_only = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
prepass_double_sided_ps_ = &prepass_ps_.sub("DoubleSided");
prepass_double_sided_ps_->state_set(state_depth_only);
prepass_single_sided_ps_ = &prepass_ps_.sub("SingleSided");
prepass_single_sided_ps_->state_set(state_depth_only | DRW_STATE_CULL_BACK);
}
{
gbuffer_ps_.init();
gbuffer_ps_.clear_stencil(0x00u);
gbuffer_ps_.state_stencil(0xFFu, 0xFFu, 0xFFu);
{
/* Common resources. */
/* G-buffer. */
gbuffer_ps_.bind_image(GBUF_CLOSURE_SLOT, &inst_.gbuffer.closure_tx);
gbuffer_ps_.bind_image(GBUF_COLOR_SLOT, &inst_.gbuffer.color_tx);
/* RenderPasses & AOVs. */
gbuffer_ps_.bind_image(RBUFS_COLOR_SLOT, &inst_.render_buffers.rp_color_tx);
gbuffer_ps_.bind_image(RBUFS_VALUE_SLOT, &inst_.render_buffers.rp_value_tx);
/* Cryptomatte. */
gbuffer_ps_.bind_image(RBUFS_CRYPTOMATTE_SLOT, &inst_.render_buffers.cryptomatte_tx);
/* Storage Buffer. */
/* Textures. */
gbuffer_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
/* Uniform Buffer. */
gbuffer_ps_.bind_ubo(CAMERA_BUF_SLOT, inst_.camera.ubo_get());
gbuffer_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data);
inst_.sampling.bind_resources(&gbuffer_ps_);
inst_.hiz_buffer.bind_resources(&gbuffer_ps_);
inst_.ambient_occlusion.bind_resources(&gbuffer_ps_);
inst_.cryptomatte.bind_resources(&gbuffer_ps_);
}
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM | DRW_STATE_DEPTH_EQUAL |
DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_ALWAYS;
gbuffer_double_sided_ps_ = &gbuffer_ps_.sub("DoubleSided");
gbuffer_double_sided_ps_->state_set(state);
gbuffer_single_sided_ps_ = &gbuffer_ps_.sub("SingleSided");
gbuffer_single_sided_ps_->state_set(state | DRW_STATE_CULL_BACK);
}
/* Light eval resources.*/
{
eGPUTextureUsage usage = GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_SHADER_WRITE;
dummy_light_tx_.ensure_2d(GPU_RGBA16F, int2(1), usage);
}
}
void DeferredProbeLayer::end_sync()
{
if (closure_bits_ & (CLOSURE_DIFFUSE | CLOSURE_REFLECTION)) {
const bool is_last_eval_pass = !(closure_bits_ & CLOSURE_SSS);
eval_light_ps_.init();
/* Use stencil test to reject pixel not written by this layer. */
eval_light_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_NEQUAL |
DRW_STATE_BLEND_CUSTOM);
eval_light_ps_.state_stencil(0x00u, 0x00u, (CLOSURE_DIFFUSE | CLOSURE_REFLECTION));
eval_light_ps_.shader_set(inst_.shaders.static_shader_get(DEFERRED_LIGHT_DIFFUSE_ONLY));
eval_light_ps_.bind_image("out_diffuse_light_img", dummy_light_tx_);
eval_light_ps_.bind_image("out_specular_light_img", dummy_light_tx_);
eval_light_ps_.bind_texture("gbuffer_closure_tx", &inst_.gbuffer.closure_tx);
eval_light_ps_.bind_texture("gbuffer_color_tx", &inst_.gbuffer.color_tx);
eval_light_ps_.push_constant("is_last_eval_pass", is_last_eval_pass);
eval_light_ps_.bind_image(RBUFS_COLOR_SLOT, &inst_.render_buffers.rp_color_tx);
eval_light_ps_.bind_image(RBUFS_VALUE_SLOT, &inst_.render_buffers.rp_value_tx);
eval_light_ps_.bind_texture(RBUFS_UTILITY_TEX_SLOT, inst_.pipelines.utility_tx);
eval_light_ps_.bind_texture(SSS_TRANSMITTANCE_TEX_SLOT,
inst_.subsurface.transmittance_tx_get());
eval_light_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data);
inst_.lights.bind_resources(&eval_light_ps_);
inst_.shadows.bind_resources(&eval_light_ps_);
inst_.sampling.bind_resources(&eval_light_ps_);
inst_.hiz_buffer.bind_resources(&eval_light_ps_);
inst_.ambient_occlusion.bind_resources(&eval_light_ps_);
inst_.reflection_probes.bind_resources(&eval_light_ps_);
inst_.irradiance_cache.bind_resources(&eval_light_ps_);
eval_light_ps_.barrier(GPU_BARRIER_TEXTURE_FETCH | GPU_BARRIER_SHADER_IMAGE_ACCESS);
eval_light_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3);
}
}
PassMain::Sub *DeferredProbeLayer::prepass_add(::Material *blender_mat, GPUMaterial *gpumat)
{
PassMain::Sub *pass = (blender_mat->blend_flag & MA_BL_CULL_BACKFACE) ?
prepass_single_sided_ps_ :
prepass_double_sided_ps_;
return &pass->sub(GPU_material_get_name(gpumat));
}
PassMain::Sub *DeferredProbeLayer::material_add(::Material *blender_mat, GPUMaterial *gpumat)
{
eClosureBits closure_bits = shader_closure_bits_from_flag(gpumat);
closure_bits_ |= closure_bits;
PassMain::Sub *pass = (blender_mat->blend_flag & MA_BL_CULL_BACKFACE) ?
gbuffer_single_sided_ps_ :
gbuffer_double_sided_ps_;
pass = &pass->sub(GPU_material_get_name(gpumat));
pass->state_stencil(closure_bits, 0xFFu, 0xFFu);
return pass;
}
void DeferredProbeLayer::render(View &view,
Framebuffer &prepass_fb,
Framebuffer &combined_fb,
int2 extent)
{
GPU_framebuffer_bind(prepass_fb);
inst_.manager->submit(prepass_ps_, view);
inst_.hiz_buffer.set_dirty();
inst_.lights.set_view(view, extent);
inst_.shadows.set_view(view);
inst_.irradiance_cache.set_view(view);
inst_.gbuffer.acquire(extent, closure_bits_);
GPU_framebuffer_bind(combined_fb);
inst_.manager->submit(gbuffer_ps_, view);
inst_.manager->submit(eval_light_ps_, view);
inst_.gbuffer.release();
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Deferred Probe Pipeline
*
* Closure data are written to intermediate buffer allowing screen space processing.
* \{ */
void DeferredProbePipeline::begin_sync()
{
opaque_layer_.begin_sync();
}
void DeferredProbePipeline::end_sync()
{
opaque_layer_.end_sync();
}
PassMain::Sub *DeferredProbePipeline::prepass_add(::Material *blender_mat, GPUMaterial *gpumat)
{
return opaque_layer_.prepass_add(blender_mat, gpumat);
}
PassMain::Sub *DeferredProbePipeline::material_add(::Material *blender_mat, GPUMaterial *gpumat)
{
return opaque_layer_.material_add(blender_mat, gpumat);
}
void DeferredProbePipeline::render(View &view,
Framebuffer &prepass_fb,
Framebuffer &combined_fb,
int2 extent)
{
GPU_debug_group_begin("Probe.Render");
opaque_layer_.render(view, prepass_fb, combined_fb, extent);
GPU_debug_group_end();
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Capture Pipeline
*

View File

@ -210,6 +210,58 @@ class DeferredPipeline {
/** \} */
/* -------------------------------------------------------------------- */
/** \name Deferred Probe Capture.
* \{ */
class DeferredProbeLayer {
private:
Instance &inst_;
PassMain prepass_ps_ = {"Prepass"};
PassMain::Sub *prepass_single_sided_ps_ = nullptr;
PassMain::Sub *prepass_double_sided_ps_ = nullptr;
PassMain gbuffer_ps_ = {"Shading"};
PassMain::Sub *gbuffer_single_sided_ps_ = nullptr;
PassMain::Sub *gbuffer_double_sided_ps_ = nullptr;
PassSimple eval_light_ps_ = {"EvalLights"};
/* Closures bits from the materials in this pass. */
eClosureBits closure_bits_;
Texture dummy_light_tx_ = {"dummy_light_accum_tx"};
public:
DeferredProbeLayer(Instance &inst) : inst_(inst){};
void begin_sync();
void end_sync();
PassMain::Sub *prepass_add(::Material *blender_mat, GPUMaterial *gpumat);
PassMain::Sub *material_add(::Material *blender_mat, GPUMaterial *gpumat);
void render(View &view, Framebuffer &prepass_fb, Framebuffer &combined_fb, int2 extent);
};
class DeferredProbePipeline {
private:
DeferredProbeLayer opaque_layer_;
public:
DeferredProbePipeline(Instance &inst) : opaque_layer_(inst){};
void begin_sync();
void end_sync();
PassMain::Sub *prepass_add(::Material *material, GPUMaterial *gpumat);
PassMain::Sub *material_add(::Material *material, GPUMaterial *gpumat);
void render(View &view, Framebuffer &prepass_fb, Framebuffer &combined_fb, int2 extent);
};
/** \} */
/* -------------------------------------------------------------------- */
/** \name Capture Pipeline
*
@ -317,6 +369,7 @@ class PipelineModule {
public:
BackgroundPipeline background;
WorldPipeline world;
DeferredProbePipeline probe;
DeferredPipeline deferred;
ForwardPipeline forward;
ShadowPipeline shadow;
@ -328,6 +381,7 @@ class PipelineModule {
PipelineModule(Instance &inst)
: background(inst),
world(inst),
probe(inst),
deferred(inst),
forward(inst),
shadow(inst),
@ -335,6 +389,7 @@ class PipelineModule {
void begin_sync()
{
probe.begin_sync();
deferred.begin_sync();
forward.sync();
shadow.sync();
@ -343,14 +398,27 @@ class PipelineModule {
void end_sync()
{
probe.end_sync();
deferred.end_sync();
}
PassMain::Sub *material_add(Object *ob,
::Material *blender_mat,
GPUMaterial *gpumat,
eMaterialPipeline pipeline_type)
eMaterialPipeline pipeline_type,
bool probe_capture)
{
if (probe_capture) {
switch (pipeline_type) {
case MAT_PIPE_DEFERRED_PREPASS:
return probe.prepass_add(blender_mat, gpumat);
case MAT_PIPE_DEFERRED:
return probe.material_add(blender_mat, gpumat);
default:
break;
}
}
switch (pipeline_type) {
case MAT_PIPE_DEFERRED_PREPASS:
return deferred.prepass_add(blender_mat, gpumat, false);

View File

@ -5,13 +5,6 @@
#include "eevee_reflection_probes.hh"
#include "eevee_instance.hh"
/* Generate dummy light probe texture.
*
* Baking of Light probes aren't implemented yet. For testing purposes this can be enabled to
* generate a dummy texture.
*/
#define GENERATE_DUMMY_LIGHT_PROBE_TEXTURE false
namespace blender::eevee {
void ReflectionProbeModule::init()
@ -36,29 +29,29 @@ void ReflectionProbeModule::init()
world_probe.do_update_data = true;
world_probe.do_render = true;
world_probe.index = 0;
world_probe.clipping_distances = float2(1.0f, 10.0f);
probes_.add(world_object_key_, world_probe);
probes_tx_.ensure_2d_array(GPU_RGBA16F,
int2(max_resolution_),
init_num_probes_,
GPU_TEXTURE_USAGE_SHADER_WRITE,
GPU_TEXTURE_USAGE_SHADER_WRITE | GPU_TEXTURE_USAGE_SHADER_READ,
nullptr,
REFLECTION_PROBE_MIPMAP_LEVELS);
9999);
GPU_texture_mipmap_mode(probes_tx_, true, true);
/* Cube-map is half of the resolution of the octahedral map. */
cubemap_tx_.ensure_cube(
GPU_RGBA16F, max_resolution_ / 2, GPU_TEXTURE_USAGE_ATTACHMENT, nullptr, 9999);
GPU_texture_mipmap_mode(cubemap_tx_, true, true);
recalc_lod_factors();
data_buf_.push_update();
}
{
PassSimple &pass = remap_ps_;
pass.init();
pass.shader_set(instance_.shaders.static_shader_get(REFLECTION_PROBE_REMAP));
pass.bind_texture("cubemap_tx", cubemap_tx_);
pass.bind_image("octahedral_img", probes_tx_);
pass.bind_texture("cubemap_tx", &cubemap_tx_);
pass.bind_image("octahedral_img", &probes_tx_);
pass.bind_ssbo(REFLECTION_PROBE_BUF_SLOT, data_buf_);
pass.push_constant("reflection_probe_index", &reflection_probe_index_);
pass.dispatch(&dispatch_probe_pack_);
}
}
@ -69,39 +62,24 @@ void ReflectionProbeModule::begin_sync()
reflection_probe.is_probe_used = false;
}
}
update_probes_this_sample_ = false;
if (update_probes_next_sample_) {
update_probes_this_sample_ = true;
instance_.sampling.reset();
}
}
int ReflectionProbeModule::needed_layers_get() const
{
const int max_probe_data_index = reflection_probe_data_index_max();
int max_layer = 0;
for (const ReflectionProbeData &data :
Span<ReflectionProbeData>(data_buf_.data(), max_probe_data_index + 1))
{
max_layer = max_ii(max_layer, data.layer);
for (const ReflectionProbe &probe : probes_.values()) {
const ReflectionProbeData &probe_data = data_buf_[probe.index];
max_layer = max_ii(max_layer, probe_data.layer);
}
return max_layer + 1;
}
void ReflectionProbeModule::sync(ReflectionProbe &probe)
{
switch (probe.type) {
case ReflectionProbe::Type::World: {
break;
}
case ReflectionProbe::Type::Probe: {
if (probe.do_render) {
upload_dummy_texture(probe);
probe.do_render = false;
}
break;
}
case ReflectionProbe::Type::Unused: {
break;
}
}
}
static int layer_subdivision_for(const int max_resolution,
const eLightProbeResolution probe_resolution)
{
@ -119,7 +97,6 @@ void ReflectionProbeModule::sync_world(::World *world, WorldHandle & /*ob_handle
void ReflectionProbeModule::sync_object(Object *ob, ObjectHandle &ob_handle)
{
#if GENERATE_DUMMY_LIGHT_PROBE_TEXTURE
const ::LightProbe *light_probe = (::LightProbe *)ob->data;
if (light_probe->type != LIGHTPROBE_TYPE_CUBE) {
return;
@ -128,15 +105,27 @@ void ReflectionProbeModule::sync_object(Object *ob, ObjectHandle &ob_handle)
int subdivision = layer_subdivision_for(
max_resolution_, static_cast<eLightProbeResolution>(light_probe->resolution));
ReflectionProbe &probe = find_or_insert(ob_handle, subdivision);
probe.do_update_data |= is_dirty;
probe.do_render |= is_dirty;
probe.is_probe_used = true;
/* Only update data when rerendering the probes to reduce flickering. */
if (!instance_.do_probe_sync()) {
update_probes_next_sample_ = true;
return;
}
probe.do_update_data |= is_dirty;
probe.clipping_distances = float2(light_probe->clipsta, light_probe->clipend);
ReflectionProbeData &probe_data = data_buf_[probe.index];
if (probe_data.layer_subdivision != subdivision) {
ReflectionProbeData new_probe_data = find_empty_reflection_probe_data(subdivision);
probe_data.layer = new_probe_data.layer;
probe_data.layer_subdivision = new_probe_data.layer_subdivision;
probe_data.area_index = new_probe_data.area_index;
}
probe_data.pos = float3(float4x4(ob->object_to_world) * float4(0.0, 0.0, 0.0, 1.0));
probe_data.layer_subdivision = subdivision;
#else
UNUSED_VARS(ob, ob_handle);
#endif
}
ReflectionProbe &ReflectionProbeModule::find_or_insert(ObjectHandle &ob_handle,
@ -290,62 +279,32 @@ void ReflectionProbeModule::end_sync()
{
remove_unused_probes();
const bool probe_sync_done = instance_.do_probe_sync();
if (!probe_sync_done) {
return;
}
int number_layers_needed = needed_layers_get();
int current_layers = probes_tx_.depth();
bool resize_layers = current_layers < number_layers_needed;
if (resize_layers) {
/* TODO: Create new texture and copy previous texture so we don't need to rerender all the
* probes.*/
probes_tx_.ensure_2d_array(GPU_RGBA16F,
int2(max_resolution_),
number_layers_needed,
GPU_TEXTURE_USAGE_SHADER_WRITE,
GPU_TEXTURE_USAGE_SHADER_WRITE | GPU_TEXTURE_USAGE_SHADER_READ,
nullptr,
REFLECTION_PROBE_MIPMAP_LEVELS);
9999);
GPU_texture_mipmap_mode(probes_tx_, true, true);
for (ReflectionProbe &probe : probes_.values()) {
probe.do_update_data = true;
probe.do_render = true;
}
}
recalc_lod_factors();
data_buf_.push_update();
/* Regenerate mipmaps when a probe texture is updated. It can be postponed when the world probe
* is also updated. In this case it would happen as part of the WorldProbePipeline. */
bool regenerate_mipmaps = false;
bool regenerate_mipmaps_postponed = false;
for (ReflectionProbe &probe : probes_.values()) {
if (resize_layers) {
probe.do_update_data = true;
probe.do_render = true;
}
if (!probe.needs_update()) {
continue;
}
sync(probe);
switch (probe.type) {
case ReflectionProbe::Type::World:
regenerate_mipmaps_postponed = true;
break;
case ReflectionProbe::Type::Probe:
regenerate_mipmaps = probe.do_render;
break;
case ReflectionProbe::Type::Unused:
BLI_assert_unreachable();
break;
}
probe.do_update_data = false;
}
if (regenerate_mipmaps) {
GPU_memory_barrier(GPU_BARRIER_TEXTURE_UPDATE);
if (!regenerate_mipmaps_postponed) {
GPU_texture_update_mipmap_chain(probes_tx_);
}
}
}
void ReflectionProbeModule::remove_unused_probes()
@ -470,57 +429,73 @@ std::ostream &operator<<(std::ostream &os, const ReflectionProbe &probe)
return os;
}
void ReflectionProbeModule::upload_dummy_texture(const ReflectionProbe &probe)
{
const ReflectionProbeData &probe_data = data_buf_[probe.index];
const int resolution = max_resolution_ >> probe_data.layer_subdivision;
float4 *data = static_cast<float4 *>(
MEM_mallocN(sizeof(float4) * resolution * resolution, __func__));
/* Generate dummy checker pattern. */
int index = 0;
const int BLOCK_SIZE = max_ii(1024 >> probe_data.layer_subdivision, 1);
for (int y : IndexRange(resolution)) {
for (int x : IndexRange(resolution)) {
int tx = (x / BLOCK_SIZE) & 1;
int ty = (y / BLOCK_SIZE) & 1;
bool solid = (tx + ty) & 1;
if (solid) {
data[index] = float4((probe.index & 1) == 0 ? 0.0f : 1.0f,
(probe.index & 2) == 0 ? 0.0f : 1.0f,
(probe.index & 4) == 0 ? 0.0f : 1.0f,
1.0f);
}
else {
data[index] = float4(0.0f);
}
index++;
}
}
/* Upload the checker pattern. */
int probes_per_dimension = 1 << probe_data.layer_subdivision;
int2 probe_area_pos(probe_data.area_index % probes_per_dimension,
probe_data.area_index / probes_per_dimension);
int2 pos = probe_area_pos * int2(max_resolution_ / probes_per_dimension);
GPU_texture_update_sub(
probes_tx_, GPU_DATA_FLOAT, data, UNPACK2(pos), probe_data.layer, resolution, resolution, 1);
MEM_freeN(data);
}
/** \} */
void ReflectionProbeModule::remap_to_octahedral_projection()
std::optional<ReflectionProbeUpdateInfo> ReflectionProbeModule::update_info_pop(
const ReflectionProbe::Type probe_type)
{
const ReflectionProbe &world_probe = probes_.lookup(world_object_key_);
const ReflectionProbeData &probe_data = data_buf_[world_probe.index];
const bool do_probe_sync = instance_.do_probe_sync();
const int max_shift = int(log2(max_resolution_));
for (const Map<uint64_t, ReflectionProbe>::Item &item : probes_.items()) {
if (!item.value.do_render) {
continue;
}
if (probe_type == ReflectionProbe::Type::World && item.value.type != probe_type) {
return std::nullopt;
}
if (probe_type == ReflectionProbe::Type::Probe && item.value.type != probe_type) {
continue;
}
/* Do not update this probe during this sample. */
if (item.value.type == ReflectionProbe::Type::Probe && !do_probe_sync) {
continue;
}
probes_.lookup(item.key).do_render = false;
ReflectionProbeData &probe_data = data_buf_[item.value.index];
ReflectionProbeUpdateInfo info = {};
info.probe_type = item.value.type;
info.object_key = item.key;
info.resolution = 1 << (max_shift - probe_data.layer_subdivision - 1);
info.clipping_distances = item.value.clipping_distances;
info.probe_pos = probe_data.pos;
if (cubemap_tx_.ensure_cube(GPU_RGBA16F,
info.resolution,
GPU_TEXTURE_USAGE_ATTACHMENT | GPU_TEXTURE_USAGE_SHADER_READ))
{
GPU_texture_mipmap_mode(cubemap_tx_, false, true);
}
return info;
}
/* Check reset probe updating as we completed rendering all Probes. */
if (probe_type == ReflectionProbe::Type::Probe && update_probes_this_sample_ &&
update_probes_next_sample_)
{
update_probes_next_sample_ = false;
}
return std::nullopt;
}
void ReflectionProbeModule::remap_to_octahedral_projection(uint64_t object_key)
{
const ReflectionProbe &probe = probes_.lookup(object_key);
const ReflectionProbeData &probe_data = data_buf_[probe.index];
/* Update shader parameters that change per dispatch. */
reflection_probe_index_ = probe.index;
dispatch_probe_pack_ = int3(int2(ceil_division(max_resolution_ >> probe_data.layer_subdivision,
REFLECTION_PROBE_GROUP_SIZE)),
1);
instance_.manager->submit(remap_ps_);
/* TODO: Performance - Should only update the area that has changed. */
}
void ReflectionProbeModule::update_probes_texture_mipmaps()
{
GPU_texture_update_mipmap_chain(probes_tx_);
}

View File

@ -22,9 +22,10 @@ class Instance;
struct ObjectHandle;
struct WorldHandle;
class CaptureView;
struct ReflectionProbeUpdateInfo;
/* -------------------------------------------------------------------- */
/** \name Reflection Probes
/** \name Reflection Probe
* \{ */
struct ReflectionProbe {
@ -32,7 +33,8 @@ struct ReflectionProbe {
Type type = Type::Unused;
/* Probe data needs to be updated. */
/* Probe data needs to be updated.
* TODO: Remove this flag? */
bool do_update_data = false;
/* Should the area in the probes_tx_ be updated? */
bool do_render = false;
@ -50,6 +52,11 @@ struct ReflectionProbe {
*/
int index = -1;
/**
* Far and near clipping distances for rendering
*/
float2 clipping_distances;
/**
* Check if the probe needs to be updated during this sample.
*/
@ -67,6 +74,12 @@ struct ReflectionProbe {
}
};
/** \} */
/* -------------------------------------------------------------------- */
/** \name Reflection Probe Module
* \{ */
class ReflectionProbeModule {
private:
/** The max number of probes to initially allocate. */
@ -85,8 +98,6 @@ class ReflectionProbeModule {
ReflectionProbeDataBuf data_buf_;
Map<uint64_t, ReflectionProbe> probes_;
/** Texture containing a cubemap used as input for updating #probes_tx_. */
Texture cubemap_tx_ = {"Probe.Cubemap"};
/** Probes texture stored in octahedral mapping. */
Texture probes_tx_ = {"Probes"};
@ -94,6 +105,17 @@ class ReflectionProbeModule {
int3 dispatch_probe_pack_ = int3(0);
/**
* Texture containing a cubemap where the probe should be rendering to.
*
* NOTE: TextureFromPool doesn't support cubemaps.
*/
Texture cubemap_tx_ = {"Probe.Cubemap"};
int reflection_probe_index_ = 0;
bool update_probes_next_sample_ = false;
bool update_probes_this_sample_ = false;
public:
ReflectionProbeModule(Instance &instance) : instance_(instance) {}
@ -115,7 +137,6 @@ class ReflectionProbeModule {
void debug_print() const;
private:
void sync(ReflectionProbe &cubemap);
ReflectionProbe &find_or_insert(ObjectHandle &ob_handle, int subdivision_level);
/** Get the number of layers that is needed to store probes. */
@ -140,16 +161,41 @@ class ReflectionProbeModule {
*/
ReflectionProbeData find_empty_reflection_probe_data(int subdivision_level) const;
void upload_dummy_texture(const ReflectionProbe &probe);
void remap_to_octahedral_projection();
/**
* Pop the next reflection probe that requires to be updated.
*/
std::optional<ReflectionProbeUpdateInfo> update_info_pop(ReflectionProbe::Type probe_type);
void remap_to_octahedral_projection(uint64_t object_key);
void update_probes_texture_mipmaps();
/* Capture View requires access to the cube-maps texture for frame-buffer configuration. */
friend class CaptureView;
/* Instance requires access to #update_probes_this_sample_ */
friend class Instance;
};
std::ostream &operator<<(std::ostream &os, const ReflectionProbeModule &module);
std::ostream &operator<<(std::ostream &os, const ReflectionProbeData &probe_data);
std::ostream &operator<<(std::ostream &os, const ReflectionProbe &probe);
/** \} */
/* -------------------------------------------------------------------- */
/** \name Reflection Probe Update Info
* \{ */
struct ReflectionProbeUpdateInfo {
float3 probe_pos;
ReflectionProbe::Type probe_type;
/**
* Resolution of the cubemap to be rendered.
*/
int resolution;
float2 clipping_distances;
uint64_t object_key;
};
/** \} */
} // namespace blender::eevee

View File

@ -127,6 +127,8 @@ void Sampling::step()
/* TODO de-correlate. */
data_.dimensions[SAMPLING_AO_U] = r[0];
data_.dimensions[SAMPLING_AO_V] = r[1];
/* TODO de-correlate. */
data_.dimensions[SAMPLING_CURVES_U] = r[0];
}
{
/* Using leaped Halton sequence so we can reused the same primes as lens. */

View File

@ -90,6 +90,8 @@ const char *ShaderModule::static_shader_create_info_name_get(eShaderType shader_
return "eevee_film_cryptomatte_post";
case DEFERRED_LIGHT:
return "eevee_deferred_light";
case DEFERRED_LIGHT_DIFFUSE_ONLY:
return "eevee_deferred_light_diffuse";
case HIZ_DEBUG:
return "eevee_hiz_debug";
case HIZ_UPDATE:
@ -312,6 +314,7 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu
case MAT_GEOM_MESH:
/** Noop. */
break;
case MAT_GEOM_POINT_CLOUD:
case MAT_GEOM_CURVES:
/** Hair attributes come from sampler buffer. Transfer attributes to sampler. */
for (auto &input : info.vertex_inputs_) {
@ -380,8 +383,7 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu
}
{
/* Only mesh and curves support vertex displacement for now. */
if (ELEM(geometry_type, MAT_GEOM_MESH, MAT_GEOM_CURVES, MAT_GEOM_GPENCIL)) {
if (!ELEM(geometry_type, MAT_GEOM_WORLD, MAT_GEOM_VOLUME)) {
vert_gen << "vec3 nodetree_displacement()\n";
vert_gen << "{\n";
vert_gen << ((codegen.displacement) ? codegen.displacement : "return vec3(0);\n");
@ -442,6 +444,9 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu
case MAT_GEOM_MESH:
info.additional_info("eevee_geom_mesh");
break;
case MAT_GEOM_POINT_CLOUD:
info.additional_info("eevee_geom_point_cloud");
break;
}
/* Pipeline Info. */

View File

@ -33,6 +33,7 @@ enum eShaderType {
FILM_CRYPTOMATTE_POST,
DEFERRED_LIGHT,
DEFERRED_LIGHT_DIFFUSE_ONLY,
DEBUG_SURFELS,

View File

@ -101,6 +101,7 @@ enum eSamplingDimension : uint32_t {
SAMPLING_RAYTRACE_X = 18u,
SAMPLING_AO_U = 19u,
SAMPLING_AO_V = 20u,
SAMPLING_CURVES_U = 21u,
};
/**
@ -326,8 +327,8 @@ struct AOVsInfoData {
uint4 hash_value[AOV_MAX];
uint4 hash_color[AOV_MAX];
/* Length of used data. */
uint color_len;
uint value_len;
int color_len;
int value_len;
/** Id of the AOV to be displayed (from the start of the AOV array). -1 for combined. */
int display_id;
/** True if the AOV to be displayed is from the value accumulation buffer. */
@ -1094,6 +1095,14 @@ float4 utility_tx_sample(sampler2DArray util_tx, float2 uv, float layer)
{
return textureLod(util_tx, float3(uv, layer), 0.0);
}
/* Sample at uv position but with scale and bias so that uv space bounds lie on texel centers. */
float4 utility_tx_sample_lut(sampler2DArray util_tx, float2 uv, float layer)
{
/* Scale and bias coordinates, for correct filtered lookup. */
uv = uv * ((UTIL_TEX_SIZE - 1.0) / UTIL_TEX_SIZE) + (0.5 / UTIL_TEX_SIZE);
return textureLod(util_tx, float3(uv, layer), 0.0);
}
#endif
/** \} */

View File

@ -77,7 +77,7 @@ void SubsurfaceModule::precompute_samples_location()
for (auto i : IndexRange(data_.sample_len)) {
float theta = golden_angle * i + M_PI * 2.0f * rand_u;
/* Scale using rand_v in order to keep first sample always at center. */
float x = (1.0f + (rand_v / data_.sample_len)) * (i / (float)data_.sample_len);
float x = (1.0f + (rand_v / data_.sample_len)) * (i / float(data_.sample_len));
float r = burley_sample(d, x);
data_.samples[i].x = cosf(theta) * r;
data_.samples[i].y = sinf(theta) * r;

View File

@ -18,6 +18,8 @@
#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
#include "draw_common.hh"
#include "eevee_instance.hh"
namespace blender::eevee {
@ -122,6 +124,7 @@ void SyncModule::sync_mesh(Object *ob,
bool is_shadow_caster = false;
bool is_alpha_blend = false;
bool do_probe_sync = inst_.do_probe_sync();
for (auto i : material_array.gpu_materials.index_range()) {
GPUBatch *geom = mat_geom[i];
if (geom == nullptr) {
@ -132,6 +135,10 @@ void SyncModule::sync_mesh(Object *ob,
geometry_call(material.prepass.sub_pass, geom, res_handle);
geometry_call(material.shadow.sub_pass, geom, res_handle);
geometry_call(material.capture.sub_pass, geom, res_handle);
if (do_probe_sync) {
geometry_call(material.probe_prepass.sub_pass, geom, res_handle);
geometry_call(material.probe_shading.sub_pass, geom, res_handle);
}
is_shadow_caster = is_shadow_caster || material.shadow.sub_pass != nullptr;
is_alpha_blend = is_alpha_blend || material.is_alpha_blend_transparent;
@ -149,6 +156,49 @@ void SyncModule::sync_mesh(Object *ob,
/** \} */
/* -------------------------------------------------------------------- */
/** \name Point Cloud
* \{ */
void SyncModule::sync_point_cloud(Object *ob,
ObjectHandle &ob_handle,
ResourceHandle res_handle,
const ObjectRef &ob_ref)
{
int material_slot = 1;
bool has_motion = inst_.velocity.step_object_sync(
ob, ob_handle.object_key, res_handle, ob_handle.recalc);
Material &material = inst_.materials.material_get(
ob, has_motion, material_slot - 1, MAT_GEOM_POINT_CLOUD);
auto drawcall_add = [&](MaterialPass &matpass) {
if (matpass.sub_pass == nullptr) {
return;
}
PassMain::Sub &object_pass = matpass.sub_pass->sub("Point Cloud Sub Pass");
GPUBatch *geometry = point_cloud_sub_pass_setup(object_pass, ob, matpass.gpumat);
object_pass.draw(geometry, res_handle);
};
drawcall_add(material.shading);
drawcall_add(material.prepass);
drawcall_add(material.shadow);
inst_.cryptomatte.sync_object(ob, res_handle);
GPUMaterial *gpu_material =
inst_.materials.material_array_get(ob, has_motion).gpu_materials[material_slot - 1];
::Material *mat = GPU_material_get_material(gpu_material);
inst_.cryptomatte.sync_material(mat);
bool is_caster = material.shadow.sub_pass != nullptr;
bool is_alpha_blend = material.is_alpha_blend_transparent;
inst_.shadows.sync_object(ob_handle, res_handle, is_caster, is_alpha_blend);
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name GPencil
* \{ */
@ -293,52 +343,41 @@ void SyncModule::sync_gpencil(Object *ob, ObjectHandle &ob_handle, ResourceHandl
/** \name Hair
* \{ */
static void shgroup_curves_call(MaterialPass &matpass,
Object *ob,
ParticleSystem *part_sys = nullptr,
ModifierData *modifier_data = nullptr)
{
UNUSED_VARS(ob, modifier_data);
if (matpass.sub_pass == nullptr) {
return;
}
if (part_sys != nullptr) {
// DRW_shgroup_hair_create_sub(ob, part_sys, modifier_data, matpass.sub_pass, matpass.gpumat);
}
else {
// DRW_shgroup_curves_create_sub(ob, matpass.sub_pass, matpass.gpumat);
}
}
void SyncModule::sync_curves(Object *ob,
ObjectHandle &ob_handle,
ResourceHandle res_handle,
ModifierData *modifier_data)
ModifierData *modifier_data,
ParticleSystem *particle_sys)
{
UNUSED_VARS(res_handle);
int mat_nr = CURVES_MATERIAL_NR;
ParticleSystem *part_sys = nullptr;
if (modifier_data != nullptr) {
part_sys = reinterpret_cast<ParticleSystemModifierData *>(modifier_data)->psys;
if (!DRW_object_is_visible_psys_in_active_context(ob, part_sys)) {
return;
}
ParticleSettings *part_settings = part_sys->part;
const int draw_as = (part_settings->draw_as == PART_DRAW_REND) ? part_settings->ren_as :
part_settings->draw_as;
if (draw_as != PART_DRAW_PATH) {
return;
}
mat_nr = part_settings->omat;
if (particle_sys != nullptr) {
mat_nr = particle_sys->part->omat;
}
bool has_motion = inst_.velocity.step_object_sync(ob, ob_handle.object_key, ob_handle.recalc);
bool has_motion = inst_.velocity.step_object_sync(
ob, ob_handle.object_key, res_handle, ob_handle.recalc, modifier_data, particle_sys);
Material &material = inst_.materials.material_get(ob, has_motion, mat_nr - 1, MAT_GEOM_CURVES);
shgroup_curves_call(material.shading, ob, part_sys, modifier_data);
shgroup_curves_call(material.prepass, ob, part_sys, modifier_data);
shgroup_curves_call(material.shadow, ob, part_sys, modifier_data);
auto drawcall_add = [&](MaterialPass &matpass) {
if (matpass.sub_pass == nullptr) {
return;
}
if (particle_sys != nullptr) {
PassMain::Sub &sub_pass = matpass.sub_pass->sub("Hair SubPass");
GPUBatch *geometry = hair_sub_pass_setup(
sub_pass, inst_.scene, ob, particle_sys, modifier_data, matpass.gpumat);
sub_pass.draw(geometry, res_handle);
}
else {
PassMain::Sub &sub_pass = matpass.sub_pass->sub("Curves SubPass");
GPUBatch *geometry = curves_sub_pass_setup(sub_pass, inst_.scene, ob, matpass.gpumat);
sub_pass.draw(geometry, res_handle);
}
};
drawcall_add(material.shading);
drawcall_add(material.prepass);
drawcall_add(material.shadow);
inst_.cryptomatte.sync_object(ob, res_handle);
GPUMaterial *gpu_material =
@ -346,9 +385,6 @@ void SyncModule::sync_curves(Object *ob,
::Material *mat = GPU_material_get_material(gpu_material);
inst_.cryptomatte.sync_material(mat);
/* TODO(fclem) Hair velocity. */
// shading_passes.velocity.gpencil_add(ob, ob_handle);
bool is_caster = material.shadow.sub_pass != nullptr;
bool is_alpha_blend = material.is_alpha_blend_transparent;
inst_.shadows.sync_object(ob_handle, res_handle, is_caster, is_alpha_blend);

View File

@ -40,15 +40,15 @@ struct ObjectKey {
Object *parent;
/** Dupli objects recursive unique identifier */
int id[MAX_DUPLI_RECUR];
/** If object uses particle system hair. */
bool use_particle_hair;
/** Used for particle system hair. */
int sub_key_;
#ifdef DEBUG
char name[64];
#endif
ObjectKey() : ob(nullptr), parent(nullptr){};
ObjectKey(Object *ob_, Object *parent_, int id_[MAX_DUPLI_RECUR], bool use_particle_hair_)
: ob(ob_), parent(parent_), use_particle_hair(use_particle_hair_)
ObjectKey(Object *ob_, Object *parent_, int id_[MAX_DUPLI_RECUR], int sub_key_ = 0)
: ob(ob_), parent(parent_), sub_key_(sub_key_)
{
if (id_) {
memcpy(id, id_, sizeof(id));
@ -67,16 +67,19 @@ struct ObjectKey {
break;
}
}
if (sub_key_ != 0) {
hash_value = BLI_ghashutil_combine_hash(hash_value, sub_key_);
}
#ifdef DEBUG
STRNCPY(name, ob->id.name);
#endif
}
ObjectKey(Object *ob, DupliObject *dupli, Object *parent)
: ObjectKey(ob, parent, dupli ? dupli->persistent_id : nullptr, false){};
ObjectKey(Object *ob, DupliObject *dupli, Object *parent, int sub_key_ = 0)
: ObjectKey(ob, parent, dupli ? dupli->persistent_id : nullptr, sub_key_){};
ObjectKey(Object *ob)
: ObjectKey(ob, DRW_object_get_dupli(ob), DRW_object_get_dupli_parent(ob)){};
ObjectKey(Object *ob, int sub_key_ = 0)
: ObjectKey(ob, DRW_object_get_dupli(ob), DRW_object_get_dupli_parent(ob), sub_key_){};
uint64_t hash() const
{
@ -91,8 +94,8 @@ struct ObjectKey {
if (parent != k.parent) {
return (parent < k.parent);
}
if (use_particle_hair != k.use_particle_hair) {
return (use_particle_hair < k.use_particle_hair);
if (sub_key_ != k.sub_key_) {
return (sub_key_ < k.sub_key_);
}
return memcmp(id, k.id, sizeof(id)) < 0;
}
@ -105,7 +108,7 @@ struct ObjectKey {
if (parent != k.parent) {
return false;
}
if (use_particle_hair != k.use_particle_hair) {
if (sub_key_ != k.sub_key_) {
return false;
}
return memcmp(id, k.id, sizeof(id)) == 0;
@ -164,11 +167,16 @@ class SyncModule {
ObjectHandle &ob_handle,
ResourceHandle res_handle,
const ObjectRef &ob_ref);
void sync_point_cloud(Object *ob,
ObjectHandle &ob_handle,
ResourceHandle res_handle,
const ObjectRef &ob_ref);
void sync_gpencil(Object *ob, ObjectHandle &ob_handle, ResourceHandle res_handle);
void sync_curves(Object *ob,
ObjectHandle &ob_handle,
ResourceHandle res_handle,
ModifierData *modifier_data = nullptr);
ModifierData *modifier_data = nullptr,
ParticleSystem *particle_sys = nullptr);
void sync_light_probe(Object *ob, ObjectHandle &ob_handle);
};

View File

@ -15,8 +15,11 @@
#include "BKE_object.h"
#include "BLI_map.hh"
#include "DEG_depsgraph_query.h"
#include "DNA_particle_types.h"
#include "DNA_rigidbody_types.h"
#include "draw_cache_impl.h"
#include "eevee_instance.hh"
// #include "eevee_renderpasses.hh"
#include "eevee_shader.hh"
@ -85,7 +88,9 @@ void VelocityModule::step_camera_sync()
bool VelocityModule::step_object_sync(Object *ob,
ObjectKey &object_key,
ResourceHandle resource_handle,
int /*IDRecalcFlag*/ recalc)
int /*IDRecalcFlag*/ recalc,
ModifierData *modifier_data /*= nullptr*/,
ParticleSystem *particle_sys /*= nullptr*/)
{
bool has_motion = object_has_velocity(ob) || (recalc & ID_RECALC_TRANSFORM);
/* NOTE: Fragile. This will only work with 1 frame of lag since we can't record every geometry
@ -105,7 +110,7 @@ bool VelocityModule::step_object_sync(Object *ob,
VelocityObjectData &vel = velocity_map.lookup_or_add_default(object_key);
vel.obj.ofs[step_] = object_steps_usage[step_]++;
vel.obj.resource_id = resource_handle.resource_index();
vel.id = (ID *)ob->data;
vel.id = particle_sys ? &particle_sys->part->id : &ob->id;
object_steps[step_]->get_or_resize(vel.obj.ofs[step_]) = float4x4_view(ob->object_to_world);
if (step_ == STEP_CURRENT) {
/* Replace invalid steps. Can happen if object was hidden in one of those steps. */
@ -125,10 +130,17 @@ bool VelocityModule::step_object_sync(Object *ob,
if (has_deform) {
auto add_cb = [&]() {
VelocityGeometryData data;
if (particle_sys) {
data.pos_buf = DRW_hair_pos_buffer_get(ob, particle_sys, modifier_data);
return data;
}
switch (ob->type) {
case OB_CURVES:
data.pos_buf = DRW_curves_pos_buffer_get(ob);
break;
case OB_POINTCLOUD:
data.pos_buf = DRW_pointcloud_position_and_radius_buffer_get(ob);
break;
default:
data.pos_buf = DRW_cache_object_pos_vertbuf_get(ob);
break;
@ -173,7 +185,9 @@ bool VelocityModule::step_object_sync(Object *ob,
}
/* TODO(@fclem): Reset sampling here? Should ultimately be covered by depsgraph update tags. */
inst_.sampling.reset();
/* NOTE(Miguel Pozo): Disable, since is_deform is always true for objects with particle
* modifiers, and this causes the renderer to get stuck at sample 1. */
// inst_.sampling.reset();
return true;
}

View File

@ -108,7 +108,9 @@ class VelocityModule {
bool step_object_sync(Object *ob,
ObjectKey &object_key,
ResourceHandle resource_handle,
int recalc = 0);
int recalc = 0,
ModifierData *modifier_data = nullptr,
ParticleSystem *particle_sys = nullptr);
/* Moves next frame data to previous frame data. Nullify next frame data. */
void step_swap();

View File

@ -195,31 +195,89 @@ void ShadingView::update_view()
/** \name Capture View
* \{ */
void CaptureView::render()
void CaptureView::render_world()
{
if (!inst_.reflection_probes.do_world_update_get()) {
const std::optional<ReflectionProbeUpdateInfo> update_info =
inst_.reflection_probes.update_info_pop(ReflectionProbe::Type::World);
if (!update_info.has_value()) {
return;
}
inst_.reflection_probes.do_world_update_set(false);
View view = {"Capture.View"};
GPU_debug_group_begin("World.Capture");
View view = {"World.Capture.View"};
for (int face : IndexRange(6)) {
float4x4 view_m4 = cubeface_mat(face);
float4x4 win_m4 = math::projection::perspective(-update_info->clipping_distances.x,
update_info->clipping_distances.x,
-update_info->clipping_distances.x,
update_info->clipping_distances.x,
update_info->clipping_distances.x,
update_info->clipping_distances.y);
view.sync(view_m4, win_m4);
capture_fb_.ensure(GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE_CUBEFACE(inst_.reflection_probes.cubemap_tx_, face));
GPU_framebuffer_bind(capture_fb_);
float4x4 view_m4 = cubeface_mat(face);
float4x4 win_m4 = math::projection::perspective(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 10.0f);
view.sync(view_m4, win_m4);
inst_.pipelines.world.render(view);
}
GPU_texture_update_mipmap_chain(inst_.reflection_probes.cubemap_tx_);
inst_.reflection_probes.remap_to_octahedral_projection();
inst_.reflection_probes.remap_to_octahedral_projection(update_info->object_key);
inst_.reflection_probes.update_probes_texture_mipmaps();
GPU_debug_group_end();
}
void CaptureView::render_probes()
{
Framebuffer prepass_fb;
View view = {"Capture.View"};
bool do_update_mipmap_chain = false;
while (const std::optional<ReflectionProbeUpdateInfo> update_info =
inst_.reflection_probes.update_info_pop(ReflectionProbe::Type::Probe))
{
GPU_debug_group_begin("Probe.Capture");
do_update_mipmap_chain = true;
int2 extent = int2(update_info->resolution);
inst_.render_buffers.acquire(extent);
inst_.render_buffers.vector_tx.clear(float4(0.0f));
prepass_fb.ensure(GPU_ATTACHMENT_TEXTURE(inst_.render_buffers.depth_tx),
GPU_ATTACHMENT_TEXTURE(inst_.render_buffers.vector_tx));
for (int face : IndexRange(6)) {
float4x4 view_m4 = cubeface_mat(face);
view_m4 = math::translate(view_m4, -update_info->probe_pos);
float4x4 win_m4 = math::projection::perspective(-update_info->clipping_distances.x,
update_info->clipping_distances.x,
-update_info->clipping_distances.x,
update_info->clipping_distances.x,
update_info->clipping_distances.x,
update_info->clipping_distances.y);
view.sync(view_m4, win_m4);
capture_fb_.ensure(
GPU_ATTACHMENT_TEXTURE(inst_.render_buffers.depth_tx),
GPU_ATTACHMENT_TEXTURE_CUBEFACE(inst_.reflection_probes.cubemap_tx_, face));
GPU_framebuffer_bind(capture_fb_);
GPU_framebuffer_clear_color_depth(capture_fb_, float4(0.0f, 0.0f, 0.0f, 1.0f), 1.0f);
inst_.pipelines.probe.render(view, prepass_fb, capture_fb_, extent);
}
inst_.render_buffers.release();
GPU_debug_group_end();
inst_.reflection_probes.remap_to_octahedral_projection(update_info->object_key);
}
if (do_update_mipmap_chain) {
/* TODO: only update the regions that have been updated. */
/* TODO: Composite world into the probes. */
inst_.reflection_probes.update_probes_texture_mipmaps();
}
}
/** \} */
} // namespace blender::eevee

View File

@ -155,7 +155,8 @@ class CaptureView {
public:
CaptureView(Instance &inst) : inst_(inst) {}
void render();
void render_world();
void render_probes();
};
/** \} */

View File

@ -60,6 +60,56 @@ vec3 attr_load_uv(vec3 attr)
/** \} */
#elif defined(MAT_GEOM_POINT_CLOUD)
/* -------------------------------------------------------------------- */
/** \name Point Cloud
*
* Point Cloud objects loads attributes from buffers through sampler buffers.
* \{ */
# pragma BLENDER_REQUIRE(common_pointcloud_lib.glsl)
# ifdef OBINFO_LIB
vec3 attr_load_orco(vec4 orco)
{
vec3 P = pointcloud_get_pos();
vec3 lP = transform_point(ModelMatrixInverse, P);
return OrcoTexCoFactors[0].xyz + lP * OrcoTexCoFactors[1].xyz;
}
# endif
vec4 attr_load_tangent(samplerBuffer cd_buf)
{
return pointcloud_get_customdata_vec4(cd_buf);
}
vec3 attr_load_uv(samplerBuffer cd_buf)
{
return pointcloud_get_customdata_vec3(cd_buf);
}
vec4 attr_load_color(samplerBuffer cd_buf)
{
return pointcloud_get_customdata_vec4(cd_buf);
}
vec4 attr_load_vec4(samplerBuffer cd_buf)
{
return pointcloud_get_customdata_vec4(cd_buf);
}
vec3 attr_load_vec3(samplerBuffer cd_buf)
{
return pointcloud_get_customdata_vec3(cd_buf);
}
vec2 attr_load_vec2(samplerBuffer cd_buf)
{
return pointcloud_get_customdata_vec2(cd_buf);
}
float attr_load_float(samplerBuffer cd_buf)
{
return pointcloud_get_customdata_float(cd_buf);
}
/** \} */
#elif defined(MAT_GEOM_GPENCIL)
/* -------------------------------------------------------------------- */

View File

@ -55,7 +55,10 @@ void main()
vec3 reflection_light = vec3(0.0);
float shadow = 1.0;
#ifdef DO_REFLECTION_PROBES
reflection_probes_eval(reflection_data, P, V, reflection_light);
#endif
lightprobe_eval(diffuse_data, reflection_data, P, Ng, V, diffuse_light, reflection_light);
light_eval(diffuse_data,

View File

@ -16,8 +16,6 @@ void main()
init_interface();
vec3 T;
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
hair_get_pos_tan_binor_time(is_persp,
ModelMatrixInverse,
@ -30,14 +28,15 @@ void main()
interp.curves_thickness,
interp.curves_time_width);
interp.N = cross(T, interp.curves_binormal);
interp.N = cross(interp.curves_tangent, interp.curves_binormal);
interp.curves_strand_id = hair_get_strand_id();
interp.barycentric_coords = hair_get_barycentric();
#ifdef MAT_VELOCITY
/* Due to the screen space nature of the vertex positioning, we compute only the motion of curve
* strand, not its cylinder. Otherwise we would add the rotation velocity. */
int vert_idx = hair_get_base_id();
vec3 prv, nxt, pos = texelFetch(hairPointBuffer, vert_idx).point_position;
vec3 prv, nxt;
vec3 pos = texelFetch(hairPointBuffer, vert_idx).point_position;
velocity_local_pos_get(pos, vert_idx, prv, nxt);
/* FIXME(fclem): Evaluating before displacement avoid displacement being treated as motion but
* ignores motion from animated displacement. Supporting animated displacement motion vectors

View File

@ -0,0 +1,48 @@
#pragma BLENDER_REQUIRE(gpu_shader_math_rotation_lib.glsl)
#pragma BLENDER_REQUIRE(common_pointcloud_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_attributes_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_nodetree_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_surf_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_velocity_lib.glsl)
void main()
{
DRW_VIEW_FROM_RESOURCE_ID;
#ifdef MAT_SHADOW
shadow_interp.view_id = drw_view_id;
#endif
init_interface();
point_cloud_interp.id = pointcloud_get_point_id();
pointcloud_get_pos_and_radius(point_cloud_interp.position, point_cloud_interp.radius);
pointcloud_get_pos_and_nor(interp.P, interp.N);
#ifdef MAT_SHADOW
/* Since point clouds always face the view, camera and shadow orientation don't match.
* Apply a bias to avoid self-shadow issues. */
/* TODO(fclem): remove multiplication here. Here only for keeping the size correct for now. */
float actual_radius = point_cloud_interp.radius * 0.01;
interp.P -= cameraVec(interp.P) * actual_radius;
#endif
#ifdef MAT_VELOCITY
vec3 lP = point_world_to_object(point_cloud_interp.position);
vec3 prv, nxt;
velocity_local_pos_get(lP, point_cloud_interp.id, prv, nxt);
/* FIXME(fclem): Evaluating before displacement avoid displacement being treated as motion but
* ignores motion from animated displacement. Supporting animated displacement motion vectors
* would require evaluating the nodetree multiple time with different nodetree UBOs evaluated at
* different times, but also with different attributes (maybe we could assume static attribute at
* least). */
velocity_vertex(prv, lP, nxt, motion.prev, motion.next);
#endif
init_globals();
attrib_load();
interp.P += nodetree_displacement();
gl_Position = point_world_to_ndc(interp.P);
}

View File

@ -48,6 +48,8 @@ void main()
sphere.center = light._position;
sphere.radius = light.influence_radius_max;
break;
default:
break;
}
/* TODO(fclem): HiZ culling? Could be quite beneficial given the nature of the 2.5D culling. */

View File

@ -235,26 +235,111 @@ float nodetree_thickness();
vec4 closure_to_rgba(Closure cl);
#endif
/* Stubs. */
vec2 btdf_lut(float a, float b, float c)
/* Fresnel monochromatic, perfect mirror */
float F_eta(float eta, float cos_theta)
{
return vec2(1, 0);
/* Compute fresnel reflectance without explicitly computing
* the refracted direction. */
float c = abs(cos_theta);
float g = eta * eta - 1.0 + c * c;
if (g > 0.0) {
g = sqrt(g);
float A = (g - c) / (g + c);
float B = (c * (g + c) - 1.0) / (c * (g - c) + 1.0);
return 0.5 * A * A * (1.0 + B * B);
}
/* Total internal reflections. */
return 1.0;
}
vec2 brdf_lut(float a, float b)
/* Simplified form of F_eta(eta, 1.0). */
float F0_from_ior(float eta)
{
return vec2(1, 0);
float A = (eta - 1.0) / (eta + 1.0);
return A * A;
}
vec3 F_brdf_multi_scatter(vec3 a, vec3 b, vec2 c)
/* Return the fresnel color from a precomputed LUT value (from brdf_lutb). */
vec3 F_brdf_single_scatter(vec3 f0, vec3 f90, vec2 lut)
{
return a;
return lut.y * f90 + lut.x * f0;
}
vec3 F_brdf_single_scatter(vec3 a, vec3 b, vec2 c)
/* Return the fresnel color from a precomputed LUT value (from brdf_lutb). */
vec3 F_brdf_multi_scatter(vec3 f0, vec3 f90, vec2 lut)
{
return a;
/**
* From "A Multiple-Scattering Microfacet Model for Real-Time Image-based Lighting"
* by Carmelo J. Fdez-Aguera
* https://jcgt.org/published/0008/01/03/paper.pdf
*/
vec3 FssEss = lut.y * f90 + lut.x * f0;
float Ess = lut.x + lut.y;
float Ems = 1.0 - Ess;
vec3 Favg = f0 + (1.0 - f0) / 21.0;
vec3 Fms = FssEss * Favg / (1.0 - (1.0 - Ess) * Favg);
/* We don't do anything special for diffuse surfaces because the principle bsdf
* does not care about energy conservation of the specular layer for dielectrics. */
return FssEss + Fms * Ems;
}
float F_eta(float a, float b)
vec2 brdf_lut(float cos_theta, float roughness)
{
return a;
#ifdef EEVEE_UTILITY_TX
return utility_tx_sample_lut(utility_tx, vec2(cos_theta, roughness), UTIL_BSDF_LAYER).rg;
#else
return vec2(1.0, 0.0);
#endif
}
vec2 btdf_lut(float cos_theta, float roughness, float ior)
{
if (ior <= 1e-5) {
return vec2(0.0);
}
if (ior >= 1.0) {
vec2 split_sum = brdf_lut(cos_theta, roughness);
float f0 = F0_from_ior(ior);
/* Baked IOR for GGX BRDF. */
const float specular = 1.0;
const float eta_brdf = (2.0 / (1.0 - sqrt(0.08 * specular))) - 1.0;
/* Avoid harsh transition coming from ior == 1. */
float f90 = fast_sqrt(saturate(f0 / (F0_from_ior(eta_brdf) * 0.25)));
float fresnel = F_brdf_single_scatter(vec3(f0), vec3(f90), split_sum).r;
/* Setting the BTDF to one is not really important since it is only used for multiscatter
* and it's already quite close to ground truth. */
float btdf = 1.0;
return vec2(btdf, fresnel);
}
/* IOR is sin of critical angle. */
float critical_cos = sqrt(1.0 - ior * ior);
vec3 coords;
coords.x = sqr(ior);
coords.y = cos_theta;
coords.y -= critical_cos;
coords.y /= (coords.y > 0.0) ? (1.0 - critical_cos) : critical_cos;
coords.y = coords.y * 0.5 + 0.5;
coords.z = roughness;
coords = saturate(coords);
float layer = coords.z * UTIL_BTDF_LAYER_COUNT;
float layer_floored = floor(layer);
#ifdef EEVEE_UTILITY_TX
coords.z = UTIL_BTDF_LAYER + layer_floored;
vec2 btdf_low = utility_tx_sample_lut(utility_tx, coords.xy, coords.z).rg;
vec2 btdf_high = utility_tx_sample_lut(utility_tx, coords.xy, coords.z + 1.0).rg;
/* Manual trilinear interpolation. */
vec2 btdf = mix(btdf_low, btdf_high, layer - layer_floored);
return btdf;
#else
return vec2(0.0);
#endif
}
void output_renderpass_color(int id, vec4 color)
@ -292,13 +377,13 @@ void clear_aovs()
void output_aov(vec4 color, float value, uint hash)
{
#if defined(MAT_RENDER_PASS_SUPPORT) && defined(GPU_FRAGMENT_SHADER)
for (uint i = 0; i < AOV_MAX && i < rp_buf.aovs.color_len; i++) {
for (int i = 0; i < AOV_MAX && i < rp_buf.aovs.color_len; i++) {
if (rp_buf.aovs.hash_color[i].x == hash) {
imageStore(rp_color_img, ivec3(ivec2(gl_FragCoord.xy), rp_buf.color_len + i), color);
return;
}
}
for (uint i = 0; i < AOV_MAX && i < rp_buf.aovs.value_len; i++) {
for (int i = 0; i < AOV_MAX && i < rp_buf.aovs.value_len; i++) {
if (rp_buf.aovs.hash_value[i].x == hash) {
imageStore(rp_value_img, ivec3(ivec2(gl_FragCoord.xy), rp_buf.value_len + i), vec4(value));
return;

View File

@ -5,7 +5,7 @@
void main()
{
ReflectionProbeData probe_data = reflection_probe_buf[0];
ReflectionProbeData probe_data = reflection_probe_buf[reflection_probe_index];
ivec3 texture_coord = ivec3(gl_GlobalInvocationID.xyz);
ivec3 texture_size = imageSize(octahedral_img);
@ -25,12 +25,14 @@ void main()
vec3 R = octahedral_uv_to_direction(octahedral_uv);
vec4 col = textureLod(cubemap_tx, R, float(probe_data.layer_subdivision));
// col.xy = octahedral_uv;
int probes_per_dimension = 1 << probe_data.layer_subdivision;
ivec2 area_coord = ivec2(probe_data.area_index % probes_per_dimension,
probe_data.area_index / probes_per_dimension);
ivec2 area_offset = area_coord * octahedral_size;
imageStore(octahedral_img, octahedral_coord + ivec3(area_offset, 0), col);
/* Convert transmittance to transparency. */
col.a = 1.0 - col.a;
imageStore(octahedral_img, octahedral_coord + ivec3(area_offset, probe_data.layer), col);
}

View File

@ -2,6 +2,7 @@
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
#pragma BLENDER_REQUIRE(gpu_shader_codegen_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_nodetree_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_sampling_lib.glsl)
#if defined(USE_BARYCENTRICS) && defined(GPU_FRAGMENT_SHADER) && defined(MAT_GEOM_MESH)
vec3 barycentric_distances_get()
@ -39,6 +40,18 @@ void init_globals_curves()
{
/* Shade as a cylinder. */
float cos_theta = interp.curves_time_width / interp.curves_thickness;
#if defined(GPU_FRAGMENT_SHADER) && defined(MAT_GEOM_CURVES)
if (hairThicknessRes == 1) {
/* Random cosine normal distribution on the hair surface. */
float noise = utility_tx_fetch(utility_tx, gl_FragCoord.xy, UTIL_BLUE_NOISE_LAYER).x;
# ifdef EEVEE_SAMPLING_DATA
/* Needs to check for SAMPLING_DATA,
* otherwise Surfel and World (?!?!) shader validation fails. */
noise = fract(noise + sampling_rng_1D_get(SAMPLING_CURVES_U));
# endif
cos_theta = noise * 2.0 - 1.0;
}
#endif
float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta));
g_data.N = g_data.Ni = normalize(interp.N * sin_theta + interp.curves_binormal * cos_theta);

View File

@ -30,7 +30,7 @@ GPU_SHADER_CREATE_INFO(eevee_deferred_base)
.image_out(2, Qualifier::WRITE, GPU_RGBA16F, "out_diffuse_light_img")
.image_out(3, Qualifier::WRITE, GPU_RGBA16F, "out_specular_light_img");
GPU_SHADER_CREATE_INFO(eevee_deferred_light)
GPU_SHADER_CREATE_INFO(eevee_deferred_light_base)
.fragment_source("eevee_deferred_light_frag.glsl")
.sampler(0, ImageType::FLOAT_2D_ARRAY, "gbuffer_closure_tx")
.sampler(1, ImageType::FLOAT_2D_ARRAY, "gbuffer_color_tx")
@ -46,7 +46,15 @@ GPU_SHADER_CREATE_INFO(eevee_deferred_light)
"eevee_hiz_data",
"eevee_render_pass_out",
"draw_view",
"draw_fullscreen")
"draw_fullscreen");
GPU_SHADER_CREATE_INFO(eevee_deferred_light)
.additional_info("eevee_deferred_light_base")
.define("DO_REFLECTION_PROBES")
.do_static_compilation(true);
GPU_SHADER_CREATE_INFO(eevee_deferred_light_diffuse)
.additional_info("eevee_deferred_light_base")
.do_static_compilation(true);
#undef image_array_out

View File

@ -20,6 +20,7 @@ GPU_SHADER_CREATE_INFO(eevee_sampling_data)
.storage_buf(SAMPLING_BUF_SLOT, Qualifier::READ, "SamplingData", "sampling_buf");
GPU_SHADER_CREATE_INFO(eevee_utility_texture)
.define("EEVEE_UTILITY_TX")
.sampler(RBUFS_UTILITY_TEX_SLOT, ImageType::FLOAT_2D_ARRAY, "utility_tx");
GPU_SHADER_CREATE_INFO(eevee_camera).uniform_buf(CAMERA_BUF_SLOT, "CameraData", "camera_buf");
@ -38,6 +39,25 @@ GPU_SHADER_CREATE_INFO(eevee_geom_mesh)
.vertex_source("eevee_geom_mesh_vert.glsl")
.additional_info("draw_modelmat_new", "draw_resource_id_varying", "draw_view");
GPU_SHADER_INTERFACE_INFO(eevee_surf_point_cloud_iface, "point_cloud_interp")
.smooth(Type::FLOAT, "radius")
.smooth(Type::VEC3, "position")
.flat(Type::INT, "id");
GPU_SHADER_CREATE_INFO(eevee_geom_point_cloud)
.additional_info("eevee_shared")
.define("MAT_GEOM_POINT_CLOUD")
.vertex_source("eevee_geom_point_cloud_vert.glsl")
.vertex_out(eevee_surf_point_cloud_iface)
/* TODO(Miguel Pozo): Remove once we get rid of old EEVEE. */
.define("pointRadius", "point_cloud_interp.radius")
.define("pointPosition", "point_cloud_interp.position")
.define("pointID", "point_cloud_interp.id")
.additional_info("draw_pointcloud_new",
"draw_modelmat_new",
"draw_resource_id_varying",
"draw_view");
GPU_SHADER_CREATE_INFO(eevee_geom_gpencil)
.additional_info("eevee_shared")
.define("MAT_GEOM_GPENCIL")
@ -48,10 +68,11 @@ GPU_SHADER_CREATE_INFO(eevee_geom_curves)
.additional_info("eevee_shared")
.define("MAT_GEOM_CURVES")
.vertex_source("eevee_geom_curves_vert.glsl")
.additional_info("draw_hair",
"draw_curves_infos",
.additional_info("draw_modelmat_new",
"draw_resource_id_varying",
"draw_resource_id_new");
"draw_view",
"draw_hair_new",
"draw_curves_infos");
GPU_SHADER_CREATE_INFO(eevee_geom_world)
.additional_info("eevee_shared")
@ -223,7 +244,8 @@ GPU_SHADER_CREATE_INFO(eevee_material_stub)
EEVEE_MAT_FINAL_VARIATION(prefix##_world, "eevee_geom_world", __VA_ARGS__) \
EEVEE_MAT_FINAL_VARIATION(prefix##_gpencil, "eevee_geom_gpencil", __VA_ARGS__) \
EEVEE_MAT_FINAL_VARIATION(prefix##_curves, "eevee_geom_curves", __VA_ARGS__) \
EEVEE_MAT_FINAL_VARIATION(prefix##_mesh, "eevee_geom_mesh", __VA_ARGS__)
EEVEE_MAT_FINAL_VARIATION(prefix##_mesh, "eevee_geom_mesh", __VA_ARGS__) \
EEVEE_MAT_FINAL_VARIATION(prefix##_point_cloud, "eevee_geom_point_cloud", __VA_ARGS__)
# define EEVEE_MAT_PIPE_VARIATIONS(name, ...) \
EEVEE_MAT_GEOM_VARIATIONS(name##_world, "eevee_surf_world", __VA_ARGS__) \

View File

@ -19,6 +19,7 @@ GPU_SHADER_CREATE_INFO(eevee_reflection_probe_data)
/* Sample cubemap and remap into an octahedral texture. */
GPU_SHADER_CREATE_INFO(eevee_reflection_probe_remap)
.local_group_size(REFLECTION_PROBE_GROUP_SIZE, REFLECTION_PROBE_GROUP_SIZE)
.push_constant(Type::INT, "reflection_probe_index")
.storage_buf(REFLECTION_PROBE_BUF_SLOT,
Qualifier::READ,
"ReflectionProbeData",

View File

@ -69,7 +69,7 @@ bool intersects_near_plane(IsectBox box)
void main()
{
if (gl_GlobalInvocationID.x >= resource_len) {
if (int(gl_GlobalInvocationID.x) >= resource_len) {
return;
}

View File

@ -152,6 +152,8 @@ void DRW_curves_batch_cache_create_requested(struct Object *ob);
int DRW_pointcloud_material_count_get(struct PointCloud *pointcloud);
struct GPUVertBuf *DRW_pointcloud_position_and_radius_buffer_get(struct Object *ob);
struct GPUVertBuf **DRW_pointcloud_evaluated_attribute(struct PointCloud *pointcloud,
const char *name);
struct GPUBatch *DRW_pointcloud_batch_cache_get_dots(struct Object *ob);

View File

@ -387,6 +387,12 @@ GPUBatch *DRW_pointcloud_batch_cache_get_dots(Object *ob)
return DRW_batch_request(&cache->eval_cache.dots);
}
GPUVertBuf *DRW_pointcloud_position_and_radius_buffer_get(Object *ob)
{
PointCloud &pointcloud = *static_cast<PointCloud *>(ob->data);
return pointcloud_position_and_radius_get(&pointcloud);
}
GPUVertBuf **DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, const char *name)
{
PointCloudBatchCache &cache = *pointcloud_batch_cache_get(*pointcloud);

View File

@ -410,6 +410,18 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object,
void DRW_curves_update()
{
/* Ensure there's a valid active view.
* "Next" engines use this function, but this still uses the old Draw Manager. */
if (DRW_view_default_get() == nullptr) {
/* Create a dummy default view, it's not really used. */
DRW_view_default_set(DRW_view_create(
float4x4::identity().ptr(), float4x4::identity().ptr(), nullptr, nullptr, nullptr));
}
if (DRW_view_get_active() == nullptr) {
DRW_view_set_active(DRW_view_default_get());
}
/* Update legacy hair too, to avoid verbosity in callers. */
DRW_hair_update();

View File

@ -98,6 +98,8 @@ void DRW_pointcloud_free()
}
#include "draw_common.hh"
/* For drw_curves_get_attribute_sampler_name. */
#include "draw_curves_private.hh"
namespace blender::draw {
template<typename PassT>
@ -119,14 +121,20 @@ GPUBatch *point_cloud_sub_pass_setup_implementation(PassT &sub_ps,
sub_ps.bind_texture("ptcloud_pos_rad_tx", pos_rad_buf);
if (gpu_material != nullptr) {
/* Only single material supported for now. */
GPUBatch **geom = pointcloud_surface_shaded_get(&pointcloud, &gpu_material, 1);
return geom[0];
}
else {
GPUBatch *geom = pointcloud_surface_get(&pointcloud);
return geom;
ListBase gpu_attrs = GPU_material_attributes(gpu_material);
LISTBASE_FOREACH (GPUMaterialAttribute *, gpu_attr, &gpu_attrs) {
GPUVertBuf **attribute_buf = DRW_pointcloud_evaluated_attribute(&pointcloud, gpu_attr->name);
if (attribute_buf) {
char sampler_name[32];
/** NOTE: Reusing curve attribute function. */
drw_curves_get_attribute_sampler_name(gpu_attr->name, sampler_name);
sub_ps.bind_texture(sampler_name, attribute_buf);
}
}
}
GPUBatch *geom = pointcloud_surface_get(&pointcloud);
return geom;
}
GPUBatch *point_cloud_sub_pass_setup(PassMain::Sub &sub_ps,

View File

@ -95,7 +95,7 @@ uint drw_view_id = 0;
(DRW_VIEW_LEN > 2) ? 2 : \
1)
# define DRW_VIEW_MASK ~(0xFFFFFFFFu << DRW_VIEW_SHIFT)
# define DRW_VIEW_FROM_RESOURCE_ID drw_view_id = (drw_ResourceID & DRW_VIEW_MASK)
# define DRW_VIEW_FROM_RESOURCE_ID drw_view_id = (uint(drw_ResourceID) & DRW_VIEW_MASK)
#endif
struct FrustumCorners {

View File

@ -10,7 +10,10 @@
int pointcloud_get_point_id()
{
# ifdef GPU_VERTEX_SHADER
return gl_VertexID / 32;
# endif
return 0;
}
mat3 pointcloud_get_facing_matrix(vec3 p)
@ -40,8 +43,12 @@ void pointcloud_get_pos_nor_radius(out vec3 outpos, out vec3 outnor, out float o
mat3 facing_mat = pointcloud_get_facing_matrix(p);
int vert_id = 0;
# ifdef GPU_VERTEX_SHADER
/* NOTE: Avoid modulo by non-power-of-two in shader. See Index buffer setup. */
int vert_id = gl_VertexID % 32;
vert_id = gl_VertexID % 32;
# endif
vec3 pos_inst = vec3(0.0);
switch (vert_id) {

View File

@ -45,7 +45,7 @@ void write_draw_call(DrawGroup group, uint group_id)
void main()
{
uint proto_id = gl_GlobalInvocationID.x;
int proto_id = int(gl_GlobalInvocationID.x);
if (proto_id >= prototype_len) {
return;
}
@ -59,7 +59,7 @@ void main()
uint visible_instance_len = 0;
if (visibility_word_per_draw > 0) {
uint visibility_word = resource_index * visibility_word_per_draw;
for (uint i = 0; i < visibility_word_per_draw; i++, visibility_word++) {
for (int i = 0; i < visibility_word_per_draw; i++, visibility_word++) {
/* NOTE: This assumes `proto.instance_len` is 1. */
/* TODO: Assert. */
visible_instance_len += bitCount(visibility_buf[visibility_word]);
@ -103,7 +103,7 @@ void main()
/* Fill resource_id buffer for each instance of this draw. */
if (visibility_word_per_draw > 0) {
uint visibility_word = resource_index * visibility_word_per_draw;
for (uint i = 0; i < visibility_word_per_draw; i++, visibility_word++) {
for (int i = 0; i < visibility_word_per_draw; i++, visibility_word++) {
uint word = visibility_buf[visibility_word];
uint view_index = i * 32u;
while (word != 0u) {

View File

@ -112,7 +112,7 @@ vec4 frustum_culling_sphere_calc(FrustumCorners frustum_corners)
void main()
{
drw_view_id = int(gl_LocalInvocationID.x);
drw_view_id = gl_LocalInvocationID.x;
/* Invalid views are disabled. */
if (all(equal(drw_view.viewinv[2].xyz, vec3(0.0)))) {

View File

@ -23,7 +23,7 @@ void mask_visibility_bit(uint view_id)
void main()
{
if (gl_GlobalInvocationID.x >= resource_len) {
if (int(gl_GlobalInvocationID.x) >= resource_len) {
return;
}
@ -38,7 +38,7 @@ void main()
Sphere inscribed_sphere = shape_sphere(bounds.bounding_sphere.xyz,
bounds._inner_sphere_radius);
for (drw_view_id = 0; drw_view_id < view_len; drw_view_id++) {
for (drw_view_id = 0u; drw_view_id < uint(view_len); drw_view_id++) {
if (drw_view_culling.bound_sphere.w == -1.0) {
/* View disabled. */
mask_visibility_bit(drw_view_id);

View File

@ -338,13 +338,13 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
}
/* materials and particles animdata */
else if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) {
offset += (short)(0.7f * U.widget_unit);
offset += short(0.7f * U.widget_unit);
/* If not in Action Editor mode, action-groups (and their children)
* must carry some offset too. */
}
else if (ac->datatype != ANIMCONT_ACTION) {
offset += (short)(0.7f * U.widget_unit);
offset += short(0.7f * U.widget_unit);
}
/* nodetree animdata */
@ -3994,7 +3994,7 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y
*/
rctf box;
box.xmin = offset;
box.xmax = (float)v2d->cur.xmax;
box.xmax = float(v2d->cur.xmax);
box.ymin = yminc + NLACHANNEL_SKIP;
box.ymax = ymaxc + NLACHANNEL_SKIP - 1;
UI_draw_roundbox_4fv(&box, true, 8, color);
@ -4503,7 +4503,7 @@ void ANIM_channel_draw(
}
else {
/* A bit of padding when there is no expand widget. */
offset += (short)(0.2f * U.widget_unit);
offset += short(0.2f * U.widget_unit);
}
/* step 3) draw icon ............................................... */
@ -4598,7 +4598,7 @@ void ANIM_channel_draw(
immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, float(offset), yminc);
immVertex2f(pos, (float)v2d->cur.xmax, yminc);
immVertex2f(pos, float(v2d->cur.xmax), yminc);
immEnd();
immUnbindProgram();
@ -4654,7 +4654,7 @@ void ANIM_channel_draw(
/* solo... */
if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) {
/* A touch of padding because the star icon is so wide. */
offset += (short)(1.2f * ICON_WIDTH);
offset += short(1.2f * ICON_WIDTH);
}
/* protect... */
@ -4839,12 +4839,12 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
/* Get NLA context for value remapping */
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
depsgraph, (float)scene->r.cfra);
depsgraph, float(scene->r.cfra));
NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context(
&nla_cache, &id_ptr, adt, &anim_eval_context);
/* get current frame and apply NLA-mapping to it (if applicable) */
cfra = BKE_nla_tweakedit_remap(adt, (float)scene->r.cfra, NLATIME_CONVERT_UNMAP);
cfra = BKE_nla_tweakedit_remap(adt, float(scene->r.cfra), NLATIME_CONVERT_UNMAP);
/* Get flags for keyframing. */
flag = ANIM_get_keyframing_flags(scene, true);
@ -4901,7 +4901,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
/* Get NLA context for value remapping */
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
depsgraph, (float)scene->r.cfra);
depsgraph, float(scene->r.cfra));
NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context(
&nla_cache, &id_ptr, key->adt, &anim_eval_context);
@ -4967,7 +4967,7 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, void * /*id_poin*/
float cfra;
/* get current frame - *no* NLA mapping should be done */
cfra = (float)scene->r.cfra;
cfra = float(scene->r.cfra);
/* get flags for keyframing */
flag = ANIM_get_keyframing_flags(scene, true);
@ -5363,7 +5363,7 @@ void ANIM_channel_draw_widgets(const bContext *C,
/* step 5) draw mute+protection toggles + (sliders) ....................... */
/* reset offset - now goes from RHS of panel */
offset = (int)rect->xmax;
offset = int(rect->xmax);
/* TODO: when drawing sliders, make those draw instead of these toggles if not enough space. */
if (v2d && !is_being_renamed) {
@ -5393,7 +5393,7 @@ void ANIM_channel_draw_widgets(const bContext *C,
offset -= ICON_WIDTH;
draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_SOLO);
/* A touch of padding because the star icon is so wide. */
offset -= (short)(0.2f * ICON_WIDTH);
offset -= short(0.2f * ICON_WIDTH);
}
/* protect... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {

View File

@ -54,7 +54,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
Scene *scene = CTX_data_scene(C);
const float time = scene->r.cfra + scene->r.subframe;
const float x = (float)(time * scene->r.framelen);
const float x = float(time * scene->r.framelen);
GPU_line_width((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
@ -95,8 +95,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
/* only draw two separate 'curtains' if there's no overlap between them */
if (PSFRA < PEFRA + end_frame_width) {
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
immRectf(pos, (float)(PEFRA + end_frame_width), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, float(PSFRA), v2d->cur.ymax);
immRectf(pos, float(PEFRA + end_frame_width), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
@ -123,8 +123,8 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
immUniformThemeColorShadeAlpha(TH_BACK, -25, -100);
if (scene->r.sfra < scene->r.efra) {
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)scene->r.sfra, v2d->cur.ymax);
immRectf(pos, (float)scene->r.efra, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, float(scene->r.sfra), v2d->cur.ymax);
immRectf(pos, float(scene->r.efra), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
@ -137,11 +137,11 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
immBegin(GPU_PRIM_LINES, 4);
immVertex2f(pos, (float)scene->r.sfra, v2d->cur.ymin);
immVertex2f(pos, (float)scene->r.sfra, v2d->cur.ymax);
immVertex2f(pos, float(scene->r.sfra), v2d->cur.ymin);
immVertex2f(pos, float(scene->r.sfra), v2d->cur.ymax);
immVertex2f(pos, (float)scene->r.efra, v2d->cur.ymin);
immVertex2f(pos, (float)scene->r.efra, v2d->cur.ymax);
immVertex2f(pos, float(scene->r.efra), v2d->cur.ymin);
immVertex2f(pos, float(scene->r.efra), v2d->cur.ymax);
immEnd();
immUnbindProgram();
@ -259,7 +259,7 @@ static short bezt_nlamapping_restore(KeyframeEditData *ked, BezTriple *bezt)
{
/* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */
AnimData *adt = (AnimData *)ked->data;
short only_keys = (short)ked->i1;
short only_keys = short(ked->i1);
/* adjust BezTriple handles only if allowed to */
if (only_keys == 0) {
@ -278,7 +278,7 @@ static short bezt_nlamapping_apply(KeyframeEditData *ked, BezTriple *bezt)
{
/* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */
AnimData *adt = (AnimData *)ked->data;
short only_keys = (short)ked->i1;
short only_keys = short(ked->i1);
/* adjust BezTriple handles only if allowed to */
if (only_keys == 0) {
@ -356,7 +356,7 @@ static void fcurve_scene_coord_range_get(Scene *scene,
fcu->bezt, scene->r.pefra + 1, fcu->totvert, &replace);
}
else if (fcu->fpt) {
const int unclamped_start = (int)(scene->r.psfra - fcu->fpt[0].vec[0]);
const int unclamped_start = int(scene->r.psfra - fcu->fpt[0].vec[0]);
start = max_ii(unclamped_start, 0);
end = min_ii(unclamped_start + (scene->r.pefra - scene->r.psfra) + 1, fcu->totvert);
}
@ -390,7 +390,7 @@ static void fcurve_scene_coord_range_get(Scene *scene,
else {
const int resol = fcu->driver ?
32 :
min_ii((int)(5.0f * len_v2v2(bezt->vec[1], prev_bezt->vec[1])),
min_ii(int(5.0f * len_v2v2(bezt->vec[1], prev_bezt->vec[1])),
32);
if (resol < 2) {
max_coord = max_ff(max_coord, prev_bezt->vec[1][1]);
@ -572,7 +572,7 @@ static bool find_prev_next_keyframes(bContext *C, int *r_nextfra, int *r_prevfra
bool donenext = false, doneprev = false;
int nextcount = 0, prevcount = 0;
cfranext = cfraprev = (float)(scene->r.cfra);
cfranext = cfraprev = float(scene->r.cfra);
/* seed up dummy dopesheet context with flags to perform necessary filtering */
if ((scene->flag & SCE_KEYS_NO_SELONLY) == 0) {
@ -601,7 +601,7 @@ static bool find_prev_next_keyframes(bContext *C, int *r_nextfra, int *r_prevfra
aknext = ED_keylist_find_next(keylist, cfranext);
if (aknext) {
if (scene->r.cfra == (int)aknext->cfra) {
if (scene->r.cfra == int(aknext->cfra)) {
/* make this the new starting point for the search and ignore */
cfranext = aknext->cfra;
}
@ -619,7 +619,7 @@ static bool find_prev_next_keyframes(bContext *C, int *r_nextfra, int *r_prevfra
akprev = ED_keylist_find_prev(keylist, cfraprev);
if (akprev) {
if (scene->r.cfra == (int)akprev->cfra) {
if (scene->r.cfra == int(akprev->cfra)) {
/* make this the new starting point for the search */
}
else {

View File

@ -230,7 +230,7 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3])
* so the base color is simply one of the three primary colors
*/
grouping = (4 - (tot % 2));
hsv[0] = HSV_BANDWIDTH * (float)(cur % grouping);
hsv[0] = HSV_BANDWIDTH * float(cur % grouping);
/* 'Value' (i.e. darkness) needs to vary so that larger sets of three will be
* 'darker' (i.e. smaller value), so that they don't look that similar to previous ones.

View File

@ -104,7 +104,7 @@ int ED_markers_post_apply_transform(
ListBase *markers, Scene *scene, int mode, float value, char side)
{
TimeMarker *marker;
float cfra = (float)scene->r.cfra;
float cfra = float(scene->r.cfra);
int changed_tot = 0;
/* sanity check - no markers, or locked markers */
@ -129,7 +129,7 @@ int ED_markers_post_apply_transform(
}
case TFM_TIME_SCALE: {
/* rescale the distance between the marker and the current frame */
marker->frame = cfra + round_fl_to_int((float)(marker->frame - cfra) * value);
marker->frame = cfra + round_fl_to_int(float(marker->frame - cfra) * value);
changed_tot++;
break;
}
@ -149,7 +149,7 @@ TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x)
if (markers) {
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
dist = fabsf((float)marker->frame - x);
dist = fabsf(float(marker->frame) - x);
if (dist < min_dist) {
min_dist = dist;
@ -185,10 +185,10 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float *
for (marker = static_cast<TimeMarker *>(markers->first); marker; marker = marker->next) {
if (!sel || (marker->flag & SELECT)) {
if (marker->frame < min) {
min = (float)marker->frame;
min = float(marker->frame);
}
if (marker->frame > max) {
max = (float)marker->frame;
max = float(marker->frame);
}
}
}
@ -1021,7 +1021,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even
/* Modal numinput active, try to handle numeric inputs first... */
if (event->val == KM_PRESS && has_numinput && handleNumInput(C, &mm->num, event)) {
float value = (float)RNA_int_get(op->ptr, "frames");
float value = float(RNA_int_get(op->ptr, "frames"));
applyNumInput(&mm->num, &value);
if (use_time) {
@ -1068,7 +1068,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even
float fac;
mm->evtx = event->xy[0];
fac = ((float)(event->xy[0] - mm->firstx) * dx);
fac = (float(event->xy[0] - mm->firstx) * dx);
apply_keyb_grid((event->modifier & KM_SHIFT) != 0,
(event->modifier & KM_CTRL) != 0,
@ -1087,7 +1087,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even
}
if (!handled && event->val == KM_PRESS && handleNumInput(C, &mm->num, event)) {
float value = (float)RNA_int_get(op->ptr, "frames");
float value = float(RNA_int_get(op->ptr, "frames"));
applyNumInput(&mm->num, &value);
if (use_time) {

View File

@ -582,13 +582,13 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void * /*arg*/)
/* init template data */
fed.min = -1.0f;
fed.max = 1.0f;
fed.time = (float)scene->r.cfra; /* XXX make this int for ease of use? */
fed.time = float(scene->r.cfra); /* XXX make this int for ease of use? */
fed.f1 = fed.f2 = 0;
/* check that no data exists for the current frame... */
if (env->data) {
bool exists;
int i = BKE_fcm_envelope_find_index(env->data, (float)(scene->r.cfra), env->totvert, &exists);
int i = BKE_fcm_envelope_find_index(env->data, float(scene->r.cfra), env->totvert, &exists);
/* binarysearch_...() will set exists by default to 0,
* so if it is non-zero, that means that the point exists already */

View File

@ -203,7 +203,7 @@ static void draw_keylist_ui_data_init(DrawKeylistUIData *ctx,
ctx->smaller_size = 0.35f * ctx->icon_size;
ctx->ipo_size = 0.1f * ctx->icon_size;
ctx->gpencil_size = ctx->smaller_size * 0.8f;
ctx->screenspace_margin = (0.35f * (float)UI_UNIT_X) / UI_view2d_scale_get_x(v2d);
ctx->screenspace_margin = (0.35f * float(UI_UNIT_X)) / UI_view2d_scale_get_x(v2d);
ctx->show_ipo = (saction_flag & SACTION_SHOW_INTERPOLATION) != 0;
@ -249,7 +249,7 @@ static void draw_keylist_block_gpencil(const DrawKeylistUIData *ctx,
box.ymax = ypos + ctx->gpencil_size;
UI_draw_roundbox_4fv(
&box, true, 0.25f * (float)UI_UNIT_X, (ab->block.sel) ? ctx->sel_mhcol : ctx->unsel_mhcol);
&box, true, 0.25f * float(UI_UNIT_X), (ab->block.sel) ? ctx->sel_mhcol : ctx->unsel_mhcol);
}
static void draw_keylist_block_moving_hold(const DrawKeylistUIData *ctx,

View File

@ -818,7 +818,7 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
static short snap_bezier_nearest(KeyframeEditData * /*ked*/, BezTriple *bezt)
{
if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)floorf(bezt->vec[1][0] + 0.5f);
bezt->vec[1][0] = float(floorf(bezt->vec[1][0] + 0.5f));
}
return 0;
}
@ -827,10 +827,10 @@ static short snap_bezier_nearest(KeyframeEditData * /*ked*/, BezTriple *bezt)
static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
{
const Scene *scene = ked->scene;
const float secf = (float)FPS;
const float secf = float(FPS);
if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (floorf(bezt->vec[1][0] / secf + 0.5f) * secf);
bezt->vec[1][0] = float(floorf(bezt->vec[1][0] / secf + 0.5f)) * secf;
}
return 0;
}
@ -840,7 +840,7 @@ static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
{
const Scene *scene = ked->scene;
if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)scene->r.cfra;
bezt->vec[1][0] = float(scene->r.cfra);
}
return 0;
}
@ -849,7 +849,7 @@ static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt)
{
if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]);
bezt->vec[1][0] = float(ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]));
}
return 0;
}

View File

@ -390,6 +390,11 @@ void blend_to_default_fcurve(PointerRNA *id_ptr, FCurve *fcu, const float factor
/* ---------------- */
struct ButterworthCoefficients {
double *A, *d1, *d2;
int filter_order;
};
ButterworthCoefficients *ED_anim_allocate_butterworth_coefficients(const int filter_order)
{
ButterworthCoefficients *bw_coeff = static_cast<ButterworthCoefficients *>(
@ -415,7 +420,7 @@ void ED_anim_calculate_butterworth_coefficients(const float cutoff_frequency,
const float sampling_frequency,
ButterworthCoefficients *bw_coeff)
{
double s = (double)sampling_frequency;
double s = double(sampling_frequency);
const double a = tan(M_PI * cutoff_frequency / s);
const double a2 = a * a;
double r;
@ -466,7 +471,7 @@ static float butterworth_calculate_blend_value(float *samples,
if (sample_index - start_index <= blend_in_out) {
const int blend_index = sample_index - start_index;
const float blend_in_out_factor = clamp_f((float)blend_index / blend_in_out, 0.0f, 1.0f);
const float blend_in_out_factor = clamp_f(float(blend_index) / blend_in_out, 0.0f, 1.0f);
const float blend_value = interpf(blend_in_y_filtered +
slope_in_filtered * (blend_in_out - blend_index),
blend_in_y_samples + slope_in_samples * blend_index,
@ -475,7 +480,7 @@ static float butterworth_calculate_blend_value(float *samples,
}
if (end_index - sample_index <= blend_in_out) {
const int blend_index = end_index - sample_index;
const float blend_in_out_factor = clamp_f((float)blend_index / blend_in_out, 0.0f, 1.0f);
const float blend_in_out_factor = clamp_f(float(blend_index) / blend_in_out, 0.0f, 1.0f);
const float blend_value = interpf(blend_out_y_filtered +
slope_out_filtered * (blend_in_out - blend_index),
blend_out_y_samples + slope_out_samples * blend_index,
@ -512,9 +517,9 @@ void butterworth_smooth_fcurve_segment(FCurve *fcu,
const float fwd_offset = samples[0];
for (int i = 0; i < sample_count; i++) {
const double x = (double)(samples[i] - fwd_offset);
const double x = double(samples[i] - fwd_offset);
const double filtered_value = butterworth_filter_value(x, w0, w1, w2, bw_coeff);
filtered_values[i] = (float)(filtered_value) + fwd_offset;
filtered_values[i] = float(filtered_value) + fwd_offset;
}
for (int i = 0; i < filter_order; i++) {
@ -527,9 +532,9 @@ void butterworth_smooth_fcurve_segment(FCurve *fcu,
/* Run the filter backwards as well to remove phase offset. */
for (int i = sample_count - 1; i >= 0; i--) {
const double x = (double)(filtered_values[i] - bwd_offset);
const double x = double(filtered_values[i] - bwd_offset);
const double filtered_value = butterworth_filter_value(x, w0, w1, w2, bw_coeff);
filtered_values[i] = (float)(filtered_value) + bwd_offset;
filtered_values[i] = float(filtered_value) + bwd_offset;
}
const int segment_end_index = segment->start_index + segment->length;
@ -537,7 +542,7 @@ void butterworth_smooth_fcurve_segment(FCurve *fcu,
BezTriple right_bezt = fcu->bezt[segment_end_index - 1];
const int samples_start_index = filter_order * sample_rate;
const int samples_end_index = (int)(right_bezt.vec[1][0] - left_bezt.vec[1][0] + filter_order) *
const int samples_end_index = int(right_bezt.vec[1][0] - left_bezt.vec[1][0] + filter_order) *
sample_rate;
const int blend_in_out_clamped = min_ii(blend_in_out,
@ -549,11 +554,10 @@ void butterworth_smooth_fcurve_segment(FCurve *fcu,
blend_in_out_factor = 1;
}
else if (i < segment->start_index + segment->length / 2) {
blend_in_out_factor = min_ff((float)(i - segment->start_index) / blend_in_out_clamped, 1.0f);
blend_in_out_factor = min_ff(float(i - segment->start_index) / blend_in_out_clamped, 1.0f);
}
else {
blend_in_out_factor = min_ff((float)(segment_end_index - i - 1) / blend_in_out_clamped,
1.0f);
blend_in_out_factor = min_ff(float(segment_end_index - i - 1) / blend_in_out_clamped, 1.0f);
}
const float x_delta = fcu->bezt[i].vec[1][0] - left_bezt.vec[1][0] + filter_order;
@ -941,7 +945,7 @@ void sample_fcurve_segment(FCurve *fcu,
const int sample_count)
{
for (int i = 0; i < sample_count; i++) {
const float evaluation_time = start_frame + ((float)i / sample_rate);
const float evaluation_time = start_frame + (float(i) / sample_rate);
samples[i] = evaluate_fcurve(fcu, evaluation_time);
}
}
@ -981,8 +985,8 @@ void sample_fcurve(FCurve *fcu)
* keyframes while sampling will affect the outcome...
* - only start sampling+adding from index=1, so that we don't overwrite original keyframe
*/
range = (int)ceil(end->vec[1][0] - start->vec[1][0]);
sfra = (int)floor(start->vec[1][0]);
range = int(ceil(end->vec[1][0] - start->vec[1][0]));
sfra = int(floor(start->vec[1][0]));
if (range) {
value_cache = static_cast<TempFrameValCache *>(
@ -990,7 +994,7 @@ void sample_fcurve(FCurve *fcu)
/* sample values */
for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
fp->frame = (float)(sfra + n);
fp->frame = float(sfra + n);
fp->val = evaluate_fcurve(fcu, fp->frame);
}
@ -1591,13 +1595,13 @@ eKeyPasteError paste_animedit_keys(bAnimContext *ac,
/* methods of offset */
switch (offset_mode) {
case KEYFRAME_PASTE_OFFSET_CFRA_START:
offset[0] = (float)(scene->r.cfra - animcopy_firstframe);
offset[0] = float(scene->r.cfra - animcopy_firstframe);
break;
case KEYFRAME_PASTE_OFFSET_CFRA_END:
offset[0] = (float)(scene->r.cfra - animcopy_lastframe);
offset[0] = float(scene->r.cfra - animcopy_lastframe);
break;
case KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE:
offset[0] = (float)(scene->r.cfra - animcopy_cfra);
offset[0] = float(scene->r.cfra - animcopy_cfra);
break;
case KEYFRAME_PASTE_OFFSET_NONE:
offset[0] = 0.0f;

View File

@ -800,7 +800,7 @@ static float *setting_get_rna_values(
tmp_bool = static_cast<bool *>(MEM_malloc_arrayN(length, sizeof(*tmp_bool), __func__));
RNA_property_boolean_get_array(ptr, prop, tmp_bool);
for (int i = 0; i < length; i++) {
values[i] = (float)tmp_bool[i];
values[i] = float(tmp_bool[i]);
}
MEM_freeN(tmp_bool);
break;
@ -808,7 +808,7 @@ static float *setting_get_rna_values(
tmp_int = static_cast<int *>(MEM_malloc_arrayN(length, sizeof(*tmp_int), __func__));
RNA_property_int_get_array(ptr, prop, tmp_int);
for (int i = 0; i < length; i++) {
values[i] = (float)tmp_int[i];
values[i] = float(tmp_int[i]);
}
MEM_freeN(tmp_int);
break;
@ -824,16 +824,16 @@ static float *setting_get_rna_values(
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
*values = (float)RNA_property_boolean_get(ptr, prop);
*values = float(RNA_property_boolean_get(ptr, prop));
break;
case PROP_INT:
*values = (float)RNA_property_int_get(ptr, prop);
*values = float(RNA_property_int_get(ptr, prop));
break;
case PROP_FLOAT:
*values = RNA_property_float_get(ptr, prop);
break;
case PROP_ENUM:
*values = (float)RNA_property_enum_get(ptr, prop);
*values = float(RNA_property_enum_get(ptr, prop));
break;
default:
*values = 0.0f;
@ -2382,7 +2382,7 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
float cfra = (float)scene->r.cfra;
float cfra = float(scene->r.cfra);
int selected_objects_len = 0;
int selected_objects_success_len = 0;
@ -2533,7 +2533,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
char *path;
uiBut *but;
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
CTX_data_depsgraph_pointer(C), (float)scene->r.cfra);
CTX_data_depsgraph_pointer(C), float(scene->r.cfra));
bool changed = false;
int index;
const bool all = RNA_boolean_get(op->ptr, "all");
@ -2884,7 +2884,7 @@ void ANIM_OT_keyframe_clear_button(wmOperatorType *ot)
bool autokeyframe_cfra_can_key(const Scene *scene, ID *id)
{
float cfra = (float)scene->r.cfra; /* XXX for now, this will do */
float cfra = float(scene->r.cfra); /* XXX for now, this will do */
/* only filter if auto-key mode requires this */
if (IS_AUTOKEY_ON(scene) == 0) {
@ -3071,7 +3071,7 @@ bool ED_autokeyframe_object(bContext *C, Scene *scene, Object *ob, KeyingSet *ks
* 3) Free the extra info.
*/
ANIM_relative_keyingset_add_source(&dsources, &ob->id, nullptr, nullptr);
ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra);
ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, float(scene->r.cfra));
BLI_freelistN(&dsources);
return true;
@ -3091,7 +3091,7 @@ bool ED_autokeyframe_pchan(
* 3) Free the extra info.
*/
ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan);
ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra);
ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, float(scene->r.cfra));
BLI_freelistN(&dsources);
return true;

View File

@ -151,7 +151,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, PoseBlendData *pbd)
}
/* Perform actual auto-keying. */
ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra);
ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, float(scene->r.cfra));
BLI_freelistN(&dsources);
/* send notifiers for this */

View File

@ -363,7 +363,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
pose_frame_range_from_object_get(pso, ob, &prev_frame, &next_frame);
const float factor = ED_slider_factor_get(pso->slider);
const float current_frame = (float)pso->current_frame;
const float current_frame = float(pso->current_frame);
/* Calculate the relative weights of the endpoints. */
if (pso->mode == POSESLIDE_BREAKDOWN) {
@ -377,8 +377,8 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, Object *ob, flo
* - they then get normalized so that they only sum up to 1
*/
next_weight = current_frame - (float)pso->prev_frame;
prev_weight = (float)pso->next_frame - current_frame;
next_weight = current_frame - float(pso->prev_frame);
prev_weight = float(pso->next_frame) - current_frame;
const float total_weight = next_weight + prev_weight;
next_weight = (next_weight / total_weight);
@ -620,7 +620,7 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
path = BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion");
/* Get the current frame number. */
const float current_frame = (float)pso->current_frame;
const float current_frame = float(pso->current_frame);
const float factor = ED_slider_factor_get(pso->slider);
/* Using this path, find each matching F-Curve for the variables we're interested in. */
@ -677,7 +677,7 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
/* Compute breakdown based on actual frame range. */
const float interp_factor = (current_frame - pso->prev_frame) /
(float)(pso->next_frame - pso->prev_frame);
float(pso->next_frame - pso->prev_frame);
interp_qt_qtqt(quat_breakdown, quat_prev, quat_next, interp_factor);
@ -911,7 +911,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
static void pose_slide_autoKeyframe(bContext *C, tPoseSlideOp *pso)
{
/* Wrapper around the generic call. */
poseAnim_mapping_autoKeyframe(C, pso->scene, &pso->pfLinks, (float)pso->current_frame);
poseAnim_mapping_autoKeyframe(C, pso->scene, &pso->pfLinks, float(pso->current_frame));
}
/**
@ -1052,7 +1052,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, const wmEvent *
return OPERATOR_CANCELLED;
}
float current_frame = (float)pso->current_frame;
float current_frame = float(pso->current_frame);
/* Firstly, check if the current frame is a keyframe. */
const ActKeyColumn *ak = ED_keylist_find_exact(pso->keylist, current_frame);

View File

@ -1223,7 +1223,7 @@ static int pose_clear_transform_generic_exec(bContext *C,
/* insert keyframes */
ANIM_apply_keyingset(
C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra);
C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, float(scene->r.cfra));
/* now recalculate paths */
if (ob_iter->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) {
@ -1366,7 +1366,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
depsgraph, (float)scene->r.cfra);
depsgraph, float(scene->r.cfra));
const bool only_select = RNA_boolean_get(op->ptr, "only_selected");
FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {

View File

@ -1428,15 +1428,20 @@ static float gpencil_sculpt_rotation_eval_get(tGP_BrushEditData *gso,
}
}
if (pt_eval->runtime.idx_orig != 0) {
pt_orig_prev = &gps_orig->points[pt_eval->runtime.idx_orig - 1];
if (pt_eval->runtime.pt_orig == NULL) {
pt_orig_prev = pt_prev_eval;
}
else {
if (gps_orig->totpoints > 1) {
pt_orig_prev = &gps_orig->points[pt_eval->runtime.idx_orig + 1];
if (pt_eval->runtime.idx_orig != 0) {
pt_orig_prev = &gps_orig->points[pt_eval->runtime.idx_orig - 1];
}
else {
return 0.0f;
if (gps_orig->totpoints > 1) {
pt_orig_prev = &gps_orig->points[pt_eval->runtime.idx_orig + 1];
}
else {
return 0.0f;
}
}
}
@ -1463,7 +1468,6 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso,
GP_SpaceConversion *gsc = &gso->gsc;
rcti *rect = &gso->brush_rect;
Brush *brush = gso->brush;
char tool = gso->brush->gpencil_sculpt_tool;
const int radius = (brush->flag & GP_BRUSH_USE_PRESSURE) ? gso->brush->size * gso->pressure :
gso->brush->size;
const bool is_masking = GPENCIL_ANY_SCULPT_MASK(gso->mask);
@ -1542,8 +1546,7 @@ static bool gpencil_sculpt_brush_do_stroke(tGP_BrushEditData *gso,
/* To each point individually... */
pt = &gps->points[i];
if ((i != gps->totpoints - 2) && (pt->runtime.pt_orig == NULL) &&
(tool != GPSCULPT_TOOL_GRAB)) {
if ((i != gps->totpoints - 2) && (pt->runtime.pt_orig == NULL)) {
continue;
}
pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;

View File

@ -15,6 +15,7 @@ extern "C" {
#endif
struct BezTriple;
struct ButterworthCoefficients;
struct FCurve;
struct Scene;
struct bAnimContext;
@ -436,12 +437,7 @@ void breakdown_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment,
*/
void ED_ANIM_get_1d_gauss_kernel(const float sigma, int kernel_size, double *r_kernel);
typedef struct ButterworthCoefficients {
double *A, *d1, *d2;
int filter_order;
} ButterworthCoefficients;
ButterworthCoefficients *ED_anim_allocate_butterworth_coefficients(const int filter_order);
struct ButterworthCoefficients *ED_anim_allocate_butterworth_coefficients(const int filter_order);
void ED_anim_free_butterworth_coefficients(struct ButterworthCoefficients *bw_coeff);
void ED_anim_calculate_butterworth_coefficients(float cutoff,
float sampling_frequency,

View File

@ -287,8 +287,8 @@ static bool snap_mask_layer_cframe(MaskLayerShape *mask_layer_shape, Scene *scen
static bool snap_mask_layer_nearmarker(MaskLayerShape *mask_layer_shape, Scene *scene)
{
if (mask_layer_shape->flag & MASK_SHAPE_SELECT) {
mask_layer_shape->frame = (int)ED_markers_find_nearest_marker_time(
&scene->markers, float(mask_layer_shape->frame));
mask_layer_shape->frame = int(
ED_markers_find_nearest_marker_time(&scene->markers, float(mask_layer_shape->frame)));
}
return false;
}

View File

@ -137,7 +137,7 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op)
SNPRINTF(offset_str, "%.1f%%", RNA_float_get(op->ptr, "offset_pct"));
}
else {
double offset_val = (double)RNA_float_get(op->ptr, "offset");
double offset_val = double(RNA_float_get(op->ptr, "offset"));
BKE_unit_value_as_string(offset_str,
NUM_STR_REP_LEN,
offset_val * sce->unit.scale_length,
@ -261,7 +261,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
opdata->is_modal = is_modal;
int otype = RNA_enum_get(op->ptr, "offset_type");
opdata->value_mode = (otype == BEVEL_AMT_PERCENT) ? OFFSET_VALUE_PERCENT : OFFSET_VALUE;
opdata->segments = (float)RNA_int_get(op->ptr, "segments");
opdata->segments = float(RNA_int_get(op->ptr, "segments"));
float pixels_per_inch = U.dpi;
for (int i = 0; i < NUM_VALUE_KINDS; i++) {
@ -564,7 +564,7 @@ static void edbm_bevel_mouse_set_value(wmOperator *op, const wmEvent *event)
CLAMP(value, value_clamp_min[vmode], value_clamp_max[vmode]);
if (vmode == SEGMENTS_VALUE) {
opdata->segments = value;
RNA_int_set(op->ptr, "segments", (int)(value + 0.5f));
RNA_int_set(op->ptr, "segments", int(value + 0.5f));
}
else {
RNA_float_set(op->ptr, value_rna_name[vmode], value);
@ -702,7 +702,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
else {
opdata->segments += delta;
}
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
RNA_int_set(op->ptr, "segments", int(opdata->segments));
edbm_bevel_calc(op);
edbm_bevel_update_status_text(C, op);
handled = true;
@ -722,7 +722,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
case BEV_MODAL_SEGMENTS_UP:
opdata->segments = opdata->segments + 1;
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
RNA_int_set(op->ptr, "segments", int(opdata->segments));
edbm_bevel_calc(op);
edbm_bevel_update_status_text(C, op);
handled = true;
@ -730,7 +730,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
case BEV_MODAL_SEGMENTS_DOWN:
opdata->segments = max_ff(opdata->segments - 1, 1);
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
RNA_int_set(op->ptr, "segments", int(opdata->segments));
edbm_bevel_calc(op);
edbm_bevel_update_status_text(C, op);
handled = true;

View File

@ -781,7 +781,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
float nor[3] = {0.0, 0.0, 0.0};
/* 2D normal calc */
const float mval_f[2] = {(float)event->mval[0], (float)event->mval[1]};
const float mval_f[2] = {float(event->mval[0]), float(event->mval[1])};
/* check for edges that are half selected, use for rotation */
bool done = false;

View File

@ -49,7 +49,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip");
const bool dupli = RNA_boolean_get(op->ptr, "dupli");
const bool use_auto_merge = (RNA_boolean_get(op->ptr, "use_auto_merge") && (dupli == false) &&
(steps >= 3) && fabsf(fabsf(angle) - (float)(M_PI * 2)) <= 1e-6f);
(steps >= 3) && fabsf(fabsf(angle) - float(M_PI * 2)) <= 1e-6f);
if (is_zero_v3(axis)) {
BKE_report(op->reports, RPT_ERROR, "Invalid/unset axis");

View File

@ -510,7 +510,7 @@ static void knifetool_draw_visible_distances(const KnifeTool_OpData *kcd)
else {
BKE_unit_value_as_string(numstr,
sizeof(numstr),
(double)(cut_len * unit->scale_length),
double(cut_len * unit->scale_length),
distance_precision,
B_UNIT_LENGTH,
unit,
@ -3141,7 +3141,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
{
float p[3], p_cage[3];
uint ob_index = (uint)(uintptr_t)BLI_smallhash_lookup(&fobs, uintptr_t(f));
uint ob_index = uint(uintptr_t(BLI_smallhash_lookup(&fobs, uintptr_t(f))));
ob = kcd->objects[ob_index];
if (use_hit_prev &&
@ -3255,8 +3255,8 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd,
* Apply the mouse coordinates to a copy of the view-context
* since we don't want to rely on this being set elsewhere. */
ViewContext vc = kcd->vc;
vc.mval[0] = (int)kcd->curr.mval[0];
vc.mval[1] = (int)kcd->curr.mval[1];
vc.mval[0] = int(kcd->curr.mval[0]);
vc.mval[1] = int(kcd->curr.mval[1]);
f = EDBM_face_find_nearest(&vc, &dist);
@ -3342,8 +3342,8 @@ static float knife_snap_size(KnifeTool_OpData *kcd, float maxsize)
int density = 0;
if (!kcd->curr.is_space) {
density = (float)knife_sample_screen_density_from_closest_face(
kcd, maxsize * 2.0f, kcd->curr.ob, kcd->curr.ob_index, kcd->curr.bmface, kcd->curr.cage);
density = float(knife_sample_screen_density_from_closest_face(
kcd, maxsize * 2.0f, kcd->curr.ob, kcd->curr.ob_index, kcd->curr.bmface, kcd->curr.cage));
}
return density ? min_ff(maxsize / (float(density) * 0.5f), maxsize) : maxsize;
@ -4980,7 +4980,7 @@ static bool edbm_mesh_knife_point_isect(LinkNode *polys, const float cent_ss[2])
while (p) {
const float(*mval_fl)[2] = static_cast<const float(*)[2]>(p->link);
const int mval_tot = MEM_allocN_len(mval_fl) / sizeof(*mval_fl);
isect += (int)isect_point_poly_v2(cent_ss, mval_fl, mval_tot - 1, false);
isect += int(isect_point_poly_v2(cent_ss, mval_fl, mval_tot - 1, false));
p = p->next;
}

View File

@ -381,8 +381,8 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
uint base_index;
uint e_index;
} exec_data{};
exec_data.base_index = (uint)RNA_int_get(op->ptr, "object_index");
exec_data.e_index = (uint)RNA_int_get(op->ptr, "edge_index");
exec_data.base_index = uint(RNA_int_get(op->ptr, "object_index"));
exec_data.e_index = uint(RNA_int_get(op->ptr, "edge_index"));
const Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@ -646,7 +646,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
lcd->vc.mval[0] = event->mval[0];
lcd->vc.mval[1] = event->mval[1];
loopcut_mouse_move(lcd, (int)lcd->cuts);
loopcut_mouse_move(lcd, int(lcd->cuts));
ED_region_tag_redraw(lcd->region);
handled = true;
@ -668,8 +668,8 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* allow zero so you can backspace and type in a value
* otherwise 1 as minimum would make more sense */
lcd->cuts = clamp_f(cuts, 0, SUBD_CUTS_MAX);
RNA_int_set(op->ptr, "number_cuts", (int)lcd->cuts);
ringsel_find_edge(lcd, (int)lcd->cuts);
RNA_int_set(op->ptr, "number_cuts", int(lcd->cuts));
ringsel_find_edge(lcd, int(lcd->cuts));
show_cuts = true;
ED_region_tag_redraw(lcd->region);
}
@ -689,7 +689,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
outputNumInput(&lcd->num, str_rep, &sce->unit);
}
else {
BLI_snprintf(str_rep, NUM_STR_REP_LEN, "%d", (int)lcd->cuts);
BLI_snprintf(str_rep, NUM_STR_REP_LEN, "%d", int(lcd->cuts));
BLI_snprintf(str_rep + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%.2f", smoothness);
}
SNPRINTF(

View File

@ -1131,7 +1131,7 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op)
* 1 0 <-- coefficients array indices
*/
float A = standardRange / float(len);
float B = (float)(-sfra) * A;
float B = float(-sfra) * A;
gen->coefficients[1] = A;
gen->coefficients[0] = B;

View File

@ -545,7 +545,7 @@ static void PE_free_shape_tree(PEData *data)
static void PE_create_random_generator(PEData *data)
{
uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX);
uint rng_seed = uint(PIL_check_seconds_timer_i() & UINT_MAX);
rng_seed ^= POINTER_AS_UINT(data->ob);
rng_seed ^= POINTER_AS_UINT(data->edit);
data->rng = BLI_rng_new(rng_seed);
@ -1363,7 +1363,7 @@ static void iterate_lengths_iter(void *__restrict iter_data_v,
for (int j = 1; j < point->totkey; j++) {
PTCacheEditKey *key;
int k;
float mul = 1.0f / (float)point->totkey;
float mul = 1.0f / float(point->totkey);
if (pset->flag & PE_LOCK_FIRST) {
key = point->keys + 1;
k = 1;
@ -2772,11 +2772,11 @@ static void rekey_particle(PEData *data, int pa_index)
sta = key->time = okey->time;
end = (key + data->totrekey - 1)->time = (okey + pa->totkey - 1)->time;
dval = (end - sta) / (float)(data->totrekey - 1);
dval = (end - sta) / float(data->totrekey - 1);
/* interpolate new keys from old ones */
for (k = 1, key++; k < data->totrekey - 1; k++, key++) {
state.time = float(k) / (float)(data->totrekey - 1);
state.time = float(k) / float(data->totrekey - 1);
psys_get_particle_on_path(&sim, pa_index, &state, 0);
copy_v3_v3(key->co, state.co);
key->time = sta + k * dval;
@ -2815,7 +2815,7 @@ static int rekey_exec(bContext *C, wmOperator *op)
PE_set_data(C, &data);
data.dval = 1.0f / (float)(data.totrekey - 1);
data.dval = 1.0f / float(data.totrekey - 1);
data.totrekey = RNA_int_get(op->ptr, "keys_number");
foreach_selected_point(&data, rekey_particle);
@ -2878,7 +2878,7 @@ static void rekey_particle_to_time(
/* interpolate new keys from old ones (roots stay the same) */
for (k = 1, key++; k < pa->totkey; k++, key++) {
state.time = path_time * float(k) / (float)(pa->totkey - 1);
state.time = path_time * float(k) / float(pa->totkey - 1);
psys_get_particle_on_path(&sim, pa_index, &state, 0);
copy_v3_v3(key->co, state.co);
}
@ -3746,7 +3746,7 @@ static void brush_comb(PEData *data,
return;
}
fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->combfac);
fac = float(pow(double(1.0f - mouse_distance / data->rad), double(data->combfac)));
copy_v3_v3(cvec, data->dvec);
mul_mat3_m4_v3(imat, cvec);
@ -3765,7 +3765,7 @@ static void brush_cut(PEData *data, int pa_index)
ParticleCacheKey *key = edit->pathcache[pa_index];
float rad2, cut_time = 1.0;
float x0, x1, v0, v1, o0, o1, xo0, xo1, d, dv;
int k, cut, keys = (int)pow(2.0, (double)pset->draw_step);
int k, cut, keys = int(pow(2.0, double(pset->draw_step)));
int screen_co[2];
BLI_assert(data->rng != nullptr);
@ -3789,11 +3789,11 @@ static void brush_cut(PEData *data, int pa_index)
cut = 0;
x0 = (float)screen_co[0];
x1 = (float)screen_co[1];
x0 = float(screen_co[0]);
x1 = float(screen_co[1]);
o0 = (float)data->mval[0];
o1 = (float)data->mval[1];
o0 = float(data->mval[0]);
o1 = float(data->mval[1]);
xo0 = x0 - o0;
xo1 = x1 - o1;
@ -3811,16 +3811,16 @@ static void brush_cut(PEData *data, int pa_index)
V3D_PROJ_RET_OK) ||
key_test_depth(data, key->co, screen_co) == 0)
{
x0 = (float)screen_co[0];
x1 = (float)screen_co[1];
x0 = float(screen_co[0]);
x1 = float(screen_co[1]);
xo0 = x0 - o0;
xo1 = x1 - o1;
continue;
}
v0 = (float)screen_co[0] - x0;
v1 = (float)screen_co[1] - x1;
v0 = float(screen_co[0]) - x0;
v1 = float(screen_co[1]) - x1;
dv = v0 * v0 + v1 * v1;
@ -3837,7 +3837,7 @@ static void brush_cut(PEData *data, int pa_index)
cut_time /= dv;
if (cut_time < 1.0f) {
cut_time += (float)(k - 1);
cut_time += float(k - 1);
cut_time /= float(keys);
cut = 1;
break;
@ -3845,8 +3845,8 @@ static void brush_cut(PEData *data, int pa_index)
}
}
x0 = (float)screen_co[0];
x1 = (float)screen_co[1];
x0 = float(screen_co[0]);
x1 = float(screen_co[1]);
xo0 = x0 - o0;
xo1 = x1 - o1;
@ -3948,7 +3948,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
normalize_v3(onor_prev);
}
fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->pufffac);
fac = float(pow(double(1.0f - mouse_distance / data->rad), double(data->pufffac)));
fac *= 0.025f;
if (data->invert) {
fac = -fac;
@ -4601,7 +4601,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
point->flag |= PEP_TAG; /* signal for duplicate */
}
framestep = pa->lifetime / (float)(pset->totaddkey - 1);
framestep = pa->lifetime / float(pset->totaddkey - 1);
if (tree) {
ParticleData *ppa;
@ -4627,7 +4627,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
maxd = ptn[maxw - 1].dist;
for (w = 0; w < maxw; w++) {
weight[w] = (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd));
weight[w] = float(pow(2.0, double(-6.0f * ptn[w].dist / maxd)));
totw += weight[w];
}
for (; w < 3; w++) {
@ -4685,7 +4685,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
for (k = 0, hkey = pa->hair; k < pset->totaddkey; k++, hkey++) {
madd_v3_v3v3fl(hkey->co, pa->state.co, pa->state.vel, k * framestep * timestep);
hkey->time += k * framestep;
hkey->weight = 1.0f - float(k) / (float)(pset->totaddkey - 1);
hkey->weight = 1.0f - float(k) / float(pset->totaddkey - 1);
}
}
for (k = 0, hkey = pa->hair; k < pset->totaddkey; k++, hkey++) {
@ -4812,7 +4812,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.context = C; /* TODO(mai): why isn't this set in bedit->data? */
view3d_operator_needs_opengl(C);
selected = (short)count_selected_keys(scene, edit);
selected = short(count_selected_keys(scene, edit));
dmax = max_ff(fabsf(dx), fabsf(dy));
tot_steps = dmax / (0.2f * pe_brush_size_get(scene, brush)) + 1;
@ -4941,7 +4941,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
foreach_mouse_hit_key(&data, brush_smooth_get, selected);
if (data.tot) {
mul_v3_fl(data.vec, 1.0f / (float)data.tot);
mul_v3_fl(data.vec, 1.0f / float(data.tot));
foreach_mouse_hit_key(&data, brush_smooth_do, selected);
}
@ -5359,7 +5359,7 @@ void PE_create_particle_edit(
psys_copy_particles(psys, psys_eval);
}
totpoint = psys ? psys->totpart : (int)((PTCacheMem *)cache->mem_cache.first)->totpoint;
totpoint = psys ? psys->totpart : int(((PTCacheMem *)cache->mem_cache.first)->totpoint);
edit = static_cast<PTCacheEdit *>(MEM_callocN(sizeof(PTCacheEdit), "PE_create_particle_edit"));
edit->points = static_cast<PTCacheEditPoint *>(
@ -5432,7 +5432,7 @@ void PE_create_particle_edit(
key->co = static_cast<float *>(cur[BPHYS_DATA_LOCATION]);
key->vel = static_cast<float *>(cur[BPHYS_DATA_VELOCITY]);
key->rot = static_cast<float *>(cur[BPHYS_DATA_ROTATION]);
key->ftime = (float)pm->frame;
key->ftime = float(pm->frame);
key->time = &key->ftime;
BKE_ptcache_mem_pointers_incr(cur);

View File

@ -160,7 +160,7 @@ static void undoptcache_to_editcache(PTCacheUndo *undo, PTCacheEdit *edit)
LOOP_POINTS {
LOOP_KEYS {
if ((int)key->ftime == (int)pm->frame) {
if (int(key->ftime) == int(pm->frame)) {
key->co = static_cast<float *>(cur[BPHYS_DATA_LOCATION]);
key->vel = static_cast<float *>(cur[BPHYS_DATA_VELOCITY]);
key->rot = static_cast<float *>(cur[BPHYS_DATA_ROTATION]);

View File

@ -508,8 +508,8 @@ static ScrArea *screen_area_trim(
}
/* Measurement with ScrVerts because winx and winy might not be correct at this time. */
float fac = abs(size) / (float)(vertical ? ((*area)->v3->vec.x - (*area)->v1->vec.x) :
((*area)->v3->vec.y - (*area)->v1->vec.y));
float fac = abs(size) / float(vertical ? ((*area)->v3->vec.x - (*area)->v1->vec.x) :
((*area)->v3->vec.y - (*area)->v1->vec.y));
fac = (reverse == vertical) ? 1.0f - fac : fac;
ScrArea *newsa = area_split(
CTX_wm_window(C), screen, *area, vertical ? SCREEN_AXIS_V : SCREEN_AXIS_H, fac, true);
@ -581,7 +581,7 @@ bool screen_area_close(bContext *C, bScreen *screen, ScrArea *area)
const int ar_length = vertical ? (neighbor->v3->vec.x - neighbor->v1->vec.x) :
(neighbor->v3->vec.y - neighbor->v1->vec.y);
/* Calculate the ratio of the lengths of the shared edges. */
float alignment = MIN2(area_length, ar_length) / (float)MAX2(area_length, ar_length);
float alignment = MIN2(area_length, ar_length) / float(MAX2(area_length, ar_length));
if (alignment > best_alignment) {
best_alignment = alignment;
sa2 = neighbor;
@ -1129,7 +1129,7 @@ static void screen_global_area_refresh(wmWindow *win,
static int screen_global_header_size()
{
return (int)ceilf(ED_area_headersize() / UI_SCALE_FAC);
return int(ceilf(ED_area_headersize() / UI_SCALE_FAC));
}
static void screen_global_topbar_area_refresh(wmWindow *win, bScreen *screen)

View File

@ -150,7 +150,7 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win,
float max[2] = {0.0f, 0.0f};
LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) {
const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y};
const float fv[2] = {float(sv->vec.x), float(sv->vec.y)};
minmax_v2v2_v2(min, max, fv);
}

View File

@ -883,7 +883,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b
az->alpha = 1.0f;
}
else if (mouse_sq < fadeout_sq) {
az->alpha = 1.0f - (float)(mouse_sq - fadein_sq) / (float)(fadeout_sq - fadein_sq);
az->alpha = 1.0f - float(mouse_sq - fadein_sq) / float(fadeout_sq - fadein_sq);
}
else {
az->alpha = 0.0f;
@ -1767,7 +1767,7 @@ static int area_snap_calc_location(const bScreen *screen,
BLI_assert(snap_type != SNAP_NONE);
int m_cursor_final = -1;
const int m_cursor = origval + delta;
const int m_span = (float)(bigger + smaller);
const int m_span = float(bigger + smaller);
const int m_min = origval - smaller;
// const int axis_max = axis_min + m_span;
@ -2328,8 +2328,8 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
/* The factor will be close to 1.0f when near the top-left and the bottom-right corners. */
const float factor_v = (float)(event->xy[1] - sad->sa1->v1->vec.y) / (float)sad->sa1->winy;
const float factor_h = (float)(event->xy[0] - sad->sa1->v1->vec.x) / (float)sad->sa1->winx;
const float factor_v = float(event->xy[1] - sad->sa1->v1->vec.y) / float(sad->sa1->winy);
const float factor_h = float(event->xy[0] - sad->sa1->v1->vec.x) / float(sad->sa1->winx);
const bool is_left = factor_v < 0.5f;
const bool is_bottom = factor_h < 0.5f;
const bool is_right = !is_left;
@ -2367,11 +2367,11 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
dir_axis = eScreenAxis(RNA_property_enum_get(op->ptr, prop_dir));
if (dir_axis == SCREEN_AXIS_H) {
RNA_property_float_set(
op->ptr, prop_factor, (float)(event->xy[0] - area->v1->vec.x) / (float)area->winx);
op->ptr, prop_factor, float(event->xy[0] - area->v1->vec.x) / float(area->winx));
}
else {
RNA_property_float_set(
op->ptr, prop_factor, (float)(event->xy[1] - area->v1->vec.y) / (float)area->winy);
op->ptr, prop_factor, float(event->xy[1] - area->v1->vec.y) / float(area->winy));
}
if (!area_split_init(C, op)) {
@ -2585,7 +2585,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
CTX_wm_screen(C)->do_draw = true;
}
float fac = (float)(sd->delta + sd->origval - sd->origmin) / sd->origsize;
float fac = float(sd->delta + sd->origval - sd->origmin) / sd->origsize;
RNA_float_set(op->ptr, "factor", fac);
}
@ -5418,7 +5418,7 @@ float ED_region_blend_alpha(ARegion *region)
RegionAlphaInfo *rgi = static_cast<RegionAlphaInfo *>(region->regiontimer->customdata);
float alpha;
alpha = (float)region->regiontimer->duration / TIMEOUT;
alpha = float(region->regiontimer->duration) / TIMEOUT;
/* makes sure the blend out works 100% - without area redraws */
if (rgi->hidden) {
alpha = 0.9f - TIMESTEP - alpha;

View File

@ -59,6 +59,7 @@ set(SRC
paint_vertex_proj.cc
paint_vertex_weight_ops.cc
paint_vertex_weight_utils.cc
paint_weight.cc
sculpt.cc
sculpt_automasking.cc
sculpt_boundary.cc

View File

@ -517,3 +517,54 @@ void paint_init_pivot(Object *ob, Scene *scene);
/* paint curve defines */
#define PAINT_CURVE_NUM_SEGMENTS 40
namespace blender::ed::sculpt_paint::vwpaint {
struct NormalAnglePrecalc {
bool do_mask_normal;
/* what angle to mask at */
float angle;
/* cos(angle), faster to compare */
float angle__cos;
float angle_inner;
float angle_inner__cos;
/* difference between angle and angle_inner, for easy access */
float angle_range;
};
void view_angle_limits_init(NormalAnglePrecalc *a, float angle, bool do_mask_normal);
float view_angle_limits_apply_falloff(const NormalAnglePrecalc *a, float angle_cos, float *mask_p);
bool test_brush_angle_falloff(const Brush &brush,
const NormalAnglePrecalc &normal_angle_precalc,
const float angle_cos,
float *brush_strength);
bool use_normal(const VPaint *vp);
bool brush_use_accumulate_ex(const Brush *brush, const int ob_mode);
bool brush_use_accumulate(const VPaint *vp);
void get_brush_alpha_data(const Scene *scene,
const SculptSession *ss,
const Brush *brush,
float *r_brush_size_pressure,
float *r_brush_alpha_value,
float *r_brush_alpha_pressure);
void init_stroke(Depsgraph *depsgraph, Object *ob);
void init_session_data(const ToolSettings *ts, Object *ob);
void init_session(Depsgraph *depsgraph, Scene *scene, Object *ob, eObjectMode object_mode);
Vector<PBVHNode *> pbvh_gather_generic(Object *ob, VPaint *wp, Sculpt *sd, Brush *brush);
void mode_enter_generic(
Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, const eObjectMode mode_flag);
void mode_exit_generic(Object *ob, const eObjectMode mode_flag);
bool mode_toggle_poll_test(bContext *C);
void smooth_brush_toggle_off(const bContext *C, Paint *paint, StrokeCache *cache);
void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache *cache);
void update_cache_variants(bContext *C, VPaint *vp, Object *ob, PointerRNA *ptr);
void update_cache_invariants(
bContext *C, VPaint *vp, SculptSession *ss, wmOperator *op, const float mval[2]);
void last_stroke_update(Scene *scene, const float location[3]);
} // namespace blender::ed::sculpt_paint::vwpaint

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -356,9 +356,9 @@ static void do_paint_pixels(void *__restrict userdata,
#ifdef DEBUG_PIXEL_NODES
uint hash = BLI_hash_int(POINTER_AS_UINT(node));
brush_color[0] = (float)(hash & 255) / 255.0f;
brush_color[1] = (float)((hash >> 8) & 255) / 255.0f;
brush_color[2] = (float)((hash >> 16) & 255) / 255.0f;
brush_color[0] = float(hash & 255) / 255.0f;
brush_color[1] = float((hash >> 8) & 255) / 255.0f;
brush_color[2] = float((hash >> 16) & 255) / 255.0f;
#else
copy_v3_v3(brush_color,
ss->cache->invert ? BKE_brush_secondary_color_get(ss->scene, brush) :

View File

@ -358,7 +358,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
BLI_path_abs(filepath, BKE_main_blendfile_path(bmain));
const double fps = (((double)scene_eval->r.frs_sec) / (double)scene_eval->r.frs_sec_base);
const double fps = ((double(scene_eval->r.frs_sec)) / double(scene_eval->r.frs_sec_base));
const int start_frame = scene_eval->r.sfra;
const int end_frame = scene_eval->r.efra;

View File

@ -984,7 +984,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
}
/* Keep aligned with rna_Object_material_slots_get. */
CTX_data_pointer_set(
result, &ob->id, &RNA_MaterialSlot, (void *)(matnr + (uintptr_t)&ob->id));
result, &ob->id, &RNA_MaterialSlot, (void *)(matnr + uintptr_t(&ob->id)));
}
}
@ -1041,7 +1041,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
if (part) {
CTX_data_pointer_set(
result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]);
result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[int(part->texact)]);
}
}
else if (ct) {
@ -1052,7 +1052,7 @@ int /*eContextResult*/ buttons_context(const bContext *C,
if (ls) {
CTX_data_pointer_set(
result, &ls->id, &RNA_LineStyleTextureSlot, ls->mtex[(int)ls->texact]);
result, &ls->id, &RNA_LineStyleTextureSlot, ls->mtex[int(ls->texact)]);
}
}

View File

@ -80,10 +80,10 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile,
v2d->cur.ymax += sfile->layout->offset_top;
BLI_rcti_init(&rect_view,
(int)(v2d->tot.xmin + rect_view_fl.xmin),
(int)(v2d->tot.xmin + rect_view_fl.xmax),
(int)(v2d->tot.ymax - rect_view_fl.ymin),
(int)(v2d->tot.ymax - rect_view_fl.ymax));
int(v2d->tot.xmin + rect_view_fl.xmin),
int(v2d->tot.xmin + rect_view_fl.xmax),
int(v2d->tot.ymax - rect_view_fl.ymin),
int(v2d->tot.ymax - rect_view_fl.ymax));
sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view);
@ -427,13 +427,13 @@ static int file_box_select_find_last_selected(SpaceFile *sfile,
(layout->flag & FILE_LAYOUT_VER && bounds_first.ymin != bounds_last.ymin))
{
/* use vertical distance */
const int my_loc = (int)mouseco_view[1];
const int my_loc = int(mouseco_view[1]);
dist_first = BLI_rcti_length_y(&bounds_first, my_loc);
dist_last = BLI_rcti_length_y(&bounds_last, my_loc);
}
else {
/* use horizontal distance */
const int mx_loc = (int)mouseco_view[0];
const int mx_loc = int(mouseco_view[0]);
dist_first = BLI_rcti_length_x(&bounds_first, mx_loc);
dist_last = BLI_rcti_length_x(&bounds_last, mx_loc);
}
@ -1433,7 +1433,7 @@ int file_highlight_set(SpaceFile *sfile, ARegion *region, int mx, int my)
UI_view2d_region_to_view(v2d, mx, my, &fx, &fy);
highlight_file = ED_fileselect_layout_offset(
sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy));
sfile->layout, int(v2d->tot.xmin + fx), int(v2d->tot.ymax - fy));
if ((highlight_file >= 0) && (highlight_file < numfiles)) {
params->highlight_file = highlight_file;
@ -2414,7 +2414,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator * /*op*/, const wmEv
const int numfiles_layout = ED_fileselect_layout_numfiles(sfile->layout, region);
const int first_visible_item = ED_fileselect_layout_offset(
sfile->layout, (int)region->v2d.cur.xmin, (int)-region->v2d.cur.ymax);
sfile->layout, int(region->v2d.cur.xmin), int(-region->v2d.cur.ymax));
const int last_visible_item = first_visible_item + numfiles_layout + 1;
/* NOTE: the special case for vertical layout is because filename is at the bottom of items then,

View File

@ -26,7 +26,7 @@ void file_tile_boundbox(const ARegion *region, FileLayout *layout, const int fil
int xmin, ymax;
ED_fileselect_layout_tilepos(layout, file, &xmin, &ymax);
ymax = (int)region->v2d.tot.ymax - ymax; /* real, view space ymax */
ymax = int(region->v2d.tot.ymax) - ymax; /* real, view space ymax */
BLI_rcti_init(r_bounds,
xmin,
xmin + layout->tile_w + layout->tile_border_x,

View File

@ -868,7 +868,7 @@ static int calculate_bezt_draw_resolution(BezTriple *bezt,
return max_bez_resolution;
}
const int resolution = (int)(5.0f * len_v2v2(bezt->vec[1], prevbezt->vec[1]));
const int resolution = int(5.0f * len_v2v2(bezt->vec[1], prevbezt->vec[1]));
/* NOTE: higher values will crash */
/* TODO: view scale should factor into this someday too... */

View File

@ -164,10 +164,10 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
x = sipo->cursorTime;
}
else if (adt) {
x = BKE_nla_tweakedit_remap(adt, (float)scene->r.cfra, NLATIME_CONVERT_UNMAP);
x = BKE_nla_tweakedit_remap(adt, float(scene->r.cfra), NLATIME_CONVERT_UNMAP);
}
else {
x = (float)scene->r.cfra;
x = float(scene->r.cfra);
}
/* Normalize units of cursor's value. */
@ -187,7 +187,7 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
}
else {
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
ac->depsgraph, (float)scene->r.cfra);
ac->depsgraph, float(scene->r.cfra));
for (ale = static_cast<bAnimListElem *>(anim_data.first); ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->key_data;
@ -220,12 +220,12 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* Adjust current frame for NLA-mapping. */
float cfra = (float)scene->r.cfra;
float cfra = float(scene->r.cfra);
if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) {
cfra = sipo->cursorTime;
}
else if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)scene->r.cfra, NLATIME_CONVERT_UNMAP);
cfra = BKE_nla_tweakedit_remap(adt, float(scene->r.cfra), NLATIME_CONVERT_UNMAP);
}
const float curval = evaluate_fcurve_only_curve(fcu, cfra);
@ -2726,7 +2726,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
/* Store marker's time (if available). */
if (marker) {
ked.f1 = (float)marker->frame;
ked.f1 = float(marker->frame);
}
else {
return;

View File

@ -1250,7 +1250,7 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode)
ce = static_cast<CfraElem *>(MEM_callocN(sizeof(CfraElem), "cfraElem"));
BLI_addtail(&ked.list, ce);
ce->cfra = (float)scene->r.cfra;
ce->cfra = float(scene->r.cfra);
break;
case GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */
@ -1567,10 +1567,10 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short
if (leftright == GRAPHKEYS_LRSEL_LEFT) {
ked.f1 = MINAFRAMEF;
ked.f2 = (float)(scene->r.cfra + 0.1f);
ked.f2 = float(scene->r.cfra + 0.1f);
}
else {
ked.f1 = (float)(scene->r.cfra - 0.1f);
ked.f1 = float(scene->r.cfra - 0.1f);
ked.f2 = MAXFRAMEF;
}

View File

@ -1035,7 +1035,7 @@ static void gaussian_smooth_allocate_operator_data(tGraphSliderOp *gso,
segment_link->segment = segment;
BezTriple left_bezt = fcu->bezt[segment->start_index];
BezTriple right_bezt = fcu->bezt[segment->start_index + segment->length - 1];
const int sample_count = (int)(right_bezt.vec[1][0] - left_bezt.vec[1][0]) +
const int sample_count = int(right_bezt.vec[1][0] - left_bezt.vec[1][0]) +
(filter_width * 2 + 1);
float *samples = static_cast<float *>(
MEM_callocN(sizeof(float) * sample_count, "Smooth FCurve Op Samples"));
@ -1137,7 +1137,7 @@ static void gaussian_smooth_graph_keys(bAnimContext *ac,
LISTBASE_FOREACH (FCurveSegment *, segment, &segments) {
BezTriple left_bezt = fcu->bezt[segment->start_index];
BezTriple right_bezt = fcu->bezt[segment->start_index + segment->length - 1];
const int sample_count = (int)(right_bezt.vec[1][0] - left_bezt.vec[1][0]) +
const int sample_count = int(right_bezt.vec[1][0] - left_bezt.vec[1][0]) +
(filter_width * 2 + 1);
float *samples = static_cast<float *>(
MEM_callocN(sizeof(float) * sample_count, "Smooth FCurve Op Samples"));
@ -1243,7 +1243,7 @@ static int btw_calculate_sample_count(BezTriple *right_bezt,
{
/* Adding a constant 60 frames to combat the issue that the phase delay is shifting data out of
* the sample count range. This becomes an issue when running the filter backwards. */
const int sample_count = ((int)(right_bezt->vec[1][0] - left_bezt->vec[1][0]) + 1 +
const int sample_count = (int(right_bezt->vec[1][0] - left_bezt->vec[1][0]) + 1 +
(filter_order * 2)) *
samples_per_frame +
60;
@ -1320,7 +1320,7 @@ static void btw_smooth_modal_update(bContext *C, wmOperator *op)
tBtwOperatorData *operator_data = (tBtwOperatorData *)gso->operator_data;
const float frame_rate = (float)(ac.scene->r.frs_sec) / ac.scene->r.frs_sec_base;
const float frame_rate = float(ac.scene->r.frs_sec) / ac.scene->r.frs_sec_base;
const int samples_per_frame = RNA_int_get(op->ptr, "samples_per_frame");
const float sampling_frequency = frame_rate * samples_per_frame;
@ -1367,7 +1367,7 @@ static int btw_smooth_invoke(bContext *C, wmOperator *op, const wmEvent *event)
btw_smooth_allocate_operator_data(gso, filter_order, samples_per_frame);
gso->free_operator_data = btw_smooth_free_operator_data;
const float frame_rate = (float)(gso->scene->r.frs_sec) / gso->scene->r.frs_sec_base;
const float frame_rate = float(gso->scene->r.frs_sec) / gso->scene->r.frs_sec_base;
const float sampling_frequency = frame_rate * samples_per_frame;
ED_slider_factor_bounds_set(gso->slider, 0, sampling_frequency / 2);
ED_slider_factor_set(gso->slider, RNA_float_get(op->ptr, "cutoff_frequency"));
@ -1392,7 +1392,7 @@ static void btw_smooth_graph_keys(bAnimContext *ac,
ButterworthCoefficients *bw_coeff = ED_anim_allocate_butterworth_coefficients(filter_order);
const float frame_rate = (float)(ac->scene->r.frs_sec) / ac->scene->r.frs_sec_base;
const float frame_rate = float(ac->scene->r.frs_sec) / ac->scene->r.frs_sec_base;
const float sampling_frequency = frame_rate * samples_per_frame;
/* Clamp cutoff frequency to Nyquist Frequency. */
cutoff_frequency = min_ff(cutoff_frequency, sampling_frequency / 2);

View File

@ -139,10 +139,10 @@ void get_graph_keyframe_extents(bAnimContext *ac,
}
else {
if (xmin) {
*xmin = (float)PSFRA;
*xmin = float(PSFRA);
}
if (xmax) {
*xmax = (float)PEFRA;
*xmax = float(PEFRA);
}
if (ymin) {
*ymin = -5;
@ -159,10 +159,10 @@ void get_graph_keyframe_extents(bAnimContext *ac,
/* Set default range. */
if (ac->scene) {
if (xmin) {
*xmin = (float)PSFRA;
*xmin = float(PSFRA);
}
if (xmax) {
*xmax = (float)PEFRA;
*xmax = float(PEFRA);
}
}
else {
@ -470,8 +470,8 @@ static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator * /*op*/)
/* Ghost curves are snapshots of the visible portions of the curves,
* so set range to be the visible range. */
v2d = &ac.region->v2d;
start = (int)v2d->cur.xmin;
end = (int)v2d->cur.xmax;
start = int(v2d->cur.xmin);
end = int(v2d->cur.xmax);
/* Bake selected curves into a ghost curve. */
create_ghost_curves(&ac, start, end);

View File

@ -101,8 +101,8 @@ static SpaceLink *graph_create(const ScrArea * /*area*/, const Scene *scene)
region->regiontype = RGN_TYPE_WINDOW;
region->v2d.tot.xmin = 0.0f;
region->v2d.tot.ymin = (float)scene->r.sfra - 10.0f;
region->v2d.tot.xmax = (float)scene->r.efra;
region->v2d.tot.ymin = float(scene->r.sfra) - 10.0f;
region->v2d.tot.xmax = float(scene->r.efra);
region->v2d.tot.ymax = 10.0f;
region->v2d.cur = region->v2d.tot;

View File

@ -765,7 +765,7 @@ void uiTemplateImage(uiLayout *layout,
ImageUser *iuser = static_cast<ImageUser *>(userptr->data);
Scene *scene = CTX_data_scene(C);
BKE_image_user_frame_calc(ima, iuser, (int)scene->r.cfra);
BKE_image_user_frame_calc(ima, iuser, int(scene->r.cfra));
uiLayoutSetContextPointer(layout, "edit_image", &imaptr);
uiLayoutSetContextPointer(layout, "edit_image_user", userptr);

View File

@ -280,7 +280,7 @@ void ED_image_draw_info(Scene *scene,
col[0] = col[1] = col[2] = fp[0];
}
else if (cp) {
col[0] = col[1] = col[2] = (float)cp[0] / 255.0f;
col[0] = col[1] = col[2] = float(cp[0]) / 255.0f;
}
else {
col[0] = col[1] = col[2] = 0.0f;
@ -382,10 +382,10 @@ void ED_image_draw_info(Scene *scene,
}
else if (cp) {
rgb_to_hsv(
(float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &hue, &sat, &val);
rgb_to_yuv((float)cp[0] / 255.0f,
(float)cp[0] / 255.0f,
(float)cp[0] / 255.0f,
float(cp[0]) / 255.0f, float(cp[0]) / 255.0f, float(cp[0]) / 255.0f, &hue, &sat, &val);
rgb_to_yuv(float(cp[0]) / 255.0f,
float(cp[0]) / 255.0f,
float(cp[0]) / 255.0f,
&lum,
&u,
&v,
@ -560,8 +560,8 @@ void draw_image_cache(const bContext *C, ARegion *region)
float ED_space_image_zoom_level(const View2D *v2d, const int grid_dimension)
{
/* UV-space length per pixel */
float xzoom = (v2d->cur.xmax - v2d->cur.xmin) / (float)(v2d->mask.xmax - v2d->mask.xmin);
float yzoom = (v2d->cur.ymax - v2d->cur.ymin) / (float)(v2d->mask.ymax - v2d->mask.ymin);
float xzoom = (v2d->cur.xmax - v2d->cur.xmin) / float(v2d->mask.xmax - v2d->mask.xmin);
float yzoom = (v2d->cur.ymax - v2d->cur.ymin) / float(v2d->mask.ymax - v2d->mask.ymin);
/* Zoom_factor for UV/Image editor is calculated based on:
* - Default grid size on startup, which is 256x256 pixels

View File

@ -280,10 +280,10 @@ void ED_space_image_get_zoom(SpaceImage *sima,
ED_space_image_get_size(sima, &width, &height);
*r_zoomx = (float)(BLI_rcti_size_x(&region->winrct) + 1) /
(float)(BLI_rctf_size_x(&region->v2d.cur) * width);
*r_zoomy = (float)(BLI_rcti_size_y(&region->winrct) + 1) /
(float)(BLI_rctf_size_y(&region->v2d.cur) * height);
*r_zoomx = float(BLI_rcti_size_x(&region->winrct) + 1) /
float(BLI_rctf_size_x(&region->v2d.cur) * width);
*r_zoomy = float(BLI_rcti_size_y(&region->winrct) + 1) /
float(BLI_rctf_size_y(&region->v2d.cur) * height);
}
void ED_space_image_get_uv_aspect(SpaceImage *sima, float *r_aspx, float *r_aspy)

Some files were not shown because too many files have changed in this diff Show More