/* SPDX-FileCopyrightText: Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bke
*/
/**
* variables on the UI for now
*
* float mediafrict; friction to env
* float nodemass; softbody mass of *vertex*
* float grav; softbody amount of gravitation to apply
*
* float goalspring; softbody goal springs
* float goalfrict; softbody goal springs friction
* float mingoal; quick limits for goal
* float maxgoal;
*
* float inspring; softbody inner springs
* float infrict; softbody inner springs friction
*
*/
#include
#include
#include
#include
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
/* types */
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_lattice_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_listbase.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.h"
#include "BLI_threads.h"
#include "BLI_time.h"
#include "BLI_utildefines.h"
#include "BKE_collision.h"
#include "BKE_curve.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_effect.h"
#include "BKE_global.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_mesh.hh"
#include "BKE_modifier.hh"
#include "BKE_pointcache.h"
#include "BKE_scene.hh"
#include "BKE_softbody.h"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
namespace blender {
static CLG_LogRef LOG = {"physics.softbody"};
/* callbacks for errors and interrupts and some goo */
static int (*SB_localInterruptCallBack)() = nullptr;
/* ********** soft body engine ******* */
enum type_spring { SB_EDGE = 1, SB_BEND = 2, SB_STIFFQUAD = 3, SB_HANDLE = 4 };
struct BodySpring {
int v1, v2;
float len, cf, load;
float ext_force[3]; /* edges colliding and sailing */
type_spring springtype;
short flag;
};
struct BodyFace {
int v1, v2, v3;
float ext_force[3]; /* faces colliding */
short flag;
};
struct ReferenceVert {
float pos[3]; /* position relative to com */
float mass; /* node mass */
};
struct ReferenceState {
float com[3]; /* Center of mass. */
ReferenceVert *ivert; /* List of initial values. */
};
using ColliderMeshMap = Map