Smoke: add temperature grid, with values 0..1 corresponding to 0..1000K.
This commit is contained in:
@@ -367,6 +367,8 @@ static void create_mesh_volume_attributes(Scene *scene,
|
|||||||
create_mesh_volume_attribute(b_ob, mesh, scene->image_manager, ATTR_STD_VOLUME_FLAME, frame);
|
create_mesh_volume_attribute(b_ob, mesh, scene->image_manager, ATTR_STD_VOLUME_FLAME, frame);
|
||||||
if(mesh->need_attribute(scene, ATTR_STD_VOLUME_HEAT))
|
if(mesh->need_attribute(scene, ATTR_STD_VOLUME_HEAT))
|
||||||
create_mesh_volume_attribute(b_ob, mesh, scene->image_manager, ATTR_STD_VOLUME_HEAT, frame);
|
create_mesh_volume_attribute(b_ob, mesh, scene->image_manager, ATTR_STD_VOLUME_HEAT, frame);
|
||||||
|
if(mesh->need_attribute(scene, ATTR_STD_VOLUME_TEMPERATURE))
|
||||||
|
create_mesh_volume_attribute(b_ob, mesh, scene->image_manager, ATTR_STD_VOLUME_TEMPERATURE, frame);
|
||||||
if(mesh->need_attribute(scene, ATTR_STD_VOLUME_VELOCITY))
|
if(mesh->need_attribute(scene, ATTR_STD_VOLUME_VELOCITY))
|
||||||
create_mesh_volume_attribute(b_ob, mesh, scene->image_manager, ATTR_STD_VOLUME_VELOCITY, frame);
|
create_mesh_volume_attribute(b_ob, mesh, scene->image_manager, ATTR_STD_VOLUME_VELOCITY, frame);
|
||||||
}
|
}
|
||||||
|
@@ -1066,7 +1066,8 @@ void BlenderSession::builtin_image_info(const string &builtin_name,
|
|||||||
|
|
||||||
if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY) ||
|
if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY) ||
|
||||||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME) ||
|
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME) ||
|
||||||
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT))
|
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT) ||
|
||||||
|
builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE))
|
||||||
channels = 1;
|
channels = 1;
|
||||||
else if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR))
|
else if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR))
|
||||||
channels = 4;
|
channels = 4;
|
||||||
@@ -1287,6 +1288,13 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE)) {
|
||||||
|
SmokeDomainSettings_temperature_grid_get_length(&b_domain.ptr, &length);
|
||||||
|
if(length == num_pixels) {
|
||||||
|
SmokeDomainSettings_temperature_grid_get(&b_domain.ptr, pixels);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Cycles error: unknown volume attribute %s, skipping\n",
|
"Cycles error: unknown volume attribute %s, skipping\n",
|
||||||
|
@@ -798,6 +798,7 @@ typedef enum AttributeStandard {
|
|||||||
ATTR_STD_VOLUME_COLOR,
|
ATTR_STD_VOLUME_COLOR,
|
||||||
ATTR_STD_VOLUME_FLAME,
|
ATTR_STD_VOLUME_FLAME,
|
||||||
ATTR_STD_VOLUME_HEAT,
|
ATTR_STD_VOLUME_HEAT,
|
||||||
|
ATTR_STD_VOLUME_TEMPERATURE,
|
||||||
ATTR_STD_VOLUME_VELOCITY,
|
ATTR_STD_VOLUME_VELOCITY,
|
||||||
ATTR_STD_POINTINESS,
|
ATTR_STD_POINTINESS,
|
||||||
ATTR_STD_NUM,
|
ATTR_STD_NUM,
|
||||||
|
@@ -281,6 +281,8 @@ const char *Attribute::standard_name(AttributeStandard std)
|
|||||||
return "flame";
|
return "flame";
|
||||||
case ATTR_STD_VOLUME_HEAT:
|
case ATTR_STD_VOLUME_HEAT:
|
||||||
return "heat";
|
return "heat";
|
||||||
|
case ATTR_STD_VOLUME_TEMPERATURE:
|
||||||
|
return "temperature";
|
||||||
case ATTR_STD_VOLUME_VELOCITY:
|
case ATTR_STD_VOLUME_VELOCITY:
|
||||||
return "velocity";
|
return "velocity";
|
||||||
case ATTR_STD_POINTINESS:
|
case ATTR_STD_POINTINESS:
|
||||||
@@ -425,6 +427,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
|
|||||||
case ATTR_STD_VOLUME_DENSITY:
|
case ATTR_STD_VOLUME_DENSITY:
|
||||||
case ATTR_STD_VOLUME_FLAME:
|
case ATTR_STD_VOLUME_FLAME:
|
||||||
case ATTR_STD_VOLUME_HEAT:
|
case ATTR_STD_VOLUME_HEAT:
|
||||||
|
case ATTR_STD_VOLUME_TEMPERATURE:
|
||||||
attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_VOXEL);
|
attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_VOXEL);
|
||||||
break;
|
break;
|
||||||
case ATTR_STD_VOLUME_COLOR:
|
case ATTR_STD_VOLUME_COLOR:
|
||||||
|
@@ -362,6 +362,42 @@ static void rna_SmokeModifier_heat_grid_get(PointerRNA *ptr, float *values)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rna_SmokeModifier_temperature_grid_get(PointerRNA *ptr, float *values)
|
||||||
|
{
|
||||||
|
#ifdef WITH_SMOKE
|
||||||
|
SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
|
||||||
|
int length[RNA_MAX_ARRAY_DIMENSION];
|
||||||
|
int size = rna_SmokeModifier_grid_get_length(ptr, length);
|
||||||
|
float *flame;
|
||||||
|
|
||||||
|
BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
|
||||||
|
|
||||||
|
if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt) {
|
||||||
|
flame = smoke_turbulence_get_flame(sds->wt);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
flame = smoke_get_flame(sds->fluid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flame) {
|
||||||
|
/* Output is such that 0..1 maps to 0..1000K */
|
||||||
|
float offset = sds->flame_ignition;
|
||||||
|
float scale = sds->flame_max_temp - sds->flame_ignition;
|
||||||
|
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
values[i] = (flame[i] > 0.01f) ? offset + flame[i] * scale : 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
memset(values, 0, size * sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
|
BLI_rw_mutex_unlock(sds->fluid_mutex);
|
||||||
|
#else
|
||||||
|
UNUSED_VARS(ptr, values);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void rna_SmokeFlow_density_vgroup_get(PointerRNA *ptr, char *value)
|
static void rna_SmokeFlow_density_vgroup_get(PointerRNA *ptr, char *value)
|
||||||
{
|
{
|
||||||
SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
|
SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
|
||||||
@@ -677,6 +713,14 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
|
|||||||
RNA_def_property_float_funcs(prop, "rna_SmokeModifier_heat_grid_get", NULL, NULL);
|
RNA_def_property_float_funcs(prop, "rna_SmokeModifier_heat_grid_get", NULL, NULL);
|
||||||
RNA_def_property_ui_text(prop, "Heat Grid", "Smoke heat grid");
|
RNA_def_property_ui_text(prop, "Heat Grid", "Smoke heat grid");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "temperature_grid", PROP_FLOAT, PROP_NONE);
|
||||||
|
RNA_def_property_array(prop, 32);
|
||||||
|
RNA_def_property_flag(prop, PROP_DYNAMIC);
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
RNA_def_property_dynamic_array_funcs(prop, "rna_SmokeModifier_grid_get_length");
|
||||||
|
RNA_def_property_float_funcs(prop, "rna_SmokeModifier_temperature_grid_get", NULL, NULL);
|
||||||
|
RNA_def_property_ui_text(prop, "Temperature Grid", "Smoke temperature grid, range 0..1 represents 0..1000K");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_XYZ); /* can change each frame when using adaptive domain */
|
prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_XYZ); /* can change each frame when using adaptive domain */
|
||||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
RNA_def_property_ui_text(prop, "cell_size", "Cell Size");
|
RNA_def_property_ui_text(prop, "cell_size", "Cell Size");
|
||||||
|
Reference in New Issue
Block a user