MacOS: Enable support for EDR rendering #105662

Merged
Brecht Van Lommel merged 26 commits from Jason-Fielder/blender:macos_EDR_support into main 2023-08-09 14:25:23 +02:00
108 changed files with 2529 additions and 1816 deletions
Showing only changes of commit 0ec202033f - Show all commits

View File

@ -149,7 +149,11 @@ void BlenderSync::sync_light(BL::Object &b_parent,
light->set_is_shadow_catcher(b_ob_info.real_object.is_shadow_catcher());
/* Light group and linking. */
light->set_lightgroup(ustring(b_ob_info.real_object.lightgroup()));
string lightgroup = b_ob_info.real_object.lightgroup();
if (lightgroup.empty()) {
lightgroup = b_parent.lightgroup();
}
light->set_lightgroup(ustring(lightgroup));
light->set_light_set_membership(
BlenderLightLink::get_light_set_membership(PointerRNA_NULL, b_ob_info.real_object));
light->set_shadow_set_membership(

View File

@ -350,7 +350,11 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
}
/* Light group and linking. */
object->set_lightgroup(ustring(b_ob.lightgroup()));
string lightgroup = b_ob.lightgroup();
if (lightgroup.empty()) {
lightgroup = b_parent.lightgroup();
}
object->set_lightgroup(ustring(lightgroup));
object->set_light_set_membership(BlenderLightLink::get_light_set_membership(b_parent, b_ob));
object->set_receiver_light_set(BlenderLightLink::get_receiver_light_set(b_parent, b_ob));

View File

@ -931,6 +931,8 @@ def km_user_interface(_params):
("ui.reset_default_button", {"type": 'BACK_SPACE', "value": 'PRESS'}, {"properties": [("all", True)]}),
# UI lists (polls check if there's a UI list under the cursor).
("ui.list_start_filter", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
# UI views (polls check if there's a UI view under the cursor).
("ui.view_start_filter", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
])
return keymap
@ -4508,6 +4510,11 @@ def km_grease_pencil_edit(params):
items.extend([
*_template_items_select_actions(params, "grease_pencil.select_all"),
# Select linked
("grease_pencil.select_linked", {"type": 'L', "value": 'PRESS'}, None),
("grease_pencil.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
("grease_pencil.select_more", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "ctrl": True, "repeat": True}, None),
("grease_pencil.select_less", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True, "repeat": True}, None),
])
return keymap

View File

@ -2030,6 +2030,13 @@ class VIEW3D_MT_select_edit_gpencil(Menu):
layout.separator()
layout.operator("grease_pencil.select_linked", text="Linked")
layout.separator()
layout.operator("grease_pencil.select_more")
layout.operator("grease_pencil.select_less")
class VIEW3D_MT_select_paint_mask(Menu):
bl_label = "Select"

View File

