Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/softbody.c
| Show First 20 Lines • Show All 508 Lines • ▼ Show 20 Lines | if (!BLI_ghash_ensure_p(hash, ob, &val_p)) { | ||||
| *val_p = ccdmesh; | *val_p = ccdmesh; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * \note group overrides scene when not NULL. | * \note group overrides scene when not NULL. | ||||
| */ | */ | ||||
| static void ccd_build_deflector_hash(SceneLayer *sl, Group *group, Object *vertexowner, GHash *hash) | static void ccd_build_deflector_hash(ViewLayer *sl, Group *group, Object *vertexowner, GHash *hash) | ||||
| { | { | ||||
| Object *ob; | Object *ob; | ||||
| if (!hash) return; | if (!hash) return; | ||||
| if (group) { | if (group) { | ||||
| /* Explicit collision group */ | /* Explicit collision group */ | ||||
| for (GroupObject *go = group->gobject.first; go; go = go->next) { | for (GroupObject *go = group->gobject.first; go; go = go->next) { | ||||
| Show All 29 Lines | if (ccdmesh) { | ||||
| ccd_mesh_update(ob, ccdmesh); | ccd_mesh_update(ob, ccdmesh); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * \note group overrides scene when not NULL. | * \note group overrides scene when not NULL. | ||||
| */ | */ | ||||
| static void ccd_update_deflector_hash(SceneLayer *sl, Group *group, Object *vertexowner, GHash *hash) | static void ccd_update_deflector_hash(ViewLayer *sl, Group *group, Object *vertexowner, GHash *hash) | ||||
| { | { | ||||
| Object *ob; | Object *ob; | ||||
| if ((!hash) || (!vertexowner)) return; | if ((!hash) || (!vertexowner)) return; | ||||
| if (group) { | if (group) { | ||||
| /* Explicit collision group */ | /* Explicit collision group */ | ||||
| for (GroupObject *go = group->gobject.first; go; go = go->next) { | for (GroupObject *go = group->gobject.first; go; go = go->next) { | ||||
| ▲ Show 20 Lines • Show All 402 Lines • ▼ Show 20 Lines | |||||
| ** since that would only valid for 'slow' moving collision targets and dito particles | ** since that would only valid for 'slow' moving collision targets and dito particles | ||||
| */ | */ | ||||
| /* +++ dependency information functions*/ | /* +++ dependency information functions*/ | ||||
| /** | /** | ||||
| * \note group overrides scene when not NULL. | * \note group overrides scene when not NULL. | ||||
| */ | */ | ||||
| static bool are_there_deflectors(SceneLayer *sl, Group *group) | static bool are_there_deflectors(ViewLayer *sl, Group *group) | ||||
| { | { | ||||
| if (group) { | if (group) { | ||||
| for (GroupObject *go = group->gobject.first; go; go = go->next) { | for (GroupObject *go = group->gobject.first; go; go = go->next) { | ||||
| if (go->ob->pd && go->ob->pd->deflect) | if (go->ob->pd && go->ob->pd->deflect) | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (Base *base = FIRSTBASE(sl); base; base = base->next) { | for (Base *base = FIRSTBASE(sl); base; base = base->next) { | ||||
| if (base->object->pd) { | if (base->object->pd) { | ||||
| if (base->object->pd->deflect) | if (base->object->pd->deflect) | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int query_external_colliders(SceneLayer *sl, Group *group) | static int query_external_colliders(ViewLayer *sl, Group *group) | ||||
| { | { | ||||
| return(are_there_deflectors(sl, group)); | return(are_there_deflectors(sl, group)); | ||||
| } | } | ||||
| /* --- dependency information functions*/ | /* --- dependency information functions*/ | ||||
| /* +++ the aabb "force" section*/ | /* +++ the aabb "force" section*/ | ||||
| static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), unsigned int UNUSED(par_layer), struct Object *vertexowner, float UNUSED(time)) | static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), unsigned int UNUSED(par_layer), struct Object *vertexowner, float UNUSED(time)) | ||||
| ▲ Show 20 Lines • Show All 1,235 Lines • ▼ Show 20 Lines | static void softbody_calc_forcesEx(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, float forcetime, float timenow) | ||||
| /* float gravity; */ /* UNUSED */ | /* float gravity; */ /* UNUSED */ | ||||
| /* float iks; */ | /* float iks; */ | ||||
| float fieldfactor = -1.0f, windfactor = 0.25; | float fieldfactor = -1.0f, windfactor = 0.25; | ||||
| int do_deflector /*, do_selfcollision*/, do_springcollision, do_aero; | int do_deflector /*, do_selfcollision*/, do_springcollision, do_aero; | ||||
| /* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */ | /* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */ | ||||
| /* check conditions for various options */ | /* check conditions for various options */ | ||||
| do_deflector= query_external_colliders(eval_ctx->scene_layer, sb->collision_group); | do_deflector= query_external_colliders(eval_ctx->view_layer, sb->collision_group); | ||||
| /* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */ | /* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */ | ||||
| do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); | do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); | ||||
| do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); | do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); | ||||
| /* iks = 1.0f/(1.0f-sb->inspring)-1.0f; */ /* inner spring constants function */ /* UNUSED */ | /* iks = 1.0f/(1.0f-sb->inspring)-1.0f; */ /* inner spring constants function */ /* UNUSED */ | ||||
| /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */ | /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */ | ||||
| if (do_springcollision || do_aero) | if (do_springcollision || do_aero) | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | else { | ||||
| int do_deflector, do_selfcollision, do_springcollision, do_aero; | int do_deflector, do_selfcollision, do_springcollision, do_aero; | ||||
| if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { | if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { | ||||
| copy_v3_v3(gravity, scene->physics_settings.gravity); | copy_v3_v3(gravity, scene->physics_settings.gravity); | ||||
| mul_v3_fl(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity); | mul_v3_fl(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity); | ||||
| } | } | ||||
| /* check conditions for various options */ | /* check conditions for various options */ | ||||
| do_deflector= query_external_colliders(eval_ctx->scene_layer, sb->collision_group); | do_deflector= query_external_colliders(eval_ctx->view_layer, sb->collision_group); | ||||
| do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); | do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); | ||||
| do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); | do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); | ||||
| do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); | do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); | ||||
| iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ | iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ | ||||
| /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */ | /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */ | ||||
| if (do_springcollision || do_aero) scan_for_ext_spring_forces(eval_ctx, scene, ob, timenow); | if (do_springcollision || do_aero) scan_for_ext_spring_forces(eval_ctx, scene, ob, timenow); | ||||
| ▲ Show 20 Lines • Show All 1,194 Lines • ▼ Show 20 Lines | static void softbody_step(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, SoftBody *sb, float dtime) | ||||
| sst=PIL_check_seconds_timer(); | sst=PIL_check_seconds_timer(); | ||||
| /* Integration back in time is possible in theory, but pretty useless here. | /* Integration back in time is possible in theory, but pretty useless here. | ||||
| * So we refuse to do so. Since we do not know anything about 'outside' changes | * So we refuse to do so. Since we do not know anything about 'outside' changes | ||||
| * especially colliders we refuse to go more than 10 frames. | * especially colliders we refuse to go more than 10 frames. | ||||
| */ | */ | ||||
| if (dtime < 0 || dtime > 10.5f) return; | if (dtime < 0 || dtime > 10.5f) return; | ||||
| ccd_update_deflector_hash(eval_ctx->scene_layer, sb->collision_group, ob, sb->scratch->colliderhash); | ccd_update_deflector_hash(eval_ctx->view_layer, sb->collision_group, ob, sb->scratch->colliderhash); | ||||
| if (sb->scratch->needstobuildcollider) { | if (sb->scratch->needstobuildcollider) { | ||||
| if (query_external_colliders(eval_ctx->scene_layer, sb->collision_group)) { | if (query_external_colliders(eval_ctx->view_layer, sb->collision_group)) { | ||||
| ccd_build_deflector_hash(eval_ctx->scene_layer, sb->collision_group, ob, sb->scratch->colliderhash); | ccd_build_deflector_hash(eval_ctx->view_layer, sb->collision_group, ob, sb->scratch->colliderhash); | ||||
| } | } | ||||
| sb->scratch->needstobuildcollider=0; | sb->scratch->needstobuildcollider=0; | ||||
| } | } | ||||
| if (sb->solver_ID < 2) { | if (sb->solver_ID < 2) { | ||||
| /* special case of 2nd order Runge-Kutta type AKA Heun */ | /* special case of 2nd order Runge-Kutta type AKA Heun */ | ||||
| int mid_flags=0; | int mid_flags=0; | ||||
| float err = 0; | float err = 0; | ||||
| ▲ Show 20 Lines • Show All 232 Lines • Show Last 20 Lines | |||||