Merge branch 'master' into sculpt-dev

This commit is contained in:
Pablo Dobarro 2021-02-27 18:32:35 +01:00
commit 9f78a24eca
11 changed files with 153 additions and 66 deletions

View File

@ -1732,7 +1732,7 @@ compile_OCIO() {
fi
# To be changed each time we make edits that would modify the compiled result!
ocio_magic=2
ocio_magic=3
_init_ocio
# Force having own builds for the dependencies.
@ -1802,11 +1802,11 @@ compile_OCIO() {
make -j$THREADS && make install
# Force linking against static libs
rm -f $_inst/lib/*.so*
#rm -f $_inst/lib/*.so*
# Additional depencencies
cp ext/dist/lib/libtinyxml.a $_inst/lib
cp ext/dist/lib/libyaml-cpp.a $_inst/lib
#cp ext/dist/lib/libtinyxml.a $_inst/lib
#cp ext/dist/lib/libyaml-cpp.a $_inst/lib
make clean

View File

@ -352,7 +352,7 @@ if(WITH_CYCLES_OSL)
list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -force_load ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
find_path(OSL_SHADER_DIR NAMES stdosl.h PATHS ${CYCLES_OSL}/shaders)
find_path(OSL_SHADER_DIR NAMES stdosl.h PATHS ${CYCLES_OSL}/share/OSL/shaders)
if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER AND OSL_SHADER_DIR)
set(OSL_FOUND TRUE)

View File

@ -276,7 +276,6 @@ class AlembicObject : public Node {
MatrixSampleMap xform_samples;
Alembic::AbcGeom::IObject iobject;
Transform xform;
/* Set if the path points to a valid IObject whose type is supported. */
AbcSchemaType schema_type;

View File

@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 8
#define BLENDER_FILE_SUBVERSION 9
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file

View File

@ -5242,7 +5242,7 @@ static int has_linked_ids_to_read(Main *mainvar)
}
static void read_library_linked_id(
ReportList *reports, FileData *fd, Main *mainvar, ID *id, ID **r_id)
FileData *basefd, FileData *fd, Main *mainvar, ID *id, ID **r_id)
{
BHead *bhead = NULL;
const bool is_valid = BKE_idtype_idcode_is_linkable(GS(id->name)) ||
@ -5253,7 +5253,7 @@ static void read_library_linked_id(
}
if (!is_valid) {
BLO_reportf_wrap(reports,
BLO_reportf_wrap(basefd->reports,
RPT_ERROR,
TIP_("LIB: %s: '%s' is directly linked from '%s' (parent '%s'), but is a "
"non-linkable data type"),
@ -5272,14 +5272,14 @@ static void read_library_linked_id(
read_libblock(fd, mainvar, bhead, id->tag, false, r_id);
}
else {
BLO_reportf_wrap(reports,
BLO_reportf_wrap(basefd->reports,
RPT_INFO,
TIP_("LIB: %s: '%s' missing from '%s', parent '%s'"),
BKE_idtype_idcode_to_name(GS(id->name)),
id->name + 2,
mainvar->curlib->filepath_abs,
library_parent_filepath(mainvar->curlib));
fd->library_id_missing_count++;
basefd->library_id_missing_count++;
/* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
if (r_id) {
@ -5313,7 +5313,7 @@ static void read_library_linked_ids(FileData *basefd,
* we go back to a single linked data when loading the file. */
ID **realid = NULL;
if (!BLI_ghash_ensure_p(loaded_ids, id->name, (void ***)&realid)) {
read_library_linked_id(basefd->reports, fd, mainvar, id, realid);
read_library_linked_id(basefd, fd, mainvar, id, realid);
}
/* realid shall never be NULL - unless some source file/lib is broken
@ -5434,7 +5434,7 @@ static FileData *read_library_file_data(FileData *basefd,
if (fd == NULL) {
BLO_reportf_wrap(
basefd->reports, RPT_INFO, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath_abs);
fd->library_file_missing_count++;
basefd->library_file_missing_count++;
}
return fd;
@ -5483,9 +5483,6 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
/* Test if linked data-locks need to read further linked data-locks
* and create link placeholders for them. */
BLO_expand_main(fd, mainptr);
basefd->library_file_missing_count += fd->library_file_missing_count;
basefd->library_id_missing_count += fd->library_id_missing_count;
}
}
}

View File

@ -1723,16 +1723,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_END;
}
/**
* Versioning code until next subversion bump goes here.
*
* \note Be sure to check when bumping the version:
* - "versioning_userdef.c", #blo_do_versions_userdef
* - "versioning_userdef.c", #do_versions_theme
*
* \note Keep this message at the bottom of the function.
*/
{
if (!MAIN_VERSION_ATLEAST(bmain, 293, 9)) {
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "bokeh_overblur")) {
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
scene->eevee.bokeh_neighbor_max = 10.0f;
@ -1754,6 +1745,24 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_GEOMETRY) {
version_node_socket_name(ntree, GEO_NODE_ATTRIBUTE_PROXIMITY, "Result", "Distance");
}
}
FOREACH_NODETREE_END;
}
/**
* Versioning code until next subversion bump goes here.
*
* \note Be sure to check when bumping the version:
* - "versioning_userdef.c", #blo_do_versions_userdef
* - "versioning_userdef.c", #do_versions_theme
*
* \note Keep this message at the bottom of the function.
*/
{
/* Keep this block, even when empty. */
LISTBASE_FOREACH (Brush *, br, &bmain->brushes) {
BKE_brush_default_input_curves_set(br);

View File

@ -1847,7 +1847,7 @@ static bool gpencil_generic_stroke_select(bContext *C,
bGPDspoint *pt;
int i;
bool hit = false;
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
for (i = 0, pt = gps_active->points; i < gps_active->totpoints; i++, pt++) {
bGPDspoint *pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt;
/* convert point coords to screenspace */
@ -2252,12 +2252,12 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
int i;
/* firstly, check for hit-point */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
for (i = 0, pt = gps_active->points; i < gps_active->totpoints; i++, pt++) {
int xy[2];
bGPDspoint pt2;
gpencil_point_to_parent_space(pt, gpstroke_iter.diff_mat, &pt2);
gpencil_point_to_xy(&gsc, gps, &pt2, &xy[0], &xy[1]);
gpencil_point_to_xy(&gsc, gps_active, &pt2, &xy[0], &xy[1]);
/* do boundbox check first */
if (!ELEM(V2D_IS_CLIPPED, xy[0], xy[1])) {

View File

@ -56,6 +56,8 @@ const EnumPropertyItem rna_enum_region_type_items[] = {
#ifdef RNA_RUNTIME
# include "RNA_access.h"
# include "BKE_global.h"
# include "BKE_screen.h"
# include "BKE_workspace.h"
@ -274,6 +276,25 @@ static void rna_Area_ui_type_update(bContext *C, PointerRNA *ptr)
ED_area_tag_refresh(area);
}
static PointerRNA rna_Region_data_get(PointerRNA *ptr)
{
bScreen *screen = (bScreen *)ptr->owner_id;
ARegion *region = ptr->data;
if (region->regiondata != NULL) {
if (region->regiontype == RGN_TYPE_WINDOW) {
/* We could make this static, it wont change at run-time. */
SpaceType *st = BKE_spacetype_from_id(SPACE_VIEW3D);
if (region->type == BKE_regiontype_from_id(st, region->regiontype)) {
PointerRNA newptr;
RNA_pointer_create(&screen->id, &RNA_RegionView3D, region->regiondata, &newptr);
return newptr;
}
}
}
return PointerRNA_NULL;
}
static void rna_View2D_region_to_view(struct View2D *v2d, float x, float y, float result[2])
{
UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]);
@ -539,6 +560,13 @@ static void rna_def_region(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop, "rna_region_alignment_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Alignment", "Alignment of the region within the area");
prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(
prop, "Region Data", "Region specific data (the type depends on the region type)");
RNA_def_property_struct_type(prop, "AnyType");
RNA_def_property_pointer_funcs(prop, "rna_Region_data_get", NULL, NULL, NULL);
RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw");
}

View File

@ -647,11 +647,6 @@ static wmEvent *rna_Window_event_add_simulate(wmWindow *win,
e.alt = alt;
e.oskey = oskey;
e.prevx = win->eventstate->x;
e.prevy = win->eventstate->y;
e.prevval = win->eventstate->val;
e.prevtype = win->eventstate->type;
e.ascii = '\0';
e.utf8_buf[0] = '\0';
if (unicode != NULL) {

View File

@ -31,7 +31,8 @@
static bNodeSocketTemplate geo_node_attribute_proximity_in[] = {
{SOCK_GEOMETRY, N_("Geometry")},
{SOCK_GEOMETRY, N_("Target")},
{SOCK_STRING, N_("Result")},
{SOCK_STRING, N_("Distance")},
{SOCK_STRING, N_("Location")},
{-1, ""},
};
@ -60,50 +61,66 @@ static void geo_attribute_proximity_init(bNodeTree *UNUSED(ntree), bNode *node)
namespace blender::nodes {
static void proximity_calc(MutableSpan<float> distance_span,
MutableSpan<float3> location_span,
Span<float3> positions,
BVHTreeFromMesh &tree_data_mesh,
BVHTreeFromPointCloud &tree_data_pointcloud,
const bool bvh_mesh_success,
const bool bvh_pointcloud_success)
const bool bvh_pointcloud_success,
const bool store_distances,
const bool store_locations)
{
/* The pointcloud loop uses the values already in the span,
* which is only set if the mesh BVH is used (because it's first). */
if (!bvh_mesh_success) {
distance_span.fill(FLT_MAX);
}
IndexRange range = positions.index_range();
parallel_for(range, 512, [&](IndexRange range) {
BVHTreeNearest nearest;
BVHTreeNearest nearest_from_mesh;
BVHTreeNearest nearest_from_pointcloud;
if (bvh_mesh_success) {
copy_v3_fl(nearest.co, FLT_MAX);
nearest.index = -1;
copy_v3_fl(nearest_from_mesh.co, FLT_MAX);
copy_v3_fl(nearest_from_pointcloud.co, FLT_MAX);
for (int i : range) {
nearest.dist_sq = len_squared_v3v3(nearest.co, positions[i]);
nearest_from_mesh.index = -1;
nearest_from_pointcloud.index = -1;
for (int i : range) {
/* Use the distance to the last found point as upper bound to speedup the bvh lookup. */
nearest_from_mesh.dist_sq = len_squared_v3v3(nearest_from_mesh.co, positions[i]);
if (bvh_mesh_success) {
BLI_bvhtree_find_nearest(tree_data_mesh.tree,
positions[i],
&nearest,
&nearest_from_mesh,
tree_data_mesh.nearest_callback,
&tree_data_mesh);
distance_span[i] = sqrtf(nearest.dist_sq);
}
}
if (bvh_pointcloud_success) {
copy_v3_fl(nearest.co, FLT_MAX);
nearest.index = -1;
/* Use the distance to the closest point in the mesh to speedup the pointcloud bvh lookup.
* This is ok because we only need to find the closest point in the pointcloud if it's closer
* than the mesh. */
nearest_from_pointcloud.dist_sq = nearest_from_mesh.dist_sq;
for (int i : range) {
/* Use the distance to the last found point as upper bound to speedup the bvh lookup. */
nearest.dist_sq = len_squared_v3v3(nearest.co, positions[i]);
if (bvh_pointcloud_success) {
BLI_bvhtree_find_nearest(tree_data_pointcloud.tree,
positions[i],
&nearest,
&nearest_from_pointcloud,
tree_data_pointcloud.nearest_callback,
&tree_data_pointcloud);
distance_span[i] = std::min(distance_span[i], sqrtf(nearest.dist_sq));
}
if (nearest_from_pointcloud.dist_sq < nearest_from_mesh.dist_sq) {
if (store_distances) {
distance_span[i] = sqrtf(nearest_from_pointcloud.dist_sq);
}
if (store_locations) {
location_span[i] = nearest_from_pointcloud.co;
}
}
else {
if (store_distances) {
distance_span[i] = sqrtf(nearest_from_mesh.dist_sq);
}
if (store_locations) {
location_span[i] = nearest_from_mesh.co;
}
}
}
});
@ -151,14 +168,18 @@ static void attribute_calc_proximity(GeometryComponent &component,
/* This node works on the "point" domain, since that is where positions are stored. */
const AttributeDomain result_domain = ATTR_DOMAIN_POINT;
const std::string result_attribute_name = params.get_input<std::string>("Result");
const std::string distance_attribute_name = params.get_input<std::string>("Distance");
OutputAttributePtr distance_attribute = component.attribute_try_get_for_output(
result_attribute_name, result_domain, CD_PROP_FLOAT);
distance_attribute_name, result_domain, CD_PROP_FLOAT);
const std::string location_attribute_name = params.get_input<std::string>("Location");
OutputAttributePtr location_attribute = component.attribute_try_get_for_output(
location_attribute_name, result_domain, CD_PROP_FLOAT3);
ReadAttributePtr position_attribute = component.attribute_try_get_for_read("position");
BLI_assert(position_attribute->custom_data_type() == CD_PROP_FLOAT3);
if (!distance_attribute || !position_attribute) {
if (!position_attribute || (!distance_attribute && !location_attribute)) {
return;
}
@ -183,12 +204,24 @@ static void attribute_calc_proximity(GeometryComponent &component,
tree_data_pointcloud);
}
proximity_calc(distance_attribute->get_span_for_write_only<float>(),
position_attribute->get_span<float3>(),
Span<float3> position_span = position_attribute->get_span<float3>();
MutableSpan<float> distance_span = distance_attribute ?
distance_attribute->get_span_for_write_only<float>() :
MutableSpan<float>();
MutableSpan<float3> location_span = location_attribute ?
location_attribute->get_span_for_write_only<float3>() :
MutableSpan<float3>();
proximity_calc(distance_span,
location_span,
position_span,
tree_data_mesh,
tree_data_pointcloud,
bvh_mesh_success,
bvh_pointcloud_success);
bvh_pointcloud_success,
distance_attribute, /* Boolean. */
location_attribute); /* Boolean. */
if (bvh_mesh_success) {
free_bvhtree_from_mesh(&tree_data_mesh);
@ -197,7 +230,12 @@ static void attribute_calc_proximity(GeometryComponent &component,
free_bvhtree_from_pointcloud(&tree_data_pointcloud);
}
distance_attribute.apply_span_and_save();
if (distance_attribute) {
distance_attribute.apply_span_and_save();
}
if (location_attribute) {
location_attribute.apply_span_and_save();
}
}
static void geo_node_attribute_proximity_exec(GeoNodeExecParams params)

View File

@ -148,8 +148,29 @@ wmEvent *WM_event_add_simulate(wmWindow *win, const wmEvent *event_to_add)
return NULL;
}
wmEvent *event = wm_event_add(win, event_to_add);
win->eventstate->x = event->x;
win->eventstate->y = event->y;
win->eventstate->prevval = event->prevval = win->eventstate->val;
win->eventstate->prevtype = event->prevtype = win->eventstate->type;
win->eventstate->prevx = event->prevx = win->eventstate->x;
win->eventstate->prevy = event->prevy = win->eventstate->y;
if (event->type == MOUSEMOVE) {
/* Pass. */
}
else {
win->eventstate->val = event->val;
win->eventstate->type = event->type;
if (ISMOUSE_BUTTON(event->type)) {
if (event->val == KM_PRESS) {
win->eventstate->prevclickx = event->x;
win->eventstate->prevclicky = event->y;
}
}
}
return event;
}