Cycles Hair: Addition of render settings and static BVH strand width scaling
Addition of a RNA function to toggle between the hair settings and rebuild the cache. This enables the usage of the render step, child number and full display percentage with f12 rendering. A scaling to the strand radius has also been added for the static bvh. This only matches up with dynamic for uniform scaling. A very small fix is included for multiple uvs/vertex colours when using child particles.
This commit is contained in:
@@ -37,9 +37,10 @@ void curveinterp_v3_v3v3v3v3(float3 *p, float3 *v1, float3 *v2, float3 *v3, floa
|
|||||||
void interp_weights(float t, float data[4], int type);
|
void interp_weights(float t, float data[4], int type);
|
||||||
float shaperadius(float shape, float root, float tip, float time);
|
float shaperadius(float shape, float root, float tip, float time);
|
||||||
void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData, int interpolation);
|
void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData, int interpolation);
|
||||||
bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, int uv_num);
|
void ToggleRender(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, BL::Scene *scene);
|
||||||
bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, int vcol_num);
|
bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int uv_num);
|
||||||
bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents);
|
bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int vcol_num);
|
||||||
|
bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background);
|
||||||
void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments, float3 RotCam);
|
void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments, float3 RotCam);
|
||||||
void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments);
|
void ExportCurveTriangleRibbons(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments);
|
||||||
void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int resolution, int segments);
|
void ExportCurveTriangleGeometry(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int resolution, int segments);
|
||||||
@@ -151,7 +152,7 @@ void InterpolateKeySegments(int seg, int segno, int key, int curve, float3 *keyl
|
|||||||
curveinterp_v3_v3v3v3v3(keyloc, &ckey_loc1, &ckey_loc2, &ckey_loc3, &ckey_loc4, t);
|
curveinterp_v3_v3v3v3v3(keyloc, &ckey_loc1, &ckey_loc2, &ckey_loc3, &ckey_loc4, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents)
|
bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background)
|
||||||
{
|
{
|
||||||
|
|
||||||
int curvenum = 0;
|
int curvenum = 0;
|
||||||
@@ -176,12 +177,10 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
|
|||||||
|
|
||||||
int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
|
int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
|
||||||
int shader = mesh->used_shaders[mi];
|
int shader = mesh->used_shaders[mi];
|
||||||
int draw_step = b_psys.settings().draw_step();
|
int draw_step = background ? b_psys.settings().render_step() : b_psys.settings().draw_step();
|
||||||
int ren_step = (int)pow((float)2.0f,(float)draw_step);
|
int ren_step = (int)pow((float)2.0f,(float)draw_step);
|
||||||
/*b_psys.settings().render_step(draw_step);*/
|
|
||||||
|
|
||||||
int totparts = b_psys.particles.length();
|
int totparts = b_psys.particles.length();
|
||||||
int totchild = b_psys.child_particles.length() * b_psys.settings().draw_percentage() / 100;
|
int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_psys.settings().draw_percentage() / 100.0f);
|
||||||
int totcurves = totchild;
|
int totcurves = totchild;
|
||||||
|
|
||||||
if(use_parents || b_psys.settings().child_type() == 0)
|
if(use_parents || b_psys.settings().child_type() == 0)
|
||||||
@@ -240,7 +239,7 @@ bool ObtainCacheParticleData(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, int uv_num)
|
bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int uv_num)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
int keyno = 0;
|
int keyno = 0;
|
||||||
@@ -269,13 +268,10 @@ bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Parti
|
|||||||
#if 0
|
#if 0
|
||||||
int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
|
int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
|
||||||
int shader = mesh->used_shaders[mi];
|
int shader = mesh->used_shaders[mi];
|
||||||
int draw_step = b_psys.settings().draw_step();
|
|
||||||
int ren_step = (int)pow((float)2.0f,(float)draw_step);
|
|
||||||
b_psys.settings().render_step(draw_step);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int totparts = b_psys.particles.length();
|
int totparts = b_psys.particles.length();
|
||||||
int totchild = b_psys.child_particles.length() * b_psys.settings().draw_percentage() / 100;
|
int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_psys.settings().draw_percentage() / 100.0f);
|
||||||
int totcurves = totchild;
|
int totcurves = totchild;
|
||||||
|
|
||||||
if (use_parents || b_psys.settings().child_type() == 0)
|
if (use_parents || b_psys.settings().child_type() == 0)
|
||||||
@@ -314,7 +310,7 @@ bool ObtainCacheParticleUV(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Parti
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, int vcol_num)
|
bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool use_parents, bool background, int vcol_num)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
int keyno = 0;
|
int keyno = 0;
|
||||||
@@ -342,12 +338,9 @@ bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
|
|||||||
#if 0
|
#if 0
|
||||||
int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
|
int mi = clamp(b_psys.settings().material()-1, 0, mesh->used_shaders.size()-1);
|
||||||
int shader = mesh->used_shaders[mi];
|
int shader = mesh->used_shaders[mi];
|
||||||
int draw_step = b_psys.settings().draw_step();
|
|
||||||
int ren_step = (int)pow((float)2.0f,(float)draw_step);
|
|
||||||
b_psys.settings().render_step(draw_step);
|
|
||||||
#endif
|
#endif
|
||||||
int totparts = b_psys.particles.length();
|
int totparts = b_psys.particles.length();
|
||||||
int totchild = b_psys.child_particles.length() * b_psys.settings().draw_percentage() / 100;
|
int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_psys.settings().draw_percentage() / 100.0f);
|
||||||
int totcurves = totchild;
|
int totcurves = totchild;
|
||||||
|
|
||||||
if (use_parents || b_psys.settings().child_type() == 0)
|
if (use_parents || b_psys.settings().child_type() == 0)
|
||||||
@@ -386,6 +379,18 @@ bool ObtainCacheParticleVcol(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, Par
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToggleRender(Mesh *mesh, BL::Mesh *b_mesh, BL::Object *b_ob, BL::Scene *scene)
|
||||||
|
{
|
||||||
|
BL::Object::modifiers_iterator b_mod;
|
||||||
|
for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
|
||||||
|
if ((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && (b_mod->show_viewport()) && (b_mod->show_render())) {
|
||||||
|
BL::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr);
|
||||||
|
BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr);
|
||||||
|
b_psys.ToggleRender(*scene, *b_ob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments, float3 RotCam)
|
void ExportCurveTrianglePlanes(Mesh *mesh, ParticleCurveData *CData, int interpolation, bool use_smooth, int segments, float3 RotCam)
|
||||||
{
|
{
|
||||||
int vertexno = mesh->verts.size();
|
int vertexno = mesh->verts.size();
|
||||||
@@ -945,7 +950,10 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
|
|||||||
|
|
||||||
ParticleCurveData CData;
|
ParticleCurveData CData;
|
||||||
|
|
||||||
ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, use_parents);
|
if(!preview)
|
||||||
|
ToggleRender(mesh, &b_mesh, &b_ob, &b_scene);
|
||||||
|
|
||||||
|
ObtainCacheParticleData(mesh, &b_mesh, &b_ob, &CData, use_parents, !preview);
|
||||||
|
|
||||||
/* attach strands to mesh */
|
/* attach strands to mesh */
|
||||||
BL::Object b_CamOb = b_scene.camera();
|
BL::Object b_CamOb = b_scene.camera();
|
||||||
@@ -959,7 +967,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
|
|||||||
|
|
||||||
if(primitive == CURVE_TRIANGLES){
|
if(primitive == CURVE_TRIANGLES){
|
||||||
int vert_num = mesh->triangles.size() * 3;
|
int vert_num = mesh->triangles.size() * 3;
|
||||||
ObtainCacheParticleUV(mesh, &b_mesh, &b_ob, &CData, use_parents, 0);
|
ObtainCacheParticleUV(mesh, &b_mesh, &b_ob, &CData, use_parents, !preview, 0);
|
||||||
if(triangle_method == CURVE_CAMERA_TRIANGLES) {
|
if(triangle_method == CURVE_CAMERA_TRIANGLES) {
|
||||||
ExportCurveTrianglePlanes(mesh, &CData, interpolation, use_smooth, segments, RotCam);
|
ExportCurveTrianglePlanes(mesh, &CData, interpolation, use_smooth, segments, RotCam);
|
||||||
ExportCurveTriangleUVs(mesh, &CData, interpolation, use_smooth, segments, vert_num, 1);
|
ExportCurveTriangleUVs(mesh, &CData, interpolation, use_smooth, segments, vert_num, 1);
|
||||||
@@ -1021,7 +1029,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
|
|||||||
Attribute *attr_vcol = mesh->curve_attributes.add(
|
Attribute *attr_vcol = mesh->curve_attributes.add(
|
||||||
ustring(l->name().c_str()), TypeDesc::TypeColor, ATTR_ELEMENT_CURVE);
|
ustring(l->name().c_str()), TypeDesc::TypeColor, ATTR_ELEMENT_CURVE);
|
||||||
|
|
||||||
ObtainCacheParticleVcol(mesh, &b_mesh, &b_ob, &CData, use_parents, vcol_num);
|
ObtainCacheParticleVcol(mesh, &b_mesh, &b_ob, &CData, use_parents, !preview, vcol_num);
|
||||||
|
|
||||||
float3 *vcol = attr_vcol->data_float3();
|
float3 *vcol = attr_vcol->data_float3();
|
||||||
|
|
||||||
@@ -1051,7 +1059,7 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
|
|||||||
else
|
else
|
||||||
attr = mesh->curve_attributes.add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CURVE);
|
attr = mesh->curve_attributes.add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CURVE);
|
||||||
|
|
||||||
ObtainCacheParticleUV(mesh, &b_mesh, &b_ob, &CData, use_parents, uv_num);
|
ObtainCacheParticleUV(mesh, &b_mesh, &b_ob, &CData, use_parents, !preview, uv_num);
|
||||||
|
|
||||||
float3 *uv = attr->data_float3();
|
float3 *uv = attr->data_float3();
|
||||||
|
|
||||||
@@ -1065,6 +1073,9 @@ void BlenderSync::sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!preview)
|
||||||
|
ToggleRender(mesh, &b_mesh, &b_ob, &b_scene);
|
||||||
|
|
||||||
mesh->compute_bounds();
|
mesh->compute_bounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,12 +84,20 @@ void Object::apply_transform()
|
|||||||
{
|
{
|
||||||
if(!mesh || tfm == transform_identity())
|
if(!mesh || tfm == transform_identity())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
float3 c0 = transform_get_column(&tfm, 0);
|
||||||
|
float3 c1 = transform_get_column(&tfm, 1);
|
||||||
|
float3 c2 = transform_get_column(&tfm, 2);
|
||||||
|
float scalar = pow(fabsf(dot(cross(c0, c1), c2)), 1.0f/3.0f);
|
||||||
|
|
||||||
for(size_t i = 0; i < mesh->verts.size(); i++)
|
for(size_t i = 0; i < mesh->verts.size(); i++)
|
||||||
mesh->verts[i] = transform_point(&tfm, mesh->verts[i]);
|
mesh->verts[i] = transform_point(&tfm, mesh->verts[i]);
|
||||||
|
|
||||||
for(size_t i = 0; i < mesh->curve_keys.size(); i++)
|
for(size_t i = 0; i < mesh->curve_keys.size(); i++) {
|
||||||
mesh->curve_keys[i].co = transform_point(&tfm, mesh->curve_keys[i].co);
|
mesh->curve_keys[i].co = transform_point(&tfm, mesh->curve_keys[i].co);
|
||||||
|
/* scale for strand radius - only correct for uniform transforms*/
|
||||||
|
mesh->curve_keys[i].radius *= scalar;
|
||||||
|
}
|
||||||
|
|
||||||
/* store matrix to transform later. when accessing these as attributes we
|
/* store matrix to transform later. when accessing these as attributes we
|
||||||
* do not want the transform to be applied for consistency between static
|
* do not want the transform to be applied for consistency between static
|
||||||
|
@@ -299,6 +299,7 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o
|
|||||||
int path_nbr = 0;
|
int path_nbr = 0;
|
||||||
int totpart;
|
int totpart;
|
||||||
int max_k = 0;
|
int max_k = 0;
|
||||||
|
int step_nbr = 0;
|
||||||
|
|
||||||
if (particlesystem == NULL)
|
if (particlesystem == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -306,14 +307,21 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o
|
|||||||
part = particlesystem->part;
|
part = particlesystem->part;
|
||||||
pars = particlesystem->particles;
|
pars = particlesystem->particles;
|
||||||
|
|
||||||
|
if(particlesystem->renderdata) {
|
||||||
|
step_nbr = part->ren_step;
|
||||||
|
totchild = particlesystem->totchild;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
step_nbr = part->draw_step;
|
||||||
|
totchild = (int)((float)particlesystem->totchild * (float)(part->disp) / 100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
if (part == NULL || pars == NULL || !psys_check_enabled(object, particlesystem))
|
if (part == NULL || pars == NULL || !psys_check_enabled(object, particlesystem))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (part->ren_as == PART_DRAW_OB || part->ren_as == PART_DRAW_GR || part->ren_as == PART_DRAW_NOT)
|
if (part->ren_as == PART_DRAW_OB || part->ren_as == PART_DRAW_GR || part->ren_as == PART_DRAW_NOT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
totchild = particlesystem->totchild * part->disp / 100;
|
|
||||||
|
|
||||||
/* can happen for disconnected/global hair */
|
/* can happen for disconnected/global hair */
|
||||||
if (part->type == PART_HAIR && !particlesystem->childcache)
|
if (part->type == PART_HAIR && !particlesystem->childcache)
|
||||||
totchild = 0;
|
totchild = 0;
|
||||||
@@ -324,7 +332,7 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (part->ren_as == PART_DRAW_PATH && particlesystem->pathcache)
|
if (part->ren_as == PART_DRAW_PATH && particlesystem->pathcache)
|
||||||
path_nbr = (int)pow(2.0, part->draw_step);
|
path_nbr = (int)pow(2.0, step_nbr);
|
||||||
|
|
||||||
if (particle_no < totpart) {
|
if (particle_no < totpart) {
|
||||||
|
|
||||||
@@ -373,7 +381,10 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, Par
|
|||||||
|
|
||||||
part = particlesystem->part;
|
part = particlesystem->part;
|
||||||
|
|
||||||
|
if(particlesystem->renderdata)
|
||||||
totchild = particlesystem->totchild;
|
totchild = particlesystem->totchild;
|
||||||
|
else
|
||||||
|
totchild = (int)((float)particlesystem->totchild * (float)(part->disp) / 100.0f);
|
||||||
|
|
||||||
/* can happen for disconnected/global hair */
|
/* can happen for disconnected/global hair */
|
||||||
if (part->type == PART_HAIR && !particlesystem->childcache)
|
if (part->type == PART_HAIR && !particlesystem->childcache)
|
||||||
@@ -419,7 +430,7 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, Par
|
|||||||
if (n_uv && ELEM(PART_FROM_FACE, PART_FROM_FACE, PART_FROM_VOLUME)) {
|
if (n_uv && ELEM(PART_FROM_FACE, PART_FROM_FACE, PART_FROM_VOLUME)) {
|
||||||
if (cpa->num != DMCACHE_NOTFOUND) {
|
if (cpa->num != DMCACHE_NOTFOUND) {
|
||||||
MFace *mface = modifier->dm->getTessFaceData(modifier->dm, cpa->num, CD_MFACE);
|
MFace *mface = modifier->dm->getTessFaceData(modifier->dm, cpa->num, CD_MFACE);
|
||||||
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MTFACE, 0);
|
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MTFACE, uv_no);
|
||||||
mtface += cpa->num;
|
mtface += cpa->num;
|
||||||
|
|
||||||
psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, n_uv);
|
psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, n_uv);
|
||||||
@@ -441,7 +452,7 @@ static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, Par
|
|||||||
if (n_uv && ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
|
if (n_uv && ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
|
||||||
if (num != DMCACHE_NOTFOUND) {
|
if (num != DMCACHE_NOTFOUND) {
|
||||||
MFace *mface = modifier->dm->getTessFaceData(modifier->dm, num, CD_MFACE);
|
MFace *mface = modifier->dm->getTessFaceData(modifier->dm, num, CD_MFACE);
|
||||||
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MTFACE, 0);
|
MTFace *mtface = (MTFace *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MTFACE, uv_no);
|
||||||
mtface += num;
|
mtface += num;
|
||||||
|
|
||||||
psys_interpolate_uvs(mtface, mface->v4, parent->fuv, n_uv);
|
psys_interpolate_uvs(mtface, mface->v4, parent->fuv, n_uv);
|
||||||
@@ -470,7 +481,10 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, P
|
|||||||
|
|
||||||
part = particlesystem->part;
|
part = particlesystem->part;
|
||||||
|
|
||||||
|
if(particlesystem->renderdata)
|
||||||
totchild = particlesystem->totchild;
|
totchild = particlesystem->totchild;
|
||||||
|
else
|
||||||
|
totchild = (int)((float)particlesystem->totchild * (float)(part->disp) / 100.0f);
|
||||||
|
|
||||||
/* can happen for disconnected/global hair */
|
/* can happen for disconnected/global hair */
|
||||||
if (part->type == PART_HAIR && !particlesystem->childcache)
|
if (part->type == PART_HAIR && !particlesystem->childcache)
|
||||||
@@ -520,7 +534,7 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, P
|
|||||||
if (n_mcol && ELEM(PART_FROM_FACE, PART_FROM_FACE, PART_FROM_VOLUME)) {
|
if (n_mcol && ELEM(PART_FROM_FACE, PART_FROM_FACE, PART_FROM_VOLUME)) {
|
||||||
if (cpa->num != DMCACHE_NOTFOUND) {
|
if (cpa->num != DMCACHE_NOTFOUND) {
|
||||||
MFace *mface = modifier->dm->getTessFaceData(modifier->dm, cpa->num, CD_MFACE);
|
MFace *mface = modifier->dm->getTessFaceData(modifier->dm, cpa->num, CD_MFACE);
|
||||||
MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MCOL, 0);
|
MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MCOL, vcol_no);
|
||||||
mc += cpa->num * 4;
|
mc += cpa->num * 4;
|
||||||
|
|
||||||
psys_interpolate_mcol(mc, mface->v4, cpa->fuv, &mcol);
|
psys_interpolate_mcol(mc, mface->v4, cpa->fuv, &mcol);
|
||||||
@@ -546,7 +560,7 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, P
|
|||||||
if (n_mcol && ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
|
if (n_mcol && ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
|
||||||
if (num != DMCACHE_NOTFOUND) {
|
if (num != DMCACHE_NOTFOUND) {
|
||||||
MFace *mface = modifier->dm->getTessFaceData(modifier->dm, num, CD_MFACE);
|
MFace *mface = modifier->dm->getTessFaceData(modifier->dm, num, CD_MFACE);
|
||||||
MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MCOL, 0);
|
MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->dm->faceData, CD_MCOL, vcol_no);
|
||||||
mc += num * 4;
|
mc += num * 4;
|
||||||
|
|
||||||
psys_interpolate_mcol(mc, mface->v4, parent->fuv, &mcol);
|
psys_interpolate_mcol(mc, mface->v4, parent->fuv, &mcol);
|
||||||
@@ -564,6 +578,22 @@ static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem, P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rna_ParticleSystem_ToggleRender(ParticleSystem *particlesystem, Scene *scene, Object *object)
|
||||||
|
{
|
||||||
|
ParticleSystemModifierData *psmd = psys_get_modifier(object, particlesystem);
|
||||||
|
float mat[4][4];
|
||||||
|
|
||||||
|
unit_m4(mat);
|
||||||
|
|
||||||
|
if (particlesystem->renderdata)
|
||||||
|
psys_render_restore(object, particlesystem);
|
||||||
|
else {
|
||||||
|
psys_render_set(object, particlesystem, mat, mat, 1, 1, 0.f);
|
||||||
|
psmd->flag &= ~eParticleSystemFlag_psys_updated;
|
||||||
|
particle_system_update(scene, object, particlesystem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr, short flag)
|
static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr, short flag)
|
||||||
{
|
{
|
||||||
if (ptr->type == &RNA_ParticleSystem) {
|
if (ptr->type == &RNA_ParticleSystem) {
|
||||||
@@ -3345,6 +3375,12 @@ static void rna_def_particle_system(BlenderRNA *brna)
|
|||||||
|
|
||||||
RNA_def_struct_path_func(srna, "rna_ParticleSystem_path");
|
RNA_def_struct_path_func(srna, "rna_ParticleSystem_path");
|
||||||
|
|
||||||
|
/* Toggle Render settings */
|
||||||
|
func = RNA_def_function(srna, "ToggleRender", "rna_ParticleSystem_ToggleRender");
|
||||||
|
RNA_def_function_ui_description(func, "Toggle render settings");
|
||||||
|
prop = RNA_def_pointer(func, "scene", "Scene", "", "Scene");
|
||||||
|
prop = RNA_def_pointer(func, "object", "Object", "", "Object");
|
||||||
|
|
||||||
/* extract cached hair location data */
|
/* extract cached hair location data */
|
||||||
func = RNA_def_function(srna, "co_hair", "rna_ParticleSystem_co_hair");
|
func = RNA_def_function(srna, "co_hair", "rna_ParticleSystem_co_hair");
|
||||||
RNA_def_function_ui_description(func, "Obtain cache hair data");
|
RNA_def_function_ui_description(func, "Obtain cache hair data");
|
||||||
|
Reference in New Issue
Block a user