UI: TreeView Hierarchy Line with Region Zoom #117420

Merged
Harley Acheson merged 4 commits from Harley/blender:TreeViewLines into main 2024-01-23 20:39:24 +01:00
101 changed files with 1184 additions and 1069 deletions
Showing only changes of commit 76229ada94 - Show all commits

View File

@ -42,8 +42,8 @@ if(NOT DEFINED CMAKE_BUILD_TYPE_INIT)
set(CMAKE_BUILD_TYPE_INIT "Release")
# Internal logic caches this variable, avoid showing it by default
# since it's easy to accidentally set instead of the build type.
mark_as_advanced(CMAKE_BUILD_TYPE_INIT)
endif()
mark_as_advanced(CMAKE_BUILD_TYPE_INIT)
# Omit superfluous "Up-to-date" messages.
if(NOT DEFINED CMAKE_INSTALL_MESSAGE)

View File

@ -114,6 +114,10 @@ find_package_wrapper(Epoxy REQUIRED)
# XXX Linking errors with debian static tiff :/
# find_package_wrapper(TIFF REQUIRED)
find_package(TIFF)
# CMake 3.28.1 defines this, it doesn't seem to be used, hide by default in the UI.
if(DEFINED tiff_DIR)
mark_as_advanced(tiff_DIR)
endif()
if(WITH_VULKAN_BACKEND)
if((DEFINED LIBDIR) AND (EXISTS "${LIBDIR}/vulkan") AND (EXISTS "${LIBDIR}/shaderc"))
@ -156,6 +160,11 @@ endfunction()
if(NOT WITH_SYSTEM_FREETYPE)
# FreeType compiled with Brotli compression for woff2.
find_package_wrapper(Freetype REQUIRED)
# CMake 3.28.1 defines this, it doesn't seem to be used, hide by default in the UI.
if(DEFINED freetype_DIR)
mark_as_advanced(freetype_DIR)
endif()
if(DEFINED LIBDIR)
find_package_wrapper(Brotli REQUIRED)

View File

@ -50,9 +50,9 @@ import pxr.UsdShade as UsdShade
class USDHookExample(bpy.types.USDHook):
"""Example implementation of USD IO hooks"""
bl_idname = "usd_hook_example"
bl_label = "Example"
bl_description = "Example implementation of USD IO hooks"
@staticmethod
def on_export(export_context):

View File

@ -97,17 +97,29 @@ CUDADevice::CUDADevice(const DeviceInfo &info, Stats &stats, Profiler &profiler)
cuda_assert(cuDeviceGetAttribute(
&pitch_alignment, CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT, cuDevice));
unsigned int ctx_flags = CU_CTX_LMEM_RESIZE_TO_MAX;
if (can_map_host) {
ctx_flags |= CU_CTX_MAP_HOST;
init_host_memory();
}
int active = 0;
unsigned int ctx_flags = 0;
cuda_assert(cuDevicePrimaryCtxGetState(cuDevice, &ctx_flags, &active));
/* Configure primary context only once. */
if (active == 0) {
ctx_flags |= CU_CTX_LMEM_RESIZE_TO_MAX;
result = cuDevicePrimaryCtxSetFlags(cuDevice, ctx_flags);
if (result != CUDA_SUCCESS && result != CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE) {
set_error(string_printf("Failed to configure CUDA context (%s)", cuewErrorString(result)));
return;
}
}
/* Create context. */
result = cuCtxCreate(&cuContext, ctx_flags, cuDevice);
result = cuDevicePrimaryCtxRetain(&cuContext, cuDevice);
if (result != CUDA_SUCCESS) {
set_error(string_printf("Failed to create CUDA context (%s)", cuewErrorString(result)));
set_error(string_printf("Failed to retain CUDA context (%s)", cuewErrorString(result)));
return;
}
@ -124,7 +136,7 @@ CUDADevice::~CUDADevice()
{
texture_info.free();
cuda_assert(cuCtxDestroy(cuContext));
cuda_assert(cuDevicePrimaryCtxRelease(cuDevice));
}
bool CUDADevice::support_device(const uint /*kernel_features*/)

View File

@ -40,18 +40,18 @@ ccl_device_inline float bsdf_get_specular_roughness_squared(ccl_private const Sh
return 1.0f;
}
ccl_device_inline float bsdf_get_roughness_squared(ccl_private const ShaderClosure *sc)
ccl_device_inline float bsdf_get_roughness_pass_squared(ccl_private const ShaderClosure *sc)
{
/* This version includes diffuse, mainly for baking Principled BSDF
* where specular and metallic zero otherwise does not bake the
* specified roughness parameter. */
if (sc->type == CLOSURE_BSDF_OREN_NAYAR_ID) {
ccl_private OrenNayarBsdf *bsdf = (ccl_private OrenNayarBsdf *)sc;
return sqr(sqr(bsdf->roughness));
}
/* For the Principled BSDF, we want the Roughness pass to return the value that
* was set in the node. However, this value doesn't affect all closures (e.g.
* diffuse), so skip those that don't really have a concept of roughness. */
if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
return 0.0f;
return -1.0f;
}
return bsdf_get_specular_roughness_squared(sc);

View File

@ -930,13 +930,16 @@ ccl_device float surface_shader_average_roughness(ccl_private const ShaderData *
if (CLOSURE_IS_BSDF(sc->type)) {
/* sqrt once to undo the squaring from multiplying roughness on the
* two axes, and once for the squared roughness convention. */
float weight = fabsf(average(sc->weight));
roughness += weight * sqrtf(safe_sqrtf(bsdf_get_roughness_squared(sc)));
sum_weight += weight;
float value = bsdf_get_roughness_pass_squared(sc);
if (value >= 0.0f) {
float weight = fabsf(average(sc->weight));
roughness += weight * sqrtf(sqrtf(value));
sum_weight += weight;
}
}
}
return (sum_weight > 0.0f) ? roughness / sum_weight : 0.0f;
return (sum_weight > 0.0f) ? roughness / sum_weight : 1.0f;
}
ccl_device Spectrum surface_shader_transparency(KernelGlobals kg, ccl_private const ShaderData *sd)

View File

@ -525,16 +525,11 @@ class ARMATURE_OT_copy_bone_color_to_selected(Operator):
class ARMATURE_OT_collection_solo_visibility(Operator):
"""Hide all other bone collections and show the active one.
Note that it is necessary to also show the ancestors of the active bone
collection in order to ensure its visibility.
"""
"""Hide all other bone collections and show the active one. """ \
"""Note that it is necessary to also show the ancestors of the active """ \
"""bone collection in order to ensure its visibility"""
bl_idname = "armature.collection_solo_visibility"
bl_label = "Solo Visibility"
bl_description = "Hide all other bone collections and show the active one. " + \
"Note that it is necessary to also show the ancestors of the active " + \
"bone collection in order to ensure its visibility"
bl_options = {'REGISTER', 'UNDO'}
name: StringProperty(name='Bone Collection')
@ -589,11 +584,11 @@ class ARMATURE_OT_collection_show_all(Operator):
class ARMATURE_OT_collection_remove_unused(Operator):
"""Remove all bone collections that have neither bones nor children."""
"""Remove all bone collections that have neither bones nor children.\n""" \
"""This is done recursively, so bone collections that only have unused children are also removed"""
bl_idname = "armature.collection_remove_unused"
bl_label = "Remove Unused Bone Collections"
bl_description = ("Remove all bone collections that have neither bones nor children.\n"
"This is done recursively, so bone collections that only have unused children are also removed")
bl_options = {'REGISTER', 'UNDO'}
@classmethod

View File

