Reimplemented the voxel texture type for displaying hair continuum grids.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
This commit is contained in:
Lukas Tönne 2014-10-31 20:29:51 +01:00
parent cd717f145d
commit d42525a9b5
7 changed files with 899 additions and 878 deletions

View File

@ -33,7 +33,10 @@ extern "C" {
#endif
struct Implicit_Data;
struct Object;
struct ClothModifierData;
struct ListBase;
struct VoxelData;
typedef enum eMassSpringSolverStatus {
BPH_SOLVER_SUCCESS = (1 << 0),
@ -50,7 +53,7 @@ void BPH_cloth_solver_free(struct ClothModifierData *clmd);
int BPH_cloth_solve(struct Object *ob, float frame, struct ClothModifierData *clmd, struct ListBase *effectors);
void BKE_cloth_solver_set_positions(struct ClothModifierData *clmd);
bool implicit_hair_volume_get_texture_data(struct Object *UNUSED(ob), struct ClothModifierData *clmd, struct ListBase *UNUSED(effectors), struct VoxelData *vd);
bool BPH_cloth_solver_get_texture_data(struct Object *ob, struct ClothModifierData *clmd, struct VoxelData *vd);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,8 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_texture_types.h"
#include "implicit.h"
/* ================ Volumetric Hair Interaction ================
@ -509,30 +511,16 @@ static HairGridVert *hair_volume_create_collision_grid(ClothModifierData *clmd,
}
#endif
#if 0
bool implicit_hair_volume_get_texture_data(Object *UNUSED(ob), ClothModifierData *clmd, ListBase *UNUSED(effectors), VoxelData *vd)
bool BPH_hair_volume_get_texture_data(HairVertexGrid *grid, VoxelData *vd)
{
lfVector *lX, *lV;
HairGridVert *hairgrid/*, *collgrid*/;
int numverts;
int totres, i;
int depth;
if (!clmd->clothObject || !clmd->clothObject->implicit)
return false;
lX = clmd->clothObject->implicit->X;
lV = clmd->clothObject->implicit->V;
numverts = clmd->clothObject->numverts;
hairgrid = hair_volume_create_hair_grid(clmd, lX, lV, numverts);
// collgrid = hair_volume_create_collision_grid(clmd, lX, numverts);
vd->resol[0] = hair_grid_res;
vd->resol[1] = hair_grid_res;
vd->resol[2] = hair_grid_res;
vd->resol[0] = grid->res;
vd->resol[1] = grid->res;
vd->resol[2] = grid->res;
totres = hair_grid_size(hair_grid_res);
totres = hair_grid_size(grid->res);
if (vd->hair_type == TEX_VD_HAIRVELOCITY) {
depth = 4;
@ -549,20 +537,21 @@ bool implicit_hair_volume_get_texture_data(Object *UNUSED(ob), ClothModifierData
for (i = 0; i < totres; ++i) {
switch (vd->hair_type) {
case TEX_VD_HAIRDENSITY:
vd->dataset[i] = hairgrid[i].density;
vd->dataset[i] = grid->verts[i].density;
break;
case TEX_VD_HAIRRESTDENSITY:
vd->dataset[i] = 0.0f; // TODO
break;
case TEX_VD_HAIRVELOCITY:
vd->dataset[i + 0*totres] = hairgrid[i].velocity[0];
vd->dataset[i + 1*totres] = hairgrid[i].velocity[1];
vd->dataset[i + 2*totres] = hairgrid[i].velocity[2];
vd->dataset[i + 3*totres] = len_v3(hairgrid[i].velocity);
case TEX_VD_HAIRVELOCITY: {
float tmp = grid->verts[i].velocity[1];
vd->dataset[i + 0*totres] = grid->verts[i].velocity[0];
vd->dataset[i + 1*totres] = grid->verts[i].velocity[1];
vd->dataset[i + 2*totres] = grid->verts[i].velocity[2];
vd->dataset[i + 3*totres] = len_v3(grid->verts[i].velocity);
break;
}
case TEX_VD_HAIRENERGY:
vd->dataset[i] = 0.0f; // TODO
break;
@ -573,10 +562,5 @@ bool implicit_hair_volume_get_texture_data(Object *UNUSED(ob), ClothModifierData
vd->dataset = NULL;
}
MEM_freeN(hairgrid);
// MEM_freeN(collgrid);
return true;
}
#endif

View File

@ -168,6 +168,9 @@ bool BPH_mass_spring_force_spring_goal(struct Implicit_Data *data, int i, const
struct HairVertexGrid;
struct HairColliderGrid;
struct Object;
struct VoxelData;
struct HairVertexGrid *BPH_hair_volume_create_vertex_grid(int res, const float gmin[3], const float gmax[3]);
void BPH_hair_volume_free_vertex_grid(struct HairVertexGrid *grid);
void BPH_hair_volume_grid_geometry(struct HairVertexGrid *grid, float cellsize[3], int res[3], float gmin[3], float gmax[3]);
@ -195,6 +198,8 @@ void BPH_hair_volume_vertex_grid_forces(struct HairVertexGrid *grid, const float
float smoothfac, float pressurefac, float minpressure,
float f[3], float dfdx[3][3], float dfdv[3][3]);
bool BPH_hair_volume_get_texture_data(struct HairVertexGrid *grid, struct VoxelData *vd);
#ifdef __cplusplus
}
#endif

View File

@ -33,6 +33,7 @@ set(INC
../imbuf
../makesdna
../makesrna
../physics
../../../intern/guardedalloc
../../../intern/mikktspace
../../../intern/smoke/extern

View File

@ -40,6 +40,7 @@ incs = [
'../imbuf',
'../makesdna',
'../makesrna',
'../physics',
'../../../intern/mikktspace',
'../../../intern/smoke/extern',
]

View File

@ -58,6 +58,7 @@
#include "BKE_modifier.h"
#include "smoke_API.h"
#include "BPH_mass_spring.h"
#include "DNA_texture_types.h"
#include "DNA_object_force.h"
@ -380,8 +381,7 @@ static void init_frame_hair(VoxelData *vd, int UNUSED(cfra))
ParticleSystemModifierData *pmd = (ParticleSystemModifierData *)md;
if (pmd->psys && pmd->psys->clmd) {
// XXX TODO was moved into own subfolder, figure out how to handle this (perhaps make a wrapper in BKE)
// found |= implicit_hair_volume_get_texture_data(ob, pmd->psys->clmd, NULL, vd);
found |= BPH_cloth_solver_get_texture_data(ob, pmd->psys->clmd, vd);
}
}