Fix #115344: Generated coordinates for hair psys
When using particle system the generated coordinates where not set. The reason is that a loose resource handle was created for particle system that didn't contain enough information to calculate orcos. This PR will create the object info from its parent object. Pull Request: https://projects.blender.org/blender/blender/pulls/123307
This commit is contained in:
@@ -267,7 +267,8 @@ void Instance::object_sync(Object *ob)
|
||||
if (partsys_is_visible && ob != DRW_context_state_get()->object_edit) {
|
||||
auto sync_hair =
|
||||
[&](ObjectHandle hair_handle, ModifierData &md, ParticleSystem &particle_sys) {
|
||||
ResourceHandle _res_handle = manager->resource_handle(ob->object_to_world());
|
||||
ResourceHandle _res_handle = manager->resource_handle_for_psys(ob_ref,
|
||||
ob->object_to_world());
|
||||
sync.sync_curves(ob, hair_handle, _res_handle, ob_ref, &md, &particle_sys);
|
||||
};
|
||||
foreach_hair_particle_handle(ob, ob_handle, sync_hair);
|
||||
|
||||
@@ -207,6 +207,7 @@ DRWShadingGroup *DRW_shgroup_hair_create_sub(Object *object,
|
||||
if (hair_cache->num_uv_layers == 0) {
|
||||
DRW_shgroup_buffer_texture(shgrp, "u", g_dummy_vbo);
|
||||
DRW_shgroup_buffer_texture(shgrp, "au", g_dummy_vbo);
|
||||
DRW_shgroup_buffer_texture(shgrp, "a", g_dummy_vbo);
|
||||
}
|
||||
if (hair_cache->num_col_layers == 0) {
|
||||
DRW_shgroup_buffer_texture(shgrp, "c", g_dummy_vbo);
|
||||
@@ -378,6 +379,7 @@ blender::gpu::Batch *hair_sub_pass_setup_implementation(PassT &sub_ps,
|
||||
if (hair_cache->num_uv_layers == 0) {
|
||||
sub_ps.bind_texture("u", g_dummy_vbo);
|
||||
sub_ps.bind_texture("au", g_dummy_vbo);
|
||||
sub_ps.bind_texture("a", g_dummy_vbo);
|
||||
}
|
||||
if (hair_cache->num_col_layers == 0) {
|
||||
sub_ps.bind_texture("c", g_dummy_vbo);
|
||||
|
||||
@@ -142,6 +142,11 @@ class Manager {
|
||||
ResourceHandle resource_handle(const float4x4 &model_matrix,
|
||||
const float3 &bounds_center,
|
||||
const float3 &bounds_half_extent);
|
||||
/**
|
||||
* Get resource id for particle system. The draw-calls for this resource won't be culled. The
|
||||
* associated object info will contain the info from its parent object.
|
||||
*/
|
||||
ResourceHandle resource_handle_for_psys(const ObjectRef ref, const float4x4 &model_matrix);
|
||||
|
||||
/** Update the bounds of an already created handle. */
|
||||
void update_handle_bounds(ResourceHandle handle,
|
||||
@@ -265,6 +270,16 @@ inline ResourceHandle Manager::resource_handle(const float4x4 &model_matrix,
|
||||
return ResourceHandle(resource_len_++, false);
|
||||
}
|
||||
|
||||
inline ResourceHandle Manager::resource_handle_for_psys(const ObjectRef ref,
|
||||
const float4x4 &model_matrix)
|
||||
{
|
||||
bool is_active_object = (ref.dupli_object ? ref.dupli_parent : ref.object) == object_active;
|
||||
matrix_buf.current().get_or_resize(resource_len_).sync(model_matrix);
|
||||
bounds_buf.current().get_or_resize(resource_len_).sync();
|
||||
infos_buf.current().get_or_resize(resource_len_).sync(ref, is_active_object);
|
||||
return ResourceHandle(resource_len_++, (ref.object->transflag & OB_NEG_SCALE) != 0);
|
||||
}
|
||||
|
||||
inline void Manager::update_handle_bounds(ResourceHandle handle,
|
||||
const ObjectRef ref,
|
||||
float inflate_bounds)
|
||||
|
||||
Reference in New Issue
Block a user