@ -2655,10 +2655,11 @@ class BatchRenameAction(bpy.types.PropertyGroup):
class WM_OT_batch_rename(Operator):
"""Rename multiple items at once"""
bl_idname = "wm.batch_rename"
bl_label = "Batch Rename"
bl_description = "Rename multiple items at once"
bl_options = {'UNDO'}
data_type: EnumProperty(

View File

@ -113,6 +113,8 @@ def translation_update(_):
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
for mod in _modules_loaded:
for cls in mod.classes:
register_class(cls)
@ -184,6 +186,9 @@ def unregister():
for cls in reversed(mod.classes):
if cls.is_registered:
unregister_class(cls)
for cls in reversed(classes):
if cls.is_registered:
unregister_class(cls)
try:
bpy.app.handlers.translation_update_post.remove(translation_update)
@ -251,9 +256,6 @@ class UI_UL_list(bpy.types.UIList):
return cls.sort_items_helper(_sort, lambda e: e[1].lower())
bpy.utils.register_class(UI_UL_list)
class UI_MT_list_item_context_menu(bpy.types.Menu):
"""
UI List item context menu definition. Scripts can append/prepend this to
@ -270,9 +272,6 @@ class UI_MT_list_item_context_menu(bpy.types.Menu):
pass
bpy.utils.register_class(UI_MT_list_item_context_menu)
class UI_MT_button_context_menu(bpy.types.Menu):
"""
UI button context menu definition. Scripts can append/prepend this to
@ -290,4 +289,8 @@ class UI_MT_button_context_menu(bpy.types.Menu):
self.layout.menu_contents("WM_MT_button_context")
bpy.utils.register_class(UI_MT_button_context_menu)
classes = (
UI_UL_list,
UI_MT_list_item_context_menu,
UI_MT_button_context_menu,
)

View File

@ -884,9 +884,9 @@ class GreasePencilLayerDisplayPanel:
class GreasePencilFlipTintColors(Operator):
"""Switch tint colors"""
bl_label = "Flip Colors"
bl_idname = "gpencil.tint_flip"
bl_description = "Switch tint colors"
@classmethod
def poll(cls, context):

View File

@ -1327,41 +1327,38 @@ class CLIP_MT_view(Menu):
sc = context.space_data
if sc.view == 'CLIP':
layout.prop(sc, "show_region_ui")
layout.prop(sc, "show_region_toolbar")
layout.prop(sc, "show_region_ui")
layout.prop(sc, "show_region_hud")
layout.separator()
layout.operator("clip.view_selected")
layout.operator("clip.view_all")
layout.operator("clip.view_all", text="View Fit").fit_view = True
layout.operator("clip.view_center_cursor")
layout.menu("CLIP_MT_view_zoom")
layout.separator()
layout.operator("clip.view_zoom_in")
layout.operator("clip.view_zoom_out")
layout.separator()
layout.prop(sc, "show_metadata")
layout.separator()
else:
layout.operator_context = 'INVOKE_REGION_PREVIEW'
layout.operator("clip.graph_view_all")
if sc.view == 'GRAPH':
layout.operator("clip.graph_center_current_frame")
layout.operator("view2d.zoom_border", text="Zoom")
layout.operator_context = 'INVOKE_DEFAULT'
layout.separator()
layout.menu("CLIP_MT_view_zoom")
else:
if sc.view == 'GRAPH':
layout.operator_context = 'INVOKE_REGION_PREVIEW'
layout.operator("clip.graph_center_current_frame")
layout.operator("clip.graph_view_all")
layout.operator_context = 'INVOKE_DEFAULT'
layout.prop(sc, "show_seconds")
layout.prop(sc, "show_locked_time")
layout.separator()
layout.menu("INFO_MT_area")

View File

@ -363,11 +363,14 @@ class DOPESHEET_MT_view(Menu):
layout.prop(st, "show_region_ui")
layout.prop(st, "show_region_hud")
layout.separator()
layout.operator("action.view_selected")
layout.operator("action.view_all")
layout.operator("action.view_frame")
layout.separator()
layout.prop(st.dopesheet, "use_multi_word_filter", text="Multi-Word Match Search")
layout.separator()
layout.prop(st, "use_realtime_update")
@ -380,31 +383,24 @@ class DOPESHEET_MT_view(Menu):
layout.prop(st, "show_interpolation")
layout.prop(st, "show_extremes")
layout.prop(st, "use_auto_merge_keyframes")
layout.separator()
layout.prop(st, "show_markers")
layout.separator()
layout.prop(st, "show_seconds")
layout.prop(st, "show_locked_time")
layout.separator()
layout.operator("anim.previewrange_set")
layout.operator("anim.previewrange_clear")
layout.operator("action.previewrange_set")
layout.separator()
layout.operator("action.view_all")
layout.operator("action.view_selected")
layout.operator("action.view_frame")
# Add this to show key-binding (reverse action in dope-sheet).
layout.separator()
props = layout.operator("wm.context_set_enum", text="Toggle Graph Editor", icon='GRAPH')
props.data_path = "area.type"
props.value = 'GRAPH_EDITOR'
layout.separator()
layout.menu("INFO_MT_area")

View File

@ -150,40 +150,39 @@ class GRAPH_MT_view(Menu):
layout.prop(st, "show_region_hud")
layout.separator()
layout.operator("graph.view_selected")
layout.operator("graph.view_all")
layout.operator("graph.view_frame")
layout.separator()
layout.prop(st, "use_realtime_update")
layout.prop(st, "show_cursor")
layout.prop(st, "show_sliders")
layout.prop(st, "use_auto_merge_keyframes")
layout.separator()
if st.mode != 'DRIVERS':
layout.separator()
layout.prop(st, "show_markers")
layout.prop(st, "show_extrapolation")
layout.prop(st, "show_handles")
layout.prop(st, "use_only_selected_keyframe_handles")
layout.prop(st, "show_cursor")
layout.prop(st, "show_seconds")
layout.prop(st, "show_locked_time")
layout.separator()
layout.prop(st, "show_extrapolation")
layout.prop(st, "show_handles")
layout.prop(st, "use_only_selected_keyframe_handles")
layout.separator()
layout.operator("anim.previewrange_set")
layout.operator("anim.previewrange_clear")
layout.operator("graph.previewrange_set")
layout.separator()
layout.operator("graph.view_all")
layout.operator("graph.view_selected")
layout.operator("graph.view_frame")
# Add this to show key-binding (reverse action in dope-sheet).
layout.separator()
props = layout.operator("wm.context_set_enum", text="Toggle Dope Sheet")
props.data_path = "area.type"
props.value = 'DOPESHEET_EDITOR'
layout.separator()
layout.menu("INFO_MT_area")

View File

@ -116,28 +116,26 @@ class NLA_MT_view(Menu):
layout.prop(st, "show_region_hud")
layout.separator()
layout.prop(st, "use_realtime_update")
layout.prop(st, "show_seconds")
layout.prop(st, "show_locked_time")
layout.prop(st, "show_strip_curves")
layout.operator("nla.view_selected")
layout.operator("nla.view_all")
layout.operator("nla.view_frame")
layout.separator()
layout.prop(st, "use_realtime_update")
layout.prop(st, "show_strip_curves")
layout.separator()
layout.prop(st, "show_markers")
layout.prop(st, "show_local_markers")
layout.prop(st, "show_seconds")
layout.prop(st, "show_locked_time")
layout.separator()
layout.operator("anim.previewrange_set")
layout.operator("anim.previewrange_clear")
layout.operator("nla.previewrange_set")
layout.separator()
layout.operator("nla.view_all")
layout.operator("nla.view_selected")
layout.operator("nla.view_frame")
layout.separator()
layout.menu("INFO_MT_area")

View File

@ -415,22 +415,24 @@ class SEQUENCER_MT_view(Menu):
# mode, else the lookup for the shortcut will fail in
# wm_keymap_item_find_props() (see #32595).
layout.operator_context = 'INVOKE_REGION_PREVIEW'
layout.prop(st, "show_region_toolbar")
layout.prop(st, "show_region_ui")
layout.prop(st, "show_region_tool_header")
layout.prop(st, "show_region_toolbar")
layout.operator_context = 'INVOKE_DEFAULT'
if is_sequencer_view:
layout.prop(st, "show_region_hud")
layout.prop(st, "show_region_channels")
layout.separator()
if st.view_type == 'SEQUENCER':
layout.prop(st, "show_backdrop", text="Preview as Backdrop")
if is_preview or st.show_backdrop:
layout.prop(st, "show_transform_preview", text="Preview During Transform")
layout.separator()
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("sequencer.refresh_all", icon='FILE_REFRESH', text="Refresh All")
layout.operator_context = 'INVOKE_DEFAULT'
layout.separator()
layout.operator_context = 'INVOKE_REGION_WIN'
@ -438,26 +440,23 @@ class SEQUENCER_MT_view(Menu):
# See above (#32595)
layout.operator_context = 'INVOKE_REGION_PREVIEW'
layout.operator("sequencer.view_selected", text="Frame Selected")
if is_sequencer_view:
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("sequencer.view_all")
layout.operator("sequencer.view_frame")
layout.operator("view2d.zoom_border", text="Zoom")
layout.operator("view2d.zoom_border", text="Zoom to Border")
layout.prop(st, "use_clamp_view")
if is_preview:
if is_sequencer_view:
layout.separator()
layout.operator_context = 'INVOKE_REGION_PREVIEW'
layout.separator()
layout.operator("sequencer.view_all_preview", text="Fit Preview in Window")
if is_sequencer_view:
layout.menu("SEQUENCER_MT_preview_zoom", text="Fractional Preview Zoom")
else:
layout.operator("view2d.zoom_border", text="Zoom")
layout.operator("view2d.zoom_border", text="Zoom to Border")
layout.menu("SEQUENCER_MT_preview_zoom")
layout.prop(st, "use_zoom_to_fit")
if st.display_mode == 'WAVEFORM':
@ -465,42 +464,34 @@ class SEQUENCER_MT_view(Menu):
layout.prop(st, "show_separate_color", text="Show Separate Color Channels")
layout.separator()
layout.menu("SEQUENCER_MT_proxy")
layout.operator_context = 'INVOKE_DEFAULT'
layout.separator()
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("sequencer.refresh_all", icon='FILE_REFRESH', text="Refresh All")
layout.operator_context = 'INVOKE_DEFAULT'
layout.separator()
if is_sequencer_view:
layout.separator()
layout.prop(st, "show_markers")
layout.prop(st, "show_seconds")
layout.prop(st, "show_locked_time")
layout.separator()
layout.operator_context = 'INVOKE_DEFAULT'
layout.menu("SEQUENCER_MT_navigation")
layout.menu("SEQUENCER_MT_range")
layout.separator()
layout.prop(st, "show_locked_time")
layout.separator()
layout.prop(st, "show_seconds")
layout.prop(st, "show_markers")
if context.preferences.view.show_developer_ui:
layout.menu("SEQUENCER_MT_view_cache", text="Show Cache")
layout.separator()
layout.menu("SEQUENCER_MT_view_cache", text="Cache")
layout.separator()
layout.operator("render.opengl", text="Sequence Render Image", icon='RENDER_STILL').sequencer = True
props = layout.operator("render.opengl", text="Sequence Render Animation", icon='RENDER_ANIMATION')
props.animation = True
props.sequencer = True
layout.separator()
layout.operator("sequencer.export_subtitles", text="Export Subtitles", icon='EXPORT')
layout.operator("sequencer.export_subtitles", text="Export Subtitles", icon='EXPORT')
layout.separator()
# Note that the context is needed for the shortcut to display properly.
@ -514,7 +505,6 @@ class SEQUENCER_MT_view(Menu):
props.value_1 = 'SEQUENCER'
props.value_2 = 'PREVIEW'
layout.operator_context = 'INVOKE_DEFAULT'
layout.separator()
layout.menu("INFO_MT_area")

View File

@ -123,35 +123,27 @@ class TIME_MT_view(Menu):
scene = context.scene
st = context.space_data
layout.menu("INFO_MT_area")
layout.prop(st, "show_region_hud")
layout.separator()
# NOTE: "action" now, since timeline is in the dopesheet editor, instead of as own editor
layout.operator("action.view_frame")
layout.operator("action.view_all")
layout.separator()
layout.menu("TIME_MT_cache")
layout.separator()
layout.prop(st.dopesheet, "show_only_errors")
layout.prop(scene, "show_keys_from_selected_only")
layout.operator("action.view_frame")
layout.separator()
layout.prop(st, "show_markers")
layout.separator()
layout.prop(st, "show_locked_time")
layout.prop(st, "show_seconds")
layout.prop(st, "show_locked_time")
layout.separator()
layout.prop(st, "show_region_hud")
layout.prop(scene, "show_keys_from_selected_only")
layout.prop(st.dopesheet, "show_only_errors")
layout.separator()
layout.menu("TIME_MT_cache")
layout.separator()
layout.menu("INFO_MT_area")
class TIME_MT_cache(Menu):

View File

@ -2028,7 +2028,8 @@ class USERPREF_PT_extensions(ExtensionsPanel, Panel):
class USERPREF_PT_extensions_repos(ExtensionsPanel, Panel):
bl_label = "Extension Repositories"
bl_label = "Repositories"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
@ -2162,9 +2163,6 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
row = layout.row()
row.prop(wm, "addon_support", expand=True)
row = layout.row()
row.prop(wm, "addon_filter", text="")
row = layout.row()
row.prop(prefs.view, "show_addons_enabled_only")
@ -2233,6 +2231,9 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
search = wm.addon_search.lower()
support = wm.addon_support
if use_extension_repos:
filter = "All"
# initialized on demand
user_addon_paths = []
@ -2284,13 +2285,17 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
sub = row.row()
sub.active = is_enabled
sub.label(text=iface_("%s: %s") % (iface_(info["category"]), iface_(info["name"])))
if use_extension_repos:
sub.label(text=iface_(info["name"]))
else:
sub.label(text="%s: %s" % (iface_(info["category"]), iface_(info["name"])))
if info["warning"]:
sub.label(icon='ERROR')
# icon showing support level.
sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
if not use_extension_repos:
sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION'))
# Expanded UI (only if additional info is available)
if info["show_expanded"]:

View File

@ -334,6 +334,11 @@ int BLF_default(void);
* Draw the string using the default font, size and DPI.
*/
void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL();
/**
* As above but with a very contrasting dark shadow.
*/
void BLF_draw_default_shadowed(float x, float y, float z, const char *str, size_t str_len)
ATTR_NONNULL();
/**
* Set size and DPI, and return default font ID.
*/

View File

@ -11,6 +11,7 @@
#include "DNA_userdef_types.h"
#include "BLI_assert.h"
#include "BLI_math_vector_types.hh"
#include "BLF_api.h"
@ -58,3 +59,20 @@ void BLF_draw_default(float x, float y, float z, const char *str, const size_t s
BLF_position(global_font_default, x, y, z);
BLF_draw(global_font_default, str, str_len);
}
void BLF_draw_default_shadowed(float x, float y, float z, const char *str, const size_t str_len)
{
ASSERT_DEFAULT_SET;
BLF_size(global_font_default, global_font_size * UI_SCALE_FAC);
BLF_enable(global_font_default, BLF_SHADOW);
BLF_shadow(global_font_default, 5, blender::float4{0.0f, 0.0f, 0.0f, 1.0f});
BLF_shadow_offset(global_font_default, 0, 0);
BLF_position(global_font_default, x, y, z);
BLF_draw(global_font_default, str, str_len);
BLF_shadow(global_font_default, 3, blender::float4{0.0f, 0.0f, 0.0f, 1.0f});
BLF_shadow_offset(global_font_default, 1, -1);
BLF_draw(global_font_default, str, str_len);
BLF_disable(global_font_default, BLF_SHADOW);
}

View File

@ -19,6 +19,7 @@ extern "C" {
struct Depsgraph;
struct ID;
struct ImBuf;
struct ImBufAnim;
struct Image;
struct ImageFormatData;
struct ImagePool;
@ -31,7 +32,6 @@ struct RenderResult;
struct ReportList;
struct Scene;
struct StampData;
struct anim;
#define IMA_MAX_SPACE 64
#define IMA_UDIM_MAX 2000
@ -108,14 +108,14 @@ int BKE_imbuf_write_as(struct ImBuf *ibuf,
/**
* Used by sequencer too.
*/
struct anim *openanim(const char *filepath,
int flags,
int streamindex,
char colorspace[IMA_MAX_SPACE]);
struct anim *openanim_noload(const char *filepath,
int flags,
int streamindex,
char colorspace[IMA_MAX_SPACE]);
struct ImBufAnim *openanim(const char *filepath,
int flags,
int streamindex,
char colorspace[IMA_MAX_SPACE]);
struct ImBufAnim *openanim_noload(const char *filepath,
int flags,
int streamindex,
char colorspace[IMA_MAX_SPACE]);
void BKE_image_tag_time(struct Image *ima);

View File

@ -590,7 +590,7 @@ static void view3d_data_consistency_ensure(wmWindow *win, Scene *scene, ViewLaye
* be found. */
Base *base;
for (base = static_cast<Base *>(view_layer->object_bases.first); base; base = base->next) {
if (base->local_view_bits & v3d->local_view_uuid) {
if (base->local_view_bits & v3d->local_view_uid) {
break;
}
}
@ -602,7 +602,7 @@ static void view3d_data_consistency_ensure(wmWindow *win, Scene *scene, ViewLaye
/* No valid object found for the local view3D, it has to be cleared off. */
MEM_freeN(v3d->localvd);
v3d->localvd = nullptr;
v3d->local_view_uuid = 0;
v3d->local_view_uid = 0;
/* Region-base storage is different depending on whether the space is active or not. */
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;

View File

@ -559,7 +559,7 @@ static void loose_data_instantiate_object_base_instance_init(Main *bmain,
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (v3d != nullptr) {
base->local_view_bits |= v3d->local_view_uuid;
base->local_view_bits |= v3d->local_view_uid;
}
if (flag & FILE_AUTOSELECT) {

View File

@ -1346,9 +1346,9 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
}
static Brush *gpencil_brush_ensure(
Main *bmain, ToolSettings *ts, const char *brush_name, eObjectMode mode, bool *r_new)
Main *bmain, ToolSettings *ts, const char *brush_name, eObjectMode mode, bool *r_is_new)
{
*r_new = false;
*r_is_new = false;
Brush *brush = (Brush *)BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
/* If the brush exist, but the type is not GPencil or the mode is wrong, create a new one. */
@ -1358,7 +1358,7 @@ static Brush *gpencil_brush_ensure(
if (brush == nullptr) {
brush = BKE_brush_add_gpencil(bmain, ts, brush_name, mode);
*r_new = true;
*r_is_new = true;
}
if (brush->gpencil_settings == nullptr) {
@ -1370,93 +1370,93 @@ static Brush *gpencil_brush_ensure(
void BKE_brush_gpencil_paint_presets(Main *bmain, ToolSettings *ts, const bool reset)
{
bool r_new = false;
bool is_new = false;
Paint *paint = &ts->gp_paint->paint;
Brush *brush_prev = paint->brush;
Brush *brush, *deft_draw;
/* Airbrush brush. */
brush = gpencil_brush_ensure(bmain, ts, "Airbrush", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Airbrush", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_AIRBRUSH);
}
/* Ink Pen brush. */
brush = gpencil_brush_ensure(bmain, ts, "Ink Pen", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Ink Pen", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_INK_PEN);
}
/* Ink Pen Rough brush. */
brush = gpencil_brush_ensure(bmain, ts, "Ink Pen Rough", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Ink Pen Rough", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_INK_PEN_ROUGH);
}
/* Marker Bold brush. */
brush = gpencil_brush_ensure(bmain, ts, "Marker Bold", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Marker Bold", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_MARKER_BOLD);
}
/* Marker Chisel brush. */
brush = gpencil_brush_ensure(bmain, ts, "Marker Chisel", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Marker Chisel", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_MARKER_CHISEL);
}
/* Pen brush. */
brush = gpencil_brush_ensure(bmain, ts, "Pen", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Pen", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PEN);
}
/* Pencil Soft brush. */
brush = gpencil_brush_ensure(bmain, ts, "Pencil Soft", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Pencil Soft", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PENCIL_SOFT);
}
/* Pencil brush. */
brush = gpencil_brush_ensure(bmain, ts, "Pencil", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Pencil", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PENCIL);
}
deft_draw = brush; /* save default brush. */
/* Fill brush. */
brush = gpencil_brush_ensure(bmain, ts, "Fill Area", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Fill Area", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_FILL_AREA);
}
/* Soft Eraser brush. */
brush = gpencil_brush_ensure(bmain, ts, "Eraser Soft", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Eraser Soft", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_ERASER_SOFT);
}
/* Hard Eraser brush. */
brush = gpencil_brush_ensure(bmain, ts, "Eraser Hard", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Eraser Hard", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_ERASER_HARD);
}
/* Point Eraser brush. */
brush = gpencil_brush_ensure(bmain, ts, "Eraser Point", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Eraser Point", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_ERASER_POINT);
}
/* Stroke Eraser brush. */
brush = gpencil_brush_ensure(bmain, ts, "Eraser Stroke", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Eraser Stroke", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_ERASER_STROKE);
}
/* Tint brush. */
brush = gpencil_brush_ensure(bmain, ts, "Tint", OB_MODE_PAINT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Tint", OB_MODE_PAINT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_TINT);
}
@ -1471,36 +1471,38 @@ void BKE_brush_gpencil_paint_presets(Main *bmain, ToolSettings *ts, const bool r
void BKE_brush_gpencil_vertex_presets(Main *bmain, ToolSettings *ts, const bool reset)
{
bool r_new = false;
bool is_new = false;
Paint *vertexpaint = &ts->gp_vertexpaint->paint;
Brush *brush_prev = vertexpaint->brush;
Brush *brush, *deft_vertex;
/* Vertex Draw brush. */
brush = gpencil_brush_ensure(bmain, ts, "Vertex Draw", OB_MODE_VERTEX_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Vertex Draw", OB_MODE_VERTEX_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_DRAW);
}
deft_vertex = brush; /* save default brush. */
/* Vertex Blur brush. */
brush = gpencil_brush_ensure(bmain, ts, "Vertex Blur", OB_MODE_VERTEX_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Vertex Blur", OB_MODE_VERTEX_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_BLUR);
}
/* Vertex Average brush. */
brush = gpencil_brush_ensure(bmain, ts, "Vertex Average", OB_MODE_VERTEX_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(
bmain, ts, "Vertex Average", OB_MODE_VERTEX_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_AVERAGE);
}
/* Vertex Smear brush. */
brush = gpencil_brush_ensure(bmain, ts, "Vertex Smear", OB_MODE_VERTEX_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Vertex Smear", OB_MODE_VERTEX_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_SMEAR);
}
/* Vertex Replace brush. */
brush = gpencil_brush_ensure(bmain, ts, "Vertex Replace", OB_MODE_VERTEX_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(
bmain, ts, "Vertex Replace", OB_MODE_VERTEX_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_REPLACE);
}
@ -1517,67 +1519,67 @@ void BKE_brush_gpencil_vertex_presets(Main *bmain, ToolSettings *ts, const bool
void BKE_brush_gpencil_sculpt_presets(Main *bmain, ToolSettings *ts, const bool reset)
{
bool r_new = false;
bool is_new = false;
Paint *sculptpaint = &ts->gp_sculptpaint->paint;
Brush *brush_prev = sculptpaint->brush;
Brush *brush, *deft_sculpt;
/* Smooth brush. */
brush = gpencil_brush_ensure(bmain, ts, "Smooth Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Smooth Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_SMOOTH_STROKE);
}
deft_sculpt = brush;
/* Strength brush. */
brush = gpencil_brush_ensure(
bmain, ts, "Strength Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
bmain, ts, "Strength Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_STRENGTH_STROKE);
}
/* Thickness brush. */
brush = gpencil_brush_ensure(
bmain, ts, "Thickness Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
bmain, ts, "Thickness Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_THICKNESS_STROKE);
}
/* Grab brush. */
brush = gpencil_brush_ensure(bmain, ts, "Grab Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Grab Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_GRAB_STROKE);
}
/* Push brush. */
brush = gpencil_brush_ensure(bmain, ts, "Push Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Push Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PUSH_STROKE);
}
/* Twist brush. */
brush = gpencil_brush_ensure(bmain, ts, "Twist Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Twist Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_TWIST_STROKE);
}
/* Pinch brush. */
brush = gpencil_brush_ensure(bmain, ts, "Pinch Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Pinch Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PINCH_STROKE);
}
/* Randomize brush. */
brush = gpencil_brush_ensure(
bmain, ts, "Randomize Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
bmain, ts, "Randomize Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_RANDOMIZE_STROKE);
}
/* Clone brush. */
brush = gpencil_brush_ensure(bmain, ts, "Clone Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Clone Stroke", OB_MODE_SCULPT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_CLONE_STROKE);
}
@ -1594,34 +1596,35 @@ void BKE_brush_gpencil_sculpt_presets(Main *bmain, ToolSettings *ts, const bool
void BKE_brush_gpencil_weight_presets(Main *bmain, ToolSettings *ts, const bool reset)
{
bool r_new = false;
bool is_new = false;
Paint *weightpaint = &ts->gp_weightpaint->paint;
Brush *brush_prev = weightpaint->brush;
Brush *brush, *deft_weight;
/* Weight Draw brush. */
brush = gpencil_brush_ensure(bmain, ts, "Weight Draw", OB_MODE_WEIGHT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Weight Draw", OB_MODE_WEIGHT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_WEIGHT_DRAW);
}
deft_weight = brush; /* save default brush. */
/* Weight Blur brush. */
brush = gpencil_brush_ensure(bmain, ts, "Weight Blur", OB_MODE_WEIGHT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Weight Blur", OB_MODE_WEIGHT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_WEIGHT_BLUR);
}
/* Weight Average brush. */
brush = gpencil_brush_ensure(bmain, ts, "Weight Average", OB_MODE_WEIGHT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(
bmain, ts, "Weight Average", OB_MODE_WEIGHT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_WEIGHT_AVERAGE);
}
/* Weight Smear brush. */
brush = gpencil_brush_ensure(bmain, ts, "Weight Smear", OB_MODE_WEIGHT_GPENCIL_LEGACY, &r_new);
if ((reset) || (r_new)) {
brush = gpencil_brush_ensure(bmain, ts, "Weight Smear", OB_MODE_WEIGHT_GPENCIL_LEGACY, &is_new);
if ((reset) || (is_new)) {
BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_WEIGHT_SMEAR);
}

View File

@ -142,9 +142,9 @@ static Material *gpencil_add_from_curve_material(Main *bmain,
const float fill_color[4],
const bool stroke,
const bool fill,
int *r_idx)
int *r_index)
{
Material *mat_gp = BKE_gpencil_object_material_new(bmain, ob_gp, "Material", r_idx);
Material *mat_gp = BKE_gpencil_object_material_new(bmain, ob_gp, "Material", r_index);
MaterialGPencilStyle *gp_style = mat_gp->gp_style;
/* Stroke color. */
@ -267,12 +267,12 @@ static int gpencil_get_stroke_material_fromcurve(
copy_v4_v4(color_fill, &mat_curve_fill->r);
}
int r_idx = gpencil_check_same_material_color(
int index = gpencil_check_same_material_color(
ob_gp, color_stroke, color_fill, *r_do_stroke, *r_do_fill, &mat_gp);
if ((ob_gp->totcol < r_idx) || (r_idx < 0)) {
if ((ob_gp->totcol < index) || (index < 0)) {
mat_gp = gpencil_add_from_curve_material(
bmain, ob_gp, color_stroke, color_fill, *r_do_stroke, *r_do_fill, &r_idx);
bmain, ob_gp, color_stroke, color_fill, *r_do_stroke, *r_do_fill, &index);
}
/* Set fill and stroke depending of curve type (3D or 2D). */
@ -285,7 +285,7 @@ static int gpencil_get_stroke_material_fromcurve(
mat_gp->gp_style->flag |= GP_MATERIAL_FILL_SHOW;
}
return r_idx;
return index;
}
/* Helper: Convert one spline to grease pencil stroke. */
@ -333,11 +333,11 @@ static void gpencil_convert_spline(Main *bmain,
* Notice: The color of the material is the color of viewport and not the final shader color.
*/
bool do_stroke, do_fill;
int r_idx = gpencil_get_stroke_material_fromcurve(bmain, ob_gp, ob_cu, &do_stroke, &do_fill);
CLAMP_MIN(r_idx, 0);
int index = gpencil_get_stroke_material_fromcurve(bmain, ob_gp, ob_cu, &do_stroke, &do_fill);
CLAMP_MIN(index, 0);
/* Assign material index to stroke. */
gps->mat_nr = r_idx;
gps->mat_nr = index;
/* Add stroke to frame. */
BLI_addtail(&gpf->strokes, gps);

View File

@ -2626,20 +2626,23 @@ int BKE_imbuf_write_stamp(const Scene *scene,
return BKE_imbuf_write(ibuf, filepath, imf);
}
anim *openanim_noload(const char *filepath,
int flags,
int streamindex,
char colorspace[IMA_MAX_SPACE])
ImBufAnim *openanim_noload(const char *filepath,
int flags,
int streamindex,
char colorspace[IMA_MAX_SPACE])
{
anim *anim;
ImBufAnim *anim;
anim = IMB_open_anim(filepath, flags, streamindex, colorspace);
return anim;
}
anim *openanim(const char *filepath, int flags, int streamindex, char colorspace[IMA_MAX_SPACE])
ImBufAnim *openanim(const char *filepath,
int flags,
int streamindex,
char colorspace[IMA_MAX_SPACE])
{
anim *anim;
ImBufAnim *anim;
ImBuf *ibuf;
anim = IMB_open_anim(filepath, flags, streamindex, colorspace);

View File

@ -1609,7 +1609,7 @@ bool BKE_base_is_visible(const View3D *v3d, const Base *base)
return base->flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT;
}
if ((v3d->localvd) && ((v3d->local_view_uuid & base->local_view_bits) == 0)) {
if ((v3d->localvd) && ((v3d->local_view_uid & base->local_view_bits) == 0)) {
return false;
}
@ -1618,7 +1618,7 @@ bool BKE_base_is_visible(const View3D *v3d, const Base *base)
}
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
return (v3d->local_collections_uuid & base->local_collections_bits) != 0;
return (v3d->local_collections_uid & base->local_collections_bits) != 0;
}
return base->flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT;
@ -1636,12 +1636,12 @@ bool BKE_object_is_visible_in_viewport(const View3D *v3d, const Object *ob)
return false;
}
if (v3d->localvd && ((v3d->local_view_uuid & ob->base_local_view_bits) == 0)) {
if (v3d->localvd && ((v3d->local_view_uid & ob->base_local_view_bits) == 0)) {
return false;
}
if ((v3d->flag & V3D_LOCAL_COLLECTIONS) &&
((v3d->local_collections_uuid & ob->runtime->local_collections_bits) == 0))
((v3d->local_collections_uid & ob->runtime->local_collections_bits) == 0))
{
return false;
}
@ -1725,30 +1725,30 @@ void BKE_layer_collection_isolate_global(Scene * /*scene*/,
}
static void layer_collection_local_visibility_set_recursive(LayerCollection *layer_collection,
const int local_collections_uuid)
const int local_collections_uid)
{
layer_collection->local_collections_bits |= local_collections_uuid;
layer_collection->local_collections_bits |= local_collections_uid;
LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
layer_collection_local_visibility_set_recursive(child, local_collections_uuid);
layer_collection_local_visibility_set_recursive(child, local_collections_uid);
}
}
static void layer_collection_local_visibility_unset_recursive(LayerCollection *layer_collection,
const int local_collections_uuid)
const int local_collections_uid)
{
layer_collection->local_collections_bits &= ~local_collections_uuid;
layer_collection->local_collections_bits &= ~local_collections_uid;
LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
layer_collection_local_visibility_unset_recursive(child, local_collections_uuid);
layer_collection_local_visibility_unset_recursive(child, local_collections_uid);
}
}
static void layer_collection_local_sync(const Scene *scene,
ViewLayer *view_layer,
LayerCollection *layer_collection,
const ushort local_collections_uuid,
const ushort local_collections_uid,
bool visible)
{
if ((layer_collection->local_collections_bits & local_collections_uuid) == 0) {
if ((layer_collection->local_collections_bits & local_collections_uid) == 0) {
visible = false;
}
@ -1760,13 +1760,13 @@ static void layer_collection_local_sync(const Scene *scene,
BKE_view_layer_synced_ensure(scene, view_layer);
Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
base->local_collections_bits |= local_collections_uuid;
base->local_collections_bits |= local_collections_uid;
}
}
LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
if ((child->flag & LAYER_COLLECTION_EXCLUDE) == 0) {
layer_collection_local_sync(scene, view_layer, child, local_collections_uuid, visible);
layer_collection_local_sync(scene, view_layer, child, local_collections_uid, visible);
}
}
}
@ -1777,16 +1777,16 @@ void BKE_layer_collection_local_sync(const Scene *scene, ViewLayer *view_layer,
return;
}
const ushort local_collections_uuid = v3d->local_collections_uuid;
const ushort local_collections_uid = v3d->local_collections_uid;
/* Reset flags and set the bases visible by default. */
BKE_view_layer_synced_ensure(scene, view_layer);
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
base->local_collections_bits &= ~local_collections_uuid;
base->local_collections_bits &= ~local_collections_uid;
}
LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) {
layer_collection_local_sync(scene, view_layer, layer_collection, local_collections_uuid, true);
layer_collection_local_sync(scene, view_layer, layer_collection, local_collections_uid, true);
}
}
@ -1817,18 +1817,18 @@ void BKE_layer_collection_isolate_local(
const Scene *scene, ViewLayer *view_layer, const View3D *v3d, LayerCollection *lc, bool extend)
{
LayerCollection *lc_master = static_cast<LayerCollection *>(view_layer->layer_collections.first);
bool hide_it = extend && ((v3d->local_collections_uuid & lc->local_collections_bits) != 0);
bool hide_it = extend && ((v3d->local_collections_uid & lc->local_collections_bits) != 0);
if (!extend) {
/* Hide all collections. */
LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) {
layer_collection_local_visibility_unset_recursive(lc_iter, v3d->local_collections_uuid);
layer_collection_local_visibility_unset_recursive(lc_iter, v3d->local_collections_uid);
}
}
/* Make all the direct parents visible. */
if (hide_it) {
lc->local_collections_bits &= ~(v3d->local_collections_uuid);
lc->local_collections_bits &= ~(v3d->local_collections_uid);
}
else {
LayerCollection *lc_parent = lc;
@ -1840,7 +1840,7 @@ void BKE_layer_collection_isolate_local(
}
while (lc_parent != lc) {
lc_parent->local_collections_bits |= v3d->local_collections_uuid;
lc_parent->local_collections_bits |= v3d->local_collections_uid;
LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) {
@ -1851,7 +1851,7 @@ void BKE_layer_collection_isolate_local(
}
/* Make all the children visible. */
layer_collection_local_visibility_set_recursive(lc, v3d->local_collections_uuid);
layer_collection_local_visibility_set_recursive(lc, v3d->local_collections_uid);
}
BKE_layer_collection_local_sync(scene, view_layer, v3d);

View File

@ -1362,29 +1362,6 @@ static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo)
BKE_ntree_update_tag_all(ntree);
}
/* Build a set of built-in node types to check for known types. */
static blender::Set<int> get_known_node_types_set()
{
blender::Set<int> result;
NODE_TYPES_BEGIN (ntype) {
result.add(ntype->type);
}
NODE_TYPES_END;
return result;
}
static bool can_read_node_type(const int type)
{
/* Can always read custom node types. */
if (type == NODE_CUSTOM) {
return true;
}
/* Check known built-in types. */
static blender::Set<int> known_types = get_known_node_types_set();
return known_types.contains(type);
}
static void node_set_typeinfo(const bContext *C,
bNodeTree *ntree,
bNode *node,
@ -1392,19 +1369,6 @@ static void node_set_typeinfo(const bContext *C,
{
/* for nodes saved in older versions storage can get lost, make undefined then */
if (node->flag & NODE_INIT) {
/* If the integer type is unknown then this is a node from a newer Blender version.
* These cannot be read reliably so replace the idname with an undefined type. This keeps links
* and socket names but discards storage and other type-specific data.
*/
if (!can_read_node_type(node->type)) {
node->type = NODE_CUSTOM;
/* This type name is arbitrary, it just has to be unique enough to not match a future node
* idname. Includes the old type identifier for debugging purposes. */
const std::string old_idname = node->idname;
BLI_snprintf(node->idname, sizeof(node->idname), "Undefined[%s]", old_idname.c_str());
typeinfo = nullptr;
}
if (typeinfo && typeinfo->storagename[0] && !node->storage) {
typeinfo = nullptr;
}
@ -4094,8 +4058,57 @@ void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash,
namespace blender::bke {
/* Build a set of built-in node types to check for known types. */
static blender::Set<int> get_known_node_types_set()
{
blender::Set<int> result;
NODE_TYPES_BEGIN (ntype) {
result.add(ntype->type);
}
NODE_TYPES_END;
return result;
}
static bool can_read_node_type(const int type)
{
/* Can always read custom node types. */
if (type == NODE_CUSTOM) {
return true;
}
/* Check known built-in types. */
static blender::Set<int> known_types = get_known_node_types_set();
return known_types.contains(type);
}
static void node_replace_undefined_types(bNode *node)
{
/* If the integer type is unknown then this node cannot be read. */
if (!can_read_node_type(node->type)) {
node->type = NODE_CUSTOM;
/* This type name is arbitrary, it just has to be unique enough to not match a future node
* idname. Includes the old type identifier for debugging purposes. */
const std::string old_idname = node->idname;
BLI_snprintf(node->idname, sizeof(node->idname), "Undefined[%s]", old_idname.c_str());
node->typeinfo = &NodeTypeUndefined;
}
}
void ntreeUpdateAllNew(Main *main)
{
/* Replace unknown node types with "Undefined".
* This happens when loading files from newer Blender versions. Such nodes cannot be read
* reliably so replace the idname with an undefined type. This keeps links and socket names but
* discards storage and other type-specific data.
*
* Replacement has to happen after after-liblink-versioning, since some node types still get
* replaced in those late versioning steps. */
FOREACH_NODETREE_BEGIN (main, ntree, owner_id) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
node_replace_undefined_types(node);
}
}
FOREACH_NODETREE_END;
/* Update all new node trees on file read or append, to add/remove sockets
* in groups nodes if the group changed, and handle any update flags that
* might have been set in file reading or versioning. */

View File

@ -62,6 +62,8 @@
#include "BLO_read_write.hh"
#include "DEG_depsgraph_query.hh"
#include "BIK_api.h"
#ifdef WITH_BULLET
@ -3356,7 +3358,20 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
cache->flag |= PTCACHE_BAKED;
/* write info file */
if (cache->flag & PTCACHE_DISK_CACHE) {
BKE_ptcache_write(pid, 0);
if (pid->type == PTCACHE_TYPE_PARTICLES) {
/* Since writing this from outside the bake job, make sure the ParticleSystem and
* PTCacheID is in a fully evaluated state. */
PTCacheID pid_eval;
Object *ob = reinterpret_cast<Object *>(pid->owner_id);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
ParticleSystem *psys = static_cast<ParticleSystem *>(pid->calldata);
ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
BKE_ptcache_id_from_particles(&pid_eval, ob_eval, psys_eval);
BKE_ptcache_write(&pid_eval, 0);
}
else {
BKE_ptcache_write(pid, 0);
}
}
}
}
@ -3386,7 +3401,20 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
if (bake) {
cache->flag |= PTCACHE_BAKED;
if (cache->flag & PTCACHE_DISK_CACHE) {
BKE_ptcache_write(pid, 0);
if (pid->type == PTCACHE_TYPE_PARTICLES) {
/* Since writing this from outside the bake job, make sure the ParticleSystem and
* PTCacheID is in a fully evaluated state. */
PTCacheID pid_eval;
Object *ob = reinterpret_cast<Object *>(pid->owner_id);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
ParticleSystem *psys = static_cast<ParticleSystem *>(pid->calldata);
ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys);
BKE_ptcache_id_from_particles(&pid_eval, ob_eval, psys_eval);
BKE_ptcache_write(&pid_eval, 0);
}
else {
BKE_ptcache_write(pid, 0);
}
}
}
}

View File

@ -1850,6 +1850,42 @@ static void versioning_grease_pencil_stroke_radii_scaling(GreasePencil *grease_p
}
}
static void fix_geometry_nodes_object_info_scale(bNodeTree &ntree)
{
using namespace blender;
MultiValueMap<bNodeSocket *, bNodeLink *> out_links_per_socket;
LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
if (link->fromnode->type == GEO_NODE_OBJECT_INFO) {
out_links_per_socket.add(link->fromsock, link);
}
}
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree.nodes) {
if (node->type != GEO_NODE_OBJECT_INFO) {
continue;
}
bNodeSocket *scale = nodeFindSocket(node, SOCK_OUT, "Scale");
const Span<bNodeLink *> links = out_links_per_socket.lookup(scale);
if (links.is_empty()) {
continue;
}
bNode *absolute_value = nodeAddNode(nullptr, &ntree, "ShaderNodeVectorMath");
absolute_value->custom1 = NODE_VECTOR_MATH_ABSOLUTE;
absolute_value->parent = node->parent;
absolute_value->locx = node->locx + 100;
absolute_value->locy = node->locy - 50;
nodeAddLink(&ntree,
node,
scale,
absolute_value,
static_cast<bNodeSocket *>(absolute_value->inputs.first));
for (bNodeLink *link : links) {
link->fromnode = absolute_value;
link->fromsock = static_cast<bNodeSocket *>(absolute_value->outputs.first);
}
}
}
void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
{
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 1)) {
@ -2628,6 +2664,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
if (ntree->type == NTREE_GEOMETRY) {
version_geometry_nodes_use_rotation_socket(*ntree);
versioning_nodes_dynamic_sockets_2(*ntree);
fix_geometry_nodes_object_info_scale(*ntree);
}
}
}
@ -2656,7 +2693,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 401, 13)) {
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
LISTBASE_FOREACH_MUTABLE (bNode *, node, &ntree->nodes) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == CMP_NODE_MAP_UV) {
node->custom2 = CMP_NODE_MAP_UV_FILTERING_ANISOTROPIC;
}

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
#include "BLI_array.hh"
#include "BLI_hash.hh"
#include "BLI_index_range.hh"
#include "BLI_math_vector.h"
#include "BLI_math_vector_types.hh"
#include "BLI_task.hh"
@ -71,21 +72,19 @@ CachedTexture::CachedTexture(Context &context,
const float2 pixel_coordinates = ((float2(x, y) + 0.5f) / float2(size)) * 2.0f - 1.0f;
/* Note that it is expected that the offset is scaled by the scale. */
const float3 coordinates = (float3(pixel_coordinates, 0.0f) + offset) * scale;
TexResult texture_result;
BKE_texture_get_value_ex(
texture, coordinates, &texture_result, image_pool, use_color_management);
const int result_type = multitex_ext_safe(
texture, coordinates, &texture_result, image_pool, use_color_management, false);
float4 color = float4(texture_result.trgba);
float value = texture_result.tin;
if (texture_result.talpha) {
value = texture_result.trgba[3];
}
else {
color.w = 1.0f;
color.w = texture_result.talpha ? color.w : texture_result.tin;
if (!(result_type & TEX_RGB)) {
copy_v3_fl(color, color.w);
}
color_pixels[y * size.x + x] = color;
value_pixels[y * size.x + x] = value;
value_pixels[y * size.x + x] = color.w;
}
}
});

