Fix bug in cached meshes where convex hull was missing. Previously if a mesh was copied from the cache it would not have its convex hull if the original mesh that was cached didn't previously compute it.
Fixes #2609 PiperOrigin-RevId: 756223337 Change-Id: I54705456636c270607a17340b249047e0df75d0b
This commit is contained in:
committed by
Copybara-Service
parent
6cfea71985
commit
f4774a5449
@@ -75,14 +75,19 @@ PNGImage PNGImage::Load(const mjCBase* obj, mjResource* resource,
|
||||
image.color_type_ = color_type;
|
||||
mjCCache *cache = reinterpret_cast<mjCCache*>(mj_globalCache());
|
||||
|
||||
// cache callback
|
||||
auto callback = [&image](const void* data) {
|
||||
const PNGImage *cached_image = static_cast<const PNGImage*>(data);
|
||||
if (cached_image->color_type_ == image.color_type_) {
|
||||
image = *cached_image;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// try loading from cache
|
||||
if (cache && cache->PopulateData(resource, [&image](const void* data) {
|
||||
const PNGImage *cached_image = static_cast<const PNGImage*>(data);
|
||||
if (cached_image->color_type_ == image.color_type_) {
|
||||
image = *cached_image;
|
||||
}
|
||||
})) {
|
||||
if (!image.data_.empty()) return image;
|
||||
if (cache && cache->PopulateData(resource, callback)) {
|
||||
return image;
|
||||
}
|
||||
|
||||
// open PNG resource
|
||||
|
||||
Reference in New Issue
Block a user