Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_cloth.c
| Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | |||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| static float cloth_brush_simulation_falloff_get(const Brush *brush, | static float cloth_brush_simulation_falloff_get(const Brush *brush, | ||||
| const float radius, | const float radius, | ||||
| const float location[3], | const float location[3], | ||||
| const float co[3]) | const float co[3]) | ||||
| { | { | ||||
| /* Global simulation does not have any falloff as the entire mesh is being simulated. */ | |||||
| if (brush->cloth_simulation_area_type == BRUSH_CLOTH_SIMULATION_AREA_GLOBAL) { | |||||
| return 1.0f; | |||||
| } | |||||
| const float distance = len_v3v3(location, co); | const float distance = len_v3v3(location, co); | ||||
| const float limit = radius + (radius * brush->cloth_sim_limit); | const float limit = radius + (radius * brush->cloth_sim_limit); | ||||
| const float falloff = radius + (radius * brush->cloth_sim_limit * brush->cloth_sim_falloff); | const float falloff = radius + (radius * brush->cloth_sim_limit * brush->cloth_sim_falloff); | ||||
| if (distance > limit) { | if (distance > limit) { | ||||
| /* Outiside the limits. */ | /* Outiside the limits. */ | ||||
| return 0.0f; | return 0.0f; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | static void do_cloth_brush_build_constraints_task_cb_ex( | ||||
| * positions. */ | * positions. */ | ||||
| const bool cloth_is_deform_brush = ss->cache != NULL && brush != NULL && | const bool cloth_is_deform_brush = ss->cache != NULL && brush != NULL && | ||||
| SCULPT_is_cloth_deform_brush(brush); | SCULPT_is_cloth_deform_brush(brush); | ||||
| float radius_squared = 0.0f; | float radius_squared = 0.0f; | ||||
| if (cloth_is_deform_brush) { | if (cloth_is_deform_brush) { | ||||
| radius_squared = ss->cache->initial_radius * ss->cache->initial_radius; | radius_squared = ss->cache->initial_radius * ss->cache->initial_radius; | ||||
| } | } | ||||
| const float cloth_sim_radius_squared = data->cloth_sim_radius * data->cloth_sim_radius; | /* Only limit the contraint creation to a radius when the simulation is local. */ | ||||
| const float cloth_sim_radius_squared = brush->cloth_simulation_area_type == | |||||
| BRUSH_CLOTH_SIMULATION_AREA_LOCAL ? | |||||
| data->cloth_sim_radius * data->cloth_sim_radius : | |||||
| FLT_MAX; | |||||
| BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) | BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) | ||||
| { | { | ||||
| const float len_squared = len_squared_v3v3(vd.co, data->cloth_sim_initial_location); | const float len_squared = len_squared_v3v3(vd.co, data->cloth_sim_initial_location); | ||||
| if (len_squared < cloth_sim_radius_squared) { | if (len_squared < cloth_sim_radius_squared) { | ||||
| SculptVertexNeighborIter ni; | SculptVertexNeighborIter ni; | ||||
| int build_indices[CLOTH_MAX_CONSTRAINTS_PER_VERTEX]; | int build_indices[CLOTH_MAX_CONSTRAINTS_PER_VERTEX]; | ||||
| ▲ Show 20 Lines • Show All 1,008 Lines • Show Last 20 Lines | |||||