Geometry: add Attributes panel for PointCloud and Hair
There is a list of attributes, along with operators to add and remove attributes. For adding, there are a few standard attributes that can be added quickly, as well as a popup to create a custom attribute. Ref T76659 Differential Revision: https://developer.blender.org/D8636
This commit is contained in:
parent
a1397a3cc6
commit
370d6e5025
@ -18,7 +18,7 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
import bpy
|
||||
from bpy.types import Panel, UIList
|
||||
from bpy.types import Menu, Panel, UIList
|
||||
from rna_prop_ui import PropertyPanel
|
||||
|
||||
|
||||
@ -51,14 +51,68 @@ class DATA_PT_context_hair(DataButtonsPanel, Panel):
|
||||
layout.template_ID(space, "pin_id")
|
||||
|
||||
|
||||
class DATA_PT_hair(DataButtonsPanel, Panel):
|
||||
bl_label = "Hair"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
|
||||
class HAIR_MT_add_attribute(Menu):
|
||||
bl_label = "Add Attribute"
|
||||
|
||||
@staticmethod
|
||||
def add_standard_attribute(layout, hair, name, data_type, domain):
|
||||
exists = hair.attributes.get(name) != None
|
||||
|
||||
col = layout.column()
|
||||
col.enabled = not exists
|
||||
col.operator_context = 'EXEC_DEFAULT'
|
||||
|
||||
props = col.operator("geometry.attribute_add", text=name)
|
||||
props.name = name
|
||||
props.data_type = data_type
|
||||
props.domain = domain
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
hair = context.hair
|
||||
pass
|
||||
|
||||
self.add_standard_attribute(layout, hair, 'Radius', 'FLOAT', 'POINT')
|
||||
self.add_standard_attribute(layout, hair, 'Color', 'FLOAT_COLOR', 'POINT')
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator_context = 'INVOKE_DEFAULT'
|
||||
layout.operator("geometry.attribute_add", text="Custom...")
|
||||
|
||||
|
||||
class HAIR_UL_attributes(UIList):
|
||||
def draw_item(self, context, layout, data, attribute, icon, active_data, active_propname, index):
|
||||
data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type]
|
||||
domain = attribute.bl_rna.properties['domain'].enum_items[attribute.domain]
|
||||
|
||||
split = layout.split(factor=0.5)
|
||||
row = split.row()
|
||||
row.prop(attribute, "name", text="", emboss=False)
|
||||
sub = split.split()
|
||||
sub.alignment = 'RIGHT'
|
||||
sub.active = False
|
||||
sub.label(text=domain.name)
|
||||
sub.label(text=data_type.name)
|
||||
|
||||
|
||||
class DATA_PT_hair_attributes(DataButtonsPanel, Panel):
|
||||
bl_label = "Attributes"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
|
||||
|
||||
def draw(self, context):
|
||||
hair = context.hair
|
||||
|
||||
layout = self.layout
|
||||
row = layout.row()
|
||||
|
||||
col = row.column()
|
||||
col.template_list("HAIR_UL_attributes", "attributes", hair, "attributes", hair.attributes, "active_index", rows=3)
|
||||
|
||||
col = row.column(align=True)
|
||||
col.menu("HAIR_MT_add_attribute", icon='ADD', text="")
|
||||
col.operator("geometry.attribute_remove", icon='REMOVE', text="")
|
||||
|
||||
|
||||
|
||||
class DATA_PT_custom_props_hair(DataButtonsPanel, PropertyPanel, Panel):
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
|
||||
@ -68,8 +122,10 @@ class DATA_PT_custom_props_hair(DataButtonsPanel, PropertyPanel, Panel):
|
||||
|
||||
classes = (
|
||||
DATA_PT_context_hair,
|
||||
DATA_PT_hair,
|
||||
DATA_PT_hair_attributes,
|
||||
DATA_PT_custom_props_hair,
|
||||
HAIR_MT_add_attribute,
|
||||
HAIR_UL_attributes,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
# <pep8 compliant>
|
||||
import bpy
|
||||
from bpy.types import Panel, UIList
|
||||
from bpy.types import Menu, Panel, UIList
|
||||
from rna_prop_ui import PropertyPanel
|
||||
|
||||
|
||||
@ -51,14 +51,67 @@ class DATA_PT_context_pointcloud(DataButtonsPanel, Panel):
|
||||
layout.template_ID(space, "pin_id")
|
||||
|
||||
|
||||
class DATA_PT_pointcloud(DataButtonsPanel, Panel):
|
||||
bl_label = "Point Cloud"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
|
||||
class POINTCLOUD_MT_add_attribute(Menu):
|
||||
bl_label = "Add Attribute"
|
||||
|
||||
@staticmethod
|
||||
def add_standard_attribute(layout, pointcloud, name, data_type, domain):
|
||||
exists = pointcloud.attributes.get(name) != None
|
||||
|
||||
col = layout.column()
|
||||
col.enabled = not exists
|
||||
col.operator_context = 'EXEC_DEFAULT'
|
||||
|
||||
props = col.operator("geometry.attribute_add", text=name)
|
||||
props.name = name
|
||||
props.data_type = data_type
|
||||
props.domain = domain
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
pointcloud = context.pointcloud
|
||||
pass
|
||||
|
||||
self.add_standard_attribute(layout, pointcloud, 'Radius', 'FLOAT', 'POINT')
|
||||
self.add_standard_attribute(layout, pointcloud, 'Color', 'FLOAT_COLOR', 'POINT')
|
||||
self.add_standard_attribute(layout, pointcloud, 'Particle ID', 'INT', 'POINT')
|
||||
self.add_standard_attribute(layout, pointcloud, 'Velocity', 'FLOAT_VECTOR', 'POINT')
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator_context = 'INVOKE_DEFAULT'
|
||||
layout.operator("geometry.attribute_add", text="Custom...")
|
||||
|
||||
|
||||
class POINTCLOUD_UL_attributes(UIList):
|
||||
def draw_item(self, context, layout, data, attribute, icon, active_data, active_propname, index):
|
||||
data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type]
|
||||
|
||||
split = layout.split(factor=0.75)
|
||||
split.prop(attribute, "name", text="", emboss=False)
|
||||
sub = split.row()
|
||||
sub.alignment = 'RIGHT'
|
||||
sub.active = False
|
||||
sub.label(text=data_type.name)
|
||||
|
||||
|
||||
class DATA_PT_pointcloud_attributes(DataButtonsPanel, Panel):
|
||||
bl_label = "Attributes"
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
|
||||
|
||||
def draw(self, context):
|
||||
pointcloud = context.pointcloud
|
||||
|
||||
layout = self.layout
|
||||
row = layout.row()
|
||||
|
||||
col = row.column()
|
||||
col.template_list("POINTCLOUD_UL_attributes", "attributes", pointcloud, "attributes", pointcloud.attributes, "active_index", rows=3)
|
||||
|
||||
col = row.column(align=True)
|
||||
col.menu("POINTCLOUD_MT_add_attribute", icon='ADD', text="")
|
||||
col.operator("geometry.attribute_remove", icon='REMOVE', text="")
|
||||
|
||||
|
||||
|
||||
class DATA_PT_custom_props_pointcloud(DataButtonsPanel, PropertyPanel, Panel):
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
|
||||
@ -68,8 +121,10 @@ class DATA_PT_custom_props_pointcloud(DataButtonsPanel, PropertyPanel, Panel):
|
||||
|
||||
classes = (
|
||||
DATA_PT_context_pointcloud,
|
||||
DATA_PT_pointcloud,
|
||||
DATA_PT_pointcloud_attributes,
|
||||
DATA_PT_custom_props_pointcloud,
|
||||
POINTCLOUD_MT_add_attribute,
|
||||
POINTCLOUD_UL_attributes,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
|
@ -53,12 +53,14 @@ typedef enum AttributeDomain {
|
||||
|
||||
/* Attributes */
|
||||
|
||||
bool BKE_id_attributes_supported(struct ID *id);
|
||||
|
||||
struct CustomDataLayer *BKE_id_attribute_new(struct ID *id,
|
||||
const char *name,
|
||||
const int type,
|
||||
const AttributeDomain domain,
|
||||
struct ReportList *reports);
|
||||
void BKE_id_attribute_remove(struct ID *id,
|
||||
bool BKE_id_attribute_remove(struct ID *id,
|
||||
struct CustomDataLayer *layer,
|
||||
struct ReportList *reports);
|
||||
|
||||
|
@ -101,6 +101,18 @@ static CustomData *attribute_customdata_find(ID *id, CustomDataLayer *layer)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool BKE_id_attributes_supported(struct ID *id)
|
||||
{
|
||||
DomainInfo info[ATTR_DOMAIN_NUM];
|
||||
get_domains(id, info);
|
||||
for (AttributeDomain domain = 0; domain < ATTR_DOMAIN_NUM; domain++) {
|
||||
if (info[domain].customdata) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BKE_id_attribute_rename(ID *id,
|
||||
CustomDataLayer *layer,
|
||||
const char *new_name,
|
||||
@ -139,7 +151,7 @@ CustomDataLayer *BKE_id_attribute_new(
|
||||
return (index == -1) ? NULL : &(customdata->layers[index]);
|
||||
}
|
||||
|
||||
void BKE_id_attribute_remove(ID *id, CustomDataLayer *layer, ReportList *reports)
|
||||
bool BKE_id_attribute_remove(ID *id, CustomDataLayer *layer, ReportList *reports)
|
||||
{
|
||||
CustomData *customdata = attribute_customdata_find(id, layer);
|
||||
const int index = (customdata) ?
|
||||
@ -148,16 +160,17 @@ void BKE_id_attribute_remove(ID *id, CustomDataLayer *layer, ReportList *reports
|
||||
|
||||
if (index == -1) {
|
||||
BKE_report(reports, RPT_ERROR, "Attribute is not part of this geometry");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (BKE_id_attribute_required(id, layer)) {
|
||||
BKE_report(reports, RPT_ERROR, "Attribute is required and can't be removed");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const int length = BKE_id_attribute_data_length(id, layer);
|
||||
CustomData_free_layer(customdata, layer->type, length, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
int BKE_id_attributes_length(ID *id, const CustomDataMask mask)
|
||||
|
@ -23,11 +23,12 @@ if(WITH_BLENDER)
|
||||
add_subdirectory(animation)
|
||||
add_subdirectory(armature)
|
||||
add_subdirectory(curve)
|
||||
add_subdirectory(geometry)
|
||||
add_subdirectory(gizmo_library)
|
||||
add_subdirectory(gpencil)
|
||||
add_subdirectory(interface)
|
||||
add_subdirectory(io)
|
||||
add_subdirectory(lattice)
|
||||
add_subdirectory(gizmo_library)
|
||||
add_subdirectory(mask)
|
||||
add_subdirectory(mesh)
|
||||
add_subdirectory(metaball)
|
||||
|
45
source/blender/editors/geometry/CMakeLists.txt
Normal file
45
source/blender/editors/geometry/CMakeLists.txt
Normal file
@ -0,0 +1,45 @@
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
set(INC
|
||||
../include
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../depsgraph
|
||||
../../makesdna
|
||||
../../makesrna
|
||||
../../windowmanager
|
||||
)
|
||||
|
||||
set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
geometry_attributes.c
|
||||
geometry_ops.c
|
||||
|
||||
geometry_intern.h
|
||||
)
|
||||
|
||||
set(LIB
|
||||
bf_blenkernel
|
||||
bf_depsgraph
|
||||
bf_editor_object
|
||||
bf_windowmanager
|
||||
)
|
||||
|
||||
blender_add_lib(bf_editor_geometry "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
156
source/blender/editors/geometry/geometry_attributes.c
Normal file
156
source/blender/editors/geometry/geometry_attributes.c
Normal file
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2020 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup edgeometry
|
||||
*/
|
||||
|
||||
#include "BKE_attribute.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_geometry.h"
|
||||
#include "ED_object.h"
|
||||
|
||||
#include "geometry_intern.h"
|
||||
|
||||
/*********************** Attribute Operators ************************/
|
||||
|
||||
static bool geometry_attributes_poll(bContext *C)
|
||||
{
|
||||
Object *ob = ED_object_context(C);
|
||||
ID *data = (ob) ? ob->data : NULL;
|
||||
return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)) &&
|
||||
BKE_id_attributes_supported(data);
|
||||
}
|
||||
|
||||
static const EnumPropertyItem *geometry_attribute_domain_itemf(bContext *C,
|
||||
PointerRNA *UNUSED(ptr),
|
||||
PropertyRNA *UNUSED(prop),
|
||||
bool *r_free)
|
||||
{
|
||||
Object *ob = ED_object_context(C);
|
||||
return rna_enum_attribute_domain_itemf(ob->data, r_free);
|
||||
}
|
||||
|
||||
static int geometry_attribute_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = ED_object_context(C);
|
||||
ID *id = ob->data;
|
||||
|
||||
char name[MAX_NAME];
|
||||
RNA_string_get(op->ptr, "name", name);
|
||||
CustomDataType type = (CustomDataType)RNA_enum_get(op->ptr, "data_type");
|
||||
AttributeDomain domain = (AttributeDomain)RNA_enum_get(op->ptr, "domain");
|
||||
CustomDataLayer *layer = BKE_id_attribute_new(id, name, type, domain, op->reports);
|
||||
|
||||
if (layer == NULL) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
BKE_id_attributes_active_set(id, layer);
|
||||
|
||||
DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void GEOMETRY_OT_attribute_add(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Add Geometry Attribute";
|
||||
ot->description = "Add attribute to geometry";
|
||||
ot->idname = "GEOMETRY_OT_attribute_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->poll = geometry_attributes_poll;
|
||||
ot->exec = geometry_attribute_add_exec;
|
||||
ot->invoke = WM_operator_props_popup_confirm;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_string(ot->srna, "name", "Attribute", MAX_NAME, "Name", "Name of new attribute");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_enum(ot->srna,
|
||||
"data_type",
|
||||
rna_enum_attribute_type_items,
|
||||
CD_PROP_FLOAT,
|
||||
"Data Type",
|
||||
"Type of data stored in attribute");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_enum(ot->srna,
|
||||
"domain",
|
||||
rna_enum_attribute_domain_items,
|
||||
ATTR_DOMAIN_POINT,
|
||||
"Domain",
|
||||
"Type of element that attribute is stored on");
|
||||
RNA_def_enum_funcs(prop, geometry_attribute_domain_itemf);
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
}
|
||||
|
||||
static int geometry_attribute_remove_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = ED_object_context(C);
|
||||
ID *id = ob->data;
|
||||
CustomDataLayer *layer = BKE_id_attributes_active_get(id);
|
||||
|
||||
if (layer == NULL) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (!BKE_id_attribute_remove(id, layer, op->reports)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void GEOMETRY_OT_attribute_remove(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Remove Geometry Attribute";
|
||||
ot->description = "Remove attribute from geometry";
|
||||
ot->idname = "GEOMETRY_OT_attribute_remove";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = geometry_attribute_remove_exec;
|
||||
ot->poll = geometry_attributes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
33
source/blender/editors/geometry/geometry_intern.h
Normal file
33
source/blender/editors/geometry/geometry_intern.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2020 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup edgeometry
|
||||
*/
|
||||
|
||||
#ifndef __GEOMETRY_INTERN_H__
|
||||
#define __GEOMETRY_INTERN_H__
|
||||
|
||||
struct wmOperatorType;
|
||||
|
||||
/* *** geometry_attributes.c *** */
|
||||
void GEOMETRY_OT_attribute_add(struct wmOperatorType *ot);
|
||||
void GEOMETRY_OT_attribute_remove(struct wmOperatorType *ot);
|
||||
|
||||
#endif /* __GEOMETRY_INTERN_H__ */
|
36
source/blender/editors/geometry/geometry_ops.c
Normal file
36
source/blender/editors/geometry/geometry_ops.c
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2020 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup edgeometry
|
||||
*/
|
||||
|
||||
#include "WM_api.h"
|
||||
|
||||
#include "ED_geometry.h"
|
||||
|
||||
#include "geometry_intern.h"
|
||||
|
||||
/**************************** registration **********************************/
|
||||
|
||||
void ED_operatortypes_geometry(void)
|
||||
{
|
||||
WM_operatortype_append(GEOMETRY_OT_attribute_add);
|
||||
WM_operatortype_append(GEOMETRY_OT_attribute_remove);
|
||||
}
|
37
source/blender/editors/include/ED_geometry.h
Normal file
37
source/blender/editors/include/ED_geometry.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2020 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup editors
|
||||
*/
|
||||
|
||||
#ifndef __ED_GEOMETRY_H__
|
||||
#define __ED_GEOMETRY_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void ED_operatortypes_geometry(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ED_GEOMETRY_H__ */
|
@ -35,6 +35,7 @@ set(SRC
|
||||
)
|
||||
|
||||
set(LIB
|
||||
bf_editor_geometry
|
||||
bf_editor_space_action
|
||||
bf_editor_space_buttons
|
||||
bf_editor_space_clip
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "ED_clip.h"
|
||||
#include "ED_curve.h"
|
||||
#include "ED_fileselect.h"
|
||||
#include "ED_geometry.h"
|
||||
#include "ED_gizmo_library.h"
|
||||
#include "ED_gpencil.h"
|
||||
#include "ED_lattice.h"
|
||||
@ -106,6 +107,7 @@ void ED_spacetypes_init(void)
|
||||
ED_operatortypes_object();
|
||||
ED_operatortypes_lattice();
|
||||
ED_operatortypes_mesh();
|
||||
ED_operatortypes_geometry();
|
||||
ED_operatortypes_sculpt();
|
||||
ED_operatortypes_uvedit();
|
||||
ED_operatortypes_paint();
|
||||
|
@ -26,6 +26,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ID;
|
||||
struct bNodeSocketType;
|
||||
struct bNodeTreeType;
|
||||
struct bNodeType;
|
||||
@ -231,6 +232,10 @@ extern const EnumPropertyItem rna_enum_context_mode_items[];
|
||||
extern const EnumPropertyItem rna_enum_curveprofile_preset_items[];
|
||||
extern const EnumPropertyItem rna_enum_preference_section_items[];
|
||||
|
||||
extern const EnumPropertyItem rna_enum_attribute_type_items[];
|
||||
extern const EnumPropertyItem rna_enum_attribute_domain_items[];
|
||||
extern const EnumPropertyItem *rna_enum_attribute_domain_itemf(struct ID *id, bool *r_free);
|
||||
|
||||
/* API calls */
|
||||
int rna_node_tree_type_to_enum(struct bNodeTreeType *typeinfo);
|
||||
int rna_node_tree_idname_to_enum(const char *idname);
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
#include "WM_types.h"
|
||||
|
||||
static const EnumPropertyItem rna_enum_attribute_type_items[] = {
|
||||
const EnumPropertyItem rna_enum_attribute_type_items[] = {
|
||||
{CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating point value"},
|
||||
{CD_PROP_INT32, "INT", 0, "Integer", "32 bit integer"},
|
||||
{CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating point values"},
|
||||
@ -47,7 +47,7 @@ static const EnumPropertyItem rna_enum_attribute_type_items[] = {
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem rna_enum_attribute_domain_items[] = {
|
||||
const EnumPropertyItem rna_enum_attribute_domain_items[] = {
|
||||
/* Not implement yet
|
||||
{ATTR_DOMAIN_GEOMETRY, "GEOMETRY", 0, "Geometry", "Attribute on (whole) geometry"}, */
|
||||
{ATTR_DOMAIN_VERTEX, "VERTEX", 0, "Vertex", "Attribute on mesh vertex"},
|
||||
@ -101,14 +101,10 @@ static int rna_Attribute_type_get(PointerRNA *ptr)
|
||||
return layer->type;
|
||||
}
|
||||
|
||||
static const EnumPropertyItem *rna_Attribute_domain_itemf(bContext *UNUSED(C),
|
||||
PointerRNA *ptr,
|
||||
PropertyRNA *UNUSED(prop),
|
||||
bool *r_free)
|
||||
const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id, bool *r_free)
|
||||
{
|
||||
EnumPropertyItem *item = NULL;
|
||||
const EnumPropertyItem *domain_item = NULL;
|
||||
ID *id = ptr->owner_id;
|
||||
const ID_Type id_type = GS(id->name);
|
||||
int totitem = 0, a;
|
||||
|
||||
@ -133,6 +129,14 @@ static const EnumPropertyItem *rna_Attribute_domain_itemf(bContext *UNUSED(C),
|
||||
return item;
|
||||
}
|
||||
|
||||
static const EnumPropertyItem *rna_Attribute_domain_itemf(bContext *UNUSED(C),
|
||||
PointerRNA *ptr,
|
||||
PropertyRNA *UNUSED(prop),
|
||||
bool *r_free)
|
||||
{
|
||||
return rna_enum_attribute_domain_itemf(ptr->owner_id, r_free);
|
||||
}
|
||||
|
||||
static int rna_Attribute_domain_get(PointerRNA *ptr)
|
||||
{
|
||||
return BKE_id_attribute_domain(ptr->owner_id, ptr->data);
|
||||
@ -617,7 +621,7 @@ static void rna_def_attribute_group(BlenderRNA *brna)
|
||||
rna_enum_attribute_domain_items,
|
||||
ATTR_DOMAIN_VERTEX,
|
||||
"Domain",
|
||||
"Attribute domain");
|
||||
"Type of element that attribute is stored on");
|
||||
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||
parm = RNA_def_pointer(func, "attribute", "Attribute", "", "New geometry attribute");
|
||||
RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
|
||||
|
Loading…
Reference in New Issue
Block a user