Curves: initial surface collision for curves sculpt mode #104469

Merged
Jacques Lucke merged 29 commits from JacquesLucke/blender:temp-curves-surface-collision into main 2023-02-11 13:46:39 +01:00
26 changed files with 209 additions and 49 deletions
Showing only changes of commit 3f3364d118 - Show all commits

View File

@ -1,5 +1,4 @@
This repository is only used as a mirror of git.blender.org. Blender development happens on
https://developer.blender.org.
This repository is only used as a mirror. Blender development happens on projects.blender.org.
To get started with contributing code, please see:
https://wiki.blender.org/wiki/Process/Contributing_Code

3
.github/stale.yml vendored
View File

@ -15,8 +15,7 @@ staleLabel: stale
# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
This issue has been automatically closed, because this repository is only
used as a mirror of git.blender.org. Blender development happens on
developer.blender.org.
used as a mirror. Blender development happens on projects.blender.org.
To get started contributing code, please read:
https://wiki.blender.org/wiki/Process/Contributing_Code

View File

@ -24,7 +24,7 @@ Development
-----------
- [Build Instructions](https://wiki.blender.org/wiki/Building_Blender)
- [Code Review & Bug Tracker](https://developer.blender.org)
- [Code Review & Bug Tracker](https://projects.blender.org)
- [Developer Forum](https://devtalk.blender.org)
- [Developer Documentation](https://wiki.blender.org)

View File

@ -23,19 +23,19 @@ if(EXISTS ${SOURCE_DIR}/.git)
if(MY_WC_BRANCH STREQUAL "HEAD")
# Detached HEAD, check whether commit hash is reachable
# in the master branch
# in the main branch
execute_process(COMMAND git rev-parse --short=12 HEAD
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND git branch --list master blender-v* --contains ${MY_WC_HASH}
execute_process(COMMAND git branch --list main blender-v* --contains ${MY_WC_HASH}
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE _git_contains_check
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT _git_contains_check STREQUAL "")
set(MY_WC_BRANCH "master")
set(MY_WC_BRANCH "main")
else()
execute_process(COMMAND git show-ref --tags -d
WORKING_DIRECTORY ${SOURCE_DIR}
@ -48,7 +48,7 @@ if(EXISTS ${SOURCE_DIR}/.git)
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(_git_tag_hashes MATCHES "${_git_head_hash}")
set(MY_WC_BRANCH "master")
set(MY_WC_BRANCH "main")
else()
execute_process(COMMAND git branch --contains ${MY_WC_HASH}
WORKING_DIRECTORY ${SOURCE_DIR}

View File

@ -11,11 +11,11 @@
mkdir ~/blender-git
cd ~/blender-git
git clone http://git.blender.org/blender.git
git clone https://projects.blender.org/blender/blender.git
cd blender
git submodule update --init --recursive
git submodule foreach git checkout master
git submodule foreach git pull --rebase origin master
git submodule foreach git checkout main
git submodule foreach git pull --rebase origin main
# create build dir
mkdir ~/blender-git/build-cmake
@ -35,7 +35,7 @@ ln -s ~/blender-git/build-cmake/bin/blender ~/blender-git/blender/blender.bin
echo ""
echo "* Useful Commands *"
echo " Run Blender: ~/blender-git/blender/blender.bin"
echo " Update Blender: git pull --rebase; git submodule foreach git pull --rebase origin master"
echo " Update Blender: git pull --rebase; git submodule foreach git pull --rebase origin main"
echo " Reconfigure Blender: cd ~/blender-git/build-cmake ; cmake ."
echo " Build Blender: cd ~/blender-git/build-cmake ; make"
echo ""

View File

@ -5,16 +5,16 @@
update-code:
git:
submodules:
- branch: master
- branch: main
commit_id: HEAD
path: release/scripts/addons
- branch: master
- branch: main
commit_id: HEAD
path: release/scripts/addons_contrib
- branch: master
- branch: main
commit_id: HEAD
path: release/datafiles/locale
- branch: master
- branch: main
commit_id: HEAD
path: source/tools
svn:

View File

@ -58,7 +58,7 @@ Each Blender release supports one Python version, and the package is only compat
## Source Code
* [Releases](https://download.blender.org/source/)
* Repository: [git.blender.org/blender.git](https://git.blender.org/gitweb/gitweb.cgi/blender.git)
* Repository: [projects.blender.org/blender/blender.git](https://projects.blender.org/blender/blender)
## Credits

View File

@ -202,8 +202,8 @@ def submodules_update(
sys.exit(1)
# Update submodules to appropriate given branch,
# falling back to master if none is given and/or found in a sub-repository.
branch_fallback = "master"
# falling back to main if none is given and/or found in a sub-repository.
branch_fallback = "main"
if not branch:
branch = branch_fallback

View File

@ -3,9 +3,9 @@ if NOT exist "%BLENDER_DIR%\source\tools\.git" (
if not "%GIT%" == "" (
"%GIT%" submodule update --init --recursive --progress
if errorlevel 1 goto FAIL
"%GIT%" submodule foreach git checkout master
"%GIT%" submodule foreach git checkout main
if errorlevel 1 goto FAIL
"%GIT%" submodule foreach git pull --rebase origin master
"%GIT%" submodule foreach git pull --rebase origin main
if errorlevel 1 goto FAIL
goto EOF
) else (

View File

@ -1816,9 +1816,9 @@ def pyrna2sphinx(basepath):
# operators
def write_ops():
API_BASEURL = "https://developer.blender.org/diffusion/B/browse/master/release/scripts"
API_BASEURL_ADDON = "https://developer.blender.org/diffusion/BA"
API_BASEURL_ADDON_CONTRIB = "https://developer.blender.org/diffusion/BAC"
API_BASEURL = "https://projects.blender.org/blender/blender/src/branch/main/release/scripts"
API_BASEURL_ADDON = "https://projects.blender.org/blender/blender-addons"
API_BASEURL_ADDON_CONTRIB = "https://projects.blender.org/blender/blender-addons-contrib"
op_modules = {}
op = None

View File

@ -156,7 +156,7 @@ var Popover = function() {
},
getNamed : function(v) {
$.each(all_versions, function(ix, title) {
if (ix === "master" || ix === "latest") {
if (ix === "master" || ix === "main" || ix === "latest") {
var m = title.match(/\d\.\d[\w\d\.]*/)[0];
if (parseFloat(m) == v) {
v = ix;

View File

@ -1,5 +1,5 @@
Project: Blender
URL: https://git.blender.org/blender.git
URL: https://projects.blender.org/blender/blender.git
License: Apache 2.0
Upstream version: N/A
Local modifications: None

View File

@ -8,9 +8,9 @@ else
exit 1
fi
BRANCH="master"
BRANCH="main"
# repo="git://git.blender.org/libmv.git"
# repo="https://projects.blender.org/blender/libmv.git"
repo="/home/sergey/Developer/libmv"
tmp=`mktemp -d`

View File

@ -96,8 +96,8 @@ Chat <a href="https://blender.chat/channel/today">
<p class="p5">
<span class="s3">Development <a href="https://www.blender.org/get-involved/developers/">
<span class="s4">www.blender.org/get-involved/developers/</span></a><br>
GIT and Bug Tracker <a href="https://developer.blender.org/">
<span class="s4">developer.blender.org</span></a><br>
GIT and Bug Tracker <a href="https://projects.blender.org/">
<span class="s4">projects.blender.org</span></a><br>
Chat <a href="https://blender.chat/channel/blender-coders">
<span class="s4">#blender-coders</span></a> on blender.chat</span>
</p>

View File

@ -3,7 +3,7 @@ echo Starting blender with GPU debugging options, log files will be created
echo in your temp folder, windows explorer will open after you close blender
echo to help you find them.
echo.
echo If you report a bug on https://developer.blender.org you can attach these files
echo If you report a bug on https://projects.blender.org you can attach these files
echo by dragging them into the text area of your bug report, please include both
echo blender_debug_output.txt and blender_system_info.txt in your report.
echo.

View File

@ -3,7 +3,7 @@ echo Starting blender with GPU debugging and glitch workaround options, log file
echo will be created in your temp folder, windows explorer will open after you
echo close blender to help you find them.
echo.
echo If you report a bug on https://developer.blender.org you can attach these files
echo If you report a bug on https://projects.blender.org you can attach these files
echo by dragging them into the text area of your bug report, please include both
echo blender_debug_output.txt and blender_system_info.txt in your report.
echo.

View File

@ -3,7 +3,7 @@ echo Starting blender with debug logging options, log files will be created
echo in your temp folder, windows explorer will open after you close blender
echo to help you find them.
echo.
echo If you report a bug on https://developer.blender.org you can attach these files
echo If you report a bug on https://projects.blender.org you can attach these files
echo by dragging them into the text area of your bug report, please include both
echo blender_debug_output.txt and blender_system_info.txt in your report.
echo.

View File

@ -3,7 +3,7 @@ echo Starting blender with factory settings, log files will be created
echo in your temp folder, windows explorer will open after you close blender
echo to help you find them.
echo.
echo If you report a bug on https://developer.blender.org you can attach these files
echo If you report a bug on https://projects.blender.org you can attach these files
echo by dragging them into the text area of your bug report, please include both
echo blender_debug_output.txt and blender_system_info.txt in your report.
echo.

View File

@ -637,9 +637,6 @@ typedef struct DRWManager {
DRWView *view_active;
DRWView *view_previous;
uint primary_view_num;
/** TODO(@fclem): Remove this. Only here to support
* shaders without common_view_lib.glsl */
ViewMatrices view_storage_cpy;
#ifdef USE_GPU_SELECT
uint select_id;

View File

@ -1161,9 +1161,6 @@ static void drw_update_view(void)
GPU_uniformbuf_update(G_draw.view_ubo, &DST.view_active->storage);
GPU_uniformbuf_update(G_draw.clipping_ubo, &DST.view_active->clip_planes);
/* TODO: get rid of this. */
DST.view_storage_cpy = DST.view_active->storage;
draw_compute_culling(DST.view_active);
}

View File

@ -9,11 +9,13 @@
#include "BLI_rand.hh"
#include "BKE_attribute.hh"
#include "BKE_crazyspace.hh"
#include "BKE_curves.hh"
#include "ED_curves.h"
#include "ED_object.h"
#include "ED_select_utils.h"
#include "ED_view3d.h"
namespace blender::ed::curves {
@ -283,4 +285,140 @@ void select_random(bke::CurvesGeometry &curves,
selection.finish();
}
/**
* Helper struct for `find_closest_point_to_screen_co`.
*/
struct FindClosestPointData {
int index = -1;
float distance = FLT_MAX;
};
static bool find_closest_point_to_screen_co(const Depsgraph &depsgraph,
const ARegion *region,
const RegionView3D *rv3d,
const Object &object,
const bke::CurvesGeometry &curves,
float2 mouse_pos,
float radius,
FindClosestPointData &closest_data)
{
float4x4 projection;
ED_view3d_ob_project_mat_get(rv3d, &object, projection.ptr());
const bke::crazyspace::GeometryDeformation deformation =
bke::crazyspace::get_evaluated_curves_deformation(depsgraph, object);
const float radius_sq = pow2f(radius);
auto [min_point_index, min_distance] = threading::parallel_reduce(
curves.points_range(),
1024,
FindClosestPointData(),
[&](const IndexRange point_range, const FindClosestPointData &init) {
FindClosestPointData best_match = init;
for (const int point_i : point_range) {
const float3 pos = deformation.positions[point_i];
/* Find the position of the point in screen space. */
float2 pos_proj;
ED_view3d_project_float_v2_m4(region, pos, pos_proj, projection.ptr());
const float distance_proj_sq = math::distance_squared(pos_proj, mouse_pos);
if (distance_proj_sq > radius_sq ||
distance_proj_sq > best_match.distance * best_match.distance) {
/* Ignore the point because it's too far away or there is already a better point. */
continue;
}
FindClosestPointData better_candidate;
better_candidate.index = point_i;
better_candidate.distance = std::sqrt(distance_proj_sq);
best_match = better_candidate;
}
return best_match;
},
[](const FindClosestPointData &a, const FindClosestPointData &b) {
if (a.distance < b.distance) {
return a;
}
return b;
});
if (min_point_index > 0) {
closest_data.index = min_point_index;
closest_data.distance = min_distance;
return true;
}
return false;
}
bool select_pick(const ViewContext &vc,
bke::CurvesGeometry &curves,
const eAttrDomain selection_domain,
const SelectPick_Params &params,
const int2 mval)
{
FindClosestPointData closest_point;
bool found = find_closest_point_to_screen_co(*vc.depsgraph,
vc.region,
vc.rv3d,
*vc.obact,
curves,
float2(mval),
ED_view3d_select_dist_px(),
closest_point);
bool changed = false;
if (params.sel_op == SEL_OP_SET) {
if (found || params.deselect_all) {
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
curves, selection_domain, CD_PROP_BOOL);
fill_selection_false(selection.span);
selection.finish();
changed = true;
}
}
if (found) {
bke::GSpanAttributeWriter selection = ensure_selection_attribute(
curves, selection_domain, CD_PROP_BOOL);
int elem_index = closest_point.index;
if (selection_domain == ATTR_DOMAIN_CURVE) {
/* Find the curve index for the found point. */
auto it = std::upper_bound(
curves.offsets().begin(), curves.offsets().end(), closest_point.index);
BLI_assert(it != curves.offsets().end());
elem_index = std::distance(curves.offsets().begin(), it) - 1;
}
selection.span.type().to_static_type_tag<bool, float>([&](auto type_tag) {
using T = typename decltype(type_tag)::type;
if constexpr (std::is_void_v<T>) {
BLI_assert_unreachable();
}
else {
MutableSpan<T> selection_typed = selection.span.typed<T>();
switch (params.sel_op) {
case SEL_OP_ADD:
case SEL_OP_SET:
selection_typed[elem_index] = T(1);
break;
case SEL_OP_SUB:
selection_typed[elem_index] = T(0);
break;
case SEL_OP_XOR:
selection_typed[elem_index] = T(1 - selection_typed[elem_index]);
break;
default:
break;
}
}
});
selection.finish();
}
return changed || found;
}
} // namespace blender::ed::curves

View File

@ -9,6 +9,8 @@
struct bContext;
struct Curves;
struct UndoType;
struct SelectPick_Params;
struct ViewContext;
#ifdef __cplusplus
extern "C" {
@ -134,6 +136,17 @@ void select_random(bke::CurvesGeometry &curves,
const eAttrDomain selection_domain,
uint32_t random_seed,
float probability);
/**
* Select point or curve under the cursor.
*/
bool select_pick(const ViewContext &vc,
bke::CurvesGeometry &curves,
const eAttrDomain selection_domain,
const SelectPick_Params &params,
const int2 mval);
/** \} */
} // namespace blender::ed::curves

View File

@ -73,6 +73,7 @@ set(SRC
)
set(LIB
bf_editor_curves
bf_editor_lattice
bf_editor_mesh
)

View File

@ -69,6 +69,7 @@
#include "ED_armature.h"
#include "ED_curve.h"
#include "ED_curves.h"
#include "ED_gpencil.h"
#include "ED_lattice.h"
#include "ED_mball.h"
@ -2968,10 +2969,15 @@ static bool ed_wpaint_vertex_select_pick(bContext *C,
static int view3d_select_exec(bContext *C, wmOperator *op)
{
using namespace blender;
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewContext vc;
ED_view3d_viewcontext_init(C, &vc, depsgraph);
SelectPick_Params params{};
ED_select_pick_params_from_operator(op->ptr, &params);
@ -3021,10 +3027,6 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
}
else if (obedit->type == OB_ARMATURE) {
if (enumerate) {
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewContext vc;
ED_view3d_viewcontext_init(C, &vc, depsgraph);
GPUSelectResult buffer[MAXPICKELEMS];
const int hits = mixed_bones_object_selectbuffer(
&vc, buffer, ARRAY_SIZE(buffer), mval, VIEW3D_SELECT_FILTER_NOP, false, true, false);
@ -3047,6 +3049,19 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
else if (obedit->type == OB_FONT) {
changed = ED_curve_editfont_select_pick(C, mval, &params);
}
else if (obedit->type == OB_CURVES) {
Curves &curves_id = *static_cast<Curves *>(obact->data);
bke::CurvesGeometry &curves = curves_id.geometry.wrap();
changed = ed::curves::select_pick(
vc, curves, eAttrDomain(curves_id.selection_domain), params, mval);
if (changed) {
/* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a
* generic attribute for now. */
DEG_id_tag_update(&curves_id.id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &curves_id);
return true;
}
}
}
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
changed = PE_mouse_particles(C, mval, &params);
@ -3535,8 +3550,7 @@ static bool do_mesh_box_select(ViewContext *vc,
}
if (ts->selectmode & SCE_SELECT_EDGE) {
/* Does both use_zbuf and non-use_zbuf versions (need screen cos for both) */
struct BoxSelectUserData_ForMeshEdge cb_data {
};
struct BoxSelectUserData_ForMeshEdge cb_data {};
cb_data.data = &data;
cb_data.esel = use_zbuf ? esel : nullptr;
cb_data.backbuf_offset = use_zbuf ? DRW_select_buffer_context_offset_for_object_elem(

View File

@ -2713,7 +2713,9 @@ static wmGizmoGroup *gizmogroup_xform_find(TransInfo *t)
void transform_gizmo_3d_model_from_constraint_and_mode_init(TransInfo *t)
{
wmGizmo *gizmo_modal_current = t->region ? WM_gizmomap_get_modal(t->region->gizmo_map) : NULL;
wmGizmo *gizmo_modal_current = t->region && t->region->gizmo_map ?
WM_gizmomap_get_modal(t->region->gizmo_map) :
NULL;
if (!gizmo_modal_current || !ELEM(gizmo_modal_current->parent_gzgroup->type,
g_GGT_xform_gizmo,
g_GGT_xform_gizmo_context)) {

View File

@ -150,7 +150,7 @@ class TestConfig:
default_config += """tests = ['*']\n"""
default_config += """categories = ['*']\n"""
default_config += """builds = {\n"""
default_config += """ 'master': '/home/user/blender-git/build/bin/blender',"""
default_config += """ 'main': '/home/user/blender-git/build/bin/blender',"""
default_config += """ '2.93': '/home/user/blender-2.93/blender',"""
default_config += """}\n"""
default_config += """revisions = {\n"""