Merge branch 'master' into blender2.8

This commit is contained in:
Sergey Sharybin 2017-11-22 12:50:17 +01:00
commit 5d2b3a966e
18 changed files with 239 additions and 244 deletions

View File

@ -119,7 +119,7 @@ ccl_device float bssrdf_cubic_eval(const float radius, const float sharpness, fl
else {
Rmy = powf(Rm, y);
ry = powf(r, y);
ryinv = (r > 0.0f)? powf(r, 2.0f*y - 2.0f): 0.0f;
ryinv = (r > 0.0f)? powf(r, y - 1.0f): 0.0f;
}
const float Rmy5 = (Rmy*Rmy) * (Rmy*Rmy) * Rmy;

View File

@ -73,9 +73,15 @@
/* tunable parameters */
# define CUDA_THREADS_BLOCK_WIDTH 16
# define CUDA_KERNEL_MAX_REGISTERS 48
/* CUDA 9.0 seems to cause slowdowns on high-end Pascal cards unless we increase the number of registers */
# if __CUDACC_VER_MAJOR__ == 9 && __CUDA_ARCH__ >= 600
# define CUDA_KERNEL_MAX_REGISTERS 64
# else
# define CUDA_KERNEL_MAX_REGISTERS 48
# endif
# define CUDA_KERNEL_BRANCHED_MAX_REGISTERS 63
/* unknown architecture */
#else
# error "Unknown or unsupported CUDA architecture, can't determine launch bounds"

View File

@ -232,7 +232,11 @@ static void register_closure(OSL::ShadingSystem *ss, const char *name, int id, O
/* optimization: it's possible to not use a prepare function at all and
* only initialize the actual class when accessing the closure component
* data, but then we need to map the id to the class somehow */
#if OSL_LIBRARY_VERSION_CODE >= 10900
ss->register_closure(name, id, params, prepare, NULL);
#else
ss->register_closure(name, id, params, prepare, NULL, 16);
#endif
}
void OSLShader::register_closures(OSLShadingSystem *ss_)

View File

@ -198,7 +198,7 @@ ccl_device_noinline float3 svm_bevel(
/* Normalize. */
float3 N = safe_normalize(sum_N);
return is_zero(N) ? sd->N : N;
return is_zero(N) ? sd->N : (sd->flag & SD_BACKFACING) ? -N : N;
}
ccl_device void svm_node_bevel(

View File

@ -18,9 +18,9 @@ CCL_NAMESPACE_BEGIN
/* Brick */
ccl_device_noinline float brick_noise(int n) /* fast integer noise */
ccl_device_noinline float brick_noise(uint n) /* fast integer noise */
{
int nn;
uint nn;
n = (n + 1013) & 0x7fffffff;
n = (n >> 13) ^ n;
nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;

View File

@ -58,13 +58,12 @@ struct UserDef *BKE_blendfile_userdef_read_from_memory(
const void *filebuf, int filelength,
struct ReportList *reports);
int BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports);
bool BKE_blendfile_userdef_write(const char *filepath, struct ReportList *reports);
struct WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, struct ReportList *reports);
bool BKE_blendfile_workspace_config_write(struct Main *bmain, const char *filepath, struct ReportList *reports);
void BKE_blendfile_workspace_config_data_free(struct WorkspaceConfigFileData *workspace_config);
/* partial blend file writing */
void BKE_blendfile_write_partial_tag_ID(struct ID *id, bool set);
void BKE_blendfile_write_partial_begin(struct Main *bmain_src);

View File

@ -521,19 +521,22 @@ UserDef *BKE_blendfile_userdef_read_from_memory(
}
/* only write the userdef in a .blend */
int BKE_blendfile_userdef_write(const char *filepath, ReportList *reports)
/**
* Only write the userdef in a .blend
* \return success
*/
bool BKE_blendfile_userdef_write(const char *filepath, ReportList *reports)
{
Main *mainb = MEM_callocN(sizeof(Main), "empty main");
int retval = 0;
bool ok = false;
if (BLO_write_file(mainb, filepath, G_FILE_USERPREFS, reports, NULL)) {
retval = 1;
ok = true;
}
MEM_freeN(mainb);
return retval;
return ok;
}
WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepath, ReportList *reports)

View File

@ -1775,7 +1775,7 @@ void driver_variable_name_validate(DriverVar *dvar)
/* 1) Must start with a letter */
/* XXX: We assume that valid unicode letters in other languages are ok too, hence the blacklisting */
if (ELEM(dvar->name[0], '0', '1', '2', '3', '4', '5', '6', '7', '8', '9')) {
if (IN_RANGE_INCL(dvar->name[0], '0', '9')) {
dvar->flag |= DVAR_FLAG_INVALID_START_NUM;
}
else if (dvar->name[0] == '_') {

View File

@ -508,14 +508,16 @@ void BLI_spin_unlock(SpinLock *spin)
#endif
}
#if defined(__APPLE__) || defined(_MSC_VER)
void BLI_spin_end(SpinLock *UNUSED(spin))
{
}
#else
void BLI_spin_end(SpinLock *spin)
{
#if defined(__APPLE__)
#elif defined(_MSC_VER)
#else
pthread_spin_destroy(spin);
#endif
}
#endif
/* Read/Write Mutex Lock */

View File

@ -57,7 +57,6 @@ static void recount_totsels(BMesh *bm)
tots[1] = &bm->totedgesel;
tots[2] = &bm->totfacesel;
#pragma omp parallel for schedule(static) if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT)
for (i = 0; i < 3; i++) {
BMIter iter;
BMElem *ele;
@ -253,44 +252,34 @@ void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode)
if (selectmode & SCE_SELECT_VERTEX) {
/* both loops only set edge/face flags and read off verts */
#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT)
{
#pragma omp section
BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) &&
BM_elem_flag_test(e->v2, BM_ELEM_SELECT) &&
!BM_elem_flag_test(e, BM_ELEM_HIDDEN))
{
BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) &&
BM_elem_flag_test(e->v2, BM_ELEM_SELECT) &&
!BM_elem_flag_test(e, BM_ELEM_HIDDEN))
{
BM_elem_flag_enable(e, BM_ELEM_SELECT);
}
else {
BM_elem_flag_disable(e, BM_ELEM_SELECT);
}
}
BM_elem_flag_enable(e, BM_ELEM_SELECT);
}
#pragma omp section
{
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
bool ok = true;
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) {
ok = false;
break;
}
} while ((l_iter = l_iter->next) != l_first);
}
else {
ok = false;
}
BM_elem_flag_set(f, BM_ELEM_SELECT, ok);
}
else {
BM_elem_flag_disable(e, BM_ELEM_SELECT);
}
}
/* end sections */
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
bool ok = true;
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) {
ok = false;
break;
}
} while ((l_iter = l_iter->next) != l_first);
}
else {
ok = false;
}
BM_elem_flag_set(f, BM_ELEM_SELECT, ok);
}
}
else if (selectmode & SCE_SELECT_EDGE) {
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
@ -375,42 +364,31 @@ void BM_mesh_select_flush(BMesh *bm)
bool ok;
/* we can use 2 sections here because the second loop isnt checking edge selection */
#pragma omp parallel sections if (bm->totedge + bm->totface >= BM_OMP_LIMIT)
{
#pragma omp section
BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) &&
BM_elem_flag_test(e->v2, BM_ELEM_SELECT) &&
!BM_elem_flag_test(e, BM_ELEM_HIDDEN))
{
BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) &&
BM_elem_flag_test(e->v2, BM_ELEM_SELECT) &&
!BM_elem_flag_test(e, BM_ELEM_HIDDEN))
{
BM_elem_flag_enable(e, BM_ELEM_SELECT);
BM_elem_flag_enable(e, BM_ELEM_SELECT);
}
}
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
ok = true;
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) {
ok = false;
break;
}
}
} while ((l_iter = l_iter->next) != l_first);
}
else {
ok = false;
}
#pragma omp section
{
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
ok = true;
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
if (!BM_elem_flag_test(l_iter->v, BM_ELEM_SELECT)) {
ok = false;
break;
}
} while ((l_iter = l_iter->next) != l_first);
}
else {
ok = false;
}
if (ok) {
BM_elem_flag_enable(f, BM_ELEM_SELECT);
}
}
if (ok) {
BM_elem_flag_enable(f, BM_ELEM_SELECT);
}
}
@ -1107,8 +1085,6 @@ void BM_mesh_elem_hflag_disable_test(
{
/* fast path for deselect all, avoid topology loops
* since we know all will be de-selected anyway. */
#pragma omp parallel for schedule(static) if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT)
for (i = 0; i < 3; i++) {
BMIter iter;
BMElem *ele;

View File

@ -550,37 +550,30 @@ static int bmo_mesh_flag_count(
{
int count_vert = 0, count_edge = 0, count_face = 0;
#pragma omp parallel sections if ((bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) && \
(ELEM(htype, BM_VERT, BM_EDGE, BM_FACE) == 0))
{
#pragma omp section
if (htype & BM_VERT) {
BMIter iter;
BMVert *ele;
BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
if (BMO_vert_flag_test_bool(bm, ele, oflag) == test_for_enabled) {
count_vert++;
}
if (htype & BM_VERT) {
BMIter iter;
BMVert *ele;
BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
if (BMO_vert_flag_test_bool(bm, ele, oflag) == test_for_enabled) {
count_vert++;
}
}
#pragma omp section
if (htype & BM_EDGE) {
BMIter iter;
BMEdge *ele;
BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
if (BMO_edge_flag_test_bool(bm, ele, oflag) == test_for_enabled) {
count_edge++;
}
}
if (htype & BM_EDGE) {
BMIter iter;
BMEdge *ele;
BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
if (BMO_edge_flag_test_bool(bm, ele, oflag) == test_for_enabled) {
count_edge++;
}
}
#pragma omp section
if (htype & BM_FACE) {
BMIter iter;
BMFace *ele;
BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
if (BMO_face_flag_test_bool(bm, ele, oflag) == test_for_enabled) {
count_face++;
}
}
if (htype & BM_FACE) {
BMIter iter;
BMFace *ele;
BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
if (BMO_face_flag_test_bool(bm, ele, oflag) == test_for_enabled) {
count_face++;
}
}
}
@ -601,33 +594,25 @@ int BMO_mesh_disabled_flag_count(BMesh *bm, const char htype, const short oflag)
void BMO_mesh_flag_disable_all(BMesh *bm, BMOperator *UNUSED(op), const char htype, const short oflag)
{
#pragma omp parallel sections if ((bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT) && \
(ELEM(htype, BM_VERT, BM_EDGE, BM_FACE) == 0))
{
#pragma omp section
if (htype & BM_VERT) {
BMIter iter;
BMVert *ele;
BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
BMO_vert_flag_disable(bm, ele, oflag);
}
if (htype & BM_VERT) {
BMIter iter;
BMVert *ele;
BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
BMO_vert_flag_disable(bm, ele, oflag);
}
#pragma omp section
if (htype & BM_EDGE) {
BMIter iter;
BMEdge *ele;
BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
BMO_edge_flag_disable(bm, ele, oflag);
}
}
if (htype & BM_EDGE) {
BMIter iter;
BMEdge *ele;
BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
BMO_edge_flag_disable(bm, ele, oflag);
}
#pragma omp section
if (htype & BM_FACE) {
BMIter iter;
BMFace *ele;
BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
BMO_face_flag_disable(bm, ele, oflag);
}
}
if (htype & BM_FACE) {
BMIter iter;
BMFace *ele;
BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
BMO_face_flag_disable(bm, ele, oflag);
}
}
}
@ -1383,38 +1368,32 @@ static void bmo_flag_layer_clear(BMesh *bm)
const int totflags_offset = bm->totflags - 1;
#pragma omp parallel sections if (bm->totvert + bm->totedge + bm->totface >= BM_OMP_LIMIT)
/* now go through and memcpy all the flag */
{
/* now go through and memcpy all the flag */
#pragma omp section
{
BMIter iter;
BMVert_OFlag *ele;
int i;
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) {
ele->oflags[totflags_offset] = zero_flag;
BM_elem_index_set(&ele->base, i); /* set_inline */
}
BMIter iter;
BMVert_OFlag *ele;
int i;
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_VERTS_OF_MESH, i) {
ele->oflags[totflags_offset] = zero_flag;
BM_elem_index_set(&ele->base, i); /* set_inline */
}
#pragma omp section
{
BMIter iter;
BMEdge_OFlag *ele;
int i;
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
ele->oflags[totflags_offset] = zero_flag;
BM_elem_index_set(&ele->base, i); /* set_inline */
}
}
{
BMIter iter;
BMEdge_OFlag *ele;
int i;
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_EDGES_OF_MESH, i) {
ele->oflags[totflags_offset] = zero_flag;
BM_elem_index_set(&ele->base, i); /* set_inline */
}
#pragma omp section
{
BMIter iter;
BMFace_OFlag *ele;
int i;
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
ele->oflags[totflags_offset] = zero_flag;
BM_elem_index_set(&ele->base, i); /* set_inline */
}
}
{
BMIter iter;
BMFace_OFlag *ele;
int i;
BM_ITER_MESH_INDEX (ele, &iter, bm, BM_FACES_OF_MESH, i) {
ele->oflags[totflags_offset] = zero_flag;
BM_elem_index_set(&ele->base, i); /* set_inline */
}
}

View File

@ -67,15 +67,16 @@ void KeyingOperation::deinitExecution()
void KeyingOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float pixelColor[4];
float screenColor[4];
float pixel_color[4];
float screen_color[4];
this->m_pixelReader->readSampled(pixelColor, x, y, sampler);
this->m_screenReader->readSampled(screenColor, x, y, sampler);
this->m_pixelReader->readSampled(pixel_color, x, y, sampler);
this->m_screenReader->readSampled(screen_color, x, y, sampler);
const int primary_channel = max_axis_v3(screenColor);
const int primary_channel = max_axis_v3(screen_color);
const float min_pixel_color = min_fff(pixel_color[0], pixel_color[1], pixel_color[2]);
if (pixelColor[primary_channel] > 1.0f) {
if (min_pixel_color > 1.0f) {
/* overexposure doesn't happen on screen itself and usually happens
* on light sources in the shot, this need to be checked separately
* because saturation and falloff calculation is based on the fact
@ -84,8 +85,8 @@ void KeyingOperation::executePixelSampled(float output[4], float x, float y, Pix
output[0] = 1.0f;
}
else {
float saturation = get_pixel_saturation(pixelColor, this->m_screenBalance, primary_channel);
float screen_saturation = get_pixel_saturation(screenColor, this->m_screenBalance, primary_channel);
float saturation = get_pixel_saturation(pixel_color, this->m_screenBalance, primary_channel);
float screen_saturation = get_pixel_saturation(screen_color, this->m_screenBalance, primary_channel);
if (saturation < 0) {
/* means main channel of pixel is different from screen,

View File

@ -1236,7 +1236,6 @@ void EDBM_mesh_reveal(BMEditMesh *em, bool select)
/* Use tag flag to remember what was hidden before all is revealed.
* BM_ELEM_HIDDEN --> BM_ELEM_TAG */
#pragma omp parallel for schedule(static) if (em->bm->totvert + em->bm->totedge + em->bm->totface >= BM_OMP_LIMIT)
for (i = 0; i < 3; i++) {
BMIter iter;
BMElem *ele;

View File

@ -361,7 +361,7 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot)
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
RNA_def_enum_funcs(prop, RNA_scene_itemf);
RNA_def_enum_funcs(prop, RNA_scene_without_active_itemf);
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
ot->prop = prop;
}

View File

@ -238,6 +238,7 @@ const EnumPropertyItem *RNA_group_local_itemf(struct bContext *C, struct Pointer
const EnumPropertyItem *RNA_image_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
const EnumPropertyItem *RNA_image_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
const EnumPropertyItem *RNA_scene_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
const EnumPropertyItem *RNA_scene_without_active_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
const EnumPropertyItem *RNA_scene_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
const EnumPropertyItem *RNA_movieclip_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
const EnumPropertyItem *RNA_movieclip_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);

View File

@ -596,99 +596,100 @@ static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values)
{
MCol *mcol = (MCol *)ptr->data;
values[2] = (&mcol[0].r)[0] / 255.0f;
values[1] = (&mcol[0].r)[1] / 255.0f;
values[0] = (&mcol[0].r)[2] / 255.0f;
values[3] = mcol[0].a / 255.0f;
values[2] = mcol[0].r / 255.0f;
values[1] = mcol[0].g / 255.0f;
values[0] = mcol[0].b / 255.0f;
}
static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values)
{
MCol *mcol = (MCol *)ptr->data;
(&mcol[0].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f);
(&mcol[0].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
(&mcol[0].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f);
(&mcol[0].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
mcol[0].a = round_fl_to_uchar_clamp(values[3] * 255.0f);
mcol[0].r = round_fl_to_uchar_clamp(values[2] * 255.0f);
mcol[0].g = round_fl_to_uchar_clamp(values[1] * 255.0f);
mcol[0].b = round_fl_to_uchar_clamp(values[0] * 255.0f);
}
static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values)
{
MCol *mcol = (MCol *)ptr->data;
values[3] = (&mcol[1].r)[3] / 255.0f;
values[2] = (&mcol[1].r)[0] / 255.0f;
values[1] = (&mcol[1].r)[1] / 255.0f;
values[0] = (&mcol[1].r)[2] / 255.0f;
values[3] = mcol[1].a / 255.0f;
values[2] = mcol[1].r / 255.0f;
values[1] = mcol[1].g / 255.0f;
values[0] = mcol[1].b / 255.0f;
}
static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values)
{
MCol *mcol = (MCol *)ptr->data;
(&mcol[1].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f);
(&mcol[1].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
(&mcol[1].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f);
(&mcol[1].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
mcol[1].a = round_fl_to_uchar_clamp(values[3] * 255.0f);
mcol[1].r = round_fl_to_uchar_clamp(values[2] * 255.0f);
mcol[1].g = round_fl_to_uchar_clamp(values[1] * 255.0f);
mcol[1].b = round_fl_to_uchar_clamp(values[0] * 255.0f);
}
static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values)
{
MCol *mcol = (MCol *)ptr->data;
values[3] = (&mcol[2].r)[3] / 255.0f;
values[2] = (&mcol[2].r)[0] / 255.0f;
values[1] = (&mcol[2].r)[1] / 255.0f;
values[0] = (&mcol[2].r)[2] / 255.0f;
values[3] = mcol[2].a / 255.0f;
values[2] = mcol[2].r / 255.0f;
values[1] = mcol[2].g / 255.0f;
values[0] = mcol[2].b / 255.0f;
}
static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values)
{
MCol *mcol = (MCol *)ptr->data;
(&mcol[2].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f);
(&mcol[2].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
(&mcol[2].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f);
(&mcol[2].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
mcol[2].a = round_fl_to_uchar_clamp(values[3] * 255.0f);
mcol[2].r = round_fl_to_uchar_clamp(values[2] * 255.0f);
mcol[2].g = round_fl_to_uchar_clamp(values[1] * 255.0f);
mcol[2].b = round_fl_to_uchar_clamp(values[0] * 255.0f);
}
static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values)
{
MCol *mcol = (MCol *)ptr->data;
values[2] = (&mcol[3].r)[0] / 255.0f;
values[1] = (&mcol[3].r)[1] / 255.0f;
values[0] = (&mcol[3].r)[2] / 255.0f;
values[3] = (&mcol[3].r)[3] / 255.0f;
values[3] = mcol[3].a / 255.0f;
values[2] = mcol[3].r / 255.0f;
values[1] = mcol[3].g / 255.0f;
values[0] = mcol[3].b / 255.0f;
}
static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values)
{
MCol *mcol = (MCol *)ptr->data;
(&mcol[3].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f);
(&mcol[3].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
(&mcol[3].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f);
(&mcol[3].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
mcol[3].a = round_fl_to_uchar_clamp(values[3] * 255.0f);
mcol[3].r = round_fl_to_uchar_clamp(values[2] * 255.0f);
mcol[3].g = round_fl_to_uchar_clamp(values[1] * 255.0f);
mcol[3].b = round_fl_to_uchar_clamp(values[0] * 255.0f);
}
static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values)
{
MLoopCol *mcol = (MLoopCol *)ptr->data;
MLoopCol *mlcol = (MLoopCol *)ptr->data;
values[0] = (&mcol->r)[0] / 255.0f;
values[1] = (&mcol->r)[1] / 255.0f;
values[2] = (&mcol->r)[2] / 255.0f;
values[3] = (&mcol->r)[3] / 255.0f;
values[0] = mlcol->r / 255.0f;
values[1] = mlcol->g / 255.0f;
values[2] = mlcol->b / 255.0f;
values[3] = mlcol->a / 255.0f;
}
static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values)
{
MLoopCol *mcol = (MLoopCol *)ptr->data;
MLoopCol *mlcol = (MLoopCol *)ptr->data;
(&mcol->r)[0] = round_fl_to_uchar_clamp(values[0] * 255.0f);
(&mcol->r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f);
(&mcol->r)[2] = round_fl_to_uchar_clamp(values[2] * 255.0f);
(&mcol->r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f);
mlcol->r = round_fl_to_uchar_clamp(values[0] * 255.0f);
mlcol->g = round_fl_to_uchar_clamp(values[1] * 255.0f);
mlcol->b = round_fl_to_uchar_clamp(values[2] * 255.0f);
mlcol->a = round_fl_to_uchar_clamp(values[3] * 255.0f);
}
static int rna_Mesh_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info))

