WIP: use generic copy-on-write system to avoid unnecessary data copies #104470
|
@ -464,12 +464,17 @@ void GHOST_NDOFManager::updateButton(int button_number, bool press, uint64_t tim
|
|||
ndof_button_names[button]);
|
||||
|
||||
GHOST_IWindow *window = system_.getWindowManager()->getActiveWindow();
|
||||
const GHOST_TKey key = ghost_map_keyboard_from_ndof_buttom(button);
|
||||
if (key != GHOST_kKeyUnknown) {
|
||||
sendKeyEvent(key, press, time, window);
|
||||
}
|
||||
else {
|
||||
sendButtonEvent(button, press, time, window);
|
||||
|
||||
/* Delivery will fail, so don't bother sending.
|
||||
* Do, however update the buttons internal depressed state. */
|
||||
if (window != nullptr) {
|
||||
const GHOST_TKey key = ghost_map_keyboard_from_ndof_buttom(button);
|
||||
if (key != GHOST_kKeyUnknown) {
|
||||
sendKeyEvent(key, press, time, window);
|
||||
}
|
||||
else {
|
||||
sendButtonEvent(button, press, time, window);
|
||||
}
|
||||
}
|
||||
|
||||
int mask = 1 << button_number;
|
||||
|
@ -547,9 +552,11 @@ bool GHOST_NDOFManager::sendMotionEvent()
|
|||
|
||||
GHOST_IWindow *window = system_.getWindowManager()->getActiveWindow();
|
||||
|
||||
/* Delivery will fail, so don't bother sending. */
|
||||
if (window == nullptr) {
|
||||
motion_state_ = GHOST_kNotStarted; /* Avoid large `dt` times when changing windows. */
|
||||
return false; /* Delivery will fail, so don't bother sending. */
|
||||
/* Avoid large `dt` times when changing windows. */
|
||||
motion_state_ = GHOST_kNotStarted;
|
||||
return false;
|
||||
}
|
||||
|
||||
GHOST_EventNDOFMotion *event = new GHOST_EventNDOFMotion(motion_time_, window);
|
||||
|
|
|
@ -2586,8 +2586,6 @@ static void pointer_handle_enter(void *data,
|
|||
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface);
|
||||
|
||||
win->activate();
|
||||
|
||||
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
|
||||
seat->cursor_source_serial = serial;
|
||||
seat->pointer.serial = serial;
|
||||
|
@ -2627,8 +2625,6 @@ static void pointer_handle_leave(void *data,
|
|||
static_cast<GWL_Seat *>(data)->pointer.wl_surface_window = nullptr;
|
||||
if (wl_surface && ghost_wl_surface_own(wl_surface)) {
|
||||
CLOG_INFO(LOG, 2, "leave");
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface);
|
||||
win->deactivate();
|
||||
}
|
||||
else {
|
||||
CLOG_INFO(LOG, 2, "leave (skipped)");
|
||||
|
|
|
@ -5332,7 +5332,10 @@ class VIEW3D_MT_edit_curves(Menu):
|
|||
bl_label = "Curves"
|
||||
|
||||
def draw(self, _context):
|
||||
pass
|
||||
layout = self.layout
|
||||
|
||||
layout.menu("VIEW3D_MT_transform")
|
||||
layout.separator()
|
||||
|
||||
|
||||
class VIEW3D_MT_object_mode_pie(Menu):
|
||||
|
|
|
@ -89,7 +89,7 @@ set(SRC
|
|||
intern/cachefile.c
|
||||
intern/callbacks.c
|
||||
intern/camera.c
|
||||
intern/cdderivedmesh.c
|
||||
intern/cdderivedmesh.cc
|
||||
intern/cloth.cc
|
||||
intern/collection.c
|
||||
intern/collision.c
|
||||
|
@ -119,9 +119,9 @@ set(SRC
|
|||
intern/customdata.cc
|
||||
intern/customdata_file.c
|
||||
intern/data_transfer.cc
|
||||
intern/deform.c
|
||||
intern/deform.cc
|
||||
intern/displist.cc
|
||||
intern/dynamicpaint.c
|
||||
intern/dynamicpaint.cc
|
||||
intern/editlattice.c
|
||||
intern/editmesh.cc
|
||||
intern/editmesh_bvh.c
|
||||
|
@ -131,7 +131,7 @@ set(SRC
|
|||
intern/fcurve.c
|
||||
intern/fcurve_cache.c
|
||||
intern/fcurve_driver.c
|
||||
intern/fluid.c
|
||||
intern/fluid.cc
|
||||
intern/fmodifier.c
|
||||
intern/freestyle.c
|
||||
intern/geometry_component_curves.cc
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
* BKE_cdderivedmesh.h contains the function prototypes for this file.
|
||||
*/
|
||||
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "atomic_ops.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
|
@ -29,11 +33,7 @@
|
|||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
struct CDDerivedMesh {
|
||||
DerivedMesh dm;
|
||||
|
||||
/* these point to data in the DerivedMesh custom data layers,
|
||||
|
@ -52,7 +52,7 @@ typedef struct {
|
|||
/* Mesh connectivity */
|
||||
MeshElemMap *pmap;
|
||||
int *pmap_mem;
|
||||
} CDDerivedMesh;
|
||||
};
|
||||
|
||||
/**************** DerivedMesh interface functions ****************/
|
||||
static int cdDM_getNumVerts(DerivedMesh *dm)
|
||||
|
@ -157,11 +157,8 @@ static void cdDM_release(DerivedMesh *dm)
|
|||
/**************** CDDM interface functions ****************/
|
||||
static CDDerivedMesh *cdDM_create(const char *desc)
|
||||
{
|
||||
CDDerivedMesh *cddm;
|
||||
DerivedMesh *dm;
|
||||
|
||||
cddm = MEM_callocN(sizeof(*cddm), desc);
|
||||
dm = &cddm->dm;
|
||||
CDDerivedMesh *cddm = MEM_cnew<CDDerivedMesh>(desc);
|
||||
DerivedMesh *dm = &cddm->dm;
|
||||
|
||||
dm->getNumVerts = cdDM_getNumVerts;
|
||||
dm->getNumEdges = cdDM_getNumEdges;
|
||||
|
@ -218,14 +215,17 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh, const CustomData_MeshMasks *ma
|
|||
CustomData_merge(&mesh->ldata, &dm->loopData, cddata_masks.lmask, mesh->totloop);
|
||||
CustomData_merge(&mesh->pdata, &dm->polyData, cddata_masks.pmask, mesh->totpoly);
|
||||
|
||||
cddm->vert_positions = CustomData_get_layer_named_for_write(
|
||||
&dm->vertData, CD_PROP_FLOAT3, "position", mesh->totvert);
|
||||
cddm->vert_positions = static_cast<float(*)[3]>(CustomData_get_layer_named_for_write(
|
||||
&dm->vertData, CD_PROP_FLOAT3, "position", mesh->totvert));
|
||||
/* Though this may be an unnecessary calculation, simply retrieving the layer may return nothing
|
||||
* or dirty normals. */
|
||||
cddm->vert_normals = BKE_mesh_vertex_normals_ensure(mesh);
|
||||
cddm->medge = CustomData_get_layer_for_write(&dm->edgeData, CD_MEDGE, mesh->totedge);
|
||||
cddm->mloop = CustomData_get_layer_for_write(&dm->loopData, CD_MLOOP, mesh->totloop);
|
||||
cddm->mpoly = CustomData_get_layer_for_write(&dm->polyData, CD_MPOLY, mesh->totpoly);
|
||||
cddm->medge = static_cast<MEdge *>(
|
||||
CustomData_get_layer_for_write(&dm->edgeData, CD_MEDGE, mesh->totedge));
|
||||
cddm->mloop = static_cast<MLoop *>(
|
||||
CustomData_get_layer_for_write(&dm->loopData, CD_MLOOP, mesh->totloop));
|
||||
cddm->mpoly = static_cast<MPoly *>(
|
||||
CustomData_get_layer_for_write(&dm->polyData, CD_MPOLY, mesh->totpoly));
|
||||
#if 0
|
||||
cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE);
|
||||
#else
|
|
@ -5,11 +5,11 @@
|
|||
* \ingroup bke
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
@ -46,7 +46,7 @@ bDeformGroup *BKE_object_defgroup_new(Object *ob, const char *name)
|
|||
|
||||
BLI_assert(OB_TYPE_SUPPORT_VGROUP(ob->type));
|
||||
|
||||
defgroup = MEM_callocN(sizeof(bDeformGroup), __func__);
|
||||
defgroup = MEM_cnew<bDeformGroup>(__func__);
|
||||
|
||||
BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
|
||||
|
||||
|
@ -62,31 +62,26 @@ bDeformGroup *BKE_object_defgroup_new(Object *ob, const char *name)
|
|||
|
||||
void BKE_defgroup_copy_list(ListBase *outbase, const ListBase *inbase)
|
||||
{
|
||||
bDeformGroup *defgroup, *defgroupn;
|
||||
|
||||
BLI_listbase_clear(outbase);
|
||||
|
||||
for (defgroup = inbase->first; defgroup; defgroup = defgroup->next) {
|
||||
defgroupn = BKE_defgroup_duplicate(defgroup);
|
||||
LISTBASE_FOREACH (const bDeformGroup *, defgroup, inbase) {
|
||||
bDeformGroup *defgroupn = BKE_defgroup_duplicate(defgroup);
|
||||
BLI_addtail(outbase, defgroupn);
|
||||
}
|
||||
}
|
||||
|
||||
bDeformGroup *BKE_defgroup_duplicate(const bDeformGroup *ingroup)
|
||||
{
|
||||
bDeformGroup *outgroup;
|
||||
|
||||
if (!ingroup) {
|
||||
BLI_assert(0);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
outgroup = MEM_callocN(sizeof(bDeformGroup), "copy deformGroup");
|
||||
bDeformGroup *outgroup = MEM_cnew<bDeformGroup>(__func__);
|
||||
|
||||
/* For now, just copy everything over. */
|
||||
memcpy(outgroup, ingroup, sizeof(bDeformGroup));
|
||||
|
||||
outgroup->next = outgroup->prev = NULL;
|
||||
outgroup->next = outgroup->prev = nullptr;
|
||||
|
||||
return outgroup;
|
||||
}
|
||||
|
@ -132,10 +127,10 @@ void BKE_defvert_copy(MDeformVert *dvert_dst, const MDeformVert *dvert_src)
|
|||
}
|
||||
|
||||
if (dvert_src->totweight) {
|
||||
dvert_dst->dw = MEM_dupallocN(dvert_src->dw);
|
||||
dvert_dst->dw = static_cast<MDeformWeight *>(MEM_dupallocN(dvert_src->dw));
|
||||
}
|
||||
else {
|
||||
dvert_dst->dw = NULL;
|
||||
dvert_dst->dw = nullptr;
|
||||
}
|
||||
|
||||
dvert_dst->totweight = dvert_src->totweight;
|
||||
|
@ -157,7 +152,7 @@ void BKE_defvert_copy_index(MDeformVert *dvert_dst,
|
|||
dw_dst->weight = dw_src->weight;
|
||||
}
|
||||
else {
|
||||
/* Source was NULL, assign zero (could also remove). */
|
||||
/* Source was nullptr, assign zero (could also remove). */
|
||||
dw_dst = BKE_defvert_find_index(dvert_dst, defgroup_dst);
|
||||
|
||||
if (dw_dst) {
|
||||
|
@ -307,7 +302,7 @@ void BKE_defvert_normalize_lock_single(MDeformVert *dvert,
|
|||
}
|
||||
}
|
||||
else {
|
||||
MDeformWeight *dw_lock = NULL;
|
||||
MDeformWeight *dw_lock = nullptr;
|
||||
MDeformWeight *dw;
|
||||
uint i;
|
||||
float tot_weight = 0.0f;
|
||||
|
@ -423,7 +418,7 @@ void BKE_defvert_flip_merged(MDeformVert *dvert, const int *flip_map, const int
|
|||
for (dw = dvert->dw, i = 0; i < totweight; dw++, i++) {
|
||||
if (dw->def_nr < flip_map_num) {
|
||||
if (flip_map[dw->def_nr] >= 0) {
|
||||
/* error checkers complain of this but we'll never get NULL return */
|
||||
/* error checkers complain of this but we'll never get nullptr return */
|
||||
dw_cpy = BKE_defvert_ensure_index(dvert, flip_map[dw->def_nr]);
|
||||
dw = &dvert->dw[i]; /* in case array got realloced */
|
||||
|
||||
|
@ -441,7 +436,7 @@ void BKE_defvert_flip_merged(MDeformVert *dvert, const int *flip_map, const int
|
|||
bool BKE_object_supports_vertex_groups(const Object *ob)
|
||||
{
|
||||
const ID *id = (const ID *)ob->data;
|
||||
if (id == NULL) {
|
||||
if (id == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -467,7 +462,7 @@ const ListBase *BKE_id_defgroup_list_get(const ID *id)
|
|||
BLI_assert_unreachable();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const int *object_defgroup_active_index_get_p(const Object *ob)
|
||||
|
@ -487,7 +482,7 @@ static const int *object_defgroup_active_index_get_p(const Object *ob)
|
|||
return &gpd->vertex_group_active_index;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ListBase *BKE_id_defgroup_list_get_mutable(ID *id)
|
||||
|
@ -498,38 +493,38 @@ ListBase *BKE_id_defgroup_list_get_mutable(ID *id)
|
|||
|
||||
bDeformGroup *BKE_object_defgroup_find_name(const Object *ob, const char *name)
|
||||
{
|
||||
if (name == NULL || name[0] == '\0') {
|
||||
return NULL;
|
||||
if (name == nullptr || name[0] == '\0') {
|
||||
return nullptr;
|
||||
}
|
||||
const ListBase *defbase = BKE_object_defgroup_list(ob);
|
||||
return BLI_findstring(defbase, name, offsetof(bDeformGroup, name));
|
||||
return static_cast<bDeformGroup *>(BLI_findstring(defbase, name, offsetof(bDeformGroup, name)));
|
||||
}
|
||||
|
||||
int BKE_id_defgroup_name_index(const ID *id, const char *name)
|
||||
{
|
||||
int index;
|
||||
if (!BKE_id_defgroup_name_find(id, name, &index, NULL)) {
|
||||
if (!BKE_id_defgroup_name_find(id, name, &index, nullptr)) {
|
||||
return -1;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
bool BKE_id_defgroup_name_find(const struct ID *id,
|
||||
bool BKE_id_defgroup_name_find(const ID *id,
|
||||
const char *name,
|
||||
int *r_index,
|
||||
struct bDeformGroup **r_group)
|
||||
bDeformGroup **r_group)
|
||||
{
|
||||
if (name == NULL || name[0] == '\0') {
|
||||
if (name == nullptr || name[0] == '\0') {
|
||||
return false;
|
||||
}
|
||||
const ListBase *defbase = BKE_id_defgroup_list_get(id);
|
||||
int index;
|
||||
LISTBASE_FOREACH_INDEX (bDeformGroup *, group, defbase, index) {
|
||||
if (STREQ(name, group->name)) {
|
||||
if (r_index != NULL) {
|
||||
if (r_index != nullptr) {
|
||||
*r_index = index;
|
||||
}
|
||||
if (r_group != NULL) {
|
||||
if (r_group != nullptr) {
|
||||
*r_group = group;
|
||||
}
|
||||
return true;
|
||||
|
@ -582,19 +577,19 @@ static int *object_defgroup_unlocked_flip_map_ex(const Object *ob,
|
|||
*r_flip_map_num = defbase_num;
|
||||
|
||||
if (defbase_num == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bDeformGroup *dg;
|
||||
char name_flip[sizeof(dg->name)];
|
||||
int i, flip_num;
|
||||
int *map = MEM_mallocN(defbase_num * sizeof(int), __func__);
|
||||
int *map = static_cast<int *>(MEM_mallocN(defbase_num * sizeof(int), __func__));
|
||||
|
||||
for (i = 0; i < defbase_num; i++) {
|
||||
map[i] = -1;
|
||||
}
|
||||
|
||||
for (dg = defbase->first, i = 0; dg; dg = dg->next, i++) {
|
||||
for (dg = static_cast<bDeformGroup *>(defbase->first), i = 0; dg; dg = dg->next, i++) {
|
||||
if (map[i] == -1) { /* may be calculated previously */
|
||||
|
||||
/* in case no valid value is found, use this */
|
||||
|
@ -642,18 +637,17 @@ int *BKE_object_defgroup_flip_map_single(const Object *ob,
|
|||
*r_flip_map_num = defbase_num;
|
||||
|
||||
if (defbase_num == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bDeformGroup *dg;
|
||||
char name_flip[sizeof(dg->name)];
|
||||
int i, flip_num, *map = MEM_mallocN(defbase_num * sizeof(int), __func__);
|
||||
char name_flip[sizeof(bDeformGroup::name)];
|
||||
int i, flip_num, *map = static_cast<int *>(MEM_mallocN(defbase_num * sizeof(int), __func__));
|
||||
|
||||
for (i = 0; i < defbase_num; i++) {
|
||||
map[i] = use_default ? i : -1;
|
||||
}
|
||||
|
||||
dg = BLI_findlink(defbase, defgroup);
|
||||
bDeformGroup *dg = static_cast<bDeformGroup *>(BLI_findlink(defbase, defgroup));
|
||||
|
||||
BLI_string_flip_side_name(name_flip, dg->name, false, sizeof(name_flip));
|
||||
if (!STREQ(name_flip, dg->name)) {
|
||||
|
@ -671,7 +665,7 @@ int *BKE_object_defgroup_flip_map_single(const Object *ob,
|
|||
int BKE_object_defgroup_flip_index(const Object *ob, int index, const bool use_default)
|
||||
{
|
||||
const ListBase *defbase = BKE_object_defgroup_list(ob);
|
||||
bDeformGroup *dg = BLI_findlink(defbase, index);
|
||||
bDeformGroup *dg = static_cast<bDeformGroup *>(BLI_findlink(defbase, index));
|
||||
int flip_index = -1;
|
||||
|
||||
if (dg) {
|
||||
|
@ -691,7 +685,7 @@ static bool defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object *
|
|||
const ListBase *defbase = BKE_object_defgroup_list(ob);
|
||||
bDeformGroup *curdef;
|
||||
|
||||
for (curdef = defbase->first; curdef; curdef = curdef->next) {
|
||||
for (curdef = static_cast<bDeformGroup *>(defbase->first); curdef; curdef = curdef->next) {
|
||||
if (dg != curdef) {
|
||||
if (STREQ(curdef->name, name)) {
|
||||
return true;
|
||||
|
@ -702,46 +696,42 @@ static bool defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object *
|
|||
return false;
|
||||
}
|
||||
|
||||
struct DeformGroupUniqueNameData {
|
||||
Object *ob;
|
||||
bDeformGroup *dg;
|
||||
};
|
||||
|
||||
static bool defgroup_unique_check(void *arg, const char *name)
|
||||
{
|
||||
struct {
|
||||
Object *ob;
|
||||
void *dg;
|
||||
} *data = arg;
|
||||
DeformGroupUniqueNameData *data = static_cast<DeformGroupUniqueNameData *>(arg);
|
||||
return defgroup_find_name_dupe(name, data->dg, data->ob);
|
||||
}
|
||||
|
||||
void BKE_object_defgroup_unique_name(bDeformGroup *dg, Object *ob)
|
||||
{
|
||||
struct {
|
||||
Object *ob;
|
||||
void *dg;
|
||||
} data;
|
||||
data.ob = ob;
|
||||
data.dg = dg;
|
||||
|
||||
DeformGroupUniqueNameData data{ob, dg};
|
||||
BLI_uniquename_cb(defgroup_unique_check, &data, DATA_("Group"), '.', dg->name, sizeof(dg->name));
|
||||
}
|
||||
|
||||
float BKE_defvert_find_weight(const struct MDeformVert *dvert, const int defgroup)
|
||||
float BKE_defvert_find_weight(const MDeformVert *dvert, const int defgroup)
|
||||
{
|
||||
MDeformWeight *dw = BKE_defvert_find_index(dvert, defgroup);
|
||||
return dw ? dw->weight : 0.0f;
|
||||
}
|
||||
|
||||
float BKE_defvert_array_find_weight_safe(const struct MDeformVert *dvert,
|
||||
float BKE_defvert_array_find_weight_safe(const MDeformVert *dvert,
|
||||
const int index,
|
||||
const int defgroup)
|
||||
{
|
||||
/* Invalid defgroup index means the vgroup selected is invalid,
|
||||
* does not exist, in that case it is OK to return 1.0
|
||||
* (i.e. maximum weight, as if no vgroup was selected).
|
||||
* But in case of valid defgroup and NULL dvert data pointer, it means that vgroup **is** valid,
|
||||
* and just totally empty, so we shall return '0.0' value then! */
|
||||
* But in case of valid defgroup and nullptr dvert data pointer, it means that vgroup **is**
|
||||
* valid, and just totally empty, so we shall return '0.0' value then! */
|
||||
if (defgroup == -1) {
|
||||
return 1.0f;
|
||||
}
|
||||
if (dvert == NULL) {
|
||||
if (dvert == nullptr) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
@ -764,7 +754,7 @@ MDeformWeight *BKE_defvert_find_index(const MDeformVert *dvert, const int defgro
|
|||
BLI_assert(0);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MDeformWeight *BKE_defvert_ensure_index(MDeformVert *dvert, const int defgroup)
|
||||
|
@ -774,7 +764,7 @@ MDeformWeight *BKE_defvert_ensure_index(MDeformVert *dvert, const int defgroup)
|
|||
/* do this check always, this function is used to check for it */
|
||||
if (!dvert || defgroup < 0) {
|
||||
BLI_assert(0);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dw_new = BKE_defvert_find_index(dvert, defgroup);
|
||||
|
@ -782,7 +772,8 @@ MDeformWeight *BKE_defvert_ensure_index(MDeformVert *dvert, const int defgroup)
|
|||
return dw_new;
|
||||
}
|
||||
|
||||
dw_new = MEM_mallocN(sizeof(MDeformWeight) * (dvert->totweight + 1), "deformWeight");
|
||||
dw_new = static_cast<MDeformWeight *>(
|
||||
MEM_mallocN(sizeof(MDeformWeight) * (dvert->totweight + 1), __func__));
|
||||
if (dvert->dw) {
|
||||
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
|
||||
MEM_freeN(dvert->dw);
|
||||
|
@ -810,8 +801,8 @@ void BKE_defvert_add_index_notest(MDeformVert *dvert, const int defgroup, const
|
|||
return;
|
||||
}
|
||||
|
||||
dw_new = MEM_callocN(sizeof(MDeformWeight) * (dvert->totweight + 1),
|
||||
"defvert_add_to group, new deformWeight");
|
||||
dw_new = static_cast<MDeformWeight *>(
|
||||
MEM_callocN(sizeof(MDeformWeight) * (dvert->totweight + 1), __func__));
|
||||
if (dvert->dw) {
|
||||
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
|
||||
MEM_freeN(dvert->dw);
|
||||
|
@ -838,18 +829,19 @@ void BKE_defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw)
|
|||
* this deform weight, and reshuffle the others.
|
||||
*/
|
||||
if (dvert->totweight) {
|
||||
BLI_assert(dvert->dw != NULL);
|
||||
BLI_assert(dvert->dw != nullptr);
|
||||
|
||||
if (i != dvert->totweight) {
|
||||
dvert->dw[i] = dvert->dw[dvert->totweight];
|
||||
}
|
||||
|
||||
dvert->dw = MEM_reallocN(dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
|
||||
dvert->dw = static_cast<MDeformWeight *>(
|
||||
MEM_reallocN(dvert->dw, sizeof(MDeformWeight) * dvert->totweight));
|
||||
}
|
||||
else {
|
||||
/* If there are no other deform weights left then just remove this one. */
|
||||
MEM_freeN(dvert->dw);
|
||||
dvert->dw = NULL;
|
||||
dvert->dw = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -877,7 +869,7 @@ int BKE_defvert_find_shared(const MDeformVert *dvert_a, const MDeformVert *dvert
|
|||
return -1;
|
||||
}
|
||||
|
||||
bool BKE_defvert_is_weight_zero(const struct MDeformVert *dvert, const int defgroup_tot)
|
||||
bool BKE_defvert_is_weight_zero(const MDeformVert *dvert, const int defgroup_tot)
|
||||
{
|
||||
MDeformWeight *dw = dvert->dw;
|
||||
for (int i = dvert->totweight; i != 0; i--, dw++) {
|
||||
|
@ -891,14 +883,14 @@ bool BKE_defvert_is_weight_zero(const struct MDeformVert *dvert, const int defgr
|
|||
return true;
|
||||
}
|
||||
|
||||
float BKE_defvert_total_selected_weight(const struct MDeformVert *dv,
|
||||
float BKE_defvert_total_selected_weight(const MDeformVert *dv,
|
||||
int defbase_num,
|
||||
const bool *defbase_sel)
|
||||
{
|
||||
float total = 0.0f;
|
||||
const MDeformWeight *dw = dv->dw;
|
||||
|
||||
if (defbase_sel == NULL) {
|
||||
if (defbase_sel == nullptr) {
|
||||
return total;
|
||||
}
|
||||
|
||||
|
@ -913,7 +905,7 @@ float BKE_defvert_total_selected_weight(const struct MDeformVert *dv,
|
|||
return total;
|
||||
}
|
||||
|
||||
float BKE_defvert_multipaint_collective_weight(const struct MDeformVert *dv,
|
||||
float BKE_defvert_multipaint_collective_weight(const MDeformVert *dv,
|
||||
const int defbase_num,
|
||||
const bool *defbase_sel,
|
||||
const int defbase_sel_num,
|
||||
|
@ -959,7 +951,7 @@ float BKE_defvert_calc_lock_relative_weight(float weight,
|
|||
}
|
||||
|
||||
float BKE_defvert_lock_relative_weight(const float weight,
|
||||
const struct MDeformVert *dv,
|
||||
const MDeformVert *dv,
|
||||
const int defbase_num,
|
||||
const bool *defbase_locked,
|
||||
const bool *defbase_unlocked)
|
||||
|
@ -991,7 +983,8 @@ void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int totver
|
|||
|
||||
for (int i = 0; i < totvert; i++) {
|
||||
if (src[i].dw) {
|
||||
dst[i].dw = MEM_mallocN(sizeof(MDeformWeight) * src[i].totweight, "copy_deformWeight");
|
||||
dst[i].dw = static_cast<MDeformWeight *>(
|
||||
MEM_mallocN(sizeof(MDeformWeight) * src[i].totweight, __func__));
|
||||
memcpy(dst[i].dw, src[i].dw, sizeof(MDeformWeight) * src[i].totweight);
|
||||
}
|
||||
}
|
||||
|
@ -1059,7 +1052,8 @@ void BKE_defvert_extract_vgroup_to_edgeweights(const MDeformVert *dvert,
|
|||
{
|
||||
if (dvert && defgroup != -1) {
|
||||
int i = edges_num;
|
||||
float *tmp_weights = MEM_mallocN(sizeof(*tmp_weights) * (size_t)verts_num, __func__);
|
||||
float *tmp_weights = static_cast<float *>(
|
||||
MEM_mallocN(sizeof(*tmp_weights) * (size_t)verts_num, __func__));
|
||||
|
||||
BKE_defvert_extract_vgroup_to_vertweights(
|
||||
dvert, defgroup, verts_num, invert_vgroup, tmp_weights);
|
||||
|
@ -1087,7 +1081,8 @@ void BKE_defvert_extract_vgroup_to_loopweights(const MDeformVert *dvert,
|
|||
{
|
||||
if (dvert && defgroup != -1) {
|
||||
int i = loops_num;
|
||||
float *tmp_weights = MEM_mallocN(sizeof(*tmp_weights) * (size_t)verts_num, __func__);
|
||||
float *tmp_weights = static_cast<float *>(
|
||||
MEM_mallocN(sizeof(*tmp_weights) * (size_t)verts_num, __func__));
|
||||
|
||||
BKE_defvert_extract_vgroup_to_vertweights(
|
||||
dvert, defgroup, verts_num, invert_vgroup, tmp_weights);
|
||||
|
@ -1109,7 +1104,7 @@ void BKE_defvert_extract_vgroup_to_polyweights(const MDeformVert *dvert,
|
|||
const int defgroup,
|
||||
const int verts_num,
|
||||
const MLoop *loops,
|
||||
const int UNUSED(loops_num),
|
||||
const int /*loops_num*/,
|
||||
const MPoly *polys,
|
||||
const int polys_num,
|
||||
const bool invert_vgroup,
|
||||
|
@ -1117,7 +1112,8 @@ void BKE_defvert_extract_vgroup_to_polyweights(const MDeformVert *dvert,
|
|||
{
|
||||
if (dvert && defgroup != -1) {
|
||||
int i = polys_num;
|
||||
float *tmp_weights = MEM_mallocN(sizeof(*tmp_weights) * (size_t)verts_num, __func__);
|
||||
float *tmp_weights = static_cast<float *>(
|
||||
MEM_mallocN(sizeof(*tmp_weights) * (size_t)verts_num, __func__));
|
||||
|
||||
BKE_defvert_extract_vgroup_to_vertweights(
|
||||
dvert, defgroup, verts_num, invert_vgroup, tmp_weights);
|
||||
|
@ -1131,7 +1127,7 @@ void BKE_defvert_extract_vgroup_to_polyweights(const MDeformVert *dvert,
|
|||
for (; j--; ml++) {
|
||||
w += tmp_weights[ml->v];
|
||||
}
|
||||
r_weights[i] = w / (float)mp->totloop;
|
||||
r_weights[i] = w / float(mp->totloop);
|
||||
}
|
||||
|
||||
MEM_freeN(tmp_weights);
|
||||
|
@ -1217,9 +1213,9 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||
Object *ob_dst,
|
||||
const MDeformVert *data_src,
|
||||
MDeformVert *data_dst,
|
||||
const CustomData *UNUSED(cd_src),
|
||||
const CustomData * /*cd_src*/,
|
||||
CustomData *cd_dst,
|
||||
const bool UNUSED(use_dupref_dst),
|
||||
const bool /*use_dupref_dst*/,
|
||||
const int tolayers,
|
||||
const bool *use_layers_src,
|
||||
const int num_layers_src)
|
||||
|
@ -1231,7 +1227,7 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||
|
||||
const int tot_dst = BLI_listbase_count(dst_defbase);
|
||||
|
||||
const size_t elem_size = sizeof(*((MDeformVert *)NULL));
|
||||
const size_t elem_size = sizeof(*((MDeformVert *)nullptr));
|
||||
|
||||
switch (tolayers) {
|
||||
case DT_LAYERS_INDEX_DST:
|
||||
|
@ -1258,14 +1254,15 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||
}
|
||||
else if (use_delete && idx_dst > idx_src) {
|
||||
while (idx_dst-- > idx_src) {
|
||||
BKE_object_defgroup_remove(ob_dst, dst_defbase->last);
|
||||
BKE_object_defgroup_remove(ob_dst, static_cast<bDeformGroup *>(dst_defbase->last));
|
||||
}
|
||||
}
|
||||
if (r_map) {
|
||||
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!
|
||||
* Again, use_create is not relevant in this case */
|
||||
if (!data_dst) {
|
||||
data_dst = CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, num_elem_dst);
|
||||
data_dst = static_cast<MDeformVert *>(
|
||||
CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, num_elem_dst));
|
||||
}
|
||||
|
||||
while (idx_src--) {
|
||||
|
@ -1286,7 +1283,7 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||
0,
|
||||
0,
|
||||
vgroups_datatransfer_interp,
|
||||
NULL);
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1295,7 +1292,7 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||
|
||||
if (use_delete) {
|
||||
/* Remove all unused dst vgroups first, simpler in this case. */
|
||||
for (dg_dst = dst_defbase->first; dg_dst;) {
|
||||
for (dg_dst = static_cast<bDeformGroup *>(dst_defbase->first); dg_dst;) {
|
||||
bDeformGroup *dg_dst_next = dg_dst->next;
|
||||
|
||||
if (BKE_object_defgroup_name_index(ob_src, dg_dst->name) == -1) {
|
||||
|
@ -1305,7 +1302,8 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||
}
|
||||
}
|
||||
|
||||
for (idx_src = 0, dg_src = src_list->first; idx_src < num_layers_src;
|
||||
for (idx_src = 0, dg_src = static_cast<bDeformGroup *>(src_list->first);
|
||||
idx_src < num_layers_src;
|
||||
idx_src++, dg_src = dg_src->next) {
|
||||
if (!use_layers_src[idx_src]) {
|
||||
continue;
|
||||
|
@ -1325,7 +1323,8 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!
|
||||
* use_create is not relevant in this case */
|
||||
if (!data_dst) {
|
||||
data_dst = CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, num_elem_dst);
|
||||
data_dst = static_cast<MDeformVert *>(
|
||||
CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, num_elem_dst));
|
||||
}
|
||||
|
||||
data_transfer_layersmapping_add_item(r_map,
|
||||
|
@ -1342,7 +1341,7 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
|
|||
0,
|
||||
0,
|
||||
vgroups_datatransfer_interp,
|
||||
NULL);
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1371,13 +1370,13 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
|
|||
{
|
||||
int idx_src, idx_dst;
|
||||
|
||||
const size_t elem_size = sizeof(*((MDeformVert *)NULL));
|
||||
const size_t elem_size = sizeof(*((MDeformVert *)nullptr));
|
||||
|
||||
/* NOTE:
|
||||
* VGroups are a bit hairy, since their layout is defined on object level (ob->defbase),
|
||||
* while their actual data is a (mesh) CD layer.
|
||||
* This implies we may have to handle data layout itself while having NULL data itself,
|
||||
* and even have to support NULL data_src in transfer data code
|
||||
* This implies we may have to handle data layout itself while having nullptr data itself,
|
||||
* and even have to support nullptr data_src in transfer data code
|
||||
* (we always create a data_dst, though).
|
||||
*
|
||||
* NOTE: Above comment is outdated, but this function was written when that was true.
|
||||
|
@ -1391,12 +1390,15 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
|
|||
return true;
|
||||
}
|
||||
|
||||
const MDeformVert *data_src = CustomData_get_layer(cd_src, CD_MDEFORMVERT);
|
||||
const MDeformVert *data_src = static_cast<const MDeformVert *>(
|
||||
CustomData_get_layer(cd_src, CD_MDEFORMVERT));
|
||||
|
||||
MDeformVert *data_dst = CustomData_get_layer_for_write(cd_dst, CD_MDEFORMVERT, num_elem_dst);
|
||||
MDeformVert *data_dst = static_cast<MDeformVert *>(
|
||||
CustomData_get_layer_for_write(cd_dst, CD_MDEFORMVERT, num_elem_dst));
|
||||
if (data_dst && use_dupref_dst && r_map) {
|
||||
/* If dest is a derivedmesh, we do not want to overwrite cdlayers of org mesh! */
|
||||
data_dst = CustomData_get_layer_for_write(cd_dst, CD_MDEFORMVERT, num_elem_dst);
|
||||
data_dst = static_cast<MDeformVert *>(
|
||||
CustomData_get_layer_for_write(cd_dst, CD_MDEFORMVERT, num_elem_dst));
|
||||
}
|
||||
|
||||
if (fromlayers == DT_LAYERS_ACTIVE_SRC || fromlayers >= 0) {
|
||||
|
@ -1428,7 +1430,7 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
|
|||
if (!use_create) {
|
||||
return true;
|
||||
}
|
||||
dg_src = BLI_findlink(src_defbase, idx_src);
|
||||
dg_src = static_cast<bDeformGroup *>(BLI_findlink(src_defbase, idx_src));
|
||||
BKE_object_defgroup_add_name(ob_dst, dg_src->name);
|
||||
idx_dst = BKE_object_defgroup_active_index_get(ob_dst) - 1;
|
||||
}
|
||||
|
@ -1447,7 +1449,7 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
|
|||
}
|
||||
}
|
||||
else if (tolayers == DT_LAYERS_NAME_DST) {
|
||||
bDeformGroup *dg_src = BLI_findlink(src_defbase, idx_src);
|
||||
bDeformGroup *dg_src = static_cast<bDeformGroup *>(BLI_findlink(src_defbase, idx_src));
|
||||
if ((idx_dst = BKE_object_defgroup_name_index(ob_dst, dg_src->name)) == -1) {
|
||||
if (!use_create) {
|
||||
return true;
|
||||
|
@ -1464,7 +1466,8 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
|
|||
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!
|
||||
* use_create is not relevant in this case */
|
||||
if (!data_dst) {
|
||||
data_dst = CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, num_elem_dst);
|
||||
data_dst = static_cast<MDeformVert *>(
|
||||
CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, num_elem_dst));
|
||||
}
|
||||
|
||||
data_transfer_layersmapping_add_item(r_map,
|
||||
|
@ -1481,12 +1484,12 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
|
|||
0,
|
||||
0,
|
||||
vgroups_datatransfer_interp,
|
||||
NULL);
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int num_src, num_sel_unused;
|
||||
bool *use_layers_src = NULL;
|
||||
bool *use_layers_src = nullptr;
|
||||
bool ret = false;
|
||||
|
||||
switch (fromlayers) {
|
||||
|
@ -1585,7 +1588,7 @@ void BKE_defbase_blend_write(BlendWriter *writer, const ListBase *defbase)
|
|||
|
||||
void BKE_defvert_blend_write(BlendWriter *writer, int count, const MDeformVert *dvlist)
|
||||
{
|
||||
if (dvlist == NULL) {
|
||||
if (dvlist == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1602,22 +1605,23 @@ void BKE_defvert_blend_write(BlendWriter *writer, int count, const MDeformVert *
|
|||
|
||||
void BKE_defvert_blend_read(BlendDataReader *reader, int count, MDeformVert *mdverts)
|
||||
{
|
||||
if (mdverts == NULL) {
|
||||
if (mdverts == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = count; i > 0; i--, mdverts++) {
|
||||
/* Convert to vertex group allocation system. */
|
||||
MDeformWeight *dw;
|
||||
if (mdverts->dw && (dw = BLO_read_get_new_data_address(reader, mdverts->dw))) {
|
||||
if (mdverts->dw &&
|
||||
(dw = static_cast<MDeformWeight *>(BLO_read_get_new_data_address(reader, mdverts->dw)))) {
|
||||
const size_t dw_len = sizeof(MDeformWeight) * mdverts->totweight;
|
||||
void *dw_tmp = MEM_mallocN(dw_len, __func__);
|
||||
memcpy(dw_tmp, dw, dw_len);
|
||||
mdverts->dw = dw_tmp;
|
||||
mdverts->dw = static_cast<MDeformWeight *>(dw_tmp);
|
||||
MEM_freeN(dw);
|
||||
}
|
||||
else {
|
||||
mdverts->dw = NULL;
|
||||
mdverts->dw = nullptr;
|
||||
mdverts->totweight = 0;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -34,10 +34,10 @@
|
|||
|
||||
#ifdef WITH_FLUID
|
||||
|
||||
# include <float.h>
|
||||
# include <math.h>
|
||||
# include <stdio.h>
|
||||
# include <string.h> /* memset */
|
||||
# include <cfloat>
|
||||
# include <cmath>
|
||||
# include <cstdio>
|
||||
# include <cstring> /* memset */
|
||||
|
||||
# include "DNA_customdata_types.h"
|
||||
# include "DNA_light_types.h"
|
||||
|
@ -80,7 +80,7 @@
|
|||
/** Max value for phi initialization */
|
||||
#define PHI_MAX 9999.0f
|
||||
|
||||
static void fluid_modifier_reset_ex(struct FluidModifierData *fmd, bool need_lock);
|
||||
static void fluid_modifier_reset_ex(FluidModifierData *fmd, bool need_lock);
|
||||
|
||||
#ifdef WITH_FLUID
|
||||
// #define DEBUG_PRINT
|
||||
|
@ -93,11 +93,6 @@ static CLG_LogRef LOG = {"bke.fluid"};
|
|||
|
||||
static ThreadMutex object_update_lock = BLI_MUTEX_INITIALIZER;
|
||||
|
||||
struct FluidModifierData;
|
||||
struct Mesh;
|
||||
struct Object;
|
||||
struct Scene;
|
||||
|
||||
# define ADD_IF_LOWER_POS(a, b) (min_ff((a) + (b), max_ff((a), (b))))
|
||||
# define ADD_IF_LOWER_NEG(a, b) (max_ff((a) + (b), min_ff((a), (b))))
|
||||
# define ADD_IF_LOWER(a, b) (((b) > 0) ? ADD_IF_LOWER_POS((a), (b)) : ADD_IF_LOWER_NEG((a), (b)))
|
||||
|
@ -108,7 +103,7 @@ bool BKE_fluid_reallocate_fluid(FluidDomainSettings *fds, int res[3], int free_o
|
|||
manta_free(fds->fluid);
|
||||
}
|
||||
if (!min_iii(res[0], res[1], res[2])) {
|
||||
fds->fluid = NULL;
|
||||
fds->fluid = nullptr;
|
||||
}
|
||||
else {
|
||||
fds->fluid = manta_init(res, fds->fmd);
|
||||
|
@ -118,7 +113,7 @@ bool BKE_fluid_reallocate_fluid(FluidDomainSettings *fds, int res[3], int free_o
|
|||
fds->res_noise[2] = res[2] * fds->noise_scale;
|
||||
}
|
||||
|
||||
return (fds->fluid != NULL);
|
||||
return (fds->fluid != nullptr);
|
||||
}
|
||||
|
||||
void BKE_fluid_reallocate_copy_fluid(FluidDomainSettings *fds,
|
||||
|
@ -130,7 +125,7 @@ void BKE_fluid_reallocate_copy_fluid(FluidDomainSettings *fds,
|
|||
int o_shift[3],
|
||||
int n_shift[3])
|
||||
{
|
||||
struct MANTA *fluid_old = fds->fluid;
|
||||
MANTA *fluid_old = fds->fluid;
|
||||
const int block_size = fds->noise_scale;
|
||||
int new_shift[3] = {0};
|
||||
sub_v3_v3v3_int(new_shift, n_shift, o_shift);
|
||||
|
@ -563,7 +558,7 @@ static int get_light(Scene *scene, ViewLayer *view_layer, float *light)
|
|||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
LISTBASE_FOREACH (Base *, base_tmp, BKE_view_layer_object_bases_get(view_layer)) {
|
||||
if (base_tmp->object->type == OB_LAMP) {
|
||||
Light *la = base_tmp->object->data;
|
||||
Light *la = static_cast<Light *>(base_tmp->object->data);
|
||||
|
||||
if (la->type == LA_LOCAL) {
|
||||
copy_v3_v3(light, base_tmp->object->object_to_world[3]);
|
||||
|
@ -640,7 +635,7 @@ static bool is_static_object(Object *ob)
|
|||
/** \name Bounding Box
|
||||
* \{ */
|
||||
|
||||
typedef struct FluidObjectBB {
|
||||
struct FluidObjectBB {
|
||||
float *influence;
|
||||
float *velocity;
|
||||
float *distances;
|
||||
|
@ -648,7 +643,7 @@ typedef struct FluidObjectBB {
|
|||
int min[3], max[3], res[3];
|
||||
int hmin[3], hmax[3], hres[3];
|
||||
int total_cells, valid;
|
||||
} FluidObjectBB;
|
||||
};
|
||||
|
||||
static void bb_boundInsert(FluidObjectBB *bb, const float point[3])
|
||||
{
|
||||
|
@ -685,15 +680,19 @@ static void bb_allocateData(FluidObjectBB *bb, bool use_velocity, bool use_influ
|
|||
bb->total_cells = res[0] * res[1] * res[2];
|
||||
copy_v3_v3_int(bb->res, res);
|
||||
|
||||
bb->numobjs = MEM_calloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_numobjs");
|
||||
bb->numobjs = static_cast<float *>(
|
||||
MEM_calloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_numobjs"));
|
||||
if (use_influence) {
|
||||
bb->influence = MEM_calloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_influence");
|
||||
bb->influence = static_cast<float *>(
|
||||
MEM_calloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_influence"));
|
||||
}
|
||||
if (use_velocity) {
|
||||
bb->velocity = MEM_calloc_arrayN(bb->total_cells, sizeof(float[3]), "fluid_bb_velocity");
|
||||
bb->velocity = static_cast<float *>(
|
||||
MEM_calloc_arrayN(bb->total_cells, sizeof(float[3]), "fluid_bb_velocity"));
|
||||
}
|
||||
|
||||
bb->distances = MEM_malloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_distances");
|
||||
bb->distances = static_cast<float *>(
|
||||
MEM_malloc_arrayN(bb->total_cells, sizeof(float), "fluid_bb_distances"));
|
||||
copy_vn_fl(bb->distances, bb->total_cells, FLT_MAX);
|
||||
|
||||
bb->valid = true;
|
||||
|
@ -810,7 +809,7 @@ static void bb_combineMaps(FluidObjectBB *output,
|
|||
/** \name Effectors
|
||||
* \{ */
|
||||
|
||||
BLI_INLINE void apply_effector_fields(FluidEffectorSettings *UNUSED(fes),
|
||||
BLI_INLINE void apply_effector_fields(FluidEffectorSettings * /*fes*/,
|
||||
int index,
|
||||
float src_distance_value,
|
||||
float *dest_phi_in,
|
||||
|
@ -935,7 +934,7 @@ static void update_velocities(FluidEffectorSettings *fes,
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct ObstaclesFromDMData {
|
||||
struct ObstaclesFromDMData {
|
||||
FluidEffectorSettings *fes;
|
||||
|
||||
const float (*vert_positions)[3];
|
||||
|
@ -948,13 +947,13 @@ typedef struct ObstaclesFromDMData {
|
|||
bool has_velocity;
|
||||
float *vert_vel;
|
||||
int *min, *max, *res;
|
||||
} ObstaclesFromDMData;
|
||||
};
|
||||
|
||||
static void obstacles_from_mesh_task_cb(void *__restrict userdata,
|
||||
const int z,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
ObstaclesFromDMData *data = userdata;
|
||||
ObstaclesFromDMData *data = static_cast<ObstaclesFromDMData *>(userdata);
|
||||
FluidObjectBB *bb = data->bb;
|
||||
|
||||
for (int x = data->min[0]; x < data->max[0]; x++) {
|
||||
|
@ -999,10 +998,10 @@ static void obstacles_from_mesh(Object *coll_ob,
|
|||
{
|
||||
if (fes->mesh) {
|
||||
const MLoopTri *looptri;
|
||||
BVHTreeFromMesh tree_data = {NULL};
|
||||
BVHTreeFromMesh tree_data = {nullptr};
|
||||
int numverts, i;
|
||||
|
||||
float *vert_vel = NULL;
|
||||
float *vert_vel = nullptr;
|
||||
bool has_velocity = false;
|
||||
|
||||
Mesh *me = BKE_mesh_copy_for_eval(fes->mesh, false);
|
||||
|
@ -1016,14 +1015,16 @@ static void obstacles_from_mesh(Object *coll_ob,
|
|||
|
||||
/* TODO(sebbas): Make initialization of vertex velocities optional? */
|
||||
{
|
||||
vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_obs_velocity");
|
||||
vert_vel = static_cast<float *>(
|
||||
MEM_callocN(sizeof(float[3]) * numverts, "manta_obs_velocity"));
|
||||
|
||||
if (fes->numverts != numverts || !fes->verts_old) {
|
||||
if (fes->verts_old) {
|
||||
MEM_freeN(fes->verts_old);
|
||||
}
|
||||
|
||||
fes->verts_old = MEM_callocN(sizeof(float[3]) * numverts, "manta_obs_verts_old");
|
||||
fes->verts_old = static_cast<float *>(
|
||||
MEM_callocN(sizeof(float[3]) * numverts, "manta_obs_verts_old"));
|
||||
fes->numverts = numverts;
|
||||
}
|
||||
else {
|
||||
|
@ -1055,7 +1056,7 @@ static void obstacles_from_mesh(Object *coll_ob,
|
|||
/* Set emission map.
|
||||
* Use 3 cell diagonals as margin (3 * 1.732 = 5.196). */
|
||||
int bounds_margin = (int)ceil(5.196);
|
||||
clamp_bounds_in_domain(fds, bb->min, bb->max, NULL, NULL, bounds_margin, dt);
|
||||
clamp_bounds_in_domain(fds, bb->min, bb->max, nullptr, nullptr, bounds_margin, dt);
|
||||
bb_allocateData(bb, true, false);
|
||||
|
||||
/* Setup loop bounds. */
|
||||
|
@ -1069,19 +1070,18 @@ static void obstacles_from_mesh(Object *coll_ob,
|
|||
bool use_effector = fes->flags & FLUID_EFFECTOR_USE_EFFEC;
|
||||
if (use_effector && BKE_bvhtree_from_mesh_get(&tree_data, me, BVHTREE_FROM_LOOPTRI, 4)) {
|
||||
|
||||
ObstaclesFromDMData data = {
|
||||
.fes = fes,
|
||||
.vert_positions = positions,
|
||||
.mloop = mloop,
|
||||
.mlooptri = looptri,
|
||||
.tree = &tree_data,
|
||||
.bb = bb,
|
||||
.has_velocity = has_velocity,
|
||||
.vert_vel = vert_vel,
|
||||
.min = min,
|
||||
.max = max,
|
||||
.res = res,
|
||||
};
|
||||
ObstaclesFromDMData data{};
|
||||
data.fes = fes;
|
||||
data.vert_positions = positions;
|
||||
data.mloop = mloop;
|
||||
data.mlooptri = looptri;
|
||||
data.tree = &tree_data;
|
||||
data.bb = bb;
|
||||
data.has_velocity = has_velocity;
|
||||
data.vert_vel = vert_vel;
|
||||
data.min = min;
|
||||
data.max = max;
|
||||
data.res = res;
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BLI_parallel_range_settings_defaults(&settings);
|
||||
|
@ -1094,7 +1094,7 @@ static void obstacles_from_mesh(Object *coll_ob,
|
|||
if (vert_vel) {
|
||||
MEM_freeN(vert_vel);
|
||||
}
|
||||
BKE_id_free(NULL, me);
|
||||
BKE_id_free(nullptr, me);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1153,7 +1153,7 @@ static void update_obstacleflags(FluidDomainSettings *fds,
|
|||
|
||||
static bool escape_effectorobject(Object *flowobj,
|
||||
FluidDomainSettings *fds,
|
||||
FluidEffectorSettings *UNUSED(fes),
|
||||
FluidEffectorSettings * /*fes*/,
|
||||
int frame)
|
||||
{
|
||||
bool is_static = is_static_object(flowobj);
|
||||
|
@ -1176,7 +1176,7 @@ static bool escape_effectorobject(Object *flowobj,
|
|||
|
||||
static void compute_obstaclesemission(Scene *scene,
|
||||
FluidObjectBB *bb_maps,
|
||||
struct Depsgraph *depsgraph,
|
||||
Depsgraph *depsgraph,
|
||||
float dt,
|
||||
Object **effecobjs,
|
||||
int frame,
|
||||
|
@ -1223,7 +1223,7 @@ static void compute_obstaclesemission(Scene *scene,
|
|||
for (int subframe = 0; subframe <= subframes; subframe++) {
|
||||
|
||||
/* Temporary emission map used when subframes are enabled, i.e. at least one subframe. */
|
||||
FluidObjectBB bb_temp = {NULL};
|
||||
FluidObjectBB bb_temp = {nullptr};
|
||||
|
||||
/* Set scene time */
|
||||
/* Handle emission subframe */
|
||||
|
@ -1284,8 +1284,8 @@ static void update_obstacles(Depsgraph *depsgraph,
|
|||
int frame,
|
||||
float dt)
|
||||
{
|
||||
FluidObjectBB *bb_maps = NULL;
|
||||
Object **effecobjs = NULL;
|
||||
FluidObjectBB *bb_maps = nullptr;
|
||||
Object **effecobjs = nullptr;
|
||||
uint numeffecobjs = 0;
|
||||
bool is_resume = (fds->cache_frame_pause_data == frame);
|
||||
bool is_first_frame = (frame == fds->cache_frame_start);
|
||||
|
@ -1298,7 +1298,8 @@ static void update_obstacles(Depsgraph *depsgraph,
|
|||
ensure_obstaclefields(fds);
|
||||
|
||||
/* Allocate effector map for each effector object. */
|
||||
bb_maps = MEM_callocN(sizeof(struct FluidObjectBB) * numeffecobjs, "fluid_effector_bb_maps");
|
||||
bb_maps = static_cast<FluidObjectBB *>(
|
||||
MEM_callocN(sizeof(FluidObjectBB) * numeffecobjs, "fluid_effector_bb_maps"));
|
||||
|
||||
/* Initialize effector map for each effector object. */
|
||||
compute_obstaclesemission(scene,
|
||||
|
@ -1459,7 +1460,7 @@ static void update_obstacles(Depsgraph *depsgraph,
|
|||
/** \name Flow
|
||||
* \{ */
|
||||
|
||||
typedef struct EmitFromParticlesData {
|
||||
struct EmitFromParticlesData {
|
||||
FluidFlowSettings *ffs;
|
||||
KDTree_3d *tree;
|
||||
|
||||
|
@ -1469,13 +1470,13 @@ typedef struct EmitFromParticlesData {
|
|||
|
||||
float solid;
|
||||
float smooth;
|
||||
} EmitFromParticlesData;
|
||||
};
|
||||
|
||||
static void emit_from_particles_task_cb(void *__restrict userdata,
|
||||
const int z,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
EmitFromParticlesData *data = userdata;
|
||||
EmitFromParticlesData *data = static_cast<EmitFromParticlesData *>(userdata);
|
||||
FluidFlowSettings *ffs = data->ffs;
|
||||
FluidObjectBB *bb = data->bb;
|
||||
|
||||
|
@ -1527,7 +1528,7 @@ static void emit_from_particles(Object *flow_ob,
|
|||
/* radius based flow */
|
||||
const float solid = ffs->particle_size * 0.5f;
|
||||
const float smooth = 0.5f; /* add 0.5 cells of linear falloff to reduce aliasing */
|
||||
KDTree_3d *tree = NULL;
|
||||
KDTree_3d *tree = nullptr;
|
||||
|
||||
sim.depsgraph = depsgraph;
|
||||
sim.scene = scene;
|
||||
|
@ -1545,10 +1546,10 @@ static void emit_from_particles(Object *flow_ob,
|
|||
totchild = psys->totchild * psys->part->disp / 100;
|
||||
}
|
||||
|
||||
particle_pos = MEM_callocN(sizeof(float[3]) * (totpart + totchild),
|
||||
"manta_flow_particles_pos");
|
||||
particle_vel = MEM_callocN(sizeof(float[3]) * (totpart + totchild),
|
||||
"manta_flow_particles_vel");
|
||||
particle_pos = static_cast<float *>(
|
||||
MEM_callocN(sizeof(float[3]) * (totpart + totchild), "manta_flow_particles_pos"));
|
||||
particle_vel = static_cast<float *>(
|
||||
MEM_callocN(sizeof(float[3]) * (totpart + totchild), "manta_flow_particles_vel"));
|
||||
|
||||
/* setup particle radius emission if enabled */
|
||||
if (ffs->flags & FLUID_FLOW_USE_PART_SIZE) {
|
||||
|
@ -1600,7 +1601,7 @@ static void emit_from_particles(Object *flow_ob,
|
|||
}
|
||||
|
||||
/* set emission map */
|
||||
clamp_bounds_in_domain(fds, bb->min, bb->max, NULL, NULL, bounds_margin, dt);
|
||||
clamp_bounds_in_domain(fds, bb->min, bb->max, nullptr, nullptr, bounds_margin, dt);
|
||||
bb_allocateData(bb, ffs->flags & FLUID_FLOW_INITVELOCITY, true);
|
||||
|
||||
if (!(ffs->flags & FLUID_FLOW_USE_PART_SIZE)) {
|
||||
|
@ -1646,17 +1647,16 @@ static void emit_from_particles(Object *flow_ob,
|
|||
|
||||
BLI_kdtree_3d_balance(tree);
|
||||
|
||||
EmitFromParticlesData data = {
|
||||
.ffs = ffs,
|
||||
.tree = tree,
|
||||
.bb = bb,
|
||||
.particle_vel = particle_vel,
|
||||
.min = min,
|
||||
.max = max,
|
||||
.res = res,
|
||||
.solid = solid,
|
||||
.smooth = smooth,
|
||||
};
|
||||
EmitFromParticlesData data{};
|
||||
data.ffs = ffs;
|
||||
data.tree = tree;
|
||||
data.bb = bb;
|
||||
data.particle_vel = particle_vel;
|
||||
data.min = min;
|
||||
data.max = max;
|
||||
data.res = res;
|
||||
data.solid = solid;
|
||||
data.smooth = smooth;
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BLI_parallel_range_settings_defaults(&settings);
|
||||
|
@ -1920,7 +1920,7 @@ static void sample_mesh(FluidFlowSettings *ffs,
|
|||
tex_co[1] = tex_co[1] * 2.0f - 1.0f;
|
||||
tex_co[2] = ffs->texture_offset;
|
||||
}
|
||||
BKE_texture_get_value(NULL, ffs->noise_texture, tex_co, &texres, false);
|
||||
BKE_texture_get_value(nullptr, ffs->noise_texture, tex_co, &texres, false);
|
||||
emission_strength *= texres.tin;
|
||||
}
|
||||
}
|
||||
|
@ -1976,7 +1976,7 @@ static void sample_mesh(FluidFlowSettings *ffs,
|
|||
influence_map[index] = MAX2(volume_factor, emission_strength);
|
||||
}
|
||||
|
||||
typedef struct EmitFromDMData {
|
||||
struct EmitFromDMData {
|
||||
FluidDomainSettings *fds;
|
||||
FluidFlowSettings *ffs;
|
||||
|
||||
|
@ -1995,13 +1995,13 @@ typedef struct EmitFromDMData {
|
|||
float *vert_vel;
|
||||
float *flow_center;
|
||||
int *min, *max, *res;
|
||||
} EmitFromDMData;
|
||||
};
|
||||
|
||||
static void emit_from_mesh_task_cb(void *__restrict userdata,
|
||||
const int z,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
EmitFromDMData *data = userdata;
|
||||
EmitFromDMData *data = static_cast<EmitFromDMData *>(userdata);
|
||||
FluidObjectBB *bb = data->bb;
|
||||
|
||||
for (int x = data->min[0]; x < data->max[0]; x++) {
|
||||
|
@ -2051,10 +2051,10 @@ static void emit_from_mesh(
|
|||
Object *flow_ob, FluidDomainSettings *fds, FluidFlowSettings *ffs, FluidObjectBB *bb, float dt)
|
||||
{
|
||||
if (ffs->mesh) {
|
||||
BVHTreeFromMesh tree_data = {NULL};
|
||||
BVHTreeFromMesh tree_data = {nullptr};
|
||||
int i;
|
||||
|
||||
float *vert_vel = NULL;
|
||||
float *vert_vel = nullptr;
|
||||
bool has_velocity = false;
|
||||
|
||||
int defgrp_index = ffs->vgroup_density - 1;
|
||||
|
@ -2070,17 +2070,19 @@ static void emit_from_mesh(
|
|||
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(me);
|
||||
const int numverts = me->totvert;
|
||||
const MDeformVert *dvert = BKE_mesh_deform_verts(me);
|
||||
const float(*mloopuv)[2] = CustomData_get_layer_named(
|
||||
&me->ldata, CD_PROP_FLOAT2, ffs->uvlayer_name);
|
||||
const float(*mloopuv)[2] = static_cast<const float(*)[2]>(
|
||||
CustomData_get_layer_named(&me->ldata, CD_PROP_FLOAT2, ffs->uvlayer_name));
|
||||
|
||||
if (ffs->flags & FLUID_FLOW_INITVELOCITY) {
|
||||
vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_velocity");
|
||||
vert_vel = static_cast<float *>(
|
||||
MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_velocity"));
|
||||
|
||||
if (ffs->numverts != numverts || !ffs->verts_old) {
|
||||
if (ffs->verts_old) {
|
||||
MEM_freeN(ffs->verts_old);
|
||||
}
|
||||
ffs->verts_old = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_verts_old");
|
||||
ffs->verts_old = static_cast<float *>(
|
||||
MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_verts_old"));
|
||||
ffs->numverts = numverts;
|
||||
}
|
||||
else {
|
||||
|
@ -2122,7 +2124,7 @@ static void emit_from_mesh(
|
|||
/* Set emission map.
|
||||
* Use 3 cell diagonals as margin (3 * 1.732 = 5.196). */
|
||||
int bounds_margin = (int)ceil(5.196);
|
||||
clamp_bounds_in_domain(fds, bb->min, bb->max, NULL, NULL, bounds_margin, dt);
|
||||
clamp_bounds_in_domain(fds, bb->min, bb->max, nullptr, nullptr, bounds_margin, dt);
|
||||
bb_allocateData(bb, ffs->flags & FLUID_FLOW_INITVELOCITY, true);
|
||||
|
||||
/* Setup loop bounds. */
|
||||
|
@ -2136,25 +2138,24 @@ static void emit_from_mesh(
|
|||
bool use_flow = ffs->flags & FLUID_FLOW_USE_INFLOW;
|
||||
if (use_flow && BKE_bvhtree_from_mesh_get(&tree_data, me, BVHTREE_FROM_LOOPTRI, 4)) {
|
||||
|
||||
EmitFromDMData data = {
|
||||
.fds = fds,
|
||||
.ffs = ffs,
|
||||
.vert_positions = positions,
|
||||
.vert_normals = vert_normals,
|
||||
.mloop = mloop,
|
||||
.mlooptri = mlooptri,
|
||||
.mloopuv = mloopuv,
|
||||
.dvert = dvert,
|
||||
.defgrp_index = defgrp_index,
|
||||
.tree = &tree_data,
|
||||
.bb = bb,
|
||||
.has_velocity = has_velocity,
|
||||
.vert_vel = vert_vel,
|
||||
.flow_center = flow_center,
|
||||
.min = min,
|
||||
.max = max,
|
||||
.res = res,
|
||||
};
|
||||
EmitFromDMData data{};
|
||||
data.fds = fds;
|
||||
data.ffs = ffs;
|
||||
data.vert_positions = positions;
|
||||
data.vert_normals = vert_normals;
|
||||
data.mloop = mloop;
|
||||
data.mlooptri = mlooptri;
|
||||
data.mloopuv = mloopuv;
|
||||
data.dvert = dvert;
|
||||
data.defgrp_index = defgrp_index;
|
||||
data.tree = &tree_data;
|
||||
data.bb = bb;
|
||||
data.has_velocity = has_velocity;
|
||||
data.vert_vel = vert_vel;
|
||||
data.flow_center = flow_center;
|
||||
data.min = min;
|
||||
data.max = max;
|
||||
data.res = res;
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BLI_parallel_range_settings_defaults(&settings);
|
||||
|
@ -2167,7 +2168,7 @@ static void emit_from_mesh(
|
|||
if (vert_vel) {
|
||||
MEM_freeN(vert_vel);
|
||||
}
|
||||
BKE_id_free(NULL, me);
|
||||
BKE_id_free(nullptr, me);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2692,7 +2693,7 @@ static bool escape_flowsobject(Object *flowobj,
|
|||
|
||||
static void compute_flowsemission(Scene *scene,
|
||||
FluidObjectBB *bb_maps,
|
||||
struct Depsgraph *depsgraph,
|
||||
Depsgraph *depsgraph,
|
||||
float dt,
|
||||
Object **flowobjs,
|
||||
int frame,
|
||||
|
@ -2738,7 +2739,7 @@ static void compute_flowsemission(Scene *scene,
|
|||
/* Emission loop. When not using subframes this will loop only once. */
|
||||
for (int subframe = 0; subframe <= subframes; subframe++) {
|
||||
/* Temporary emission map used when subframes are enabled, i.e. at least one subframe. */
|
||||
FluidObjectBB bb_temp = {NULL};
|
||||
FluidObjectBB bb_temp = {nullptr};
|
||||
|
||||
/* Set scene time */
|
||||
if ((subframe < subframes || time_per_frame + dt + FLT_EPSILON < frame_length) &&
|
||||
|
@ -2812,7 +2813,7 @@ static void compute_flowsemission(Scene *scene,
|
|||
# endif
|
||||
}
|
||||
|
||||
static void update_flowsfluids(struct Depsgraph *depsgraph,
|
||||
static void update_flowsfluids(Depsgraph *depsgraph,
|
||||
Scene *scene,
|
||||
Object *ob,
|
||||
FluidDomainSettings *fds,
|
||||
|
@ -2821,8 +2822,8 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
|
|||
int frame,
|
||||
float dt)
|
||||
{
|
||||
FluidObjectBB *bb_maps = NULL;
|
||||
Object **flowobjs = NULL;
|
||||
FluidObjectBB *bb_maps = nullptr;
|
||||
Object **flowobjs = nullptr;
|
||||
uint numflowobjs = 0;
|
||||
bool is_resume = (fds->cache_frame_pause_data == frame);
|
||||
bool is_first_frame = (fds->cache_frame_start == frame);
|
||||
|
@ -2835,7 +2836,8 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
|
|||
ensure_flowsfields(fds);
|
||||
|
||||
/* Allocate emission map for each flow object. */
|
||||
bb_maps = MEM_callocN(sizeof(struct FluidObjectBB) * numflowobjs, "fluid_flow_bb_maps");
|
||||
bb_maps = static_cast<FluidObjectBB *>(
|
||||
MEM_callocN(sizeof(FluidObjectBB) * numflowobjs, "fluid_flow_bb_maps"));
|
||||
|
||||
/* Initialize emission map for each flow object. */
|
||||
compute_flowsemission(scene,
|
||||
|
@ -3082,7 +3084,7 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct UpdateEffectorsData {
|
||||
struct UpdateEffectorsData {
|
||||
Scene *scene;
|
||||
FluidDomainSettings *fds;
|
||||
ListBase *effectors;
|
||||
|
@ -3097,13 +3099,13 @@ typedef struct UpdateEffectorsData {
|
|||
float *velocity_z;
|
||||
int *flags;
|
||||
float *phi_obs_in;
|
||||
} UpdateEffectorsData;
|
||||
};
|
||||
|
||||
static void update_effectors_task_cb(void *__restrict userdata,
|
||||
const int x,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
UpdateEffectorsData *data = userdata;
|
||||
UpdateEffectorsData *data = static_cast<UpdateEffectorsData *>(userdata);
|
||||
FluidDomainSettings *fds = data->fds;
|
||||
|
||||
for (int y = 0; y < fds->res[1]; y++) {
|
||||
|
@ -3141,7 +3143,7 @@ static void update_effectors_task_cb(void *__restrict userdata,
|
|||
/* Do effectors. */
|
||||
pd_point_from_loc(data->scene, voxel_center, vel, index, &epoint);
|
||||
BKE_effectors_apply(
|
||||
data->effectors, NULL, fds->effector_weights, &epoint, retvel, NULL, NULL);
|
||||
data->effectors, nullptr, fds->effector_weights, &epoint, retvel, nullptr, nullptr);
|
||||
|
||||
/* Convert retvel to local space. */
|
||||
mag = len_v3(retvel);
|
||||
|
@ -3168,12 +3170,12 @@ static void update_effectors_task_cb(void *__restrict userdata,
|
|||
}
|
||||
|
||||
static void update_effectors(
|
||||
Depsgraph *depsgraph, Scene *scene, Object *ob, FluidDomainSettings *fds, float UNUSED(dt))
|
||||
Depsgraph *depsgraph, Scene *scene, Object *ob, FluidDomainSettings *fds, float /*dt*/)
|
||||
{
|
||||
ListBase *effectors;
|
||||
/* make sure smoke flow influence is 0.0f */
|
||||
fds->effector_weights->weight[PFIELD_FLUIDFLOW] = 0.0f;
|
||||
effectors = BKE_effectors_create(depsgraph, ob, NULL, fds->effector_weights, false);
|
||||
effectors = BKE_effectors_create(depsgraph, ob, nullptr, fds->effector_weights, false);
|
||||
|
||||
if (effectors) {
|
||||
/* Precalculate wind forces. */
|
||||
|
@ -3231,7 +3233,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
|
|||
int num_verts, num_faces;
|
||||
|
||||
if (!fds->fluid) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
num_verts = manta_liquid_get_num_verts(fds->fluid);
|
||||
|
@ -3243,12 +3245,12 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
|
|||
# endif
|
||||
|
||||
if (!num_verts || !num_faces) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
me = BKE_mesh_new_nomain(num_verts, 0, 0, num_faces * 3, num_faces);
|
||||
if (!me) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
float(*positions)[3] = BKE_mesh_vert_positions_for_write(me);
|
||||
mpolys = BKE_mesh_polys_for_write(me);
|
||||
|
@ -3277,13 +3279,13 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds,
|
|||
/* Velocities. */
|
||||
/* If needed, vertex velocities will be read too. */
|
||||
bool use_speedvectors = fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS;
|
||||
float(*velarray)[3] = NULL;
|
||||
float(*velarray)[3] = nullptr;
|
||||
float time_mult = fds->dx / (DT_DEFAULT * (25.0f / FPS));
|
||||
|
||||
if (use_speedvectors) {
|
||||
CustomDataLayer *velocity_layer = BKE_id_attribute_new(
|
||||
&me->id, "velocity", CD_PROP_FLOAT3, ATTR_DOMAIN_POINT, NULL);
|
||||
velarray = velocity_layer->data;
|
||||
&me->id, "velocity", CD_PROP_FLOAT3, ATTR_DOMAIN_POINT, nullptr);
|
||||
velarray = static_cast<float(*)[3]>(velocity_layer->data);
|
||||
}
|
||||
|
||||
/* Loop for vertices and normals. */
|
||||
|
@ -3620,7 +3622,7 @@ static void fluid_modifier_processFlow(FluidModifierData *fmd,
|
|||
|
||||
if (fmd->flow) {
|
||||
if (fmd->flow->mesh) {
|
||||
BKE_id_free(NULL, fmd->flow->mesh);
|
||||
BKE_id_free(nullptr, fmd->flow->mesh);
|
||||
}
|
||||
fmd->flow->mesh = BKE_mesh_copy_for_eval(me, false);
|
||||
}
|
||||
|
@ -3647,7 +3649,7 @@ static void fluid_modifier_processEffector(FluidModifierData *fmd,
|
|||
|
||||
if (fmd->effector) {
|
||||
if (fmd->effector->mesh) {
|
||||
BKE_id_free(NULL, fmd->effector->mesh);
|
||||
BKE_id_free(nullptr, fmd->effector->mesh);
|
||||
}
|
||||
fmd->effector->mesh = BKE_mesh_copy_for_eval(me, false);
|
||||
}
|
||||
|
@ -3669,10 +3671,10 @@ static void fluid_modifier_processDomain(FluidModifierData *fmd,
|
|||
const int scene_framenr)
|
||||
{
|
||||
FluidDomainSettings *fds = fmd->domain;
|
||||
Object *guide_parent = NULL;
|
||||
Object **objs = NULL;
|
||||
Object *guide_parent = nullptr;
|
||||
Object **objs = nullptr;
|
||||
uint numobj = 0;
|
||||
FluidModifierData *fmd_parent = NULL;
|
||||
FluidModifierData *fmd_parent = nullptr;
|
||||
|
||||
bool is_startframe, has_advanced;
|
||||
is_startframe = (scene_framenr == fds->cache_frame_start);
|
||||
|
@ -4089,7 +4091,7 @@ static void fluid_modifier_process(
|
|||
}
|
||||
}
|
||||
|
||||
struct Mesh *BKE_fluid_modifier_do(
|
||||
Mesh *BKE_fluid_modifier_do(
|
||||
FluidModifierData *fmd, Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *me)
|
||||
{
|
||||
/* Optimization: Do not update viewport during bakes (except in replay mode)
|
||||
|
@ -4100,13 +4102,13 @@ struct Mesh *BKE_fluid_modifier_do(
|
|||
if (!G.moving) {
|
||||
/* Lock so preview render does not read smoke data while it gets modified. */
|
||||
if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
|
||||
BLI_rw_mutex_lock(fmd->domain->fluid_mutex, THREAD_LOCK_WRITE);
|
||||
BLI_rw_mutex_lock(static_cast<ThreadRWMutex *>(fmd->domain->fluid_mutex), THREAD_LOCK_WRITE);
|
||||
}
|
||||
|
||||
fluid_modifier_process(fmd, depsgraph, scene, ob, me);
|
||||
|
||||
if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
|
||||
BLI_rw_mutex_unlock(fmd->domain->fluid_mutex);
|
||||
BLI_rw_mutex_unlock(static_cast<ThreadRWMutex *>(fmd->domain->fluid_mutex));
|
||||
}
|
||||
|
||||
if (fmd->domain) {
|
||||
|
@ -4136,7 +4138,7 @@ struct Mesh *BKE_fluid_modifier_do(
|
|||
}
|
||||
}
|
||||
|
||||
Mesh *result = NULL;
|
||||
Mesh *result = nullptr;
|
||||
if (fmd->type & MOD_FLUID_TYPE_DOMAIN && fmd->domain) {
|
||||
if (needs_viewport_update) {
|
||||
/* Return generated geometry depending on domain type. */
|
||||
|
@ -4367,7 +4369,7 @@ static void manta_smoke_calc_transparency(FluidDomainSettings *fds,
|
|||
}
|
||||
}
|
||||
|
||||
float BKE_fluid_get_velocity_at(struct Object *ob, float position[3], float velocity[3])
|
||||
float BKE_fluid_get_velocity_at(Object *ob, float position[3], float velocity[3])
|
||||
{
|
||||
FluidModifierData *fmd = (FluidModifierData *)BKE_modifiers_findby_type(ob, eModifierType_Fluid);
|
||||
zero_v3(velocity);
|
||||
|
@ -4450,8 +4452,8 @@ int BKE_fluid_get_data_flags(FluidDomainSettings *fds)
|
|||
return flags;
|
||||
}
|
||||
|
||||
void BKE_fluid_particle_system_create(struct Main *bmain,
|
||||
struct Object *ob,
|
||||
void BKE_fluid_particle_system_create(Main *bmain,
|
||||
Object *ob,
|
||||
const char *pset_name,
|
||||
const char *parts_name,
|
||||
const char *psys_name,
|
||||
|
@ -4463,7 +4465,7 @@ void BKE_fluid_particle_system_create(struct Main *bmain,
|
|||
|
||||
/* add particle system */
|
||||
part = BKE_particlesettings_add(bmain, pset_name);
|
||||
psys = MEM_callocN(sizeof(ParticleSystem), "particle_system");
|
||||
psys = MEM_cnew<ParticleSystem>(__func__);
|
||||
|
||||
part->type = psys_type;
|
||||
part->totpart = 0;
|
||||
|
@ -4483,12 +4485,12 @@ void BKE_fluid_particle_system_create(struct Main *bmain,
|
|||
BKE_modifier_unique_name(&ob->modifiers, (ModifierData *)pfmd);
|
||||
}
|
||||
|
||||
void BKE_fluid_particle_system_destroy(struct Object *ob, const int particle_type)
|
||||
void BKE_fluid_particle_system_destroy(Object *ob, const int particle_type)
|
||||
{
|
||||
ParticleSystemModifierData *pfmd;
|
||||
ParticleSystem *psys, *next_psys;
|
||||
|
||||
for (psys = ob->particlesystem.first; psys; psys = next_psys) {
|
||||
for (psys = static_cast<ParticleSystem *>(ob->particlesystem.first); psys; psys = next_psys) {
|
||||
next_psys = psys->next;
|
||||
if (psys->part->type == particle_type) {
|
||||
/* clear modifier */
|
||||
|
@ -4608,7 +4610,7 @@ void BKE_fluid_domain_type_set(Object *object, FluidDomainSettings *settings, in
|
|||
settings->type = type;
|
||||
}
|
||||
|
||||
void BKE_fluid_flow_behavior_set(Object *UNUSED(object), FluidFlowSettings *settings, int behavior)
|
||||
void BKE_fluid_flow_behavior_set(Object * /*object*/, FluidFlowSettings *settings, int behavior)
|
||||
{
|
||||
settings->behavior = behavior;
|
||||
}
|
||||
|
@ -4628,7 +4630,7 @@ void BKE_fluid_flow_type_set(Object *object, FluidFlowSettings *settings, int ty
|
|||
settings->type = type;
|
||||
}
|
||||
|
||||
void BKE_fluid_effector_type_set(Object *UNUSED(object), FluidEffectorSettings *settings, int type)
|
||||
void BKE_fluid_effector_type_set(Object * /*object*/, FluidEffectorSettings *settings, int type)
|
||||
{
|
||||
settings->type = type;
|
||||
}
|
||||
|
@ -4688,14 +4690,14 @@ static void fluid_modifier_freeDomain(FluidModifierData *fmd)
|
|||
}
|
||||
|
||||
if (fmd->domain->fluid_mutex) {
|
||||
BLI_rw_mutex_free(fmd->domain->fluid_mutex);
|
||||
BLI_rw_mutex_free(static_cast<ThreadRWMutex *>(fmd->domain->fluid_mutex));
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(fmd->domain->effector_weights);
|
||||
|
||||
if (!(fmd->modifier.flag & eModifierFlag_SharedCaches)) {
|
||||
BKE_ptcache_free_list(&(fmd->domain->ptcaches[0]));
|
||||
fmd->domain->point_cache[0] = NULL;
|
||||
fmd->domain->point_cache[0] = nullptr;
|
||||
}
|
||||
|
||||
if (fmd->domain->coba) {
|
||||
|
@ -4703,7 +4705,7 @@ static void fluid_modifier_freeDomain(FluidModifierData *fmd)
|
|||
}
|
||||
|
||||
MEM_freeN(fmd->domain);
|
||||
fmd->domain = NULL;
|
||||
fmd->domain = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4711,16 +4713,16 @@ static void fluid_modifier_freeFlow(FluidModifierData *fmd)
|
|||
{
|
||||
if (fmd->flow) {
|
||||
if (fmd->flow->mesh) {
|
||||
BKE_id_free(NULL, fmd->flow->mesh);
|
||||
BKE_id_free(nullptr, fmd->flow->mesh);
|
||||
}
|
||||
fmd->flow->mesh = NULL;
|
||||
fmd->flow->mesh = nullptr;
|
||||
|
||||
MEM_SAFE_FREE(fmd->flow->verts_old);
|
||||
fmd->flow->numverts = 0;
|
||||
fmd->flow->flags &= ~FLUID_FLOW_NEEDS_UPDATE;
|
||||
|
||||
MEM_freeN(fmd->flow);
|
||||
fmd->flow = NULL;
|
||||
fmd->flow = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4728,20 +4730,20 @@ static void fluid_modifier_freeEffector(FluidModifierData *fmd)
|
|||
{
|
||||
if (fmd->effector) {
|
||||
if (fmd->effector->mesh) {
|
||||
BKE_id_free(NULL, fmd->effector->mesh);
|
||||
BKE_id_free(nullptr, fmd->effector->mesh);
|
||||
}
|
||||
fmd->effector->mesh = NULL;
|
||||
fmd->effector->mesh = nullptr;
|
||||
|
||||
MEM_SAFE_FREE(fmd->effector->verts_old);
|
||||
fmd->effector->numverts = 0;
|
||||
fmd->effector->flags &= ~FLUID_EFFECTOR_NEEDS_UPDATE;
|
||||
|
||||
MEM_freeN(fmd->effector);
|
||||
fmd->effector = NULL;
|
||||
fmd->effector = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void fluid_modifier_reset_ex(struct FluidModifierData *fmd, bool need_lock)
|
||||
static void fluid_modifier_reset_ex(FluidModifierData *fmd, bool need_lock)
|
||||
{
|
||||
if (!fmd) {
|
||||
return;
|
||||
|
@ -4750,16 +4752,17 @@ static void fluid_modifier_reset_ex(struct FluidModifierData *fmd, bool need_loc
|
|||
if (fmd->domain) {
|
||||
if (fmd->domain->fluid) {
|
||||
if (need_lock) {
|
||||
BLI_rw_mutex_lock(fmd->domain->fluid_mutex, THREAD_LOCK_WRITE);
|
||||
BLI_rw_mutex_lock(static_cast<ThreadRWMutex *>(fmd->domain->fluid_mutex),
|
||||
THREAD_LOCK_WRITE);
|
||||
}
|
||||
|
||||
#ifdef WITH_FLUID
|
||||
manta_free(fmd->domain->fluid);
|
||||
#endif
|
||||
fmd->domain->fluid = NULL;
|
||||
fmd->domain->fluid = nullptr;
|
||||
|
||||
if (need_lock) {
|
||||
BLI_rw_mutex_unlock(fmd->domain->fluid_mutex);
|
||||
BLI_rw_mutex_unlock(static_cast<ThreadRWMutex *>(fmd->domain->fluid_mutex));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4779,7 +4782,7 @@ static void fluid_modifier_reset_ex(struct FluidModifierData *fmd, bool need_loc
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_fluid_modifier_reset(struct FluidModifierData *fmd)
|
||||
void BKE_fluid_modifier_reset(FluidModifierData *fmd)
|
||||
{
|
||||
fluid_modifier_reset_ex(fmd, true);
|
||||
}
|
||||
|
@ -4795,7 +4798,7 @@ void BKE_fluid_modifier_free(FluidModifierData *fmd)
|
|||
fluid_modifier_freeEffector(fmd);
|
||||
}
|
||||
|
||||
void BKE_fluid_modifier_create_type_data(struct FluidModifierData *fmd)
|
||||
void BKE_fluid_modifier_create_type_data(FluidModifierData *fmd)
|
||||
{
|
||||
if (!fmd) {
|
||||
return;
|
||||
|
@ -4819,7 +4822,7 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *fmd)
|
|||
fmd->domain->openvdb_compression = VDB_COMPRESSION_ZIP;
|
||||
#endif
|
||||
|
||||
fmd->domain->effector_weights = BKE_effector_add_weights(NULL);
|
||||
fmd->domain->effector_weights = BKE_effector_add_weights(nullptr);
|
||||
fmd->domain->fluid_mutex = BLI_rw_mutex_alloc();
|
||||
|
||||
char cache_name[64];
|
||||
|
@ -4831,7 +4834,7 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *fmd)
|
|||
fmd->domain->point_cache[0] = BKE_ptcache_add(&(fmd->domain->ptcaches[0]));
|
||||
fmd->domain->point_cache[0]->flag |= PTCACHE_DISK_CACHE;
|
||||
fmd->domain->point_cache[0]->step = 1;
|
||||
fmd->domain->point_cache[1] = NULL; /* Deprecated */
|
||||
fmd->domain->point_cache[1] = nullptr; /* Deprecated */
|
||||
}
|
||||
else if (fmd->type & MOD_FLUID_TYPE_FLOW) {
|
||||
if (fmd->flow) {
|
||||
|
@ -4851,9 +4854,7 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *fmd)
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_fluid_modifier_copy(const struct FluidModifierData *fmd,
|
||||
struct FluidModifierData *tfmd,
|
||||
const int flag)
|
||||
void BKE_fluid_modifier_copy(const FluidModifierData *fmd, FluidModifierData *tfmd, const int flag)
|
||||
{
|
||||
tfmd->type = fmd->type;
|
||||
tfmd->time = fmd->time;
|
||||
|
@ -4871,7 +4872,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *fmd,
|
|||
if (tfds->effector_weights) {
|
||||
MEM_freeN(tfds->effector_weights);
|
||||
}
|
||||
tfds->effector_weights = MEM_dupallocN(fds->effector_weights);
|
||||
tfds->effector_weights = static_cast<EffectorWeights *>(MEM_dupallocN(fds->effector_weights));
|
||||
|
||||
/* adaptive domain options */
|
||||
tfds->adapt_margin = fds->adapt_margin;
|
||||
|
@ -5002,7 +5003,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *fmd,
|
|||
tfds->display_thickness = fds->display_thickness;
|
||||
tfds->show_gridlines = fds->show_gridlines;
|
||||
if (fds->coba) {
|
||||
tfds->coba = MEM_dupallocN(fds->coba);
|
||||
tfds->coba = static_cast<ColorBand *>(MEM_dupallocN(fds->coba));
|
||||
}
|
||||
tfds->vector_scale = fds->vector_scale;
|
||||
tfds->vector_draw_type = fds->vector_draw_type;
|
|
@ -276,7 +276,7 @@ struct TileChangeset {
|
|||
const int chunk_len = chunk_x_len * chunk_y_len;
|
||||
|
||||
for (int chunk_index = 0; chunk_index < chunk_len; chunk_index++) {
|
||||
chunk_dirty_flags_[chunk_index] = chunk_dirty_flags_[chunk_index] |
|
||||
chunk_dirty_flags_[chunk_index] = chunk_dirty_flags_[chunk_index] ||
|
||||
other.chunk_dirty_flags_[chunk_index];
|
||||
}
|
||||
has_dirty_chunks_ |= other.has_dirty_chunks_;
|
||||
|
|
|
@ -751,7 +751,7 @@ static DerivedMesh *multires_dm_create_local(Scene *scene,
|
|||
bool alloc_paint_mask,
|
||||
MultiresFlags flags)
|
||||
{
|
||||
MultiresModifierData mmd = {{nullptr}};
|
||||
MultiresModifierData mmd{};
|
||||
|
||||
mmd.lvl = lvl;
|
||||
mmd.sculptlvl = lvl;
|
||||
|
|
|
@ -84,7 +84,7 @@ bool multiresModifier_reshapeFromDeformModifier(Depsgraph *depsgraph,
|
|||
MultiresModifierData *mmd,
|
||||
ModifierData *deform_md)
|
||||
{
|
||||
MultiresModifierData highest_mmd = *mmd;
|
||||
MultiresModifierData highest_mmd = blender::dna::shallow_copy(*mmd);
|
||||
highest_mmd.sculptlvl = highest_mmd.totlvl;
|
||||
highest_mmd.lvl = highest_mmd.totlvl;
|
||||
highest_mmd.renderlvl = highest_mmd.totlvl;
|
||||
|
|
|
@ -1094,7 +1094,7 @@ static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
|
|||
for (index = 0; index < totface; index++) {
|
||||
CCGFace *f = ccgdm->faceMap[index].face;
|
||||
int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f);
|
||||
int flag = (faceFlags) ? faceFlags[index].flag : ME_SMOOTH;
|
||||
char flag = (faceFlags) ? faceFlags[index].flag : char(ME_SMOOTH);
|
||||
|
||||
for (S = 0; S < numVerts; S++) {
|
||||
for (y = 0; y < gridSize - 1; y++) {
|
||||
|
|
|
@ -71,6 +71,36 @@ void parallel_for(IndexRange range, int64_t grain_size, const Function &function
|
|||
function(range);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as #parallel_for but tries to make the sub-range sizes multiples of the given alignment.
|
||||
* This can improve performance when the range is processed using vectorized and/or unrolled loops,
|
||||
* because the fallback loop that processes remaining values is used less often. A disadvantage of
|
||||
* using this instead of #parallel_for is that the size differences between sub-ranges can be
|
||||
* larger, which means that work is distributed less evenly.
|
||||
*/
|
||||
template<typename Function>
|
||||
void parallel_for_aligned(const IndexRange range,
|
||||
const int64_t grain_size,
|
||||
const int64_t alignment,
|
||||
const Function &function)
|
||||
{
|
||||
const int64_t global_begin = range.start();
|
||||
const int64_t global_end = range.one_after_last();
|
||||
const int64_t alignment_mask = ~(alignment - 1);
|
||||
parallel_for(range, grain_size, [&](const IndexRange unaligned_range) {
|
||||
/* Move the sub-range boundaries down to the next aligned index. The "global" begin and end
|
||||
* remain fixed though. */
|
||||
const int64_t unaligned_begin = unaligned_range.start();
|
||||
const int64_t unaligned_end = unaligned_range.one_after_last();
|
||||
const int64_t aligned_begin = std::max(global_begin, unaligned_begin & alignment_mask);
|
||||
const int64_t aligned_end = unaligned_end == global_end ?
|
||||
unaligned_end :
|
||||
std::max(global_begin, unaligned_end & alignment_mask);
|
||||
const IndexRange aligned_range{aligned_begin, aligned_end - aligned_begin};
|
||||
function(aligned_range);
|
||||
});
|
||||
}
|
||||
|
||||
template<typename Value, typename Function, typename Reduction>
|
||||
Value parallel_reduce(IndexRange range,
|
||||
int64_t grain_size,
|
||||
|
|
|
@ -501,11 +501,15 @@ static int fast_expansion_sum_zeroelim(
|
|||
while ((eindex < elen) && (findex < flen)) {
|
||||
if ((fnow > enow) == (fnow > -enow)) {
|
||||
Two_Sum(Q, enow, Qnew, hh);
|
||||
enow = e[++eindex];
|
||||
if (++eindex < elen) {
|
||||
enow = e[eindex];
|
||||
}
|
||||
}
|
||||
else {
|
||||
Two_Sum(Q, fnow, Qnew, hh);
|
||||
fnow = f[++findex];
|
||||
if (++findex < flen) {
|
||||
fnow = f[findex];
|
||||
}
|
||||
}
|
||||
Q = Qnew;
|
||||
if (hh != 0.0) {
|
||||
|
@ -515,7 +519,9 @@ static int fast_expansion_sum_zeroelim(
|
|||
}
|
||||
while (eindex < elen) {
|
||||
Two_Sum(Q, enow, Qnew, hh);
|
||||
enow = e[++eindex];
|
||||
if (++eindex < elen) {
|
||||
enow = e[eindex];
|
||||
}
|
||||
Q = Qnew;
|
||||
if (hh != 0.0) {
|
||||
h[hindex++] = hh;
|
||||
|
@ -523,7 +529,9 @@ static int fast_expansion_sum_zeroelim(
|
|||
}
|
||||
while (findex < flen) {
|
||||
Two_Sum(Q, fnow, Qnew, hh);
|
||||
fnow = f[++findex];
|
||||
if (++findex < flen) {
|
||||
fnow = f[findex];
|
||||
}
|
||||
Q = Qnew;
|
||||
if (hh != 0.0) {
|
||||
h[hindex++] = hh;
|
||||
|
|
|
@ -43,7 +43,7 @@ set(SRC
|
|||
intern/versioning_260.c
|
||||
intern/versioning_270.c
|
||||
intern/versioning_280.c
|
||||
intern/versioning_290.c
|
||||
intern/versioning_290.cc
|
||||
intern/versioning_300.cc
|
||||
intern/versioning_400.cc
|
||||
intern/versioning_common.cc
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
/* allow readfile to use deprecated functionality */
|
||||
#define DNA_DEPRECATED_ALLOW
|
||||
|
||||
#include "BLI_alloca.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_string.h"
|
||||
|
@ -73,16 +72,16 @@
|
|||
|
||||
static eSpaceSeq_Proxy_RenderSize get_sequencer_render_size(Main *bmain)
|
||||
{
|
||||
eSpaceSeq_Proxy_RenderSize render_size = 100;
|
||||
eSpaceSeq_Proxy_RenderSize render_size = eSpaceSeq_Proxy_RenderSize(100);
|
||||
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
switch (sl->spacetype) {
|
||||
case SPACE_SEQ: {
|
||||
SpaceSeq *sseq = (SpaceSeq *)sl;
|
||||
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
|
||||
render_size = sseq->render_size;
|
||||
render_size = eSpaceSeq_Proxy_RenderSize(sseq->render_size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +95,7 @@ static eSpaceSeq_Proxy_RenderSize get_sequencer_render_size(Main *bmain)
|
|||
|
||||
static bool can_use_proxy(const Sequence *seq, int psize)
|
||||
{
|
||||
if (seq->strip->proxy == NULL) {
|
||||
if (seq->strip->proxy == nullptr) {
|
||||
return false;
|
||||
}
|
||||
short size_flags = seq->strip->proxy->build_size_flags;
|
||||
|
@ -110,7 +109,7 @@ static void seq_convert_transform_animation(const Sequence *seq,
|
|||
const int image_size,
|
||||
const int scene_size)
|
||||
{
|
||||
if (scene->adt == NULL || scene->adt->action == NULL) {
|
||||
if (scene->adt == nullptr || scene->adt->action == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -121,7 +120,7 @@ static void seq_convert_transform_animation(const Sequence *seq,
|
|||
/* Convert offset animation, but only if crop is not used. */
|
||||
if ((seq->flag & use_transform_flag) != 0 && (seq->flag & use_crop_flag) == 0) {
|
||||
FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
|
||||
if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) {
|
||||
if (fcu != nullptr && !BKE_fcurve_is_empty(fcu)) {
|
||||
BezTriple *bezt = fcu->bezt;
|
||||
for (int i = 0; i < fcu->totvert; i++, bezt++) {
|
||||
/* Same math as with old_image_center_*, but simplified. */
|
||||
|
@ -142,11 +141,11 @@ static void seq_convert_transform_crop(const Scene *scene,
|
|||
Sequence *seq,
|
||||
const eSpaceSeq_Proxy_RenderSize render_size)
|
||||
{
|
||||
if (seq->strip->transform == NULL) {
|
||||
seq->strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform");
|
||||
if (seq->strip->transform == nullptr) {
|
||||
seq->strip->transform = MEM_cnew<StripTransform>(__func__);
|
||||
}
|
||||
if (seq->strip->crop == NULL) {
|
||||
seq->strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop");
|
||||
if (seq->strip->crop == nullptr) {
|
||||
seq->strip->crop = MEM_cnew<StripCrop>(__func__);
|
||||
}
|
||||
|
||||
StripCrop *c = seq->strip->crop;
|
||||
|
@ -161,7 +160,7 @@ static void seq_convert_transform_crop(const Scene *scene,
|
|||
const uint32_t use_crop_flag = (1 << 17);
|
||||
|
||||
const StripElem *s_elem = seq->strip->stripdata;
|
||||
if (s_elem != NULL) {
|
||||
if (s_elem != nullptr) {
|
||||
image_size_x = s_elem->orig_width;
|
||||
image_size_y = s_elem->orig_height;
|
||||
|
||||
|
@ -186,8 +185,8 @@ static void seq_convert_transform_crop(const Scene *scene,
|
|||
t->xofs = t->yofs = 0;
|
||||
|
||||
/* Reverse scale to fit for strips not using offset. */
|
||||
float project_aspect = (float)scene->r.xsch / (float)scene->r.ysch;
|
||||
float image_aspect = (float)image_size_x / (float)image_size_y;
|
||||
float project_aspect = float(scene->r.xsch) / float(scene->r.ysch);
|
||||
float image_aspect = float(image_size_x) / float(image_size_y);
|
||||
if (project_aspect > image_aspect) {
|
||||
t->scale_x = project_aspect / image_aspect;
|
||||
}
|
||||
|
@ -207,8 +206,8 @@ static void seq_convert_transform_crop(const Scene *scene,
|
|||
int cropped_image_size_x = image_size_x - c->right - c->left;
|
||||
int cropped_image_size_y = image_size_y - c->top - c->bottom;
|
||||
c->bottom = c->top = c->left = c->right = 0;
|
||||
t->scale_x *= (float)image_size_x / (float)cropped_image_size_x;
|
||||
t->scale_y *= (float)image_size_y / (float)cropped_image_size_y;
|
||||
t->scale_x *= float(image_size_x) / float(cropped_image_size_x);
|
||||
t->scale_y *= float(image_size_y) / float(cropped_image_size_y);
|
||||
}
|
||||
|
||||
if ((seq->flag & use_transform_flag) != 0) {
|
||||
|
@ -217,8 +216,8 @@ static void seq_convert_transform_crop(const Scene *scene,
|
|||
old_image_center_y = image_size_y / 2 - c->bottom + t->yofs;
|
||||
|
||||
/* Preserve original image size. */
|
||||
t->scale_x = t->scale_y = MAX2((float)image_size_x / (float)scene->r.xsch,
|
||||
(float)image_size_y / (float)scene->r.ysch);
|
||||
t->scale_x = t->scale_y = MAX2(float(image_size_x) / float(scene->r.xsch),
|
||||
float(image_size_y) / float(scene->r.ysch));
|
||||
|
||||
/* Convert crop. */
|
||||
if ((seq->flag & use_crop_flag) != 0) {
|
||||
|
@ -265,12 +264,12 @@ static void seq_convert_transform_animation_2(const Scene *scene,
|
|||
const char *path,
|
||||
const float scale_to_fit_factor)
|
||||
{
|
||||
if (scene->adt == NULL || scene->adt->action == NULL) {
|
||||
if (scene->adt == nullptr || scene->adt->action == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
|
||||
if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) {
|
||||
if (fcu != nullptr && !BKE_fcurve_is_empty(fcu)) {
|
||||
BezTriple *bezt = fcu->bezt;
|
||||
for (int i = 0; i < fcu->totvert; i++, bezt++) {
|
||||
/* Same math as with old_image_center_*, but simplified. */
|
||||
|
@ -286,7 +285,7 @@ static void seq_convert_transform_crop_2(const Scene *scene,
|
|||
const eSpaceSeq_Proxy_RenderSize render_size)
|
||||
{
|
||||
const StripElem *s_elem = seq->strip->stripdata;
|
||||
if (s_elem == NULL) {
|
||||
if (s_elem == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -301,8 +300,8 @@ static void seq_convert_transform_crop_2(const Scene *scene,
|
|||
}
|
||||
|
||||
/* Calculate scale factor, so image fits in preview area with original aspect ratio. */
|
||||
const float scale_to_fit_factor = MIN2((float)scene->r.xsch / (float)image_size_x,
|
||||
(float)scene->r.ysch / (float)image_size_y);
|
||||
const float scale_to_fit_factor = MIN2(float(scene->r.xsch) / float(image_size_x),
|
||||
float(scene->r.ysch) / float(image_size_y));
|
||||
t->scale_x *= scale_to_fit_factor;
|
||||
t->scale_y *= scale_to_fit_factor;
|
||||
c->top /= scale_to_fit_factor;
|
||||
|
@ -351,7 +350,7 @@ static void seq_update_meta_disp_range(Scene *scene)
|
|||
{
|
||||
Editing *ed = SEQ_editing_get(scene);
|
||||
|
||||
if (ed == NULL) {
|
||||
if (ed == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -411,7 +410,7 @@ static void version_node_socket_duplicate(bNodeTree *ntree,
|
|||
}
|
||||
}
|
||||
|
||||
void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
||||
void do_versions_after_linking_290(Main *bmain, ReportList * /*reports*/)
|
||||
{
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 290, 1)) {
|
||||
/* Patch old grease pencil modifiers material filter. */
|
||||
|
@ -421,8 +420,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Array: {
|
||||
ArrayGpencilModifierData *gpmd = (ArrayGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -430,8 +429,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Color: {
|
||||
ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -439,8 +438,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Hook: {
|
||||
HookGpencilModifierData *gpmd = (HookGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -448,8 +447,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Lattice: {
|
||||
LatticeGpencilModifierData *gpmd = (LatticeGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -457,8 +456,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Mirror: {
|
||||
MirrorGpencilModifierData *gpmd = (MirrorGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -466,8 +465,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Multiply: {
|
||||
MultiplyGpencilModifierData *gpmd = (MultiplyGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -475,8 +474,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Noise: {
|
||||
NoiseGpencilModifierData *gpmd = (NoiseGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -484,8 +483,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Offset: {
|
||||
OffsetGpencilModifierData *gpmd = (OffsetGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -493,8 +492,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Opacity: {
|
||||
OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -502,8 +501,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Simplify: {
|
||||
SimplifyGpencilModifierData *gpmd = (SimplifyGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -511,8 +510,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Smooth: {
|
||||
SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -520,8 +519,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Subdiv: {
|
||||
SubdivGpencilModifierData *gpmd = (SubdivGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -529,8 +528,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Texture: {
|
||||
TextureGpencilModifierData *gpmd = (TextureGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -538,8 +537,8 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
case eGpencilModifierType_Thick: {
|
||||
ThickGpencilModifierData *gpmd = (ThickGpencilModifierData *)md;
|
||||
if (gpmd->materialname[0] != '\0') {
|
||||
gpmd->material = BLI_findstring(
|
||||
&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2);
|
||||
gpmd->material = static_cast<Material *>(
|
||||
BLI_findstring(&bmain->materials, gpmd->materialname, offsetof(ID, name) + 2));
|
||||
gpmd->materialname[0] = '\0';
|
||||
}
|
||||
break;
|
||||
|
@ -551,15 +550,15 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
}
|
||||
|
||||
/* Patch first frame for old files. */
|
||||
Scene *scene = bmain->scenes.first;
|
||||
if (scene != NULL) {
|
||||
Scene *scene = static_cast<Scene *>(bmain->scenes.first);
|
||||
if (scene != nullptr) {
|
||||
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
|
||||
if (ob->type != OB_GPENCIL) {
|
||||
continue;
|
||||
}
|
||||
bGPdata *gpd = ob->data;
|
||||
bGPdata *gpd = static_cast<bGPdata *>(ob->data);
|
||||
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
|
||||
bGPDframe *gpf = gpl->frames.first;
|
||||
bGPDframe *gpf = static_cast<bGPDframe *>(gpl->frames.first);
|
||||
if (gpf && gpf->framenum > scene->r.sfra) {
|
||||
bGPDframe *gpf_dup = BKE_gpencil_frame_duplicate(gpf, true);
|
||||
gpf_dup->framenum = scene->r.sfra;
|
||||
|
@ -600,8 +599,7 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
/* Convert all Multires displacement to Catmull-Clark subdivision limit surface. */
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 292, 1)) {
|
||||
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
|
||||
ModifierData *md;
|
||||
for (md = ob->modifiers.first; md; md = md->next) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
|
||||
if (md->type == eModifierType_Multires) {
|
||||
MultiresModifierData *mmd = (MultiresModifierData *)md;
|
||||
if (mmd->simple) {
|
||||
|
@ -617,7 +615,7 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
eSpaceSeq_Proxy_RenderSize render_size = get_sequencer_render_size(bmain);
|
||||
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
if (scene->ed != NULL) {
|
||||
if (scene->ed != nullptr) {
|
||||
seq_convert_transform_crop_lb(scene, &scene->ed->seqbase, render_size);
|
||||
}
|
||||
}
|
||||
|
@ -628,12 +626,12 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
* Armature obdata. */
|
||||
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
BKE_pose_rebuild(bmain, ob, ob->data, true);
|
||||
BKE_pose_rebuild(bmain, ob, static_cast<bArmature *>(ob->data), true);
|
||||
}
|
||||
}
|
||||
|
||||
/* Wet Paint Radius Factor */
|
||||
for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
|
||||
LISTBASE_FOREACH (Brush *, br, &bmain->brushes) {
|
||||
if (br->ob_mode & OB_MODE_SCULPT && br->wet_paint_radius_factor == 0.0f) {
|
||||
br->wet_paint_radius_factor = 1.0f;
|
||||
}
|
||||
|
@ -641,7 +639,7 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
|
|||
|
||||
eSpaceSeq_Proxy_RenderSize render_size = get_sequencer_render_size(bmain);
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
if (scene->ed != NULL) {
|
||||
if (scene->ed != nullptr) {
|
||||
seq_convert_transform_crop_lb_2(scene, &scene->ed->seqbase, render_size);
|
||||
}
|
||||
}
|
||||
|
@ -797,12 +795,12 @@ static void version_node_join_geometry_for_multi_input_socket(bNodeTree *ntree)
|
|||
{
|
||||
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
|
||||
if (link->tonode->type == GEO_NODE_JOIN_GEOMETRY && !(link->tosock->flag & SOCK_MULTI_INPUT)) {
|
||||
link->tosock = link->tonode->inputs.first;
|
||||
link->tosock = static_cast<bNodeSocket *>(link->tonode->inputs.first);
|
||||
}
|
||||
}
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (node->type == GEO_NODE_JOIN_GEOMETRY) {
|
||||
bNodeSocket *socket = node->inputs.first;
|
||||
bNodeSocket *socket = static_cast<bNodeSocket *>(node->inputs.first);
|
||||
socket->flag |= SOCK_MULTI_INPUT;
|
||||
socket->limit = 4095;
|
||||
nodeRemoveSocket(ntree, node, socket->next);
|
||||
|
@ -811,7 +809,7 @@ static void version_node_join_geometry_for_multi_input_socket(bNodeTree *ntree)
|
|||
}
|
||||
|
||||
/* NOLINTNEXTLINE: readability-function-size */
|
||||
void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
||||
void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
{
|
||||
UNUSED_VARS(fd);
|
||||
|
||||
|
@ -854,7 +852,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "SpaceImage", "float", "uv_opacity")) {
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
if (sl->spacetype == SPACE_IMAGE) {
|
||||
|
@ -869,7 +867,8 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
/* Init Grease Pencil new random curves. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "random_hue")) {
|
||||
LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
|
||||
if ((brush->gpencil_settings) && (brush->gpencil_settings->curve_rand_pressure == NULL)) {
|
||||
if ((brush->gpencil_settings) &&
|
||||
(brush->gpencil_settings->curve_rand_pressure == nullptr)) {
|
||||
brush->gpencil_settings->curve_rand_pressure = BKE_curvemapping_add(
|
||||
1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
brush->gpencil_settings->curve_rand_strength = BKE_curvemapping_add(
|
||||
|
@ -923,7 +922,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
if (!MAIN_VERSION_ATLEAST(bmain, 290, 6)) {
|
||||
/* Transition to saving expansion for all of a modifier's sub-panels. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "ModifierData", "short", "ui_expand_flag")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->mode & eModifierMode_Expanded_DEPRECATED) {
|
||||
md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
|
||||
|
@ -951,7 +950,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
/* Transition to saving expansion for all of a constraint's sub-panels. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "bConstraint", "short", "ui_expand_flag")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (bConstraint *, con, &object->constraints) {
|
||||
if (con->flag & CONSTRAINT_EXPAND_DEPRECATED) {
|
||||
con->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
|
||||
|
@ -965,7 +964,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
/* Transition to saving expansion for all of grease pencil modifier's sub-panels. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "GpencilModifierData", "short", "ui_expand_flag")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (GpencilModifierData *, md, &object->greasepencil_modifiers) {
|
||||
if (md->mode & eGpencilModifierMode_Expanded_DEPRECATED) {
|
||||
md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
|
||||
|
@ -979,7 +978,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
/* Transition to saving expansion for all of an effect's sub-panels. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "ShaderFxData", "short", "ui_expand_flag")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ShaderFxData *, fx, &object->shader_fx) {
|
||||
if (fx->mode & eShaderFxMode_Expanded_DEPRECATED) {
|
||||
fx->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
|
||||
|
@ -993,7 +992,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
/* Refactor bevel profile type to use an enum. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "short", "profile_type")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->type == eModifierType_Bevel) {
|
||||
BevelModifierData *bmd = (BevelModifierData *)md;
|
||||
|
@ -1006,7 +1005,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
/* Change ocean modifier values from [0, 10] to [0, 1] ranges. */
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->type == eModifierType_Ocean) {
|
||||
OceanModifierData *omd = (OceanModifierData *)md;
|
||||
|
@ -1037,7 +1036,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
/* Refactor bevel affect type to use an enum. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "char", "affect_type")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->type == eModifierType_Bevel) {
|
||||
BevelModifierData *bmd = (BevelModifierData *)md;
|
||||
|
@ -1052,7 +1051,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
/* Initialize additional velocity parameter for #CacheFile's. */
|
||||
if (!DNA_struct_elem_find(
|
||||
fd->filesdna, "MeshSeqCacheModifierData", "float", "velocity_scale")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->type == eModifierType_MeshSequenceCache) {
|
||||
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
|
||||
|
@ -1063,15 +1062,14 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "CacheFile", "char", "velocity_unit")) {
|
||||
for (CacheFile *cache_file = bmain->cachefiles.first; cache_file != NULL;
|
||||
cache_file = cache_file->id.next) {
|
||||
LISTBASE_FOREACH (CacheFile *, cache_file, &bmain->cachefiles) {
|
||||
BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name));
|
||||
cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND;
|
||||
}
|
||||
}
|
||||
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "OceanModifierData", "int", "viewport_resolution")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->type == eModifierType_Ocean) {
|
||||
OceanModifierData *omd = (OceanModifierData *)md;
|
||||
|
@ -1094,10 +1092,10 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 291, 2)) {
|
||||
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
RigidBodyWorld *rbw = scene->rigidbody_world;
|
||||
|
||||
if (rbw == NULL) {
|
||||
if (rbw == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1111,8 +1109,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
/* PointCloud attributes. */
|
||||
for (PointCloud *pointcloud = bmain->pointclouds.first; pointcloud != NULL;
|
||||
pointcloud = pointcloud->id.next) {
|
||||
LISTBASE_FOREACH (PointCloud *, pointcloud, &bmain->pointclouds) {
|
||||
do_versions_point_attributes(&pointcloud->pdata);
|
||||
}
|
||||
|
||||
|
@ -1130,7 +1127,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
/* Solver and Collections for Boolean. */
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->type == eModifierType_Boolean) {
|
||||
BooleanModifierData *bmd = (BooleanModifierData *)md;
|
||||
|
@ -1160,10 +1157,10 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 291, 5)) {
|
||||
/* Fix fcurves to allow for new bezier handles behavior (T75881 and D8752). */
|
||||
for (bAction *act = bmain->actions.first; act; act = act->id.next) {
|
||||
for (FCurve *fcu = act->curves.first; fcu; fcu = fcu->next) {
|
||||
LISTBASE_FOREACH (bAction *, act, &bmain->actions) {
|
||||
LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
|
||||
/* Only need to fix Bezier curves with at least 2 key-frames. */
|
||||
if (fcu->totvert < 2 || fcu->bezt == NULL) {
|
||||
if (fcu->totvert < 2 || fcu->bezt == nullptr) {
|
||||
continue;
|
||||
}
|
||||
do_versions_291_fcurve_handles_limit(fcu);
|
||||
|
@ -1184,7 +1181,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
/* Add custom profile and bevel mode to curve bevels. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "Curve", "char", "bevel_mode")) {
|
||||
LISTBASE_FOREACH (Curve *, curve, &bmain->curves) {
|
||||
if (curve->bevobj != NULL) {
|
||||
if (curve->bevobj != nullptr) {
|
||||
curve->bevel_mode = CU_BEV_MODE_OBJECT;
|
||||
}
|
||||
else {
|
||||
|
@ -1198,7 +1195,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
|
||||
if (md->type == eModifierType_Fluid) {
|
||||
FluidModifierData *fmd = (FluidModifierData *)md;
|
||||
if (fmd->domain != NULL) {
|
||||
if (fmd->domain != nullptr) {
|
||||
if (!fmd->domain->coba_field && fmd->domain->type == FLUID_DOMAIN_TYPE_LIQUID) {
|
||||
fmd->domain->coba_field = FLUID_DOMAIN_FIELD_PHI;
|
||||
}
|
||||
|
@ -1216,7 +1213,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
if (!MAIN_VERSION_ATLEAST(bmain, 291, 6)) {
|
||||
/* Darken Inactive Overlay. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "fade_alpha")) {
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
|
@ -1239,7 +1236,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
/* Alembic importer: allow vertex interpolation by default. */
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->type != eModifierType_MeshSequenceCache) {
|
||||
continue;
|
||||
|
@ -1264,11 +1261,11 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) {
|
||||
relation->parent = blo_read_get_new_globaldata_address(fd, relation->parent);
|
||||
BLI_assert(relation->parentid == 0);
|
||||
if (relation->parent != NULL) {
|
||||
if (relation->parent != nullptr) {
|
||||
LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) {
|
||||
wmWindow *win = BLI_findptr(
|
||||
&wm->windows, relation->parent, offsetof(wmWindow, workspace_hook));
|
||||
if (win != NULL) {
|
||||
wmWindow *win = static_cast<wmWindow *>(
|
||||
BLI_findptr(&wm->windows, relation->parent, offsetof(wmWindow, workspace_hook)));
|
||||
if (win != nullptr) {
|
||||
relation->parentid = win->winid;
|
||||
break;
|
||||
}
|
||||
|
@ -1310,7 +1307,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 291, 9)) {
|
||||
/* Remove options of legacy UV/Image editor */
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
switch (sl->spacetype) {
|
||||
|
@ -1370,7 +1367,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
if (!MAIN_VERSION_ATLEAST(bmain, 292, 5)) {
|
||||
/* Initialize the opacity of the overlay wireframe */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_opacity")) {
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
|
@ -1401,7 +1398,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
|
||||
if (md->type == eModifierType_WeightVGProximity) {
|
||||
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md;
|
||||
if (wmd->cmap_curve == NULL) {
|
||||
if (wmd->cmap_curve == nullptr) {
|
||||
wmd->cmap_curve = BKE_curvemapping_add(1, 0.0, 0.0, 1.0, 1.0);
|
||||
BKE_curvemapping_init(wmd->cmap_curve);
|
||||
}
|
||||
|
@ -1442,7 +1439,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
/* EEVEE/Cycles Volumes consistency */
|
||||
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
/* Remove Volume Transmittance render pass from each view layer. */
|
||||
LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
|
||||
view_layer->eevee.render_passes &= ~EEVEE_RENDER_PASS_UNUSED_8;
|
||||
|
@ -1471,7 +1468,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
if (node->type == CMP_NODE_CRYPTOMATTE_LEGACY) {
|
||||
NodeCryptomatte *storage = (NodeCryptomatte *)node->storage;
|
||||
char *matte_id = storage->matte_id;
|
||||
if (matte_id == NULL || strlen(storage->matte_id) == 0) {
|
||||
if (matte_id == nullptr || strlen(storage->matte_id) == 0) {
|
||||
continue;
|
||||
}
|
||||
BKE_cryptomatte_matte_id_to_entries(storage, storage->matte_id);
|
||||
|
@ -1505,7 +1502,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
if (scene->toolsettings->sequencer_tool_settings == NULL) {
|
||||
if (scene->toolsettings->sequencer_tool_settings == nullptr) {
|
||||
scene->toolsettings->sequencer_tool_settings = SEQ_tool_settings_init();
|
||||
}
|
||||
}
|
||||
|
@ -1530,7 +1527,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
|
||||
if (md->type == eModifierType_Fluid) {
|
||||
FluidModifierData *fmd = (FluidModifierData *)md;
|
||||
if (fmd->domain != NULL) {
|
||||
if (fmd->domain != nullptr) {
|
||||
fmd->domain->viscosity_value = 0.05;
|
||||
}
|
||||
}
|
||||
|
@ -1549,7 +1546,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
if (node->type != CMP_NODE_SETALPHA) {
|
||||
continue;
|
||||
}
|
||||
NodeSetAlpha *storage = MEM_callocN(sizeof(NodeSetAlpha), "NodeSetAlpha");
|
||||
NodeSetAlpha *storage = MEM_cnew<NodeSetAlpha>("NodeSetAlpha");
|
||||
storage->mode = CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA;
|
||||
node->storage = storage;
|
||||
}
|
||||
|
@ -1559,7 +1556,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
Editing *ed = SEQ_editing_get(scene);
|
||||
if (ed == NULL) {
|
||||
if (ed == nullptr) {
|
||||
continue;
|
||||
}
|
||||
ed->cache_flag = (SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_FINAL_OUT);
|
||||
|
@ -1575,7 +1572,8 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (node->type == CMP_NODE_OUTPUT_FILE) {
|
||||
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
|
||||
NodeImageMultiFileSocket *simf = sock->storage;
|
||||
NodeImageMultiFileSocket *simf = static_cast<NodeImageMultiFileSocket *>(
|
||||
sock->storage);
|
||||
simf->save_as_render = true;
|
||||
}
|
||||
}
|
||||
|
@ -1617,7 +1615,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
continue;
|
||||
}
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (node->type == GEO_NODE_OBJECT_INFO && node->storage == NULL) {
|
||||
if (node->type == GEO_NODE_OBJECT_INFO && node->storage == nullptr) {
|
||||
NodeGeometryObjectInfo *data = (NodeGeometryObjectInfo *)MEM_callocN(
|
||||
sizeof(NodeGeometryObjectInfo), __func__);
|
||||
data->transform_space = GEO_NODE_TRANSFORM_SPACE_RELATIVE;
|
||||
|
@ -1767,7 +1765,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
&sl->regionbase;
|
||||
ARegion *new_footer = do_versions_add_region_if_not_found(
|
||||
regionbase, RGN_TYPE_FOOTER, "footer for spreadsheet", RGN_TYPE_HEADER);
|
||||
if (new_footer != NULL) {
|
||||
if (new_footer != nullptr) {
|
||||
new_footer->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP :
|
||||
RGN_ALIGN_BOTTOM;
|
||||
}
|
||||
|
@ -1842,7 +1840,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
if (!MAIN_VERSION_ATLEAST(bmain, 293, 18)) {
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "bArmature", "float", "axes_position")) {
|
||||
/* Convert the axes draw position to its old default (tip of bone). */
|
||||
LISTBASE_FOREACH (struct bArmature *, arm, &bmain->armatures) {
|
||||
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
|
||||
arm->axes_position = 1.0;
|
||||
}
|
||||
}
|
|
@ -184,7 +184,7 @@ void version_node_socket_index_animdata(Main *bmain,
|
|||
|
||||
/* The for loop for the input ids is at the top level otherwise we lose the animation
|
||||
* keyframe data. Not sure what causes that, so I (Sybren) moved the code here from
|
||||
* versioning_290.c as-is (structure-wise). */
|
||||
* versioning_290.cc as-is (structure-wise). */
|
||||
for (int input_index = total_number_of_sockets - 1; input_index >= socket_index_orig;
|
||||
input_index--) {
|
||||
FOREACH_NODETREE_BEGIN (bmain, ntree, owner_id) {
|
||||
|
|
|
@ -1506,7 +1506,7 @@ static void offset_meet(BevelParams *bp,
|
|||
* Update: changed again from 0.0001f to fix bug T95335.
|
||||
* Original two bugs remained fixed.
|
||||
*/
|
||||
#define BEVEL_GOOD_ANGLE 0.001f
|
||||
#define BEVEL_GOOD_ANGLE 0.1f
|
||||
|
||||
/**
|
||||
* Calculate the meeting point between e1 and e2 (one of which should have zero offsets),
|
||||
|
|
|
@ -32,7 +32,7 @@ set(SRC
|
|||
armature_skinning.c
|
||||
armature_utils.c
|
||||
editarmature_undo.c
|
||||
meshlaplacian.c
|
||||
meshlaplacian.cc
|
||||
pose_edit.c
|
||||
pose_group.c
|
||||
pose_lib_2.c
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BLI_alloca.h"
|
||||
#include "BLI_edgehash.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_memarena.h"
|
||||
|
@ -36,10 +35,10 @@
|
|||
#include "meshlaplacian.h"
|
||||
|
||||
/* ************* XXX *************** */
|
||||
static void waitcursor(int UNUSED(val))
|
||||
static void waitcursor(int /*val*/)
|
||||
{
|
||||
}
|
||||
static void progress_bar(int UNUSED(dummy_val), const char *UNUSED(dummy))
|
||||
static void progress_bar(int /*dummy_val*/, const char * /*dummy*/)
|
||||
{
|
||||
}
|
||||
static void start_progress_bar(void)
|
||||
|
@ -206,11 +205,14 @@ static LaplacianSystem *laplacian_system_construct_begin(int verts_num, int face
|
|||
{
|
||||
LaplacianSystem *sys;
|
||||
|
||||
sys = MEM_callocN(sizeof(LaplacianSystem), "LaplacianSystem");
|
||||
sys = MEM_cnew<LaplacianSystem>(__func__);
|
||||
|
||||
sys->verts = MEM_callocN(sizeof(float *) * verts_num, "LaplacianSystemVerts");
|
||||
sys->vpinned = MEM_callocN(sizeof(char) * verts_num, "LaplacianSystemVpinned");
|
||||
sys->faces = MEM_callocN(sizeof(int[3]) * faces_num, "LaplacianSystemFaces");
|
||||
sys->verts = static_cast<float **>(
|
||||
MEM_callocN(sizeof(float *) * verts_num, "LaplacianSystemVerts"));
|
||||
sys->vpinned = static_cast<char *>(
|
||||
MEM_callocN(sizeof(char) * verts_num, "LaplacianSystemVpinned"));
|
||||
sys->faces = static_cast<int(*)[3]>(
|
||||
MEM_callocN(sizeof(int[3]) * faces_num, "LaplacianSystemFaces"));
|
||||
|
||||
sys->verts_num = 0;
|
||||
sys->faces_num = 0;
|
||||
|
@ -251,7 +253,8 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
|
|||
|
||||
laplacian_begin_solve(sys, 0);
|
||||
|
||||
sys->varea = MEM_callocN(sizeof(float) * verts_num, "LaplacianSystemVarea");
|
||||
sys->varea = static_cast<float *>(
|
||||
MEM_callocN(sizeof(float) * verts_num, "LaplacianSystemVarea"));
|
||||
|
||||
sys->edgehash = BLI_edgehash_new_ex(__func__,
|
||||
BLI_EDGEHASH_SIZE_GUESS_FROM_POLYS(sys->faces_num));
|
||||
|
@ -284,7 +287,8 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
|
|||
}
|
||||
|
||||
if (sys->storeweights) {
|
||||
sys->fweights = MEM_callocN(sizeof(float[3]) * faces_num, "LaplacianFWeight");
|
||||
sys->fweights = static_cast<float(*)[3]>(
|
||||
MEM_callocN(sizeof(float[3]) * faces_num, "LaplacianFWeight"));
|
||||
}
|
||||
|
||||
for (a = 0, face = sys->faces; a < faces_num; a++, face++) {
|
||||
|
@ -292,12 +296,12 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
|
|||
}
|
||||
|
||||
MEM_freeN(sys->faces);
|
||||
sys->faces = NULL;
|
||||
sys->faces = nullptr;
|
||||
|
||||
MEM_SAFE_FREE(sys->varea);
|
||||
|
||||
BLI_edgehash_free(sys->edgehash, NULL);
|
||||
sys->edgehash = NULL;
|
||||
BLI_edgehash_free(sys->edgehash, nullptr);
|
||||
sys->edgehash = nullptr;
|
||||
}
|
||||
|
||||
static void laplacian_system_delete(LaplacianSystem *sys)
|
||||
|
@ -389,10 +393,10 @@ static void bvh_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTr
|
|||
|
||||
#ifdef USE_KDOPBVH_WATERTIGHT
|
||||
if (isect_ray_tri_watertight_v3(
|
||||
data->start, ray->isect_precalc, UNPACK3(vtri_co), &dist_test, NULL))
|
||||
data->start, ray->isect_precalc, UNPACK3(vtri_co), &dist_test, nullptr))
|
||||
#else
|
||||
UNUSED_VARS(ray);
|
||||
if (isect_ray_tri_v3(data->start, data->vec, UNPACK3(vtri_co), &dist_test, NULL))
|
||||
if (isect_ray_tri_v3(data->start, data->vec, UNPACK3(vtri_co), &dist_test, nullptr))
|
||||
#endif
|
||||
{
|
||||
if (dist_test < hit->dist) {
|
||||
|
@ -417,7 +421,8 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
|
|||
int a;
|
||||
|
||||
sys->heat.bvhtree = BLI_bvhtree_new(tris_num, 0.0f, 4, 6);
|
||||
sys->heat.vltree = MEM_callocN(sizeof(MLoopTri *) * verts_num, "HeatVFaces");
|
||||
sys->heat.vltree = static_cast<const MLoopTri **>(
|
||||
MEM_callocN(sizeof(MLoopTri *) * verts_num, "HeatVFaces"));
|
||||
|
||||
for (a = 0; a < tris_num; a++) {
|
||||
const MLoopTri *lt = &looptri[a];
|
||||
|
@ -453,7 +458,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
|
|||
int visible;
|
||||
|
||||
lt = sys->heat.vltree[vertex];
|
||||
if (lt == NULL) {
|
||||
if (lt == nullptr) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -553,7 +558,8 @@ static void heat_calc_vnormals(LaplacianSystem *sys)
|
|||
float fnor[3];
|
||||
int a, v1, v2, v3, (*face)[3];
|
||||
|
||||
sys->heat.vert_normals = MEM_callocN(sizeof(float[3]) * sys->verts_num, "HeatVNors");
|
||||
sys->heat.vert_normals = static_cast<float(*)[3]>(
|
||||
MEM_callocN(sizeof(float[3]) * sys->verts_num, "HeatVNors"));
|
||||
|
||||
for (a = 0, face = sys->faces; a < sys->faces_num; a++, face++) {
|
||||
v1 = (*face)[0];
|
||||
|
@ -581,9 +587,9 @@ static void heat_laplacian_create(LaplacianSystem *sys)
|
|||
int a;
|
||||
|
||||
/* heat specific definitions */
|
||||
sys->heat.mindist = MEM_callocN(sizeof(float) * verts_num, "HeatMinDist");
|
||||
sys->heat.H = MEM_callocN(sizeof(float) * verts_num, "HeatH");
|
||||
sys->heat.p = MEM_callocN(sizeof(float) * verts_num, "HeatP");
|
||||
sys->heat.mindist = static_cast<float *>(MEM_callocN(sizeof(float) * verts_num, "HeatMinDist"));
|
||||
sys->heat.H = static_cast<float *>(MEM_callocN(sizeof(float) * verts_num, "HeatH"));
|
||||
sys->heat.p = static_cast<float *>(MEM_callocN(sizeof(float) * verts_num, "HeatP"));
|
||||
|
||||
/* add verts and faces to laplacian */
|
||||
for (a = 0; a < verts_num; a++) {
|
||||
|
@ -648,7 +654,7 @@ void heat_bone_weighting(Object *ob,
|
|||
const MPoly *mp;
|
||||
const MLoop *ml;
|
||||
float solution, weight;
|
||||
int *vertsflipped = NULL, *mask = NULL;
|
||||
int *vertsflipped = nullptr, *mask = nullptr;
|
||||
int a, tris_num, j, bbone, firstsegment, lastsegment;
|
||||
bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
|
||||
|
||||
|
@ -658,14 +664,14 @@ void heat_bone_weighting(Object *ob,
|
|||
bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
|
||||
bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
|
||||
|
||||
*error_str = NULL;
|
||||
*error_str = nullptr;
|
||||
|
||||
/* bone heat needs triangulated faces */
|
||||
tris_num = poly_to_tri_count(me->totpoly, me->totloop);
|
||||
|
||||
/* count triangles and create mask */
|
||||
if (ob->mode & OB_MODE_WEIGHT_PAINT && (use_face_sel || use_vert_sel)) {
|
||||
mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask");
|
||||
mask = static_cast<int *>(MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask"));
|
||||
|
||||
/* (added selectedVerts content for vertex mask, they used to just equal 1) */
|
||||
if (use_vert_sel) {
|
||||
|
@ -698,7 +704,8 @@ void heat_bone_weighting(Object *ob,
|
|||
sys = laplacian_system_construct_begin(me->totvert, tris_num, 1);
|
||||
|
||||
sys->heat.tris_num = poly_to_tri_count(me->totpoly, me->totloop);
|
||||
mlooptri = MEM_mallocN(sizeof(*sys->heat.mlooptri) * sys->heat.tris_num, __func__);
|
||||
mlooptri = static_cast<MLoopTri *>(
|
||||
MEM_mallocN(sizeof(*sys->heat.mlooptri) * sys->heat.tris_num, __func__));
|
||||
|
||||
BKE_mesh_recalc_looptri(loops, polys, vert_positions, me->totloop, me->totpoly, mlooptri);
|
||||
|
||||
|
@ -716,9 +723,9 @@ void heat_bone_weighting(Object *ob,
|
|||
laplacian_system_construct_end(sys);
|
||||
|
||||
if (dgroupflip) {
|
||||
vertsflipped = MEM_callocN(sizeof(int) * me->totvert, "vertsflipped");
|
||||
vertsflipped = static_cast<int *>(MEM_callocN(sizeof(int) * me->totvert, "vertsflipped"));
|
||||
for (a = 0; a < me->totvert; a++) {
|
||||
vertsflipped[a] = mesh_get_x_mirror_vert(ob, NULL, a, use_topology);
|
||||
vertsflipped[a] = mesh_get_x_mirror_vert(ob, nullptr, a, use_topology);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -799,7 +806,7 @@ void heat_bone_weighting(Object *ob,
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (*error_str == NULL) {
|
||||
else if (*error_str == nullptr) {
|
||||
*error_str = N_("Bone Heat Weighting: failed to find solution for one or more bones");
|
||||
break;
|
||||
}
|
||||
|
@ -950,7 +957,7 @@ static void harmonic_ray_callback(void *userdata,
|
|||
const BVHTreeRay *ray,
|
||||
BVHTreeRayHit *hit)
|
||||
{
|
||||
struct MeshRayCallbackData *data = userdata;
|
||||
MeshRayCallbackData *data = static_cast<MeshRayCallbackData *>(userdata);
|
||||
MeshDeformBind *mdb = data->mdb;
|
||||
const MLoop *mloop = mdb->cagemesh_cache.mloop;
|
||||
const MLoopTri *looptri = mdb->cagemesh_cache.looptri, *lt;
|
||||
|
@ -966,7 +973,7 @@ static void harmonic_ray_callback(void *userdata,
|
|||
face[2] = mdb->cagecos[mloop[lt->tri[2]].v];
|
||||
|
||||
bool isect_ray_tri = isect_ray_tri_watertight_v3(
|
||||
ray->origin, ray->isect_precalc, UNPACK3(face), &dist, NULL);
|
||||
ray->origin, ray->isect_precalc, UNPACK3(face), &dist, nullptr);
|
||||
|
||||
if (!isect_ray_tri || dist > isec->vec_length) {
|
||||
return;
|
||||
|
@ -1004,8 +1011,8 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb,
|
|||
float end[3], vec_normal[3];
|
||||
|
||||
/* happens binding when a cage has no faces */
|
||||
if (UNLIKELY(mdb->bvhtree == NULL)) {
|
||||
return NULL;
|
||||
if (UNLIKELY(mdb->bvhtree == nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* setup isec */
|
||||
|
@ -1034,10 +1041,11 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb,
|
|||
const float len = isect_mdef.lambda;
|
||||
MDefBoundIsect *isect;
|
||||
|
||||
float(*mp_cagecos)[3] = BLI_array_alloca(mp_cagecos, mp->totloop);
|
||||
blender::Array<blender::float3, 64> mp_cagecos(mp->totloop);
|
||||
|
||||
/* create MDefBoundIsect, and extra for 'poly_weights[]' */
|
||||
isect = BLI_memarena_alloc(mdb->memarena, sizeof(*isect) + (sizeof(float) * mp->totloop));
|
||||
isect = static_cast<MDefBoundIsect *>(
|
||||
BLI_memarena_alloc(mdb->memarena, sizeof(*isect) + (sizeof(float) * mp->totloop)));
|
||||
|
||||
/* compute intersection coordinate */
|
||||
madd_v3_v3v3fl(isect->co, co1, isect_mdef.vec, len);
|
||||
|
@ -1053,12 +1061,15 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb,
|
|||
copy_v3_v3(mp_cagecos[i], cagecos[mloop[mp->loopstart + i].v]);
|
||||
}
|
||||
|
||||
interp_weights_poly_v3(isect->poly_weights, mp_cagecos, mp->totloop, isect->co);
|
||||
interp_weights_poly_v3(isect->poly_weights,
|
||||
reinterpret_cast<float(*)[3]>(mp_cagecos.data()),
|
||||
mp->totloop,
|
||||
isect->co);
|
||||
|
||||
return isect;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co)
|
||||
|
@ -1150,7 +1161,7 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb)
|
|||
int *stack, *tag = mdb->tag;
|
||||
int a, b, i, xyz[3], stacksize, size = mdb->size;
|
||||
|
||||
stack = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformBindStack");
|
||||
stack = static_cast<int *>(MEM_callocN(sizeof(int) * mdb->size3, __func__));
|
||||
|
||||
/* we know lower left corner is EXTERIOR because of padding */
|
||||
tag[0] = MESHDEFORM_TAG_EXTERIOR;
|
||||
|
@ -1230,8 +1241,8 @@ static float meshdeform_boundary_phi(const MeshDeformBind *mdb,
|
|||
|
||||
static float meshdeform_interp_w(MeshDeformBind *mdb,
|
||||
const float *gridvec,
|
||||
float *UNUSED(vec),
|
||||
int UNUSED(cagevert))
|
||||
float * /*vec*/,
|
||||
int /*cagevert*/)
|
||||
{
|
||||
float dvec[3], ivec[3], result = 0.0f;
|
||||
float totweight = 0.0f;
|
||||
|
@ -1419,7 +1430,7 @@ static void meshdeform_matrix_add_semibound_phi(
|
|||
}
|
||||
|
||||
static void meshdeform_matrix_add_exterior_phi(
|
||||
MeshDeformBind *mdb, int x, int y, int z, int UNUSED(cagevert))
|
||||
MeshDeformBind *mdb, int x, int y, int z, int /*cagevert*/)
|
||||
{
|
||||
float phi, totweight;
|
||||
int i, a, acenter;
|
||||
|
@ -1453,7 +1464,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
|
|||
char message[256];
|
||||
|
||||
/* setup variable indices */
|
||||
mdb->varidx = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformDSvaridx");
|
||||
mdb->varidx = static_cast<int *>(MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformDSvaridx"));
|
||||
for (a = 0, totvar = 0; a < mdb->size3; a++) {
|
||||
mdb->varidx[a] = (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) ? -1 : totvar++;
|
||||
}
|
||||
|
@ -1531,7 +1542,8 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
|
|||
/* dynamic bind */
|
||||
for (b = 0; b < mdb->size3; b++) {
|
||||
if (mdb->phi[b] >= MESHDEFORM_MIN_INFLUENCE) {
|
||||
inf = BLI_memarena_alloc(mdb->memarena, sizeof(*inf));
|
||||
inf = static_cast<MDefBindInfluence *>(
|
||||
BLI_memarena_alloc(mdb->memarena, sizeof(*inf)));
|
||||
inf->vertex = a;
|
||||
inf->weight = mdb->phi[b];
|
||||
inf->next = mdb->dyngrid[b];
|
||||
|
@ -1594,20 +1606,23 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
|
|||
/* allocate memory */
|
||||
mdb->size = (2 << (mmd->gridsize - 1)) + 2;
|
||||
mdb->size3 = mdb->size * mdb->size * mdb->size;
|
||||
mdb->tag = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformBindTag");
|
||||
mdb->phi = MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindPhi");
|
||||
mdb->totalphi = MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindTotalPhi");
|
||||
mdb->boundisect = MEM_callocN(sizeof(*mdb->boundisect) * mdb->size3, "MDefBoundIsect");
|
||||
mdb->semibound = MEM_callocN(sizeof(int) * mdb->size3, "MDefSemiBound");
|
||||
mdb->tag = static_cast<int *>(MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformBindTag"));
|
||||
mdb->phi = static_cast<float *>(MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindPhi"));
|
||||
mdb->totalphi = static_cast<float *>(
|
||||
MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindTotalPhi"));
|
||||
mdb->boundisect = static_cast<MDefBoundIsect *(*)[6]>(
|
||||
MEM_callocN(sizeof(*mdb->boundisect) * mdb->size3, "MDefBoundIsect"));
|
||||
mdb->semibound = static_cast<int *>(MEM_callocN(sizeof(int) * mdb->size3, "MDefSemiBound"));
|
||||
mdb->bvhtree = BKE_bvhtree_from_mesh_get(&mdb->bvhdata, mdb->cagemesh, BVHTREE_FROM_LOOPTRI, 4);
|
||||
mdb->inside = MEM_callocN(sizeof(int) * mdb->verts_num, "MDefInside");
|
||||
mdb->inside = static_cast<int *>(MEM_callocN(sizeof(int) * mdb->verts_num, "MDefInside"));
|
||||
|
||||
if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
|
||||
mdb->dyngrid = MEM_callocN(sizeof(MDefBindInfluence *) * mdb->size3, "MDefDynGrid");
|
||||
mdb->dyngrid = static_cast<MDefBindInfluence **>(
|
||||
MEM_callocN(sizeof(MDefBindInfluence *) * mdb->size3, "MDefDynGrid"));
|
||||
}
|
||||
else {
|
||||
mdb->weights = MEM_callocN(sizeof(float) * mdb->verts_num * mdb->cage_verts_num,
|
||||
"MDefWeights");
|
||||
mdb->weights = static_cast<float *>(
|
||||
MEM_callocN(sizeof(float) * mdb->verts_num * mdb->cage_verts_num, "MDefWeights"));
|
||||
}
|
||||
|
||||
mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
|
||||
|
@ -1697,8 +1712,10 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
|
|||
}
|
||||
|
||||
/* convert MDefBindInfluences to smaller MDefInfluences */
|
||||
mmd->dyngrid = MEM_callocN(sizeof(MDefCell) * mdb->size3, "MDefDynGrid");
|
||||
mmd->dyninfluences = MEM_callocN(sizeof(MDefInfluence) * mmd->influences_num, "MDefInfluence");
|
||||
mmd->dyngrid = static_cast<MDefCell *>(
|
||||
MEM_callocN(sizeof(MDefCell) * mdb->size3, "MDefDynGrid"));
|
||||
mmd->dyninfluences = static_cast<MDefInfluence *>(
|
||||
MEM_callocN(sizeof(MDefInfluence) * mmd->influences_num, "MDefInfluence"));
|
||||
offset = 0;
|
||||
for (a = 0; a < mdb->size3; a++) {
|
||||
cell = &mmd->dyngrid[a];
|
||||
|
@ -1764,12 +1781,14 @@ void ED_mesh_deform_bind_callback(Object *object,
|
|||
BKE_mesh_wrapper_ensure_mdata(cagemesh);
|
||||
|
||||
/* get mesh and cage mesh */
|
||||
mdb.vertexcos = MEM_callocN(sizeof(float[3]) * verts_num, "MeshDeformCos");
|
||||
mdb.vertexcos = static_cast<float(*)[3]>(
|
||||
MEM_callocN(sizeof(float[3]) * verts_num, "MeshDeformCos"));
|
||||
mdb.verts_num = verts_num;
|
||||
|
||||
mdb.cagemesh = cagemesh;
|
||||
mdb.cage_verts_num = mdb.cagemesh->totvert;
|
||||
mdb.cagecos = MEM_callocN(sizeof(*mdb.cagecos) * mdb.cage_verts_num, "MeshDeformBindCos");
|
||||
mdb.cagecos = static_cast<float(*)[3]>(
|
||||
MEM_callocN(sizeof(*mdb.cagecos) * mdb.cage_verts_num, "MeshDeformBindCos"));
|
||||
copy_m4_m4(mdb.cagemat, cagemat);
|
||||
|
||||
const float(*positions)[3] = BKE_mesh_vert_positions(mdb.cagemesh);
|
|
@ -7,6 +7,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#define RIGID_DEFORM
|
||||
|
||||
struct Mesh;
|
||||
|
@ -51,6 +55,10 @@ void rigid_deform_iteration(void);
|
|||
void rigid_deform_end(int cancel);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Harmonic Coordinates */
|
||||
|
||||
/* ED_mesh_deform_bind_callback(...) defined in ED_armature.h */
|
||||
|
|
|
@ -56,8 +56,7 @@ IndexMask retrieve_selected_curves(const Curves &curves_id, Vector<int64_t> &r_i
|
|||
return retrieve_selected_curves(curves, r_indices);
|
||||
}
|
||||
|
||||
static IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves,
|
||||
Vector<int64_t> &r_indices)
|
||||
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, Vector<int64_t> &r_indices)
|
||||
{
|
||||
return index_mask_ops::find_indices_from_virtual_array(
|
||||
curves.points_range(),
|
||||
|
|
|
@ -359,7 +359,7 @@ void ED_pose_bone_select_tag_update(struct Object *ob);
|
|||
*/
|
||||
void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool select);
|
||||
|
||||
/* meshlaplacian.c */
|
||||
/* meshlaplacian.cc */
|
||||
|
||||
void ED_mesh_deform_bind_callback(struct Object *object,
|
||||
struct MeshDeformModifierData *mmd,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
struct bContext;
|
||||
struct Curves;
|
||||
struct UndoType;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -93,6 +94,7 @@ IndexMask retrieve_selected_curves(const Curves &curves_id, Vector<int64_t> &r_i
|
|||
* Find points that are selected (a selection factor greater than zero),
|
||||
* or points in curves with a selection factor greater than zero).
|
||||
*/
|
||||
IndexMask retrieve_selected_points(const bke::CurvesGeometry &curves, Vector<int64_t> &r_indices);
|
||||
IndexMask retrieve_selected_points(const Curves &curves_id, Vector<int64_t> &r_indices);
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,8 +34,8 @@ set(INC_SYS
|
|||
|
||||
set(SRC
|
||||
object_add.cc
|
||||
object_bake.c
|
||||
object_bake_api.c
|
||||
object_bake.cc
|
||||
object_bake_api.cc
|
||||
object_collection.c
|
||||
object_constraint.c
|
||||
object_data_transfer.c
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* \ingroup edobj
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
@ -56,14 +56,15 @@
|
|||
|
||||
static Image *bake_object_image_get(Object *ob, int mat_nr)
|
||||
{
|
||||
Image *image = NULL;
|
||||
ED_object_get_active_image(ob, mat_nr + 1, &image, NULL, NULL, NULL);
|
||||
Image *image = nullptr;
|
||||
ED_object_get_active_image(ob, mat_nr + 1, &image, nullptr, nullptr, nullptr);
|
||||
return image;
|
||||
}
|
||||
|
||||
static Image **bake_object_image_get_array(Object *ob)
|
||||
{
|
||||
Image **image_array = MEM_mallocN(sizeof(Material *) * ob->totcol, __func__);
|
||||
Image **image_array = static_cast<Image **>(
|
||||
MEM_mallocN(sizeof(Material *) * ob->totcol, __func__));
|
||||
for (int i = 0; i < ob->totcol; i++) {
|
||||
image_array[i] = bake_object_image_get(ob, i);
|
||||
}
|
||||
|
@ -74,8 +75,8 @@ static Image **bake_object_image_get_array(Object *ob)
|
|||
|
||||
/* holder of per-object data needed for bake job
|
||||
* needed to make job totally thread-safe */
|
||||
typedef struct MultiresBakerJobData {
|
||||
struct MultiresBakerJobData *next, *prev;
|
||||
struct MultiresBakerJobData {
|
||||
MultiresBakerJobData *next, *prev;
|
||||
/* material aligned image array (for per-face bake image) */
|
||||
struct {
|
||||
Image **array;
|
||||
|
@ -84,10 +85,10 @@ typedef struct MultiresBakerJobData {
|
|||
DerivedMesh *lores_dm, *hires_dm;
|
||||
int lvl, tot_lvl;
|
||||
ListBase images;
|
||||
} MultiresBakerJobData;
|
||||
};
|
||||
|
||||
/* data passing to multires-baker job */
|
||||
typedef struct {
|
||||
struct MultiresBakeJob {
|
||||
Scene *scene;
|
||||
ListBase data;
|
||||
/** Clear the images before baking */
|
||||
|
@ -108,7 +109,7 @@ typedef struct {
|
|||
int threads;
|
||||
/** User scale used to scale displacement when baking derivative map. */
|
||||
float user_scale;
|
||||
} MultiresBakeJob;
|
||||
};
|
||||
|
||||
static bool multiresbake_check(bContext *C, wmOperator *op)
|
||||
{
|
||||
|
@ -178,7 +179,7 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
|
|||
BKE_imageuser_default(&iuser);
|
||||
iuser.tile = tile->tile_number;
|
||||
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
|
||||
|
||||
if (!ibuf) {
|
||||
BKE_report(
|
||||
|
@ -187,7 +188,7 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
|
|||
ok = false;
|
||||
}
|
||||
else {
|
||||
if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
|
||||
if (ibuf->rect == nullptr && ibuf->rect_float == nullptr) {
|
||||
ok = false;
|
||||
}
|
||||
|
||||
|
@ -200,7 +201,7 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
|
|||
}
|
||||
}
|
||||
|
||||
BKE_image_release_ibuf(ima, ibuf, NULL);
|
||||
BKE_image_release_ibuf(ima, ibuf, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +221,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
|
|||
DerivedMesh *dm;
|
||||
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
MultiresModifierData tmp_mmd = *mmd;
|
||||
MultiresModifierData tmp_mmd = blender::dna::shallow_copy(*mmd);
|
||||
|
||||
*lvl = mmd->lvl;
|
||||
|
||||
|
@ -234,7 +235,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
|
|||
DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
|
||||
tmp_mmd.lvl = mmd->lvl;
|
||||
tmp_mmd.sculptlvl = mmd->lvl;
|
||||
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0);
|
||||
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, MultiresFlags(0));
|
||||
|
||||
cddm->release(cddm);
|
||||
|
||||
|
@ -245,7 +246,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
|
|||
{
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
|
||||
MultiresModifierData tmp_mmd = *mmd;
|
||||
MultiresModifierData tmp_mmd = blender::dna::shallow_copy(*mmd);
|
||||
DerivedMesh *cddm = CDDM_from_mesh(me);
|
||||
DerivedMesh *dm;
|
||||
|
||||
|
@ -261,7 +262,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
|
|||
|
||||
tmp_mmd.lvl = mmd->totlvl;
|
||||
tmp_mmd.sculptlvl = mmd->totlvl;
|
||||
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0);
|
||||
dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, MultiresFlags(0));
|
||||
cddm->release(cddm);
|
||||
|
||||
return dm;
|
||||
|
@ -287,7 +288,7 @@ static void clear_single_image(Image *image, ClearFlag flag)
|
|||
BKE_imageuser_default(&iuser);
|
||||
iuser.tile = tile->tile_number;
|
||||
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, NULL);
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, nullptr);
|
||||
|
||||
if (flag == CLEAR_TANGENT_NORMAL) {
|
||||
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
|
||||
|
@ -301,7 +302,7 @@ static void clear_single_image(Image *image, ClearFlag flag)
|
|||
|
||||
image->id.tag |= LIB_TAG_DOIT;
|
||||
|
||||
BKE_image_release_ibuf(image, ibuf, NULL);
|
||||
BKE_image_release_ibuf(image, ibuf, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -342,7 +343,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
|
|||
|
||||
if (scene->r.bake_flag & R_BAKE_CLEAR) { /* clear images */
|
||||
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
|
||||
ClearFlag clear_flag = 0;
|
||||
ClearFlag clear_flag = ClearFlag(0);
|
||||
|
||||
ob = base->object;
|
||||
// me = (Mesh *)ob->data;
|
||||
|
@ -364,7 +365,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
|
||||
MultiresBakeRender bkr = {NULL};
|
||||
MultiresBakeRender bkr = {nullptr};
|
||||
|
||||
ob = base->object;
|
||||
|
||||
|
@ -439,14 +440,13 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
|
|||
// bkj->reports = op->reports;
|
||||
|
||||
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
|
||||
MultiresBakerJobData *data;
|
||||
int lvl;
|
||||
|
||||
ob = base->object;
|
||||
|
||||
multires_flush_sculpt_updates(ob);
|
||||
|
||||
data = MEM_callocN(sizeof(MultiresBakerJobData), "multiresBaker derivedMesh_data");
|
||||
MultiresBakerJobData *data = MEM_cnew<MultiresBakerJobData>(__func__);
|
||||
|
||||
data->ob_image.array = bake_object_image_get_array(ob);
|
||||
data->ob_image.len = ob->totcol;
|
||||
|
@ -464,14 +464,14 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
|
|||
static void multiresbake_startjob(void *bkv, bool *stop, bool *do_update, float *progress)
|
||||
{
|
||||
MultiresBakerJobData *data;
|
||||
MultiresBakeJob *bkj = bkv;
|
||||
MultiresBakeJob *bkj = static_cast<MultiresBakeJob *>(bkv);
|
||||
int baked_objects = 0, tot_obj;
|
||||
|
||||
tot_obj = BLI_listbase_count(&bkj->data);
|
||||
|
||||
if (bkj->bake_clear) { /* clear images */
|
||||
for (data = bkj->data.first; data; data = data->next) {
|
||||
ClearFlag clear_flag = 0;
|
||||
for (data = static_cast<MultiresBakerJobData *>(bkj->data.first); data; data = data->next) {
|
||||
ClearFlag clear_flag = ClearFlag(0);
|
||||
|
||||
if (bkj->mode == RE_BAKE_NORMALS) {
|
||||
clear_flag = CLEAR_TANGENT_NORMAL;
|
||||
|
@ -484,8 +484,8 @@ static void multiresbake_startjob(void *bkv, bool *stop, bool *do_update, float
|
|||
}
|
||||
}
|
||||
|
||||
for (data = bkj->data.first; data; data = data->next) {
|
||||
MultiresBakeRender bkr = {NULL};
|
||||
for (data = static_cast<MultiresBakerJobData *>(bkj->data.first); data; data = data->next) {
|
||||
MultiresBakeRender bkr = {nullptr};
|
||||
|
||||
/* copy data stored in job descriptor */
|
||||
bkr.scene = bkj->scene;
|
||||
|
@ -526,18 +526,18 @@ static void multiresbake_startjob(void *bkv, bool *stop, bool *do_update, float
|
|||
|
||||
static void multiresbake_freejob(void *bkv)
|
||||
{
|
||||
MultiresBakeJob *bkj = bkv;
|
||||
MultiresBakeJob *bkj = static_cast<MultiresBakeJob *>(bkv);
|
||||
MultiresBakerJobData *data, *next;
|
||||
LinkData *link;
|
||||
|
||||
data = bkj->data.first;
|
||||
data = static_cast<MultiresBakerJobData *>(bkj->data.first);
|
||||
while (data) {
|
||||
next = data->next;
|
||||
data->lores_dm->release(data->lores_dm);
|
||||
data->hires_dm->release(data->hires_dm);
|
||||
|
||||
/* delete here, since this delete will be called from main thread */
|
||||
for (link = data->images.first; link; link = link->next) {
|
||||
for (link = static_cast<LinkData *>(data->images.first); link; link = link->next) {
|
||||
Image *ima = (Image *)link->data;
|
||||
BKE_image_partial_update_mark_full_update(ima);
|
||||
}
|
||||
|
@ -556,14 +556,12 @@ static void multiresbake_freejob(void *bkv)
|
|||
static int multiresbake_image_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
MultiresBakeJob *bkr;
|
||||
wmJob *wm_job;
|
||||
|
||||
if (!multiresbake_check(C, op)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
bkr = MEM_callocN(sizeof(MultiresBakeJob), "MultiresBakeJob data");
|
||||
MultiresBakeJob *bkr = MEM_cnew<MultiresBakeJob>(__func__);
|
||||
init_multiresbake_job(C, bkr);
|
||||
|
||||
if (!bkr->data.first) {
|
||||
|
@ -572,15 +570,15 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
/* setup job */
|
||||
wm_job = WM_jobs_get(CTX_wm_manager(C),
|
||||
CTX_wm_window(C),
|
||||
scene,
|
||||
"Multires Bake",
|
||||
WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS,
|
||||
WM_JOB_TYPE_OBJECT_BAKE_TEXTURE);
|
||||
wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
|
||||
CTX_wm_window(C),
|
||||
scene,
|
||||
"Multires Bake",
|
||||
WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS,
|
||||
WM_JOB_TYPE_OBJECT_BAKE_TEXTURE);
|
||||
WM_jobs_customdata_set(wm_job, bkr, multiresbake_freejob);
|
||||
WM_jobs_timer(wm_job, 0.5, NC_IMAGE, 0); /* TODO: only draw bake image, can we enforce this. */
|
||||
WM_jobs_callbacks(wm_job, multiresbake_startjob, NULL, NULL, NULL);
|
||||
WM_jobs_callbacks(wm_job, multiresbake_startjob, nullptr, nullptr, nullptr);
|
||||
|
||||
G.is_break = false;
|
||||
|
||||
|
@ -596,7 +594,7 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op)
|
|||
/* ****************** render BAKING ********************** */
|
||||
|
||||
/** Catch escape key to cancel. */
|
||||
static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
||||
static int objects_bake_render_modal(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||
{
|
||||
/* no running blender, remove handler and pass through */
|
||||
if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) {
|
||||
|
@ -620,7 +618,7 @@ static bool is_multires_bake(Scene *scene)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int objects_bake_render_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(_event))
|
||||
static int objects_bake_render_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int result = OPERATOR_CANCELLED;
|
|
@ -65,7 +65,7 @@
|
|||
/* prototypes */
|
||||
static void bake_set_props(wmOperator *op, Scene *scene);
|
||||
|
||||
typedef struct BakeAPIRender {
|
||||
struct BakeAPIRender {
|
||||
/* Data to work on. */
|
||||
Main *main;
|
||||
Scene *scene;
|
||||
|
@ -113,13 +113,13 @@ typedef struct BakeAPIRender {
|
|||
ReportList *reports;
|
||||
int result;
|
||||
ScrArea *area;
|
||||
} BakeAPIRender;
|
||||
};
|
||||
|
||||
/* callbacks */
|
||||
|
||||
static void bake_progress_update(void *bjv, float progress)
|
||||
{
|
||||
BakeAPIRender *bj = bjv;
|
||||
BakeAPIRender *bj = static_cast<BakeAPIRender *>(bjv);
|
||||
|
||||
if (bj->progress && *bj->progress != progress) {
|
||||
*bj->progress = progress;
|
||||
|
@ -130,7 +130,7 @@ static void bake_progress_update(void *bjv, float progress)
|
|||
}
|
||||
|
||||
/** Catch escape key to cancel. */
|
||||
static int bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
||||
static int bake_modal(bContext *C, wmOperator * /*op*/, const wmEvent *event)
|
||||
{
|
||||
/* no running blender, remove handler and pass through */
|
||||
if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE)) {
|
||||
|
@ -151,7 +151,7 @@ static int bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
|||
* for exec() when there is no render job
|
||||
* NOTE: this won't check for the escape key being pressed, but doing so isn't thread-safe.
|
||||
*/
|
||||
static bool bake_break(void *UNUSED(rjv))
|
||||
static bool bake_break(void * /*rjv*/)
|
||||
{
|
||||
if (G.is_break) {
|
||||
return true;
|
||||
|
@ -162,7 +162,7 @@ static bool bake_break(void *UNUSED(rjv))
|
|||
static void bake_update_image(ScrArea *area, Image *image)
|
||||
{
|
||||
if (area && area->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */
|
||||
SpaceImage *sima = area->spacedata.first;
|
||||
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
||||
if (sima) {
|
||||
sima->image = image;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ static bool write_internal_bake_pixels(Image *image,
|
|||
ImBuf *ibuf;
|
||||
void *lock;
|
||||
bool is_float;
|
||||
char *mask_buffer = NULL;
|
||||
char *mask_buffer = nullptr;
|
||||
const size_t pixels_num = (size_t)width * (size_t)height;
|
||||
|
||||
ImageUser iuser;
|
||||
|
@ -199,11 +199,11 @@ static bool write_internal_bake_pixels(Image *image,
|
|||
}
|
||||
|
||||
if (margin > 0 || !is_clear) {
|
||||
mask_buffer = MEM_callocN(sizeof(char) * pixels_num, "Bake Mask");
|
||||
mask_buffer = static_cast<char *>(MEM_callocN(sizeof(char) * pixels_num, "Bake Mask"));
|
||||
RE_bake_mask_fill(pixel_array, pixels_num, mask_buffer);
|
||||
}
|
||||
|
||||
is_float = (ibuf->rect_float != NULL);
|
||||
is_float = (ibuf->rect_float != nullptr);
|
||||
|
||||
/* colormanagement conversions */
|
||||
if (!is_noncolor) {
|
||||
|
@ -296,7 +296,7 @@ static bool write_internal_bake_pixels(Image *image,
|
|||
imb_freemipmapImBuf(ibuf);
|
||||
}
|
||||
|
||||
BKE_image_release_ibuf(image, ibuf, NULL);
|
||||
BKE_image_release_ibuf(image, ibuf, nullptr);
|
||||
|
||||
if (mask_buffer) {
|
||||
MEM_freeN(mask_buffer);
|
||||
|
@ -332,7 +332,7 @@ static bool write_external_bake_pixels(const char *filepath,
|
|||
char const *uv_layer,
|
||||
const float uv_offset[2])
|
||||
{
|
||||
ImBuf *ibuf = NULL;
|
||||
ImBuf *ibuf = nullptr;
|
||||
bool ok = false;
|
||||
bool is_float;
|
||||
|
||||
|
@ -382,10 +382,10 @@ static bool write_external_bake_pixels(const char *filepath,
|
|||
|
||||
/* margins */
|
||||
if (margin > 0) {
|
||||
char *mask_buffer = NULL;
|
||||
char *mask_buffer = nullptr;
|
||||
const size_t pixels_num = (size_t)width * (size_t)height;
|
||||
|
||||
mask_buffer = MEM_callocN(sizeof(char) * pixels_num, "Bake Mask");
|
||||
mask_buffer = static_cast<char *>(MEM_callocN(sizeof(char) * pixels_num, "Bake Mask"));
|
||||
RE_bake_mask_fill(pixel_array, pixels_num, mask_buffer);
|
||||
RE_bake_margin(ibuf, mask_buffer, margin, margin_type, mesh_eval, uv_layer, uv_offset);
|
||||
|
||||
|
@ -429,7 +429,7 @@ static bool bake_object_check(const Scene *scene,
|
|||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
Base *base = BKE_view_layer_base_find(view_layer, ob);
|
||||
|
||||
if (base == NULL) {
|
||||
if (base == nullptr) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is not in view layer", ob->id.name + 2);
|
||||
return false;
|
||||
}
|
||||
|
@ -468,11 +468,11 @@ static bool bake_object_check(const Scene *scene,
|
|||
}
|
||||
|
||||
for (int i = 0; i < ob->totcol; i++) {
|
||||
const bNodeTree *ntree = NULL;
|
||||
const bNode *node = NULL;
|
||||
const bNodeTree *ntree = nullptr;
|
||||
const bNode *node = nullptr;
|
||||
const int mat_nr = i + 1;
|
||||
Image *image;
|
||||
ED_object_get_active_image(ob, mat_nr, &image, NULL, &node, &ntree);
|
||||
ED_object_get_active_image(ob, mat_nr, &image, nullptr, &node, &ntree);
|
||||
|
||||
if (image) {
|
||||
|
||||
|
@ -514,7 +514,7 @@ static bool bake_object_check(const Scene *scene,
|
|||
}
|
||||
else {
|
||||
Material *mat = BKE_object_material_get(ob, mat_nr);
|
||||
if (mat != NULL) {
|
||||
if (mat != nullptr) {
|
||||
BKE_reportf(reports,
|
||||
RPT_INFO,
|
||||
"No active image found in material \"%s\" (%d) for object \"%s\"",
|
||||
|
@ -614,7 +614,8 @@ static bool bake_objects_check(Main *bmain,
|
|||
return false;
|
||||
}
|
||||
|
||||
for (link = selected_objects->first; link; link = link->next) {
|
||||
for (link = static_cast<CollectionPointerLink *>(selected_objects->first); link;
|
||||
link = link->next) {
|
||||
Object *ob_iter = (Object *)link->ptr.data;
|
||||
|
||||
if (ob_iter == ob) {
|
||||
|
@ -643,8 +644,10 @@ static bool bake_objects_check(Main *bmain,
|
|||
return false;
|
||||
}
|
||||
|
||||
for (link = selected_objects->first; link; link = link->next) {
|
||||
if (!bake_object_check(scene, view_layer, link->ptr.data, target, reports)) {
|
||||
for (link = static_cast<CollectionPointerLink *>(selected_objects->first); link;
|
||||
link = link->next) {
|
||||
if (!bake_object_check(
|
||||
scene, view_layer, static_cast<Object *>(link->ptr.data), target, reports)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -655,8 +658,7 @@ static bool bake_objects_check(Main *bmain,
|
|||
/* it needs to be called after bake_objects_check since the image tagging happens there */
|
||||
static void bake_targets_clear(Main *bmain, const bool is_tangent)
|
||||
{
|
||||
Image *image;
|
||||
for (image = bmain->images.first; image; image = image->id.next) {
|
||||
LISTBASE_FOREACH (Image *, image, &bmain->images) {
|
||||
if ((image->id.tag & LIB_TAG_DOIT) != 0) {
|
||||
RE_bake_ibuf_clear(image, is_tangent);
|
||||
}
|
||||
|
@ -704,17 +706,17 @@ static bool bake_targets_init_image_textures(const BakeAPIRender *bkr,
|
|||
|
||||
/* Allocate material mapping. */
|
||||
targets->materials_num = materials_num;
|
||||
targets->material_to_image = MEM_callocN(sizeof(Image *) * targets->materials_num,
|
||||
"BakeTargets.material_to_image");
|
||||
targets->material_to_image = static_cast<Image **>(
|
||||
MEM_callocN(sizeof(Image *) * targets->materials_num, __func__));
|
||||
|
||||
/* Error handling and tag (in case multiple materials share the same image). */
|
||||
BKE_main_id_tag_idcode(bkr->main, ID_IM, LIB_TAG_DOIT, false);
|
||||
|
||||
targets->images = NULL;
|
||||
targets->images = nullptr;
|
||||
|
||||
for (int i = 0; i < materials_num; i++) {
|
||||
Image *image;
|
||||
ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL);
|
||||
ED_object_get_active_image(ob, i + 1, &image, nullptr, nullptr, nullptr);
|
||||
|
||||
targets->material_to_image[i] = image;
|
||||
|
||||
|
@ -723,8 +725,8 @@ static bool bake_targets_init_image_textures(const BakeAPIRender *bkr,
|
|||
if (image && !(image->id.tag & LIB_TAG_DOIT)) {
|
||||
LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) {
|
||||
/* Add bake image. */
|
||||
targets->images = MEM_recallocN(targets->images,
|
||||
sizeof(BakeImage) * (targets->images_num + 1));
|
||||
targets->images = static_cast<BakeImage *>(
|
||||
MEM_recallocN(targets->images, sizeof(BakeImage) * (targets->images_num + 1)));
|
||||
targets->images[targets->images_num].image = image;
|
||||
targets->images[targets->images_num].tile_number = tile->tile_number;
|
||||
targets->images_num++;
|
||||
|
@ -878,7 +880,7 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr,
|
|||
bake->im_format.imtype,
|
||||
true,
|
||||
false,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
if (bkr->is_automatic_name) {
|
||||
BLI_path_suffix(name, FILE_MAX, ob->id.name + 2, "_");
|
||||
|
@ -949,7 +951,7 @@ static bool bake_targets_init_vertex_colors(Main *bmain,
|
|||
return false;
|
||||
}
|
||||
|
||||
Mesh *me = ob->data;
|
||||
Mesh *me = static_cast<Mesh *>(ob->data);
|
||||
if (!BKE_id_attributes_color_find(&me->id, me->active_color_attribute)) {
|
||||
BKE_report(reports, RPT_ERROR, "No active color attribute to bake to");
|
||||
return false;
|
||||
|
@ -958,18 +960,18 @@ static bool bake_targets_init_vertex_colors(Main *bmain,
|
|||
/* Ensure mesh and editmesh topology are in sync. */
|
||||
ED_object_editmode_load(bmain, ob);
|
||||
|
||||
targets->images = MEM_callocN(sizeof(BakeImage), "BakeTargets.images");
|
||||
targets->images = MEM_cnew<BakeImage>(__func__);
|
||||
targets->images_num = 1;
|
||||
|
||||
targets->material_to_image = MEM_callocN(sizeof(int) * ob->totcol,
|
||||
"BakeTargets.material_to_image");
|
||||
targets->material_to_image = static_cast<Image **>(
|
||||
MEM_callocN(sizeof(Image *) * ob->totcol, __func__));
|
||||
targets->materials_num = ob->totcol;
|
||||
|
||||
BakeImage *bk_image = &targets->images[0];
|
||||
bk_image->width = me->totloop;
|
||||
bk_image->height = 1;
|
||||
bk_image->offset = 0;
|
||||
bk_image->image = NULL;
|
||||
bk_image->image = nullptr;
|
||||
|
||||
targets->pixels_num = bk_image->width * bk_image->height;
|
||||
|
||||
|
@ -1009,7 +1011,7 @@ static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
|
|||
Mesh *me_eval,
|
||||
BakePixel *pixel_array)
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
Mesh *me = static_cast<Mesh *>(ob->data);
|
||||
const int pixels_num = targets->pixels_num;
|
||||
|
||||
/* Initialize blank pixels. */
|
||||
|
@ -1029,7 +1031,7 @@ static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
|
|||
|
||||
/* Populate through adjacent triangles, first triangle wins. */
|
||||
const int tottri = poly_to_tri_count(me_eval->totpoly, me_eval->totloop);
|
||||
MLoopTri *looptri = MEM_mallocN(sizeof(*looptri) * tottri, __func__);
|
||||
MLoopTri *looptri = static_cast<MLoopTri *>(MEM_mallocN(sizeof(*looptri) * tottri, __func__));
|
||||
|
||||
const MLoop *loops = BKE_mesh_loops(me_eval);
|
||||
BKE_mesh_recalc_looptri(loops,
|
||||
|
@ -1040,8 +1042,10 @@ static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
|
|||
looptri);
|
||||
|
||||
/* For mapping back to original mesh in case there are modifiers. */
|
||||
const int *vert_origindex = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX);
|
||||
const int *poly_origindex = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
|
||||
const int *vert_origindex = static_cast<const int *>(
|
||||
CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX));
|
||||
const int *poly_origindex = static_cast<const int *>(
|
||||
CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX));
|
||||
const MPoly *orig_polys = BKE_mesh_polys(me);
|
||||
const MLoop *orig_loops = BKE_mesh_loops(me);
|
||||
|
||||
|
@ -1053,7 +1057,7 @@ static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
|
|||
uint v = loops[l].v;
|
||||
|
||||
/* Map back to original loop if there are modifiers. */
|
||||
if (vert_origindex != NULL && poly_origindex != NULL) {
|
||||
if (vert_origindex != nullptr && poly_origindex != nullptr) {
|
||||
l = find_original_loop(
|
||||
orig_polys, orig_loops, vert_origindex, poly_origindex, lt->poly, v);
|
||||
if (l == ORIGINDEX_NONE || l >= me->totloop) {
|
||||
|
@ -1129,11 +1133,11 @@ static void convert_float_color_to_byte_color(const MPropCol *float_colors,
|
|||
|
||||
static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
Mesh *me = static_cast<Mesh *>(ob->data);
|
||||
BMEditMesh *em = me->edit_mesh;
|
||||
CustomDataLayer *active_color_layer = BKE_id_attributes_color_find(&me->id,
|
||||
me->active_color_attribute);
|
||||
BLI_assert(active_color_layer != NULL);
|
||||
BLI_assert(active_color_layer != nullptr);
|
||||
const eAttrDomain domain = BKE_id_attribute_domain(&me->id, active_color_layer);
|
||||
|
||||
const int channels_num = targets->channels_num;
|
||||
|
@ -1144,10 +1148,12 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
|||
const int totvert = me->totvert;
|
||||
const int totloop = me->totloop;
|
||||
|
||||
MPropCol *mcol = MEM_malloc_arrayN(totvert, sizeof(MPropCol), __func__);
|
||||
MPropCol *mcol = static_cast<MPropCol *>(
|
||||
MEM_malloc_arrayN(totvert, sizeof(MPropCol), __func__));
|
||||
|
||||
/* Accumulate float vertex colors in scene linear color space. */
|
||||
int *num_loops_for_vertex = MEM_callocN(sizeof(int) * me->totvert, "num_loops_for_vertex");
|
||||
int *num_loops_for_vertex = static_cast<int *>(
|
||||
MEM_callocN(sizeof(int) * me->totvert, "num_loops_for_vertex"));
|
||||
memset(mcol, 0, sizeof(MPropCol) * me->totvert);
|
||||
|
||||
const MLoop *mloop = BKE_mesh_loops(me);
|
||||
|
@ -1177,7 +1183,8 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
|||
memcpy(data, &mcol[i], sizeof(MPropCol));
|
||||
}
|
||||
else {
|
||||
convert_float_color_to_byte_color(&mcol[i], 1, is_noncolor, data);
|
||||
convert_float_color_to_byte_color(
|
||||
&mcol[i], 1, is_noncolor, static_cast<MLoopCol *>(data));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -1188,7 +1195,8 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
|||
memcpy(active_color_layer->data, mcol, sizeof(MPropCol) * me->totvert);
|
||||
}
|
||||
else {
|
||||
convert_float_color_to_byte_color(mcol, totvert, is_noncolor, active_color_layer->data);
|
||||
convert_float_color_to_byte_color(
|
||||
mcol, totvert, is_noncolor, static_cast<MLoopCol *>(active_color_layer->data));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1218,7 +1226,8 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
|||
memcpy(data, &color, sizeof(MPropCol));
|
||||
}
|
||||
else {
|
||||
convert_float_color_to_byte_color(&color, 1, is_noncolor, data);
|
||||
convert_float_color_to_byte_color(
|
||||
&color, 1, is_noncolor, static_cast<MLoopCol *>(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1226,14 +1235,14 @@ static bool bake_targets_output_vertex_colors(BakeTargets *targets, Object *ob)
|
|||
else {
|
||||
/* Copy to mesh. */
|
||||
if (active_color_layer->type == CD_PROP_COLOR) {
|
||||
MPropCol *colors = active_color_layer->data;
|
||||
MPropCol *colors = static_cast<MPropCol *>(active_color_layer->data);
|
||||
for (int i = 0; i < me->totloop; i++) {
|
||||
zero_v4(colors[i].color);
|
||||
bake_result_add_to_rgba(colors[i].color, &result[i * channels_num], channels_num);
|
||||
}
|
||||
}
|
||||
else {
|
||||
MLoopCol *colors = active_color_layer->data;
|
||||
MLoopCol *colors = static_cast<MLoopCol *>(active_color_layer->data);
|
||||
for (int i = 0; i < me->totloop; i++) {
|
||||
MPropCol color;
|
||||
zero_v4(color.color);
|
||||
|
@ -1281,8 +1290,8 @@ static bool bake_targets_init(const BakeAPIRender *bkr,
|
|||
|
||||
targets->is_noncolor = is_noncolor_pass(bkr->pass_type);
|
||||
targets->channels_num = RE_pass_depth(bkr->pass_type);
|
||||
targets->result = MEM_callocN(sizeof(float) * targets->channels_num * targets->pixels_num,
|
||||
"bake return pixels");
|
||||
targets->result = static_cast<float *>(MEM_callocN(
|
||||
sizeof(float) * targets->channels_num * targets->pixels_num, "bake return pixels"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1352,23 +1361,23 @@ static int bake(const BakeAPIRender *bkr,
|
|||
int op_result = OPERATOR_CANCELLED;
|
||||
bool ok = false;
|
||||
|
||||
Object *ob_cage = NULL;
|
||||
Object *ob_cage_eval = NULL;
|
||||
Object *ob_low_eval = NULL;
|
||||
Object *ob_cage = nullptr;
|
||||
Object *ob_cage_eval = nullptr;
|
||||
Object *ob_low_eval = nullptr;
|
||||
|
||||
BakeHighPolyData *highpoly = NULL;
|
||||
BakeHighPolyData *highpoly = nullptr;
|
||||
int tot_highpoly = 0;
|
||||
|
||||
Mesh *me_low_eval = NULL;
|
||||
Mesh *me_cage_eval = NULL;
|
||||
Mesh *me_low_eval = nullptr;
|
||||
Mesh *me_cage_eval = nullptr;
|
||||
|
||||
MultiresModifierData *mmd_low = NULL;
|
||||
MultiresModifierData *mmd_low = nullptr;
|
||||
int mmd_flags_low = 0;
|
||||
|
||||
BakePixel *pixel_array_low = NULL;
|
||||
BakePixel *pixel_array_high = NULL;
|
||||
BakePixel *pixel_array_low = nullptr;
|
||||
BakePixel *pixel_array_high = nullptr;
|
||||
|
||||
BakeTargets targets = {NULL};
|
||||
BakeTargets targets = {nullptr};
|
||||
|
||||
const bool preserve_origindex = (bkr->target == R_BAKE_TARGET_VERTEX_COLORS);
|
||||
|
||||
|
@ -1395,8 +1404,9 @@ static int bake(const BakeAPIRender *bkr,
|
|||
CollectionPointerLink *link;
|
||||
tot_highpoly = 0;
|
||||
|
||||
for (link = selected_objects->first; link; link = link->next) {
|
||||
Object *ob_iter = link->ptr.data;
|
||||
for (link = static_cast<CollectionPointerLink *>(selected_objects->first); link;
|
||||
link = link->next) {
|
||||
Object *ob_iter = static_cast<Object *>(link->ptr.data);
|
||||
|
||||
if (ob_iter == ob_low) {
|
||||
continue;
|
||||
|
@ -1406,9 +1416,10 @@ static int bake(const BakeAPIRender *bkr,
|
|||
}
|
||||
|
||||
if (bkr->is_cage && bkr->custom_cage[0] != '\0') {
|
||||
ob_cage = BLI_findstring(&bmain->objects, bkr->custom_cage, offsetof(ID, name) + 2);
|
||||
ob_cage = static_cast<Object *>(
|
||||
BLI_findstring(&bmain->objects, bkr->custom_cage, offsetof(ID, name) + 2));
|
||||
|
||||
if (ob_cage == NULL || ob_cage->type != OB_MESH) {
|
||||
if (ob_cage == nullptr || ob_cage->type != OB_MESH) {
|
||||
BKE_report(reports, RPT_ERROR, "No valid cage object");
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -1445,8 +1456,9 @@ static int bake(const BakeAPIRender *bkr,
|
|||
|
||||
/* Populate the pixel array with the face data. Except if we use a cage, then
|
||||
* it is populated later with the cage mesh (smoothed version of the mesh). */
|
||||
pixel_array_low = MEM_mallocN(sizeof(BakePixel) * targets.pixels_num, "bake pixels low poly");
|
||||
if ((bkr->is_selected_to_active && (ob_cage == NULL) && bkr->is_cage) == false) {
|
||||
pixel_array_low = static_cast<BakePixel *>(
|
||||
MEM_mallocN(sizeof(BakePixel) * targets.pixels_num, "bake pixels low poly"));
|
||||
if ((bkr->is_selected_to_active && (ob_cage == nullptr) && bkr->is_cage) == false) {
|
||||
bake_targets_populate_pixels(bkr, &targets, ob_low, me_low_eval, pixel_array_low);
|
||||
}
|
||||
|
||||
|
@ -1469,7 +1481,7 @@ static int bake(const BakeAPIRender *bkr,
|
|||
else if (bkr->is_cage) {
|
||||
bool is_changed = false;
|
||||
|
||||
ModifierData *md = ob_low_eval->modifiers.first;
|
||||
ModifierData *md = static_cast<ModifierData *>(ob_low_eval->modifiers.first);
|
||||
while (md) {
|
||||
ModifierData *md_next = md->next;
|
||||
|
||||
|
@ -1498,15 +1510,17 @@ static int bake(const BakeAPIRender *bkr,
|
|||
BKE_object_handle_data_update(depsgraph, scene, ob_low_eval);
|
||||
}
|
||||
|
||||
me_cage_eval = BKE_mesh_new_from_object(NULL, ob_low_eval, false, preserve_origindex);
|
||||
me_cage_eval = BKE_mesh_new_from_object(nullptr, ob_low_eval, false, preserve_origindex);
|
||||
bake_targets_populate_pixels(bkr, &targets, ob_low, me_cage_eval, pixel_array_low);
|
||||
}
|
||||
|
||||
highpoly = MEM_callocN(sizeof(BakeHighPolyData) * tot_highpoly, "bake high poly objects");
|
||||
highpoly = static_cast<BakeHighPolyData *>(
|
||||
MEM_callocN(sizeof(BakeHighPolyData) * tot_highpoly, "bake high poly objects"));
|
||||
|
||||
/* populate highpoly array */
|
||||
for (link = selected_objects->first; link; link = link->next) {
|
||||
Object *ob_iter = link->ptr.data;
|
||||
for (link = static_cast<CollectionPointerLink *>(selected_objects->first); link;
|
||||
link = link->next) {
|
||||
Object *ob_iter = static_cast<Object *>(link->ptr.data);
|
||||
|
||||
if (ob_iter == ob_low) {
|
||||
continue;
|
||||
|
@ -1518,7 +1532,7 @@ static int bake(const BakeAPIRender *bkr,
|
|||
highpoly[i].ob_eval->visibility_flag &= ~OB_HIDE_RENDER;
|
||||
highpoly[i].ob_eval->base_flag |= (BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT |
|
||||
BASE_ENABLED_RENDER);
|
||||
highpoly[i].me = BKE_mesh_new_from_object(NULL, highpoly[i].ob_eval, false, false);
|
||||
highpoly[i].me = BKE_mesh_new_from_object(nullptr, highpoly[i].ob_eval, false, false);
|
||||
|
||||
/* Low-poly to high-poly transformation matrix. */
|
||||
copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world);
|
||||
|
@ -1531,7 +1545,7 @@ static int bake(const BakeAPIRender *bkr,
|
|||
|
||||
BLI_assert(i == tot_highpoly);
|
||||
|
||||
if (ob_cage != NULL) {
|
||||
if (ob_cage != nullptr) {
|
||||
ob_cage_eval->visibility_flag |= OB_HIDE_RENDER;
|
||||
ob_cage_eval->base_flag &= ~(BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT |
|
||||
BASE_ENABLED_RENDER);
|
||||
|
@ -1540,8 +1554,8 @@ static int bake(const BakeAPIRender *bkr,
|
|||
ob_low_eval->base_flag &= ~(BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT | BASE_ENABLED_RENDER);
|
||||
|
||||
/* populate the pixel arrays with the corresponding face data for each high poly object */
|
||||
pixel_array_high = MEM_mallocN(sizeof(BakePixel) * targets.pixels_num,
|
||||
"bake pixels high poly");
|
||||
pixel_array_high = static_cast<BakePixel *>(
|
||||
MEM_mallocN(sizeof(BakePixel) * targets.pixels_num, "bake pixels high poly"));
|
||||
|
||||
if (!RE_bake_pixels_populate_from_objects(
|
||||
me_low_eval,
|
||||
|
@ -1550,7 +1564,7 @@ static int bake(const BakeAPIRender *bkr,
|
|||
highpoly,
|
||||
tot_highpoly,
|
||||
targets.pixels_num,
|
||||
ob_cage != NULL,
|
||||
ob_cage != nullptr,
|
||||
bkr->cage_extrusion,
|
||||
bkr->max_ray_distance,
|
||||
ob_low_eval->object_to_world,
|
||||
|
@ -1637,8 +1651,8 @@ static int bake(const BakeAPIRender *bkr,
|
|||
}
|
||||
else {
|
||||
/* From multi-resolution. */
|
||||
Mesh *me_nores = NULL;
|
||||
ModifierData *md = NULL;
|
||||
Mesh *me_nores = nullptr;
|
||||
ModifierData *md = nullptr;
|
||||
int mode;
|
||||
|
||||
BKE_object_eval_reset(ob_low_eval);
|
||||
|
@ -1649,7 +1663,7 @@ static int bake(const BakeAPIRender *bkr,
|
|||
md->mode &= ~eModifierMode_Render;
|
||||
|
||||
/* Evaluate modifiers again. */
|
||||
me_nores = BKE_mesh_new_from_object(NULL, ob_low_eval, false, false);
|
||||
me_nores = BKE_mesh_new_from_object(nullptr, ob_low_eval, false, false);
|
||||
bake_targets_populate_pixels(bkr, &targets, ob_low, me_nores, pixel_array_low);
|
||||
}
|
||||
|
||||
|
@ -1662,7 +1676,7 @@ static int bake(const BakeAPIRender *bkr,
|
|||
ob_low_eval->object_to_world);
|
||||
|
||||
if (md) {
|
||||
BKE_id_free(NULL, &me_nores->id);
|
||||
BKE_id_free(nullptr, &me_nores->id);
|
||||
md->mode = mode;
|
||||
}
|
||||
}
|
||||
|
@ -1694,8 +1708,8 @@ cleanup:
|
|||
|
||||
if (highpoly) {
|
||||
for (int i = 0; i < tot_highpoly; i++) {
|
||||
if (highpoly[i].me != NULL) {
|
||||
BKE_id_free(NULL, &highpoly[i].me->id);
|
||||
if (highpoly[i].me != nullptr) {
|
||||
BKE_id_free(nullptr, &highpoly[i].me->id);
|
||||
}
|
||||
}
|
||||
MEM_freeN(highpoly);
|
||||
|
@ -1715,12 +1729,12 @@ cleanup:
|
|||
|
||||
bake_targets_free(&targets);
|
||||
|
||||
if (me_low_eval != NULL) {
|
||||
BKE_id_free(NULL, &me_low_eval->id);
|
||||
if (me_low_eval != nullptr) {
|
||||
BKE_id_free(nullptr, &me_low_eval->id);
|
||||
}
|
||||
|
||||
if (me_cage_eval != NULL) {
|
||||
BKE_id_free(NULL, &me_cage_eval->id);
|
||||
if (me_cage_eval != nullptr) {
|
||||
BKE_id_free(nullptr, &me_cage_eval->id);
|
||||
}
|
||||
|
||||
DEG_graph_free(depsgraph);
|
||||
|
@ -1738,12 +1752,12 @@ static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr)
|
|||
bkr->main = CTX_data_main(C);
|
||||
bkr->view_layer = CTX_data_view_layer(C);
|
||||
bkr->scene = CTX_data_scene(C);
|
||||
bkr->area = screen ? BKE_screen_find_big_area(screen, SPACE_IMAGE, 10) : NULL;
|
||||
bkr->area = screen ? BKE_screen_find_big_area(screen, SPACE_IMAGE, 10) : nullptr;
|
||||
|
||||
bkr->pass_type = RNA_enum_get(op->ptr, "type");
|
||||
bkr->pass_type = eScenePassType(RNA_enum_get(op->ptr, "type"));
|
||||
bkr->pass_filter = RNA_enum_get(op->ptr, "pass_filter");
|
||||
bkr->margin = RNA_int_get(op->ptr, "margin");
|
||||
bkr->margin_type = RNA_enum_get(op->ptr, "margin_type");
|
||||
bkr->margin_type = eBakeMarginType(RNA_enum_get(op->ptr, "margin_type"));
|
||||
|
||||
bkr->save_mode = (eBakeSaveMode)RNA_enum_get(op->ptr, "save_mode");
|
||||
bkr->target = (eBakeTarget)RNA_enum_get(op->ptr, "target");
|
||||
|
@ -1759,9 +1773,9 @@ static void bake_init_api_data(wmOperator *op, bContext *C, BakeAPIRender *bkr)
|
|||
bkr->max_ray_distance = RNA_float_get(op->ptr, "max_ray_distance");
|
||||
|
||||
bkr->normal_space = RNA_enum_get(op->ptr, "normal_space");
|
||||
bkr->normal_swizzle[0] = RNA_enum_get(op->ptr, "normal_r");
|
||||
bkr->normal_swizzle[1] = RNA_enum_get(op->ptr, "normal_g");
|
||||
bkr->normal_swizzle[2] = RNA_enum_get(op->ptr, "normal_b");
|
||||
bkr->normal_swizzle[0] = eBakeNormalSwizzle(RNA_enum_get(op->ptr, "normal_r"));
|
||||
bkr->normal_swizzle[1] = eBakeNormalSwizzle(RNA_enum_get(op->ptr, "normal_g"));
|
||||
bkr->normal_swizzle[2] = eBakeNormalSwizzle(RNA_enum_get(op->ptr, "normal_b"));
|
||||
|
||||
bkr->width = RNA_int_get(op->ptr, "width");
|
||||
bkr->height = RNA_int_get(op->ptr, "height");
|
||||
|
@ -1800,7 +1814,7 @@ static int bake_exec(bContext *C, wmOperator *op)
|
|||
{
|
||||
Render *re;
|
||||
int result = OPERATOR_CANCELLED;
|
||||
BakeAPIRender bkr = {NULL};
|
||||
BakeAPIRender bkr = {nullptr};
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
G.is_break = false;
|
||||
|
@ -1812,7 +1826,7 @@ static int bake_exec(bContext *C, wmOperator *op)
|
|||
re = bkr.render;
|
||||
|
||||
/* setup new render */
|
||||
RE_test_break_cb(re, NULL, bake_break);
|
||||
RE_test_break_cb(re, nullptr, bake_break);
|
||||
|
||||
if (!bake_pass_filter_check(bkr.pass_type, bkr.pass_filter, bkr.reports)) {
|
||||
goto finally;
|
||||
|
@ -1843,13 +1857,14 @@ static int bake_exec(bContext *C, wmOperator *op)
|
|||
else {
|
||||
CollectionPointerLink *link;
|
||||
bkr.is_clear = bkr.is_clear && BLI_listbase_is_single(&bkr.selected_objects);
|
||||
for (link = bkr.selected_objects.first; link; link = link->next) {
|
||||
Object *ob_iter = link->ptr.data;
|
||||
result = bake(&bkr, ob_iter, NULL, bkr.reports);
|
||||
for (link = static_cast<CollectionPointerLink *>(bkr.selected_objects.first); link;
|
||||
link = link->next) {
|
||||
Object *ob_iter = static_cast<Object *>(link->ptr.data);
|
||||
result = bake(&bkr, ob_iter, nullptr, bkr.reports);
|
||||
}
|
||||
}
|
||||
|
||||
RE_SetReports(re, NULL);
|
||||
RE_SetReports(re, nullptr);
|
||||
|
||||
finally:
|
||||
G.is_rendering = false;
|
||||
|
@ -1857,7 +1872,7 @@ finally:
|
|||
return result;
|
||||
}
|
||||
|
||||
static void bake_startjob(void *bkv, bool *UNUSED(stop), bool *do_update, float *progress)
|
||||
static void bake_startjob(void *bkv, bool * /*stop*/, bool *do_update, float *progress)
|
||||
{
|
||||
BakeAPIRender *bkr = (BakeAPIRender *)bkv;
|
||||
|
||||
|
@ -1896,9 +1911,10 @@ static void bake_startjob(void *bkv, bool *UNUSED(stop), bool *do_update, float
|
|||
else {
|
||||
CollectionPointerLink *link;
|
||||
bkr->is_clear = bkr->is_clear && BLI_listbase_is_single(&bkr->selected_objects);
|
||||
for (link = bkr->selected_objects.first; link; link = link->next) {
|
||||
Object *ob_iter = link->ptr.data;
|
||||
bkr->result = bake(bkr, ob_iter, NULL, bkr->reports);
|
||||
for (link = static_cast<CollectionPointerLink *>(bkr->selected_objects.first); link;
|
||||
link = link->next) {
|
||||
Object *ob_iter = static_cast<Object *>(link->ptr.data);
|
||||
bkr->result = bake(bkr, ob_iter, nullptr, bkr->reports);
|
||||
|
||||
if (bkr->result == OPERATOR_CANCELLED) {
|
||||
return;
|
||||
|
@ -1906,7 +1922,7 @@ static void bake_startjob(void *bkv, bool *UNUSED(stop), bool *do_update, float
|
|||
}
|
||||
}
|
||||
|
||||
RE_SetReports(bkr->render, NULL);
|
||||
RE_SetReports(bkr->render, nullptr);
|
||||
}
|
||||
|
||||
static void bake_job_complete(void *bkv)
|
||||
|
@ -2037,10 +2053,9 @@ static void bake_set_props(wmOperator *op, Scene *scene)
|
|||
}
|
||||
}
|
||||
|
||||
static int bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
||||
static int bake_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
wmJob *wm_job;
|
||||
BakeAPIRender *bkr;
|
||||
Render *re;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
|
@ -2051,7 +2066,7 @@ static int bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
bkr = MEM_mallocN(sizeof(BakeAPIRender), "render bake");
|
||||
BakeAPIRender *bkr = static_cast<BakeAPIRender *>(MEM_mallocN(sizeof(BakeAPIRender), __func__));
|
||||
|
||||
/* init bake render */
|
||||
bake_init_api_data(op, C, bkr);
|
||||
|
@ -2059,7 +2074,7 @@ static int bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
|
|||
re = bkr->render;
|
||||
|
||||
/* setup new render */
|
||||
RE_test_break_cb(re, NULL, bake_break);
|
||||
RE_test_break_cb(re, nullptr, bake_break);
|
||||
RE_progress_cb(re, bkr, bake_progress_update);
|
||||
|
||||
/* setup job */
|
||||
|
@ -2074,7 +2089,7 @@ static int bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
|
|||
WM_jobs_timer(
|
||||
wm_job, 0.5, (bkr->target == R_BAKE_TARGET_VERTEX_COLORS) ? NC_GEOM | ND_DATA : NC_IMAGE, 0);
|
||||
WM_jobs_callbacks_ex(
|
||||
wm_job, bake_startjob, NULL, NULL, NULL, bake_job_complete, bake_job_canceled);
|
||||
wm_job, bake_startjob, nullptr, nullptr, nullptr, bake_job_complete, bake_job_canceled);
|
||||
|
||||
G.is_break = false;
|
||||
G.is_rendering = true;
|
||||
|
@ -2121,7 +2136,7 @@ void OBJECT_OT_bake(wmOperatorType *ot)
|
|||
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
|
||||
RNA_def_string_file_path(ot->srna,
|
||||
"filepath",
|
||||
NULL,
|
||||
nullptr,
|
||||
FILE_MAX,
|
||||
"File Path",
|
||||
"Image filepath to use when saving externally");
|
||||
|
@ -2185,7 +2200,7 @@ void OBJECT_OT_bake(wmOperatorType *ot)
|
|||
1.0f);
|
||||
RNA_def_string(ot->srna,
|
||||
"cage_object",
|
||||
NULL,
|
||||
nullptr,
|
||||
MAX_NAME,
|
||||
"Cage Object",
|
||||
"Object to use as cage, instead of calculating the cage from the active object "
|
||||
|
@ -2245,7 +2260,7 @@ void OBJECT_OT_bake(wmOperatorType *ot)
|
|||
"Automatically name the output file with the pass type");
|
||||
RNA_def_string(ot->srna,
|
||||
"uv_layer",
|
||||
NULL,
|
||||
nullptr,
|
||||
MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX,
|
||||
"UV Layer",
|
||||
"UV layer to override active");
|
|
@ -114,7 +114,7 @@ void FLUID_OT_bake_guides(struct wmOperatorType *ot);
|
|||
void FLUID_OT_free_guides(struct wmOperatorType *ot);
|
||||
void FLUID_OT_pause_bake(struct wmOperatorType *ot);
|
||||
|
||||
/* dynamicpaint.c */
|
||||
/* dynamicpaint.cc */
|
||||
|
||||
void DPAINT_OT_bake(struct wmOperatorType *ot);
|
||||
/**
|
||||
|
|
|
@ -1865,7 +1865,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event
|
|||
return OPERATOR_FINISHED;
|
||||
}
|
||||
case SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC: {
|
||||
expand_cache->falloff_gradient = SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC;
|
||||
expand_cache->falloff_gradient = true;
|
||||
sculpt_expand_check_topology_islands(ob);
|
||||
|
||||
sculpt_expand_falloff_factors_from_vertex_and_symm_create(
|
||||
|
@ -1889,7 +1889,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator *op, const wmEvent *event
|
|||
break;
|
||||
}
|
||||
case SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS: {
|
||||
expand_cache->falloff_gradient = SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS;
|
||||
expand_cache->falloff_gradient = true;
|
||||
sculpt_expand_check_topology_islands(ob);
|
||||
|
||||
sculpt_expand_falloff_factors_from_vertex_and_symm_create(
|
||||
|
|
|
@ -29,7 +29,7 @@ set(INC_SYS
|
|||
)
|
||||
|
||||
set(SRC
|
||||
drawobject.c
|
||||
drawobject.cc
|
||||
space_view3d.cc
|
||||
view3d_buttons.c
|
||||
view3d_camera_control.c
|
||||
|
|
|
@ -53,11 +53,11 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
|
|||
return;
|
||||
}
|
||||
|
||||
const Mesh *me = ob->data;
|
||||
const Mesh *me = static_cast<const Mesh *>(ob->data);
|
||||
{
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||
const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
|
||||
if (me_eval != NULL) {
|
||||
if (me_eval != nullptr) {
|
||||
me = me_eval;
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
|
|||
GPU_front_facing(ob->transflag & OB_NEG_SCALE);
|
||||
|
||||
/* Just to create the data to pass to immediate mode! (sigh) */
|
||||
const int *facemap_data = CustomData_get_layer(&me->pdata, CD_FACEMAP);
|
||||
const int *facemap_data = static_cast<const int *>(CustomData_get_layer(&me->pdata, CD_FACEMAP));
|
||||
if (facemap_data) {
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
|
@ -76,7 +76,7 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
|
|||
int mpoly_len = me->totpoly;
|
||||
int mloop_len = me->totloop;
|
||||
|
||||
facemap_data = CustomData_get_layer(&me->pdata, CD_FACEMAP);
|
||||
facemap_data = static_cast<const int *>(CustomData_get_layer(&me->pdata, CD_FACEMAP));
|
||||
|
||||
/* Make a batch and free it each time for now. */
|
||||
const int looptris_len = poly_to_tri_count(mpoly_len, mloop_len);
|
||||
|
@ -100,9 +100,12 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
|
|||
for (mp = polys, i = 0; i < mpoly_len; i++, mp++) {
|
||||
if (facemap_data[i] == facemap) {
|
||||
for (int j = 2; j < mp->totloop; j++) {
|
||||
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), positions[loops[mlt->tri[0]].v]);
|
||||
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), positions[loops[mlt->tri[1]].v]);
|
||||
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), positions[loops[mlt->tri[2]].v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[loops[mlt->tri[0]].v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[loops[mlt->tri[1]].v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[loops[mlt->tri[2]].v]);
|
||||
vbo_len_used += 3;
|
||||
mlt++;
|
||||
}
|
||||
|
@ -120,9 +123,10 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
|
|||
const MLoop *ml_a = ml_start + 1;
|
||||
const MLoop *ml_b = ml_start + 2;
|
||||
for (int j = 2; j < mp->totloop; j++) {
|
||||
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), positions[ml_start->v]);
|
||||
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), positions[ml_a->v]);
|
||||
copy_v3_v3(GPU_vertbuf_raw_step(&pos_step), positions[ml_b->v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[ml_start->v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)), positions[ml_a->v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)), positions[ml_b->v]);
|
||||
vbo_len_used += 3;
|
||||
|
||||
ml_a++;
|
||||
|
@ -136,7 +140,7 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
|
|||
GPU_vertbuf_data_resize(vbo_pos, vbo_len_used);
|
||||
}
|
||||
|
||||
GPUBatch *draw_batch = GPU_batch_create(GPU_PRIM_TRIS, vbo_pos, NULL);
|
||||
GPUBatch *draw_batch = GPU_batch_create(GPU_PRIM_TRIS, vbo_pos, nullptr);
|
||||
GPU_batch_program_set_builtin(draw_batch, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
GPU_batch_uniform_4fv(draw_batch, "color", col);
|
||||
GPU_batch_draw(draw_batch);
|
|
@ -30,6 +30,7 @@ set(SRC
|
|||
transform_convert_armature.c
|
||||
transform_convert_cursor.c
|
||||
transform_convert_curve.c
|
||||
transform_convert_curves.cc
|
||||
transform_convert_gpencil.c
|
||||
transform_convert_graph.c
|
||||
transform_convert_lattice.c
|
||||
|
|
|
@ -713,6 +713,7 @@ static void init_proportional_edit(TransInfo *t)
|
|||
if (!ELEM(t->data_type,
|
||||
&TransConvertType_Action,
|
||||
&TransConvertType_Curve,
|
||||
&TransConvertType_Curves,
|
||||
&TransConvertType_Graph,
|
||||
&TransConvertType_GPencil,
|
||||
&TransConvertType_Lattice,
|
||||
|
@ -784,6 +785,7 @@ static void init_TransDataContainers(TransInfo *t,
|
|||
&TransConvertType_Pose,
|
||||
&TransConvertType_EditArmature,
|
||||
&TransConvertType_Curve,
|
||||
&TransConvertType_Curves,
|
||||
&TransConvertType_GPencil,
|
||||
&TransConvertType_Lattice,
|
||||
&TransConvertType_MBall,
|
||||
|
@ -959,6 +961,9 @@ static TransConvertTypeInfo *convert_type_get(const TransInfo *t, Object **r_obj
|
|||
if (t->obedit_type == OB_ARMATURE) {
|
||||
return &TransConvertType_EditArmature;
|
||||
}
|
||||
if (t->obedit_type == OB_CURVES) {
|
||||
return &TransConvertType_Curves;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
if (ob && (ob->mode & OB_MODE_POSE)) {
|
||||
|
|
|
@ -134,6 +134,10 @@ extern TransConvertTypeInfo TransConvertType_Cursor3D;
|
|||
|
||||
extern TransConvertTypeInfo TransConvertType_Curve;
|
||||
|
||||
/* transform_convert_curves.cc */
|
||||
|
||||
extern TransConvertTypeInfo TransConvertType_Curves;
|
||||
|
||||
/* transform_convert_graph.c */
|
||||
|
||||
extern TransConvertTypeInfo TransConvertType_Graph;
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup edtransform
|
||||
*/
|
||||
|
||||
#include "BLI_array.hh"
|
||||
#include "BLI_index_mask_ops.hh"
|
||||
#include "BLI_span.hh"
|
||||
|
||||
#include "BKE_curves.hh"
|
||||
|
||||
#include "ED_curves.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "transform.h"
|
||||
#include "transform_convert.h"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Curve/Surfaces Transform Creation
|
||||
* \{ */
|
||||
|
||||
namespace blender::ed::transform::curves {
|
||||
|
||||
static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t)
|
||||
{
|
||||
MutableSpan<TransDataContainer> trans_data_contrainers(t->data_container, t->data_container_len);
|
||||
Array<Vector<int64_t>> selected_indices_per_object(t->data_container_len);
|
||||
Array<IndexMask> selection_per_object(t->data_container_len);
|
||||
|
||||
/* Count selected elements per object and create TransData structs. */
|
||||
for (const int i : trans_data_contrainers.index_range()) {
|
||||
TransDataContainer &tc = trans_data_contrainers[i];
|
||||
Curves *curves_id = static_cast<Curves *>(tc.obedit->data);
|
||||
bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry);
|
||||
|
||||
selection_per_object[i] = ed::curves::retrieve_selected_points(curves,
|
||||
selected_indices_per_object[i]);
|
||||
|
||||
tc.data_len = selection_per_object[i].size();
|
||||
if (tc.data_len > 0) {
|
||||
tc.data = MEM_cnew_array<TransData>(tc.data_len, __func__);
|
||||
}
|
||||
}
|
||||
|
||||
/* Populate TransData structs. */
|
||||
for (const int i : trans_data_contrainers.index_range()) {
|
||||
TransDataContainer &tc = trans_data_contrainers[i];
|
||||
if (tc.data_len == 0) {
|
||||
continue;
|
||||
}
|
||||
Curves *curves_id = static_cast<Curves *>(tc.obedit->data);
|
||||
bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry);
|
||||
IndexMask selected_indices = selection_per_object[i];
|
||||
|
||||
float mtx[3][3], smtx[3][3];
|
||||
copy_m3_m4(mtx, tc.obedit->object_to_world);
|
||||
pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON);
|
||||
|
||||
MutableSpan<float3> positions = curves.positions_for_write();
|
||||
threading::parallel_for(selected_indices.index_range(), 1024, [&](const IndexRange range) {
|
||||
for (const int selection_i : range) {
|
||||
TransData *td = &tc.data[selection_i];
|
||||
float *elem = reinterpret_cast<float *>(&positions[selected_indices[selection_i]]);
|
||||
copy_v3_v3(td->iloc, elem);
|
||||
copy_v3_v3(td->center, td->iloc);
|
||||
td->loc = elem;
|
||||
|
||||
td->flag = TD_SELECTED;
|
||||
td->ext = nullptr;
|
||||
|
||||
copy_m3_m3(td->smtx, smtx);
|
||||
copy_m3_m3(td->mtx, mtx);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static void recalcData_curves(TransInfo *t)
|
||||
{
|
||||
Span<TransDataContainer> trans_data_contrainers(t->data_container, t->data_container_len);
|
||||
for (const TransDataContainer &tc : trans_data_contrainers) {
|
||||
Curves *curves_id = static_cast<Curves *>(tc.obedit->data);
|
||||
bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id->geometry);
|
||||
|
||||
curves.calculate_bezier_auto_handles();
|
||||
curves.tag_positions_changed();
|
||||
DEG_id_tag_update(&curves_id->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::ed::transform::curves
|
||||
|
||||
/** \} */
|
||||
|
||||
TransConvertTypeInfo TransConvertType_Curves = {
|
||||
/*flags*/ (T_EDIT | T_POINTS),
|
||||
/*createTransData*/ blender::ed::transform::curves::createTransCurvesVerts,
|
||||
/*recalcData*/ blender::ed::transform::curves::recalcData_curves,
|
||||
/*special_aftertrans_update*/ nullptr,
|
||||
};
|
|
@ -32,7 +32,7 @@ set(SRC
|
|||
uvedit_rip.c
|
||||
uvedit_select.c
|
||||
uvedit_smart_stitch.c
|
||||
uvedit_unwrap_ops.c
|
||||
uvedit_unwrap_ops.cc
|
||||
|
||||
uvedit_clipboard_graph_iso.hh
|
||||
uvedit_intern.h
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -52,6 +52,64 @@ static int64_t compute_grain_size(const ExecutionHints &hints, const IndexMask m
|
|||
return grain_size;
|
||||
}
|
||||
|
||||
static int64_t compute_alignment(const int64_t grain_size)
|
||||
{
|
||||
if (grain_size <= 512) {
|
||||
/* Don't use a number that's too large, or otherwise the work will be split quite unevenly. */
|
||||
return 8;
|
||||
}
|
||||
/* It's not common that more elements are processed in a loop at once. */
|
||||
return 32;
|
||||
}
|
||||
|
||||
static void add_sliced_parameters(const Signature &signature,
|
||||
Params &full_params,
|
||||
const IndexRange slice_range,
|
||||
ParamsBuilder &r_sliced_params)
|
||||
{
|
||||
for (const int param_index : signature.params.index_range()) {
|
||||
const ParamType ¶m_type = signature.params[param_index].type;
|
||||
switch (param_type.category()) {
|
||||
case ParamCategory::SingleInput: {
|
||||
const GVArray &varray = full_params.readonly_single_input(param_index);
|
||||
r_sliced_params.add_readonly_single_input(varray.slice(slice_range));
|
||||
break;
|
||||
}
|
||||
case ParamCategory::SingleMutable: {
|
||||
const GMutableSpan span = full_params.single_mutable(param_index);
|
||||
const GMutableSpan sliced_span = span.slice(slice_range);
|
||||
r_sliced_params.add_single_mutable(sliced_span);
|
||||
break;
|
||||
}
|
||||
case ParamCategory::SingleOutput: {
|
||||
if (bool(signature.params[param_index].flag & ParamFlag::SupportsUnusedOutput)) {
|
||||
const GMutableSpan span = full_params.uninitialized_single_output_if_required(
|
||||
param_index);
|
||||
if (span.is_empty()) {
|
||||
r_sliced_params.add_ignored_single_output();
|
||||
}
|
||||
else {
|
||||
const GMutableSpan sliced_span = span.slice(slice_range);
|
||||
r_sliced_params.add_uninitialized_single_output(sliced_span);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const GMutableSpan span = full_params.uninitialized_single_output(param_index);
|
||||
const GMutableSpan sliced_span = span.slice(slice_range);
|
||||
r_sliced_params.add_uninitialized_single_output(sliced_span);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ParamCategory::VectorInput:
|
||||
case ParamCategory::VectorMutable:
|
||||
case ParamCategory::VectorOutput: {
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MultiFunction::call_auto(IndexMask mask, Params params, Context context) const
|
||||
{
|
||||
if (mask.is_empty()) {
|
||||
|
@ -71,71 +129,31 @@ void MultiFunction::call_auto(IndexMask mask, Params params, Context context) co
|
|||
return;
|
||||
}
|
||||
|
||||
threading::parallel_for(mask.index_range(), grain_size, [&](const IndexRange sub_range) {
|
||||
const IndexMask sliced_mask = mask.slice(sub_range);
|
||||
if (!hints.allocates_array) {
|
||||
/* There is no benefit to changing indices in this case. */
|
||||
this->call(sliced_mask, params, context);
|
||||
return;
|
||||
}
|
||||
if (sliced_mask[0] < grain_size) {
|
||||
/* The indices are low, no need to offset them. */
|
||||
this->call(sliced_mask, params, context);
|
||||
return;
|
||||
}
|
||||
const int64_t input_slice_start = sliced_mask[0];
|
||||
const int64_t input_slice_size = sliced_mask.last() - input_slice_start + 1;
|
||||
const IndexRange input_slice_range{input_slice_start, input_slice_size};
|
||||
|
||||
Vector<int64_t> offset_mask_indices;
|
||||
const IndexMask offset_mask = mask.slice_and_offset(sub_range, offset_mask_indices);
|
||||
|
||||
ParamsBuilder offset_params{*this, offset_mask.min_array_size()};
|
||||
|
||||
/* Slice all parameters so that for the actual function call. */
|
||||
for (const int param_index : this->param_indices()) {
|
||||
const ParamType param_type = this->param_type(param_index);
|
||||
switch (param_type.category()) {
|
||||
case ParamCategory::SingleInput: {
|
||||
const GVArray &varray = params.readonly_single_input(param_index);
|
||||
offset_params.add_readonly_single_input(varray.slice(input_slice_range));
|
||||
break;
|
||||
const int64_t alignment = compute_alignment(grain_size);
|
||||
threading::parallel_for_aligned(
|
||||
mask.index_range(), grain_size, alignment, [&](const IndexRange sub_range) {
|
||||
const IndexMask sliced_mask = mask.slice(sub_range);
|
||||
if (!hints.allocates_array) {
|
||||
/* There is no benefit to changing indices in this case. */
|
||||
this->call(sliced_mask, params, context);
|
||||
return;
|
||||
}
|
||||
case ParamCategory::SingleMutable: {
|
||||
const GMutableSpan span = params.single_mutable(param_index);
|
||||
const GMutableSpan sliced_span = span.slice(input_slice_range);
|
||||
offset_params.add_single_mutable(sliced_span);
|
||||
break;
|
||||
if (sliced_mask[0] < grain_size) {
|
||||
/* The indices are low, no need to offset them. */
|
||||
this->call(sliced_mask, params, context);
|
||||
return;
|
||||
}
|
||||
case ParamCategory::SingleOutput: {
|
||||
if (bool(signature_ref_->params[param_index].flag & ParamFlag::SupportsUnusedOutput)) {
|
||||
const GMutableSpan span = params.uninitialized_single_output_if_required(param_index);
|
||||
if (span.is_empty()) {
|
||||
offset_params.add_ignored_single_output();
|
||||
}
|
||||
else {
|
||||
const GMutableSpan sliced_span = span.slice(input_slice_range);
|
||||
offset_params.add_uninitialized_single_output(sliced_span);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const GMutableSpan span = params.uninitialized_single_output(param_index);
|
||||
const GMutableSpan sliced_span = span.slice(input_slice_range);
|
||||
offset_params.add_uninitialized_single_output(sliced_span);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ParamCategory::VectorInput:
|
||||
case ParamCategory::VectorMutable:
|
||||
case ParamCategory::VectorOutput: {
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const int64_t input_slice_start = sliced_mask[0];
|
||||
const int64_t input_slice_size = sliced_mask.last() - input_slice_start + 1;
|
||||
const IndexRange input_slice_range{input_slice_start, input_slice_size};
|
||||
|
||||
this->call(offset_mask, offset_params, context);
|
||||
});
|
||||
Vector<int64_t> offset_mask_indices;
|
||||
const IndexMask offset_mask = mask.slice_and_offset(sub_range, offset_mask_indices);
|
||||
|
||||
ParamsBuilder sliced_params{*this, offset_mask.min_array_size()};
|
||||
add_sliced_parameters(*signature_ref_, params, input_slice_range, sliced_params);
|
||||
this->call(offset_mask, sliced_params, context);
|
||||
});
|
||||
}
|
||||
|
||||
std::string MultiFunction::debug_name() const
|
||||
|
|
|
@ -1094,6 +1094,8 @@ typedef struct ExplodeModifierData {
|
|||
} ExplodeModifierData;
|
||||
|
||||
typedef struct MultiresModifierData {
|
||||
DNA_DEFINE_CXX_METHODS(MultiresModifierData)
|
||||
|
||||
ModifierData modifier;
|
||||
|
||||
char lvl, sculptlvl, renderlvl, totlvl;
|
||||
|
|
|
@ -238,7 +238,6 @@ static void compute_point_counts_per_child(const bke::CurvesGeometry &guide_curv
|
|||
{
|
||||
const OffsetIndices guide_points_by_curve = guide_curves.points_by_curve();
|
||||
threading::parallel_for(r_points_per_child.index_range(), 512, [&](const IndexRange range) {
|
||||
int points_sum = 0;
|
||||
for (const int child_curve_i : range) {
|
||||
const int neighbor_count = all_neighbor_counts[child_curve_i];
|
||||
if (neighbor_count == 0) {
|
||||
|
@ -250,7 +249,6 @@ static void compute_point_counts_per_child(const bke::CurvesGeometry &guide_curv
|
|||
const int points_per_curve_in_group = points_per_curve_by_group.lookup_default(group, -1);
|
||||
if (points_per_curve_in_group != -1) {
|
||||
r_points_per_child[child_curve_i] = points_per_curve_in_group;
|
||||
points_sum += points_per_curve_in_group;
|
||||
r_use_direct_interpolation[child_curve_i] = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -268,7 +266,6 @@ static void compute_point_counts_per_child(const bke::CurvesGeometry &guide_curv
|
|||
const int points_in_child = std::max<int>(1, roundf(neighbor_points_weighted_sum));
|
||||
r_points_per_child[child_curve_i] = points_in_child;
|
||||
r_use_direct_interpolation[child_curve_i] = false;
|
||||
points_sum += r_points_per_child[child_curve_i];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -89,6 +89,20 @@
|
|||
*/
|
||||
#define USE_WIN_ACTIVATE
|
||||
|
||||
/**
|
||||
* When the window is de-activated, release all held modifiers.
|
||||
*
|
||||
* Needed so events generated over unfocused (non-active) windows don't have modifiers held.
|
||||
* Since modifier press/release events aren't send to unfocused windows it's best to assume
|
||||
* modifiers are not pressed. This means when modifiers *are* held, events will incorrectly
|
||||
* reported as not being held. Since this is standard behavior for Linux/MS-Window,
|
||||
* opt to use this.
|
||||
*
|
||||
* NOTE(@campbellbarton): Events generated for non-active windows are rare,
|
||||
* this happens when using the mouse-wheel over an unfocused window, see: T103722.
|
||||
*/
|
||||
#define USE_WIN_DEACTIVATE
|
||||
|
||||
/* the global to talk to ghost */
|
||||
static GHOST_SystemHandle g_system = NULL;
|
||||
#if !(defined(WIN32) || defined(__APPLE__))
|
||||
|
@ -1130,6 +1144,41 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_pt
|
|||
|
||||
switch (type) {
|
||||
case GHOST_kEventWindowDeactivate:
|
||||
#ifdef USE_WIN_DEACTIVATE
|
||||
/* Release all held modifiers before de-activating the window. */
|
||||
if (win->eventstate->modifier != 0) {
|
||||
const uint8_t keymodifier_eventstate = win->eventstate->modifier;
|
||||
const uint8_t keymodifier_l = wm_ghost_modifier_query(MOD_SIDE_LEFT);
|
||||
const uint8_t keymodifier_r = wm_ghost_modifier_query(MOD_SIDE_RIGHT);
|
||||
/* NOTE(@campbellbarton): when non-zero, there are modifiers held in
|
||||
* `win->eventstate` which are not considered held by the GHOST internal state.
|
||||
* While this should not happen, it's important all modifier held in event-state
|
||||
* receive release events. Without this, so any events generated while the window
|
||||
* is *not* active will have modifiers held. */
|
||||
const uint8_t keymodifier_unhandled = keymodifier_eventstate &
|
||||
~(keymodifier_l | keymodifier_r);
|
||||
const uint8_t keymodifier_sided[2] = {
|
||||
keymodifier_l | keymodifier_unhandled,
|
||||
keymodifier_r,
|
||||
};
|
||||
GHOST_TEventKeyData kdata = {
|
||||
.key = GHOST_kKeyUnknown,
|
||||
.utf8_buf = {'\0'},
|
||||
.is_repeat = false,
|
||||
};
|
||||
for (int i = 0; i < ARRAY_SIZE(g_modifier_table); i++) {
|
||||
if (keymodifier_eventstate & g_modifier_table[i].flag) {
|
||||
for (int side = 0; side < 2; side++) {
|
||||
if ((keymodifier_sided[side] & g_modifier_table[i].flag) == 0) {
|
||||
kdata.key = g_modifier_table[i].ghost_key_pair[side];
|
||||
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, &kdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* USE_WIN_DEACTIVATE */
|
||||
|
||||
wm_event_add_ghostevent(wm, win, type, data);
|
||||
win->active = 0; /* XXX */
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue