Nodes: Panel declarations for grouping sockets #108649

Merged
Lukas Tönne merged 27 commits from LukasTonne/blender:node-socket-categories into main 2023-06-14 18:02:46 +02:00
195 changed files with 2938 additions and 1938 deletions
Showing only changes of commit 7b28d4c3f4 - Show all commits

View File

@ -914,10 +914,9 @@ set_and_warn_dependency(WITH_TBB WITH_MOD_FLUID OFF)
# NanoVDB requires OpenVDB to convert the data structure
set_and_warn_dependency(WITH_OPENVDB WITH_NANOVDB OFF)
# OpenVDB, Alembic and Vulkan, OSL uses 'half' or 'imath' from OpenEXR
# OpenVDB, Alembic and OSL uses 'half' or 'imath' from OpenEXR
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENVDB OFF)
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_ALEMBIC OFF)
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_VULKAN_BACKEND OFF)
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_CYCLES_OSL OFF)
# auto enable openimageio for cycles

View File

@ -95,7 +95,7 @@ set(USD_EXTRA_ARGS
# Ray: I'm not sure if the other platforms relied on this or not but this is no longer
# needed for windows. If mac/lin confirm, this can be removed.
if(NOT WIN32)
LIST(append USD_EXTRA_ARGS
list(APPEND USD_EXTRA_ARGS
# USD wants the tbb debug lib set even when you are doing a release build
# Otherwise it will error out during the cmake configure phase.
-DTBB_LIBRARIES_DEBUG=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${SHAREDLIBEXT}

View File

@ -5,8 +5,24 @@
#ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
# undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
-# define _DEBUG
+// BLENDER: TBB excepts this to have a value.
+// BLENDER: TBB expects this to have a value.
+# define _DEBUG 1
# ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
# undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
# undef _CRT_NOFORCE_MANIFEST
--- a/boost/config/stdlib/libcpp.hpp 2022-08-03 22:47:07.000000000 -0400
+++ b/boost/config/stdlib/libcpp.hpp 2022-09-16 22:16:17.044119011 -0400
@@ -168,4 +168,13 @@
# define BOOST_NO_CXX14_HDR_SHARED_MUTEX
#endif
+#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 15000
+//
+// Unary function is now deprecated in C++11 and later:
+//
+#if __cplusplus >= 201103L
+#define BOOST_NO_CXX98_FUNCTION_BASE
+#endif
+#endif
+
// --- end ---

View File

@ -5,6 +5,8 @@ from __future__ import annotations
import bpy
import _cycles
from bpy.app.translations import pgettext_tip as tip_
def osl_compile(input_path, report):
"""compile .osl file with given filepath to temporary .oso file"""
@ -103,7 +105,7 @@ def update_script_node(node, report):
ok = _cycles.osl_update_node(data, node.id_data.as_pointer(), node.as_pointer(), oso_path)
if not ok:
report({'ERROR'}, "OSL query failed to open " + oso_path)
report({'ERROR'}, tip_("OSL query failed to open %s") % oso_path)
else:
report({'ERROR'}, "OSL script compilation failed, see console for errors")

View File

@ -197,8 +197,14 @@ ccl_device_inline void object_normal_transform(KernelGlobals kg,
}
#endif
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
*N = normalize(transform_direction_transposed(&tfm, *N));
if (sd->object != OBJECT_NONE) {
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
*N = normalize(transform_direction_transposed(&tfm, *N));
}
else if (sd->type == PRIMITIVE_LAMP) {
Transform tfm = lamp_fetch_transform(kg, sd->lamp, true);
*N = normalize(transform_direction_transposed(&tfm, *N));
}
}
ccl_device_inline bool object_negative_scale_applied(const int object_flag)

View File

@ -47,7 +47,9 @@ shader node_texture_coordinate(
if (!getattribute("geom:generated", Generated)) {
Generated = transform("object", P);
}
getattribute("geom:uv", UV);
if (!getattribute("geom:uv", UV)) {
UV = point(1.0 - u - v, u, 0.0);
}
}
if (use_transform) {

View File

@ -71,6 +71,11 @@ ccl_device_noinline void svm_node_attr(KernelGlobals kg,
}
#endif
if (sd->type == PRIMITIVE_LAMP && node.y == ATTR_STD_UV) {
stack_store_float3(stack, out_offset, make_float3(1.0f - sd->u - sd->v, sd->u, 0.0f));
return;
}
if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) {
/* No generated attribute, fall back to object coordinates. */
float3 f = sd->P;

View File

@ -25,24 +25,32 @@ ccl_device_noinline void svm_node_vector_transform(KernelGlobals kg,
NodeVectorTransformConvertSpace to = (NodeVectorTransformConvertSpace)ito;
Transform tfm;
bool is_object = (sd->object != OBJECT_NONE);
bool is_direction = (type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR ||
type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL);
bool is_object = (sd->object != OBJECT_NONE) || (sd->type == PRIMITIVE_LAMP);
bool is_normal = (type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL);
bool is_direction = (type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR);
/* From world */
if (from == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD) {
if (to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) {
tfm = kernel_data.cam.worldtocamera;
if (is_direction)
in = transform_direction(&tfm, in);
else
in = transform_point(&tfm, in);
if (is_normal) {
tfm = kernel_data.cam.cameratoworld;
in = normalize(transform_direction_transposed(&tfm, in));
}
else {
tfm = kernel_data.cam.worldtocamera;
in = is_direction ? transform_direction(&tfm, in) : transform_point(&tfm, in);
}
}
else if (to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT && is_object) {
if (is_direction)
if (is_normal) {
object_inverse_normal_transform(kg, sd, &in);
}
else if (is_direction) {
object_inverse_dir_transform(kg, sd, &in);
else
}
else {
object_inverse_position_transform(kg, sd, &in);
}
}
}
@ -51,17 +59,25 @@ ccl_device_noinline void svm_node_vector_transform(KernelGlobals kg,
if (to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD ||
to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT)
{
tfm = kernel_data.cam.cameratoworld;
if (is_direction)
in = transform_direction(&tfm, in);
else
in = transform_point(&tfm, in);
if (is_normal) {
tfm = kernel_data.cam.worldtocamera;
in = normalize(transform_direction_transposed(&tfm, in));
}
else {
tfm = kernel_data.cam.cameratoworld;
in = is_direction ? transform_direction(&tfm, in) : transform_point(&tfm, in);
}
}
if (to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT && is_object) {
if (is_direction)
if (is_normal) {
object_inverse_normal_transform(kg, sd, &in);
}
else if (is_direction) {
object_inverse_dir_transform(kg, sd, &in);
else
}
else {
object_inverse_position_transform(kg, sd, &in);
}
}
}
@ -71,24 +87,33 @@ ccl_device_noinline void svm_node_vector_transform(KernelGlobals kg,
to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) &&
is_object)
{
if (is_direction)
if (is_normal) {
object_normal_transform(kg, sd, &in);
}
else if (is_direction) {
object_dir_transform(kg, sd, &in);
else
}
else {
object_position_transform(kg, sd, &in);
}
}
if (to == NODE_VECTOR_TRANSFORM_CONVERT_SPACE_CAMERA) {
tfm = kernel_data.cam.worldtocamera;
if (is_direction)
in = transform_direction(&tfm, in);
else
in = transform_point(&tfm, in);
if (is_normal) {
tfm = kernel_data.cam.cameratoworld;
in = normalize(transform_direction_transposed(&tfm, in));
}
else {
tfm = kernel_data.cam.worldtocamera;
if (is_direction) {
in = transform_direction(&tfm, in);
}
else {
in = transform_point(&tfm, in);
}
}
}
}
/* Normalize Normal */
if (type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL)
in = normalize(in);
/* Output */
if (stack_valid(vector_out)) {
stack_store_float3(stack, vector_out, in);

View File

@ -1335,7 +1335,7 @@ static void ghost_wayland_log_handler(const char *msg, va_list arg)
}
}
#ifdef WITH_GHOST_X11
#if defined(WITH_GHOST_X11) && defined(WITH_GHOST_WAYLAND_LIBDECOR)
/**
* Check if the system is running X11.
* This is not intended to be a fool-proof check (the `DISPLAY` is not validated for e.g.).
@ -1349,7 +1349,7 @@ static bool ghost_wayland_is_x11_available()
}
return false;
}
#endif /* WITH_GHOST_X11 */
#endif /* WITH_GHOST_X11 && WITH_GHOST_WAYLAND_LIBDECOR */
static GHOST_TKey xkb_map_gkey(const xkb_keysym_t sym)
{

View File

@ -38,6 +38,8 @@ const UserDef U_default = {
.sounddir = "//",
.i18ndir = "",
.image_editor = "",
.text_editor = "",
.text_editor_args = "",
.anim_player = "",
.anim_player_preset = 0,
.v2d_min_gridsize = 45,

View File

@ -68,7 +68,7 @@ _km_hierarchy = [
('Font', 'EMPTY', 'WINDOW', [
_km_expand_from_toolsystem('VIEW_3D', 'EDIT_TEXT'),
]),
('Grease Pencil', 'EMPTY', 'WINDOW', []),
('Pose', 'EMPTY', 'WINDOW', [
_km_expand_from_toolsystem('VIEW_3D', 'POSE'),
]),

View File

@ -3667,7 +3667,8 @@ def km_grease_pencil_stroke_edit_mode(params):
("gpencil.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
# Extrude and move selected points
op_tool_optional(
("gpencil.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
("gpencil.extrude_move", {"type": 'E', "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
(op_tool_cycle, "builtin.extrude"), params),
# Delete
op_menu("VIEW3D_MT_edit_gpencil_delete", {"type": 'X', "value": 'PRESS'}),
@ -4493,6 +4494,21 @@ def km_grease_pencil_stroke_vertex_replace(_params):
return keymap
def km_grease_pencil_edit(params):
items = []
keymap = (
"Grease Pencil Edit Mode",
{"space_type": 'EMPTY', "region_type": 'WINDOW'},
{"items": items},
)
items.extend([
*_template_items_select_actions(params, "grease_pencil.select_all"),
])
return keymap
def km_face_mask(params):
items = []
keymap = (
@ -4656,8 +4672,10 @@ def km_object_mode(params):
op_menu("VIEW3D_MT_add", {"type": 'A', "value": 'PRESS', "shift": True}),
op_menu("VIEW3D_MT_object_apply", {"type": 'A', "value": 'PRESS', "ctrl": True}),
op_menu("VIEW3D_MT_make_links", {"type": 'L', "value": 'PRESS', "ctrl": True}),
("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True}, None),
("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
("object.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
("wm.context_toggle", {"type": 'PERIOD', "value": 'PRESS', "ctrl": True},
{"properties": [("data_path", 'tool_settings.use_transform_data_origin')]}),
@ -4762,7 +4780,8 @@ def km_curve(params):
("curve.separate", {"type": 'P', "value": 'PRESS'}, None),
("curve.split", {"type": 'Y', "value": 'PRESS'}, None),
op_tool_optional(
("curve.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
("curve.extrude_move", {"type": 'E', "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
(op_tool_cycle, "builtin.extrude"), params),
("curve.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
("curve.make_segment", {"type": 'F', "value": 'PRESS'}, None),
@ -5371,7 +5390,8 @@ def km_mesh(params):
("mesh.normals_make_consistent", {"type": 'N', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("inside", True)]}),
op_tool_optional(
("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'}, None),
("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'},
{"properties": [("allow_navigation", params.use_transform_navigation)]}),
(op_tool_cycle, "builtin.extrude_region"), params),
op_menu("VIEW3D_MT_edit_mesh_extrude", {"type": 'E', "value": 'PRESS', "alt": True}),
("transform.edge_crease", {"type": 'E', "value": 'PRESS', "shift": True}, None),
@ -5388,11 +5408,13 @@ def km_mesh(params):
# No tool is available for this.
("mesh.rip_move", {"type": 'V', "value": 'PRESS', "alt": True},
{"properties": [("MESH_OT_rip", [("use_fill", True)],)]}),
("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True}, None),
("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
op_menu("VIEW3D_MT_edit_mesh_merge", {"type": 'M', "value": 'PRESS'}),
op_menu("VIEW3D_MT_edit_mesh_split", {"type": 'M', "value": 'PRESS', "alt": True}),
("mesh.edge_face_add", {"type": 'F', "value": 'PRESS', "repeat": True}, None),
("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
op_menu("VIEW3D_MT_mesh_add", {"type": 'A', "value": 'PRESS', "shift": True}),
("mesh.separate", {"type": 'P', "value": 'PRESS'}, None),
("mesh.split", {"type": 'Y', "value": 'PRESS'}, None),
@ -5510,7 +5532,8 @@ def km_armature(params):
("armature.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
("armature.dissolve", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None),
op_tool_optional(
("armature.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
("armature.extrude_move", {"type": 'E', "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("allow_navigation", params.use_transform_navigation)])]}),
(op_tool_cycle, "builtin.extrude"), params),
("armature.extrude_forked", {"type": 'E', "value": 'PRESS', "shift": True}, None),
("armature.click_extrude", {"type": params.action_mouse, "value": 'CLICK', "ctrl": True}, None),
@ -8209,7 +8232,7 @@ def generate_keymaps(params=None):
km_animation_channels(params),
# Modes.
km_grease_pencil(params),
km_grease_pencil(params), # TODO: Rename to km_annotate
km_grease_pencil_stroke_curve_edit_mode(params),
km_grease_pencil_stroke_edit_mode(params),
km_grease_pencil_stroke_paint_mode(params),
@ -8238,6 +8261,7 @@ def generate_keymaps(params=None):
km_grease_pencil_stroke_vertex_average(params),
km_grease_pencil_stroke_vertex_smear(params),
km_grease_pencil_stroke_vertex_replace(params),
km_grease_pencil_edit(params),
km_face_mask(params),
km_weight_paint_vertex_selection(params),
km_pose(params),

View File

@ -0,0 +1,6 @@
import bpy
filepaths = bpy.context.preferences.filepaths
filepaths.text_editor = ""
filepaths.text_editor_args = ""

View File

@ -0,0 +1,12 @@
import bpy
import platform
filepaths = bpy.context.preferences.filepaths
filepaths.text_editor_args = "-g $filepath:$line:$column"
match platform.system():
case "Windows":
filepaths.text_editor = "code.cmd"
case _:
filepaths.text_editor = "code"

View File

@ -28,6 +28,7 @@ _modules = [
"screen_play_rendered_anim",
"sequencer",
"spreadsheet",
"text",
"userpref",
"uvcalc_follow_active",
"uvcalc_lightmap",

View File

@ -82,11 +82,7 @@ class ASSET_OT_open_containing_blend_file(Operator):
@classmethod
def poll(cls, context):
asset_file_handle = getattr(context, "asset_file_handle", None)
asset_library_ref = getattr(context, "asset_library_ref", None)
if not asset_library_ref:
cls.poll_message_set("No asset library selected")
return False
if not asset_file_handle:
cls.poll_message_set("No asset selected")
return False

View File

@ -91,7 +91,7 @@ class NodeAddOperator:
except AttributeError as e:
self.report(
{'ERROR_INVALID_INPUT'},
"Node has no attribute " + setting.name)
tip_("Node has no attribute %s") % setting.name)
print(str(e))
# Continue despite invalid attribute

View File

@ -413,6 +413,24 @@ class AddPresetHairDynamics(AddPresetBase, Operator):
]
class AddPresetTextEditor(AddPresetBase, Operator):
"""Add or remove a Text Editor Preset"""
bl_idname = "text_editor.preset_add"
bl_label = "Add Text Editor Preset"
preset_menu = "USERPREF_PT_text_editor_presets"
preset_defines = [
"filepaths = bpy.context.preferences.filepaths"
]
preset_values = [
"filepaths.text_editor",
"filepaths.text_editor_args"
]
preset_subdir = "text_editor"
class AddPresetTrackingCamera(AddPresetBase, Operator):
"""Add or remove a Tracking Camera Intrinsics Preset"""
bl_idname = "clip.camera_preset_add"
@ -692,6 +710,7 @@ classes = (
AddPresetOperator,
AddPresetRender,
AddPresetCameraSafeAreas,
AddPresetTextEditor,
AddPresetTrackingCamera,
AddPresetTrackingSettings,
AddPresetTrackingTrackColor,

View File

@ -0,0 +1,83 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
from bpy.types import Operator
from bpy.props import (
IntProperty,
StringProperty,
)
class TEXT_OT_jump_to_file_at_point(Operator):
bl_idname = "text.jump_to_file_at_point"
bl_label = "Open Text File at point"
bl_description = "Edit text file in external text editor"
filepath: StringProperty(name="filepath")
line: IntProperty(name="line")
column: IntProperty(name="column")
def execute(self, context):
import shlex
import subprocess
from string import Template
if not self.properties.is_property_set("filepath"):
text = getattr(getattr(context, "space_data", None), "text", None)
if not text:
return {'CANCELLED'}
self.filepath = text.filepath
self.line = text.current_line_index
self.column = text.current_character
text_editor = context.preferences.filepaths.text_editor
text_editor_args = context.preferences.filepaths.text_editor_args
# Use the internal text editor.
if not text_editor:
return bpy.ops.text.jump_to_file_at_point_internal(
filepath=self.filepath,
line=self.line,
column=self.column,
)
if not text_editor_args:
self.report(
{'ERROR_INVALID_INPUT'},
"Provide text editor argument format in File Paths/Applications Preferences, "
"see input field tool-tip for more information.",
)
return {'CANCELLED'}
if "$filepath" not in text_editor_args:
self.report({'ERROR_INVALID_INPUT'}, "Text Editor Args Format must contain $filepath")
return {'CANCELLED'}
args = [text_editor]
template_vars = {
"filepath": self.filepath,
"line": self.line + 1,
"column": self.column + 1,
"line0": self.line,
"column0": self.column,
}
try:
args.extend([Template(arg).substitute(**template_vars) for arg in shlex.split(text_editor_args)])
except Exception as ex:
self.report({'ERROR'}, "Exception parsing template: %r" % ex)
return {'CANCELLED'}
try:
# With `check=True` if `process.returncode != 0` an exception will be raised.
subprocess.run(args, check=True)
except Exception as ex:
self.report({'ERROR'}, "Exception running external editor: %r" % ex)
return {'CANCELLED'}
return {'FINISHED'}
classes = (
TEXT_OT_jump_to_file_at_point,
)

View File

@ -13,6 +13,12 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
bl_label = "Extrude Individual and Move"
bl_idname = "view3d.edit_mesh_extrude_individual_move"
allow_navigation: BoolProperty(
name="allow_navigation",
default=False,
description="Allow navigation",
)
@classmethod
def poll(cls, context):
obj = context.active_object
@ -32,14 +38,29 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
TRANSFORM_OT_translate={
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"allow_navigation": self.allow_navigation,
},
)
elif select_mode[2] and totface > 1:
bpy.ops.mesh.extrude_faces_move('INVOKE_REGION_WIN')
bpy.ops.mesh.extrude_faces_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={
"allow_navigation": self.allow_navigation,
})
elif select_mode[1] and totedge >= 1:
bpy.ops.mesh.extrude_edges_move('INVOKE_REGION_WIN')
bpy.ops.mesh.extrude_edges_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"allow_navigation": self.allow_navigation,
},
)
else:
bpy.ops.mesh.extrude_vertices_move('INVOKE_REGION_WIN')
bpy.ops.mesh.extrude_vertices_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"allow_navigation": self.allow_navigation,
},
)
# ignore return from operators above because they are 'RUNNING_MODAL',
# and cause this one not to be freed. #24671.
@ -60,13 +81,19 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
description="Dissolves adjacent faces and intersects new geometry",
)
allow_navigation: BoolProperty(
name="allow_navigation",
default=False,
description="Allow navigation",
)
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj is not None and obj.mode == 'EDIT')
@staticmethod
def extrude_region(context, use_vert_normals, dissolve_and_intersect):
def extrude_region(context, use_vert_normals, dissolve_and_intersect, allow_navigation):
mesh = context.object.data
totface = mesh.total_face_sel
@ -77,7 +104,9 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
if use_vert_normals:
bpy.ops.mesh.extrude_region_shrink_fatten(
'INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={},
TRANSFORM_OT_shrink_fatten={
"allow_navigation": allow_navigation,
},
)
elif dissolve_and_intersect:
bpy.ops.mesh.extrude_manifold(
@ -88,6 +117,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
TRANSFORM_OT_translate={
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"allow_navigation": allow_navigation,
},
)
else:
@ -96,6 +126,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
TRANSFORM_OT_translate={
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"allow_navigation": allow_navigation,
},
)
@ -109,16 +140,23 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
# Not a popular choice, too restrictive for retopo.
# "constraint_axis": (True, True, False)})
"constraint_axis": (False, False, False),
"allow_navigation": allow_navigation,
})
else:
bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN')
bpy.ops.mesh.extrude_region_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"allow_navigation": allow_navigation,
},
)
# ignore return from operators above because they are 'RUNNING_MODAL',
# and cause this one not to be freed. #24671.
return {'FINISHED'}
def execute(self, context):
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, False, self.dissolve_and_intersect)
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(
context, False, self.dissolve_and_intersect, self.allow_navigation)
def invoke(self, context, _event):
return self.execute(context)
@ -129,13 +167,19 @@ class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator):
bl_label = "Extrude and Move on Individual Normals"
bl_idname = "view3d.edit_mesh_extrude_move_shrink_fatten"
allow_navigation: BoolProperty(
name="allow_navigation",
default=False,
description="Allow navigation",
)
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj is not None and obj.mode == 'EDIT')
def execute(self, context):
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True, False)
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True, False, self.allow_navigation)
def invoke(self, context, _event):
return self.execute(context)
@ -146,6 +190,12 @@ class VIEW3D_OT_edit_mesh_extrude_manifold_normal(Operator):
bl_label = "Extrude Manifold Along Normals"
bl_idname = "view3d.edit_mesh_extrude_manifold_normal"
allow_navigation: BoolProperty(
name="allow_navigation",
default=False,
description="Allow navigation",
)
@classmethod
def poll(cls, context):
obj = context.active_object
@ -160,6 +210,7 @@ class VIEW3D_OT_edit_mesh_extrude_manifold_normal(Operator):
TRANSFORM_OT_translate={
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"allow_navigation": self.allow_navigation,
},
)
return {'FINISHED'}

View File

@ -256,7 +256,13 @@ class TEXT_MT_text(Menu):
if text:
layout.separator()
layout.operator("text.reload")
row = layout.row()
row.operator("text.reload")
row.enabled = not text.is_in_memory
row = layout.row()
op = row.operator("text.jump_to_file_at_point", text="Edit Externally")
row.enabled = (not text.is_in_memory and context.preferences.filepaths.text_editor != "")
layout.separator()
layout.operator("text.save", icon='FILE_TICK')

View File

@ -1972,7 +1972,7 @@ class _defs_gpencil_paint:
def generate_from_brushes(context):
if context and context.preferences.experimental.use_grease_pencil_version3:
return tuple([ToolDef.from_dict(dict(
idname="builtin_brush.draw",
idname="builtin_brush.Draw",
label="Draw",
icon="brush.gpencil_draw.draw",
data_block='DRAW',

View File

@ -10,6 +10,7 @@ from bpy.app.translations import (
pgettext_iface as iface_,
pgettext_tip as tip_,
)
from bl_ui.utils import PresetPanel
# -----------------------------------------------------------------------------
@ -1399,6 +1400,13 @@ class USERPREF_PT_file_paths_render(FilePathsPanel, Panel):
col.prop(paths, "render_cache_directory", text="Render Cache")
class USERPREF_PT_text_editor_presets(PresetPanel, Panel):
bl_label = "Text Editor Presets"
preset_subdir = "text_editor"
preset_operator = "script.execute_preset"
preset_add_operator = "text_editor.preset_add"
class USERPREF_PT_file_paths_applications(FilePathsPanel, Panel):
bl_label = "Applications"
@ -1416,6 +1424,25 @@ class USERPREF_PT_file_paths_applications(FilePathsPanel, Panel):
col.prop(paths, "animation_player", text="Player")
class USERPREF_PT_text_editor(FilePathsPanel, Panel):
bl_label = "Text Editor"
bl_parent_id = "USERPREF_PT_file_paths_applications"
def draw_header_preset(self, _context):
USERPREF_PT_text_editor_presets.draw_panel_header(self.layout)
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
paths = context.preferences.filepaths
col = layout.column()
col.prop(paths, "text_editor", text="Program")
col.prop(paths, "text_editor_args", text="Arguments")
class USERPREF_PT_file_paths_development(FilePathsPanel, Panel):
bl_label = "Development"
@ -2510,6 +2537,8 @@ classes = (
USERPREF_PT_file_paths_script_directories,
USERPREF_PT_file_paths_render,
USERPREF_PT_file_paths_applications,
USERPREF_PT_text_editor,
USERPREF_PT_text_editor_presets,
USERPREF_PT_file_paths_development,
USERPREF_PT_file_paths_asset_libraries,

View File

@ -945,11 +945,11 @@ class VIEW3D_MT_editor_menus(Menu):
tool_settings.use_gpencil_select_mask_stroke or
tool_settings.use_gpencil_select_mask_segment)
):
layout.menu("VIEW3D_MT_select_gpencil")
layout.menu("VIEW3D_MT_select_edit_gpencil")
elif mode_string == 'EDIT_GPENCIL':
layout.menu("VIEW3D_MT_select_gpencil")
layout.menu("VIEW3D_MT_select_edit_gpencil")
elif mode_string == 'VERTEX_GPENCIL':
layout.menu("VIEW3D_MT_select_gpencil")
layout.menu("VIEW3D_MT_select_edit_gpencil")
elif mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
mesh = obj.data
if mesh.use_paint_mask:
@ -1043,17 +1043,9 @@ class VIEW3D_MT_transform_base:
"use_transform_navigation",
False)
props = layout.operator("transform.translate")
props.release_confirm = False
props.allow_navigation = allow_navigation
props = layout.operator("transform.rotate")
props.release_confirm = False
props.allow_navigation = allow_navigation
props = layout.operator("transform.resize", text="Scale")
props.release_confirm = False
props.allow_navigation = allow_navigation
layout.operator("transform.translate").allow_navigation = allow_navigation
layout.operator("transform.rotate").allow_navigation = allow_navigation
layout.operator("transform.resize", text="Scale").allow_navigation = allow_navigation
layout.separator()
@ -1073,21 +1065,30 @@ class VIEW3D_MT_transform_base:
# Generic transform menu - geometry types
class VIEW3D_MT_transform(VIEW3D_MT_transform_base, Menu):
def draw(self, context):
allow_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_transform_navigation",
False)
# base menu
VIEW3D_MT_transform_base.draw(self, context)
# generic...
layout = self.layout
if context.mode == 'EDIT_MESH':
layout.operator("transform.shrink_fatten", text="Shrink/Fatten")
layout.operator("transform.shrink_fatten", text="Shrink/Fatten").allow_navigation = allow_navigation
layout.operator("transform.skin_resize")
elif context.mode == 'EDIT_CURVE':
layout.operator("transform.transform", text="Radius").mode = 'CURVE_SHRINKFATTEN'
if context.mode != 'EDIT_CURVES':
layout.separator()
layout.operator("transform.translate", text="Move Texture Space").texture_space = True
layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
props = layout.operator("transform.translate", text="Move Texture Space")
props.texture_space = True
props.allow_navigation = allow_navigation
props = layout.operator("transform.resize", text="Scale Texture Space")
props.texture_space = True
props.allow_navigation = allow_navigation
# Object-specific extensions to Transform menu
@ -1984,7 +1985,7 @@ class VIEW3D_MT_paint_gpencil(Menu):
class VIEW3D_MT_select_edit_gpencil(Menu):
bl_label = "Select"
def draw(self, context):
def draw_legacy(self, context):
layout = self.layout
layout.operator("gpencil.select_all", text="All").action = 'SELECT'
@ -2017,6 +2018,18 @@ class VIEW3D_MT_select_edit_gpencil(Menu):
layout.operator("gpencil.select_more")
layout.operator("gpencil.select_less")
def draw(self, context):
if not context.preferences.experimental.use_grease_pencil_version3:
self.draw_legacy(context)
layout = self.layout
layout.operator("grease_pencil.select_all", text="All").action = 'SELECT'
layout.operator("grease_pencil.select_all", text="None").action = 'DESELECT'
layout.operator("grease_pencil.select_all", text="Invert").action = 'INVERT'
layout.separator()
class VIEW3D_MT_select_paint_mask(Menu):
bl_label = "Select"
@ -4169,6 +4182,11 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
col.operator("mesh.delete", text="Delete Edges").type = 'EDGE'
if is_face_mode:
allow_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_transform_navigation",
False)
col = row.column(align=True)
col.label(text="Face Context Menu", icon='FACESEL')
@ -4179,9 +4197,12 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
col.separator()
col.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces")
col.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals")
col.operator("mesh.extrude_faces_move", text="Extrude Individual Faces")
col.operator("view3d.edit_mesh_extrude_move_normal",
text="Extrude Faces").allow_navigation = allow_navigation
col.operator("view3d.edit_mesh_extrude_move_shrink_fatten",
text="Extrude Faces Along Normals").allow_navigation = allow_navigation
col.operator("mesh.extrude_faces_move",
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.allow_navigation = allow_navigation
col.operator("mesh.inset")
col.operator("mesh.poke")
@ -4230,46 +4251,39 @@ class VIEW3D_MT_edit_mesh_select_mode(Menu):
class VIEW3D_MT_edit_mesh_extrude(Menu):
bl_label = "Extrude"
_extrude_funcs = {
'VERT': lambda layout:
layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices"),
'EDGE': lambda layout:
layout.operator("mesh.extrude_edges_move", text="Extrude Edges"),
'REGION': lambda layout:
layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces"),
'REGION_VERT_NORMAL': lambda layout:
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"),
'FACE': lambda layout:
layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"),
'MANIFOLD': lambda layout:
layout.operator("view3d.edit_mesh_extrude_manifold_normal", text="Extrude Manifold"),
}
@staticmethod
def extrude_options(context):
tool_settings = context.tool_settings
select_mode = tool_settings.mesh_select_mode
mesh = context.object.data
menu = []
if mesh.total_face_sel:
menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE', 'MANIFOLD']
if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
menu += ['EDGE']
if mesh.total_vert_sel and select_mode[0]:
menu += ['VERT']
# should never get here
return menu
def draw(self, context):
from math import pi
allow_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_transform_navigation",
False)
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
for menu_id in self.extrude_options(context):
self._extrude_funcs[menu_id](layout)
tool_settings = context.tool_settings
select_mode = tool_settings.mesh_select_mode
mesh = context.object.data
if mesh.total_face_sel:
layout.operator("view3d.edit_mesh_extrude_move_normal",
text="Extrude Faces").allow_navigation = allow_navigation
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten",
text="Extrude Faces Along Normals").allow_navigation = allow_navigation
layout.operator(
"mesh.extrude_faces_move",
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.allow_navigation = allow_navigation
layout.operator("view3d.edit_mesh_extrude_manifold_normal",
text="Extrude Manifold").allow_navigation = allow_navigation
if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
layout.operator("mesh.extrude_edges_move",
text="Extrude Edges").TRANSFORM_OT_translate.allow_navigation = allow_navigation
if mesh.total_vert_sel and select_mode[0]:
layout.operator("mesh.extrude_vertices_move",
text="Extrude Vertices").TRANSFORM_OT_translate.allow_navigation = allow_navigation
layout.separator()
@ -4421,14 +4435,23 @@ class VIEW3D_MT_edit_mesh_faces(Menu):
bl_label = "Face"
bl_idname = "VIEW3D_MT_edit_mesh_faces"
def draw(self, _context):
def draw(self, context):
allow_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_transform_navigation",
False)
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces")
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals")
layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces")
layout.operator("view3d.edit_mesh_extrude_move_normal",
text="Extrude Faces").allow_navigation = allow_navigation
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten",
text="Extrude Faces Along Normals").allow_navigation = allow_navigation
layout.operator(
"mesh.extrude_faces_move",
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.allow_navigation = allow_navigation
layout.separator()
@ -7044,72 +7067,70 @@ class VIEW3D_PT_snapping(Panel):
def draw(self, context):
tool_settings = context.tool_settings
snap_elements = tool_settings.snap_elements
obj = context.active_object
object_mode = 'OBJECT' if obj is None else obj.mode
layout = self.layout
col = layout.column()
col.label(text="Snap With")
row = col.row(align=True)
row.prop(tool_settings, "snap_target", expand=True)
col.label(text="Snap To")
col.prop(tool_settings, "snap_elements", expand=True)
col.prop(tool_settings, "snap_elements_base", expand=True)
col.label(text="Snap Individual Elements To")
col.prop(tool_settings, "snap_elements_individual", expand=True)
col.separator()
if 'INCREMENT' in snap_elements:
if 'INCREMENT' in tool_settings.snap_elements:
col.prop(tool_settings, "use_snap_grid_absolute")
if snap_elements != {'INCREMENT'}:
if snap_elements != {'FACE_NEAREST'}:
col.label(text="Snap With")
row = col.row(align=True)
row.prop(tool_settings, "snap_target", expand=True)
if 'VOLUME' in tool_settings.snap_elements:
col.prop(tool_settings, "use_snap_peel_object")
if obj:
col.label(text="Target Selection")
col_targetsel = col.column(align=True)
if object_mode == 'EDIT' and obj.type not in {'LATTICE', 'META', 'FONT'}:
col_targetsel.prop(
tool_settings,
"use_snap_self",
text="Include Active",
icon='EDITMODE_HLT',
)
col_targetsel.prop(
tool_settings,
"use_snap_edit",
text="Include Edited",
icon='OUTLINER_DATA_MESH',
)
col_targetsel.prop(
tool_settings,
"use_snap_nonedit",
text="Include Non-Edited",
icon='OUTLINER_OB_MESH',
)
if 'FACE_NEAREST' in tool_settings.snap_elements:
col.prop(tool_settings, "use_snap_to_same_target")
if object_mode == 'EDIT':
col.prop(tool_settings, "snap_face_nearest_steps")
col.separator()
col.prop(tool_settings, "use_snap_align_rotation")
col.prop(tool_settings, "use_snap_backface_culling")
col.separator()
if obj:
col.label(text="Target Selection")
col_targetsel = col.column(align=True)
if object_mode == 'EDIT' and obj.type not in {'LATTICE', 'META', 'FONT'}:
col_targetsel.prop(
tool_settings,
"use_snap_selectable",
text="Exclude Non-Selectable",
icon='RESTRICT_SELECT_OFF',
"use_snap_self",
text="Include Active",
icon='EDITMODE_HLT',
)
if object_mode in {'OBJECT', 'POSE', 'EDIT', 'WEIGHT_PAINT'}:
col.prop(tool_settings, "use_snap_align_rotation")
col.prop(tool_settings, "use_snap_backface_culling")
is_face_nearest_enabled = 'FACE_NEAREST' in snap_elements
if is_face_nearest_enabled or 'FACE' in snap_elements:
sub = col.column()
sub.active = not is_face_nearest_enabled
sub.prop(tool_settings, "use_snap_project")
if is_face_nearest_enabled:
col.prop(tool_settings, "use_snap_to_same_target")
if object_mode == 'EDIT':
col.prop(tool_settings, "snap_face_nearest_steps")
if 'VOLUME' in snap_elements:
col.prop(tool_settings, "use_snap_peel_object")
col_targetsel.prop(
tool_settings,
"use_snap_edit",
text="Include Edited",
icon='OUTLINER_DATA_MESH',
)
col_targetsel.prop(
tool_settings,
"use_snap_nonedit",
text="Include Non-Edited",
icon='OUTLINER_OB_MESH',
)
col_targetsel.prop(
tool_settings,
"use_snap_selectable",
text="Exclude Non-Selectable",
icon='RESTRICT_SELECT_OFF',
)
col.label(text="Affect")
row = col.row(align=True)

View File

@ -58,6 +58,11 @@ struct AnimData *BKE_animdata_ensure_id(struct ID *id);
*/
bool BKE_animdata_set_action(struct ReportList *reports, struct ID *id, struct bAction *act);
/**
* Same as BKE_animdata_set_action(), except sets `tmpact` instead of `action`.
*/
bool BKE_animdata_set_tmpact(struct ReportList *reports, struct ID *id, struct bAction *act);
bool BKE_animdata_action_editable(const struct AnimData *adt);
/**

View File

@ -27,7 +27,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 4
#define BLENDER_FILE_SUBVERSION 5
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file

View File

@ -184,6 +184,7 @@ eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode);
bool BKE_paint_ensure_from_paintmode(struct Scene *sce, ePaintMode mode);
struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode);
const struct EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode);
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(ePaintMode mode);
const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode);
uint BKE_paint_get_brush_tool_offset_from_paintmode(ePaintMode mode);
struct Paint *BKE_paint_get_active(struct Scene *sce, struct ViewLayer *view_layer);

View File

@ -37,6 +37,7 @@ set(INC
../../../intern/mikktspace
../../../intern/opensubdiv
../../../extern/curve_fit_nd
../../../extern/fmtlib/include
# dna_type_offsets.h
${CMAKE_CURRENT_BINARY_DIR}/../makesdna/intern
@ -554,6 +555,7 @@ set(LIB
bf_rna
bf_shader_fx
bf_simulation
extern_fmtlib
# For `vfontdata_freetype.c`.
${FREETYPE_LIBRARIES} ${BROTLI_LIBRARIES}

View File

@ -114,39 +114,23 @@ AnimData *BKE_animdata_ensure_id(ID *id)
return NULL;
}
/* Action Setter --------------------------------------- */
bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
/* Action / Tmpact Setter shared code -------------------------
*
* Both the action and tmpact setter functions have essentially
* identical semantics, because tmpact is just a place to temporarily
* store the main action during tweaking. This function contains the
* shared code between those two setter functions, setting the action
* of the passed `act_slot` to `act`.
*
* Preconditions:
* - `id` and `act_slot` must be non-null (but the pointer `act_slot`
* points to can be null).
* - `id` must have animation data.
* - `act_slot` must be a pointer to either the `action` or `tmpact`
* field of `id`'s animation data.
*/
static bool animdata_set_action(ReportList *reports, ID *id, bAction **act_slot, bAction *act)
{
AnimData *adt = BKE_animdata_from_id(id);
/* Animdata validity check. */
if (adt == NULL) {
BKE_report(reports, RPT_WARNING, "No AnimData to set action on");
return false;
}
if (adt->action == act) {
/* Don't bother reducing and increasing the user count when there is nothing changing. */
return true;
}
if (!BKE_animdata_action_editable(adt)) {
/* Cannot remove, otherwise things turn to custard. */
BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being edited in NLA");
return false;
}
/* Unassign current action. */
if (adt->action) {
id_us_min((ID *)adt->action);
adt->action = NULL;
}
if (act == NULL) {
return true;
}
/* Action must have same type as owner. */
if (!BKE_animdata_action_ensure_idroot(id, act)) {
/* Cannot set to this type. */
@ -160,12 +144,59 @@ bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
return false;
}
adt->action = act;
id_us_plus((ID *)adt->action);
if (*act_slot == act) {
/* Don't bother reducing and increasing the user count when there is nothing changing. */
return true;
}
/* Unassign current action. */
if (*act_slot) {
id_us_min((ID *)*act_slot);
*act_slot = NULL;
}
if (act == NULL) {
return true;
}
*act_slot = act;
id_us_plus((ID *)*act_slot);
return true;
}
/* Tmpact Setter --------------------------------------- */
bool BKE_animdata_set_tmpact(ReportList *reports, ID *id, bAction *act)
{
AnimData *adt = BKE_animdata_from_id(id);
if (adt == NULL) {
BKE_report(reports, RPT_WARNING, "No AnimData to set tmpact on");
return false;
}
return animdata_set_action(reports, id, &adt->tmpact, act);
}
/* Action Setter --------------------------------------- */
bool BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act)
{
AnimData *adt = BKE_animdata_from_id(id);
if (adt == NULL) {
BKE_report(reports, RPT_WARNING, "No AnimData to set action on");
return false;
}
if (!BKE_animdata_action_editable(adt)) {
/* Cannot remove, otherwise things turn to custard. */
BKE_report(reports, RPT_ERROR, "Cannot change action, as it is still being edited in NLA");
return false;
}
return animdata_set_action(reports, id, &adt->action, act);
}
bool BKE_animdata_action_editable(const AnimData *adt)
{
/* Active action is only editable when it is not a tweaking strip. */

View File

@ -64,7 +64,22 @@ static void pchan_deform_accumulate(const DualQuat *deform_dq,
if (dq_accum) {
BLI_assert(!co_accum);
add_weighted_dq_dq(dq_accum, deform_dq, weight);
if (deform_dq->scale_weight) {
/* FIX https://projects.blender.org/blender/blender/issues/32022 */
DualQuat mdq = *deform_dq;
float dst[3];
mul_v3_m4v3(dst, mdq.scale, co_in);
sub_v3_v3(dst, co_in);
mdq.trans[0] -= .5f * (mdq.quat[1] * dst[0] + mdq.quat[2] * dst[1] + mdq.quat[3] * dst[2]);
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;
add_weighted_dq_dq(dq_accum, &mdq, weight);
}
else {
add_weighted_dq_dq(dq_accum, deform_dq, weight);
}
}
else {
float tmp[3];

View File

@ -368,6 +368,10 @@ void clothModifier_do(ClothModifierData *clmd,
return;
}
/* Since implicit sharing is introduced, mesh data can be moved to other places.
* Therefore some fields in simulation data need to be updated accordingly */
clmd->clothObject->edges = reinterpret_cast<const vec2i *>(mesh->edges().data());
/* try to read from cache */
bool can_simulate = (framenr == clmd->clothObject->last_frame + 1) &&
!(cache->flag & PTCACHE_BAKED);

View File

@ -18,6 +18,8 @@
#include "BLT_translation.h"
#include <fmt/format.h>
namespace blender::bke {
MeshFieldContext::MeshFieldContext(const Mesh &mesh, const eAttrDomain domain)
@ -266,9 +268,7 @@ GVArray AttributeFieldInput::get_varray_for_context(const GeometryFieldContext &
std::string AttributeFieldInput::socket_inspection_name() const
{
std::stringstream ss;
ss << '"' << name_ << '"' << TIP_(" attribute from geometry");
return ss.str();
return fmt::format(TIP_("\"{}\" attribute from geometry"), name_);
}
uint64_t AttributeFieldInput::hash() const
@ -350,9 +350,7 @@ GVArray AnonymousAttributeFieldInput::get_varray_for_context(const GeometryField
std::string AnonymousAttributeFieldInput::socket_inspection_name() const
{
std::stringstream ss;
ss << '"' << debug_name_ << '"' << TIP_(" from ") << producer_name_;
return ss.str();
return fmt::format(TIP_("\"{}\" from {}"), TIP_(debug_name_.c_str()), producer_name_);
}
uint64_t AnonymousAttributeFieldInput::hash() const

View File

@ -1053,16 +1053,35 @@ void GreasePencil::remove_drawing(const int index_to_remove)
shrink_array<GreasePencilDrawingBase *>(&this->drawing_array, &this->drawing_array_num, 1);
}
void GreasePencil::foreach_visible_drawing(
int frame, blender::FunctionRef<void(GreasePencilDrawing &)> function)
enum ForeachDrawingMode {
VISIBLE,
EDITABLE,
};
static void foreach_drawing_ex(GreasePencil &grease_pencil,
int frame,
ForeachDrawingMode mode,
blender::FunctionRef<void(GreasePencilDrawing &)> function)
{
using namespace blender::bke::greasepencil;
blender::Span<GreasePencilDrawingBase *> drawings = this->drawings();
for (const Layer *layer : this->layers()) {
if (!layer->is_visible()) {
continue;
blender::Span<GreasePencilDrawingBase *> drawings = grease_pencil.drawings();
for (const Layer *layer : grease_pencil.layers()) {
switch (mode) {
case VISIBLE: {
if (!layer->is_visible()) {
continue;
}
break;
}
case EDITABLE: {
if (!layer->is_visible() || layer->is_locked()) {
continue;
}
break;
}
}
int index = layer->drawing_index_at(frame);
if (index == -1) {
continue;
@ -1078,6 +1097,18 @@ void GreasePencil::foreach_visible_drawing(
}
}
void GreasePencil::foreach_visible_drawing(
int frame, blender::FunctionRef<void(GreasePencilDrawing &)> function)
{
foreach_drawing_ex(*this, frame, VISIBLE, function);
}
void GreasePencil::foreach_editable_drawing(
int frame, blender::FunctionRef<void(GreasePencilDrawing &)> function)
{
foreach_drawing_ex(*this, frame, EDITABLE, function);
}
bool GreasePencil::bounds_min_max(float3 &min, float3 &max) const
{
bool found = false;

View File

@ -331,7 +331,7 @@ static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_MESH_DEPRECATED:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
@ -479,7 +479,7 @@ static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *so
case SOCK_CUSTOM:
/* Custom node sockets where default_value is defined uses custom properties for storage. */
break;
case __SOCK_MESH:
case SOCK_MESH_DEPRECATED:
case SOCK_SHADER:
case SOCK_GEOMETRY:
BLI_assert_unreachable();
@ -934,7 +934,7 @@ static void lib_link_node_socket(BlendLibReader *reader, ID *self_id, bNodeSocke
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_MESH_DEPRECATED:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
@ -1027,7 +1027,7 @@ static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock)
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_MESH_DEPRECATED:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
@ -1716,7 +1716,7 @@ static void socket_id_user_increment(bNodeSocket *sock)
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_MESH_DEPRECATED:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
@ -1762,7 +1762,7 @@ static bool socket_id_user_decrement(bNodeSocket *sock)
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_MESH_DEPRECATED:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
@ -1815,7 +1815,7 @@ void nodeModifySocketType(bNodeTree *ntree,
case SOCK_SHADER:
case SOCK_BOOLEAN:
case SOCK_CUSTOM:
case __SOCK_MESH:
case SOCK_MESH_DEPRECATED:
case SOCK_OBJECT:
case SOCK_IMAGE:
case SOCK_GEOMETRY:
@ -1954,7 +1954,8 @@ const char *nodeStaticSocketType(const int type, const int subtype)
return "NodeSocketTexture";
case SOCK_MATERIAL:
return "NodeSocketMaterial";
default:
case SOCK_CUSTOM:
case SOCK_MESH_DEPRECATED:
break;
}
return nullptr;
@ -2033,7 +2034,8 @@ const char *nodeStaticSocketInterfaceType(const int type, const int subtype)
return "NodeSocketInterfaceTexture";
case SOCK_MATERIAL:
return "NodeSocketInterfaceMaterial";
default:
case SOCK_CUSTOM:
case SOCK_MESH_DEPRECATED:
break;
}
return nullptr;
@ -2068,7 +2070,8 @@ const char *nodeStaticSocketLabel(const int type, const int /*subtype*/)
return "Texture";
case SOCK_MATERIAL:
return "Material";
default:
case SOCK_CUSTOM:
case SOCK_MESH_DEPRECATED:
break;
}
return nullptr;
@ -2590,7 +2593,7 @@ static void *socket_value_storage(bNodeSocket &socket)
case SOCK_STRING:
/* We don't want do this now! */
return nullptr;
case __SOCK_MESH:
case SOCK_MESH_DEPRECATED:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:

View File

@ -458,6 +458,29 @@ const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
return nullptr;
}
const char *BKE_paint_get_tool_enum_translation_context_from_paintmode(ePaintMode mode)
{
switch (mode) {
case PAINT_MODE_SCULPT:
case PAINT_MODE_GPENCIL:
case PAINT_MODE_TEXTURE_2D:
case PAINT_MODE_TEXTURE_3D:
return BLT_I18NCONTEXT_ID_BRUSH;
case PAINT_MODE_VERTEX:
case PAINT_MODE_WEIGHT:
case PAINT_MODE_SCULPT_UV:
case PAINT_MODE_VERTEX_GPENCIL:
case PAINT_MODE_SCULPT_GPENCIL:
case PAINT_MODE_WEIGHT_GPENCIL:
case PAINT_MODE_SCULPT_CURVES:
case PAINT_MODE_INVALID:
break;
}
/* Invalid paint mode. */
return BLT_I18NCONTEXT_DEFAULT;
}
Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
{
if (sce && view_layer) {

View File

@ -3489,12 +3489,14 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
}
}
hair_create_input_mesh(sim, totpoint, totedge, &psys->hair_in_mesh);
/* Free hair_out_mesh before modifying hair_in_mesh in hair_create_input_mesh() to avoid copying
* on write since they share some data */
if (psys->hair_out_mesh) {
BKE_id_free(NULL, psys->hair_out_mesh);
}
hair_create_input_mesh(sim, totpoint, totedge, &psys->hair_in_mesh);
psys->clmd->point_cache = psys->pointcache;
/* for hair sim we replace the internal cloth effector weights temporarily
* to use the particle settings

View File

@ -386,7 +386,7 @@ UndoStep *BKE_undosys_stack_init_or_active_with_type(UndoStack *ustack, const Un
void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size_t memory_limit)
{
UNDO_NESTED_ASSERT(false);
if ((steps == -1) && (memory_limit != 0)) {
if ((steps == -1) && (memory_limit == 0)) {
return;
}
@ -400,6 +400,12 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size
if (memory_limit) {
data_size_all += us->data_size;
if (data_size_all > memory_limit) {
CLOG_INFO(&LOG,
1,
"At step %zu: data_size_all=%zu >= memory_limit=%zu",
us_count,
data_size_all,
memory_limit);
break;
}
}
@ -413,6 +419,8 @@ void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size
}
}
CLOG_INFO(&LOG, 1, "Total steps %zu: data_size_all=%zu", us_count, data_size_all);
if (us) {
#ifdef WITH_GLOBAL_UNDO_KEEP_ONE
/* Hack, we need to keep at least one BKE_UNDOSYS_TYPE_MEMFILE. */

View File

@ -126,6 +126,18 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
/* 400 4 did not require any do_version here. */
if (!MAIN_VERSION_ATLEAST(bmain, 400, 5)) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
#define SCE_SNAP_PROJECT (1 << 3)
if (scene->toolsettings->snap_flag & SCE_SNAP_PROJECT) {
scene->toolsettings->snap_mode |= SCE_SNAP_MODE_FACE_RAYCAST;
}
#undef SCE_SNAP_PROJECT
}
}
/**
* Versioning code until next subversion bump goes here.
*

View File

@ -1111,7 +1111,6 @@ static void bm_vert_table_build(BMesh &bm,
BM_elem_index_set(vert, i); /* set_inline */
table[i] = vert;
hflag |= vert->head.hflag;
BM_CHECK_ELEMENT(vert);
}
need_select_vert = (hflag & BM_ELEM_SELECT) != 0;
need_hide_vert = (hflag & BM_ELEM_HIDDEN) != 0;
@ -1133,7 +1132,6 @@ static void bm_edge_table_build(BMesh &bm,
table[i] = edge;
hflag |= edge->head.hflag;
need_sharp_edge |= (edge->head.hflag & BM_ELEM_SMOOTH) == 0;
BM_CHECK_ELEMENT(edge);
}
need_select_edge = (hflag & BM_ELEM_SELECT) != 0;
need_hide_edge = (hflag & BM_ELEM_HIDDEN) != 0;
@ -1199,7 +1197,6 @@ static void bm_face_loop_table_build(BMesh &bm,
hflag |= face->head.hflag;
need_sharp_face |= (face->head.hflag & BM_ELEM_SMOOTH) == 0;
need_material_index |= face->mat_nr != 0;
BM_CHECK_ELEMENT(face);
BMLoop *loop = BM_FACE_FIRST_LOOP(face);
for ([[maybe_unused]] const int i : IndexRange(face->len)) {
@ -1220,7 +1217,6 @@ static void bm_face_loop_table_build(BMesh &bm,
need_pin[i] = true;
}
}
BM_CHECK_ELEMENT(loop);
loop = loop->next;
loop_i++;
}

View File

@ -74,7 +74,7 @@ void TrackPositionNode::convert_to_operations(NodeConverter &converter,
operationY->set_track_name(trackpos_data->track_name);
operationY->set_framenumber(frame_number);
operationY->set_axis(1);
operationX->set_position(static_cast<CMPNodeTrackPositionMode>(editor_node->custom1));
operationY->set_position(static_cast<CMPNodeTrackPositionMode>(editor_node->custom1));
operationY->set_relative_frame(editor_node->custom2);
converter.add_operation(operationY);
converter.map_output_socket(outputY, operationY->get_output_socket());

View File

@ -246,7 +246,7 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu
/* WORKAROUND: Needed because node_tree isn't present in test shaders. */
if (pipeline_type == MAT_PIPE_DEFERRED) {
info.define("MAT_RENDER_PASS_SUPPORT");
info.additional_info("eevee_render_pass_out");
}
if (GPU_material_flag_get(gpumat, GPU_MATFLAG_TRANSPARENT)) {

View File

@ -20,7 +20,7 @@ void main()
/* View position is passed to keep accuracy. */
g_data.N = normal_view_to_world(viewCameraVec(interp.P));
g_data.Ng = g_data.N;
g_data.P = -g_data.N + cameraPos;
g_data.P = -g_data.N;
attrib_load();
nodetree_surface();

View File

@ -107,7 +107,8 @@ GPU_SHADER_CREATE_INFO(eevee_surf_deferred)
.additional_info("eevee_camera",
"eevee_utility_texture",
"eevee_sampling_data",
"eevee_render_pass_out",
/* Added at runtime because of test shaders not having `node_tree`. */
// "eevee_render_pass_out",
"eevee_cryptomatte_out");
GPU_SHADER_CREATE_INFO(eevee_surf_forward)

View File

@ -326,8 +326,9 @@ static void grease_pencil_geom_batch_ensure(GreasePencil &grease_pencil, int cfr
"radius", ATTR_DOMAIN_POINT, 1.0f);
const VArray<float> opacities = *attributes.lookup_or_default<float>(
"opacity", ATTR_DOMAIN_POINT, 1.0f);
/* Assumes that if the ".selection" attribute does not exist, all points are selected. */
const VArray<float> selection_float = *attributes.lookup_or_default<float>(
".selection", ATTR_DOMAIN_POINT, false);
".selection", ATTR_DOMAIN_POINT, true);
const VArray<int8_t> start_caps = *attributes.lookup_or_default<int8_t>(
"start_cap", ATTR_DOMAIN_CURVE, 0);
const VArray<int8_t> end_caps = *attributes.lookup_or_default<int8_t>(

View File

@ -991,42 +991,44 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
static void flip_names(tAnimCopybufItem *aci, char **r_name)
{
if (aci->is_bone) {
int ofs_start;
int ofs_end;
if (BLI_str_quoted_substr_range(aci->rna_path, "pose.bones[", &ofs_start, &ofs_end)) {
char *str_start = aci->rna_path + ofs_start;
const char *str_end = aci->rna_path + ofs_end;
/* Swap out the name.
* Note that there is no need to un-escape the string to flip it. */
char bname_new[MAX_VGROUP_NAME];
char *str_iter;
int length, prefix_l, postfix_l;
prefix_l = str_start - aci->rna_path;
length = str_end - str_start;
postfix_l = strlen(str_end);
/* Temporary substitute with NULL terminator. */
BLI_assert(str_start[length] == '\"');
str_start[length] = 0;
BLI_string_flip_side_name(bname_new, str_start, false, sizeof(bname_new));
str_start[length] = '\"';
str_iter = *r_name = MEM_mallocN(sizeof(char) * (prefix_l + postfix_l + length + 1),
"flipped_path");
BLI_strncpy(str_iter, aci->rna_path, prefix_l + 1);
str_iter += prefix_l;
BLI_strncpy(str_iter, bname_new, length + 1);
str_iter += length;
BLI_strncpy(str_iter, str_end, postfix_l + 1);
str_iter[postfix_l] = '\0';
}
if (!aci->is_bone) {
return;
}
int ofs_start, ofs_end;
if (!BLI_str_quoted_substr_range(aci->rna_path, "pose.bones[", &ofs_start, &ofs_end)) {
return;
}
char *str_start = aci->rna_path + ofs_start;
const char *str_end = aci->rna_path + ofs_end;
/* Swap out the name.
* NOTE: there is no need to un-escape the string to flip it.
* However the buffer does need to be twice the size. */
char bname_new[MAX_VGROUP_NAME * 2];
char *str_iter;
int len_old, prefix_l, postfix_l;
prefix_l = str_start - aci->rna_path;
len_old = str_end - str_start;
postfix_l = strlen(str_end);
/* Temporary substitute with NULL terminator. */
BLI_assert(str_start[len_old] == '\"');
str_start[len_old] = 0;
const int len_new = BLI_string_flip_side_name(bname_new, str_start, false, sizeof(bname_new));
str_start[len_old] = '\"';
str_iter = *r_name = MEM_mallocN(sizeof(char) * (prefix_l + postfix_l + len_new + 1),
"flipped_path");
memcpy(str_iter, aci->rna_path, prefix_l);
str_iter += prefix_l;
memcpy(str_iter, bname_new, len_new);
str_iter += len_new;
memcpy(str_iter, str_end, postfix_l);
str_iter[postfix_l] = '\0';
}
/* ------------------- */

View File

@ -398,26 +398,30 @@ static void init_indexer_entry_from_value(FileIndexerEntry &indexer_entry,
if (entry.has_description()) {
const StringRefNull description = entry.get_description();
char *description_c_str = static_cast<char *>(MEM_mallocN(description.size() + 1, __func__));
BLI_strncpy(description_c_str, description.c_str(), description.size() + 1);
const size_t c_str_size = description.size() + 1;
char *description_c_str = static_cast<char *>(MEM_mallocN(c_str_size, __func__));
memcpy(description_c_str, description.c_str(), c_str_size);
asset_data->description = description_c_str;
}
if (entry.has_author()) {
const StringRefNull author = entry.get_author();
char *author_c_str = static_cast<char *>(MEM_mallocN(author.size() + 1, __func__));
BLI_strncpy(author_c_str, author.c_str(), author.size() + 1);
const size_t c_str_size = author.size() + 1;
char *author_c_str = static_cast<char *>(MEM_mallocN(c_str_size, __func__));
memcpy(author_c_str, author.c_str(), c_str_size);
asset_data->author = author_c_str;
}
if (entry.has_copyright()) {
const StringRefNull copyright = entry.get_copyright();
char *copyright_c_str = static_cast<char *>(MEM_mallocN(copyright.size() + 1, __func__));
BLI_strncpy(copyright_c_str, copyright.c_str(), copyright.size() + 1);
const size_t c_str_size = copyright.size() + 1;
char *copyright_c_str = static_cast<char *>(MEM_mallocN(c_str_size, __func__));
memcpy(copyright_c_str, copyright.c_str(), c_str_size);
asset_data->copyright = copyright_c_str;
}
if (entry.has_license()) {
const StringRefNull license = entry.get_license();
char *license_c_str = static_cast<char *>(MEM_mallocN(license.size() + 1, __func__));
BLI_strncpy(license_c_str, license.c_str(), license.size() + 1);
const size_t c_str_size = license.size() + 1;
char *license_c_str = static_cast<char *>(MEM_mallocN(c_str_size, __func__));
memcpy(license_c_str, license.c_str(), c_str_size);
asset_data->license = license_c_str;
}

View File

@ -5610,7 +5610,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Curve *cu;
float location[3];
const bool use_proj = ((vc.scene->toolsettings->snap_flag & SCE_SNAP) &&
(vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE_RAYCAST));
(vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE));
Nurb *nu;
BezTriple *bezt;
@ -5642,7 +5642,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
vc.depsgraph,
vc.region,
vc.v3d,
SCE_SNAP_MODE_FACE_RAYCAST,
SCE_SNAP_MODE_FACE,
&(const struct SnapObjectParams){
.snap_target_select = (vc.obedit != NULL) ? SCE_SNAP_TARGET_NOT_ACTIVE :
SCE_SNAP_TARGET_ALL,

View File

@ -439,11 +439,11 @@ void apply_selection_operation_at_index(GMutableSpan selection,
}
static std::optional<FindClosestData> find_closest_point_to_screen_co(
const Depsgraph &depsgraph,
const ARegion *region,
const RegionView3D *rv3d,
const Object &object,
const bke::CurvesGeometry &curves,
Span<float3> deformed_positions,
float2 mouse_pos,
float radius,
const FindClosestData &initial_closest)
@ -451,9 +451,6 @@ static std::optional<FindClosestData> find_closest_point_to_screen_co(
float4x4 projection;
ED_view3d_ob_project_mat_get(rv3d, &object, projection.ptr());
const bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_curves_deformation(depsgraph, object);
const float radius_sq = pow2f(radius);
const FindClosestData new_closest_data = threading::parallel_reduce(
curves.points_range(),
@ -462,7 +459,7 @@ static std::optional<FindClosestData> find_closest_point_to_screen_co(
[&](const IndexRange point_range, const FindClosestData &init) {
FindClosestData best_match = init;
for (const int point_i : point_range) {
const float3 pos = deformation.positions[point_i];
const float3 pos = deformed_positions[point_i];
/* Find the position of the point in screen space. */
float2 pos_proj;
@ -498,11 +495,11 @@ static std::optional<FindClosestData> find_closest_point_to_screen_co(
}
static std::optional<FindClosestData> find_closest_curve_to_screen_co(
const Depsgraph &depsgraph,
const ARegion *region,
const RegionView3D *rv3d,
const Object &object,
const bke::CurvesGeometry &curves,
Span<float3> deformed_positions,
float2 mouse_pos,
float radius,
const FindClosestData &initial_closest)
@ -510,9 +507,6 @@ static std::optional<FindClosestData> find_closest_curve_to_screen_co(
float4x4 projection;
ED_view3d_ob_project_mat_get(rv3d, &object, projection.ptr());
const bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_curves_deformation(depsgraph, object);
const float radius_sq = pow2f(radius);
const OffsetIndices points_by_curve = curves.points_by_curve();
@ -525,7 +519,7 @@ static std::optional<FindClosestData> find_closest_curve_to_screen_co(
for (const int curve_i : curves_range) {
const IndexRange points = points_by_curve[curve_i];
if (points.size() == 1) {
const float3 pos = deformation.positions[points.first()];
const float3 pos = deformed_positions[points.first()];
/* Find the position of the point in screen space. */
float2 pos_proj;
@ -548,8 +542,8 @@ static std::optional<FindClosestData> find_closest_curve_to_screen_co(
}
for (const int segment_i : points.drop_back(1)) {
const float3 pos1 = deformation.positions[segment_i];
const float3 pos2 = deformation.positions[segment_i + 1];
const float3 pos1 = deformed_positions[segment_i];
const float3 pos2 = deformed_positions[segment_i + 1];
float2 pos1_proj, pos2_proj;
ED_view3d_project_float_v2_m4(region, pos1, pos1_proj, projection.ptr());
@ -591,26 +585,27 @@ std::optional<FindClosestData> closest_elem_find_screen_space(
const ViewContext &vc,
const Object &object,
bke::CurvesGeometry &curves,
const Span<float3> deformed_positions,
const eAttrDomain domain,
const int2 coord,
const FindClosestData &initial_closest)
{
switch (domain) {
case ATTR_DOMAIN_POINT:
return find_closest_point_to_screen_co(*vc.depsgraph,
vc.region,
return find_closest_point_to_screen_co(vc.region,
vc.rv3d,
object,
curves,
deformed_positions,
float2(coord),
ED_view3d_select_dist_px(),
initial_closest);
case ATTR_DOMAIN_CURVE:
return find_closest_curve_to_screen_co(*vc.depsgraph,
vc.region,
return find_closest_curve_to_screen_co(vc.region,
vc.rv3d,
object,
curves,
deformed_positions,
float2(coord),
ED_view3d_select_dist_px(),
initial_closest);
@ -622,6 +617,7 @@ std::optional<FindClosestData> closest_elem_find_screen_space(
bool select_box(const ViewContext &vc,
bke::CurvesGeometry &curves,
const Span<float3> deformed_positions,
const eAttrDomain selection_domain,
const rcti &rect,
const eSelectOp sel_op)
@ -638,15 +634,13 @@ bool select_box(const ViewContext &vc,
float4x4 projection;
ED_view3d_ob_project_mat_get(vc.rv3d, vc.obact, projection.ptr());
const bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_curves_deformation(*vc.depsgraph, *vc.obact);
const OffsetIndices points_by_curve = curves.points_by_curve();
if (selection_domain == ATTR_DOMAIN_POINT) {
threading::parallel_for(curves.points_range(), 1024, [&](const IndexRange point_range) {
for (const int point_i : point_range) {
float2 pos_proj;
ED_view3d_project_float_v2_m4(
vc.region, deformation.positions[point_i], pos_proj, projection.ptr());
vc.region, deformed_positions[point_i], pos_proj, projection.ptr());
if (BLI_rcti_isect_pt_v(&rect, int2(pos_proj))) {
apply_selection_operation_at_index(selection.span, point_i, sel_op);
changed = true;
@ -661,7 +655,7 @@ bool select_box(const ViewContext &vc,
if (points.size() == 1) {
float2 pos_proj;
ED_view3d_project_float_v2_m4(
vc.region, deformation.positions[points.first()], pos_proj, projection.ptr());
vc.region, deformed_positions[points.first()], pos_proj, projection.ptr());
if (BLI_rcti_isect_pt_v(&rect, int2(pos_proj))) {
apply_selection_operation_at_index(selection.span, curve_i, sel_op);
changed = true;
@ -669,8 +663,8 @@ bool select_box(const ViewContext &vc,
continue;
}
for (const int segment_i : points.drop_back(1)) {
const float3 pos1 = deformation.positions[segment_i];
const float3 pos2 = deformation.positions[segment_i + 1];
const float3 pos1 = deformed_positions[segment_i];
const float3 pos2 = deformed_positions[segment_i + 1];
float2 pos1_proj, pos2_proj;
ED_view3d_project_float_v2_m4(vc.region, pos1, pos1_proj, projection.ptr());
@ -692,6 +686,7 @@ bool select_box(const ViewContext &vc,
bool select_lasso(const ViewContext &vc,
bke::CurvesGeometry &curves,
const Span<float3> deformed_positions,
const eAttrDomain selection_domain,
const Span<int2> coords,
const eSelectOp sel_op)
@ -712,15 +707,13 @@ bool select_lasso(const ViewContext &vc,
float4x4 projection;
ED_view3d_ob_project_mat_get(vc.rv3d, vc.obact, projection.ptr());
const bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_curves_deformation(*vc.depsgraph, *vc.obact);
const OffsetIndices points_by_curve = curves.points_by_curve();
if (selection_domain == ATTR_DOMAIN_POINT) {
threading::parallel_for(curves.points_range(), 1024, [&](const IndexRange point_range) {
for (const int point_i : point_range) {
float2 pos_proj;
ED_view3d_project_float_v2_m4(
vc.region, deformation.positions[point_i], pos_proj, projection.ptr());
vc.region, deformed_positions[point_i], pos_proj, projection.ptr());
/* Check the lasso bounding box first as an optimization. */
if (BLI_rcti_isect_pt_v(&bbox, int2(pos_proj)) &&
BLI_lasso_is_point_inside(
@ -739,7 +732,7 @@ bool select_lasso(const ViewContext &vc,
if (points.size() == 1) {
float2 pos_proj;
ED_view3d_project_float_v2_m4(
vc.region, deformation.positions[points.first()], pos_proj, projection.ptr());
vc.region, deformed_positions[points.first()], pos_proj, projection.ptr());
/* Check the lasso bounding box first as an optimization. */
if (BLI_rcti_isect_pt_v(&bbox, int2(pos_proj)) &&
BLI_lasso_is_point_inside(
@ -751,8 +744,8 @@ bool select_lasso(const ViewContext &vc,
continue;
}
for (const int segment_i : points.drop_back(1)) {
const float3 pos1 = deformation.positions[segment_i];
const float3 pos2 = deformation.positions[segment_i + 1];
const float3 pos1 = deformed_positions[segment_i];
const float3 pos2 = deformed_positions[segment_i + 1];
float2 pos1_proj, pos2_proj;
ED_view3d_project_float_v2_m4(vc.region, pos1, pos1_proj, projection.ptr());
@ -783,6 +776,7 @@ bool select_lasso(const ViewContext &vc,
bool select_circle(const ViewContext &vc,
bke::CurvesGeometry &curves,
const Span<float3> deformed_positions,
const eAttrDomain selection_domain,
const int2 coord,
const float radius,
@ -801,15 +795,13 @@ bool select_circle(const ViewContext &vc,
float4x4 projection;
ED_view3d_ob_project_mat_get(vc.rv3d, vc.obact, projection.ptr());
const bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_curves_deformation(*vc.depsgraph, *vc.obact);
const OffsetIndices points_by_curve = curves.points_by_curve();
if (selection_domain == ATTR_DOMAIN_POINT) {
threading::parallel_for(curves.points_range(), 1024, [&](const IndexRange point_range) {
for (const int point_i : point_range) {
float2 pos_proj;
ED_view3d_project_float_v2_m4(
vc.region, deformation.positions[point_i], pos_proj, projection.ptr());
vc.region, deformed_positions[point_i], pos_proj, projection.ptr());
if (math::distance_squared(pos_proj, float2(coord)) <= radius_sq) {
apply_selection_operation_at_index(selection.span, point_i, sel_op);
changed = true;
@ -824,7 +816,7 @@ bool select_circle(const ViewContext &vc,
if (points.size() == 1) {
float2 pos_proj;
ED_view3d_project_float_v2_m4(
vc.region, deformation.positions[points.first()], pos_proj, projection.ptr());
vc.region, deformed_positions[points.first()], pos_proj, projection.ptr());
if (math::distance_squared(pos_proj, float2(coord)) <= radius_sq) {
apply_selection_operation_at_index(selection.span, curve_i, sel_op);
changed = true;
@ -832,8 +824,8 @@ bool select_circle(const ViewContext &vc,
continue;
}
for (const int segment_i : points.drop_back(1)) {
const float3 pos1 = deformation.positions[segment_i];
const float3 pos2 = deformation.positions[segment_i + 1];
const float3 pos1 = deformed_positions[segment_i];
const float3 pos2 = deformed_positions[segment_i + 1];
float2 pos1_proj, pos2_proj;
ED_view3d_project_float_v2_m4(vc.region, pos1, pos1_proj, projection.ptr());

View File

@ -280,7 +280,7 @@ static int gizmo_move_modal(bContext *C,
CTX_data_ensure_evaluated_depsgraph(C),
region,
CTX_wm_view3d(C),
(SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE_RAYCAST),
(SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE),
&(const struct SnapObjectParams){
.snap_target_select = SCE_SNAP_TARGET_ALL,
.edit_mode_type = SNAP_GEOM_EDIT,

View File

@ -512,7 +512,7 @@ static void ed_keymap_gpencil_weightpainting_smear(wmKeyConfig *keyconf)
/* ==================== */
void ED_keymap_gpencil(wmKeyConfig *keyconf)
void ED_keymap_gpencil_legacy(wmKeyConfig *keyconf)
{
ed_keymap_gpencil_general(keyconf);
ed_keymap_gpencil_curve_editing(keyconf);
@ -547,7 +547,7 @@ void ED_keymap_gpencil(wmKeyConfig *keyconf)
/* ****************************************** */
void ED_operatortypes_gpencil(void)
void ED_operatortypes_gpencil_legacy(void)
{
/* Annotations -------------------- */

View File

@ -21,6 +21,7 @@ set(INC_SYS
set(SRC
intern/grease_pencil_add.cc
intern/grease_pencil_ops.cc
)
set(LIB

View File

@ -0,0 +1,96 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2023 Blender Foundation. */
/** \file
* \ingroup edgreasepencil
*/
#include "BLI_vector_set.hh"
#include "BKE_context.h"
#include "BKE_grease_pencil.hh"
#include "DNA_object_types.h"
#include "DEG_depsgraph.h"
#include "ED_curves.h"
#include "ED_grease_pencil.h"
#include "ED_screen.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "WM_api.h"
namespace blender::ed::greasepencil {
bool editable_grease_pencil_poll(bContext *C)
{
Object *object = CTX_data_active_object(C);
if (object == nullptr || object->type != OB_GREASE_PENCIL) {
return false;
}
if (!ED_operator_object_active_editable_ex(C, object)) {
return false;
}
if ((object->mode & OB_MODE_EDIT) == 0) {
return false;
}
return true;
}
static int select_all_exec(bContext *C, wmOperator *op)
{
int action = RNA_enum_get(op->ptr, "action");
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, [action](GreasePencilDrawing &drawing) {
// TODO: Support different selection domains.
blender::ed::curves::select_all(drawing.geometry.wrap(), ATTR_DOMAIN_POINT, action);
});
/* 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_all(wmOperatorType *ot)
{
ot->name = "(De)select All Strokes";
ot->idname = "GREASE_PENCIL_OT_select_all";
ot->description = "(De)select all visible strokes";
ot->exec = select_all_exec;
ot->poll = editable_grease_pencil_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
static void keymap_grease_pencil_editing(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Grease Pencil Edit Mode", 0, 0);
keymap->poll = editable_grease_pencil_poll;
}
} // namespace blender::ed::greasepencil
void ED_operatortypes_grease_pencil(void)
{
using namespace blender::ed::greasepencil;
WM_operatortype_append(GREASE_PENCIL_OT_select_all);
}
void ED_keymap_grease_pencil(wmKeyConfig *keyconf)
{
using namespace blender::ed::greasepencil;
keymap_grease_pencil_editing(keyconf);
}

View File

@ -54,12 +54,13 @@ int *ED_curves_offsets_for_write(struct Curves *curves_id);
#ifdef __cplusplus
# include "BKE_attribute.hh"
# include "BKE_crazyspace.hh"
# include "BKE_curves.hh"
# include "BLI_index_mask.hh"
# include "BLI_vector.hh"
# include "BLI_vector_set.hh"
# include "BKE_curves.hh"
# include "ED_select_utils.h"
namespace blender::ed::curves {
@ -192,6 +193,7 @@ struct FindClosestData {
std::optional<FindClosestData> closest_elem_find_screen_space(const ViewContext &vc,
const Object &object,
bke::CurvesGeometry &curves,
Span<float3> deformed_positions,
eAttrDomain domain,
int2 coord,
const FindClosestData &initial);
@ -201,6 +203,7 @@ std::optional<FindClosestData> closest_elem_find_screen_space(const ViewContext
*/
bool select_box(const ViewContext &vc,
bke::CurvesGeometry &curves,
Span<float3> deformed_positions,
eAttrDomain selection_domain,
const rcti &rect,
eSelectOp sel_op);
@ -210,6 +213,7 @@ bool select_box(const ViewContext &vc,
*/
bool select_lasso(const ViewContext &vc,
bke::CurvesGeometry &curves,
Span<float3> deformed_positions,
eAttrDomain selection_domain,
Span<int2> coords,
eSelectOp sel_op);
@ -219,6 +223,7 @@ bool select_lasso(const ViewContext &vc,
*/
bool select_circle(const ViewContext &vc,
bke::CurvesGeometry &curves,
Span<float3> deformed_positions,
eAttrDomain selection_domain,
int2 coord,
float radius,

View File

@ -196,9 +196,9 @@ bool ED_gpencil_stroke_material_visible(struct Object *ob, const struct bGPDstro
/* ----------- Grease Pencil Operators ----------------- */
void ED_keymap_gpencil(struct wmKeyConfig *keyconf);
void ED_keymap_gpencil_legacy(struct wmKeyConfig *keyconf);
void ED_operatortypes_gpencil(void);
void ED_operatortypes_gpencil_legacy(void);
void ED_operatormacros_gpencil(void);
/* ------------- Copy-Paste Buffers -------------------- */

View File

@ -7,13 +7,24 @@
#pragma once
struct bContext;
struct Main;
struct Object;
struct wmKeyConfig;
#ifdef __cplusplus
extern "C" {
#endif
/* -------------------------------------------------------------------- */
/** \name C Wrappers
* \{ */
void ED_operatortypes_grease_pencil(void);
void ED_keymap_grease_pencil(struct wmKeyConfig *keyconf);
#ifdef __cplusplus
}
#endif
@ -22,6 +33,8 @@ extern "C" {
namespace blender::ed::greasepencil {
bool editable_grease_pencil_poll(bContext *C);
void create_blank(Main &bmain, Object &object, int frame_number);
void create_stroke(Main &bmain, Object &object, float4x4 matrix, int frame_number);
void create_suzanne(Main &bmain, Object &object, float4x4 matrix, const int frame_number);

View File

@ -34,13 +34,13 @@ struct uiViewHandle;
struct uiViewItemHandle;
struct wmDrag;
void UI_but_func_pushed_state_set(uiBut *but, std::function<bool(const uiBut &)> func);
namespace blender::ui {
class AbstractGridView;
class AbstractTreeView;
void UI_but_func_pushed_state_set(uiBut *but, std::function<bool(const uiBut &)> func);
/**
* An item in a breadcrumb-like context. Currently this struct is very simple, but more
* could be added to it in the future, to support interactivity or tooltips, for example.

View File

@ -52,6 +52,7 @@
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_interface.hh"
#include "UI_interface_icons.h"
#include "UI_view2d.h"
@ -2551,7 +2552,7 @@ double ui_but_value_get(uiBut *but)
if (but->rnaprop) {
PropertyRNA *prop = but->rnaprop;
BLI_assert(RNA_property_array_check(prop) ? but->rnaindex != -1 : true);
BLI_assert(but->rnaindex != -1);
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
@ -4721,7 +4722,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
but->rnaindex = index;
}
else {
but->rnaindex = -1;
but->rnaindex = 0;
}
if (icon) {

View File

@ -277,7 +277,13 @@ static void ui_selectcontext_apply(bContext *C,
const double value,
const double value_orig);
# define IS_ALLSELECT_EVENT(event) (((event)->modifier & KM_ALT) != 0)
/**
* Only respond to events which are expected to be used for multi button editing,
* e.g. ALT is also used for button array pasting, see #108096.
*/
# define IS_ALLSELECT_EVENT(event) \
(((event)->modifier & KM_ALT) != 0 && \
(ISMOUSE((event)->type) || ELEM((event)->type, EVT_RETKEY, EVT_PADENTER)))
/** just show a tinted color so users know its activated */
# define UI_BUT_IS_SELECT_CONTEXT UI_BUT_NODE_ACTIVE
@ -3330,7 +3336,9 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
char *buf = static_cast<char *>(
MEM_mallocN(sizeof(char) * (sellen + 1), "ui_textedit_copypaste"));
BLI_strncpy(buf, data->str + but->selsta, sellen + 1);
memcpy(buf, data->str + but->selsta, sellen);
buf[sellen] = '\0';
WM_clipboard_text_set(buf, false);
MEM_freeN(buf);
@ -8857,7 +8865,7 @@ uiBut *UI_region_active_but_prop_get(const ARegion *region,
else {
memset(r_ptr, 0, sizeof(*r_ptr));
*r_prop = nullptr;
*r_index = -1;
*r_index = 0;
}
return activebut;

View File

@ -240,8 +240,7 @@ struct uiBut {
/* RNA data */
PointerRNA rnapoin = {};
PropertyRNA *rnaprop = nullptr;
/** The index (arrays only), otherwise set to -1. */
int rnaindex = -1;
int rnaindex = 0;
/* Operator data */
wmOperatorType *optype = nullptr;

View File

@ -3172,7 +3172,8 @@ void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop,
/* Decorators have own RNA data, using the normal #uiBut RNA members has many side-effects. */
but->decorated_rnapoin = *ptr;
but->decorated_rnaprop = prop;
but->decorated_rnaindex = (!is_array) ? -1 : (is_expand) ? i : index;
/* ui_def_but_rna() sets non-array buttons to have a RNA index of 0. */
but->decorated_rnaindex = (!is_array || is_expand) ? i : index;
}
}

View File

@ -1739,43 +1739,21 @@ void UI_editsource_but_replace(const uiBut *old_but, uiBut *new_but)
}
static int editsource_text_edit(bContext *C,
wmOperator *op,
wmOperator * /*op*/,
const char filepath[FILE_MAX],
const int line)
{
Main *bmain = CTX_data_main(C);
Text *text = nullptr;
wmOperatorType *ot = WM_operatortype_find("TEXT_OT_jump_to_file_at_point", true);
PointerRNA op_props;
/* Developers may wish to copy-paste to an external editor. */
printf("%s:%d\n", filepath, line);
WM_operator_properties_create_ptr(&op_props, ot);
RNA_string_set(&op_props, "filepath", filepath);
RNA_int_set(&op_props, "line", line - 1);
RNA_int_set(&op_props, "column", 0);
LISTBASE_FOREACH (Text *, text_iter, &bmain->texts) {
if (text_iter->filepath && BLI_path_cmp(text_iter->filepath, filepath) == 0) {
text = text_iter;
break;
}
}
if (text == nullptr) {
text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain));
}
if (text == nullptr) {
BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath);
return OPERATOR_CANCELLED;
}
txt_move_toline(text, line - 1, false);
/* naughty!, find text area to set, not good behavior
* but since this is a developer tool lets allow it - campbell */
if (!ED_text_activate_in_screen(C, text)) {
BKE_reportf(op->reports, RPT_INFO, "See '%s' in the text editor", text->id.name + 2);
}
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
return OPERATOR_FINISHED;
int result = WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &op_props, NULL);
WM_operator_properties_free(&op_props);
return result;
}
static int editsource_exec(bContext *C, wmOperator *op)

View File

@ -124,21 +124,7 @@ bool ui_but_is_popover_once_compat(const uiBut *but)
bool ui_but_has_array_value(const uiBut *but)
{
return (but->rnapoin.data && but->rnaprop &&
ELEM(RNA_property_subtype(but->rnaprop),
PROP_COLOR,
PROP_TRANSLATION,
PROP_DIRECTION,
PROP_VELOCITY,
PROP_ACCELERATION,
PROP_MATRIX,
PROP_EULER,
PROP_QUATERNION,
PROP_AXISANGLE,
PROP_XYZ,
PROP_XYZ_LENGTH,
PROP_COLOR_GAMMA,
PROP_COORDS));
return (but->rnapoin.data && but->rnaprop && RNA_property_array_check(but->rnaprop));
}
static wmOperatorType *g_ot_tool_set_by_id = nullptr;

View File

@ -6739,7 +6739,7 @@ void uiTemplateComponentMenu(uiLayout *layout,
/* set rna directly, uiDefBlockButN doesn't do this */
but->rnapoin = *ptr;
but->rnaprop = RNA_struct_find_property(ptr, propname);
but->rnaindex = -1;
but->rnaindex = 0;
UI_block_align_end(block);
}

View File

@ -28,27 +28,27 @@ set(INC_SYS
)
set(SRC
io_alembic.c
io_cache.c
io_collada.c
io_gpencil_export.c
io_gpencil_import.c
io_gpencil_utils.c
io_obj.c
io_ops.c
io_ply_ops.c
io_stl_ops.c
io_usd.c
io_alembic.cc
io_cache.cc
io_collada.cc
io_gpencil_export.cc
io_gpencil_import.cc
io_gpencil_utils.cc
io_obj.cc
io_ops.cc
io_ply_ops.cc
io_stl_ops.cc
io_usd.cc
io_alembic.h
io_cache.h
io_collada.h
io_gpencil.h
io_obj.h
io_alembic.hh
io_cache.hh
io_collada.hh
io_gpencil.hh
io_obj.hh
io_ops.h
io_ply_ops.h
io_stl_ops.h
io_usd.h
io_ply_ops.hh
io_stl_ops.hh
io_usd.hh
)
set(LIB

View File

@ -15,8 +15,8 @@
# include "BLI_winstuff.h"
# endif
# include <errno.h>
# include <string.h>
# include <cerrno>
# include <cstring>
# include "MEM_guardedalloc.h"
@ -51,7 +51,7 @@
# include "DEG_depsgraph.h"
# include "io_alembic.h"
# include "io_alembic.hh"
# include "ABC_alembic.h"
@ -66,10 +66,10 @@ const EnumPropertyItem rna_enum_abc_export_evaluation_mode_items[] = {
0,
"Viewport",
"Use Viewport settings for object visibility, modifier settings, etc"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (!RNA_struct_property_is_set(op->ptr, "as_background_job")) {
RNA_boolean_set(op->ptr, "as_background_job", true);
@ -82,8 +82,6 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
UNUSED_VARS(event);
}
static int wm_alembic_export_exec(bContext *C, wmOperator *op)
@ -96,39 +94,38 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op)
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
struct AlembicExportParams params = {
.frame_start = RNA_int_get(op->ptr, "start"),
.frame_end = RNA_int_get(op->ptr, "end"),
AlembicExportParams params{};
params.frame_start = RNA_int_get(op->ptr, "start");
params.frame_end = RNA_int_get(op->ptr, "end");
.frame_samples_xform = RNA_int_get(op->ptr, "xsamples"),
.frame_samples_shape = RNA_int_get(op->ptr, "gsamples"),
params.frame_samples_xform = RNA_int_get(op->ptr, "xsamples");
params.frame_samples_shape = RNA_int_get(op->ptr, "gsamples");
.shutter_open = RNA_float_get(op->ptr, "sh_open"),
.shutter_close = RNA_float_get(op->ptr, "sh_close"),
params.shutter_open = RNA_float_get(op->ptr, "sh_open");
params.shutter_close = RNA_float_get(op->ptr, "sh_close");
.selected_only = RNA_boolean_get(op->ptr, "selected"),
.uvs = RNA_boolean_get(op->ptr, "uvs"),
.normals = RNA_boolean_get(op->ptr, "normals"),
.vcolors = RNA_boolean_get(op->ptr, "vcolors"),
.orcos = RNA_boolean_get(op->ptr, "orcos"),
.apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv"),
.curves_as_mesh = RNA_boolean_get(op->ptr, "curves_as_mesh"),
.flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten"),
.visible_objects_only = RNA_boolean_get(op->ptr, "visible_objects_only"),
.face_sets = RNA_boolean_get(op->ptr, "face_sets"),
.use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"),
.export_hair = RNA_boolean_get(op->ptr, "export_hair"),
.export_particles = RNA_boolean_get(op->ptr, "export_particles"),
.export_custom_properties = RNA_boolean_get(op->ptr, "export_custom_properties"),
.use_instancing = RNA_boolean_get(op->ptr, "use_instancing"),
.packuv = RNA_boolean_get(op->ptr, "packuv"),
.triangulate = RNA_boolean_get(op->ptr, "triangulate"),
.quad_method = RNA_enum_get(op->ptr, "quad_method"),
.ngon_method = RNA_enum_get(op->ptr, "ngon_method"),
.evaluation_mode = RNA_enum_get(op->ptr, "evaluation_mode"),
params.selected_only = RNA_boolean_get(op->ptr, "selected");
params.uvs = RNA_boolean_get(op->ptr, "uvs");
params.normals = RNA_boolean_get(op->ptr, "normals");
params.vcolors = RNA_boolean_get(op->ptr, "vcolors");
params.orcos = RNA_boolean_get(op->ptr, "orcos");
params.apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv");
params.curves_as_mesh = RNA_boolean_get(op->ptr, "curves_as_mesh");
params.flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten");
params.visible_objects_only = RNA_boolean_get(op->ptr, "visible_objects_only");
params.face_sets = RNA_boolean_get(op->ptr, "face_sets");
params.use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema");
params.export_hair = RNA_boolean_get(op->ptr, "export_hair");
params.export_particles = RNA_boolean_get(op->ptr, "export_particles");
params.export_custom_properties = RNA_boolean_get(op->ptr, "export_custom_properties");
params.use_instancing = RNA_boolean_get(op->ptr, "use_instancing");
params.packuv = RNA_boolean_get(op->ptr, "packuv");
params.triangulate = RNA_boolean_get(op->ptr, "triangulate");
params.quad_method = RNA_enum_get(op->ptr, "quad_method");
params.ngon_method = RNA_enum_get(op->ptr, "ngon_method");
params.evaluation_mode = eEvaluationMode(RNA_enum_get(op->ptr, "evaluation_mode"));
.global_scale = RNA_float_get(op->ptr, "global_scale"),
};
params.global_scale = RNA_float_get(op->ptr, "global_scale");
/* Take some defaults from the scene, if not specified explicitly. */
Scene *scene = CTX_data_scene(C);
@ -155,7 +152,7 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Manual Transform"), ICON_NONE);
uiItemR(box, imfptr, "global_scale", 0, NULL, ICON_NONE);
uiItemR(box, imfptr, "global_scale", 0, nullptr, ICON_NONE);
/* Scene Options */
box = uiLayoutBox(layout);
@ -172,12 +169,12 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(col, imfptr, "gsamples", 0, IFACE_("Geometry"), ICON_NONE);
sub = uiLayoutColumn(col, true);
uiItemR(sub, imfptr, "sh_open", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
uiItemR(sub, imfptr, "sh_open", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "sh_close", UI_ITEM_R_SLIDER, IFACE_("Close"), ICON_NONE);
uiItemS(col);
uiItemR(col, imfptr, "flatten", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "flatten", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "use_instancing", 0, IFACE_("Use Instancing"), ICON_NONE);
uiItemR(sub, imfptr, "export_custom_properties", 0, IFACE_("Custom Properties"), ICON_NONE);
@ -186,7 +183,7 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(sub, imfptr, "visible_objects_only", 0, IFACE_("Visible Objects"), ICON_NONE);
col = uiLayoutColumn(box, true);
uiItemR(col, imfptr, "evaluation_mode", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "evaluation_mode", 0, nullptr, ICON_NONE);
/* Object Data */
box = uiLayoutBox(layout);
@ -195,16 +192,16 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "uvs", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "uvs", 0, nullptr, ICON_NONE);
row = uiLayoutRow(col, false);
uiLayoutSetActive(row, RNA_boolean_get(imfptr, "uvs"));
uiItemR(row, imfptr, "packuv", 0, NULL, ICON_NONE);
uiItemR(row, imfptr, "packuv", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "normals", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "vcolors", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "orcos", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "face_sets", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "curves_as_mesh", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "normals", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "vcolors", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "orcos", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "face_sets", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "curves_as_mesh", 0, nullptr, ICON_NONE);
uiItemS(col);
@ -215,7 +212,7 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemS(col);
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "triangulate", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "triangulate", 0, nullptr, ICON_NONE);
sub = uiLayoutColumn(col, false);
uiLayoutSetActive(sub, RNA_boolean_get(imfptr, "triangulate"));
uiItemR(sub, imfptr, "quad_method", 0, IFACE_("Method Quads"), ICON_NONE);
@ -227,8 +224,8 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemL(row, IFACE_("Particle Systems"), ICON_PARTICLE_DATA);
col = uiLayoutColumn(box, true);
uiItemR(col, imfptr, "export_hair", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "export_particles", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "export_hair", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "export_particles", 0, nullptr, ICON_NONE);
}
static void wm_alembic_export_draw(bContext *C, wmOperator *op)
@ -236,7 +233,7 @@ static void wm_alembic_export_draw(bContext *C, wmOperator *op)
/* Conveniently set start and end frame to match the scene's frame range. */
Scene *scene = CTX_data_scene(C);
if (scene != NULL && RNA_boolean_get(op->ptr, "init_scene_frame_range")) {
if (scene != nullptr && RNA_boolean_get(op->ptr, "init_scene_frame_range")) {
RNA_int_set(op->ptr, "start", scene->r.sfra);
RNA_int_set(op->ptr, "end", scene->r.efra);
@ -246,7 +243,7 @@ static void wm_alembic_export_draw(bContext *C, wmOperator *op)
ui_alembic_export_settings(op->layout, op->ptr);
}
static bool wm_alembic_export_check(bContext *UNUSED(C), wmOperator *op)
static bool wm_alembic_export_check(bContext * /*C*/, wmOperator *op)
{
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
@ -475,15 +472,15 @@ void WM_OT_alembic_export(wmOperatorType *ot)
/* TODO(kevin): check on de-duplicating all this with code in image_ops.c */
typedef struct CacheFrame {
struct CacheFrame {
struct CacheFrame *next, *prev;
int framenr;
} CacheFrame;
};
static int cmp_frame(const void *a, const void *b)
{
const CacheFrame *frame_a = a;
const CacheFrame *frame_b = b;
const CacheFrame *frame_a = static_cast<const CacheFrame *>(a);
const CacheFrame *frame_b = static_cast<const CacheFrame *>(b);
if (frame_a->framenr < frame_b->framenr) {
return -1;
@ -515,7 +512,7 @@ static int get_sequence_len(const char *filepath, int *ofs)
}
DIR *dir = opendir(dirpath);
if (dir == NULL) {
if (dir == nullptr) {
fprintf(stderr,
"Error opening directory '%s': %s\n",
dirpath,
@ -527,11 +524,11 @@ static int get_sequence_len(const char *filepath, int *ofs)
const char *basename = BLI_path_basename(filepath);
const int len = strlen(basename) - (numdigit + strlen(ext));
ListBase frames;
ListBase frames{};
BLI_listbase_clear(&frames);
struct dirent *fname;
while ((fname = readdir(dir)) != NULL) {
dirent *fname;
while ((fname = readdir(dir)) != nullptr) {
/* do we have the right extension? */
if (!strstr(fname->d_name, ext)) {
continue;
@ -541,7 +538,7 @@ static int get_sequence_len(const char *filepath, int *ofs)
continue;
}
CacheFrame *cache_frame = MEM_callocN(sizeof(CacheFrame), "abc_frame");
CacheFrame *cache_frame = MEM_cnew<CacheFrame>("abc_frame");
BLI_path_frame_get(fname->d_name, &cache_frame->framenr, &numdigit);
@ -552,9 +549,9 @@ static int get_sequence_len(const char *filepath, int *ofs)
BLI_listbase_sort(&frames, cmp_frame);
CacheFrame *cache_frame = frames.first;
CacheFrame *cache_frame = static_cast<CacheFrame *>(frames.first);
if (cache_frame) {
if (cache_frame != nullptr) {
int frame_curr = cache_frame->framenr;
(*ofs) = frame_curr;
@ -583,21 +580,21 @@ static void ui_alembic_import_settings(uiLayout *layout, PointerRNA *imfptr)
uiLayout *row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Manual Transform"), ICON_NONE);
uiItemR(box, imfptr, "scale", 0, NULL, ICON_NONE);
uiItemR(box, imfptr, "scale", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Options"), ICON_NONE);
uiLayout *col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "relative_path", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "set_frame_range", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "is_sequence", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "validate_meshes", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "always_add_cache_reader", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "relative_path", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "set_frame_range", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "is_sequence", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "validate_meshes", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "always_add_cache_reader", 0, nullptr, ICON_NONE);
}
static void wm_alembic_import_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_alembic_import_draw(bContext * /*C*/, wmOperator *op)
{
ui_alembic_import_settings(op->layout, op->ptr);
}
@ -645,7 +642,7 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op)
ED_object_mode_set(C, OB_MODE_OBJECT);
}
struct AlembicImportParams params = {0};
AlembicImportParams params = {0};
params.global_scale = scale;
params.sequence_len = sequence_len;
params.sequence_offset = offset;

View File

@ -31,7 +31,7 @@
#include "WM_api.h"
#include "WM_types.h"
#include "io_cache.h"
#include "io_cache.hh"
static void reload_cachefile(bContext *C, CacheFile *cache_file)
{
@ -43,11 +43,11 @@ static void cachefile_init(bContext *C, wmOperator *op)
{
PropertyPointerRNA *pprop;
op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
op->customdata = pprop = MEM_cnew<PropertyPointerRNA>("OpenPropertyPointerRNA");
UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop);
}
static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
char filepath[FILE_MAX];
@ -63,14 +63,12 @@ static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent *eve
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
UNUSED_VARS(event);
}
static void open_cancel(bContext *UNUSED(C), wmOperator *op)
static void open_cancel(bContext * /*C*/, wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
op->customdata = nullptr;
}
static int cachefile_open_exec(bContext *C, wmOperator *op)
@ -85,22 +83,23 @@ static int cachefile_open_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filepath), 0);
CacheFile *cache_file = static_cast<CacheFile *>(
BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filepath), 0));
STRNCPY(cache_file->filepath, filepath);
DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE);
/* Will be set when running invoke, not exec directly. */
if (op->customdata != NULL) {
if (op->customdata != nullptr) {
/* hook into UI */
PropertyPointerRNA *pprop = op->customdata;
if (pprop->prop) {
PropertyPointerRNA *pprop = static_cast<PropertyPointerRNA *>(op->customdata);
if (pprop->prop != nullptr) {
/* When creating new ID blocks, use is already 1, but RNA
* pointer see also increases user, so this compensates it. */
id_us_min(&cache_file->id);
PointerRNA idptr;
RNA_id_pointer_create(&cache_file->id, &idptr);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, NULL);
RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr, nullptr);
RNA_property_update(C, &pprop->ptr, pprop->prop);
}
@ -131,11 +130,11 @@ void CACHEFILE_OT_open(wmOperatorType *ot)
/* ***************************** Reload Operator **************************** */
static int cachefile_reload_exec(bContext *C, wmOperator *UNUSED(op))
static int cachefile_reload_exec(bContext *C, wmOperator * /*op*/)
{
CacheFile *cache_file = CTX_data_edit_cachefile(C);
if (!cache_file) {
if (cache_file == nullptr) {
return OPERATOR_CANCELLED;
}
@ -159,7 +158,7 @@ void CACHEFILE_OT_reload(wmOperatorType *ot)
/* ***************************** Add Layer Operator **************************** */
static int cachefile_layer_open_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int cachefile_layer_open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
char filepath[FILE_MAX];
@ -176,8 +175,6 @@ static int cachefile_layer_open_invoke(bContext *C, wmOperator *op, const wmEven
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
UNUSED_VARS(event);
}
static int cachefile_layer_add_exec(bContext *C, wmOperator *op)
@ -187,9 +184,9 @@ static int cachefile_layer_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
CacheFile *cache_file = op->customdata;
CacheFile *cache_file = static_cast<CacheFile *>(op->customdata);
if (!cache_file) {
if (cache_file == nullptr) {
return OPERATOR_CANCELLED;
}
@ -198,13 +195,13 @@ static int cachefile_layer_add_exec(bContext *C, wmOperator *op)
CacheFileLayer *layer = BKE_cachefile_add_layer(cache_file, filepath);
if (!layer) {
if (layer == nullptr) {
WM_report(RPT_ERROR, "Could not add a layer to the cache file");
return OPERATOR_CANCELLED;
}
reload_cachefile(C, cache_file);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, nullptr);
return OPERATOR_FINISHED;
}
@ -229,11 +226,11 @@ void CACHEFILE_OT_layer_add(wmOperatorType *ot)
/* ***************************** Remove Layer Operator **************************** */
static int cachefile_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
static int cachefile_layer_remove_exec(bContext *C, wmOperator * /*op*/)
{
CacheFile *cache_file = CTX_data_edit_cachefile(C);
if (!cache_file) {
if (cache_file == nullptr) {
return OPERATOR_CANCELLED;
}
@ -241,7 +238,7 @@ static int cachefile_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
BKE_cachefile_remove_layer(cache_file, layer);
reload_cachefile(C, cache_file);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, nullptr);
return OPERATOR_FINISHED;
}
@ -264,13 +261,13 @@ static int cachefile_layer_move_exec(bContext *C, wmOperator *op)
{
CacheFile *cache_file = CTX_data_edit_cachefile(C);
if (!cache_file) {
if (cache_file == nullptr) {
return OPERATOR_CANCELLED;
}
CacheFileLayer *layer = BKE_cachefile_get_active_layer(cache_file);
if (!layer) {
if (layer == nullptr) {
return OPERATOR_CANCELLED;
}
@ -280,7 +277,7 @@ static int cachefile_layer_move_exec(bContext *C, wmOperator *op)
cache_file->active_layer = BLI_findindex(&cache_file->layers, layer) + 1;
/* Only reload if something moved, might be expensive. */
reload_cachefile(C, cache_file);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, nullptr);
}
return OPERATOR_FINISHED;
@ -291,7 +288,7 @@ void CACHEFILE_OT_layer_move(wmOperatorType *ot)
static const EnumPropertyItem layer_slot_move[] = {
{-1, "UP", 0, "Up", ""},
{1, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
ot->name = "Move layer";

View File

@ -34,9 +34,9 @@
# include "collada.h"
# include "io_collada.h"
# include "io_collada.hh"
static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
ED_fileselect_ensure_default_filepath(C, op, ".dae");
@ -156,16 +156,16 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
// Scene *scene = CTX_data_scene(C);
ExportSettings export_settings;
ExportSettings export_settings{};
export_settings.filepath = filepath;
export_settings.apply_modifiers = apply_modifiers != 0;
export_settings.global_forward = global_forward;
export_settings.global_up = global_up;
export_settings.global_forward = BC_global_forward_axis(global_forward);
export_settings.global_up = BC_global_up_axis(global_up);
export_settings.apply_global_orientation = apply_global_orientation != 0;
export_settings.export_mesh_type = export_mesh_type;
export_settings.export_mesh_type = BC_export_mesh_type(export_mesh_type);
export_settings.selected = selected != 0;
export_settings.include_children = include_children != 0;
export_settings.include_armatures = include_armatures != 0;
@ -178,15 +178,17 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
export_settings.keep_flat_curves = keep_flat_curves != 0;
export_settings.active_uv_only = active_uv_only != 0;
export_settings.export_animation_type = export_animation_type;
export_settings.export_animation_type = BC_export_animation_type(export_animation_type);
export_settings.use_texture_copies = use_texture_copies != 0;
export_settings.triangulate = triangulate != 0;
export_settings.use_object_instantiation = use_object_instantiation != 0;
export_settings.use_blender_profile = use_blender_profile != 0;
export_settings.sort_by_name = sort_by_name != 0;
export_settings.object_transformation_type = export_object_transformation_type;
export_settings.animation_transformation_type = export_animation_transformation_type;
export_settings.object_transformation_type = BC_export_transformation_type(
export_object_transformation_type);
export_settings.animation_transformation_type = BC_export_transformation_type(
export_animation_transformation_type);
export_settings.keep_smooth_curves = keep_smooth_curves != 0;
if (export_animation_type != BC_ANIMATION_EXPORT_SAMPLES) {
@ -230,17 +232,17 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
bool include_animations = RNA_boolean_get(imfptr, "include_animations");
int ui_section = RNA_enum_get(imfptr, "prop_bc_export_ui_section");
BC_export_animation_type animation_type = RNA_enum_get(imfptr,
"export_animation_type_selection");
BC_export_animation_type animation_type = BC_export_animation_type(
RNA_enum_get(imfptr, "export_animation_type_selection"));
BC_export_transformation_type animation_transformation_type = RNA_enum_get(
imfptr, "export_animation_transformation_type_selection");
BC_export_transformation_type animation_transformation_type = BC_export_transformation_type(
RNA_enum_get(imfptr, "export_animation_transformation_type_selection"));
bool sampling = animation_type == BC_ANIMATION_EXPORT_SAMPLES;
/* Export Options: */
row = uiLayoutRow(layout, false);
uiItemR(row, imfptr, "prop_bc_export_ui_section", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(row, imfptr, "prop_bc_export_ui_section", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
@ -249,12 +251,12 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
/* Export data options. */
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "selected", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "selected", 0, nullptr, ICON_NONE);
sub = uiLayoutColumn(col, false);
uiLayoutSetEnabled(sub, RNA_boolean_get(imfptr, "selected"));
uiItemR(sub, imfptr, "include_children", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "include_armatures", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "include_shapekeys", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "include_children", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "include_armatures", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "include_shapekeys", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
@ -269,7 +271,7 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
uiItemL(box, IFACE_("Texture Options"), ICON_TEXTURE_DATA);
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "use_texture_copies", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_texture_copies", 0, nullptr, ICON_NONE);
row = uiLayoutRowWithHeading(col, true, IFACE_("UV"));
uiItemR(row, imfptr, "active_uv_only", 0, IFACE_("Only Selected Map"), ICON_NONE);
}
@ -279,7 +281,7 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "triangulate", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "triangulate", 0, nullptr, ICON_NONE);
row = uiLayoutRowWithHeading(col, true, IFACE_("Apply Modifiers"));
uiItemR(row, imfptr, "apply_modifiers", 0, "", ICON_NONE);
@ -288,10 +290,10 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(sub, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE);
if (RNA_boolean_get(imfptr, "include_animations")) {
uiItemR(col, imfptr, "export_animation_transformation_type_selection", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "export_animation_transformation_type_selection", 0, nullptr, ICON_NONE);
}
else {
uiItemR(col, imfptr, "export_object_transformation_type_selection", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "export_object_transformation_type_selection", 0, nullptr, ICON_NONE);
}
}
else if (ui_section == BC_UI_SECTION_ARMATURE) {
@ -300,25 +302,25 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
uiItemL(box, IFACE_("Armature Options"), ICON_ARMATURE_DATA);
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "deform_bones_only", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "open_sim", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "deform_bones_only", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "open_sim", 0, nullptr, ICON_NONE);
}
else if (ui_section == BC_UI_SECTION_ANIMATION) {
/* Animation options. */
box = uiLayoutBox(layout);
uiItemR(box, imfptr, "include_animations", 0, NULL, ICON_NONE);
uiItemR(box, imfptr, "include_animations", 0, nullptr, ICON_NONE);
col = uiLayoutColumn(box, false);
row = uiLayoutRow(col, false);
uiLayoutSetActive(row, include_animations);
uiItemR(row, imfptr, "export_animation_type_selection", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(row, imfptr, "export_animation_type_selection", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
uiLayoutSetActive(row, include_animations && animation_type == BC_ANIMATION_EXPORT_SAMPLES);
if (RNA_boolean_get(imfptr, "include_animations")) {
uiItemR(box, imfptr, "export_animation_transformation_type_selection", 0, NULL, ICON_NONE);
uiItemR(box, imfptr, "export_animation_transformation_type_selection", 0, nullptr, ICON_NONE);
}
else {
uiItemR(box, imfptr, "export_object_transformation_type_selection", 0, NULL, ICON_NONE);
uiItemR(box, imfptr, "export_object_transformation_type_selection", 0, nullptr, ICON_NONE);
}
row = uiLayoutColumn(col, false);
@ -326,17 +328,17 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
include_animations &&
(animation_transformation_type == BC_TRANSFORMATION_TYPE_DECOMPOSED ||
animation_type == BC_ANIMATION_EXPORT_KEYS));
uiItemR(row, imfptr, "keep_smooth_curves", 0, NULL, ICON_NONE);
uiItemR(row, imfptr, "keep_smooth_curves", 0, nullptr, ICON_NONE);
sub = uiLayoutColumn(col, false);
uiLayoutSetActive(sub, sampling && include_animations);
uiItemR(sub, imfptr, "sampling_rate", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "keep_keyframes", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "sampling_rate", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "keep_keyframes", 0, nullptr, ICON_NONE);
sub = uiLayoutColumn(col, false);
uiLayoutSetActive(sub, include_animations);
uiItemR(sub, imfptr, "keep_flat_curves", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "include_all_actions", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "keep_flat_curves", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "include_all_actions", 0, nullptr, ICON_NONE);
}
else if (ui_section == BC_UI_SECTION_COLLADA) {
/* Collada options: */
@ -345,20 +347,20 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
uiItemL(row, IFACE_("Collada Options"), ICON_MODIFIER);
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "use_object_instantiation", 1, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_blender_profile", 1, NULL, ICON_NONE);
uiItemR(col, imfptr, "sort_by_name", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "keep_bind_info", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "limit_precision", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_object_instantiation", 1, nullptr, ICON_NONE);
uiItemR(col, imfptr, "use_blender_profile", 1, nullptr, ICON_NONE);
uiItemR(col, imfptr, "sort_by_name", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "keep_bind_info", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "limit_precision", 0, nullptr, ICON_NONE);
}
}
static void wm_collada_export_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_collada_export_draw(bContext * /*C*/, wmOperator *op)
{
uiCollada_exportSettings(op->layout, op->ptr);
}
static bool wm_collada_export_check(bContext *UNUSED(C), wmOperator *op)
static bool wm_collada_export_check(bContext * /*C*/, wmOperator *op)
{
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
@ -377,7 +379,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
static const EnumPropertyItem prop_bc_export_mesh_type[] = {
{BC_MESH_TYPE_VIEW, "view", 0, "Viewport", "Apply modifier's viewport settings"},
{BC_MESH_TYPE_RENDER, "render", 0, "Render", "Apply modifier's render settings"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem prop_bc_export_global_forward[] = {
@ -387,7 +389,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
{BC_GLOBAL_FORWARD_MINUS_X, "-X", 0, "-X", "Global Forward is negative X Axis"},
{BC_GLOBAL_FORWARD_MINUS_Y, "-Y", 0, "-Y", "Global Forward is negative Y Axis"},
{BC_GLOBAL_FORWARD_MINUS_Z, "-Z", 0, "-Z", "Global Forward is negative Z Axis"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem prop_bc_export_global_up[] = {
@ -397,7 +399,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
{BC_GLOBAL_UP_MINUS_X, "-X", 0, "-X", "Global UP is negative X Axis"},
{BC_GLOBAL_UP_MINUS_Y, "-Y", 0, "-Y", "Global UP is negative Y Axis"},
{BC_GLOBAL_UP_MINUS_Z, "-Z", 0, "-Z", "Global UP is negative Z Axis"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem prop_bc_export_transformation_type[] = {
@ -411,7 +413,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
0,
"Decomposed",
"Use <rotate>, <translate> and <scale> representation for exported transformations"},
{0, NULL, 0, NULL, NULL}};
{0, nullptr, 0, nullptr, nullptr}};
static const EnumPropertyItem prop_bc_export_animation_type[] = {
{BC_ANIMATION_EXPORT_SAMPLES,
@ -424,7 +426,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
0,
"Curves",
"Export Curves (note: guided by curve keys)"},
{0, NULL, 0, NULL, NULL}};
{0, nullptr, 0, nullptr, nullptr}};
static const EnumPropertyItem prop_bc_export_ui_section[] = {
{BC_UI_SECTION_MAIN, "main", 0, "Main", "Data export section"},
@ -432,7 +434,7 @@ void WM_OT_collada_export(wmOperatorType *ot)
{BC_UI_SECTION_ARMATURE, "armature", 0, "Arm", "Armature export section"},
{BC_UI_SECTION_ANIMATION, "animation", 0, "Anim", "Animation export section"},
{BC_UI_SECTION_COLLADA, "collada", 0, "Extra", "Collada export section"},
{0, NULL, 0, NULL, NULL}};
{0, nullptr, 0, nullptr, nullptr}};
ot->name = "Export COLLADA";
ot->description = "Save a Collada file";
@ -688,7 +690,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
int keep_bind_info;
int custom_normals;
ImportSettings import_settings;
ImportSettings import_settings{};
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filepath given");
@ -737,24 +739,24 @@ static void uiCollada_importSettings(uiLayout *layout, PointerRNA *imfptr)
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Import Data Options"), ICON_MESH_DATA);
uiItemR(box, imfptr, "import_units", 0, NULL, ICON_NONE);
uiItemR(box, imfptr, "custom_normals", 0, NULL, ICON_NONE);
uiItemR(box, imfptr, "import_units", 0, nullptr, ICON_NONE);
uiItemR(box, imfptr, "custom_normals", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Armature Options"), ICON_ARMATURE_DATA);
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "fix_orientation", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "find_chains", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "auto_connect", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "min_chain_length", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "fix_orientation", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "find_chains", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "auto_connect", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "min_chain_length", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
uiItemR(box, imfptr, "keep_bind_info", 0, NULL, ICON_NONE);
uiItemR(box, imfptr, "keep_bind_info", 0, nullptr, ICON_NONE);
}
static void wm_collada_import_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_collada_import_draw(bContext * /*C*/, wmOperator *op)
{
uiCollada_importSettings(op->layout, op->ptr);
}

View File

@ -35,7 +35,7 @@
# include "DEG_depsgraph.h"
# include "DEG_depsgraph_query.h"
# include "io_gpencil.h"
# include "io_gpencil.hh"
# include "gpencil_io.h"
@ -48,7 +48,7 @@ static void gpencil_export_common_props_definition(wmOperatorType *ot)
{GP_EXPORT_ACTIVE, "ACTIVE", 0, "Active", "Include only the active object"},
{GP_EXPORT_SELECTED, "SELECTED", 0, "Selected", "Include selected objects"},
{GP_EXPORT_VISIBLE, "VISIBLE", 0, "Visible", "Include all visible objects"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
RNA_def_boolean(ot->srna, "use_fill", true, "Fill", "Export strokes with fill enabled");
@ -78,7 +78,7 @@ static void gpencil_export_common_props_definition(wmOperatorType *ot)
/* <-------- SVG single frame export. --------> */
# ifdef WITH_PUGIXML
static bool wm_gpencil_export_svg_common_check(bContext *UNUSED(C), wmOperator *op)
static bool wm_gpencil_export_svg_common_check(bContext * /*C*/, wmOperator *op)
{
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
@ -92,7 +92,7 @@ static bool wm_gpencil_export_svg_common_check(bContext *UNUSED(C), wmOperator *
return false;
}
static int wm_gpencil_export_svg_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int wm_gpencil_export_svg_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
ED_fileselect_ensure_default_filepath(C, op, ".svg");
@ -112,7 +112,7 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op)
}
ARegion *region = get_invoke_region(C);
if (region == NULL) {
if (region == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Unable to find valid 3D View area");
return OPERATOR_CANCELLED;
}
@ -123,7 +123,8 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op)
const bool use_fill = RNA_boolean_get(op->ptr, "use_fill");
const bool use_norm_thickness = RNA_boolean_get(op->ptr, "use_normalized_thickness");
const eGpencilExportSelect select_mode = RNA_enum_get(op->ptr, "selected_object_type");
const eGpencilExportSelect select_mode = eGpencilExportSelect(
RNA_enum_get(op->ptr, "selected_object_type"));
const bool use_clip_camera = RNA_boolean_get(op->ptr, "use_clip_camera");
@ -133,20 +134,21 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op)
SET_FLAG_FROM_TEST(flag, use_norm_thickness, GP_EXPORT_NORM_THICKNESS);
SET_FLAG_FROM_TEST(flag, use_clip_camera, GP_EXPORT_CLIP_CAMERA);
GpencilIOParams params = {.C = C,
.region = region,
.v3d = v3d,
.ob = ob,
.mode = GP_EXPORT_TO_SVG,
.frame_start = scene->r.cfra,
.frame_end = scene->r.cfra,
.frame_cur = scene->r.cfra,
.flag = flag,
.scale = 1.0f,
.select_mode = select_mode,
.frame_mode = GP_EXPORT_FRAME_ACTIVE,
.stroke_sample = RNA_float_get(op->ptr, "stroke_sample"),
.resolution = 1.0f};
GpencilIOParams params{};
params.C = C;
params.region = region;
params.v3d = v3d;
params.ob = ob;
params.mode = GP_EXPORT_TO_SVG;
params.frame_start = scene->r.cfra;
params.frame_end = scene->r.cfra;
params.frame_cur = scene->r.cfra;
params.flag = flag;
params.scale = 1.0f;
params.select_mode = select_mode;
params.frame_mode = GP_EXPORT_FRAME_ACTIVE;
params.stroke_sample = RNA_float_get(op->ptr, "stroke_sample");
params.resolution = 1.0f;
/* Do export. */
WM_cursor_wait(true);
@ -173,27 +175,27 @@ static void ui_gpencil_export_svg_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemL(row, IFACE_("Scene Options"), ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "selected_object_type", 0, NULL, ICON_NONE);
uiItemR(row, imfptr, "selected_object_type", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Export Options"), ICON_NONE);
uiLayout *col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "stroke_sample", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_fill", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_normalized_thickness", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_clip_camera", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "stroke_sample", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "use_fill", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "use_normalized_thickness", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "use_clip_camera", 0, nullptr, ICON_NONE);
}
static void wm_gpencil_export_svg_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_gpencil_export_svg_draw(bContext * /*C*/, wmOperator *op)
{
ui_gpencil_export_svg_settings(op->layout, op->ptr);
}
static bool wm_gpencil_export_svg_poll(bContext *C)
{
if ((CTX_wm_window(C) == NULL) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) {
if ((CTX_wm_window(C) == nullptr) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) {
return false;
}
@ -232,7 +234,7 @@ void WM_OT_gpencil_export_svg(wmOperatorType *ot)
/* <-------- PDF single frame export. --------> */
# ifdef WITH_HARU
static bool wm_gpencil_export_pdf_common_check(bContext *UNUSED(C), wmOperator *op)
static bool wm_gpencil_export_pdf_common_check(bContext * /*C*/, wmOperator *op)
{
char filepath[FILE_MAX];
@ -247,7 +249,7 @@ static bool wm_gpencil_export_pdf_common_check(bContext *UNUSED(C), wmOperator *
return false;
}
static int wm_gpencil_export_pdf_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int wm_gpencil_export_pdf_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
ED_fileselect_ensure_default_filepath(C, op, ".pdf");
@ -267,7 +269,7 @@ static int wm_gpencil_export_pdf_exec(bContext *C, wmOperator *op)
}
ARegion *region = get_invoke_region(C);
if (region == NULL) {
if (region == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Unable to find valid 3D View area");
return OPERATOR_CANCELLED;
}
@ -286,20 +288,21 @@ static int wm_gpencil_export_pdf_exec(bContext *C, wmOperator *op)
SET_FLAG_FROM_TEST(flag, use_fill, GP_EXPORT_FILL);
SET_FLAG_FROM_TEST(flag, use_norm_thickness, GP_EXPORT_NORM_THICKNESS);
GpencilIOParams params = {.C = C,
.region = region,
.v3d = v3d,
.ob = ob,
.mode = GP_EXPORT_TO_PDF,
.frame_start = scene->r.sfra,
.frame_end = scene->r.efra,
.frame_cur = scene->r.cfra,
.flag = flag,
.scale = 1.0f,
.select_mode = select_mode,
.frame_mode = frame_mode,
.stroke_sample = RNA_float_get(op->ptr, "stroke_sample"),
.resolution = 1.0f};
GpencilIOParams params{};
params.C = C;
params.region = region;
params.v3d = v3d;
params.ob = ob;
params.mode = GP_EXPORT_TO_PDF;
params.frame_start = scene->r.sfra;
params.frame_end = scene->r.efra;
params.frame_cur = scene->r.cfra;
params.flag = flag;
params.scale = 1.0f;
params.select_mode = select_mode;
params.frame_mode = frame_mode;
params.stroke_sample = RNA_float_get(op->ptr, "stroke_sample");
params.resolution = 1.0f;
/* Do export. */
WM_cursor_wait(true);
@ -326,7 +329,7 @@ static void ui_gpencil_export_pdf_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemL(row, IFACE_("Scene Options"), ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "selected_object_type", 0, NULL, ICON_NONE);
uiItemR(row, imfptr, "selected_object_type", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
@ -339,19 +342,19 @@ static void ui_gpencil_export_pdf_settings(uiLayout *layout, PointerRNA *imfptr)
uiLayoutSetPropSep(box, true);
sub = uiLayoutColumn(col, true);
uiItemR(sub, imfptr, "stroke_sample", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "use_fill", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "use_normalized_thickness", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "stroke_sample", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "use_fill", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "use_normalized_thickness", 0, nullptr, ICON_NONE);
}
static void wm_gpencil_export_pdf_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_gpencil_export_pdf_draw(bContext * /*C*/, wmOperator *op)
{
ui_gpencil_export_pdf_settings(op->layout, op->ptr);
}
static bool wm_gpencil_export_pdf_poll(bContext *C)
{
if ((CTX_wm_window(C) == NULL) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) {
if ((CTX_wm_window(C) == nullptr) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) {
return false;
}
@ -382,7 +385,7 @@ void WM_OT_gpencil_export_pdf(wmOperatorType *ot)
{GP_EXPORT_FRAME_ACTIVE, "ACTIVE", 0, "Active", "Include only active frame"},
{GP_EXPORT_FRAME_SELECTED, "SELECTED", 0, "Selected", "Include selected frames"},
{GP_EXPORT_FRAME_SCENE, "SCENE", 0, "Scene", "Include all scene frames"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
gpencil_export_common_props_definition(ot);

View File

@ -35,12 +35,12 @@
# include "ED_gpencil_legacy.h"
# include "io_gpencil.h"
# include "io_gpencil.hh"
# include "gpencil_io.h"
/* <-------- SVG single frame import. --------> */
static bool wm_gpencil_import_svg_common_check(bContext *UNUSED(C), wmOperator *op)
static bool wm_gpencil_import_svg_common_check(bContext * /*C*/, wmOperator *op)
{
char filepath[FILE_MAX];
@ -55,7 +55,7 @@ static bool wm_gpencil_import_svg_common_check(bContext *UNUSED(C), wmOperator *
return false;
}
static int wm_gpencil_import_svg_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int wm_gpencil_import_svg_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
WM_event_add_fileselect(C, op);
@ -74,7 +74,7 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator *op)
}
ARegion *region = get_invoke_region(C);
if (region == NULL) {
if (region == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Unable to find valid 3D View area");
return OPERATOR_CANCELLED;
}
@ -86,33 +86,32 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator *op)
const int resolution = RNA_int_get(op->ptr, "resolution");
const float scale = RNA_float_get(op->ptr, "scale");
GpencilIOParams params = {
.C = C,
.region = region,
.v3d = v3d,
.ob = NULL,
.mode = GP_IMPORT_FROM_SVG,
.frame_start = scene->r.cfra,
.frame_end = scene->r.cfra,
.frame_cur = scene->r.cfra,
.flag = flag,
.scale = scale,
.select_mode = 0,
.frame_mode = 0,
.stroke_sample = 0.0f,
.resolution = resolution,
};
GpencilIOParams params {};
params.C = C;
params.region = region;
params.v3d = v3d;
params.ob = nullptr;
params.mode = GP_IMPORT_FROM_SVG;
params.frame_start = scene->r.cfra;
params.frame_end = scene->r.cfra;
params.frame_cur = scene->r.cfra;
params.flag = flag;
params.scale = scale;
params.select_mode = 0;
params.frame_mode = 0;
params.stroke_sample = 0.0f;
params.resolution = resolution;
/* Loop all selected files to import them. All SVG imported shared the same import
* parameters, but they are created in separated grease pencil objects. */
PropertyRNA *prop;
if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
char *directory = RNA_string_get_alloc(op->ptr, "directory", NULL, 0, NULL);
char *directory = RNA_string_get_alloc(op->ptr, "directory", nullptr, 0, nullptr);
if ((prop = RNA_struct_find_property(op->ptr, "files"))) {
char file_path[FILE_MAX];
RNA_PROP_BEGIN (op->ptr, itemptr, prop) {
char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0, NULL);
char *filename = RNA_string_get_alloc(&itemptr, "name", nullptr, 0, nullptr);
BLI_path_join(file_path, sizeof(file_path), directory, filename);
MEM_freeN(filename);
@ -138,18 +137,18 @@ static void ui_gpencil_import_svg_settings(uiLayout *layout, PointerRNA *imfptr)
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayout *col = uiLayoutColumn(layout, false);
uiItemR(col, imfptr, "resolution", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "scale", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "resolution", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "scale", 0, nullptr, ICON_NONE);
}
static void wm_gpencil_import_svg_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_gpencil_import_svg_draw(bContext * /*C*/, wmOperator *op)
{
ui_gpencil_import_svg_settings(op->layout, op->ptr);
}
static bool wm_gpencil_import_svg_poll(bContext *C)
{
if ((CTX_wm_window(C) == NULL) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) {
if ((CTX_wm_window(C) == nullptr) || (CTX_data_mode_enum(C) != CTX_MODE_OBJECT)) {
return false;
}

View File

@ -15,17 +15,17 @@
# include "WM_api.h"
# include "io_gpencil.h"
# include "io_gpencil.hh"
ARegion *get_invoke_region(bContext *C)
{
bScreen *screen = CTX_wm_screen(C);
if (screen == NULL) {
return NULL;
if (screen == nullptr) {
return nullptr;
}
ScrArea *area = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0);
if (area == NULL) {
return NULL;
if (area == nullptr) {
return nullptr;
}
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
@ -36,18 +36,18 @@ ARegion *get_invoke_region(bContext *C)
View3D *get_invoke_view3d(bContext *C)
{
bScreen *screen = CTX_wm_screen(C);
if (screen == NULL) {
return NULL;
if (screen == nullptr) {
return nullptr;
}
ScrArea *area = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0);
if (area == NULL) {
return NULL;
if (area == nullptr) {
return nullptr;
}
if (area) {
return area->spacedata.first;
if (area != nullptr) {
return static_cast<View3D *>(area->spacedata.first);
}
return NULL;
return nullptr;
}
#endif /* WITH_IO_GPENCIL */

View File

@ -39,7 +39,8 @@
# include "IO_orientation.h"
# include "IO_path_util_types.h"
# include "IO_wavefront_obj.h"
# include "io_obj.h"
# include "io_obj.hh"
static const EnumPropertyItem io_obj_export_evaluation_mode[] = {
{DAG_EVAL_RENDER, "DAG_EVAL_RENDER", 0, "Render", "Export objects as they appear in render"},
@ -48,7 +49,7 @@ static const EnumPropertyItem io_obj_export_evaluation_mode[] = {
0,
"Viewport",
"Export objects as they appear in the viewport"},
{0, NULL, 0, NULL, NULL}};
{0, nullptr, 0, nullptr, nullptr}};
static const EnumPropertyItem io_obj_path_mode[] = {
{PATH_REFERENCE_AUTO, "AUTO", 0, "Auto", "Use relative paths with subdirectories only"},
@ -57,9 +58,9 @@ static const EnumPropertyItem io_obj_path_mode[] = {
{PATH_REFERENCE_MATCH, "MATCH", 0, "Match", "Match absolute/relative setting with input path"},
{PATH_REFERENCE_STRIP, "STRIP", 0, "Strip", "Write filename only"},
{PATH_REFERENCE_COPY, "COPY", 0, "Copy", "Copy the file to the destination path"},
{0, NULL, 0, NULL, NULL}};
{0, nullptr, 0, nullptr, nullptr}};
static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
ED_fileselect_ensure_default_filepath(C, op, ".obj");
@ -73,7 +74,7 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
struct OBJExportParams export_params;
OBJExportParams export_params{};
export_params.file_base_for_tests[0] = '\0';
RNA_string_get(op->ptr, "filepath", export_params.filepath);
export_params.blen_filepath = CTX_data_main(C)->filepath;
@ -81,18 +82,18 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
export_params.start_frame = RNA_int_get(op->ptr, "start_frame");
export_params.end_frame = RNA_int_get(op->ptr, "end_frame");
export_params.forward_axis = RNA_enum_get(op->ptr, "forward_axis");
export_params.up_axis = RNA_enum_get(op->ptr, "up_axis");
export_params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
export_params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
export_params.global_scale = RNA_float_get(op->ptr, "global_scale");
export_params.apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
export_params.export_eval_mode = RNA_enum_get(op->ptr, "export_eval_mode");
export_params.export_eval_mode = eEvaluationMode(RNA_enum_get(op->ptr, "export_eval_mode"));
export_params.export_selected_objects = RNA_boolean_get(op->ptr, "export_selected_objects");
export_params.export_uv = RNA_boolean_get(op->ptr, "export_uv");
export_params.export_normals = RNA_boolean_get(op->ptr, "export_normals");
export_params.export_colors = RNA_boolean_get(op->ptr, "export_colors");
export_params.export_materials = RNA_boolean_get(op->ptr, "export_materials");
export_params.path_mode = RNA_enum_get(op->ptr, "path_mode");
export_params.path_mode = ePathReferenceMode(RNA_enum_get(op->ptr, "path_mode"));
export_params.export_triangulated_mesh = RNA_boolean_get(op->ptr, "export_triangulated_mesh");
export_params.export_curves_as_nurbs = RNA_boolean_get(op->ptr, "export_curves_as_nurbs");
export_params.export_pbr_extensions = RNA_boolean_get(op->ptr, "export_pbr_extensions");
@ -124,7 +125,7 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr)
col = uiLayoutColumn(box, false);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Limit to"));
uiItemR(sub, imfptr, "export_selected_objects", 0, IFACE_("Selected Only"), ICON_NONE);
uiItemR(sub, imfptr, "global_scale", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "global_scale", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "forward_axis", 0, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(sub, imfptr, "up_axis", 0, IFACE_("Up Axis"), ICON_NONE);
@ -177,10 +178,10 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(sub, imfptr, "end_frame", 0, IFACE_("End"), ICON_NONE);
}
static void wm_obj_export_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_obj_export_draw(bContext * /*C*/, wmOperator *op)
{
PointerRNA ptr;
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
RNA_pointer_create(nullptr, op->type->srna, op->properties, &ptr);
ui_obj_export_settings(op->layout, &ptr);
}
@ -372,7 +373,7 @@ void WM_OT_obj_export(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_HIDDEN);
}
static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
WM_event_add_fileselect(C, op);
return OPERATOR_RUNNING_MODAL;
@ -380,12 +381,12 @@ static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
static int wm_obj_import_exec(bContext *C, wmOperator *op)
{
struct OBJImportParams import_params;
OBJImportParams import_params{};
RNA_string_get(op->ptr, "filepath", import_params.filepath);
import_params.global_scale = RNA_float_get(op->ptr, "global_scale");
import_params.clamp_size = RNA_float_get(op->ptr, "clamp_size");
import_params.forward_axis = RNA_enum_get(op->ptr, "forward_axis");
import_params.up_axis = RNA_enum_get(op->ptr, "up_axis");
import_params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
import_params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
import_params.use_split_objects = RNA_boolean_get(op->ptr, "use_split_objects");
import_params.use_split_groups = RNA_boolean_get(op->ptr, "use_split_groups");
import_params.import_vertex_groups = RNA_boolean_get(op->ptr, "import_vertex_groups");
@ -438,8 +439,8 @@ static void ui_obj_import_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemL(box, IFACE_("Transform"), ICON_OBJECT_DATA);
uiLayout *col = uiLayoutColumn(box, false);
uiLayout *sub = uiLayoutColumn(col, false);
uiItemR(sub, imfptr, "global_scale", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "clamp_size", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "global_scale", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "clamp_size", 0, nullptr, ICON_NONE);
sub = uiLayoutColumn(col, false);
uiItemR(sub, imfptr, "forward_axis", 0, IFACE_("Forward Axis"), ICON_NONE);
@ -448,10 +449,10 @@ static void ui_obj_import_settings(uiLayout *layout, PointerRNA *imfptr)
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Options"), ICON_EXPORT);
col = uiLayoutColumn(box, false);
uiItemR(col, imfptr, "use_split_objects", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_split_groups", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "import_vertex_groups", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "validate_meshes", 0, NULL, ICON_NONE);
uiItemR(col, imfptr, "use_split_objects", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "use_split_groups", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "import_vertex_groups", 0, nullptr, ICON_NONE);
uiItemR(col, imfptr, "validate_meshes", 0, nullptr, ICON_NONE);
}
static void wm_obj_import_draw(bContext *C, wmOperator *op)
@ -484,6 +485,7 @@ void WM_OT_obj_import(wmOperatorType *ot)
WM_FILESEL_DIRECTORY | WM_FILESEL_FILES,
FILE_DEFAULTDISPLAY,
FILE_SORT_DEFAULT);
RNA_def_float(
ot->srna,
"global_scale",

View File

@ -11,22 +11,22 @@
#include "WM_api.h"
#ifdef WITH_COLLADA
# include "io_collada.h"
# include "io_collada.hh"
#endif
#ifdef WITH_ALEMBIC
# include "io_alembic.h"
# include "io_alembic.hh"
#endif
#ifdef WITH_USD
# include "io_usd.h"
# include "io_usd.hh"
#endif
#include "io_cache.h"
#include "io_gpencil.h"
#include "io_obj.h"
#include "io_ply_ops.h"
#include "io_stl_ops.h"
#include "io_cache.hh"
#include "io_gpencil.hh"
#include "io_obj.hh"
#include "io_ply_ops.hh"
#include "io_stl_ops.hh"
void ED_operatortypes_io(void)
{
@ -60,7 +60,6 @@ void ED_operatortypes_io(void)
WM_operatortype_append(CACHEFILE_OT_layer_add);
WM_operatortype_append(CACHEFILE_OT_layer_remove);
WM_operatortype_append(CACHEFILE_OT_layer_move);
#ifdef WITH_IO_WAVEFRONT_OBJ
WM_operatortype_append(WM_OT_obj_export);
WM_operatortype_append(WM_OT_obj_import);

View File

@ -8,4 +8,12 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
void ED_operatortypes_io(void);
#ifdef __cplusplus
}
#endif

View File

@ -36,7 +36,7 @@
# include "IO_path_util_types.h"
# include "IO_ply.h"
# include "io_ply_ops.h"
# include "io_ply_ops.hh"
static const EnumPropertyItem ply_vertex_colors_mode[] = {
{PLY_VERTEX_COLOR_NONE, "NONE", 0, "None", "Do not import/export color attributes"},
@ -50,9 +50,9 @@ static const EnumPropertyItem ply_vertex_colors_mode[] = {
0,
"Linear",
"Vertex colors in the file are in linear color space"},
{0, NULL, 0, NULL, NULL}};
{0, nullptr, 0, nullptr, nullptr}};
static int wm_ply_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int wm_ply_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
ED_fileselect_ensure_default_filepath(C, op, ".ply");
@ -66,20 +66,20 @@ static int wm_ply_export_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No filepath given");
return OPERATOR_CANCELLED;
}
struct PLYExportParams export_params = {"\0"};
PLYExportParams export_params = {"\0"};
export_params.file_base_for_tests[0] = '\0';
RNA_string_get(op->ptr, "filepath", export_params.filepath);
export_params.blen_filepath = CTX_data_main(C)->filepath;
export_params.forward_axis = RNA_enum_get(op->ptr, "forward_axis");
export_params.up_axis = RNA_enum_get(op->ptr, "up_axis");
export_params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
export_params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
export_params.global_scale = RNA_float_get(op->ptr, "global_scale");
export_params.apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
export_params.export_selected_objects = RNA_boolean_get(op->ptr, "export_selected_objects");
export_params.export_uv = RNA_boolean_get(op->ptr, "export_uv");
export_params.export_normals = RNA_boolean_get(op->ptr, "export_normals");
export_params.vertex_colors = RNA_enum_get(op->ptr, "export_colors");
export_params.vertex_colors = ePLYVertexColorMode(RNA_enum_get(op->ptr, "export_colors"));
export_params.export_triangulated_mesh = RNA_boolean_get(op->ptr, "export_triangulated_mesh");
export_params.ascii_format = RNA_boolean_get(op->ptr, "ascii_format");
@ -102,7 +102,7 @@ static void ui_ply_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(sub, imfptr, "ascii_format", 0, IFACE_("ASCII"), ICON_NONE);
sub = uiLayoutColumnWithHeading(col, false, IFACE_("Limit to"));
uiItemR(sub, imfptr, "export_selected_objects", 0, IFACE_("Selected Only"), ICON_NONE);
uiItemR(sub, imfptr, "global_scale", 0, NULL, ICON_NONE);
uiItemR(sub, imfptr, "global_scale", 0, nullptr, ICON_NONE);
uiItemR(sub, imfptr, "forward_axis", 0, IFACE_("Forward Axis"), ICON_NONE);
uiItemR(sub, imfptr, "up_axis", 0, IFACE_("Up Axis"), ICON_NONE);
@ -122,17 +122,17 @@ static void ui_ply_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(sub, imfptr, "export_triangulated_mesh", 0, IFACE_("Triangulated Mesh"), ICON_NONE);
}
static void wm_ply_export_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_ply_export_draw(bContext * /*C*/, wmOperator *op)
{
PointerRNA ptr;
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
RNA_pointer_create(nullptr, op->type->srna, op->properties, &ptr);
ui_ply_export_settings(op->layout, &ptr);
}
/**
* Return true if any property in the UI is changed.
*/
static bool wm_ply_export_check(bContext *UNUSED(C), wmOperator *op)
static bool wm_ply_export_check(bContext * /*C*/, wmOperator *op)
{
char filepath[FILE_MAX];
bool changed = false;
@ -232,13 +232,13 @@ static int wm_ply_import_invoke(bContext *C, wmOperator *op, const wmEvent *even
static int wm_ply_import_execute(bContext *C, wmOperator *op)
{
struct PLYImportParams params;
params.forward_axis = RNA_enum_get(op->ptr, "forward_axis");
params.up_axis = RNA_enum_get(op->ptr, "up_axis");
PLYImportParams params{};
params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
params.use_scene_unit = RNA_boolean_get(op->ptr, "use_scene_unit");
params.global_scale = RNA_float_get(op->ptr, "global_scale");
params.merge_verts = RNA_boolean_get(op->ptr, "merge_verts");
params.vertex_colors = RNA_enum_get(op->ptr, "import_colors");
params.vertex_colors = ePLYVertexColorMode(RNA_enum_get(op->ptr, "import_colors"));
int files_len = RNA_collection_length(op->ptr, "files");

View File

@ -22,7 +22,7 @@
# include "RNA_define.h"
# include "IO_stl.h"
# include "io_stl_ops.h"
# include "io_stl_ops.hh"
static int wm_stl_import_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
@ -31,9 +31,9 @@ static int wm_stl_import_invoke(bContext *C, wmOperator *op, const wmEvent *even
static int wm_stl_import_execute(bContext *C, wmOperator *op)
{
struct STLImportParams params;
params.forward_axis = RNA_enum_get(op->ptr, "forward_axis");
params.up_axis = RNA_enum_get(op->ptr, "up_axis");
STLImportParams params{};
params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
params.use_facet_normal = RNA_boolean_get(op->ptr, "use_facet_normal");
params.use_scene_unit = RNA_boolean_get(op->ptr, "use_scene_unit");
params.global_scale = RNA_float_get(op->ptr, "global_scale");
@ -73,7 +73,7 @@ static int wm_stl_import_execute(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static bool wm_stl_import_check(bContext *UNUSED(C), wmOperator *op)
static bool wm_stl_import_check(bContext * /*C*/, wmOperator *op)
{
const int num_axes = 3;
/* Both forward and up axes cannot be the same (or same except opposite sign). */

View File

@ -9,7 +9,8 @@
#ifdef WITH_USD
# include "DNA_modifier_types.h"
# include "DNA_space_types.h"
# include <string.h>
# include <cstring>
# include "BKE_context.h"
# include "BKE_main.h"
@ -40,10 +41,10 @@
# include "DEG_depsgraph.h"
# include "io_usd.h"
# include "io_usd.hh"
# include "usd.h"
# include <stdio.h>
# include <cstdio>
const EnumPropertyItem rna_enum_usd_export_evaluation_mode_items[] = {
{DAG_EVAL_RENDER,
@ -56,7 +57,7 @@ const EnumPropertyItem rna_enum_usd_export_evaluation_mode_items[] = {
0,
"Viewport",
"Use Viewport settings for object visibility, modifier settings, etc"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
const EnumPropertyItem rna_enum_usd_mtl_name_collision_mode_items[] = {
@ -70,14 +71,14 @@ const EnumPropertyItem rna_enum_usd_mtl_name_collision_mode_items[] = {
0,
"Reference Existing",
"If a material with the same name already exists, reference that instead of importing"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
const EnumPropertyItem rna_enum_usd_tex_import_mode_items[] = {
{USD_TEX_IMPORT_NONE, "IMPORT_NONE", 0, "None", "Don't import textures"},
{USD_TEX_IMPORT_PACK, "IMPORT_PACK", 0, "Packed", "Import textures as packed data"},
{USD_TEX_IMPORT_COPY, "IMPORT_COPY", 0, "Copy", "Copy files to textures directory"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
const EnumPropertyItem rna_enum_usd_tex_name_collision_mode_items[] = {
@ -87,21 +88,21 @@ const EnumPropertyItem rna_enum_usd_tex_name_collision_mode_items[] = {
"Use Existing",
"If a file with the same name already exists, use that instead of copying"},
{USD_TEX_NAME_COLLISION_OVERWRITE, "OVERWRITE", 0, "Overwrite", "Overwrite existing files"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* Stored in the wmOperator's customdata field to indicate it should run as a background job.
* This is set when the operator is invoked, and not set when it is only executed. */
enum { AS_BACKGROUND_JOB = 1 };
typedef struct eUSDOperatorOptions {
struct eUSDOperatorOptions {
bool as_background_job;
} eUSDOperatorOptions;
};
/* Ensure that the prim_path is not set to
* the absolute root path '/'. */
static void process_prim_path(char *prim_path)
{
if (prim_path == NULL || prim_path[0] == '\0') {
if (prim_path == nullptr || prim_path[0] == '\0') {
return;
}
@ -112,9 +113,9 @@ static void process_prim_path(char *prim_path)
}
}
static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
eUSDOperatorOptions *options = MEM_callocN(sizeof(eUSDOperatorOptions), "eUSDOperatorOptions");
eUSDOperatorOptions *options = MEM_cnew<eUSDOperatorOptions>("eUSDOperatorOptions");
options->as_background_job = true;
op->customdata = options;
@ -135,8 +136,8 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
eUSDOperatorOptions *options = (eUSDOperatorOptions *)op->customdata;
const bool as_background_job = (options != NULL && options->as_background_job);
eUSDOperatorOptions *options = static_cast<eUSDOperatorOptions *>(op->customdata);
const bool as_background_job = (options != nullptr && options->as_background_job);
MEM_SAFE_FREE(op->customdata);
const bool selected_objects_only = RNA_boolean_get(op->ptr, "selected_objects_only");
@ -158,7 +159,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "root_prim_path", root_prim_path);
process_prim_path(root_prim_path);
struct USDExportParams params = {
USDExportParams params = {
export_animation,
export_hair,
export_uvmaps,
@ -167,7 +168,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
selected_objects_only,
visible_objects_only,
use_instancing,
evaluation_mode,
eEvaluationMode(evaluation_mode),
generate_preview_surface,
export_textures,
overwrite_textures,
@ -181,75 +182,75 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static void wm_usd_export_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_usd_export_draw(bContext * /*C*/, wmOperator *op)
{
uiLayout *layout = op->layout;
uiLayout *col;
struct PointerRNA *ptr = op->ptr;
PointerRNA *ptr = op->ptr;
uiLayoutSetPropSep(layout, true);
uiLayout *box = uiLayoutBox(layout);
col = uiLayoutColumn(box, true);
uiItemR(col, ptr, "selected_objects_only", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "visible_objects_only", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "selected_objects_only", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "visible_objects_only", 0, nullptr, ICON_NONE);
col = uiLayoutColumn(box, true);
uiItemR(col, ptr, "export_animation", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "export_hair", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "export_uvmaps", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "export_normals", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "export_materials", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "root_prim_path", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "export_animation", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "export_hair", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "export_uvmaps", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "export_normals", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "export_materials", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "root_prim_path", 0, nullptr, ICON_NONE);
col = uiLayoutColumn(box, true);
uiItemR(col, ptr, "evaluation_mode", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "evaluation_mode", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
col = uiLayoutColumnWithHeading(box, true, IFACE_("Materials"));
uiItemR(col, ptr, "generate_preview_surface", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "generate_preview_surface", 0, nullptr, ICON_NONE);
const bool export_mtl = RNA_boolean_get(ptr, "export_materials");
uiLayoutSetActive(col, export_mtl);
uiLayout *row = uiLayoutRow(col, true);
uiItemR(row, ptr, "export_textures", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "export_textures", 0, nullptr, ICON_NONE);
const bool preview = RNA_boolean_get(ptr, "generate_preview_surface");
uiLayoutSetActive(row, export_mtl && preview);
row = uiLayoutRow(col, true);
uiItemR(row, ptr, "overwrite_textures", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "overwrite_textures", 0, nullptr, ICON_NONE);
const bool export_tex = RNA_boolean_get(ptr, "export_textures");
uiLayoutSetActive(row, export_mtl && preview && export_tex);
box = uiLayoutBox(layout);
col = uiLayoutColumnWithHeading(box, true, IFACE_("File References"));
uiItemR(col, ptr, "relative_paths", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "relative_paths", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Experimental"), ICON_NONE);
uiItemR(box, ptr, "use_instancing", 0, NULL, ICON_NONE);
uiItemR(box, ptr, "use_instancing", 0, nullptr, ICON_NONE);
}
static void free_operator_customdata(wmOperator *op)
{
if (op->customdata) {
MEM_freeN(op->customdata);
op->customdata = NULL;
op->customdata = nullptr;
}
}
static void wm_usd_export_cancel(bContext *UNUSED(C), wmOperator *op)
static void wm_usd_export_cancel(bContext * /*C*/, wmOperator *op)
{
free_operator_customdata(op);
}
static bool wm_usd_export_check(bContext *UNUSED(C), wmOperator *op)
static bool wm_usd_export_check(bContext * /*C*/, wmOperator *op)
{
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
if (!BLI_path_extension_check_n(filepath, ".usd", ".usda", ".usdc", ".usdz", NULL)) {
if (!BLI_path_extension_check_n(filepath, ".usd", ".usda", ".usdc", ".usdz", nullptr)) {
BLI_path_extension_ensure(filepath, FILE_MAX, ".usdc");
RNA_string_set(op->ptr, "filepath", filepath);
return true;
@ -258,7 +259,7 @@ static bool wm_usd_export_check(bContext *UNUSED(C), wmOperator *op)
return false;
}
void WM_OT_usd_export(struct wmOperatorType *ot)
void WM_OT_usd_export(wmOperatorType *ot)
{
ot->name = "Export USD";
ot->description = "Export current scene in a USD archive";
@ -363,7 +364,7 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
RNA_def_string(ot->srna,
"root_prim_path",
NULL,
nullptr,
FILE_MAX,
"Root Prim",
"If set, add a transform primitive with the given path to the stage "
@ -374,7 +375,7 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
static int wm_usd_import_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
eUSDOperatorOptions *options = MEM_callocN(sizeof(eUSDOperatorOptions), "eUSDOperatorOptions");
eUSDOperatorOptions *options = MEM_cnew<eUSDOperatorOptions>("eUSDOperatorOptions");
options->as_background_job = true;
op->customdata = options;
@ -391,8 +392,8 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath);
eUSDOperatorOptions *options = (eUSDOperatorOptions *)op->customdata;
const bool as_background_job = (options != NULL && options->as_background_job);
eUSDOperatorOptions *options = static_cast<eUSDOperatorOptions *>(op->customdata);
const bool as_background_job = (options != nullptr && options->as_background_job);
MEM_SAFE_FREE(op->customdata);
const float scale = RNA_float_get(op->ptr, "scale");
@ -426,7 +427,7 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
const bool create_collection = RNA_boolean_get(op->ptr, "create_collection");
char *prim_path_mask = RNA_string_get_alloc(op->ptr, "prim_path_mask", NULL, 0, NULL);
char *prim_path_mask = RNA_string_get_alloc(op->ptr, "prim_path_mask", nullptr, 0, nullptr);
const bool import_guide = RNA_boolean_get(op->ptr, "import_guide");
const bool import_proxy = RNA_boolean_get(op->ptr, "import_proxy");
@ -439,8 +440,8 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
const float light_intensity_scale = RNA_float_get(op->ptr, "light_intensity_scale");
const eUSDMtlNameCollisionMode mtl_name_collision_mode = RNA_enum_get(op->ptr,
"mtl_name_collision_mode");
const eUSDMtlNameCollisionMode mtl_name_collision_mode = eUSDMtlNameCollisionMode(
RNA_enum_get(op->ptr, "mtl_name_collision_mode"));
/* TODO(makowalski): Add support for sequences. */
const bool is_sequence = false;
@ -456,44 +457,46 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
const bool validate_meshes = false;
const bool use_instancing = false;
const eUSDTexImportMode import_textures_mode = RNA_enum_get(op->ptr, "import_textures_mode");
const eUSDTexImportMode import_textures_mode = eUSDTexImportMode(
RNA_enum_get(op->ptr, "import_textures_mode"));
char import_textures_dir[FILE_MAXDIR];
RNA_string_get(op->ptr, "import_textures_dir", import_textures_dir);
const eUSDTexNameCollisionMode tex_name_collision_mode = RNA_enum_get(op->ptr,
"tex_name_collision_mode");
const eUSDTexNameCollisionMode tex_name_collision_mode = eUSDTexNameCollisionMode(
RNA_enum_get(op->ptr, "tex_name_collision_mode"));
struct USDImportParams params = {.scale = scale,
.is_sequence = is_sequence,
.set_frame_range = set_frame_range,
.sequence_len = sequence_len,
.offset = offset,
.validate_meshes = validate_meshes,
.mesh_read_flag = mesh_read_flag,
.import_cameras = import_cameras,
.import_curves = import_curves,
.import_lights = import_lights,
.import_materials = import_materials,
.import_meshes = import_meshes,
.import_volumes = import_volumes,
.import_shapes = import_shapes,
.prim_path_mask = prim_path_mask,
.import_subdiv = import_subdiv,
.import_instance_proxies = import_instance_proxies,
.create_collection = create_collection,
.import_guide = import_guide,
.import_proxy = import_proxy,
.import_render = import_render,
.import_visible_only = import_visible_only,
.use_instancing = use_instancing,
.import_usd_preview = import_usd_preview,
.set_material_blend = set_material_blend,
.light_intensity_scale = light_intensity_scale,
.mtl_name_collision_mode = mtl_name_collision_mode,
.import_textures_mode = import_textures_mode,
.tex_name_collision_mode = tex_name_collision_mode,
.import_all_materials = import_all_materials};
USDImportParams params{};
params.scale = scale;
params.is_sequence = is_sequence;
params.set_frame_range = set_frame_range;
params.sequence_len = sequence_len;
params.offset = offset;
params.validate_meshes = validate_meshes;
params.mesh_read_flag = mesh_read_flag;
params.import_cameras = import_cameras;
params.import_curves = import_curves;
params.import_lights = import_lights;
params.import_materials = import_materials;
params.import_meshes = import_meshes;
params.import_volumes = import_volumes;
params.import_shapes = import_shapes;
params.prim_path_mask = prim_path_mask;
params.import_subdiv = import_subdiv;
params.import_instance_proxies = import_instance_proxies;
params.create_collection = create_collection;
params.import_guide = import_guide;
params.import_proxy = import_proxy;
params.import_render = import_render;
params.import_visible_only = import_visible_only;
params.use_instancing = use_instancing;
params.import_usd_preview = import_usd_preview;
params.set_material_blend = set_material_blend;
params.light_intensity_scale = light_intensity_scale;
params.mtl_name_collision_mode = mtl_name_collision_mode;
params.import_textures_mode = import_textures_mode;
params.tex_name_collision_mode = tex_name_collision_mode;
params.import_all_materials = import_all_materials;
STRNCPY(params.import_textures_dir, import_textures_dir);
@ -502,73 +505,73 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static void wm_usd_import_cancel(bContext *UNUSED(C), wmOperator *op)
static void wm_usd_import_cancel(bContext * /*C*/, wmOperator *op)
{
free_operator_customdata(op);
}
static void wm_usd_import_draw(bContext *UNUSED(C), wmOperator *op)
static void wm_usd_import_draw(bContext * /*C*/, wmOperator *op)
{
uiLayout *layout = op->layout;
struct PointerRNA *ptr = op->ptr;
PointerRNA *ptr = op->ptr;
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayout *box = uiLayoutBox(layout);
uiLayout *col = uiLayoutColumnWithHeading(box, true, IFACE_("Data Types"));
uiItemR(col, ptr, "import_cameras", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_curves", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_lights", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_materials", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_meshes", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_volumes", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_shapes", 0, NULL, ICON_NONE);
uiItemR(box, ptr, "prim_path_mask", 0, NULL, ICON_NONE);
uiItemR(box, ptr, "scale", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_cameras", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_curves", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_lights", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_materials", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_meshes", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_volumes", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_shapes", 0, nullptr, ICON_NONE);
uiItemR(box, ptr, "prim_path_mask", 0, nullptr, ICON_NONE);
uiItemR(box, ptr, "scale", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
col = uiLayoutColumnWithHeading(box, true, IFACE_("Mesh Data"));
uiItemR(col, ptr, "read_mesh_uvs", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "read_mesh_colors", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "read_mesh_uvs", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "read_mesh_colors", 0, nullptr, ICON_NONE);
col = uiLayoutColumnWithHeading(box, true, IFACE_("Include"));
uiItemR(col, ptr, "import_subdiv", 0, IFACE_("Subdivision"), ICON_NONE);
uiItemR(col, ptr, "import_instance_proxies", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_visible_only", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_guide", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_proxy", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_render", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_instance_proxies", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_visible_only", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_guide", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_proxy", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_render", 0, nullptr, ICON_NONE);
col = uiLayoutColumnWithHeading(box, true, IFACE_("Options"));
uiItemR(col, ptr, "set_frame_range", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "relative_path", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "create_collection", 0, NULL, ICON_NONE);
uiItemR(box, ptr, "light_intensity_scale", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "set_frame_range", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "relative_path", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "create_collection", 0, nullptr, ICON_NONE);
uiItemR(box, ptr, "light_intensity_scale", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
col = uiLayoutColumnWithHeading(box, true, IFACE_("Materials"));
uiItemR(col, ptr, "import_all_materials", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_usd_preview", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_all_materials", 0, nullptr, ICON_NONE);
uiItemR(col, ptr, "import_usd_preview", 0, nullptr, ICON_NONE);
uiLayoutSetEnabled(col, RNA_boolean_get(ptr, "import_materials"));
uiLayout *row = uiLayoutRow(col, true);
uiItemR(row, ptr, "set_material_blend", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "set_material_blend", 0, nullptr, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(ptr, "import_usd_preview"));
uiItemR(col, ptr, "mtl_name_collision_mode", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "mtl_name_collision_mode", 0, nullptr, ICON_NONE);
box = uiLayoutBox(layout);
col = uiLayoutColumn(box, true);
uiItemR(col, ptr, "import_textures_mode", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "import_textures_mode", 0, nullptr, ICON_NONE);
bool copy_textures = RNA_enum_get(op->ptr, "import_textures_mode") == USD_TEX_IMPORT_COPY;
row = uiLayoutRow(col, true);
uiItemR(row, ptr, "import_textures_dir", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "import_textures_dir", 0, nullptr, ICON_NONE);
uiLayoutSetEnabled(row, copy_textures);
row = uiLayoutRow(col, true);
uiItemR(row, ptr, "tex_name_collision_mode", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "tex_name_collision_mode", 0, nullptr, ICON_NONE);
uiLayoutSetEnabled(row, copy_textures);
uiLayoutSetEnabled(col, RNA_boolean_get(ptr, "import_materials"));
}
void WM_OT_usd_import(struct wmOperatorType *ot)
void WM_OT_usd_import(wmOperatorType *ot)
{
ot->name = "Import USD";
ot->description = "Import USD stage into current scene";
@ -652,7 +655,7 @@ void WM_OT_usd_import(struct wmOperatorType *ot)
RNA_def_string(ot->srna,
"prim_path_mask",
NULL,
nullptr,
0,
"Path Mask",
"Import only the primitive at the given path and its descendents. "

View File

@ -11,5 +11,4 @@
struct wmOperatorType;
void WM_OT_usd_export(struct wmOperatorType *ot);
void WM_OT_usd_import(struct wmOperatorType *ot);

View File

@ -438,7 +438,9 @@ void MESH_OT_bisect(wmOperatorType *ot)
1.0f);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_boolean(ot->srna, "use_fill", false, "Fill", "Fill in the cut");
prop = RNA_def_boolean(ot->srna, "use_fill", false, "Fill", "Fill in the cut");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MASK);
RNA_def_boolean(
ot->srna, "clear_inner", false, "Clear Inner", "Remove geometry behind the plane");
RNA_def_boolean(

View File

@ -710,7 +710,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
const bool rot_src = RNA_boolean_get(op->ptr, "rotate_source");
const bool use_proj = ((vc.scene->toolsettings->snap_flag & SCE_SNAP) &&
(vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE_RAYCAST));
(vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE));
/* First calculate the center of transformation. */
zero_v3(center);

View File

@ -18,6 +18,8 @@
#include "BKE_layer.h"
#include "BKE_report.h"
#include "BLT_translation.h"
#include "RNA_access.h"
#include "RNA_define.h"
@ -1102,6 +1104,8 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void MESH_OT_rip(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name = "Rip";
ot->idname = "MESH_OT_rip";
@ -1116,5 +1120,6 @@ void MESH_OT_rip(wmOperatorType *ot)
/* to give to transform */
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR_DUMMY);
RNA_def_boolean(ot->srna, "use_fill", false, "Fill", "Fill the ripped region");
prop = RNA_def_boolean(ot->srna, "use_fill", false, "Fill", "Fill the ripped region");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MESH);
}

View File

@ -1946,7 +1946,7 @@ void EDBM_project_snap_verts(
depsgraph,
region,
CTX_wm_view3d(C),
SCE_SNAP_MODE_FACE_RAYCAST,
SCE_SNAP_MODE_FACE,
&(const struct SnapObjectParams){
.snap_target_select = target_op,
.edit_mode_type = SNAP_GEOM_FINAL,

View File

@ -2951,10 +2951,14 @@ static int paste_material_exec(bContext *C, wmOperator *op)
* TODO(@ideasman42): support merging indirectly referenced data-blocks besides the material,
* this would be useful for pasting materials with node-groups between files. */
if (ma->nodetree) {
/* This implicitly points to local data, assign after remapping. */
ma->nodetree->owner_id = nullptr;
/* Map remote ID's to local ones. */
BKE_library_foreach_ID_link(
bmain, &ma->nodetree->id, paste_material_nodetree_ids_relink_or_clear, bmain, IDWALK_NOP);
ma->nodetree->owner_id = &ma->id;
}
BKE_main_free(temp_bmain);

View File

@ -547,10 +547,17 @@ static eContextResult screen_ctx_property(const bContext *C, bContextDataResult
int index;
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
if (ptr.data && prop) {
/* UI_context_active_but_prop_get returns an index of 0 if the property is not
* an array, but other functions expect -1 for non-arrays. */
if (!RNA_property_array_check(prop)) {
index = -1;
}
CTX_data_type_set(result, CTX_DATA_TYPE_PROPERTY);
CTX_data_pointer_set_ptr(result, &ptr);
CTX_data_prop_set(result, prop, index);
CTX_data_type_set(result, CTX_DATA_TYPE_PROPERTY);
CTX_data_pointer_set_ptr(result, &ptr);
CTX_data_prop_set(result, prop, index);
}
return CTX_RESULT_OK;
}

View File

@ -3341,11 +3341,14 @@ static bool screen_maximize_area_poll(bContext *C)
const wmWindow *win = CTX_wm_window(C);
const bScreen *screen = CTX_wm_screen(C);
const ScrArea *area = CTX_wm_area(C);
const wmWindowManager *wm = CTX_wm_manager(C);
return ED_operator_areaactive(C) &&
/* Don't allow maximizing global areas but allow minimizing from them. */
((screen->state != SCREENNORMAL) || !ED_area_is_global(area)) &&
/* Don't change temporary screens. */
!WM_window_is_temp_screen(win);
!WM_window_is_temp_screen(win) &&
/* Don't maximize when dragging. */
BLI_listbase_is_empty(&wm->drags);
}
static void SCREEN_OT_screen_full_area(wmOperatorType *ot)

View File

@ -151,9 +151,9 @@ static void grease_pencil_stroke_cancel(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_brush_stroke(wmOperatorType *ot)
{
ot->name = "Stroke Curves Sculpt";
ot->name = "Grease Pencil Draw";
ot->idname = "GREASE_PENCIL_OT_brush_stroke";
ot->description = "Sculpt curves using a brush";
ot->description = "Draw a new stroke in the active Grease Pencil object";
ot->invoke = grease_pencil_stroke_invoke;
ot->modal = grease_pencil_stroke_modal;

View File

@ -6628,9 +6628,13 @@ static void default_paint_slot_color_get(int layer_type, Material *ma, float col
case LAYER_ROUGHNESS:
case LAYER_METALLIC: {
bNodeTree *ntree = nullptr;
ma->nodetree->ensure_topology_cache();
const blender::Span<bNode *> nodes = ma->nodetree->nodes_by_type("ShaderNodeBsdfPrincipled");
bNode *in_node = nodes.is_empty() ? nullptr : nodes.first();
bNode *in_node = nullptr;
if (ma && ma->nodetree) {
ma->nodetree->ensure_topology_cache();
const blender::Span<bNode *> nodes = ma->nodetree->nodes_by_type(
"ShaderNodeBsdfPrincipled");
in_node = nodes.is_empty() ? nullptr : nodes.first();
}
if (!in_node) {
/* An existing material or Principled BSDF node could not be found.
* Copy default color values from a default Principled BSDF instead. */
@ -6861,7 +6865,8 @@ static int texture_paint_add_texture_paint_slot_invoke(bContext *C,
get_default_texture_layer_name_for_object(ob, type, (char *)&imagename, sizeof(imagename));
RNA_string_set(op->ptr, "name", imagename);
/* Set default color. Copy the color from nodes, so it matches the existing material. */
/* Set default color. Copy the color from nodes, so it matches the existing material.
* Material could be null so we should have a default color. */
float color[4];
default_paint_slot_color_get(type, ma, color);
RNA_float_set_array(op->ptr, "color", color);

View File

@ -17,6 +17,8 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@ -389,7 +391,8 @@ static int palette_color_add_exec(bContext *C, wmOperator * /*op*/)
PAINT_MODE_TEXTURE_3D,
PAINT_MODE_TEXTURE_2D,
PAINT_MODE_VERTEX,
PAINT_MODE_SCULPT)) {
PAINT_MODE_SCULPT))
{
copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
color->value = 0.0;
}
@ -1011,6 +1014,8 @@ static void PAINT_OT_brush_select(wmOperatorType *ot)
const char *prop_id = BKE_paint_get_tool_prop_id_from_paintmode(paint_mode);
prop = RNA_def_enum(
ot->srna, prop_id, BKE_paint_get_tool_enum_from_paintmode(paint_mode), 0, prop_id, "");
RNA_def_property_translation_context(
prop, BKE_paint_get_tool_enum_translation_context_from_paintmode(paint_mode));
RNA_def_property_flag(prop, PROP_HIDDEN);
}

View File

@ -12,6 +12,8 @@
#include "BLI_math_color_blend.h"
#include "BLI_task.h"
#include "BLT_translation.h"
#include "DNA_meshdata_types.h"
#include "DNA_userdef_types.h"
@ -476,5 +478,6 @@ void SCULPT_OT_color_filter(wmOperatorType *ot)
"",
0.0f,
1.0f);
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MESH);
RNA_def_property_subtype(prop, PROP_COLOR_GAMMA);
}

View File

@ -35,6 +35,7 @@
#include "ED_geometry.h"
#include "ED_gizmo_library.h"
#include "ED_gpencil_legacy.h"
#include "ED_grease_pencil.h"
#include "ED_grease_pencil_draw.h"
#include "ED_lattice.h"
#include "ED_markers.h"
@ -93,8 +94,9 @@ void ED_spacetypes_init(void)
ED_operatortypes_anim();
ED_operatortypes_animchannels();
ED_operatortypes_asset();
ED_operatortypes_gpencil_legacy();
ED_operatortypes_grease_pencil_draw();
ED_operatortypes_gpencil();
ED_operatortypes_grease_pencil();
ED_operatortypes_object();
ED_operatortypes_lattice();
ED_operatortypes_mesh();
@ -183,7 +185,8 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf)
ED_keymap_screen(keyconf);
ED_keymap_anim(keyconf);
ED_keymap_animchannels(keyconf);
ED_keymap_gpencil(keyconf);
ED_keymap_gpencil_legacy(keyconf);
ED_keymap_grease_pencil(keyconf);
ED_keymap_object(keyconf);
ED_keymap_lattice(keyconf);
ED_keymap_mesh(keyconf);

View File

@ -37,18 +37,6 @@
#include "console_intern.h"
/* TODO: Text operations not yet supported for console:
* Mac KM_OSKEY-arrow to beginning/end of line
* Mac KM_OSKEY-backspace to start of line
* Mac KM_OSKEY-delete to end of line
* Text cursor insertion by mouse
* Mouse drag to select does not change text cursor position.
* Shift-ctrl-arrow to select word
* ctrl-x to copy to clipboard and delete.
* ctrl-a to select all
* ctrl-zshift-crtrl-z undo/redo
*/
/* -------------------------------------------------------------------- */
/** \name Utilities
* \{ */

View File

@ -23,6 +23,7 @@ set(INC
../../render
../../windowmanager
../../../../intern/guardedalloc
../../../../extern/fmtlib/include
# dna_type_offsets.h
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
@ -58,6 +59,7 @@ set(LIB
bf_blenkernel
bf_blenlib
bf_editor_screen
extern_fmtlib
)
if(WITH_COMPOSITOR_CPU)

View File

@ -1196,7 +1196,7 @@ static const float std_node_socket_colors[][4] = {
{0.78, 0.78, 0.16, 1.0}, /* SOCK_RGBA */
{0.39, 0.78, 0.39, 1.0}, /* SOCK_SHADER */
{0.80, 0.65, 0.84, 1.0}, /* SOCK_BOOLEAN */
{0.0, 0.0, 0.0, 1.0}, /*__SOCK_MESH (deprecated) */
{0.0, 0.0, 0.0, 1.0}, /* SOCK_MESH_DEPRECATED */
{0.35, 0.55, 0.36, 1.0}, /* SOCK_INT */
{0.44, 0.70, 1.00, 1.0}, /* SOCK_STRING */
{0.93, 0.62, 0.36, 1.0}, /* SOCK_OBJECT */
@ -1299,7 +1299,7 @@ static void std_node_socket_draw(
}
if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_HIDE_VALUE) ||
((sock->flag & SOCK_IS_LINKED) && !(sock->link->is_muted())))
((sock->flag & SOCK_IS_LINKED) && !all_links_muted(*sock)))
{
node_socket_button_label(C, layout, ptr, node_ptr, text);
return;

View File

@ -91,6 +91,8 @@
#include "node_intern.hh" /* own include */
#include <fmt/format.h>
namespace geo_log = blender::nodes::geo_eval_log;
using blender::bke::node_tree_zones::TreeZone;
using blender::bke::node_tree_zones::TreeZones;
@ -857,7 +859,7 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
return;
}
if (value_type.is<std::string>()) {
ss << *static_cast<const std::string *>(buffer) << " " << TIP_("(String)");
ss << fmt::format(TIP_("{} (String)"), *static_cast<const std::string *>(buffer));
return;
}
@ -874,22 +876,22 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
BLI_SCOPED_DEFER([&]() { socket_type.destruct(socket_value); });
if (socket_type.is<int>()) {
ss << *static_cast<int *>(socket_value) << " " << TIP_("(Integer)");
ss << fmt::format(TIP_("{} (Integer)"), *static_cast<int *>(socket_value));
}
else if (socket_type.is<float>()) {
ss << *static_cast<float *>(socket_value) << " " << TIP_("(Float)");
ss << fmt::format(TIP_("{} (Float)"), *static_cast<float *>(socket_value));
}
else if (socket_type.is<blender::float3>()) {
ss << *static_cast<blender::float3 *>(socket_value) << " " << TIP_("(Vector)");
const blender::float3 &vector = *static_cast<blender::float3 *>(socket_value);
ss << fmt::format(TIP_("({}, {}, {}) (Vector)"), vector.x, vector.y, vector.z);
}
else if (socket_type.is<blender::ColorGeometry4f>()) {
const blender::ColorGeometry4f &color = *static_cast<blender::ColorGeometry4f *>(socket_value);
ss << "(" << color.r << ", " << color.g << ", " << color.b << ", " << color.a << ") "
<< TIP_("(Color)");
ss << fmt::format(TIP_("({}, {}, {}, {}) (Color)"), color.r, color.g, color.b, color.a);
}
else if (socket_type.is<bool>()) {
ss << ((*static_cast<bool *>(socket_value)) ? TIP_("True") : TIP_("False")) << " "
<< TIP_("(Boolean)");
ss << fmt::format(TIP_("{} (Boolean)"),
((*static_cast<bool *>(socket_value)) ? TIP_("True") : TIP_("False")));
}
}

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