View File

@ -1478,7 +1478,7 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op)
wmWindowManager *wm = CTX_wm_manager(C);
char filepath[FILE_MAX];
const char *cfgdir;
bool ok = false;
bool ok = true;
/* update keymaps in user preferences */
WM_keyconfig_update(wm);
@ -1488,31 +1488,34 @@ static int wm_userpref_write_exec(bContext *C, wmOperator *op)
printf("trying to save userpref at %s ", filepath);
if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) {
printf("ok\n");
ok = true;
}
else {
printf("fail\n");
ok = false;
}
}
else {
BKE_report(op->reports, RPT_ERROR, "Unable to create userpref path");
}
if (U.app_template[0] && (cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) {
/* Also save app-template prefs */
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL);
printf("trying to save app-template userpref at %s ", filepath);
if (BKE_blendfile_userdef_write(filepath, op->reports) == 0) {
printf("fail\n");
ok = true;
if (U.app_template[0]) {
if ((cfgdir = BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, U.app_template))) {
/* Also save app-template prefs */
BLI_path_join(filepath, sizeof(filepath), cfgdir, BLENDER_USERPREF_FILE, NULL);
printf("trying to save app-template userpref at %s ", filepath);
if (BKE_blendfile_userdef_write(filepath, op->reports) != 0) {
printf("ok\n");
}
else {
printf("fail\n");
ok = false;
}
}
else {
printf("ok\n");
BKE_report(op->reports, RPT_ERROR, "Unable to create app-template userpref path");
ok = false;
}
}
else if (U.app_template[0]) {
BKE_report(op->reports, RPT_ERROR, "Unable to create app-template userpref path");
}
return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}

