Cycles: Add missing velocity attribute to builtin image loader
For some reason other parts of blender importer were assuming velocity is supported, but actual loader was not aware of that. Fixes T48064: Adding velocity attribute crashes render
This commit is contained in:
parent
19539c50c9
commit
951fad2baa
Notes:
blender-bot
2023-02-14 08:00:46 +01:00
Referenced by issue #48064, Smoke-cycles-OpenvVDB Adding velocity attribute crashes render
|
@ -1117,6 +1117,8 @@ void BlenderSession::builtin_image_info(const string &builtin_name, void *builti
|
|||
channels = 1;
|
||||
else if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR))
|
||||
channels = 4;
|
||||
else if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY))
|
||||
channels = 3;
|
||||
else
|
||||
return;
|
||||
|
||||
|
@ -1246,6 +1248,11 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
|
|||
int3 resolution = get_int3(b_domain.domain_resolution());
|
||||
int length, amplify = (b_domain.use_high_resolution())? b_domain.amplify() + 1: 1;
|
||||
|
||||
/* Velocity data is always low-resolution. */
|
||||
if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) {
|
||||
amplify = 1;
|
||||
}
|
||||
|
||||
int width = resolution.x * amplify;
|
||||
int height = resolution.y * amplify;
|
||||
int depth = resolution.z * amplify;
|
||||
|
@ -1278,6 +1285,14 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) {
|
||||
SmokeDomainSettings_velocity_grid_get_length(&b_domain.ptr, &length);
|
||||
|
||||
if(length == num_pixels*3) {
|
||||
SmokeDomainSettings_velocity_grid_get(&b_domain.ptr, pixels);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Cycles error: unknown volume attribute, skipping\n");
|
||||
pixels[0] = 0.0f;
|
||||
|
|
Loading…
Reference in New Issue