WIP: Vulkan: Workbench #107886
|
@ -5,8 +5,24 @@
|
||||||
#ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
|
#ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
|
||||||
# undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
|
# undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
|
||||||
-# define _DEBUG
|
-# define _DEBUG
|
||||||
+// BLENDER: TBB excepts this to have a value.
|
+// BLENDER: TBB expects this to have a value.
|
||||||
+# define _DEBUG 1
|
+# define _DEBUG 1
|
||||||
# ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
|
# ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
|
||||||
# undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
|
# undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
|
||||||
# undef _CRT_NOFORCE_MANIFEST
|
# 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 ---
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
# NOTE: Resolved up-stream, quiet noisy compiler warnings for now.
|
||||||
|
add_cxx_flag("-Wno-uninitialized")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(INC
|
set(INC
|
||||||
include
|
include
|
||||||
)
|
)
|
||||||
|
|
|
@ -104,7 +104,7 @@ ccl_device int bsdf_ashikhmin_velvet_sample(ccl_private const ShaderClosure *sc,
|
||||||
float cosHI = fabsf(dot(wi, H));
|
float cosHI = fabsf(dot(wi, H));
|
||||||
float cosNH = dot(N, H);
|
float cosNH = dot(N, H);
|
||||||
|
|
||||||
if (!(fabsf(cosNI) > 1e-5f && fabsf(cosNH) < 1.0f - 1e-5f && cosHI > 1e-5f)) {
|
if (!(cosNI > 1e-5f && fabsf(cosNH) < 1.0f - 1e-5f && cosHI > 1e-5f)) {
|
||||||
*pdf = 0.0f;
|
*pdf = 0.0f;
|
||||||
*eval = zero_spectrum();
|
*eval = zero_spectrum();
|
||||||
return LABEL_NONE;
|
return LABEL_NONE;
|
||||||
|
|
|
@ -224,7 +224,7 @@ ccl_device void osl_closure_dielectric_bsdf_setup(KernelGlobals kg,
|
||||||
sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
|
sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* GGX (either single- or multiscattering) */
|
/* GGX (either single- or multi-scattering). */
|
||||||
else {
|
else {
|
||||||
if (has_reflection && has_transmission) {
|
if (has_reflection && has_transmission) {
|
||||||
sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf);
|
sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf);
|
||||||
|
@ -278,7 +278,7 @@ ccl_device void osl_closure_conductor_bsdf_setup(KernelGlobals kg,
|
||||||
if (closure->distribution == make_string("beckmann", 14712237670914973463ull)) {
|
if (closure->distribution == make_string("beckmann", 14712237670914973463ull)) {
|
||||||
sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
|
sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
|
||||||
}
|
}
|
||||||
/* GGX (either single- or multiscattering) */
|
/* GGX (either single- or multi-scattering) */
|
||||||
else {
|
else {
|
||||||
sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
|
sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
|
||||||
preserve_energy = (closure->distribution == make_string("multi_ggx", 16842698693386468366ull));
|
preserve_energy = (closure->distribution == make_string("multi_ggx", 16842698693386468366ull));
|
||||||
|
@ -338,7 +338,7 @@ ccl_device void osl_closure_generalized_schlick_bsdf_setup(
|
||||||
sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
|
sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* GGX (either single- or multiscattering) */
|
/* GGX (either single- or multi-scattering) */
|
||||||
else {
|
else {
|
||||||
if (has_reflection && has_transmission) {
|
if (has_reflection && has_transmission) {
|
||||||
sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf);
|
sd->flag |= bsdf_microfacet_ggx_glass_setup(bsdf);
|
||||||
|
@ -414,7 +414,7 @@ ccl_device void osl_closure_microfacet_setup(KernelGlobals kg,
|
||||||
else if (closure->distribution == make_string("ashikhmin_shirley", 11318482998918370922ull)) {
|
else if (closure->distribution == make_string("ashikhmin_shirley", 11318482998918370922ull)) {
|
||||||
sd->flag |= bsdf_ashikhmin_shirley_setup(bsdf);
|
sd->flag |= bsdf_ashikhmin_shirley_setup(bsdf);
|
||||||
}
|
}
|
||||||
/* GGX (either single- or multiscattering) */
|
/* GGX (either single- or multi-scattering) */
|
||||||
else {
|
else {
|
||||||
if (closure->refract == 1) {
|
if (closure->refract == 1) {
|
||||||
sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
|
sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
|
||||||
|
@ -523,7 +523,7 @@ ccl_device void osl_closure_microfacet_aniso_fresnel_setup(
|
||||||
bsdf->ior = closure->ior;
|
bsdf->ior = closure->ior;
|
||||||
bsdf->T = closure->T;
|
bsdf->T = closure->T;
|
||||||
|
|
||||||
/* Only GGX (either single- or multiscattering) supported here */
|
/* Only GGX (either single- or multi-scattering) supported here */
|
||||||
sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
|
sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
|
||||||
|
|
||||||
const bool preserve_energy = (closure->distribution ==
|
const bool preserve_energy = (closure->distribution ==
|
||||||
|
|
|
@ -47,7 +47,9 @@ shader node_texture_coordinate(
|
||||||
if (!getattribute("geom:generated", Generated)) {
|
if (!getattribute("geom:generated", Generated)) {
|
||||||
Generated = transform("object", P);
|
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) {
|
if (use_transform) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ closure color principled_diffuse(normal N, float roughness) BUILTIN;
|
||||||
closure color principled_sheen(normal N) BUILTIN;
|
closure color principled_sheen(normal N) BUILTIN;
|
||||||
closure color principled_clearcoat(normal N, float clearcoat, float clearcoat_roughness) BUILTIN;
|
closure color principled_clearcoat(normal N, float clearcoat, float clearcoat_roughness) BUILTIN;
|
||||||
|
|
||||||
/* Needed to pass along the color for multiscattering saturation adjustment,
|
/* Needed to pass along the color for multi-scattering saturation adjustment,
|
||||||
* otherwise could be replaced by microfacet() */
|
* otherwise could be replaced by microfacet() */
|
||||||
closure color microfacet_multi_ggx_glass(normal N, float ag, float eta, color C) BUILTIN;
|
closure color microfacet_multi_ggx_glass(normal N, float ag, float eta, color C) BUILTIN;
|
||||||
closure color microfacet_multi_ggx_aniso(normal N, vector T, float ax, float ay, color C) BUILTIN;
|
closure color microfacet_multi_ggx_aniso(normal N, vector T, float ax, float ay, color C) BUILTIN;
|
||||||
|
|
|
@ -71,6 +71,11 @@ ccl_device_noinline void svm_node_attr(KernelGlobals kg,
|
||||||
}
|
}
|
||||||
#endif
|
#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) {
|
if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) {
|
||||||
/* No generated attribute, fall back to object coordinates. */
|
/* No generated attribute, fall back to object coordinates. */
|
||||||
float3 f = sd->P;
|
float3 f = sd->P;
|
||||||
|
|
|
@ -170,14 +170,15 @@ typedef enum {
|
||||||
GHOST_kModifierKeyNum
|
GHOST_kModifierKeyNum
|
||||||
} GHOST_TModifierKey;
|
} GHOST_TModifierKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \note these values are stored in #wmWindow::windowstate,
|
||||||
|
* don't change, only add new values.
|
||||||
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GHOST_kWindowStateNormal = 0,
|
GHOST_kWindowStateNormal = 0,
|
||||||
GHOST_kWindowStateMaximized,
|
GHOST_kWindowStateMaximized = 1,
|
||||||
GHOST_kWindowStateMinimized,
|
GHOST_kWindowStateMinimized = 2,
|
||||||
GHOST_kWindowStateFullScreen,
|
GHOST_kWindowStateFullScreen = 3,
|
||||||
GHOST_kWindowStateEmbedded,
|
|
||||||
// GHOST_kWindowStateModified,
|
|
||||||
// GHOST_kWindowStateUnModified,
|
|
||||||
} GHOST_TWindowState;
|
} GHOST_TWindowState;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -332,9 +332,6 @@ static bool gwl_window_state_set_for_libdecor(libdecor_frame *frame,
|
||||||
libdecor_frame_set_fullscreen(frame, nullptr);
|
libdecor_frame_set_fullscreen(frame, nullptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GHOST_kWindowStateEmbedded: {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -377,9 +374,6 @@ static bool gwl_window_state_set_for_xdg(xdg_toplevel *toplevel,
|
||||||
xdg_toplevel_set_fullscreen(toplevel, nullptr);
|
xdg_toplevel_set_fullscreen(toplevel, nullptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GHOST_kWindowStateEmbedded: {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ def keyconfig_update(keyconfig_data, keyconfig_version):
|
||||||
km_items.append(('ROTATE_NORMALS', {"type": 'N', "value": 'PRESS'}, None))
|
km_items.append(('ROTATE_NORMALS', {"type": 'N', "value": 'PRESS'}, None))
|
||||||
break
|
break
|
||||||
|
|
||||||
if keyconfig_version <= (3, 6, 3):
|
if keyconfig_version <= (4, 0, 3):
|
||||||
if not has_copy:
|
if not has_copy:
|
||||||
keyconfig_data = copy.deepcopy(keyconfig_data)
|
keyconfig_data = copy.deepcopy(keyconfig_data)
|
||||||
has_copy = True
|
has_copy = True
|
||||||
|
|
|
@ -8,7 +8,6 @@ from bpy.app.translations import pgettext_tip as tip_
|
||||||
|
|
||||||
|
|
||||||
def guess_player_path(preset):
|
def guess_player_path(preset):
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if preset == 'INTERNAL':
|
if preset == 'INTERNAL':
|
||||||
|
@ -17,6 +16,7 @@ def guess_player_path(preset):
|
||||||
elif preset == 'DJV':
|
elif preset == 'DJV':
|
||||||
player_path = "djv"
|
player_path = "djv"
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
|
import os
|
||||||
test_path = "/Applications/DJV2.app/Contents/Resources/bin/djv"
|
test_path = "/Applications/DJV2.app/Contents/Resources/bin/djv"
|
||||||
if os.path.exists(test_path):
|
if os.path.exists(test_path):
|
||||||
player_path = test_path
|
player_path = test_path
|
||||||
|
@ -141,7 +141,15 @@ class PlayRenderedAnim(Operator):
|
||||||
opts = [file, "%d-%d" % (scene.frame_start, scene.frame_end)]
|
opts = [file, "%d-%d" % (scene.frame_start, scene.frame_end)]
|
||||||
cmd.extend(opts)
|
cmd.extend(opts)
|
||||||
elif preset == 'RV':
|
elif preset == 'RV':
|
||||||
opts = ["-fps", str(rd.fps), "-play", "[ %s ]" % file]
|
opts = ["-fps", str(rd.fps), "-play"]
|
||||||
|
if scene.use_preview_range:
|
||||||
|
opts += [
|
||||||
|
"%s" % file.replace("#", "", file.count('#') - 1),
|
||||||
|
"%d-%d" % (frame_start, frame_end),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
opts.append(file)
|
||||||
|
|
||||||
cmd.extend(opts)
|
cmd.extend(opts)
|
||||||
elif preset == 'MPLAYER':
|
elif preset == 'MPLAYER':
|
||||||
opts = []
|
opts = []
|
||||||
|
|
|
@ -937,7 +937,6 @@ def brush_settings_advanced(layout, context, brush, popover=False):
|
||||||
|
|
||||||
col = layout.column(heading="Auto-Masking", align=True)
|
col = layout.column(heading="Auto-Masking", align=True)
|
||||||
|
|
||||||
col = layout.column(align=True)
|
|
||||||
col.prop(brush, "use_automasking_topology", text="Topology")
|
col.prop(brush, "use_automasking_topology", text="Topology")
|
||||||
col.prop(brush, "use_automasking_face_sets", text="Face Sets")
|
col.prop(brush, "use_automasking_face_sets", text="Face Sets")
|
||||||
|
|
||||||
|
|
|
@ -764,20 +764,26 @@ class NODE_PT_quality(bpy.types.Panel):
|
||||||
tree = snode.node_tree
|
tree = snode.node_tree
|
||||||
prefs = bpy.context.preferences
|
prefs = bpy.context.preferences
|
||||||
|
|
||||||
|
use_realtime = False
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
if prefs.experimental.use_full_frame_compositor:
|
if prefs.experimental.use_experimental_compositors:
|
||||||
col.prop(tree, "execution_mode")
|
col.prop(tree, "execution_mode")
|
||||||
|
use_realtime = tree.execution_mode == 'REALTIME'
|
||||||
|
|
||||||
|
col = layout.column()
|
||||||
|
col.active = not use_realtime
|
||||||
col.prop(tree, "render_quality", text="Render")
|
col.prop(tree, "render_quality", text="Render")
|
||||||
col.prop(tree, "edit_quality", text="Edit")
|
col.prop(tree, "edit_quality", text="Edit")
|
||||||
col.prop(tree, "chunk_size")
|
col.prop(tree, "chunk_size")
|
||||||
|
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
|
col.active = not use_realtime
|
||||||
col.prop(tree, "use_opencl")
|
col.prop(tree, "use_opencl")
|
||||||
col.prop(tree, "use_groupnode_buffer")
|
col.prop(tree, "use_groupnode_buffer")
|
||||||
col.prop(tree, "use_two_pass")
|
col.prop(tree, "use_two_pass")
|
||||||
col.prop(tree, "use_viewer_border")
|
col.prop(tree, "use_viewer_border")
|
||||||
col.separator()
|
|
||||||
|
col = layout.column()
|
||||||
col.prop(snode, "use_auto_render")
|
col.prop(snode, "use_auto_render")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ if "_icon_cache" in locals():
|
||||||
del release
|
del release
|
||||||
|
|
||||||
|
|
||||||
# (filename -> icon_value) map
|
# (icon_name -> icon_value) map
|
||||||
_icon_cache = {}
|
_icon_cache = {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,14 +236,14 @@ class ToolSelectPanelHelper:
|
||||||
icon_value = _icon_cache.get(icon_name)
|
icon_value = _icon_cache.get(icon_name)
|
||||||
if icon_value is None:
|
if icon_value is None:
|
||||||
dirname = bpy.utils.system_resource('DATAFILES', path="icons")
|
dirname = bpy.utils.system_resource('DATAFILES', path="icons")
|
||||||
filename = os.path.join(dirname, icon_name + ".dat")
|
filepath = os.path.join(dirname, icon_name + ".dat")
|
||||||
try:
|
try:
|
||||||
icon_value = bpy.app.icons.new_triangles_from_file(filename)
|
icon_value = bpy.app.icons.new_triangles_from_file(filepath)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filepath):
|
||||||
print("Missing icons:", filename, ex)
|
print("Missing icons:", filepath, ex)
|
||||||
else:
|
else:
|
||||||
print("Corrupt icon:", filename, ex)
|
print("Corrupt icon:", filepath, ex)
|
||||||
# Use none as a fallback (avoids layout issues).
|
# Use none as a fallback (avoids layout issues).
|
||||||
if icon_name != "none":
|
if icon_name != "none":
|
||||||
icon_value = ToolSelectPanelHelper._icon_value_from_icon_handle("none")
|
icon_value = ToolSelectPanelHelper._icon_value_from_icon_handle("none")
|
||||||
|
|
|
@ -2417,7 +2417,7 @@ class USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel):
|
||||||
({"property": "use_new_curves_tools"}, ("blender/blender/issues/68981", "#68981")),
|
({"property": "use_new_curves_tools"}, ("blender/blender/issues/68981", "#68981")),
|
||||||
({"property": "use_new_point_cloud_type"}, ("blender/blender/issues/75717", "#75717")),
|
({"property": "use_new_point_cloud_type"}, ("blender/blender/issues/75717", "#75717")),
|
||||||
({"property": "use_sculpt_texture_paint"}, ("blender/blender/issues/96225", "#96225")),
|
({"property": "use_sculpt_texture_paint"}, ("blender/blender/issues/96225", "#96225")),
|
||||||
({"property": "use_full_frame_compositor"}, ("blender/blender/issues/88150", "#88150")),
|
({"property": "use_experimental_compositors"}, ("blender/blender/issues/88150", "#88150")),
|
||||||
({"property": "enable_eevee_next"}, ("blender/blender/issues/93220", "#93220")),
|
({"property": "enable_eevee_next"}, ("blender/blender/issues/93220", "#93220")),
|
||||||
({"property": "enable_workbench_next"}, ("blender/blender/issues/101619", "#101619")),
|
({"property": "enable_workbench_next"}, ("blender/blender/issues/101619", "#101619")),
|
||||||
({"property": "use_grease_pencil_version3"}, ("blender/blender/projects/40", "Grease Pencil 3.0")),
|
({"property": "use_grease_pencil_version3"}, ("blender/blender/projects/40", "Grease Pencil 3.0")),
|
||||||
|
|
|
@ -2028,7 +2028,7 @@ class VIEW3D_MT_select_edit_gpencil(Menu):
|
||||||
layout.operator("grease_pencil.select_all", text="None").action = 'DESELECT'
|
layout.operator("grease_pencil.select_all", text="None").action = 'DESELECT'
|
||||||
layout.operator("grease_pencil.select_all", text="Invert").action = 'INVERT'
|
layout.operator("grease_pencil.select_all", text="Invert").action = 'INVERT'
|
||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_MT_select_paint_mask(Menu):
|
class VIEW3D_MT_select_paint_mask(Menu):
|
||||||
|
|
|
@ -65,7 +65,7 @@ void BKE_blendfile_read_setup_readfile(struct bContext *C,
|
||||||
const char *startup_app_template);
|
const char *startup_app_template);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simpler version of #BKE_blendfile_read_setup_readfile used when reading undoe steps from
|
* Simpler version of #BKE_blendfile_read_setup_readfile used when reading undo steps from
|
||||||
* memfile. */
|
* memfile. */
|
||||||
void BKE_blendfile_read_setup_undo(struct bContext *C,
|
void BKE_blendfile_read_setup_undo(struct bContext *C,
|
||||||
struct BlendFileData *bfd,
|
struct BlendFileData *bfd,
|
||||||
|
|
|
@ -75,15 +75,13 @@ bool BKE_texture_dependsOnTime(const struct Tex *texture);
|
||||||
*/
|
*/
|
||||||
bool BKE_texture_is_image_user(const struct Tex *tex);
|
bool BKE_texture_is_image_user(const struct Tex *tex);
|
||||||
|
|
||||||
void BKE_texture_get_value_ex(const struct Scene *scene,
|
void BKE_texture_get_value_ex(struct Tex *texture,
|
||||||
struct Tex *texture,
|
|
||||||
const float *tex_co,
|
const float *tex_co,
|
||||||
struct TexResult *texres,
|
struct TexResult *texres,
|
||||||
struct ImagePool *pool,
|
struct ImagePool *pool,
|
||||||
bool use_color_management);
|
bool use_color_management);
|
||||||
|
|
||||||
void BKE_texture_get_value(const struct Scene *scene,
|
void BKE_texture_get_value(struct Tex *texture,
|
||||||
struct Tex *texture,
|
|
||||||
const float *tex_co,
|
const float *tex_co,
|
||||||
struct TexResult *texres,
|
struct TexResult *texres,
|
||||||
bool use_color_management);
|
bool use_color_management);
|
||||||
|
|
|
@ -21,6 +21,7 @@ struct MovieClipUser;
|
||||||
struct MovieDistortion;
|
struct MovieDistortion;
|
||||||
struct MovieReconstructContext;
|
struct MovieReconstructContext;
|
||||||
struct MovieTracking;
|
struct MovieTracking;
|
||||||
|
struct MovieTrackingCamera;
|
||||||
struct MovieTrackingMarker;
|
struct MovieTrackingMarker;
|
||||||
struct MovieTrackingObject;
|
struct MovieTrackingObject;
|
||||||
struct MovieTrackingPlaneMarker;
|
struct MovieTrackingPlaneMarker;
|
||||||
|
@ -464,6 +465,16 @@ void BKE_tracking_camera_principal_point_pixel_get(struct MovieClip *clip,
|
||||||
void BKE_tracking_camera_principal_point_pixel_set(struct MovieClip *clip,
|
void BKE_tracking_camera_principal_point_pixel_set(struct MovieClip *clip,
|
||||||
const float principal_point_pixel[2]);
|
const float principal_point_pixel[2]);
|
||||||
|
|
||||||
|
/* Compares distortion related parameters of camera. Ideally, this implementation will be
|
||||||
|
* abstracted away in the future, but for now, one needs to be careful about it and handle any
|
||||||
|
* extra parameters of distortions models. */
|
||||||
|
bool BKE_tracking_camera_distortion_equal(const struct MovieTrackingCamera *a,
|
||||||
|
const struct MovieTrackingCamera *b);
|
||||||
|
/* Hashes distortion related parameters of camera. Ideally, this implementation will be
|
||||||
|
* abstracted away in the future, but for now, one needs to be careful about it and handle any
|
||||||
|
* extra parameters of distortions models. */
|
||||||
|
uint64_t BKE_tracking_camera_distortion_hash(const struct MovieTrackingCamera *camera);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
/* --------------------------------------------------------------------
|
||||||
* (Un)distortion.
|
* (Un)distortion.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1852,7 +1852,7 @@ void BKE_pose_blend_write(BlendWriter *writer, bPose *pose, bArmature *arm)
|
||||||
|
|
||||||
animviz_motionpath_blend_write(writer, chan->mpath);
|
animviz_motionpath_blend_write(writer, chan->mpath);
|
||||||
|
|
||||||
/* Prevent crashes with autosave,
|
/* Prevent crashes with auto-save,
|
||||||
* when a bone duplicated in edit-mode has not yet been assigned to its pose-channel.
|
* when a bone duplicated in edit-mode has not yet been assigned to its pose-channel.
|
||||||
* Also needed with memundo, in some cases we can store a step before pose has been
|
* Also needed with memundo, in some cases we can store a step before pose has been
|
||||||
* properly rebuilt from previous undo step. */
|
* properly rebuilt from previous undo step. */
|
||||||
|
|
|
@ -114,10 +114,10 @@ AnimData *BKE_animdata_ensure_id(ID *id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Action / Tmpact Setter shared code -------------------------
|
/* Action / `tmpact` Setter shared code -------------------------
|
||||||
*
|
*
|
||||||
* Both the action and tmpact setter functions have essentially
|
* Both the action and `tmpact` setter functions have essentially
|
||||||
* identical semantics, because tmpact is just a place to temporarily
|
* identical semantics, because `tmpact` is just a place to temporarily
|
||||||
* store the main action during tweaking. This function contains the
|
* store the main action during tweaking. This function contains the
|
||||||
* shared code between those two setter functions, setting the action
|
* shared code between those two setter functions, setting the action
|
||||||
* of the passed `act_slot` to `act`.
|
* of the passed `act_slot` to `act`.
|
||||||
|
|
|
@ -65,7 +65,7 @@ static void pchan_deform_accumulate(const DualQuat *deform_dq,
|
||||||
BLI_assert(!co_accum);
|
BLI_assert(!co_accum);
|
||||||
|
|
||||||
if (deform_dq->scale_weight) {
|
if (deform_dq->scale_weight) {
|
||||||
/* FIX https://projects.blender.org/blender/blender/issues/32022 */
|
/* FIX #32022. */
|
||||||
DualQuat mdq = *deform_dq;
|
DualQuat mdq = *deform_dq;
|
||||||
float dst[3];
|
float dst[3];
|
||||||
mul_v3_m4v3(dst, mdq.scale, co_in);
|
mul_v3_m4v3(dst, mdq.scale, co_in);
|
||||||
|
|
|
@ -208,14 +208,13 @@ static void setup_app_userdef(BlendFileData *bfd)
|
||||||
BKE_blender_userdef_data_set_and_free(bfd->user);
|
BKE_blender_userdef_data_set_and_free(bfd->user);
|
||||||
bfd->user = nullptr;
|
bfd->user = nullptr;
|
||||||
|
|
||||||
/* Security issue: any blend file could include a USER block.
|
/* Security issue: any blend file could include a #BLO_CODE_USER block.
|
||||||
*
|
*
|
||||||
* Currently we load prefs from BLENDER_STARTUP_FILE and later on load BLENDER_USERPREF_FILE,
|
* Preferences are loaded from #BLENDER_STARTUP_FILE and later on load #BLENDER_USERPREF_FILE,
|
||||||
* to load the preferences defined in the users home dir.
|
* to load the preferences defined in the users home directory.
|
||||||
*
|
*
|
||||||
* This means we will never accidentally (or maliciously)
|
* This means we will never accidentally (or maliciously)
|
||||||
* enable scripts auto-execution by loading a '.blend' file.
|
* enable scripts auto-execution by loading a `.blend` file. */
|
||||||
*/
|
|
||||||
U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE;
|
U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +250,7 @@ typedef struct ReuseOldBMainData {
|
||||||
* NOTE: The case where the `old_bmain` would be a library in the newly read one is not handled
|
* NOTE: The case where the `old_bmain` would be a library in the newly read one is not handled
|
||||||
* here, as it does not create explicit issues. The local data from `old_bmain` is either
|
* here, as it does not create explicit issues. The local data from `old_bmain` is either
|
||||||
* discarded, or added to the `new_bmain` as local data as well. Worst case, there will be a
|
* discarded, or added to the `new_bmain` as local data as well. Worst case, there will be a
|
||||||
* doublon of a linked data as a local one, without any known relationships between them. In
|
* double of a linked data as a local one, without any known relationships between them. In
|
||||||
* practice, this latter case is not expected to commonly happen.
|
* practice, this latter case is not expected to commonly happen.
|
||||||
*/
|
*/
|
||||||
static IDRemapper *reuse_bmain_data_remapper_ensure(ReuseOldBMainData *reuse_data)
|
static IDRemapper *reuse_bmain_data_remapper_ensure(ReuseOldBMainData *reuse_data)
|
||||||
|
@ -747,7 +746,7 @@ static void setup_app_data(bContext *C,
|
||||||
wmWindow *win = nullptr;
|
wmWindow *win = nullptr;
|
||||||
bScreen *curscreen = nullptr;
|
bScreen *curscreen = nullptr;
|
||||||
|
|
||||||
/* Ensure that there is a valid scene and viewlayer. */
|
/* Ensure that there is a valid scene and view-layer. */
|
||||||
if (curscene == nullptr) {
|
if (curscene == nullptr) {
|
||||||
curscene = static_cast<Scene *>(bfd->main->scenes.first);
|
curscene = static_cast<Scene *>(bfd->main->scenes.first);
|
||||||
}
|
}
|
||||||
|
@ -904,7 +903,7 @@ static void setup_app_data(bContext *C,
|
||||||
bmain->filepath[0] = '\0';
|
bmain->filepath[0] = '\0';
|
||||||
}
|
}
|
||||||
else if (recover) {
|
else if (recover) {
|
||||||
/* In case of autosave or quit.blend, use original filepath instead. */
|
/* In case of auto-save or quit.blend, use original filepath instead. */
|
||||||
bmain->recovered = true;
|
bmain->recovered = true;
|
||||||
STRNCPY(bmain->filepath, bfd->filepath);
|
STRNCPY(bmain->filepath, bfd->filepath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1931,7 +1931,7 @@ static void sample_mesh(FluidFlowSettings *ffs,
|
||||||
tex_co[1] = tex_co[1] * 2.0f - 1.0f;
|
tex_co[1] = tex_co[1] * 2.0f - 1.0f;
|
||||||
tex_co[2] = ffs->texture_offset;
|
tex_co[2] = ffs->texture_offset;
|
||||||
}
|
}
|
||||||
BKE_texture_get_value(nullptr, ffs->noise_texture, tex_co, &texres, false);
|
BKE_texture_get_value(ffs->noise_texture, tex_co, &texres, false);
|
||||||
emission_strength *= texres.tin;
|
emission_strength *= texres.tin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
*
|
*
|
||||||
* ```
|
* \code{.cc}
|
||||||
* Image *image = ...;
|
* Image *image = ...;
|
||||||
* ImBuf *image_buffer = ...;
|
* ImBuf *image_buffer = ...;
|
||||||
*
|
*
|
||||||
|
@ -44,8 +44,7 @@
|
||||||
*
|
*
|
||||||
* // Free partial_update_user.
|
* // Free partial_update_user.
|
||||||
* BKE_image_partial_update_free(partial_update_user);
|
* BKE_image_partial_update_free(partial_update_user);
|
||||||
*
|
* \endcode
|
||||||
* ```
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
|
@ -331,7 +331,6 @@ static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket
|
||||||
case SOCK_BOOLEAN:
|
case SOCK_BOOLEAN:
|
||||||
case SOCK_INT:
|
case SOCK_INT:
|
||||||
case SOCK_STRING:
|
case SOCK_STRING:
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_SHADER:
|
case SOCK_SHADER:
|
||||||
case SOCK_GEOMETRY:
|
case SOCK_GEOMETRY:
|
||||||
|
@ -479,7 +478,6 @@ static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *so
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
/* Custom node sockets where default_value is defined uses custom properties for storage. */
|
/* Custom node sockets where default_value is defined uses custom properties for storage. */
|
||||||
break;
|
break;
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
case SOCK_SHADER:
|
case SOCK_SHADER:
|
||||||
case SOCK_GEOMETRY:
|
case SOCK_GEOMETRY:
|
||||||
BLI_assert_unreachable();
|
BLI_assert_unreachable();
|
||||||
|
@ -923,7 +921,6 @@ static void lib_link_node_socket(BlendLibReader *reader, ID *self_id, bNodeSocke
|
||||||
case SOCK_BOOLEAN:
|
case SOCK_BOOLEAN:
|
||||||
case SOCK_INT:
|
case SOCK_INT:
|
||||||
case SOCK_STRING:
|
case SOCK_STRING:
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_SHADER:
|
case SOCK_SHADER:
|
||||||
case SOCK_GEOMETRY:
|
case SOCK_GEOMETRY:
|
||||||
|
@ -1016,7 +1013,6 @@ static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock)
|
||||||
case SOCK_BOOLEAN:
|
case SOCK_BOOLEAN:
|
||||||
case SOCK_INT:
|
case SOCK_INT:
|
||||||
case SOCK_STRING:
|
case SOCK_STRING:
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_SHADER:
|
case SOCK_SHADER:
|
||||||
case SOCK_GEOMETRY:
|
case SOCK_GEOMETRY:
|
||||||
|
@ -1705,7 +1701,6 @@ static void socket_id_user_increment(bNodeSocket *sock)
|
||||||
case SOCK_BOOLEAN:
|
case SOCK_BOOLEAN:
|
||||||
case SOCK_INT:
|
case SOCK_INT:
|
||||||
case SOCK_STRING:
|
case SOCK_STRING:
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_SHADER:
|
case SOCK_SHADER:
|
||||||
case SOCK_GEOMETRY:
|
case SOCK_GEOMETRY:
|
||||||
|
@ -1751,7 +1746,6 @@ static bool socket_id_user_decrement(bNodeSocket *sock)
|
||||||
case SOCK_BOOLEAN:
|
case SOCK_BOOLEAN:
|
||||||
case SOCK_INT:
|
case SOCK_INT:
|
||||||
case SOCK_STRING:
|
case SOCK_STRING:
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_SHADER:
|
case SOCK_SHADER:
|
||||||
case SOCK_GEOMETRY:
|
case SOCK_GEOMETRY:
|
||||||
|
@ -1804,7 +1798,6 @@ void nodeModifySocketType(bNodeTree *ntree,
|
||||||
case SOCK_SHADER:
|
case SOCK_SHADER:
|
||||||
case SOCK_BOOLEAN:
|
case SOCK_BOOLEAN:
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
case SOCK_OBJECT:
|
case SOCK_OBJECT:
|
||||||
case SOCK_IMAGE:
|
case SOCK_IMAGE:
|
||||||
case SOCK_GEOMETRY:
|
case SOCK_GEOMETRY:
|
||||||
|
@ -1944,7 +1937,6 @@ const char *nodeStaticSocketType(const int type, const int subtype)
|
||||||
case SOCK_MATERIAL:
|
case SOCK_MATERIAL:
|
||||||
return "NodeSocketMaterial";
|
return "NodeSocketMaterial";
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2024,7 +2016,6 @@ const char *nodeStaticSocketInterfaceType(const int type, const int subtype)
|
||||||
case SOCK_MATERIAL:
|
case SOCK_MATERIAL:
|
||||||
return "NodeSocketInterfaceMaterial";
|
return "NodeSocketInterfaceMaterial";
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2060,7 +2051,6 @@ const char *nodeStaticSocketLabel(const int type, const int /*subtype*/)
|
||||||
case SOCK_MATERIAL:
|
case SOCK_MATERIAL:
|
||||||
return "Material";
|
return "Material";
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2582,7 +2572,6 @@ static void *socket_value_storage(bNodeSocket &socket)
|
||||||
case SOCK_STRING:
|
case SOCK_STRING:
|
||||||
/* We don't want do this now! */
|
/* We don't want do this now! */
|
||||||
return nullptr;
|
return nullptr;
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
case SOCK_SHADER:
|
case SOCK_SHADER:
|
||||||
case SOCK_GEOMETRY:
|
case SOCK_GEOMETRY:
|
||||||
|
|
|
@ -705,22 +705,15 @@ bool BKE_texture_dependsOnTime(const Tex *texture)
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void BKE_texture_get_value_ex(const Scene *scene,
|
void BKE_texture_get_value_ex(Tex *texture,
|
||||||
Tex *texture,
|
|
||||||
const float *tex_co,
|
const float *tex_co,
|
||||||
TexResult *texres,
|
TexResult *texres,
|
||||||
ImagePool *pool,
|
ImagePool *pool,
|
||||||
bool use_color_management)
|
bool use_color_management)
|
||||||
{
|
{
|
||||||
int result_type;
|
|
||||||
bool do_color_manage = false;
|
|
||||||
|
|
||||||
if (scene && use_color_management) {
|
|
||||||
do_color_manage = BKE_scene_check_color_management_enabled(scene);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* no node textures for now */
|
/* no node textures for now */
|
||||||
result_type = multitex_ext_safe(texture, tex_co, texres, pool, do_color_manage, false);
|
const int result_type = multitex_ext_safe(
|
||||||
|
texture, tex_co, texres, pool, use_color_management, false);
|
||||||
|
|
||||||
/* if the texture gave an RGB value, we assume it didn't give a valid
|
/* if the texture gave an RGB value, we assume it didn't give a valid
|
||||||
* intensity, since this is in the context of modifiers don't use perceptual color conversion.
|
* intensity, since this is in the context of modifiers don't use perceptual color conversion.
|
||||||
|
@ -734,13 +727,12 @@ void BKE_texture_get_value_ex(const Scene *scene,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_texture_get_value(const Scene *scene,
|
void BKE_texture_get_value(Tex *texture,
|
||||||
Tex *texture,
|
|
||||||
const float *tex_co,
|
const float *tex_co,
|
||||||
TexResult *texres,
|
TexResult *texres,
|
||||||
bool use_color_management)
|
bool use_color_management)
|
||||||
{
|
{
|
||||||
BKE_texture_get_value_ex(scene, texture, tex_co, texres, nullptr, use_color_management);
|
BKE_texture_get_value_ex(texture, tex_co, texres, nullptr, use_color_management);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void texture_nodes_fetch_images_for_pool(Tex *texture, bNodeTree *ntree, ImagePool *pool)
|
static void texture_nodes_fetch_images_for_pool(Tex *texture, bNodeTree *ntree, ImagePool *pool)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* \ingroup bke
|
* \ingroup bke
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
@ -23,9 +24,12 @@
|
||||||
|
|
||||||
#include "BLI_bitmap_draw_2d.h"
|
#include "BLI_bitmap_draw_2d.h"
|
||||||
#include "BLI_ghash.h"
|
#include "BLI_ghash.h"
|
||||||
|
#include "BLI_hash.hh"
|
||||||
#include "BLI_listbase.h"
|
#include "BLI_listbase.h"
|
||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_math_base.h"
|
#include "BLI_math_base.h"
|
||||||
|
#include "BLI_math_vector.h"
|
||||||
|
#include "BLI_math_vector_types.hh"
|
||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
#include "BLI_string_utils.h"
|
#include "BLI_string_utils.h"
|
||||||
#include "BLI_threads.h"
|
#include "BLI_threads.h"
|
||||||
|
@ -2197,6 +2201,66 @@ void BKE_tracking_camera_principal_point_pixel_set(MovieClip *clip,
|
||||||
principal_point_pixel, frame_width, frame_height, camera->principal_point);
|
principal_point_pixel, frame_width, frame_height, camera->principal_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BKE_tracking_camera_distortion_equal(const MovieTrackingCamera *a,
|
||||||
|
const MovieTrackingCamera *b)
|
||||||
|
{
|
||||||
|
if (a->pixel_aspect != b->pixel_aspect || a->focal != b->focal ||
|
||||||
|
!equals_v2v2(a->principal_point, b->principal_point))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a->distortion_model != b->distortion_model) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (a->distortion_model) {
|
||||||
|
case TRACKING_DISTORTION_MODEL_POLYNOMIAL:
|
||||||
|
return a->k1 == b->k1 && a->k2 == b->k2 && a->k3 == b->k3;
|
||||||
|
case TRACKING_DISTORTION_MODEL_DIVISION:
|
||||||
|
return a->division_k1 == b->division_k1 && a->division_k2 == b->division_k2;
|
||||||
|
case TRACKING_DISTORTION_MODEL_NUKE:
|
||||||
|
return a->nuke_k1 == b->nuke_k1 && a->nuke_k2 == b->nuke_k2;
|
||||||
|
case TRACKING_DISTORTION_MODEL_BROWN:
|
||||||
|
return a->brown_k1 == b->brown_k1 && a->brown_k2 == b->brown_k2 &&
|
||||||
|
a->brown_k3 == b->brown_k3 && a->brown_k4 == b->brown_k4 &&
|
||||||
|
a->brown_p1 == b->brown_p1 && a->brown_p2 == b->brown_p2;
|
||||||
|
}
|
||||||
|
|
||||||
|
BLI_assert_unreachable();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t BKE_tracking_camera_distortion_hash(const MovieTrackingCamera *camera)
|
||||||
|
{
|
||||||
|
using namespace blender;
|
||||||
|
switch (camera->distortion_model) {
|
||||||
|
case TRACKING_DISTORTION_MODEL_POLYNOMIAL:
|
||||||
|
return get_default_hash_4(camera->distortion_model,
|
||||||
|
float2(camera->pixel_aspect, camera->focal),
|
||||||
|
float2(camera->principal_point),
|
||||||
|
float3(camera->k1, camera->k2, camera->k3));
|
||||||
|
case TRACKING_DISTORTION_MODEL_DIVISION:
|
||||||
|
return get_default_hash_4(camera->distortion_model,
|
||||||
|
float2(camera->pixel_aspect, camera->focal),
|
||||||
|
float2(camera->principal_point),
|
||||||
|
float2(camera->division_k1, camera->division_k2));
|
||||||
|
case TRACKING_DISTORTION_MODEL_NUKE:
|
||||||
|
return get_default_hash_4(camera->distortion_model,
|
||||||
|
float2(camera->pixel_aspect, camera->focal),
|
||||||
|
float2(camera->principal_point),
|
||||||
|
float2(camera->nuke_k1, camera->nuke_k2));
|
||||||
|
case TRACKING_DISTORTION_MODEL_BROWN:
|
||||||
|
return get_default_hash_4(
|
||||||
|
float2(camera->pixel_aspect, camera->focal),
|
||||||
|
float2(camera->principal_point),
|
||||||
|
float4(camera->brown_k1, camera->brown_k2, camera->brown_k3, camera->brown_k4),
|
||||||
|
float2(camera->brown_p1, camera->brown_p2));
|
||||||
|
}
|
||||||
|
|
||||||
|
BLI_assert_unreachable();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* --------------------------------------------------------------------
|
/* --------------------------------------------------------------------
|
||||||
* (Un)distortion.
|
* (Un)distortion.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -205,8 +205,8 @@ eFileAttributes BLI_file_attributes(const char *path);
|
||||||
* Usage of this function is strongly discouraged as it is not thread safe. It will likely cause
|
* Usage of this function is strongly discouraged as it is not thread safe. It will likely cause
|
||||||
* issues if there is an operation on another thread that does not expect the current working
|
* issues if there is an operation on another thread that does not expect the current working
|
||||||
* directory to change. This has been added to support USDZ export, which has a problematic
|
* directory to change. This has been added to support USDZ export, which has a problematic
|
||||||
* "feature" described in this issue https://projects.blender.org/blender/blender/issues/99807. It
|
* "feature" described in this issue #99807. It will be removed if it is possible to resolve
|
||||||
* will be removed if it is possible to resolve that issue upstream in the USD library.
|
* that issue upstream in the USD library.
|
||||||
*
|
*
|
||||||
* \return true on success, false otherwise.
|
* \return true on success, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -91,6 +91,11 @@ template<typename T> inline T floor(const T &a)
|
||||||
return std::floor(a);
|
return std::floor(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T> inline T round(const T &a)
|
||||||
|
{
|
||||||
|
return std::round(a);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repeats the saw-tooth pattern even on negative numbers.
|
* Repeats the saw-tooth pattern even on negative numbers.
|
||||||
* ex: `mod_periodic(-3, 4) = 1`, `mod(-3, 4)= -3`
|
* ex: `mod_periodic(-3, 4) = 1`, `mod(-3, 4)= -3`
|
||||||
|
@ -127,6 +132,20 @@ template<typename T> inline T sqrt(const T &a)
|
||||||
return std::sqrt(a);
|
return std::sqrt(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Inverse value.
|
||||||
|
* If the input is zero the output is NaN. */
|
||||||
|
template<typename T> inline T rcp(const T &a)
|
||||||
|
{
|
||||||
|
return T(1) / a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Inverse value.
|
||||||
|
* If the input is zero the output is zero. */
|
||||||
|
template<typename T> inline T safe_rcp(const T &a)
|
||||||
|
{
|
||||||
|
return a ? T(1) / a : T(0);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T> inline T cos(const T &a)
|
template<typename T> inline T cos(const T &a)
|
||||||
{
|
{
|
||||||
return std::cos(a);
|
return std::cos(a);
|
||||||
|
|
|
@ -111,7 +111,7 @@ template<typename T, int Size>
|
||||||
{
|
{
|
||||||
VecBase<T, Size> result = a;
|
VecBase<T, Size> result = a;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = std::clamp(result[i], min[i], max[i]);
|
result[i] = math::clamp(result[i], min[i], max[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ template<typename T, int Size>
|
||||||
{
|
{
|
||||||
VecBase<T, Size> result = a;
|
VecBase<T, Size> result = a;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = std::clamp(result[i], min, max);
|
result[i] = math::clamp(result[i], min, max);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ template<typename T, int Size>
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
BLI_assert(b[i] != 0);
|
BLI_assert(b[i] != 0);
|
||||||
result[i] = std::fmod(a[i], b[i]);
|
result[i] = math::mod(a[i], b[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ template<typename T, int Size>
|
||||||
BLI_assert(b != 0);
|
BLI_assert(b != 0);
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = std::fmod(a[i], b);
|
result[i] = math::mod(a[i], b);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ template<typename T, int Size>
|
||||||
{
|
{
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = (b[i] != 0) ? std::fmod(a[i], b[i]) : 0;
|
result[i] = (b[i] != 0) ? math::mod(a[i], b[i]) : 0;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ template<typename T, int Size>
|
||||||
}
|
}
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = std::fmod(a[i], b);
|
result[i] = math::mod(a[i], b);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ template<typename T, int Size>
|
||||||
{
|
{
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = std::pow(x[i], y);
|
result[i] = math::pow(x[i], y);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ template<typename T, int Size>
|
||||||
{
|
{
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = std::pow(x[i], y[i]);
|
result[i] = math::pow(x[i], y[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ template<typename T, int Size>
|
||||||
{
|
{
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = std::floor(a[i]);
|
result[i] = math::floor(a[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ template<typename T, int Size>
|
||||||
{
|
{
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = std::round(a[i]);
|
result[i] = math::round(a[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,62 @@ template<typename T, int Size>
|
||||||
{
|
{
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = std::ceil(a[i]);
|
result[i] = math::ceil(a[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per-element square root.
|
||||||
|
* Negative elements are evaluated to NaN.
|
||||||
|
*/
|
||||||
|
template<typename T, int Size>
|
||||||
|
[[nodiscard]] inline VecBase<T, Size> sqrt(const VecBase<T, Size> &a)
|
||||||
|
{
|
||||||
|
VecBase<T, Size> result;
|
||||||
|
for (int i = 0; i < Size; i++) {
|
||||||
|
result[i] = math::sqrt(a[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per-element square root.
|
||||||
|
* Negative elements are evaluated to zero.
|
||||||
|
*/
|
||||||
|
template<typename T, int Size>
|
||||||
|
[[nodiscard]] inline VecBase<T, Size> safe_sqrt(const VecBase<T, Size> &a)
|
||||||
|
{
|
||||||
|
VecBase<T, Size> result;
|
||||||
|
for (int i = 0; i < Size; i++) {
|
||||||
|
result[i] = a[i] >= T(0) ? math ::sqrt(a[i]) : T(0);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per-element inverse.
|
||||||
|
* Zero elements are evaluated to NaN.
|
||||||
|
*/
|
||||||
|
template<typename T, int Size> [[nodiscard]] inline VecBase<T, Size> rcp(const VecBase<T, Size> &a)
|
||||||
|
{
|
||||||
|
VecBase<T, Size> result;
|
||||||
|
for (int i = 0; i < Size; i++) {
|
||||||
|
result[i] = math::rcp(a[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per-element inverse.
|
||||||
|
* Zero elements are evaluated to zero.
|
||||||
|
*/
|
||||||
|
template<typename T, int Size>
|
||||||
|
[[nodiscard]] inline VecBase<T, Size> safe_rcp(const VecBase<T, Size> &a)
|
||||||
|
{
|
||||||
|
VecBase<T, Size> result;
|
||||||
|
for (int i = 0; i < Size; i++) {
|
||||||
|
result[i] = math::safe_rcp(a[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +361,7 @@ template<typename T, int Size>
|
||||||
{
|
{
|
||||||
VecBase<T, Size> result;
|
VecBase<T, Size> result;
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
result[i] = a[i] - std::floor(a[i]);
|
result[i] = math::fract(a[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -332,9 +387,9 @@ template<typename T, int Size>
|
||||||
*/
|
*/
|
||||||
template<typename T, int Size> [[nodiscard]] inline T length_manhattan(const VecBase<T, Size> &a)
|
template<typename T, int Size> [[nodiscard]] inline T length_manhattan(const VecBase<T, Size> &a)
|
||||||
{
|
{
|
||||||
T result = std::abs(a[0]);
|
T result = math::abs(a[0]);
|
||||||
for (int i = 1; i < Size; i++) {
|
for (int i = 1; i < Size; i++) {
|
||||||
result += std::abs(a[i]);
|
result += math::abs(a[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -346,7 +401,7 @@ template<typename T, int Size> [[nodiscard]] inline T length_squared(const VecBa
|
||||||
|
|
||||||
template<typename T, int Size> [[nodiscard]] inline T length(const VecBase<T, Size> &a)
|
template<typename T, int Size> [[nodiscard]] inline T length(const VecBase<T, Size> &a)
|
||||||
{
|
{
|
||||||
return std::sqrt(length_squared(a));
|
return math::sqrt(length_squared(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return true if each individual column is unit scaled. Mainly for assert usage. */
|
/** Return true if each individual column is unit scaled. Mainly for assert usage. */
|
||||||
|
@ -356,8 +411,8 @@ template<typename T, int Size> [[nodiscard]] inline bool is_unit_scale(const Vec
|
||||||
* normalized and in the case we don't want NAN to be raising asserts since there
|
* normalized and in the case we don't want NAN to be raising asserts since there
|
||||||
* is nothing to be done in that case. */
|
* is nothing to be done in that case. */
|
||||||
const T test_unit = math::length_squared(v);
|
const T test_unit = math::length_squared(v);
|
||||||
return (!(std::abs(test_unit - T(1)) >= AssertUnitEpsilon<T>::value) ||
|
return (!(math::abs(test_unit - T(1)) >= AssertUnitEpsilon<T>::value) ||
|
||||||
!(std::abs(test_unit) >= AssertUnitEpsilon<T>::value));
|
!(math::abs(test_unit) >= AssertUnitEpsilon<T>::value));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, int Size>
|
template<typename T, int Size>
|
||||||
|
@ -593,7 +648,7 @@ template<typename T, int Size>
|
||||||
const T epsilon = T(0))
|
const T epsilon = T(0))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Size; i++) {
|
for (int i = 0; i < Size; i++) {
|
||||||
if (std::abs(a[i] - b[i]) > epsilon) {
|
if (math::abs(a[i] - b[i]) > epsilon) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,7 @@ static float BLI_convexhull_aabb_fit_hull_2d(const float (*points_hull)[2], int
|
||||||
i_prev = i;
|
i_prev = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (area_best != FLT_MAX) ? atan2f(dvec_best[0], dvec_best[1]) : 0.0f;
|
return (area_best != FLT_MAX) ? (float)atan2(dvec_best[0], dvec_best[1]) : 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], int n)
|
float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], int n)
|
||||||
|
|
|
@ -136,4 +136,40 @@ TEST(math_vector, Sign)
|
||||||
EXPECT_FLOAT_EQ(result.z, 0);
|
EXPECT_FLOAT_EQ(result.z, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(math_vector, sqrt)
|
||||||
|
{
|
||||||
|
const float3 a(1.0f, 4.0f, 9.0f);
|
||||||
|
const float3 result = math::sqrt(a);
|
||||||
|
EXPECT_NEAR(result.x, 1.0f, 1e-6f);
|
||||||
|
EXPECT_NEAR(result.y, 2.0f, 1e-6f);
|
||||||
|
EXPECT_NEAR(result.z, 3.0f, 1e-6f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(math_vector, safe_sqrt)
|
||||||
|
{
|
||||||
|
const float3 a(1.0f, -4.0f, 9.0f);
|
||||||
|
const float3 result = math::safe_sqrt(a);
|
||||||
|
EXPECT_NEAR(result.x, 1.0f, 1e-6f);
|
||||||
|
EXPECT_NEAR(result.y, 0.0f, 1e-6f);
|
||||||
|
EXPECT_NEAR(result.z, 3.0f, 1e-6f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(math_vector, rcp)
|
||||||
|
{
|
||||||
|
const float3 a(1.0f, 2.0f, 4.0f);
|
||||||
|
const float3 result = math::rcp(a);
|
||||||
|
EXPECT_NEAR(result.x, 1.0f, 1e-6f);
|
||||||
|
EXPECT_NEAR(result.y, 0.5f, 1e-6f);
|
||||||
|
EXPECT_NEAR(result.z, 0.25f, 1e-6f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(math_vector, safe_rcp)
|
||||||
|
{
|
||||||
|
const float3 a(1.0f, 0.0f, 4.0f);
|
||||||
|
const float3 result = math::safe_rcp(a);
|
||||||
|
EXPECT_NEAR(result.x, 1.0f, 1e-6f);
|
||||||
|
EXPECT_NEAR(result.y, 0.0f, 1e-6f);
|
||||||
|
EXPECT_NEAR(result.z, 0.25f, 1e-6f);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace blender::tests
|
} // namespace blender::tests
|
||||||
|
|
|
@ -47,8 +47,8 @@ typedef struct WorkspaceConfigFileData {
|
||||||
|
|
||||||
typedef enum eBlenFileType {
|
typedef enum eBlenFileType {
|
||||||
BLENFILETYPE_BLEND = 1,
|
BLENFILETYPE_BLEND = 1,
|
||||||
/* BLENFILETYPE_PUB = 2, */ /* UNUSED */
|
// BLENFILETYPE_PUB = 2, /* UNUSED */
|
||||||
/* BLENFILETYPE_RUNTIME = 3, */ /* UNUSED */
|
// BLENFILETYPE_RUNTIME = 3, /* UNUSED */
|
||||||
} eBlenFileType;
|
} eBlenFileType;
|
||||||
|
|
||||||
typedef struct BlendFileData {
|
typedef struct BlendFileData {
|
||||||
|
@ -59,17 +59,24 @@ typedef struct BlendFileData {
|
||||||
int globalf;
|
int globalf;
|
||||||
char filepath[1024]; /* 1024 = FILE_MAX */
|
char filepath[1024]; /* 1024 = FILE_MAX */
|
||||||
|
|
||||||
struct bScreen *curscreen; /* TODO: think this isn't needed anymore? */
|
/** TODO: think this isn't needed anymore? */
|
||||||
|
struct bScreen *curscreen;
|
||||||
struct Scene *curscene;
|
struct Scene *curscene;
|
||||||
struct ViewLayer *cur_view_layer; /* layer to activate in workspaces when reading without UI */
|
/** Layer to activate in workspaces when reading without UI. */
|
||||||
|
struct ViewLayer *cur_view_layer;
|
||||||
|
|
||||||
eBlenFileType type;
|
eBlenFileType type;
|
||||||
} BlendFileData;
|
} BlendFileData;
|
||||||
|
|
||||||
/** Data used by WM readfile code and BKE's setup_app_data to handle the complex preservation logic
|
/**
|
||||||
* of WindowManager and other UI data-blocks across blendfile reading prcess. */
|
* Data used by WM readfile code and BKE's setup_app_data to handle the complex preservation logic
|
||||||
|
* of WindowManager and other UI data-blocks across blend-file reading process.
|
||||||
|
*/
|
||||||
typedef struct BlendFileReadWMSetupData {
|
typedef struct BlendFileReadWMSetupData {
|
||||||
struct wmWindowManager *old_wm; /** The existing WM when filereading process is started. */
|
/** The existing WM when filereading process is started. */
|
||||||
|
struct wmWindowManager *old_wm;
|
||||||
|
|
||||||
|
bool is_read_homefile;
|
||||||
} BlendFileReadWMSetupData;
|
} BlendFileReadWMSetupData;
|
||||||
|
|
||||||
struct BlendFileReadParams {
|
struct BlendFileReadParams {
|
||||||
|
@ -81,10 +88,10 @@ struct BlendFileReadParams {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct BlendFileReadReport {
|
typedef struct BlendFileReadReport {
|
||||||
/* General reports handling. */
|
/** General reports handling. */
|
||||||
struct ReportList *reports;
|
struct ReportList *reports;
|
||||||
|
|
||||||
/* Timing information. */
|
/** Timing information. */
|
||||||
struct {
|
struct {
|
||||||
double whole;
|
double whole;
|
||||||
double libraries;
|
double libraries;
|
||||||
|
@ -93,38 +100,44 @@ typedef struct BlendFileReadReport {
|
||||||
double lib_overrides_recursive_resync;
|
double lib_overrides_recursive_resync;
|
||||||
} duration;
|
} duration;
|
||||||
|
|
||||||
/* Count information. */
|
/** Count information. */
|
||||||
struct {
|
struct {
|
||||||
/* Some numbers of IDs that ended up in a specific state, or required some specific process
|
/**
|
||||||
* during this file read. */
|
* Some numbers of IDs that ended up in a specific state, or required some specific process
|
||||||
|
* during this file read.
|
||||||
|
*/
|
||||||
int missing_libraries;
|
int missing_libraries;
|
||||||
int missing_linked_id;
|
int missing_linked_id;
|
||||||
/* Some sub-categories of the above `missing_linked_id` counter. */
|
/** Some sub-categories of the above `missing_linked_id` counter. */
|
||||||
int missing_obdata;
|
int missing_obdata;
|
||||||
int missing_obproxies;
|
int missing_obproxies;
|
||||||
|
|
||||||
/* Number of root override IDs that were resynced. */
|
/** Number of root override IDs that were resynced. */
|
||||||
int resynced_lib_overrides;
|
int resynced_lib_overrides;
|
||||||
|
|
||||||
/* Number of proxies converted to library overrides. */
|
/** Number of proxies converted to library overrides. */
|
||||||
int proxies_to_lib_overrides_success;
|
int proxies_to_lib_overrides_success;
|
||||||
/* Number of proxies that failed to convert to library overrides. */
|
/** Number of proxies that failed to convert to library overrides. */
|
||||||
int proxies_to_lib_overrides_failures;
|
int proxies_to_lib_overrides_failures;
|
||||||
/* Number of sequencer strips that were not read because were in non-supported channels. */
|
/** Number of sequencer strips that were not read because were in non-supported channels. */
|
||||||
int sequence_strips_skipped;
|
int sequence_strips_skipped;
|
||||||
} count;
|
} count;
|
||||||
|
|
||||||
/* Number of libraries which had overrides that needed to be resynced, and a single linked list
|
/**
|
||||||
* of those. */
|
* Number of libraries which had overrides that needed to be resynced,
|
||||||
|
* and a single linked list of those.
|
||||||
|
*/
|
||||||
int resynced_lib_overrides_libraries_count;
|
int resynced_lib_overrides_libraries_count;
|
||||||
bool do_resynced_lib_overrides_libraries_list;
|
bool do_resynced_lib_overrides_libraries_list;
|
||||||
struct LinkNode *resynced_lib_overrides_libraries;
|
struct LinkNode *resynced_lib_overrides_libraries;
|
||||||
} BlendFileReadReport;
|
} BlendFileReadReport;
|
||||||
|
|
||||||
/* skip reading some data-block types (may want to skip screen data too). */
|
/** Skip reading some data-block types (may want to skip screen data too). */
|
||||||
typedef enum eBLOReadSkip {
|
typedef enum eBLOReadSkip {
|
||||||
BLO_READ_SKIP_NONE = 0,
|
BLO_READ_SKIP_NONE = 0,
|
||||||
|
/** Skip #BLO_CODE_USER blocks. */
|
||||||
BLO_READ_SKIP_USERDEF = (1 << 0),
|
BLO_READ_SKIP_USERDEF = (1 << 0),
|
||||||
|
/** Only read #BLO_CODE_USER (and associated data). */
|
||||||
BLO_READ_SKIP_DATA = (1 << 1),
|
BLO_READ_SKIP_DATA = (1 << 1),
|
||||||
/** Do not attempt to re-use IDs from old bmain for unchanged ones in case of undo. */
|
/** Do not attempt to re-use IDs from old bmain for unchanged ones in case of undo. */
|
||||||
BLO_READ_SKIP_UNDO_OLD_MAIN = (1 << 2),
|
BLO_READ_SKIP_UNDO_OLD_MAIN = (1 << 2),
|
||||||
|
@ -133,7 +146,7 @@ ENUM_OPERATORS(eBLOReadSkip, BLO_READ_SKIP_UNDO_OLD_MAIN)
|
||||||
#define BLO_READ_SKIP_ALL (BLO_READ_SKIP_USERDEF | BLO_READ_SKIP_DATA)
|
#define BLO_READ_SKIP_ALL (BLO_READ_SKIP_USERDEF | BLO_READ_SKIP_DATA)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a blender file from a pathname. The function returns NULL
|
* Open a blender file from a `filepath`. The function returns NULL
|
||||||
* and sets a report in the list if it cannot open the file.
|
* and sets a report in the list if it cannot open the file.
|
||||||
*
|
*
|
||||||
* \param filepath: The path of the file to open.
|
* \param filepath: The path of the file to open.
|
||||||
|
@ -189,10 +202,12 @@ typedef struct BLODataBlockInfo {
|
||||||
char name[64]; /* MAX_NAME */
|
char name[64]; /* MAX_NAME */
|
||||||
struct AssetMetaData *asset_data;
|
struct AssetMetaData *asset_data;
|
||||||
bool free_asset_data;
|
bool free_asset_data;
|
||||||
/* Optimization: Tag data-blocks for which we know there is no preview.
|
/**
|
||||||
|
* Optimization: Tag data-blocks for which we know there is no preview.
|
||||||
* Knowing this can be used to skip the (potentially expensive) preview loading process. If this
|
* Knowing this can be used to skip the (potentially expensive) preview loading process. If this
|
||||||
* is set to true it means we looked for a preview and couldn't find one. False may mean that
|
* is set to true it means we looked for a preview and couldn't find one. False may mean that
|
||||||
* either no preview was found, or that it wasn't looked for in the first place. */
|
* either no preview was found, or that it wasn't looked for in the first place.
|
||||||
|
*/
|
||||||
bool no_preview_found;
|
bool no_preview_found;
|
||||||
} BLODataBlockInfo;
|
} BLODataBlockInfo;
|
||||||
|
|
||||||
|
@ -336,9 +351,11 @@ typedef enum eBLOLibLinkFlags {
|
||||||
BLO_LIBLINK_FORCE_INDIRECT = 1 << 17,
|
BLO_LIBLINK_FORCE_INDIRECT = 1 << 17,
|
||||||
/** Set fake user on appended IDs. */
|
/** Set fake user on appended IDs. */
|
||||||
BLO_LIBLINK_APPEND_SET_FAKEUSER = 1 << 19,
|
BLO_LIBLINK_APPEND_SET_FAKEUSER = 1 << 19,
|
||||||
/** Append (make local) also indirect dependencies of appended IDs coming from other libraries.
|
/**
|
||||||
|
* Append (make local) also indirect dependencies of appended IDs coming from other libraries.
|
||||||
* NOTE: All IDs (including indirectly linked ones) coming from the same initial library are
|
* NOTE: All IDs (including indirectly linked ones) coming from the same initial library are
|
||||||
* always made local. */
|
* always made local.
|
||||||
|
*/
|
||||||
BLO_LIBLINK_APPEND_RECURSIVE = 1 << 20,
|
BLO_LIBLINK_APPEND_RECURSIVE = 1 << 20,
|
||||||
/** Try to re-use previously appended matching ID on new append. */
|
/** Try to re-use previously appended matching ID on new append. */
|
||||||
BLO_LIBLINK_APPEND_LOCAL_ID_REUSE = 1 << 21,
|
BLO_LIBLINK_APPEND_LOCAL_ID_REUSE = 1 << 21,
|
||||||
|
@ -437,7 +454,7 @@ typedef struct TempLibraryContext {
|
||||||
struct LibraryLink_Params liblink_params;
|
struct LibraryLink_Params liblink_params;
|
||||||
struct Library *lib;
|
struct Library *lib;
|
||||||
|
|
||||||
/* The ID datablock that was loaded. Is NULL if loading failed. */
|
/** The ID datablock that was loaded. Is NULL if loading failed. */
|
||||||
struct ID *temp_id;
|
struct ID *temp_id;
|
||||||
} TempLibraryContext;
|
} TempLibraryContext;
|
||||||
|
|
||||||
|
@ -485,7 +502,7 @@ void BLO_expand_main(void *fdhandle, struct Main *mainvar);
|
||||||
void BLO_update_defaults_startup_blend(struct Main *bmain, const char *app_template);
|
void BLO_update_defaults_startup_blend(struct Main *bmain, const char *app_template);
|
||||||
void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char *app_template);
|
void BLO_update_defaults_workspace(struct WorkSpace *workspace, const char *app_template);
|
||||||
|
|
||||||
/* Disable unwanted experimental feature settings on startup. */
|
/** Disable unwanted experimental feature settings on startup. */
|
||||||
void BLO_sanitize_experimental_features_userpref_blend(struct UserDef *userdef);
|
void BLO_sanitize_experimental_features_userpref_blend(struct UserDef *userdef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -498,8 +515,9 @@ void BLO_sanitize_experimental_features_userpref_blend(struct UserDef *userdef);
|
||||||
*/
|
*/
|
||||||
struct BlendThumbnail *BLO_thumbnail_from_file(const char *filepath);
|
struct BlendThumbnail *BLO_thumbnail_from_file(const char *filepath);
|
||||||
|
|
||||||
/* datafiles (generated theme) */
|
/** Default theme, see: `release/datafiles/userdef/userdef_default_theme.c`. */
|
||||||
extern const struct bTheme U_theme_default;
|
extern const struct bTheme U_theme_default;
|
||||||
|
/** Default preferences, defined by: `release/datafiles/userdef/userdef_default.c`. */
|
||||||
extern const struct UserDef U_default;
|
extern const struct UserDef U_default;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -126,7 +126,7 @@
|
||||||
* - read associated 'direct data'
|
* - read associated 'direct data'
|
||||||
* - link direct data (internal and to LibBlock)
|
* - link direct data (internal and to LibBlock)
|
||||||
* - read #FileGlobal
|
* - read #FileGlobal
|
||||||
* - read #USER data, only when indicated (file is `~/.config/blender/X.XX/config/userpref.blend`)
|
* - read #USER data, only when indicated (file is `~/.config/blender/X.X/config/userpref.blend`)
|
||||||
* - free file
|
* - free file
|
||||||
* - per Library (per #Main)
|
* - per Library (per #Main)
|
||||||
* - read file
|
* - read file
|
||||||
|
|
|
@ -206,7 +206,7 @@ bool BLO_memfile_write_file(MemFile *memfile, const char *filepath)
|
||||||
MemFileChunk *chunk;
|
MemFileChunk *chunk;
|
||||||
int file, oflags;
|
int file, oflags;
|
||||||
|
|
||||||
/* NOTE: This is currently used for autosave and 'quit.blend',
|
/* NOTE: This is currently used for auto-save and `quit.blend`,
|
||||||
* where _not_ following symlinks is OK,
|
* where _not_ following symlinks is OK,
|
||||||
* however if this is ever executed explicitly by the user,
|
* however if this is ever executed explicitly by the user,
|
||||||
* we may want to allow writing to symlinks.
|
* we may want to allow writing to symlinks.
|
||||||
|
|
|
@ -2184,46 +2184,6 @@ static void versioning_replace_legacy_mix_rgb_node(bNodeTree *ntree)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void versioning_replace_legacy_glossy_node(bNodeTree *ntree)
|
|
||||||
{
|
|
||||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
|
||||||
if (node->type == SH_NODE_BSDF_GLOSSY_LEGACY) {
|
|
||||||
strcpy(node->idname, "ShaderNodeBsdfAnisotropic");
|
|
||||||
node->type = SH_NODE_BSDF_GLOSSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void versioning_remove_microfacet_sharp_distribution(bNodeTree *ntree)
|
|
||||||
{
|
|
||||||
/* Find all glossy, glass and refraction BSDF nodes that have their distribution
|
|
||||||
* set to SHARP and set them to GGX, disconnect any link to the Roughness input
|
|
||||||
* and set its value to zero. */
|
|
||||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
|
||||||
if (!ELEM(node->type, SH_NODE_BSDF_GLOSSY, SH_NODE_BSDF_GLASS, SH_NODE_BSDF_REFRACTION)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (node->custom1 != SHD_GLOSSY_SHARP_DEPRECATED) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
node->custom1 = SHD_GLOSSY_GGX;
|
|
||||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
|
||||||
if (!STREQ(socket->identifier, "Roughness")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (socket->link != nullptr) {
|
|
||||||
nodeRemLink(ntree, socket->link);
|
|
||||||
}
|
|
||||||
bNodeSocketValueFloat *socket_value = (bNodeSocketValueFloat *)socket->default_value;
|
|
||||||
socket_value->value = 0.0f;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void version_fix_image_format_copy(Main *bmain, ImageFormatData *format)
|
static void version_fix_image_format_copy(Main *bmain, ImageFormatData *format)
|
||||||
{
|
{
|
||||||
/* Fix bug where curves in image format were not properly copied to file output
|
/* Fix bug where curves in image format were not properly copied to file output
|
||||||
|
@ -4461,26 +4421,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
if (!MAIN_VERSION_ATLEAST(bmain, 306, 11)) {
|
||||||
* Versioning code until next subversion bump goes here.
|
BKE_animdata_main_cb(bmain, version_liboverride_nla_frame_start_end, NULL);
|
||||||
*
|
|
||||||
* \note Be sure to check when bumping the version:
|
|
||||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
|
||||||
* - "versioning_userdef.c", #do_versions_theme
|
|
||||||
*
|
|
||||||
* \note Keep this message at the bottom of the function.
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
/* Keep this block, even when empty. */
|
|
||||||
|
|
||||||
/* Convert anisotropic BSDF node to glossy BSDF. */
|
|
||||||
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
|
|
||||||
versioning_replace_legacy_glossy_node(ntree);
|
|
||||||
versioning_remove_microfacet_sharp_distribution(ntree);
|
|
||||||
}
|
|
||||||
FOREACH_NODETREE_END;
|
|
||||||
|
|
||||||
BKE_animdata_main_cb(bmain, version_liboverride_nla_frame_start_end, nullptr);
|
|
||||||
|
|
||||||
/* Store simulation bake directory in geometry nodes modifier. */
|
/* Store simulation bake directory in geometry nodes modifier. */
|
||||||
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
|
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
|
||||||
|
@ -4519,4 +4461,18 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Versioning code until next subversion bump goes here.
|
||||||
|
*
|
||||||
|
* \note Be sure to check when bumping the version:
|
||||||
|
* - #do_versions_after_linking_300 in this file.
|
||||||
|
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||||
|
* - "versioning_userdef.c", #do_versions_theme
|
||||||
|
*
|
||||||
|
* \note Keep this message at the bottom of the function.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
/* Keep this block, even when empty. */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,23 @@
|
||||||
|
|
||||||
// static CLG_LogRef LOG = {"blo.readfile.doversion"};
|
// static CLG_LogRef LOG = {"blo.readfile.doversion"};
|
||||||
|
|
||||||
void do_versions_after_linking_400(FileData * /*fd*/, Main *bmain)
|
void do_versions_after_linking_400(FileData * /*fd*/, Main * /*bmain*/)
|
||||||
{
|
{
|
||||||
UNUSED_VARS(bmain);
|
/**
|
||||||
|
* Versioning code until next subversion bump goes here.
|
||||||
|
*
|
||||||
|
* \note Be sure to check when bumping the version:
|
||||||
|
* - #blo_do_versions_400 in this file.
|
||||||
|
* - "versioning_cycles.cc", #blo_do_versions_cycles
|
||||||
|
* - "versioning_cycles.cc", #do_versions_after_linking_cycles
|
||||||
|
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||||
|
* - "versioning_userdef.c", #do_versions_theme
|
||||||
|
*
|
||||||
|
* \note Keep this message at the bottom of the function.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
/* Keep this block, even when empty. */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void version_mesh_legacy_to_struct_of_array_format(Mesh &mesh)
|
static void version_mesh_legacy_to_struct_of_array_format(Mesh &mesh)
|
||||||
|
@ -101,6 +115,46 @@ static void version_geometry_nodes_add_realize_instance_nodes(bNodeTree *ntree)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void versioning_replace_legacy_glossy_node(bNodeTree *ntree)
|
||||||
|
{
|
||||||
|
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||||
|
if (node->type == SH_NODE_BSDF_GLOSSY_LEGACY) {
|
||||||
|
strcpy(node->idname, "ShaderNodeBsdfAnisotropic");
|
||||||
|
node->type = SH_NODE_BSDF_GLOSSY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void versioning_remove_microfacet_sharp_distribution(bNodeTree *ntree)
|
||||||
|
{
|
||||||
|
/* Find all glossy, glass and refraction BSDF nodes that have their distribution
|
||||||
|
* set to SHARP and set them to GGX, disconnect any link to the Roughness input
|
||||||
|
* and set its value to zero. */
|
||||||
|
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||||
|
if (!ELEM(node->type, SH_NODE_BSDF_GLOSSY, SH_NODE_BSDF_GLASS, SH_NODE_BSDF_REFRACTION)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (node->custom1 != SHD_GLOSSY_SHARP_DEPRECATED) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
node->custom1 = SHD_GLOSSY_GGX;
|
||||||
|
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
||||||
|
if (!STREQ(socket->identifier, "Roughness")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (socket->link != nullptr) {
|
||||||
|
nodeRemLink(ntree, socket->link);
|
||||||
|
}
|
||||||
|
bNodeSocketValueFloat *socket_value = (bNodeSocketValueFloat *)socket->default_value;
|
||||||
|
socket_value->value = 0.0f;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
|
void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
|
||||||
{
|
{
|
||||||
if (!MAIN_VERSION_ATLEAST(bmain, 400, 1)) {
|
if (!MAIN_VERSION_ATLEAST(bmain, 400, 1)) {
|
||||||
|
@ -124,7 +178,9 @@ void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MAIN_VERSION_ATLEAST(bmain, 400, 4)) {
|
/* 400 4 did not require any do_version here. */
|
||||||
|
|
||||||
|
if (!MAIN_VERSION_ATLEAST(bmain, 400, 5)) {
|
||||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||||
#define SCE_SNAP_PROJECT (1 << 3)
|
#define SCE_SNAP_PROJECT (1 << 3)
|
||||||
if (scene->toolsettings->snap_flag & SCE_SNAP_PROJECT) {
|
if (scene->toolsettings->snap_flag & SCE_SNAP_PROJECT) {
|
||||||
|
@ -138,12 +194,22 @@ void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
|
||||||
* Versioning code until next subversion bump goes here.
|
* Versioning code until next subversion bump goes here.
|
||||||
*
|
*
|
||||||
* \note Be sure to check when bumping the version:
|
* \note Be sure to check when bumping the version:
|
||||||
|
* - #do_versions_after_linking_400 in this file.
|
||||||
|
* - "versioning_cycles.cc", #blo_do_versions_cycles
|
||||||
|
* - "versioning_cycles.cc", #do_versions_after_linking_cycles
|
||||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||||
* - "versioning_userdef.c", #do_versions_theme
|
* - "versioning_userdef.c", #do_versions_theme
|
||||||
*
|
*
|
||||||
* \note Keep this message at the bottom of the function.
|
* \note Keep this message at the bottom of the function.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
/* Convert anisotropic BSDF node to glossy BSDF. */
|
||||||
|
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
|
||||||
|
versioning_replace_legacy_glossy_node(ntree);
|
||||||
|
versioning_remove_microfacet_sharp_distribution(ntree);
|
||||||
|
}
|
||||||
|
FOREACH_NODETREE_END;
|
||||||
|
|
||||||
/* Keep this block, even when empty. */
|
/* Keep this block, even when empty. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,12 @@
|
||||||
* - write library block
|
* - write library block
|
||||||
* - per LibBlock
|
* - per LibBlock
|
||||||
* - write the ID of LibBlock
|
* - write the ID of LibBlock
|
||||||
* - write #TEST (#RenderInfo struct. 128x128 blend file preview is optional).
|
* - write #BLO_CODE_GLOB (#RenderInfo struct. 128x128 blend file preview is optional).
|
||||||
* - write #GLOB (#FileGlobal struct) (some global vars).
|
* - write #BLO_CODE_GLOB (#FileGlobal struct) (some global vars).
|
||||||
* - write #DNA1 (#SDNA struct)
|
* - write #BLO_CODE_DNA1 (#SDNA struct)
|
||||||
* - write #USER (#UserDef struct) if filename is `~/.config/blender/X.XX/config/startup.blend`.
|
* - write #BLO_CODE_USER (#UserDef struct) for file paths:
|
||||||
|
- #BLENDER_STARTUP_FILE (on UNIX `~/.config/blender/X.X/config/startup.blend`).
|
||||||
|
- #BLENDER_USERPREF_FILE (on UNIX `~/.config/blender/X.X/config/userpref.blend`).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
@ -971,10 +973,10 @@ static void write_libraries(WriteData *wd, Main *main)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* To be able to restore 'quit.blend' and temp saves,
|
/* To be able to restore `quit.blend` and temp saves,
|
||||||
* the packed blend has to be in undo buffers... */
|
* the packed blend has to be in undo buffers... */
|
||||||
/* XXX needs rethink, just like save UI in undo files now -
|
/* XXX needs rethink, just like save UI in undo files now -
|
||||||
* would be nice to append things only for the 'quit.blend' and temp saves. */
|
* would be nice to append things only for the `quit.blend` and temp saves. */
|
||||||
if (found_one) {
|
if (found_one) {
|
||||||
/* Not overridable. */
|
/* Not overridable. */
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,7 @@ const char *BLT_pgettext(const char *msgctxt, const char *msgid)
|
||||||
bool BLT_translate(void)
|
bool BLT_translate(void)
|
||||||
{
|
{
|
||||||
#ifdef WITH_INTERNATIONAL
|
#ifdef WITH_INTERNATIONAL
|
||||||
return true;
|
return BLI_thread_is_main();
|
||||||
/* return BLI_thread_is_main(); */
|
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct Render;
|
||||||
|
|
||||||
/* Keep ascii art. */
|
/* Keep ascii art. */
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
|
|
||||||
|
@ -294,6 +296,9 @@ extern "C" {
|
||||||
* It can be executed during editing (blenkernel/node.cc) or rendering
|
* It can be executed during editing (blenkernel/node.cc) or rendering
|
||||||
* (renderer/pipeline.c)
|
* (renderer/pipeline.c)
|
||||||
*
|
*
|
||||||
|
* \param render: [struct Render]
|
||||||
|
* Render instance for GPU context.
|
||||||
|
*
|
||||||
* \param render_data: [struct RenderData]
|
* \param render_data: [struct RenderData]
|
||||||
* Render data for this composite, this won't always belong to a scene.
|
* Render data for this composite, this won't always belong to a scene.
|
||||||
*
|
*
|
||||||
|
@ -305,10 +310,10 @@ extern "C" {
|
||||||
* (true) or editing (false).
|
* (true) or editing (false).
|
||||||
* based on this setting the system will work differently:
|
* based on this setting the system will work differently:
|
||||||
* - during rendering only Composite & the File output node will be calculated
|
* - during rendering only Composite & the File output node will be calculated
|
||||||
* \see NodeOperation.is_output_program(int rendering) of the specific operations
|
* \see NodeOperation.is_output_program(bool rendering) of the specific operations
|
||||||
*
|
*
|
||||||
* - during editing all output nodes will be calculated
|
* - during editing all output nodes will be calculated
|
||||||
* \see NodeOperation.is_output_program(int rendering) of the specific operations
|
* \see NodeOperation.is_output_program(bool rendering) of the specific operations
|
||||||
*
|
*
|
||||||
* - another quality setting can be used bNodeTree.
|
* - another quality setting can be used bNodeTree.
|
||||||
* The quality is determined by the bNodeTree fields.
|
* The quality is determined by the bNodeTree fields.
|
||||||
|
@ -326,10 +331,11 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
|
|
||||||
void COM_execute(RenderData *render_data,
|
void COM_execute(Render *render,
|
||||||
|
RenderData *render_data,
|
||||||
Scene *scene,
|
Scene *scene,
|
||||||
bNodeTree *node_tree,
|
bNodeTree *node_tree,
|
||||||
int rendering,
|
bool rendering,
|
||||||
const char *view_name);
|
const char *view_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include "COM_WorkScheduler.h"
|
#include "COM_WorkScheduler.h"
|
||||||
#include "COM_compositor.h"
|
#include "COM_compositor.h"
|
||||||
|
|
||||||
|
#include "RE_compositor.hh"
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
bool is_initialized = false;
|
bool is_initialized = false;
|
||||||
ThreadMutex mutex;
|
ThreadMutex mutex;
|
||||||
|
@ -47,10 +49,11 @@ static void compositor_reset_node_tree_status(bNodeTree *node_tree)
|
||||||
node_tree->runtime->stats_draw(node_tree->runtime->sdh, IFACE_("Compositing"));
|
node_tree->runtime->stats_draw(node_tree->runtime->sdh, IFACE_("Compositing"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void COM_execute(RenderData *render_data,
|
void COM_execute(Render *render,
|
||||||
|
RenderData *render_data,
|
||||||
Scene *scene,
|
Scene *scene,
|
||||||
bNodeTree *node_tree,
|
bNodeTree *node_tree,
|
||||||
int rendering,
|
bool rendering,
|
||||||
const char *view_name)
|
const char *view_name)
|
||||||
{
|
{
|
||||||
/* Initialize mutex, TODO: this mutex init is actually not thread safe and
|
/* Initialize mutex, TODO: this mutex init is actually not thread safe and
|
||||||
|
@ -73,26 +76,41 @@ void COM_execute(RenderData *render_data,
|
||||||
compositor_init_node_previews(render_data, node_tree);
|
compositor_init_node_previews(render_data, node_tree);
|
||||||
compositor_reset_node_tree_status(node_tree);
|
compositor_reset_node_tree_status(node_tree);
|
||||||
|
|
||||||
/* Initialize workscheduler. */
|
if (U.experimental.use_full_frame_compositor &&
|
||||||
const bool use_opencl = (node_tree->flag & NTREE_COM_OPENCL) != 0;
|
node_tree->execution_mode == NTREE_EXECUTION_MODE_REALTIME)
|
||||||
blender::compositor::WorkScheduler::initialize(use_opencl, BKE_render_num_threads(render_data));
|
{
|
||||||
|
/* Realtime GPU compositor. */
|
||||||
|
|
||||||
/* Execute. */
|
/* TODO: add persistence and depsgraph updates for better performance. */
|
||||||
const bool twopass = (node_tree->flag & NTREE_TWO_PASS) && !rendering;
|
blender::render::RealtimeCompositor compositor(
|
||||||
if (twopass) {
|
*render, *scene, *render_data, *node_tree, rendering, view_name);
|
||||||
blender::compositor::ExecutionSystem fast_pass(
|
compositor.execute();
|
||||||
render_data, scene, node_tree, rendering, true, view_name);
|
|
||||||
fast_pass.execute();
|
|
||||||
|
|
||||||
if (node_tree->runtime->test_break(node_tree->runtime->tbh)) {
|
|
||||||
BLI_mutex_unlock(&g_compositor.mutex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* Tiled and Full Frame compositors. */
|
||||||
|
|
||||||
blender::compositor::ExecutionSystem system(
|
/* Initialize workscheduler. */
|
||||||
render_data, scene, node_tree, rendering, false, view_name);
|
const bool use_opencl = (node_tree->flag & NTREE_COM_OPENCL) != 0;
|
||||||
system.execute();
|
blender::compositor::WorkScheduler::initialize(use_opencl,
|
||||||
|
BKE_render_num_threads(render_data));
|
||||||
|
|
||||||
|
/* Execute. */
|
||||||
|
const bool twopass = (node_tree->flag & NTREE_TWO_PASS) && !rendering;
|
||||||
|
if (twopass) {
|
||||||
|
blender::compositor::ExecutionSystem fast_pass(
|
||||||
|
render_data, scene, node_tree, rendering, true, view_name);
|
||||||
|
fast_pass.execute();
|
||||||
|
|
||||||
|
if (node_tree->runtime->test_break(node_tree->runtime->tbh)) {
|
||||||
|
BLI_mutex_unlock(&g_compositor.mutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
blender::compositor::ExecutionSystem system(
|
||||||
|
render_data, scene, node_tree, rendering, false, view_name);
|
||||||
|
system.execute();
|
||||||
|
}
|
||||||
|
|
||||||
BLI_mutex_unlock(&g_compositor.mutex);
|
BLI_mutex_unlock(&g_compositor.mutex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ set(INC
|
||||||
../../blenkernel
|
../../blenkernel
|
||||||
../../blenlib
|
../../blenlib
|
||||||
../../blentranslation
|
../../blentranslation
|
||||||
|
../../draw
|
||||||
../../gpu
|
../../gpu
|
||||||
../../imbuf
|
../../imbuf
|
||||||
../../makesdna
|
../../makesdna
|
||||||
|
@ -17,6 +18,9 @@ set(INC
|
||||||
../../render
|
../../render
|
||||||
../../gpu/intern
|
../../gpu/intern
|
||||||
../../../../intern/guardedalloc
|
../../../../intern/guardedalloc
|
||||||
|
|
||||||
|
# dna_type_offsets.h
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
|
||||||
)
|
)
|
||||||
|
|
||||||
set(INC_SYS
|
set(INC_SYS
|
||||||
|
@ -74,6 +78,7 @@ set(SRC
|
||||||
|
|
||||||
cached_resources/intern/cached_mask.cc
|
cached_resources/intern/cached_mask.cc
|
||||||
cached_resources/intern/cached_texture.cc
|
cached_resources/intern/cached_texture.cc
|
||||||
|
cached_resources/intern/distortion_grid.cc
|
||||||
cached_resources/intern/morphological_distance_feather_weights.cc
|
cached_resources/intern/morphological_distance_feather_weights.cc
|
||||||
cached_resources/intern/ocio_color_space_conversion_shader.cc
|
cached_resources/intern/ocio_color_space_conversion_shader.cc
|
||||||
cached_resources/intern/smaa_precomputed_textures.cc
|
cached_resources/intern/smaa_precomputed_textures.cc
|
||||||
|
@ -83,6 +88,7 @@ set(SRC
|
||||||
cached_resources/COM_cached_mask.hh
|
cached_resources/COM_cached_mask.hh
|
||||||
cached_resources/COM_cached_resource.hh
|
cached_resources/COM_cached_resource.hh
|
||||||
cached_resources/COM_cached_texture.hh
|
cached_resources/COM_cached_texture.hh
|
||||||
|
cached_resources/COM_distortion_grid.hh
|
||||||
cached_resources/COM_morphological_distance_feather_weights.hh
|
cached_resources/COM_morphological_distance_feather_weights.hh
|
||||||
cached_resources/COM_ocio_color_space_conversion_shader.hh
|
cached_resources/COM_ocio_color_space_conversion_shader.hh
|
||||||
cached_resources/COM_smaa_precomputed_textures.hh
|
cached_resources/COM_smaa_precomputed_textures.hh
|
||||||
|
@ -133,6 +139,7 @@ set(GLSL_SRC
|
||||||
shaders/compositor_morphological_distance_feather.glsl
|
shaders/compositor_morphological_distance_feather.glsl
|
||||||
shaders/compositor_morphological_distance_threshold.glsl
|
shaders/compositor_morphological_distance_threshold.glsl
|
||||||
shaders/compositor_morphological_step.glsl
|
shaders/compositor_morphological_step.glsl
|
||||||
|
shaders/compositor_movie_distortion.glsl
|
||||||
shaders/compositor_normalize.glsl
|
shaders/compositor_normalize.glsl
|
||||||
shaders/compositor_parallel_reduction.glsl
|
shaders/compositor_parallel_reduction.glsl
|
||||||
shaders/compositor_plane_deform.glsl
|
shaders/compositor_plane_deform.glsl
|
||||||
|
@ -234,6 +241,7 @@ set(SRC_SHADER_CREATE_INFOS
|
||||||
shaders/infos/compositor_morphological_distance_info.hh
|
shaders/infos/compositor_morphological_distance_info.hh
|
||||||
shaders/infos/compositor_morphological_distance_threshold_info.hh
|
shaders/infos/compositor_morphological_distance_threshold_info.hh
|
||||||
shaders/infos/compositor_morphological_step_info.hh
|
shaders/infos/compositor_morphological_step_info.hh
|
||||||
|
shaders/infos/compositor_movie_distortion_info.hh
|
||||||
shaders/infos/compositor_normalize_info.hh
|
shaders/infos/compositor_normalize_info.hh
|
||||||
shaders/infos/compositor_parallel_reduction_info.hh
|
shaders/infos/compositor_parallel_reduction_info.hh
|
||||||
shaders/infos/compositor_plane_deform_info.hh
|
shaders/infos/compositor_plane_deform_info.hh
|
||||||
|
|
|
@ -42,8 +42,17 @@ class Context {
|
||||||
public:
|
public:
|
||||||
Context(TexturePool &texture_pool);
|
Context(TexturePool &texture_pool);
|
||||||
|
|
||||||
/* Get the active compositing scene. */
|
/* Get the node tree used for compositing. */
|
||||||
virtual const Scene *get_scene() const = 0;
|
virtual const bNodeTree &get_node_tree() const = 0;
|
||||||
|
|
||||||
|
/* True if compositor should do write file outputs, false if only running for viewing. */
|
||||||
|
virtual bool use_file_output() const = 0;
|
||||||
|
|
||||||
|
/* True if color management should be used for texture evaluation. */
|
||||||
|
virtual bool use_texture_color_management() const = 0;
|
||||||
|
|
||||||
|
/* Get the render settings for compositing. */
|
||||||
|
virtual const RenderData &get_render_data() const = 0;
|
||||||
|
|
||||||
/* Get the width and height of the render passes and of the output texture returned by the
|
/* Get the width and height of the render passes and of the output texture returned by the
|
||||||
* get_input_texture and get_output_texture methods respectively. */
|
* get_input_texture and get_output_texture methods respectively. */
|
||||||
|
@ -63,7 +72,7 @@ class Context {
|
||||||
|
|
||||||
/* Get the texture where the given render pass is stored. This should be called by the Render
|
/* Get the texture where the given render pass is stored. This should be called by the Render
|
||||||
* Layer node to populate its outputs. */
|
* Layer node to populate its outputs. */
|
||||||
virtual GPUTexture *get_input_texture(int view_layer, eScenePassType pass_type) = 0;
|
virtual GPUTexture *get_input_texture(int view_layer, const char *pass_name) = 0;
|
||||||
|
|
||||||
/* Get the name of the view currently being rendered. */
|
/* Get the name of the view currently being rendered. */
|
||||||
virtual StringRef get_view_name() = 0;
|
virtual StringRef get_view_name() = 0;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "COM_cached_mask.hh"
|
#include "COM_cached_mask.hh"
|
||||||
#include "COM_cached_texture.hh"
|
#include "COM_cached_texture.hh"
|
||||||
|
#include "COM_distortion_grid.hh"
|
||||||
#include "COM_morphological_distance_feather_weights.hh"
|
#include "COM_morphological_distance_feather_weights.hh"
|
||||||
#include "COM_ocio_color_space_conversion_shader.hh"
|
#include "COM_ocio_color_space_conversion_shader.hh"
|
||||||
#include "COM_smaa_precomputed_textures.hh"
|
#include "COM_smaa_precomputed_textures.hh"
|
||||||
|
@ -45,6 +46,7 @@ class StaticCacheManager {
|
||||||
CachedMaskContainer cached_masks;
|
CachedMaskContainer cached_masks;
|
||||||
SMAAPrecomputedTexturesContainer smaa_precomputed_textures;
|
SMAAPrecomputedTexturesContainer smaa_precomputed_textures;
|
||||||
OCIOColorSpaceConversionShaderContainer ocio_color_space_conversion_shaders;
|
OCIOColorSpaceConversionShaderContainer ocio_color_space_conversion_shaders;
|
||||||
|
DistortionGridContainer distortion_grids;
|
||||||
|
|
||||||
/* Reset the cache manager by deleting the cached resources that are no longer needed because
|
/* Reset the cache manager by deleting the cached resources that are no longer needed because
|
||||||
* they weren't used in the last evaluation and prepare the remaining cached resources to track
|
* they weren't used in the last evaluation and prepare the remaining cached resources to track
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include "GPU_texture.h"
|
#include "GPU_texture.h"
|
||||||
|
|
||||||
#include "DNA_scene_types.h"
|
|
||||||
#include "DNA_texture_types.h"
|
#include "DNA_texture_types.h"
|
||||||
|
|
||||||
#include "COM_cached_resource.hh"
|
#include "COM_cached_resource.hh"
|
||||||
|
@ -49,7 +48,7 @@ class CachedTexture : public CachedResource {
|
||||||
GPUTexture *value_texture_ = nullptr;
|
GPUTexture *value_texture_ = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CachedTexture(Tex *texture, const Scene *scene, int2 size, float2 offset, float2 scale);
|
CachedTexture(Tex *texture, bool use_color_management, int2 size, float2 offset, float2 scale);
|
||||||
|
|
||||||
~CachedTexture();
|
~CachedTexture();
|
||||||
|
|
||||||
|
@ -74,8 +73,12 @@ class CachedTextureContainer : CachedResourceContainer {
|
||||||
* CachedTexture cached resource with the given parameters in the container, if one exists,
|
* CachedTexture cached resource with the given parameters in the container, if one exists,
|
||||||
* return it, otherwise, return a newly created one and add it to the container. In both cases,
|
* return it, otherwise, return a newly created one and add it to the container. In both cases,
|
||||||
* tag the cached resource as needed to keep it cached for the next evaluation. */
|
* tag the cached resource as needed to keep it cached for the next evaluation. */
|
||||||
CachedTexture &get(
|
CachedTexture &get(Context &context,
|
||||||
Context &context, Tex *texture, const Scene *scene, int2 size, float2 offset, float2 scale);
|
Tex *texture,
|
||||||
|
bool use_color_management,
|
||||||
|
int2 size,
|
||||||
|
float2 offset,
|
||||||
|
float2 scale);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace blender::realtime_compositor
|
} // namespace blender::realtime_compositor
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "BLI_map.hh"
|
||||||
|
#include "BLI_math_vector_types.hh"
|
||||||
|
|
||||||
|
#include "GPU_shader.h"
|
||||||
|
#include "GPU_texture.h"
|
||||||
|
|
||||||
|
#include "DNA_movieclip_types.h"
|
||||||
|
|
||||||
|
#include "COM_cached_resource.hh"
|
||||||
|
|
||||||
|
namespace blender::realtime_compositor {
|
||||||
|
|
||||||
|
enum class DistortionType : uint8_t {
|
||||||
|
Distort,
|
||||||
|
Undistort,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Distortion Grid Key.
|
||||||
|
*/
|
||||||
|
class DistortionGridKey {
|
||||||
|
public:
|
||||||
|
MovieTrackingCamera camera;
|
||||||
|
int2 size;
|
||||||
|
DistortionType type;
|
||||||
|
int2 calibration_size;
|
||||||
|
|
||||||
|
DistortionGridKey(MovieTrackingCamera camera,
|
||||||
|
int2 size,
|
||||||
|
DistortionType type,
|
||||||
|
int2 calibration_size);
|
||||||
|
|
||||||
|
uint64_t hash() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const DistortionGridKey &a, const DistortionGridKey &b);
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------------------------------
|
||||||
|
* Distortion Grid.
|
||||||
|
*
|
||||||
|
* A cached resource that computes and caches a GPU texture containing the normalized coordinates
|
||||||
|
* after applying the camera distortion of a given movie clip tracking camera. See the constructor
|
||||||
|
* for more information. */
|
||||||
|
class DistortionGrid : public CachedResource {
|
||||||
|
private:
|
||||||
|
GPUTexture *texture_ = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/* The calibration size is the size of the image where the tracking camera was calibrated, this
|
||||||
|
* is the size of the movie clip in most cases. */
|
||||||
|
DistortionGrid(MovieClip *movie_clip, int2 size, DistortionType type, int2 calibration_size);
|
||||||
|
|
||||||
|
~DistortionGrid();
|
||||||
|
|
||||||
|
void bind_as_texture(GPUShader *shader, const char *texture_name) const;
|
||||||
|
|
||||||
|
void unbind_as_texture() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Distortion Grid Container.
|
||||||
|
*/
|
||||||
|
class DistortionGridContainer : CachedResourceContainer {
|
||||||
|
private:
|
||||||
|
Map<DistortionGridKey, std::unique_ptr<DistortionGrid>> map_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void reset() override;
|
||||||
|
|
||||||
|
/* Check if there is an available DistortionGrid cached resource with the given parameters in the
|
||||||
|
* container, if one exists, return it, otherwise, return a newly created one and add it to the
|
||||||
|
* container. In both cases, tag the cached resource as needed to keep it cached for the next
|
||||||
|
* evaluation. */
|
||||||
|
DistortionGrid &get(MovieClip *movie_clip, int2 size, DistortionType type, int frame_number);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace blender::realtime_compositor
|
|
@ -51,7 +51,7 @@ bool operator==(const CachedTextureKey &a, const CachedTextureKey &b)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CachedTexture::CachedTexture(
|
CachedTexture::CachedTexture(
|
||||||
Tex *texture, const Scene *scene, int2 size, float2 offset, float2 scale)
|
Tex *texture, bool use_color_management, int2 size, float2 offset, float2 scale)
|
||||||
{
|
{
|
||||||
ImagePool *image_pool = BKE_image_pool_new();
|
ImagePool *image_pool = BKE_image_pool_new();
|
||||||
BKE_texture_fetch_images_for_pool(texture, image_pool);
|
BKE_texture_fetch_images_for_pool(texture, image_pool);
|
||||||
|
@ -67,7 +67,8 @@ CachedTexture::CachedTexture(
|
||||||
/* Note that it is expected that the offset is scaled by the scale. */
|
/* Note that it is expected that the offset is scaled by the scale. */
|
||||||
coordinates = (coordinates + offset) * scale;
|
coordinates = (coordinates + offset) * scale;
|
||||||
TexResult texture_result;
|
TexResult texture_result;
|
||||||
BKE_texture_get_value_ex(scene, texture, coordinates, &texture_result, image_pool, true);
|
BKE_texture_get_value_ex(
|
||||||
|
texture, coordinates, &texture_result, image_pool, use_color_management);
|
||||||
color_pixels[y * size.x + x] = float4(texture_result.trgba);
|
color_pixels[y * size.x + x] = float4(texture_result.trgba);
|
||||||
value_pixels[y * size.x + x] = texture_result.talpha ? texture_result.trgba[3] :
|
value_pixels[y * size.x + x] = texture_result.talpha ? texture_result.trgba[3] :
|
||||||
texture_result.tin;
|
texture_result.tin;
|
||||||
|
@ -131,8 +132,12 @@ void CachedTextureContainer::reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedTexture &CachedTextureContainer::get(
|
CachedTexture &CachedTextureContainer::get(Context &context,
|
||||||
Context &context, Tex *texture, const Scene *scene, int2 size, float2 offset, float2 scale)
|
Tex *texture,
|
||||||
|
bool use_color_management,
|
||||||
|
int2 size,
|
||||||
|
float2 offset,
|
||||||
|
float2 scale)
|
||||||
{
|
{
|
||||||
const CachedTextureKey key(size, offset, scale);
|
const CachedTextureKey key(size, offset, scale);
|
||||||
|
|
||||||
|
@ -143,8 +148,9 @@ CachedTexture &CachedTextureContainer::get(
|
||||||
cached_textures_for_id.clear();
|
cached_textures_for_id.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &cached_texture = *cached_textures_for_id.lookup_or_add_cb(
|
auto &cached_texture = *cached_textures_for_id.lookup_or_add_cb(key, [&]() {
|
||||||
key, [&]() { return std::make_unique<CachedTexture>(texture, scene, size, offset, scale); });
|
return std::make_unique<CachedTexture>(texture, use_color_management, size, offset, scale);
|
||||||
|
});
|
||||||
|
|
||||||
cached_texture.needed = true;
|
cached_texture.needed = true;
|
||||||
return cached_texture;
|
return cached_texture;
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "BLI_array.hh"
|
||||||
|
#include "BLI_hash.hh"
|
||||||
|
#include "BLI_index_range.hh"
|
||||||
|
#include "BLI_math_vector_types.hh"
|
||||||
|
#include "BLI_task.hh"
|
||||||
|
|
||||||
|
#include "DNA_defaults.h"
|
||||||
|
#include "DNA_movieclip_types.h"
|
||||||
|
#include "DNA_tracking_types.h"
|
||||||
|
|
||||||
|
#include "GPU_texture.h"
|
||||||
|
|
||||||
|
#include "BKE_movieclip.h"
|
||||||
|
#include "BKE_tracking.h"
|
||||||
|
|
||||||
|
#include "COM_distortion_grid.hh"
|
||||||
|
|
||||||
|
namespace blender::realtime_compositor {
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------
|
||||||
|
* Distortion Grid Key.
|
||||||
|
*/
|
||||||
|
|
||||||
|
DistortionGridKey::DistortionGridKey(MovieTrackingCamera camera,
|
||||||
|
int2 size,
|
||||||
|
DistortionType type,
|
||||||
|
int2 calibration_size)
|
||||||
|
: camera(camera), size(size), type(type), calibration_size(calibration_size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t DistortionGridKey::hash() const
|
||||||
|
{
|
||||||
|
return get_default_hash_4(
|
||||||
|
BKE_tracking_camera_distortion_hash(&camera), size, type, calibration_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const DistortionGridKey &a, const DistortionGridKey &b)
|
||||||
|
{
|
||||||
|
return BKE_tracking_camera_distortion_equal(&a.camera, &b.camera) && a.size == b.size &&
|
||||||
|
a.type == b.type && a.calibration_size == b.calibration_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------
|
||||||
|
* Distortion Grid.
|
||||||
|
*/
|
||||||
|
|
||||||
|
DistortionGrid::DistortionGrid(MovieClip *movie_clip,
|
||||||
|
int2 size,
|
||||||
|
DistortionType type,
|
||||||
|
int2 calibration_size)
|
||||||
|
{
|
||||||
|
MovieDistortion *distortion = BKE_tracking_distortion_new(
|
||||||
|
&movie_clip->tracking, calibration_size.x, calibration_size.y);
|
||||||
|
|
||||||
|
Array<float2> distortion_grid(size.x * size.y);
|
||||||
|
threading::parallel_for(IndexRange(size.y), 1, [&](const IndexRange sub_y_range) {
|
||||||
|
for (const int64_t y : sub_y_range) {
|
||||||
|
for (const int64_t x : IndexRange(size.x)) {
|
||||||
|
/* The tracking distortion functions expect the coordinates to be in the space of the image
|
||||||
|
* where the tracking camera was calibrated. So we first remap the coordinates into that
|
||||||
|
* space, apply the distortion, then remap back to the original coordinates space. This is
|
||||||
|
* done by dividing the by the size then multiplying by the calibration size, making sure
|
||||||
|
* to add 0.5 to evaluate at the center of pixels. */
|
||||||
|
float2 coordinates = ((float2(x, y) + 0.5f) / float2(size)) * float2(calibration_size);
|
||||||
|
|
||||||
|
if (type == DistortionType::Undistort) {
|
||||||
|
BKE_tracking_distortion_undistort_v2(distortion, coordinates, coordinates);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BKE_tracking_distortion_distort_v2(distortion, coordinates, coordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Note that we should remap the coordinates back into the original size by dividing by the
|
||||||
|
* calibration size and multiplying by the size, however, we skip the latter to store the
|
||||||
|
* coordinates in normalized form, since this is what the shader expects. */
|
||||||
|
distortion_grid[y * size.x + x] = coordinates / float2(calibration_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
BKE_tracking_distortion_free(distortion);
|
||||||
|
|
||||||
|
texture_ = GPU_texture_create_2d("Distortion Grid",
|
||||||
|
size.x,
|
||||||
|
size.y,
|
||||||
|
1,
|
||||||
|
GPU_RG16F,
|
||||||
|
GPU_TEXTURE_USAGE_SHADER_READ,
|
||||||
|
*distortion_grid.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
DistortionGrid::~DistortionGrid()
|
||||||
|
{
|
||||||
|
GPU_texture_free(texture_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DistortionGrid::bind_as_texture(GPUShader *shader, const char *texture_name) const
|
||||||
|
{
|
||||||
|
const int texture_image_unit = GPU_shader_get_sampler_binding(shader, texture_name);
|
||||||
|
GPU_texture_bind(texture_, texture_image_unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DistortionGrid::unbind_as_texture() const
|
||||||
|
{
|
||||||
|
GPU_texture_unbind(texture_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------
|
||||||
|
* Distortion Grid Container.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void DistortionGridContainer::reset()
|
||||||
|
{
|
||||||
|
/* First, delete all resources that are no longer needed. */
|
||||||
|
map_.remove_if([](auto item) { return !item.value->needed; });
|
||||||
|
|
||||||
|
/* Second, reset the needed status of the remaining resources to false to ready them to track
|
||||||
|
* their needed status for the next evaluation. */
|
||||||
|
for (auto &value : map_.values()) {
|
||||||
|
value->needed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int2 get_movie_clip_size(MovieClip *movie_clip, int frame_number)
|
||||||
|
{
|
||||||
|
MovieClipUser user = *DNA_struct_default_get(MovieClipUser);
|
||||||
|
BKE_movieclip_user_set_frame(&user, frame_number);
|
||||||
|
|
||||||
|
int2 size;
|
||||||
|
BKE_movieclip_get_size(movie_clip, &user, &size.x, &size.y);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
DistortionGrid &DistortionGridContainer::get(MovieClip *movie_clip,
|
||||||
|
int2 size,
|
||||||
|
DistortionType type,
|
||||||
|
int frame_number)
|
||||||
|
{
|
||||||
|
const int2 calibration_size = get_movie_clip_size(movie_clip, frame_number);
|
||||||
|
|
||||||
|
const DistortionGridKey key(movie_clip->tracking.camera, size, type, calibration_size);
|
||||||
|
|
||||||
|
auto &distortion_grid = *map_.lookup_or_add_cb(key, [&]() {
|
||||||
|
return std::make_unique<DistortionGrid>(movie_clip, size, type, calibration_size);
|
||||||
|
});
|
||||||
|
|
||||||
|
distortion_grid.needed = true;
|
||||||
|
return distortion_grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace blender::realtime_compositor
|
|
@ -23,18 +23,19 @@ int2 Context::get_compositing_region_size() const
|
||||||
|
|
||||||
float Context::get_render_percentage() const
|
float Context::get_render_percentage() const
|
||||||
{
|
{
|
||||||
return get_scene()->r.size / 100.0f;
|
return get_render_data().size / 100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Context::get_frame_number() const
|
int Context::get_frame_number() const
|
||||||
{
|
{
|
||||||
return get_scene()->r.cfra;
|
return get_render_data().cfra;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Context::get_time() const
|
float Context::get_time() const
|
||||||
{
|
{
|
||||||
const float frame_number = float(get_frame_number());
|
const float frame_number = float(get_frame_number());
|
||||||
const float frame_rate = float(get_scene()->r.frs_sec) / float(get_scene()->r.frs_sec_base);
|
const float frame_rate = float(get_render_data().frs_sec) /
|
||||||
|
float(get_render_data().frs_sec_base);
|
||||||
return frame_number / frame_rate;
|
return frame_number / frame_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ bool Evaluator::validate_node_tree()
|
||||||
|
|
||||||
void Evaluator::compile_and_evaluate()
|
void Evaluator::compile_and_evaluate()
|
||||||
{
|
{
|
||||||
derived_node_tree_ = std::make_unique<DerivedNodeTree>(*context_.get_scene()->nodetree);
|
derived_node_tree_ = std::make_unique<DerivedNodeTree>(context_.get_node_tree());
|
||||||
|
|
||||||
if (!validate_node_tree()) {
|
if (!validate_node_tree()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma BLENDER_REQUIRE(gpu_shader_compositor_texture_utilities.glsl)
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
|
||||||
|
imageStore(output_img, texel, texture(input_tx, texture_load(distortion_grid_tx, texel).xy));
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
#include "gpu_shader_create_info.hh"
|
||||||
|
|
||||||
|
GPU_SHADER_CREATE_INFO(compositor_movie_distortion)
|
||||||
|
.local_group_size(16, 16)
|
||||||
|
.sampler(0, ImageType::FLOAT_2D, "input_tx")
|
||||||
|
.sampler(1, ImageType::FLOAT_2D, "distortion_grid_tx")
|
||||||
|
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||||
|
.compute_source("compositor_movie_distortion.glsl")
|
||||||
|
.do_static_compilation(true);
|
|
@ -58,9 +58,24 @@ class Context : public realtime_compositor::Context {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const Scene *get_scene() const override
|
const bNodeTree &get_node_tree() const override
|
||||||
{
|
{
|
||||||
return DRW_context_state_get()->scene;
|
return *DRW_context_state_get()->scene->nodetree;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool use_file_output() const override
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool use_texture_color_management() const override
|
||||||
|
{
|
||||||
|
return BKE_scene_check_color_management_enabled(DRW_context_state_get()->scene);
|
||||||
|
}
|
||||||
|
|
||||||
|
const RenderData &get_render_data() const override
|
||||||
|
{
|
||||||
|
return DRW_context_state_get()->scene->r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int2 get_render_size() const override
|
int2 get_render_size() const override
|
||||||
|
@ -130,15 +145,20 @@ class Context : public realtime_compositor::Context {
|
||||||
return DRW_viewport_texture_list_get()->color;
|
return DRW_viewport_texture_list_get()->color;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUTexture *get_input_texture(int /*view_layer*/, eScenePassType /*pass_type*/) override
|
GPUTexture *get_input_texture(int view_layer, const char *pass_name) override
|
||||||
{
|
{
|
||||||
return get_output_texture();
|
if (view_layer == 0 && STREQ(pass_name, RE_PASSNAME_COMBINED)) {
|
||||||
|
return get_output_texture();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef get_view_name() override
|
StringRef get_view_name() override
|
||||||
{
|
{
|
||||||
const SceneRenderView *view = static_cast<SceneRenderView *>(
|
const SceneRenderView *view = static_cast<SceneRenderView *>(
|
||||||
BLI_findlink(&get_scene()->r.views, DRW_context_state_get()->v3d->multiview_eye));
|
BLI_findlink(&get_render_data().views, DRW_context_state_get()->v3d->multiview_eye));
|
||||||
return view->name;
|
return view->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -373,7 +373,9 @@ static void try_convert_single_object(Object &curves_ob,
|
||||||
|
|
||||||
HairKey &key = hair_keys[key_i];
|
HairKey &key = hair_keys[key_i];
|
||||||
copy_v3_v3(key.co, key_pos_ha);
|
copy_v3_v3(key.co, key_pos_ha);
|
||||||
key.time = 100.0f * key_i / float(hair_keys.size() - 1);
|
const float key_fac = key_i / float(hair_keys.size() - 1);
|
||||||
|
key.time = 100.0f * key_fac;
|
||||||
|
key.weight = 1.0f - key_fac;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,8 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
|
||||||
uiItemR(sub, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE);
|
uiItemR(sub, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE);
|
||||||
|
|
||||||
if (RNA_boolean_get(imfptr, "include_animations")) {
|
if (RNA_boolean_get(imfptr, "include_animations")) {
|
||||||
uiItemR(col, imfptr, "export_animation_transformation_type_selection", 0, nullptr, ICON_NONE);
|
uiItemR(
|
||||||
|
col, imfptr, "export_animation_transformation_type_selection", 0, nullptr, ICON_NONE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uiItemR(col, imfptr, "export_object_transformation_type_selection", 0, nullptr, ICON_NONE);
|
uiItemR(col, imfptr, "export_object_transformation_type_selection", 0, nullptr, ICON_NONE);
|
||||||
|
@ -317,7 +318,8 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
|
||||||
|
|
||||||
uiLayoutSetActive(row, include_animations && animation_type == BC_ANIMATION_EXPORT_SAMPLES);
|
uiLayoutSetActive(row, include_animations && animation_type == BC_ANIMATION_EXPORT_SAMPLES);
|
||||||
if (RNA_boolean_get(imfptr, "include_animations")) {
|
if (RNA_boolean_get(imfptr, "include_animations")) {
|
||||||
uiItemR(box, imfptr, "export_animation_transformation_type_selection", 0, nullptr, ICON_NONE);
|
uiItemR(
|
||||||
|
box, imfptr, "export_animation_transformation_type_selection", 0, nullptr, ICON_NONE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uiItemR(box, imfptr, "export_object_transformation_type_selection", 0, nullptr, ICON_NONE);
|
uiItemR(box, imfptr, "export_object_transformation_type_selection", 0, nullptr, ICON_NONE);
|
||||||
|
|
|
@ -86,7 +86,7 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator *op)
|
||||||
const int resolution = RNA_int_get(op->ptr, "resolution");
|
const int resolution = RNA_int_get(op->ptr, "resolution");
|
||||||
const float scale = RNA_float_get(op->ptr, "scale");
|
const float scale = RNA_float_get(op->ptr, "scale");
|
||||||
|
|
||||||
GpencilIOParams params {};
|
GpencilIOParams params{};
|
||||||
params.C = C;
|
params.C = C;
|
||||||
params.region = region;
|
params.region = region;
|
||||||
params.v3d = v3d;
|
params.v3d = v3d;
|
||||||
|
|
|
@ -1086,7 +1086,7 @@ static void shader_preview_texture(ShaderPreview *sp, Tex *tex, Scene *sce, Rend
|
||||||
/* Fill in image buffer. */
|
/* Fill in image buffer. */
|
||||||
float *rect_float = rv->combined_buffer.data;
|
float *rect_float = rv->combined_buffer.data;
|
||||||
float tex_coord[3] = {0.0f, 0.0f, 0.0f};
|
float tex_coord[3] = {0.0f, 0.0f, 0.0f};
|
||||||
bool color_manage = true;
|
bool color_manage = BKE_scene_check_color_management_enabled(sce);
|
||||||
|
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
/* Tex coords between -1.0f and 1.0f. */
|
/* Tex coords between -1.0f and 1.0f. */
|
||||||
|
@ -1097,7 +1097,7 @@ static void shader_preview_texture(ShaderPreview *sp, Tex *tex, Scene *sce, Rend
|
||||||
|
|
||||||
/* Evaluate texture at tex_coord. */
|
/* Evaluate texture at tex_coord. */
|
||||||
TexResult texres = {0};
|
TexResult texres = {0};
|
||||||
BKE_texture_get_value_ex(sce, tex, tex_coord, &texres, img_pool, color_manage);
|
BKE_texture_get_value_ex(tex, tex_coord, &texres, img_pool, color_manage);
|
||||||
copy_v4_fl4(rect_float,
|
copy_v4_fl4(rect_float,
|
||||||
texres.trgba[0],
|
texres.trgba[0],
|
||||||
texres.trgba[1],
|
texres.trgba[1],
|
||||||
|
|
|
@ -391,8 +391,7 @@ static int palette_color_add_exec(bContext *C, wmOperator * /*op*/)
|
||||||
PAINT_MODE_TEXTURE_3D,
|
PAINT_MODE_TEXTURE_3D,
|
||||||
PAINT_MODE_TEXTURE_2D,
|
PAINT_MODE_TEXTURE_2D,
|
||||||
PAINT_MODE_VERTEX,
|
PAINT_MODE_VERTEX,
|
||||||
PAINT_MODE_SCULPT))
|
PAINT_MODE_SCULPT)) {
|
||||||
{
|
|
||||||
copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
|
copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
|
||||||
color->value = 0.0;
|
color->value = 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1196,7 +1196,7 @@ static const float std_node_socket_colors[][4] = {
|
||||||
{0.78, 0.78, 0.16, 1.0}, /* SOCK_RGBA */
|
{0.78, 0.78, 0.16, 1.0}, /* SOCK_RGBA */
|
||||||
{0.39, 0.78, 0.39, 1.0}, /* SOCK_SHADER */
|
{0.39, 0.78, 0.39, 1.0}, /* SOCK_SHADER */
|
||||||
{0.80, 0.65, 0.84, 1.0}, /* SOCK_BOOLEAN */
|
{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, 0.0}, /* UNUSED */
|
||||||
{0.35, 0.55, 0.36, 1.0}, /* SOCK_INT */
|
{0.35, 0.55, 0.36, 1.0}, /* SOCK_INT */
|
||||||
{0.44, 0.70, 1.00, 1.0}, /* SOCK_STRING */
|
{0.44, 0.70, 1.00, 1.0}, /* SOCK_STRING */
|
||||||
{0.93, 0.62, 0.36, 1.0}, /* SOCK_OBJECT */
|
{0.93, 0.62, 0.36, 1.0}, /* SOCK_OBJECT */
|
||||||
|
|
|
@ -3327,6 +3327,12 @@ static bool realtime_compositor_is_in_use(const bContext &context)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (U.experimental.use_full_frame_compositor &&
|
||||||
|
scene->nodetree->execution_mode == NTREE_EXECUTION_MODE_REALTIME)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const Main *main = CTX_data_main(&context);
|
const Main *main = CTX_data_main(&context);
|
||||||
LISTBASE_FOREACH (const bScreen *, screen, &main->screens) {
|
LISTBASE_FOREACH (const bScreen *, screen, &main->screens) {
|
||||||
LISTBASE_FOREACH (const ScrArea *, area, &screen->areabase) {
|
LISTBASE_FOREACH (const ScrArea *, area, &screen->areabase) {
|
||||||
|
|
|
@ -95,6 +95,8 @@ struct CompoJob {
|
||||||
/* Evaluated state/ */
|
/* Evaluated state/ */
|
||||||
Depsgraph *compositor_depsgraph;
|
Depsgraph *compositor_depsgraph;
|
||||||
bNodeTree *localtree;
|
bNodeTree *localtree;
|
||||||
|
/* Render instance. */
|
||||||
|
Render *re;
|
||||||
/* Jon system integration. */
|
/* Jon system integration. */
|
||||||
const bool *stop;
|
const bool *stop;
|
||||||
bool *do_update;
|
bool *do_update;
|
||||||
|
@ -239,6 +241,9 @@ static void compo_initjob(void *cjv)
|
||||||
if (cj->recalc_flags) {
|
if (cj->recalc_flags) {
|
||||||
compo_tag_output_nodes(cj->localtree, cj->recalc_flags);
|
compo_tag_output_nodes(cj->localtree, cj->recalc_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cj->re = RE_NewSceneRender(scene);
|
||||||
|
RE_gl_context_create(cj->re);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called before redraw notifiers, it moves finished previews over. */
|
/* Called before redraw notifiers, it moves finished previews over. */
|
||||||
|
@ -286,17 +291,19 @@ static void compo_startjob(void *cjv,
|
||||||
BKE_callback_exec_id(cj->bmain, &scene->id, BKE_CB_EVT_COMPOSITE_PRE);
|
BKE_callback_exec_id(cj->bmain, &scene->id, BKE_CB_EVT_COMPOSITE_PRE);
|
||||||
|
|
||||||
if ((cj->scene->r.scemode & R_MULTIVIEW) == 0) {
|
if ((cj->scene->r.scemode & R_MULTIVIEW) == 0) {
|
||||||
ntreeCompositExecTree(cj->scene, ntree, &cj->scene->r, false, true, "");
|
ntreeCompositExecTree(cj->re, cj->scene, ntree, &cj->scene->r, false, true, "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LISTBASE_FOREACH (SceneRenderView *, srv, &scene->r.views) {
|
LISTBASE_FOREACH (SceneRenderView *, srv, &scene->r.views) {
|
||||||
if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) {
|
if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ntreeCompositExecTree(cj->scene, ntree, &cj->scene->r, false, true, srv->name);
|
ntreeCompositExecTree(cj->re, cj->scene, ntree, &cj->scene->r, false, true, srv->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RE_gl_context_destroy(cj->re);
|
||||||
|
|
||||||
ntree->runtime->test_break = nullptr;
|
ntree->runtime->test_break = nullptr;
|
||||||
ntree->runtime->stats_draw = nullptr;
|
ntree->runtime->stats_draw = nullptr;
|
||||||
ntree->runtime->progress = nullptr;
|
ntree->runtime->progress = nullptr;
|
||||||
|
|
|
@ -2222,8 +2222,6 @@ void node_insert_on_link_flags(Main &bmain, SpaceNode &snode)
|
||||||
static int get_main_socket_priority(const bNodeSocket *socket)
|
static int get_main_socket_priority(const bNodeSocket *socket)
|
||||||
{
|
{
|
||||||
switch ((eNodeSocketDatatype)socket->type) {
|
switch ((eNodeSocketDatatype)socket->type) {
|
||||||
case SOCK_MESH_DEPRECATED:
|
|
||||||
return -1;
|
|
||||||
case SOCK_CUSTOM:
|
case SOCK_CUSTOM:
|
||||||
return 0;
|
return 0;
|
||||||
case SOCK_BOOLEAN:
|
case SOCK_BOOLEAN:
|
||||||
|
|
|
@ -23,21 +23,21 @@ set(INC_SYS
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SRC
|
set(SRC
|
||||||
space_text.c
|
space_text.cc
|
||||||
text_autocomplete.c
|
text_autocomplete.cc
|
||||||
text_draw.c
|
text_draw.cc
|
||||||
text_format.c
|
text_format.cc
|
||||||
text_format_lua.c
|
text_format_lua.cc
|
||||||
text_format_osl.c
|
text_format_osl.cc
|
||||||
text_format_pov.c
|
text_format_pov.cc
|
||||||
text_format_pov_ini.c
|
text_format_pov_ini.cc
|
||||||
text_format_py.c
|
text_format_py.cc
|
||||||
text_header.c
|
text_header.cc
|
||||||
text_ops.c
|
text_ops.cc
|
||||||
text_undo.cc
|
text_undo.cc
|
||||||
|
|
||||||
text_format.h
|
text_format.hh
|
||||||
text_intern.h
|
text_intern.hh
|
||||||
)
|
)
|
||||||
|
|
||||||
set(LIB
|
set(LIB
|
||||||
|
|
|
@ -35,17 +35,17 @@
|
||||||
#include "RNA_access.h"
|
#include "RNA_access.h"
|
||||||
#include "RNA_path.h"
|
#include "RNA_path.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
#include "text_intern.h" /* own include */
|
#include "text_intern.hh" /* own include */
|
||||||
|
|
||||||
/* ******************** default callbacks for text space ***************** */
|
/* ******************** default callbacks for text space ***************** */
|
||||||
|
|
||||||
static SpaceLink *text_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
|
static SpaceLink *text_create(const ScrArea * /*area*/, const Scene * /*scene*/)
|
||||||
{
|
{
|
||||||
ARegion *region;
|
ARegion *region;
|
||||||
SpaceText *stext;
|
SpaceText *stext;
|
||||||
|
|
||||||
stext = MEM_callocN(sizeof(SpaceText), "inittext");
|
stext = static_cast<SpaceText *>(MEM_callocN(sizeof(SpaceText), "inittext"));
|
||||||
stext->spacetype = SPACE_TEXT;
|
stext->spacetype = SPACE_TEXT;
|
||||||
|
|
||||||
stext->lheight = 12;
|
stext->lheight = 12;
|
||||||
|
@ -55,20 +55,20 @@ static SpaceLink *text_create(const ScrArea *UNUSED(area), const Scene *UNUSED(s
|
||||||
stext->showlinenrs = true;
|
stext->showlinenrs = true;
|
||||||
|
|
||||||
/* header */
|
/* header */
|
||||||
region = MEM_callocN(sizeof(ARegion), "header for text");
|
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "header for text"));
|
||||||
|
|
||||||
BLI_addtail(&stext->regionbase, region);
|
BLI_addtail(&stext->regionbase, region);
|
||||||
region->regiontype = RGN_TYPE_HEADER;
|
region->regiontype = RGN_TYPE_HEADER;
|
||||||
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
||||||
|
|
||||||
/* footer */
|
/* footer */
|
||||||
region = MEM_callocN(sizeof(ARegion), "footer for text");
|
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "footer for text"));
|
||||||
BLI_addtail(&stext->regionbase, region);
|
BLI_addtail(&stext->regionbase, region);
|
||||||
region->regiontype = RGN_TYPE_FOOTER;
|
region->regiontype = RGN_TYPE_FOOTER;
|
||||||
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
|
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
|
||||||
|
|
||||||
/* properties region */
|
/* properties region */
|
||||||
region = MEM_callocN(sizeof(ARegion), "properties region for text");
|
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "properties region for text"));
|
||||||
|
|
||||||
BLI_addtail(&stext->regionbase, region);
|
BLI_addtail(&stext->regionbase, region);
|
||||||
region->regiontype = RGN_TYPE_UI;
|
region->regiontype = RGN_TYPE_UI;
|
||||||
|
@ -76,7 +76,7 @@ static SpaceLink *text_create(const ScrArea *UNUSED(area), const Scene *UNUSED(s
|
||||||
region->flag = RGN_FLAG_HIDDEN;
|
region->flag = RGN_FLAG_HIDDEN;
|
||||||
|
|
||||||
/* main region */
|
/* main region */
|
||||||
region = MEM_callocN(sizeof(ARegion), "main region for text");
|
region = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "main region for text"));
|
||||||
|
|
||||||
BLI_addtail(&stext->regionbase, region);
|
BLI_addtail(&stext->regionbase, region);
|
||||||
region->regiontype = RGN_TYPE_WINDOW;
|
region->regiontype = RGN_TYPE_WINDOW;
|
||||||
|
@ -89,20 +89,20 @@ static void text_free(SpaceLink *sl)
|
||||||
{
|
{
|
||||||
SpaceText *stext = (SpaceText *)sl;
|
SpaceText *stext = (SpaceText *)sl;
|
||||||
|
|
||||||
stext->text = NULL;
|
stext->text = nullptr;
|
||||||
text_free_caches(stext);
|
text_free_caches(stext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* spacetype; init callback */
|
/* spacetype; init callback */
|
||||||
static void text_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area)) {}
|
static void text_init(wmWindowManager * /*wm*/, ScrArea * /*area*/) {}
|
||||||
|
|
||||||
static SpaceLink *text_duplicate(SpaceLink *sl)
|
static SpaceLink *text_duplicate(SpaceLink *sl)
|
||||||
{
|
{
|
||||||
SpaceText *stextn = MEM_dupallocN(sl);
|
SpaceText *stextn = static_cast<SpaceText *>(MEM_dupallocN(sl));
|
||||||
|
|
||||||
/* clear or remove stuff from old */
|
/* clear or remove stuff from old */
|
||||||
|
|
||||||
stextn->runtime.drawcache = NULL; /* space need its own cache */
|
stextn->runtime.drawcache = nullptr; /* space need its own cache */
|
||||||
|
|
||||||
return (SpaceLink *)stextn;
|
return (SpaceLink *)stextn;
|
||||||
}
|
}
|
||||||
|
@ -111,13 +111,13 @@ static void text_listener(const wmSpaceTypeListenerParams *params)
|
||||||
{
|
{
|
||||||
ScrArea *area = params->area;
|
ScrArea *area = params->area;
|
||||||
const wmNotifier *wmn = params->notifier;
|
const wmNotifier *wmn = params->notifier;
|
||||||
SpaceText *st = area->spacedata.first;
|
SpaceText *st = static_cast<SpaceText *>(area->spacedata.first);
|
||||||
|
|
||||||
/* context changes */
|
/* context changes */
|
||||||
switch (wmn->category) {
|
switch (wmn->category) {
|
||||||
case NC_TEXT:
|
case NC_TEXT:
|
||||||
/* check if active text was changed, no need to redraw if text isn't active
|
/* check if active text was changed, no need to redraw if text isn't active
|
||||||
* (reference == NULL) means text was unlinked, should update anyway for this
|
* (reference == nullptr) means text was unlinked, should update anyway for this
|
||||||
* case -- no way to know was text active before unlinking or not */
|
* case -- no way to know was text active before unlinking or not */
|
||||||
if (wmn->reference && wmn->reference != st->text) {
|
if (wmn->reference && wmn->reference != st->text) {
|
||||||
break;
|
break;
|
||||||
|
@ -220,7 +220,7 @@ static void text_keymap(wmKeyConfig *keyconf)
|
||||||
WM_keymap_ensure(keyconf, "Text", SPACE_TEXT, 0);
|
WM_keymap_ensure(keyconf, "Text", SPACE_TEXT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *text_context_dir[] = {"edit_text", NULL};
|
const char *text_context_dir[] = {"edit_text", nullptr};
|
||||||
|
|
||||||
static int /*eContextResult*/ text_context(const bContext *C,
|
static int /*eContextResult*/ text_context(const bContext *C,
|
||||||
const char *member,
|
const char *member,
|
||||||
|
@ -233,7 +233,7 @@ static int /*eContextResult*/ text_context(const bContext *C,
|
||||||
return CTX_RESULT_OK;
|
return CTX_RESULT_OK;
|
||||||
}
|
}
|
||||||
if (CTX_data_equals(member, "edit_text")) {
|
if (CTX_data_equals(member, "edit_text")) {
|
||||||
if (st->text != NULL) {
|
if (st->text != nullptr) {
|
||||||
CTX_data_id_pointer_set(result, &st->text->id);
|
CTX_data_id_pointer_set(result, &st->text->id);
|
||||||
}
|
}
|
||||||
return CTX_RESULT_OK;
|
return CTX_RESULT_OK;
|
||||||
|
@ -286,7 +286,7 @@ static void text_main_region_draw(const bContext *C, ARegion *region)
|
||||||
|
|
||||||
static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region)
|
static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region)
|
||||||
{
|
{
|
||||||
SpaceText *st = area->spacedata.first;
|
SpaceText *st = static_cast<SpaceText *>(area->spacedata.first);
|
||||||
int wmcursor = WM_CURSOR_TEXT_EDIT;
|
int wmcursor = WM_CURSOR_TEXT_EDIT;
|
||||||
|
|
||||||
if (st->text && BLI_rcti_isect_pt(&st->runtime.scroll_region_handle,
|
if (st->text && BLI_rcti_isect_pt(&st->runtime.scroll_region_handle,
|
||||||
|
@ -301,10 +301,10 @@ static void text_cursor(wmWindow *win, ScrArea *area, ARegion *region)
|
||||||
|
|
||||||
/* ************* dropboxes ************* */
|
/* ************* dropboxes ************* */
|
||||||
|
|
||||||
static bool text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
|
static bool text_drop_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/)
|
||||||
{
|
{
|
||||||
if (drag->type == WM_DRAG_PATH) {
|
if (drag->type == WM_DRAG_PATH) {
|
||||||
const eFileSel_File_Types file_type = WM_drag_get_path_file_type(drag);
|
const eFileSel_File_Types file_type = eFileSel_File_Types(WM_drag_get_path_file_type(drag));
|
||||||
if (ELEM(file_type, 0, FILE_TYPE_PYSCRIPT, FILE_TYPE_TEXT)) {
|
if (ELEM(file_type, 0, FILE_TYPE_PYSCRIPT, FILE_TYPE_TEXT)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -312,18 +312,18 @@ static bool text_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNU
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void text_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
|
static void text_drop_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
|
||||||
{
|
{
|
||||||
/* copy drag path to properties */
|
/* copy drag path to properties */
|
||||||
RNA_string_set(drop->ptr, "filepath", WM_drag_get_path(drag));
|
RNA_string_set(drop->ptr, "filepath", WM_drag_get_path(drag));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool text_drop_paste_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event))
|
static bool text_drop_paste_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/)
|
||||||
{
|
{
|
||||||
return (drag->type == WM_DRAG_ID);
|
return (drag->type == WM_DRAG_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void text_drop_paste(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop)
|
static void text_drop_paste(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
|
||||||
{
|
{
|
||||||
char *text;
|
char *text;
|
||||||
ID *id = WM_drag_get_local_ID(drag, 0);
|
ID *id = WM_drag_get_local_ID(drag, 0);
|
||||||
|
@ -339,8 +339,8 @@ static void text_dropboxes(void)
|
||||||
{
|
{
|
||||||
ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
|
ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
|
||||||
|
|
||||||
WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy, NULL, NULL);
|
WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy, nullptr, nullptr);
|
||||||
WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste, NULL, NULL);
|
WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************* end drop *********** */
|
/* ************* end drop *********** */
|
||||||
|
@ -348,7 +348,7 @@ static void text_dropboxes(void)
|
||||||
/****************** header region ******************/
|
/****************** header region ******************/
|
||||||
|
|
||||||
/* add handlers, stuff you only do once or on area/region changes */
|
/* add handlers, stuff you only do once or on area/region changes */
|
||||||
static void text_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
|
static void text_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
|
||||||
{
|
{
|
||||||
ED_region_header_init(region);
|
ED_region_header_init(region);
|
||||||
}
|
}
|
||||||
|
@ -390,15 +390,13 @@ static void text_properties_region_draw(const bContext *C, ARegion *region)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void text_id_remap(ScrArea *UNUSED(area),
|
static void text_id_remap(ScrArea * /*area*/, SpaceLink *slink, const IDRemapper *mappings)
|
||||||
SpaceLink *slink,
|
|
||||||
const struct IDRemapper *mappings)
|
|
||||||
{
|
{
|
||||||
SpaceText *stext = (SpaceText *)slink;
|
SpaceText *stext = (SpaceText *)slink;
|
||||||
BKE_id_remapper_apply(mappings, (ID **)&stext->text, ID_REMAP_APPLY_ENSURE_REAL);
|
BKE_id_remapper_apply(mappings, (ID **)&stext->text, ID_REMAP_APPLY_ENSURE_REAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void text_space_blend_read_data(BlendDataReader *UNUSED(reader), SpaceLink *sl)
|
static void text_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLink *sl)
|
||||||
{
|
{
|
||||||
SpaceText *st = (SpaceText *)sl;
|
SpaceText *st = (SpaceText *)sl;
|
||||||
memset(&st->runtime, 0x0, sizeof(st->runtime));
|
memset(&st->runtime, 0x0, sizeof(st->runtime));
|
||||||
|
@ -419,7 +417,7 @@ static void text_space_blend_write(BlendWriter *writer, SpaceLink *sl)
|
||||||
|
|
||||||
void ED_spacetype_text(void)
|
void ED_spacetype_text(void)
|
||||||
{
|
{
|
||||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype text");
|
SpaceType *st = static_cast<SpaceType *>(MEM_callocN(sizeof(SpaceType), "spacetype text"));
|
||||||
ARegionType *art;
|
ARegionType *art;
|
||||||
|
|
||||||
st->spaceid = SPACE_TEXT;
|
st->spaceid = SPACE_TEXT;
|
||||||
|
@ -440,7 +438,7 @@ void ED_spacetype_text(void)
|
||||||
st->blend_write = text_space_blend_write;
|
st->blend_write = text_space_blend_write;
|
||||||
|
|
||||||
/* regions: main window */
|
/* regions: main window */
|
||||||
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype text region"));
|
||||||
art->regionid = RGN_TYPE_WINDOW;
|
art->regionid = RGN_TYPE_WINDOW;
|
||||||
art->init = text_main_region_init;
|
art->init = text_main_region_init;
|
||||||
art->draw = text_main_region_draw;
|
art->draw = text_main_region_draw;
|
||||||
|
@ -450,7 +448,7 @@ void ED_spacetype_text(void)
|
||||||
BLI_addhead(&st->regiontypes, art);
|
BLI_addhead(&st->regiontypes, art);
|
||||||
|
|
||||||
/* regions: properties */
|
/* regions: properties */
|
||||||
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype text region"));
|
||||||
art->regionid = RGN_TYPE_UI;
|
art->regionid = RGN_TYPE_UI;
|
||||||
art->prefsizex = UI_COMPACT_PANEL_WIDTH;
|
art->prefsizex = UI_COMPACT_PANEL_WIDTH;
|
||||||
art->keymapflag = ED_KEYMAP_UI;
|
art->keymapflag = ED_KEYMAP_UI;
|
||||||
|
@ -460,7 +458,7 @@ void ED_spacetype_text(void)
|
||||||
BLI_addhead(&st->regiontypes, art);
|
BLI_addhead(&st->regiontypes, art);
|
||||||
|
|
||||||
/* regions: header */
|
/* regions: header */
|
||||||
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype text region"));
|
||||||
art->regionid = RGN_TYPE_HEADER;
|
art->regionid = RGN_TYPE_HEADER;
|
||||||
art->prefsizey = HEADERY;
|
art->prefsizey = HEADERY;
|
||||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
|
||||||
|
@ -470,7 +468,7 @@ void ED_spacetype_text(void)
|
||||||
BLI_addhead(&st->regiontypes, art);
|
BLI_addhead(&st->regiontypes, art);
|
||||||
|
|
||||||
/* regions: footer */
|
/* regions: footer */
|
||||||
art = MEM_callocN(sizeof(ARegionType), "spacetype text region");
|
art = static_cast<ARegionType *>(MEM_callocN(sizeof(ARegionType), "spacetype text region"));
|
||||||
art->regionid = RGN_TYPE_FOOTER;
|
art->regionid = RGN_TYPE_FOOTER;
|
||||||
art->prefsizey = HEADERY;
|
art->prefsizey = HEADERY;
|
||||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER;
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER;
|
|
@ -30,8 +30,8 @@
|
||||||
|
|
||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
#include "text_intern.h" /* own include */
|
#include "text_intern.hh" /* own include */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Public API
|
/** \name Public API
|
||||||
|
@ -155,7 +155,7 @@ static GHash *text_autocomplete_build(Text *text)
|
||||||
|
|
||||||
gh = BLI_ghash_str_new(__func__);
|
gh = BLI_ghash_str_new(__func__);
|
||||||
|
|
||||||
for (linep = text->lines.first; linep; linep = linep->next) {
|
for (linep = static_cast<TextLine *>(text->lines.first); linep; linep = linep->next) {
|
||||||
size_t i_start = 0;
|
size_t i_start = 0;
|
||||||
size_t i_end = 0;
|
size_t i_end = 0;
|
||||||
size_t i_pos = 0;
|
size_t i_pos = 0;
|
||||||
|
@ -217,7 +217,7 @@ static GHash *text_autocomplete_build(Text *text)
|
||||||
tft = ED_text_format_get(text);
|
tft = ED_text_format_get(text);
|
||||||
|
|
||||||
GHASH_ITER (gh_iter, gh) {
|
GHASH_ITER (gh_iter, gh) {
|
||||||
const char *s = BLI_ghashIterator_getValue(&gh_iter);
|
const char *s = static_cast<char *>(BLI_ghashIterator_getValue(&gh_iter));
|
||||||
texttool_suggest_add(s, tft->format_identifier(s));
|
texttool_suggest_add(s, tft->format_identifier(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ static void confirm_suggestion(Text *text)
|
||||||
/** \name Auto Complete Operator
|
/** \name Auto Complete Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
static int text_autocomplete_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
@ -588,10 +588,10 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
|
||||||
|
|
||||||
static void text_autocomplete_free(bContext *C, wmOperator *op)
|
static void text_autocomplete_free(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
GHash *gh = op->customdata;
|
GHash *gh = static_cast<GHash *>(op->customdata);
|
||||||
if (gh) {
|
if (gh) {
|
||||||
BLI_ghash_free(gh, NULL, MEM_freeN);
|
BLI_ghash_free(gh, nullptr, MEM_freeN);
|
||||||
op->customdata = NULL;
|
op->customdata = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* other stuff */
|
/* other stuff */
|
|
@ -31,8 +31,8 @@
|
||||||
#include "UI_resources.h"
|
#include "UI_resources.h"
|
||||||
#include "UI_view2d.h"
|
#include "UI_view2d.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
#include "text_intern.h"
|
#include "text_intern.hh"
|
||||||
|
|
||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
#include "WM_types.h"
|
#include "WM_types.h"
|
||||||
|
@ -41,12 +41,12 @@
|
||||||
/** \name Text Font Drawing
|
/** \name Text Font Drawing
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
typedef struct TextDrawContext {
|
struct TextDrawContext {
|
||||||
int font_id;
|
int font_id;
|
||||||
int cwidth_px;
|
int cwidth_px;
|
||||||
int lheight_px;
|
int lheight_px;
|
||||||
bool syntax_highlight;
|
bool syntax_highlight;
|
||||||
} TextDrawContext;
|
};
|
||||||
|
|
||||||
static void text_draw_context_init(const SpaceText *st, TextDrawContext *tdc)
|
static void text_draw_context_init(const SpaceText *st, TextDrawContext *tdc)
|
||||||
{
|
{
|
||||||
|
@ -58,10 +58,10 @@ static void text_draw_context_init(const SpaceText *st, TextDrawContext *tdc)
|
||||||
|
|
||||||
static void text_font_begin(const TextDrawContext *tdc)
|
static void text_font_begin(const TextDrawContext *tdc)
|
||||||
{
|
{
|
||||||
BLF_size(tdc->font_id, (float)tdc->lheight_px);
|
BLF_size(tdc->font_id, float(tdc->lheight_px));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void text_font_end(const TextDrawContext *UNUSED(tdc)) {}
|
static void text_font_end(const TextDrawContext * /*tdc*/) {}
|
||||||
|
|
||||||
static int text_font_draw(const TextDrawContext *tdc, int x, int y, const char *str)
|
static int text_font_draw(const TextDrawContext *tdc, int x, int y, const char *str)
|
||||||
{
|
{
|
||||||
|
@ -207,7 +207,7 @@ void wrap_offset(
|
||||||
text = st->text;
|
text = st->text;
|
||||||
|
|
||||||
/* Move pointer to first visible line (top) */
|
/* Move pointer to first visible line (top) */
|
||||||
linep = text->lines.first;
|
linep = static_cast<TextLine *>(text->lines.first);
|
||||||
i = st->top;
|
i = st->top;
|
||||||
while (i > 0 && linep) {
|
while (i > 0 && linep) {
|
||||||
int lines = text_get_visible_lines(st, region, linep->line);
|
int lines = text_get_visible_lines(st, region, linep->line);
|
||||||
|
@ -416,7 +416,7 @@ static int text_draw_wrapped(const SpaceText *st,
|
||||||
int mi, ma, mstart, mend; /* mem */
|
int mi, ma, mstart, mend; /* mem */
|
||||||
char fmt_prev = 0xff;
|
char fmt_prev = 0xff;
|
||||||
/* don't draw lines below this */
|
/* don't draw lines below this */
|
||||||
const int clip_min_y = -(int)(st->runtime.lheight_px - 1);
|
const int clip_min_y = -int(st->runtime.lheight_px - 1);
|
||||||
|
|
||||||
flatten_string(st, &fs, str);
|
flatten_string(st, &fs, str);
|
||||||
str = fs.buf;
|
str = fs.buf;
|
||||||
|
@ -509,7 +509,7 @@ static void text_draw(const SpaceText *st,
|
||||||
const bool use_syntax = (tdc->syntax_highlight && format);
|
const bool use_syntax = (tdc->syntax_highlight && format);
|
||||||
FlattenString fs;
|
FlattenString fs;
|
||||||
int columns, size, n, w = 0, padding, amount = 0;
|
int columns, size, n, w = 0, padding, amount = 0;
|
||||||
const char *in = NULL;
|
const char *in = nullptr;
|
||||||
|
|
||||||
for (n = flatten_string(st, &fs, str), str = fs.buf; n > 0; n--) {
|
for (n = flatten_string(st, &fs, str), str = fs.buf; n > 0; n--) {
|
||||||
columns = BLI_str_utf8_char_width_safe(str);
|
columns = BLI_str_utf8_char_width_safe(str);
|
||||||
|
@ -567,7 +567,7 @@ static void text_draw(const SpaceText *st,
|
||||||
/** \name Cache Utilities
|
/** \name Cache Utilities
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
typedef struct DrawCache {
|
struct DrawCache {
|
||||||
int *line_height;
|
int *line_height;
|
||||||
int total_lines, nlines;
|
int total_lines, nlines;
|
||||||
|
|
||||||
|
@ -580,11 +580,12 @@ typedef struct DrawCache {
|
||||||
/* for partial lines recalculation */
|
/* for partial lines recalculation */
|
||||||
short update_flag;
|
short update_flag;
|
||||||
int valid_head, valid_tail; /* amount of unchanged lines */
|
int valid_head, valid_tail; /* amount of unchanged lines */
|
||||||
} DrawCache;
|
};
|
||||||
|
|
||||||
static void text_drawcache_init(SpaceText *st)
|
static void text_drawcache_init(SpaceText *st)
|
||||||
{
|
{
|
||||||
DrawCache *drawcache = MEM_callocN(sizeof(DrawCache), "text draw cache");
|
DrawCache *drawcache = static_cast<DrawCache *>(
|
||||||
|
MEM_callocN(sizeof(DrawCache), "text draw cache"));
|
||||||
|
|
||||||
drawcache->winx = -1;
|
drawcache->winx = -1;
|
||||||
drawcache->nlines = BLI_listbase_count(&st->text->lines);
|
drawcache->nlines = BLI_listbase_count(&st->text->lines);
|
||||||
|
@ -599,13 +600,13 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
|
||||||
int full_update = 0, nlines = 0;
|
int full_update = 0, nlines = 0;
|
||||||
Text *txt = st->text;
|
Text *txt = st->text;
|
||||||
|
|
||||||
if (st->runtime.drawcache == NULL) {
|
if (st->runtime.drawcache == nullptr) {
|
||||||
text_drawcache_init(st);
|
text_drawcache_init(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
text_update_character_width(st);
|
text_update_character_width(st);
|
||||||
|
|
||||||
drawcache = st->runtime.drawcache;
|
drawcache = static_cast<DrawCache *>(st->runtime.drawcache);
|
||||||
nlines = drawcache->nlines;
|
nlines = drawcache->nlines;
|
||||||
|
|
||||||
/* check if full cache update is needed */
|
/* check if full cache update is needed */
|
||||||
|
@ -634,7 +635,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drawcache->update_flag) {
|
if (drawcache->update_flag) {
|
||||||
TextLine *line = st->text->lines.first;
|
TextLine *line = static_cast<TextLine *>(st->text->lines.first);
|
||||||
int lineno = 0, size, lines_count;
|
int lineno = 0, size, lines_count;
|
||||||
int *fp = drawcache->line_height, *new_tail, *old_tail;
|
int *fp = drawcache->line_height, *new_tail, *old_tail;
|
||||||
|
|
||||||
|
@ -642,10 +643,10 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
|
||||||
size = sizeof(int) * nlines;
|
size = sizeof(int) * nlines;
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fp = MEM_reallocN(fp, size);
|
fp = static_cast<int *>(MEM_reallocN(fp, size));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fp = MEM_callocN(size, "text drawcache line_height");
|
fp = static_cast<int *>(MEM_callocN(size, "text drawcache line_height"));
|
||||||
}
|
}
|
||||||
|
|
||||||
drawcache->valid_tail = drawcache->valid_head = 0;
|
drawcache->valid_tail = drawcache->valid_head = 0;
|
||||||
|
@ -716,12 +717,12 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
|
||||||
void text_drawcache_tag_update(SpaceText *st, const bool full)
|
void text_drawcache_tag_update(SpaceText *st, const bool full)
|
||||||
{
|
{
|
||||||
/* This happens if text editor ops are called from Python. */
|
/* This happens if text editor ops are called from Python. */
|
||||||
if (st == NULL) {
|
if (st == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->runtime.drawcache != NULL) {
|
if (st->runtime.drawcache != nullptr) {
|
||||||
DrawCache *drawcache = st->runtime.drawcache;
|
DrawCache *drawcache = static_cast<DrawCache *>(st->runtime.drawcache);
|
||||||
Text *txt = st->text;
|
Text *txt = st->text;
|
||||||
|
|
||||||
if (drawcache->update_flag) {
|
if (drawcache->update_flag) {
|
||||||
|
@ -764,7 +765,7 @@ void text_drawcache_tag_update(SpaceText *st, const bool full)
|
||||||
|
|
||||||
void text_free_caches(SpaceText *st)
|
void text_free_caches(SpaceText *st)
|
||||||
{
|
{
|
||||||
DrawCache *drawcache = st->runtime.drawcache;
|
DrawCache *drawcache = static_cast<DrawCache *>(st->runtime.drawcache);
|
||||||
|
|
||||||
if (drawcache) {
|
if (drawcache) {
|
||||||
if (drawcache->line_height) {
|
if (drawcache->line_height) {
|
||||||
|
@ -784,7 +785,7 @@ void text_free_caches(SpaceText *st)
|
||||||
/* cache should be updated in caller */
|
/* cache should be updated in caller */
|
||||||
static int text_get_visible_lines_no(const SpaceText *st, int lineno)
|
static int text_get_visible_lines_no(const SpaceText *st, int lineno)
|
||||||
{
|
{
|
||||||
const DrawCache *drawcache = st->runtime.drawcache;
|
const DrawCache *drawcache = static_cast<const DrawCache *>(st->runtime.drawcache);
|
||||||
|
|
||||||
return drawcache->line_height[lineno];
|
return drawcache->line_height[lineno];
|
||||||
}
|
}
|
||||||
|
@ -853,7 +854,7 @@ int text_get_total_lines(SpaceText *st, ARegion *region)
|
||||||
DrawCache *drawcache;
|
DrawCache *drawcache;
|
||||||
|
|
||||||
text_update_drawcache(st, region);
|
text_update_drawcache(st, region);
|
||||||
drawcache = st->runtime.drawcache;
|
drawcache = static_cast<DrawCache *>(st->runtime.drawcache);
|
||||||
|
|
||||||
return drawcache->total_lines;
|
return drawcache->total_lines;
|
||||||
}
|
}
|
||||||
|
@ -910,13 +911,15 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *scroll, rcti *b
|
||||||
CLAMP(st->runtime.scroll_region_handle.ymin, pix_bottom_margin, region->winy - pix_top_margin);
|
CLAMP(st->runtime.scroll_region_handle.ymin, pix_bottom_margin, region->winy - pix_top_margin);
|
||||||
CLAMP(st->runtime.scroll_region_handle.ymax, pix_bottom_margin, region->winy - pix_top_margin);
|
CLAMP(st->runtime.scroll_region_handle.ymax, pix_bottom_margin, region->winy - pix_top_margin);
|
||||||
|
|
||||||
st->runtime.scroll_px_per_line = (pix_available > 0) ? (float)ltexth / pix_available : 0;
|
st->runtime.scroll_px_per_line = (pix_available > 0) ? float(ltexth) / pix_available : 0;
|
||||||
if (st->runtime.scroll_px_per_line < 0.1f) {
|
if (st->runtime.scroll_px_per_line < 0.1f) {
|
||||||
st->runtime.scroll_px_per_line = 0.1f;
|
st->runtime.scroll_px_per_line = 0.1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_off = text_get_span_wrap(st, region, st->text->lines.first, st->text->curl);
|
curl_off = text_get_span_wrap(
|
||||||
sell_off = text_get_span_wrap(st, region, st->text->lines.first, st->text->sell);
|
st, region, static_cast<TextLine *>(st->text->lines.first), st->text->curl);
|
||||||
|
sell_off = text_get_span_wrap(
|
||||||
|
st, region, static_cast<TextLine *>(st->text->lines.first), st->text->sell);
|
||||||
lhlstart = MIN2(curl_off, sell_off);
|
lhlstart = MIN2(curl_off, sell_off);
|
||||||
lhlend = MAX2(curl_off, sell_off);
|
lhlend = MAX2(curl_off, sell_off);
|
||||||
|
|
||||||
|
@ -1013,16 +1016,13 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back)
|
||||||
BLI_rcti_size_y(&st->runtime.scroll_region_select));
|
BLI_rcti_size_y(&st->runtime.scroll_region_select));
|
||||||
UI_GetThemeColor3fv(TH_HILITE, col);
|
UI_GetThemeColor3fv(TH_HILITE, col);
|
||||||
col[3] = 0.18f;
|
col[3] = 0.18f;
|
||||||
UI_draw_roundbox_aa(
|
|
||||||
&(const rctf){
|
rctf rect;
|
||||||
.xmin = st->runtime.scroll_region_select.xmin + 1,
|
rect.xmin = st->runtime.scroll_region_select.xmin + 1;
|
||||||
.xmax = st->runtime.scroll_region_select.xmax - 1,
|
rect.xmax = st->runtime.scroll_region_select.xmax - 1;
|
||||||
.ymin = st->runtime.scroll_region_select.ymin,
|
rect.ymin = st->runtime.scroll_region_select.ymin;
|
||||||
.ymax = st->runtime.scroll_region_select.ymax,
|
rect.ymax = st->runtime.scroll_region_select.ymax;
|
||||||
},
|
UI_draw_roundbox_aa(&rect, true, rad, col);
|
||||||
true,
|
|
||||||
rad,
|
|
||||||
col);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -1117,7 +1117,7 @@ static void draw_documentation(const SpaceText *st, ARegion *region)
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
if (lines >= 0) {
|
if (lines >= 0) {
|
||||||
y -= st->runtime.lheight_px;
|
y -= st->runtime.lheight_px;
|
||||||
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, NULL);
|
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, nullptr);
|
||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
br = DOC_WIDTH;
|
br = DOC_WIDTH;
|
||||||
|
@ -1128,7 +1128,7 @@ static void draw_documentation(const SpaceText *st, ARegion *region)
|
||||||
buf[br] = '\0';
|
buf[br] = '\0';
|
||||||
if (lines >= 0) {
|
if (lines >= 0) {
|
||||||
y -= st->runtime.lheight_px;
|
y -= st->runtime.lheight_px;
|
||||||
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, NULL);
|
text_draw(st, &tdc, buf, 0, 0, x + 4, y - 3, nullptr);
|
||||||
}
|
}
|
||||||
p -= i - br - 1; /* Rewind pointer to last break */
|
p -= i - br - 1; /* Rewind pointer to last break */
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -1177,7 +1177,8 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
|
||||||
top = texttool_suggest_top();
|
top = texttool_suggest_top();
|
||||||
|
|
||||||
wrap_offset(st, region, st->text->curl, st->text->curc, &offl, &offc);
|
wrap_offset(st, region, st->text->curl, st->text->curc, &offl, &offc);
|
||||||
vcurl = txt_get_span(st->text->lines.first, st->text->curl) - st->top + offl;
|
vcurl = txt_get_span(static_cast<TextLine *>(st->text->lines.first), st->text->curl) - st->top +
|
||||||
|
offl;
|
||||||
vcurc = text_get_char_pos(st, st->text->curl->line, st->text->curc) - st->left + offc;
|
vcurc = text_get_char_pos(st, st->text->curl->line, st->text->curc) - st->left + offc;
|
||||||
|
|
||||||
x = TXT_BODY_LEFT(st) + (vcurc * st->runtime.cwidth_px);
|
x = TXT_BODY_LEFT(st) + (vcurc * st->runtime.cwidth_px);
|
||||||
|
@ -1196,14 +1197,14 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not needed but stands out nicer */
|
/* not needed but stands out nicer */
|
||||||
UI_draw_box_shadow(
|
{
|
||||||
&(const rctf){
|
rctf rect;
|
||||||
.xmin = x,
|
rect.xmin = x;
|
||||||
.xmax = x + boxw,
|
rect.xmax = x + boxw;
|
||||||
.ymin = y - boxh,
|
rect.ymin = y - boxh;
|
||||||
.ymax = y,
|
rect.ymax = y;
|
||||||
},
|
UI_draw_box_shadow(&rect, 220);
|
||||||
220);
|
}
|
||||||
|
|
||||||
uint pos = GPU_vertformat_attr_add(
|
uint pos = GPU_vertformat_attr_add(
|
||||||
immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
||||||
|
@ -1222,7 +1223,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) {
|
for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) {
|
||||||
int len = txt_utf8_forward_columns(item->name, SUGG_LIST_WIDTH, NULL) - item->name;
|
int len = txt_utf8_forward_columns(item->name, SUGG_LIST_WIDTH, nullptr) - item->name;
|
||||||
|
|
||||||
y -= lheight;
|
y -= lheight;
|
||||||
|
|
||||||
|
@ -1242,7 +1243,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
|
||||||
}
|
}
|
||||||
|
|
||||||
format_draw_color(tdc, item->type);
|
format_draw_color(tdc, item->type);
|
||||||
text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, NULL);
|
text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, nullptr);
|
||||||
|
|
||||||
if (item == last) {
|
if (item == last) {
|
||||||
break;
|
break;
|
||||||
|
@ -1266,7 +1267,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *region)
|
||||||
|
|
||||||
/* Convert to view space character coordinates to determine if cursor is hidden */
|
/* Convert to view space character coordinates to determine if cursor is hidden */
|
||||||
wrap_offset(st, region, text->sell, text->selc, &offl, &offc);
|
wrap_offset(st, region, text->sell, text->selc, &offl, &offc);
|
||||||
vsell = txt_get_span(text->lines.first, text->sell) - st->top + offl;
|
vsell = txt_get_span(static_cast<TextLine *>(text->lines.first), text->sell) - st->top + offl;
|
||||||
vselc = text_get_char_pos(st, text->sell->line, text->selc) - st->left + offc;
|
vselc = text_get_char_pos(st, text->sell->line, text->selc) - st->left + offc;
|
||||||
|
|
||||||
if (vselc < 0) {
|
if (vselc < 0) {
|
||||||
|
@ -1287,7 +1288,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *region)
|
||||||
if (text->curl != text->sell || text->curc != text->selc) {
|
if (text->curl != text->sell || text->curc != text->selc) {
|
||||||
/* Convert all to view space character coordinates */
|
/* Convert all to view space character coordinates */
|
||||||
wrap_offset(st, region, text->curl, text->curc, &offl, &offc);
|
wrap_offset(st, region, text->curl, text->curc, &offl, &offc);
|
||||||
vcurl = txt_get_span(text->lines.first, text->curl) - st->top + offl;
|
vcurl = txt_get_span(static_cast<TextLine *>(text->lines.first), text->curl) - st->top + offl;
|
||||||
vcurc = text_get_char_pos(st, text->curl->line, text->curc) - st->left + offc;
|
vcurc = text_get_char_pos(st, text->curl->line, text->curc) - st->left + offc;
|
||||||
|
|
||||||
if (vcurc < 0) {
|
if (vcurc < 0) {
|
||||||
|
@ -1449,7 +1450,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
|
||||||
linep = startl;
|
linep = startl;
|
||||||
c = startc;
|
c = startc;
|
||||||
fc = BLI_str_utf8_offset_to_index(linep->line, startc);
|
fc = BLI_str_utf8_offset_to_index(linep->line, startc);
|
||||||
endl = NULL;
|
endl = nullptr;
|
||||||
endc = -1;
|
endc = -1;
|
||||||
find = -b;
|
find = -b;
|
||||||
stack = 0;
|
stack = 0;
|
||||||
|
@ -1559,7 +1560,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
|
||||||
viewc = text_get_char_pos(st, startl->line, startc) - st->left + offc;
|
viewc = text_get_char_pos(st, startl->line, startc) - st->left + offc;
|
||||||
|
|
||||||
if (viewc >= 0) {
|
if (viewc >= 0) {
|
||||||
viewl = txt_get_span(text->lines.first, startl) - st->top + offl;
|
viewl = txt_get_span(static_cast<TextLine *>(text->lines.first), startl) - st->top + offl;
|
||||||
|
|
||||||
text_font_draw_character(
|
text_font_draw_character(
|
||||||
tdc, x + viewc * st->runtime.cwidth_px, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
tdc, x + viewc * st->runtime.cwidth_px, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
||||||
|
@ -1573,7 +1574,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
|
||||||
viewc = text_get_char_pos(st, endl->line, endc) - st->left + offc;
|
viewc = text_get_char_pos(st, endl->line, endc) - st->left + offc;
|
||||||
|
|
||||||
if (viewc >= 0) {
|
if (viewc >= 0) {
|
||||||
viewl = txt_get_span(text->lines.first, endl) - st->top + offl;
|
viewl = txt_get_span(static_cast<TextLine *>(text->lines.first), endl) - st->top + offl;
|
||||||
|
|
||||||
text_font_draw_character(
|
text_font_draw_character(
|
||||||
tdc, x + viewc * st->runtime.cwidth_px, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
tdc, x + viewc * st->runtime.cwidth_px, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
||||||
|
@ -1609,10 +1610,10 @@ void draw_text_main(SpaceText *st, ARegion *region)
|
||||||
st->runtime.lheight_px = (U.widget_unit * st->lheight) / 20;
|
st->runtime.lheight_px = (U.widget_unit * st->lheight) / 20;
|
||||||
|
|
||||||
/* don't draw lines below this */
|
/* don't draw lines below this */
|
||||||
const int clip_min_y = -(int)(st->runtime.lheight_px - 1);
|
const int clip_min_y = -int(st->runtime.lheight_px - 1);
|
||||||
|
|
||||||
st->runtime.viewlines = (st->runtime.lheight_px) ?
|
st->runtime.viewlines = (st->runtime.lheight_px) ?
|
||||||
(int)(region->winy - clip_min_y) / TXT_LINE_HEIGHT(st) :
|
int(region->winy - clip_min_y) / TXT_LINE_HEIGHT(st) :
|
||||||
0;
|
0;
|
||||||
|
|
||||||
text_draw_context_init(st, &tdc);
|
text_draw_context_init(st, &tdc);
|
||||||
|
@ -1629,7 +1630,7 @@ void draw_text_main(SpaceText *st, ARegion *region)
|
||||||
|
|
||||||
/* update syntax formatting if needed */
|
/* update syntax formatting if needed */
|
||||||
tft = ED_text_format_get(text);
|
tft = ED_text_format_get(text);
|
||||||
tmp = text->lines.first;
|
tmp = static_cast<TextLine *>(text->lines.first);
|
||||||
lineno = 0;
|
lineno = 0;
|
||||||
for (i = 0; i < st->top && tmp; i++) {
|
for (i = 0; i < st->top && tmp; i++) {
|
||||||
if (tdc.syntax_highlight && !tmp->format) {
|
if (tdc.syntax_highlight && !tmp->format) {
|
||||||
|
@ -1658,7 +1659,7 @@ void draw_text_main(SpaceText *st, ARegion *region)
|
||||||
|
|
||||||
text_font_begin(&tdc);
|
text_font_begin(&tdc);
|
||||||
|
|
||||||
tdc.cwidth_px = max_ii((int)BLF_fixed_width(tdc.font_id), 1);
|
tdc.cwidth_px = max_ii(int(BLF_fixed_width(tdc.font_id)), 1);
|
||||||
st->runtime.cwidth_px = tdc.cwidth_px;
|
st->runtime.cwidth_px = tdc.cwidth_px;
|
||||||
|
|
||||||
/* draw line numbers background */
|
/* draw line numbers background */
|
||||||
|
@ -1759,7 +1760,7 @@ void text_update_character_width(SpaceText *st)
|
||||||
|
|
||||||
text_font_begin(&tdc);
|
text_font_begin(&tdc);
|
||||||
st->runtime.cwidth_px = BLF_fixed_width(tdc.font_id);
|
st->runtime.cwidth_px = BLF_fixed_width(tdc.font_id);
|
||||||
st->runtime.cwidth_px = MAX2(st->runtime.cwidth_px, (char)1);
|
st->runtime.cwidth_px = MAX2(st->runtime.cwidth_px, char(1));
|
||||||
text_font_end(&tdc);
|
text_font_end(&tdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1767,7 +1768,7 @@ bool ED_text_activate_in_screen(bContext *C, Text *text)
|
||||||
{
|
{
|
||||||
ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
|
ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
|
||||||
if (area) {
|
if (area) {
|
||||||
SpaceText *st = area->spacedata.first;
|
SpaceText *st = static_cast<SpaceText *>(area->spacedata.first);
|
||||||
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
|
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
|
||||||
st->text = text;
|
st->text = text;
|
||||||
if (region) {
|
if (region) {
|
||||||
|
@ -1785,7 +1786,7 @@ void ED_text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center)
|
||||||
Text *text;
|
Text *text;
|
||||||
int i, x, winx = region->winx;
|
int i, x, winx = region->winx;
|
||||||
|
|
||||||
if (ELEM(NULL, st, st->text, st->text->curl)) {
|
if (ELEM(nullptr, st, st->text, st->text->curl)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1793,7 +1794,7 @@ void ED_text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center)
|
||||||
|
|
||||||
text_update_character_width(st);
|
text_update_character_width(st);
|
||||||
|
|
||||||
i = txt_get_span(text->lines.first, text->sell);
|
i = txt_get_span(static_cast<TextLine *>(text->lines.first), text->sell);
|
||||||
if (st->wordwrap) {
|
if (st->wordwrap) {
|
||||||
int offl, offc;
|
int offl, offc;
|
||||||
wrap_offset(st, region, text->sell, text->selc, &offl, &offc);
|
wrap_offset(st, region, text->sell, text->selc, &offl, &offc);
|
||||||
|
@ -1851,7 +1852,7 @@ void text_scroll_to_cursor__area(SpaceText *st, ScrArea *area, const bool center
|
||||||
{
|
{
|
||||||
ARegion *region;
|
ARegion *region;
|
||||||
|
|
||||||
if (ELEM(NULL, st, st->text, st->text->curl)) {
|
if (ELEM(nullptr, st, st->text, st->text->curl)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1875,13 +1876,13 @@ bool ED_text_region_location_from_cursor(SpaceText *st,
|
||||||
const int cursor_co[2],
|
const int cursor_co[2],
|
||||||
int r_pixel_co[2])
|
int r_pixel_co[2])
|
||||||
{
|
{
|
||||||
TextLine *line = NULL;
|
TextLine *line = nullptr;
|
||||||
|
|
||||||
if (!st->text) {
|
if (!st->text) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = BLI_findlink(&st->text->lines, cursor_co[0]);
|
line = static_cast<TextLine *>(BLI_findlink(&st->text->lines, cursor_co[0]));
|
||||||
if (!line || (cursor_co[1] < 0) || (cursor_co[1] > line->len)) {
|
if (!line || (cursor_co[1] < 0) || (cursor_co[1] > line->len)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
* \ingroup sptext
|
* \ingroup sptext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "ED_text.h"
|
#include "ED_text.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
|
|
||||||
/****************** flatten string **********************/
|
/****************** flatten string **********************/
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ static void flatten_string_append(FlattenString *fs, const char *c, int accum, i
|
||||||
int *naccum;
|
int *naccum;
|
||||||
fs->len *= 2;
|
fs->len *= 2;
|
||||||
|
|
||||||
nbuf = MEM_callocN(sizeof(*fs->buf) * fs->len, "fs->buf");
|
nbuf = static_cast<char *>(MEM_callocN(sizeof(*fs->buf) * fs->len, "fs->buf"));
|
||||||
naccum = MEM_callocN(sizeof(*fs->accum) * fs->len, "fs->accum");
|
naccum = static_cast<int *>(MEM_callocN(sizeof(*fs->accum) * fs->len, "fs->accum"));
|
||||||
|
|
||||||
memcpy(nbuf, fs->buf, fs->pos * sizeof(*fs->buf));
|
memcpy(nbuf, fs->buf, fs->pos * sizeof(*fs->buf));
|
||||||
memcpy(naccum, fs->accum, fs->pos * sizeof(*fs->accum));
|
memcpy(naccum, fs->accum, fs->pos * sizeof(*fs->accum));
|
||||||
|
@ -99,7 +99,7 @@ void flatten_string_free(FlattenString *fs)
|
||||||
|
|
||||||
int flatten_string_strlen(FlattenString *fs, const char *str)
|
int flatten_string_strlen(FlattenString *fs, const char *str)
|
||||||
{
|
{
|
||||||
const int len = (fs->pos - (int)(str - fs->buf)) - 1;
|
const int len = (fs->pos - int(str - fs->buf)) - 1;
|
||||||
BLI_assert(strlen(str) == len);
|
BLI_assert(strlen(str) == len);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@ -109,14 +109,14 @@ int text_check_format_len(TextLine *line, uint len)
|
||||||
if (line->format) {
|
if (line->format) {
|
||||||
if (strlen(line->format) < len) {
|
if (strlen(line->format) < len) {
|
||||||
MEM_freeN(line->format);
|
MEM_freeN(line->format);
|
||||||
line->format = MEM_mallocN(len + 2, "SyntaxFormat");
|
line->format = static_cast<char *>(MEM_mallocN(len + 2, "SyntaxFormat"));
|
||||||
if (!line->format) {
|
if (!line->format) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
line->format = MEM_mallocN(len + 2, "SyntaxFormat");
|
line->format = static_cast<char *>(MEM_mallocN(len + 2, "SyntaxFormat"));
|
||||||
if (!line->format) {
|
if (!line->format) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ void text_format_fill_ascii(const char **str_p, char **fmt_p, const char type, c
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *** Registration *** */
|
/* *** Registration *** */
|
||||||
static ListBase tft_lb = {NULL, NULL};
|
static ListBase tft_lb = {nullptr, nullptr};
|
||||||
void ED_text_format_register(TextFormatType *tft)
|
void ED_text_format_register(TextFormatType *tft)
|
||||||
{
|
{
|
||||||
BLI_addtail(&tft_lb, tft);
|
BLI_addtail(&tft_lb, tft);
|
||||||
|
@ -179,7 +179,7 @@ TextFormatType *ED_text_format_get(Text *text)
|
||||||
if (text_ext) {
|
if (text_ext) {
|
||||||
text_ext++; /* skip the '.' */
|
text_ext++; /* skip the '.' */
|
||||||
/* Check all text formats in the static list */
|
/* Check all text formats in the static list */
|
||||||
for (tft = tft_lb.first; tft; tft = tft->next) {
|
for (tft = static_cast<TextFormatType *>(tft_lb.first); tft; tft = tft->next) {
|
||||||
/* All formats should have an ext, but just in case */
|
/* All formats should have an ext, but just in case */
|
||||||
const char **ext;
|
const char **ext;
|
||||||
for (ext = tft->ext; *ext; ext++) {
|
for (ext = tft->ext; *ext; ext++) {
|
||||||
|
@ -193,11 +193,11 @@ TextFormatType *ED_text_format_get(Text *text)
|
||||||
|
|
||||||
/* If we make it here we never found an extension that worked - return
|
/* If we make it here we never found an extension that worked - return
|
||||||
* the "default" text format */
|
* the "default" text format */
|
||||||
return tft_lb.first;
|
return static_cast<TextFormatType *>(tft_lb.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the "default" text format */
|
/* Return the "default" text format */
|
||||||
return tft_lb.first;
|
return static_cast<TextFormatType *>(tft_lb.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ED_text_format_comment_line_prefix(Text *text)
|
const char *ED_text_format_comment_line_prefix(Text *text)
|
||||||
|
@ -208,14 +208,14 @@ const char *ED_text_format_comment_line_prefix(Text *text)
|
||||||
|
|
||||||
bool ED_text_is_syntax_highlight_supported(Text *text)
|
bool ED_text_is_syntax_highlight_supported(Text *text)
|
||||||
{
|
{
|
||||||
if (text == NULL) {
|
if (text == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextFormatType *tft;
|
TextFormatType *tft;
|
||||||
|
|
||||||
const char *text_ext = BLI_path_extension(text->id.name + 2);
|
const char *text_ext = BLI_path_extension(text->id.name + 2);
|
||||||
if (text_ext == NULL) {
|
if (text_ext == nullptr) {
|
||||||
/* Extensionless data-blocks are considered highlightable as Python. */
|
/* Extensionless data-blocks are considered highlightable as Python. */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ bool ED_text_is_syntax_highlight_supported(Text *text)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check all text formats in the static list */
|
/* Check all text formats in the static list */
|
||||||
for (tft = tft_lb.first; tft; tft = tft->next) {
|
for (tft = static_cast<TextFormatType *>(tft_lb.first); tft; tft = tft->next) {
|
||||||
/* All formats should have an ext, but just in case */
|
/* All formats should have an ext, but just in case */
|
||||||
const char **ext;
|
const char **ext;
|
||||||
for (ext = tft->ext; *ext; ext++) {
|
for (ext = tft->ext; *ext; ext++) {
|
|
@ -8,18 +8,20 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
struct Text;
|
||||||
|
|
||||||
/* *** Flatten String *** */
|
/* *** Flatten String *** */
|
||||||
typedef struct FlattenString {
|
struct FlattenString {
|
||||||
char fixedbuf[256];
|
char fixedbuf[256];
|
||||||
int fixedaccum[256];
|
int fixedaccum[256];
|
||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
int *accum;
|
int *accum;
|
||||||
int pos, len;
|
int pos, len;
|
||||||
} FlattenString;
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format continuation flags (stored just after the NULL terminator).
|
* Format continuation flags (stored just after the null terminator).
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
FMT_CONT_NOP = 0, /* no continuation */
|
FMT_CONT_NOP = 0, /* no continuation */
|
||||||
|
@ -75,7 +77,7 @@ typedef struct TextFormatType {
|
||||||
*/
|
*/
|
||||||
void (*format_line)(SpaceText *st, TextLine *line, bool do_next);
|
void (*format_line)(SpaceText *st, TextLine *line, bool do_next);
|
||||||
|
|
||||||
const char **ext; /* NULL terminated extensions */
|
const char **ext; /* Null terminated extensions. */
|
||||||
|
|
||||||
/** The prefix of a single-line line comment (without trailing space). */
|
/** The prefix of a single-line line comment (without trailing space). */
|
||||||
const char *comment_line;
|
const char *comment_line;
|
||||||
|
@ -104,15 +106,34 @@ enum {
|
||||||
FMT_TYPE_DEFAULT = 'q',
|
FMT_TYPE_DEFAULT = 'q',
|
||||||
};
|
};
|
||||||
|
|
||||||
TextFormatType *ED_text_format_get(Text *text);
|
TextFormatType *ED_text_format_get(struct Text *text);
|
||||||
void ED_text_format_register(TextFormatType *tft);
|
void ED_text_format_register(TextFormatType *tft);
|
||||||
|
|
||||||
/* formatters */
|
/* formatters */
|
||||||
void ED_text_format_register_py(void);
|
void ED_text_format_register_py();
|
||||||
void ED_text_format_register_osl(void);
|
void ED_text_format_register_osl();
|
||||||
void ED_text_format_register_lua(void);
|
void ED_text_format_register_lua();
|
||||||
void ED_text_format_register_pov(void);
|
void ED_text_format_register_pov();
|
||||||
void ED_text_format_register_pov_ini(void);
|
void ED_text_format_register_pov_ini();
|
||||||
|
|
||||||
#define STR_LITERAL_STARTSWITH(str, str_literal, len_var) \
|
#define STR_LITERAL_STARTSWITH(str, str_literal, len_var) \
|
||||||
(strncmp(str, str_literal, len_var = (sizeof(str_literal) - 1)) == 0)
|
(strncmp(str, str_literal, len_var = (sizeof(str_literal) - 1)) == 0)
|
||||||
|
|
||||||
|
/* Workaround `C1061` with MSVC (looks like a bug),
|
||||||
|
* this can be removed if the issue is resolved.
|
||||||
|
*
|
||||||
|
* Add #MSVC_WORKAROUND_BREAK to break up else-if's blocks to be under 128.
|
||||||
|
* `_keep_me` just ensures #MSVC_WORKAROUND_BREAK follows an #MSVC_WORKAROUND_INIT. */
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
# define MSVC_WORKAROUND_INIT(i) \
|
||||||
|
char _keep_me = 0; \
|
||||||
|
i = -1; \
|
||||||
|
((void)0)
|
||||||
|
# define MSVC_WORKAROUND_BREAK(i) \
|
||||||
|
} \
|
||||||
|
((void)_keep_me); \
|
||||||
|
if (i != -1) {
|
||||||
|
#else
|
||||||
|
# define MSVC_WORKAROUND_INIT(i) ((void)0)
|
||||||
|
# define MSVC_WORKAROUND_BREAK(i)
|
||||||
|
#endif
|
|
@ -6,7 +6,7 @@
|
||||||
* \ingroup sptext
|
* \ingroup sptext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "BKE_text.h"
|
#include "BKE_text.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
|
|
||||||
/* *** Lua Keywords (for format_line) *** */
|
/* *** Lua Keywords (for format_line) *** */
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
int len, i;
|
int len, i;
|
||||||
|
|
||||||
/* Get continuation from previous line */
|
/* Get continuation from previous line */
|
||||||
if (line->prev && line->prev->format != NULL) {
|
if (line->prev && line->prev->format != nullptr) {
|
||||||
fmt = line->prev->format;
|
fmt = line->prev->format;
|
||||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||||
|
@ -183,7 +183,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get original continuation from this line */
|
/* Get original continuation from this line */
|
||||||
if (line->format != NULL) {
|
if (line->format != nullptr) {
|
||||||
fmt = line->format;
|
fmt = line->format;
|
||||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||||
|
@ -258,7 +258,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
}
|
}
|
||||||
/* Single line comment */
|
/* Single line comment */
|
||||||
else if (*str == '-' && *(str + 1) == '-') {
|
else if (*str == '-' && *(str + 1) == '-') {
|
||||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||||
}
|
}
|
||||||
else if (ELEM(*str, '"', '\'')) {
|
else if (ELEM(*str, '"', '\'')) {
|
||||||
/* Strings */
|
/* Strings */
|
||||||
|
@ -336,10 +336,10 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
flatten_string_free(&fs);
|
flatten_string_free(&fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ED_text_format_register_lua(void)
|
void ED_text_format_register_lua()
|
||||||
{
|
{
|
||||||
static TextFormatType tft = {NULL};
|
static TextFormatType tft = {nullptr};
|
||||||
static const char *ext[] = {"lua", NULL};
|
static const char *ext[] = {"lua", nullptr};
|
||||||
|
|
||||||
tft.format_identifier = txtfmt_lua_format_identifier;
|
tft.format_identifier = txtfmt_lua_format_identifier;
|
||||||
tft.format_line = txtfmt_lua_format_line;
|
tft.format_line = txtfmt_lua_format_line;
|
|
@ -6,7 +6,7 @@
|
||||||
* \ingroup sptext
|
* \ingroup sptext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "BKE_text.h"
|
#include "BKE_text.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
|
|
||||||
/* *** Local Functions (for format_line) *** */
|
/* *** Local Functions (for format_line) *** */
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
int len, i;
|
int len, i;
|
||||||
|
|
||||||
/* Get continuation from previous line */
|
/* Get continuation from previous line */
|
||||||
if (line->prev && line->prev->format != NULL) {
|
if (line->prev && line->prev->format != nullptr) {
|
||||||
fmt = line->prev->format;
|
fmt = line->prev->format;
|
||||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||||
|
@ -209,7 +209,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get original continuation from this line */
|
/* Get original continuation from this line */
|
||||||
if (line->format != NULL) {
|
if (line->format != nullptr) {
|
||||||
fmt = line->format;
|
fmt = line->format;
|
||||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||||
|
@ -271,7 +271,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
/* Deal with comments first */
|
/* Deal with comments first */
|
||||||
if (*str == '/' && *(str + 1) == '/') {
|
if (*str == '/' && *(str + 1) == '/') {
|
||||||
/* fill the remaining line */
|
/* fill the remaining line */
|
||||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||||
}
|
}
|
||||||
/* C-Style (multi-line) comments */
|
/* C-Style (multi-line) comments */
|
||||||
else if (*str == '/' && *(str + 1) == '*') {
|
else if (*str == '/' && *(str + 1) == '*') {
|
||||||
|
@ -354,10 +354,10 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
flatten_string_free(&fs);
|
flatten_string_free(&fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ED_text_format_register_osl(void)
|
void ED_text_format_register_osl()
|
||||||
{
|
{
|
||||||
static TextFormatType tft = {NULL};
|
static TextFormatType tft = {nullptr};
|
||||||
static const char *ext[] = {"osl", NULL};
|
static const char *ext[] = {"osl", nullptr};
|
||||||
|
|
||||||
tft.format_identifier = txtfmt_osl_format_identifier;
|
tft.format_identifier = txtfmt_osl_format_identifier;
|
||||||
tft.format_line = txtfmt_osl_format_line;
|
tft.format_line = txtfmt_osl_format_line;
|
|
@ -6,7 +6,7 @@
|
||||||
* \ingroup sptext
|
* \ingroup sptext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "BKE_text.h"
|
#include "BKE_text.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
|
|
||||||
/* *** POV Keywords (for format_line) *** */
|
/* *** POV Keywords (for format_line) *** */
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ static int txtfmt_pov_find_reserved_keywords(const char *string)
|
||||||
|
|
||||||
/* Keep aligned args for readability. */
|
/* Keep aligned args for readability. */
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
|
MSVC_WORKAROUND_INIT(i);
|
||||||
|
|
||||||
/* Float Functions */
|
/* Float Functions */
|
||||||
if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) { i = len;
|
if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) { i = len;
|
||||||
|
@ -185,6 +186,7 @@ static int txtfmt_pov_find_reserved_keywords(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "sky", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "sky", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "up", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "up", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "ln", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "ln", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
/* Color Identifiers */
|
/* Color Identifiers */
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "filter", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "filter", len)) { i = len;
|
||||||
|
@ -248,6 +250,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||||
|
|
||||||
/* Keep aligned args for readability. */
|
/* Keep aligned args for readability. */
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
|
MSVC_WORKAROUND_INIT(i);
|
||||||
|
|
||||||
/* Language Keywords */
|
/* Language Keywords */
|
||||||
if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) { i = len;
|
if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) { i = len;
|
||||||
|
@ -319,6 +322,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "now", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "now", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "pot", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "pot", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "type", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "type", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
/* Animation Options */
|
/* Animation Options */
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) { i = len;
|
||||||
|
@ -332,6 +336,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "clock", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "clock", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
/* Spline Identifiers */
|
/* Spline Identifiers */
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "extended_x_spline", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "extended_x_spline", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "general_x_spline", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "general_x_spline", len)) { i = len;
|
||||||
|
@ -347,6 +352,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
/* Patterns */
|
/* Patterns */
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) { i = len;
|
||||||
|
@ -399,6 +405,7 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "wood", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "wood", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "agate", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "agate", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
/* Objects */
|
/* Objects */
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "bicubic_patch", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "bicubic_patch", len)) { i = len;
|
||||||
|
@ -467,13 +474,12 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||||
} else { i = 0;
|
} else { i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clang-format off */
|
/* clang-format on */
|
||||||
|
|
||||||
/* If next source char is an identifier (eg. 'i' in "definite") no match */
|
/* If next source char is an identifier (eg. 'i' in "definite") no match */
|
||||||
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
|
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the specified source string for a POV modifiers. This
|
* Checks the specified source string for a POV modifiers. This
|
||||||
* name must start at the beginning of the source string and must be followed
|
* name must start at the beginning of the source string and must be followed
|
||||||
|
@ -488,6 +494,11 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
|
||||||
static int txtfmt_pov_find_specialvar(const char *string)
|
static int txtfmt_pov_find_specialvar(const char *string)
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len;
|
||||||
|
|
||||||
|
/* Keep aligned args for readability. */
|
||||||
|
/* clang-format off */
|
||||||
|
MSVC_WORKAROUND_INIT(i);
|
||||||
|
|
||||||
/* Modifiers */
|
/* Modifiers */
|
||||||
if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) { i = len;
|
if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) { i = len;
|
||||||
|
@ -579,6 +590,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "distance", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "distance", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) { i = len;
|
||||||
|
@ -633,6 +645,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "open", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "open", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "ior", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "ior", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
/* Light Types and options. */
|
/* Light Types and options. */
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) { i = len;
|
||||||
|
@ -643,6 +656,7 @@ static int txtfmt_pov_find_specialvar(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "radius", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "radius", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
/* Camera Types and options. */
|
/* Camera Types and options. */
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) { i = len;
|
||||||
|
@ -687,6 +701,8 @@ static int txtfmt_pov_find_specialvar(const char *string)
|
||||||
} else { i = 0;
|
} else { i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
/* If next source char is an identifier (eg. 'i' in "definite") no match */
|
/* If next source char is an identifier (eg. 'i' in "definite") no match */
|
||||||
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
|
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
|
||||||
}
|
}
|
||||||
|
@ -772,7 +788,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
int len, i;
|
int len, i;
|
||||||
|
|
||||||
/* Get continuation from previous line */
|
/* Get continuation from previous line */
|
||||||
if (line->prev && line->prev->format != NULL) {
|
if (line->prev && line->prev->format != nullptr) {
|
||||||
fmt = line->prev->format;
|
fmt = line->prev->format;
|
||||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||||
|
@ -782,7 +798,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get original continuation from this line */
|
/* Get original continuation from this line */
|
||||||
if (line->format != NULL) {
|
if (line->format != nullptr) {
|
||||||
fmt = line->format;
|
fmt = line->format;
|
||||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||||
|
@ -851,7 +867,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
}
|
}
|
||||||
/* Single line comment */
|
/* Single line comment */
|
||||||
else if (*str == '/' && *(str + 1) == '/') {
|
else if (*str == '/' && *(str + 1) == '/') {
|
||||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||||
}
|
}
|
||||||
else if (ELEM(*str, '"', '\'')) {
|
else if (ELEM(*str, '"', '\'')) {
|
||||||
/* Strings */
|
/* Strings */
|
||||||
|
@ -931,10 +947,10 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
|
||||||
flatten_string_free(&fs);
|
flatten_string_free(&fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ED_text_format_register_pov(void)
|
void ED_text_format_register_pov()
|
||||||
{
|
{
|
||||||
static TextFormatType tft = {NULL};
|
static TextFormatType tft = {nullptr};
|
||||||
static const char *ext[] = {"pov", "inc", "mcr", "mac", NULL};
|
static const char *ext[] = {"pov", "inc", "mcr", "mac", nullptr};
|
||||||
|
|
||||||
tft.format_identifier = txtfmt_pov_format_identifier;
|
tft.format_identifier = txtfmt_pov_format_identifier;
|
||||||
tft.format_line = txtfmt_pov_format_line;
|
tft.format_line = txtfmt_pov_format_line;
|
|
@ -6,7 +6,7 @@
|
||||||
* \ingroup sptext
|
* \ingroup sptext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "BKE_text.h"
|
#include "BKE_text.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
|
|
||||||
/* *** POV INI Keywords (for format_line) *** */
|
/* *** POV INI Keywords (for format_line) *** */
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ static int txtfmt_ini_find_reserved(const char *string)
|
||||||
|
|
||||||
/* Keep aligned args for readability. */
|
/* Keep aligned args for readability. */
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
|
MSVC_WORKAROUND_INIT(i);
|
||||||
/* POV-Ray Built-in INI Variables
|
/* POV-Ray Built-in INI Variables
|
||||||
* list is from...
|
* list is from...
|
||||||
* http://www.povray.org/documentation/view/3.7.0/212/
|
* http://www.povray.org/documentation/view/3.7.0/212/
|
||||||
|
@ -158,6 +158,7 @@ static int txtfmt_ini_find_reserved(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "Display", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "Display", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "Version", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "Version", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "Pause_When_Done", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "Pause_When_Done", len)) { i = len;
|
||||||
|
@ -208,6 +209,7 @@ static int txtfmt_ini_find_reserved(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "WarningColour", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "WarningColour", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "ErrorColour", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "ErrorColour", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "BackgroundColour", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "BackgroundColour", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "DropToEditor", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "DropToEditor", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "LastRenderName", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "LastRenderName", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "LastRenderPath", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "LastRenderPath", len)) { i = len;
|
||||||
|
@ -268,6 +270,7 @@ static int txtfmt_ini_find_reserved(const char *string)
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "Font", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "Font", len)) { i = len;
|
||||||
|
MSVC_WORKAROUND_BREAK(i)
|
||||||
/* File-types. */
|
/* File-types. */
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "df3", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "df3", len)) { i = len;
|
||||||
} else if (STR_LITERAL_STARTSWITH(string, "exr", len)) { i = len;
|
} else if (STR_LITERAL_STARTSWITH(string, "exr", len)) { i = len;
|
||||||
|
@ -357,7 +360,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
|
||||||
int len, i;
|
int len, i;
|
||||||
|
|
||||||
/* Get continuation from previous line */
|
/* Get continuation from previous line */
|
||||||
if (line->prev && line->prev->format != NULL) {
|
if (line->prev && line->prev->format != nullptr) {
|
||||||
fmt = line->prev->format;
|
fmt = line->prev->format;
|
||||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||||
|
@ -367,7 +370,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get original continuation from this line */
|
/* Get original continuation from this line */
|
||||||
if (line->format != NULL) {
|
if (line->format != nullptr) {
|
||||||
fmt = line->format;
|
fmt = line->format;
|
||||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||||
|
@ -429,7 +432,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
|
||||||
/* Multi-line comments not supported */
|
/* Multi-line comments not supported */
|
||||||
/* Single line comment */
|
/* Single line comment */
|
||||||
if (*str == ';') {
|
if (*str == ';') {
|
||||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||||
}
|
}
|
||||||
else if (ELEM(*str, '"', '\'')) {
|
else if (ELEM(*str, '"', '\'')) {
|
||||||
/* Strings */
|
/* Strings */
|
||||||
|
@ -507,10 +510,10 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
|
||||||
flatten_string_free(&fs);
|
flatten_string_free(&fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ED_text_format_register_pov_ini(void)
|
void ED_text_format_register_pov_ini()
|
||||||
{
|
{
|
||||||
static TextFormatType tft = {NULL};
|
static TextFormatType tft = {nullptr};
|
||||||
static const char *ext[] = {"ini", NULL};
|
static const char *ext[] = {"ini", nullptr};
|
||||||
|
|
||||||
tft.format_identifier = txtfmt_pov_ini_format_identifier;
|
tft.format_identifier = txtfmt_pov_ini_format_identifier;
|
||||||
tft.format_line = txtfmt_pov_ini_format_line;
|
tft.format_line = txtfmt_pov_ini_format_line;
|
|
@ -6,7 +6,7 @@
|
||||||
* \ingroup sptext
|
* \ingroup sptext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include "BKE_text.h"
|
#include "BKE_text.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
|
|
||||||
/* *** Local Functions (for format_line) *** */
|
/* *** Local Functions (for format_line) *** */
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ static uint txtfmt_py_numeral_string_count_zeros(const char *string)
|
||||||
|
|
||||||
static int txtfmt_py_find_numeral_inner(const char *string)
|
static int txtfmt_py_find_numeral_inner(const char *string)
|
||||||
{
|
{
|
||||||
if (string == NULL || *string == '\0') {
|
if (string == nullptr || *string == '\0') {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ static int txtfmt_py_find_numeral_inner(const char *string)
|
||||||
|
|
||||||
static int txtfmt_py_literal_numeral(const char *string, char prev_fmt)
|
static int txtfmt_py_literal_numeral(const char *string, char prev_fmt)
|
||||||
{
|
{
|
||||||
if (string == NULL || *string == '\0') {
|
if (string == nullptr || *string == '\0') {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
|
||||||
int len, i;
|
int len, i;
|
||||||
|
|
||||||
/* Get continuation from previous line */
|
/* Get continuation from previous line */
|
||||||
if (line->prev && line->prev->format != NULL) {
|
if (line->prev && line->prev->format != nullptr) {
|
||||||
fmt = line->prev->format;
|
fmt = line->prev->format;
|
||||||
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
BLI_assert((FMT_CONT_ALL & cont) == cont);
|
||||||
|
@ -349,7 +349,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get original continuation from this line */
|
/* Get original continuation from this line */
|
||||||
if (line->format != NULL) {
|
if (line->format != nullptr) {
|
||||||
fmt = line->format;
|
fmt = line->format;
|
||||||
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
cont_orig = fmt[strlen(fmt) + 1]; /* Just after the null-terminator */
|
||||||
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
BLI_assert((FMT_CONT_ALL & cont_orig) == cont_orig);
|
||||||
|
@ -411,7 +411,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
|
||||||
/* Deal with comments first */
|
/* Deal with comments first */
|
||||||
if (*str == '#') {
|
if (*str == '#') {
|
||||||
/* fill the remaining line */
|
/* fill the remaining line */
|
||||||
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format));
|
text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - int(fmt - line->format));
|
||||||
}
|
}
|
||||||
else if (ELEM(*str, '"', '\'')) {
|
else if (ELEM(*str, '"', '\'')) {
|
||||||
/* Strings */
|
/* Strings */
|
||||||
|
@ -546,10 +546,10 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
|
||||||
flatten_string_free(&fs);
|
flatten_string_free(&fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ED_text_format_register_py(void)
|
void ED_text_format_register_py()
|
||||||
{
|
{
|
||||||
static TextFormatType tft = {NULL};
|
static TextFormatType tft = {nullptr};
|
||||||
static const char *ext[] = {"py", NULL};
|
static const char *ext[] = {"py", nullptr};
|
||||||
|
|
||||||
tft.format_identifier = txtfmt_py_format_identifier;
|
tft.format_identifier = txtfmt_py_format_identifier;
|
||||||
tft.format_line = txtfmt_py_format_line;
|
tft.format_line = txtfmt_py_format_line;
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
|
|
||||||
#include "text_intern.h"
|
#include "text_intern.hh"
|
||||||
|
|
||||||
/* ************************ header area region *********************** */
|
/* ************************ header area region *********************** */
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ static ARegion *text_has_properties_region(ScrArea *area)
|
||||||
region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
|
region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
|
||||||
|
|
||||||
/* is error! */
|
/* is error! */
|
||||||
if (region == NULL) {
|
if (region == nullptr) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
arnew = MEM_callocN(sizeof(ARegion), "properties region");
|
arnew = static_cast<ARegion *>(MEM_callocN(sizeof(ARegion), "properties region"));
|
||||||
|
|
||||||
BLI_insertlinkafter(&area->regionbase, region, arnew);
|
BLI_insertlinkafter(&area->regionbase, region, arnew);
|
||||||
arnew->regiontype = RGN_TYPE_UI;
|
arnew->regiontype = RGN_TYPE_UI;
|
||||||
|
@ -57,10 +57,10 @@ static ARegion *text_has_properties_region(ScrArea *area)
|
||||||
|
|
||||||
static bool text_properties_poll(bContext *C)
|
static bool text_properties_poll(bContext *C)
|
||||||
{
|
{
|
||||||
return (CTX_wm_space_text(C) != NULL);
|
return (CTX_wm_space_text(C) != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_text_search_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
ScrArea *area = CTX_wm_area(C);
|
ScrArea *area = CTX_wm_area(C);
|
||||||
ARegion *region = text_has_properties_region(area);
|
ARegion *region = text_has_properties_region(area);
|
|
@ -6,8 +6,8 @@
|
||||||
* \ingroup sptext
|
* \ingroup sptext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@
|
||||||
# include "BPY_extern_run.h"
|
# include "BPY_extern_run.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
#include "text_intern.h"
|
#include "text_intern.hh"
|
||||||
|
|
||||||
static void txt_screen_clamp(SpaceText *st, ARegion *region);
|
static void txt_screen_clamp(SpaceText *st, ARegion *region);
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ static char *buf_tabs_to_spaces(const char *in_buf, const int tab_size, int *r_o
|
||||||
|
|
||||||
/* Allocate output before with extra space for expanded tabs. */
|
/* Allocate output before with extra space for expanded tabs. */
|
||||||
const int out_size = strlen(in_buf) + num_tabs * (tab_size - 1) + 1;
|
const int out_size = strlen(in_buf) + num_tabs * (tab_size - 1) + 1;
|
||||||
char *out_buf = MEM_mallocN(out_size * sizeof(char), __func__);
|
char *out_buf = static_cast<char *>(MEM_mallocN(out_size * sizeof(char), __func__));
|
||||||
|
|
||||||
/* Fill output buffer. */
|
/* Fill output buffer. */
|
||||||
int spaces_until_tab = 0;
|
int spaces_until_tab = 0;
|
||||||
|
@ -169,8 +169,8 @@ static void text_select_update_primary_clipboard(const Text *text)
|
||||||
if (!txt_has_sel(text)) {
|
if (!txt_has_sel(text)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char *buf = txt_sel_to_buf(text, NULL);
|
char *buf = txt_sel_to_buf(text, nullptr);
|
||||||
if (buf == NULL) {
|
if (buf == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WM_clipboard_text_set(buf, true);
|
WM_clipboard_text_set(buf, true);
|
||||||
|
@ -183,7 +183,7 @@ static void text_select_update_primary_clipboard(const Text *text)
|
||||||
/** \name Operator Poll
|
/** \name Operator Poll
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static bool text_new_poll(bContext *UNUSED(C))
|
static bool text_new_poll(bContext * /*C*/)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ void text_update_edited(Text *text)
|
||||||
{
|
{
|
||||||
TextLine *line;
|
TextLine *line;
|
||||||
|
|
||||||
for (line = text->lines.first; line; line = line->next) {
|
for (line = static_cast<TextLine *>(text->lines.first); line; line = line->next) {
|
||||||
text_update_line_edited(line);
|
text_update_line_edited(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ void text_update_edited(Text *text)
|
||||||
/** \name New Operator
|
/** \name New Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_new_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
|
@ -298,7 +298,7 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
|
||||||
|
|
||||||
if (prop) {
|
if (prop) {
|
||||||
RNA_id_pointer_create(&text->id, &idptr);
|
RNA_id_pointer_create(&text->id, &idptr);
|
||||||
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
|
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
|
||||||
RNA_property_update(C, &ptr, prop);
|
RNA_property_update(C, &ptr, prop);
|
||||||
}
|
}
|
||||||
else if (st) {
|
else if (st) {
|
||||||
|
@ -338,13 +338,14 @@ void TEXT_OT_new(wmOperatorType *ot)
|
||||||
|
|
||||||
static void text_open_init(bContext *C, wmOperator *op)
|
static void text_open_init(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
PropertyPointerRNA *pprop;
|
PropertyPointerRNA *pprop = static_cast<PropertyPointerRNA *>(
|
||||||
|
MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"));
|
||||||
|
|
||||||
op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA");
|
op->customdata = pprop;
|
||||||
UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop);
|
UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void text_open_cancel(bContext *UNUSED(C), wmOperator *op)
|
static void text_open_cancel(bContext * /*C*/, wmOperator *op)
|
||||||
{
|
{
|
||||||
MEM_freeN(op->customdata);
|
MEM_freeN(op->customdata);
|
||||||
}
|
}
|
||||||
|
@ -375,11 +376,11 @@ static int text_open_exec(bContext *C, wmOperator *op)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* hook into UI */
|
/* hook into UI */
|
||||||
pprop = op->customdata;
|
pprop = static_cast<PropertyPointerRNA *>(op->customdata);
|
||||||
|
|
||||||
if (pprop->prop) {
|
if (pprop->prop) {
|
||||||
RNA_id_pointer_create(&text->id, &idptr);
|
RNA_id_pointer_create(&text->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);
|
RNA_property_update(C, &pprop->ptr, pprop->prop);
|
||||||
}
|
}
|
||||||
else if (st) {
|
else if (st) {
|
||||||
|
@ -398,7 +399,7 @@ static int text_open_exec(bContext *C, wmOperator *op)
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||||
{
|
{
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
@ -440,7 +441,7 @@ void TEXT_OT_open(wmOperatorType *ot)
|
||||||
FILE_DEFAULTDISPLAY,
|
FILE_DEFAULTDISPLAY,
|
||||||
FILE_SORT_DEFAULT); /* TODO: relative_path. */
|
FILE_SORT_DEFAULT); /* TODO: relative_path. */
|
||||||
RNA_def_boolean(
|
RNA_def_boolean(
|
||||||
ot->srna, "internal", 0, "Make Internal", "Make text file internal after loading");
|
ot->srna, "internal", false, "Make Internal", "Make text file internal after loading");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -462,7 +463,7 @@ static int text_reload_exec(bContext *C, wmOperator *op)
|
||||||
|
|
||||||
/* Don't make this part of 'poll', since 'Alt-R' will type 'R',
|
/* Don't make this part of 'poll', since 'Alt-R' will type 'R',
|
||||||
* if poll checks for the filename. */
|
* if poll checks for the filename. */
|
||||||
if (text->filepath == NULL) {
|
if (text->filepath == nullptr) {
|
||||||
BKE_report(op->reports, RPT_ERROR, "This text has not been saved");
|
BKE_report(op->reports, RPT_ERROR, "This text has not been saved");
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
@ -516,10 +517,10 @@ void TEXT_OT_reload(wmOperatorType *ot)
|
||||||
static bool text_unlink_poll(bContext *C)
|
static bool text_unlink_poll(bContext *C)
|
||||||
{
|
{
|
||||||
/* it should be possible to unlink texts if they're lib-linked in... */
|
/* it should be possible to unlink texts if they're lib-linked in... */
|
||||||
return CTX_data_edit_text(C) != NULL;
|
return CTX_data_edit_text(C) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_unlink_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
|
@ -528,11 +529,11 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op))
|
||||||
/* make the previous text active, if its not there make the next text active */
|
/* make the previous text active, if its not there make the next text active */
|
||||||
if (st) {
|
if (st) {
|
||||||
if (text->id.prev) {
|
if (text->id.prev) {
|
||||||
st->text = text->id.prev;
|
st->text = static_cast<Text *>(text->id.prev);
|
||||||
text_update_cursor_moved(C);
|
text_update_cursor_moved(C);
|
||||||
}
|
}
|
||||||
else if (text->id.next) {
|
else if (text->id.next) {
|
||||||
st->text = text->id.next;
|
st->text = static_cast<Text *>(text->id.next);
|
||||||
text_update_cursor_moved(C);
|
text_update_cursor_moved(C);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -540,7 +541,7 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op))
|
||||||
BKE_id_delete(bmain, text);
|
BKE_id_delete(bmain, text);
|
||||||
|
|
||||||
text_drawcache_tag_update(st, true);
|
text_drawcache_tag_update(st, true);
|
||||||
WM_event_add_notifier(C, NC_TEXT | NA_REMOVED, NULL);
|
WM_event_add_notifier(C, NC_TEXT | NA_REMOVED, nullptr);
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
@ -567,7 +568,7 @@ void TEXT_OT_unlink(wmOperatorType *ot)
|
||||||
/** \name Make Internal Operator
|
/** \name Make Internal Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_make_internal_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_make_internal_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
|
||||||
|
@ -620,7 +621,7 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = BLI_fopen(filepath, "w");
|
fp = BLI_fopen(filepath, "w");
|
||||||
if (fp == NULL) {
|
if (fp == nullptr) {
|
||||||
BKE_reportf(reports,
|
BKE_reportf(reports,
|
||||||
RPT_ERROR,
|
RPT_ERROR,
|
||||||
"Unable to save '%s': %s",
|
"Unable to save '%s': %s",
|
||||||
|
@ -629,7 +630,7 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tmp = text->lines.first; tmp; tmp = tmp->next) {
|
for (tmp = static_cast<TextLine *>(text->lines.first); tmp; tmp = tmp->next) {
|
||||||
fputs(tmp->line, fp);
|
fputs(tmp->line, fp);
|
||||||
if (tmp->next) {
|
if (tmp->next) {
|
||||||
fputc('\n', fp);
|
fputc('\n', fp);
|
||||||
|
@ -674,8 +675,8 @@ static int text_save_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
|
||||||
/* Internal and texts without a filepath will go to "Save As". */
|
/* Internal and texts without a filepath will go to "Save As". */
|
||||||
if (text->filepath == NULL || (text->flags & TXT_ISMEM)) {
|
if (text->filepath == nullptr || (text->flags & TXT_ISMEM)) {
|
||||||
WM_operator_name_call(C, "TEXT_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL, event);
|
WM_operator_name_call(C, "TEXT_OT_save_as", WM_OP_INVOKE_DEFAULT, nullptr, event);
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
return text_save_exec(C, op);
|
return text_save_exec(C, op);
|
||||||
|
@ -726,7 +727,7 @@ static int text_save_as_exec(bContext *C, wmOperator *op)
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||||
{
|
{
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
@ -784,7 +785,7 @@ static int text_run_script(bContext *C, ReportList *reports)
|
||||||
{
|
{
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
const bool is_live = (reports == NULL);
|
const bool is_live = (reports == nullptr);
|
||||||
|
|
||||||
/* only for comparison */
|
/* only for comparison */
|
||||||
void *curl_prev = text->curl;
|
void *curl_prev = text->curl;
|
||||||
|
@ -793,7 +794,7 @@ static int text_run_script(bContext *C, ReportList *reports)
|
||||||
if (BPY_run_text(C, text, reports, !is_live)) {
|
if (BPY_run_text(C, text, reports, !is_live)) {
|
||||||
if (is_live) {
|
if (is_live) {
|
||||||
/* for nice live updates */
|
/* for nice live updates */
|
||||||
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL);
|
WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, nullptr);
|
||||||
}
|
}
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
@ -852,7 +853,7 @@ void TEXT_OT_run_script(wmOperatorType *ot)
|
||||||
/** \name Refresh Pyconstraints Operator
|
/** \name Refresh Pyconstraints Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
|
static int text_refresh_pyconstraints_exec(bContext * /*C*/, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
# if 0
|
# if 0
|
||||||
|
@ -955,7 +956,7 @@ static int text_paste_exec(bContext *C, wmOperator *op)
|
||||||
|
|
||||||
/* run the script while editing, evil but useful */
|
/* run the script while editing, evil but useful */
|
||||||
if (st->live_edit) {
|
if (st->live_edit) {
|
||||||
text_run_script(C, NULL);
|
text_run_script(C, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
|
@ -979,7 +980,7 @@ void TEXT_OT_paste(wmOperatorType *ot)
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
prop = RNA_def_boolean(ot->srna,
|
prop = RNA_def_boolean(ot->srna,
|
||||||
"selection",
|
"selection",
|
||||||
0,
|
false,
|
||||||
"Selection",
|
"Selection",
|
||||||
"Paste text selected elsewhere rather than copied (X11/Wayland only)");
|
"Paste text selected elsewhere rather than copied (X11/Wayland only)");
|
||||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||||
|
@ -991,7 +992,7 @@ void TEXT_OT_paste(wmOperatorType *ot)
|
||||||
/** \name Duplicate Operator
|
/** \name Duplicate Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_duplicate_line_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_duplicate_line_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
|
||||||
|
@ -1003,7 +1004,7 @@ static int text_duplicate_line_exec(bContext *C, wmOperator *UNUSED(op))
|
||||||
|
|
||||||
/* run the script while editing, evil but useful */
|
/* run the script while editing, evil but useful */
|
||||||
if (CTX_wm_space_text(C)->live_edit) {
|
if (CTX_wm_space_text(C)->live_edit) {
|
||||||
text_run_script(C, NULL);
|
text_run_script(C, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
|
@ -1038,15 +1039,15 @@ static void txt_copy_clipboard(Text *text)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = txt_sel_to_buf(text, NULL);
|
buf = txt_sel_to_buf(text, nullptr);
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
WM_clipboard_text_set(buf, 0);
|
WM_clipboard_text_set(buf, false);
|
||||||
MEM_freeN(buf);
|
MEM_freeN(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_copy_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
|
||||||
|
@ -1073,7 +1074,7 @@ void TEXT_OT_copy(wmOperatorType *ot)
|
||||||
/** \name Cut Operator
|
/** \name Cut Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_cut_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_cut_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
@ -1090,7 +1091,7 @@ static int text_cut_exec(bContext *C, wmOperator *UNUSED(op))
|
||||||
|
|
||||||
/* run the script while editing, evil but useful */
|
/* run the script while editing, evil but useful */
|
||||||
if (st->live_edit) {
|
if (st->live_edit) {
|
||||||
text_run_script(C, NULL);
|
text_run_script(C, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
|
@ -1117,16 +1118,16 @@ void TEXT_OT_cut(wmOperatorType *ot)
|
||||||
/** \name Indent or Autocomplete Operator
|
/** \name Indent or Autocomplete Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_indent_or_autocomplete_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_indent_or_autocomplete_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
TextLine *line = text->curl;
|
TextLine *line = text->curl;
|
||||||
bool text_before_cursor = text->curc != 0 && !ELEM(line->line[text->curc - 1], ' ', '\t');
|
bool text_before_cursor = text->curc != 0 && !ELEM(line->line[text->curc - 1], ' ', '\t');
|
||||||
if (text_before_cursor && (txt_has_sel(text) == false)) {
|
if (text_before_cursor && (txt_has_sel(text) == false)) {
|
||||||
WM_operator_name_call(C, "TEXT_OT_autocomplete", WM_OP_INVOKE_DEFAULT, NULL, NULL);
|
WM_operator_name_call(C, "TEXT_OT_autocomplete", WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WM_operator_name_call(C, "TEXT_OT_indent", WM_OP_EXEC_DEFAULT, NULL, NULL);
|
WM_operator_name_call(C, "TEXT_OT_indent", WM_OP_EXEC_DEFAULT, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1153,7 @@ void TEXT_OT_indent_or_autocomplete(wmOperatorType *ot)
|
||||||
/** \name Indent Operator
|
/** \name Indent Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_indent_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_indent_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
@ -1198,7 +1199,7 @@ void TEXT_OT_indent(wmOperatorType *ot)
|
||||||
/** \name Unindent Operator
|
/** \name Unindent Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_unindent_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_unindent_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
@ -1239,7 +1240,7 @@ void TEXT_OT_unindent(wmOperatorType *ot)
|
||||||
/** \name Line Break Operator
|
/** \name Line Break Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_line_break_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_line_break_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
@ -1336,10 +1337,10 @@ static int text_comment_exec(bContext *C, wmOperator *op)
|
||||||
void TEXT_OT_comment_toggle(wmOperatorType *ot)
|
void TEXT_OT_comment_toggle(wmOperatorType *ot)
|
||||||
{
|
{
|
||||||
static const EnumPropertyItem comment_items[] = {
|
static const EnumPropertyItem comment_items[] = {
|
||||||
{0, "TOGGLE", 0, "Toggle Comments", NULL},
|
{0, "TOGGLE", 0, "Toggle Comments", nullptr},
|
||||||
{1, "COMMENT", 0, "Comment", NULL},
|
{1, "COMMENT", 0, "Comment", nullptr},
|
||||||
{-1, "UNCOMMENT", 0, "Un-Comment", NULL},
|
{-1, "UNCOMMENT", 0, "Un-Comment", nullptr},
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* identifiers */
|
/* identifiers */
|
||||||
|
@ -1356,7 +1357,7 @@ void TEXT_OT_comment_toggle(wmOperatorType *ot)
|
||||||
/* properties */
|
/* properties */
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
prop = RNA_def_enum(ot->srna, "type", comment_items, 0, "Type", "Add or remove comments");
|
prop = RNA_def_enum(ot->srna, "type", comment_items, 0, "Type", "Add or remove comments");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -1367,9 +1368,9 @@ void TEXT_OT_comment_toggle(wmOperatorType *ot)
|
||||||
|
|
||||||
enum { TO_SPACES, TO_TABS };
|
enum { TO_SPACES, TO_TABS };
|
||||||
static const EnumPropertyItem whitespace_type_items[] = {
|
static const EnumPropertyItem whitespace_type_items[] = {
|
||||||
{TO_SPACES, "SPACES", 0, "To Spaces", NULL},
|
{TO_SPACES, "SPACES", 0, "To Spaces", nullptr},
|
||||||
{TO_TABS, "TABS", 0, "To Tabs", NULL},
|
{TO_TABS, "TABS", 0, "To Tabs", nullptr},
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
||||||
|
@ -1383,7 +1384,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
||||||
|
|
||||||
/* first convert to all space, this make it a lot easier to convert to tabs
|
/* first convert to all space, this make it a lot easier to convert to tabs
|
||||||
* because there is no mixtures of ' ' && '\t' */
|
* because there is no mixtures of ' ' && '\t' */
|
||||||
for (tmp = text->lines.first; tmp; tmp = tmp->next) {
|
for (tmp = static_cast<TextLine *>(text->lines.first); tmp; tmp = tmp->next) {
|
||||||
char *new_line;
|
char *new_line;
|
||||||
|
|
||||||
BLI_assert(tmp->line);
|
BLI_assert(tmp->line);
|
||||||
|
@ -1400,16 +1401,16 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
||||||
/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
|
/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
|
||||||
tmp->line = new_line;
|
tmp->line = new_line;
|
||||||
tmp->len = strlen(new_line);
|
tmp->len = strlen(new_line);
|
||||||
tmp->format = NULL;
|
tmp->format = nullptr;
|
||||||
if (tmp->len > max_len) {
|
if (tmp->len > max_len) {
|
||||||
max_len = tmp->len;
|
max_len = tmp->len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == TO_TABS) {
|
if (type == TO_TABS) {
|
||||||
char *tmp_line = MEM_mallocN(sizeof(*tmp_line) * (max_len + 1), __func__);
|
char *tmp_line = static_cast<char *>(MEM_mallocN(sizeof(*tmp_line) * (max_len + 1), __func__));
|
||||||
|
|
||||||
for (tmp = text->lines.first; tmp; tmp = tmp->next) {
|
for (tmp = static_cast<TextLine *>(text->lines.first); tmp; tmp = tmp->next) {
|
||||||
const char *text_check_line = tmp->line;
|
const char *text_check_line = tmp->line;
|
||||||
const int text_check_line_len = tmp->len;
|
const int text_check_line_len = tmp->len;
|
||||||
char *tmp_line_cur = tmp_line;
|
char *tmp_line_cur = tmp_line;
|
||||||
|
@ -1476,7 +1477,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
|
||||||
* still need to try and set the curc correctly. */
|
* still need to try and set the curc correctly. */
|
||||||
tmp->line = BLI_strdup(tmp_line);
|
tmp->line = BLI_strdup(tmp_line);
|
||||||
tmp->len = strlen(tmp_line);
|
tmp->len = strlen(tmp_line);
|
||||||
tmp->format = NULL;
|
tmp->format = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1520,7 +1521,7 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot)
|
||||||
/** \name Select All Operator
|
/** \name Select All Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_select_all_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_select_all_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
|
||||||
|
@ -1552,7 +1553,7 @@ void TEXT_OT_select_all(wmOperatorType *ot)
|
||||||
/** \name Select Line Operator
|
/** \name Select Line Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_select_line_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_select_line_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
|
||||||
|
@ -1584,7 +1585,7 @@ void TEXT_OT_select_line(wmOperatorType *ot)
|
||||||
/** \name Select Word Operator
|
/** \name Select Word Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_select_word_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_select_word_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
|
||||||
|
@ -1631,7 +1632,7 @@ static int move_lines_exec(bContext *C, wmOperator *op)
|
||||||
|
|
||||||
/* run the script while editing, evil but useful */
|
/* run the script while editing, evil but useful */
|
||||||
if (CTX_wm_space_text(C)->live_edit) {
|
if (CTX_wm_space_text(C)->live_edit) {
|
||||||
text_run_script(C, NULL);
|
text_run_script(C, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
|
@ -1642,7 +1643,7 @@ void TEXT_OT_move_lines(wmOperatorType *ot)
|
||||||
static const EnumPropertyItem direction_items[] = {
|
static const EnumPropertyItem direction_items[] = {
|
||||||
{TXT_MOVE_LINE_UP, "UP", 0, "Up", ""},
|
{TXT_MOVE_LINE_UP, "UP", 0, "Up", ""},
|
||||||
{TXT_MOVE_LINE_DOWN, "DOWN", 0, "Down", ""},
|
{TXT_MOVE_LINE_DOWN, "DOWN", 0, "Down", ""},
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* identifiers */
|
/* identifiers */
|
||||||
|
@ -1680,7 +1681,7 @@ static const EnumPropertyItem move_type_items[] = {
|
||||||
{NEXT_LINE, "NEXT_LINE", 0, "Next Line", ""},
|
{NEXT_LINE, "NEXT_LINE", 0, "Next Line", ""},
|
||||||
{PREV_PAGE, "PREVIOUS_PAGE", 0, "Previous Page", ""},
|
{PREV_PAGE, "PREVIOUS_PAGE", 0, "Previous Page", ""},
|
||||||
{NEXT_PAGE, "NEXT_PAGE", 0, "Next Page", ""},
|
{NEXT_PAGE, "NEXT_PAGE", 0, "Next Page", ""},
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* get cursor position in line by relative wrapped line and column positions */
|
/* get cursor position in line by relative wrapped line and column positions */
|
||||||
|
@ -2170,7 +2171,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
|
||||||
|
|
||||||
/* ensure we have the right region, it's optional */
|
/* ensure we have the right region, it's optional */
|
||||||
if (region && region->regiontype != RGN_TYPE_WINDOW) {
|
if (region && region->regiontype != RGN_TYPE_WINDOW) {
|
||||||
region = NULL;
|
region = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -2263,7 +2264,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
|
||||||
cursor_skip(st, region, st->text, -st->runtime.viewlines, select);
|
cursor_skip(st, region, st->text, -st->runtime.viewlines, select);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cursor_skip(NULL, NULL, text, -10, select);
|
cursor_skip(nullptr, nullptr, text, -10, select);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2272,7 +2273,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
|
||||||
cursor_skip(st, region, st->text, st->runtime.viewlines, select);
|
cursor_skip(st, region, st->text, st->runtime.viewlines, select);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cursor_skip(NULL, NULL, text, 10, select);
|
cursor_skip(nullptr, nullptr, text, 10, select);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2291,7 +2292,7 @@ static int text_move_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
int type = RNA_enum_get(op->ptr, "type");
|
int type = RNA_enum_get(op->ptr, "type");
|
||||||
|
|
||||||
return text_move_cursor(C, type, 0);
|
return text_move_cursor(C, type, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEXT_OT_move(wmOperatorType *ot)
|
void TEXT_OT_move(wmOperatorType *ot)
|
||||||
|
@ -2319,7 +2320,7 @@ static int text_move_select_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
int type = RNA_enum_get(op->ptr, "type");
|
int type = RNA_enum_get(op->ptr, "type");
|
||||||
|
|
||||||
return text_move_cursor(C, type, 1);
|
return text_move_cursor(C, type, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEXT_OT_move_select(wmOperatorType *ot)
|
void TEXT_OT_move_select(wmOperatorType *ot)
|
||||||
|
@ -2352,16 +2353,18 @@ static int text_jump_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
int line = RNA_int_get(op->ptr, "line");
|
int line = RNA_int_get(op->ptr, "line");
|
||||||
short nlines = txt_get_span(text->lines.first, text->lines.last) + 1;
|
short nlines = txt_get_span(static_cast<TextLine *>(text->lines.first),
|
||||||
|
static_cast<TextLine *>(text->lines.last)) +
|
||||||
|
1;
|
||||||
|
|
||||||
if (line < 1) {
|
if (line < 1) {
|
||||||
txt_move_toline(text, 1, 0);
|
txt_move_toline(text, 1, false);
|
||||||
}
|
}
|
||||||
else if (line > nlines) {
|
else if (line > nlines) {
|
||||||
txt_move_toline(text, nlines - 1, 0);
|
txt_move_toline(text, nlines - 1, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
txt_move_toline(text, line - 1, 0);
|
txt_move_toline(text, line - 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
text_update_cursor_moved(C);
|
text_update_cursor_moved(C);
|
||||||
|
@ -2370,7 +2373,7 @@ static int text_jump_exec(bContext *C, wmOperator *op)
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_jump_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
static int text_jump_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||||
{
|
{
|
||||||
return WM_operator_props_dialog_popup(C, op, 200);
|
return WM_operator_props_dialog_popup(C, op, 200);
|
||||||
}
|
}
|
||||||
|
@ -2405,7 +2408,7 @@ static const EnumPropertyItem delete_type_items[] = {
|
||||||
{DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
|
{DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
|
||||||
{DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
|
{DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
|
||||||
{DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
|
{DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int text_delete_exec(bContext *C, wmOperator *op)
|
static int text_delete_exec(bContext *C, wmOperator *op)
|
||||||
|
@ -2492,7 +2495,7 @@ static int text_delete_exec(bContext *C, wmOperator *op)
|
||||||
|
|
||||||
/* run the script while editing, evil but useful */
|
/* run the script while editing, evil but useful */
|
||||||
if (st->live_edit) {
|
if (st->live_edit) {
|
||||||
text_run_script(C, NULL);
|
text_run_script(C, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
|
@ -2520,7 +2523,7 @@ void TEXT_OT_delete(wmOperatorType *ot)
|
||||||
DEL_NEXT_CHAR,
|
DEL_NEXT_CHAR,
|
||||||
"Type",
|
"Type",
|
||||||
"Which part of the text to delete");
|
"Which part of the text to delete");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -2529,7 +2532,7 @@ void TEXT_OT_delete(wmOperatorType *ot)
|
||||||
/** \name Toggle Overwrite Operator
|
/** \name Toggle Overwrite Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_toggle_overwrite_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_toggle_overwrite_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
|
|
||||||
|
@ -2588,7 +2591,7 @@ enum eScrollZone {
|
||||||
SCROLLHANDLE_MAX_OUTSIDE,
|
SCROLLHANDLE_MAX_OUTSIDE,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct TextScroll {
|
struct TextScroll {
|
||||||
int mval_prev[2];
|
int mval_prev[2];
|
||||||
int mval_delta[2];
|
int mval_delta[2];
|
||||||
|
|
||||||
|
@ -2605,7 +2608,7 @@ typedef struct TextScroll {
|
||||||
} state;
|
} state;
|
||||||
int ofs_delta[2];
|
int ofs_delta[2];
|
||||||
int ofs_delta_px[2];
|
int ofs_delta_px[2];
|
||||||
} TextScroll;
|
};
|
||||||
|
|
||||||
static void text_scroll_state_init(TextScroll *tsc, SpaceText *st, ARegion *region)
|
static void text_scroll_state_init(TextScroll *tsc, SpaceText *st, ARegion *region)
|
||||||
{
|
{
|
||||||
|
@ -2624,7 +2627,7 @@ static bool text_scroll_poll(bContext *C)
|
||||||
{
|
{
|
||||||
/* it should be possible to still scroll linked texts to read them,
|
/* it should be possible to still scroll linked texts to read them,
|
||||||
* even if they can't be edited... */
|
* even if they can't be edited... */
|
||||||
return CTX_data_edit_text(C) != NULL;
|
return CTX_data_edit_text(C) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_scroll_exec(bContext *C, wmOperator *op)
|
static int text_scroll_exec(bContext *C, wmOperator *op)
|
||||||
|
@ -2648,7 +2651,7 @@ static int text_scroll_exec(bContext *C, wmOperator *op)
|
||||||
static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
TextScroll *tsc = op->customdata;
|
TextScroll *tsc = static_cast<TextScroll *>(op->customdata);
|
||||||
const int mval[2] = {event->xy[0], event->xy[1]};
|
const int mval[2] = {event->xy[0], event->xy[1]};
|
||||||
|
|
||||||
text_update_character_width(st);
|
text_update_character_width(st);
|
||||||
|
@ -2737,7 +2740,7 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
static void scroll_exit(bContext *C, wmOperator *op)
|
static void scroll_exit(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
TextScroll *tsc = op->customdata;
|
TextScroll *tsc = static_cast<TextScroll *>(op->customdata);
|
||||||
|
|
||||||
st->flags &= ~ST_SCROLL_SELECT;
|
st->flags &= ~ST_SCROLL_SELECT;
|
||||||
|
|
||||||
|
@ -2754,7 +2757,7 @@ static void scroll_exit(bContext *C, wmOperator *op)
|
||||||
|
|
||||||
static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
TextScroll *tsc = op->customdata;
|
TextScroll *tsc = static_cast<TextScroll *>(op->customdata);
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
ARegion *region = CTX_wm_region(C);
|
ARegion *region = CTX_wm_region(C);
|
||||||
|
|
||||||
|
@ -2800,7 +2803,7 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
return text_scroll_exec(C, op);
|
return text_scroll_exec(C, op);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsc = MEM_callocN(sizeof(TextScroll), "TextScroll");
|
tsc = static_cast<TextScroll *>(MEM_callocN(sizeof(TextScroll), "TextScroll"));
|
||||||
tsc->is_first = true;
|
tsc->is_first = true;
|
||||||
tsc->zone = SCROLLHANDLE_BAR;
|
tsc->zone = SCROLLHANDLE_BAR;
|
||||||
|
|
||||||
|
@ -2868,14 +2871,14 @@ static bool text_region_scroll_poll(bContext *C)
|
||||||
ARegion *region = CTX_wm_region(C);
|
ARegion *region = CTX_wm_region(C);
|
||||||
|
|
||||||
if (!st || !text) {
|
if (!st || !text) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!region || region->regiontype != RGN_TYPE_WINDOW) {
|
if (!region || region->regiontype != RGN_TYPE_WINDOW) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
|
@ -2915,7 +2918,7 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
|
||||||
return OPERATOR_PASS_THROUGH;
|
return OPERATOR_PASS_THROUGH;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsc = MEM_callocN(sizeof(TextScroll), "TextScroll");
|
tsc = static_cast<TextScroll *>(MEM_callocN(sizeof(TextScroll), "TextScroll"));
|
||||||
tsc->is_first = true;
|
tsc->is_first = true;
|
||||||
tsc->is_scrollbar = true;
|
tsc->is_scrollbar = true;
|
||||||
tsc->zone = zone;
|
tsc->zone = zone;
|
||||||
|
@ -2969,11 +2972,11 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
|
||||||
/** \name Set Selection Operator
|
/** \name Set Selection Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
typedef struct SetSelection {
|
struct SetSelection {
|
||||||
int selc, sell;
|
int selc, sell;
|
||||||
short mval_prev[2];
|
short mval_prev[2];
|
||||||
wmTimer *timer; /* needed for scrolling when mouse at region bounds */
|
wmTimer *timer; /* needed for scrolling when mouse at region bounds */
|
||||||
} SetSelection;
|
};
|
||||||
|
|
||||||
static int flatten_width(SpaceText *st, const char *str)
|
static int flatten_width(SpaceText *st, const char *str)
|
||||||
{
|
{
|
||||||
|
@ -3016,11 +3019,11 @@ static int flatten_column_to_offset(SpaceText *st, const char *str, int index)
|
||||||
|
|
||||||
static TextLine *get_line_pos_wrapped(SpaceText *st, ARegion *region, int *y)
|
static TextLine *get_line_pos_wrapped(SpaceText *st, ARegion *region, int *y)
|
||||||
{
|
{
|
||||||
TextLine *linep = st->text->lines.first;
|
TextLine *linep = static_cast<TextLine *>(st->text->lines.first);
|
||||||
int i, lines;
|
int i, lines;
|
||||||
|
|
||||||
if (*y < -st->top) {
|
if (*y < -st->top) {
|
||||||
return NULL; /* We are beyond the first line... */
|
return nullptr; /* We are beyond the first line... */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = -st->top; i <= *y && linep; linep = linep->next, i += lines) {
|
for (i = -st->top; i <= *y && linep; linep = linep->next, i += lines) {
|
||||||
|
@ -3142,11 +3145,11 @@ static void text_cursor_set_to_pos_wrapped(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (y < 0) { /* Before start of text. */
|
else if (y < 0) { /* Before start of text. */
|
||||||
linep = st->text->lines.first;
|
linep = static_cast<TextLine *>(st->text->lines.first);
|
||||||
charp = 0;
|
charp = 0;
|
||||||
}
|
}
|
||||||
else { /* Beyond end of text */
|
else { /* Beyond end of text */
|
||||||
linep = st->text->lines.last;
|
linep = static_cast<TextLine *>(st->text->lines.last);
|
||||||
charp = linep->len;
|
charp = linep->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3191,7 +3194,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *region, int x, int y,
|
||||||
charp = &text->curc;
|
charp = &text->curc;
|
||||||
}
|
}
|
||||||
|
|
||||||
y -= txt_get_span(text->lines.first, *linep) - st->top;
|
y -= txt_get_span(static_cast<TextLine *>(text->lines.first), *linep) - st->top;
|
||||||
|
|
||||||
if (y > 0) {
|
if (y > 0) {
|
||||||
while (y-- != 0) {
|
while (y-- != 0) {
|
||||||
|
@ -3223,7 +3226,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *region, int x, int y,
|
||||||
|
|
||||||
static void text_cursor_timer_ensure(bContext *C, SetSelection *ssel)
|
static void text_cursor_timer_ensure(bContext *C, SetSelection *ssel)
|
||||||
{
|
{
|
||||||
if (ssel->timer == NULL) {
|
if (ssel->timer == nullptr) {
|
||||||
wmWindowManager *wm = CTX_wm_manager(C);
|
wmWindowManager *wm = CTX_wm_manager(C);
|
||||||
wmWindow *win = CTX_wm_window(C);
|
wmWindow *win = CTX_wm_window(C);
|
||||||
|
|
||||||
|
@ -3239,20 +3242,20 @@ static void text_cursor_timer_remove(bContext *C, SetSelection *ssel)
|
||||||
|
|
||||||
WM_event_remove_timer(wm, win, ssel->timer);
|
WM_event_remove_timer(wm, win, ssel->timer);
|
||||||
}
|
}
|
||||||
ssel->timer = NULL;
|
ssel->timer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
ARegion *region = CTX_wm_region(C);
|
ARegion *region = CTX_wm_region(C);
|
||||||
SetSelection *ssel = op->customdata;
|
SetSelection *ssel = static_cast<SetSelection *>(op->customdata);
|
||||||
|
|
||||||
if (event->mval[1] < 0 || event->mval[1] > region->winy) {
|
if (event->mval[1] < 0 || event->mval[1] > region->winy) {
|
||||||
text_cursor_timer_ensure(C, ssel);
|
text_cursor_timer_ensure(C, ssel);
|
||||||
|
|
||||||
if (event->type == TIMER) {
|
if (event->type == TIMER) {
|
||||||
text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], 1);
|
text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], true);
|
||||||
ED_text_scroll_to_cursor(st, region, false);
|
ED_text_scroll_to_cursor(st, region, false);
|
||||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
||||||
}
|
}
|
||||||
|
@ -3262,7 +3265,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev
|
||||||
|
|
||||||
if (event->type == TIMER) {
|
if (event->type == TIMER) {
|
||||||
text_cursor_set_to_pos(
|
text_cursor_set_to_pos(
|
||||||
st, region, CLAMPIS(event->mval[0], 0, region->winx), event->mval[1], 1);
|
st, region, CLAMPIS(event->mval[0], 0, region->winx), event->mval[1], true);
|
||||||
ED_text_scroll_to_cursor(st, region, false);
|
ED_text_scroll_to_cursor(st, region, false);
|
||||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
||||||
}
|
}
|
||||||
|
@ -3271,7 +3274,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev
|
||||||
text_cursor_timer_remove(C, ssel);
|
text_cursor_timer_remove(C, ssel);
|
||||||
|
|
||||||
if (event->type != TIMER) {
|
if (event->type != TIMER) {
|
||||||
text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], 1);
|
text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], true);
|
||||||
ED_text_scroll_to_cursor(st, region, false);
|
ED_text_scroll_to_cursor(st, region, false);
|
||||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
||||||
|
|
||||||
|
@ -3284,7 +3287,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev
|
||||||
static void text_cursor_set_exit(bContext *C, wmOperator *op)
|
static void text_cursor_set_exit(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
SetSelection *ssel = op->customdata;
|
SetSelection *ssel = static_cast<SetSelection *>(op->customdata);
|
||||||
|
|
||||||
text_update_cursor_moved(C);
|
text_update_cursor_moved(C);
|
||||||
text_select_update_primary_clipboard(st->text);
|
text_select_update_primary_clipboard(st->text);
|
||||||
|
@ -3305,12 +3308,12 @@ static int text_selection_set_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
op->customdata = MEM_callocN(sizeof(SetSelection), "SetCursor");
|
op->customdata = MEM_callocN(sizeof(SetSelection), "SetCursor");
|
||||||
ssel = op->customdata;
|
ssel = static_cast<SetSelection *>(op->customdata);
|
||||||
|
|
||||||
ssel->mval_prev[0] = event->mval[0];
|
ssel->mval_prev[0] = event->mval[0];
|
||||||
ssel->mval_prev[1] = event->mval[1];
|
ssel->mval_prev[1] = event->mval[1];
|
||||||
|
|
||||||
ssel->sell = txt_get_span(st->text->lines.first, st->text->sell);
|
ssel->sell = txt_get_span(static_cast<TextLine *>(st->text->lines.first), st->text->sell);
|
||||||
ssel->selc = st->text->selc;
|
ssel->selc = st->text->selc;
|
||||||
|
|
||||||
WM_event_add_modal_handler(C, op);
|
WM_event_add_modal_handler(C, op);
|
||||||
|
@ -3369,7 +3372,7 @@ static int text_cursor_set_exec(bContext *C, wmOperator *op)
|
||||||
int x = RNA_int_get(op->ptr, "x");
|
int x = RNA_int_get(op->ptr, "x");
|
||||||
int y = RNA_int_get(op->ptr, "y");
|
int y = RNA_int_get(op->ptr, "y");
|
||||||
|
|
||||||
text_cursor_set_to_pos(st, region, x, y, 0);
|
text_cursor_set_to_pos(st, region, x, y, false);
|
||||||
|
|
||||||
text_update_cursor_moved(C);
|
text_update_cursor_moved(C);
|
||||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
|
||||||
|
@ -3414,7 +3417,7 @@ void TEXT_OT_cursor_set(wmOperatorType *ot)
|
||||||
/** \name Line Number Operator
|
/** \name Line Number Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
static int text_line_number_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
|
@ -3448,9 +3451,9 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm
|
||||||
}
|
}
|
||||||
|
|
||||||
jump_to *= 10;
|
jump_to *= 10;
|
||||||
jump_to += (int)(event_ascii - '0');
|
jump_to += int(event_ascii - '0');
|
||||||
|
|
||||||
txt_move_toline(text, jump_to - 1, 0);
|
txt_move_toline(text, jump_to - 1, false);
|
||||||
last_jump = time;
|
last_jump = time;
|
||||||
|
|
||||||
text_update_cursor_moved(C);
|
text_update_cursor_moved(C);
|
||||||
|
@ -3489,7 +3492,7 @@ static int text_insert_exec(bContext *C, wmOperator *op)
|
||||||
|
|
||||||
text_drawcache_tag_update(st, false);
|
text_drawcache_tag_update(st, false);
|
||||||
|
|
||||||
str = RNA_string_get_alloc(op->ptr, "text", NULL, 0, &str_len);
|
str = RNA_string_get_alloc(op->ptr, "text", nullptr, 0, &str_len);
|
||||||
|
|
||||||
ED_text_undo_push_init(C);
|
ED_text_undo_push_init(C);
|
||||||
|
|
||||||
|
@ -3561,7 +3564,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
|
|
||||||
/* run the script while editing, evil but useful */
|
/* run the script while editing, evil but useful */
|
||||||
if (ret == OPERATOR_FINISHED && st->live_edit) {
|
if (ret == OPERATOR_FINISHED && st->live_edit) {
|
||||||
text_run_script(C, NULL);
|
text_run_script(C, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -3586,7 +3589,7 @@ void TEXT_OT_insert(wmOperatorType *ot)
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
prop = RNA_def_string(
|
prop = RNA_def_string(
|
||||||
ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position");
|
ot->srna, "text", nullptr, 0, "Text", "Text to insert at the cursor position");
|
||||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3597,8 +3600,10 @@ void TEXT_OT_insert(wmOperatorType *ot)
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
/* mode */
|
/* mode */
|
||||||
#define TEXT_FIND 0
|
enum {
|
||||||
#define TEXT_REPLACE 1
|
TEXT_FIND = 0,
|
||||||
|
TEXT_REPLACE = 1,
|
||||||
|
};
|
||||||
|
|
||||||
static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||||
{
|
{
|
||||||
|
@ -3620,7 +3625,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||||
|
|
||||||
/* Replace current */
|
/* Replace current */
|
||||||
if (mode != TEXT_FIND && txt_has_sel(text)) {
|
if (mode != TEXT_FIND && txt_has_sel(text)) {
|
||||||
tmp = txt_sel_to_buf(text, NULL);
|
tmp = txt_sel_to_buf(text, nullptr);
|
||||||
|
|
||||||
if (flags & ST_MATCH_CASE) {
|
if (flags & ST_MATCH_CASE) {
|
||||||
found = STREQ(st->findstr, tmp);
|
found = STREQ(st->findstr, tmp);
|
||||||
|
@ -3635,7 +3640,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||||
txt_insert_buf(text, st->replacestr, strlen(st->replacestr));
|
txt_insert_buf(text, st->replacestr, strlen(st->replacestr));
|
||||||
if (text->curl && text->curl->format) {
|
if (text->curl && text->curl->format) {
|
||||||
MEM_freeN(text->curl->format);
|
MEM_freeN(text->curl->format);
|
||||||
text->curl->format = NULL;
|
text->curl->format = nullptr;
|
||||||
}
|
}
|
||||||
text_update_cursor_moved(C);
|
text_update_cursor_moved(C);
|
||||||
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
|
||||||
|
@ -3643,7 +3648,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MEM_freeN(tmp);
|
MEM_freeN(tmp);
|
||||||
tmp = NULL;
|
tmp = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find next */
|
/* Find next */
|
||||||
|
@ -3653,12 +3658,12 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
|
||||||
}
|
}
|
||||||
else if (flags & ST_FIND_ALL) {
|
else if (flags & ST_FIND_ALL) {
|
||||||
if (text->id.next) {
|
if (text->id.next) {
|
||||||
text = st->text = text->id.next;
|
text = st->text = static_cast<Text *>(text->id.next);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
text = st->text = bmain->texts.first;
|
text = st->text = static_cast<Text *>(bmain->texts.first);
|
||||||
}
|
}
|
||||||
txt_move_toline(text, 0, 0);
|
txt_move_toline(text, 0, false);
|
||||||
text_update_cursor_moved(C);
|
text_update_cursor_moved(C);
|
||||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
|
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
|
||||||
}
|
}
|
||||||
|
@ -3719,7 +3724,7 @@ static int text_replace_all(bContext *C)
|
||||||
txt_insert_buf(text, st->replacestr, strlen(st->replacestr));
|
txt_insert_buf(text, st->replacestr, strlen(st->replacestr));
|
||||||
if (text->curl && text->curl->format) {
|
if (text->curl && text->curl->format) {
|
||||||
MEM_freeN(text->curl->format);
|
MEM_freeN(text->curl->format);
|
||||||
text->curl->format = NULL;
|
text->curl->format = nullptr;
|
||||||
}
|
}
|
||||||
found = txt_find_string(text, st->findstr, 0, flags & ST_MATCH_CASE);
|
found = txt_find_string(text, st->findstr, 0, flags & ST_MATCH_CASE);
|
||||||
} while (found);
|
} while (found);
|
||||||
|
@ -3762,7 +3767,7 @@ void TEXT_OT_replace(wmOperatorType *ot)
|
||||||
/* properties */
|
/* properties */
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
prop = RNA_def_boolean(ot->srna, "all", false, "Replace All", "Replace all occurrences");
|
prop = RNA_def_boolean(ot->srna, "all", false, "Replace All", "Replace all occurrences");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -3777,7 +3782,7 @@ static int text_find_set_selected_exec(bContext *C, wmOperator *op)
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
tmp = txt_sel_to_buf(text, NULL);
|
tmp = txt_sel_to_buf(text, nullptr);
|
||||||
STRNCPY(st->findstr, tmp);
|
STRNCPY(st->findstr, tmp);
|
||||||
MEM_freeN(tmp);
|
MEM_freeN(tmp);
|
||||||
|
|
||||||
|
@ -3806,13 +3811,13 @@ void TEXT_OT_find_set_selected(wmOperatorType *ot)
|
||||||
/** \name Replace Set Selected
|
/** \name Replace Set Selected
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static int text_replace_set_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
static int text_replace_set_selected_exec(bContext *C, wmOperator * /*op*/)
|
||||||
{
|
{
|
||||||
SpaceText *st = CTX_wm_space_text(C);
|
SpaceText *st = CTX_wm_space_text(C);
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
tmp = txt_sel_to_buf(text, NULL);
|
tmp = txt_sel_to_buf(text, nullptr);
|
||||||
STRNCPY(st->replacestr, tmp);
|
STRNCPY(st->replacestr, tmp);
|
||||||
MEM_freeN(tmp);
|
MEM_freeN(tmp);
|
||||||
|
|
||||||
|
@ -3851,7 +3856,7 @@ static int text_jump_to_file_at_point_internal_exec(bContext *C, wmOperator *op)
|
||||||
const int column = RNA_int_get(op->ptr, "column");
|
const int column = RNA_int_get(op->ptr, "column");
|
||||||
|
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
Text *text = NULL;
|
Text *text = nullptr;
|
||||||
|
|
||||||
LISTBASE_FOREACH (Text *, text_iter, &bmain->texts) {
|
LISTBASE_FOREACH (Text *, text_iter, &bmain->texts) {
|
||||||
if (text_iter->filepath && BLI_path_cmp(text_iter->filepath, filepath) == 0) {
|
if (text_iter->filepath && BLI_path_cmp(text_iter->filepath, filepath) == 0) {
|
||||||
|
@ -3860,11 +3865,11 @@ static int text_jump_to_file_at_point_internal_exec(bContext *C, wmOperator *op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text == NULL) {
|
if (text == nullptr) {
|
||||||
text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain));
|
text = BKE_text_load(bmain, filepath, BKE_main_blendfile_path(bmain));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text == NULL) {
|
if (text == nullptr) {
|
||||||
BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath);
|
BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath);
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
@ -3897,12 +3902,12 @@ void TEXT_OT_jump_to_file_at_point_internal(wmOperatorType *ot)
|
||||||
/* flags */
|
/* flags */
|
||||||
ot->flag = 0;
|
ot->flag = 0;
|
||||||
|
|
||||||
prop = RNA_def_string(ot->srna, "filepath", NULL, FILE_MAX, "Filepath", "");
|
prop = RNA_def_string(ot->srna, "filepath", nullptr, FILE_MAX, "Filepath", "");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||||
prop = RNA_def_int(ot->srna, "line", 0, 0, INT_MAX, "Line", "Line to jump to", 1, 10000);
|
prop = RNA_def_int(ot->srna, "line", 0, 0, INT_MAX, "Line", "Line to jump to", 1, 10000);
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||||
prop = RNA_def_int(ot->srna, "column", 0, 0, INT_MAX, "Column", "Column to jump to", 1, 10000);
|
prop = RNA_def_int(ot->srna, "column", 0, 0, INT_MAX, "Column", "Column to jump to", 1, 10000);
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PropertyFlag(PROP_HIDDEN | PROP_SKIP_SAVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
@ -3917,7 +3922,7 @@ static const EnumPropertyItem resolution_items[] = {
|
||||||
{RESOLVE_RELOAD, "RELOAD", 0, "Reload", ""},
|
{RESOLVE_RELOAD, "RELOAD", 0, "Reload", ""},
|
||||||
{RESOLVE_SAVE, "SAVE", 0, "Save", ""},
|
{RESOLVE_SAVE, "SAVE", 0, "Save", ""},
|
||||||
{RESOLVE_MAKE_INTERNAL, "MAKE_INTERNAL", 0, "Make Internal", ""},
|
{RESOLVE_MAKE_INTERNAL, "MAKE_INTERNAL", 0, "Make Internal", ""},
|
||||||
{0, NULL, 0, NULL, NULL},
|
{0, nullptr, 0, nullptr, nullptr},
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool text_resolve_conflict_poll(bContext *C)
|
static bool text_resolve_conflict_poll(bContext *C)
|
||||||
|
@ -3928,7 +3933,7 @@ static bool text_resolve_conflict_poll(bContext *C)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((text->filepath != NULL) && !(text->flags & TXT_ISMEM));
|
return ((text->filepath != nullptr) && !(text->flags & TXT_ISMEM));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_resolve_conflict_exec(bContext *C, wmOperator *op)
|
static int text_resolve_conflict_exec(bContext *C, wmOperator *op)
|
||||||
|
@ -3951,7 +3956,7 @@ static int text_resolve_conflict_exec(bContext *C, wmOperator *op)
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||||
{
|
{
|
||||||
Text *text = CTX_data_edit_text(C);
|
Text *text = CTX_data_edit_text(C);
|
||||||
uiPopupMenu *pup;
|
uiPopupMenu *pup;
|
||||||
|
@ -4065,7 +4070,7 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot)
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
RNA_def_boolean(
|
RNA_def_boolean(
|
||||||
ot->srna, "split_lines", 0, "Split Lines", "Create one object per line in the text");
|
ot->srna, "split_lines", false, "Split Lines", "Create one object per line in the text");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
|
@ -6,8 +6,8 @@
|
||||||
* \ingroup sptext
|
* \ingroup sptext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@
|
||||||
#include "RNA_access.h"
|
#include "RNA_access.h"
|
||||||
#include "RNA_define.h"
|
#include "RNA_define.h"
|
||||||
|
|
||||||
#include "text_format.h"
|
#include "text_format.hh"
|
||||||
#include "text_intern.h"
|
#include "text_intern.hh"
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Implements ED Undo System
|
/** \name Implements ED Undo System
|
||||||
|
@ -52,12 +52,12 @@
|
||||||
/**
|
/**
|
||||||
* Only stores the state of a text buffer.
|
* Only stores the state of a text buffer.
|
||||||
*/
|
*/
|
||||||
typedef struct TextState {
|
struct TextState {
|
||||||
BArrayState *buf_array_state;
|
BArrayState *buf_array_state;
|
||||||
|
|
||||||
int cursor_line, cursor_line_select;
|
int cursor_line, cursor_line_select;
|
||||||
int cursor_column, cursor_column_select;
|
int cursor_column, cursor_column_select;
|
||||||
} TextState;
|
};
|
||||||
|
|
||||||
static void text_state_encode(TextState *state, Text *text, BArrayStore *buffer_store)
|
static void text_state_encode(TextState *state, Text *text, BArrayStore *buffer_store)
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ static void text_state_decode(TextState *state, Text *text)
|
||||||
/** \name Implements ED Undo System
|
/** \name Implements ED Undo System
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
typedef struct TextUndoStep {
|
struct TextUndoStep {
|
||||||
UndoStep step;
|
UndoStep step;
|
||||||
UndoRefID_Text text_ref;
|
UndoRefID_Text text_ref;
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +114,7 @@ typedef struct TextUndoStep {
|
||||||
* the second is the state after the operation is done.
|
* the second is the state after the operation is done.
|
||||||
*/
|
*/
|
||||||
TextState states[2];
|
TextState states[2];
|
||||||
} TextUndoStep;
|
};
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
BArrayStore *buffer_store;
|
BArrayStore *buffer_store;
|
||||||
|
|
|
@ -119,7 +119,9 @@ static float transdata_get_time_shuffle_offset_side(ListBase *trans_datas, const
|
||||||
}
|
}
|
||||||
|
|
||||||
total_offset += offset;
|
total_offset += offset;
|
||||||
} while (!IS_EQF(offset, 0.0f));
|
} while (!IS_EQT(offset, 0.0f, 1e-4));
|
||||||
|
/* Needs a eps greater than FLT_EPS because strip->start/end could be non-integral, and after
|
||||||
|
* those calculations, `offset` could fall outside of FLT_EPS. */
|
||||||
|
|
||||||
return total_offset;
|
return total_offset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1385,7 +1385,7 @@ eSnapMode snapObjectsTransform(
|
||||||
SnapObjectParams snap_object_params{};
|
SnapObjectParams snap_object_params{};
|
||||||
snap_object_params.snap_target_select = t->tsnap.target_operation;
|
snap_object_params.snap_target_select = t->tsnap.target_operation;
|
||||||
snap_object_params.edit_mode_type = (t->flag & T_EDIT) != 0 ? SNAP_GEOM_EDIT : SNAP_GEOM_FINAL;
|
snap_object_params.edit_mode_type = (t->flag & T_EDIT) != 0 ? SNAP_GEOM_EDIT : SNAP_GEOM_FINAL;
|
||||||
snap_object_params.use_occlusion_test = t->settings->snap_mode != SCE_SNAP_MODE_FACE;
|
snap_object_params.use_occlusion_test = true;
|
||||||
snap_object_params.use_backface_culling = (t->tsnap.flag & SCE_SNAP_BACKFACE_CULLING) != 0;
|
snap_object_params.use_backface_culling = (t->tsnap.flag & SCE_SNAP_BACKFACE_CULLING) != 0;
|
||||||
|
|
||||||
float *target = (t->tsnap.status & SNAP_SOURCE_FOUND) ? t->tsnap.snap_source : t->center_global;
|
float *target = (t->tsnap.status & SNAP_SOURCE_FOUND) ? t->tsnap.snap_source : t->center_global;
|
||||||
|
|
|
@ -969,7 +969,8 @@ struct RaycastObjUserData {
|
||||||
/* read/write args */
|
/* read/write args */
|
||||||
float *ray_depth;
|
float *ray_depth;
|
||||||
|
|
||||||
bool use_occlusion_test;
|
uint use_occlusion_test : 1;
|
||||||
|
uint use_occlusion_test_edit : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -986,21 +987,17 @@ static eSnapMode raycast_obj_fn(SnapObjectContext *sctx,
|
||||||
{
|
{
|
||||||
RaycastObjUserData *dt = static_cast<RaycastObjUserData *>(data);
|
RaycastObjUserData *dt = static_cast<RaycastObjUserData *>(data);
|
||||||
const uint ob_index = dt->ob_index++;
|
const uint ob_index = dt->ob_index++;
|
||||||
bool use_occlusion_test = dt->use_occlusion_test;
|
|
||||||
/* read/write args */
|
/* read/write args */
|
||||||
float *ray_depth = dt->ray_depth;
|
float *ray_depth = dt->ray_depth;
|
||||||
|
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
bool is_edit = false;
|
bool is_edit = false;
|
||||||
if (use_occlusion_test) {
|
|
||||||
if (ELEM(ob_eval->dt, OB_BOUNDBOX, OB_WIRE)) {
|
|
||||||
/* Do not hit objects that are in wire or bounding box
|
|
||||||
* display mode. */
|
|
||||||
return SCE_SNAP_MODE_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ob_data == nullptr) {
|
if (ob_data == nullptr) {
|
||||||
|
if (dt->use_occlusion_test_edit && ELEM(ob_eval->dt, OB_BOUNDBOX, OB_WIRE)) {
|
||||||
|
/* Do not hit objects that are in wire or bounding box display mode. */
|
||||||
|
return SCE_SNAP_MODE_NONE;
|
||||||
|
}
|
||||||
if (ob_eval->type == OB_MESH) {
|
if (ob_eval->type == OB_MESH) {
|
||||||
BMEditMesh *em = BKE_editmesh_from_object(ob_eval);
|
BMEditMesh *em = BKE_editmesh_from_object(ob_eval);
|
||||||
if (UNLIKELY(!em)) { /* See #mesh_for_snap doc-string. */
|
if (UNLIKELY(!em)) { /* See #mesh_for_snap doc-string. */
|
||||||
|
@ -1028,6 +1025,10 @@ static eSnapMode raycast_obj_fn(SnapObjectContext *sctx,
|
||||||
return SCE_SNAP_MODE_NONE;
|
return SCE_SNAP_MODE_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (dt->use_occlusion_test && ELEM(ob_eval->dt, OB_BOUNDBOX, OB_WIRE)) {
|
||||||
|
/* Do not hit objects that are in wire or bounding box display mode. */
|
||||||
|
return SCE_SNAP_MODE_NONE;
|
||||||
|
}
|
||||||
else if (GS(ob_data->name) != ID_ME) {
|
else if (GS(ob_data->name) != ID_ME) {
|
||||||
return SCE_SNAP_MODE_NONE;
|
return SCE_SNAP_MODE_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1080,26 +1081,20 @@ static bool raycastObjects(SnapObjectContext *sctx,
|
||||||
const SnapObjectParams *params,
|
const SnapObjectParams *params,
|
||||||
const float ray_start[3],
|
const float ray_start[3],
|
||||||
const float ray_dir[3],
|
const float ray_dir[3],
|
||||||
|
const bool use_occlusion_test,
|
||||||
|
const bool use_occlusion_test_edit,
|
||||||
/* read/write args */
|
/* read/write args */
|
||||||
/* Parameters below cannot be const, because they are assigned to a
|
/* Parameters below cannot be const, because they are assigned to a
|
||||||
* non-const variable (readability-non-const-parameter). */
|
* non-const variable (readability-non-const-parameter). */
|
||||||
float *ray_depth /* NOLINT */)
|
float *ray_depth /* NOLINT */)
|
||||||
{
|
{
|
||||||
const View3D *v3d = sctx->runtime.v3d;
|
|
||||||
if (params->use_occlusion_test && v3d && XRAY_FLAG_ENABLED(v3d)) {
|
|
||||||
/* General testing of occlusion geometry is disabled if the snap is not intended for the edit
|
|
||||||
* cage. */
|
|
||||||
if (params->edit_mode_type == SNAP_GEOM_EDIT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RaycastObjUserData data = {};
|
RaycastObjUserData data = {};
|
||||||
data.ray_start = ray_start;
|
data.ray_start = ray_start;
|
||||||
data.ray_dir = ray_dir;
|
data.ray_dir = ray_dir;
|
||||||
data.ob_index = 0;
|
data.ob_index = 0;
|
||||||
data.ray_depth = ray_depth;
|
data.ray_depth = ray_depth;
|
||||||
data.use_occlusion_test = params->use_occlusion_test;
|
data.use_occlusion_test = use_occlusion_test;
|
||||||
|
data.use_occlusion_test_edit = use_occlusion_test_edit;
|
||||||
|
|
||||||
return iter_snap_objects(sctx, params, raycast_obj_fn, &data) != SCE_SNAP_MODE_NONE;
|
return iter_snap_objects(sctx, params, raycast_obj_fn, &data) != SCE_SNAP_MODE_NONE;
|
||||||
}
|
}
|
||||||
|
@ -3117,7 +3112,14 @@ bool ED_transform_snap_object_project_ray_ex(SnapObjectContext *sctx,
|
||||||
sctx->ret.dist_sq = FLT_MAX;
|
sctx->ret.dist_sq = FLT_MAX;
|
||||||
sctx->ret.is_edit = false;
|
sctx->ret.is_edit = false;
|
||||||
|
|
||||||
if (raycastObjects(sctx, params, ray_start, ray_normal, ray_depth)) {
|
if (raycastObjects(sctx,
|
||||||
|
params,
|
||||||
|
ray_start,
|
||||||
|
ray_normal,
|
||||||
|
params->use_occlusion_test,
|
||||||
|
params->use_occlusion_test,
|
||||||
|
ray_depth))
|
||||||
|
{
|
||||||
copy_v3_v3(r_loc, sctx->ret.loc);
|
copy_v3_v3(r_loc, sctx->ret.loc);
|
||||||
if (r_no) {
|
if (r_no) {
|
||||||
copy_v3_v3(r_no, sctx->ret.no);
|
copy_v3_v3(r_no, sctx->ret.no);
|
||||||
|
@ -3167,7 +3169,14 @@ bool ED_transform_snap_object_project_ray_all(SnapObjectContext *sctx,
|
||||||
float ray_depth_prev = ray_depth;
|
float ray_depth_prev = ray_depth;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (raycastObjects(sctx, params, ray_start, ray_normal, &ray_depth)) {
|
if (raycastObjects(sctx,
|
||||||
|
params,
|
||||||
|
ray_start,
|
||||||
|
ray_normal,
|
||||||
|
params->use_occlusion_test,
|
||||||
|
params->use_occlusion_test,
|
||||||
|
&ray_depth))
|
||||||
|
{
|
||||||
if (sort) {
|
if (sort) {
|
||||||
BLI_listbase_sort(r_hit_list, hit_depth_cmp);
|
BLI_listbase_sort(r_hit_list, hit_depth_cmp);
|
||||||
}
|
}
|
||||||
|
@ -3275,17 +3284,21 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont
|
||||||
|
|
||||||
const RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
const RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||||
|
|
||||||
if (snap_to_flag & (SCE_SNAP_MODE_FACE | SCE_SNAP_MODE_FACE_NEAREST)) {
|
bool use_occlusion_test = params->use_occlusion_test;
|
||||||
if (params->use_occlusion_test && XRAY_ENABLED(v3d)) {
|
|
||||||
/* Remove Snap to Face with Occlusion Test as they are not visible in wireframe mode. */
|
if (use_occlusion_test && XRAY_ENABLED(v3d) && (snap_to_flag & SCE_SNAP_MODE_FACE)) {
|
||||||
snap_to_flag &= ~(SCE_SNAP_MODE_FACE | SCE_SNAP_MODE_FACE_NEAREST);
|
if (snap_to_flag != SCE_SNAP_MODE_FACE) {
|
||||||
}
|
/* In theory everything is visible in X-Ray except faces. */
|
||||||
else if (prev_co == nullptr || init_co == nullptr) {
|
snap_to_flag &= ~SCE_SNAP_MODE_FACE;
|
||||||
/* No location to work with #SCE_SNAP_MODE_FACE_NEAREST. */
|
use_occlusion_test = false;
|
||||||
snap_to_flag &= ~SCE_SNAP_MODE_FACE_NEAREST;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((snap_to_flag & SCE_SNAP_MODE_FACE_NEAREST) && ELEM(nullptr, prev_co, init_co)) {
|
||||||
|
/* No location to work with #SCE_SNAP_MODE_FACE_NEAREST. */
|
||||||
|
snap_to_flag &= ~SCE_SNAP_MODE_FACE_NEAREST;
|
||||||
|
}
|
||||||
|
|
||||||
/* NOTE: if both face ray-cast and face nearest are enabled, first find result of nearest, then
|
/* NOTE: if both face ray-cast and face nearest are enabled, first find result of nearest, then
|
||||||
* override with ray-cast. */
|
* override with ray-cast. */
|
||||||
if ((snap_to_flag & SCE_SNAP_MODE_FACE_NEAREST) && !has_hit) {
|
if ((snap_to_flag & SCE_SNAP_MODE_FACE_NEAREST) && !has_hit) {
|
||||||
|
@ -3310,8 +3323,6 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool use_occlusion_test = params->use_occlusion_test && !XRAY_ENABLED(v3d);
|
|
||||||
|
|
||||||
if ((snap_to_flag & SCE_SNAP_MODE_FACE) || use_occlusion_test) {
|
if ((snap_to_flag & SCE_SNAP_MODE_FACE) || use_occlusion_test) {
|
||||||
float ray_start[3], ray_normal[3];
|
float ray_start[3], ray_normal[3];
|
||||||
if (!ED_view3d_win_to_ray_clipped_ex(
|
if (!ED_view3d_win_to_ray_clipped_ex(
|
||||||
|
@ -3322,7 +3333,13 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont
|
||||||
|
|
||||||
float dummy_ray_depth = BVH_RAYCAST_DIST_MAX;
|
float dummy_ray_depth = BVH_RAYCAST_DIST_MAX;
|
||||||
|
|
||||||
has_hit = raycastObjects(sctx, params, ray_start, ray_normal, &dummy_ray_depth);
|
has_hit = raycastObjects(sctx,
|
||||||
|
params,
|
||||||
|
ray_start,
|
||||||
|
ray_normal,
|
||||||
|
use_occlusion_test,
|
||||||
|
use_occlusion_test && (snap_to_flag & SCE_SNAP_MODE_FACE) == 0,
|
||||||
|
&dummy_ray_depth);
|
||||||
|
|
||||||
if (has_hit) {
|
if (has_hit) {
|
||||||
if (r_face_nor) {
|
if (r_face_nor) {
|
||||||
|
|
|
@ -1780,7 +1780,7 @@ static float pack_islands_scale_margin(const Span<PackIsland *> islands,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If some of the islands are locked, we build a summary about them here. */
|
/* If some of the islands are locked, we build a summary about them here. */
|
||||||
rctf locked_bounds; /* AABB of islands which can't translate. */
|
rctf locked_bounds = {0.0f}; /* AABB of islands which can't translate. */
|
||||||
int64_t locked_island_count = 0; /* Index of first non-locked island. */
|
int64_t locked_island_count = 0; /* Index of first non-locked island. */
|
||||||
for (int64_t i = 0; i < islands.size(); i++) {
|
for (int64_t i = 0; i < islands.size(); i++) {
|
||||||
PackIsland *pack_island = islands[i];
|
PackIsland *pack_island = islands[i];
|
||||||
|
|
|
@ -316,32 +316,32 @@ typedef struct GPUSamplerState {
|
||||||
|
|
||||||
/* The sampler state is of type PARAMETERS, so serialize the parameters. */
|
/* The sampler state is of type PARAMETERS, so serialize the parameters. */
|
||||||
BLI_assert(this->type == GPU_SAMPLER_STATE_TYPE_PARAMETERS);
|
BLI_assert(this->type == GPU_SAMPLER_STATE_TYPE_PARAMETERS);
|
||||||
std::string serialized_paramaters;
|
std::string serialized_parameters;
|
||||||
|
|
||||||
if (this->filtering & GPU_SAMPLER_FILTERING_LINEAR) {
|
if (this->filtering & GPU_SAMPLER_FILTERING_LINEAR) {
|
||||||
serialized_paramaters += "linear-filter_";
|
serialized_parameters += "linear-filter_";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->filtering & GPU_SAMPLER_FILTERING_MIPMAP) {
|
if (this->filtering & GPU_SAMPLER_FILTERING_MIPMAP) {
|
||||||
serialized_paramaters += "mipmap_";
|
serialized_parameters += "mipmap_";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->filtering & GPU_SAMPLER_FILTERING_ANISOTROPIC) {
|
if (this->filtering & GPU_SAMPLER_FILTERING_ANISOTROPIC) {
|
||||||
serialized_paramaters += "anisotropic_";
|
serialized_parameters += "anisotropic_";
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this->extend_x) {
|
switch (this->extend_x) {
|
||||||
case GPU_SAMPLER_EXTEND_MODE_EXTEND:
|
case GPU_SAMPLER_EXTEND_MODE_EXTEND:
|
||||||
serialized_paramaters += "extend-x_";
|
serialized_parameters += "extend-x_";
|
||||||
break;
|
break;
|
||||||
case GPU_SAMPLER_EXTEND_MODE_REPEAT:
|
case GPU_SAMPLER_EXTEND_MODE_REPEAT:
|
||||||
serialized_paramaters += "repeat-x_";
|
serialized_parameters += "repeat-x_";
|
||||||
break;
|
break;
|
||||||
case GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT:
|
case GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT:
|
||||||
serialized_paramaters += "mirrored-repeat-x_";
|
serialized_parameters += "mirrored-repeat-x_";
|
||||||
break;
|
break;
|
||||||
case GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER:
|
case GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER:
|
||||||
serialized_paramaters += "clamp-to-border-x_";
|
serialized_parameters += "clamp-to-border-x_";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BLI_assert_unreachable();
|
BLI_assert_unreachable();
|
||||||
|
@ -349,16 +349,16 @@ typedef struct GPUSamplerState {
|
||||||
|
|
||||||
switch (this->extend_yz) {
|
switch (this->extend_yz) {
|
||||||
case GPU_SAMPLER_EXTEND_MODE_EXTEND:
|
case GPU_SAMPLER_EXTEND_MODE_EXTEND:
|
||||||
serialized_paramaters += "extend-y_";
|
serialized_parameters += "extend-y_";
|
||||||
break;
|
break;
|
||||||
case GPU_SAMPLER_EXTEND_MODE_REPEAT:
|
case GPU_SAMPLER_EXTEND_MODE_REPEAT:
|
||||||
serialized_paramaters += "repeat-y_";
|
serialized_parameters += "repeat-y_";
|
||||||
break;
|
break;
|
||||||
case GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT:
|
case GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT:
|
||||||
serialized_paramaters += "mirrored-repeat-y_";
|
serialized_parameters += "mirrored-repeat-y_";
|
||||||
break;
|
break;
|
||||||
case GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER:
|
case GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER:
|
||||||
serialized_paramaters += "clamp-to-border-y_";
|
serialized_parameters += "clamp-to-border-y_";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BLI_assert_unreachable();
|
BLI_assert_unreachable();
|
||||||
|
@ -366,22 +366,22 @@ typedef struct GPUSamplerState {
|
||||||
|
|
||||||
switch (this->extend_yz) {
|
switch (this->extend_yz) {
|
||||||
case GPU_SAMPLER_EXTEND_MODE_EXTEND:
|
case GPU_SAMPLER_EXTEND_MODE_EXTEND:
|
||||||
serialized_paramaters += "extend-z";
|
serialized_parameters += "extend-z";
|
||||||
break;
|
break;
|
||||||
case GPU_SAMPLER_EXTEND_MODE_REPEAT:
|
case GPU_SAMPLER_EXTEND_MODE_REPEAT:
|
||||||
serialized_paramaters += "repeat-z";
|
serialized_parameters += "repeat-z";
|
||||||
break;
|
break;
|
||||||
case GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT:
|
case GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT:
|
||||||
serialized_paramaters += "mirrored-repeat-z";
|
serialized_parameters += "mirrored-repeat-z";
|
||||||
break;
|
break;
|
||||||
case GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER:
|
case GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER:
|
||||||
serialized_paramaters += "clamp-to-border-z";
|
serialized_parameters += "clamp-to-border-z";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BLI_assert_unreachable();
|
BLI_assert_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
return serialized_paramaters;
|
return serialized_parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(GPUSamplerState const &rhs) const
|
bool operator==(GPUSamplerState const &rhs) const
|
||||||
|
|
|
@ -382,8 +382,7 @@ void MTLImmediate::end()
|
||||||
|
|
||||||
/* SSBO vertex fetch - Nullify elements buffer. */
|
/* SSBO vertex fetch - Nullify elements buffer. */
|
||||||
if (rps.cached_vertex_buffer_bindings[MTL_SSBO_VERTEX_FETCH_IBO_INDEX].metal_buffer ==
|
if (rps.cached_vertex_buffer_bindings[MTL_SSBO_VERTEX_FETCH_IBO_INDEX].metal_buffer ==
|
||||||
nil)
|
nil) {
|
||||||
{
|
|
||||||
rps.bind_vertex_buffer(null_buffer, 0, MTL_SSBO_VERTEX_FETCH_IBO_INDEX);
|
rps.bind_vertex_buffer(null_buffer, 0, MTL_SSBO_VERTEX_FETCH_IBO_INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -306,18 +306,19 @@ void MTLBufferPool::update_memory_pools()
|
||||||
deletion_time_threshold_s = 2;
|
deletion_time_threshold_s = 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* Spare pool memory >= 1GB. */
|
/* Spare pool memory >= 1GB. */
|
||||||
if (allocations_in_pool_ >= MEMORY_SIZE_1GB) {
|
if (allocations_in_pool_ >= MEMORY_SIZE_1GB)
|
||||||
deletion_time_threshold_s = 4;
|
{
|
||||||
}
|
deletion_time_threshold_s = 4;
|
||||||
/* Spare pool memory >= 512MB.*/
|
}
|
||||||
else if (allocations_in_pool_ >= MEMORY_SIZE_512MB) {
|
/* Spare pool memory >= 512MB.*/
|
||||||
deletion_time_threshold_s = 15;
|
else if (allocations_in_pool_ >= MEMORY_SIZE_512MB) {
|
||||||
}
|
deletion_time_threshold_s = 15;
|
||||||
/* Spare pool memory >= 256MB. */
|
}
|
||||||
else if (allocations_in_pool_ >= MEMORY_SIZE_256MB) {
|
/* Spare pool memory >= 256MB. */
|
||||||
deletion_time_threshold_s = 60;
|
else if (allocations_in_pool_ >= MEMORY_SIZE_256MB) {
|
||||||
}
|
deletion_time_threshold_s = 60;
|
||||||
|
}
|
||||||
|
|
||||||
if (time_passed > deletion_time_threshold_s) {
|
if (time_passed > deletion_time_threshold_s) {
|
||||||
|
|
||||||
|
|
|
@ -338,8 +338,7 @@ bool MTLShader::finalize(const shader::ShaderCreateInfo *info)
|
||||||
if (error) {
|
if (error) {
|
||||||
/* Only exit out if genuine error and not warning. */
|
/* Only exit out if genuine error and not warning. */
|
||||||
if ([[error localizedDescription] rangeOfString:@"Compilation succeeded"].location ==
|
if ([[error localizedDescription] rangeOfString:@"Compilation succeeded"].location ==
|
||||||
NSNotFound)
|
NSNotFound) {
|
||||||
{
|
|
||||||
const char *errors_c_str = [[error localizedDescription] UTF8String];
|
const char *errors_c_str = [[error localizedDescription] UTF8String];
|
||||||
const char *sources_c_str = shd_builder_->glsl_fragment_source_.c_str();
|
const char *sources_c_str = shd_builder_->glsl_fragment_source_.c_str();
|
||||||
|
|
||||||
|
@ -877,8 +876,7 @@ MTLRenderPipelineStateInstance *MTLShader::bake_pipeline_state(
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (const uint i :
|
for (const uint i :
|
||||||
IndexRange(pipeline_descriptor.vertex_descriptor.max_attribute_value + 1))
|
IndexRange(pipeline_descriptor.vertex_descriptor.max_attribute_value + 1)) {
|
||||||
{
|
|
||||||
|
|
||||||
/* Metal back-end attribute descriptor state. */
|
/* Metal back-end attribute descriptor state. */
|
||||||
const MTLVertexAttributeDescriptorPSO &attribute_desc =
|
const MTLVertexAttributeDescriptorPSO &attribute_desc =
|
||||||
|
@ -1071,8 +1069,7 @@ MTLRenderPipelineStateInstance *MTLShader::bake_pipeline_state(
|
||||||
bool null_pointsize = true;
|
bool null_pointsize = true;
|
||||||
float MTL_pointsize = pipeline_descriptor.point_size;
|
float MTL_pointsize = pipeline_descriptor.point_size;
|
||||||
if (pipeline_descriptor.vertex_descriptor.prim_topology_class ==
|
if (pipeline_descriptor.vertex_descriptor.prim_topology_class ==
|
||||||
MTLPrimitiveTopologyClassPoint)
|
MTLPrimitiveTopologyClassPoint) {
|
||||||
{
|
|
||||||
/* `if pointsize is > 0.0`, PROGRAM_POINT_SIZE is enabled, and `gl_PointSize` shader keyword
|
/* `if pointsize is > 0.0`, PROGRAM_POINT_SIZE is enabled, and `gl_PointSize` shader keyword
|
||||||
* overrides the value. Otherwise, if < 0.0, use global constant point size. */
|
* overrides the value. Otherwise, if < 0.0, use global constant point size. */
|
||||||
if (MTL_pointsize < 0.0) {
|
if (MTL_pointsize < 0.0) {
|
||||||
|
@ -1144,8 +1141,7 @@ MTLRenderPipelineStateInstance *MTLShader::bake_pipeline_state(
|
||||||
|
|
||||||
/* Setup pixel format state */
|
/* Setup pixel format state */
|
||||||
for (int color_attachment = 0; color_attachment < GPU_FB_MAX_COLOR_ATTACHMENT;
|
for (int color_attachment = 0; color_attachment < GPU_FB_MAX_COLOR_ATTACHMENT;
|
||||||
color_attachment++)
|
color_attachment++) {
|
||||||
{
|
|
||||||
/* Fetch color attachment pixel format in back-end pipeline state. */
|
/* Fetch color attachment pixel format in back-end pipeline state. */
|
||||||
MTLPixelFormat pixel_format = pipeline_descriptor.color_attachment_format[color_attachment];
|
MTLPixelFormat pixel_format = pipeline_descriptor.color_attachment_format[color_attachment];
|
||||||
/* Populate MTL API PSO attachment descriptor. */
|
/* Populate MTL API PSO attachment descriptor. */
|
||||||
|
@ -1386,8 +1382,7 @@ bool MTLShader::bake_compute_pipeline_state(MTLContext *ctx)
|
||||||
|
|
||||||
/* Only exit out if genuine error and not warning */
|
/* Only exit out if genuine error and not warning */
|
||||||
if ([[error localizedDescription] rangeOfString:@"Compilation succeeded"].location ==
|
if ([[error localizedDescription] rangeOfString:@"Compilation succeeded"].location ==
|
||||||
NSNotFound)
|
NSNotFound) {
|
||||||
{
|
|
||||||
BLI_assert(false);
|
BLI_assert(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1892,7 +1892,7 @@ bool gpu::MTLTexture::texture_is_baked()
|
||||||
void gpu::MTLTexture::prepare_internal()
|
void gpu::MTLTexture::prepare_internal()
|
||||||
{
|
{
|
||||||
/* Metal: Texture clearing is done using frame-buffer clear. This has no performance impact or
|
/* Metal: Texture clearing is done using frame-buffer clear. This has no performance impact or
|
||||||
* bandwidth implications for lossless compression and is considered best-practise.
|
* bandwidth implications for lossless compression and is considered best-practice.
|
||||||
*
|
*
|
||||||
* Attachment usage also required for depth-stencil attachment targets, for depth-update support.
|
* Attachment usage also required for depth-stencil attachment targets, for depth-update support.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -289,8 +289,6 @@ static void test_texture_roundtrip__GPU_DATA_FLOAT__GPU_RGB10_A2UI()
|
||||||
GPU_TEST(texture_roundtrip__GPU_DATA_FLOAT__GPU_RGB10_A2UI);
|
GPU_TEST(texture_roundtrip__GPU_DATA_FLOAT__GPU_RGB10_A2UI);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void test_texture_roundtrip__GPU_DATA_FLOAT__GPU_R11F_G11F_B10F()
|
static void test_texture_roundtrip__GPU_DATA_FLOAT__GPU_R11F_G11F_B10F()
|
||||||
{
|
{
|
||||||
texture_create_upload_read_with_bias<GPU_R11F_G11F_B10F, GPU_DATA_FLOAT>(0.0009f);
|
texture_create_upload_read_with_bias<GPU_R11F_G11F_B10F, GPU_DATA_FLOAT>(0.0009f);
|
||||||
|
@ -654,18 +652,18 @@ static void test_texture_roundtrip__GPU_DATA_UINT__GPU_RGB32UI()
|
||||||
GPU_TEST(texture_roundtrip__GPU_DATA_UINT__GPU_RGB32UI);
|
GPU_TEST(texture_roundtrip__GPU_DATA_UINT__GPU_RGB32UI);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void test_texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT24()
|
|
||||||
{
|
|
||||||
texture_create_upload_read<GPU_DEPTH_COMPONENT24, GPU_DATA_UINT, uint32_t>();
|
|
||||||
}
|
|
||||||
GPU_TEST(texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT24);
|
|
||||||
|
|
||||||
static void test_texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT32F()
|
static void test_texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT32F()
|
||||||
{
|
{
|
||||||
texture_create_upload_read<GPU_DEPTH_COMPONENT32F, GPU_DATA_UINT, uint32_t>();
|
texture_create_upload_read<GPU_DEPTH_COMPONENT32F, GPU_DATA_UINT, uint32_t>();
|
||||||
}
|
}
|
||||||
GPU_TEST(texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT32F);
|
GPU_TEST(texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT32F);
|
||||||
|
|
||||||
|
static void test_texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT24()
|
||||||
|
{
|
||||||
|
texture_create_upload_read<GPU_DEPTH_COMPONENT24, GPU_DATA_UINT, uint32_t>();
|
||||||
|
}
|
||||||
|
GPU_TEST(texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT24);
|
||||||
|
|
||||||
#if RUN_COMPONENT_UNIMPLEMENTED
|
#if RUN_COMPONENT_UNIMPLEMENTED
|
||||||
static void test_texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT16()
|
static void test_texture_roundtrip__GPU_DATA_UINT__GPU_DEPTH_COMPONENT16()
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,12 +75,14 @@ void VKBackend::platform_init(const VKDevice &device)
|
||||||
|
|
||||||
void VKBackend::detect_workarounds(VKDevice &device)
|
void VKBackend::detect_workarounds(VKDevice &device)
|
||||||
{
|
{
|
||||||
device.workarounds_.depth_component_24 = false;
|
VKWorkarounds workarounds;
|
||||||
|
|
||||||
/* */
|
/* AMD GPUs don't support texture formats that use are aligned to 24 or 48 bits. */
|
||||||
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
|
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
|
||||||
device.workarounds_.depth_component_24 = true;
|
workarounds.not_aligned_pixel_formats = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.workarounds_ = workarounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VKBackend::platform_exit()
|
void VKBackend::platform_exit()
|
||||||
|
|
|
@ -78,8 +78,13 @@ void pop_marker(VkCommandBuffer vk_command_buffer);
|
||||||
void push_marker(const VKDevice &device, const char *name);
|
void push_marker(const VKDevice &device, const char *name);
|
||||||
void set_marker(const VKDevice &device, const char *name);
|
void set_marker(const VKDevice &device, const char *name);
|
||||||
void pop_marker(const VKDevice &device);
|
void pop_marker(const VKDevice &device);
|
||||||
/* how to use : debug::raise_message(0xB41ca2,VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,"This
|
/**
|
||||||
* is a raise message. %llx", (uintptr_t)vk_object); */
|
* How to use:
|
||||||
|
* \code{.cc}
|
||||||
|
* debug::raise_message(0xB41ca2, VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
|
||||||
|
* "This is a raise message. %llx", (uintptr_t)vk_object);
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
void raise_message(int32_t id_number,
|
void raise_message(int32_t id_number,
|
||||||
VkDebugUtilsMessageSeverityFlagBitsEXT vk_severity_flag_bits,
|
VkDebugUtilsMessageSeverityFlagBitsEXT vk_severity_flag_bits,
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
|
|
|
@ -17,6 +17,16 @@
|
||||||
namespace blender::gpu {
|
namespace blender::gpu {
|
||||||
class VKBackend;
|
class VKBackend;
|
||||||
|
|
||||||
|
struct VKWorkarounds {
|
||||||
|
/**
|
||||||
|
* Some devices don't support pixel formats that are aligned to 24 and 48 bits.
|
||||||
|
* In this case we need to use a different texture format.
|
||||||
|
*
|
||||||
|
* If set to true we should work around this issue by using a different texture format.
|
||||||
|
*/
|
||||||
|
bool not_aligned_pixel_formats = false;
|
||||||
|
};
|
||||||
|
|
||||||
class VKDevice : public NonCopyable {
|
class VKDevice : public NonCopyable {
|
||||||
private:
|
private:
|
||||||
/** Copies of the handles owned by the GHOST context. */
|
/** Copies of the handles owned by the GHOST context. */
|
||||||
|
@ -37,11 +47,7 @@ class VKDevice : public NonCopyable {
|
||||||
debug::VKDebuggingTools debugging_tools_;
|
debug::VKDebuggingTools debugging_tools_;
|
||||||
|
|
||||||
/* Workarounds */
|
/* Workarounds */
|
||||||
struct {
|
VKWorkarounds workarounds_;
|
||||||
bool depth_component_24 = false;
|
|
||||||
bool texture_format_rgb16f = false;
|
|
||||||
|
|
||||||
} workarounds_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VkPhysicalDevice physical_device_get() const
|
VkPhysicalDevice physical_device_get() const
|
||||||
|
@ -103,14 +109,9 @@ class VKDevice : public NonCopyable {
|
||||||
std::string vendor_name() const;
|
std::string vendor_name() const;
|
||||||
std::string driver_version() const;
|
std::string driver_version() const;
|
||||||
|
|
||||||
/**
|
const VKWorkarounds &workarounds_get() const
|
||||||
* Some devices don't support `GPU_DEPTH_COMPONENT_24` texture formats.
|
|
||||||
*
|
|
||||||
* Check with this function if the workaround should be used to work around this issue.
|
|
||||||
*/
|
|
||||||
bool get_component_24_workaround() const
|
|
||||||
{
|
{
|
||||||
return workarounds_.depth_component_24;
|
return workarounds_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -266,10 +266,11 @@ bool VKTexture::init_internal()
|
||||||
* allocation of the texture on the device. */
|
* allocation of the texture on the device. */
|
||||||
|
|
||||||
const VKDevice &device = VKBackend::get().device_get();
|
const VKDevice &device = VKBackend::get().device_get();
|
||||||
if (format_ == GPU_DEPTH_COMPONENT24 && device.get_component_24_workaround()) {
|
const VKWorkarounds &workarounds = device.workarounds_get();
|
||||||
|
if (format_ == GPU_DEPTH_COMPONENT24 && workarounds.not_aligned_pixel_formats) {
|
||||||
format_ = GPU_DEPTH_COMPONENT32F;
|
format_ = GPU_DEPTH_COMPONENT32F;
|
||||||
}
|
}
|
||||||
if (format_ == GPU_DEPTH24_STENCIL8 && device.get_component_24_workaround()) {
|
if (format_ == GPU_DEPTH24_STENCIL8 && workarounds.not_aligned_pixel_formats) {
|
||||||
format_ = GPU_DEPTH32F_STENCIL8;
|
format_ = GPU_DEPTH32F_STENCIL8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,6 @@ set(SRC
|
||||||
intern/usd_asset_utils.cc
|
intern/usd_asset_utils.cc
|
||||||
intern/usd_capi_export.cc
|
intern/usd_capi_export.cc
|
||||||
intern/usd_capi_import.cc
|
intern/usd_capi_import.cc
|
||||||
intern/usd_common.cc
|
|
||||||
intern/usd_hierarchy_iterator.cc
|
intern/usd_hierarchy_iterator.cc
|
||||||
intern/usd_writer_abstract.cc
|
intern/usd_writer_abstract.cc
|
||||||
intern/usd_writer_camera.cc
|
intern/usd_writer_camera.cc
|
||||||
|
@ -101,7 +100,6 @@ set(SRC
|
||||||
usd.h
|
usd.h
|
||||||
|
|
||||||
intern/usd_asset_utils.h
|
intern/usd_asset_utils.h
|
||||||
intern/usd_common.h
|
|
||||||
intern/usd_exporter_context.h
|
intern/usd_exporter_context.h
|
||||||
intern/usd_hierarchy_iterator.h
|
intern/usd_hierarchy_iterator.h
|
||||||
intern/usd_writer_abstract.h
|
intern/usd_writer_abstract.h
|
||||||
|
@ -161,8 +159,6 @@ if(WITH_GTESTS)
|
||||||
tests/usd_curves_test.cc
|
tests/usd_curves_test.cc
|
||||||
tests/usd_export_test.cc
|
tests/usd_export_test.cc
|
||||||
tests/usd_stage_creation_test.cc
|
tests/usd_stage_creation_test.cc
|
||||||
tests/usd_tests_common.cc
|
|
||||||
tests/usd_tests_common.h
|
|
||||||
tests/usd_usdz_export_test.cc
|
tests/usd_usdz_export_test.cc
|
||||||
intern/usd_writer_material.h
|
intern/usd_writer_material.h
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
#include "usd.h"
|
#include "usd.h"
|
||||||
#include "usd_common.h"
|
|
||||||
#include "usd_hierarchy_iterator.h"
|
#include "usd_hierarchy_iterator.h"
|
||||||
|
|
||||||
#include <pxr/base/plug/registry.h>
|
#include <pxr/base/plug/registry.h>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "IO_types.h"
|
#include "IO_types.h"
|
||||||
#include "usd.h"
|
#include "usd.h"
|
||||||
#include "usd_common.h"
|
|
||||||
#include "usd_hierarchy_iterator.h"
|
#include "usd_hierarchy_iterator.h"
|
||||||
#include "usd_reader_geom.h"
|
#include "usd_reader_geom.h"
|
||||||
#include "usd_reader_prim.h"
|
#include "usd_reader_prim.h"
|
||||||
|
@ -409,11 +408,6 @@ static void import_freejob(void *user_data)
|
||||||
|
|
||||||
using namespace blender::io::usd;
|
using namespace blender::io::usd;
|
||||||
|
|
||||||
void USD_ensure_plugin_path_registered()
|
|
||||||
{
|
|
||||||
blender::io::usd::ensure_usd_plugin_path_registered();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool USD_import(struct bContext *C,
|
bool USD_import(struct bContext *C,
|
||||||
const char *filepath,
|
const char *filepath,
|
||||||
const USDImportParams *params,
|
const USDImportParams *params,
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
/* SPDX-FileCopyrightText: 2021 Blender Foundation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
||||||
|
|
||||||
#include "usd_common.h"
|
|
||||||
|
|
||||||
#include <pxr/base/plug/registry.h>
|
|
||||||
|
|
||||||
#include "BKE_appdir.h"
|
|
||||||
|
|
||||||
namespace blender::io::usd {
|
|
||||||
|
|
||||||
void ensure_usd_plugin_path_registered()
|
|
||||||
{
|
|
||||||
/* If #PXR_PYTHON_SUPPORT_ENABLED is defined, we *must* be dynamic and
|
|
||||||
* the plugins are placed relative to the USD shared library hence no
|
|
||||||
* hinting is required. */
|
|
||||||
#ifndef PXR_PYTHON_SUPPORT_ENABLED
|
|
||||||
static bool plugin_path_registered = false;
|
|
||||||
if (plugin_path_registered) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
plugin_path_registered = true;
|
|
||||||
|
|
||||||
/* Tell USD which directory to search for its JSON files. If 'datafiles/usd'
|
|
||||||
* does not exist, the USD library will not be able to read or write any files. */
|
|
||||||
const char *blender_usd_datafiles = BKE_appdir_folder_id(BLENDER_DATAFILES, "usd");
|
|
||||||
if (blender_usd_datafiles) {
|
|
||||||
const std::string blender_usd_data_folder = blender_usd_datafiles;
|
|
||||||
/* The trailing slash indicates to the USD library that the path is a directory. */
|
|
||||||
pxr::PlugRegistry::GetInstance().RegisterPlugins(blender_usd_data_folder + SEP_STR);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace blender::io::usd
|
|
|
@ -1,10 +0,0 @@
|
||||||
/* SPDX-FileCopyrightText: 2021 Blender Foundation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace blender::io::usd {
|
|
||||||
|
|
||||||
void ensure_usd_plugin_path_registered();
|
|
||||||
|
|
||||||
} // namespace blender::io::usd
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
|
|
||||||
#include "usd.h"
|
#include "usd.h"
|
||||||
#include "usd_tests_common.h"
|
|
||||||
|
|
||||||
namespace blender::io::usd {
|
namespace blender::io::usd {
|
||||||
|
|
||||||
|
@ -86,10 +85,6 @@ class UsdCurvesTest : public BlendfileLoadingBaseTest {
|
||||||
virtual void SetUp() override
|
virtual void SetUp() override
|
||||||
{
|
{
|
||||||
BlendfileLoadingBaseTest::SetUp();
|
BlendfileLoadingBaseTest::SetUp();
|
||||||
std::string usd_plugin_path = register_usd_plugins_for_tests();
|
|
||||||
if (usd_plugin_path.empty()) {
|
|
||||||
FAIL();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown() override
|
virtual void TearDown() override
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include "WM_api.h"
|
#include "WM_api.h"
|
||||||
|
|
||||||
#include "usd.h"
|
#include "usd.h"
|
||||||
#include "usd_tests_common.h"
|
|
||||||
#include "usd_writer_material.h"
|
#include "usd_writer_material.h"
|
||||||
|
|
||||||
namespace blender::io::usd {
|
namespace blender::io::usd {
|
||||||
|
@ -73,10 +72,6 @@ class UsdExportTest : public BlendfileLoadingBaseTest {
|
||||||
virtual void SetUp() override
|
virtual void SetUp() override
|
||||||
{
|
{
|
||||||
BlendfileLoadingBaseTest::SetUp();
|
BlendfileLoadingBaseTest::SetUp();
|
||||||
std::string usd_plugin_path = register_usd_plugins_for_tests();
|
|
||||||
if (usd_plugin_path.empty()) {
|
|
||||||
FAIL() << "Unable to find the USD Plugins path.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void TearDown() override
|
virtual void TearDown() override
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
#include "testing/testing.h"
|
#include "testing/testing.h"
|
||||||
|
|
||||||
#include "usd_tests_common.h"
|
|
||||||
|
|
||||||
#include <pxr/usd/usd/stage.h>
|
#include <pxr/usd/usd/stage.h>
|
||||||
#include <pxr/usd/usdGeom/capsule.h>
|
#include <pxr/usd/usdGeom/capsule.h>
|
||||||
#include <pxr/usdImaging/usdImaging/capsuleAdapter.h>
|
#include <pxr/usdImaging/usdImaging/capsuleAdapter.h>
|
||||||
|
@ -21,13 +19,6 @@ TEST_F(USDImagingTest, CapsuleAdapterTest)
|
||||||
* We create a capsule shape on an in-memory stage and attempt
|
* We create a capsule shape on an in-memory stage and attempt
|
||||||
* to access the shape's points and topology. */
|
* to access the shape's points and topology. */
|
||||||
|
|
||||||
/* We must register USD plugin paths before creating the stage
|
|
||||||
* to avoid a crash in the USD asset resolver initialization code. */
|
|
||||||
if (register_usd_plugins_for_tests().empty()) {
|
|
||||||
FAIL();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory();
|
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory();
|
||||||
|
|
||||||
if (!stage) {
|
if (!stage) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue