Mesh: Rewrite split edges algorithm #110661

Merged
Hans Goudey merged 78 commits from HooglyBoogly/blender:split-edges-rewrite-2 into main 2023-08-30 14:23:49 +02:00
68 changed files with 329 additions and 447 deletions
Showing only changes of commit bd34bf213a - Show all commits

View File

@ -120,7 +120,7 @@ MetalDevice::MetalDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
}
if (device_vendor == METAL_GPU_APPLE) {
/* Set kernel_specialization_level based on user prefs. */
/* Set kernel_specialization_level based on user preferences. */
switch (info.kernel_optimization_level) {
case KERNEL_OPTIMIZATION_LEVEL_OFF:
kernel_specialization_level = PSO_GENERIC;

View File

@ -48,7 +48,7 @@ ccl_device_inline bool point_light_sample(const ccl_global KernelLight *klight,
if (r_sq == 0) {
/* Use intensity instead of radiance for point light. */
ls->eval_fac /= sqr(ls->t);
/* `ls->Ng` is not well-defined for point light, so use the incoming direction instead. */
/* `ls->Ng` is not well-defined for point light, so use the incoming direction instead. */
ls->Ng = -ls->D;
}
else {

View File

@ -458,7 +458,7 @@ void LightTree::recursive_build(const Child child,
if (should_split(emitters, start, middle, end, node->measure, node->light_link, split_dim)) {
if (split_dim != -1) {
/* Partition the emitters between start and end based on the centroids. */
/* Partition the emitters between start and end based on the centroids. */
std::nth_element(emitters + start,
emitters + middle,
emitters + end,

View File

@ -85,7 +85,7 @@ class GHOST_SystemHeadless : public GHOST_System {
{
#ifdef __linux__
GHOST_Context *context;
for (int minor = 6; minor >= 0; --minor) {
for (int minor = 6; minor >= 3; --minor) {
context = new GHOST_ContextEGL((GHOST_System *)this,
false,
EGLNativeWindowType(0),
@ -104,21 +104,6 @@ class GHOST_SystemHeadless : public GHOST_System {
context = nullptr;
}
context = new GHOST_ContextEGL((GHOST_System *)this,
false,
EGLNativeWindowType(0),
EGLNativeDisplayType(EGL_DEFAULT_DISPLAY),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3,
3,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
if (context->initializeDrawingContext() != GHOST_kSuccess) {
delete context;
context = nullptr;
}
return context;
#else
return nullptr;

View File

@ -129,19 +129,26 @@ uint8_t GHOST_SystemSDL::getNumDisplays() const
GHOST_IContext *GHOST_SystemSDL::createOffscreenContext(GHOST_GPUSettings /*gpuSettings*/)
{
GHOST_Context *context = new GHOST_ContextSDL(false,
nullptr,
0, /* Profile bit. */
3,
3,
GHOST_OPENGL_SDL_CONTEXT_FLAGS,
GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY);
for (int minor = 6; minor >= 3; --minor) {
GHOST_Context *context = new GHOST_ContextSDL(false,
nullptr,
0, /* Profile bit. */
4,
minor,
GHOST_OPENGL_SDL_CONTEXT_FLAGS,
GHOST_OPENGL_SDL_RESET_NOTIFICATION_STRATEGY);
if (context->initializeDrawingContext()) {
if (context->initializeDrawingContext()) {
return context;
}
delete context;
context = nullptr;
}
if (context && context->initializeDrawingContext()) {
return context;
}
delete context;
return nullptr;
}

View File

@ -6250,7 +6250,7 @@ static GHOST_Context *createOffscreenContext_impl(GHOST_SystemWayland *system,
/* Caller must lock `system->server_mutex`. */
GHOST_Context *context;
for (int minor = 6; minor >= 0; --minor) {
for (int minor = 6; minor >= 3; --minor) {
context = new GHOST_ContextEGL(system,
false,
EGLNativeWindowType(egl_window),
@ -6267,22 +6267,6 @@ static GHOST_Context *createOffscreenContext_impl(GHOST_SystemWayland *system,
}
delete context;
}
context = new GHOST_ContextEGL(system,
false,
EGLNativeWindowType(egl_window),
EGLNativeDisplayType(wl_display),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3,
3,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
if (context->initializeDrawingContext()) {
return context;
}
delete context;
return nullptr;
}

View File

@ -299,7 +299,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GPUSettings gpuS
HDC prev_hdc = wglGetCurrentDC();
HGLRC prev_context = wglGetCurrentContext();
for (int minor = 5; minor >= 0; --minor) {
for (int minor = 6; minor >= 3; --minor) {
context = new GHOST_ContextWGL(false,
true,
wnd,
@ -311,31 +311,15 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GPUSettings gpuS
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
if (context->initializeDrawingContext()) {
goto finished;
wglMakeCurrent(prev_hdc, prev_context);
return context;
}
else {
delete context;
context = nullptr;
}
}
context = new GHOST_ContextWGL(false,
true,
wnd,
mHDC,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
3,
3,
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
if (context->initializeDrawingContext()) {
goto finished;
}
else {
delete context;
return NULL;
}
finished:
wglMakeCurrent(prev_hdc, prev_context);
return context;
@ -465,8 +449,8 @@ GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(int32_t x, int32_t y)
GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys &keys) const
{
/* `GetAsyncKeyState` returns the current interrupt-level state of the hardware, which is needed
* when passing key states to a newly-activated window - #40059. Alterative `GetKeyState` only
* returns the state as processed by the thread's message queue. */
* when passing key states to a newly-activated window - #40059. Alternative `GetKeyState` only
* returns the state as processed by the thread's message queue. */
bool down = HIBYTE(::GetAsyncKeyState(VK_LSHIFT)) != 0;
keys.set(GHOST_kModifierKeyLeftShift, down);
down = HIBYTE(::GetAsyncKeyState(VK_RSHIFT)) != 0;

View File

@ -403,16 +403,6 @@ static GHOST_Context *create_glx_context(Display *display,
GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GPUSettings gpuSettings)
{
/* During development:
* try 4.x compatibility profile
* try 3.3 compatibility profile
* fall back to 3.0 if needed
*
* Final Blender 2.8:
* try 4.x core profile
* try 3.3 core profile
* no fall-backs. */
const bool debug_context = (gpuSettings.flags & GHOST_gpuDebugContext) != 0;
GHOST_Context *context = nullptr;
@ -431,29 +421,21 @@ GHOST_IContext *GHOST_SystemX11::createOffscreenContext(GHOST_GPUSettings gpuSet
#ifdef USE_EGL
/* Try to initialize an EGL context. */
for (int minor = 5; minor >= 0; --minor) {
for (int minor = 6; minor >= 3; --minor) {
context = create_egl_context(this, m_display, debug_context, 4, minor);
if (context != nullptr) {
return context;
}
}
context = create_egl_context(this, m_display, debug_context, 3, 3);
if (context != nullptr) {
return context;
}
/* EGL initialization failed, try to fallback to a GLX context. */
#endif
for (int minor = 5; minor >= 0; --minor) {
for (int minor = 6; minor >= 3; --minor) {
context = create_glx_context(m_display, debug_context, 4, minor);
if (context != nullptr) {
return context;
}
}
context = create_glx_context(m_display, debug_context, 3, 3);
if (context != nullptr) {
return context;
}
return nullptr;
}

View File

@ -1139,7 +1139,7 @@ static void frame_handle_commit(libdecor_frame * /*frame*/, void *data)
# endif
}
/* NOTE: cannot be `const` because of the LIBDECOR API. */
/* NOTE: cannot be `const` because of the LIBDECOR API. */
static libdecor_frame_interface libdecor_frame_iface = {
frame_handle_configure,
frame_handle_close,
@ -1770,7 +1770,7 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
#endif
case GHOST_kDrawingContextTypeOpenGL:
for (int minor = 6; minor >= 0; --minor) {
for (int minor = 6; minor >= 3; --minor) {
context = new GHOST_ContextEGL(system_,
m_wantStereoVisual,
EGLNativeWindowType(window_->egl_window),
@ -1786,20 +1786,11 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
return context;
}
delete context;
context = nullptr;
}
context = new GHOST_ContextEGL(system_,
m_wantStereoVisual,
EGLNativeWindowType(window_->egl_window),
EGLNativeDisplayType(system_->wl_display()),
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
3,
3,
GHOST_OPENGL_EGL_CONTEXT_FLAGS,
GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY,
EGL_OPENGL_API);
}
if (context->initializeDrawingContext()) {
if (context && context->initializeDrawingContext()) {
return context;
}

View File

@ -595,11 +595,7 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
if (type == GHOST_kDrawingContextTypeOpenGL) {
GHOST_Context *context;
/* - AMD and Intel give us exactly this version
* - NVIDIA gives at least this version <-- desired behavior
* So we ask for 4.5, 4.4 ... 3.3 in descending order
* to get the best version on the user's system. */
for (int minor = 5; minor >= 0; --minor) {
for (int minor = 6; minor >= 3; --minor) {
context = new GHOST_ContextWGL(m_wantStereoVisual,
m_wantAlphaBackground,
m_hWnd,
@ -615,23 +611,9 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty
}
else {
delete context;
context = nullptr;
}
}
context = new GHOST_ContextWGL(m_wantStereoVisual,
m_wantAlphaBackground,
m_hWnd,
m_hDC,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
3,
3,
(m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY);
if (context && !context->initializeDrawingContext()) {
delete context;
context = nullptr;
}
return context;
}
else if (type == GHOST_kDrawingContextTypeD3D) {

View File

@ -1256,38 +1256,20 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
#ifdef WITH_OPENGL_BACKEND
if (type == GHOST_kDrawingContextTypeOpenGL) {
/* During development:
* - Try 4.x compatibility profile.
* - Try 3.3 compatibility profile.
* - Fall back to 3.0 if needed.
*
* Final Blender 2.8:
* - Try 4.x core profile
* - Try 3.3 core profile
* - No fall-backs. */
GHOST_Context *context;
# ifdef USE_EGL
/* Try to initialize an EGL context. */
for (int minor = 5; minor >= 0; --minor) {
for (int minor = 6; minor >= 3; --minor) {
context = create_egl_context(
this->m_system, m_window, m_display, m_wantStereoVisual, m_is_debug_context, 4, minor);
if (context != nullptr) {
return context;
}
}
context = create_egl_context(
this->m_system, m_window, m_display, m_wantStereoVisual, m_is_debug_context, 3, 3);
if (context != nullptr) {
return context;
}
/* EGL initialization failed, try to fallback to a GLX context. */
# endif
for (int minor = 5; minor >= 0; --minor) {
for (int minor = 6; minor >= 3; --minor) {
context = create_glx_context(m_window,
m_display,
(GLXFBConfig)m_fbconfig,
@ -1299,16 +1281,6 @@ GHOST_Context *GHOST_WindowX11::newDrawingContext(GHOST_TDrawingContextType type
return context;
}
}
context = create_glx_context(m_window,
m_display,
(GLXFBConfig)m_fbconfig,
m_wantStereoVisual,
m_is_debug_context,
3,
3);
if (context != nullptr) {
return context;
}
/* Ugly, but we get crashes unless a whole bunch of systems are patched. */
fprintf(stderr, "Error! Unsupported graphics card or driver.\n");

View File

@ -160,7 +160,7 @@ enum {
G_FLAG_USERPREF_NO_SAVE_ON_EXIT = (1 << 4),
G_FLAG_SCRIPT_AUTOEXEC = (1 << 13),
/** When this flag is set ignore the prefs #USER_SCRIPT_AUTOEXEC_DISABLE. */
/** When this flag is set ignore the preferences #USER_SCRIPT_AUTOEXEC_DISABLE. */
G_FLAG_SCRIPT_OVERRIDE_PREF = (1 << 14),
G_FLAG_SCRIPT_AUTOEXEC_FAIL = (1 << 15),
G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET = (1 << 16),

View File

@ -1307,7 +1307,7 @@ bool BKE_blendfile_userdef_write_all(ReportList *reports)
if (use_template_userpref) {
if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) {
/* Also save app-template prefs */
/* Also save app-template preferences. */
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE);
printf("Writing userprefs app-template: \"%s\" ", filepath);

View File

@ -98,12 +98,12 @@ template<> struct TraitsType<ColorPaint4b> {
};
template<typename T> using Traits = typename TraitsType<T>::type;
static float get_luminance(ColorPaint4f c)
static inline float get_luminance(ColorPaint4f c)
{
return IMB_colormanagement_get_luminance(&c.r);
}
static int get_luminance(ColorPaint4b c)
static inline int get_luminance(ColorPaint4b c)
{
return IMB_colormanagement_get_luminance_byte(&c.r);
}

View File

@ -4414,10 +4414,10 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
do_versions_rename_id(bmain, ID_BR, "Draw Weight", "Weight Draw");
}
/* fcm->name was never used to store modifier name so it has always been an empty string. Now
* this property supports name editing. So assign value to name variable of Fmodifier otherwise
* modifier interface would show an empty name field. Also ensure uniqueness when opening old
* files. */
/* `fcm->name` was never used to store modifier name so it has always been an empty string.
* Now this property supports name editing. So assign value to name variable of F-modifier
* otherwise modifier interface would show an empty name field.
* Also ensure uniqueness when opening old files. */
if (!MAIN_VERSION_ATLEAST(bmain, 306, 7)) {
LISTBASE_FOREACH (bAction *, act, &bmain->actions) {
LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {

View File

@ -353,7 +353,7 @@ void Instance::render_read_result(RenderLayer *render_layer, const char *view_na
if (result) {
BLI_mutex_lock(&render->update_render_passes_mutex);
/* WORKAROUND: We use texture read to avoid using a framebuffer to get the render result.
/* WORKAROUND: We use texture read to avoid using a frame-buffer to get the render result.
* However, on some implementation, we need a buffer with a few extra bytes for the read to
* happen correctly (see GLTexture::read()). So we need a custom memory allocation. */
/* Avoid memcpy(), replace the pointer directly. */
@ -376,7 +376,7 @@ void Instance::render_read_result(RenderLayer *render_layer, const char *view_na
if (result) {
BLI_mutex_lock(&render->update_render_passes_mutex);
/* WORKAROUND: We use texture read to avoid using a framebuffer to get the render result.
/* WORKAROUND: We use texture read to avoid using a frame-buffer to get the render result.
* However, on some implementation, we need a buffer with a few extra bytes for the read to
* happen correctly (see GLTexture::read()). So we need a custom memory allocation. */
/* Avoid memcpy(), replace the pointer directly. */

View File

@ -106,9 +106,9 @@ class ReflectionProbeModule {
int3 dispatch_probe_pack_ = int3(0);
/**
* Texture containing a cubemap where the probe should be rendering to.
* Texture containing a cube-map where the probe should be rendering to.
*
* NOTE: TextureFromPool doesn't support cubemaps.
* NOTE: TextureFromPool doesn't support cube-maps.
*/
Texture cubemap_tx_ = {"Probe.Cubemap"};
int reflection_probe_index_ = 0;

View File

@ -163,7 +163,7 @@ void SyncModule::sync_mesh(Object *ob,
void SyncModule::sync_point_cloud(Object *ob,
ObjectHandle &ob_handle,
ResourceHandle res_handle,
const ObjectRef &ob_ref)
const ObjectRef & /*ob_ref*/)
{
int material_slot = 1;

View File

@ -2639,7 +2639,7 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator * /*op*/)
action_empty = true;
}
else {
/* TODO: check for keyframe + fmodifier data on these too */
/* TODO: check for keyframe + F-modifier data on these too. */
}
/* 2) No NLA Tracks and/or NLA Strips */

View File

@ -15,7 +15,7 @@
#include "BLT_translation.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_node.h"
#include "ED_object.h"

View File

@ -9,7 +9,7 @@
#include "DNA_object_types.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_transverts.h"
namespace blender::ed::curves {
@ -50,15 +50,3 @@ float (*ED_curves_point_normals_array_create(const Curves *curves_id))[3]
return reinterpret_cast<float(*)[3]>(data);
}
void ED_curves_transverts_create(Curves *curves_id, TransVertStore *tvs)
{
using namespace blender;
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
ed::curves::transverts_from_curves_positions_create(curves, tvs);
}
int *ED_curves_offsets_for_write(Curves *curves_id)
{
return curves_id->geometry.wrap().offsets_for_write().data();
}

View File

@ -8,7 +8,7 @@
#include "BKE_curves.hh"
#include "ED_curves.h"
#include "ED_curves.hh"
namespace blender::ed::curves {

View File

@ -10,7 +10,7 @@
#include "BKE_curves.hh"
#include "ED_curves.h"
#include "ED_curves.hh"
namespace blender::ed::curves {

View File

@ -18,7 +18,7 @@
#include "BLT_translation.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"

View File

@ -15,7 +15,7 @@
#include "BKE_crazyspace.hh"
#include "BKE_curves.hh"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_object.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"

View File

@ -18,7 +18,7 @@
#include "DEG_depsgraph.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_undo.h"
#include "MEM_guardedalloc.h"

View File

@ -6,7 +6,7 @@
* \ingroup edcurves
*/
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"

View File

@ -15,7 +15,7 @@
#include "DEG_depsgraph.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_grease_pencil.h"
#include "ED_screen.h"
#include "ED_view3d.h"

View File

@ -8,6 +8,16 @@
#pragma once
#include "BKE_attribute.hh"
#include "BKE_crazyspace.hh"
#include "BKE_curves.hh"
#include "BLI_index_mask.hh"
#include "BLI_vector.hh"
#include "BLI_vector_set.hh"
#include "ED_select_utils.h"
struct bContext;
struct Curves;
struct UndoType;
@ -15,54 +25,25 @@ struct SelectPick_Params;
struct ViewContext;
struct rcti;
struct TransVertStore;
#ifdef __cplusplus
extern "C" {
#endif
struct wmKeyConfig;
/* -------------------------------------------------------------------- */
/** \name C Wrappers
* \{ */
void ED_operatortypes_curves(void);
void ED_curves_undosys_type(struct UndoType *ut);
void ED_keymap_curves(struct wmKeyConfig *keyconf);
void ED_operatortypes_curves();
void ED_curves_undosys_type(UndoType *ut);
void ED_keymap_curves(wmKeyConfig *keyconf);
/**
* Return an owning pointer to an array of point normals the same size as the number of control
* points. The normals depend on the normal mode for each curve and the "tilt" attribute and may be
* calculated for the evaluated points and sampled back to the control points.
*/
float (*ED_curves_point_normals_array_create(const struct Curves *curves_id))[3];
/**
* Wrapper for `transverts_from_curves_positions_create`.
*/
void ED_curves_transverts_create(struct Curves *curves_id, struct TransVertStore *tvs);
/**
* C wrapper for #CurvesGeometry::offsets_for_write().
*/
int *ED_curves_offsets_for_write(struct Curves *curves_id);
float (*ED_curves_point_normals_array_create(const Curves *curves_id))[3];
/** \} */
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
# include "BKE_attribute.hh"
# include "BKE_crazyspace.hh"
# include "BKE_curves.hh"
# include "BLI_index_mask.hh"
# include "BLI_vector.hh"
# include "BLI_vector_set.hh"
# include "ED_select_utils.h"
namespace blender::ed::curves {
bool object_has_editable_curves(const Main &bmain, const Object &object);
@ -109,7 +90,7 @@ IndexMask end_points(const bke::CurvesGeometry &curves,
* Return a mask of random points or curves.
*
* \param random_seed: The seed for the \a RandomNumberGenerator.
* \param probability: Determins how likely a point/curve will be chosen. If set to 0.0, nothing
* \param probability: Determines how likely a point/curve will be chosen. If set to 0.0, nothing
* will be in the mask, if set to 1.0 everything will be in the mask.
*/
IndexMask random_mask(const bke::CurvesGeometry &curves,
@ -261,4 +242,3 @@ bool remove_selection(bke::CurvesGeometry &curves, eAttrDomain selection_domain)
/** \} */
} // namespace blender::ed::curves
#endif

View File

@ -1453,7 +1453,6 @@ enum {
enum eButProgressType {
UI_BUT_PROGRESS_TYPE_BAR = 0,
UI_BUT_PROGRESS_TYPE_RING = 1,
UI_BUT_PROGRESS_TYPE_PIE = 2,
};
/***************************** ID Utilities *******************************/

View File

@ -3510,7 +3510,7 @@ void uiItemProgressIndicator(uiLayout *layout,
0,
"");
if (has_text && ELEM(progress_type, UI_BUT_PROGRESS_TYPE_RING, UI_BUT_PROGRESS_TYPE_PIE)) {
if (has_text && (progress_type == UI_BUT_PROGRESS_TYPE_RING)) {
/* For progress bar, centered is okay, left aligned for ring/pie. */
but->drawflag |= UI_BUT_TEXT_LEFT;
}

View File

@ -6759,8 +6759,7 @@ void uiTemplateNodeSocket(uiLayout *layout, bContext * /*C*/, float color[4])
/* XXX using explicit socket colors is not quite ideal.
* Eventually it should be possible to use theme colors for this purpose,
* but this requires a better design for extendable color palettes in user prefs.
*/
* but this requires a better design for extendable color palettes in user preferences. */
uiBut *but = uiDefBut(
block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, nullptr, 0, 0, 0, 0, "");
rgba_float_to_uchar(but->col, color);

View File

@ -3640,11 +3640,11 @@ static void widget_progress_type_bar(uiButProgress *but_progress,
/**
* Used for both ring & pie types.
*/
static void widget_progress_type_circle(uiButProgress *but_progress,
uiWidgetColors *wcol,
rcti *rect,
const float ring_width)
static void widget_progress_type_ring(uiButProgress *but_progress,
uiWidgetColors *wcol,
rcti *rect)
{
const float ring_width = 0.6; /* 0.0 would be a pie. */
const float outer_rad = (rect->ymax - rect->ymin) / 2.0f;
const float inner_rad = outer_rad * ring_width;
const float x = rect->xmin + outer_rad;
@ -3687,12 +3687,8 @@ static void widget_progress_indicator(uiBut *but,
widget_progress_type_bar(but_progress, wcol, rect, roundboxalign, zoom);
break;
}
case UI_BUT_PROGRESS_TYPE_PIE: {
widget_progress_type_circle(but_progress, wcol, rect, 0.6f);
break;
}
case UI_BUT_PROGRESS_TYPE_RING: {
widget_progress_type_circle(but_progress, wcol, rect, 0.0f);
widget_progress_type_ring(but_progress, wcol, rect);
break;
}
}

View File

@ -103,7 +103,7 @@
#include "ED_armature.h"
#include "ED_curve.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_gpencil_legacy.h"
#include "ED_grease_pencil.h"
#include "ED_mball.h"

View File

@ -691,7 +691,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
printf("%s: set screen\n", __func__);
}
screen->do_refresh = false;
/* prevent multiwin errors */
/* Prevent multi-window errors. */
screen->winid = win->winid;
screen->context = reinterpret_cast<void *>(ed_screen_context);

View File

@ -16,7 +16,7 @@
#include "BKE_crazyspace.hh"
#include "BKE_curves.hh"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_curves_sculpt.h"
struct ARegion;

View File

@ -20,7 +20,7 @@
#include "WM_message.h"
#include "WM_toolsystem.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_curves_sculpt.h"
#include "ED_image.h"
#include "ED_object.h"

View File

@ -176,7 +176,9 @@ static MDeformVert *defweight_prev_init(MDeformVert *dvert_prev,
return dv_prev;
}
/* vpaint has 'vpaint_blend' */
/**
* VPaint has 'vpaint_blend'
*/
static float wpaint_blend(const VPaint *wp,
float weight,
const float alpha,

View File

@ -29,7 +29,7 @@
#include "ED_asset.h"
#include "ED_clip.h"
#include "ED_curve.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_curves_sculpt.h"
#include "ED_fileselect.h"
#include "ED_geometry.h"

View File

@ -1288,7 +1288,7 @@ ID *buttons_context_id_path(const bContext *C)
for (int i = path->len - 1; i >= 0; i--) {
PointerRNA *ptr = &path->ptr[i];
/* Pin particle settings instead of system, since only settings are an idblock. */
/* Pin particle settings instead of system, since only settings are an ID-block. */
if (sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) {
if (ptr->type == &RNA_ParticleSystem && ptr->data) {
ParticleSystem *psys = static_cast<ParticleSystem *>(ptr->data);

View File

@ -328,7 +328,8 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
is_relative = false;
}
/* Annoying exception!, if we're dealing with the user prefs, default relative to be off. */
/* Annoying exception!, if we're dealing with the user preferences,
* default relative to be off. */
RNA_property_boolean_set(op->ptr, prop_relpath, is_relative);
}
}

View File

@ -2387,7 +2387,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator * /*op*/, const wmEv
/* if we are not editing, we are done */
if (edit_idx == -1) {
/* Do not invalidate timer if filerename is still pending,
/* Do not invalidate timer if file-rename is still pending,
* we might still be building the filelist and yet have to find edited entry. */
if (params->rename_flag == 0) {
file_params_smoothscroll_timer_clear(wm, win, sfile);

View File

@ -712,7 +712,7 @@ void ED_fileselect_params_to_userdef(SpaceFile *sfile,
sfile_udata_new->temp_win_sizey = temp_win_size[1];
}
/* Tag prefs as dirty if something has changed. */
/* Tag preferences as dirty if something has changed. */
if (memcmp(sfile_udata_new, &sfile_udata_old, sizeof(sfile_udata_old)) != 0) {
U.runtime.is_dirty = true;
}

View File

@ -1140,7 +1140,7 @@ static void draw_fcurve(bAnimContext *ac, SpaceGraph *sipo, ARegion *region, bAn
* by sampling it at various small-intervals over the visible region
*/
if (adt) {
/** We have to do this mapping dance since the keyframes were remapped but the Fmodifier
/* We have to do this mapping dance since the keyframes were remapped but the F-modifier
* evaluations are not.
*
* So we undo the keyframe remapping and instead remap the evaluation time when drawing the

View File

@ -227,7 +227,7 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot)
/* API callbacks */
ot->exec = graphkeys_previewrange_exec;
/* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier. */
/* XXX: unchecked poll to get F-samples working too, but makes modifier damage trickier. */
ot->poll = ED_operator_graphedit_active;
/* Flags */
@ -307,7 +307,7 @@ void GRAPH_OT_view_all(wmOperatorType *ot)
/* API callbacks */
ot->exec = graphkeys_viewall_exec;
/* XXX: Unchecked poll to get fsamples working too, but makes modifier damage trickier... */
/* XXX: Unchecked poll to get F-samples working too, but makes modifier damage trickier. */
ot->poll = ED_operator_graphedit_active;
/* Flags */

View File

@ -1901,7 +1901,7 @@ static ImageSaveData *image_save_as_init(bContext *C, wmOperator *op)
RNA_boolean_set(op->ptr, "save_as_render", isd->opts.save_as_render);
}
/* Show multiview save options only if image has multiviews. */
/* Show multi-view save options only if image has multi-views. */
PropertyRNA *prop;
prop = RNA_struct_find_property(op->ptr, "show_multiview");
RNA_property_boolean_set(op->ptr, prop, BKE_image_is_multiview(image));

View File

@ -460,11 +460,11 @@ static bool node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
nodeRemoveNode(bmain, ntree, node, false);
}
update_nested_node_refs_after_ungroup(*ntree, *ngroup, *gnode, node_identifier_map);
/* delete the group instance and dereference group tree */
nodeRemoveNode(bmain, ntree, gnode, true);
update_nested_node_refs_after_ungroup(*ntree, *ngroup, *gnode, node_identifier_map);
return true;
}
@ -928,45 +928,46 @@ static void update_nested_node_refs_after_moving_nodes_into_group(
const Map<int32_t, int32_t> &node_identifier_map)
{
/* Update nested node references in the parent and child node tree. */
RandomNumberGenerator rng(int(PIL_check_seconds_timer() * 1000000.0));
RandomNumberGenerator rng(PIL_check_seconds_timer_i() & UINT_MAX);
Vector<bNestedNodeRef> new_nested_node_refs;
/* Keep all nested node references that were in the group before. */
for (const bNestedNodeRef &state_id : group.nested_node_refs_span()) {
new_nested_node_refs.append(state_id);
for (const bNestedNodeRef &ref : group.nested_node_refs_span()) {
new_nested_node_refs.append(ref);
}
Set<int32_t> used_nested_node_ref_ids;
for (const bNestedNodeRef &ref : group.nested_node_refs_span()) {
used_nested_node_ref_ids.add(ref.id);
}
Map<bNestedNodePath, int32_t> new_id_by_old_path;
for (bNestedNodeRef &state_id : ntree.nested_node_refs_span()) {
const int32_t new_node_id = node_identifier_map.lookup_default(state_id.path.node_id, -1);
for (bNestedNodeRef &ref : ntree.nested_node_refs_span()) {
const int32_t new_node_id = node_identifier_map.lookup_default(ref.path.node_id, -1);
if (new_node_id == -1) {
/* The node was not moved between node groups. */
continue;
}
bNestedNodeRef new_state_id = state_id;
new_state_id.path.node_id = new_node_id;
bNestedNodeRef new_ref = ref;
new_ref.path.node_id = new_node_id;
/* Find new unique identifier for the nested node ref. */
while (true) {
const int32_t new_id = rng.get_int32(INT32_MAX);
if (used_nested_node_ref_ids.add(new_id)) {
new_state_id.id = new_id;
new_ref.id = new_id;
break;
}
}
new_id_by_old_path.add_new(state_id.path, new_state_id.id);
new_nested_node_refs.append(new_state_id);
new_id_by_old_path.add_new(ref.path, new_ref.id);
new_nested_node_refs.append(new_ref);
/* Updated the nested node ref in the parent so that it points to the same node that is now
* inside of a nested group. */
state_id.path.node_id = gnode.identifier;
state_id.path.id_in_node = new_state_id.id;
ref.path.node_id = gnode.identifier;
ref.path.id_in_node = new_ref.id;
}
MEM_SAFE_FREE(group.nested_node_refs);
group.nested_node_refs = static_cast<bNestedNodeRef *>(
MEM_malloc_arrayN(new_nested_node_refs.size(), sizeof(bNestedNodeRef), __func__));
uninitialized_copy_n(
new_nested_node_refs.data(), new_nested_node_refs.size(), group.nested_node_refs);
group.nested_node_refs_num = new_nested_node_refs.size();
}
static void node_group_make_insert_selected(const bContext &C,

View File

@ -208,7 +208,7 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq)
return;
}
}
else { /* There's no existig preview job. */
else { /* There's no existing preview job. */
pj = MEM_cnew<PreviewJob>("preview rebuild job");
pj->mutex = BLI_mutex_alloc();

View File

@ -29,7 +29,7 @@
#include "DEG_depsgraph_query.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_spreadsheet.h"
#include "NOD_geometry_nodes_lazy_function.hh"

View File

@ -62,26 +62,32 @@ struct View3DCameraControl {
/* -------------------------------------------------------------------- */
/* initial values */
/* root most parent */
/** Root most parent. */
Object *root_parent;
/* backup values */
float dist_backup;
/* backup the views distance since we use a zero dist for fly mode */
float ofs_backup[3];
/* backup the views offset in case the user cancels flying in non camera mode */
/* Backup values. */
/* backup the views quat in case the user cancels flying in non camera mode. */
/** Backup the views distance since we use a zero dist for fly mode. */
float dist_backup;
/** Backup the views offset in case the user cancels flying in non camera mode. */
float ofs_backup[3];
/** Backup the views quaternion in case the user cancels flying in non camera mode. */
float rot_backup[4];
/* remember if we're ortho or not, only used for restoring the view if it was a ortho view */
/**
* Remember if we're orthographic or not,
* only used for restoring the view if it was a orthographic view.
*/
char persp_backup;
/* are we flying an ortho camera in perspective view,
* which was originally in ortho view?
* could probably figure it out but better be explicit */
/**
* True when flying an orthographic camera in perspective view,
* which was originally in orthographic view.
* This could be detected available data but better be explicit.
*/
bool is_ortho_cam;
/* backup the objects transform */
/** Backup the objects transform. */
void *obtfm;
};

View File

@ -73,7 +73,7 @@
#include "ED_armature.h"
#include "ED_curve.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_gpencil_legacy.h"
#include "ED_grease_pencil.h"
#include "ED_lattice.h"

View File

@ -218,7 +218,7 @@ static void set_prop_dist(TransInfo *t, const bool with_dist)
TransData *td = tc->data;
for (a = 0; a < tc->data_len; a++, td++) {
if (td->flag & TD_SELECTED) {
/* Initialize, it was mallocced. */
/* Initialize, it was malloced. */
float vec[3];
td->rdist = 0.0f;

View File

@ -12,7 +12,7 @@
#include "BKE_curves.hh"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "MEM_guardedalloc.h"

View File

@ -132,7 +132,7 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *r_count, int *r_flag)
/* Count */
/* Non nested strips (resect selection and handles) */
/* Non nested strips (reset selection and handles). */
if ((seq->flag & SELECT) == 0 || SEQ_transform_is_locked(channels, seq)) {
*r_count = 0;
*r_flag = 0;

View File

@ -145,38 +145,44 @@ enum {
TD_NOTCONNECTED = 1 << 2,
/** Used for scaling of #MetaElem.rad */
TD_SINGLESIZE = 1 << 3,
/** Scale relative to individual element center */
/** Scale relative to individual element center. */
TD_INDIVIDUAL_SCALE = 1 << 4,
TD_NOCENTER = 1 << 5,
/** #TransData.ext abused for particle key timing. */
TD_NO_EXT = 1 << 6,
/** don't transform this data */
/** Don't transform this data. */
TD_SKIP = 1 << 7,
/** if this is a bez triple, we need to restore the handles,
* if this is set #TransData.hdata needs freeing */
/**
* If this is a bezier triple, we need to restore the handles,
* if this is set #TransData.hdata needs freeing.
*/
TD_BEZTRIPLE = 1 << 8,
/** when this is set, don't apply translation changes to this element */
TD_NO_LOC = 1 << 9,
/** For Graph Editor auto-snap, indicates that point should not undergo auto-snapping. */
TD_NOTIMESNAP = 1 << 10,
/** For Graph Editor - curves that can only have int-values
* need their keyframes tagged with this. */
/**
* For Graph Editor - curves that can only have int-values
* need their keyframes tagged with this.
*/
TD_INTVALUES = 1 << 11,
#define TD_MIRROR_AXIS_SHIFT 12
/** For editmode mirror. */
/** For edit-mode mirror. */
TD_MIRROR_X = 1 << 12,
TD_MIRROR_Y = 1 << 13,
TD_MIRROR_Z = 1 << 14,
#define TD_MIRROR_EDGE_AXIS_SHIFT 12
/** For editmode mirror, clamp axis to 0 */
/** For edit-mode mirror, clamp axis to 0. */
TD_MIRROR_EDGE_X = 1 << 12,
TD_MIRROR_EDGE_Y = 1 << 13,
TD_MIRROR_EDGE_Z = 1 << 14,
/** For fcurve handles, move them along with their keyframes */
/** For F-curve handles, move them along with their keyframes. */
TD_MOVEHANDLE1 = 1 << 15,
TD_MOVEHANDLE2 = 1 << 16,
/** Exceptional case with pose bone rotating when a parent bone has 'Local Location'
* option enabled and rotating also transforms it. */
/**
* Exceptional case with pose bone rotating when a parent bone has 'Local Location'
* option enabled and rotating also transforms it.
*/
TD_PBONE_LOCAL_MTX_P = 1 << 17,
/** Same as above but for a child bone. */
TD_PBONE_LOCAL_MTX_C = 1 << 18,

View File

@ -35,7 +35,7 @@
#include "WM_message.h"
#include "ED_armature.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_gizmo_library.h"
#include "ED_gizmo_utils.h"
#include "ED_gpencil_legacy.h"

View File

@ -12,7 +12,7 @@
#include "ED_armature.h"
#include "ED_curve.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_lattice.h"
#include "ED_mball.h"
#include "ED_mesh.h"

View File

@ -42,7 +42,7 @@ set(SRC
../include/ED_buttons.h
../include/ED_clip.h
../include/ED_curve.h
../include/ED_curves.h
../include/ED_curves.hh
../include/ED_curves_sculpt.h
../include/ED_datafiles.h
../include/ED_file_indexer.h

View File

@ -32,7 +32,7 @@
#include "DEG_depsgraph.h"
#include "ED_armature.h"
#include "ED_curves.h"
#include "ED_curves.hh"
#include "ED_transverts.h" /* own include */
@ -497,7 +497,7 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, const Object *obedit,
}
else if (obedit->type == OB_CURVES) {
Curves *curves_id = static_cast<Curves *>(obedit->data);
ED_curves_transverts_create(curves_id, tvs);
blender::ed::curves::transverts_from_curves_positions_create(curves_id->geometry.wrap(), tvs);
}
if (!tvs->transverts_tot && tvs->transverts) {

View File

@ -1394,6 +1394,8 @@ static int uv_pin_exec(bContext *C, wmOperator *op)
static void UV_OT_pin(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
ot->name = "Pin";
ot->description =
@ -1406,13 +1408,15 @@ static void UV_OT_pin(wmOperatorType *ot)
ot->poll = ED_operator_uvedit;
/* properties */
RNA_def_boolean(
prop = RNA_def_boolean(
ot->srna, "clear", false, "Clear", "Clear pinning for the selection instead of setting it");
RNA_def_boolean(ot->srna,
"invert",
false,
"Invert",
"Invert pinning for the selection instead of setting it");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna,
"invert",
false,
"Invert",
"Invert pinning for the selection instead of setting it");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
/** \} */

View File

@ -67,7 +67,7 @@ void MTLIndexBuf::read(uint32_t *data) const
MTLContext *ctx = MTLContext::get();
BLI_assert(ctx);
/* Ensure data is flushed for host caches. */
/* Ensure data is flushed for host caches. */
id<MTLBuffer> source_buffer = ibo_->get_metal_buffer();
if (source_buffer.storageMode == MTLStorageModeManaged) {
id<MTLBlitCommandEncoder> enc = ctx->main_command_buffer.ensure_begin_blit_encoder();

View File

@ -350,7 +350,7 @@ void MTLVertBuf::read(void *data) const
if (usage_ != GPU_USAGE_DEVICE_ONLY) {
/* Ensure data is flushed for host caches. */
/* Ensure data is flushed for host caches. */
id<MTLBuffer> source_buffer = vbo_->get_metal_buffer();
if (source_buffer.storageMode == MTLStorageModeManaged) {
id<MTLBlitCommandEncoder> enc = ctx->main_command_buffer.ensure_begin_blit_encoder();

View File

@ -122,7 +122,7 @@ void GLBackend::platform_init()
}
/* Detect support level */
if (!(epoxy_gl_version() >= 33)) {
if (!(epoxy_gl_version() >= 43)) {
support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
}
else {

View File

@ -82,7 +82,7 @@ class AbcObjectReader {
/* XXX - TODO(kevindietrich) : this references stack memory... */
ImportSettings *m_settings;
/* This is initialized from the ImportSettings above on construction. It will need to be removed
* once we fix the stack memory reference situation. */
* once we fix the stack memory reference situation. */
bool m_is_reading_a_file_sequence = false;
chrono_t m_min_time;

View File

@ -1441,7 +1441,7 @@ static char *rna_def_property_set_func(
}
else {
rna_clamp_value_range(f, prop);
/* C++ may require casting to an enum type. */
/* C++ may require casting to an enum type. */
fprintf(f, "#ifdef __cplusplus\n");
fprintf(f,
/* If #rna_clamp_value() adds an expression like `CLAMPIS(...)`
@ -4705,7 +4705,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
#if defined(__clang__)
/* TODO(@ideasman42): ideally this workaround would not be needed,
* could use some further investigation as these are intended to be declared. */
* could use some further investigation as these are intended to be declared. */
fprintf(f, "#pragma GCC diagnostic ignored \"-Wmissing-variable-declarations\"\n\n");
#endif

View File

@ -45,11 +45,11 @@ const EnumPropertyItem rna_enum_curve_normal_modes[] = {
# include "BLI_math_vector.h"
# include "BKE_attribute.h"
# include "BKE_curves.h"
# include "BKE_curves.hh"
# include "DEG_depsgraph.h"
# include "ED_curves.h"
# include "ED_curves.hh"
# include "WM_api.h"
# include "WM_types.h"
@ -69,7 +69,7 @@ static void rna_Curves_curve_offset_data_begin(CollectionPropertyIterator *iter,
{
Curves *curves = rna_curves(ptr);
rna_iterator_array_begin(iter,
ED_curves_offsets_for_write(curves),
curves->geometry.wrap().offsets_for_write().data(),
sizeof(int),
curves->geometry.curve_num + 1,
false,
@ -84,27 +84,25 @@ static int rna_Curves_curve_offset_data_lookup_int(PointerRNA *ptr, int index, P
}
r_ptr->owner_id = &curves->id;
r_ptr->type = &RNA_IntAttributeValue;
r_ptr->data = &ED_curves_offsets_for_write(curves)[index];
r_ptr->data = &curves->geometry.wrap().offsets_for_write()[index];
return true;
}
static float (*get_curves_positions(Curves *curves))[3]
static float (*get_curves_positions_for_write(Curves &curves))[3]
{
return (float(*)[3])CustomData_get_layer_named_for_write(
&curves->geometry.point_data, CD_PROP_FLOAT3, "position", curves->geometry.point_num);
return reinterpret_cast<float(*)[3]>(curves.geometry.wrap().positions_for_write().data());
}
static const float (*get_curves_positions_const(const Curves *curves))[3]
static const float (*get_curves_positions(const Curves &curves))[3]
{
return (const float(*)[3])CustomData_get_layer_named(
&curves->geometry.point_data, CD_PROP_FLOAT3, "position");
return reinterpret_cast<const float(*)[3]>(curves.geometry.wrap().positions().data());
}
static int rna_CurvePoint_index_get_const(const PointerRNA *ptr)
{
const Curves *curves = rna_curves(ptr);
const float(*co)[3] = static_cast<float(*)[3]>(ptr->data);
const float(*positions)[3] = get_curves_positions_const(curves);
const float(*positions)[3] = get_curves_positions(*curves);
return int(co - positions);
}
@ -112,7 +110,7 @@ static void rna_Curves_curves_begin(CollectionPropertyIterator *iter, PointerRNA
{
Curves *curves = rna_curves(ptr);
rna_iterator_array_begin(iter,
ED_curves_offsets_for_write(curves),
curves->geometry.wrap().offsets_for_write().data(),
sizeof(int),
curves->geometry.curve_num,
false,
@ -133,7 +131,7 @@ static int rna_Curves_curves_lookup_int(PointerRNA *ptr, int index, PointerRNA *
}
r_ptr->owner_id = &curves->id;
r_ptr->type = &RNA_CurveSlice;
r_ptr->data = &ED_curves_offsets_for_write(curves)[index];
r_ptr->data = &curves->geometry.wrap().offsets_for_write()[index];
return true;
}
@ -151,7 +149,7 @@ int rna_Curves_position_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *
}
r_ptr->owner_id = &curves->id;
r_ptr->type = &RNA_FloatVectorAttributeValue;
r_ptr->data = &get_curves_positions(curves)[index];
r_ptr->data = &get_curves_positions_for_write(*curves)[index];
return true;
}
@ -159,7 +157,7 @@ static void rna_Curves_position_data_begin(CollectionPropertyIterator *iter, Poi
{
Curves *curves = rna_curves(ptr);
rna_iterator_array_begin(iter,
get_curves_positions(curves),
get_curves_positions_for_write(*curves),
sizeof(float[3]),
curves->geometry.point_num,
false,
@ -216,7 +214,7 @@ int rna_Curves_points_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
}
r_ptr->owner_id = &curves->id;
r_ptr->type = &RNA_CurvePoint;
r_ptr->data = &get_curves_positions(curves)[index];
r_ptr->data = &get_curves_positions_for_write(*curves)[index];
return true;
}
@ -254,7 +252,7 @@ static void rna_CurveSlice_points_begin(CollectionPropertyIterator *iter, Pointe
Curves *curves = rna_curves(ptr);
const int offset = rna_CurveSlice_first_point_index_get(ptr);
const int size = rna_CurveSlice_points_length_get(ptr);
float(*positions)[3] = get_curves_positions(curves);
float(*positions)[3] = get_curves_positions_for_write(*curves);
float(*co)[3] = positions + offset;
rna_iterator_array_begin(iter, co, sizeof(float[3]), size, 0, nullptr);
}

View File

@ -959,7 +959,6 @@ void RNA_api_ui_layout(StructRNA *srna)
static const EnumPropertyItem progress_type_items[] = {
{UI_BUT_PROGRESS_TYPE_BAR, "BAR", 0, "Bar", ""},
{UI_BUT_PROGRESS_TYPE_RING, "RING", 0, "Ring", ""},
{UI_BUT_PROGRESS_TYPE_PIE, "PIE", 0, "Pie", ""},
{0, nullptr, 0, nullptr, nullptr},
};

View File

@ -138,6 +138,34 @@ static bool buffer_from_filepath(const char *filepath, void **r_mem, size_t *r_s
/** \} */
/** Use a flag to store held modifiers & mouse buttons. */
typedef enum eWS_Qual {
WS_QUAL_LSHIFT = (1 << 0),
WS_QUAL_RSHIFT = (1 << 1),
WS_QUAL_SHIFT = (WS_QUAL_LSHIFT | WS_QUAL_RSHIFT),
WS_QUAL_LALT = (1 << 2),
WS_QUAL_RALT = (1 << 3),
WS_QUAL_ALT = (WS_QUAL_LALT | WS_QUAL_RALT),
WS_QUAL_LCTRL = (1 << 4),
WS_QUAL_RCTRL = (1 << 5),
WS_QUAL_CTRL = (WS_QUAL_LCTRL | WS_QUAL_RCTRL),
WS_QUAL_LMOUSE = (1 << 16),
WS_QUAL_MMOUSE = (1 << 17),
WS_QUAL_RMOUSE = (1 << 18),
WS_QUAL_MOUSE = (WS_QUAL_LMOUSE | WS_QUAL_MMOUSE | WS_QUAL_RMOUSE),
} eWS_Qual;
typedef struct GhostData {
GHOST_SystemHandle system;
GHOST_WindowHandle window;
/** Not GHOST, but low level GPU context. */
GPUContext *gpu_context;
/** Held keys. */
eWS_Qual qual;
} GhostData;
/**
* The minimal context necessary for displaying an image.
* Used while displaying images both on load and while playing.
@ -213,6 +241,8 @@ typedef struct PlayState {
bool need_frame_update;
/** The current frame calculated by scrubbing the mouse cursor. */
int frame_cursor_x;
GhostData ghost_data;
} PlayState;
/* for debugging */
@ -232,35 +262,9 @@ static void print_ps(PlayState *ps)
}
#endif
/* global for window and events */
typedef enum eWS_Qual {
WS_QUAL_LSHIFT = (1 << 0),
WS_QUAL_RSHIFT = (1 << 1),
WS_QUAL_SHIFT = (WS_QUAL_LSHIFT | WS_QUAL_RSHIFT),
WS_QUAL_LALT = (1 << 2),
WS_QUAL_RALT = (1 << 3),
WS_QUAL_ALT = (WS_QUAL_LALT | WS_QUAL_RALT),
WS_QUAL_LCTRL = (1 << 4),
WS_QUAL_RCTRL = (1 << 5),
WS_QUAL_CTRL = (WS_QUAL_LCTRL | WS_QUAL_RCTRL),
WS_QUAL_LMOUSE = (1 << 16),
WS_QUAL_MMOUSE = (1 << 17),
WS_QUAL_RMOUSE = (1 << 18),
WS_QUAL_MOUSE = (WS_QUAL_LMOUSE | WS_QUAL_MMOUSE | WS_QUAL_RMOUSE),
} eWS_Qual;
static struct WindowStateGlobal {
GHOST_SystemHandle ghost_system;
void *ghost_window;
GPUContext *blender_gpu_context;
/* events */
eWS_Qual qual;
} g_WS = {NULL};
static void playanim_window_get_size(int *r_width, int *r_height)
static void playanim_window_get_size(GHOST_WindowHandle ghost_window, int *r_width, int *r_height)
{
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(g_WS.ghost_window);
GHOST_RectangleHandle bounds = GHOST_GetClientBounds(ghost_window);
*r_width = GHOST_GetWidthRectangle(bounds);
*r_height = GHOST_GetHeightRectangle(bounds);
GHOST_DisposeRectangle(bounds);
@ -274,30 +278,30 @@ static void playanim_gl_matrix(void)
}
/* implementation */
static void playanim_event_qual_update(void)
static void playanim_event_qual_update(GhostData *ghost_data)
{
bool val;
/* Shift */
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyLeftShift, &val);
SET_FLAG_FROM_TEST(g_WS.qual, val, WS_QUAL_LSHIFT);
GHOST_GetModifierKeyState(ghost_data->system, GHOST_kModifierKeyLeftShift, &val);
SET_FLAG_FROM_TEST(ghost_data->qual, val, WS_QUAL_LSHIFT);
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyRightShift, &val);
SET_FLAG_FROM_TEST(g_WS.qual, val, WS_QUAL_RSHIFT);
GHOST_GetModifierKeyState(ghost_data->system, GHOST_kModifierKeyRightShift, &val);
SET_FLAG_FROM_TEST(ghost_data->qual, val, WS_QUAL_RSHIFT);
/* Control */
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyLeftControl, &val);
SET_FLAG_FROM_TEST(g_WS.qual, val, WS_QUAL_LCTRL);
GHOST_GetModifierKeyState(ghost_data->system, GHOST_kModifierKeyLeftControl, &val);
SET_FLAG_FROM_TEST(ghost_data->qual, val, WS_QUAL_LCTRL);
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyRightControl, &val);
SET_FLAG_FROM_TEST(g_WS.qual, val, WS_QUAL_RCTRL);
GHOST_GetModifierKeyState(ghost_data->system, GHOST_kModifierKeyRightControl, &val);
SET_FLAG_FROM_TEST(ghost_data->qual, val, WS_QUAL_RCTRL);
/* Alt */
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyLeftAlt, &val);
SET_FLAG_FROM_TEST(g_WS.qual, val, WS_QUAL_LALT);
GHOST_GetModifierKeyState(ghost_data->system, GHOST_kModifierKeyLeftAlt, &val);
SET_FLAG_FROM_TEST(ghost_data->qual, val, WS_QUAL_LALT);
GHOST_GetModifierKeyState(g_WS.ghost_system, GHOST_kModifierKeyRightAlt, &val);
SET_FLAG_FROM_TEST(g_WS.qual, val, WS_QUAL_RALT);
GHOST_GetModifierKeyState(ghost_data->system, GHOST_kModifierKeyRightAlt, &val);
SET_FLAG_FROM_TEST(ghost_data->qual, val, WS_QUAL_RALT);
}
typedef struct PlayAnimPict {
@ -608,7 +612,8 @@ static void draw_display_buffer(const PlayDisplayContext *display_ctx,
* \param draw_flip: X/Y flipping (ignored when null).
* \param indicator_factor: Display a vertical indicator (ignored when -1).
*/
static void playanim_toscreen_ex(const PlayDisplayContext *display_ctx,
static void playanim_toscreen_ex(GHOST_WindowHandle ghost_window,
const PlayDisplayContext *display_ctx,
const PlayAnimPict *picture,
ImBuf *ibuf,
/* Run-time drawing arguments (not used on-load). */
@ -618,7 +623,7 @@ static void playanim_toscreen_ex(const PlayDisplayContext *display_ctx,
const bool draw_flip[2],
const float indicator_factor)
{
GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
GHOST_ActivateWindowDrawingContext(ghost_window);
GPU_clear_color(0.1f, 0.1f, 0.1f, 0.0f);
@ -667,7 +672,7 @@ static void playanim_toscreen_ex(const PlayDisplayContext *display_ctx,
SNPRINTF(label, "%s | <failed to load buffer>", picture->filepath);
}
playanim_window_get_size(&sizex, &sizey);
playanim_window_get_size(ghost_window, &sizex, &sizey);
fsizex_inv = 1.0f / sizex;
fsizey_inv = 1.0f / sizey;
@ -702,10 +707,11 @@ static void playanim_toscreen_ex(const PlayDisplayContext *display_ctx,
GPU_matrix_pop_projection();
}
GHOST_SwapWindowBuffers(g_WS.ghost_window);
GHOST_SwapWindowBuffers(ghost_window);
}
static void playanim_toscreen_on_load(const PlayDisplayContext *display_ctx,
static void playanim_toscreen_on_load(GHOST_WindowHandle ghost_window,
const PlayDisplayContext *display_ctx,
const PlayAnimPict *picture,
ImBuf *ibuf)
{
@ -716,7 +722,7 @@ static void playanim_toscreen_on_load(const PlayDisplayContext *display_ctx,
const bool *draw_flip = NULL;
playanim_toscreen_ex(
display_ctx, picture, ibuf, fstep, font_id, zoom, draw_flip, indicator_factor);
ghost_window, display_ctx, picture, ibuf, fstep, font_id, zoom, draw_flip, indicator_factor);
}
static void playanim_toscreen(PlayState *ps, const PlayAnimPict *picture, ImBuf *ibuf)
@ -728,7 +734,7 @@ static void playanim_toscreen(PlayState *ps, const PlayAnimPict *picture, ImBuf
}
int fontid = -1;
if ((g_WS.qual & (WS_QUAL_SHIFT | WS_QUAL_LMOUSE)) ||
if ((ps->ghost_data.qual & (WS_QUAL_SHIFT | WS_QUAL_LMOUSE)) ||
/* Always inform the user of an error, this should be an exceptional case. */
(ibuf == NULL))
{
@ -736,7 +742,8 @@ static void playanim_toscreen(PlayState *ps, const PlayAnimPict *picture, ImBuf
}
BLI_assert(ps->loading == false);
playanim_toscreen_ex(&ps->display_ctx,
playanim_toscreen_ex(ps->ghost_data.window,
&ps->display_ctx,
picture,
ibuf,
fontid,
@ -746,7 +753,8 @@ static void playanim_toscreen(PlayState *ps, const PlayAnimPict *picture, ImBuf
indicator_factor);
}
static void build_pict_list_from_anim(const PlayDisplayContext *display_ctx,
static void build_pict_list_from_anim(GhostData *ghost_data,
const PlayDisplayContext *display_ctx,
const char *filepath_first)
{
/* OCIO_TODO: support different input color space */
@ -758,7 +766,7 @@ static void build_pict_list_from_anim(const PlayDisplayContext *display_ctx,
ImBuf *ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
if (ibuf) {
playanim_toscreen_on_load(display_ctx, NULL, ibuf);
playanim_toscreen_on_load(ghost_data->window, display_ctx, NULL, ibuf);
IMB_freeImBuf(ibuf);
}
@ -772,7 +780,8 @@ static void build_pict_list_from_anim(const PlayDisplayContext *display_ctx,
}
}
static void build_pict_list_from_image_sequence(const PlayDisplayContext *display_ctx,
static void build_pict_list_from_image_sequence(GhostData *ghost_data,
const PlayDisplayContext *display_ctx,
const char *filepath_first,
const int totframes,
const int fstep,
@ -834,7 +843,7 @@ static void build_pict_list_from_image_sequence(const PlayDisplayContext *displa
if (ibuf) {
if (display_imbuf) {
playanim_toscreen_on_load(display_ctx, picture, ibuf);
playanim_toscreen_on_load(ghost_data->window, display_ctx, picture, ibuf);
}
#ifdef USE_FRAME_CACHE_LIMIT
if (fill_cache) {
@ -864,8 +873,8 @@ static void build_pict_list_from_image_sequence(const PlayDisplayContext *displa
fp_decoded.digits,
fp_framenr);
while (GHOST_ProcessEvents(g_WS.ghost_system, false)) {
GHOST_DispatchEvents(g_WS.ghost_system);
while (GHOST_ProcessEvents(ghost_data->system, false)) {
GHOST_DispatchEvents(ghost_data->system);
if (*loading_p == false) {
break;
}
@ -873,7 +882,8 @@ static void build_pict_list_from_image_sequence(const PlayDisplayContext *displa
}
}
static void build_pict_list(const PlayDisplayContext *display_ctx,
static void build_pict_list(struct GhostData *ghost_data,
const PlayDisplayContext *display_ctx,
const char *filepath_first,
const int totframes,
const int fstep,
@ -881,10 +891,11 @@ static void build_pict_list(const PlayDisplayContext *display_ctx,
{
*loading_p = true;
if (IMB_isanim(filepath_first)) {
build_pict_list_from_anim(display_ctx, filepath_first);
build_pict_list_from_anim(ghost_data, display_ctx, filepath_first);
}
else {
build_pict_list_from_image_sequence(display_ctx, filepath_first, totframes, fstep, loading_p);
build_pict_list_from_image_sequence(
ghost_data, display_ctx, filepath_first, totframes, fstep, loading_p);
}
*loading_p = false;
}
@ -920,7 +931,7 @@ static void change_frame(PlayState *ps)
return;
}
playanim_window_get_size(&sizex, &sizey);
playanim_window_get_size(ps->ghost_data.window, &sizex, &sizey);
i_last = ((PlayAnimPict *)picsbase.last)->frame;
i = (i_last * ps->frame_cursor_x) / sizex;
CLAMP(i, 0, i_last);
@ -973,10 +984,12 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
const GHOST_TEventType type = GHOST_GetEventType(evt);
/* Convert ghost event into value keyboard or mouse. */
const int val = ELEM(type, GHOST_kEventKeyDown, GHOST_kEventButtonDown);
GHOST_SystemHandle ghost_system = ps->ghost_data.system;
GHOST_WindowHandle ghost_window = ps->ghost_data.window;
// print_ps(ps);
playanim_event_qual_update();
playanim_event_qual_update(&ps->ghost_data);
/* first check if we're busy loading files */
if (ps->loading) {
@ -1034,7 +1047,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
break;
case GHOST_kKeyF: {
if (val) {
int axis = (g_WS.qual & WS_QUAL_SHIFT) ? 1 : 0;
int axis = (ps->ghost_data.qual & WS_QUAL_SHIFT) ? 1 : 0;
ps->draw_flip[axis] = !ps->draw_flip[axis];
}
break;
@ -1062,7 +1075,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
break;
case GHOST_kKey4:
case GHOST_kKeyNumpad4:
if (g_WS.qual & WS_QUAL_SHIFT) {
if (ps->ghost_data.qual & WS_QUAL_SHIFT) {
swaptime = ps->fstep / 24.0;
update_sound_fps();
}
@ -1110,7 +1123,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
if (val) {
ps->sstep = true;
ps->wait2 = false;
if (g_WS.qual & WS_QUAL_SHIFT) {
if (ps->ghost_data.qual & WS_QUAL_SHIFT) {
ps->picture = picsbase.first;
ps->next_frame = 0;
}
@ -1122,7 +1135,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
case GHOST_kKeyDownArrow:
if (val) {
ps->wait2 = false;
if (g_WS.qual & WS_QUAL_SHIFT) {
if (ps->ghost_data.qual & WS_QUAL_SHIFT) {
ps->next_frame = ps->direction = -1;
}
else {
@ -1135,7 +1148,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
if (val) {
ps->sstep = true;
ps->wait2 = false;
if (g_WS.qual & WS_QUAL_SHIFT) {
if (ps->ghost_data.qual & WS_QUAL_SHIFT) {
ps->picture = picsbase.last;
ps->next_frame = 0;
}
@ -1147,7 +1160,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
case GHOST_kKeyUpArrow:
if (val) {
ps->wait2 = false;
if (g_WS.qual & WS_QUAL_SHIFT) {
if (ps->ghost_data.qual & WS_QUAL_SHIFT) {
ps->next_frame = ps->direction = 1;
}
else {
@ -1160,7 +1173,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
case GHOST_kKeySlash:
case GHOST_kKeyNumpadSlash:
if (val) {
if (g_WS.qual & WS_QUAL_SHIFT) {
if (ps->ghost_data.qual & WS_QUAL_SHIFT) {
if (ps->picture && ps->picture->ibuf) {
printf(" Name: %s | Speed: %.2f frames/s\n",
ps->picture->ibuf->filepath,
@ -1273,7 +1286,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
if (val == 0) {
break;
}
if (g_WS.qual & WS_QUAL_CTRL) {
if (ps->ghost_data.qual & WS_QUAL_CTRL) {
playanim_window_zoom(ps, 0.1f);
}
else {
@ -1289,7 +1302,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
if (val == 0) {
break;
}
if (g_WS.qual & WS_QUAL_CTRL) {
if (ps->ghost_data.qual & WS_QUAL_CTRL) {
playanim_window_zoom(ps, -0.1f);
}
else {
@ -1313,46 +1326,46 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
GHOST_TEventButtonData *bd = GHOST_GetEventData(evt);
int cx, cy, sizex, sizey, inside_window;
GHOST_GetCursorPosition(g_WS.ghost_system, g_WS.ghost_window, &cx, &cy);
playanim_window_get_size(&sizex, &sizey);
GHOST_GetCursorPosition(ghost_system, ghost_window, &cx, &cy);
playanim_window_get_size(ghost_window, &sizex, &sizey);
inside_window = (cx >= 0 && cx < sizex && cy >= 0 && cy <= sizey);
if (bd->button == GHOST_kButtonMaskLeft) {
if (type == GHOST_kEventButtonDown) {
if (inside_window) {
g_WS.qual |= WS_QUAL_LMOUSE;
ps->ghost_data.qual |= WS_QUAL_LMOUSE;
tag_change_frame(ps, cx);
}
}
else {
g_WS.qual &= ~WS_QUAL_LMOUSE;
ps->ghost_data.qual &= ~WS_QUAL_LMOUSE;
}
}
else if (bd->button == GHOST_kButtonMaskMiddle) {
if (type == GHOST_kEventButtonDown) {
if (inside_window) {
g_WS.qual |= WS_QUAL_MMOUSE;
ps->ghost_data.qual |= WS_QUAL_MMOUSE;
}
}
else {
g_WS.qual &= ~WS_QUAL_MMOUSE;
ps->ghost_data.qual &= ~WS_QUAL_MMOUSE;
}
}
else if (bd->button == GHOST_kButtonMaskRight) {
if (type == GHOST_kEventButtonDown) {
if (inside_window) {
g_WS.qual |= WS_QUAL_RMOUSE;
ps->ghost_data.qual |= WS_QUAL_RMOUSE;
}
}
else {
g_WS.qual &= ~WS_QUAL_RMOUSE;
ps->ghost_data.qual &= ~WS_QUAL_RMOUSE;
}
}
break;
}
case GHOST_kEventCursorMove: {
if (g_WS.qual & WS_QUAL_LMOUSE) {
if (ps->ghost_data.qual & WS_QUAL_LMOUSE) {
GHOST_TEventCursorData *cd = GHOST_GetEventData(evt);
int cx, cy;
@ -1362,8 +1375,8 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
* however the API currently doesn't support this. */
{
int x_test, y_test;
GHOST_GetCursorPosition(g_WS.ghost_system, g_WS.ghost_window, &cx, &cy);
GHOST_ScreenToClient(g_WS.ghost_window, cd->x, cd->y, &x_test, &y_test);
GHOST_GetCursorPosition(ghost_system, ghost_window, &cx, &cy);
GHOST_ScreenToClient(ghost_window, cd->x, cd->y, &x_test, &y_test);
if (cx != x_test || cy != y_test) {
/* we're not the last event... skipping */
@ -1377,15 +1390,15 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
}
case GHOST_kEventWindowActivate:
case GHOST_kEventWindowDeactivate: {
g_WS.qual &= ~WS_QUAL_MOUSE;
ps->ghost_data.qual &= ~WS_QUAL_MOUSE;
break;
}
case GHOST_kEventWindowSize:
case GHOST_kEventWindowMove: {
float zoomx, zoomy;
playanim_window_get_size(&ps->display_ctx.size[0], &ps->display_ctx.size[1]);
GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
playanim_window_get_size(ghost_window, &ps->display_ctx.size[0], &ps->display_ctx.size[1]);
GHOST_ActivateWindowDrawingContext(ghost_window);
zoomx = (float)ps->display_ctx.size[0] / ps->ibufx;
zoomy = (float)ps->display_ctx.size[1] / ps->ibufy;
@ -1438,28 +1451,29 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
return true;
}
static void playanim_window_open(const char *title, int posx, int posy, int sizex, int sizey)
static GHOST_WindowHandle playanim_window_open(
GHOST_SystemHandle ghost_system, const char *title, int posx, int posy, int sizex, int sizey)
{
GHOST_GPUSettings gpusettings = {0};
const eGPUBackendType gpu_backend = GPU_backend_type_selection_get();
gpusettings.context_type = wm_ghost_drawing_context_type(gpu_backend);
uint32_t scr_w, scr_h;
GHOST_GetMainDisplayDimensions(g_WS.ghost_system, &scr_w, &scr_h);
GHOST_GetMainDisplayDimensions(ghost_system, &scr_w, &scr_h);
posy = (scr_h - posy - sizey);
g_WS.ghost_window = GHOST_CreateWindow(g_WS.ghost_system,
NULL,
title,
posx,
posy,
sizex,
sizey,
/* Could optionally start full-screen. */
GHOST_kWindowStateNormal,
false,
gpusettings);
return GHOST_CreateWindow(ghost_system,
NULL,
title,
posx,
posy,
sizex,
sizey,
/* Could optionally start full-screen. */
GHOST_kWindowStateNormal,
false,
gpusettings);
}
static void playanim_window_zoom(PlayState *ps, const float zoom_offset)
@ -1472,20 +1486,20 @@ static void playanim_window_zoom(PlayState *ps, const float zoom_offset)
}
// playanim_window_get_position(&ofsx, &ofsy);
playanim_window_get_size(&sizex, &sizey);
playanim_window_get_size(ps->ghost_data.window, &sizex, &sizey);
// ofsx += sizex / 2; /* UNUSED */
// ofsy += sizey / 2; /* UNUSED */
sizex = ps->zoom * ps->ibufx;
sizey = ps->zoom * ps->ibufy;
// ofsx -= sizex / 2; /* UNUSED */
// ofsy -= sizey / 2; /* UNUSED */
// window_set_position(g_WS.ghost_window, sizex, sizey);
GHOST_SetClientSize(g_WS.ghost_window, sizex, sizey);
// window_set_position(ps->ghost_data.window, sizex, sizey);
GHOST_SetClientSize(ps->ghost_data.window, sizex, sizey);
}
static bool playanim_window_font_scale_from_dpi(PlayState *ps)
{
const float scale = (GHOST_GetDPIHint(g_WS.ghost_window) / 96.0f);
const float scale = (GHOST_GetDPIHint(ps->ghost_data.window) / 96.0f);
const float font_size_base = 11.0f; /* Font size un-scaled. */
const int font_size = (int)(font_size_base * scale) + 0.5f;
if (ps->font_size != font_size) {
@ -1649,31 +1663,31 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
}
{
GHOST_EventConsumerHandle consumer = GHOST_CreateEventConsumer(ghost_event_proc, &ps);
GHOST_SetBacktraceHandler((GHOST_TBacktraceFn)BLI_system_backtrace);
g_WS.ghost_system = GHOST_CreateSystem();
ps.ghost_data.system = GHOST_CreateSystem();
if (UNLIKELY(g_WS.ghost_system == NULL)) {
if (UNLIKELY(ps.ghost_data.system == NULL)) {
/* GHOST will have reported the back-ends that failed to load. */
CLOG_WARN(&LOG, "GHOST: unable to initialize, exiting!");
/* This will leak memory, it's preferable to crashing. */
exit(EXIT_FAILURE);
}
GHOST_AddEventConsumer(g_WS.ghost_system, consumer);
GHOST_AddEventConsumer(ps.ghost_data.system, consumer);
playanim_window_open("Blender Animation Player", start_x, start_y, ibuf->x, ibuf->y);
ps.ghost_data.window = playanim_window_open(
ps.ghost_data.system, "Blender Animation Player", start_x, start_y, ibuf->x, ibuf->y);
}
GHOST_GetMainDisplayDimensions(g_WS.ghost_system, &maxwinx, &maxwiny);
GHOST_GetMainDisplayDimensions(ps.ghost_data.system, &maxwinx, &maxwiny);
// GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
// GHOST_ActivateWindowDrawingContext(ps.ghost_data.window);
/* initialize OpenGL immediate mode */
g_WS.blender_gpu_context = GPU_context_create(g_WS.ghost_window, NULL);
/* Initialize OpenGL immediate mode. */
ps.ghost_data.gpu_context = GPU_context_create(ps.ghost_data.window, NULL);
GPU_init();
/* initialize the font */
@ -1700,13 +1714,13 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
{
int window_size[2];
playanim_window_get_size(&window_size[0], &window_size[1]);
playanim_window_get_size(ps.ghost_data.window, &window_size[0], &window_size[1]);
GPU_viewport(0, 0, window_size[0], window_size[1]);
GPU_scissor(0, 0, window_size[0], window_size[1]);
playanim_gl_matrix();
}
GHOST_SwapWindowBuffers(g_WS.ghost_window);
GHOST_SwapWindowBuffers(ps.ghost_data.window);
if (sfra == -1 || efra == -1) {
/* one of the frames was invalid, just use all images */
@ -1714,7 +1728,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
efra = MAXFRAME;
}
build_pict_list(&ps.display_ctx, filepath, (efra - sfra) + 1, ps.fstep, &ps.loading);
build_pict_list(
&ps.ghost_data, &ps.display_ctx, filepath, (efra - sfra) + 1, ps.fstep, &ps.loading);
#ifdef WITH_AUDASPACE
source = AUD_Sound_file(filepath);
@ -1735,7 +1750,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
for (i = 2; i < argc; i++) {
STRNCPY(filepath, argv[i]);
build_pict_list(&ps.display_ctx, filepath, (efra - sfra) + 1, ps.fstep, &ps.loading);
build_pict_list(
&ps.ghost_data, &ps.display_ctx, filepath, (efra - sfra) + 1, ps.fstep, &ps.loading);
}
IMB_freeImBuf(ibuf);
@ -1813,7 +1829,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
/* why only windows? (from 2.4x) - campbell */
#ifdef _WIN32
GHOST_SetTitle(g_WS.ghost_window, ps.picture->filepath);
GHOST_SetTitle(ps.ghost_data.window, ps.picture->filepath);
#endif
while (pupdate_time()) {
@ -1834,8 +1850,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
ps.next_frame = ps.direction;
while ((has_event = GHOST_ProcessEvents(g_WS.ghost_system, false))) {
GHOST_DispatchEvents(g_WS.ghost_system);
while ((has_event = GHOST_ProcessEvents(ps.ghost_data.system, false))) {
GHOST_DispatchEvents(ps.ghost_data.system);
}
if (ps.go == false) {
break;
@ -1939,14 +1955,14 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
BLF_exit();
if (g_WS.blender_gpu_context) {
GPU_context_active_set(g_WS.blender_gpu_context);
if (ps.ghost_data.gpu_context) {
GPU_context_active_set(ps.ghost_data.gpu_context);
GPU_exit();
GPU_context_discard(g_WS.blender_gpu_context);
g_WS.blender_gpu_context = NULL;
GPU_context_discard(ps.ghost_data.gpu_context);
ps.ghost_data.gpu_context = NULL;
}
GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window);
GHOST_DisposeWindow(ps.ghost_data.system, ps.ghost_data.window);
/* early exit, IMB and BKE should be exited only in end */
if (ps.dropped_file[0]) {