View File

@ -54,25 +54,33 @@ shared TYPE reduction_data[reduction_size];
void main()
{
/* Load the data from the texture, while returning IDENTITY for out of bound coordinates. The
* developer is expected to define the IDENTITY macro to be a vec4 that does not affect the
* output of the reduction. For instance, sum reductions have an identity of vec4(0.0), while
* max value reductions have an identity of vec4(FLT_MIN). */
vec4 value = texture_load(input_tx, ivec2(gl_GlobalInvocationID.xy), IDENTITY);
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
/* Initialize the shared array given the previously loaded value. This step can be different
* depending on whether this is the initial reduction pass or a latter one. Indeed, the input
* texture for the initial reduction is the source texture itself, while the input texture to a
* latter reduction pass is an intermediate texture after one or more reductions have happened.
* This is significant because the data being reduced might be computed from the original data
* and different from it, for instance, when summing the luminance of an image, the original data
* is a vec4 color, while the reduced data is a float luminance value. So for the initial
* reduction pass, the luminance will be computed from the color, reduced, then stored into an
* intermediate float texture. On the other hand, for latter reduction passes, the luminance will
* be loaded directly and reduced without extra processing. So the developer is expected to
* define the INITIALIZE and LOAD macros to be expressions that derive the needed value from the
* loaded value for the initial reduction pass and latter ones respectively. */
reduction_data[gl_LocalInvocationIndex] = is_initial_reduction ? INITIALIZE(value) : LOAD(value);
/* Initialize the shared array for out of bound invocations using the IDENTITY value. The
* developer is expected to define the IDENTITY macro to be a value of type TYPE that does not
* affect the output of the reduction. For instance, sum reductions have an identity of 0.0,
* while max value reductions have an identity of FLT_MIN */
if (any(lessThan(texel, ivec2(0))) || any(greaterThanEqual(texel, texture_size(input_tx)))) {
reduction_data[gl_LocalInvocationIndex] = IDENTITY;
}
else {
vec4 value = texture_load_unbound(input_tx, texel);
/* Initialize the shared array given the previously loaded value. This step can be different
* depending on whether this is the initial reduction pass or a latter one. Indeed, the input
* texture for the initial reduction is the source texture itself, while the input texture to a
* latter reduction pass is an intermediate texture after one or more reductions have happened.
* This is significant because the data being reduced might be computed from the original data
* and different from it, for instance, when summing the luminance of an image, the original
* data is a vec4 color, while the reduced data is a float luminance value. So for the initial
* reduction pass, the luminance will be computed from the color, reduced, then stored into an
* intermediate float texture. On the other hand, for latter reduction passes, the luminance
* will be loaded directly and reduced without extra processing. So the developer is expected
* to define the INITIALIZE and LOAD macros to be expressions that derive the needed value from
* the loaded value for the initial reduction pass and latter ones respectively. */
reduction_data[gl_LocalInvocationIndex] = is_initial_reduction ? INITIALIZE(value) :
LOAD(value);
}
/* Reduce the reduction data by half on every iteration until only one element remains. See the
* above figure for an intuitive understanding of the stride value. */

View File

@ -16,13 +16,13 @@ GPU_SHADER_CREATE_INFO(compositor_parallel_reduction_shared)
GPU_SHADER_CREATE_INFO(compositor_sum_shared)
.additional_info("compositor_parallel_reduction_shared")
.define("IDENTITY", "vec4(0.0)")
.define("REDUCE(lhs, rhs)", "lhs + rhs");
GPU_SHADER_CREATE_INFO(compositor_sum_float_shared)
.additional_info("compositor_sum_shared")
.image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
.define("TYPE", "float")
.define("IDENTITY", "0.0")
.define("LOAD(value)", "value.x");
GPU_SHADER_CREATE_INFO(compositor_sum_red)
@ -56,6 +56,7 @@ GPU_SHADER_CREATE_INFO(compositor_sum_color)
.additional_info("compositor_sum_shared")
.image(0, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
.define("TYPE", "vec4")
.define("IDENTITY", "vec4(0.0)")
.define("INITIALIZE(value)", "value")
.define("LOAD(value)", "value")
.do_static_compilation(true);
@ -69,7 +70,7 @@ GPU_SHADER_CREATE_INFO(compositor_sum_squared_difference_float_shared)
.image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
.push_constant(Type::FLOAT, "subtrahend")
.define("TYPE", "float")
.define("IDENTITY", "vec4(subtrahend)")
.define("IDENTITY", "0.0")
.define("LOAD(value)", "value.x")
.define("REDUCE(lhs, rhs)", "lhs + rhs");
@ -104,7 +105,7 @@ GPU_SHADER_CREATE_INFO(compositor_maximum_luminance)
.image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
.push_constant(Type::VEC3, "luminance_coefficients")
.define("TYPE", "float")
.define("IDENTITY", "vec4(FLT_MIN)")
.define("IDENTITY", "FLT_MIN")
.define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
.define("LOAD(value)", "value.x")
.define("REDUCE(lhs, rhs)", "max(lhs, rhs)")
@ -116,7 +117,7 @@ GPU_SHADER_CREATE_INFO(compositor_maximum_float_in_range)
.push_constant(Type::FLOAT, "lower_bound")
.push_constant(Type::FLOAT, "upper_bound")
.define("TYPE", "float")
.define("IDENTITY", "vec4(lower_bound)")
.define("IDENTITY", "lower_bound")
.define("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : lower_bound")
.define("LOAD(value)", "value.x")
.define("REDUCE(lhs, rhs)", "((rhs > lhs) && (rhs <= upper_bound)) ? rhs : lhs")
@ -132,7 +133,7 @@ GPU_SHADER_CREATE_INFO(compositor_minimum_luminance)
.image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
.push_constant(Type::VEC3, "luminance_coefficients")
.define("TYPE", "float")
.define("IDENTITY", "vec4(FLT_MAX)")
.define("IDENTITY", "FLT_MAX")
.define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
.define("LOAD(value)", "value.x")
.define("REDUCE(lhs, rhs)", "min(lhs, rhs)")
@ -144,7 +145,7 @@ GPU_SHADER_CREATE_INFO(compositor_minimum_float_in_range)
.push_constant(Type::FLOAT, "lower_bound")
.push_constant(Type::FLOAT, "upper_bound")
.define("TYPE", "float")
.define("IDENTITY", "vec4(upper_bound)")
.define("IDENTITY", "upper_bound")
.define("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : upper_bound")
.define("LOAD(value)", "value.x")
.define("REDUCE(lhs, rhs)", "((rhs < lhs) && (rhs >= lower_bound)) ? rhs : lhs")

View File

@ -10,7 +10,7 @@
struct MovieClip;
struct MovieClipCache;
struct anim;
struct ImBufAnim;
namespace blender::deg {
@ -26,7 +26,7 @@ class MovieClipBackup {
void init_from_movieclip(MovieClip *movieclip);
void restore_to_movieclip(MovieClip *movieclip);
struct anim *anim;
struct ImBufAnim *anim;
struct MovieClipCache *cache;
};

View File

@ -668,7 +668,7 @@ RenderEngineType DRW_engine_viewport_eevee_type = {
/*next*/ nullptr,
/*prev*/ nullptr,
/*idname*/ EEVEE_ENGINE,
/*name*/ N_("EEVEE (Legacy)"),
/*name*/ N_("EEVEE"),
/*flag*/ RE_INTERNAL | RE_USE_PREVIEW | RE_USE_STEREO_VIEWPORT | RE_USE_GPU_CONTEXT,
/*update*/ nullptr,
/*render*/ &DRW_render_to_image,

View File

@ -212,7 +212,7 @@ RenderEngineType DRW_engine_viewport_eevee_next_type = {
/*next*/ nullptr,
/*prev*/ nullptr,
/*idname*/ "BLENDER_EEVEE_NEXT",
/*name*/ N_("EEVEE"),
/*name*/ N_("EEVEE-Next"),
/*flag*/ RE_INTERNAL | RE_USE_PREVIEW | RE_USE_STEREO_VIEWPORT | RE_USE_GPU_CONTEXT,
/*update*/ nullptr,
/*render*/ &DRW_render_to_image,

View File

@ -1145,21 +1145,14 @@ void DRW_draw_region_engine_info(int xoffset, int *yoffset, int line_height)
if (data->info[0] != '\0') {
const int font_id = BLF_default();
UI_FontThemeColor(font_id, TH_TEXT_HI);
BLF_enable(font_id, BLF_SHADOW);
BLF_shadow(font_id, 5, blender::float4{0.0f, 0.0f, 0.0f, 1.0f});
BLF_shadow_offset(font_id, 1, -1);
const char *buf_step = IFACE_(data->info);
do {
const char *buf = buf_step;
buf_step = BLI_strchr_or_end(buf, '\n');
const int buf_len = buf_step - buf;
*yoffset -= line_height;
BLF_draw_default(xoffset, *yoffset, 0.0f, buf, buf_len);
BLF_draw_default_shadowed(xoffset, *yoffset, 0.0f, buf, buf_len);
} while (*buf_step ? ((void)buf_step++, true) : false);
BLF_disable(font_id, BLF_SHADOW);
}
}
}

View File

@ -196,16 +196,16 @@ void DRW_stats_reset()
static void draw_stat_5row(const rcti *rect, int u, int v, const char *txt, const int size)
{
BLF_draw_default(rect->xmin + (1 + u * 5) * U.widget_unit,
rect->ymax - (3 + v) * U.widget_unit,
0.0f,
txt,
size);
BLF_draw_default_shadowed(rect->xmin + (1 + u * 5) * U.widget_unit,
rect->ymax - (3 + v) * U.widget_unit,
0.0f,
txt,
size);
}
static void draw_stat(const rcti *rect, int u, int v, const char *txt, const int size)
{
BLF_draw_default(
BLF_draw_default_shadowed(
rect->xmin + (1 + u) * U.widget_unit, rect->ymax - (3 + v) * U.widget_unit, 0.0f, txt, size);
}
@ -219,11 +219,6 @@ void DRW_stats_draw(const rcti *rect)
int fontid = BLF_default();
UI_FontThemeColor(fontid, TH_TEXT_HI);
BLF_enable(fontid, BLF_SHADOW);
const float rgba[] = {0.0f, 0.0f, 0.0f, 0.75f};
BLF_shadow(fontid, 5, rgba);
BLF_shadow_offset(fontid, 0, -1);
BLF_batch_draw_begin();
/* ------------------------------------------ */
@ -352,5 +347,4 @@ void DRW_stats_draw(const rcti *rect)
}
BLF_batch_draw_end();
BLF_disable(fontid, BLF_SHADOW);
}

View File

@ -5,7 +5,7 @@
#include "testing/testing.h"
#include "BKE_context.hh"
#include "BKE_idtype.h"
#include "BKE_idtype.hh"
#include "BKE_main.hh"
#include "BKE_node.hh"
#include "BKE_object.hh"

View File

@ -219,7 +219,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op
/* Create a new grease pencil object. */
Object *ob_gpencil = nullptr;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
ob_gpencil = ED_gpencil_add_object(C, scene->cursor.location, local_view_bits);
float invmat[4][4];
invert_m4_m4(invmat, ob_gpencil->object_to_world);

View File

@ -226,7 +226,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op)
}
if (ob_gpencil == nullptr) {
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
const float loc[3] = {0.0f, 0.0f, 0.0f};
ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits);
newob = true;

View File

@ -2093,7 +2093,7 @@ static bool gpencil_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
ushort local_view_bits = 0;
if (v3d->localvd) {
local_view_bits = v3d->local_view_uuid;
local_view_bits = v3d->local_view_uid;
}
/* create new default object */
obact = ED_gpencil_add_object(C, cur, local_view_bits);

View File

