Merge branch 'blender-v2.82-release'
This commit is contained in:
@@ -830,17 +830,19 @@ static void eevee_lightbake_render_world_sample(void *ved, void *user_data)
|
||||
EEVEE_lightbake_render_world(sldata, vedata, lbake->rt_fb);
|
||||
EEVEE_lightbake_filter_diffuse(sldata, vedata, lbake->rt_color, lbake->store_fb, 0, 1.0f);
|
||||
|
||||
/* Clear the cache to avoid white values in the grid. */
|
||||
GPU_framebuffer_texture_attach(lbake->store_fb, lbake->grid_prev, 0, 0);
|
||||
GPU_framebuffer_bind(lbake->store_fb);
|
||||
/* Clear to 1.0f for visibility. */
|
||||
GPU_framebuffer_clear_color(lbake->store_fb, ((float[4]){1.0f, 1.0f, 1.0f, 1.0f}));
|
||||
DRW_draw_pass(vedata->psl->probe_grid_fill);
|
||||
if (lcache->flag & LIGHTCACHE_UPDATE_GRID) {
|
||||
/* Clear the cache to avoid white values in the grid. */
|
||||
GPU_framebuffer_texture_attach(lbake->store_fb, lbake->grid_prev, 0, 0);
|
||||
GPU_framebuffer_bind(lbake->store_fb);
|
||||
/* Clear to 1.0f for visibility. */
|
||||
GPU_framebuffer_clear_color(lbake->store_fb, ((float[4]){1.0f, 1.0f, 1.0f, 1.0f}));
|
||||
DRW_draw_pass(vedata->psl->probe_grid_fill);
|
||||
|
||||
SWAP(GPUTexture *, lbake->grid_prev, lcache->grid_tx.tex);
|
||||
SWAP(GPUTexture *, lbake->grid_prev, lcache->grid_tx.tex);
|
||||
|
||||
/* Make a copy for later. */
|
||||
eevee_lightbake_copy_irradiance(lbake, lcache);
|
||||
/* Make a copy for later. */
|
||||
eevee_lightbake_copy_irradiance(lbake, lcache);
|
||||
}
|
||||
|
||||
lcache->cube_len = 1;
|
||||
lcache->grid_len = lbake->grid_len;
|
||||
|
||||
@@ -140,7 +140,7 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata)
|
||||
cb->light_point = BUF_INSTANCE(grp_sub, format, DRW_cache_light_point_lines_get());
|
||||
cb->light_spot = BUF_INSTANCE(grp_sub, format, DRW_cache_light_spot_lines_get());
|
||||
cb->light_sun = BUF_INSTANCE(grp_sub, format, DRW_cache_light_sun_lines_get());
|
||||
cb->probe_cube = BUF_INSTANCE(grp_sub, format, DRW_cache_lightprobe_planar_get());
|
||||
cb->probe_cube = BUF_INSTANCE(grp_sub, format, DRW_cache_lightprobe_cube_get());
|
||||
cb->probe_grid = BUF_INSTANCE(grp_sub, format, DRW_cache_lightprobe_grid_get());
|
||||
cb->probe_planar = BUF_INSTANCE(grp_sub, format, DRW_cache_lightprobe_planar_get());
|
||||
cb->solid_quad = BUF_INSTANCE(grp_sub, format, DRW_cache_quad_get());
|
||||
@@ -707,7 +707,7 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
||||
case LIGHTPROBE_TYPE_CUBE:
|
||||
instdata.clip_sta = show_clipping ? prb->clipsta : -1.0;
|
||||
instdata.clip_end = show_clipping ? prb->clipend : -1.0;
|
||||
DRW_buffer_add_entry(cb->probe_grid, color_p, &instdata);
|
||||
DRW_buffer_add_entry(cb->probe_cube, color_p, &instdata);
|
||||
DRW_buffer_add_entry(cb->groundline, instdata.pos);
|
||||
|
||||
if (show_influence) {
|
||||
|
||||
@@ -1636,44 +1636,51 @@ GPUBatch *DRW_cache_speaker_get(void)
|
||||
GPUBatch *DRW_cache_lightprobe_cube_get(void)
|
||||
{
|
||||
if (!SHC.drw_lightprobe_cube) {
|
||||
int v_idx = 0;
|
||||
GPUVertFormat format = extra_vert_format();
|
||||
|
||||
int v_len = (6 + 3 + (1 + 2 * DIAMOND_NSEGMENTS) * 6) * 2;
|
||||
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
|
||||
GPU_vertbuf_data_alloc(vbo, v_len);
|
||||
|
||||
const float r = 14.0f;
|
||||
int v = 0;
|
||||
int flag = VCLASS_SCREENSPACE;
|
||||
/* Icon */
|
||||
const float sin_pi_3 = 0.86602540378f;
|
||||
const float cos_pi_3 = 0.5f;
|
||||
const float v[7][3] = {
|
||||
{0.0f, 1.0f, 0.0f},
|
||||
{sin_pi_3, cos_pi_3, 0.0f},
|
||||
{sin_pi_3, -cos_pi_3, 0.0f},
|
||||
{0.0f, -1.0f, 0.0f},
|
||||
{-sin_pi_3, -cos_pi_3, 0.0f},
|
||||
{-sin_pi_3, cos_pi_3, 0.0f},
|
||||
{0.0f, 0.0f, 0.0f},
|
||||
const float p[7][2] = {
|
||||
{0.0f, 1.0f},
|
||||
{sin_pi_3, cos_pi_3},
|
||||
{sin_pi_3, -cos_pi_3},
|
||||
{0.0f, -1.0f},
|
||||
{-sin_pi_3, -cos_pi_3},
|
||||
{-sin_pi_3, cos_pi_3},
|
||||
{0.0f, 0.0f},
|
||||
};
|
||||
|
||||
/* Position Only 3D format */
|
||||
static GPUVertFormat format = {0};
|
||||
static struct {
|
||||
uint pos;
|
||||
} attr_id;
|
||||
if (format.attr_len == 0) {
|
||||
attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
}
|
||||
|
||||
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
|
||||
GPU_vertbuf_data_alloc(vbo, (6 + 3) * 2);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]);
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 6]);
|
||||
float t1[2], t2[2];
|
||||
copy_v2_v2(t1, p[i]);
|
||||
copy_v2_v2(t2, p[(i + 1) % 6]);
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t1[0] * r, t1[1] * r, 0.0f}, flag});
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t2[0] * r, t2[1] * r, 0.0f}, flag});
|
||||
}
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[1][0] * r, p[1][1] * r, 0.0f}, flag});
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[5][0] * r, p[5][1] * r, 0.0f}, flag});
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[3][0] * r, p[3][1] * r, 0.0f}, flag});
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
|
||||
/* Direction Lines */
|
||||
flag = VCLASS_LIGHT_DIST | VCLASS_SCREENSPACE;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
char axes[] = "zZyYxX";
|
||||
float zsta = light_distance_z_get(axes[i], true);
|
||||
float zend = light_distance_z_get(axes[i], false);
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zsta}, flag});
|
||||
GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zend}, flag});
|
||||
circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zsta, flag);
|
||||
circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zend, flag);
|
||||
}
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]);
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]);
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
|
||||
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]);
|
||||
GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]);
|
||||
|
||||
SHC.drw_lightprobe_cube = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
|
||||
}
|
||||
|
||||
@@ -979,7 +979,8 @@ static void bindVert(void *__restrict userdata,
|
||||
freeBindData(bwdata);
|
||||
}
|
||||
|
||||
static bool surfacedeformBind(SurfaceDeformModifierData *smd,
|
||||
static bool surfacedeformBind(SurfaceDeformModifierData *smd_orig,
|
||||
SurfaceDeformModifierData *smd_eval,
|
||||
float (*vertexCos)[3],
|
||||
uint numverts,
|
||||
uint tnumpoly,
|
||||
@@ -999,38 +1000,38 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd,
|
||||
|
||||
vert_edges = MEM_calloc_arrayN(tnumverts, sizeof(*vert_edges), "SDefVertEdgeMap");
|
||||
if (vert_edges == NULL) {
|
||||
modifier_setError((ModifierData *)smd, "Out of memory");
|
||||
modifier_setError((ModifierData *)smd_eval, "Out of memory");
|
||||
return false;
|
||||
}
|
||||
|
||||
adj_array = MEM_malloc_arrayN(tnumedges, 2 * sizeof(*adj_array), "SDefVertEdge");
|
||||
if (adj_array == NULL) {
|
||||
modifier_setError((ModifierData *)smd, "Out of memory");
|
||||
modifier_setError((ModifierData *)smd_eval, "Out of memory");
|
||||
MEM_freeN(vert_edges);
|
||||
return false;
|
||||
}
|
||||
|
||||
edge_polys = MEM_calloc_arrayN(tnumedges, sizeof(*edge_polys), "SDefEdgeFaceMap");
|
||||
if (edge_polys == NULL) {
|
||||
modifier_setError((ModifierData *)smd, "Out of memory");
|
||||
modifier_setError((ModifierData *)smd_eval, "Out of memory");
|
||||
MEM_freeN(vert_edges);
|
||||
MEM_freeN(adj_array);
|
||||
return false;
|
||||
}
|
||||
|
||||
smd->verts = MEM_malloc_arrayN(numverts, sizeof(*smd->verts), "SDefBindVerts");
|
||||
if (smd->verts == NULL) {
|
||||
modifier_setError((ModifierData *)smd, "Out of memory");
|
||||
smd_orig->verts = MEM_malloc_arrayN(numverts, sizeof(*smd_orig->verts), "SDefBindVerts");
|
||||
if (smd_orig->verts == NULL) {
|
||||
modifier_setError((ModifierData *)smd_eval, "Out of memory");
|
||||
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
|
||||
return false;
|
||||
}
|
||||
|
||||
BKE_bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 2);
|
||||
if (treeData.tree == NULL) {
|
||||
modifier_setError((ModifierData *)smd, "Out of memory");
|
||||
modifier_setError((ModifierData *)smd_eval, "Out of memory");
|
||||
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
|
||||
MEM_freeN(smd->verts);
|
||||
smd->verts = NULL;
|
||||
MEM_freeN(smd_orig->verts);
|
||||
smd_orig->verts = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1038,16 +1039,16 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd,
|
||||
mpoly, medge, mloop, tnumpoly, tnumedges, vert_edges, adj_array, edge_polys);
|
||||
|
||||
if (adj_result == MOD_SDEF_BIND_RESULT_NONMANY_ERR) {
|
||||
modifier_setError((ModifierData *)smd, "Target has edges with more than two polygons");
|
||||
modifier_setError((ModifierData *)smd_eval, "Target has edges with more than two polygons");
|
||||
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
|
||||
free_bvhtree_from_mesh(&treeData);
|
||||
MEM_freeN(smd->verts);
|
||||
smd->verts = NULL;
|
||||
MEM_freeN(smd_orig->verts);
|
||||
smd_orig->verts = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
smd->numverts = numverts;
|
||||
smd->numpoly = tnumpoly;
|
||||
smd_orig->numverts = numverts;
|
||||
smd_orig->numpoly = tnumpoly;
|
||||
|
||||
SDefBindCalcData data = {
|
||||
.treeData = &treeData,
|
||||
@@ -1058,22 +1059,22 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd,
|
||||
.mloop = mloop,
|
||||
.looptri = BKE_mesh_runtime_looptri_ensure(target),
|
||||
.targetCos = MEM_malloc_arrayN(tnumverts, sizeof(float[3]), "SDefTargetBindVertArray"),
|
||||
.bind_verts = smd->verts,
|
||||
.bind_verts = smd_orig->verts,
|
||||
.vertexCos = vertexCos,
|
||||
.falloff = smd->falloff,
|
||||
.falloff = smd_orig->falloff,
|
||||
.success = MOD_SDEF_BIND_RESULT_SUCCESS,
|
||||
};
|
||||
|
||||
if (data.targetCos == NULL) {
|
||||
modifier_setError((ModifierData *)smd, "Out of memory");
|
||||
freeData((ModifierData *)smd);
|
||||
modifier_setError((ModifierData *)smd_eval, "Out of memory");
|
||||
freeData((ModifierData *)smd_orig);
|
||||
return false;
|
||||
}
|
||||
|
||||
invert_m4_m4(data.imat, smd->mat);
|
||||
invert_m4_m4(data.imat, smd_orig->mat);
|
||||
|
||||
for (int i = 0; i < tnumverts; i++) {
|
||||
mul_v3_m4v3(data.targetCos[i], smd->mat, mvert[i].co);
|
||||
mul_v3_m4v3(data.targetCos[i], smd_orig->mat, mvert[i].co);
|
||||
}
|
||||
|
||||
TaskParallelSettings settings;
|
||||
@@ -1084,28 +1085,28 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd,
|
||||
MEM_freeN(data.targetCos);
|
||||
|
||||
if (data.success == MOD_SDEF_BIND_RESULT_MEM_ERR) {
|
||||
modifier_setError((ModifierData *)smd, "Out of memory");
|
||||
freeData((ModifierData *)smd);
|
||||
modifier_setError((ModifierData *)smd_eval, "Out of memory");
|
||||
freeData((ModifierData *)smd_orig);
|
||||
}
|
||||
else if (data.success == MOD_SDEF_BIND_RESULT_NONMANY_ERR) {
|
||||
modifier_setError((ModifierData *)smd, "Target has edges with more than two polygons");
|
||||
freeData((ModifierData *)smd);
|
||||
modifier_setError((ModifierData *)smd_eval, "Target has edges with more than two polygons");
|
||||
freeData((ModifierData *)smd_orig);
|
||||
}
|
||||
else if (data.success == MOD_SDEF_BIND_RESULT_CONCAVE_ERR) {
|
||||
modifier_setError((ModifierData *)smd, "Target contains concave polygons");
|
||||
freeData((ModifierData *)smd);
|
||||
modifier_setError((ModifierData *)smd_eval, "Target contains concave polygons");
|
||||
freeData((ModifierData *)smd_orig);
|
||||
}
|
||||
else if (data.success == MOD_SDEF_BIND_RESULT_OVERLAP_ERR) {
|
||||
modifier_setError((ModifierData *)smd, "Target contains overlapping verts");
|
||||
freeData((ModifierData *)smd);
|
||||
modifier_setError((ModifierData *)smd_eval, "Target contains overlapping verts");
|
||||
freeData((ModifierData *)smd_orig);
|
||||
}
|
||||
else if (data.success == MOD_SDEF_BIND_RESULT_GENERIC_ERR) {
|
||||
/* I know this message is vague, but I could not think of a way
|
||||
* to explain this with a reasonably sized message.
|
||||
* Though it shouldn't really matter all that much,
|
||||
* because this is very unlikely to occur */
|
||||
modifier_setError((ModifierData *)smd, "Target contains invalid polygons");
|
||||
freeData((ModifierData *)smd);
|
||||
modifier_setError((ModifierData *)smd_eval, "Target contains invalid polygons");
|
||||
freeData((ModifierData *)smd_orig);
|
||||
}
|
||||
|
||||
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
|
||||
@@ -1216,7 +1217,7 @@ static void surfacedeformModifier_do(ModifierData *md,
|
||||
invert_m4_m4(tmp_mat, ob->obmat);
|
||||
mul_m4_m4m4(smd_orig->mat, tmp_mat, ob_target->obmat);
|
||||
|
||||
if (!surfacedeformBind(smd_orig, vertexCos, numverts, tnumpoly, tnumverts, target)) {
|
||||
if (!surfacedeformBind(smd_orig, smd, vertexCos, numverts, tnumpoly, tnumverts, target)) {
|
||||
smd->flags &= ~MOD_SDEF_BIND;
|
||||
}
|
||||
/* Early abort, this is binding 'call', no need to perform whole evaluation. */
|
||||
|
||||
@@ -51,6 +51,7 @@ int BPY_is_pyconstraint(struct Text *text);
|
||||
void BPY_python_start(int argc, const char **argv);
|
||||
void BPY_python_end(void);
|
||||
void BPY_python_reset(struct bContext *C);
|
||||
void BPY_python_use_system_env(void);
|
||||
|
||||
/* global interpreter lock */
|
||||
|
||||
|
||||
@@ -84,6 +84,9 @@ CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_RNA, "bpy.rna");
|
||||
* stop bpy_context_clear from invalidating. */
|
||||
static int py_call_level = 0;
|
||||
|
||||
/* Set by command line arguments before Python starts. */
|
||||
static bool py_use_system_env = false;
|
||||
|
||||
// #define TIME_PY_RUN // simple python tests. prints on exit.
|
||||
|
||||
#ifdef TIME_PY_RUN
|
||||
@@ -276,6 +279,10 @@ void BPY_python_start(int argc, const char **argv)
|
||||
* While harmless, it's noisy. */
|
||||
Py_FrozenFlag = 1;
|
||||
|
||||
/* Only use the systems environment variables when explicitly requested.
|
||||
* Since an incorrect 'PYTHONPATH' causes difficult to debug errors, see: T72807. */
|
||||
Py_IgnoreEnvironmentFlag = !py_use_system_env;
|
||||
|
||||
Py_Initialize();
|
||||
|
||||
// PySys_SetArgv(argc, argv); /* broken in py3, not a huge deal */
|
||||
@@ -408,6 +415,12 @@ void BPY_python_reset(bContext *C)
|
||||
BPY_modules_load_user(C);
|
||||
}
|
||||
|
||||
void BPY_python_use_system_env(void)
|
||||
{
|
||||
BLI_assert(!Py_IsInitialized());
|
||||
py_use_system_env = true;
|
||||
}
|
||||
|
||||
static void python_script_error_jump_text(struct Text *text)
|
||||
{
|
||||
int lineno;
|
||||
|
||||
@@ -559,6 +559,7 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
|
||||
BLI_argsPrintArgDoc(ba, "--python-expr");
|
||||
BLI_argsPrintArgDoc(ba, "--python-console");
|
||||
BLI_argsPrintArgDoc(ba, "--python-exit-code");
|
||||
BLI_argsPrintArgDoc(ba, "--python-use-system-env");
|
||||
BLI_argsPrintArgDoc(ba, "--addons");
|
||||
|
||||
printf("\n");
|
||||
@@ -1907,6 +1908,17 @@ static int arg_handle_python_exit_code_set(int argc, const char **argv, void *UN
|
||||
}
|
||||
}
|
||||
|
||||
static const char arg_handle_python_use_system_env_set_doc[] =
|
||||
"\n\t"
|
||||
"Allow Python to use system environment variables such as 'PYTHONPATH'.";
|
||||
static int arg_handle_python_use_system_env_set(int UNUSED(argc),
|
||||
const char **UNUSED(argv),
|
||||
void *UNUSED(data))
|
||||
{
|
||||
BPY_python_use_system_env();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char arg_handle_addons_set_doc[] =
|
||||
"<addon(s)>\n"
|
||||
"\tComma separated list of add-ons (no spaces).";
|
||||
@@ -2188,6 +2200,9 @@ void main_args_setup(bContext *C, bArgs *ba)
|
||||
ba, 1, NULL, "--env-system-scripts", CB_EX(arg_handle_env_system_set, scripts), NULL);
|
||||
BLI_argsAdd(ba, 1, NULL, "--env-system-python", CB_EX(arg_handle_env_system_set, python), NULL);
|
||||
|
||||
BLI_argsAdd(
|
||||
ba, 1, NULL, "--python-use-system-env", CB(arg_handle_python_use_system_env_set), NULL);
|
||||
|
||||
/* second pass: custom window stuff */
|
||||
BLI_argsAdd(ba, 2, "-p", "--window-geometry", CB(arg_handle_window_geometry), NULL);
|
||||
BLI_argsAdd(ba, 2, "-w", "--window-border", CB(arg_handle_with_borders), NULL);
|
||||
|
||||
Reference in New Issue
Block a user