@ -9,7 +9,9 @@
#include "BLI_cpp_type.hh"
#include "BLI_generic_span.hh"
#include "BLI_generic_virtual_array.hh"
#include "BLI_math_axis_angle.hh"
#include "BLI_math_color.hh"
#include "BLI_math_quaternion.hh"
#include "BLI_math_vector.h"
#include "BLI_math_vector.hh"
@ -31,7 +33,8 @@ inline void convert_to_static_type(const CPPType &cpp_type, const Func &func)
bool,
int8_t,
ColorGeometry4f,
ColorGeometry4b>([&](auto type_tag) {
ColorGeometry4b,
math::Quaternion>([&](auto type_tag) {
using T = typename decltype(type_tag)::type;
if constexpr (std::is_same_v<T, void>) {
/* It's expected that the given cpp type is one of the supported ones. */
@ -400,7 +403,10 @@ class BooleanPropagationMixer {
* This mixer accumulates values in a type that is different from the one that is mixed.
* Some types cannot encode the floating point weights in their values (e.g. int and bool).
*/
template<typename T, typename AccumulationT, T (*ConvertToT)(const AccumulationT &value)>
template<typename T,
typename AccumulationT,
AccumulationT (*ValueToAccumulate)(const T &value),
T (*AccumulateToValue)(const AccumulationT &value)>
class SimpleMixerWithAccumulationType {
private:
struct Item {
@ -432,7 +438,7 @@ class SimpleMixerWithAccumulationType {
void set(const int64_t index, const T &value, const float weight = 1.0f)
{
const AccumulationT converted_value = static_cast<AccumulationT>(value);
const AccumulationT converted_value = ValueToAccumulate(value);
Item &item = accumulation_buffer_[index];
item.value = converted_value * weight;
item.weight = weight;
@ -440,7 +446,7 @@ class SimpleMixerWithAccumulationType {
void mix_in(const int64_t index, const T &value, const float weight = 1.0f)
{
const AccumulationT converted_value = static_cast<AccumulationT>(value);
const AccumulationT converted_value = ValueToAccumulate(value);
Item &item = accumulation_buffer_[index];
item.value += converted_value * weight;
item.weight += weight;
@ -457,7 +463,7 @@ class SimpleMixerWithAccumulationType {
const Item &item = accumulation_buffer_[i];
if (item.weight > 0.0f) {
const float weight_inv = 1.0f / item.weight;
const T converted_value = ConvertToT(item.value * weight_inv);
const T converted_value = AccumulateToValue(item.value * weight_inv);
buffer_[i] = converted_value;
}
else {
@ -532,40 +538,68 @@ template<> struct DefaultMixerStruct<ColorGeometry4b> {
using type = ColorGeometry4bMixer;
};
template<> struct DefaultMixerStruct<int> {
static double int_to_double(const int &value)
{
return double(value);
}
static int double_to_int(const double &value)
{
return int(std::round(value));
}
/* Store interpolated ints in a double temporarily, so that weights are handled correctly. It
* uses double instead of float so that it is accurate for all 32 bit integers. */
using type = SimpleMixerWithAccumulationType<int, double, double_to_int>;
using type = SimpleMixerWithAccumulationType<int, double, int_to_double, double_to_int>;
};
template<> struct DefaultMixerStruct<int2> {
static double2 int_to_double(const int2 &value)
{
return double2(value);
}
static int2 double_to_int(const double2 &value)
{
return int2(math::round(value));
}
/* Store interpolated ints in a double temporarily, so that weights are handled correctly. It
* uses double instead of float so that it is accurate for all 32 bit integers. */
using type = SimpleMixerWithAccumulationType<int2, double2, double_to_int>;
using type = SimpleMixerWithAccumulationType<int2, double2, int_to_double, double_to_int>;
};
template<> struct DefaultMixerStruct<bool> {
static float bool_to_float(const bool &value)
{
return value ? 1.0f : 0.0f;
}
static bool float_to_bool(const float &value)
{
return value >= 0.5f;
}
/* Store interpolated booleans in a float temporary.
* Otherwise information provided by weights is easily rounded away. */
using type = SimpleMixerWithAccumulationType<bool, float, float_to_bool>;
using type = SimpleMixerWithAccumulationType<bool, float, bool_to_float, float_to_bool>;
};
template<> struct DefaultMixerStruct<int8_t> {
static float int8_t_to_float(const int8_t &value)
{
return float(value);
}
static int8_t float_to_int8_t(const float &value)
{
return int8_t(std::round(value));
}
/* Store interpolated 8 bit integers in a float temporarily to increase accuracy. */
using type = SimpleMixerWithAccumulationType<int8_t, float, float_to_int8_t>;
using type = SimpleMixerWithAccumulationType<int8_t, float, int8_t_to_float, float_to_int8_t>;
};
template<> struct DefaultMixerStruct<math::Quaternion> {
static float3 quat_to_expmap(const math::Quaternion &value)
{
return value.expmap();
}
static math::Quaternion expmap_to_quat(const float3 &value)
{
return math::Quaternion::expmap(value);
}
using type =
SimpleMixerWithAccumulationType<math::Quaternion, float3, quat_to_expmap, expmap_to_quat>;
};
template<typename T> struct DefaultPropagationMixerStruct {

View File

@ -612,8 +612,8 @@ int CustomData_layertype_layers_max(eCustomDataType type);
#ifdef __cplusplus
/** \return The maximum length for a layer name with the given prefix. */
int CustomData_name_max_length_calc(blender::StringRef name);
/** \return The maximum size in bytes needed for a layer name with the given prefix. */
int CustomData_name_maxncpy_calc(blender::StringRef name);
#endif

View File

@ -59,11 +59,6 @@ void texttool_suggest_select(SuggItem *sel);
SuggItem *texttool_suggest_selected(void);
int *texttool_suggest_top(void);
/* Documentation */
void texttool_docs_show(const char *docs);
char *texttool_docs_get(void);
void texttool_docs_clear(void);
#ifdef __cplusplus
}
#endif

View File

@ -74,7 +74,7 @@ static void pchan_deform_accumulate(const DualQuat *deform_dq,
mdq.trans[1] += .5f * (mdq.quat[0] * dst[0] + mdq.quat[2] * dst[2] - mdq.quat[3] * dst[1]);
mdq.trans[2] += .5f * (mdq.quat[0] * dst[1] + mdq.quat[3] * dst[0] - mdq.quat[1] * dst[2]);
mdq.trans[3] += .5f * (mdq.quat[0] * dst[2] + mdq.quat[1] * dst[1] - mdq.quat[2] * dst[0]);
mdq.scale_weight = 0.f;
mdq.scale_weight = 0.0f;
add_weighted_dq_dq(dq_accum, &mdq, weight);
}
else {

View File

@ -174,7 +174,7 @@ bool BKE_id_attribute_rename(ID *id,
* is clamped to it's maximum length, otherwise assigning an over-long name multiple times
* will add `.001` suffix unnecessarily. */
{
const int new_name_maxncpy = CustomData_name_max_length_calc(new_name);
const int new_name_maxncpy = CustomData_name_maxncpy_calc(new_name);
/* NOTE: A function that performs a clamped comparison without copying would be handy here. */
char new_name_clamped[MAX_CUSTOMDATA_LAYER_NAME];
BLI_strncpy_utf8(new_name_clamped, new_name, new_name_maxncpy);
@ -255,7 +255,7 @@ static bool unique_name_cb(void *arg, const char *name)
bool BKE_id_attribute_calc_unique_name(ID *id, const char *name, char *outname)
{
AttrUniqueData data{id};
const int name_maxncpy = CustomData_name_max_length_calc(name);
const int name_maxncpy = CustomData_name_maxncpy_calc(name);
/* Set default name if none specified.
* NOTE: We only call IFACE_() if needed to avoid locale lookup overhead. */

View File

@ -107,11 +107,13 @@ static int attribute_data_type_complexity(const eCustomDataType data_type)
return 6;
case CD_PROP_BYTE_COLOR:
return 7;
case CD_PROP_COLOR:
case CD_PROP_QUATERNION:
return 8;
case CD_PROP_COLOR:
return 9;
#if 0 /* These attribute types are not supported yet. */
case CD_PROP_STRING:
return 9;
return 10;
#endif
default:
/* Only accept "generic" custom data types used by the attribute system. */

View File

@ -3,11 +3,39 @@
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "BLI_array_utils.hh"
#include "BLI_math_quaternion.hh"
#include "BKE_attribute_math.hh"
namespace blender::bke::attribute_math {
template<>
math::Quaternion mix2(const float factor, const math::Quaternion &a, const math::Quaternion &b)
{
return math::interpolate(a, b, factor);
}
template<>
math::Quaternion mix3(const float3 &weights,
const math::Quaternion &v0,
const math::Quaternion &v1,
const math::Quaternion &v2)
{
const float3 expmap_mixed = mix3(weights, v0.expmap(), v1.expmap(), v2.expmap());
return math::Quaternion::expmap(expmap_mixed);
}
template<>
math::Quaternion mix4(const float4 &weights,
const math::Quaternion &v0,
const math::Quaternion &v1,
const math::Quaternion &v2,
const math::Quaternion &v3)
{
const float3 expmap_mixed = mix4(weights, v0.expmap(), v1.expmap(), v2.expmap(), v3.expmap());
return math::Quaternion::expmap(expmap_mixed);
}
ColorGeometry4fMixer::ColorGeometry4fMixer(MutableSpan<ColorGeometry4f> buffer,
ColorGeometry4f default_color)
: ColorGeometry4fMixer(buffer, buffer.index_range(), default_color)

View File

@ -24,6 +24,7 @@
#include "BLI_index_range.hh"
#include "BLI_math.h"
#include "BLI_math_color_blend.h"
#include "BLI_math_quaternion_types.hh"
#include "BLI_math_vector.hh"
#include "BLI_mempool.h"
#include "BLI_path_util.h"
@ -1933,6 +1934,8 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr},
/* 51: CD_HAIRLENGTH */
{sizeof(float), "float", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},
/* 52: CD_PROP_QUATERNION */
{sizeof(float[4]), "vec4f", 1, N_("Quaternion"), nullptr, nullptr, nullptr, nullptr, nullptr},
};
static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
@ -4353,7 +4356,7 @@ static bool customdata_unique_check(void *arg, const char *name)
return cd_layer_find_dupe(data_arg->data, name, data_arg->type, data_arg->index);
}
int CustomData_name_max_length_calc(const blender::StringRef name)
int CustomData_name_maxncpy_calc(const blender::StringRef name)
{
if (name.startswith(".")) {
return MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX;
@ -4379,7 +4382,7 @@ void CustomData_set_layer_unique_name(CustomData *data, const int index)
return;
}
const int max_length = CustomData_name_max_length_calc(nlayer->name);
const int name_maxncpy = CustomData_name_maxncpy_calc(nlayer->name);
/* Set default name if none specified. Note we only call DATA_() when
* needed to avoid overhead of locale lookups in the depsgraph. */
@ -4388,7 +4391,7 @@ void CustomData_set_layer_unique_name(CustomData *data, const int index)
}
const char *defname = ""; /* Dummy argument, never used as `name` is never zero length. */
BLI_uniquename_cb(customdata_unique_check, &data_arg, defname, '.', nlayer->name, max_length);
BLI_uniquename_cb(customdata_unique_check, &data_arg, defname, '.', nlayer->name, name_maxncpy);
}
void CustomData_validate_layer_name(const CustomData *data,
@ -5354,6 +5357,8 @@ const blender::CPPType *custom_data_type_to_cpp_type(const eCustomDataType type)
return &CPPType::get<int8_t>();
case CD_PROP_BYTE_COLOR:
return &CPPType::get<ColorGeometry4b>();
case CD_PROP_QUATERNION:
return &CPPType::get<math::Quaternion>();
case CD_PROP_STRING:
return &CPPType::get<MStringProperty>();
default:
@ -5390,6 +5395,9 @@ eCustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type)
if (type.is<ColorGeometry4b>()) {
return CD_PROP_BYTE_COLOR;
}
if (type.is<math::Quaternion>()) {
return CD_PROP_QUATERNION;
}
if (type.is<MStringProperty>()) {
return CD_PROP_STRING;
}

View File

@ -675,8 +675,8 @@ static void grid_cell_points_cb_ex(void *__restrict userdata,
int co[3];
for (int j = 3; j--;) {
co[j] = (int)floorf((bData->realCoord[bData->s_pos[i]].v[j] - grid->grid_bounds.min[j]) /
bData->dim[j] * grid->dim[j]);
co[j] = int(floorf((bData->realCoord[bData->s_pos[i]].v[j] - grid->grid_bounds.min[j]) /
bData->dim[j] * grid->dim[j]));
CLAMP(co[j], 0, grid->dim[j] - 1);
}

View File

@ -661,6 +661,26 @@ static int customdata_compare(
}
break;
}
case CD_PROP_QUATERNION: {
const float(*l1_data)[4] = (float(*)[4])l1->data;
const float(*l2_data)[4] = (float(*)[4])l2->data;
for (int i = 0; i < total_length; i++) {
if (compare_threshold_relative(l1_data[i][0], l2_data[i][0], thresh)) {
return MESHCMP_ATTRIBUTE_VALUE_MISMATCH;
}
if (compare_threshold_relative(l1_data[i][1], l2_data[i][1], thresh)) {
return MESHCMP_ATTRIBUTE_VALUE_MISMATCH;
}
if (compare_threshold_relative(l1_data[i][2], l2_data[i][2], thresh)) {
return MESHCMP_ATTRIBUTE_VALUE_MISMATCH;
}
if (compare_threshold_relative(l1_data[i][3], l2_data[i][3], thresh)) {
return MESHCMP_ATTRIBUTE_VALUE_MISMATCH;
}
}
break;
}
case CD_PROP_INT32: {
const int *l1_data = (int *)l1->data;
const int *l2_data = (int *)l2->data;

View File

@ -18,6 +18,7 @@
#include "BLI_endian_switch.h"
#include "BLI_fileops.hh"
#include "BLI_math_matrix_types.hh"
#include "BLI_math_quaternion_types.hh"
#include "BLI_path_util.h"
#include "RNA_access.h"
@ -778,6 +779,10 @@ static std::shared_ptr<io::serialize::Value> serialize_primitive_value(
const ColorGeometry4f value = *static_cast<const ColorGeometry4f *>(value_ptr);
return serialize_float_array({&value.r, 4});
}
case CD_PROP_QUATERNION: {
const math::Quaternion value = *static_cast<const math::Quaternion *>(value_ptr);
return serialize_float_array({&value.x, 4});
}
default:
break;
}
@ -966,6 +971,9 @@ template<typename T>
case CD_PROP_COLOR: {
return deserialize_float_array(io_value, {static_cast<float *>(r_value), 4});
}
case CD_PROP_QUATERNION: {
return deserialize_float_array(io_value, {static_cast<float *>(r_value), 4});
}
default:
break;
}

View File

@ -207,42 +207,3 @@ int *texttool_suggest_top(void)
{
return &suggestions.top;
}
/*************************/
/* Documentation methods */
/*************************/
void texttool_docs_show(const char *docs)
{
int len;
if (!docs) {
return;
}
len = strlen(docs);
MEM_SAFE_FREE(documentation);
/* Ensure documentation ends with a '\n' */
if (docs[len - 1] != '\n') {
documentation = MEM_mallocN(len + 2, "Documentation");
memcpy(documentation, docs, len);
documentation[len++] = '\n';
}
else {
documentation = MEM_mallocN(len + 1, "Documentation");
memcpy(documentation, docs, len);
}
documentation[len] = '\0';
}
char *texttool_docs_get(void)
{
return documentation;
}
void texttool_docs_clear(void)
{
txttl_free_docs();
}

View File

@ -11,6 +11,7 @@
#include "BLI_index_mask.hh"
#include "BLI_math_base.hh"
#include "BLI_math_color.hh"
#include "BLI_math_quaternion.hh"
#include "BLI_math_vector.hh"
namespace blender::length_parameterize {

View File

@ -32,7 +32,7 @@ template<typename T> class OffsetIndices {
OffsetIndices() = default;
OffsetIndices(const Span<T> offsets) : offsets_(offsets)
{
BLI_assert(std::is_sorted(offsets_.begin(), offsets_.end()));
BLI_assert(offsets_.size() < 2 || std::is_sorted(offsets_.begin(), offsets_.end()));
}
/** Return the total number of elements in the referenced arrays. */

View File

@ -89,7 +89,7 @@ size_t BLI_string_flip_side_name(char *name_dst,
* \param defname: To initialize name if latter is empty
* \param delim: Delimits numeric suffix in name
* \param name: Name to be ensured unique
* \param name_len: Maximum length of name area
* \param name_maxncpy: Maximum length of name area
* \return true if there if the name was changed
*/
bool BLI_uniquename_cb(UniquenameCheckCallback unique_check,
@ -97,7 +97,7 @@ bool BLI_uniquename_cb(UniquenameCheckCallback unique_check,
const char *defname,
char delim,
char *name,
size_t name_len) ATTR_NONNULL(1, 3, 5);
size_t name_maxncpy) ATTR_NONNULL(1, 3, 5);
/**
* Ensures that the specified block has a unique name within the containing list,
* incrementing its numeric suffix as necessary. Returns true if name had to be adjusted.
@ -107,14 +107,14 @@ bool BLI_uniquename_cb(UniquenameCheckCallback unique_check,
* \param defname: To initialize block name if latter is empty
* \param delim: Delimits numeric suffix in name
* \param name_offset: Offset of name within block structure
* \param name_len: Maximum length of name area
* \param name_maxncpy: Maximum length of name area
*/
bool BLI_uniquename(struct ListBase *list,
void *vlink,
const char *defname,
char delim,
int name_offset,
size_t name_len) ATTR_NONNULL(1, 3);
size_t name_maxncpy) ATTR_NONNULL(1, 3);
/* Expand array functions. */

View File

@ -6,6 +6,7 @@
#include "BLI_cpp_type_make.hh"
#include "BLI_cpp_types_make.hh"
#include "BLI_math_matrix_types.hh"
#include "BLI_math_quaternion_types.hh"
#include "BLI_math_vector_types.hh"
namespace blender {
@ -65,6 +66,8 @@ BLI_CPP_TYPE_MAKE(uint64_t, CPPTypeFlags::BasicType)
BLI_CPP_TYPE_MAKE(blender::ColorGeometry4f, CPPTypeFlags::BasicType)
BLI_CPP_TYPE_MAKE(blender::ColorGeometry4b, CPPTypeFlags::BasicType)
BLI_CPP_TYPE_MAKE(blender::math::Quaternion, CPPTypeFlags::BasicType)
BLI_CPP_TYPE_MAKE(std::string, CPPTypeFlags::BasicType)
BLI_VECTOR_CPP_TYPE_MAKE(std::string)
@ -94,6 +97,8 @@ void register_cpp_types()
BLI_CPP_TYPE_REGISTER(blender::ColorGeometry4f);
BLI_CPP_TYPE_REGISTER(blender::ColorGeometry4b);
BLI_CPP_TYPE_REGISTER(math::Quaternion);
BLI_CPP_TYPE_REGISTER(std::string);
BLI_VECTOR_CPP_TYPE_REGISTER(std::string);

View File

@ -4422,7 +4422,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
}
if (!MAIN_VERSION_ATLEAST(bmain, 306, 11)) {
BKE_animdata_main_cb(bmain, version_liboverride_nla_frame_start_end, NULL);
BKE_animdata_main_cb(bmain, version_liboverride_nla_frame_start_end, nullptr);
/* Store simulation bake directory in geometry nodes modifier. */
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {

View File

@ -1365,46 +1365,49 @@ static bool write_file_handle(Main *mainvar,
return mywrite_end(wd);
}
/* do reverse file history: .blend1 -> .blend2, .blend -> .blend1 */
/* return: success(0), failure(1) */
static bool do_history(const char *name, ReportList *reports)
/**
* Do reverse file history: `.blend1` -> `.blend2`, `.blend` -> `.blend1` ... etc.
* \return True on success.
*/
static bool do_history(const char *filepath, ReportList *reports)
{
char tempname1[FILE_MAX], tempname2[FILE_MAX];
int hisnr = U.versions;
/* Add 2 because version number maximum is double-digits. */
char filepath_tmp1[FILE_MAX + 2], filepath_tmp2[FILE_MAX + 2];
int version_number = min_ii(99, U.versions);
if (U.versions == 0) {
return false;
}
if (strlen(name) < 2) {
BKE_report(reports, RPT_ERROR, "Unable to make version backup: filename too short");
if (version_number == 0) {
return true;
}
while (hisnr > 1) {
SNPRINTF(tempname1, "%s%d", name, hisnr - 1);
if (BLI_exists(tempname1)) {
SNPRINTF(tempname2, "%s%d", name, hisnr);
if (strlen(filepath) < 2) {
BKE_report(reports, RPT_ERROR, "Unable to make version backup: filename too short");
return false;
}
if (BLI_rename_overwrite(tempname1, tempname2)) {
while (version_number > 1) {
SNPRINTF(filepath_tmp1, "%s%d", filepath, version_number - 1);
if (BLI_exists(filepath_tmp1)) {
SNPRINTF(filepath_tmp2, "%s%d", filepath, version_number);
if (BLI_rename_overwrite(filepath_tmp1, filepath_tmp2)) {
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
return true;
return false;
}
}
hisnr--;
version_number--;
}
/* is needed when hisnr==1 */
if (BLI_exists(name)) {
SNPRINTF(tempname1, "%s%d", name, hisnr);
/* Needed when `version_number == 1`. */
if (BLI_exists(filepath)) {
SNPRINTF(filepath_tmp1, "%s%d", filepath, version_number);
if (BLI_rename_overwrite(name, tempname1)) {
if (BLI_rename_overwrite(filepath, filepath_tmp1)) {
BKE_report(reports, RPT_ERROR, "Unable to make version backup");
return true;
return false;
}
}
return false;
return true;
}
/** \} */
@ -1558,8 +1561,7 @@ bool BLO_write_file(Main *mainvar,
/* file save to temporary file was successful */
/* now do reverse file history (move .blend1 -> .blend2, .blend -> .blend1) */
if (use_save_versions) {
const bool err_hist = do_history(filepath, reports);
if (err_hist) {
if (!do_history(filepath, reports)) {
BKE_report(reports, RPT_ERROR, "Version backup failed (file saved with @)");
return false;
}

View File

@ -348,7 +348,7 @@ static bool mdisp_in_mdispquad(BMLoop *l_src,
return 0;
}
mul_v2_fl(r_uv, (float)(res - 1));
mul_v2_fl(r_uv, float(res - 1));
mdisp_axis_from_quad(v1, v2, v3, v4, r_axis_x, r_axis_y);
@ -509,7 +509,7 @@ void BM_loop_interp_multires_ex(BMesh * /*bm*/,
mdisp_axis_from_quad(v1, v2, v3, v4, axis_x, axis_y);
const int res = (int)sqrt(md_dst->totdisp);
const int res = int(sqrt(md_dst->totdisp));
BMLoopInterpMultiresData data = {};
data.l_dst = l_dst;
data.l_src_first = BM_FACE_FIRST_LOOP(f_src);
@ -523,7 +523,7 @@ void BM_loop_interp_multires_ex(BMesh * /*bm*/,
data.e1 = e1;
data.e2 = e2;
data.res = res;
data.d = 1.0f / (float)(res - 1);
data.d = 1.0f / float(res - 1);
TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
@ -609,7 +609,7 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
* </pre>
*/
sides = (int)sqrt(mdp->totdisp);
sides = int(sqrt(mdp->totdisp));
for (y = 0; y < sides; y++) {
mid_v3_v3v3(co1, mdn->disps[y * sides], mdl->disps[y]);
@ -652,7 +652,7 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
BM_ELEM_CD_GET_VOID_P(l->radial_next->next, cd_loop_mdisp_offset));
}
sides = (int)sqrt(mdl1->totdisp);
sides = int(sqrt(mdl1->totdisp));
for (y = 0; y < sides; y++) {
int a1, a2, o1, o2;
@ -1117,7 +1117,7 @@ struct LoopGroupCD {
int data_len;
};
static void bm_loop_walk_add(struct LoopWalkCtx *lwc, BMLoop *l)
static void bm_loop_walk_add(LoopWalkCtx *lwc, BMLoop *l)
{
const int i = BM_elem_index_get(l);
const float w = lwc->loop_weights[i];
@ -1135,7 +1135,7 @@ static void bm_loop_walk_add(struct LoopWalkCtx *lwc, BMLoop *l)
*
* \note called for fan matching so we're pretty much safe not to break the stack
*/
static void bm_loop_walk_data(struct LoopWalkCtx *lwc, BMLoop *l_walk)
static void bm_loop_walk_data(LoopWalkCtx *lwc, BMLoop *l_walk)
{
int i;
@ -1169,7 +1169,7 @@ static void bm_loop_walk_data(struct LoopWalkCtx *lwc, BMLoop *l_walk)
LinkNode *BM_vert_loop_groups_data_layer_create(
BMesh *bm, BMVert *v, const int layer_n, const float *loop_weights, MemArena *arena)
{
struct LoopWalkCtx lwc;
LoopWalkCtx lwc;
LinkNode *groups = nullptr;
BMLoop *l;
BMIter liter;
@ -1196,8 +1196,7 @@ LinkNode *BM_vert_loop_groups_data_layer_create(
BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
if (BM_elem_flag_test(l, BM_ELEM_INTERNAL_TAG)) {
struct LoopGroupCD *lf = static_cast<LoopGroupCD *>(
BLI_memarena_alloc(lwc.arena, sizeof(*lf)));
LoopGroupCD *lf = static_cast<LoopGroupCD *>(BLI_memarena_alloc(lwc.arena, sizeof(*lf)));
int len_prev = lwc.data_len;
lwc.data_ref = BM_ELEM_CD_GET_VOID_P(l, lwc.cd_layer_offset);
@ -1216,7 +1215,7 @@ LinkNode *BM_vert_loop_groups_data_layer_create(
mul_vn_fl(lf->data_weights, lf->data_len, 1.0f / lwc.weight_accum);
}
else {
copy_vn_fl(lf->data_weights, lf->data_len, 1.0f / (float)lf->data_len);
copy_vn_fl(lf->data_weights, lf->data_len, 1.0f / float(lf->data_len));
}
BLI_linklist_prepend_arena(&groups, lf, lwc.arena);
@ -1233,7 +1232,7 @@ static void bm_vert_loop_groups_data_layer_merge__single(BMesh *bm,
int layer_n,
void *data_tmp)
{
struct LoopGroupCD *lf = static_cast<LoopGroupCD *>(lf_p);
LoopGroupCD *lf = static_cast<LoopGroupCD *>(lf_p);
const int type = bm->ldata.layers[layer_n].type;
int i;
const float *data_weights;
@ -1251,7 +1250,7 @@ static void bm_vert_loop_groups_data_layer_merge__single(BMesh *bm,
static void bm_vert_loop_groups_data_layer_merge_weights__single(
BMesh *bm, void *lf_p, const int layer_n, void *data_tmp, const float *loop_weights)
{
struct LoopGroupCD *lf = static_cast<LoopGroupCD *>(lf_p);
LoopGroupCD *lf = static_cast<LoopGroupCD *>(lf_p);
const int type = bm->ldata.layers[layer_n].type;
int i;
const float *data_weights;

View File

@ -32,16 +32,16 @@ class DenoiseFilter {
#ifdef WITH_OPENIMAGEDENOISE
oidn::DeviceRef device_;
oidn::FilterRef filter_;
#endif
bool initialized_ = false;
#endif
public:
#ifdef WITH_OPENIMAGEDENOISE
~DenoiseFilter()
{
BLI_assert(!initialized_);
}
#ifdef WITH_OPENIMAGEDENOISE
void init_and_lock_denoiser(MemoryBuffer *output)
{
/* Since it's memory intensive, it's better to run only one instance of OIDN at a time.

View File

@ -298,3 +298,6 @@ if(WITH_OPENCOLORIO)
endif()
blender_add_lib(bf_realtime_compositor "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
# Needed so we can use dna_type_offsets.h
add_dependencies(bf_realtime_compositor bf_dna)

View File

@ -246,7 +246,7 @@ void output_renderpass_color(int id, vec4 color)
imageStore(rp_color_img, ivec3(texel, id), color);
}
#endif
};
}
void output_renderpass_value(int id, float value)
{
@ -256,7 +256,7 @@ void output_renderpass_value(int id, float value)
imageStore(rp_value_img, ivec3(texel, id), vec4(value));
}
#endif
};
}
void clear_aovs()
{

View File

@ -83,7 +83,7 @@ bool drw_custom_data_match_attribute(const CustomData *custom_data,
int *r_layer_index,
eCustomDataType *r_type)
{
const eCustomDataType possible_attribute_types[9] = {
const eCustomDataType possible_attribute_types[10] = {
CD_PROP_BOOL,
CD_PROP_INT8,
CD_PROP_INT32_2D,
@ -92,6 +92,7 @@ bool drw_custom_data_match_attribute(const CustomData *custom_data,
CD_PROP_FLOAT2,
CD_PROP_FLOAT3,
CD_PROP_COLOR,
CD_PROP_QUATERNION,
CD_PROP_BYTE_COLOR,
};

View File

@ -392,6 +392,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
}
case CD_PROP_BYTE_COLOR:
case CD_PROP_COLOR:
case CD_PROP_QUATERNION:
case CD_PROP_FLOAT3:
case CD_PROP_BOOL:
case CD_PROP_INT8:

View File

@ -107,6 +107,7 @@ static uint gpu_component_size_for_attribute_type(eCustomDataType type)
return 3;
case CD_PROP_COLOR:
case CD_PROP_BYTE_COLOR:
case CD_PROP_QUATERNION:
return 4;
default:
return 0;
@ -315,6 +316,7 @@ static void extract_attr(const MeshRenderData *mr,
case CD_PROP_FLOAT3:
extract_attr_generic<float3>(mr, vbo, request);
break;
case CD_PROP_QUATERNION:
case CD_PROP_COLOR:
extract_attr_generic<float4>(mr, vbo, request);
break;

View File

@ -100,7 +100,7 @@ bool ED_asset_can_mark_single_from_context(const bContext *C)
return ED_asset_type_is_supported(id);
}
bool ED_asset_copy_to_id(const struct AssetMetaData *asset_data, struct ID *destination)
bool ED_asset_copy_to_id(const AssetMetaData *asset_data, ID *destination)
{
if (!BKE_id_can_be_asset(destination)) {
return false;

View File

@ -76,6 +76,102 @@ static void GREASE_PENCIL_OT_select_all(wmOperatorType *ot)
WM_operator_properties_select_all(ot);
}
static int select_more_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [](int /*drawing_index*/, GreasePencilDrawing &drawing) {
// TODO: Support different selection domains.
blender::ed::curves::select_adjacent(drawing.geometry.wrap(), false);
});
/* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
* attribute for now. */
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil);
return OPERATOR_FINISHED;
}
static void GREASE_PENCIL_OT_select_more(wmOperatorType *ot)
{
ot->name = "Select More";
ot->idname = "GREASE_PENCIL_OT_select_more";
ot->description = "Grow the selection by one point";
ot->exec = select_more_exec;
ot->poll = editable_grease_pencil_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int select_less_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [](int /*drawing_index*/, GreasePencilDrawing &drawing) {
// TODO: Support different selection domains.
blender::ed::curves::select_adjacent(drawing.geometry.wrap(), true);
});
/* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
* attribute for now. */
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil);
return OPERATOR_FINISHED;
}
static void GREASE_PENCIL_OT_select_less(wmOperatorType *ot)
{
ot->name = "Select Less";
ot->idname = "GREASE_PENCIL_OT_select_less";
ot->description = "Shrink the selection by one point";
ot->exec = select_less_exec;
ot->poll = editable_grease_pencil_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int select_linked_exec(bContext *C, wmOperator * /*op*/)
{
Scene *scene = CTX_data_scene(C);
Object *object = CTX_data_active_object(C);
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
grease_pencil.foreach_editable_drawing(
scene->r.cfra, [](int /*drawing_index*/, GreasePencilDrawing &drawing) {
// TODO: Support different selection domains.
blender::ed::curves::select_linked(drawing.geometry.wrap());
});
/* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic
* attribute for now. */
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &grease_pencil);
return OPERATOR_FINISHED;
}
static void GREASE_PENCIL_OT_select_linked(wmOperatorType *ot)
{
ot->name = "Select Linked";
ot->idname = "GREASE_PENCIL_OT_select_linked";
ot->description = "Select all points in curves with any point selection";
ot->exec = select_linked_exec;
ot->poll = editable_grease_pencil_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static void keymap_grease_pencil_editing(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Edit Mode", 0, 0);
@ -88,6 +184,9 @@ void ED_operatortypes_grease_pencil(void)
{
using namespace blender::ed::greasepencil;
WM_operatortype_append(GREASE_PENCIL_OT_select_all);
WM_operatortype_append(GREASE_PENCIL_OT_select_more);
WM_operatortype_append(GREASE_PENCIL_OT_select_less);
WM_operatortype_append(GREASE_PENCIL_OT_select_linked);
}
void ED_keymap_grease_pencil(wmKeyConfig *keyconf)

View File

@ -84,6 +84,13 @@ class AbstractView {
/** Listen to a notifier, returning true if a redraw is needed. */
virtual bool listen(const wmNotifier &) const;
/**
* Enable filtering. Typically used to enable a filter text button. Triggered on Ctrl+F by
* default.
* \return True when filtering was enabled successfully.
*/
virtual bool begin_filtering(const bContext &C) const;
/**
* Makes \a item valid for display in this view. Behavior is undefined for items not registered
* with this.
@ -136,6 +143,9 @@ class AbstractViewItem {
bool is_active_ = false;
bool is_renaming_ = false;
/** Cache filtered state here to avoid having to re-query. */
mutable std::optional<bool> is_filtered_visible_;
public:
virtual ~AbstractViewItem() = default;
@ -174,6 +184,10 @@ class AbstractViewItem {
*/
virtual std::unique_ptr<AbstractViewItemDropTarget> create_drop_target();
/** Return the result of #is_filtered_visible(), but ensure the result is cached so it's only
* queried once per redraw. */
bool is_filtered_visible_cached() const;
/** Get the view this item is registered for using #AbstractView::register_item(). */
AbstractView &get_view() const;
@ -217,6 +231,12 @@ class AbstractViewItem {
*/
virtual void update_from_old(const AbstractViewItem &old);
/**
* \note Do not call this directly to avoid constantly rechecking the filter state. Instead use
* #is_filtered_visible_cached() for querying.
*/
virtual bool is_filtered_visible() const;
/**
* Add a text button for renaming the item to \a block. This must be used for the built-in
* renaming to work. This button is meant to appear temporarily. It is removed when renaming is

View File

@ -98,6 +98,8 @@ class AbstractGridView : public AbstractView {
protected:
Vector<std::unique_ptr<AbstractGridViewItem>> items_;
/** Store this to avoid recomputing. */
mutable std::optional<int> item_count_filtered_;
/** <identifier, item> map to lookup items by identifier, used for efficient lookups in
* #update_from_old(). */
Map<StringRef, AbstractGridViewItem *> item_map_;
@ -109,6 +111,7 @@ class AbstractGridView : public AbstractView {
using ItemIterFn = FunctionRef<void(AbstractGridViewItem &)>;
void foreach_item(ItemIterFn iter_fn) const;
void foreach_filtered_item(ItemIterFn iter_fn) const;
/**
* Convenience wrapper constructing the item by forwarding given arguments to the constructor of
@ -126,6 +129,7 @@ class AbstractGridView : public AbstractView {
template<class ItemT, typename... Args> inline ItemT &add_item(Args &&...args);
const GridViewStyle &get_style() const;
int get_item_count() const;
int get_item_count_filtered() const;
protected:
virtual void build_items() = 0;

View File

@ -933,10 +933,10 @@ void UI_but_execute(const struct bContext *C, struct ARegion *region, uiBut *but
bool UI_but_online_manual_id(const uiBut *but,
char *r_str,
size_t maxlength) ATTR_WARN_UNUSED_RESULT;
size_t str_maxncpy) ATTR_WARN_UNUSED_RESULT;
bool UI_but_online_manual_id_from_active(const struct bContext *C,
char *r_str,
size_t maxlength) ATTR_WARN_UNUSED_RESULT;
size_t str_maxncpy) ATTR_WARN_UNUSED_RESULT;
bool UI_but_is_userdef(const uiBut *but);
/* Buttons
@ -3269,6 +3269,13 @@ void UI_interface_tag_script_reload(void);
/* Support click-drag motion which presses the button and closes a popover (like a menu). */
#define USE_UI_POPOVER_ONCE
/**
* Call the #ui::AbstractView::begin_filtering() function of the view to enable filtering.
* Typically used to enable a filter text button. Triggered on Ctrl+F by default.
* \return True when filtering was enabled successfully.
*/
bool UI_view_begin_filtering(const struct bContext *C, const uiViewHandle *view_handle);
bool UI_view_item_is_interactive(const uiViewItemHandle *item_handle);
bool UI_view_item_is_active(const uiViewItemHandle *item_handle);
bool UI_view_item_matches(const uiViewItemHandle *a_handle, const uiViewItemHandle *b_handle);

View File

@ -66,6 +66,7 @@ class TreeViewItemContainer {
enum class IterOptions {
None = 0,
SkipCollapsed = 1 << 0,
SkipFiltered = 1 << 1,
/* Keep ENUM_OPERATORS() below updated! */
};

View File

@ -2699,7 +2699,7 @@ void ui_but_value_set(uiBut *but, double value)
ui_but_update_select_flag(but, &value);
}
int ui_but_string_get_max_length(uiBut *but)
int ui_but_string_get_maxncpy(uiBut *but)
{
if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
return but->hardmax;
@ -4937,20 +4937,20 @@ static int findBitIndex(uint x)
/* Auto-complete helper functions. */
struct AutoComplete {
size_t maxlen;
size_t maxncpy;
int matches;
char *truncate;
const char *startname;
};
AutoComplete *UI_autocomplete_begin(const char *startname, size_t maxlen)
AutoComplete *UI_autocomplete_begin(const char *startname, size_t maxncpy)
{
AutoComplete *autocpl;
autocpl = MEM_cnew<AutoComplete>(__func__);
autocpl->maxlen = maxlen;
autocpl->maxncpy = maxncpy;
autocpl->matches = 0;
autocpl->truncate = static_cast<char *>(MEM_callocN(sizeof(char) * maxlen, __func__));
autocpl->truncate = static_cast<char *>(MEM_callocN(sizeof(char) * maxncpy, __func__));
autocpl->startname = startname;
return autocpl;
@ -4961,7 +4961,7 @@ void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name)
char *truncate = autocpl->truncate;
const char *startname = autocpl->startname;
int match_index = 0;
for (int a = 0; a < autocpl->maxlen - 1; a++) {
for (int a = 0; a < autocpl->maxncpy - 1; a++) {
if (startname[a] == 0 || startname[a] != name[a]) {
match_index = a;
break;
@ -4973,11 +4973,11 @@ void UI_autocomplete_update_name(AutoComplete *autocpl, const char *name)
autocpl->matches++;
/* first match */
if (truncate[0] == 0) {
BLI_strncpy(truncate, name, autocpl->maxlen);
BLI_strncpy(truncate, name, autocpl->maxncpy);
}
else {
/* remove from truncate what is not in bone->name */
for (int a = 0; a < autocpl->maxlen - 1; a++) {
for (int a = 0; a < autocpl->maxncpy - 1; a++) {
if (name[a] == 0) {
truncate[a] = 0;
break;
@ -5000,11 +5000,11 @@ int UI_autocomplete_end(AutoComplete *autocpl, char *autoname)
else {
match = AUTOCOMPLETE_PARTIAL_MATCH;
}
BLI_strncpy(autoname, autocpl->truncate, autocpl->maxlen);
BLI_strncpy(autoname, autocpl->truncate, autocpl->maxncpy);
}
else {
if (autoname != autocpl->startname) { /* don't copy a string over itself */
BLI_strncpy(autoname, autocpl->startname, autocpl->maxlen);
BLI_strncpy(autoname, autocpl->startname, autocpl->maxncpy);
}
}
@ -6271,7 +6271,7 @@ uiBut *uiDefSearchBut(uiBlock *block,
void *arg,
int retval,
int icon,
int maxlen,
int maxncpy,
int x,
int y,
short width,
@ -6280,8 +6280,20 @@ uiBut *uiDefSearchBut(uiBlock *block,
float a2,
const char *tip)
{
uiBut *but = ui_def_but(
block, UI_BTYPE_SEARCH_MENU, retval, "", x, y, width, height, arg, 0.0, maxlen, a1, a2, tip);
uiBut *but = ui_def_but(block,
UI_BTYPE_SEARCH_MENU,
retval,
"",
x,
y,
width,
height,
arg,
0.0,
maxncpy,
a1,
a2,
tip);
ui_def_but_icon(but, icon, UI_HAS_ICON);
@ -6466,7 +6478,7 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block,
void *arg,
int retval,
int icon,
int maxlen,
int maxncpy,
int x,
int y,
short width,
@ -6475,7 +6487,7 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block,
float a2,
const char *tip)
{
uiBut *but = uiDefSearchBut(block, arg, retval, icon, maxlen, x, y, width, height, a1, a2, tip);
uiBut *but = uiDefSearchBut(block, arg, retval, icon, maxncpy, x, y, width, height, a1, a2, tip);
UI_but_func_search_set(but,
ui_searchbox_create_generic,
operator_enum_search_update_fn,

View File

@ -2489,23 +2489,23 @@ static void ui_but_set_float_array(
static void float_array_to_string(const float *values,
const int values_len,
char *output,
int output_len_max)
int output_maxncpy)
{
const int values_end = values_len - 1;
int ofs = 0;
output[ofs++] = '[';
for (int i = 0; i < values_len; i++) {
ofs += BLI_snprintf_rlen(
output + ofs, output_len_max - ofs, (i != values_end) ? "%f, " : "%f]", values[i]);
output + ofs, output_maxncpy - ofs, (i != values_end) ? "%f, " : "%f]", values[i]);
}
}
static void ui_but_copy_numeric_array(uiBut *but, char *output, int output_len_max)
static void ui_but_copy_numeric_array(uiBut *but, char *output, int output_maxncpy)
{
const int values_len = get_but_property_array_length(but);
blender::Array<float, 16> values(values_len);
RNA_property_float_get_array(&but->rnapoin, but->rnaprop, values.data());
float_array_to_string(values.data(), values_len, output, output_len_max);
float_array_to_string(values.data(), values_len, output, output_maxncpy);
}
static bool parse_float_array(char *text, float *values, int values_len_expected)
@ -2545,11 +2545,11 @@ static void ui_but_paste_numeric_array(bContext *C,
}
}
static void ui_but_copy_numeric_value(uiBut *but, char *output, int output_len_max)
static void ui_but_copy_numeric_value(uiBut *but, char *output, int output_maxncpy)
{
/* Get many decimal places, then strip trailing zeros.
* NOTE: too high values start to give strange results. */
ui_but_string_get_ex(but, output, output_len_max, UI_PRECISION_FLOAT_MAX, false, nullptr);
ui_but_string_get_ex(but, output, output_maxncpy, UI_PRECISION_FLOAT_MAX, false, nullptr);
BLI_str_rstrip_float_zero(output, '\0');
}
@ -2588,7 +2588,7 @@ static void ui_but_paste_normalized_vector(bContext *C,
}
}
static void ui_but_copy_color(uiBut *but, char *output, int output_len_max)
static void ui_but_copy_color(uiBut *but, char *output, int output_maxncpy)
{
float rgba[4];
@ -2606,7 +2606,7 @@ static void ui_but_copy_color(uiBut *but, char *output, int output_len_max)
srgb_to_linearrgb_v3_v3(rgba, rgba);
}
float_array_to_string(rgba, 4, output, output_len_max);
float_array_to_string(rgba, 4, output, output_maxncpy);
}
static void ui_but_paste_color(bContext *C, uiBut *but, char *buf_paste)
@ -2630,9 +2630,9 @@ static void ui_but_paste_color(bContext *C, uiBut *but, char *buf_paste)
}
}
static void ui_but_copy_text(uiBut *but, char *output, int output_len_max)
static void ui_but_copy_text(uiBut *but, char *output, int output_maxncpy)
{
ui_but_string_get(but, output, output_len_max);
ui_but_string_get(but, output, output_maxncpy);
}
static void ui_but_paste_text(bContext *C, uiBut *but, uiHandleButtonData *data, char *buf_paste)
@ -2708,31 +2708,31 @@ static void ui_but_paste_CurveProfile(bContext *C, uiBut *but)
}
}
static void ui_but_copy_operator(bContext *C, uiBut *but, char *output, int output_len_max)
static void ui_but_copy_operator(bContext *C, uiBut *but, char *output, int output_maxncpy)
{
PointerRNA *opptr = UI_but_operator_ptr_get(but);
char *str;
str = WM_operator_pystring_ex(C, nullptr, false, true, but->optype, opptr);
BLI_strncpy(output, str, output_len_max);
BLI_strncpy(output, str, output_maxncpy);
MEM_freeN(str);
}
static bool ui_but_copy_menu(uiBut *but, char *output, int output_len_max)
static bool ui_but_copy_menu(uiBut *but, char *output, int output_maxncpy)
{
MenuType *mt = UI_but_menutype_get(but);
if (mt) {
BLI_snprintf(output, output_len_max, "bpy.ops.wm.call_menu(name=\"%s\")", mt->idname);
BLI_snprintf(output, output_maxncpy, "bpy.ops.wm.call_menu(name=\"%s\")", mt->idname);
return true;
}
return false;
}
static bool ui_but_copy_popover(uiBut *but, char *output, int output_len_max)
static bool ui_but_copy_popover(uiBut *but, char *output, int output_maxncpy)
{
PanelType *pt = UI_but_paneltype_get(but);
if (pt) {
BLI_snprintf(output, output_len_max, "bpy.ops.wm.call_panel(name=\"%s\")", pt->idname);
BLI_snprintf(output, output_maxncpy, "bpy.ops.wm.call_panel(name=\"%s\")", pt->idname);
return true;
}
return false;
@ -2746,7 +2746,7 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
/* Arbitrary large value (allow for paths: 'PATH_MAX') */
char buf[4096] = {0};
const int buf_max_len = sizeof(buf);
const int buf_maxncpy = sizeof(buf);
/* Left false for copying internal data (color-band for eg). */
bool is_buf_set = false;
@ -2760,10 +2760,10 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
break;
}
if (copy_array && ui_but_has_array_value(but)) {
ui_but_copy_numeric_array(but, buf, buf_max_len);
ui_but_copy_numeric_array(but, buf, buf_maxncpy);
}
else {
ui_but_copy_numeric_value(but, buf, buf_max_len);
ui_but_copy_numeric_value(but, buf, buf_maxncpy);
}
is_buf_set = true;
break;
@ -2772,7 +2772,7 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
if (!has_required_data) {
break;
}
ui_but_copy_numeric_array(but, buf, buf_max_len);
ui_but_copy_numeric_array(but, buf, buf_maxncpy);
is_buf_set = true;
break;
@ -2780,7 +2780,7 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
if (!has_required_data) {
break;
}
ui_but_copy_color(but, buf, buf_max_len);
ui_but_copy_color(but, buf, buf_maxncpy);
is_buf_set = true;
break;
@ -2789,7 +2789,7 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
if (!has_required_data) {
break;
}
ui_but_copy_text(but, buf, buf_max_len);
ui_but_copy_text(but, buf, buf_maxncpy);
is_buf_set = true;
break;
@ -2809,18 +2809,18 @@ static void ui_but_copy(bContext *C, uiBut *but, const bool copy_array)
if (!but->optype) {
break;
}
ui_but_copy_operator(C, but, buf, buf_max_len);
ui_but_copy_operator(C, but, buf, buf_maxncpy);
is_buf_set = true;
break;
case UI_BTYPE_MENU:
case UI_BTYPE_PULLDOWN:
if (ui_but_copy_menu(but, buf, buf_max_len)) {
if (ui_but_copy_menu(but, buf, buf_maxncpy)) {
is_buf_set = true;
}
break;
case UI_BTYPE_POPOVER:
if (ui_but_copy_popover(but, buf, buf_max_len)) {
if (ui_but_copy_popover(but, buf, buf_maxncpy)) {
is_buf_set = true;
}
break;
@ -3425,7 +3425,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
#endif
/* retrieve string */
data->str_maxncpy = ui_but_string_get_max_length(but);
data->str_maxncpy = ui_but_string_get_maxncpy(but);
if (data->str_maxncpy != 0) {
data->str = static_cast<char *>(MEM_callocN(sizeof(char) * data->str_maxncpy, "textedit str"));
/* We do not want to truncate precision to default here, it's nice to show value,

View File

@ -675,7 +675,7 @@ void ui_but_string_get_ex(uiBut *but,
void ui_but_string_get(uiBut *but, char *str, size_t str_maxncpy) ATTR_NONNULL();
/**
* A version of #ui_but_string_get_ex for dynamic buffer sizes
* (where #ui_but_string_get_max_length returns 0).
* (where #ui_but_string_get_maxncpy returns 0).
*
* \param r_str_size: size of the returned string (including terminator).
*/
@ -687,7 +687,7 @@ void ui_but_convert_to_unit_alt_name(uiBut *but, char *str, size_t str_maxncpy)
bool ui_but_string_set(bContext *C, uiBut *but, const char *str) ATTR_NONNULL();
bool ui_but_string_eval_number(bContext *C, const uiBut *but, const char *str, double *value)
ATTR_NONNULL();
int ui_but_string_get_max_length(uiBut *but);
int ui_but_string_get_maxncpy(uiBut *but);
/**
* Clear & exit the active button's string..
*/

View File

@ -43,6 +43,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "RNA_path.h"
#include "RNA_prototypes.h"
#include "RNA_types.h"
@ -1751,7 +1752,7 @@ static int editsource_text_edit(bContext *C,
RNA_int_set(&op_props, "line", line - 1);
RNA_int_set(&op_props, "column", 0);
int result = WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &op_props, NULL);
int result = WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &op_props, nullptr);
WM_operator_properties_free(&op_props);
return result;
}
@ -2341,6 +2342,48 @@ static void UI_OT_list_start_filter(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
/** \name UI View Start Filter Operator
* \{ */
static bool ui_view_focused_poll(bContext *C)
{
const ARegion *region = CTX_wm_region(C);
if (!region) {
return false;
}
const wmWindow *win = CTX_wm_window(C);
const uiViewHandle *view = UI_region_view_find_at(region, win->eventstate->xy, 0);
return view != nullptr;
}
static int ui_view_start_filter_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
const ARegion *region = CTX_wm_region(C);
const uiViewHandle *hovered_view = UI_region_view_find_at(region, event->xy, 0);
if (!UI_view_begin_filtering(C, hovered_view)) {
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
return OPERATOR_FINISHED;
}
static void UI_OT_view_start_filter(wmOperatorType *ot)
{
ot->name = "View Filter";
ot->idname = "UI_OT_view_start_filter";
ot->description = "Start entering filter text for the data-set in focus";
ot->invoke = ui_view_start_filter_invoke;
ot->poll = ui_view_focused_poll;
ot->flag = OPTYPE_INTERNAL;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name UI View Drop Operator
* \{ */
@ -2528,6 +2571,7 @@ void ED_operatortypes_ui(void)
WM_operatortype_append(UI_OT_list_start_filter);
WM_operatortype_append(UI_OT_view_start_filter);
WM_operatortype_append(UI_OT_view_drop);
WM_operatortype_append(UI_OT_view_item_rename);

View File

@ -535,7 +535,7 @@ int ui_searchbox_autocomplete(bContext *C, ARegion *region, uiBut *but, char *st
BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
if (str[0]) {
data->items.autocpl = UI_autocomplete_begin(str, ui_but_string_get_max_length(but));
data->items.autocpl = UI_autocomplete_begin(str, ui_but_string_get_maxncpy(but));
ui_searchbox_update_fn(C, search_but, but->editstr, &data->items);

View File

@ -827,11 +827,11 @@ int UI_calc_float_precision(int prec, double value)
return prec;
}
bool UI_but_online_manual_id(const uiBut *but, char *r_str, size_t maxlength)
bool UI_but_online_manual_id(const uiBut *but, char *r_str, size_t str_maxncpy)
{
if (but->rnapoin.owner_id && but->rnapoin.data && but->rnaprop) {
BLI_snprintf(r_str,
maxlength,
str_maxncpy,
"%s.%s",
RNA_struct_identifier(but->rnapoin.type),
RNA_property_identifier(but->rnaprop));
@ -846,12 +846,12 @@ bool UI_but_online_manual_id(const uiBut *but, char *r_str, size_t maxlength)
return false;
}
bool UI_but_online_manual_id_from_active(const bContext *C, char *r_str, size_t maxlength)
bool UI_but_online_manual_id_from_active(const bContext *C, char *r_str, size_t str_maxncpy)
{
uiBut *but = UI_context_active_but_get(C);
if (but) {
return UI_but_online_manual_id(but, r_str, maxlength);
return UI_but_online_manual_id(but, r_str, str_maxncpy);
}
*r_str = '\0';

View File

@ -10,6 +10,8 @@
#include "UI_abstract_view.hh"
using namespace blender;
namespace blender::ui {
void AbstractView::register_item(AbstractViewItem &item)
@ -76,6 +78,11 @@ bool AbstractView::listen(const wmNotifier & /*notifier*/) const
return false;
}
bool AbstractView::begin_filtering(const bContext & /*C*/) const
{
return false;
}
/** \} */
/* ---------------------------------------------------------------------- */
@ -119,16 +126,26 @@ std::optional<rcti> AbstractView::get_bounds() const
/** \} */
} // namespace blender::ui
/* ---------------------------------------------------------------------- */
/** \name General API functions
* \{ */
namespace blender::ui {
std::unique_ptr<DropTargetInterface> view_drop_target(uiViewHandle *view_handle)
{
AbstractView &view = reinterpret_cast<AbstractView &>(*view_handle);
return view.create_drop_target();
}
/** \} */
} // namespace blender::ui
bool UI_view_begin_filtering(const bContext *C, const uiViewHandle *view_handle)
{
const ui::AbstractView &view = reinterpret_cast<const ui::AbstractView &>(*view_handle);
return view.begin_filtering(*C);
}
/** \} */

View File

@ -166,6 +166,27 @@ void AbstractViewItem::build_context_menu(bContext & /*C*/, uiLayout & /*column*
/** \} */
/* ---------------------------------------------------------------------- */
/** \name Filtering
* \{ */
bool AbstractViewItem::is_filtered_visible() const
{
return true;
}
bool AbstractViewItem::is_filtered_visible_cached() const
{
if (is_filtered_visible_.has_value()) {
return *is_filtered_visible_;
}
is_filtered_visible_ = is_filtered_visible();
return *is_filtered_visible_;
}
/** \} */
/* ---------------------------------------------------------------------- */
/** \name Drag 'n Drop
* \{ */

View File

@ -44,6 +44,15 @@ void AbstractGridView::foreach_item(ItemIterFn iter_fn) const
}
}
void AbstractGridView::foreach_filtered_item(ItemIterFn iter_fn) const
{
for (const auto &item_ptr : items_) {
if (item_ptr->is_filtered_visible_cached()) {
iter_fn(*item_ptr);
}
}
}
AbstractGridViewItem *AbstractGridView::find_matching_item(
const AbstractGridViewItem &item_to_match, const AbstractGridView &view_to_search_in) const
{
@ -86,6 +95,20 @@ int AbstractGridView::get_item_count() const
return items_.size();
}
int AbstractGridView::get_item_count_filtered() const
{
if (item_count_filtered_) {
return *item_count_filtered_;
}
int i = 0;
foreach_filtered_item([&i](const auto &) { i++; });
BLI_assert(i <= get_item_count());
item_count_filtered_ = i;
return i;
}
GridViewStyle::GridViewStyle(int width, int height) : tile_width(width), tile_height(height) {}
/* ---------------------------------------------------------------------- */
@ -265,7 +288,7 @@ void BuildOnlyVisibleButtonsHelper::fill_layout_before_visible(uiBlock &block) c
void BuildOnlyVisibleButtonsHelper::fill_layout_after_visible(uiBlock &block) const
{
const int last_item_idx = grid_view_.get_item_count() - 1;
const int last_item_idx = grid_view_.get_item_count_filtered() - 1;
const int last_visible_idx = visible_items_range_.last();
if (last_item_idx > last_visible_idx) {
@ -350,7 +373,7 @@ void GridViewLayoutBuilder::build_from_view(const AbstractGridView &grid_view,
int item_idx = 0;
uiLayout *row = nullptr;
grid_view.foreach_item([&](AbstractGridViewItem &item) {
grid_view.foreach_filtered_item([&](AbstractGridViewItem &item) {
/* Skip if item isn't visible. */
if (!build_visible_helper.is_item_visible(item_idx)) {
item_idx++;

View File

@ -52,7 +52,15 @@ AbstractTreeViewItem &TreeViewItemContainer::add_tree_item(
void TreeViewItemContainer::foreach_item_recursive(ItemIterFn iter_fn, IterOptions options) const
{
for (const auto &child : children_) {
iter_fn(*child);
bool skip = false;
if (bool(options & IterOptions::SkipFiltered) && !child->is_filtered_visible_cached()) {
skip = true;
}
if (!skip) {
iter_fn(*child);
}
if (bool(options & IterOptions::SkipCollapsed) && child->is_collapsed()) {
continue;
}
@ -428,7 +436,8 @@ void TreeViewLayoutBuilder::build_from_tree(const AbstractTreeView &tree_view)
uiLayoutColumn(box, false);
tree_view.foreach_item([this](AbstractTreeViewItem &item) { build_row(item); },
AbstractTreeView::IterOptions::SkipCollapsed);
AbstractTreeView::IterOptions::SkipCollapsed |
AbstractTreeView::IterOptions::SkipFiltered);
UI_block_layout_set_current(&block(), &parent_layout);
}
@ -502,7 +511,7 @@ void TreeViewBuilder::ensure_min_rows_items(AbstractTreeView &tree_view)
int tot_visible_items = 0;
tree_view.foreach_item(
[&tot_visible_items](AbstractTreeViewItem & /*item*/) { tot_visible_items++; },
AbstractTreeView::IterOptions::SkipCollapsed);
AbstractTreeView::IterOptions::SkipCollapsed | AbstractTreeView::IterOptions::SkipFiltered);
if (tot_visible_items >= tree_view.min_rows_) {
return;

View File

@ -473,7 +473,7 @@ void WM_OT_alembic_export(wmOperatorType *ot)
/* TODO(kevin): check on de-duplicating all this with code in image_ops.c */
struct CacheFrame {
struct CacheFrame *next, *prev;
CacheFrame *next, *prev;
int framenr;
};

View File

@ -8,6 +8,7 @@
#include "BLI_color.hh"
#include "BLI_generic_pointer.hh"
#include "BLI_math_quaternion.hh"
#include "BKE_attribute.h"
#include "BKE_context.h"
@ -106,6 +107,8 @@ static StringRefNull rna_property_name_for_type(const eCustomDataType type)
return "value_int";
case CD_PROP_INT32_2D:
return "value_int_vector_2d";
case CD_PROP_QUATERNION:
return "value_quat";
default:
BLI_assert_unreachable();
return "";
@ -198,6 +201,12 @@ static int mesh_set_attribute_exec(bContext *C, wmOperator *op)
case CD_PROP_COLOR:
RNA_float_get_array(op->ptr, prop_name.c_str(), static_cast<float *>(buffer));
break;
case CD_PROP_QUATERNION: {
float4 value;
RNA_float_get_array(op->ptr, prop_name.c_str(), value);
*static_cast<math::Quaternion *>(buffer) = math::normalize(math::Quaternion(value));
break;
}
case CD_PROP_BYTE_COLOR:
ColorGeometry4f value;
RNA_float_get_array(op->ptr, prop_name.c_str(), value);
@ -330,6 +339,11 @@ static int mesh_set_attribute_invoke(bContext *C, wmOperator *op, const wmEvent
case CD_PROP_INT32_2D:
RNA_property_int_set_array(op->ptr, prop, *active_value.get<int2>());
break;
case CD_PROP_QUATERNION: {
const math::Quaternion value = math::normalize(*active_value.get<math::Quaternion>());
RNA_property_float_set_array(op->ptr, prop, float4(value));
break;
}
default:
BLI_assert_unreachable();
}
@ -408,6 +422,16 @@ void MESH_OT_attribute_set(wmOperatorType *ot)
RNA_def_float_color(
ot->srna, "value_color", 4, color_default, -FLT_MAX, FLT_MAX, "Value", "", 0.0f, 1.0f);
RNA_def_boolean(ot->srna, "value_bool", false, "Value", "");
RNA_def_float_array(ot->srna,
"value_quat",
4,
rna_default_quaternion,
-FLT_MAX,
FLT_MAX,
"Value",
"",
FLT_MAX,
FLT_MAX);
}
/** \} */

View File

@ -123,8 +123,10 @@ void PaintOperation::on_stroke_done(const bContext &C)
/* Set position, radius and opacity attribute. */
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
MutableSpan<float3> positions = curves.positions_for_write();
SpanAttributeWriter<float> radii = attributes.lookup_for_write_span<float>("radius");
SpanAttributeWriter<float> opacities = attributes.lookup_for_write_span<float>("opacity");
SpanAttributeWriter<float> radii = attributes.lookup_or_add_for_write_span<float>(
"radius", ATTR_DOMAIN_POINT);
SpanAttributeWriter<float> opacities = attributes.lookup_or_add_for_write_span<float>(
"opacity", ATTR_DOMAIN_POINT);
for (const int i : IndexRange(stroke_points.size())) {
const bke::greasepencil::StrokePoint &point = stroke_points[i];
const int point_i = new_points_range[i];
@ -135,7 +137,9 @@ void PaintOperation::on_stroke_done(const bContext &C)
/* Set material index attribute. */
int material_index = 0;
SpanAttributeWriter<int> materials = attributes.lookup_for_write_span<int>("material_index");
SpanAttributeWriter<int> materials = attributes.lookup_or_add_for_write_span<int>(
"material_index", ATTR_DOMAIN_CURVE);
materials.span.slice(new_curves_range).fill(material_index);
/* Set curve_type attribute. */

View File

@ -59,9 +59,11 @@ set(SRC
tree/tree_element_id.cc
tree/tree_element_id_curve.cc
tree/tree_element_id_library.cc
tree/tree_element_id_linestyle.cc
tree/tree_element_id_mesh.cc
tree/tree_element_id_metaball.cc
tree/tree_element_id_scene.cc
tree/tree_element_id_texture.cc
tree/tree_element_label.cc
tree/tree_element_nla.cc
tree/tree_element_overrides.cc
@ -82,9 +84,11 @@ set(SRC
tree/tree_element_id.hh
tree/tree_element_id_curve.hh
tree/tree_element_id_library.hh
tree/tree_element_id_linestyle.hh
tree/tree_element_id_mesh.hh
tree/tree_element_id_metaball.hh
tree/tree_element_id_scene.hh
tree/tree_element_id_texture.hh
tree/tree_element_label.hh
tree/tree_element_nla.hh
tree/tree_element_overrides.hh

View File

@ -554,6 +554,8 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
case ID_ME:
case ID_CU_LEGACY:
case ID_MB:
case ID_TE:
case ID_LS:
BLI_assert_msg(0, "ID type expected to be expanded through new tree-element design");
break;
case ID_OB: {
@ -567,14 +569,6 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
}
break;
}
case ID_TE: {
Tex *tex = (Tex *)id;
if (outliner_animdata_test(tex->adt)) {
outliner_add_element(space_outliner, &te->subtree, tex, te, TSE_ANIM_DATA, 0);
}
outliner_add_element(space_outliner, &te->subtree, tex->ima, te, TSE_SOME_ID, 0);
break;
}
case ID_CA: {
Camera *ca = (Camera *)id;
if (outliner_animdata_test(ca->adt)) {
@ -679,20 +673,6 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
}
break;
}
case ID_LS: {
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
if (outliner_animdata_test(linestyle->adt)) {
outliner_add_element(space_outliner, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0);
}
for (int a = 0; a < MAX_MTEX; a++) {
if (linestyle->mtex[a]) {
outliner_add_element(space_outliner, &te->subtree, linestyle->mtex[a]->tex, te, 0, a);
}
}
break;
}
case ID_GD_LEGACY: {
bGPdata *gpd = (bGPdata *)id;

View File

@ -22,9 +22,11 @@
#include "common.hh"
#include "tree_element_id_curve.hh"
#include "tree_element_id_library.hh"
#include "tree_element_id_linestyle.hh"
#include "tree_element_id_mesh.hh"
#include "tree_element_id_metaball.hh"
#include "tree_element_id_scene.hh"
#include "tree_element_id_texture.hh"
#include "tree_element_id.hh"
@ -48,9 +50,12 @@ std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_t
return std::make_unique<TreeElementIDCurve>(legacy_te, (Curve &)id);
case ID_MB:
return std::make_unique<TreeElementIDMetaBall>(legacy_te, (MetaBall &)id);
case ID_TE:
return std::make_unique<TreeElementIDTexture>(legacy_te, (Tex &)id);
case ID_LS:
return std::make_unique<TreeElementIDLineStyle>(legacy_te, (FreestyleLineStyle &)id);
case ID_OB:
case ID_MA:
case ID_TE:
case ID_LT:
case ID_LA:
case ID_CA:
@ -64,7 +69,6 @@ std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_t
case ID_PA:
case ID_MC:
case ID_MSK:
case ID_LS:
case ID_LP:
case ID_GD_LEGACY:
case ID_WS:

View File

@ -0,0 +1,49 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#include "DNA_ID.h"
#include "DNA_linestyle_types.h"
#include "DNA_listBase.h"
#include "DNA_outliner_types.h"
#include "DNA_texture_types.h"
#include "../outliner_intern.hh"
#include "tree_element_id_linestyle.hh"
namespace blender::ed::outliner {
TreeElementIDLineStyle::TreeElementIDLineStyle(TreeElement &legacy_te,
FreestyleLineStyle &linestyle)
: TreeElementID(legacy_te, linestyle.id), linestyle_(linestyle)
{
}
void TreeElementIDLineStyle::expand(SpaceOutliner &space_outliner) const
{
expand_animation_data(space_outliner, linestyle_.adt);
expandTextures(space_outliner);
}
bool TreeElementIDLineStyle::isExpandValid() const
{
return true;
}
void TreeElementIDLineStyle::expandTextures(SpaceOutliner &space_outliner) const
{
for (int a = 0; a < MAX_MTEX; a++) {
if (linestyle_.mtex[a]) {
outliner_add_element(
&space_outliner, &legacy_te_.subtree, (linestyle_.mtex[a])->tex, &legacy_te_, TSE_SOME_ID, a);
}
}
}
} // namespace blender::ed::outliner

View File

@ -0,0 +1,30 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#pragma once
#include "tree_element_id.hh"
struct FreestyleLineStyle;
namespace blender::ed::outliner {
class TreeElementIDLineStyle final : public TreeElementID {
FreestyleLineStyle &linestyle_;
public:
TreeElementIDLineStyle(TreeElement &legacy_te, FreestyleLineStyle &linestyle);
void expand(SpaceOutliner &) const override;
bool isExpandValid() const override;
private:
void expandTextures(SpaceOutliner &) const;
};
} // namespace blender::ed::outliner

View File

@ -0,0 +1,42 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#include "DNA_listBase.h"
#include "DNA_outliner_types.h"
#include "DNA_texture_types.h"
#include "../outliner_intern.hh"
#include "tree_element_id_texture.hh"
namespace blender::ed::outliner {
TreeElementIDTexture::TreeElementIDTexture(TreeElement &legacy_te, Tex &texture)
: TreeElementID(legacy_te, texture.id), texture_(texture)
{
}
bool TreeElementIDTexture::isExpandValid() const
{
return true;
}
void TreeElementIDTexture::expand(SpaceOutliner &space_outliner) const
{
expand_animation_data(space_outliner, texture_.adt);
expandImage(space_outliner);
}
void TreeElementIDTexture::expandImage(SpaceOutliner &space_outliner) const
{
outliner_add_element(
&space_outliner, &legacy_te_.subtree, texture_.ima, &legacy_te_, TSE_SOME_ID, 0);
}
} // namespace blender::ed::outliner

View File

@ -0,0 +1,28 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#pragma once
#include "tree_element_id.hh"
namespace blender::ed::outliner {
class TreeElementIDTexture final : public TreeElementID {
Tex &texture_;
public:
TreeElementIDTexture(TreeElement &legacy_te, Tex &texture);
void expand(SpaceOutliner &) const override;
bool isExpandValid() const override;
private:
void expandImage(SpaceOutliner &) const;
};
} // namespace blender::ed::outliner

View File

@ -37,6 +37,7 @@ typedef struct GizmoGroup_retime {
wmGizmo *add_handle_gizmo;
wmGizmo *move_handle_gizmo;
wmGizmo *remove_handle_gizmo;
wmGizmo *speed_set_gizmo;
} GizmoGroup_retime;
static bool gizmogroup_retime_poll(const bContext *C, wmGizmoGroupType *gzgt)
@ -81,6 +82,8 @@ static void gizmogroup_retime_setup(const bContext * /* C */, wmGizmoGroup *gzgr
ggd->remove_handle_gizmo = WM_gizmo_new_ptr(gzt_remove_handle, gzgroup, nullptr);
const wmGizmoType *gzt_move_handle = WM_gizmotype_find("GIZMO_GT_retime_handle_move", true);
ggd->move_handle_gizmo = WM_gizmo_new_ptr(gzt_move_handle, gzgroup, nullptr);
const wmGizmoType *gzt_speed_set = WM_gizmotype_find("GIZMO_GT_retime_speed_set", true);
ggd->speed_set_gizmo = WM_gizmo_new_ptr(gzt_speed_set, gzgroup, nullptr);
gzgroup->customdata = ggd;
/* Assign operators. */
@ -90,6 +93,8 @@ static void gizmogroup_retime_setup(const bContext * /* C */, wmGizmoGroup *gzgr
WM_gizmo_operator_set(ggd->add_handle_gizmo, 0, ot, nullptr);
ot = WM_operatortype_find("SEQUENCER_OT_retiming_handle_remove", true);
WM_gizmo_operator_set(ggd->remove_handle_gizmo, 0, ot, nullptr);
ot = WM_operatortype_find("SEQUENCER_OT_retiming_segment_speed_set", true);
WM_gizmo_operator_set(ggd->speed_set_gizmo, 0, ot, nullptr);
}
void SEQUENCER_GGT_gizmo_retime(wmGizmoGroupType *gzgt)

View File

@ -403,61 +403,6 @@ static void retime_handle_draw(const bContext *C,
immEnd();
}
static void retime_speed_text_draw(const bContext *C,
const Sequence *seq,
const SeqRetimingHandle *handle)
{
SeqRetimingHandle *last_handle = SEQ_retiming_last_handle_get(seq);
if (handle == last_handle) {
return;
}
const Scene *scene = CTX_data_scene(C);
const int start_frame = SEQ_time_left_handle_frame_get(scene, seq);
const int end_frame = SEQ_time_right_handle_frame_get(scene, seq);
int next_handle_index = SEQ_retiming_handle_index_get(seq, handle) + 1;
const SeqRetimingHandle *next_handle = &SEQ_retiming_handles_get(seq)[next_handle_index];
if (handle_x_get(scene, seq, next_handle) < start_frame ||
handle_x_get(scene, seq, handle) > end_frame)
{
return; /* Label out of strip bounds. */
}
char label_str[40];
size_t label_len;
if (SEQ_retiming_handle_is_transition_type(handle)) {
const float prev_speed = SEQ_retiming_handle_speed_get(seq, handle - 1);
const float next_speed = SEQ_retiming_handle_speed_get(seq, next_handle + 1);
label_len = SNPRINTF_RLEN(label_str,
"%d%% - %d%%",
round_fl_to_int(prev_speed * 100.0f),
round_fl_to_int(next_speed * 100.0f));
}
else {
const float speed = SEQ_retiming_handle_speed_get(seq, next_handle);
label_len = SNPRINTF_RLEN(label_str, "%d%%", round_fl_to_int(speed * 100.0f));
}
const float width = pixels_to_view_width(C, BLF_width(BLF_default(), label_str, label_len));
const float xmin = max_ff(SEQ_time_left_handle_frame_get(scene, seq),
handle_x_get(scene, seq, handle));
const float xmax = min_ff(SEQ_time_right_handle_frame_get(scene, seq),
handle_x_get(scene, seq, next_handle));
const float text_x = (xmin + xmax - width) / 2;
const float text_y = strip_y_rescale(seq, 0) + pixels_to_view_height(C, 5);
if (width > xmax - xmin) {
return; /* Not enough space to draw label. */
}
const uchar col[4] = {255, 255, 255, 255};
UI_view2d_text_cache_add(UI_view2d_fromcontext(C), text_x, text_y, label_str, label_len, col);
}
static void gizmo_retime_handle_draw(const bContext *C, wmGizmo *gz)
{
RetimeHandleMoveGizmo *gizmo = (RetimeHandleMoveGizmo *)gz;
@ -488,8 +433,6 @@ static void gizmo_retime_handle_draw(const bContext *C, wmGizmo *gz)
MutableSpan handles = SEQ_retiming_handles_get(seq);
for (const SeqRetimingHandle &handle : handles) {
retime_speed_text_draw(C, seq, &handle);
if (&handle == handles.begin()) {
continue; /* Ignore first handle. */
}
@ -646,3 +589,183 @@ void GIZMO_GT_retime_remove(wmGizmoType *gzt)
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Retiming Speed Set Gizmo
* \{ */
static size_t label_str_get(const Sequence *seq,
const SeqRetimingHandle *handle,
size_t str_len,
char *r_label_str)
{
const SeqRetimingHandle *next_handle = handle + 1;
if (SEQ_retiming_handle_is_transition_type(handle)) {
const float prev_speed = SEQ_retiming_handle_speed_get(seq, handle - 1);
const float next_speed = SEQ_retiming_handle_speed_get(seq, next_handle + 1);
return BLI_snprintf_rlen(r_label_str,
str_len,
"%d%% - %d%%",
round_fl_to_int(prev_speed * 100.0f),
round_fl_to_int(next_speed * 100.0f));
}
const float speed = SEQ_retiming_handle_speed_get(seq, next_handle);
return BLI_snprintf_rlen(r_label_str, str_len, "%d%%", round_fl_to_int(speed * 100.0f));
}
static bool label_rect_get(const bContext *C,
const Sequence *seq,
const SeqRetimingHandle *handle,
char *label_str,
size_t label_len,
rctf *rect)
{
const Scene *scene = CTX_data_scene(C);
const SeqRetimingHandle *next_handle = handle + 1;
const float width = pixels_to_view_width(C, BLF_width(BLF_default(), label_str, label_len));
const float height = pixels_to_view_height(C, BLF_height(BLF_default(), label_str, label_len));
const float xmin = max_ff(SEQ_time_left_handle_frame_get(scene, seq),
handle_x_get(scene, seq, handle));
const float xmax = min_ff(SEQ_time_right_handle_frame_get(scene, seq),
handle_x_get(scene, seq, next_handle));
rect->xmin = (xmin + xmax - width) / 2;
rect->xmax = rect->xmin + width;
rect->ymin = strip_y_rescale(seq, 0) + pixels_to_view_height(C, 5);
rect->ymax = rect->ymin + height;
return width < xmax - xmin;
}
static void label_rect_apply_mouseover_offset(const View2D *v2d, rctf *rect)
{
float scale_x, scale_y;
UI_view2d_scale_get_inverse(v2d, &scale_x, &scale_y);
rect->xmin -= RETIME_HANDLE_MOUSEOVER_THRESHOLD * scale_x;
rect->xmax += RETIME_HANDLE_MOUSEOVER_THRESHOLD * scale_x;
rect->ymax += RETIME_HANDLE_MOUSEOVER_THRESHOLD * scale_y;
}
static void retime_speed_text_draw(const bContext *C,
const Sequence *seq,
const SeqRetimingHandle *handle)
{
SeqRetimingHandle *last_handle = SEQ_retiming_last_handle_get(seq);
if (handle == last_handle) {
return;
}
const Scene *scene = CTX_data_scene(C);
const int start_frame = SEQ_time_left_handle_frame_get(scene, seq);
const int end_frame = SEQ_time_right_handle_frame_get(scene, seq);
const SeqRetimingHandle *next_handle = handle + 1;
if (handle_x_get(scene, seq, next_handle) < start_frame ||
handle_x_get(scene, seq, handle) > end_frame)
{
return; /* Label out of strip bounds. */
}
char label_str[40];
rctf label_rect;
size_t label_len = label_str_get(seq, handle, sizeof(label_str), label_str);
if (!label_rect_get(C, seq, handle, label_str, label_len, &label_rect)) {
return; /* Not enough space to draw label. */
}
const uchar col[4] = {255, 255, 255, 255};
UI_view2d_text_cache_add(
UI_view2d_fromcontext(C), label_rect.xmin, label_rect.ymin, label_str, label_len, col);
}
static void gizmo_retime_speed_set_draw(const bContext *C, wmGizmo * /* gz */)
{
const View2D *v2d = UI_view2d_fromcontext(C);
wmOrtho2_region_pixelspace(CTX_wm_region(C));
GPU_blend(GPU_BLEND_ALPHA);
GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
Sequence *seq = active_seq_from_context(C);
SEQ_retiming_data_ensure(seq);
MutableSpan handles = SEQ_retiming_handles_get(seq);
for (const SeqRetimingHandle &handle : handles) {
retime_speed_text_draw(C, seq, &handle);
}
immUnbindProgram();
GPU_blend(GPU_BLEND_NONE);
UI_view2d_text_cache_draw(CTX_wm_region(C));
UI_view2d_view_ortho(v2d); /* 'UI_view2d_text_cache_draw()' messes up current view. */
}
static int gizmo_retime_speed_set_test_select(bContext *C, wmGizmo *gz, const int mval[2])
{
Scene *scene = CTX_data_scene(C);
wmGizmoOpElem *op_elem = WM_gizmo_operator_get(gz, 0);
const View2D *v2d = UI_view2d_fromcontext(C);
Sequence *seq = active_seq_from_context(C);
SEQ_retiming_data_ensure(seq);
for (const SeqRetimingHandle &handle : SEQ_retiming_handles_get(seq)) {
if (SEQ_retiming_handle_is_transition_type(&handle)) {
continue;
}
char label_str[40];
rctf label_rect;
size_t label_len = label_str_get(seq, &handle, sizeof(label_str), label_str);
if (!label_rect_get(C, seq, &handle, label_str, label_len, &label_rect)) {
continue;
}
label_rect_apply_mouseover_offset(v2d, &label_rect);
float mouse_view[2];
UI_view2d_region_to_view(v2d, mval[0], mval[1], &mouse_view[0], &mouse_view[1]);
if (!BLI_rctf_isect_pt(&label_rect, mouse_view[0], mouse_view[1])) {
continue;
}
/* Store next handle in RNA property, since label rect uses first handle as reference. */
const int handle_index = SEQ_retiming_handle_index_get(seq, &handle) + 1;
RNA_int_set(&op_elem->ptr, "handle_index", handle_index);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return 0;
}
return -1;
}
static int gizmo_retime_speed_set_cursor_get(wmGizmo *gz)
{
if (RNA_boolean_get(gz->ptr, "show_drag")) {
return WM_CURSOR_TEXT_EDIT;
}
return WM_CURSOR_DEFAULT;
}
void GIZMO_GT_speed_set_remove(wmGizmoType *gzt)
{
/* Identifiers. */
gzt->idname = "GIZMO_GT_retime_speed_set";
/* Api callbacks. */
gzt->draw = gizmo_retime_speed_set_draw;
gzt->test_select = gizmo_retime_speed_set_test_select;
gzt->cursor_get = gizmo_retime_speed_set_cursor_get;
gzt->struct_size = sizeof(wmGizmo);
/* Currently only used for cursor display. */
RNA_def_boolean(gzt->srna, "show_drag", true, "Show Drag", "");
}
/** \} */

View File

@ -312,6 +312,7 @@ void SEQUENCER_OT_retiming_reset(struct wmOperatorType *ot);
void SEQUENCER_OT_retiming_handle_move(struct wmOperatorType *ot);
void SEQUENCER_OT_retiming_handle_add(struct wmOperatorType *ot);
void SEQUENCER_OT_retiming_handle_remove(struct wmOperatorType *ot);
void SEQUENCER_OT_retiming_segment_speed_set(struct wmOperatorType *ot);
/* sequencer_gizmo_retime.c */
void SEQUENCER_GGT_gizmo_retime(struct wmGizmoGroupType *gzgt);
@ -320,6 +321,7 @@ void SEQUENCER_GGT_gizmo_retime(struct wmGizmoGroupType *gzgt);
void GIZMO_GT_retime_handle_add(struct wmGizmoType *gzt);
void GIZMO_GT_retime_handle(struct wmGizmoType *gzt);
void GIZMO_GT_retime_remove(struct wmGizmoType *gzt);
void GIZMO_GT_speed_set_remove(struct wmGizmoType *gzt);
#ifdef __cplusplus
}

View File

@ -74,6 +74,7 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_retiming_handle_move);
WM_operatortype_append(SEQUENCER_OT_retiming_handle_add);
WM_operatortype_append(SEQUENCER_OT_retiming_handle_remove);
WM_operatortype_append(SEQUENCER_OT_retiming_segment_speed_set);
/* sequencer_select.c */
WM_operatortype_append(SEQUENCER_OT_select_all);

View File

@ -461,3 +461,95 @@ void SEQUENCER_OT_retiming_handle_remove(wmOperatorType *ot)
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Retiming Set Segment Speed
* \{ */
static int sequencer_retiming_segment_speed_set_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
const Editing *ed = SEQ_editing_get(scene);
Sequence *seq = ed->act_seq;
MutableSpan handles = SEQ_retiming_handles_get(seq);
SeqRetimingHandle *handle = &handles[RNA_int_get(op->ptr, "handle_index")];
SEQ_retiming_handle_speed_set(scene, seq, handle, RNA_float_get(op->ptr, "speed"));
SEQ_relations_invalidate_cache_raw(scene, seq);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
static int sequencer_retiming_segment_speed_set_invoke(bContext *C,
wmOperator *op,
const wmEvent *event)
{
const Scene *scene = CTX_data_scene(C);
const Editing *ed = SEQ_editing_get(scene);
const Sequence *seq = ed->act_seq;
if (seq == nullptr) {
return OPERATOR_CANCELLED;
}
MutableSpan handles = SEQ_retiming_handles_get(seq);
SeqRetimingHandle *handle = nullptr;
if (RNA_struct_property_is_set(op->ptr, "handle_index")) {
const int handle_index = RNA_int_get(op->ptr, "handle_index");
BLI_assert(handle_index < handles.size());
handle = &handles[handle_index];
}
else {
handle = closest_retiming_handle_get(C, seq, event->mval[0]);
}
if (handle == nullptr) {
BKE_report(op->reports, RPT_ERROR, "No handle available");
return OPERATOR_CANCELLED;
}
RNA_float_set(op->ptr, "speed", SEQ_retiming_handle_speed_get(seq, handle) * 100.0f);
RNA_int_set(op->ptr, "handle_index", SEQ_retiming_handle_index_get(seq, handle));
return WM_operator_props_popup(C, op, event);
}
void SEQUENCER_OT_retiming_segment_speed_set(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Speed";
ot->description = "Set speed of retimed segment";
ot->idname = "SEQUENCER_OT_retiming_segment_speed_set";
/* api callbacks */
ot->invoke = sequencer_retiming_segment_speed_set_invoke;
ot->exec = sequencer_retiming_segment_speed_set_exec;
ot->poll = retiming_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
PropertyRNA *prop = RNA_def_int(ot->srna,
"handle_index",
0,
0,
INT_MAX,
"Handle Index",
"Index of handle to be removed",
0,
INT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
prop = RNA_def_float(ot->srna,
"speed",
100.0f,
0.001f,
FLT_MAX,
"Speed",
"New speed of retimed segment",
0.1f,
INT_MAX);
}
/** \} */

View File

@ -430,6 +430,7 @@ static void sequencer_gizmos(void)
WM_gizmotype_append(GIZMO_GT_retime_handle_add);
WM_gizmotype_append(GIZMO_GT_retime_handle);
WM_gizmotype_append(GIZMO_GT_retime_remove);
WM_gizmotype_append(GIZMO_GT_speed_set_remove);
WM_gizmogrouptype_append(SEQUENCER_GGT_gizmo2d);
WM_gizmogrouptype_append(SEQUENCER_GGT_gizmo2d_translate);

View File

@ -346,6 +346,7 @@ static float get_default_column_width(const ColumnValues &values)
return 3.0f * float_width;
case SPREADSHEET_VALUE_TYPE_COLOR:
case SPREADSHEET_VALUE_TYPE_BYTE_COLOR:
case SPREADSHEET_VALUE_TYPE_QUATERNION:
return 4.0f * float_width;
case SPREADSHEET_VALUE_TYPE_INSTANCES:
return 8.0f;

View File

@ -9,6 +9,7 @@
#include "BLI_color.hh"
#include "BLI_cpp_type.hh"
#include "BLI_hash.hh"
#include "BLI_math_quaternion_types.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_string.h"
#include "BLI_string_ref.hh"
@ -56,6 +57,9 @@ eSpreadsheetColumnValueType cpp_type_to_column_type(const CPPType &type)
if (type.is<ColorGeometry4b>()) {
return SPREADSHEET_VALUE_TYPE_BYTE_COLOR;
}
if (type.is<math::Quaternion>()) {
return SPREADSHEET_VALUE_TYPE_QUATERNION;
}
return SPREADSHEET_VALUE_TYPE_UNKNOWN;
}

View File

@ -5,6 +5,7 @@
#include <iomanip>
#include <sstream>
#include "BLI_math_quaternion_types.hh"
#include "BLI_math_vector_types.hh"
#include "BKE_geometry_set.hh"
@ -204,6 +205,10 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer {
const ColorGeometry4b value = data.get<ColorGeometry4b>(real_index);
this->draw_byte_color(params, value);
}
else if (data.type().is<math::Quaternion>()) {
const float4 value = float4(data.get<math::Quaternion>(real_index));
this->draw_float_vector(params, Span(&value.x, 4));
}
else if (data.type().is<bke::InstanceReference>()) {
const bke::InstanceReference value = data.get<bke::InstanceReference>(real_index);
switch (value.type()) {

View File

@ -107,6 +107,7 @@ static std::string value_string(const SpreadsheetRowFilter &row_filter,
}
case SPREADSHEET_VALUE_TYPE_STRING:
return row_filter.value_string;
case SPREADSHEET_VALUE_TYPE_QUATERNION:
case SPREADSHEET_VALUE_TYPE_UNKNOWN:
return "";
}
@ -250,7 +251,8 @@ static void spreadsheet_filter_panel_draw(const bContext *C, Panel *panel)
uiItemR(layout, filter_ptr, "value_string", 0, IFACE_("Value"), ICON_NONE);
break;
case SPREADSHEET_VALUE_TYPE_UNKNOWN:
uiItemL(layout, IFACE_("Unknown column type"), ICON_ERROR);
case SPREADSHEET_VALUE_TYPE_QUATERNION:
uiItemL(layout, IFACE_("Unsupported column type"), ICON_ERROR);
break;
}
}

View File

@ -27,7 +27,6 @@ set(SRC
text_autocomplete.cc
text_draw.cc
text_format.cc
text_format_lua.cc
text_format_osl.cc
text_format_pov.cc
text_format_pov_ini.cc

View File

@ -481,7 +481,6 @@ void ED_spacetype_text(void)
/* register formatters */
ED_text_format_register_py();
ED_text_format_register_osl();
ED_text_format_register_lua();
ED_text_format_register_pov();
ED_text_format_register_pov_ini();
}

View File

@ -316,8 +316,6 @@ static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *
return OPERATOR_CANCELLED;
}
static int doc_scroll = 0;
static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
/* NOTE(@ideasman42): this code could be refactored or rewritten. */
@ -332,9 +330,6 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
if (texttool_suggest_first()) {
tools |= TOOL_SUGG_LIST;
}
if (texttool_docs_get()) {
tools |= TOOL_DOCUMENT;
}
}
switch (event->type) {
@ -356,21 +351,12 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
swallow = 1;
draw = 1;
}
if (tools & TOOL_DOCUMENT) {
texttool_docs_clear();
doc_scroll = 0;
draw = 1;
}
retval = OPERATOR_FINISHED;
}
else {
if (tools & TOOL_SUGG_LIST) {
texttool_suggest_clear();
}
if (tools & TOOL_DOCUMENT) {
texttool_docs_clear();
doc_scroll = 0;
}
retval = OPERATOR_CANCELLED;
}
draw = 1;
@ -382,10 +368,6 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
if (tools & TOOL_SUGG_LIST) {
texttool_suggest_clear();
}
else if (tools & TOOL_DOCUMENT) {
texttool_docs_clear();
doc_scroll = 0;
}
else {
draw = swallow = 0;
}
@ -403,11 +385,6 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
swallow = 1;
draw = 1;
}
if (tools & TOOL_DOCUMENT) {
texttool_docs_clear();
doc_scroll = 0;
draw = 1;
}
retval = OPERATOR_FINISHED;
}
break;
@ -443,10 +420,6 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
}
}
}
if (tools & TOOL_DOCUMENT) {
texttool_docs_clear();
doc_scroll = 0;
}
}
break;
case EVT_RIGHTARROWKEY:
@ -480,10 +453,6 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
}
}
}
if (tools & TOOL_DOCUMENT) {
texttool_docs_clear();
doc_scroll = 0;
}
}
break;
case EVT_PAGEDOWNKEY:
@ -492,12 +461,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
case WHEELDOWNMOUSE:
case EVT_DOWNARROWKEY:
if (event->val == KM_PRESS) {
if (tools & TOOL_DOCUMENT) {
doc_scroll++;
swallow = 1;
draw = 1;
}
else if (tools & TOOL_SUGG_LIST) {
if (tools & TOOL_SUGG_LIST) {
SuggItem *sel = texttool_suggest_selected();
if (!sel) {
texttool_suggest_select(texttool_suggest_first());
@ -526,14 +490,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
case WHEELUPMOUSE:
case EVT_UPARROWKEY:
if (event->val == KM_PRESS) {
if (tools & TOOL_DOCUMENT) {
if (doc_scroll > 0) {
doc_scroll--;
}
swallow = 1;
draw = 1;
}
else if (tools & TOOL_SUGG_LIST) {
if (tools & TOOL_SUGG_LIST) {
SuggItem *sel = texttool_suggest_selected();
while (sel && scroll--) {
if (sel != texttool_suggest_first() && sel->prev) {
@ -560,11 +517,6 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
texttool_suggest_clear();
draw = 1;
}
if (tools & TOOL_DOCUMENT) {
texttool_docs_clear();
doc_scroll = 0;
draw = 1;
}
#endif
}

View File

@ -1031,120 +1031,6 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back)
/** \name Draw Documentation
* \{ */
#if 0
static void draw_documentation(const SpaceText *st, ARegion *region)
{
TextDrawContext tdc = {0};
TextLine *tmp;
char *docs, buf[DOC_WIDTH + 1], *p;
int i, br, lines;
int boxw, boxh, l, x, y /* , top */ /* UNUSED */;
if (!st || !st->text) {
return;
}
if (!texttool_text_is_active(st->text)) {
return;
}
docs = texttool_docs_get();
if (!docs) {
return;
}
text_draw_context_init(st, &tdc);
/* Count the visible lines to the cursor */
for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) {
/* pass */
}
if (l < 0) {
return;
}
x = TXT_BODY_LEFT(st) + (st->runtime.cwidth_px * (st->text->curc - st->left));
if (texttool_suggest_first()) {
x += SUGG_LIST_WIDTH * st->runtime.cwidth_px + 50;
}
/* top = */ /* UNUSED */ y = region->winy - st->runtime.lheight_px * l - 2;
boxw = DOC_WIDTH * st->runtime.cwidth_px + 20;
boxh = (DOC_HEIGHT + 1) * TXT_LINE_HEIGHT(st);
/* Draw panel */
uint pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformThemeColor(TH_BACK);
immRecti(pos, x, y, x + boxw, y - boxh);
immUniformThemeColor(TH_SHADE1);
immBegin(GPU_PRIM_LINE_LOOP, 4);
immVertex2i(pos, x, y);
immVertex2i(pos, x + boxw, y);
immVertex2i(pos, x + boxw, y - boxh);
immVertex2i(pos, x, y - boxh);
immEnd();
immBegin(GPU_PRIM_LINE_LOOP, 3);
immVertex2i(pos, x + boxw - 10, y - 7);
immVertex2i(pos, x + boxw - 4, y - 7);
immVertex2i(pos, x + boxw - 7, y - 2);
immEnd();
immBegin(GPU_PRIM_LINE_LOOP, 3);
immVertex2i(pos, x + boxw - 10, y - boxh + 7);
immVertex2i(pos, x + boxw - 4, y - boxh + 7);
immVertex2i(pos, x + boxw - 7, y - boxh + 2);
immEnd();
immUnbindProgram();
UI_FontThemeColor(tdc.font_id, TH_TEXT);
i = 0;
br = DOC_WIDTH;
lines = 0; /* XXX -doc_scroll; */
for (p = docs; *p; p++) {
if (*p == '\r' && *(++p) != '\n') {
*(--p) = '\n'; /* Fix line endings */
}
if (ELEM(*p, ' ', '\t')) {
br = i;
}
else if (*p == '\n') {
buf[i] = '\0';
if (lines >= 0) {
y -= st->runtime.lheight_px;
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, nullptr);
}
i = 0;
br = DOC_WIDTH;
lines++;
}
buf[i++] = *p;
if (i == DOC_WIDTH) { /* Reached the width, go to last break and wrap there */
buf[br] = '\0';
if (lines >= 0) {
y -= st->runtime.lheight_px;
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, nullptr);
}
p -= i - br - 1; /* Rewind pointer to last break */
i = 0;
br = DOC_WIDTH;
lines++;
}
if (lines >= DOC_HEIGHT) {
break;
}
}
}
#endif
/** \} */
/* -------------------------------------------------------------------- */
/** \name Draw Suggestion List
* \{ */

View File

@ -112,7 +112,6 @@ void ED_text_format_register(TextFormatType *tft);
/* formatters */
void ED_text_format_register_py();
void ED_text_format_register_osl();
void ED_text_format_register_lua();
void ED_text_format_register_pov();
void ED_text_format_register_pov_ini();

View File

@ -1,350 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup sptext
*/
#include <cstring>
#include "BLI_blenlib.h"
#include "DNA_space_types.h"
#include "DNA_text_types.h"
#include "BKE_text.h"
#include "text_format.hh"
/* *** Lua Keywords (for format_line) *** */
/**
* Checks the specified source string for a Lua keyword (minus boolean & 'nil').
* This name must start at the beginning of the source string and must be
* followed by a non-identifier (see #text_check_identifier(char)) or null char.
*
* If a keyword is found, the length of the matching word is returned.
* Otherwise, -1 is returned.
*
* See:
* http://www.lua.org/manual/5.1/manual.html#2.1
*/
static int txtfmt_lua_find_keyword(const char *string)
{
int i, len;
/* Keep aligned args for readability. */
/* clang-format off */
if (STR_LITERAL_STARTSWITH(string, "and", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "do", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "end", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "function", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "in", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "local", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "not", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "or", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "return", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "then", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "until", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
} else { i = 0;
}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
if (i == 0 || text_check_identifier(string[i])) {
return -1;
}
return i;
}
/**
* Checks the specified source string for a Lua special name/function. This
* name must start at the beginning of the source string and must be followed
* by a non-identifier (see *text_check_identifier(char)) or null character.
*
* If a special name is found, the length of the matching name is returned.
* Otherwise, -1 is returned.
*
* See:
* http://www.lua.org/manual/5.1/manual.html#5.1
*/
static int txtfmt_lua_find_specialvar(const char *string)
{
int i, len;
/* Keep aligned args for readability. */
/* clang-format off */
if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "collectgarbage", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "dofile", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "error", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "_G", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "getfenv", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "getmetatable", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "__index", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "ipairs", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "load", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "loadfile", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "loadstring", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "next", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "pairs", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "pcall", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "print", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "rawequal", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "rawget", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "rawset", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "select", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "setfenv", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "setmetatable", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "tonumber", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "tostring", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "type", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "unpack", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "_VERSION", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "xpcall", len)) { i = len;
} else { i = 0;
}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
if (i == 0 || text_check_identifier(string[i])) {
return -1;
}
return i;
}
static int txtfmt_lua_find_bool(const char *string)
{
int i, len;
/* Keep aligned args for readability. */
/* clang-format off */
if (STR_LITERAL_STARTSWITH(string, "nil", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "true", len)) { i = len;
} else if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
} else { i = 0;
}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
if (i == 0 || text_check_identifier(string[i])) {
return -1;
}
return i;
}
static char txtfmt_lua_format_identifier(const char *str)
{
char fmt;
/* Keep aligned args for readability. */
/* clang-format off */
if (txtfmt_lua_find_specialvar(str) != -1) { fmt = FMT_TYPE_SPECIAL;
} else if (txtfmt_lua_find_keyword(str) != -1) { fmt = FMT_TYPE_KEYWORD;
} else { fmt = FMT_TYPE_DEFAULT;
}
/* clang-format on */
return fmt;
}
static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_next)
{
FlattenString fs;
const char *str;
char *fmt;
char cont_orig, cont, find, prev = ' ';
int len, i;
/* Get continuation from previous line */
if (line->prev && line->prev->format != nullptr) {
fmt = line->prev->format;
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
BLI_assert((FMT_CONT_ALL & cont) == cont);
}
else {
cont = FMT_CONT_NOP;
}
/* Get original continuation from this line */
if (line->format != nullptr) {
fmt = line->format;
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
}
else {
cont_orig = 0xFF;
}
len = flatten_string(st, &fs, line->line);
str = fs.buf;
if (!text_check_format_len(line, len)) {
flatten_string_free(&fs);
return;
}
fmt = line->format;
while (*str) {
/* Handle escape sequences by skipping both \ and next char */
if (*str == '\\') {
*fmt = prev;
fmt++;
str++;
if (*str == '\0') {
break;
}
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
continue;
}
/* Handle continuations */
if (cont) {
/* Multi-line comments */
if (cont & FMT_CONT_COMMENT_C) {
if (*str == ']' && *(str + 1) == ']') {
*fmt = FMT_TYPE_COMMENT;
fmt++;
str++;
*fmt = FMT_TYPE_COMMENT;
cont = FMT_CONT_NOP;
}
else {
*fmt = FMT_TYPE_COMMENT;
}
/* Handle other comments */
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
if (*str == find) {
cont = 0;
}
*fmt = FMT_TYPE_STRING;
}
str += BLI_str_utf8_size_safe(str) - 1;
}
/* Not in a string... */
else {
/* Multi-line comments */
if (*str == '-' && *(str + 1) == '-' && *(str + 2) == '[' && *(str + 3) == '[') {
cont = FMT_CONT_COMMENT_C;
*fmt = FMT_TYPE_COMMENT;
fmt++;
str++;
*fmt = FMT_TYPE_COMMENT;
fmt++;
str++;
*fmt = FMT_TYPE_COMMENT;
fmt++;
str++;
*fmt = FMT_TYPE_COMMENT;
}
/* Single line comment */
else if (*str == '-' && *(str + 1) == '-') {
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
}
else if (ELEM(*str, '"', '\'')) {
/* Strings */
find = *str;
cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE;
*fmt = FMT_TYPE_STRING;
}
/* White-space (all white-space has been converted to spaces). */
else if (*str == ' ') {
*fmt = FMT_TYPE_WHITESPACE;
}
/* Numbers (digits not part of an identifier and periods followed by digits) */
else if ((prev != FMT_TYPE_DEFAULT && text_check_digit(*str)) ||
(*str == '.' && text_check_digit(*(str + 1))))
{
*fmt = FMT_TYPE_NUMERAL;
}
/* Booleans */
else if (prev != FMT_TYPE_DEFAULT && (i = txtfmt_lua_find_bool(str)) != -1) {
if (i > 0) {
text_format_fill_ascii(&str, &fmt, FMT_TYPE_NUMERAL, i);
}
else {
str += BLI_str_utf8_size_safe(str) - 1;
*fmt = FMT_TYPE_DEFAULT;
}
}
/* Punctuation */
else if ((*str != '#') && text_check_delim(*str)) {
*fmt = FMT_TYPE_SYMBOL;
}
/* Identifiers and other text (no previous white-space/delimiters so text continues). */
else if (prev == FMT_TYPE_DEFAULT) {
str += BLI_str_utf8_size_safe(str) - 1;
*fmt = FMT_TYPE_DEFAULT;
}
/* Not white-space, a digit, punctuation, or continuing text.
* Must be new, check for special words. */
else {
/* Keep aligned arguments for readability. */
/* clang-format off */
/* Special `vars(v)` or built-in `keywords(b)` */
/* keep in sync with `txtfmt_osl_format_identifier()`. */
if ((i = txtfmt_lua_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
} else if ((i = txtfmt_lua_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD;
}
/* clang-format on */
if (i > 0) {
text_format_fill_ascii(&str, &fmt, prev, i);
}
else {
str += BLI_str_utf8_size_safe(str) - 1;
*fmt = FMT_TYPE_DEFAULT;
}
}
}
prev = *fmt;
fmt++;
str++;
}
/* Terminate and add continuation char */
*fmt = '\0';
fmt++;
*fmt = cont;
/* If continuation has changed and we're allowed, process the next line */
if (cont != cont_orig && do_next && line->next) {
txtfmt_lua_format_line(st, line->next, do_next);
}
flatten_string_free(&fs);
}
void ED_text_format_register_lua()
{
static TextFormatType tft = {nullptr};
static const char *ext[] = {"lua", nullptr};
tft.format_identifier = txtfmt_lua_format_identifier;
tft.format_line = txtfmt_lua_format_line;
tft.ext = ext;
tft.comment_line = "--";
ED_text_format_register(&tft);
}

View File

@ -63,7 +63,6 @@ void text_update_cursor_moved(struct bContext *C);
#define DOC_HEIGHT 10
#define TOOL_SUGG_LIST 0x01
#define TOOL_DOCUMENT 0x02
int wrap_width(const struct SpaceText *st, struct ARegion *region);
/**

View File

@ -590,6 +590,9 @@ static void handle_armature_parent_orientation(Object *ob, float r_mat[3][3])
if (active_pchan && active_pchan->parent) {
/* For child, show parent local regardless if "local location" is set for parent bone. */
transform_orientations_create_from_axis(r_mat, UNPACK3(active_pchan->parent->pose_mat));
float ob_orientations_mat[3][3];
transform_orientations_create_from_axis(ob_orientations_mat, UNPACK3(ob->object_to_world));
mul_m3_m3_pre(r_mat, ob_orientations_mat);
return;
}

View File

@ -690,10 +690,10 @@ void Controller::ComputeSteerableViewMap()
img[i] = new GrayImage(_pView->width(), _pView->height());
for (unsigned int y = 0; y < img[i]->height(); ++y) {
for (unsigned int x = 0; x < img[i]->width(); ++x) {
//img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y)) / 255.0f);
img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y)));
// img[i]->setPixel(x, y, float(qGray(qimg.pixel(x, y))) / 255.0f);
img[i]->setPixel(x, y, float(qGray(qimg.pixel(x, y))));
// float c = qGray(qimg.pixel(x, y));
//img[i]->setPixel(x, y, qGray(qimg.pixel(x, y)));
// img[i]->setPixel(x, y, qGray(qimg.pixel(x, y)));
}
}
offscreenBuffer.DetachNode(ng[i]);

View File

@ -6,6 +6,7 @@
#include "BLI_cpp_type_make.hh"
#include "BLI_cpp_types_make.hh"
#include "BLI_math_matrix_types.hh"
#include "BLI_math_quaternion_types.hh"
#include "BLI_math_vector_types.hh"
#include "FN_field_cpp_type_make.hh"
@ -16,6 +17,7 @@ FN_FIELD_CPP_TYPE_MAKE(blender::float2);
FN_FIELD_CPP_TYPE_MAKE(blender::float3);
FN_FIELD_CPP_TYPE_MAKE(blender::ColorGeometry4f);
FN_FIELD_CPP_TYPE_MAKE(blender::ColorGeometry4b);
FN_FIELD_CPP_TYPE_MAKE(blender::math::Quaternion);
FN_FIELD_CPP_TYPE_MAKE(bool);
FN_FIELD_CPP_TYPE_MAKE(int8_t);
FN_FIELD_CPP_TYPE_MAKE(int32_t);
@ -31,6 +33,7 @@ void FN_register_cpp_types()
FN_FIELD_CPP_TYPE_REGISTER(blender::float3);
FN_FIELD_CPP_TYPE_REGISTER(blender::ColorGeometry4f);
FN_FIELD_CPP_TYPE_REGISTER(blender::ColorGeometry4b);
FN_FIELD_CPP_TYPE_REGISTER(blender::math::Quaternion);
FN_FIELD_CPP_TYPE_REGISTER(bool);
FN_FIELD_CPP_TYPE_REGISTER(int8_t);
FN_FIELD_CPP_TYPE_REGISTER(int32_t);

View File

@ -793,8 +793,6 @@ if(WITH_GPU_BUILDTIME_SHADER_BUILDER)
intern/gpu_shader_builder_stubs.cc
${shader_create_info_list_file}
)
setup_platform_linker_flags(shader_builder)
target_link_libraries(shader_builder PUBLIC buildinfoobj)
else()
if(WIN32)
@ -809,8 +807,9 @@ if(WITH_GPU_BUILDTIME_SHADER_BUILDER)
${shader_create_info_list_file}
${MANIFEST}
)
endif()
setup_platform_linker_flags(shader_builder)
target_link_libraries(shader_builder PUBLIC
bf_gpu
bf_intern_clog
@ -848,6 +847,7 @@ if(WITH_GTESTS)
tests/gpu_testing.cc
tests/buffer_texture_test.cc
tests/compute_test.cc
tests/framebuffer_test.cc
tests/immediate_test.cc
tests/index_buffer_test.cc

View File

@ -271,5 +271,36 @@ void DRW_cdlayer_attr_aliases_add(struct GPUVertFormat * /*format*/,
{
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Stubs of IMB_imbuf.h
* \{ */
struct ImBuf *IMB_ibImageFromMemory(const unsigned char * /*mem*/,
size_t /*size*/,
int /*flags*/,
char /*colorspace*/[IM_MAX_SPACE],
const char * /*descr*/)
{
BLI_assert_unreachable();
return nullptr;
}
struct ImBuf *IMB_allocFromBuffer(const uint8_t * /*rect*/,
const float * /*rectf*/,
unsigned int /*w*/,
unsigned int /*h*/,
unsigned int /*channels*/)
{
BLI_assert_unreachable();
return nullptr;
}
bool IMB_saveiff(struct ImBuf * /*ibuf*/, const char * /*filepath*/, int /*flags*/)
{
BLI_assert_unreachable();
return false;
}
/** \} */
}

View File

@ -755,7 +755,8 @@ inline size_t to_bytesize(eGPUTextureFormat tex_format, eGPUDataFormat data_form
* Standard component len calculation does not apply, as the texture formats contain multiple
* channels, but associated data format contains several compacted components. */
if ((tex_format == GPU_R11F_G11F_B10F && data_format == GPU_DATA_10_11_11_REV) ||
(tex_format == GPU_RGB10_A2 && data_format == GPU_DATA_2_10_10_10_REV))
((tex_format == GPU_RGB10_A2 || tex_format == GPU_RGB10_A2UI) &&
data_format == GPU_DATA_2_10_10_10_REV))
{
return 4;
}

View File

@ -3113,6 +3113,14 @@ std::string MSLGeneratorInterface::generate_msl_fragment_input_population()
<< this->vertex_output_varyings[0].name << ";" << std::endl;
}
/* Assign default gl_FragDepth.
* If gl_FragDepth is used, it should default to the original depth value. Resolves #107159 where
* overlay_wireframe_frag may not write to gl_FragDepth. */
if (this->uses_gl_FragDepth) {
out << "\t" << shader_stage_inst_name << ".gl_FragDepth = " << shader_stage_inst_name
<< ".gl_FragCoord.z;" << std::endl;
}
/* NOTE: We will only assign to the intersection of the vertex output and fragment input.
* Fragment input represents varying variables which are declared (but are not necessarily
* used). The Vertex out defines the set which is passed into the fragment shader, which

View File

@ -484,6 +484,7 @@ inline std::string tex_data_format_to_msl_type_str(eGPUDataFormat type)
case GPU_DATA_UINT_24_8:
return "uint"; /* Problematic type - but will match alignment. */
case GPU_DATA_10_11_11_REV:
case GPU_DATA_2_10_10_10_REV:
return "float"; /* Problematic type - each component will be read as a float. */
default:
BLI_assert(false);
@ -509,6 +510,7 @@ inline std::string tex_data_format_to_msl_texture_template_type(eGPUDataFormat t
case GPU_DATA_UINT_24_8:
return "uint"; /* Problematic type. */
case GPU_DATA_10_11_11_REV:
case GPU_DATA_2_10_10_10_REV:
return "float"; /* Problematic type. */
default:
BLI_assert(false);

View File

@ -580,7 +580,8 @@ void gpu::MTLTexture::update_sub(
}
/* Safety Checks. */
if (type == GPU_DATA_UINT_24_8 || type == GPU_DATA_10_11_11_REV) {
if (type == GPU_DATA_UINT_24_8 || type == GPU_DATA_10_11_11_REV ||
type == GPU_DATA_2_10_10_10_REV) {
BLI_assert(can_use_direct_blit &&
"Special input data type must be a 1-1 mapping with destination texture as it "
"cannot easily be split");
@ -747,7 +748,7 @@ void gpu::MTLTexture::update_sub(
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(staging_buffer, 0, 1);
cs.bind_compute_buffer(staging_buffer, 0, 1, true);
cs.bind_compute_texture(texture_handle, 0);
[compute_encoder
dispatchThreads:MTLSizeMake(extent[0], 1, 1) /* Width, Height, Layer */
@ -767,7 +768,7 @@ void gpu::MTLTexture::update_sub(
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(staging_buffer, 0, 1);
cs.bind_compute_buffer(staging_buffer, 0, 1, true);
cs.bind_compute_texture(texture_handle, 0);
[compute_encoder
dispatchThreads:MTLSizeMake(extent[0], extent[1], 1) /* Width, layers, nil */
@ -827,7 +828,7 @@ void gpu::MTLTexture::update_sub(
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(staging_buffer, 0, 1);
cs.bind_compute_buffer(staging_buffer, 0, 1, true);
cs.bind_compute_texture(texture_handle, 0);
[compute_encoder
dispatchThreads:MTLSizeMake(
@ -848,7 +849,7 @@ void gpu::MTLTexture::update_sub(
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(staging_buffer, 0, 1);
cs.bind_compute_buffer(staging_buffer, 0, 1, true);
cs.bind_compute_texture(texture_handle, 0);
[compute_encoder dispatchThreads:MTLSizeMake(extent[0],
extent[1],
@ -891,7 +892,7 @@ void gpu::MTLTexture::update_sub(
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(staging_buffer, 0, 1);
cs.bind_compute_buffer(staging_buffer, 0, 1, true);
cs.bind_compute_texture(texture_handle, 0);
[compute_encoder
dispatchThreads:MTLSizeMake(
@ -1454,9 +1455,13 @@ void gpu::MTLTexture::read_internal(int mip,
BLI_assert(validate_data_format(format_, data_format));
}
/* SPECIAL Workaround for R11G11B10 textures requesting a read using: GPU_DATA_10_11_11_REV. */
if (desired_output_format == GPU_DATA_10_11_11_REV) {
BLI_assert(format_ == GPU_R11F_G11F_B10F);
/* SPECIAL Workaround for R11G11B10, GPU_RGB10_A2, GPU_RGB10_A2UI textures requesting a read
* using: GPU_DATA_10_11_11_REV. */
if (desired_output_format == GPU_DATA_10_11_11_REV ||
desired_output_format == GPU_DATA_2_10_10_10_REV)
{
BLI_assert(format_ == GPU_R11F_G11F_B10F || format_ == GPU_RGB10_A2 ||
format_ == GPU_RGB10_A2UI);
/* override parameters - we'll be able to use simple copy, as bpp will match at 4 bytes. */
image_bpp = sizeof(int);
@ -1537,12 +1542,54 @@ void gpu::MTLTexture::read_internal(int mip,
/* Perform per-texture type read. */
switch (type_) {
case GPU_TEXTURE_1D: {
if (can_use_simple_read) {
/* Use Blit Encoder READ. */
id<MTLBlitCommandEncoder> enc = ctx->main_command_buffer.ensure_begin_blit_encoder();
if (G.debug & G_DEBUG_GPU) {
[enc insertDebugSignpost:@"GPUTextureRead1D"];
}
[enc copyFromTexture:read_texture
sourceSlice:0
sourceLevel:mip
sourceOrigin:MTLOriginMake(x_off, 0, 0)
sourceSize:MTLSizeMake(width, 1, 1)
toBuffer:destination_buffer
destinationOffset:0
destinationBytesPerRow:bytes_per_row
destinationBytesPerImage:bytes_per_image];
copy_successful = true;
}
else {
/* Use Compute READ. */
id<MTLComputeCommandEncoder> compute_encoder =
ctx->main_command_buffer.ensure_begin_compute_encoder();
id<MTLComputePipelineState> pso = texture_read_1d_get_kernel(
compute_specialization_kernel);
TextureReadParams params = {
mip,
{width, 1, 1},
{x_off, 0, 0},
};
/* Bind resources via compute state for optimal state caching performance. */
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(destination_buffer, 0, 1, true);
cs.bind_compute_texture(read_texture, 0);
[compute_encoder dispatchThreads:MTLSizeMake(width, 1, 1) /* Width, Height, Layer */
threadsPerThreadgroup:MTLSizeMake(8, 8, 1)];
copy_successful = true;
}
} break;
case GPU_TEXTURE_2D: {
if (can_use_simple_read) {
/* Use Blit Encoder READ. */
id<MTLBlitCommandEncoder> enc = ctx->main_command_buffer.ensure_begin_blit_encoder();
if (G.debug & G_DEBUG_GPU) {
[enc insertDebugSignpost:@"GPUTextureRead"];
[enc insertDebugSignpost:@"GPUTextureRead2D"];
}
[enc copyFromTexture:read_texture
sourceSlice:0
@ -1572,7 +1619,7 @@ void gpu::MTLTexture::read_internal(int mip,
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(destination_buffer, 0, 1);
cs.bind_compute_buffer(destination_buffer, 0, 1, true);
cs.bind_compute_texture(read_texture, 0);
[compute_encoder dispatchThreads:MTLSizeMake(width, height, 1) /* Width, Height, Layer */
threadsPerThreadgroup:MTLSizeMake(8, 8, 1)];
@ -1585,7 +1632,7 @@ void gpu::MTLTexture::read_internal(int mip,
/* Use Blit Encoder READ. */
id<MTLBlitCommandEncoder> enc = ctx->main_command_buffer.ensure_begin_blit_encoder();
if (G.debug & G_DEBUG_GPU) {
[enc insertDebugSignpost:@"GPUTextureRead"];
[enc insertDebugSignpost:@"GPUTextureRead2DArray"];
}
int base_slice = z_off;
int final_slice = base_slice + depth;
@ -1622,7 +1669,7 @@ void gpu::MTLTexture::read_internal(int mip,
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(destination_buffer, 0, 1);
cs.bind_compute_buffer(destination_buffer, 0, 1, true);
cs.bind_compute_texture(read_texture, 0);
[compute_encoder
dispatchThreads:MTLSizeMake(width, height, depth) /* Width, Height, Layer */
@ -1631,11 +1678,55 @@ void gpu::MTLTexture::read_internal(int mip,
}
} break;
case GPU_TEXTURE_3D: {
if (can_use_simple_read) {
/* Use Blit Encoder READ. */
id<MTLBlitCommandEncoder> enc = ctx->main_command_buffer.ensure_begin_blit_encoder();
if (G.debug & G_DEBUG_GPU) {
[enc insertDebugSignpost:@"GPUTextureRead3D"];
}
[enc copyFromTexture:read_texture
sourceSlice:0
sourceLevel:mip
sourceOrigin:MTLOriginMake(x_off, y_off, z_off)
sourceSize:MTLSizeMake(width, height, depth)
toBuffer:destination_buffer
destinationOffset:0
destinationBytesPerRow:bytes_per_row
destinationBytesPerImage:bytes_per_image];
copy_successful = true;
}
else {
/* Use Compute READ. */
id<MTLComputeCommandEncoder> compute_encoder =
ctx->main_command_buffer.ensure_begin_compute_encoder();
id<MTLComputePipelineState> pso = texture_read_3d_get_kernel(
compute_specialization_kernel);
TextureReadParams params = {
mip,
{width, height, depth},
{x_off, y_off, z_off},
};
/* Bind resources via compute state for optimal state caching performance. */
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(destination_buffer, 0, 1, true);
cs.bind_compute_texture(read_texture, 0);
[compute_encoder
dispatchThreads:MTLSizeMake(width, height, depth) /* Width, Height, Layer */
threadsPerThreadgroup:MTLSizeMake(4, 4, 4)];
copy_successful = true;
}
} break;
case GPU_TEXTURE_CUBE_ARRAY: {
if (can_use_simple_read) {
id<MTLBlitCommandEncoder> enc = ctx->main_command_buffer.ensure_begin_blit_encoder();
if (G.debug & G_DEBUG_GPU) {
[enc insertDebugSignpost:@"GPUTextureRead"];
[enc insertDebugSignpost:@"GPUTextureReadCubeArray"];
}
int base_slice = z_off;
int final_slice = base_slice + depth;

View File

@ -191,6 +191,9 @@ size_t get_mtl_format_bytesize(MTLPixelFormat tex_format)
case MTLPixelFormatRGBA8Uint:
case MTLPixelFormatRGBA8Sint:
case MTLPixelFormatRGBA8Unorm:
case MTLPixelFormatRGBA8Snorm:
case MTLPixelFormatRGB10A2Uint:
case MTLPixelFormatRGB10A2Unorm:
return 4;
case MTLPixelFormatRGBA32Uint:
case MTLPixelFormatRGBA32Sint:
@ -200,10 +203,13 @@ size_t get_mtl_format_bytesize(MTLPixelFormat tex_format)
case MTLPixelFormatRGBA16Sint:
case MTLPixelFormatRGBA16Float:
case MTLPixelFormatRGBA16Unorm:
case MTLPixelFormatRGBA16Snorm:
return 8;
case MTLPixelFormatRG8Uint:
case MTLPixelFormatRG8Sint:
case MTLPixelFormatRG8Unorm:
case MTLPixelFormatRG8Snorm:
case MTLPixelFormatRG8Unorm_sRGB:
return 2;
case MTLPixelFormatRG32Uint:
case MTLPixelFormatRG32Sint:
@ -212,6 +218,8 @@ size_t get_mtl_format_bytesize(MTLPixelFormat tex_format)
case MTLPixelFormatRG16Uint:
case MTLPixelFormatRG16Sint:
case MTLPixelFormatRG16Float:
case MTLPixelFormatRG16Unorm:
case MTLPixelFormatRG16Snorm:
return 4;
case MTLPixelFormatR8Uint:
case MTLPixelFormatR8Sint:
@ -225,6 +233,7 @@ size_t get_mtl_format_bytesize(MTLPixelFormat tex_format)
case MTLPixelFormatR16Sint:
case MTLPixelFormatR16Float:
case MTLPixelFormatR16Snorm:
case MTLPixelFormatR16Unorm:
return 2;
case MTLPixelFormatRG11B10Float:
return 4;
@ -249,6 +258,7 @@ int get_mtl_format_num_components(MTLPixelFormat tex_format)
case MTLPixelFormatRGBA8Uint:
case MTLPixelFormatRGBA8Sint:
case MTLPixelFormatRGBA8Unorm:
case MTLPixelFormatRGBA8Snorm:
case MTLPixelFormatRGBA32Uint:
case MTLPixelFormatRGBA32Sint:
case MTLPixelFormatRGBA32Float:
@ -256,7 +266,10 @@ int get_mtl_format_num_components(MTLPixelFormat tex_format)
case MTLPixelFormatRGBA16Sint:
case MTLPixelFormatRGBA16Float:
case MTLPixelFormatRGBA16Unorm:
case MTLPixelFormatRGBA16Snorm:
case MTLPixelFormatRGBA8Unorm_sRGB:
case MTLPixelFormatRGB10A2Uint:
case MTLPixelFormatRGB10A2Unorm:
return 4;
case MTLPixelFormatRG11B10Float:
@ -272,17 +285,21 @@ int get_mtl_format_num_components(MTLPixelFormat tex_format)
case MTLPixelFormatRG16Sint:
case MTLPixelFormatRG16Float:
case MTLPixelFormatDepth32Float_Stencil8:
case MTLPixelFormatRG16Snorm:
case MTLPixelFormatRG16Unorm:
return 2;
case MTLPixelFormatR8Uint:
case MTLPixelFormatR8Sint:
case MTLPixelFormatR8Unorm:
case MTLPixelFormatR8Snorm:
case MTLPixelFormatR32Uint:
case MTLPixelFormatR32Sint:
case MTLPixelFormatR32Float:
case MTLPixelFormatR16Uint:
case MTLPixelFormatR16Sint:
case MTLPixelFormatR16Float:
case MTLPixelFormatR16Unorm:
case MTLPixelFormatR16Snorm:
case MTLPixelFormatDepth32Float:
case MTLPixelFormatDepth16Unorm:

View File

@ -650,11 +650,11 @@ mat4x4 normalize_and_get_size(mat4x4 mat, out vec4 r_size)
mat2x2 adjoint(mat2x2 mat)
{
mat2x2 adj;
mat2x2 adj = mat2x2(0.0);
for (int c = 0; c < 2; c++) {
for (int r = 0; r < 2; r++) {
/* Copy other cells except the "cross" to compute the determinant. */
float tmp;
float tmp = 0.0;
for (int m_c = 0; m_c < 2; m_c++) {
for (int m_r = 0; m_r < 2; m_r++) {
if (m_c != c && m_r != r) {
@ -671,11 +671,11 @@ mat2x2 adjoint(mat2x2 mat)
}
mat3x3 adjoint(mat3x3 mat)
{
mat3x3 adj;
mat3x3 adj = mat3x3(0.0);
for (int c = 0; c < 3; c++) {
for (int r = 0; r < 3; r++) {
/* Copy other cells except the "cross" to compute the determinant. */
mat2x2 tmp;
mat2x2 tmp = mat2x2(0.0);
for (int m_c = 0; m_c < 3; m_c++) {
for (int m_r = 0; m_r < 3; m_r++) {
if (m_c != c && m_r != r) {
@ -694,11 +694,11 @@ mat3x3 adjoint(mat3x3 mat)
}
mat4x4 adjoint(mat4x4 mat)
{
mat4x4 adj;
mat4x4 adj = mat4x4(0.0);
for (int c = 0; c < 4; c++) {
for (int r = 0; r < 4; r++) {
/* Copy other cells except the "cross" to compute the determinant. */
mat3x3 tmp;
mat3x3 tmp = mat3x3(0.0);
for (int m_c = 0; m_c < 4; m_c++) {
for (int m_r = 0; m_r < 4; m_r++) {
if (m_c != c && m_r != r) {

View File

@ -146,7 +146,7 @@ int g_test_id = 0;
# define EXPECT_OP(OP, val1, val2) \
out_test[g_test_id++] = test_output( \
as_raw_data(val1), as_raw_data(val2), bool(OP), int(__LINE__), to_type(val1))
as_raw_data(val1), as_raw_data(val2), bool(all(OP)), int(__LINE__), to_type(val1))
#else
/** WORKAROUND: Fragment shader variant for older platform. */
@ -158,7 +158,7 @@ int g_test_id = 0;
} \
if (int(gl_FragCoord.y) == g_test_id - 1) { \
TestOutput to = test_output( \
as_raw_data(val1), as_raw_data(val2), bool(OP), int(__LINE__), to_type(val1)); \
as_raw_data(val1), as_raw_data(val2), bool(all(OP)), int(__LINE__), to_type(val1)); \
switch (int(gl_FragCoord.x)) { \
case 0: \
out_test = uvec4( \

View File

@ -0,0 +1,112 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#include "gpu_testing.hh"
#include "MEM_guardedalloc.h"
#include "BLI_math_vector_types.hh"
#include "GPU_capabilities.h"
#include "GPU_compute.h"
#include "GPU_storage_buffer.h"
#include "GPU_texture.h"
namespace blender::gpu::tests {
static void test_compute_direct()
{
if (!GPU_compute_shader_support()) {
/* We can't test as a the platform does not support compute shaders. */
GTEST_SKIP() << "Skipping test: platform not supported";
return;
}
static constexpr uint SIZE = 32;
/* Build compute shader. */
GPUShader *shader = GPU_shader_create_from_info_name("gpu_compute_2d_test");
EXPECT_NE(shader, nullptr);
/* Create texture to store result and attach to shader. */
GPUTexture *texture = GPU_texture_create_2d(
"gpu_shader_compute_2d", SIZE, SIZE, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_GENERAL, nullptr);
EXPECT_NE(texture, nullptr);
GPU_shader_bind(shader);
GPU_texture_image_bind(texture, GPU_shader_get_sampler_binding(shader, "img_output"));
/* Dispatch compute task. */
GPU_compute_dispatch(shader, SIZE, SIZE, 1);
/* Check if compute has been done. */
GPU_memory_barrier(GPU_BARRIER_TEXTURE_UPDATE);
float4 *data = static_cast<float4 *>(GPU_texture_read(texture, GPU_DATA_FLOAT, 0));
const float4 expected_result(1.0f, 0.5f, 0.2f, 1.0f);
EXPECT_NE(data, nullptr);
for (int index = 0; index < SIZE * SIZE; index++) {
EXPECT_EQ(data[index], expected_result);
}
MEM_freeN(data);
/* Cleanup. */
GPU_shader_unbind();
GPU_texture_unbind(texture);
GPU_texture_free(texture);
GPU_shader_free(shader);
}
GPU_TEST(compute_direct)
static void test_compute_indirect()
{
if (!GPU_compute_shader_support()) {
/* We can't test as a the platform does not support compute shaders. */
GTEST_SKIP() << "Skipping test: platform not supported";
return;
}
static constexpr uint SIZE = 32;
/* Build compute shader. */
GPUShader *shader = GPU_shader_create_from_info_name("gpu_compute_2d_test");
EXPECT_NE(shader, nullptr);
/* Create texture to store result and attach to shader. */
GPUTexture *texture = GPU_texture_create_2d(
"gpu_shader_compute_2d", SIZE, SIZE, 1, GPU_RGBA32F, GPU_TEXTURE_USAGE_GENERAL, nullptr);
EXPECT_NE(texture, nullptr);
GPU_texture_clear(texture, GPU_DATA_FLOAT, float4(0.0f));
GPU_shader_bind(shader);
GPU_texture_image_bind(texture, GPU_shader_get_sampler_binding(shader, "img_output"));
/* Generate compute tasks. */
uint4 commands[1] = {
{SIZE, SIZE, 1, 0},
};
GPUStorageBuf *compute_commands = GPU_storagebuf_create_ex(
sizeof(commands), &commands, GPU_USAGE_STATIC, __func__);
/* Dispatch compute task. */
GPU_compute_dispatch_indirect(shader, compute_commands);
/* Check if compute has been done. */
GPU_memory_barrier(GPU_BARRIER_TEXTURE_UPDATE);
float4 *data = static_cast<float4 *>(GPU_texture_read(texture, GPU_DATA_FLOAT, 0));
const float4 expected_result(1.0f, 0.5f, 0.2f, 1.0f);
EXPECT_NE(data, nullptr);
for (int index = 0; index < SIZE * SIZE; index++) {
EXPECT_EQ(data[index], expected_result);
}
MEM_freeN(data);
/* Cleanup. */
GPU_storagebuf_free(compute_commands);
GPU_shader_unbind();
GPU_texture_unbind(texture);
GPU_texture_free(texture);
GPU_shader_free(shader);
}
GPU_TEST(compute_indirect);
} // namespace blender::gpu::tests

View File

@ -108,9 +108,15 @@ void VKBackend::compute_dispatch(int groups_x_len, int groups_y_len, int groups_
command_buffer.dispatch(groups_x_len, groups_y_len, groups_z_len);
}
void VKBackend::compute_dispatch_indirect(StorageBuf * /*indirect_buf*/)
void VKBackend::compute_dispatch_indirect(StorageBuf *indirect_buf)
{
NOT_YET_IMPLEMENTED;
BLI_assert(indirect_buf);
VKContext &context = *VKContext::get();
context.state_manager_get().apply_bindings();
context.bind_compute_pipeline();
VKStorageBuffer &indirect_buffer = *unwrap(indirect_buf);
VKCommandBuffer &command_buffer = context.command_buffer_get();
command_buffer.dispatch(indirect_buffer);
}
Context *VKBackend::context_alloc(void *ghost_window, void *ghost_context)

View File

@ -13,6 +13,7 @@
#include "vk_index_buffer.hh"
#include "vk_memory.hh"
#include "vk_pipeline.hh"
#include "vk_storage_buffer.hh"
#include "vk_texture.hh"
#include "vk_vertex_buffer.hh"
@ -307,6 +308,12 @@ void VKCommandBuffer::dispatch(int groups_x_len, int groups_y_len, int groups_z_
vkCmdDispatch(vk_command_buffer_, groups_x_len, groups_y_len, groups_z_len);
}
void VKCommandBuffer::dispatch(VKStorageBuffer &command_buffer)
{
ensure_no_active_framebuffer();
vkCmdDispatchIndirect(vk_command_buffer_, command_buffer.vk_handle(), 0);
}
void VKCommandBuffer::submit()
{
ensure_no_active_framebuffer();

View File

@ -21,6 +21,7 @@ class VKFrameBuffer;
class VKIndexBuffer;
class VKPipeline;
class VKPushConstants;
class VKStorageBuffer;
class VKTexture;
class VKVertexBuffer;
@ -160,6 +161,7 @@ class VKCommandBuffer : NonCopyable, NonMovable {
const VkPipelineLayout vk_pipeline_layout,
const VkShaderStageFlags vk_shader_stages);
void dispatch(int groups_x_len, int groups_y_len, int groups_z_len);
void dispatch(VKStorageBuffer &command_buffer);
/** Copy the contents of a texture MIP level to the dst buffer. */
void copy(VKBuffer &dst_buffer, VKTexture &src_texture, Span<VkBufferImageCopy> regions);
void copy(VKTexture &dst_texture, VKBuffer &src_buffer, Span<VkBufferImageCopy> regions);

View File

@ -14,28 +14,32 @@
namespace blender::gpu {
void VKStorageBuffer::update(const void *data)
{
ensure_allocated();
buffer_.update(data);
}
void VKStorageBuffer::ensure_allocated()
{
if (!buffer_.is_allocated()) {
allocate();
}
buffer_.update(data);
}
void VKStorageBuffer::allocate()
{
buffer_.create(size_in_bytes_,
usage_,
static_cast<VkBufferUsageFlagBits>(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
static_cast<VkBufferUsageFlagBits>(VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT |
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
VK_BUFFER_USAGE_TRANSFER_DST_BIT));
debug::object_label(buffer_.vk_handle(), name_);
}
void VKStorageBuffer::bind(int slot)
{
ensure_allocated();
VKContext &context = *VKContext::get();
if (!buffer_.is_allocated()) {
allocate();
}
VKShader *shader = static_cast<VKShader *>(context.shader);
const VKShaderInterface &shader_interface = shader->interface_get();
const std::optional<VKDescriptorSet::Location> location =
@ -49,10 +53,8 @@ void VKStorageBuffer::unbind() {}
void VKStorageBuffer::clear(uint32_t clear_value)
{
ensure_allocated();
VKContext &context = *VKContext::get();
if (!buffer_.is_allocated()) {
allocate();
}
buffer_.clear(context, clear_value);
}
@ -61,14 +63,12 @@ void VKStorageBuffer::copy_sub(VertBuf * /*src*/,
uint /*src_offset*/,
uint /*copy_size*/)
{
NOT_YET_IMPLEMENTED;
}
void VKStorageBuffer::read(void *data)
{
if (!buffer_.is_allocated()) {
allocate();
}
ensure_allocated();
VKContext &context = *VKContext::get();
VKCommandBuffer &command_buffer = context.command_buffer_get();
command_buffer.submit();

View File

@ -45,8 +45,15 @@ class VKStorageBuffer : public StorageBuf {
return buffer_.size_in_bytes();
}
void ensure_allocated();
private:
void allocate();
};
static inline VKStorageBuffer *unwrap(StorageBuf *storage_buffer)
{
return static_cast<VKStorageBuffer *>(storage_buffer);
}
} // namespace blender::gpu

View File

@ -84,8 +84,7 @@ typedef struct CustomData {
* MUST be >= CD_NUMTYPES, but we can't use a define here.
* Correct size is ensured in CustomData_update_typemap assert().
*/
int typemap[52];
char _pad[4];
int typemap[53];
/** Number of layers, size of layers array. */
int totlayer, maxlayer;
/** In editmode, total size of all data layers. */
@ -181,8 +180,9 @@ typedef enum eCustomDataType {
CD_PROP_BOOL = 50,
CD_HAIRLENGTH = 51,
CD_PROP_QUATERNION = 52,
CD_NUMTYPES = 52,
CD_NUMTYPES = 53,
} eCustomDataType;
/* Bits for eCustomDataMask */
@ -224,6 +224,7 @@ typedef enum eCustomDataType {
#define CD_MASK_PROP_BOOL (1ULL << CD_PROP_BOOL)
#define CD_MASK_PROP_INT8 (1ULL << CD_PROP_INT8)
#define CD_MASK_PROP_INT32_2D (1ULL << CD_PROP_INT32_2D)
#define CD_MASK_PROP_QUATERNION (1ULL << CD_PROP_QUATERNION)
#define CD_MASK_HAIRLENGTH (1ULL << CD_HAIRLENGTH)
@ -237,7 +238,7 @@ typedef enum eCustomDataType {
#define CD_MASK_PROP_ALL \
(CD_MASK_PROP_FLOAT | CD_MASK_PROP_FLOAT2 | CD_MASK_PROP_FLOAT3 | CD_MASK_PROP_INT32 | \
CD_MASK_PROP_COLOR | CD_MASK_PROP_STRING | CD_MASK_PROP_BYTE_COLOR | CD_MASK_PROP_BOOL | \
CD_MASK_PROP_INT8 | CD_MASK_PROP_INT32_2D)
CD_MASK_PROP_INT8 | CD_MASK_PROP_INT32_2D | CD_MASK_PROP_QUATERNION)
/* All color attributes */
#define CD_MASK_COLOR_ALL (CD_MASK_PROP_COLOR | CD_MASK_PROP_BYTE_COLOR)

View File

@ -2028,6 +2028,7 @@ typedef enum eSpreadsheetColumnValueType {
SPREADSHEET_VALUE_TYPE_BYTE_COLOR = 8,
SPREADSHEET_VALUE_TYPE_INT8 = 9,
SPREADSHEET_VALUE_TYPE_INT32_2D = 10,
SPREADSHEET_VALUE_TYPE_QUATERNION = 11,
} eSpreadsheetColumnValueType;
/**

View File

@ -49,11 +49,11 @@ typedef struct vec3d {
typedef struct vec4i {
int x, y, z, w;
} vec4i;
*/
typedef struct vec4f {
float x, y, z, w;
} vec4f;
/*
typedef struct vec4d {
double x, y, z, w;
} vec4d;

View File

@ -42,6 +42,7 @@ const EnumPropertyItem rna_enum_attribute_type_items[] = {
{CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
{CD_PROP_INT8, "INT8", 0, "8-Bit Integer", "Smaller integer with a range from -128 to 127"},
{CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"},
{CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"},
{0, NULL, 0, NULL, NULL},
};
@ -70,6 +71,7 @@ const EnumPropertyItem rna_enum_attribute_type_with_auto_items[] = {
{CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
{CD_PROP_FLOAT2, "FLOAT2", 0, "2D Vector", "2D vector with floating-point values"},
{CD_PROP_INT32_2D, "INT32_2D", 0, "2D Integer Vector", "32-bit signed integer vector"},
{CD_PROP_QUATERNION, "QUATERNION", 0, "Quaternion", "Floating point quaternion rotation"},
{0, NULL, 0, NULL, NULL},
};
@ -168,6 +170,8 @@ static StructRNA *srna_by_custom_data_layer_type(const eCustomDataType type)
return &RNA_ByteIntAttribute;
case CD_PROP_INT32_2D:
return &RNA_Int2Attribute;
case CD_PROP_QUATERNION:
return &RNA_QuaternionAttribute;
default:
return NULL;
}
@ -301,6 +305,9 @@ static void rna_Attribute_data_begin(CollectionPropertyIterator *iter, PointerRN
case CD_PROP_INT32_2D:
struct_size = sizeof(int[2]);
break;
case CD_PROP_QUATERNION:
struct_size = sizeof(float[4]);
break;
default:
struct_size = 0;
length = 0;
@ -1069,6 +1076,40 @@ static void rna_def_attribute_int2(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
}
static void rna_def_attribute_quaternion(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "QuaternionAttribute", "Attribute");
RNA_def_struct_sdna(srna, "CustomDataLayer");
RNA_def_struct_ui_text(srna, "Quaternion Attribute", "Geometry attribute that stores rotation");
prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "QuaternionAttributeValue");
RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
RNA_def_property_collection_funcs(prop,
"rna_Attribute_data_begin",
"rna_iterator_array_next",
"rna_iterator_array_end",
"rna_iterator_array_get",
"rna_Attribute_data_length",
NULL,
NULL,
NULL);
srna = RNA_def_struct(brna, "QuaternionAttributeValue", NULL);
RNA_def_struct_sdna(srna, "vec4f");
RNA_def_struct_ui_text(
srna, "Quaternion Attribute Value", "Rotation value in geometry attribute");
prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Value", "Quaternion");
RNA_def_property_float_sdna(prop, NULL, "x");
RNA_def_property_array(prop, 4);
RNA_def_property_update(prop, 0, "rna_Attribute_update_data");
}
static void rna_def_attribute_float2(BlenderRNA *brna)
{
StructRNA *srna;
@ -1149,6 +1190,7 @@ static void rna_def_attribute(BlenderRNA *brna)
rna_def_attribute_byte_color(brna);
rna_def_attribute_int(brna);
rna_def_attribute_int2(brna);
rna_def_attribute_quaternion(brna);
rna_def_attribute_string(brna);
rna_def_attribute_bool(brna);
rna_def_attribute_float2(brna);

View File

@ -250,19 +250,19 @@ static void rna_def_latticepoint(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "LatticePoint", NULL);
srna = RNA_def_struct(brna, "LatticePoint", nullptr);
RNA_def_struct_sdna(srna, "BPoint");
RNA_def_struct_ui_text(srna, "LatticePoint", "Point in the lattice grid");
RNA_def_struct_path_func(srna, "rna_LatticePoint_path");
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "f1", SELECT);
RNA_def_property_boolean_sdna(prop, nullptr, "f1", SELECT);
RNA_def_property_ui_text(prop, "Point selected", "Selection status");
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 3);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_float_funcs(prop, "rna_LatticePoint_co_get", NULL, NULL);
RNA_def_property_float_funcs(prop, "rna_LatticePoint_co_get", nullptr, nullptr);
RNA_def_property_ui_text(
prop,
"Location",
@ -270,13 +270,13 @@ static void rna_def_latticepoint(BlenderRNA *brna)
"(edit/animate the Deformed Location instead)");
prop = RNA_def_property(srna, "co_deform", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "vec");
RNA_def_property_float_sdna(prop, nullptr, "vec");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Deformed Location", "");
RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "weight");
RNA_def_property_float_sdna(prop, nullptr, "weight");
RNA_def_property_range(prop, 0.01f, 100.0f);
RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
RNA_def_property_update(prop, 0, "rna_Lattice_update_data");
@ -287,10 +287,10 @@ static void rna_def_latticepoint(BlenderRNA *brna)
"rna_iterator_array_next",
"rna_iterator_array_end",
"rna_iterator_array_get",
NULL,
NULL,
NULL,
NULL);
nullptr,
nullptr,
nullptr,
nullptr);
RNA_def_property_struct_type(prop, "VertexGroupElement");
RNA_def_property_ui_text(
prop, "Groups", "Weights for the vertex groups this point is member of");
@ -307,8 +307,8 @@ static void rna_def_lattice(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_LATTICE_DATA);
prop = RNA_def_property(srna, "points_u", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pntsu");
RNA_def_property_int_funcs(prop, NULL, "rna_Lattice_points_u_set", NULL);
RNA_def_property_int_sdna(prop, nullptr, "pntsu");
RNA_def_property_int_funcs(prop, nullptr, "rna_Lattice_points_u_set", nullptr);
RNA_def_property_range(prop, 1, 64);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(
@ -317,8 +317,8 @@ static void rna_def_lattice(BlenderRNA *brna)
RNA_def_property_editable_func(prop, "rna_Lattice_size_editable");
prop = RNA_def_property(srna, "points_v", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pntsv");
RNA_def_property_int_funcs(prop, NULL, "rna_Lattice_points_v_set", NULL);
RNA_def_property_int_sdna(prop, nullptr, "pntsv");
RNA_def_property_int_funcs(prop, nullptr, "rna_Lattice_points_v_set", nullptr);
RNA_def_property_range(prop, 1, 64);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(
@ -327,8 +327,8 @@ static void rna_def_lattice(BlenderRNA *brna)
RNA_def_property_editable_func(prop, "rna_Lattice_size_editable");
prop = RNA_def_property(srna, "points_w", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pntsw");
RNA_def_property_int_funcs(prop, NULL, "rna_Lattice_points_w_set", NULL);
RNA_def_property_int_sdna(prop, nullptr, "pntsw");
RNA_def_property_int_funcs(prop, nullptr, "rna_Lattice_points_w_set", nullptr);
RNA_def_property_range(prop, 1, 64);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(
@ -337,39 +337,39 @@ static void rna_def_lattice(BlenderRNA *brna)
RNA_def_property_editable_func(prop, "rna_Lattice_size_editable");
prop = RNA_def_property(srna, "interpolation_type_u", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "typeu");
RNA_def_property_enum_sdna(prop, nullptr, "typeu");
RNA_def_property_enum_items(prop, rna_enum_keyblock_type_items);
RNA_def_property_ui_text(prop, "Interpolation Type U", "");
RNA_def_property_update(prop, 0, "rna_Lattice_update_data_editlatt");
prop = RNA_def_property(srna, "interpolation_type_v", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "typev");
RNA_def_property_enum_sdna(prop, nullptr, "typev");
RNA_def_property_enum_items(prop, rna_enum_keyblock_type_items);
RNA_def_property_ui_text(prop, "Interpolation Type V", "");
RNA_def_property_update(prop, 0, "rna_Lattice_update_data_editlatt");
prop = RNA_def_property(srna, "interpolation_type_w", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "typew");
RNA_def_property_enum_sdna(prop, nullptr, "typew");
RNA_def_property_enum_items(prop, rna_enum_keyblock_type_items);
RNA_def_property_ui_text(prop, "Interpolation Type W", "");
RNA_def_property_update(prop, 0, "rna_Lattice_update_data_editlatt");
prop = RNA_def_property(srna, "use_outside", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LT_OUTSIDE);
RNA_def_property_boolean_funcs(prop, NULL, "rna_Lattice_use_outside_set");
RNA_def_property_boolean_sdna(prop, nullptr, "flag", LT_OUTSIDE);
RNA_def_property_boolean_funcs(prop, nullptr, "rna_Lattice_use_outside_set");
RNA_def_property_ui_text(
prop, "Outside", "Only display and take into account the outer vertices");
RNA_def_property_update(prop, 0, "rna_Lattice_update_data_editlatt");
prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "vgroup");
RNA_def_property_string_sdna(prop, nullptr, "vgroup");
RNA_def_property_ui_text(
prop, "Vertex Group", "Vertex group to apply the influence of the lattice");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Lattice_vg_name_set");
RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Lattice_vg_name_set");
RNA_def_property_update(prop, 0, "rna_Lattice_update_data_editlatt");
prop = RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "key");
RNA_def_property_pointer_sdna(prop, nullptr, "key");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_clear_flag(prop, PROP_PTR_NO_OWNERSHIP);
RNA_def_property_ui_text(prop, "Shape Keys", "");
@ -381,14 +381,14 @@ static void rna_def_lattice(BlenderRNA *brna)
"rna_iterator_array_next",
"rna_iterator_array_end",
"rna_iterator_array_get",
NULL,
NULL,
NULL,
NULL);
nullptr,
nullptr,
nullptr,
nullptr);
RNA_def_property_ui_text(prop, "Points", "Points of the lattice");
prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Lattice_is_editmode_get", NULL);
RNA_def_property_boolean_funcs(prop, "rna_Lattice_is_editmode_get", nullptr);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");

View File

@ -39,7 +39,7 @@ void RNA_api_lattice(StructRNA *srna)
func = RNA_def_function(srna, "transform", "rna_Lattice_transform");
RNA_def_function_ui_description(func, "Transform lattice by a matrix");
parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
parm = RNA_def_float_matrix(func, "matrix", 4, 4, nullptr, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
RNA_def_boolean(func, "shape_keys", 0, "", "Transform Shape Keys");

View File

@ -607,16 +607,16 @@ static void rna_def_maskParent(BlenderRNA *brna)
static const EnumPropertyItem mask_id_type_items[] = {
{ID_MC, "MOVIECLIP", ICON_SEQUENCE, "Movie Clip", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem parent_type_items[] = {
{MASK_PARENT_POINT_TRACK, "POINT_TRACK", 0, "Point Track", ""},
{MASK_PARENT_PLANE_TRACK, "PLANE_TRACK", 0, "Plane Track", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
srna = RNA_def_struct(brna, "MaskParent", NULL);
srna = RNA_def_struct(brna, "MaskParent", nullptr);
RNA_def_struct_ui_text(srna, "Mask Parent", "Parenting settings for masking element");
/* Target Properties - ID-block to Drive */
@ -626,16 +626,16 @@ static void rna_def_maskParent(BlenderRNA *brna)
// RNA_def_property_editable_func(prop, "rna_maskSpline_id_editable");
/* NOTE: custom set function is ONLY to avoid rna setting a user for this. */
RNA_def_property_pointer_funcs(
prop, NULL, "rna_MaskParent_id_set", "rna_MaskParent_id_typef", NULL);
prop, nullptr, "rna_MaskParent_id_set", "rna_MaskParent_id_typef", nullptr);
RNA_def_property_ui_text(
prop, "ID", "ID-block to which masking element would be parented to or to its property");
RNA_def_property_update(prop, 0, "rna_Mask_update_parent");
prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "id_type");
RNA_def_property_enum_sdna(prop, nullptr, "id_type");
RNA_def_property_enum_items(prop, mask_id_type_items);
RNA_def_property_enum_default(prop, ID_MC);
RNA_def_property_enum_funcs(prop, NULL, "rna_MaskParent_id_type_set", NULL);
RNA_def_property_enum_funcs(prop, nullptr, "rna_MaskParent_id_type_set", nullptr);
// RNA_def_property_editable_func(prop, "rna_MaskParent_id_type_editable");
RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
RNA_def_property_update(prop, 0, "rna_Mask_update_parent");
@ -668,27 +668,27 @@ static void rna_def_maskSplinePointUW(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "MaskSplinePointUW", NULL);
srna = RNA_def_struct(brna, "MaskSplinePointUW", nullptr);
RNA_def_struct_ui_text(
srna, "Mask Spline UW Point", "Single point in spline segment defining feather");
/* u */
prop = RNA_def_property(srna, "u", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "u");
RNA_def_property_float_sdna(prop, nullptr, "u");
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "U", "U coordinate of point along spline segment");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
/* weight */
prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "w");
RNA_def_property_float_sdna(prop, nullptr, "w");
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "Weight", "Weight of feather point");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
/* select */
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SELECT);
RNA_def_property_ui_text(prop, "Select", "Selection status");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
}
@ -704,12 +704,12 @@ static void rna_def_maskSplinePoint(BlenderRNA *brna)
{HD_ALIGN, "ALIGNED", 0, "Aligned Single", ""},
{HD_ALIGN_DOUBLESIDE, "ALIGNED_DOUBLESIDE", 0, "Aligned", ""},
{HD_FREE, "FREE", 0, "Free", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
rna_def_maskSplinePointUW(brna);
srna = RNA_def_struct(brna, "MaskSplinePoint", NULL);
srna = RNA_def_struct(brna, "MaskSplinePoint", nullptr);
RNA_def_struct_ui_text(
srna, "Mask Spline Point", "Single point in spline used for defining mask");
@ -717,28 +717,28 @@ static void rna_def_maskSplinePoint(BlenderRNA *brna)
prop = RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(
prop, "rna_MaskSplinePoint_handle1_get", "rna_MaskSplinePoint_handle1_set", NULL);
prop, "rna_MaskSplinePoint_handle1_get", "rna_MaskSplinePoint_handle1_set", nullptr);
RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(
prop, "rna_MaskSplinePoint_ctrlpoint_get", "rna_MaskSplinePoint_ctrlpoint_set", NULL);
prop, "rna_MaskSplinePoint_ctrlpoint_get", "rna_MaskSplinePoint_ctrlpoint_set", nullptr);
RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
prop = RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(
prop, "rna_MaskSplinePoint_handle2_get", "rna_MaskSplinePoint_handle2_set", NULL);
prop, "rna_MaskSplinePoint_handle2_get", "rna_MaskSplinePoint_handle2_set", nullptr);
RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
/* handle_type */
prop = RNA_def_property(srna, "handle_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_funcs(
prop, "rna_MaskSplinePoint_handle_type_get", "rna_MaskSplinePoint_handle_type_set", NULL);
prop, "rna_MaskSplinePoint_handle_type_get", "rna_MaskSplinePoint_handle_type_set", nullptr);
RNA_def_property_enum_items(prop, handle_type_items);
RNA_def_property_ui_text(prop, "Handle Type", "Handle type");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
@ -748,7 +748,7 @@ static void rna_def_maskSplinePoint(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop,
"rna_MaskSplinePoint_handle_left_type_get",
"rna_MaskSplinePoint_handle_left_type_set",
NULL);
nullptr);
RNA_def_property_enum_items(prop, handle_type_items);
RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle type");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
@ -758,21 +758,21 @@ static void rna_def_maskSplinePoint(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop,
"rna_MaskSplinePoint_handle_right_type_get",
"rna_MaskSplinePoint_handle_right_type_set",
NULL);
nullptr);
RNA_def_property_enum_items(prop, handle_type_items);
RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle type");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
/* weight */
prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "bezt.weight");
RNA_def_property_float_sdna(prop, nullptr, "bezt.weight");
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "Weight", "Weight of the point");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
/* select */
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "bezt.f1", SELECT);
RNA_def_property_boolean_sdna(prop, nullptr, "bezt.f1", SELECT);
RNA_def_property_ui_text(prop, "Select", "Selection status");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
@ -783,7 +783,7 @@ static void rna_def_maskSplinePoint(BlenderRNA *brna)
/* feather points */
prop = RNA_def_property(srna, "feather_points", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MaskSplinePointUW");
RNA_def_property_collection_sdna(prop, NULL, "uw", "tot_uw");
RNA_def_property_collection_sdna(prop, nullptr, "uw", "tot_uw");
RNA_def_property_ui_text(prop, "Feather Points", "Points defining feather");
}
@ -794,7 +794,7 @@ static void rna_def_mask_splines(BlenderRNA *brna)
PropertyRNA *prop;
PropertyRNA *parm;
srna = RNA_def_struct(brna, "MaskSplines", NULL);
srna = RNA_def_struct(brna, "MaskSplines", nullptr);
RNA_def_struct_sdna(srna, "MaskLayer");
RNA_def_struct_ui_text(srna, "Mask Splines", "Collection of masking splines");
@ -817,8 +817,11 @@ static void rna_def_mask_splines(BlenderRNA *brna)
/* active spline */
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "MaskSpline");
RNA_def_property_pointer_funcs(
prop, "rna_MaskLayer_active_spline_get", "rna_MaskLayer_active_spline_set", NULL, NULL);
RNA_def_property_pointer_funcs(prop,
"rna_MaskLayer_active_spline_get",
"rna_MaskLayer_active_spline_set",
nullptr,
nullptr);
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_ui_text(prop, "Active Spline", "Active spline of masking layer");
@ -828,8 +831,8 @@ static void rna_def_mask_splines(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop,
"rna_MaskLayer_active_spline_point_get",
"rna_MaskLayer_active_spline_point_set",
NULL,
NULL);
nullptr,
nullptr);
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_ui_text(prop, "Active Point", "Active point of masking layer");
}
@ -840,7 +843,7 @@ static void rna_def_maskSplinePoints(BlenderRNA *brna)
FunctionRNA *func;
PropertyRNA *parm;
srna = RNA_def_struct(brna, "MaskSplinePoints", NULL);
srna = RNA_def_struct(brna, "MaskSplinePoints", nullptr);
RNA_def_struct_sdna(srna, "MaskSpline");
RNA_def_struct_ui_text(srna, "Mask Spline Points", "Collection of masking spline points");
@ -867,7 +870,7 @@ static void rna_def_maskSpline(BlenderRNA *brna)
static const EnumPropertyItem spline_interpolation_items[] = {
{MASK_SPLINE_INTERP_LINEAR, "LINEAR", 0, "Linear", ""},
{MASK_SPLINE_INTERP_EASE, "EASE", 0, "Ease", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem spline_offset_mode_items[] = {
@ -877,7 +880,7 @@ static void rna_def_maskSpline(BlenderRNA *brna)
0,
"Smooth",
"Calculate feather offset as a second curve"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
StructRNA *srna;
@ -885,12 +888,12 @@ static void rna_def_maskSpline(BlenderRNA *brna)
rna_def_maskSplinePoint(brna);
srna = RNA_def_struct(brna, "MaskSpline", NULL);
srna = RNA_def_struct(brna, "MaskSpline", nullptr);
RNA_def_struct_ui_text(srna, "Mask spline", "Single spline used for defining mask shape");
/* offset mode */
prop = RNA_def_property(srna, "offset_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "offset_mode");
RNA_def_property_enum_sdna(prop, nullptr, "offset_mode");
RNA_def_property_enum_items(prop, spline_offset_mode_items);
RNA_def_property_ui_text(
prop, "Feather Offset", "The method used for calculating the feather offset");
@ -898,7 +901,7 @@ static void rna_def_maskSpline(BlenderRNA *brna)
/* weight interpolation */
prop = RNA_def_property(srna, "weight_interpolation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "weight_interp");
RNA_def_property_enum_sdna(prop, nullptr, "weight_interp");
RNA_def_property_enum_items(prop, spline_interpolation_items);
RNA_def_property_ui_text(
prop, "Weight Interpolation", "The type of weight interpolation for spline");
@ -907,14 +910,14 @@ static void rna_def_maskSpline(BlenderRNA *brna)
/* cyclic */
prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MASK_SPLINE_CYCLIC);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", MASK_SPLINE_CYCLIC);
RNA_def_property_ui_text(prop, "Cyclic", "Make this spline a closed loop");
RNA_def_property_update(prop, NC_MASK | NA_EDITED, "rna_Mask_update_data");
/* fill */
prop = RNA_def_property(srna, "use_fill", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MASK_SPLINE_NOFILL);
RNA_def_property_boolean_negative_sdna(prop, nullptr, "flag", MASK_SPLINE_NOFILL);
RNA_def_property_ui_text(prop, "Fill", "Make this spline filled");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MASK);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, "rna_Mask_update_data");
@ -922,14 +925,14 @@ static void rna_def_maskSpline(BlenderRNA *brna)
/* self-intersection check */
prop = RNA_def_property(srna, "use_self_intersection_check", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MASK_SPLINE_NOINTERSECT);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", MASK_SPLINE_NOINTERSECT);
RNA_def_property_ui_text(
prop, "Self Intersection Check", "Prevent feather from self-intersections");
RNA_def_property_update(prop, NC_MASK | NA_EDITED, "rna_Mask_update_data");
prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MaskSplinePoint");
RNA_def_property_collection_sdna(prop, NULL, "points", "tot_point");
RNA_def_property_collection_sdna(prop, nullptr, "points", "tot_point");
RNA_def_property_ui_text(prop, "Points", "Collection of points");
RNA_def_property_srna(prop, "MaskSplinePoints");
}
@ -946,7 +949,7 @@ static void rna_def_mask_layer(BlenderRNA *brna)
{MASK_BLEND_MUL, "MUL", 0, "Multiply", ""},
{MASK_BLEND_REPLACE, "REPLACE", 0, "Replace", ""},
{MASK_BLEND_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
StructRNA *srna;
@ -956,14 +959,14 @@ static void rna_def_mask_layer(BlenderRNA *brna)
rna_def_mask_splines(brna);
rna_def_maskSplinePoints(brna);
srna = RNA_def_struct(brna, "MaskLayer", NULL);
srna = RNA_def_struct(brna, "MaskLayer", nullptr);
RNA_def_struct_ui_text(srna, "Mask Layer", "Single layer used for masking pixels");
RNA_def_struct_path_func(srna, "rna_MaskLayer_path");
/* name */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Unique name of layer");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MaskLayer_name_set");
RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_MaskLayer_name_set");
RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2);
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
RNA_def_struct_name_property(srna, prop);
@ -975,79 +978,79 @@ static void rna_def_mask_layer(BlenderRNA *brna)
"rna_iterator_listbase_next",
"rna_iterator_listbase_end",
"rna_iterator_listbase_get",
NULL,
NULL,
NULL,
NULL);
nullptr,
nullptr,
nullptr,
nullptr);
RNA_def_property_struct_type(prop, "MaskSpline");
RNA_def_property_ui_text(prop, "Splines", "Collection of splines which defines this layer");
RNA_def_property_srna(prop, "MaskSplines");
/* restrict */
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "visibility_flag", MASK_HIDE_VIEW);
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", MASK_HIDE_VIEW);
RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport");
RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1);
RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL);
RNA_def_property_update(prop, NC_MASK | ND_DRAW, nullptr);
prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "visibility_flag", MASK_HIDE_SELECT);
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", MASK_HIDE_SELECT);
RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection in the viewport");
RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1);
RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL);
RNA_def_property_update(prop, NC_MASK | ND_DRAW, nullptr);
prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "visibility_flag", MASK_HIDE_RENDER);
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", MASK_HIDE_RENDER);
RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability");
RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, nullptr);
/* Select (for dope-sheet). */
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MASK_LAYERFLAG_SELECT);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", MASK_LAYERFLAG_SELECT);
RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the Dope Sheet");
// RNA_def_property_update(prop, NC_SCREEN | ND_MASK, NULL);
/* render settings */
prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "alpha");
RNA_def_property_float_sdna(prop, nullptr, "alpha");
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
RNA_def_property_ui_text(prop, "Opacity", "Render Opacity");
RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, nullptr);
/* weight interpolation */
prop = RNA_def_property(srna, "blend", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "blend");
RNA_def_property_enum_sdna(prop, nullptr, "blend");
RNA_def_property_enum_items(prop, masklay_blend_mode_items);
RNA_def_property_ui_text(prop, "Blend", "Method of blending mask layers");
RNA_def_property_update(prop, 0, "rna_Mask_update_data");
RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, nullptr);
prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MASK_BLENDFLAG_INVERT);
RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MASK_BLENDFLAG_INVERT);
RNA_def_property_ui_text(prop, "Restrict View", "Invert the mask black/white");
RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, nullptr);
prop = RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "falloff");
RNA_def_property_enum_sdna(prop, nullptr, "falloff");
RNA_def_property_enum_items(prop, rna_enum_proportional_falloff_curve_only_items);
RNA_def_property_ui_text(prop, "Falloff", "Falloff type the feather");
RNA_def_property_translation_context(prop,
BLT_I18NCONTEXT_ID_CURVE_LEGACY); /* Abusing id_curve :/ */
RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, nullptr);
/* filling options */
prop = RNA_def_property(srna, "use_fill_holes", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MASK_LAYERFLAG_FILL_DISCRETE);
RNA_def_property_boolean_negative_sdna(prop, nullptr, "flag", MASK_LAYERFLAG_FILL_DISCRETE);
RNA_def_property_ui_text(
prop, "Calculate Holes", "Calculate holes when filling overlapping curves");
RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, nullptr);
prop = RNA_def_property(srna, "use_fill_overlap", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MASK_LAYERFLAG_FILL_OVERLAP);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", MASK_LAYERFLAG_FILL_OVERLAP);
RNA_def_property_ui_text(
prop, "Calculate Overlap", "Calculate self intersections and overlap before filling");
RNA_def_property_update(prop, NC_MASK | NA_EDITED, NULL);
RNA_def_property_update(prop, NC_MASK | NA_EDITED, nullptr);
}
static void rna_def_masklayers(BlenderRNA *brna, PropertyRNA *cprop)
@ -1059,13 +1062,13 @@ static void rna_def_masklayers(BlenderRNA *brna, PropertyRNA *cprop)
PropertyRNA *parm;
RNA_def_property_srna(cprop, "MaskLayers");
srna = RNA_def_struct(brna, "MaskLayers", NULL);
srna = RNA_def_struct(brna, "MaskLayers", nullptr);
RNA_def_struct_sdna(srna, "Mask");
RNA_def_struct_ui_text(srna, "Mask Layers", "Collection of layers used by mask");
func = RNA_def_function(srna, "new", "rna_Mask_layers_new");
RNA_def_function_ui_description(func, "Add layer to this mask");
RNA_def_string(func, "name", NULL, 0, "Name", "Name of new layer");
RNA_def_string(func, "name", nullptr, 0, "Name", "Name of new layer");
parm = RNA_def_pointer(func, "layer", "MaskLayer", "", "New mask layer");
RNA_def_function_return(func, parm);
@ -1084,7 +1087,7 @@ static void rna_def_masklayers(BlenderRNA *brna, PropertyRNA *cprop)
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "MaskLayer");
RNA_def_property_pointer_funcs(
prop, "rna_Mask_layer_active_get", "rna_Mask_layer_active_set", NULL, NULL);
prop, "rna_Mask_layer_active_get", "rna_Mask_layer_active_set", nullptr, nullptr);
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_ui_text(prop, "Active Shape", "Active layer in this mask");
}
@ -1107,17 +1110,17 @@ static void rna_def_mask(BlenderRNA *brna)
"rna_iterator_listbase_next",
"rna_iterator_listbase_end",
"rna_iterator_listbase_get",
NULL,
NULL,
NULL,
NULL);
nullptr,
nullptr,
nullptr,
nullptr);
RNA_def_property_struct_type(prop, "MaskLayer");
RNA_def_property_ui_text(prop, "Layers", "Collection of layers which defines this mask");
rna_def_masklayers(brna, prop);
/* active masklay index */
prop = RNA_def_property(srna, "active_layer_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "masklay_act");
RNA_def_property_int_sdna(prop, nullptr, "masklay_act");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_funcs(prop,
"rna_Mask_layer_active_index_get",
@ -1125,24 +1128,24 @@ static void rna_def_mask(BlenderRNA *brna)
"rna_Mask_layer_active_index_range");
RNA_def_property_ui_text(
prop, "Active Shape Index", "Index of active layer in list of all mask's layers");
RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL);
RNA_def_property_update(prop, NC_MASK | ND_DRAW, nullptr);
/* frame range */
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "sfra");
RNA_def_property_int_funcs(prop, NULL, "rna_Mask_start_frame_set", NULL);
RNA_def_property_int_sdna(prop, nullptr, "sfra");
RNA_def_property_int_funcs(prop, nullptr, "rna_Mask_start_frame_set", nullptr);
RNA_def_property_range(prop, MINFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "Start Frame", "First frame of the mask (used for sequencer)");
RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL);
RNA_def_property_update(prop, NC_MASK | ND_DRAW, nullptr);
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "efra");
RNA_def_property_int_funcs(prop, NULL, "rna_Mask_end_frame_set", NULL);
RNA_def_property_int_sdna(prop, nullptr, "efra");
RNA_def_property_int_funcs(prop, nullptr, "rna_Mask_end_frame_set", nullptr);
RNA_def_property_range(prop, MINFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "End Frame", "Final frame of the mask (used for sequencer)");
RNA_def_property_update(prop, NC_MASK | ND_DRAW, NULL);
RNA_def_property_update(prop, NC_MASK | ND_DRAW, nullptr);
/* pointers */
rna_def_animdata_common(srna);

View File

@ -40,7 +40,7 @@
static int rna_Meta_texspace_editable(PointerRNA *ptr, const char ** /*r_info*/)
{
MetaBall *mb = (MetaBall *)ptr->data;
return (mb->texspace_flag & MB_TEXSPACE_FLAG_AUTO) ? 0 : PROP_EDITABLE;
return (mb->texspace_flag & MB_TEXSPACE_FLAG_AUTO) ? 0 : int(PROP_EDITABLE);
}
static void rna_Meta_texspace_location_get(PointerRNA *ptr, float *values)
@ -182,7 +182,7 @@ static void rna_def_metaelement(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "MetaElement", NULL);
srna = RNA_def_struct(brna, "MetaElement", nullptr);
RNA_def_struct_sdna(srna, "MetaElem");
RNA_def_struct_ui_text(srna, "Metaball Element", "Blobby element in a metaball data-block");
RNA_def_struct_path_func(srna, "rna_MetaElement_path");
@ -196,24 +196,24 @@ static void rna_def_metaelement(BlenderRNA *brna)
/* number values */
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "x");
RNA_def_property_float_sdna(prop, nullptr, "x");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Location", "");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION);
RNA_def_property_float_sdna(prop, NULL, "quat");
RNA_def_property_float_sdna(prop, nullptr, "quat");
RNA_def_property_ui_text(prop, "Rotation", "Normalized quaternion rotation");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_rotation");
prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_UNSIGNED | PROP_UNIT_LENGTH);
RNA_def_property_float_sdna(prop, NULL, "rad");
RNA_def_property_float_sdna(prop, nullptr, "rad");
RNA_def_property_ui_text(prop, "Radius", "");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "size_x", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "expx");
RNA_def_property_float_sdna(prop, nullptr, "expx");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_range(prop, 0.0f, 20.0f);
RNA_def_property_ui_text(
@ -221,7 +221,7 @@ static void rna_def_metaelement(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "expy");
RNA_def_property_float_sdna(prop, nullptr, "expy");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_range(prop, 0.0f, 20.0f);
RNA_def_property_ui_text(
@ -229,7 +229,7 @@ static void rna_def_metaelement(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "size_z", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "expz");
RNA_def_property_float_sdna(prop, nullptr, "expz");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_range(prop, 0.0f, 20.0f);
RNA_def_property_ui_text(
@ -237,29 +237,29 @@ static void rna_def_metaelement(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "stiffness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "s");
RNA_def_property_float_sdna(prop, nullptr, "s");
RNA_def_property_range(prop, 0.0f, 10.0f);
RNA_def_property_ui_text(prop, "Stiffness", "Stiffness defines how much of the element to fill");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
/* flags */
prop = RNA_def_property(srna, "use_negative", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_NEGATIVE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", MB_NEGATIVE);
RNA_def_property_ui_text(prop, "Negative", "Set metaball as negative one");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "use_scale_stiffness", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MB_SCALE_RAD);
RNA_def_property_boolean_negative_sdna(prop, nullptr, "flag", MB_SCALE_RAD);
RNA_def_property_ui_text(prop, "Scale Stiffness", "Scale stiffness instead of radius");
RNA_def_property_update(prop, 0, "rna_MetaBall_redraw_data");
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", 1); /* SELECT */
RNA_def_property_boolean_sdna(prop, nullptr, "flag", 1); /* SELECT */
RNA_def_property_ui_text(prop, "Select", "Select element");
RNA_def_property_update(prop, 0, "rna_MetaBall_redraw_data");
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MB_HIDE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", MB_HIDE);
RNA_def_property_ui_text(prop, "Hide", "Hide element");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
}
@ -274,7 +274,7 @@ static void rna_def_metaball_elements(BlenderRNA *brna, PropertyRNA *cprop)
PropertyRNA *parm;
RNA_def_property_srna(cprop, "MetaBallElements");
srna = RNA_def_struct(brna, "MetaBallElements", NULL);
srna = RNA_def_struct(brna, "MetaBallElements", nullptr);
RNA_def_struct_sdna(srna, "MetaBall");
RNA_def_struct_ui_text(srna, "Metaball Elements", "Collection of metaball elements");
@ -300,7 +300,7 @@ static void rna_def_metaball_elements(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Remove all elements from the metaball");
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "lastelem");
RNA_def_property_pointer_sdna(prop, nullptr, "lastelem");
RNA_def_property_ui_text(prop, "Active Element", "Last selected element");
}
@ -317,7 +317,7 @@ static void rna_def_metaball(BlenderRNA *brna)
"While editing, update metaball in half resolution"},
{MB_UPDATE_FAST, "FAST", 0, "Fast", "While editing, update metaball without polygonization"},
{MB_UPDATE_NEVER, "NEVER", 0, "Never", "While editing, don't update metaball at all"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
srna = RNA_def_struct(brna, "MetaBall", "ID");
@ -325,42 +325,42 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_META_DATA);
prop = RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "elems", NULL);
RNA_def_property_collection_sdna(prop, nullptr, "elems", nullptr);
RNA_def_property_struct_type(prop, "MetaElement");
RNA_def_property_ui_text(prop, "Elements", "Metaball elements");
rna_def_metaball_elements(brna, prop);
/* enums */
prop = RNA_def_property(srna, "update_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "flag");
RNA_def_property_enum_sdna(prop, nullptr, "flag");
RNA_def_property_enum_items(prop, prop_update_items);
RNA_def_property_ui_text(prop, "Update", "Metaball edit update behavior");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
/* number values */
prop = RNA_def_property(srna, "resolution", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "wiresize");
RNA_def_property_float_sdna(prop, nullptr, "wiresize");
RNA_def_property_range(prop, 0.005f, 10000.0f);
RNA_def_property_ui_range(prop, 0.05f, 1000.0f, 2.5f, 3);
RNA_def_property_ui_text(prop, "Viewport Size", "Polygonization resolution in the 3D viewport");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "render_resolution", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "rendersize");
RNA_def_property_float_sdna(prop, nullptr, "rendersize");
RNA_def_property_range(prop, 0.005f, 10000.0f);
RNA_def_property_ui_range(prop, 0.025f, 1000.0f, 2.5f, 3);
RNA_def_property_ui_text(prop, "Render Size", "Polygonization resolution in rendering");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "thresh");
RNA_def_property_float_sdna(prop, nullptr, "thresh");
RNA_def_property_range(prop, 0.0f, 5.0f);
RNA_def_property_ui_text(prop, "Threshold", "Influence of metaball elements");
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
/* texture space */
prop = RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "texspace_flag", MB_TEXSPACE_FLAG_AUTO);
RNA_def_property_boolean_sdna(prop, nullptr, "texspace_flag", MB_TEXSPACE_FLAG_AUTO);
RNA_def_property_ui_text(
prop,
"Auto Texture Space",
@ -371,7 +371,7 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable");
RNA_def_property_float_funcs(
prop, "rna_Meta_texspace_location_get", "rna_Meta_texspace_location_set", NULL);
prop, "rna_Meta_texspace_location_get", "rna_Meta_texspace_location_set", nullptr);
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
@ -380,7 +380,7 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable");
RNA_def_property_float_funcs(
prop, "rna_Meta_texspace_size_get", "rna_Meta_texspace_size_set", NULL);
prop, "rna_Meta_texspace_size_get", "rna_Meta_texspace_size_set", nullptr);
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
/* not supported yet */
@ -395,15 +395,22 @@ static void rna_def_metaball(BlenderRNA *brna)
/* materials */
prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
RNA_def_property_collection_sdna(prop, nullptr, "mat", "totcol");
RNA_def_property_struct_type(prop, "Material");
RNA_def_property_ui_text(prop, "Materials", "");
RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
RNA_def_property_collection_funcs(
prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
RNA_def_property_collection_funcs(prop,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
"rna_IDMaterials_assign_int");
prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Meta_is_editmode_get", NULL);
RNA_def_property_boolean_funcs(prop, "rna_Meta_is_editmode_get", nullptr);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");

View File

@ -52,7 +52,7 @@ const EnumPropertyItem rna_enum_color_sets_items[] = {
{19, "THEME19", ICON_COLORSET_19_VEC, "19 - Theme Color Set", ""},
{20, "THEME20", ICON_COLORSET_20_VEC, "20 - Theme Color Set", ""},
{-1, "CUSTOM", 0, "Custom Color Set", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
#ifdef RNA_RUNTIME
@ -871,14 +871,14 @@ void rna_def_actionbone_group_common(StructRNA *srna, int update_flag, const cha
/* color set + colors */
prop = RNA_def_property(srna, "color_set", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "customCol");
RNA_def_property_enum_sdna(prop, nullptr, "customCol");
RNA_def_property_enum_items(prop, rna_enum_color_sets_items);
RNA_def_property_enum_funcs(prop, NULL, "rna_ActionGroup_colorset_set", NULL);
RNA_def_property_enum_funcs(prop, nullptr, "rna_ActionGroup_colorset_set", nullptr);
RNA_def_property_ui_text(prop, "Color Set", "Custom color set to use");
RNA_def_property_update(prop, update_flag, update_cb);
prop = RNA_def_property(srna, "is_custom_color_set", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_ActionGroup_is_custom_colorset_get", NULL);
RNA_def_property_boolean_funcs(prop, "rna_ActionGroup_is_custom_colorset_get", nullptr);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(
prop, "Custom Color Set", "Color set is user-defined instead of a fixed theme color set");
@ -888,7 +888,7 @@ void rna_def_actionbone_group_common(StructRNA *srna, int update_flag, const cha
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "ThemeBoneColorSet");
/* NOTE: the DNA data is not really a pointer, but this code works :) */
RNA_def_property_pointer_sdna(prop, NULL, "cs");
RNA_def_property_pointer_sdna(prop, nullptr, "cs");
RNA_def_property_ui_text(
prop, "Colors", "Copy of the colors associated with the group's color set");
RNA_def_property_update(prop, update_flag, update_cb);
@ -900,7 +900,7 @@ static void rna_def_bone_group(BlenderRNA *brna)
PropertyRNA *prop;
/* struct */
srna = RNA_def_struct(brna, "BoneGroup", NULL);
srna = RNA_def_struct(brna, "BoneGroup", nullptr);
RNA_def_struct_sdna(srna, "bActionGroup");
RNA_def_struct_ui_text(srna, "Bone Group", "Groups of Pose Channels (Bones)");
RNA_def_struct_ui_icon(srna, ICON_GROUP_BONE);
@ -908,7 +908,7 @@ static void rna_def_bone_group(BlenderRNA *brna)
/* name */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_BoneGroup_name_set");
RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_BoneGroup_name_set");
RNA_def_struct_name_property(srna, prop);
/* TODO: add some runtime-collections stuff to access grouped bones. */
@ -920,13 +920,13 @@ static void rna_def_bone_group(BlenderRNA *brna)
static const EnumPropertyItem prop_iksolver_items[] = {
{IKSOLVER_STANDARD, "LEGACY", 0, "Standard", "Original IK solver"},
{IKSOLVER_ITASC, "ITASC", 0, "iTaSC", "Multi constraint, stateful IK solver"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem prop_solver_items[] = {
{ITASC_SOLVER_SDLS, "SDLS", 0, "SDLS", "Selective Damped Least Square"},
{ITASC_SOLVER_DLS, "DLS", 0, "DLS", "Damped Least Square with Numerical Filtering"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cprop)
@ -938,7 +938,7 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro
PropertyRNA *parm;
RNA_def_property_srna(cprop, "PoseBoneConstraints");
srna = RNA_def_struct(brna, "PoseBoneConstraints", NULL);
srna = RNA_def_struct(brna, "PoseBoneConstraints", nullptr);
RNA_def_struct_sdna(srna, "bPoseChannel");
RNA_def_struct_ui_text(srna, "PoseBone Constraints", "Collection of pose bone constraints");
@ -948,8 +948,8 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro
RNA_def_property_pointer_funcs(prop,
"rna_PoseChannel_active_constraint_get",
"rna_PoseChannel_active_constraint_set",
NULL,
NULL);
nullptr,
nullptr);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Active Constraint", "Active PoseChannel constraint");
@ -1005,7 +1005,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "PoseBone", NULL);
srna = RNA_def_struct(brna, "PoseBone", nullptr);
RNA_def_struct_sdna(srna, "bPoseChannel");
RNA_def_struct_ui_text(srna, "Pose Bone", "Channel defining pose data for a bone in a Pose");
RNA_def_struct_path_func(srna, "rna_PoseBone_path");
@ -1018,13 +1018,14 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_override_flag(
prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY | PROPOVERRIDE_LIBRARY_INSERTION);
RNA_def_property_ui_text(prop, "Constraints", "Constraints that act on this pose channel");
RNA_def_property_override_funcs(prop, NULL, NULL, "rna_PoseChannel_constraints_override_apply");
RNA_def_property_override_funcs(
prop, nullptr, nullptr, "rna_PoseChannel_constraints_override_apply");
rna_def_pose_channel_constraints(brna, prop);
/* Name + Selection Status */
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_PoseChannel_name_set");
RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_PoseChannel_name_set");
RNA_def_property_ui_text(prop, "Name", "");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_struct_name_property(srna, prop);
@ -1037,7 +1038,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
prop = RNA_def_property(srna, "bone", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "Bone");
RNA_def_property_pointer_funcs(prop, "rna_PoseChannel_bone_get", NULL, NULL, NULL);
RNA_def_property_pointer_funcs(prop, "rna_PoseChannel_bone_get", nullptr, nullptr, nullptr);
RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Bone", "Bone associated with this PoseBone");
@ -1056,7 +1057,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
/* Transformation settings */
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "loc");
RNA_def_property_float_sdna(prop, nullptr, "loc");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_location_editable");
RNA_def_property_ui_text(prop, "Location", "");
@ -1064,7 +1065,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_float_sdna(prop, nullptr, "size");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_scale_editable");
@ -1073,7 +1074,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
RNA_def_property_float_sdna(prop, NULL, "quat");
RNA_def_property_float_sdna(prop, nullptr, "quat");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable");
RNA_def_property_float_array_default(prop, rna_default_quaternion);
@ -1089,7 +1090,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_float_funcs(prop,
"rna_PoseChannel_rotation_axis_angle_get",
"rna_PoseChannel_rotation_axis_angle_set",
NULL);
nullptr);
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable");
RNA_def_property_float_array_default(prop, rna_default_axis_angle);
RNA_def_property_ui_text(
@ -1097,7 +1098,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
RNA_def_property_float_sdna(prop, NULL, "eul");
RNA_def_property_float_sdna(prop, nullptr, "eul");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_euler_editable");
RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
@ -1105,10 +1106,10 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "rotmode");
RNA_def_property_enum_sdna(prop, nullptr, "rotmode");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_enum_items(prop, rna_enum_object_rotation_mode_items);
RNA_def_property_enum_funcs(prop, NULL, "rna_PoseChannel_rotation_mode_set", NULL);
RNA_def_property_enum_funcs(prop, nullptr, "rna_PoseChannel_rotation_mode_set", nullptr);
/* XXX... disabled, since proxy-locked layers are currently
* used for ensuring proxy-syncing too */
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
@ -1120,7 +1121,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
/* Custom BBone next/prev sources */
prop = RNA_def_property(srna, "bbone_custom_handle_start", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "bbone_prev");
RNA_def_property_pointer_sdna(prop, nullptr, "bbone_prev");
RNA_def_property_struct_type(prop, "PoseBone");
RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP);
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
@ -1129,7 +1130,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update");
prop = RNA_def_property(srna, "bbone_custom_handle_end", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "bbone_next");
RNA_def_property_pointer_sdna(prop, nullptr, "bbone_next");
RNA_def_property_struct_type(prop, "PoseBone");
RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP);
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
@ -1139,7 +1140,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
/* transform matrices - should be read-only since these are set directly by AnimSys evaluation */
prop = RNA_def_property(srna, "matrix_channel", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "chan_mat");
RNA_def_property_float_sdna(prop, nullptr, "chan_mat");
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop,
@ -1155,15 +1156,15 @@ static void rna_def_pose_channel(BlenderRNA *brna)
"Basis Matrix",
"Alternative access to location/scale/rotation relative to the parent and own rest bone");
RNA_def_property_float_funcs(
prop, "rna_PoseChannel_matrix_basis_get", "rna_PoseChannel_matrix_basis_set", NULL);
prop, "rna_PoseChannel_matrix_basis_get", "rna_PoseChannel_matrix_basis_set", nullptr);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
/* final matrix */
prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "pose_mat");
RNA_def_property_float_sdna(prop, nullptr, "pose_mat");
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
RNA_def_property_float_funcs(prop, NULL, "rna_PoseChannel_matrix_set", NULL);
RNA_def_property_float_funcs(prop, nullptr, "rna_PoseChannel_matrix_set", nullptr);
RNA_def_property_ui_text(
prop,
"Pose Matrix",
@ -1172,160 +1173,160 @@ static void rna_def_pose_channel(BlenderRNA *brna)
/* Head/Tail Coordinates (in Pose Space) - Automatically calculated... */
prop = RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "pose_head");
RNA_def_property_float_sdna(prop, nullptr, "pose_head");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Pose Head Position", "Location of head of the channel's bone");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
prop = RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "pose_tail");
RNA_def_property_float_sdna(prop, nullptr, "pose_tail");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Pose Tail Position", "Location of tail of the channel's bone");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_funcs(prop, "rna_PoseChannel_length_get", NULL, NULL);
RNA_def_property_float_funcs(prop, "rna_PoseChannel_length_get", nullptr, nullptr);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Length", "Length of the bone");
/* IK Settings */
prop = RNA_def_property(srna, "is_in_ik_chain", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_PoseChannel_has_ik_get", NULL);
RNA_def_property_boolean_funcs(prop, "rna_PoseChannel_has_ik_get", nullptr);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Has IK", "Is part of an IK chain");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "lock_ik_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_NO_XDOF);
RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_NO_XDOF);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
RNA_def_property_ui_text(prop, "IK X Lock", "Disallow movement around the X axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "lock_ik_y", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_NO_YDOF);
RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_NO_YDOF);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
RNA_def_property_ui_text(prop, "IK Y Lock", "Disallow movement around the Y axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "lock_ik_z", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_NO_ZDOF);
RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_NO_ZDOF);
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, true);
RNA_def_property_ui_text(prop, "IK Z Lock", "Disallow movement around the Z axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "use_ik_limit_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_XLIMIT);
RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_XLIMIT);
RNA_def_property_ui_text(prop, "IK X Limit", "Limit movement around the X axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "use_ik_limit_y", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_YLIMIT);
RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_YLIMIT);
RNA_def_property_ui_text(prop, "IK Y Limit", "Limit movement around the Y axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "use_ik_limit_z", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_ZLIMIT);
RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_ZLIMIT);
RNA_def_property_ui_text(prop, "IK Z Limit", "Limit movement around the Z axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "use_ik_rotation_control", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_ROTCTL);
RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_ROTCTL);
RNA_def_property_ui_text(prop, "IK Rotation Control", "Apply channel rotation as IK constraint");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "use_ik_linear_control", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_LINCTL);
RNA_def_property_boolean_sdna(prop, nullptr, "ikflag", BONE_IK_LINCTL);
RNA_def_property_ui_text(
prop, "IK Linear Control", "Apply channel size as IK constraint if stretching is enabled");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_min_x", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "limitmin[0]");
RNA_def_property_float_sdna(prop, nullptr, "limitmin[0]");
RNA_def_property_range(prop, -M_PI, 0.0f);
RNA_def_property_ui_text(prop, "IK X Minimum", "Minimum angles for IK Limit");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_max_x", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "limitmax[0]");
RNA_def_property_float_sdna(prop, nullptr, "limitmax[0]");
RNA_def_property_range(prop, 0.0f, M_PI);
RNA_def_property_ui_text(prop, "IK X Maximum", "Maximum angles for IK Limit");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_min_y", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "limitmin[1]");
RNA_def_property_float_sdna(prop, nullptr, "limitmin[1]");
RNA_def_property_range(prop, -M_PI, 0.0f);
RNA_def_property_ui_text(prop, "IK Y Minimum", "Minimum angles for IK Limit");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_max_y", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "limitmax[1]");
RNA_def_property_float_sdna(prop, nullptr, "limitmax[1]");
RNA_def_property_range(prop, 0.0f, M_PI);
RNA_def_property_ui_text(prop, "IK Y Maximum", "Maximum angles for IK Limit");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_min_z", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "limitmin[2]");
RNA_def_property_float_sdna(prop, nullptr, "limitmin[2]");
RNA_def_property_range(prop, -M_PI, 0.0f);
RNA_def_property_ui_text(prop, "IK Z Minimum", "Minimum angles for IK Limit");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_max_z", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "limitmax[2]");
RNA_def_property_float_sdna(prop, nullptr, "limitmax[2]");
RNA_def_property_range(prop, 0.0f, M_PI);
RNA_def_property_ui_text(prop, "IK Z Maximum", "Maximum angles for IK Limit");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_stiffness_x", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "stiffness[0]");
RNA_def_property_float_sdna(prop, nullptr, "stiffness[0]");
RNA_def_property_range(prop, 0.0f, 0.99f);
RNA_def_property_ui_text(prop, "IK X Stiffness", "IK stiffness around the X axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_stiffness_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "stiffness[1]");
RNA_def_property_float_sdna(prop, nullptr, "stiffness[1]");
RNA_def_property_range(prop, 0.0f, 0.99f);
RNA_def_property_ui_text(prop, "IK Y Stiffness", "IK stiffness around the Y axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_stiffness_z", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "stiffness[2]");
RNA_def_property_float_sdna(prop, nullptr, "stiffness[2]");
RNA_def_property_range(prop, 0.0f, 0.99f);
RNA_def_property_ui_text(prop, "IK Z Stiffness", "IK stiffness around the Z axis");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_stretch", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "ikstretch");
RNA_def_property_float_sdna(prop, nullptr, "ikstretch");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "IK Stretch", "Allow scaling of the bone for IK");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update");
prop = RNA_def_property(srna, "ik_rotation_weight", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "ikrotweight");
RNA_def_property_float_sdna(prop, nullptr, "ikrotweight");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "IK Rotation Weight", "Weight of rotation constraint for IK");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "ik_linear_weight", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "iklinweight");
RNA_def_property_float_sdna(prop, nullptr, "iklinweight");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "IK Lin Weight", "Weight of scale constraint for IK");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
@ -1333,7 +1334,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
/* custom bone shapes */
prop = RNA_def_property(srna, "custom_shape", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "custom");
RNA_def_property_pointer_sdna(prop, nullptr, "custom");
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
@ -1343,14 +1344,14 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update");
prop = RNA_def_property(srna, "custom_shape_scale_xyz", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "custom_scale_xyz");
RNA_def_property_float_sdna(prop, nullptr, "custom_scale_xyz");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_float_array_default(prop, rna_default_scale_3d);
RNA_def_property_ui_text(prop, "Custom Shape Scale", "Adjust the size of the custom shape");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "custom_shape_translation", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "custom_translation");
RNA_def_property_float_sdna(prop, nullptr, "custom_translation");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_ui_text(
prop, "Custom Shape Translation", "Adjust the location of the custom shape");
@ -1358,20 +1359,21 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "custom_shape_rotation_euler", PROP_FLOAT, PROP_EULER);
RNA_def_property_float_sdna(prop, NULL, "custom_rotation_euler");
RNA_def_property_float_sdna(prop, nullptr, "custom_rotation_euler");
RNA_def_property_ui_text(
prop, "Custom Shape Rotation", "Adjust the rotation of the custom shape");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 100, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "use_custom_shape_bone_size", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", PCHAN_DRAW_NO_CUSTOM_BONE_SIZE);
RNA_def_property_boolean_negative_sdna(
prop, nullptr, "drawflag", PCHAN_DRAW_NO_CUSTOM_BONE_SIZE);
RNA_def_property_ui_text(
prop, "Scale to Bone Length", "Scale the custom object by the bone length");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "custom_shape_transform", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "custom_tx");
RNA_def_property_pointer_sdna(prop, nullptr, "custom_tx");
RNA_def_property_struct_type(prop, "PoseBone");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_PTR_NO_OWNERSHIP);
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
@ -1380,12 +1382,12 @@ static void rna_def_pose_channel(BlenderRNA *brna)
"Bone that defines the display transform of this custom shape");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_pointer_funcs(
prop, NULL, "rna_PoseChannel_custom_shape_transform_set", NULL, NULL);
prop, nullptr, "rna_PoseChannel_custom_shape_transform_set", nullptr, nullptr);
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
/* bone groups */
prop = RNA_def_property(srna, "bone_group_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "agrp_index");
RNA_def_property_int_sdna(prop, nullptr, "agrp_index");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_funcs(prop,
@ -1401,14 +1403,14 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "BoneGroup");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_pointer_funcs(
prop, "rna_PoseChannel_bone_group_get", "rna_PoseChannel_bone_group_set", NULL, NULL);
prop, "rna_PoseChannel_bone_group_get", "rna_PoseChannel_bone_group_set", nullptr, nullptr);
RNA_def_property_ui_text(prop, "Bone Group", "Bone group this pose channel belongs to");
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
/* transform locks */
prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_LOCX);
RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_LOCX);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location when transforming");
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
@ -1416,7 +1418,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTX);
RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTX);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation when transforming");
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
@ -1426,7 +1428,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
/* XXX this is sub-optimal - it really should be included above, but due to technical reasons
* we can't do this! */
prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROTW);
RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTW);
RNA_def_property_ui_text(
prop,
"Lock Rotation (4D Angle)",
@ -1437,7 +1439,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
/* XXX this needs a better name */
prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_ROT4D);
RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROT4D);
RNA_def_property_ui_text(
prop,
"Lock Rotations (4D)",
@ -1446,7 +1448,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "protectflag", OB_LOCK_SCALEX);
RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_SCALEX);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale when transforming");
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
@ -1470,7 +1472,7 @@ static void rna_def_pose_itasc(BlenderRNA *brna)
"Simulation",
"State-full solver running in real-time context and ignoring actions "
"and non-IK constraints"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem prop_itasc_reiteration_items[] = {
{0,
@ -1489,7 +1491,7 @@ static void rna_def_pose_itasc(BlenderRNA *brna)
0,
"Always",
"The solver reiterates (converges) on all frames"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
StructRNA *srna;
@ -1500,38 +1502,38 @@ static void rna_def_pose_itasc(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "bItasc", "Parameters for the iTaSC IK solver");
prop = RNA_def_property(srna, "precision", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "precision");
RNA_def_property_float_sdna(prop, nullptr, "precision");
RNA_def_property_range(prop, 0.0f, 0.1f);
RNA_def_property_ui_text(prop, "Precision", "Precision of convergence in case of reiteration");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "numiter");
RNA_def_property_int_sdna(prop, nullptr, "numiter");
RNA_def_property_range(prop, 0, 1000);
RNA_def_property_ui_text(
prop, "Iterations", "Maximum number of iterations for convergence in case of reiteration");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "step_count", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "numstep");
RNA_def_property_int_sdna(prop, nullptr, "numstep");
RNA_def_property_range(prop, 1.0f, 50.0f);
RNA_def_property_ui_text(prop, "Num Steps", "Divide the frame interval into this many steps");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "translate_root_bones", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ITASC_TRANSLATE_ROOT_BONES);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", ITASC_TRANSLATE_ROOT_BONES);
RNA_def_property_ui_text(
prop, "Translate Roots", "Translate root (i.e. parentless) bones to the armature origin");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
RNA_def_property_enum_items(prop, prop_itasc_mode_items);
RNA_def_property_ui_text(prop, "Mode", NULL);
RNA_def_property_ui_text(prop, "Mode", nullptr);
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update_rebuild");
prop = RNA_def_property(srna, "reiteration_method", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
RNA_def_property_enum_items(prop, prop_itasc_reiteration_items);
RNA_def_property_ui_text(prop,
"Reiteration",
@ -1540,7 +1542,7 @@ static void rna_def_pose_itasc(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "use_auto_step", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ITASC_AUTO_STEP);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", ITASC_AUTO_STEP);
RNA_def_property_ui_text(prop,
"Auto Step",
"Automatically determine the optimal number of steps for best "
@ -1548,21 +1550,21 @@ static void rna_def_pose_itasc(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "step_min", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "minstep");
RNA_def_property_float_sdna(prop, nullptr, "minstep");
RNA_def_property_range(prop, 0.0f, 0.1f);
RNA_def_property_ui_text(
prop, "Min Step", "Lower bound for timestep in second in case of automatic substeps");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "step_max", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "maxstep");
RNA_def_property_float_sdna(prop, nullptr, "maxstep");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(
prop, "Max Step", "Higher bound for timestep in second in case of automatic substeps");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "feedback", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "feedback");
RNA_def_property_float_sdna(prop, nullptr, "feedback");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(
prop,
@ -1571,20 +1573,20 @@ static void rna_def_pose_itasc(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "velocity_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "maxvel");
RNA_def_property_float_sdna(prop, nullptr, "maxvel");
RNA_def_property_range(prop, 0.0f, 100.0f);
RNA_def_property_ui_text(prop, "Max Velocity", "Maximum joint velocity in radians/second");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "solver", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "solver");
RNA_def_property_enum_sdna(prop, nullptr, "solver");
RNA_def_property_enum_items(prop, prop_solver_items);
RNA_def_property_ui_text(
prop, "Solver", "Solving method selection: automatic damping or manual damping");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update_rebuild");
prop = RNA_def_property(srna, "damping_max", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "dampmax");
RNA_def_property_float_sdna(prop, nullptr, "dampmax");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop,
"Damp",
@ -1593,7 +1595,7 @@ static void rna_def_pose_itasc(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
prop = RNA_def_property(srna, "damping_epsilon", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "dampeps");
RNA_def_property_float_sdna(prop, nullptr, "dampeps");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop,
"Epsilon",
@ -1607,13 +1609,13 @@ static void rna_def_pose_ikparam(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "IKParam", NULL);
srna = RNA_def_struct(brna, "IKParam", nullptr);
RNA_def_struct_sdna(srna, "bIKParam");
RNA_def_struct_ui_text(srna, "IKParam", "Base type for IK solver parameters");
RNA_def_struct_refine_func(srna, "rna_IKParam_refine");
prop = RNA_def_property(srna, "ik_solver", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "iksolver");
RNA_def_property_enum_sdna(prop, nullptr, "iksolver");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_enum_items(prop, prop_iksolver_items);
RNA_def_property_ui_text(prop, "IK Solver", "IK solver for which these parameters are defined");
@ -1629,7 +1631,7 @@ static void rna_def_bone_groups(BlenderRNA *brna, PropertyRNA *cprop)
PropertyRNA *parm;
RNA_def_property_srna(cprop, "BoneGroups");
srna = RNA_def_struct(brna, "BoneGroups", NULL);
srna = RNA_def_struct(brna, "BoneGroups", nullptr);
RNA_def_struct_sdna(srna, "bPose");
RNA_def_struct_ui_text(srna, "Bone Groups", "Collection of bone groups");
@ -1653,12 +1655,12 @@ static void rna_def_bone_groups(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_struct_type(prop, "BoneGroup");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_pointer_funcs(
prop, "rna_Pose_active_bone_group_get", "rna_Pose_active_bone_group_set", NULL, NULL);
prop, "rna_Pose_active_bone_group_get", "rna_Pose_active_bone_group_set", nullptr, nullptr);
RNA_def_property_ui_text(prop, "Active Bone Group", "Active bone group for this pose");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update");
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "active_group");
RNA_def_property_int_sdna(prop, nullptr, "active_group");
RNA_def_property_int_funcs(prop,
"rna_Pose_active_bone_group_index_get",
"rna_Pose_active_bone_group_index_set",
@ -1673,32 +1675,39 @@ static void rna_def_pose(BlenderRNA *brna)
PropertyRNA *prop;
/* struct definition */
srna = RNA_def_struct(brna, "Pose", NULL);
srna = RNA_def_struct(brna, "Pose", nullptr);
RNA_def_struct_sdna(srna, "bPose");
RNA_def_struct_ui_text(
srna, "Pose", "A collection of pose channels, including settings for animating bones");
/* pose channels */
prop = RNA_def_property(srna, "bones", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "chanbase", NULL);
RNA_def_property_collection_sdna(prop, nullptr, "chanbase", nullptr);
RNA_def_property_struct_type(prop, "PoseBone");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Pose Bones", "Individual pose bones for the armature");
/* can be removed, only for fast lookup */
RNA_def_property_collection_funcs(
prop, NULL, NULL, NULL, NULL, NULL, NULL, "rna_PoseBones_lookup_string", NULL);
RNA_def_property_collection_funcs(prop,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
"rna_PoseBones_lookup_string",
nullptr);
/* bone groups */
prop = RNA_def_property(srna, "bone_groups", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "agroups", NULL);
RNA_def_property_collection_sdna(prop, nullptr, "agroups", nullptr);
RNA_def_property_struct_type(prop, "BoneGroup");
RNA_def_property_ui_text(prop, "Bone Groups", "Groups of the bones");
rna_def_bone_groups(brna, prop);
/* ik solvers */
prop = RNA_def_property(srna, "ik_solver", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "iksolver");
RNA_def_property_enum_funcs(prop, NULL, "rna_Pose_ik_solver_set", NULL);
RNA_def_property_enum_sdna(prop, nullptr, "iksolver");
RNA_def_property_enum_funcs(prop, nullptr, "rna_Pose_ik_solver_set", nullptr);
RNA_def_property_enum_items(prop, prop_iksolver_items);
RNA_def_property_ui_text(prop, "IK Solver", "Selection of IK solver for IK chain");
RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_ik_solver_update");
@ -1706,7 +1715,7 @@ static void rna_def_pose(BlenderRNA *brna)
prop = RNA_def_property(srna, "ik_param", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "IKParam");
RNA_def_property_pointer_funcs(
prop, "rna_Pose_ikparam_get", NULL, "rna_Pose_ikparam_typef", NULL);
prop, "rna_Pose_ikparam_get", nullptr, "rna_Pose_ikparam_typef", nullptr);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "IK Param", "Parameters for IK solver");
@ -1714,7 +1723,7 @@ static void rna_def_pose(BlenderRNA *brna)
/* pose edit options */
prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", POSE_MIRROR_EDIT);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", POSE_MIRROR_EDIT);
RNA_def_property_ui_text(
prop, "X-Axis Mirror", "Apply changes to matching bone on opposite side of X-Axis");
RNA_def_struct_path_func(srna, "rna_Pose_path");
@ -1722,7 +1731,7 @@ static void rna_def_pose(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
prop = RNA_def_property(srna, "use_mirror_relative", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", POSE_MIRROR_RELATIVE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", POSE_MIRROR_RELATIVE);
RNA_def_property_ui_text(
prop,
"Relative Mirror",
@ -1732,7 +1741,7 @@ static void rna_def_pose(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
prop = RNA_def_property(srna, "use_auto_ik", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", POSE_AUTO_IK);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", POSE_AUTO_IK);
RNA_def_property_ui_text(
prop, "Auto IK", "Add temporary IK constraints while grabbing bones in Pose Mode");
RNA_def_struct_path_func(srna, "rna_Pose_path");

View File

@ -664,7 +664,7 @@ static void correctivesmooth_modifier_do(ModifierData *md,
me_numVerts = me->totvert;
}
BLI_assert((uint)me_numVerts == verts_num);
BLI_assert(uint(me_numVerts) == verts_num);
}
#ifdef DEBUG_TIME

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