View File

@ -3993,14 +3993,29 @@ void wm_window_keymap(wmKeyConfig *keyconf)
gesture_straightline_modal_keymap(keyconf);
}
/**
* Filter functions that can be used with rna_id_itemf() below.
* Should return false if 'id' should be excluded.
*/
static bool rna_id_enum_filter_single(ID *id, void *user_data)
{
return (id != user_data);
}
/* Generic itemf's for operators that take library args */
static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), bool *r_free, ID *id, bool local)
static const EnumPropertyItem *rna_id_itemf(
bContext *UNUSED(C), PointerRNA *UNUSED(ptr),
bool *r_free, ID *id, bool local,
bool (*filter_ids)(ID *id, void *user_data), void *user_data)
{
EnumPropertyItem item_tmp = {0}, *item = NULL;
int totitem = 0;
int i = 0;
for (; id; id = id->next) {
if ((filter_ids != NULL) && filter_ids(user_data, id) == false) {
continue;
}
if (local == false || !ID_IS_LINKED(id)) {
item_tmp.identifier = item_tmp.name = id->name + 2;
item_tmp.value = i++;
@ -4017,7 +4032,7 @@ static const EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNU
/* can add more as needed */
const EnumPropertyItem *RNA_action_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, false);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->action.first : NULL, false, NULL, NULL);
}
#if 0 /* UNUSED */
const EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
@ -4028,45 +4043,51 @@ const EnumPropertyItem *RNA_action_local_itemf(bContext *C, PointerRNA *ptr, Pro
const EnumPropertyItem *RNA_group_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, false);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_group_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, true);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->group.first : NULL, true, NULL, NULL);
}
const EnumPropertyItem *RNA_image_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, false);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_image_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, true);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->image.first : NULL, true, NULL, NULL);
}
const EnumPropertyItem *RNA_scene_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, false);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_scene_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, true);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, true, NULL, NULL);
}
const EnumPropertyItem *RNA_scene_without_active_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
Scene *scene_active = C ? CTX_data_scene(C) : NULL;
return rna_id_itemf(
C, ptr, r_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, true,
rna_id_enum_filter_single, scene_active);
}
const EnumPropertyItem *RNA_movieclip_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, false);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_movieclip_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, true);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, true, NULL, NULL);
}
const EnumPropertyItem *RNA_mask_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, false);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, false, NULL, NULL);
}
const EnumPropertyItem *RNA_mask_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), bool *r_free)
{
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, true);
return rna_id_itemf(C, ptr, r_free, C ? (ID *)CTX_data_main(C)->mask.first : NULL, true, NULL, NULL);
}