[Bf-blender-cvs] [246df680958] master: Sculpt: Fix crash with unsupported attr types in pbvh draw
Joseph Eagar
noreply at git.blender.org
Tue Dec 13 17:47:59 CET 2022
Commit: 246df68095835110a3e11eb3c7a9d2acb048332c
Author: Joseph Eagar
Date: Tue Dec 13 08:37:04 2022 -0800
Branches: master
https://developer.blender.org/rB246df68095835110a3e11eb3c7a9d2acb048332c
Sculpt: Fix crash with unsupported attr types in pbvh draw
===================================================================
M source/blender/draw/intern/draw_pbvh.cc
===================================================================
diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc
index cac3e3339fc..d56a86ab44c 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -66,6 +66,22 @@ using blender::Vector;
using string = std::string;
+static bool valid_pbvh_attr(int type)
+{
+ switch (type) {
+ case CD_PBVH_CO_TYPE:
+ case CD_PBVH_NO_TYPE:
+ case CD_PBVH_FSET_TYPE:
+ case CD_PBVH_MASK_TYPE:
+ case CD_PROP_COLOR:
+ case CD_PROP_BYTE_COLOR:
+ case CD_MLOOPUV:
+ return true;
+ }
+
+ return false;
+}
+
struct PBVHVbo {
uint64_t type;
eAttrDomain domain;
@@ -228,6 +244,10 @@ struct PBVHBatches {
for (int i : IndexRange(attrs_num)) {
PBVHAttrReq *attr = attrs + i;
+ if (!valid_pbvh_attr(attr->type)) {
+ continue;
+ }
+
PBVHVbo vbo(attr->domain, attr->type, string(attr->name));
vbo.build_key();
@@ -858,10 +878,10 @@ struct PBVHBatches {
break;
}
default:
- BLI_assert(0);
- printf("%s: error\n", __func__);
+ printf("%s: Unsupported attribute type %d\n", __func__, type);
+ BLI_assert_unreachable();
- break;
+ return;
}
if (need_aliases) {
@@ -1227,6 +1247,10 @@ struct PBVHBatches {
for (int i : IndexRange(attrs_num)) {
PBVHAttrReq *attr = attrs + i;
+ if (!valid_pbvh_attr(attr->type)) {
+ continue;
+ }
+
if (!has_vbo(attr->domain, int(attr->type), attr->name)) {
create_vbo(attr->domain, uint32_t(attr->type), attr->name, args);
}
More information about the Bf-blender-cvs
mailing list