Fix wrong conversion from power to radiance of area lights #109153
|
@ -570,10 +570,7 @@ ccl_device void svm_eval_nodes(KernelGlobals kg,
|
|||
#endif
|
||||
|
||||
SVM_CASE(NODE_TEX_VOXEL)
|
||||
IF_KERNEL_NODES_FEATURE(VOLUME)
|
||||
{
|
||||
offset = svm_node_tex_voxel(kg, sd, stack, node, offset);
|
||||
}
|
||||
offset = svm_node_tex_voxel<node_feature_mask>(kg, sd, stack, node, offset);
|
||||
break;
|
||||
SVM_CASE(NODE_AOV_START)
|
||||
if (!svm_node_aov_check(path_flag, render_buffer)) {
|
||||
|
|
|
@ -9,30 +9,41 @@ CCL_NAMESPACE_BEGIN
|
|||
/* TODO(sergey): Think of making it more generic volume-type attribute
|
||||
* sampler.
|
||||
*/
|
||||
template<uint node_feature_mask>
|
||||
ccl_device_noinline int svm_node_tex_voxel(
|
||||
KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint4 node, int offset)
|
||||
{
|
||||
uint co_offset, density_out_offset, color_out_offset, space;
|
||||
svm_unpack_node_uchar4(node.z, &co_offset, &density_out_offset, &color_out_offset, &space);
|
||||
#ifdef __VOLUME__
|
||||
int id = node.y;
|
||||
float3 co = stack_load_float3(stack, co_offset);
|
||||
if (space == NODE_TEX_VOXEL_SPACE_OBJECT) {
|
||||
co = volume_normalized_position(kg, sd, co);
|
||||
}
|
||||
else {
|
||||
kernel_assert(space == NODE_TEX_VOXEL_SPACE_WORLD);
|
||||
Transform tfm;
|
||||
tfm.x = read_node_float(kg, &offset);
|
||||
tfm.y = read_node_float(kg, &offset);
|
||||
tfm.z = read_node_float(kg, &offset);
|
||||
co = transform_point(&tfm, co);
|
||||
}
|
||||
|
||||
float4 r = kernel_tex_image_interp_3d(kg, id, co, INTERPOLATION_NONE);
|
||||
#else
|
||||
float4 r = zero_float4();
|
||||
|
||||
#ifdef __VOLUME__
|
||||
IF_KERNEL_NODES_FEATURE(VOLUME)
|
||||
{
|
||||
int id = node.y;
|
||||
float3 co = stack_load_float3(stack, co_offset);
|
||||
if (space == NODE_TEX_VOXEL_SPACE_OBJECT) {
|
||||
co = volume_normalized_position(kg, sd, co);
|
||||
}
|
||||
else {
|
||||
kernel_assert(space == NODE_TEX_VOXEL_SPACE_WORLD);
|
||||
Transform tfm;
|
||||
tfm.x = read_node_float(kg, &offset);
|
||||
tfm.y = read_node_float(kg, &offset);
|
||||
tfm.z = read_node_float(kg, &offset);
|
||||
co = transform_point(&tfm, co);
|
||||
}
|
||||
|
||||
r = kernel_tex_image_interp_3d(kg, id, co, INTERPOLATION_NONE);
|
||||
}
|
||||
else if (space != NODE_TEX_VOXEL_SPACE_OBJECT) {
|
||||
read_node_float(kg, &offset);
|
||||
read_node_float(kg, &offset);
|
||||
read_node_float(kg, &offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (stack_valid(density_out_offset))
|
||||
stack_store_float(stack, density_out_offset, r.w);
|
||||
if (stack_valid(color_out_offset))
|
||||
|
|
|
@ -1735,9 +1735,9 @@ enum KernelFeatureFlag : uint32_t {
|
|||
#define KERNEL_FEATURE_NODE_MASK_SURFACE_BACKGROUND \
|
||||
(KERNEL_FEATURE_NODE_MASK_SURFACE_LIGHT | KERNEL_FEATURE_NODE_AOV)
|
||||
#define KERNEL_FEATURE_NODE_MASK_SURFACE_SHADOW \
|
||||
(KERNEL_FEATURE_NODE_BSDF | KERNEL_FEATURE_NODE_EMISSION | KERNEL_FEATURE_NODE_VOLUME | \
|
||||
KERNEL_FEATURE_NODE_BUMP | KERNEL_FEATURE_NODE_BUMP_STATE | \
|
||||
KERNEL_FEATURE_NODE_VORONOI_EXTRA | KERNEL_FEATURE_NODE_LIGHT_PATH)
|
||||
(KERNEL_FEATURE_NODE_BSDF | KERNEL_FEATURE_NODE_EMISSION | KERNEL_FEATURE_NODE_BUMP | \
|
||||
KERNEL_FEATURE_NODE_BUMP_STATE | KERNEL_FEATURE_NODE_VORONOI_EXTRA | \
|
||||
KERNEL_FEATURE_NODE_LIGHT_PATH)
|
||||
#define KERNEL_FEATURE_NODE_MASK_SURFACE \
|
||||
(KERNEL_FEATURE_NODE_MASK_SURFACE_SHADOW | KERNEL_FEATURE_NODE_RAYTRACE | \
|
||||
KERNEL_FEATURE_NODE_AOV | KERNEL_FEATURE_NODE_LIGHT_PATH)
|
||||
|
|
|
@ -267,28 +267,6 @@ class DATA_PT_spot(DataButtonsPanel, Panel):
|
|||
col.prop(light, "show_cone")
|
||||
|
||||
|
||||
class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
|
||||
bl_label = "Falloff Curve"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
light = context.light
|
||||
engine = context.engine
|
||||
|
||||
return (
|
||||
(light and light.type in {'POINT', 'SPOT'} and light.falloff_type == 'CUSTOM_CURVE') and
|
||||
(engine in cls.COMPAT_ENGINES)
|
||||
)
|
||||
|
||||
def draw(self, context):
|
||||
light = context.light
|
||||
|
||||
self.layout.template_curve_mapping(
|
||||
light, "falloff_curve", use_negative_slope=True)
|
||||
|
||||
|
||||
class DATA_PT_custom_props_light(DataButtonsPanel, PropertyPanel, Panel):
|
||||
COMPAT_ENGINES = {
|
||||
'BLENDER_RENDER',
|
||||
|
@ -310,7 +288,6 @@ classes = (
|
|||
DATA_PT_EEVEE_shadow_cascaded_shadow_map,
|
||||
DATA_PT_EEVEE_shadow_contact,
|
||||
DATA_PT_spot,
|
||||
DATA_PT_falloff_curve,
|
||||
DATA_PT_custom_props_light,
|
||||
)
|
||||
|
||||
|
|
|
@ -388,10 +388,7 @@ struct GeometrySet {
|
|||
|
||||
/**
|
||||
* A geometry component that can store a mesh, using the #Mesh data-block.
|
||||
*
|
||||
* Attributes are stored, on any of the four attribute domains. Generic attributes are stored in
|
||||
* contiguous arrays, but often built-in attributes are stored in an array of structs fashion for
|
||||
* historical reasons, requiring more complex attribute access.
|
||||
* Attributes are stored on any of the four attribute domains.
|
||||
*/
|
||||
class MeshComponent : public GeometryComponent {
|
||||
private:
|
||||
|
|
|
@ -161,7 +161,8 @@ typedef struct RegionPollParams {
|
|||
const struct ScrArea *area;
|
||||
const struct ARegion *region;
|
||||
|
||||
/* For now only WM context members here, could add the scene or even #bContext if needed. */
|
||||
/** Full context, if WM context above is not enough. */
|
||||
const struct bContext *context;
|
||||
} RegionPollParams;
|
||||
|
||||
typedef struct ARegionType {
|
||||
|
|
|
@ -260,11 +260,15 @@ Drawing::Drawing()
|
|||
this->runtime = MEM_new<bke::greasepencil::DrawingRuntime>(__func__);
|
||||
}
|
||||
|
||||
Drawing::Drawing(const Drawing &other) : Drawing()
|
||||
Drawing::Drawing(const Drawing &other)
|
||||
{
|
||||
this->base.type = GP_DRAWING;
|
||||
this->base.flag = other.base.flag;
|
||||
|
||||
new (&this->geometry) bke::CurvesGeometry(other.geometry.wrap());
|
||||
/* Initialize runtime data. */
|
||||
this->runtime = MEM_new<bke::greasepencil::DrawingRuntime>(__func__);
|
||||
|
||||
this->runtime->triangles_cache = other.runtime->triangles_cache;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,6 @@ static void light_init_data(ID *id)
|
|||
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(la, id));
|
||||
|
||||
MEMCPY_STRUCT_AFTER(la, DNA_struct_default_get(Light), id);
|
||||
|
||||
la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
BKE_curvemapping_init(la->curfalloff);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,8 +68,6 @@ static void light_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
|
|||
/* We always need allocation of our private ID data. */
|
||||
const int flag_private_id_data = flag & ~LIB_ID_CREATE_NO_ALLOCATE;
|
||||
|
||||
la_dst->curfalloff = BKE_curvemapping_copy(la_src->curfalloff);
|
||||
|
||||
if (la_src->nodetree) {
|
||||
if (is_localized) {
|
||||
la_dst->nodetree = ntreeLocalize(la_src->nodetree);
|
||||
|
@ -96,8 +91,6 @@ static void light_free_data(ID *id)
|
|||
{
|
||||
Light *la = (Light *)id;
|
||||
|
||||
BKE_curvemapping_free(la->curfalloff);
|
||||
|
||||
/* is no lib link block, but light extension */
|
||||
if (la->nodetree) {
|
||||
ntreeFreeEmbeddedTree(la->nodetree);
|
||||
|
@ -138,10 +131,6 @@ static void light_blend_write(BlendWriter *writer, ID *id, const void *id_addres
|
|||
BKE_animdata_blend_write(writer, la->adt);
|
||||
}
|
||||
|
||||
if (la->curfalloff) {
|
||||
BKE_curvemapping_blend_write(writer, la->curfalloff);
|
||||
}
|
||||
|
||||
/* Node-tree is integral part of lights, no libdata. */
|
||||
if (la->nodetree) {
|
||||
BLO_Write_IDBuffer *temp_embedded_id_buffer = BLO_write_allocate_id_buffer();
|
||||
|
@ -162,11 +151,6 @@ static void light_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
BLO_read_data_address(reader, &la->adt);
|
||||
BKE_animdata_blend_read_data(reader, la->adt);
|
||||
|
||||
BLO_read_data_address(reader, &la->curfalloff);
|
||||
if (la->curfalloff) {
|
||||
BKE_curvemapping_blend_read(reader, la->curfalloff);
|
||||
}
|
||||
|
||||
BLO_read_data_address(reader, &la->preview);
|
||||
BKE_previewimg_blend_read(reader, la->preview);
|
||||
}
|
||||
|
|
|
@ -2958,7 +2958,6 @@ void BKE_object_obdata_size_init(Object *ob, const float size)
|
|||
}
|
||||
case OB_LAMP: {
|
||||
Light *lamp = (Light *)ob->data;
|
||||
lamp->dist *= size;
|
||||
lamp->radius *= size;
|
||||
lamp->area_size *= size;
|
||||
lamp->area_sizey *= size;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BLI_array_utils.hh"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
#include "atomic_ops.h"
|
||||
|
||||
|
@ -49,8 +50,17 @@ void gather(const GSpan src, const IndexMask &indices, GMutableSpan dst, const i
|
|||
|
||||
void count_indices(const Span<int> indices, MutableSpan<int> counts)
|
||||
{
|
||||
for (const int i : indices) {
|
||||
counts[i]++;
|
||||
if (indices.size() < 8192 || BLI_system_thread_count() < 4) {
|
||||
for (const int i : indices) {
|
||||
counts[i]++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
threading::parallel_for(indices.index_range(), 4096, [&](const IndexRange range) {
|
||||
for (const int i : indices.slice(range)) {
|
||||
atomic_add_and_fetch_int32(&counts[i], 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -990,12 +990,6 @@ static void do_version_curvemapping_walker(Main *bmain, void (*callback)(CurveMa
|
|||
}
|
||||
FOREACH_NODETREE_END;
|
||||
|
||||
LISTBASE_FOREACH (Light *, light, &bmain->lights) {
|
||||
if (light->curfalloff) {
|
||||
callback(light->curfalloff);
|
||||
}
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
|
||||
if (brush->curve) {
|
||||
callback(brush->curve);
|
||||
|
|
|
@ -1545,7 +1545,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
|
|||
if (bmain->versionfile <= 241) {
|
||||
Object *ob;
|
||||
Scene *sce;
|
||||
Light *la;
|
||||
bArmature *arm;
|
||||
bNodeTree *ntree;
|
||||
|
||||
|
@ -1590,12 +1589,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
|
|||
ntree_version_241(ntree);
|
||||
}
|
||||
|
||||
for (la = bmain->lights.first; la; la = la->id.next) {
|
||||
if (la->buffers == 0) {
|
||||
la->buffers = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* for empty drawsize and drawtype */
|
||||
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
|
||||
if (ob->empty_drawsize == 0.0f) {
|
||||
|
@ -1921,7 +1914,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
|
|||
Scene *sce;
|
||||
Object *ob;
|
||||
Image *ima;
|
||||
Light *la;
|
||||
Material *ma;
|
||||
ParticleSettings *part;
|
||||
bNodeTree *ntree;
|
||||
|
@ -2038,17 +2030,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
if (bmain->versionfile != 245 || bmain->subversionfile < 1) {
|
||||
for (la = bmain->lights.first; la; la = la->id.next) {
|
||||
la->falloff_type = LA_FALLOFF_INVLINEAR;
|
||||
|
||||
if (la->curfalloff == NULL) {
|
||||
la->curfalloff = BKE_curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
|
||||
BKE_curvemapping_init(la->curfalloff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ma = bmain->materials.first; ma; ma = ma->id.next) {
|
||||
if (ma->gloss_mir == 0.0f) {
|
||||
ma->gloss_mir = 1.0f;
|
||||
|
|
|
@ -1151,7 +1151,7 @@ static void bm_face_loop_table_build(BMesh &bm,
|
|||
bool &need_hide_poly,
|
||||
bool &need_sharp_face,
|
||||
bool &need_material_index,
|
||||
Vector<int> &ldata_layers_marked_nocopy)
|
||||
Vector<int> &loop_layers_not_to_copy)
|
||||
{
|
||||
const CustomData &ldata = bm.ldata;
|
||||
Vector<int> vert_sel_layers;
|
||||
|
@ -1226,20 +1226,17 @@ static void bm_face_loop_table_build(BMesh &bm,
|
|||
|
||||
for (const int i : vert_sel_layers.index_range()) {
|
||||
if (!need_vert_sel[i]) {
|
||||
ldata.layers[vert_sel_layers[i]].flag |= CD_FLAG_NOCOPY;
|
||||
ldata_layers_marked_nocopy.append(vert_sel_layers[i]);
|
||||
loop_layers_not_to_copy.append(vert_sel_layers[i]);
|
||||
}
|
||||
}
|
||||
for (const int i : edge_sel_layers.index_range()) {
|
||||
if (!need_edge_sel[i]) {
|
||||
ldata.layers[edge_sel_layers[i]].flag |= CD_FLAG_NOCOPY;
|
||||
ldata_layers_marked_nocopy.append(edge_sel_layers[i]);
|
||||
loop_layers_not_to_copy.append(edge_sel_layers[i]);
|
||||
}
|
||||
}
|
||||
for (const int i : pin_layers.index_range()) {
|
||||
if (!need_pin[i]) {
|
||||
ldata.layers[pin_layers[i]].flag |= CD_FLAG_NOCOPY;
|
||||
ldata_layers_marked_nocopy.append(pin_layers[i]);
|
||||
loop_layers_not_to_copy.append(pin_layers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1419,15 +1416,6 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const BMeshToMeshParams
|
|||
me->totpoly = bm->totface;
|
||||
me->act_face = -1;
|
||||
|
||||
{
|
||||
CustomData_MeshMasks mask = CD_MASK_MESH;
|
||||
CustomData_MeshMasks_update(&mask, ¶ms->cd_mask_extra);
|
||||
CustomData_copy_layout(&bm->vdata, &me->vdata, mask.vmask, CD_SET_DEFAULT, me->totvert);
|
||||
CustomData_copy_layout(&bm->edata, &me->edata, mask.emask, CD_SET_DEFAULT, me->totedge);
|
||||
CustomData_copy_layout(&bm->ldata, &me->ldata, mask.lmask, CD_SET_DEFAULT, me->totloop);
|
||||
CustomData_copy_layout(&bm->pdata, &me->pdata, mask.pmask, CD_SET_DEFAULT, me->totpoly);
|
||||
}
|
||||
|
||||
bool need_select_vert = false;
|
||||
bool need_select_edge = false;
|
||||
bool need_select_poly = false;
|
||||
|
@ -1442,7 +1430,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const BMeshToMeshParams
|
|||
Array<const BMEdge *> edge_table;
|
||||
Array<const BMFace *> face_table;
|
||||
Array<const BMLoop *> loop_table;
|
||||
Vector<int> ldata_layers_marked_nocopy;
|
||||
Vector<int> loop_layers_not_to_copy;
|
||||
threading::parallel_invoke(
|
||||
me->totface > 1024,
|
||||
[&]() {
|
||||
|
@ -1464,10 +1452,22 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const BMeshToMeshParams
|
|||
need_hide_poly,
|
||||
need_sharp_face,
|
||||
need_material_index,
|
||||
ldata_layers_marked_nocopy);
|
||||
loop_layers_not_to_copy);
|
||||
for (const int i : loop_layers_not_to_copy) {
|
||||
bm->ldata.layers[i].flag |= CD_FLAG_NOCOPY;
|
||||
}
|
||||
});
|
||||
bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE | BM_LOOP);
|
||||
|
||||
{
|
||||
CustomData_MeshMasks mask = CD_MASK_MESH;
|
||||
CustomData_MeshMasks_update(&mask, ¶ms->cd_mask_extra);
|
||||
CustomData_copy_layout(&bm->vdata, &me->vdata, mask.vmask, CD_CONSTRUCT, me->totvert);
|
||||
CustomData_copy_layout(&bm->edata, &me->edata, mask.emask, CD_CONSTRUCT, me->totedge);
|
||||
CustomData_copy_layout(&bm->ldata, &me->ldata, mask.lmask, CD_CONSTRUCT, me->totloop);
|
||||
CustomData_copy_layout(&bm->pdata, &me->pdata, mask.pmask, CD_CONSTRUCT, me->totpoly);
|
||||
}
|
||||
|
||||
/* Add optional mesh attributes before parallel iteration. */
|
||||
assert_bmesh_has_no_mesh_only_attributes(*bm);
|
||||
bke::MutableAttributeAccessor attrs = me->attributes_for_write();
|
||||
|
@ -1548,7 +1548,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const BMeshToMeshParams
|
|||
bm_to_mesh_loops(*bm, loop_table, *me);
|
||||
/* Topology could be changed, ensure #CD_MDISPS are ok. */
|
||||
multires_topology_changed(me);
|
||||
for (const int i : ldata_layers_marked_nocopy) {
|
||||
for (const int i : loop_layers_not_to_copy) {
|
||||
bm->ldata.layers[i].flag &= ~CD_FLAG_NOCOPY;
|
||||
}
|
||||
},
|
||||
|
@ -1630,18 +1630,6 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
|
|||
me->totloop = bm->totloop;
|
||||
me->totpoly = bm->totface;
|
||||
|
||||
/* Don't process shape-keys. We only feed them through the modifier stack as needed,
|
||||
* e.g. for applying modifiers or the like. */
|
||||
CustomData_MeshMasks mask = CD_MASK_DERIVEDMESH;
|
||||
if (cd_mask_extra != nullptr) {
|
||||
CustomData_MeshMasks_update(&mask, cd_mask_extra);
|
||||
}
|
||||
mask.vmask &= ~CD_MASK_SHAPEKEY;
|
||||
CustomData_merge_layout(&bm->vdata, &me->vdata, mask.vmask, CD_CONSTRUCT, me->totvert);
|
||||
CustomData_merge_layout(&bm->edata, &me->edata, mask.emask, CD_CONSTRUCT, me->totedge);
|
||||
CustomData_merge_layout(&bm->ldata, &me->ldata, mask.lmask, CD_CONSTRUCT, me->totloop);
|
||||
CustomData_merge_layout(&bm->pdata, &me->pdata, mask.pmask, CD_CONSTRUCT, me->totpoly);
|
||||
|
||||
me->runtime->deformed_only = true;
|
||||
|
||||
/* In a first pass, update indices of BMesh elements and build tables for easy iteration later.
|
||||
|
@ -1661,7 +1649,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
|
|||
Array<const BMEdge *> edge_table;
|
||||
Array<const BMFace *> face_table;
|
||||
Array<const BMLoop *> loop_table;
|
||||
Vector<int> ldata_layers_marked_nocopy;
|
||||
Vector<int> loop_layers_not_to_copy;
|
||||
threading::parallel_invoke(
|
||||
me->totface > 1024,
|
||||
[&]() {
|
||||
|
@ -1683,10 +1671,25 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
|
|||
need_hide_poly,
|
||||
need_sharp_face,
|
||||
need_material_index,
|
||||
ldata_layers_marked_nocopy);
|
||||
loop_layers_not_to_copy);
|
||||
for (const int i : loop_layers_not_to_copy) {
|
||||
bm->ldata.layers[i].flag |= CD_FLAG_NOCOPY;
|
||||
}
|
||||
});
|
||||
bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE | BM_LOOP);
|
||||
|
||||
/* Don't process shape-keys. We only feed them through the modifier stack as needed,
|
||||
* e.g. for applying modifiers or the like. */
|
||||
CustomData_MeshMasks mask = CD_MASK_DERIVEDMESH;
|
||||
if (cd_mask_extra != nullptr) {
|
||||
CustomData_MeshMasks_update(&mask, cd_mask_extra);
|
||||
}
|
||||
mask.vmask &= ~CD_MASK_SHAPEKEY;
|
||||
CustomData_merge_layout(&bm->vdata, &me->vdata, mask.vmask, CD_CONSTRUCT, me->totvert);
|
||||
CustomData_merge_layout(&bm->edata, &me->edata, mask.emask, CD_CONSTRUCT, me->totedge);
|
||||
CustomData_merge_layout(&bm->ldata, &me->ldata, mask.lmask, CD_CONSTRUCT, me->totloop);
|
||||
CustomData_merge_layout(&bm->pdata, &me->pdata, mask.pmask, CD_CONSTRUCT, me->totpoly);
|
||||
|
||||
/* Add optional mesh attributes before parallel iteration. */
|
||||
assert_bmesh_has_no_mesh_only_attributes(*bm);
|
||||
bke::MutableAttributeAccessor attrs = me->attributes_for_write();
|
||||
|
@ -1756,7 +1759,7 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
|
|||
},
|
||||
[&]() {
|
||||
bm_to_mesh_loops(*bm, loop_table, *me);
|
||||
for (const int i : ldata_layers_marked_nocopy) {
|
||||
for (const int i : loop_layers_not_to_copy) {
|
||||
bm->ldata.layers[i].flag &= ~CD_FLAG_NOCOPY;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -625,9 +625,6 @@ if(WITH_COMPOSITOR_CPU)
|
|||
COMMAND "$<TARGET_FILE:smaa_areatex>" ${GENSRC}
|
||||
DEPENDS smaa_areatex
|
||||
)
|
||||
add_custom_target(smaa_areatex_header
|
||||
SOURCES ${GENSRC}
|
||||
)
|
||||
list(APPEND SRC
|
||||
${GENSRC}
|
||||
)
|
||||
|
@ -662,8 +659,6 @@ if(WITH_COMPOSITOR_CPU)
|
|||
target_compile_options(bf_compositor PRIVATE "-Wsuggest-override")
|
||||
endif()
|
||||
|
||||
add_dependencies(bf_compositor smaa_areatex_header)
|
||||
|
||||
if(WITH_GTESTS)
|
||||
set(TEST_SRC
|
||||
tests/COM_BufferArea_test.cc
|
||||
|
|
|
@ -583,6 +583,7 @@ set(GLSL_SRC
|
|||
engines/workbench/shaders/workbench_material_lib.glsl
|
||||
engines/workbench/shaders/workbench_merge_infront_frag.glsl
|
||||
engines/workbench/shaders/workbench_next_merge_depth_frag.glsl
|
||||
engines/workbench/shaders/workbench_overlay_depth_frag.glsl
|
||||
engines/workbench/shaders/workbench_prepass_frag.glsl
|
||||
engines/workbench/shaders/workbench_prepass_hair_vert.glsl
|
||||
engines/workbench/shaders/workbench_prepass_pointcloud_vert.glsl
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "gpu_shader_create_info.hh"
|
||||
|
||||
GPU_SHADER_CREATE_INFO(workbench_overlay_depth)
|
||||
.sampler(0, ImageType::DEPTH_2D, "depth_tx")
|
||||
.sampler(1, ImageType::UINT_2D, "stencil_tx")
|
||||
.fragment_source("workbench_overlay_depth_frag.glsl")
|
||||
.additional_info("draw_fullscreen")
|
||||
.depth_write(DepthWrite::ANY)
|
||||
.do_static_compilation(true);
|
|
@ -0,0 +1,15 @@
|
|||
/* Prepare the Depth Buffer for the Overlay Engine. */
|
||||
|
||||
void main()
|
||||
{
|
||||
uint stencil = texelFetch(stencil_tx, ivec2(gl_FragCoord.xy), 0).r;
|
||||
if (stencil != 0) {
|
||||
/* Set the depth to 0 for "In Front" objects,
|
||||
* so the Overlay engine doesn't draw on top of them. */
|
||||
gl_FragDepth = 0.0;
|
||||
}
|
||||
else {
|
||||
float depth = texelFetch(depth_tx, ivec2(gl_FragCoord.xy), 0).r;
|
||||
gl_FragDepth = depth;
|
||||
}
|
||||
}
|
|
@ -115,6 +115,7 @@ AntiAliasingPass::AntiAliasingPass()
|
|||
smaa_edge_detect_sh_ = GPU_shader_create_from_info_name("workbench_smaa_stage_0");
|
||||
smaa_aa_weight_sh_ = GPU_shader_create_from_info_name("workbench_smaa_stage_1");
|
||||
smaa_resolve_sh_ = GPU_shader_create_from_info_name("workbench_smaa_stage_2");
|
||||
overlay_depth_sh_ = GPU_shader_create_from_info_name("workbench_overlay_depth");
|
||||
|
||||
smaa_search_tx_.ensure_2d(
|
||||
GPU_R8, {SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT}, GPU_TEXTURE_USAGE_SHADER_READ);
|
||||
|
@ -132,6 +133,7 @@ AntiAliasingPass::~AntiAliasingPass()
|
|||
DRW_SHADER_FREE_SAFE(smaa_edge_detect_sh_);
|
||||
DRW_SHADER_FREE_SAFE(smaa_aa_weight_sh_);
|
||||
DRW_SHADER_FREE_SAFE(smaa_resolve_sh_);
|
||||
DRW_SHADER_FREE_SAFE(overlay_depth_sh_);
|
||||
}
|
||||
|
||||
void AntiAliasingPass::init(const SceneState &scene_state)
|
||||
|
@ -143,6 +145,13 @@ void AntiAliasingPass::init(const SceneState &scene_state)
|
|||
|
||||
void AntiAliasingPass::sync(SceneResources &resources, int2 resolution)
|
||||
{
|
||||
overlay_depth_ps_.init();
|
||||
overlay_depth_ps_.state_set(DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS);
|
||||
overlay_depth_ps_.shader_set(overlay_depth_sh_);
|
||||
overlay_depth_ps_.bind_texture("depth_tx", &resources.depth_tx);
|
||||
overlay_depth_ps_.bind_texture("stencil_tx", &stencil_tx_);
|
||||
overlay_depth_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3);
|
||||
|
||||
if (!enabled_) {
|
||||
taa_accumulation_tx_.free();
|
||||
sample0_depth_tx_.free();
|
||||
|
@ -244,12 +253,16 @@ void AntiAliasingPass::draw(Manager &manager,
|
|||
GPUTexture *depth_tx,
|
||||
GPUTexture *color_tx)
|
||||
{
|
||||
auto draw_overlay_depth = [&](GPUTexture *target) {
|
||||
stencil_tx_ = resources.depth_tx.stencil_view();
|
||||
overlay_depth_fb_.ensure(GPU_ATTACHMENT_TEXTURE(target));
|
||||
overlay_depth_fb_.bind();
|
||||
manager.submit(overlay_depth_ps_);
|
||||
};
|
||||
|
||||
if (!enabled_) {
|
||||
/* TODO(@pragma37): Should render to the input color_tx and depth_tx in the first place.
|
||||
* This requires the use of TextureRefs with stencil_view() support,
|
||||
* but whether TextureRef will stay is still TBD. */
|
||||
GPU_texture_copy(color_tx, resources.color_tx);
|
||||
GPU_texture_copy(depth_tx, resources.depth_tx);
|
||||
draw_overlay_depth(depth_tx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -273,20 +286,10 @@ void AntiAliasingPass::draw(Manager &manager,
|
|||
}
|
||||
|
||||
if (sample_ == 0) {
|
||||
if (sample0_depth_tx_.is_valid()) {
|
||||
GPU_texture_copy(sample0_depth_tx_, resources.depth_tx);
|
||||
}
|
||||
/* TODO(@pragma37): Should render to the input depth_tx in the first place
|
||||
* This requires the use of TextureRef with stencil_view() support,
|
||||
* but whether TextureRef will stay is still TBD. */
|
||||
|
||||
/* Copy back the saved depth buffer for correct overlays. */
|
||||
GPU_texture_copy(depth_tx, resources.depth_tx);
|
||||
}
|
||||
else {
|
||||
/* Copy back the saved depth buffer for correct overlays. */
|
||||
GPU_texture_copy(depth_tx, sample0_depth_tx_);
|
||||
draw_overlay_depth(sample0_depth_tx_);
|
||||
}
|
||||
/* Copy back the saved depth buffer for correct overlays. */
|
||||
GPU_texture_copy(depth_tx, sample0_depth_tx_);
|
||||
|
||||
if (!DRW_state_is_image_render() || last_sample) {
|
||||
smaa_weight_tx_.acquire(
|
||||
|
|
|
@ -204,30 +204,27 @@ class Instance {
|
|||
}
|
||||
}
|
||||
|
||||
MeshPass &get_mesh_pass(ObjectRef &ob_ref, bool is_transparent)
|
||||
template<typename F>
|
||||
void draw_to_mesh_pass(ObjectRef &ob_ref, bool is_transparent, F draw_callback)
|
||||
{
|
||||
const bool in_front = (ob_ref.object->dtx & OB_DRAW_IN_FRONT) != 0;
|
||||
|
||||
if (scene_state.xray_mode || is_transparent) {
|
||||
if (in_front) {
|
||||
return transparent_ps.accumulation_in_front_ps_;
|
||||
if (scene_state.draw_transparent_depth) {
|
||||
return transparent_depth_ps.in_front_ps_;
|
||||
}
|
||||
draw_callback(transparent_ps.accumulation_in_front_ps_);
|
||||
draw_callback(transparent_depth_ps.in_front_ps_);
|
||||
}
|
||||
else {
|
||||
return transparent_ps.accumulation_ps_;
|
||||
if (scene_state.draw_transparent_depth) {
|
||||
return transparent_depth_ps.main_ps_;
|
||||
}
|
||||
draw_callback(transparent_ps.accumulation_ps_);
|
||||
draw_callback(transparent_depth_ps.main_ps_);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (in_front) {
|
||||
return opaque_ps.gbuffer_in_front_ps_;
|
||||
draw_callback(opaque_ps.gbuffer_in_front_ps_);
|
||||
}
|
||||
else {
|
||||
return opaque_ps.gbuffer_ps_;
|
||||
draw_callback(opaque_ps.gbuffer_ps_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -243,9 +240,10 @@ class Instance {
|
|||
resources.material_buf.append(material);
|
||||
int material_index = resources.material_buf.size() - 1;
|
||||
|
||||
get_mesh_pass(ob_ref, material.is_transparent())
|
||||
.get_subpass(eGeometryType::MESH, image, sampler_state, iuser)
|
||||
.draw(batch, handle, material_index);
|
||||
draw_to_mesh_pass(ob_ref, material.is_transparent(), [&](MeshPass &mesh_pass) {
|
||||
mesh_pass.get_subpass(eGeometryType::MESH, image, sampler_state, iuser)
|
||||
.draw(batch, handle, material_index);
|
||||
});
|
||||
}
|
||||
|
||||
void mesh_sync(ObjectRef &ob_ref, ResourceHandle handle, const ObjectState &object_state)
|
||||
|
@ -374,12 +372,12 @@ class Instance {
|
|||
resources.material_buf.append(mat);
|
||||
int material_index = resources.material_buf.size() - 1;
|
||||
|
||||
PassMain::Sub &pass = get_mesh_pass(ob_ref, mat.is_transparent())
|
||||
.get_subpass(eGeometryType::POINTCLOUD)
|
||||
.sub("Point Cloud SubPass");
|
||||
|
||||
GPUBatch *batch = point_cloud_sub_pass_setup(pass, ob_ref.object);
|
||||
pass.draw(batch, handle, material_index);
|
||||
draw_to_mesh_pass(ob_ref, mat.is_transparent(), [&](MeshPass &mesh_pass) {
|
||||
PassMain::Sub &pass =
|
||||
mesh_pass.get_subpass(eGeometryType::POINTCLOUD).sub("Point Cloud SubPass");
|
||||
GPUBatch *batch = point_cloud_sub_pass_setup(pass, ob_ref.object);
|
||||
pass.draw(batch, handle, material_index);
|
||||
});
|
||||
}
|
||||
|
||||
void hair_sync(Manager &manager,
|
||||
|
@ -402,13 +400,14 @@ class Instance {
|
|||
resources.material_buf.append(mat);
|
||||
int material_index = resources.material_buf.size() - 1;
|
||||
|
||||
PassMain::Sub &pass = get_mesh_pass(ob_ref, mat.is_transparent())
|
||||
.get_subpass(eGeometryType::CURVES, image, sampler_state, iuser)
|
||||
.sub("Hair SubPass");
|
||||
|
||||
pass.push_constant("emitter_object_id", int(emitter_handle.raw));
|
||||
GPUBatch *batch = hair_sub_pass_setup(pass, scene_state.scene, ob_ref.object, psys, md);
|
||||
pass.draw(batch, handle, material_index);
|
||||
draw_to_mesh_pass(ob_ref, mat.is_transparent(), [&](MeshPass &mesh_pass) {
|
||||
PassMain::Sub &pass = mesh_pass
|
||||
.get_subpass(eGeometryType::CURVES, image, sampler_state, iuser)
|
||||
.sub("Hair SubPass");
|
||||
pass.push_constant("emitter_object_id", int(emitter_handle.raw));
|
||||
GPUBatch *batch = hair_sub_pass_setup(pass, scene_state.scene, ob_ref.object, psys, md);
|
||||
pass.draw(batch, handle, material_index);
|
||||
});
|
||||
}
|
||||
|
||||
void curves_sync(Manager &manager, ObjectRef &ob_ref, const ObjectState &object_state)
|
||||
|
@ -420,12 +419,11 @@ class Instance {
|
|||
resources.material_buf.append(mat);
|
||||
int material_index = resources.material_buf.size() - 1;
|
||||
|
||||
PassMain::Sub &pass = get_mesh_pass(ob_ref, mat.is_transparent())
|
||||
.get_subpass(eGeometryType::CURVES)
|
||||
.sub("Curves SubPass");
|
||||
|
||||
GPUBatch *batch = curves_sub_pass_setup(pass, scene_state.scene, ob_ref.object);
|
||||
pass.draw(batch, handle, material_index);
|
||||
draw_to_mesh_pass(ob_ref, mat.is_transparent(), [&](MeshPass &mesh_pass) {
|
||||
PassMain::Sub &pass = mesh_pass.get_subpass(eGeometryType::CURVES).sub("Curves SubPass");
|
||||
GPUBatch *batch = curves_sub_pass_setup(pass, scene_state.scene, ob_ref.object);
|
||||
pass.draw(batch, handle, material_index);
|
||||
});
|
||||
}
|
||||
|
||||
void draw(Manager &manager, GPUTexture *depth_tx, GPUTexture *color_tx)
|
||||
|
@ -470,12 +468,8 @@ class Instance {
|
|||
}
|
||||
}
|
||||
|
||||
opaque_ps.draw(manager,
|
||||
view,
|
||||
resources,
|
||||
resolution,
|
||||
&shadow_ps,
|
||||
transparent_ps.accumulation_ps_.is_empty());
|
||||
opaque_ps.draw(
|
||||
manager, view, resources, resolution, scene_state.draw_shadows ? &shadow_ps : nullptr);
|
||||
transparent_ps.draw(manager, view, resources, resolution);
|
||||
transparent_depth_ps.draw(manager, view, resources);
|
||||
|
||||
|
|
|
@ -149,8 +149,7 @@ void OpaquePass::draw(Manager &manager,
|
|||
View &view,
|
||||
SceneResources &resources,
|
||||
int2 resolution,
|
||||
ShadowPass *shadow_pass,
|
||||
bool accumulation_ps_is_empty)
|
||||
ShadowPass *shadow_pass)
|
||||
{
|
||||
if (is_empty()) {
|
||||
return;
|
||||
|
@ -189,8 +188,7 @@ void OpaquePass::draw(Manager &manager,
|
|||
manager.submit(gbuffer_ps_, view);
|
||||
}
|
||||
|
||||
bool needs_stencil_copy = shadow_pass && !gbuffer_in_front_ps_.is_empty() &&
|
||||
!accumulation_ps_is_empty;
|
||||
bool needs_stencil_copy = shadow_pass && !gbuffer_in_front_ps_.is_empty();
|
||||
|
||||
if (needs_stencil_copy) {
|
||||
shadow_depth_stencil_tx.ensure_2d(GPU_DEPTH24_STENCIL8,
|
||||
|
@ -201,18 +199,15 @@ void OpaquePass::draw(Manager &manager,
|
|||
GPU_texture_copy(shadow_depth_stencil_tx, resources.depth_tx);
|
||||
|
||||
deferred_ps_stencil_tx = shadow_depth_stencil_tx.stencil_view();
|
||||
}
|
||||
else {
|
||||
shadow_depth_stencil_tx.free();
|
||||
|
||||
deferred_ps_stencil_tx = resources.depth_tx.stencil_view();
|
||||
}
|
||||
|
||||
if (shadow_pass && !gbuffer_in_front_ps_.is_empty()) {
|
||||
opaque_fb.ensure(GPU_ATTACHMENT_TEXTURE(deferred_ps_stencil_tx));
|
||||
opaque_fb.bind();
|
||||
GPU_framebuffer_clear_stencil(opaque_fb, 0);
|
||||
}
|
||||
else {
|
||||
shadow_depth_stencil_tx.free();
|
||||
deferred_ps_stencil_tx = resources.depth_tx.stencil_view();
|
||||
}
|
||||
|
||||
if (shadow_pass) {
|
||||
shadow_pass->draw(
|
||||
|
|
|
@ -88,7 +88,6 @@ struct SceneState {
|
|||
bool draw_aa = false;
|
||||
|
||||
bool draw_object_id = false;
|
||||
bool draw_transparent_depth = false;
|
||||
|
||||
int sample = 0;
|
||||
int samples_len = 0;
|
||||
|
@ -207,8 +206,7 @@ class OpaquePass {
|
|||
View &view,
|
||||
SceneResources &resources,
|
||||
int2 resolution,
|
||||
class ShadowPass *shadow_pass,
|
||||
bool accumulation_ps_is_empty);
|
||||
class ShadowPass *shadow_pass);
|
||||
bool is_empty() const;
|
||||
};
|
||||
|
||||
|
@ -455,6 +453,7 @@ class AntiAliasingPass {
|
|||
float weights_sum_ = 0;
|
||||
|
||||
Texture sample0_depth_tx_ = {"sample0_depth_tx"};
|
||||
GPUTexture *stencil_tx_ = nullptr;
|
||||
|
||||
Texture taa_accumulation_tx_ = {"taa_accumulation_tx"};
|
||||
Texture smaa_search_tx_ = {"smaa_search_tx"};
|
||||
|
@ -466,6 +465,7 @@ class AntiAliasingPass {
|
|||
Framebuffer smaa_edge_fb_ = {"smaa_edge_fb"};
|
||||
Framebuffer smaa_weight_fb_ = {"smaa_weight_fb"};
|
||||
Framebuffer smaa_resolve_fb_ = {"smaa_resolve_fb"};
|
||||
Framebuffer overlay_depth_fb_ = {"overlay_depth_fb"};
|
||||
|
||||
float4 smaa_viewport_metrics_ = float4(0);
|
||||
float smaa_mix_factor_ = 0;
|
||||
|
@ -474,11 +474,13 @@ class AntiAliasingPass {
|
|||
GPUShader *smaa_edge_detect_sh_ = nullptr;
|
||||
GPUShader *smaa_aa_weight_sh_ = nullptr;
|
||||
GPUShader *smaa_resolve_sh_ = nullptr;
|
||||
GPUShader *overlay_depth_sh_ = nullptr;
|
||||
|
||||
PassSimple taa_accumulation_ps_ = {"TAA.Accumulation"};
|
||||
PassSimple smaa_edge_detect_ps_ = {"SMAA.EdgeDetect"};
|
||||
PassSimple smaa_aa_weight_ps_ = {"SMAA.BlendWeights"};
|
||||
PassSimple smaa_resolve_ps_ = {"SMAA.Resolve"};
|
||||
PassSimple overlay_depth_ps_ = {"Overlay Depth"};
|
||||
|
||||
public:
|
||||
AntiAliasingPass();
|
||||
|
|
|
@ -173,7 +173,6 @@ void SceneState::init(Object *camera_ob /*= nullptr*/)
|
|||
draw_dof = camera && camera->dof.flag & CAM_DOF_ENABLED &&
|
||||
shading.flag & V3D_SHADING_DEPTH_OF_FIELD;
|
||||
|
||||
draw_transparent_depth = draw_outline || draw_dof;
|
||||
draw_object_id = draw_outline || draw_curvature;
|
||||
};
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* \ingroup edcurves
|
||||
*/
|
||||
|
||||
#include "BLI_rand.hh"
|
||||
|
||||
#include "BKE_curves.hh"
|
||||
|
||||
#include "ED_curves.h"
|
||||
|
@ -32,4 +34,23 @@ IndexMask end_points(const bke::CurvesGeometry &curves,
|
|||
return IndexMask::from_bools(end_points, memory);
|
||||
}
|
||||
|
||||
IndexMask random_mask(const bke::CurvesGeometry &curves,
|
||||
const eAttrDomain selection_domain,
|
||||
const uint32_t random_seed,
|
||||
const float probability,
|
||||
IndexMaskMemory &memory)
|
||||
{
|
||||
RandomNumberGenerator rng{random_seed};
|
||||
const auto next_bool_random_value = [&]() { return rng.get_float() <= probability; };
|
||||
|
||||
const int64_t domain_size = curves.attributes().domain_size(selection_domain);
|
||||
|
||||
Array<bool> random(domain_size);
|
||||
for (const int i : IndexRange(domain_size)) {
|
||||
random[i] = next_bool_random_value();
|
||||
}
|
||||
|
||||
return IndexMask::from_bools(random, memory);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::curves
|
||||
|
|
|
@ -890,7 +890,20 @@ static int select_random_exec(bContext *C, wmOperator *op)
|
|||
|
||||
for (Curves *curves_id : unique_curves) {
|
||||
CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||
select_random(curves, eAttrDomain(curves_id->selection_domain), uint32_t(seed), probability);
|
||||
const eAttrDomain selection_domain = eAttrDomain(curves_id->selection_domain);
|
||||
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask random_elements = random_mask(curves, selection_domain, seed, probability, memory);
|
||||
|
||||
const bool was_anything_selected = has_anything_selected(curves);
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
|
||||
curves, selection_domain, CD_PROP_BOOL);
|
||||
if (!was_anything_selected) {
|
||||
curves::fill_selection_true(selection.span);
|
||||
}
|
||||
|
||||
curves::fill_selection_false(selection.span, random_elements);
|
||||
selection.finish();
|
||||
|
||||
/* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
|
||||
* attribute for now. */
|
||||
|
|
|
@ -126,6 +126,26 @@ void fill_selection_true(GMutableSpan selection)
|
|||
}
|
||||
}
|
||||
|
||||
void fill_selection_false(GMutableSpan selection, const IndexMask &mask)
|
||||
{
|
||||
if (selection.type().is<bool>()) {
|
||||
index_mask::masked_fill(selection.typed<bool>(), false, mask);
|
||||
}
|
||||
else if (selection.type().is<float>()) {
|
||||
index_mask::masked_fill(selection.typed<float>(), 0.0f, mask);
|
||||
}
|
||||
}
|
||||
|
||||
void fill_selection_true(GMutableSpan selection, const IndexMask &mask)
|
||||
{
|
||||
if (selection.type().is<bool>()) {
|
||||
index_mask::masked_fill(selection.typed<bool>(), true, mask);
|
||||
}
|
||||
else if (selection.type().is<float>()) {
|
||||
index_mask::masked_fill(selection.typed<float>(), 1.0f, mask);
|
||||
}
|
||||
}
|
||||
|
||||
static bool contains(const VArray<bool> &varray, const IndexRange range_to_check, const bool value)
|
||||
{
|
||||
const CommonVArrayInfo info = varray.common_info();
|
||||
|
@ -369,55 +389,6 @@ void select_adjacent(bke::CurvesGeometry &curves, const bool deselect)
|
|||
selection.finish();
|
||||
}
|
||||
|
||||
void select_random(bke::CurvesGeometry &curves,
|
||||
const eAttrDomain selection_domain,
|
||||
uint32_t random_seed,
|
||||
float probability)
|
||||
{
|
||||
RandomNumberGenerator rng{random_seed};
|
||||
const auto next_bool_random_value = [&]() { return rng.get_float() <= probability; };
|
||||
|
||||
const bool was_anything_selected = has_anything_selected(curves);
|
||||
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
|
||||
curves, selection_domain, CD_PROP_BOOL);
|
||||
if (!was_anything_selected) {
|
||||
curves::fill_selection_true(selection.span);
|
||||
}
|
||||
selection.span.type().to_static_type_tag<bool, float>([&](auto type_tag) {
|
||||
using T = typename decltype(type_tag)::type;
|
||||
if constexpr (std::is_void_v<T>) {
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
else {
|
||||
MutableSpan<T> selection_typed = selection.span.typed<T>();
|
||||
switch (selection_domain) {
|
||||
case ATTR_DOMAIN_POINT: {
|
||||
for (const int point_i : selection_typed.index_range()) {
|
||||
const bool random_value = next_bool_random_value();
|
||||
if (!random_value) {
|
||||
selection_typed[point_i] = T(0);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ATTR_DOMAIN_CURVE: {
|
||||
for (const int curve_i : curves.curves_range()) {
|
||||
const bool random_value = next_bool_random_value();
|
||||
if (!random_value) {
|
||||
selection_typed[curve_i] = T(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
}
|
||||
});
|
||||
selection.finish();
|
||||
}
|
||||
|
||||
void apply_selection_operation_at_index(GMutableSpan selection,
|
||||
const int index,
|
||||
const eSelectOp sel_op)
|
||||
|
|
|
@ -158,6 +158,7 @@ static void GREASE_PENCIL_OT_select_linked(wmOperatorType *ot)
|
|||
|
||||
static int select_random_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
using namespace blender;
|
||||
const float ratio = RNA_float_get(op->ptr, "ratio");
|
||||
const int seed = WM_operator_properties_select_random_seed_increment_get(op);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
@ -166,11 +167,26 @@ static int select_random_exec(bContext *C, wmOperator *op)
|
|||
eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get(C);
|
||||
|
||||
grease_pencil.foreach_editable_drawing(
|
||||
scene->r.cfra, [&](int drawing_index, blender::bke::greasepencil::Drawing &drawing) {
|
||||
blender::ed::curves::select_random(drawing.strokes_for_write(),
|
||||
selection_domain,
|
||||
blender::get_default_hash_2<int>(seed, drawing_index),
|
||||
ratio);
|
||||
scene->r.cfra, [&](int drawing_index, bke::greasepencil::Drawing &drawing) {
|
||||
bke::CurvesGeometry &curves = drawing.strokes_for_write();
|
||||
|
||||
IndexMaskMemory memory;
|
||||
const IndexMask random_elements = ed::curves::random_mask(
|
||||
curves,
|
||||
selection_domain,
|
||||
blender::get_default_hash_2<int>(seed, drawing_index),
|
||||
ratio,
|
||||
memory);
|
||||
|
||||
const bool was_anything_selected = ed::curves::has_anything_selected(curves);
|
||||
bke::GSpanAttributeWriter selection = ed::curves::ensure_selection_attribute(
|
||||
curves, selection_domain, CD_PROP_BOOL);
|
||||
if (!was_anything_selected) {
|
||||
curves::fill_selection_true(selection.span);
|
||||
}
|
||||
|
||||
curves::fill_selection_false(selection.span, random_elements);
|
||||
selection.finish();
|
||||
});
|
||||
|
||||
/* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
|
||||
|
|
|
@ -105,6 +105,19 @@ IndexMask end_points(const bke::CurvesGeometry &curves,
|
|||
bool inverted,
|
||||
IndexMaskMemory &memory);
|
||||
|
||||
/**
|
||||
* Return a mask of random points or curves.
|
||||
*
|
||||
* \param random_seed: The seed for the \a RandomNumberGenerator.
|
||||
* \param probability: Determins how likely a point/curve will be chosen. If set to 0.0, nothing
|
||||
* will be in the mask, if set to 1.0 everything will be in the mask.
|
||||
*/
|
||||
IndexMask random_mask(const bke::CurvesGeometry &curves,
|
||||
eAttrDomain selection_domain,
|
||||
uint32_t random_seed,
|
||||
float probability,
|
||||
IndexMaskMemory &memory);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -122,6 +135,8 @@ IndexMask end_points(const bke::CurvesGeometry &curves,
|
|||
|
||||
void fill_selection_false(GMutableSpan span);
|
||||
void fill_selection_true(GMutableSpan span);
|
||||
void fill_selection_false(GMutableSpan selection, const IndexMask &mask);
|
||||
void fill_selection_true(GMutableSpan selection, const IndexMask &mask);
|
||||
|
||||
/**
|
||||
* Return true if any element is selected, on either domain with either type.
|
||||
|
@ -180,18 +195,6 @@ void select_alternate(bke::CurvesGeometry &curves, const bool deselect_ends);
|
|||
*/
|
||||
void select_adjacent(bke::CurvesGeometry &curves, bool deselect);
|
||||
|
||||
/**
|
||||
* Select random points or curves.
|
||||
*
|
||||
* \param random_seed: The seed for the \a RandomNumberGenerator.
|
||||
* \param probability: Determins how likely a point/curve will be selected. If set to 0.0, nothing
|
||||
* will be selected, if set to 1.0 everything will be selected.
|
||||
*/
|
||||
void select_random(bke::CurvesGeometry &curves,
|
||||
eAttrDomain selection_domain,
|
||||
uint32_t random_seed,
|
||||
float probability);
|
||||
|
||||
/**
|
||||
* Helper struct for `closest_elem_find_screen_space`.
|
||||
*/
|
||||
|
|
|
@ -171,7 +171,7 @@ static int calculate_to_frame_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
wmJob *wm_job = WM_jobs_get(wm,
|
||||
CTX_wm_window(C),
|
||||
CTX_data_scene(C),
|
||||
"Bake Simulation Nodes",
|
||||
"Calculate Simulation",
|
||||
WM_JOB_PROGRESS,
|
||||
WM_JOB_TYPE_CALCULATE_SIMULATION_NODES);
|
||||
|
||||
|
|
|
@ -716,7 +716,10 @@ void ED_screens_init(Main *bmain, wmWindowManager *wm)
|
|||
}
|
||||
}
|
||||
|
||||
static bool region_poll(const bScreen *screen, const ScrArea *area, const ARegion *region)
|
||||
static bool region_poll(const bContext *C,
|
||||
const bScreen *screen,
|
||||
const ScrArea *area,
|
||||
const ARegion *region)
|
||||
{
|
||||
if (!region->type || !region->type->poll) {
|
||||
/* Show region by default. */
|
||||
|
@ -727,20 +730,27 @@ static bool region_poll(const bScreen *screen, const ScrArea *area, const ARegio
|
|||
params.screen = screen;
|
||||
params.area = area;
|
||||
params.region = region;
|
||||
params.context = C;
|
||||
|
||||
return region->type->poll(¶ms);
|
||||
}
|
||||
|
||||
static void screen_regions_poll(bContext *C, const wmWindow *win, bScreen *screen)
|
||||
{
|
||||
ScrArea *prev_area = CTX_wm_area(C);
|
||||
ARegion *prev_region = CTX_wm_region(C);
|
||||
|
||||
bool any_changed = false;
|
||||
ED_screen_areas_iter (win, screen, area) {
|
||||
CTX_wm_area_set(C, area);
|
||||
|
||||
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
||||
const int old_region_flag = region->flag;
|
||||
|
||||
region->flag &= ~RGN_FLAG_POLL_FAILED;
|
||||
|
||||
if (region_poll(screen, area, region) == false) {
|
||||
CTX_wm_region_set(C, region);
|
||||
if (region_poll(C, screen, area, region) == false) {
|
||||
region->flag |= RGN_FLAG_POLL_FAILED;
|
||||
}
|
||||
|
||||
|
@ -757,6 +767,9 @@ static void screen_regions_poll(bContext *C, const wmWindow *win, bScreen *scree
|
|||
if (any_changed) {
|
||||
screen->do_refresh = true;
|
||||
}
|
||||
|
||||
CTX_wm_area_set(C, prev_area);
|
||||
CTX_wm_region_set(C, prev_region);
|
||||
}
|
||||
|
||||
void ED_screen_ensure_updated(bContext *C, wmWindowManager *wm, wmWindow *win, bScreen *screen)
|
||||
|
|
|
@ -679,6 +679,7 @@ set(SRC_SHADER_CREATE_INFOS
|
|||
../draw/engines/workbench/shaders/infos/workbench_effect_dof_info.hh
|
||||
../draw/engines/workbench/shaders/infos/workbench_effect_outline_info.hh
|
||||
../draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh
|
||||
../draw/engines/workbench/shaders/infos/workbench_overlay_depth_info.hh
|
||||
../draw/engines/workbench/shaders/infos/workbench_prepass_info.hh
|
||||
../draw/engines/workbench/shaders/infos/workbench_shadow_info.hh
|
||||
../draw/engines/workbench/shaders/infos/workbench_transparent_resolve_info.hh
|
||||
|
|
|
@ -1000,7 +1000,6 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
|||
et->setData("type", &(lamp->type));
|
||||
et->setData("flag", &(lamp->flag));
|
||||
et->setData("mode", &(lamp->mode));
|
||||
et->setData("gamma", &(lamp->k));
|
||||
et->setData("red", &(lamp->r));
|
||||
et->setData("green", &(lamp->g));
|
||||
et->setData("blue", &(lamp->b));
|
||||
|
@ -1008,18 +1007,12 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
|||
et->setData("shadow_g", &(lamp->shdwg));
|
||||
et->setData("shadow_b", &(lamp->shdwb));
|
||||
et->setData("energy", &(lamp->energy));
|
||||
et->setData("dist", &(lamp->dist));
|
||||
et->setData("spotsize", &(lamp->spotsize));
|
||||
lamp->spotsize = DEG2RADF(lamp->spotsize);
|
||||
et->setData("spotblend", &(lamp->spotblend));
|
||||
et->setData("att1", &(lamp->att1));
|
||||
et->setData("att2", &(lamp->att2));
|
||||
et->setData("falloff_type", &(lamp->falloff_type));
|
||||
et->setData("clipsta", &(lamp->clipsta));
|
||||
et->setData("clipend", &(lamp->clipend));
|
||||
et->setData("bias", &(lamp->bias));
|
||||
et->setData("bufsize", &(lamp->bufsize));
|
||||
et->setData("buffers", &(lamp->buffers));
|
||||
et->setData("radius", &(lamp->radius));
|
||||
et->setData("area_shape", &(lamp->area_shape));
|
||||
et->setData("area_size", &(lamp->area_size));
|
||||
|
@ -1027,12 +1020,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
|||
et->setData("area_sizez", &(lamp->area_sizez));
|
||||
}
|
||||
else {
|
||||
float constatt = light->getConstantAttenuation().getValue();
|
||||
float linatt = light->getLinearAttenuation().getValue();
|
||||
float quadatt = light->getQuadraticAttenuation().getValue();
|
||||
float d = 25.0f;
|
||||
float att1 = 0.0f;
|
||||
float att2 = 0.0f;
|
||||
float e = 1.0f;
|
||||
|
||||
if (light->getColor().isValid()) {
|
||||
|
@ -1042,27 +1030,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
|||
lamp->b = col.getBlue();
|
||||
}
|
||||
|
||||
if (IS_EQ(linatt, 0.0f) && quadatt > 0.0f) {
|
||||
att2 = quadatt;
|
||||
d = sqrt(1.0f / quadatt);
|
||||
}
|
||||
/* linear light */
|
||||
else if (IS_EQ(quadatt, 0.0f) && linatt > 0.0f) {
|
||||
att1 = linatt;
|
||||
d = (1.0f / linatt);
|
||||
}
|
||||
else if (IS_EQ(constatt, 1.0f)) {
|
||||
att1 = 1.0f;
|
||||
}
|
||||
else {
|
||||
/* assuming point light (const att = 1.0); */
|
||||
att1 = 1.0f;
|
||||
}
|
||||
|
||||
d *= (1.0f / unit_converter.getLinearMeter());
|
||||
|
||||
lamp->energy = e;
|
||||
lamp->dist = d;
|
||||
|
||||
switch (light->getLightType()) {
|
||||
case COLLADAFW::Light::AMBIENT_LIGHT: {
|
||||
|
@ -1070,14 +1038,6 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
|||
} break;
|
||||
case COLLADAFW::Light::SPOT_LIGHT: {
|
||||
lamp->type = LA_SPOT;
|
||||
lamp->att1 = att1;
|
||||
lamp->att2 = att2;
|
||||
if (IS_EQ(att1, 0.0f) && att2 > 0) {
|
||||
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
|
||||
}
|
||||
if (IS_EQ(att2, 0.0f) && att1 > 0) {
|
||||
lamp->falloff_type = LA_FALLOFF_INVLINEAR;
|
||||
}
|
||||
lamp->spotsize = DEG2RADF(light->getFallOffAngle().getValue());
|
||||
lamp->spotblend = light->getFallOffExponent().getValue();
|
||||
} break;
|
||||
|
@ -1087,14 +1047,6 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
|||
} break;
|
||||
case COLLADAFW::Light::POINT_LIGHT: {
|
||||
lamp->type = LA_LOCAL;
|
||||
lamp->att1 = att1;
|
||||
lamp->att2 = att2;
|
||||
if (IS_EQ(att1, 0.0f) && att2 > 0) {
|
||||
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
|
||||
}
|
||||
if (IS_EQ(att2, 0.0f) && att1 > 0) {
|
||||
lamp->falloff_type = LA_FALLOFF_INVLINEAR;
|
||||
}
|
||||
} break;
|
||||
case COLLADAFW::Light::UNDEFINED: {
|
||||
fprintf(stderr, "Current light type is not supported.\n");
|
||||
|
|
|
@ -49,26 +49,11 @@ void LightsExporter::operator()(Object *ob)
|
|||
std::string la_id(get_light_id(ob));
|
||||
std::string la_name(id_name(la));
|
||||
COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy);
|
||||
float d, constatt, linatt, quadatt;
|
||||
|
||||
d = la->dist;
|
||||
|
||||
constatt = 1.0f;
|
||||
|
||||
if (la->falloff_type == LA_FALLOFF_INVLINEAR) {
|
||||
linatt = 1.0f / d;
|
||||
quadatt = 0.0f;
|
||||
}
|
||||
else {
|
||||
linatt = 0.0f;
|
||||
quadatt = 1.0f / (d * d);
|
||||
}
|
||||
|
||||
/* sun */
|
||||
if (la->type == LA_SUN) {
|
||||
COLLADASW::DirectionalLight cla(mSW, la_id, la_name);
|
||||
cla.setColor(col, false, "color");
|
||||
cla.setConstantAttenuation(constatt);
|
||||
exportBlenderProfile(cla, la);
|
||||
addLight(cla);
|
||||
}
|
||||
|
@ -79,9 +64,6 @@ void LightsExporter::operator()(Object *ob)
|
|||
cla.setColor(col, false, "color");
|
||||
cla.setFallOffAngle(RAD2DEGF(la->spotsize), false, "fall_off_angle");
|
||||
cla.setFallOffExponent(la->spotblend, false, "fall_off_exponent");
|
||||
cla.setConstantAttenuation(constatt);
|
||||
cla.setLinearAttenuation(linatt);
|
||||
cla.setQuadraticAttenuation(quadatt);
|
||||
exportBlenderProfile(cla, la);
|
||||
addLight(cla);
|
||||
}
|
||||
|
@ -89,9 +71,6 @@ void LightsExporter::operator()(Object *ob)
|
|||
else if (la->type == LA_LOCAL) {
|
||||
COLLADASW::PointLight cla(mSW, la_id, la_name);
|
||||
cla.setColor(col, false, "color");
|
||||
cla.setConstantAttenuation(constatt);
|
||||
cla.setLinearAttenuation(linatt);
|
||||
cla.setQuadraticAttenuation(quadatt);
|
||||
exportBlenderProfile(cla, la);
|
||||
addLight(cla);
|
||||
}
|
||||
|
@ -100,9 +79,6 @@ void LightsExporter::operator()(Object *ob)
|
|||
else {
|
||||
COLLADASW::PointLight cla(mSW, la_id, la_name);
|
||||
cla.setColor(col, false, "color");
|
||||
cla.setConstantAttenuation(constatt);
|
||||
cla.setLinearAttenuation(linatt);
|
||||
cla.setQuadraticAttenuation(quadatt);
|
||||
exportBlenderProfile(cla, la);
|
||||
addLight(cla);
|
||||
}
|
||||
|
@ -113,7 +89,6 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Light *la)
|
|||
cla.addExtraTechniqueParameter("blender", "type", la->type);
|
||||
cla.addExtraTechniqueParameter("blender", "flag", la->flag);
|
||||
cla.addExtraTechniqueParameter("blender", "mode", la->mode);
|
||||
cla.addExtraTechniqueParameter("blender", "gamma", la->k, "blender_gamma");
|
||||
cla.addExtraTechniqueParameter("blender", "red", la->r);
|
||||
cla.addExtraTechniqueParameter("blender", "green", la->g);
|
||||
cla.addExtraTechniqueParameter("blender", "blue", la->b);
|
||||
|
@ -121,19 +96,11 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Light *la)
|
|||
cla.addExtraTechniqueParameter("blender", "shadow_g", la->shdwg, "blender_shadow_g");
|
||||
cla.addExtraTechniqueParameter("blender", "shadow_b", la->shdwb, "blender_shadow_b");
|
||||
cla.addExtraTechniqueParameter("blender", "energy", la->energy, "blender_energy");
|
||||
cla.addExtraTechniqueParameter("blender", "dist", la->dist, "blender_dist");
|
||||
cla.addExtraTechniqueParameter("blender", "spotsize", RAD2DEGF(la->spotsize));
|
||||
cla.addExtraTechniqueParameter("blender", "spotblend", la->spotblend);
|
||||
cla.addExtraTechniqueParameter("blender", "att1", la->att1);
|
||||
cla.addExtraTechniqueParameter("blender", "att2", la->att2);
|
||||
/* \todo figure out how we can have falloff curve supported here */
|
||||
cla.addExtraTechniqueParameter("blender", "falloff_type", la->falloff_type);
|
||||
cla.addExtraTechniqueParameter("blender", "clipsta", la->clipsta);
|
||||
cla.addExtraTechniqueParameter("blender", "clipend", la->clipend);
|
||||
cla.addExtraTechniqueParameter("blender", "bias", la->bias);
|
||||
cla.addExtraTechniqueParameter("blender", "bufsize", la->bufsize);
|
||||
cla.addExtraTechniqueParameter("blender", "samp", la->samp);
|
||||
cla.addExtraTechniqueParameter("blender", "buffers", la->buffers);
|
||||
cla.addExtraTechniqueParameter("blender", "radius", la->radius);
|
||||
cla.addExtraTechniqueParameter("blender", "area_shape", la->area_shape);
|
||||
cla.addExtraTechniqueParameter("blender", "area_size", la->area_size);
|
||||
|
|
|
@ -20,28 +20,18 @@
|
|||
.r = 1.0f, \
|
||||
.g = 1.0f, \
|
||||
.b = 1.0f, \
|
||||
.k = 1.0f, \
|
||||
.energy = 10.0f, \
|
||||
.energy_deprecated = 10.0f, \
|
||||
.dist = 25.0f, \
|
||||
.spotsize = DEG2RADF(45.0f), \
|
||||
.spotblend = 0.15f, \
|
||||
.att2 = 1.0f, \
|
||||
.mode = LA_SHADOW, \
|
||||
.bufsize = 512, \
|
||||
.clipsta = 0.05f, \
|
||||
.clipend = 40.0f, \
|
||||
.samp = 3, \
|
||||
.bias = 1.0f, \
|
||||
.area_size = 0.25f, \
|
||||
.area_sizey = 0.25f, \
|
||||
.area_sizez = 0.25f, \
|
||||
.buffers = 1, \
|
||||
.preview = NULL, \
|
||||
.falloff_type = LA_FALLOFF_INVSQUARE, \
|
||||
.coeff_const = 1.0f, \
|
||||
.coeff_lin = 0.0f, \
|
||||
.coeff_quad = 0.0f, \
|
||||
.cascade_max_dist = 200.0f, \
|
||||
.cascade_count = 4, \
|
||||
.cascade_exponent = 0.8f, \
|
||||
|
|
|
@ -31,42 +31,43 @@ typedef struct Light {
|
|||
/** Animation data (must be immediately after id for utilities to use it). */
|
||||
struct AnimData *adt;
|
||||
|
||||
/* Type and flags. */
|
||||
short type, flag;
|
||||
int mode;
|
||||
|
||||
float r, g, b, k;
|
||||
float shdwr, shdwg, shdwb, shdwpad;
|
||||
/* Color and energy. */
|
||||
float r, g, b;
|
||||
float energy;
|
||||
|
||||
float energy, dist, spotsize, spotblend;
|
||||
float energy_deprecated DNA_DEPRECATED;
|
||||
|
||||
/** Quad1 and Quad2 attenuation. */
|
||||
float att1, att2;
|
||||
float coeff_const, coeff_lin, coeff_quad;
|
||||
struct CurveMapping *curfalloff;
|
||||
short falloff_type;
|
||||
char _pad2[2];
|
||||
|
||||
float clipsta, clipend;
|
||||
float bias;
|
||||
/* Point light. */
|
||||
float radius;
|
||||
short bufsize, samp, buffers, filtertype;
|
||||
char bufflag, buftype;
|
||||
|
||||
/* Spot Light. */
|
||||
float spotsize;
|
||||
float spotblend;
|
||||
|
||||
/* Area light. */
|
||||
short area_shape;
|
||||
float area_size, area_sizey, area_sizez;
|
||||
short _pad1;
|
||||
float area_size;
|
||||
float area_sizey;
|
||||
float area_sizez;
|
||||
float area_spread;
|
||||
|
||||
/* Sun light. */
|
||||
float sun_angle;
|
||||
|
||||
/* texact is for buttons */
|
||||
short texact, shadhalostep;
|
||||
/* Shadow color. */
|
||||
float shdwr, shdwg, shdwb;
|
||||
|
||||
/** Old animation system, deprecated for 2.5. */
|
||||
struct Ipo *ipo DNA_DEPRECATED;
|
||||
/* Nodes. */
|
||||
short pr_texture, use_nodes;
|
||||
|
||||
/* Eevee */
|
||||
float bias;
|
||||
float clipsta;
|
||||
float clipend;
|
||||
|
||||
float cascade_max_dist;
|
||||
float cascade_exponent;
|
||||
float cascade_fade;
|
||||
|
@ -78,12 +79,18 @@ typedef struct Light {
|
|||
|
||||
float diff_fac, volume_fac;
|
||||
float spec_fac, att_dist;
|
||||
float _pad0;
|
||||
|
||||
/* preview */
|
||||
/* Preview */
|
||||
struct PreviewImage *preview;
|
||||
|
||||
/* nodes */
|
||||
/* Nodes */
|
||||
struct bNodeTree *nodetree;
|
||||
|
||||
/* Deprecated. */
|
||||
struct Ipo *ipo DNA_DEPRECATED; /* Old animation system. */
|
||||
float energy_deprecated DNA_DEPRECATED;
|
||||
float _pad2;
|
||||
} Light;
|
||||
|
||||
/* **************** LIGHT ********************* */
|
||||
|
|
|
@ -36,15 +36,6 @@
|
|||
# include "WM_api.h"
|
||||
# include "WM_types.h"
|
||||
|
||||
static void rna_Light_buffer_size_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
Light *la = (Light *)ptr->data;
|
||||
|
||||
CLAMP(value, 128, 10240);
|
||||
la->bufsize = value;
|
||||
la->bufsize &= (~15); /* round to multiple of 16 */
|
||||
}
|
||||
|
||||
static StructRNA *rna_Light_refine(PointerRNA *ptr)
|
||||
{
|
||||
Light *la = (Light *)ptr->data;
|
||||
|
@ -122,16 +113,6 @@ static void rna_def_light(BlenderRNA *brna)
|
|||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_LIGHT);
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
|
||||
prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "dist");
|
||||
RNA_def_property_range(prop, 0, INT_MAX);
|
||||
RNA_def_property_ui_range(prop, 0, 1000, 1, 3);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Distance",
|
||||
"Falloff distance - the light is at half the original intensity at this point");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
|
||||
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "r");
|
||||
RNA_def_property_array(prop, 3);
|
||||
|
@ -237,63 +218,6 @@ static void rna_def_light_energy(StructRNA *srna, const short light_type)
|
|||
}
|
||||
}
|
||||
|
||||
static void rna_def_light_falloff(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
static const EnumPropertyItem prop_fallofftype_items[] = {
|
||||
{LA_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", ""},
|
||||
{LA_FALLOFF_INVLINEAR, "INVERSE_LINEAR", 0, "Inverse Linear", ""},
|
||||
{LA_FALLOFF_INVSQUARE, "INVERSE_SQUARE", 0, "Inverse Square", ""},
|
||||
{LA_FALLOFF_INVCOEFFICIENTS, "INVERSE_COEFFICIENTS", 0, "Inverse Coefficients", ""},
|
||||
{LA_FALLOFF_CURVE, "CUSTOM_CURVE", 0, "Custom Curve", ""},
|
||||
{LA_FALLOFF_SLIDERS, "LINEAR_QUADRATIC_WEIGHTED", 0, "Lin/Quad Weighted", ""},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, prop_fallofftype_items);
|
||||
RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_update");
|
||||
|
||||
prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, nullptr, "curfalloff");
|
||||
RNA_def_property_ui_text(prop, "Falloff Curve", "Custom light falloff curve");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_update");
|
||||
|
||||
prop = RNA_def_property(srna, "linear_attenuation", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "att1");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_text(prop, "Linear Attenuation", "Linear distance attenuation");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
|
||||
prop = RNA_def_property(srna, "quadratic_attenuation", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "att2");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_text(prop, "Quadratic Attenuation", "Quadratic distance attenuation");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
|
||||
prop = RNA_def_property(srna, "constant_coefficient", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "coeff_const");
|
||||
RNA_def_property_range(prop, 0.0f, FLT_MAX);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Constant Coefficient", "Constant distance attenuation coefficient");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
|
||||
prop = RNA_def_property(srna, "linear_coefficient", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "coeff_lin");
|
||||
RNA_def_property_range(prop, 0.0f, FLT_MAX);
|
||||
RNA_def_property_ui_text(prop, "Linear Coefficient", "Linear distance attenuation coefficient");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
|
||||
prop = RNA_def_property(srna, "quadratic_coefficient", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "coeff_quad");
|
||||
RNA_def_property_range(prop, 0.0f, FLT_MAX);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Quadratic Coefficient", "Quadratic distance attenuation coefficient");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
}
|
||||
|
||||
static void rna_def_light_shadow(StructRNA *srna, bool sun)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
@ -302,16 +226,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
|
|||
RNA_def_property_boolean_sdna(prop, nullptr, "mode", LA_SHADOW);
|
||||
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
|
||||
|
||||
prop = RNA_def_property(srna, "shadow_buffer_size", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, nullptr, "bufsize");
|
||||
RNA_def_property_range(prop, 128, 10240);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Shadow Buffer Size",
|
||||
"Resolution of the shadow buffer, higher values give crisper shadows "
|
||||
"but use more memory");
|
||||
RNA_def_property_int_funcs(prop, nullptr, "rna_Light_buffer_size_set", nullptr);
|
||||
RNA_def_property_update(prop, 0, "rna_Light_update");
|
||||
|
||||
prop = RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "clipsta");
|
||||
RNA_def_property_range(prop, 1e-6f, FLT_MAX);
|
||||
|
@ -328,12 +242,6 @@ static void rna_def_light_shadow(StructRNA *srna, bool sun)
|
|||
RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Bias for reducing self shadowing");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_update");
|
||||
|
||||
prop = RNA_def_property(srna, "shadow_buffer_samples", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, nullptr, "samp");
|
||||
RNA_def_property_range(prop, 1, 16);
|
||||
RNA_def_property_ui_text(prop, "Samples", "Number of shadow buffer samples");
|
||||
RNA_def_property_update(prop, 0, "rna_Light_update");
|
||||
|
||||
prop = RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "shdwr");
|
||||
RNA_def_property_array(prop, 3);
|
||||
|
@ -425,7 +333,6 @@ static void rna_def_point_light(BlenderRNA *brna)
|
|||
RNA_def_struct_ui_icon(srna, ICON_LIGHT_POINT);
|
||||
|
||||
rna_def_light_energy(srna, LA_LOCAL);
|
||||
rna_def_light_falloff(srna);
|
||||
rna_def_light_shadow(srna, false);
|
||||
}
|
||||
|
||||
|
@ -449,7 +356,6 @@ static void rna_def_area_light(BlenderRNA *brna)
|
|||
|
||||
rna_def_light_energy(srna, LA_AREA);
|
||||
rna_def_light_shadow(srna, false);
|
||||
rna_def_light_falloff(srna);
|
||||
|
||||
prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, nullptr, "area_shape");
|
||||
|
@ -496,7 +402,6 @@ static void rna_def_spot_light(BlenderRNA *brna)
|
|||
RNA_def_struct_ui_icon(srna, ICON_LIGHT_SPOT);
|
||||
|
||||
rna_def_light_energy(srna, LA_SPOT);
|
||||
rna_def_light_falloff(srna);
|
||||
rna_def_light_shadow(srna, false);
|
||||
|
||||
prop = RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE);
|
||||
|
|
|
@ -267,7 +267,7 @@ static int rna_MeshVertex_index_get(PointerRNA *ptr)
|
|||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const blender::float3 *position = static_cast<const blender::float3 *>(ptr->data);
|
||||
const int index = (int)(position - mesh->vert_positions().data());
|
||||
const int index = int(position - mesh->vert_positions().data());
|
||||
BLI_assert(index >= 0);
|
||||
BLI_assert(index < mesh->totvert);
|
||||
return index;
|
||||
|
@ -277,10 +277,10 @@ static int rna_MeshEdge_index_get(PointerRNA *ptr)
|
|||
{
|
||||
using namespace blender;
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const int2 *edge = (int2 *)ptr->data;
|
||||
const int2 *edges = static_cast<const int2 *>(
|
||||
const blender::int2 *edge = static_cast<const blender::int2 *>(ptr->data);
|
||||
const blender::int2 *edges = static_cast<const blender::int2 *>(
|
||||
CustomData_get_layer_named(&mesh->edata, CD_PROP_INT32_2D, ".edge_verts"));
|
||||
const int index = (int)(edge - edges);
|
||||
const int index = int(edge - edges);
|
||||
BLI_assert(index >= 0);
|
||||
BLI_assert(index < mesh->totedge);
|
||||
return index;
|
||||
|
@ -289,8 +289,8 @@ static int rna_MeshEdge_index_get(PointerRNA *ptr)
|
|||
static int rna_MeshPolygon_index_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const int *poly_offset = (const int *)ptr->data;
|
||||
const int index = (int)(poly_offset - BKE_mesh_poly_offsets(mesh));
|
||||
const int *poly_offset = static_cast<const int *>(ptr->data);
|
||||
const int index = int(poly_offset - mesh->poly_offsets().data());
|
||||
BLI_assert(index >= 0);
|
||||
BLI_assert(index < mesh->totpoly);
|
||||
return index;
|
||||
|
@ -299,8 +299,8 @@ static int rna_MeshPolygon_index_get(PointerRNA *ptr)
|
|||
static int rna_MeshLoop_index_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const int *corner_vert = (const int *)ptr->data;
|
||||
const int index = (int)(corner_vert - mesh->corner_verts().data());
|
||||
const int *corner_vert = static_cast<const int *>(ptr->data);
|
||||
const int index = int(corner_vert - mesh->corner_verts().data());
|
||||
BLI_assert(index >= 0);
|
||||
BLI_assert(index < mesh->totloop);
|
||||
return index;
|
||||
|
@ -309,8 +309,8 @@ static int rna_MeshLoop_index_get(PointerRNA *ptr)
|
|||
static int rna_MeshLoopTriangle_index_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const MLoopTri *ltri = (MLoopTri *)ptr->data;
|
||||
const int index = (int)(ltri - BKE_mesh_runtime_looptri_ensure(mesh));
|
||||
const MLoopTri *tri = static_cast<const MLoopTri *>(ptr->data);
|
||||
const int index = int(tri - mesh->looptris().data());
|
||||
BLI_assert(index >= 0);
|
||||
BLI_assert(index < BKE_mesh_runtime_looptri_len(mesh));
|
||||
return index;
|
||||
|
@ -320,18 +320,17 @@ static int rna_MeshLoopTriangle_polygon_index_get(PointerRNA *ptr)
|
|||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const int index = rna_MeshLoopTriangle_index_get(ptr);
|
||||
const int *looptri_polys = BKE_mesh_runtime_looptri_polys_ensure(mesh);
|
||||
return looptri_polys[index];
|
||||
return mesh->looptri_polys()[index];
|
||||
}
|
||||
|
||||
static void rna_Mesh_loop_triangles_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const MLoopTri *looptris = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
const blender::Span<MLoopTri> looptris = mesh->looptris();
|
||||
rna_iterator_array_begin(iter,
|
||||
(void *)looptris,
|
||||
const_cast<MLoopTri *>(looptris.data()),
|
||||
sizeof(MLoopTri),
|
||||
BKE_mesh_runtime_looptri_len(mesh),
|
||||
looptris.size(),
|
||||
false,
|
||||
nullptr);
|
||||
}
|
||||
|
@ -351,7 +350,7 @@ int rna_Mesh_loop_triangles_lookup_int(PointerRNA *ptr, int index, PointerRNA *r
|
|||
/* Casting away const is okay because this RNA type doesn't allow changing the value. */
|
||||
r_ptr->owner_id = (ID *)&mesh->id;
|
||||
r_ptr->type = &RNA_MeshLoopTriangle;
|
||||
r_ptr->data = (void *)&BKE_mesh_runtime_looptri_ensure(mesh)[index];
|
||||
r_ptr->data = const_cast<MLoopTri *>(&mesh->looptris()[index]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -360,7 +359,7 @@ static void rna_Mesh_loop_triangle_polygons_begin(CollectionPropertyIterator *it
|
|||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
rna_iterator_array_begin(iter,
|
||||
(void *)BKE_mesh_runtime_looptri_polys_ensure(mesh),
|
||||
const_cast<int *>(mesh->looptri_polys().data()),
|
||||
sizeof(int),
|
||||
BKE_mesh_runtime_looptri_len(mesh),
|
||||
false,
|
||||
|
@ -376,7 +375,7 @@ int rna_Mesh_loop_triangle_polygons_lookup_int(PointerRNA *ptr, int index, Point
|
|||
/* Casting away const is okay because this RNA type doesn't allow changing the value. */
|
||||
r_ptr->owner_id = (ID *)&mesh->id;
|
||||
r_ptr->type = &RNA_ReadOnlyInteger;
|
||||
r_ptr->data = (void *)&BKE_mesh_runtime_looptri_polys_ensure(mesh)[index];
|
||||
r_ptr->data = const_cast<int *>(&mesh->looptri_polys()[index]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -401,8 +400,8 @@ static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
|
|||
static bool rna_MeshVertex_hide_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const bool *hide_vert = (const bool *)CustomData_get_layer_named(
|
||||
&mesh->vdata, CD_PROP_BOOL, ".hide_vert");
|
||||
const bool *hide_vert = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh->vdata, CD_PROP_BOOL, ".hide_vert"));
|
||||
const int index = rna_MeshVertex_index_get(ptr);
|
||||
return hide_vert == nullptr ? false : hide_vert[index];
|
||||
}
|
||||
|
@ -410,15 +409,15 @@ static bool rna_MeshVertex_hide_get(PointerRNA *ptr)
|
|||
static void rna_MeshVertex_hide_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
bool *hide_vert = (bool *)CustomData_get_layer_named_for_write(
|
||||
&mesh->vdata, CD_PROP_BOOL, ".hide_vert", mesh->totvert);
|
||||
bool *hide_vert = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->vdata, CD_PROP_BOOL, ".hide_vert", mesh->totvert));
|
||||
if (!hide_vert) {
|
||||
if (!value) {
|
||||
/* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */
|
||||
return;
|
||||
}
|
||||
hide_vert = (bool *)CustomData_add_layer_named(
|
||||
&mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totvert, ".hide_vert");
|
||||
hide_vert = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totvert, ".hide_vert"));
|
||||
}
|
||||
const int index = rna_MeshVertex_index_get(ptr);
|
||||
hide_vert[index] = value;
|
||||
|
@ -427,8 +426,8 @@ static void rna_MeshVertex_hide_set(PointerRNA *ptr, bool value)
|
|||
static bool rna_MeshVertex_select_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const bool *select_vert = (const bool *)CustomData_get_layer_named(
|
||||
&mesh->vdata, CD_PROP_BOOL, ".select_vert");
|
||||
const bool *select_vert = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh->vdata, CD_PROP_BOOL, ".select_vert"));
|
||||
const int index = rna_MeshVertex_index_get(ptr);
|
||||
return select_vert == nullptr ? false : select_vert[index];
|
||||
}
|
||||
|
@ -436,15 +435,15 @@ static bool rna_MeshVertex_select_get(PointerRNA *ptr)
|
|||
static void rna_MeshVertex_select_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
bool *select_vert = (bool *)CustomData_get_layer_named_for_write(
|
||||
&mesh->vdata, CD_PROP_BOOL, ".select_vert", mesh->totvert);
|
||||
bool *select_vert = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->vdata, CD_PROP_BOOL, ".select_vert", mesh->totvert));
|
||||
if (!select_vert) {
|
||||
if (!value) {
|
||||
/* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */
|
||||
return;
|
||||
}
|
||||
select_vert = (bool *)CustomData_add_layer_named(
|
||||
&mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totvert, ".select_vert");
|
||||
select_vert = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totvert, ".select_vert"));
|
||||
}
|
||||
const int index = rna_MeshVertex_index_get(ptr);
|
||||
select_vert[index] = value;
|
||||
|
@ -558,8 +557,8 @@ static void rna_MeshPolygon_normal_get(PointerRNA *ptr, float *values)
|
|||
static bool rna_MeshPolygon_hide_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const bool *hide_poly = (const bool *)CustomData_get_layer_named(
|
||||
&mesh->pdata, CD_PROP_BOOL, ".hide_poly");
|
||||
const bool *hide_poly = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".hide_poly"));
|
||||
const int index = rna_MeshPolygon_index_get(ptr);
|
||||
return hide_poly == nullptr ? false : hide_poly[index];
|
||||
}
|
||||
|
@ -567,15 +566,15 @@ static bool rna_MeshPolygon_hide_get(PointerRNA *ptr)
|
|||
static void rna_MeshPolygon_hide_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
bool *hide_poly = (bool *)CustomData_get_layer_named_for_write(
|
||||
&mesh->pdata, CD_PROP_BOOL, ".hide_poly", mesh->totpoly);
|
||||
bool *hide_poly = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->pdata, CD_PROP_BOOL, ".hide_poly", mesh->totpoly));
|
||||
if (!hide_poly) {
|
||||
if (!value) {
|
||||
/* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */
|
||||
return;
|
||||
}
|
||||
hide_poly = (bool *)CustomData_add_layer_named(
|
||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, ".hide_poly");
|
||||
hide_poly = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, ".hide_poly"));
|
||||
}
|
||||
const int index = rna_MeshPolygon_index_get(ptr);
|
||||
hide_poly[index] = value;
|
||||
|
@ -584,8 +583,8 @@ static void rna_MeshPolygon_hide_set(PointerRNA *ptr, bool value)
|
|||
static bool rna_MeshPolygon_use_smooth_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const bool *sharp_faces = (const bool *)CustomData_get_layer_named(
|
||||
&mesh->pdata, CD_PROP_BOOL, "sharp_face");
|
||||
const bool *sharp_faces = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, "sharp_face"));
|
||||
const int index = rna_MeshPolygon_index_get(ptr);
|
||||
return !(sharp_faces && sharp_faces[index]);
|
||||
}
|
||||
|
@ -593,15 +592,15 @@ static bool rna_MeshPolygon_use_smooth_get(PointerRNA *ptr)
|
|||
static void rna_MeshPolygon_use_smooth_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
bool *sharp_faces = (bool *)CustomData_get_layer_named_for_write(
|
||||
&mesh->pdata, CD_PROP_BOOL, "sharp_face", mesh->totpoly);
|
||||
bool *sharp_faces = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->pdata, CD_PROP_BOOL, "sharp_face", mesh->totpoly));
|
||||
if (!sharp_faces) {
|
||||
if (value) {
|
||||
/* Skip adding layer if the value is the same as the default. */
|
||||
return;
|
||||
}
|
||||
sharp_faces = (bool *)CustomData_add_layer_named(
|
||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, "sharp_face");
|
||||
sharp_faces = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, "sharp_face"));
|
||||
}
|
||||
const int index = rna_MeshPolygon_index_get(ptr);
|
||||
sharp_faces[index] = !value;
|
||||
|
@ -610,8 +609,8 @@ static void rna_MeshPolygon_use_smooth_set(PointerRNA *ptr, bool value)
|
|||
static bool rna_MeshPolygon_select_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const bool *select_poly = (const bool *)CustomData_get_layer_named(
|
||||
&mesh->pdata, CD_PROP_BOOL, ".select_poly");
|
||||
const bool *select_poly = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh->pdata, CD_PROP_BOOL, ".select_poly"));
|
||||
const int index = rna_MeshPolygon_index_get(ptr);
|
||||
return select_poly == nullptr ? false : select_poly[index];
|
||||
}
|
||||
|
@ -619,15 +618,15 @@ static bool rna_MeshPolygon_select_get(PointerRNA *ptr)
|
|||
static void rna_MeshPolygon_select_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
bool *select_poly = (bool *)CustomData_get_layer_named_for_write(
|
||||
&mesh->pdata, CD_PROP_BOOL, ".select_poly", mesh->totpoly);
|
||||
bool *select_poly = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->pdata, CD_PROP_BOOL, ".select_poly", mesh->totpoly));
|
||||
if (!select_poly) {
|
||||
if (!value) {
|
||||
/* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */
|
||||
return;
|
||||
}
|
||||
select_poly = (bool *)CustomData_add_layer_named(
|
||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, ".select_poly");
|
||||
select_poly = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totpoly, ".select_poly"));
|
||||
}
|
||||
const int index = rna_MeshPolygon_index_get(ptr);
|
||||
select_poly[index] = value;
|
||||
|
@ -789,8 +788,7 @@ static void rna_MeshVertex_groups_begin(CollectionPropertyIterator *iter, Pointe
|
|||
const int index = rna_MeshVertex_index_get(ptr);
|
||||
MDeformVert *dvert = &dverts[index];
|
||||
|
||||
rna_iterator_array_begin(
|
||||
iter, (void *)dvert->dw, sizeof(MDeformWeight), dvert->totweight, 0, nullptr);
|
||||
rna_iterator_array_begin(iter, dvert->dw, sizeof(MDeformWeight), dvert->totweight, 0, nullptr);
|
||||
}
|
||||
else {
|
||||
rna_iterator_array_begin(iter, nullptr, 0, 0, 0, nullptr);
|
||||
|
@ -1275,7 +1273,7 @@ static int rna_MeshPaintMaskLayer_data_length(PointerRNA *ptr)
|
|||
static int rna_MeshPoly_vertices_get_length(const PointerRNA *ptr,
|
||||
int length[RNA_MAX_ARRAY_DIMENSION])
|
||||
{
|
||||
const int *poly_offset_p = (const int *)ptr->data;
|
||||
const int *poly_offset_p = static_cast<const int *>(ptr->data);
|
||||
const int poly_start = *poly_offset_p;
|
||||
const int poly_size = *(poly_offset_p + 1) - poly_start;
|
||||
/* NOTE: raw access uses dummy item, this _could_ crash,
|
||||
|
@ -1286,7 +1284,7 @@ static int rna_MeshPoly_vertices_get_length(const PointerRNA *ptr,
|
|||
static void rna_MeshPoly_vertices_get(PointerRNA *ptr, int *values)
|
||||
{
|
||||
const Mesh *me = rna_mesh(ptr);
|
||||
const int *poly_offset_p = (const int *)ptr->data;
|
||||
const int *poly_offset_p = static_cast<const int *>(ptr->data);
|
||||
const int poly_start = *poly_offset_p;
|
||||
const int poly_size = *(poly_offset_p + 1) - poly_start;
|
||||
memcpy(values, &me->corner_verts()[poly_start], sizeof(int) * poly_size);
|
||||
|
@ -1294,24 +1292,24 @@ static void rna_MeshPoly_vertices_get(PointerRNA *ptr, int *values)
|
|||
|
||||
static int rna_MeshPolygon_loop_start_get(PointerRNA *ptr)
|
||||
{
|
||||
return *(const int *)ptr->data;
|
||||
return *static_cast<const int *>(ptr->data);
|
||||
}
|
||||
|
||||
static void rna_MeshPolygon_loop_start_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
*(int *)ptr->data = value;
|
||||
*static_cast<int *>(ptr->data) = value;
|
||||
}
|
||||
|
||||
static int rna_MeshPolygon_loop_total_get(PointerRNA *ptr)
|
||||
{
|
||||
const int *data = (const int *)ptr->data;
|
||||
const int *data = static_cast<const int *>(ptr->data);
|
||||
return *(data + 1) - *data;
|
||||
}
|
||||
|
||||
static void rna_MeshPoly_vertices_set(PointerRNA *ptr, const int *values)
|
||||
{
|
||||
Mesh *me = rna_mesh(ptr);
|
||||
const int *poly_offset_p = (const int *)ptr->data;
|
||||
const int *poly_offset_p = static_cast<const int *>(ptr->data);
|
||||
const int poly_start = *poly_offset_p;
|
||||
const int poly_size = *(poly_offset_p + 1) - poly_start;
|
||||
memcpy(&me->corner_verts_for_write()[poly_start], values, sizeof(int) * poly_size);
|
||||
|
@ -1331,8 +1329,8 @@ static void rna_MeshPoly_material_index_range(
|
|||
static bool rna_MeshEdge_hide_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const bool *hide_edge = (const bool *)CustomData_get_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, ".hide_edge");
|
||||
const bool *hide_edge = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh->edata, CD_PROP_BOOL, ".hide_edge"));
|
||||
const int index = rna_MeshEdge_index_get(ptr);
|
||||
return hide_edge == nullptr ? false : hide_edge[index];
|
||||
}
|
||||
|
@ -1340,15 +1338,15 @@ static bool rna_MeshEdge_hide_get(PointerRNA *ptr)
|
|||
static void rna_MeshEdge_hide_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
bool *hide_edge = (bool *)CustomData_get_layer_named_for_write(
|
||||
&mesh->edata, CD_PROP_BOOL, ".hide_edge", mesh->totedge);
|
||||
bool *hide_edge = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->edata, CD_PROP_BOOL, ".hide_edge", mesh->totedge));
|
||||
if (!hide_edge) {
|
||||
if (!value) {
|
||||
/* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */
|
||||
return;
|
||||
}
|
||||
hide_edge = (bool *)CustomData_add_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, ".hide_edge");
|
||||
hide_edge = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, ".hide_edge"));
|
||||
}
|
||||
const int index = rna_MeshEdge_index_get(ptr);
|
||||
hide_edge[index] = value;
|
||||
|
@ -1357,8 +1355,8 @@ static void rna_MeshEdge_hide_set(PointerRNA *ptr, bool value)
|
|||
static bool rna_MeshEdge_select_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const bool *select_edge = (const bool *)CustomData_get_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, ".select_edge");
|
||||
const bool *select_edge = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh->edata, CD_PROP_BOOL, ".select_edge"));
|
||||
const int index = rna_MeshEdge_index_get(ptr);
|
||||
return select_edge == nullptr ? false : select_edge[index];
|
||||
}
|
||||
|
@ -1366,15 +1364,15 @@ static bool rna_MeshEdge_select_get(PointerRNA *ptr)
|
|||
static void rna_MeshEdge_select_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
bool *select_edge = (bool *)CustomData_get_layer_named_for_write(
|
||||
&mesh->edata, CD_PROP_BOOL, ".select_edge", mesh->totedge);
|
||||
bool *select_edge = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->edata, CD_PROP_BOOL, ".select_edge", mesh->totedge));
|
||||
if (!select_edge) {
|
||||
if (!value) {
|
||||
/* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */
|
||||
return;
|
||||
}
|
||||
select_edge = (bool *)CustomData_add_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, ".select_edge");
|
||||
select_edge = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, ".select_edge"));
|
||||
}
|
||||
const int index = rna_MeshEdge_index_get(ptr);
|
||||
select_edge[index] = value;
|
||||
|
@ -1383,8 +1381,8 @@ static void rna_MeshEdge_select_set(PointerRNA *ptr, bool value)
|
|||
static bool rna_MeshEdge_use_edge_sharp_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const bool *sharp_edge = (const bool *)CustomData_get_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, "sharp_edge");
|
||||
const bool *sharp_edge = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh->edata, CD_PROP_BOOL, "sharp_edge"));
|
||||
const int index = rna_MeshEdge_index_get(ptr);
|
||||
return sharp_edge == nullptr ? false : sharp_edge[index];
|
||||
}
|
||||
|
@ -1392,15 +1390,15 @@ static bool rna_MeshEdge_use_edge_sharp_get(PointerRNA *ptr)
|
|||
static void rna_MeshEdge_use_edge_sharp_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
bool *sharp_edge = (bool *)CustomData_get_layer_named_for_write(
|
||||
&mesh->edata, CD_PROP_BOOL, "sharp_edge", mesh->totedge);
|
||||
bool *sharp_edge = static_cast<bool *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->edata, CD_PROP_BOOL, "sharp_edge", mesh->totedge));
|
||||
if (!sharp_edge) {
|
||||
if (!value) {
|
||||
/* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */
|
||||
return;
|
||||
}
|
||||
sharp_edge = (bool *)CustomData_add_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, "sharp_edge");
|
||||
sharp_edge = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, "sharp_edge"));
|
||||
}
|
||||
const int index = rna_MeshEdge_index_get(ptr);
|
||||
sharp_edge[index] = value;
|
||||
|
@ -1409,8 +1407,8 @@ static void rna_MeshEdge_use_edge_sharp_set(PointerRNA *ptr, bool value)
|
|||
static bool rna_MeshEdge_use_seam_get(PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const bool *seam_edge = (const bool *)CustomData_get_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, ".uv_seam");
|
||||
const bool *seam_edge = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&mesh->edata, CD_PROP_BOOL, ".uv_seam"));
|
||||
const int index = rna_MeshEdge_index_get(ptr);
|
||||
return seam_edge == nullptr ? false : seam_edge[index];
|
||||
}
|
||||
|
@ -1418,15 +1416,15 @@ static bool rna_MeshEdge_use_seam_get(PointerRNA *ptr)
|
|||
static void rna_MeshEdge_use_seam_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
bool *seam_edge = (bool *)CustomData_get_layer_named_for_write(
|
||||
&mesh->edata, CD_PROP_BOOL, ".uv_seam", mesh->totedge);
|
||||
bool *seam_edge = static_cast<bool *>(
|
||||
CustomData_get_layer_named_for_write(&mesh->edata, CD_PROP_BOOL, ".uv_seam", mesh->totedge));
|
||||
if (!seam_edge) {
|
||||
if (!value) {
|
||||
/* Skip adding layer if it doesn't exist already anyway and we're not hiding an element. */
|
||||
return;
|
||||
}
|
||||
seam_edge = (bool *)CustomData_add_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, ".uv_seam");
|
||||
seam_edge = static_cast<bool *>(CustomData_add_layer_named(
|
||||
&mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->totedge, ".uv_seam"));
|
||||
}
|
||||
const int index = rna_MeshEdge_index_get(ptr);
|
||||
seam_edge[index] = value;
|
||||
|
@ -1452,8 +1450,8 @@ static bool rna_MeshLoopTriangle_use_smooth_get(PointerRNA *ptr)
|
|||
{
|
||||
const Mesh *me = rna_mesh(ptr);
|
||||
const int poly_i = rna_MeshLoopTriangle_polygon_index_get(ptr);
|
||||
const bool *sharp_faces = (const bool *)CustomData_get_layer_named(
|
||||
&me->pdata, CD_PROP_BOOL, "sharp_face");
|
||||
const bool *sharp_faces = static_cast<const bool *>(
|
||||
CustomData_get_layer_named(&me->pdata, CD_PROP_BOOL, "sharp_face"));
|
||||
return !(sharp_faces && sharp_faces[poly_i]);
|
||||
}
|
||||
|
||||
|
@ -1479,29 +1477,28 @@ static char *rna_VertexGroupElement_path(const PointerRNA *ptr)
|
|||
|
||||
static char *rna_MeshPolygon_path(const PointerRNA *ptr)
|
||||
{
|
||||
return BLI_sprintfN("polygons[%d]", rna_MeshPolygon_index_get((PointerRNA *)ptr));
|
||||
return BLI_sprintfN("polygons[%d]", rna_MeshPolygon_index_get(const_cast<PointerRNA *>(ptr)));
|
||||
}
|
||||
|
||||
static char *rna_MeshLoopTriangle_path(const PointerRNA *ptr)
|
||||
{
|
||||
return BLI_sprintfN(
|
||||
"loop_triangles[%d]",
|
||||
(int)((MLoopTri *)ptr->data - BKE_mesh_runtime_looptri_ensure(rna_mesh(ptr))));
|
||||
const int index = rna_MeshLoopTriangle_index_get(const_cast<PointerRNA *>(ptr));
|
||||
return BLI_sprintfN("loop_triangles[%d]", index);
|
||||
}
|
||||
|
||||
static char *rna_MeshEdge_path(const PointerRNA *ptr)
|
||||
{
|
||||
return BLI_sprintfN("edges[%d]", rna_MeshEdge_index_get((PointerRNA *)ptr));
|
||||
return BLI_sprintfN("edges[%d]", rna_MeshEdge_index_get(const_cast<PointerRNA *>(ptr)));
|
||||
}
|
||||
|
||||
static char *rna_MeshLoop_path(const PointerRNA *ptr)
|
||||
{
|
||||
return BLI_sprintfN("loops[%d]", rna_MeshLoop_index_get((PointerRNA *)ptr));
|
||||
return BLI_sprintfN("loops[%d]", rna_MeshLoop_index_get(const_cast<PointerRNA *>(ptr)));
|
||||
}
|
||||
|
||||
static char *rna_MeshVertex_path(const PointerRNA *ptr)
|
||||
{
|
||||
return BLI_sprintfN("vertices[%d]", rna_MeshVertex_index_get((PointerRNA *)ptr));
|
||||
return BLI_sprintfN("vertices[%d]", rna_MeshVertex_index_get(const_cast<PointerRNA *>(ptr)));
|
||||
}
|
||||
|
||||
static char *rna_VertCustomData_data_path(const PointerRNA *ptr, const char *collection, int type)
|
||||
|
@ -1577,9 +1574,9 @@ static void rna_Mesh_edges_begin(CollectionPropertyIterator *iter, PointerRNA *p
|
|||
{
|
||||
using namespace blender;
|
||||
Mesh *mesh = rna_mesh(ptr);
|
||||
int2 *edges = static_cast<int2 *>(CustomData_get_layer_named_for_write(
|
||||
blender::int2 *edges = static_cast<blender::int2 *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->edata, CD_PROP_INT32_2D, ".edge_verts", mesh->totedge));
|
||||
rna_iterator_array_begin(iter, edges, sizeof(int2), mesh->totedge, false, nullptr);
|
||||
rna_iterator_array_begin(iter, edges, sizeof(blender::int2), mesh->totedge, false, nullptr);
|
||||
}
|
||||
static int rna_Mesh_edges_length(PointerRNA *ptr)
|
||||
{
|
||||
|
@ -1593,7 +1590,7 @@ int rna_Mesh_edges_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
|
|||
if (index < 0 || index >= mesh->totedge) {
|
||||
return false;
|
||||
}
|
||||
int2 *edges = static_cast<int2 *>(CustomData_get_layer_named_for_write(
|
||||
blender::int2 *edges = static_cast<blender::int2 *>(CustomData_get_layer_named_for_write(
|
||||
&mesh->edata, CD_PROP_INT32_2D, ".edge_verts", mesh->totedge));
|
||||
r_ptr->owner_id = &mesh->id;
|
||||
r_ptr->type = &RNA_MeshEdge;
|
||||
|
@ -1651,8 +1648,12 @@ static void rna_Mesh_vertex_normals_begin(CollectionPropertyIterator *iter, Poin
|
|||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const blender::Span<blender::float3> normals = mesh->vert_normals();
|
||||
rna_iterator_array_begin(
|
||||
iter, (void *)normals.data(), sizeof(blender::float3), mesh->totvert, false, nullptr);
|
||||
rna_iterator_array_begin(iter,
|
||||
const_cast<blender::float3 *>(normals.data()),
|
||||
sizeof(blender::float3),
|
||||
normals.size(),
|
||||
false,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
static int rna_Mesh_vertex_normals_length(PointerRNA *ptr)
|
||||
|
@ -1670,7 +1671,7 @@ int rna_Mesh_vertex_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r
|
|||
/* Casting away const is okay because this RNA type doesn't allow changing the value. */
|
||||
r_ptr->owner_id = (ID *)&mesh->id;
|
||||
r_ptr->type = &RNA_MeshNormalValue;
|
||||
r_ptr->data = (float *)&mesh->vert_normals()[index];
|
||||
r_ptr->data = const_cast<blender::float3 *>(&mesh->vert_normals()[index]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1678,8 +1679,12 @@ static void rna_Mesh_poly_normals_begin(CollectionPropertyIterator *iter, Pointe
|
|||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const blender::Span<blender::float3> normals = mesh->poly_normals();
|
||||
rna_iterator_array_begin(
|
||||
iter, (void *)normals.data(), sizeof(blender::float3), mesh->totpoly, false, nullptr);
|
||||
rna_iterator_array_begin(iter,
|
||||
const_cast<blender::float3 *>(normals.data()),
|
||||
sizeof(blender::float3),
|
||||
normals.size(),
|
||||
false,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
static int rna_Mesh_poly_normals_length(PointerRNA *ptr)
|
||||
|
@ -1697,20 +1702,25 @@ int rna_Mesh_poly_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_p
|
|||
/* Casting away const is okay because this RNA type doesn't allow changing the value. */
|
||||
r_ptr->owner_id = (ID *)&mesh->id;
|
||||
r_ptr->type = &RNA_MeshNormalValue;
|
||||
r_ptr->data = (float *)&mesh->poly_normals()[index];
|
||||
r_ptr->data = const_cast<blender::float3 *>(&mesh->poly_normals()[index]);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void rna_Mesh_corner_normals_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const float(*normals)[3] = static_cast<const float(*)[3]>(
|
||||
const blender::float3 *normals = static_cast<const blender::float3 *>(
|
||||
CustomData_get_layer(&mesh->ldata, CD_NORMAL));
|
||||
if (!normals) {
|
||||
iter->valid = false;
|
||||
return;
|
||||
}
|
||||
rna_iterator_array_begin(iter, (void *)normals, sizeof(float[3]), mesh->totloop, false, nullptr);
|
||||
rna_iterator_array_begin(iter,
|
||||
const_cast<blender::float3 *>(normals),
|
||||
sizeof(float[3]),
|
||||
mesh->totloop,
|
||||
false,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
static int rna_Mesh_corner_normals_length(PointerRNA *ptr)
|
||||
|
@ -1725,7 +1735,7 @@ static int rna_Mesh_corner_normals_length(PointerRNA *ptr)
|
|||
int rna_Mesh_corner_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const float(*normals)[3] = static_cast<const float(*)[3]>(
|
||||
const blender::float3 *normals = static_cast<const blender::float3 *>(
|
||||
CustomData_get_layer(&mesh->ldata, CD_NORMAL));
|
||||
if (index < 0 || index >= mesh->totloop || !normals) {
|
||||
return false;
|
||||
|
@ -1733,7 +1743,7 @@ int rna_Mesh_corner_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r
|
|||
/* Casting away const is okay because this RNA type doesn't allow changing the value. */
|
||||
r_ptr->owner_id = (ID *)&mesh->id;
|
||||
r_ptr->type = &RNA_MeshNormalValue;
|
||||
r_ptr->data = (float *)normals[index];
|
||||
r_ptr->data = const_cast<blender::float3 *>(&normals[index]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1754,13 +1764,13 @@ static bool get_uv_index_and_layer(const PointerRNA *ptr,
|
|||
int *r_index_in_attribute)
|
||||
{
|
||||
const Mesh *mesh = rna_mesh(ptr);
|
||||
const float(*uv_coord)[2] = (const float(*)[2])ptr->data;
|
||||
const blender::float2 *uv_coord = static_cast<const blender::float2 *>(ptr->data);
|
||||
|
||||
/* We don't know from which attribute the RNA pointer is from, so we need to scan them all. */
|
||||
const int uv_layers_num = CustomData_number_of_layers(&mesh->ldata, CD_PROP_FLOAT2);
|
||||
for (int layer_i = 0; layer_i < uv_layers_num; layer_i++) {
|
||||
const float(*layer_data)[2] = (const float(*)[2])CustomData_get_layer_n(
|
||||
&mesh->ldata, CD_PROP_FLOAT2, layer_i);
|
||||
const blender::float2 *layer_data = static_cast<const blender::float2 *>(
|
||||
CustomData_get_layer_n(&mesh->ldata, CD_PROP_FLOAT2, layer_i));
|
||||
const ptrdiff_t index = uv_coord - layer_data;
|
||||
if (index >= 0 && index < mesh->totloop) {
|
||||
*r_uv_map_index = layer_i;
|
||||
|
|
|
@ -89,7 +89,7 @@ static void rna_Mesh_free_tangents(Mesh *mesh)
|
|||
|
||||
static void rna_Mesh_calc_looptri(Mesh *mesh)
|
||||
{
|
||||
BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
mesh->looptris();
|
||||
}
|
||||
|
||||
static void rna_Mesh_calc_smooth_groups(
|
||||
|
|
|
@ -53,6 +53,7 @@ class TextureMarginMap {
|
|||
Vector<uint32_t> pixel_data_;
|
||||
ZSpan zspan_;
|
||||
uint32_t value_to_store_;
|
||||
bool write_mask_;
|
||||
char *mask_;
|
||||
|
||||
OffsetIndices<int> polys_;
|
||||
|
@ -105,12 +106,13 @@ class TextureMarginMap {
|
|||
return pixel_data_[y * w_ + x];
|
||||
}
|
||||
|
||||
void rasterize_tri(float *v1, float *v2, float *v3, uint32_t value, char *mask)
|
||||
void rasterize_tri(float *v1, float *v2, float *v3, uint32_t value, char *mask, bool writemask)
|
||||
{
|
||||
/* NOTE: This is not thread safe, because the value to be written by the rasterizer is
|
||||
* a class member. If this is ever made multi-threaded each thread needs to get its own. */
|
||||
value_to_store_ = value;
|
||||
mask_ = mask;
|
||||
write_mask_ = writemask;
|
||||
zspan_scanconvert(
|
||||
&zspan_, this, &(v1[0]), &(v2[0]), &(v3[0]), TextureMarginMap::zscan_store_pixel);
|
||||
}
|
||||
|
@ -120,10 +122,23 @@ class TextureMarginMap {
|
|||
{
|
||||
/* NOTE: Not thread safe, see comment above. */
|
||||
TextureMarginMap *m = static_cast<TextureMarginMap *>(map);
|
||||
m->set_pixel(x, y, m->value_to_store_);
|
||||
if (m->mask_) {
|
||||
m->mask_[y * m->w_ + x] = 1;
|
||||
if (m->write_mask_) {
|
||||
/* if there is a mask and write_mask_ is true, write to the mask */
|
||||
m->mask_[y * m->w_ + x] = 1;
|
||||
m->set_pixel(x, y, m->value_to_store_);
|
||||
} else {
|
||||
/* if there is a mask and write_mask_ is false, read the mask
|
||||
* to decide if the map needs to be written
|
||||
*/
|
||||
if (m->mask_[y*m->w_ + x] != 0 ) {
|
||||
m->set_pixel(x, y, m->value_to_store_);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m->set_pixel(x, y, m->value_to_store_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* The map contains 2 kinds of pixels: DijkstraPixels and polygon indices. The top bit determines
|
||||
|
@ -518,7 +533,7 @@ static void generate_margin(ImBuf *ibuf,
|
|||
/* NOTE: we need the top bit for the dijkstra distance map. */
|
||||
BLI_assert(looptri_polys[i] < 0x80000000);
|
||||
|
||||
map.rasterize_tri(vec[0], vec[1], vec[2], looptri_polys[i], draw_new_mask ? mask : nullptr);
|
||||
map.rasterize_tri(vec[0], vec[1], vec[2], looptri_polys[i], mask, draw_new_mask);
|
||||
}
|
||||
|
||||
char *tmpmask = (char *)MEM_dupallocN(mask);
|
||||
|
|
Loading…
Reference in New Issue