@ -177,7 +177,7 @@ static void trace_initialize_job_data(TraceJob *trace_job)
/* Create a new grease pencil object. */
if (trace_job->ob_gpencil == nullptr) {
ushort local_view_bits = (trace_job->v3d && trace_job->v3d->localvd) ?
trace_job->v3d->local_view_uuid :
trace_job->v3d->local_view_uid :
0;
trace_job->ob_gpencil = ED_gpencil_add_object(
trace_job->C, trace_job->ob_active->loc, local_view_bits);

View File

@ -749,21 +749,21 @@ static uint get_material_type(MaterialGPencilStyle *gp_style,
char *name,
size_t name_maxncpy)
{
uint r_i = 0;
uint i = 0;
if ((use_stroke) && (use_fill)) {
switch (gp_style->mode) {
case GP_MATERIAL_MODE_LINE: {
r_i = 1;
i = 1;
BLI_strncpy(name, "Line Stroke-Fill", name_maxncpy);
break;
}
case GP_MATERIAL_MODE_DOT: {
r_i = 2;
i = 2;
BLI_strncpy(name, "Dots Stroke-Fill", name_maxncpy);
break;
}
case GP_MATERIAL_MODE_SQUARE: {
r_i = 3;
i = 3;
BLI_strncpy(name, "Squares Stroke-Fill", name_maxncpy);
break;
}
@ -774,17 +774,17 @@ static uint get_material_type(MaterialGPencilStyle *gp_style,
else if (use_stroke) {
switch (gp_style->mode) {
case GP_MATERIAL_MODE_LINE: {
r_i = 4;
i = 4;
BLI_strncpy(name, "Line Stroke", name_maxncpy);
break;
}
case GP_MATERIAL_MODE_DOT: {
r_i = 5;
i = 5;
BLI_strncpy(name, "Dots Stroke", name_maxncpy);
break;
}
case GP_MATERIAL_MODE_SQUARE: {
r_i = 6;
i = 6;
BLI_strncpy(name, "Squares Stroke", name_maxncpy);
break;
}
@ -793,20 +793,20 @@ static uint get_material_type(MaterialGPencilStyle *gp_style,
}
}
else {
r_i = 7;
i = 7;
BLI_strncpy(name, "Solid Fill", name_maxncpy);
}
/* Create key TSSSSFFFF (T: Type S: Stroke Alpha F: Fill Alpha) */
r_i *= 1e8;
i *= 1e8;
if (use_stroke) {
r_i += gp_style->stroke_rgba[3] * 1e7;
i += gp_style->stroke_rgba[3] * 1e7;
}
if (use_fill) {
r_i += gp_style->fill_rgba[3] * 1e3;
i += gp_style->fill_rgba[3] * 1e3;
}
return r_i;
return i;
}
static bool gpencil_material_to_vertex_poll(bContext *C)

View File

@ -378,7 +378,7 @@ static void ui_block_bounds_calc_text(uiBlock *block, float offset)
uiBut *init_col_bt = static_cast<uiBut *>(block->buttons.first);
LISTBASE_FOREACH (uiBut *, bt, &block->buttons) {
if (!ELEM(bt->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) {
j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
j = BLF_width(style->widget.uifont_id, bt->drawstr.c_str(), bt->drawstr.size());
if (j > i) {
i = j;
@ -2519,7 +2519,7 @@ bool ui_but_is_rna_valid(uiBut *but)
if (but->rnaprop == nullptr || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) {
return true;
}
printf("property removed %s: %p\n", but->drawstr, but->rnaprop);
printf("property removed %s: %p\n", but->drawstr.c_str(), but->rnaprop);
return false;
}
@ -3694,9 +3694,6 @@ void UI_block_set_search_only(uiBlock *block, bool search_only)
static void ui_but_build_drawstr_float(uiBut *but, double value)
{
size_t slen = 0;
STR_CONCAT(but->drawstr, slen, but->str.c_str());
PropertySubType subtype = PROP_NONE;
if (but->rnaprop) {
subtype = RNA_property_subtype(but->rnaprop);
@ -3706,57 +3703,54 @@ static void ui_but_build_drawstr_float(uiBut *but, double value)
value += +0.0f;
if (value == double(FLT_MAX)) {
STR_CONCAT(but->drawstr, slen, "inf");
but->drawstr = but->str + "inf";
}
else if (value == double(-FLT_MAX)) {
STR_CONCAT(but->drawstr, slen, "-inf");
but->drawstr = but->str + "-inf";
}
else if (subtype == PROP_PERCENTAGE) {
const int prec = ui_but_calc_float_precision(but, value);
STR_CONCATF(but->drawstr, slen, "%.*f%%", prec, value);
but->drawstr = fmt::format("{}{:.{}f}%", but->str, value, prec);
}
else if (subtype == PROP_PIXEL) {
const int prec = ui_but_calc_float_precision(but, value);
STR_CONCATF(but->drawstr, slen, "%.*f px", prec, value);
but->drawstr = fmt::format("{}{:.{}f} px", but->str, value, prec);
}
else if (subtype == PROP_FACTOR) {
const int precision = ui_but_calc_float_precision(but, value);
if (U.factor_display_type == USER_FACTOR_AS_FACTOR) {
STR_CONCATF(but->drawstr, slen, "%.*f", precision, value);
but->drawstr = fmt::format("{}{:.{}f}", but->str, value, precision);
}
else {
STR_CONCATF(but->drawstr, slen, "%.*f%%", std::max(0, precision - 2), value * 100);
but->drawstr = fmt::format("{}{:.{}f}", but->str, value * 100, std::max(0, precision - 2));
}
}
else if (ui_but_is_unit(but)) {
char new_str[sizeof(but->drawstr)];
char new_str[UI_MAX_DRAW_STR];
ui_get_but_string_unit(but, new_str, sizeof(new_str), value, true, -1);
STR_CONCAT(but->drawstr, slen, new_str);
but->drawstr = but->str + new_str;
}
else {
const int prec = ui_but_calc_float_precision(but, value);
STR_CONCATF(but->drawstr, slen, "%.*f", prec, value);
but->drawstr = fmt::format("{}{:.{}f}", but->str, value, prec);
}
}
static void ui_but_build_drawstr_int(uiBut *but, int value)
{
size_t slen = 0;
STR_CONCAT(but->drawstr, slen, but->str.c_str());
PropertySubType subtype = PROP_NONE;
if (but->rnaprop) {
subtype = RNA_property_subtype(but->rnaprop);
}
STR_CONCATF(but->drawstr, slen, "%d", value);
but->drawstr = but->str + std::to_string(value);
if (subtype == PROP_PERCENTAGE) {
STR_CONCAT(but->drawstr, slen, "%");
but->drawstr += "%";
}
else if (subtype == PROP_PIXEL) {
STR_CONCAT(but->drawstr, slen, " px");
but->drawstr += " px";
}
}
@ -3843,7 +3837,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
}
}
}
STRNCPY(but->drawstr, but->str.c_str());
but->drawstr = but->str;
}
break;
@ -3865,10 +3859,10 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
if (ui_but_is_float(but)) {
UI_GET_BUT_VALUE_INIT(but, value);
const int prec = ui_but_calc_float_precision(but, value);
SNPRINTF(but->drawstr, "%s%.*f", but->str.c_str(), prec, value);
but->drawstr = fmt::format("{}{:.{}f}", but->str, value, prec);
}
else {
STRNCPY(but->drawstr, but->str.c_str());
but->drawstr = but->str;
}
break;
@ -3877,9 +3871,8 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
case UI_BTYPE_SEARCH_MENU:
if (!but->editstr) {
char str[UI_MAX_DRAW_STR];
ui_but_string_get(but, str, UI_MAX_DRAW_STR);
SNPRINTF(but->drawstr, "%s%s", but->str.c_str(), str);
but->drawstr = fmt::format("{}{}", but->str, str);
}
break;
@ -3892,7 +3885,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
UI_GET_BUT_VALUE_INIT(but, value);
str = WM_key_event_string(short(value), false);
}
SNPRINTF(but->drawstr, "%s%s", but->str.c_str(), str);
but->drawstr = fmt::format("{}{}", but->str, str);
break;
}
case UI_BTYPE_HOTKEY_EVENT:
@ -3906,14 +3899,17 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
kmi_dummy.ctrl = (hotkey_but->modifier_key & KM_CTRL) ? KM_PRESS : KM_NOTHING;
kmi_dummy.alt = (hotkey_but->modifier_key & KM_ALT) ? KM_PRESS : KM_NOTHING;
kmi_dummy.oskey = (hotkey_but->modifier_key & KM_OSKEY) ? KM_PRESS : KM_NOTHING;
WM_keymap_item_to_string(&kmi_dummy, true, but->drawstr, sizeof(but->drawstr));
char kmi_str[128];
WM_keymap_item_to_string(&kmi_dummy, true, kmi_str, sizeof(kmi_str));
but->drawstr = kmi_str;
}
else {
STRNCPY_UTF8(but->drawstr, IFACE_("Press a key"));
but->drawstr = IFACE_("Press a key");
}
}
else {
STRNCPY_UTF8(but->drawstr, but->str.c_str());
but->drawstr = but->str;
}
break;
@ -3922,13 +3918,13 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
case UI_BTYPE_HSVCIRCLE:
break;
default:
STRNCPY(but->drawstr, but->str.c_str());
but->drawstr = but->str;
break;
}
/* if we are doing text editing, this will override the drawstr */
if (but->editstr) {
but->drawstr[0] = '\0';
but->drawstr.clear();
}
/* text clipping moved to widget drawing code itself */
@ -5915,6 +5911,9 @@ const char *ui_but_placeholder_get(uiBut *but)
else if (type && !STREQ(RNA_struct_identifier(type), "UnknownType")) {
placeholder = RNA_struct_ui_name(type);
}
else {
placeholder = RNA_property_ui_name(but->rnaprop);
}
}
else if (but->type == UI_BTYPE_TEXT && but->icon == ICON_VIEWZOOM) {
placeholder = CTX_IFACE_(BLT_I18NCONTEXT_ID_WINDOWMANAGER, "Search");
@ -6359,7 +6358,7 @@ void UI_but_func_search_set(uiBut *but,
* buttons where any result is valid anyway, since any string will be valid anyway. */
if (0 == (but->block->flag & UI_BLOCK_LOOP) && !search_but->results_are_suggestions) {
/* skip empty buttons, not all buttons need input, we only show invalid */
if (but->drawstr[0]) {
if (!but->drawstr.empty()) {
ui_but_search_refresh(search_but);
}
}

View File

@ -375,8 +375,7 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
{
BLI_assert(ui_but_is_user_menu_compatible(C, but));
char drawstr[sizeof(but->drawstr)];
ui_but_drawstr_without_sep_char(but, drawstr, sizeof(drawstr));
std::string drawstr = ui_but_drawstr_without_sep_char(but);
/* Used for USER_MENU_TYPE_MENU. */
MenuType *mt = nullptr;
@ -401,12 +400,12 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
idname);
char *expr_result = nullptr;
if (BPY_run_string_as_string(C, expr_imports, expr, nullptr, &expr_result)) {
STRNCPY(drawstr, expr_result);
drawstr = expr_result;
MEM_freeN(expr_result);
}
else {
BLI_assert(0);
STRNCPY(drawstr, idname);
drawstr = idname;
}
}
#else
@ -416,7 +415,7 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
}
ED_screen_user_menu_item_add_operator(
&um->items,
drawstr,
drawstr.c_str(),
but->optype,
but->opptr ? static_cast<const IDProperty *>(but->opptr->data) : nullptr,
"",
@ -434,7 +433,7 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
MEM_freeN(member_id_data_path);
}
else if ((mt = UI_but_menutype_get(but))) {
ED_screen_user_menu_item_add_menu(&um->items, drawstr, mt);
ED_screen_user_menu_item_add_menu(&um->items, drawstr.c_str(), mt);
}
else if ((ot = UI_but_operatortype_get_from_enum_menu(but, &prop))) {
ED_screen_user_menu_item_add_operator(&um->items,

View File

@ -506,7 +506,7 @@ struct uiAfterFunc {
std::optional<bContextStore> context;
char undostr[BKE_UNDO_STR_MAX];
char drawstr[UI_MAX_DRAW_STR];
std::string drawstr;
};
static void button_activate_init(bContext *C,
@ -794,7 +794,7 @@ static void ui_handle_afterfunc_add_operator_ex(wmOperatorType *ot,
}
if (context_but) {
ui_but_drawstr_without_sep_char(context_but, after->drawstr, sizeof(after->drawstr));
after->drawstr = ui_but_drawstr_without_sep_char(context_but);
}
}
@ -909,7 +909,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
after->context = *but->context;
}
ui_but_drawstr_without_sep_char(but, after->drawstr, sizeof(after->drawstr));
after->drawstr = ui_but_drawstr_without_sep_char(but);
but->optype = nullptr;
but->opcontext = wmOperatorCallContext(0);
@ -929,11 +929,11 @@ static void ui_apply_but_undo(uiBut *but)
/* define which string to use for undo */
if (but->type == UI_BTYPE_MENU) {
str = but->drawstr;
str = but->drawstr.empty() ? nullptr : but->drawstr.c_str();
str_len_clip = ui_but_drawstr_len_without_sep_char(but);
}
else if (but->drawstr[0]) {
str = but->drawstr;
else if (!but->drawstr.empty()) {
str = but->drawstr.c_str();
str_len_clip = ui_but_drawstr_len_without_sep_char(but);
}
else {
@ -1042,7 +1042,7 @@ static void ui_apply_but_funcs_after(bContext *C)
after.opcontext,
(after.opptr) ? &opptr : nullptr,
nullptr,
after.drawstr);
after.drawstr.c_str());
}
if (after.opptr) {
@ -2946,7 +2946,7 @@ void ui_but_clipboard_free()
static int ui_text_position_from_hidden(uiBut *but, int pos)
{
const char *butstr = (but->editstr) ? but->editstr : but->drawstr;
const char *butstr = (but->editstr) ? but->editstr : but->drawstr.c_str();
const char *strpos = butstr;
const char *str_end = butstr + strlen(butstr);
for (int i = 0; i < pos; i++) {
@ -2958,7 +2958,7 @@ static int ui_text_position_from_hidden(uiBut *but, int pos)
static int ui_text_position_to_hidden(uiBut *but, int pos)
{
const char *butstr = (but->editstr) ? but->editstr : but->drawstr;
const char *butstr = (but->editstr) ? but->editstr : but->drawstr.c_str();
return BLI_strnlen_utf8(butstr, pos);
}
@ -2970,7 +2970,7 @@ void ui_but_text_password_hide(char password_str[UI_MAX_PASSWORD_STR],
return;
}
char *butstr = (but->editstr) ? but->editstr : but->drawstr;
char *butstr = (but->editstr) ? but->editstr : but->drawstr.data();
if (restore) {
/* restore original string */
@ -4616,7 +4616,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C,
if (ELEM(event->type, LEFTMOUSE, EVT_PADENTER, EVT_RETKEY, EVT_BUT_OPEN) &&
(event->val == KM_PRESS))
{
but->drawstr[0] = 0;
but->drawstr.clear();
hotkey_but->modifier_key = 0;
button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
return WM_UI_HANDLER_BREAK;

View File

@ -13,6 +13,7 @@
#include "BLI_compiler_attrs.h"
#include "BLI_math_vector_types.hh"
#include "BLI_rect.h"
#include "BLI_string_ref.hh"
#include "BLI_vector.hh"
#include "DNA_listBase.h"
@ -180,7 +181,7 @@ struct uiBut {
std::string str;
char drawstr[UI_MAX_DRAW_STR] = "";
std::string drawstr;
char *placeholder = nullptr;
@ -1254,7 +1255,7 @@ void ui_draw_preview_item(const uiFontStyle *fstyle,
*/
void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
rcti *rect,
const char *name,
blender::StringRef name,
int iconid,
const uchar text_col[4],
eFontStyle_Align text_align,
@ -1428,8 +1429,7 @@ uiBut *ui_list_find_mouse_over_ex(const ARegion *region, const int xy[2])
bool ui_but_contains_password(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
size_t ui_but_drawstr_without_sep_char(const uiBut *but, char *str, size_t str_maxncpy)
ATTR_NONNULL(1, 2);
blender::StringRef ui_but_drawstr_without_sep_char(const uiBut *but) ATTR_NONNULL();
size_t ui_but_drawstr_len_without_sep_char(const uiBut *but);
size_t ui_but_tip_len_only_first_line(const uiBut *but);

View File

@ -1312,7 +1312,7 @@ static void ui_item_menu_hold(bContext *C, ARegion *butregion, uiBut *but)
block->flag |= UI_BLOCK_POPUP_HOLD;
char direction = UI_DIR_DOWN;
if (!but->drawstr[0]) {
if (but->drawstr.empty()) {
switch (RGN_ALIGN_ENUM_FROM_MASK(butregion->alignment)) {
case RGN_ALIGN_LEFT:
direction = UI_DIR_RIGHT;
@ -6265,7 +6265,7 @@ static void ui_layout_introspect_button(DynStr *ds, uiButtonItem *bitem)
{
uiBut *but = bitem->but;
BLI_dynstr_appendf(ds, "'type':%d, ", int(but->type));
BLI_dynstr_appendf(ds, "'draw_string':'''%s''', ", but->drawstr);
BLI_dynstr_appendf(ds, "'draw_string':'''%s''', ", but->drawstr.c_str());
/* Not exactly needed, rna has this. */
BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : "");

View File

@ -1801,8 +1801,7 @@ static bool ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
* if this fails it only means edit-source fails - campbell */
if (BLI_rctf_compare(&but_a->rect, &but_b->rect, FLT_EPSILON) && (but_a->type == but_b->type) &&
(but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) &&
(but_a->unit_type == but_b->unit_type) &&
STREQLEN(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR))
(but_a->unit_type == but_b->unit_type) && but_a->drawstr == but_b->drawstr)
{
return true;
}

View File

@ -590,18 +590,18 @@ bool ui_but_contains_password(const uiBut *but)
size_t ui_but_drawstr_len_without_sep_char(const uiBut *but)
{
if (but->flag & UI_BUT_HAS_SEP_CHAR) {
const char *str_sep = strrchr(but->drawstr, UI_SEP_CHAR);
if (str_sep != nullptr) {
return (str_sep - but->drawstr);
const size_t sep_index = but->drawstr.find(UI_SEP_CHAR);
if (sep_index != std::string::npos) {
return sep_index;
}
}
return strlen(but->drawstr);
return but->drawstr.size();
}
size_t ui_but_drawstr_without_sep_char(const uiBut *but, char *str, size_t str_maxncpy)
blender::StringRef ui_but_drawstr_without_sep_char(const uiBut *but)
{
size_t str_len_clip = ui_but_drawstr_len_without_sep_char(but);
return BLI_strncpy_rlen(str, but->drawstr, min_zz(str_len_clip + 1, str_maxncpy));
return blender::StringRef(but->drawstr).substr(0, str_len_clip);
}
size_t ui_but_tip_len_only_first_line(const uiBut *but)

View File

@ -216,7 +216,7 @@ static void ui_update_color_picker_buts_rgb(uiBut *from_but,
const int col_len = SNPRINTF_RLEN(col, "%02X%02X%02X", UNPACK3_EX((uint), rgb_hex_uchar, ));
memcpy(bt->poin, col, col_len + 1);
}
else if (bt->str[1] == ' ') {
else if (bt->str.find(' ', 1) == 1) {
if (bt->str[0] == 'R') {
ui_but_value_set(bt, rgb_scene_linear[0]);
}

View File

@ -247,7 +247,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
}
else if (pup->but) {
/* Minimum width to enforce. */
if (pup->but->drawstr[0]) {
if (!pup->but->drawstr.empty()) {
minwidth = BLI_rctf_size_x(&pup->but->rect);
}
else {

View File

@ -1098,7 +1098,7 @@ void ui_but_search_refresh(uiButSearch *but)
items->names[i] = (char *)MEM_callocN(but->hardmax + 1, __func__);
}
ui_searchbox_update_fn((bContext *)but->block->evil_C, but, but->drawstr, items);
ui_searchbox_update_fn((bContext *)but->block->evil_C, but, but->drawstr.c_str(), items);
if (!but->results_are_suggestions) {
/* Only red-alert when we are sure of it, this can miss cases when >10 matches. */
@ -1106,7 +1106,7 @@ void ui_but_search_refresh(uiButSearch *but)
UI_but_flag_enable(but, UI_BUT_REDALERT);
}
else if (items->more == 0) {
if (UI_search_items_find_index(items, but->drawstr) == -1) {
if (UI_search_items_find_index(items, but->drawstr.c_str()) == -1) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
}
}

View File

@ -467,7 +467,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is
* doesn't have access to information about non-active tools. */
/* Title (when icon-only). */
if (but->drawstr[0] == '\0') {
if (but->drawstr.empty()) {
const char *expr_imports[] = {"bpy", "bl_ui", nullptr};
char expr[256];
SNPRINTF(expr,
@ -866,7 +866,9 @@ static uiTooltipData *ui_tooltip_data_from_button_or_extra_icon(bContext *C,
* prefix instead of comparing because the button may include the shortcut. Buttons with dynamic
* tool-tips also don't get their default label here since they can already provide more accurate
* and specific tool-tip content. */
else if (!but_label.empty() && !STRPREFIX(but->drawstr, but_label.c_str()) && !but->tip_func) {
else if (!but_label.empty() && !blender::StringRef(but->drawstr).startswith(but_label) &&
!but->tip_func)
{
UI_tooltip_text_field_add(data, but_label, {}, UI_TIP_STYLE_HEADER, UI_TIP_LC_NORMAL);
}

View File

@ -163,14 +163,14 @@ static bool menu_items_from_ui_create_item_from_button(MenuSearch_Data *data,
MenuSearch_Context *wm_context,
MenuSearch_Parent *menu_parent)
{
using namespace blender;
MenuSearch_Item *item = nullptr;
/* Use override if the name is empty, this can happen with popovers. */
std::string drawstr_override;
const char *drawstr_sep = (but->flag & UI_BUT_HAS_SEP_CHAR) ?
strrchr(but->drawstr, UI_SEP_CHAR) :
nullptr;
const bool drawstr_is_empty = (drawstr_sep == but->drawstr) || (but->drawstr[0] == '\0');
const size_t sep_index = (but->flag & UI_BUT_HAS_SEP_CHAR) ? but->drawstr.find(UI_SEP_CHAR) :
std::string::npos;
const bool drawstr_is_empty = sep_index == 0 || but->drawstr.empty();
if (but->optype != nullptr) {
if (drawstr_is_empty) {
@ -215,7 +215,7 @@ static bool menu_items_from_ui_create_item_from_button(MenuSearch_Data *data,
/* Note that these buttons are not prevented,
* but aren't typically used in menus. */
printf("Button '%s' in menu '%s' is a menu item with unsupported RNA type %d\n",
but->drawstr,
but->drawstr.c_str(),
mt->idname,
prop_type);
}
@ -236,12 +236,14 @@ static bool menu_items_from_ui_create_item_from_button(MenuSearch_Data *data,
if (item != nullptr) {
/* Handle shared settings. */
if (!drawstr_override.empty()) {
const char *drawstr_suffix = drawstr_sep ? drawstr_sep : "";
const StringRef drawstr_suffix = sep_index == std::string::npos ?
"" :
StringRef(but->drawstr).drop_prefix(sep_index);
std::string drawstr = std::string("(") + drawstr_override + ")" + drawstr_suffix;
item->drawstr = strdup_memarena(memarena, drawstr.c_str());
}
else {
item->drawstr = strdup_memarena(memarena, but->drawstr);
item->drawstr = strdup_memarena(memarena, but->drawstr.c_str());
}
item->icon = ui_but_icon(but);
@ -290,11 +292,11 @@ static bool menu_items_to_ui_button(MenuSearch_Item *item, uiBut *but)
}
if (changed) {
STRNCPY(but->drawstr, item->drawstr);
char *drawstr_sep = (item->state & UI_BUT_HAS_SEP_CHAR) ? strrchr(but->drawstr, UI_SEP_CHAR) :
nullptr;
if (drawstr_sep) {
*drawstr_sep = '\0';
but->drawstr = item->drawstr;
const size_t sep_index = but->drawstr.find(UI_SEP_CHAR);
if (sep_index != std::string::npos) {
but->drawstr.resize(sep_index);
}
but->icon = item->icon;
@ -707,7 +709,7 @@ static MenuSearch_Data *menu_items_from_ui_create(bContext *C,
}
if (but_test == nullptr) {
menu_display_name_map.add(mt, strdup_memarena(memarena, but->drawstr));
menu_display_name_map.add(mt, strdup_memarena(memarena, but->drawstr.c_str()));
}
}
else if (menu_items_from_ui_create_item_from_button(
@ -730,14 +732,14 @@ static MenuSearch_Data *menu_items_from_ui_create(bContext *C,
* we only want to do that for the last menu item, not the path that leads to it.
*/
const char *drawstr_sep = but->flag & UI_BUT_HAS_SEP_CHAR ?
strrchr(but->drawstr, UI_SEP_CHAR) :
strrchr(but->drawstr.c_str(), UI_SEP_CHAR) :
nullptr;
bool drawstr_is_empty = false;
if (drawstr_sep != nullptr) {
BLI_assert(BLI_dynstr_get_len(dyn_str) == 0);
/* Detect empty string, fallback to menu name. */
const char *drawstr = but->drawstr;
int drawstr_len = drawstr_sep - but->drawstr;
const char *drawstr = but->drawstr.c_str();
int drawstr_len = drawstr_sep - but->drawstr.c_str();
if (UNLIKELY(drawstr_len == 0)) {
drawstr = CTX_IFACE_(mt_from_but->translation_context, mt_from_but->label);
drawstr_len = strlen(drawstr);
@ -751,7 +753,7 @@ static MenuSearch_Data *menu_items_from_ui_create(bContext *C,
BLI_dynstr_clear(dyn_str);
}
else {
const char *drawstr = but->drawstr;
const char *drawstr = but->drawstr.c_str();
if (UNLIKELY(drawstr[0] == '\0')) {
drawstr = CTX_IFACE_(mt_from_but->translation_context, mt_from_but->label);
if (drawstr[0] == '\0') {
@ -792,7 +794,7 @@ static MenuSearch_Data *menu_items_from_ui_create(bContext *C,
MenuSearch_Parent *menu_parent = (MenuSearch_Parent *)BLI_memarena_calloc(
memarena, sizeof(*menu_parent));
menu_parent->drawstr = strdup_memarena(memarena, but->drawstr);
menu_parent->drawstr = strdup_memarena(memarena, but->drawstr.c_str());
menu_parent->parent = current_menu.self_as_parent;
LISTBASE_FOREACH (uiBut *, sub_but, &sub_block->buttons) {

View File

@ -1599,11 +1599,14 @@ static void ui_text_clip_middle(const uiFontStyle *fstyle, uiBut *but, const rct
0 :
int(UI_TEXT_CLIP_MARGIN + 0.5f);
const float okwidth = float(max_ii(BLI_rcti_size_x(rect) - border, 0));
const size_t max_len = sizeof(but->drawstr);
const float minwidth = float(UI_ICON_SIZE) / but->block->aspect * 2.0f;
but->ofs = 0;
but->strwidth = UI_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, '\0');
char new_drawstr[UI_MAX_DRAW_STR];
STRNCPY(new_drawstr, but->drawstr.c_str());
const size_t max_len = sizeof(new_drawstr);
but->strwidth = UI_text_clip_middle_ex(fstyle, new_drawstr, okwidth, minwidth, max_len, '\0');
but->drawstr = new_drawstr;
}
/**
@ -1622,11 +1625,14 @@ static void ui_text_clip_middle_protect_right(const uiFontStyle *fstyle,
0 :
int(UI_TEXT_CLIP_MARGIN + 0.5f);
const float okwidth = float(max_ii(BLI_rcti_size_x(rect) - border, 0));
const size_t max_len = sizeof(but->drawstr);
const float minwidth = float(UI_ICON_SIZE) / but->block->aspect * 2.0f;
but->ofs = 0;
but->strwidth = UI_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, rsep);
char new_drawstr[UI_MAX_DRAW_STR];
STRNCPY(new_drawstr, but->drawstr.c_str());
const size_t max_len = sizeof(new_drawstr);
but->strwidth = UI_text_clip_middle_ex(fstyle, new_drawstr, okwidth, minwidth, max_len, rsep);
but->drawstr = new_drawstr;
}
/**
@ -1694,13 +1700,17 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
{
const int border = UI_TEXT_CLIP_MARGIN + 1;
const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0);
int drawstr_len = strlen(but->drawstr);
const char *cpend = but->drawstr + drawstr_len;
int drawstr_len = but->drawstr.size();
char new_drawstr[UI_MAX_DRAW_STR];
STRNCPY(new_drawstr, but->drawstr.c_str());
const char *cpend = new_drawstr + drawstr_len;
/* need to set this first */
UI_fontstyle_set(fstyle);
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
but->strwidth = BLF_width(fstyle->uifont_id, new_drawstr, drawstr_len);
/* The string already fits, so do nothing. */
if (but->strwidth <= okwidth) {
@ -1723,14 +1733,14 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
*/
/* find the space after ':' separator */
char *cpoin = strrchr(but->drawstr, ':');
char *cpoin = strrchr(new_drawstr, ':');
if (cpoin && (cpoin < cpend - 2)) {
char *cp2 = cpoin;
/* chop off the leading text, starting from the right */
while (but->strwidth > okwidth && cp2 > but->drawstr) {
const char *prev_utf8 = BLI_str_find_prev_char_utf8(cp2, but->drawstr);
while (but->strwidth > okwidth && cp2 > new_drawstr) {
const char *prev_utf8 = BLI_str_find_prev_char_utf8(cp2, new_drawstr);
const int bytes = cp2 - prev_utf8;
/* shift the text after and including cp2 back by 1 char,
@ -1739,11 +1749,10 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
cp2 -= bytes;
drawstr_len -= bytes;
// BLI_assert(strlen(but->drawstr) == drawstr_len);
but->strwidth = BLF_width(fstyle->uifont_id,
but->drawstr + but->ofs,
sizeof(but->drawstr) - but->ofs) +
new_drawstr + but->ofs,
sizeof(new_drawstr) - but->ofs) +
sep_strwidth;
if (but->strwidth < sep_strwidth) {
break;
@ -1752,9 +1761,9 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
/* after the leading text is gone, chop off the : and following space, with ofs */
while ((but->strwidth > okwidth) && (but->ofs < 2)) {
ui_text_clip_give_next_off(but, but->drawstr, but->drawstr + drawstr_len);
ui_text_clip_give_next_off(but, new_drawstr, new_drawstr + drawstr_len);
but->strwidth = BLF_width(
fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
fstyle->uifont_id, new_drawstr + but->ofs, sizeof(new_drawstr) - but->ofs);
if (but->strwidth < 10) {
break;
}
@ -1766,23 +1775,25 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
if (but->strwidth > okwidth) {
float strwidth;
drawstr_len = BLF_width_to_strlen(fstyle->uifont_id,
but->drawstr + but->ofs,
new_drawstr + but->ofs,
drawstr_len - but->ofs,
okwidth,
&strwidth) +
but->ofs;
but->strwidth = strwidth;
but->drawstr[drawstr_len] = 0;
new_drawstr[drawstr_len] = 0;
}
cpoin = strrchr(but->drawstr, ':');
if (cpoin && (cpoin - but->drawstr > 0) && (drawstr_len < (sizeof(but->drawstr) - sep_len))) {
cpoin = strrchr(new_drawstr, ':');
if (cpoin && (cpoin - new_drawstr > 0) && (drawstr_len < (sizeof(new_drawstr) - sep_len))) {
/* We shortened the string and still have a colon, so insert ellipsis. */
memmove(cpoin + sep_len, cpoin, cpend - cpoin);
memcpy(cpoin, sep, sep_len);
but->strwidth = BLF_width(
fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
fstyle->uifont_id, new_drawstr + but->ofs, sizeof(new_drawstr) - but->ofs);
}
but->drawstr = new_drawstr;
}
#ifdef WITH_INPUT_IME
@ -1846,7 +1857,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
rcti *rect)
{
int drawstr_left_len = UI_MAX_DRAW_STR;
const char *drawstr = but->drawstr;
const char *drawstr = but->drawstr.c_str();
const char *drawstr_right = nullptr;
bool use_right_only = false;
const char *indeterminate_str = UI_VALUE_INDETERMINATE_CHAR;
@ -5636,7 +5647,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
rcti *rect,
const char *name,
const blender::StringRef name,
int iconid,
const uchar text_col[4],
eFontStyle_Align text_align,
@ -5644,7 +5655,7 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
{
rcti trect = *rect;
const float text_size = UI_UNIT_Y;
const bool has_text = name && name[0];
const bool has_text = !name.is_empty();
float alpha = 1.0f;
@ -5687,7 +5698,8 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
const size_t max_len = sizeof(drawstr);
const float minwidth = float(UI_ICON_SIZE);
STRNCPY(drawstr, name);
memcpy(drawstr, name.data(), name.size());
drawstr[name.size()] = '\0';
UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');
uiFontStyleDraw_Params params{};

View File

@ -201,7 +201,7 @@ static int geometry_extract_apply(bContext *C,
ushort local_view_bits = 0;
if (v3d && v3d->localvd) {
local_view_bits = v3d->local_view_uuid;
local_view_bits = v3d->local_view_uid;
}
Object *new_ob = ED_object_add_type(
C, OB_MESH, nullptr, ob->loc, ob->rot, false, local_view_bits);
@ -495,7 +495,7 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
if (RNA_boolean_get(op->ptr, "new_object")) {
ushort local_view_bits = 0;
if (v3d && v3d->localvd) {
local_view_bits = v3d->local_view_uuid;
local_view_bits = v3d->local_view_uid;
}
Object *new_ob = ED_object_add_type(
C, OB_MESH, nullptr, ob->loc, ob->rot, false, local_view_bits);

View File

@ -498,7 +498,7 @@ bool ED_object_add_generic_get_opts(bContext *C,
if (r_local_view_bits) {
View3D *v3d = CTX_wm_view3d(C);
*r_local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
*r_local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
}
/* Location! */
@ -3177,7 +3177,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
ob->flag |= OB_DONE;
/* Create a new grease pencil object and copy transformations. */
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
float loc[3], size[3], rot[3][3], eul[3];
float matrix[4][4];
mat4_to_loc_rot_size(loc, rot, size, ob->object_to_world);
@ -3430,7 +3430,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
BKE_object_free_curve_cache(newob);
}
else if (target == OB_GPENCIL_LEGACY) {
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
Object *ob_gpencil = ED_gpencil_add_object(C, newob->loc, local_view_bits);
copy_v3_v3(ob_gpencil->rot, newob->rot);
copy_v3_v3(ob_gpencil->scale, newob->scale);
@ -3473,7 +3473,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
/* Create a new grease pencil object and copy transformations.
* Nurbs Surface are not supported.
*/
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0;
Object *ob_gpencil = ED_gpencil_add_object(C, ob->loc, local_view_bits);
copy_v3_v3(ob_gpencil->rot, ob->rot);
copy_v3_v3(ob_gpencil->scale, ob->scale);

View File

@ -415,7 +415,7 @@ static int object_hide_collection_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
if (toggle) {
lc->local_collections_bits ^= v3d->local_collections_uuid;
lc->local_collections_bits ^= v3d->local_collections_uid;
BKE_layer_collection_local_sync(scene, view_layer, v3d);
}
else {

View File

@ -497,7 +497,7 @@ static Object *add_hook_object_new(
Base *basact = BKE_view_layer_active_base_get(view_layer);
BLI_assert(basact->object == ob);
if (v3d && v3d->localvd) {
basact->local_view_bits |= v3d->local_view_uuid;
basact->local_view_bits |= v3d->local_view_uid;
}
/* icky, BKE_object_add sets new base as active.

View File

@ -1242,7 +1242,7 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
int duration = 0;
if (ima->source == IMA_SRC_MOVIE && BKE_image_has_anim(ima)) {
anim *anim = ((ImageAnim *)ima->anims.first)->anim;
ImBufAnim *anim = ((ImageAnim *)ima->anims.first)->anim;
if (anim) {
duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN);
}

View File

@ -1702,7 +1702,7 @@ static int image_match_len_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_CANCELLED;
}
anim *anim = ((ImageAnim *)ima->anims.first)->anim;
ImBufAnim *anim = ((ImageAnim *)ima->anims.first)->anim;
if (!anim) {
return OPERATOR_CANCELLED;
}

View File

@ -749,10 +749,10 @@ static void stats_row(int col1,
int height)
{
*y -= height;
BLF_draw_default(col1, *y, 0.0f, key, 128);
BLF_draw_default_shadowed(col1, *y, 0.0f, key, 128);
char values[128];
SNPRINTF(values, (value2) ? "%s / %s" : "%s", value1, value2);
BLF_draw_default(col2, *y, 0.0f, values, sizeof(values));
BLF_draw_default_shadowed(col2, *y, 0.0f, values, sizeof(values));
}
void ED_info_draw_stats(
@ -771,10 +771,6 @@ void ED_info_draw_stats(
const int font_id = BLF_default();
UI_FontThemeColor(font_id, TH_TEXT_HI);
BLF_enable(font_id, BLF_SHADOW);
const float shadow_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
BLF_shadow(font_id, 5, shadow_color);
BLF_shadow_offset(font_id, 1, -1);
/* Translated labels for each stat row. */
enum {
@ -885,6 +881,4 @@ void ED_info_draw_stats(
stats_row(col1, labels[FACES], col2, stats_fmt.totfacesel, stats_fmt.totface, y, height);
stats_row(col1, labels[TRIS], col2, stats_fmt.tottrisel, stats_fmt.tottri, y, height);
}
BLF_disable(font_id, BLF_SHADOW);
}

View File

@ -537,7 +537,7 @@ static void prefetch_data_fn(void *custom_data, wmJobWorkerStatus * /*worker_sta
}
char colorspace[64] = "\0"; /* 64 == MAX_COLORSPACE_NAME length. */
anim *anim = openanim(job_data->path, IB_rect, 0, colorspace);
ImBufAnim *anim = openanim(job_data->path, IB_rect, 0, colorspace);
if (anim != nullptr) {
g_drop_coords.strip_len = IMB_anim_get_duration(anim, IMB_TC_NONE);

View File

@ -325,7 +325,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl)
v3dn->localvd = nullptr;
}
v3dn->local_collections_uuid = 0;
v3dn->local_collections_uid = 0;
v3dn->flag &= ~(V3D_LOCAL_COLLECTIONS | V3D_XR_SESSION_MIRROR);
if (v3dn->shading.type == OB_RENDER) {
@ -1610,6 +1610,12 @@ static void view3d_header_region_listener(const wmRegionListenerParams *params)
ED_region_tag_redraw(region);
}
break;
case NC_MATERIAL:
/* For the canvas picker. */
if (wmn->data == ND_SHADING_LINKS) {
ED_region_tag_redraw(region);
}
break;
}
/* From top-bar, which ones are needed? split per header? */

View File

@ -795,11 +795,11 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region,
/* camera name - draw in highlighted text color */
if (ca && ((v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) && (ca->flag & CAM_SHOWNAME)) {
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
BLF_draw_default(x1i,
y1i - (0.7f * U.widget_unit),
0.0f,
v3d->camera->id.name + 2,
sizeof(v3d->camera->id.name) - 2);
BLF_draw_default_shadowed(x1i,
y1i - (0.7f * U.widget_unit),
0.0f,
v3d->camera->id.name + 2,
sizeof(v3d->camera->id.name) - 2);
}
}
@ -1262,16 +1262,11 @@ static void draw_viewport_name(ARegion *region, View3D *v3d, int xoffset, int *y
const char *name = view3d_get_name(v3d, rv3d);
const char *name_array[3] = {name, nullptr, nullptr};
int name_array_len = 1;
const int font_id = BLF_default();
/* 6 is the maximum size of the axis roll text. */
/* increase size for unicode languages (Chinese in utf-8...) */
char tmpstr[96 + 6];
BLF_enable(font_id, BLF_SHADOW);
BLF_shadow(font_id, 5, float4{0.0f, 0.0f, 0.0f, 1.0f});
BLF_shadow_offset(font_id, 1, -1);
if (RV3D_VIEW_IS_AXIS(rv3d->view) && (rv3d->view_axis_roll != RV3D_VIEW_AXIS_ROLL_0)) {
const char *axis_roll;
switch (rv3d->view_axis_roll) {
@ -1306,9 +1301,7 @@ static void draw_viewport_name(ARegion *region, View3D *v3d, int xoffset, int *y
*yoffset -= VIEW3D_OVERLAY_LINEHEIGHT;
BLF_draw_default(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr));
BLF_disable(font_id, BLF_SHADOW);
BLF_draw_default_shadowed(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr));
}
/**
@ -1451,14 +1444,8 @@ static void draw_selected_name(
BLI_assert(BLI_string_len_array(info_array, i) < sizeof(info));
BLI_string_join_array(info, sizeof(info), info_array, i);
BLF_enable(font_id, BLF_SHADOW);
BLF_shadow(font_id, 5, float4{0.0f, 0.0f, 0.0f, 1.0f});
BLF_shadow_offset(font_id, 1, -1);
*yoffset -= VIEW3D_OVERLAY_LINEHEIGHT;
BLF_draw_default(xoffset, *yoffset, 0.0f, info, sizeof(info));
BLF_disable(font_id, BLF_SHADOW);
BLF_draw_default_shadowed(xoffset, *yoffset, 0.0f, info, sizeof(info));
}
static void draw_grid_unit_name(
@ -1478,11 +1465,8 @@ static void draw_grid_unit_name(
}
*yoffset -= VIEW3D_OVERLAY_LINEHEIGHT;
BLF_enable(font_id, BLF_SHADOW);
BLF_shadow(font_id, 5, float4{0.0f, 0.0f, 0.0f, 1.0f});
BLF_shadow_offset(font_id, 1, -1);
BLF_draw_default(xoffset, *yoffset, 0.0f, numstr[0] ? numstr : grid_unit, sizeof(numstr));
BLF_disable(font_id, BLF_SHADOW);
BLF_draw_default_shadowed(
xoffset, *yoffset, 0.0f, numstr[0] ? numstr : grid_unit, sizeof(numstr));
}
}
}
@ -2612,15 +2596,9 @@ void ED_scene_draw_fps(const Scene *scene, int xoffset, int *yoffset)
SNPRINTF(printable, IFACE_("fps: %i"), int(state.fps_average + 0.5f));
}
BLF_enable(font_id, BLF_SHADOW);
BLF_shadow(font_id, 5, float4{0.0f, 0.0f, 0.0f, 1.0f});
BLF_shadow_offset(font_id, 1, -1);
*yoffset -= VIEW3D_OVERLAY_LINEHEIGHT;
BLF_draw_default(xoffset, *yoffset, 0.0f, printable, sizeof(printable));
BLF_disable(font_id, BLF_SHADOW);
BLF_draw_default_shadowed(xoffset, *yoffset, 0.0f, printable, sizeof(printable));
}
/** \} */

View File

@ -803,7 +803,7 @@ static uint free_localview_bit(Main *bmain)
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = reinterpret_cast<View3D *>(sl);
if (v3d->localvd) {
local_view_bits |= v3d->local_view_uuid;
local_view_bits |= v3d->local_view_uid;
}
}
}
@ -889,7 +889,7 @@ static bool view3d_localview_init(const Depsgraph *depsgraph,
v3d->localvd = static_cast<View3D *>(MEM_mallocN(sizeof(View3D), "localview"));
*v3d->localvd = blender::dna::shallow_copy(*v3d);
v3d->local_view_uuid = local_view_bit;
v3d->local_view_uid = local_view_bit;
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
@ -964,15 +964,15 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
}
BKE_view_layer_synced_ensure(scene, view_layer);
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
if (base->local_view_bits & v3d->local_view_uuid) {
base->local_view_bits &= ~v3d->local_view_uuid;
if (base->local_view_bits & v3d->local_view_uid) {
base->local_view_bits &= ~v3d->local_view_uid;
}
}
Object *camera_old = v3d->camera;
Object *camera_new = v3d->localvd->camera;
v3d->local_view_uuid = 0;
v3d->local_view_uid = 0;
v3d->camera = v3d->localvd->camera;
MEM_freeN(v3d->localvd);
@ -1096,7 +1096,7 @@ static int localview_remove_from_exec(bContext *C, wmOperator *op)
BKE_view_layer_synced_ensure(scene, view_layer);
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
if (BASE_SELECTED(v3d, base)) {
base->local_view_bits &= ~v3d->local_view_uuid;
base->local_view_bits &= ~v3d->local_view_uid;
ED_object_base_select(base, BA_DESELECT);
if (base == view_layer->basact) {
@ -1147,7 +1147,7 @@ void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
/** \name Local Collections
* \{ */
static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid, bool *r_reset)
static uint free_localcollection_bit(Main *bmain, ushort local_collections_uid, bool *r_reset)
{
ushort local_view_bits = 0;
@ -1158,7 +1158,7 @@ static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid,
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = reinterpret_cast<View3D *>(sl);
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
local_view_bits |= v3d->local_collections_uuid;
local_view_bits |= v3d->local_collections_uid;
}
}
}
@ -1166,8 +1166,8 @@ static uint free_localcollection_bit(Main *bmain, ushort local_collections_uuid,
}
/* First try to keep the old uuid. */
if (local_collections_uuid && ((local_collections_uuid & local_view_bits) == 0)) {
return local_collections_uuid;
if (local_collections_uid && ((local_collections_uid & local_view_bits) == 0)) {
return local_collections_uid;
}
/* Otherwise get the first free available. */
@ -1215,13 +1215,13 @@ bool ED_view3d_local_collections_set(Main *bmain, View3D *v3d)
bool reset = false;
v3d->flag &= ~V3D_LOCAL_COLLECTIONS;
uint local_view_bit = free_localcollection_bit(bmain, v3d->local_collections_uuid, &reset);
uint local_view_bit = free_localcollection_bit(bmain, v3d->local_collections_uid, &reset);
if (local_view_bit == 0) {
return false;
}
v3d->local_collections_uuid = local_view_bit;
v3d->local_collections_uid = local_view_bit;
v3d->flag |= V3D_LOCAL_COLLECTIONS;
if (reset) {
@ -1243,9 +1243,9 @@ void ED_view3d_local_collections_reset(bContext *C, const bool reset_all)
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = reinterpret_cast<View3D *>(sl);
if (v3d->local_collections_uuid) {
if (v3d->local_collections_uid) {
if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
local_view_bit &= ~v3d->local_collections_uuid;
local_view_bit &= ~v3d->local_collections_uid;
}
else {
do_reset = true;
@ -1262,7 +1262,7 @@ void ED_view3d_local_collections_reset(bContext *C, const bool reset_all)
else if (reset_all && (do_reset || (local_view_bit != ~(0)))) {
view3d_local_collections_reset(bmain, ~(0));
View3D v3d = {};
v3d.local_collections_uuid = ~(0);
v3d.local_collections_uid = ~(0);
BKE_layer_collection_local_sync(CTX_data_scene(C), CTX_data_view_layer(C), &v3d);
DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_BASE_FLAGS);
}

View File

@ -1559,7 +1559,7 @@ static void drawAutoKeyWarning(TransInfo *t, ARegion *region)
uchar color[3];
UI_GetThemeColorShade3ubv(TH_TEXT_HI, -50, color);
BLF_color3ubv(font_id, color);
BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
BLF_draw_default_shadowed(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX);
/* autokey recording icon... */
GPU_blend(GPU_BLEND_ALPHA);

View File

@ -504,7 +504,7 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
float3 snap_source_local;
float3 snap_source_local(0);
if (rotate_mode != TRANSLATE_ROTATE_OFF) {
snap_source_local = t->tsnap.snap_source;
if (tc->use_local_mat) {

View File

@ -1288,11 +1288,8 @@ bool GLShader::finalize(const shader::ShaderCreateInfo *info)
std::string source = workaround_geometry_shader_source_create(*info);
Vector<const char *> sources;
sources.append("version");
sources.append("/* Specialization Constants. */\n");
sources.append(source.c_str());
if (!constants.types.is_empty()) {
geometry_sources_ = sources;
}
geometry_shader_from_glsl(sources);
}

View File

@ -52,7 +52,7 @@ struct ImBuf;
struct rctf;
struct rcti;
struct anim;
struct ImBufAnim;
struct ColorManagedDisplay;
@ -270,19 +270,19 @@ enum eIMBInterpolationFilterMode {
/**
* Defaults to BL_proxy within the directory of the animation.
*/
void IMB_anim_set_index_dir(anim *anim, const char *dir);
void IMB_anim_get_filename(anim *anim, char *filename, int filename_maxncpy);
void IMB_anim_set_index_dir(ImBufAnim *anim, const char *dir);
void IMB_anim_get_filename(ImBufAnim *anim, char *filename, int filename_maxncpy);
int IMB_anim_index_get_frame_index(anim *anim, IMB_Timecode_Type tc, int position);
int IMB_anim_index_get_frame_index(ImBufAnim *anim, IMB_Timecode_Type tc, int position);
int IMB_anim_proxy_get_existing(anim *anim);
int IMB_anim_proxy_get_existing(ImBufAnim *anim);
struct IndexBuildContext;
/**
* Prepare context for proxies/time-codes builder
*/
IndexBuildContext *IMB_anim_index_rebuild_context(anim *anim,
IndexBuildContext *IMB_anim_index_rebuild_context(ImBufAnim *anim,
IMB_Timecode_Type tcs_in_use,
int proxy_sizes_in_use,
int quality,
@ -306,34 +306,37 @@ void IMB_anim_index_rebuild_finish(IndexBuildContext *context, bool stop);
/**
* Return the length (in frames) of the given \a anim.
*/
int IMB_anim_get_duration(anim *anim, IMB_Timecode_Type tc);
int IMB_anim_get_duration(ImBufAnim *anim, IMB_Timecode_Type tc);
/**
* Return the encoded start offset (in seconds) of the given \a anim.
*/
double IMD_anim_get_offset(anim *anim);
double IMD_anim_get_offset(ImBufAnim *anim);
/**
* Return the fps contained in movie files (function rval is false,
* and frs_sec and frs_sec_base untouched if none available!)
*/
bool IMB_anim_get_fps(const anim *anim, bool no_av_base, short *r_frs_sec, float *r_frs_sec_base);
bool IMB_anim_get_fps(const ImBufAnim *anim,
bool no_av_base,
short *r_frs_sec,
float *r_frs_sec_base);
anim *IMB_open_anim(const char *filepath,
int ib_flags,
int streamindex,
char colorspace[IM_MAX_SPACE]);
void IMB_suffix_anim(anim *anim, const char *suffix);
void IMB_close_anim(anim *anim);
void IMB_close_anim_proxies(anim *anim);
bool IMB_anim_can_produce_frames(const anim *anim);
ImBufAnim *IMB_open_anim(const char *filepath,
int ib_flags,
int streamindex,
char colorspace[IM_MAX_SPACE]);
void IMB_suffix_anim(ImBufAnim *anim, const char *suffix);
void IMB_close_anim(ImBufAnim *anim);
void IMB_close_anim_proxies(ImBufAnim *anim);
bool IMB_anim_can_produce_frames(const ImBufAnim *anim);
int ismovie(const char *filepath);
int IMB_anim_get_image_width(anim *anim);
int IMB_anim_get_image_height(anim *anim);
bool IMB_get_gop_decode_time(anim *anim);
int IMB_anim_get_image_width(ImBufAnim *anim);
int IMB_anim_get_image_height(ImBufAnim *anim);
bool IMB_get_gop_decode_time(ImBufAnim *anim);
ImBuf *IMB_anim_absolute(anim *anim,
ImBuf *IMB_anim_absolute(ImBufAnim *anim,
int position,
IMB_Timecode_Type tc /* = 1 = IMB_TC_RECORD_RUN */,
IMB_Proxy_Size preview_size /* = 0 = IMB_PROXY_NONE */);
@ -341,9 +344,9 @@ ImBuf *IMB_anim_absolute(anim *anim,
/**
* fetches a define preview-frame, usually half way into the movie.
*/
ImBuf *IMB_anim_previewframe(anim *anim);
ImBuf *IMB_anim_previewframe(ImBufAnim *anim);
void IMB_free_anim(anim *anim);
void IMB_free_anim(ImBufAnim *anim);
#define FILTER_MASK_NULL 0
#define FILTER_MASK_MARGIN 1

View File

@ -10,7 +10,7 @@
struct IDProperty;
struct ImBuf;
struct anim;
struct ImBufAnim;
/**
* The metadata is a list of key/value pairs (both char *) that can me
@ -55,7 +55,7 @@ bool IMB_metadata_get_field(IDProperty *metadata,
void IMB_metadata_set_field(IDProperty *metadata, const char *key, const char *value);
void IMB_metadata_copy(ImBuf *dimb, ImBuf *simb);
IDProperty *IMB_anim_load_metadata(anim *anim);
IDProperty *IMB_anim_load_metadata(ImBufAnim *anim);
/* Invoke callback for every value stored in the metadata. */
typedef void (*IMBMetadataForeachCb)(const char *field, const char *value, void *userdata);

View File

@ -56,7 +56,7 @@ extern "C" {
# define LITTLE_LONG ENDIAN_NOP
#endif
/* anim.curtype, runtime only */
/** #ImBufAnim::curtype, runtime only. */
#define ANIM_NONE 0
#define ANIM_SEQUENCE (1 << 0)
#define ANIM_MOVIE (1 << 4)
@ -67,9 +67,9 @@ extern "C" {
struct IDProperty;
struct _AviMovie;
struct anim_index;
struct ImBufAnimIndex;
struct anim {
struct ImBufAnim {
int ib_flags;
int curtype;
int cur_position; /* index 0 = 1e, 1 = 2e, enz. */
@ -132,8 +132,8 @@ struct anim {
int proxies_tried;
int indices_tried;
struct anim *proxy_anim[IMB_PROXY_MAX_SLOT];
struct anim_index *curr_idx[IMB_TC_MAX_SLOT];
struct ImBufAnim *proxy_anim[IMB_PROXY_MAX_SLOT];
struct ImBufAnimIndex *curr_idx[IMB_TC_MAX_SLOT];
char colorspace[64];
char suffix[64]; /* MAX_NAME - multiview */

View File

@ -42,7 +42,7 @@ typedef struct anim_index_entry {
uint64_t pts;
} anim_index_entry;
struct anim_index {
struct ImBufAnimIndex {
char filepath[1024];
int num_entries;
@ -84,23 +84,23 @@ void IMB_index_builder_proc_frame(anim_index_builder *fp,
void IMB_index_builder_finish(anim_index_builder *fp, int rollback);
struct anim_index *IMB_indexer_open(const char *name);
uint64_t IMB_indexer_get_seek_pos(struct anim_index *idx, int frame_index);
uint64_t IMB_indexer_get_seek_pos_pts(struct anim_index *idx, int frame_index);
uint64_t IMB_indexer_get_seek_pos_dts(struct anim_index *idx, int frame_index);
struct ImBufAnimIndex *IMB_indexer_open(const char *name);
uint64_t IMB_indexer_get_seek_pos(struct ImBufAnimIndex *idx, int frame_index);
uint64_t IMB_indexer_get_seek_pos_pts(struct ImBufAnimIndex *idx, int frame_index);
uint64_t IMB_indexer_get_seek_pos_dts(struct ImBufAnimIndex *idx, int frame_index);
int IMB_indexer_get_frame_index(struct anim_index *idx, int frameno);
uint64_t IMB_indexer_get_pts(struct anim_index *idx, int frame_index);
int IMB_indexer_get_duration(struct anim_index *idx);
int IMB_indexer_get_frame_index(struct ImBufAnimIndex *idx, int frameno);
uint64_t IMB_indexer_get_pts(struct ImBufAnimIndex *idx, int frame_index);
int IMB_indexer_get_duration(struct ImBufAnimIndex *idx);
int IMB_indexer_can_scan(struct anim_index *idx, int old_frame_index, int new_frame_index);
int IMB_indexer_can_scan(struct ImBufAnimIndex *idx, int old_frame_index, int new_frame_index);
void IMB_indexer_close(struct anim_index *idx);
void IMB_indexer_close(struct ImBufAnimIndex *idx);
void IMB_free_indices(struct anim *anim);
void IMB_free_indices(struct ImBufAnim *anim);
struct anim *IMB_anim_open_proxy(struct anim *anim, IMB_Proxy_Size preview_size);
struct anim_index *IMB_anim_open_index(struct anim *anim, IMB_Timecode_Type tc);
struct ImBufAnim *IMB_anim_open_proxy(struct ImBufAnim *anim, IMB_Proxy_Size preview_size);
struct ImBufAnimIndex *IMB_anim_open_index(struct ImBufAnim *anim, IMB_Timecode_Type tc);
int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size);
int IMB_timecode_to_array_index(IMB_Timecode_Type tc);

View File

@ -83,21 +83,21 @@ int ismovie(const char * /*filepath*/)
}
/* never called, just keep the linker happy */
static int startmovie(anim * /*anim*/)
static int startmovie(ImBufAnim * /*anim*/)
{
return 1;
}
static ImBuf *movie_fetchibuf(anim * /*anim*/, int /*position*/)
static ImBuf *movie_fetchibuf(ImBufAnim * /*anim*/, int /*position*/)
{
return nullptr;
}
static void free_anim_movie(anim * /*anim*/)
static void free_anim_movie(ImBufAnim * /*anim*/)
{
/* pass */
}
#ifdef WITH_AVI
static void free_anim_avi(anim *anim)
static void free_anim_avi(ImBufAnim *anim)
{
# if defined(_WIN32)
int i;
@ -138,10 +138,10 @@ static void free_anim_avi(anim *anim)
#endif /* WITH_AVI */
#ifdef WITH_FFMPEG
static void free_anim_ffmpeg(anim *anim);
static void free_anim_ffmpeg(ImBufAnim *anim);
#endif
void IMB_free_anim(anim *anim)
void IMB_free_anim(ImBufAnim *anim)
{
if (anim == nullptr) {
printf("free anim, anim == nullptr\n");
@ -163,7 +163,7 @@ void IMB_free_anim(anim *anim)
MEM_freeN(anim);
}
void IMB_close_anim(anim *anim)
void IMB_close_anim(ImBufAnim *anim)
{
if (anim == nullptr) {
return;
@ -172,7 +172,7 @@ void IMB_close_anim(anim *anim)
IMB_free_anim(anim);
}
void IMB_close_anim_proxies(anim *anim)
void IMB_close_anim_proxies(ImBufAnim *anim)
{
if (anim == nullptr) {
return;
@ -181,7 +181,7 @@ void IMB_close_anim_proxies(anim *anim)
IMB_free_indices(anim);
}
IDProperty *IMB_anim_load_metadata(anim *anim)
IDProperty *IMB_anim_load_metadata(ImBufAnim *anim)
{
switch (anim->curtype) {
case ANIM_FFMPEG: {
@ -216,16 +216,16 @@ IDProperty *IMB_anim_load_metadata(anim *anim)
return anim->metadata;
}
anim *IMB_open_anim(const char *filepath,
int ib_flags,
int streamindex,
char colorspace[IM_MAX_SPACE])
ImBufAnim *IMB_open_anim(const char *filepath,
int ib_flags,
int streamindex,
char colorspace[IM_MAX_SPACE])
{
anim *anim;
ImBufAnim *anim;
BLI_assert(!BLI_path_is_rel(filepath));
anim = (struct anim *)MEM_callocN(sizeof(struct anim), "anim struct");
anim = (ImBufAnim *)MEM_callocN(sizeof(ImBufAnim), "anim struct");
if (anim != nullptr) {
if (colorspace) {
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
@ -243,7 +243,7 @@ anim *IMB_open_anim(const char *filepath,
return anim;
}
bool IMB_anim_can_produce_frames(const anim *anim)
bool IMB_anim_can_produce_frames(const ImBufAnim *anim)
{
#if !(defined(WITH_AVI) || defined(WITH_FFMPEG))
UNUSED_VARS(anim);
@ -262,13 +262,13 @@ bool IMB_anim_can_produce_frames(const anim *anim)
return false;
}
void IMB_suffix_anim(anim *anim, const char *suffix)
void IMB_suffix_anim(ImBufAnim *anim, const char *suffix)
{
STRNCPY(anim->suffix, suffix);
}
#ifdef WITH_AVI
static int startavi(anim *anim)
static int startavi(ImBufAnim *anim)
{
AviError avierror;
@ -387,7 +387,7 @@ static int startavi(anim *anim)
#endif /* WITH_AVI */
#ifdef WITH_AVI
static ImBuf *avi_fetchibuf(anim *anim, int position)
static ImBuf *avi_fetchibuf(ImBufAnim *anim, int position)
{
ImBuf *ibuf = nullptr;
int *tmp;
@ -442,7 +442,7 @@ static ImBuf *avi_fetchibuf(anim *anim, int position)
#ifdef WITH_FFMPEG
static int startffmpeg(anim *anim)
static int startffmpeg(ImBufAnim *anim)
{
int i, video_stream_index;
@ -747,7 +747,7 @@ static int startffmpeg(anim *anim)
return 0;
}
static double ffmpeg_steps_per_frame_get(anim *anim)
static double ffmpeg_steps_per_frame_get(ImBufAnim *anim)
{
AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
AVRational time_base = v_st->time_base;
@ -760,7 +760,7 @@ static double ffmpeg_steps_per_frame_get(anim *anim)
* It is likely to overshoot and scanning stops. Having previous frame backed up, it is possible
* to use it when overshoot happens.
*/
static void ffmpeg_double_buffer_backup_frame_store(anim *anim, int64_t pts_to_search)
static void ffmpeg_double_buffer_backup_frame_store(ImBufAnim *anim, int64_t pts_to_search)
{
/* `anim->pFrame` is beyond `pts_to_search`. Don't store it. */
if (anim->pFrame_backup_complete && anim->cur_pts >= pts_to_search) {
@ -779,7 +779,7 @@ static void ffmpeg_double_buffer_backup_frame_store(anim *anim, int64_t pts_to_s
}
/* Free stored backup frame. */
static void ffmpeg_double_buffer_backup_frame_clear(anim *anim)
static void ffmpeg_double_buffer_backup_frame_clear(ImBufAnim *anim)
{
if (anim->pFrame_backup_complete) {
av_frame_unref(anim->pFrame_backup);
@ -788,7 +788,7 @@ static void ffmpeg_double_buffer_backup_frame_clear(anim *anim)
}
/* Return recently decoded frame. If it does not exist, return frame from backup buffer. */
static AVFrame *ffmpeg_double_buffer_frame_fallback_get(anim *anim)
static AVFrame *ffmpeg_double_buffer_frame_fallback_get(ImBufAnim *anim)
{
av_log(anim->pFormatCtx, AV_LOG_ERROR, "DECODE UNHAPPY: PTS not matched!\n");
@ -806,7 +806,7 @@ static AVFrame *ffmpeg_double_buffer_frame_fallback_get(anim *anim)
*
* \param ibuf: The frame just read by `ffmpeg_fetchibuf`, processed in-place.
*/
static void ffmpeg_postprocess(anim *anim, AVFrame *input, ImBuf *ibuf)
static void ffmpeg_postprocess(ImBufAnim *anim, AVFrame *input, ImBuf *ibuf)
{
int filter_y = 0;
@ -890,7 +890,7 @@ static void ffmpeg_postprocess(anim *anim, AVFrame *input, ImBuf *ibuf)
}
}
static void final_frame_log(anim *anim,
static void final_frame_log(ImBufAnim *anim,
int64_t frame_pts_start,
int64_t frame_pts_end,
const char *str)
@ -909,7 +909,7 @@ static bool ffmpeg_pts_isect(int64_t pts_start, int64_t pts_end, int64_t pts_to_
}
/* Return frame that matches `pts_to_search`, nullptr if matching frame does not exist. */
static AVFrame *ffmpeg_frame_by_pts_get(anim *anim, int64_t pts_to_search)
static AVFrame *ffmpeg_frame_by_pts_get(ImBufAnim *anim, int64_t pts_to_search)
{
/* NOTE: `frame->pts + frame->pkt_duration` does not always match pts of next frame.
* See footage from #86361. Here it is OK to use, because PTS must match current or backup frame.
@ -936,7 +936,7 @@ static AVFrame *ffmpeg_frame_by_pts_get(anim *anim, int64_t pts_to_search)
return best_frame;
}
static void ffmpeg_decode_store_frame_pts(anim *anim)
static void ffmpeg_decode_store_frame_pts(ImBufAnim *anim)
{
anim->cur_pts = av_get_pts_from_frame(anim->pFrame);
@ -951,7 +951,7 @@ static void ffmpeg_decode_store_frame_pts(anim *anim)
int64_t(anim->cur_pts));
}
static int ffmpeg_read_video_frame(anim *anim, AVPacket *packet)
static int ffmpeg_read_video_frame(ImBufAnim *anim, AVPacket *packet)
{
int ret = 0;
while ((ret = av_read_frame(anim->pFormatCtx, packet)) >= 0) {
@ -966,7 +966,7 @@ static int ffmpeg_read_video_frame(anim *anim, AVPacket *packet)
}
/* decode one video frame also considering the packet read into cur_packet */
static int ffmpeg_decode_video_frame(anim *anim)
static int ffmpeg_decode_video_frame(ImBufAnim *anim)
{
av_log(anim->pFormatCtx, AV_LOG_DEBUG, " DECODE VIDEO FRAME\n");
@ -1079,7 +1079,7 @@ static int ffmpeg_seek_by_byte(AVFormatContext *pFormatCtx)
return false;
}
static int64_t ffmpeg_get_seek_pts(anim *anim, int64_t pts_to_search)
static int64_t ffmpeg_get_seek_pts(ImBufAnim *anim, int64_t pts_to_search)
{
/* FFMPEG seeks internally using DTS values instead of PTS. In some files DTS and PTS values are
* offset and sometimes FFMPEG fails to take this into account when seeking.
@ -1099,7 +1099,7 @@ static int64_t ffmpeg_get_seek_pts(anim *anim, int64_t pts_to_search)
/* This gives us an estimate of which pts our requested frame will have.
* Note that this might be off a bit in certain video files, but it should still be close enough.
*/
static int64_t ffmpeg_get_pts_to_search(anim *anim, anim_index *tc_index, int position)
static int64_t ffmpeg_get_pts_to_search(ImBufAnim *anim, ImBufAnimIndex *tc_index, int position)
{
int64_t pts_to_search;
@ -1120,12 +1120,12 @@ static int64_t ffmpeg_get_pts_to_search(anim *anim, anim_index *tc_index, int po
return pts_to_search;
}
static bool ffmpeg_is_first_frame_decode(anim *anim)
static bool ffmpeg_is_first_frame_decode(ImBufAnim *anim)
{
return anim->pFrame_complete == false;
}
static void ffmpeg_scan_log(anim *anim, int64_t pts_to_search)
static void ffmpeg_scan_log(ImBufAnim *anim, int64_t pts_to_search)
{
int64_t frame_pts_start = av_get_pts_from_frame(anim->pFrame);
int64_t frame_pts_end = frame_pts_start + av_get_frame_duration_in_pts_units(anim->pFrame);
@ -1138,7 +1138,7 @@ static void ffmpeg_scan_log(anim *anim, int64_t pts_to_search)
}
/* Decode frames one by one until its PTS matches pts_to_search. */
static void ffmpeg_decode_video_frame_scan(anim *anim, int64_t pts_to_search)
static void ffmpeg_decode_video_frame_scan(ImBufAnim *anim, int64_t pts_to_search)
{
const int64_t start_gop_frame = anim->cur_key_frame_pts;
bool decode_error = false;
@ -1162,7 +1162,7 @@ static void ffmpeg_decode_video_frame_scan(anim *anim, int64_t pts_to_search)
* read_seek2() functions defined. When seeking in these formats, rule to seek to last
* necessary I-frame is not honored. It is not even guaranteed that I-frame, that must be
* decoded will be read. See https://trac.ffmpeg.org/ticket/1607 & #86944. */
static int ffmpeg_generic_seek_workaround(anim *anim,
static int ffmpeg_generic_seek_workaround(ImBufAnim *anim,
int64_t *requested_pts,
int64_t pts_to_search)
{
@ -1224,7 +1224,7 @@ static int ffmpeg_generic_seek_workaround(anim *anim,
/* Read packet until timestamp matches `anim->cur_packet`, thus recovering internal `anim` stream
* position state. */
static void ffmpeg_seek_recover_stream_position(anim *anim)
static void ffmpeg_seek_recover_stream_position(ImBufAnim *anim)
{
AVPacket *temp_packet = av_packet_alloc();
while (ffmpeg_read_video_frame(anim, temp_packet) >= 0) {
@ -1240,7 +1240,7 @@ static void ffmpeg_seek_recover_stream_position(anim *anim)
}
/* Check if seeking and mainly flushing codec buffers is needed. */
static bool ffmpeg_seek_buffers_need_flushing(anim *anim, int position, int64_t seek_pos)
static bool ffmpeg_seek_buffers_need_flushing(ImBufAnim *anim, int position, int64_t seek_pos)
{
/* Get timestamp of packet read after seeking. */
AVPacket *temp_packet = av_packet_alloc();
@ -1269,9 +1269,9 @@ static bool ffmpeg_seek_buffers_need_flushing(anim *anim, int position, int64_t
}
/* Seek to last necessary key frame. */
static int ffmpeg_seek_to_key_frame(anim *anim,
static int ffmpeg_seek_to_key_frame(ImBufAnim *anim,
int position,
anim_index *tc_index,
ImBufAnimIndex *tc_index,
int64_t pts_to_search)
{
int64_t seek_pos;
@ -1361,14 +1361,14 @@ static int ffmpeg_seek_to_key_frame(anim *anim,
return ret;
}
static bool ffmpeg_must_seek(anim *anim, int position)
static bool ffmpeg_must_seek(ImBufAnim *anim, int position)
{
bool must_seek = position != anim->cur_position + 1 || ffmpeg_is_first_frame_decode(anim);
anim->seek_before_decode = must_seek;
return must_seek;
}
static ImBuf *ffmpeg_fetchibuf(anim *anim, int position, IMB_Timecode_Type tc)
static ImBuf *ffmpeg_fetchibuf(ImBufAnim *anim, int position, IMB_Timecode_Type tc)
{
if (anim == nullptr) {
return nullptr;
@ -1376,7 +1376,7 @@ static ImBuf *ffmpeg_fetchibuf(anim *anim, int position, IMB_Timecode_Type tc)
av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: seek_pos=%d\n", position);
anim_index *tc_index = IMB_anim_open_index(anim, tc);
ImBufAnimIndex *tc_index = IMB_anim_open_index(anim, tc);
int64_t pts_to_search = ffmpeg_get_pts_to_search(anim, tc_index, position);
AVStream *v_st = anim->pFormatCtx->streams[anim->videoStream];
double frame_rate = av_q2d(v_st->r_frame_rate);
@ -1455,7 +1455,7 @@ static ImBuf *ffmpeg_fetchibuf(anim *anim, int position, IMB_Timecode_Type tc)
return cur_frame_final;
}
static void free_anim_ffmpeg(anim *anim)
static void free_anim_ffmpeg(ImBufAnim *anim)
{
if (anim == nullptr) {
return;
@ -1482,7 +1482,7 @@ static void free_anim_ffmpeg(anim *anim)
* Try to initialize the #anim struct.
* Returns true on success.
*/
static bool anim_getnew(anim *anim)
static bool anim_getnew(ImBufAnim *anim)
{
BLI_assert(anim->curtype == ANIM_NONE);
if (anim == nullptr) {
@ -1539,7 +1539,7 @@ static bool anim_getnew(anim *anim)
return true;
}
ImBuf *IMB_anim_previewframe(anim *anim)
ImBuf *IMB_anim_previewframe(ImBufAnim *anim)
{
ImBuf *ibuf = nullptr;
int position = 0;
@ -1577,7 +1577,7 @@ ImBuf *IMB_anim_previewframe(anim *anim)
return ibuf;
}
ImBuf *IMB_anim_absolute(anim *anim,
ImBuf *IMB_anim_absolute(ImBufAnim *anim,
int position,
IMB_Timecode_Type tc,
IMB_Proxy_Size preview_size)
@ -1605,7 +1605,7 @@ ImBuf *IMB_anim_absolute(anim *anim,
}
}
else {
struct anim *proxy = IMB_anim_open_proxy(anim, preview_size);
ImBufAnim *proxy = IMB_anim_open_proxy(anim, preview_size);
if (proxy) {
position = IMB_anim_index_get_frame_index(anim, tc, position);
@ -1666,9 +1666,9 @@ ImBuf *IMB_anim_absolute(anim *anim,
/***/
int IMB_anim_get_duration(anim *anim, IMB_Timecode_Type tc)
int IMB_anim_get_duration(ImBufAnim *anim, IMB_Timecode_Type tc)
{
anim_index *idx;
ImBufAnimIndex *idx;
if (tc == IMB_TC_NONE) {
return anim->duration_in_frames;
}
@ -1681,12 +1681,15 @@ int IMB_anim_get_duration(anim *anim, IMB_Timecode_Type tc)
return IMB_indexer_get_duration(idx);
}
double IMD_anim_get_offset(anim *anim)
double IMD_anim_get_offset(ImBufAnim *anim)
{
return anim->start_offset;
}
bool IMB_anim_get_fps(const anim *anim, bool no_av_base, short *r_frs_sec, float *r_frs_sec_base)
bool IMB_anim_get_fps(const ImBufAnim *anim,
bool no_av_base,
short *r_frs_sec,
float *r_frs_sec_base)
{
double frs_sec_base_double;
if (anim->frs_sec) {
@ -1719,12 +1722,12 @@ bool IMB_anim_get_fps(const anim *anim, bool no_av_base, short *r_frs_sec, float
return false;
}
int IMB_anim_get_image_width(anim *anim)
int IMB_anim_get_image_width(ImBufAnim *anim)
{
return anim->x;
}
int IMB_anim_get_image_height(anim *anim)
int IMB_anim_get_image_height(ImBufAnim *anim)
{
return anim->y;
}

View File

@ -154,10 +154,10 @@ void IMB_index_builder_finish(anim_index_builder *fp, int rollback)
MEM_freeN(fp);
}
anim_index *IMB_indexer_open(const char *filepath)
ImBufAnimIndex *IMB_indexer_open(const char *filepath)
{
char header[13];
anim_index *idx;
ImBufAnimIndex *idx;
FILE *fp = BLI_fopen(filepath, "rb");
int i;
@ -185,7 +185,7 @@ anim_index *IMB_indexer_open(const char *filepath)
return nullptr;
}
idx = MEM_cnew<anim_index>("anim_index");
idx = MEM_cnew<ImBufAnimIndex>("ImBufAnimIndex");
STRNCPY(idx->filepath, filepath);
@ -235,7 +235,7 @@ anim_index *IMB_indexer_open(const char *filepath)
return idx;
}
uint64_t IMB_indexer_get_seek_pos(anim_index *idx, int frame_index)
uint64_t IMB_indexer_get_seek_pos(ImBufAnimIndex *idx, int frame_index)
{
/* This is hard coded, because our current timecode files return non zero seek position for index
* 0. Only when seeking to 0 it is guaranteed, that first packet will be read. */
@ -248,7 +248,7 @@ uint64_t IMB_indexer_get_seek_pos(anim_index *idx, int frame_index)
return idx->entries[frame_index].seek_pos;
}
uint64_t IMB_indexer_get_seek_pos_pts(anim_index *idx, int frame_index)
uint64_t IMB_indexer_get_seek_pos_pts(ImBufAnimIndex *idx, int frame_index)
{
if (frame_index < 0) {
frame_index = 0;
@ -259,7 +259,7 @@ uint64_t IMB_indexer_get_seek_pos_pts(anim_index *idx, int frame_index)
return idx->entries[frame_index].seek_pos_pts;
}
uint64_t IMB_indexer_get_seek_pos_dts(anim_index *idx, int frame_index)
uint64_t IMB_indexer_get_seek_pos_dts(ImBufAnimIndex *idx, int frame_index)
{
if (frame_index < 0) {
frame_index = 0;
@ -270,7 +270,7 @@ uint64_t IMB_indexer_get_seek_pos_dts(anim_index *idx, int frame_index)
return idx->entries[frame_index].seek_pos_dts;
}
int IMB_indexer_get_frame_index(anim_index *idx, int frameno)
int IMB_indexer_get_frame_index(ImBufAnimIndex *idx, int frameno)
{
int len = idx->num_entries;
int half;
@ -302,7 +302,7 @@ int IMB_indexer_get_frame_index(anim_index *idx, int frameno)
return first;
}
uint64_t IMB_indexer_get_pts(anim_index *idx, int frame_index)
uint64_t IMB_indexer_get_pts(ImBufAnimIndex *idx, int frame_index)
{
if (frame_index < 0) {
frame_index = 0;
@ -313,7 +313,7 @@ uint64_t IMB_indexer_get_pts(anim_index *idx, int frame_index)
return idx->entries[frame_index].pts;
}
int IMB_indexer_get_duration(anim_index *idx)
int IMB_indexer_get_duration(ImBufAnimIndex *idx)
{
if (idx->num_entries == 0) {
return 0;
@ -321,7 +321,7 @@ int IMB_indexer_get_duration(anim_index *idx)
return idx->entries[idx->num_entries - 1].frameno + 1;
}
int IMB_indexer_can_scan(anim_index *idx, int old_frame_index, int new_frame_index)
int IMB_indexer_can_scan(ImBufAnimIndex *idx, int old_frame_index, int new_frame_index)
{
/* makes only sense, if it is the same I-Frame and we are not
* trying to run backwards in time... */
@ -330,7 +330,7 @@ int IMB_indexer_can_scan(anim_index *idx, int old_frame_index, int new_frame_ind
old_frame_index < new_frame_index);
}
void IMB_indexer_close(anim_index *idx)
void IMB_indexer_close(ImBufAnimIndex *idx)
{
MEM_freeN(idx->entries);
MEM_freeN(idx);
@ -378,7 +378,7 @@ int IMB_timecode_to_array_index(IMB_Timecode_Type tc)
* - rebuild helper functions
* ---------------------------------------------------------------------- */
static void get_index_dir(anim *anim, char *index_dir, size_t index_dir_maxncpy)
static void get_index_dir(ImBufAnim *anim, char *index_dir, size_t index_dir_maxncpy)
{
if (!anim->index_dir[0]) {
char filename[FILE_MAXFILE];
@ -391,12 +391,15 @@ static void get_index_dir(anim *anim, char *index_dir, size_t index_dir_maxncpy)
}
}
void IMB_anim_get_filename(anim *anim, char *filename, int filename_maxncpy)
void IMB_anim_get_filename(ImBufAnim *anim, char *filename, int filename_maxncpy)
{
BLI_path_split_file_part(anim->filepath, filename, filename_maxncpy);
}
static bool get_proxy_filepath(anim *anim, IMB_Proxy_Size preview_size, char *filepath, bool temp)
static bool get_proxy_filepath(ImBufAnim *anim,
IMB_Proxy_Size preview_size,
char *filepath,
bool temp)
{
char index_dir[FILE_MAXDIR];
int i = IMB_proxy_size_to_array_index(preview_size);
@ -425,7 +428,7 @@ static bool get_proxy_filepath(anim *anim, IMB_Proxy_Size preview_size, char *fi
return true;
}
static void get_tc_filepath(anim *anim, IMB_Timecode_Type tc, char *filepath)
static void get_tc_filepath(ImBufAnim *anim, IMB_Timecode_Type tc, char *filepath)
{
char index_dir[FILE_MAXDIR];
int i = IMB_timecode_to_array_index(tc);
@ -479,11 +482,11 @@ struct proxy_output_ctx {
int cfra;
IMB_Proxy_Size proxy_size;
int orig_height;
struct anim *anim;
ImBufAnim *anim;
};
static proxy_output_ctx *alloc_proxy_output_ffmpeg(
anim *anim, AVStream *st, IMB_Proxy_Size proxy_size, int width, int height, int quality)
ImBufAnim *anim, AVStream *st, IMB_Proxy_Size proxy_size, int width, int height, int quality)
{
proxy_output_ctx *rv = MEM_cnew<proxy_output_ctx>("alloc_proxy_output");
@ -821,7 +824,7 @@ struct FFmpegIndexBuilderContext {
bool building_cancelled;
};
static IndexBuildContext *index_ffmpeg_create_context(anim *anim,
static IndexBuildContext *index_ffmpeg_create_context(ImBufAnim *anim,
int tcs_in_use,
int proxy_sizes_in_use,
int quality,
@ -1245,12 +1248,12 @@ static bool indexer_need_to_build_proxy(FFmpegIndexBuilderContext *context)
struct FallbackIndexBuilderContext {
int anim_type;
struct anim *anim;
ImBufAnim *anim;
AviMovie *proxy_ctx[IMB_PROXY_MAX_SLOT];
int proxy_sizes_in_use;
};
static AviMovie *alloc_proxy_output_avi(
anim *anim, const char *filepath, int width, int height, int quality)
ImBufAnim *anim, const char *filepath, int width, int height, int quality)
{
int x, y;
AviFormat format;
@ -1287,7 +1290,7 @@ static AviMovie *alloc_proxy_output_avi(
return avi;
}
static IndexBuildContext *index_fallback_create_context(anim *anim,
static IndexBuildContext *index_fallback_create_context(ImBufAnim *anim,
int /*tcs_in_use*/,
int proxy_sizes_in_use,
int quality)
@ -1328,7 +1331,7 @@ static IndexBuildContext *index_fallback_create_context(anim *anim,
static void index_rebuild_fallback_finish(FallbackIndexBuilderContext *context, const bool stop)
{
anim *anim = context->anim;
ImBufAnim *anim = context->anim;
char filepath[FILE_MAX];
char filepath_tmp[FILE_MAX];
int i;
@ -1359,7 +1362,7 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context,
{
int count = IMB_anim_get_duration(context->anim, IMB_TC_NONE);
int i, pos;
anim *anim = context->anim;
ImBufAnim *anim = context->anim;
for (pos = 0; pos < count; pos++) {
ImBuf *ibuf = IMB_anim_absolute(anim, pos, IMB_TC_NONE, IMB_PROXY_NONE);
@ -1407,7 +1410,7 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context,
* - public API
* ---------------------------------------------------------------------- */
IndexBuildContext *IMB_anim_index_rebuild_context(anim *anim,
IndexBuildContext *IMB_anim_index_rebuild_context(ImBufAnim *anim,
IMB_Timecode_Type tcs_in_use,
int proxy_sizes_in_use,
int quality,
@ -1535,7 +1538,7 @@ void IMB_anim_index_rebuild_finish(IndexBuildContext *context, const bool stop)
UNUSED_VARS(stop, proxy_sizes);
}
void IMB_free_indices(anim *anim)
void IMB_free_indices(ImBufAnim *anim)
{
int i;
@ -1557,7 +1560,7 @@ void IMB_free_indices(anim *anim)
anim->indices_tried = 0;
}
void IMB_anim_set_index_dir(anim *anim, const char *dir)
void IMB_anim_set_index_dir(ImBufAnim *anim, const char *dir)
{
if (STREQ(anim->index_dir, dir)) {
return;
@ -1567,7 +1570,7 @@ void IMB_anim_set_index_dir(anim *anim, const char *dir)
IMB_free_indices(anim);
}
anim *IMB_anim_open_proxy(anim *anim, IMB_Proxy_Size preview_size)
ImBufAnim *IMB_anim_open_proxy(ImBufAnim *anim, IMB_Proxy_Size preview_size)
{
char filepath[FILE_MAX];
int i = IMB_proxy_size_to_array_index(preview_size);
@ -1594,7 +1597,7 @@ anim *IMB_anim_open_proxy(anim *anim, IMB_Proxy_Size preview_size)
return anim->proxy_anim[i];
}
anim_index *IMB_anim_open_index(anim *anim, IMB_Timecode_Type tc)
ImBufAnimIndex *IMB_anim_open_index(ImBufAnim *anim, IMB_Timecode_Type tc)
{
char filepath[FILE_MAX];
int i = IMB_timecode_to_array_index(tc);
@ -1620,9 +1623,9 @@ anim_index *IMB_anim_open_index(anim *anim, IMB_Timecode_Type tc)
return anim->curr_idx[i];
}
int IMB_anim_index_get_frame_index(anim *anim, IMB_Timecode_Type tc, int position)
int IMB_anim_index_get_frame_index(ImBufAnim *anim, IMB_Timecode_Type tc, int position)
{
anim_index *idx = IMB_anim_open_index(anim, tc);
ImBufAnimIndex *idx = IMB_anim_open_index(anim, tc);
if (!idx) {
return position;
@ -1631,7 +1634,7 @@ int IMB_anim_index_get_frame_index(anim *anim, IMB_Timecode_Type tc, int positio
return IMB_indexer_get_frame_index(idx, position);
}
int IMB_anim_proxy_get_existing(anim *anim)
int IMB_anim_proxy_get_existing(ImBufAnim *anim)
{
const int num_proxy_sizes = IMB_PROXY_MAX_SLOT;
int existing = IMB_PROXY_NONE;

View File

@ -391,7 +391,7 @@ static ImBuf *thumb_create_ex(const char *file_path,
}
}
else if (THB_SOURCE_MOVIE == source) {
anim *anim = nullptr;
ImBufAnim *anim = nullptr;
anim = IMB_open_anim(file_path, IB_rect | IB_metadata, 0, nullptr);
if (anim != nullptr) {
img = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);

View File

@ -66,7 +66,7 @@ const char *imb_ext_image[] = {
const char *imb_ext_movie[] = {
".avi", ".flc", ".mov", ".movie", ".mp4", ".m4v", ".m2v", ".m2t", ".m2ts", ".mts",
".ts", ".mv", ".avs", ".wmv", ".ogv", ".ogg", ".r3d", ".dv", ".mpeg", ".mpg",
".mpg2", ".vob", ".mkv", ".flv", ".divx", ".xvid", ".mxf", ".webm", nullptr,
".mpg2", ".vob", ".mkv", ".flv", ".divx", ".xvid", ".mxf", ".webm", ".gif", nullptr,
};
/** Sort of wrong having audio extensions in imbuf. */

View File

@ -31,7 +31,7 @@ Object *GpencilImporter::create_object()
{
const float *cur_loc = scene_->cursor.location;
const float rot[3] = {0.0f};
ushort local_view_bits = (params_.v3d && params_.v3d->localvd) ? params_.v3d->local_view_uuid :
ushort local_view_bits = (params_.v3d && params_.v3d->localvd) ? params_.v3d->local_view_uid :
ushort(0);
Object *ob_gpencil = ED_object_add_type(params_.C,

View File

@ -76,11 +76,11 @@ int OBJCurve::total_spline_control_points(const int spline_index) const
int degree = nurb->type == CU_POLY ? 1 : nurb->orderu - 1;
/* Total control points = Number of points in the curve (+ degree of the
* curve if it is cyclic). */
int r_tot_control_points = nurb->pntsv * nurb->pntsu;
int tot_control_points = nurb->pntsv * nurb->pntsu;
if (nurb->flagu & CU_NURB_CYCLIC) {
r_tot_control_points += degree;
tot_control_points += degree;
}
return r_tot_control_points;
return tot_control_points;
}
int OBJCurve::get_nurbs_degree(const int spline_index) const

View File

@ -0,0 +1,103 @@
/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup DNA
*
* Contains functions that help dealing with arrays that are stored in DNA. Due to the constraints
* of DNA, all structs are trivial from the language's point of view (`std::is_trivial_v`).
* However, semantically, these types may have non-trivial copy-constructors and destructors.
*/
#include "MEM_guardedalloc.h"
#include "BLI_index_range.hh"
namespace blender::dna::array {
/**
* Removes an element from the array and shifts the elements after it towards the front.
*/
template<typename T>
inline void remove_index(
T **items, int *items_num, int *active_index, const int index, void (*destruct_item)(T *))
{
static_assert(std::is_trivial_v<T>);
BLI_assert(index >= 0);
BLI_assert(index < *items_num);
const int old_items_num = *items_num;
const int new_items_num = old_items_num - 1;
T *old_items = *items;
T *new_items = MEM_cnew_array<T>(new_items_num, __func__);
std::copy_n(old_items, index, new_items);
std::copy_n(old_items + index + 1, old_items_num - index - 1, new_items + index);
destruct_item(&old_items[index]);
MEM_freeN(old_items);
*items = new_items;
*items_num = new_items_num;
if (active_index) {
const int old_active_index = active_index ? *active_index : 0;
const int new_active_index = std::max(
0, old_active_index == new_items_num ? new_items_num - 1 : old_active_index);
*active_index = new_active_index;
}
}
/**
* Removes all elements from an array and frees it.
*/
template<typename T>
inline void clear(T **items, int *items_num, int *active_index, void (*destruct_item)(T *))
{
static_assert(std::is_trivial_v<T>);
for (const int i : IndexRange(*items_num)) {
destruct_item(&(*items)[i]);
}
MEM_SAFE_FREE(*items);
*items_num = 0;
if (active_index) {
*active_index = 0;
}
}
/**
* Moves one element from one index to another, moving other elements if necessary.
*/
template<typename T>
inline void move_index(T *items, const int items_num, const int from_index, const int to_index)
{
static_assert(std::is_trivial_v<T>);
BLI_assert(from_index >= 0);
BLI_assert(from_index < items_num);
BLI_assert(to_index >= 0);
BLI_assert(to_index < items_num);
UNUSED_VARS_NDEBUG(items_num);
if (from_index == to_index) {
return;
}
if (from_index < to_index) {
const T tmp = items[from_index];
for (int i = from_index; i < to_index; i++) {
items[i] = items[i + 1];
}
items[to_index] = tmp;
}
else if (from_index > to_index) {
const T tmp = items[from_index];
for (int i = from_index; i > to_index; i--) {
items[i] = items[i - 1];
}
items[to_index] = tmp;
}
}
} // namespace blender::dna::array

View File

@ -13,11 +13,11 @@
#include "DNA_defs.h"
struct GPUTexture;
struct ImBufAnim;
struct MovieCache;
struct PackedFile;
struct RenderResult;
struct Scene;
struct anim;
/* ImageUser is in Texture, in Nodes, Background Image, Image Window, .... */
/* should be used in conjunction with an ID * to Image. */
@ -47,7 +47,7 @@ typedef struct ImageUser {
typedef struct ImageAnim {
struct ImageAnim *next, *prev;
struct anim *anim;
struct ImBufAnim *anim;
} ImageAnim;
typedef struct ImageView {

View File

@ -14,10 +14,10 @@
struct AnimData;
struct ImBuf;
struct ImBufAnim;
struct MovieClipProxy;
struct MovieTrackingMarker;
struct MovieTrackingTrack;
struct anim;
struct bGPdata;
typedef struct MovieClipUser {
@ -75,7 +75,7 @@ typedef struct MovieClip {
float aspx, aspy;
/** Movie source data. */
struct anim *anim;
struct ImBufAnim *anim;
/** Cache for different stuff, not in file. */
struct MovieClipCache *cache;
/** Grease pencil data. */

View File

@ -36,7 +36,7 @@ struct bSound;
typedef struct StripAnim {
struct StripAnim *next, *prev;
struct anim *anim;
struct ImBufAnim *anim;
} StripAnim;
typedef struct StripElem {
@ -84,7 +84,7 @@ typedef struct StripProxy {
char dirpath[768];
/** Custom file. */
char filename[256];
struct anim *anim; /* custom proxy anim file */
struct ImBufAnim *anim; /* custom proxy anim file */
short tc; /* time code in use */

View File

@ -297,10 +297,10 @@ typedef struct View3D {
/** Optional string for armature bone to define center, MAXBONENAME. */
char ob_center_bone[64];
unsigned short local_view_uuid;
unsigned short local_view_uid;
char _pad6[2];
int layact DNA_DEPRECATED;
unsigned short local_collections_uuid;
unsigned short local_collections_uid;
short _pad7[2];
short debug_flag;

View File

@ -178,10 +178,13 @@ DNA_STRUCT_RENAME_ELEM(Text, name, filepath)
DNA_STRUCT_RENAME_ELEM(ThemeSpace, scrubbing_background, time_scrub_background)
DNA_STRUCT_RENAME_ELEM(ThemeSpace, show_back_grad, background_type)
DNA_STRUCT_RENAME_ELEM(UVProjectModifierData, num_projectors, projectors_num)
DNA_STRUCT_RENAME_ELEM(UserDef, autokey_flag, keying_flag)
DNA_STRUCT_RENAME_ELEM(UserDef, gp_manhattendist, gp_manhattandist)
DNA_STRUCT_RENAME_ELEM(UserDef, pythondir, pythondir_legacy)
DNA_STRUCT_RENAME_ELEM(VFont, name, filepath)
DNA_STRUCT_RENAME_ELEM(View3D, far, clip_end)
DNA_STRUCT_RENAME_ELEM(View3D, local_collections_uuid, local_collections_uid)
DNA_STRUCT_RENAME_ELEM(View3D, local_view_uuid, local_view_uid)
DNA_STRUCT_RENAME_ELEM(View3D, near, clip_start)
DNA_STRUCT_RENAME_ELEM(View3D, ob_centre, ob_center)
DNA_STRUCT_RENAME_ELEM(View3D, ob_centre_bone, ob_center_bone)
@ -219,7 +222,6 @@ DNA_STRUCT_RENAME_ELEM(bTheme, ttopbar, space_topbar)
DNA_STRUCT_RENAME_ELEM(bTheme, tuserpref, space_preferences)
DNA_STRUCT_RENAME_ELEM(bTheme, tv3d, space_view3d)
DNA_STRUCT_RENAME_ELEM(bUserAssetLibrary, path, dirpath)
DNA_STRUCT_RENAME_ELEM(UserDef, autokey_flag, keying_flag)
/* NOTE: Keep sorted! */
/* Write with a different name, old Blender versions crash loading files with non-NULL

View File

@ -575,7 +575,7 @@ static int rna_Image_frame_duration_get(PointerRNA *ptr)
}
if (BKE_image_has_anim(ima)) {
anim *anim = ((ImageAnim *)ima->anims.first)->anim;
ImBufAnim *anim = ((ImageAnim *)ima->anims.first)->anim;
if (anim) {
duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN);
}

View File

@ -142,7 +142,7 @@ static bool rna_LayerCollection_visible_get(LayerCollection *layer_collection, b
return (layer_collection->runtime_flag & LAYER_COLLECTION_VISIBLE_VIEW_LAYER) != 0;
}
if (v3d->local_collections_uuid & layer_collection->local_collections_bits) {
if (v3d->local_collections_uid & layer_collection->local_collections_bits) {
return (layer_collection->runtime_flag & LAYER_COLLECTION_HIDE_VIEWPORT) == 0;
}

View File

@ -5194,7 +5194,7 @@ static void rna_def_modifier_uvwarp(BlenderRNA *brna)
prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, nullptr, "uvlayer_name");
RNA_def_property_ui_text(prop, "UV Layer", "UV Layer name");
RNA_def_property_ui_text(prop, "UV Map", "UV map name");
RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_UVWarpModifier_uvlayer_name_set");
RNA_def_property_update(prop, 0, "rna_Modifier_update");

View File

@ -3324,7 +3324,7 @@ static void rna_Node_ItemArray_remove(ID *id,
return;
}
const int remove_index = item_to_remove - *ref.items;
blender::nodes::socket_items::remove_item(
blender::dna::array::remove_index(
ref.items, ref.items_num, ref.active_index, remove_index, Accessor::destruct_item);
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
@ -3336,8 +3336,7 @@ static void rna_Node_ItemArray_remove(ID *id,
template<typename Accessor> static void rna_Node_ItemArray_clear(ID *id, bNode *node, Main *bmain)
{
blender::nodes::socket_items::SocketItemsRef ref = Accessor::get_items_from_node(*node);
blender::nodes::socket_items::clear_items(
ref.items, ref.items_num, ref.active_index, Accessor::destruct_item);
blender::dna::array::clear(ref.items, ref.items_num, ref.active_index, Accessor::destruct_item);
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
BKE_ntree_update_tag_node_property(ntree, node);
@ -3354,7 +3353,7 @@ static void rna_Node_ItemArray_move(
if (from_index < 0 || to_index < 0 || from_index >= items_num || to_index >= items_num) {
return;
}
blender::nodes::socket_items::move_item(*ref.items, items_num, from_index, to_index);
blender::dna::array::move_index(*ref.items, items_num, from_index, to_index);
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
BKE_ntree_update_tag_node_property(ntree, node);

View File

@ -252,7 +252,7 @@ static bool rna_Object_local_view_get(Object *ob, ReportList *reports, View3D *v
return false;
}
return ((ob->base_local_view_bits & v3d->local_view_uuid) != 0);
return ((ob->base_local_view_bits & v3d->local_view_uid) != 0);
}
static void rna_Object_local_view_set(Object *ob,
@ -268,7 +268,7 @@ static void rna_Object_local_view_set(Object *ob,
return; /* Error reported. */
}
const short local_view_bits_prev = base->local_view_bits;
SET_FLAG_FROM_TEST(base->local_view_bits, state, v3d->local_view_uuid);
SET_FLAG_FROM_TEST(base->local_view_bits, state, v3d->local_view_uid);
if (local_view_bits_prev != base->local_view_bits) {
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
ScrArea *area = ED_screen_area_find_with_spacedata(screen, (SpaceLink *)v3d, true);

View File

@ -23,6 +23,8 @@
#include "BKE_node.h"
#include "BKE_node_runtime.hh"
#include "DNA_array_utils.hh"
#include "NOD_socket.hh"
namespace blender::nodes::socket_items {
@ -53,94 +55,6 @@ inline bNode *find_node_by_item(bNodeTree &ntree, const typename Accessor::ItemT
return nullptr;
}
/**
* Low level utility to remove an item from the array and to shift the elements after it.
*/
template<typename T>
inline void remove_item(T **items,
int *items_num,
int *active_index,
const int remove_index,
void (*destruct_item)(T *))
{
static_assert(std::is_trivial_v<T>);
BLI_assert(remove_index >= 0);
BLI_assert(remove_index < *items_num);
const int old_items_num = *items_num;
const int new_items_num = old_items_num - 1;
T *old_items = *items;
T *new_items = MEM_cnew_array<T>(new_items_num, __func__);
std::copy_n(old_items, remove_index, new_items);
std::copy_n(
old_items + remove_index + 1, old_items_num - remove_index - 1, new_items + remove_index);
destruct_item(&old_items[remove_index]);
MEM_SAFE_FREE(old_items);
*items = new_items;
*items_num = new_items_num;
if (active_index) {
const int old_active_index = active_index ? *active_index : 0;
const int new_active_index = std::max(
0, old_active_index == new_items_num ? new_items_num - 1 : old_active_index);
*active_index = new_active_index;
}
}
/**
* Low level utility to remove all elements from an items array.
*/
template<typename T>
inline void clear_items(T **items, int *items_num, int *active_index, void (*destruct_item)(T *))
{
static_assert(std::is_trivial_v<T>);
for (const int i : blender::IndexRange(*items_num)) {
destruct_item(&(*items)[i]);
}
MEM_SAFE_FREE(*items);
*items_num = 0;
if (active_index) {
*active_index = 0;
}
}
/**
* Low level utility to move one item from one index to another.
*/
template<typename T>
inline void move_item(T *items, const int items_num, const int from_index, const int to_index)
{
static_assert(std::is_trivial_v<T>);
BLI_assert(from_index >= 0);
BLI_assert(from_index < items_num);
BLI_assert(to_index >= 0);
BLI_assert(to_index < items_num);
UNUSED_VARS_NDEBUG(items_num);
if (from_index == to_index) {
return;
}
if (from_index < to_index) {
const T tmp = items[from_index];
for (int i = from_index; i < to_index; i++) {
items[i] = items[i + 1];
}
items[to_index] = tmp;
}
else if (from_index > to_index) {
const T tmp = items[from_index];
for (int i = from_index; i > to_index; i--) {
items[i] = items[i - 1];
}
items[to_index] = tmp;
}
}
/**
* Destruct all the items and the free the array itself.
*/

View File

@ -63,7 +63,7 @@ static void node_geo_exec(GeoNodeExecParams params)
float fps = 0.0f;
if (ImageAnim *ianim = static_cast<ImageAnim *>(image->anims.first)) {
anim *anim = ianim->anim;
ImBufAnim *anim = ianim->anim;
if (anim) {
frames = IMB_anim_get_duration(anim, IMB_TC_NONE);

View File

@ -18,7 +18,7 @@
#include "multiview.hh"
void seq_anim_add_suffix(Scene *scene, anim *anim, const int view_id)
void seq_anim_add_suffix(Scene *scene, ImBufAnim *anim, const int view_id)
{
const char *suffix = BKE_scene_multiview_view_id_suffix_get(&scene->r, view_id);
IMB_suffix_anim(anim, suffix);

View File

@ -17,7 +17,7 @@ struct Scene;
* **********************************************************************
*/
void seq_anim_add_suffix(Scene *scene, anim *anim, int view_id);
void seq_anim_add_suffix(Scene *scene, ImBufAnim *anim, int view_id);
void seq_multiview_name(
Scene *scene, int view_id, const char *prefix, const char *ext, char *r_path, size_t r_size);
/**

View File

@ -412,7 +412,7 @@ static int seq_proxy_context_count(Sequence *seq, Scene *scene)
return num_views;
}
static bool seq_proxy_need_rebuild(Sequence *seq, anim *anim)
static bool seq_proxy_need_rebuild(Sequence *seq, ImBufAnim *anim)
{
if ((seq->strip->proxy->build_flags & SEQ_PROXY_SKIP_EXISTING) == 0) {
return true;
@ -608,7 +608,7 @@ void SEQ_proxy_set(Sequence *seq, bool value)
}
}
void seq_proxy_index_dir_set(anim *anim, const char *base_dir)
void seq_proxy_index_dir_set(ImBufAnim *anim, const char *base_dir)
{
char dirname[FILE_MAX];
char filename[FILE_MAXFILE];

View File

@ -17,4 +17,4 @@ struct anim;
ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int timeline_frame);
bool seq_proxy_get_custom_file_filepath(Sequence *seq, char *name, int view_id);
void free_proxy_seq(Sequence *seq);
void seq_proxy_index_dir_set(anim *anim, const char *base_dir);
void seq_proxy_index_dir_set(ImBufAnim *anim, const char *base_dir);

View File

@ -392,7 +392,8 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */
bool is_multiview_loaded = false;
const int totfiles = seq_num_files(scene, load_data->views_format, load_data->use_multiview);
anim **anim_arr = static_cast<anim **>(MEM_callocN(sizeof(anim *) * totfiles, "Video files"));
ImBufAnim **anim_arr = static_cast<ImBufAnim **>(
MEM_callocN(sizeof(ImBufAnim *) * totfiles, "Video files"));
int i;
int orig_width = 0;
int orig_height = 0;
@ -575,7 +576,7 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
if (prefix[0] != '\0') {
for (i = 0; i < totfiles; i++) {
anim *anim;
ImBufAnim *anim;
char filepath_view[FILE_MAX];
seq_multiview_name(scene, i, prefix, ext, filepath_view, sizeof(filepath_view));
@ -596,7 +597,7 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
}
if (is_multiview_loaded == false) {
anim *anim;
ImBufAnim *anim;
anim = openanim(filepath,
IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0),
seq->streamindex,

View File

@ -336,7 +336,7 @@ struct PlayAnimPict {
/** The allocated error message to show if the file cannot be loaded. */
char *error_message;
ImBuf *ibuf;
struct anim *anim;
ImBufAnim *anim;
int frame;
int IB_flags;
@ -844,7 +844,7 @@ static void build_pict_list_from_anim(ListBase *picsbase,
const int frame_offset)
{
/* OCIO_TODO: support different input color space. */
anim *anim = IMB_open_anim(filepath_first, IB_rect, 0, nullptr);
ImBufAnim *anim = IMB_open_anim(filepath_first, IB_rect, 0, nullptr);
if (anim == nullptr) {
CLOG_WARN(&LOG, "couldn't open anim '%s'", filepath_first);
return;
@ -1807,7 +1807,7 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_
if (IMB_isanim(filepath)) {
/* OCIO_TODO: support different input color spaces. */
anim *anim = IMB_open_anim(filepath, IB_rect, 0, nullptr);
ImBufAnim *anim = IMB_open_anim(filepath, IB_rect, 0, nullptr);
if (anim) {
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
IMB_close_anim(anim);
@ -1918,7 +1918,7 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_
#ifdef WITH_AUDASPACE
g_audaspace.source = AUD_Sound_file(filepath);
if (!BLI_listbase_is_empty(&ps.picsbase)) {
anim *anim_movie = static_cast<PlayAnimPict *>(ps.picsbase.first)->anim;
ImBufAnim *anim_movie = static_cast<PlayAnimPict *>(ps.picsbase.first)->anim;
if (anim_movie) {
short frs_sec = 25;
float frs_sec_base = 1.0;

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