forked from bartvdbraak/blender
Made SimDebugData into a single global instance.
This way it doesn't have to be stored as DNA runtime pointers or passed down as a function argument. Currently there is now no property or button to enable debugging, this will be added again later.
This commit is contained in:
parent
3356f3f0bb
commit
9d9dc06014
@ -188,36 +188,39 @@ typedef struct SimDebugData {
|
|||||||
struct GHash *gh;
|
struct GHash *gh;
|
||||||
} SimDebugData;
|
} SimDebugData;
|
||||||
|
|
||||||
struct SimDebugData *BKE_sim_debug_data_new(void);
|
extern SimDebugData *_sim_debug_data;
|
||||||
|
|
||||||
void BKE_sim_debug_data_add_element(struct SimDebugData *debug_data, int type, const float v1[3], const float v2[3],
|
void BKE_sim_debug_data_set_enabled(bool enable);
|
||||||
|
bool BKE_sim_debug_data_get_enabled(void);
|
||||||
|
void BKE_sim_debug_data_free(void);
|
||||||
|
|
||||||
|
void BKE_sim_debug_data_add_element(int type, const float v1[3], const float v2[3],
|
||||||
float r, float g, float b, const char *category, unsigned int hash);
|
float r, float g, float b, const char *category, unsigned int hash);
|
||||||
void BKE_sim_debug_data_remove_element(struct SimDebugData *debug_data, unsigned int hash);
|
void BKE_sim_debug_data_remove_element(unsigned int hash);
|
||||||
|
|
||||||
#define BKE_sim_debug_data_add_dot(debug_data, p, r, g, b, category, ...) { \
|
#define BKE_sim_debug_data_add_dot(p, r, g, b, category, ...) { \
|
||||||
const float v2[3] = { 0.0f, 0.0f, 0.0f }; \
|
const float v2[3] = { 0.0f, 0.0f, 0.0f }; \
|
||||||
BKE_sim_debug_data_add_element(debug_data, SIM_DEBUG_ELEM_DOT, p, v2, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \
|
BKE_sim_debug_data_add_element(SIM_DEBUG_ELEM_DOT, p, v2, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BKE_sim_debug_data_add_circle(debug_data, p, radius, r, g, b, category, ...) { \
|
#define BKE_sim_debug_data_add_circle(p, radius, r, g, b, category, ...) { \
|
||||||
const float v2[3] = { radius, 0.0f, 0.0f }; \
|
const float v2[3] = { radius, 0.0f, 0.0f }; \
|
||||||
BKE_sim_debug_data_add_element(debug_data, SIM_DEBUG_ELEM_CIRCLE, p, v2, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \
|
BKE_sim_debug_data_add_element(SIM_DEBUG_ELEM_CIRCLE, p, v2, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BKE_sim_debug_data_add_line(debug_data, p1, p2, r, g, b, category, ...) { \
|
#define BKE_sim_debug_data_add_line(p1, p2, r, g, b, category, ...) { \
|
||||||
BKE_sim_debug_data_add_element(debug_data, SIM_DEBUG_ELEM_LINE, p1, p2, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \
|
BKE_sim_debug_data_add_element(SIM_DEBUG_ELEM_LINE, p1, p2, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BKE_sim_debug_data_add_vector(debug_data, p, d, r, g, b, category, ...) { \
|
#define BKE_sim_debug_data_add_vector(p, d, r, g, b, category, ...) { \
|
||||||
BKE_sim_debug_data_add_element(debug_data, SIM_DEBUG_ELEM_VECTOR, p, d, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \
|
BKE_sim_debug_data_add_element(SIM_DEBUG_ELEM_VECTOR, p, d, r, g, b, category, SIM_DEBUG_HASH(__VA_ARGS__)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BKE_sim_debug_data_remove(debug_data, ...) \
|
#define BKE_sim_debug_data_remove(...) \
|
||||||
BKE_sim_debug_data_remove_element(debug_data, SIM_DEBUG_HASH(__VA_ARGS__))
|
BKE_sim_debug_data_remove_element(SIM_DEBUG_HASH(__VA_ARGS__))
|
||||||
|
|
||||||
void BKE_sim_debug_data_clear(struct SimDebugData *debug_data);
|
void BKE_sim_debug_data_clear(void);
|
||||||
void BKE_sim_debug_data_clear_category(struct SimDebugData *debug_data, const char *category);
|
void BKE_sim_debug_data_clear_category(const char *category);
|
||||||
void BKE_sim_debug_data_free(struct SimDebugData *debug_data);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -990,11 +990,9 @@ static bool cloth_points_collision_response_static(ClothModifierData *clmd, Coll
|
|||||||
mag_v_rel = dot_v3v3(v_rel_old, collpair->normal);
|
mag_v_rel = dot_v3v3(v_rel_old, collpair->normal);
|
||||||
|
|
||||||
/**** DEBUG ****/
|
/**** DEBUG ****/
|
||||||
if (clmd->debug_data) {
|
BKE_sim_debug_data_add_dot(collpair->pa, 0.9, 0.2, 0.2, "collision", 833, collpair->face1, collpair->face2);
|
||||||
BKE_sim_debug_data_add_dot(clmd->debug_data, collpair->pa, 0.9, 0.2, 0.2, "collision", 833, collpair->face1, collpair->face2);
|
BKE_sim_debug_data_add_dot(collpair->pb, 0.2, 0.9, 0.2, "collision", 834, collpair->face1, collpair->face2);
|
||||||
BKE_sim_debug_data_add_dot(clmd->debug_data, collpair->pb, 0.2, 0.9, 0.2, "collision", 834, collpair->face1, collpair->face2);
|
BKE_sim_debug_data_add_line(collpair->pa, collpair->pb, 0.8, 0.8, 0.8, "collision", 835, collpair->face1, collpair->face2);
|
||||||
BKE_sim_debug_data_add_line(clmd->debug_data, collpair->pa, collpair->pb, 0.8, 0.8, 0.8, "collision", 835, collpair->face1, collpair->face2);
|
|
||||||
}
|
|
||||||
/********/
|
/********/
|
||||||
|
|
||||||
if (mag_v_rel < -ALMOST_ZERO) {
|
if (mag_v_rel < -ALMOST_ZERO) {
|
||||||
@ -1106,7 +1104,7 @@ BLI_INLINE bool cloth_point_face_collision_params(const float p1[3], const float
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CollPair *cloth_point_collpair(float p1[3], float p2[3], MVert *mverts, int bp1, int bp2, int bp3,
|
static CollPair *cloth_point_collpair(float p1[3], float p2[3], MVert *mverts, int bp1, int bp2, int bp3,
|
||||||
int index_cloth, int index_coll, float epsilon, CollPair *collpair, SimDebugData *UNUSED(debug_data))
|
int index_cloth, int index_coll, float epsilon, CollPair *collpair)
|
||||||
{
|
{
|
||||||
float *co1 = mverts[bp1].co, *co2 = mverts[bp2].co, *co3 = mverts[bp3].co;
|
float *co1 = mverts[bp1].co, *co2 = mverts[bp2].co, *co3 = mverts[bp3].co;
|
||||||
float lambda, distance1, distance2;
|
float lambda, distance1, distance2;
|
||||||
@ -1163,9 +1161,9 @@ static CollPair* cloth_point_collision(ModifierData *md1, ModifierData *md2,
|
|||||||
vert = &clmd->clothObject->verts[overlap->indexA];
|
vert = &clmd->clothObject->verts[overlap->indexA];
|
||||||
face = &collmd->mfaces[overlap->indexB];
|
face = &collmd->mfaces[overlap->indexB];
|
||||||
|
|
||||||
collpair = cloth_point_collpair(vert->tx, vert->x, mverts, face->v1, face->v2, face->v3, overlap->indexA, overlap->indexB, epsilon, collpair, clmd->debug_data);
|
collpair = cloth_point_collpair(vert->tx, vert->x, mverts, face->v1, face->v2, face->v3, overlap->indexA, overlap->indexB, epsilon, collpair);
|
||||||
if (face->v4)
|
if (face->v4)
|
||||||
collpair = cloth_point_collpair(vert->tx, vert->x, mverts, face->v3, face->v4, face->v1, overlap->indexA, overlap->indexB, epsilon, collpair, clmd->debug_data);
|
collpair = cloth_point_collpair(vert->tx, vert->x, mverts, face->v3, face->v4, face->v1, overlap->indexA, overlap->indexB, epsilon, collpair);
|
||||||
|
|
||||||
return collpair;
|
return collpair;
|
||||||
}
|
}
|
||||||
|
@ -1029,6 +1029,8 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
|
|||||||
|
|
||||||
/* ======== Simulation Debugging ======== */
|
/* ======== Simulation Debugging ======== */
|
||||||
|
|
||||||
|
SimDebugData *_sim_debug_data = NULL;
|
||||||
|
|
||||||
unsigned int BKE_sim_debug_data_hash(int i)
|
unsigned int BKE_sim_debug_data_hash(int i)
|
||||||
{
|
{
|
||||||
return BLI_ghashutil_uinthash((unsigned int)i);
|
return BLI_ghashutil_uinthash((unsigned int)i);
|
||||||
@ -1080,12 +1082,31 @@ static void debug_element_free(void *val)
|
|||||||
MEM_freeN(elem);
|
MEM_freeN(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimDebugData *BKE_sim_debug_data_new(void)
|
void BKE_sim_debug_data_set_enabled(bool enable)
|
||||||
{
|
{
|
||||||
SimDebugData *debug_data = MEM_callocN(sizeof(SimDebugData), "sim debug data");
|
if (enable) {
|
||||||
debug_data->gh = BLI_ghash_new(debug_element_hash, debug_element_compare, "sim debug element hash");
|
if (!_sim_debug_data) {
|
||||||
return debug_data;
|
_sim_debug_data = MEM_callocN(sizeof(SimDebugData), "sim debug data");
|
||||||
|
_sim_debug_data->gh = BLI_ghash_new(debug_element_hash, debug_element_compare, "sim debug element hash");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BKE_sim_debug_data_free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BKE_sim_debug_data_get_enabled(void)
|
||||||
|
{
|
||||||
|
return _sim_debug_data != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BKE_sim_debug_data_free(void)
|
||||||
|
{
|
||||||
|
if (_sim_debug_data) {
|
||||||
|
if (_sim_debug_data->gh)
|
||||||
|
BLI_ghash_free(_sim_debug_data->gh, NULL, debug_element_free);
|
||||||
|
MEM_freeN(_sim_debug_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void debug_data_insert(SimDebugData *debug_data, SimDebugElement *elem)
|
static void debug_data_insert(SimDebugData *debug_data, SimDebugElement *elem)
|
||||||
@ -1099,11 +1120,11 @@ static void debug_data_insert(SimDebugData *debug_data, SimDebugElement *elem)
|
|||||||
BLI_ghash_insert(debug_data->gh, elem, elem);
|
BLI_ghash_insert(debug_data->gh, elem, elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_sim_debug_data_add_element(SimDebugData *debug_data, int type, const float v1[3], const float v2[3], float r, float g, float b, const char *category, unsigned int hash)
|
void BKE_sim_debug_data_add_element(int type, const float v1[3], const float v2[3], float r, float g, float b, const char *category, unsigned int hash)
|
||||||
{
|
{
|
||||||
unsigned int category_hash = BLI_ghashutil_strhash_p(category);
|
unsigned int category_hash = BLI_ghashutil_strhash_p(category);
|
||||||
SimDebugElement *elem;
|
SimDebugElement *elem;
|
||||||
if (!debug_data)
|
if (!_sim_debug_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
elem = MEM_callocN(sizeof(SimDebugElement), "sim debug data element");
|
elem = MEM_callocN(sizeof(SimDebugElement), "sim debug data element");
|
||||||
@ -1116,54 +1137,44 @@ void BKE_sim_debug_data_add_element(SimDebugData *debug_data, int type, const fl
|
|||||||
copy_v3_v3(elem->v1, v1);
|
copy_v3_v3(elem->v1, v1);
|
||||||
copy_v3_v3(elem->v2, v2);
|
copy_v3_v3(elem->v2, v2);
|
||||||
|
|
||||||
debug_data_insert(debug_data, elem);
|
debug_data_insert(_sim_debug_data, elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_sim_debug_data_remove_element(SimDebugData *debug_data, unsigned int hash)
|
void BKE_sim_debug_data_remove_element(unsigned int hash)
|
||||||
{
|
{
|
||||||
SimDebugElement dummy;
|
SimDebugElement dummy;
|
||||||
if (!debug_data)
|
if (!_sim_debug_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dummy.hash = hash;
|
dummy.hash = hash;
|
||||||
BLI_ghash_remove(debug_data->gh, &dummy, NULL, debug_element_free);
|
BLI_ghash_remove(_sim_debug_data->gh, &dummy, NULL, debug_element_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_sim_debug_data_clear(SimDebugData *debug_data)
|
void BKE_sim_debug_data_clear(void)
|
||||||
{
|
{
|
||||||
if (!debug_data)
|
if (!_sim_debug_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (debug_data->gh)
|
if (_sim_debug_data->gh)
|
||||||
BLI_ghash_clear(debug_data->gh, NULL, debug_element_free);
|
BLI_ghash_clear(_sim_debug_data->gh, NULL, debug_element_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_sim_debug_data_clear_category(SimDebugData *debug_data, const char *category)
|
void BKE_sim_debug_data_clear_category(const char *category)
|
||||||
{
|
{
|
||||||
int category_hash = (int)BLI_ghashutil_strhash_p(category);
|
int category_hash = (int)BLI_ghashutil_strhash_p(category);
|
||||||
|
|
||||||
if (!debug_data)
|
if (!_sim_debug_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (debug_data->gh) {
|
if (_sim_debug_data->gh) {
|
||||||
GHashIterator iter;
|
GHashIterator iter;
|
||||||
BLI_ghashIterator_init(&iter, debug_data->gh);
|
BLI_ghashIterator_init(&iter, _sim_debug_data->gh);
|
||||||
while(!BLI_ghashIterator_done(&iter)) {
|
while(!BLI_ghashIterator_done(&iter)) {
|
||||||
SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
|
SimDebugElement *elem = BLI_ghashIterator_getValue(&iter);
|
||||||
BLI_ghashIterator_step(&iter); /* removing invalidates the current iterator, so step before removing */
|
BLI_ghashIterator_step(&iter); /* removing invalidates the current iterator, so step before removing */
|
||||||
|
|
||||||
if (elem->category_hash == category_hash)
|
if (elem->category_hash == category_hash)
|
||||||
BLI_ghash_remove(debug_data->gh, elem, NULL, debug_element_free);
|
BLI_ghash_remove(_sim_debug_data->gh, elem, NULL, debug_element_free);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_sim_debug_data_free(SimDebugData *debug_data)
|
|
||||||
{
|
|
||||||
if (!debug_data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (debug_data->gh)
|
|
||||||
BLI_ghash_free(debug_data->gh, NULL, debug_element_free);
|
|
||||||
MEM_freeN(debug_data);
|
|
||||||
}
|
|
||||||
|
@ -3871,8 +3871,6 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
|
|||||||
psys->clmd->ptcaches.first = psys->clmd->ptcaches.last= NULL;
|
psys->clmd->ptcaches.first = psys->clmd->ptcaches.last= NULL;
|
||||||
psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group);
|
psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group);
|
||||||
psys->clmd->modifier.error = NULL;
|
psys->clmd->modifier.error = NULL;
|
||||||
|
|
||||||
psys->clmd->debug_data = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -4692,7 +4690,6 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
clmd->solver_result = NULL;
|
clmd->solver_result = NULL;
|
||||||
clmd->debug_data = NULL;
|
|
||||||
}
|
}
|
||||||
else if (md->type == eModifierType_Fluidsim) {
|
else if (md->type == eModifierType_Fluidsim) {
|
||||||
FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
|
FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
|
||||||
|
@ -7617,12 +7617,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
|
|||||||
}
|
}
|
||||||
|
|
||||||
draw_new_particle_system(scene, v3d, rv3d, base, psys, dt, dflag);
|
draw_new_particle_system(scene, v3d, rv3d, base, psys, dt, dflag);
|
||||||
|
|
||||||
/* debug data */
|
|
||||||
if (psys->part->type == PART_HAIR) {
|
|
||||||
if (psys->clmd && psys->clmd->debug_data)
|
|
||||||
draw_sim_debug_data(scene, v3d, ar, base, psys->clmd->debug_data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
invert_m4_m4(ob->imat, ob->obmat);
|
invert_m4_m4(ob->imat, ob->obmat);
|
||||||
view3d_cached_text_draw_end(v3d, ar, 0, NULL);
|
view3d_cached_text_draw_end(v3d, ar, 0, NULL);
|
||||||
|
@ -147,13 +147,13 @@ static void draw_sim_debug_elements(SimDebugData *debug_data, float imat[4][4])
|
|||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_sim_debug_data(Scene *UNUSED(scene), View3D *UNUSED(v3d), ARegion *ar, Base *UNUSED(base), SimDebugData *debug_data)
|
void draw_sim_debug_data(Scene *UNUSED(scene), View3D *UNUSED(v3d), ARegion *ar)
|
||||||
{
|
{
|
||||||
RegionView3D *rv3d = ar->regiondata;
|
RegionView3D *rv3d = ar->regiondata;
|
||||||
/*Object *ob = base->object;*/
|
/*Object *ob = base->object;*/
|
||||||
float imat[4][4];
|
float imat[4][4];
|
||||||
|
|
||||||
if (!debug_data)
|
if (!_sim_debug_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
invert_m4_m4(imat, rv3d->viewmatob);
|
invert_m4_m4(imat, rv3d->viewmatob);
|
||||||
@ -164,7 +164,7 @@ void draw_sim_debug_data(Scene *UNUSED(scene), View3D *UNUSED(v3d), ARegion *ar,
|
|||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
glLoadMatrixf(rv3d->viewmat);
|
glLoadMatrixf(rv3d->viewmat);
|
||||||
draw_sim_debug_elements(debug_data, imat);
|
draw_sim_debug_elements(_sim_debug_data, imat);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
@ -3580,9 +3580,12 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
|
|||||||
/* draw viewport using opengl */
|
/* draw viewport using opengl */
|
||||||
if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(scene) || clip_border) {
|
if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(scene) || clip_border) {
|
||||||
view3d_main_area_draw_objects(C, scene, v3d, ar, &grid_unit);
|
view3d_main_area_draw_objects(C, scene, v3d, ar, &grid_unit);
|
||||||
|
|
||||||
#ifdef DEBUG_DRAW
|
#ifdef DEBUG_DRAW
|
||||||
bl_debug_draw();
|
bl_debug_draw();
|
||||||
#endif
|
#endif
|
||||||
|
draw_sim_debug_data(scene, v3d, ar);
|
||||||
|
|
||||||
ED_region_pixelspace(ar);
|
ED_region_pixelspace(ar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d,
|
|||||||
struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
|
struct Object *ob, struct DerivedMesh *dm, const int draw_flags);
|
||||||
|
|
||||||
/* drawsimdebug.c */
|
/* drawsimdebug.c */
|
||||||
void draw_sim_debug_data(Scene *scene, View3D *v3d, ARegion *ar, Base *base, struct SimDebugData *debug_data);
|
void draw_sim_debug_data(Scene *scene, View3D *v3d, ARegion *ar);
|
||||||
|
|
||||||
/* view3d_draw.c */
|
/* view3d_draw.c */
|
||||||
void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar);
|
void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar);
|
||||||
|
@ -573,8 +573,6 @@ typedef struct ClothModifierData {
|
|||||||
float hair_grid_cellsize;
|
float hair_grid_cellsize;
|
||||||
|
|
||||||
struct ClothSolverResult *solver_result;
|
struct ClothSolverResult *solver_result;
|
||||||
|
|
||||||
struct SimDebugData *debug_data; /* debug info */
|
|
||||||
} ClothModifierData;
|
} ClothModifierData;
|
||||||
|
|
||||||
typedef struct CollisionModifierData {
|
typedef struct CollisionModifierData {
|
||||||
|
@ -720,28 +720,6 @@ static int rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr)
|
|||||||
return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->cache_system != NULL));
|
return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->cache_system != NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rna_ClothModifier_show_debug_data_get(PointerRNA *ptr)
|
|
||||||
{
|
|
||||||
ClothModifierData *clmd = (ClothModifierData *)ptr->data;
|
|
||||||
return clmd->debug_data != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rna_ClothModifier_show_debug_data_set(PointerRNA *ptr, int value)
|
|
||||||
{
|
|
||||||
ClothModifierData *clmd = (ClothModifierData *)ptr->data;
|
|
||||||
if (value) {
|
|
||||||
if (!clmd->debug_data) {
|
|
||||||
clmd->debug_data = BKE_sim_debug_data_new();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (clmd->debug_data) {
|
|
||||||
BKE_sim_debug_data_free(clmd->debug_data);
|
|
||||||
clmd->debug_data = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* NOTE: Curve and array modifiers requires curve path to be evaluated,
|
/* NOTE: Curve and array modifiers requires curve path to be evaluated,
|
||||||
* dependency graph will make sure that curve eval would create such a path,
|
* dependency graph will make sure that curve eval would create such a path,
|
||||||
* but if curve was already evaluated we might miss path.
|
* but if curve was already evaluated we might miss path.
|
||||||
@ -2497,11 +2475,6 @@ static void rna_def_modifier_cloth(BlenderRNA *brna)
|
|||||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||||
RNA_def_property_ui_text(prop, "Point Cache", "");
|
RNA_def_property_ui_text(prop, "Point Cache", "");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "show_debug_data", PROP_BOOLEAN, PROP_NONE);
|
|
||||||
RNA_def_property_boolean_funcs(prop, "rna_ClothModifier_show_debug_data_get", "rna_ClothModifier_show_debug_data_set");
|
|
||||||
RNA_def_property_ui_text(prop, "Debug", "Show debug info");
|
|
||||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "hair_grid_min", PROP_FLOAT, PROP_NONE);
|
prop = RNA_def_property(srna, "hair_grid_min", PROP_FLOAT, PROP_NONE);
|
||||||
RNA_def_property_float_sdna(prop, NULL, "hair_grid_min");
|
RNA_def_property_float_sdna(prop, NULL, "hair_grid_min");
|
||||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
@ -69,8 +69,6 @@ static void initData(ModifierData *md)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
cloth_init(clmd);
|
cloth_init(clmd);
|
||||||
|
|
||||||
clmd->debug_data = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
|
static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3],
|
||||||
@ -180,7 +178,6 @@ static void copyData(ModifierData *md, ModifierData *target)
|
|||||||
tclmd->clothObject = NULL;
|
tclmd->clothObject = NULL;
|
||||||
tclmd->hairdata = NULL;
|
tclmd->hairdata = NULL;
|
||||||
tclmd->solver_result = NULL;
|
tclmd->solver_result = NULL;
|
||||||
tclmd->debug_data = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dependsOnTime(ModifierData *UNUSED(md))
|
static bool dependsOnTime(ModifierData *UNUSED(md))
|
||||||
@ -214,8 +211,6 @@ static void freeData(ModifierData *md)
|
|||||||
|
|
||||||
if (clmd->solver_result)
|
if (clmd->solver_result)
|
||||||
MEM_freeN(clmd->solver_result);
|
MEM_freeN(clmd->solver_result);
|
||||||
|
|
||||||
BKE_sim_debug_data_free(clmd->debug_data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +712,6 @@ static void cloth_continuum_step(ClothModifierData *clmd, float dt)
|
|||||||
if (smoothfac > 0.0f || density_strength > 0.0f) {
|
if (smoothfac > 0.0f || density_strength > 0.0f) {
|
||||||
HairGrid *grid = BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_cell_size, gmin, gmax);
|
HairGrid *grid = BPH_hair_volume_create_vertex_grid(clmd->sim_parms->voxel_cell_size, gmin, gmax);
|
||||||
|
|
||||||
BPH_hair_volume_set_debug_data(grid, clmd->debug_data);
|
|
||||||
BPH_hair_volume_set_debug_value(grid, parms->debug1, parms->debug2, parms->debug3, parms->debug4);
|
BPH_hair_volume_set_debug_value(grid, parms->debug1, parms->debug2, parms->debug3, parms->debug4);
|
||||||
|
|
||||||
cloth_continuum_fill_grid(grid, cloth);
|
cloth_continuum_fill_grid(grid, cloth);
|
||||||
@ -903,9 +902,7 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
|
|||||||
ColliderContacts *contacts = NULL;
|
ColliderContacts *contacts = NULL;
|
||||||
int totcolliders = 0;
|
int totcolliders = 0;
|
||||||
|
|
||||||
BPH_mass_spring_solver_debug_data(id, clmd->debug_data);
|
BKE_sim_debug_data_clear_category("collision");
|
||||||
|
|
||||||
BKE_sim_debug_data_clear_category(clmd->debug_data, "collision");
|
|
||||||
|
|
||||||
if (!clmd->solver_result)
|
if (!clmd->solver_result)
|
||||||
clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), "cloth solver result");
|
clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), "cloth solver result");
|
||||||
@ -997,8 +994,6 @@ int BPH_cloth_solve(Object *ob, float frame, ClothModifierData *clmd, ListBase *
|
|||||||
copy_v3_v3(verts[i].txold, verts[i].x);
|
copy_v3_v3(verts[i].txold, verts[i].x);
|
||||||
}
|
}
|
||||||
|
|
||||||
BPH_mass_spring_solver_debug_data(id, NULL);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,6 @@ typedef struct HairGrid {
|
|||||||
float gmin[3], gmax[3];
|
float gmin[3], gmax[3];
|
||||||
float cellsize, inv_cellsize;
|
float cellsize, inv_cellsize;
|
||||||
|
|
||||||
struct SimDebugData *debug_data;
|
|
||||||
float debug1, debug2;
|
float debug1, debug2;
|
||||||
int debug3, debug4;
|
int debug3, debug4;
|
||||||
} HairGrid;
|
} HairGrid;
|
||||||
@ -405,21 +404,20 @@ BLI_INLINE void hair_volume_add_segment_2D(HairGrid *grid,
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
SimDebugData *debug_data = grid->debug_data;
|
|
||||||
float wloc[3], x2w[3], x3w[3];
|
float wloc[3], x2w[3], x3w[3];
|
||||||
grid_to_world(grid, wloc, loc_k);
|
grid_to_world(grid, wloc, loc_k);
|
||||||
grid_to_world(grid, x2w, x2);
|
grid_to_world(grid, x2w, x2);
|
||||||
grid_to_world(grid, x3w, x3);
|
grid_to_world(grid, x3w, x3);
|
||||||
|
|
||||||
if (vert_k->samples > 0)
|
if (vert_k->samples > 0)
|
||||||
BKE_sim_debug_data_add_circle(debug_data, wloc, 0.01f, 1.0, 1.0, 0.3, "grid", 2525, debug_i, j, k);
|
BKE_sim_debug_data_add_circle(wloc, 0.01f, 1.0, 1.0, 0.3, "grid", 2525, debug_i, j, k);
|
||||||
|
|
||||||
if (grid->debug_value) {
|
if (grid->debug_value) {
|
||||||
BKE_sim_debug_data_add_dot(debug_data, wloc, 1, 0, 0, "grid", 93, debug_i, j, k);
|
BKE_sim_debug_data_add_dot(wloc, 1, 0, 0, "grid", 93, debug_i, j, k);
|
||||||
BKE_sim_debug_data_add_dot(debug_data, x2w, 0.1, 0.1, 0.7, "grid", 649, debug_i, j, k);
|
BKE_sim_debug_data_add_dot(x2w, 0.1, 0.1, 0.7, "grid", 649, debug_i, j, k);
|
||||||
BKE_sim_debug_data_add_line(debug_data, wloc, x2w, 0.3, 0.8, 0.3, "grid", 253, debug_i, j, k);
|
BKE_sim_debug_data_add_line(wloc, x2w, 0.3, 0.8, 0.3, "grid", 253, debug_i, j, k);
|
||||||
BKE_sim_debug_data_add_line(debug_data, wloc, x3w, 0.8, 0.3, 0.3, "grid", 254, debug_i, j, k);
|
BKE_sim_debug_data_add_line(wloc, x3w, 0.8, 0.3, 0.3, "grid", 254, debug_i, j, k);
|
||||||
// BKE_sim_debug_data_add_circle(debug_data, x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 0.2, "grid", 255, i, j, k);
|
// BKE_sim_debug_data_add_circle(x2w, len_v3v3(wloc, x2w), 0.2, 0.7, 0.2, "grid", 255, i, j, k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -439,8 +437,6 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
|
|||||||
const float x3[3], const float v3[3], const float x4[3], const float v4[3],
|
const float x3[3], const float v3[3], const float x4[3], const float v4[3],
|
||||||
const float dir1[3], const float dir2[3], const float dir3[3])
|
const float dir1[3], const float dir2[3], const float dir3[3])
|
||||||
{
|
{
|
||||||
SimDebugData *debug_data = grid->debug_data;
|
|
||||||
|
|
||||||
const int res[3] = { grid->res[0], grid->res[1], grid->res[2] };
|
const int res[3] = { grid->res[0], grid->res[1], grid->res[2] };
|
||||||
|
|
||||||
/* find the primary direction from the major axis of the direction vector */
|
/* find the primary direction from the major axis of the direction vector */
|
||||||
@ -476,8 +472,6 @@ void BPH_hair_volume_add_segment(HairGrid *grid,
|
|||||||
int j0, k0, j0_prev, k0_prev;
|
int j0, k0, j0_prev, k0_prev;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
(void)debug_data;
|
|
||||||
|
|
||||||
for (i = imin; i <= imax; ++i) {
|
for (i = imin; i <= imax; ++i) {
|
||||||
float shift1, shift2; /* fraction of a full cell shift [0.0, 1.0) */
|
float shift1, shift2; /* fraction of a full cell shift [0.0, 1.0) */
|
||||||
int jmin, jmax, kmin, kmax;
|
int jmin, jmax, kmin, kmax;
|
||||||
@ -1029,12 +1023,6 @@ void BPH_hair_volume_free_vertex_grid(HairGrid *grid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BPH_hair_volume_set_debug_data(HairGrid *grid, SimDebugData *debug_data)
|
|
||||||
{
|
|
||||||
grid->debug_data = debug_data;
|
|
||||||
BKE_sim_debug_data_clear_category(grid->debug_data, "grid");
|
|
||||||
}
|
|
||||||
|
|
||||||
void BPH_hair_volume_set_debug_value(HairGrid *grid, float debug1, float debug2, int debug3, int debug4)
|
void BPH_hair_volume_set_debug_value(HairGrid *grid, float debug1, float debug2, int debug3, int debug4)
|
||||||
{
|
{
|
||||||
grid->debug1 = debug1;
|
grid->debug1 = debug1;
|
||||||
|
@ -60,7 +60,6 @@ extern "C" {
|
|||||||
|
|
||||||
struct Implicit_Data;
|
struct Implicit_Data;
|
||||||
struct ImplicitSolverInput;
|
struct ImplicitSolverInput;
|
||||||
struct SimDebugData;
|
|
||||||
|
|
||||||
typedef struct ImplicitSolverResult {
|
typedef struct ImplicitSolverResult {
|
||||||
int status;
|
int status;
|
||||||
@ -74,8 +73,6 @@ BLI_INLINE void implicit_print_matrix_elem(float v)
|
|||||||
printf("%-8.3f", v);
|
printf("%-8.3f", v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BPH_mass_spring_solver_debug_data(struct Implicit_Data *id, struct SimDebugData *debug_data);
|
|
||||||
|
|
||||||
void BPH_mass_spring_set_vertex_mass(struct Implicit_Data *data, int index, float mass);
|
void BPH_mass_spring_set_vertex_mass(struct Implicit_Data *data, int index, float mass);
|
||||||
void BPH_mass_spring_set_rest_transform(struct Implicit_Data *data, int index, float rot[3][3]);
|
void BPH_mass_spring_set_rest_transform(struct Implicit_Data *data, int index, float rot[3][3]);
|
||||||
|
|
||||||
@ -142,7 +139,6 @@ struct VoxelData;
|
|||||||
struct HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize, const float gmin[3], const float gmax[3]);
|
struct HairGrid *BPH_hair_volume_create_vertex_grid(float cellsize, const float gmin[3], const float gmax[3]);
|
||||||
void BPH_hair_volume_free_vertex_grid(struct HairGrid *grid);
|
void BPH_hair_volume_free_vertex_grid(struct HairGrid *grid);
|
||||||
void BPH_hair_volume_grid_geometry(struct HairGrid *grid, float *cellsize, int res[3], float gmin[3], float gmax[3]);
|
void BPH_hair_volume_grid_geometry(struct HairGrid *grid, float *cellsize, int res[3], float gmin[3], float gmax[3]);
|
||||||
void BPH_hair_volume_set_debug_data(struct HairGrid *grid, struct SimDebugData *debug_data);
|
|
||||||
void BPH_hair_volume_set_debug_value(struct HairGrid *grid, float debug1, float debug2, int debug3, int debug4);
|
void BPH_hair_volume_set_debug_value(struct HairGrid *grid, float debug1, float debug2, int debug3, int debug4);
|
||||||
|
|
||||||
void BPH_hair_volume_grid_clear(struct HairGrid *grid);
|
void BPH_hair_volume_grid_clear(struct HairGrid *grid);
|
||||||
|
@ -700,8 +700,6 @@ typedef struct Implicit_Data {
|
|||||||
lfVector *z; /* target velocity in constrained directions */
|
lfVector *z; /* target velocity in constrained directions */
|
||||||
fmatrix3x3 *S; /* filtering matrix for constraints */
|
fmatrix3x3 *S; /* filtering matrix for constraints */
|
||||||
fmatrix3x3 *P, *Pinv; /* pre-conditioning matrix */
|
fmatrix3x3 *P, *Pinv; /* pre-conditioning matrix */
|
||||||
|
|
||||||
struct SimDebugData *debug_data;
|
|
||||||
} Implicit_Data;
|
} Implicit_Data;
|
||||||
|
|
||||||
Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
|
Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
|
||||||
@ -756,12 +754,6 @@ void BPH_mass_spring_solver_free(Implicit_Data *id)
|
|||||||
MEM_freeN(id);
|
MEM_freeN(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BPH_mass_spring_solver_debug_data(Implicit_Data *id, struct SimDebugData *debug_data)
|
|
||||||
{
|
|
||||||
if (id)
|
|
||||||
id->debug_data = debug_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ==== Transformation from/to root reference frames ==== */
|
/* ==== Transformation from/to root reference frames ==== */
|
||||||
|
|
||||||
BLI_INLINE void world_to_root_v3(Implicit_Data *data, int index, float r[3], const float v[3])
|
BLI_INLINE void world_to_root_v3(Implicit_Data *data, int index, float r[3], const float v[3])
|
||||||
|
@ -445,8 +445,6 @@ struct Implicit_Data {
|
|||||||
lMatrixCtor iM; /* masses */
|
lMatrixCtor iM; /* masses */
|
||||||
lMatrixCtor idFdX, idFdV; /* force jacobians */
|
lMatrixCtor idFdX, idFdV; /* force jacobians */
|
||||||
lMatrixCtor iS; /* filtering matrix for constraints */
|
lMatrixCtor iS; /* filtering matrix for constraints */
|
||||||
|
|
||||||
struct SimDebugData *debug_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
|
Implicit_Data *BPH_mass_spring_solver_create(int numverts, int numsprings)
|
||||||
@ -469,12 +467,6 @@ int BPH_mass_spring_solver_numvert(Implicit_Data *id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BPH_mass_spring_solver_debug_data(Implicit_Data *id, struct SimDebugData *debug_data)
|
|
||||||
{
|
|
||||||
if (id)
|
|
||||||
id->debug_data = debug_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ==== Transformation from/to root reference frames ==== */
|
/* ==== Transformation from/to root reference frames ==== */
|
||||||
|
|
||||||
BLI_INLINE void world_to_root_v3(Implicit_Data *data, int index, float r[3], const float v[3])
|
BLI_INLINE void world_to_root_v3(Implicit_Data *data, int index, float r[3], const float v[3])
|
||||||
|
Loading…
Reference in New Issue
Block a user