Curves: add surface object pointer

Ref T95776.

Differential Revision: https://developer.blender.org/D14182
This commit is contained in:
Jacques Lucke 2022-02-25 13:22:42 +01:00
parent 1a853a9e90
commit 6e11cfc56a
Notes: blender-bot 2023-02-14 05:51:15 +01:00
Referenced by issue #95917, Boolean modifiers creates odd shading when used in 'Exact' mode
Referenced by issue #95776, How to attach hair to a surface
5 changed files with 34 additions and 1 deletions

View File

@ -35,6 +35,17 @@ class DATA_PT_context_curves(DataButtonsPanel, Panel):
layout.template_ID(space, "pin_id")
class DATA_PT_curves_surface(DataButtonsPanel, Panel):
bl_label = "Surface"
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
def draw(self, context):
layout = self.layout
ob = context.object
layout.prop(ob.data, "surface")
class CURVES_MT_add_attribute(Menu):
bl_label = "Add Attribute"
@ -115,6 +126,7 @@ class DATA_PT_custom_props_curves(DataButtonsPanel, PropertyPanel, Panel):
classes = (
DATA_PT_context_curves,
DATA_PT_CURVES_attributes,
DATA_PT_curves_surface,
DATA_PT_custom_props_curves,
CURVES_MT_add_attribute,
CURVES_UL_attributes,

View File

@ -114,6 +114,7 @@ static void curves_foreach_id(ID *id, LibraryForeachIDData *data)
for (int i = 0; i < curves->totcol; i++) {
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curves->mat[i], IDWALK_CB_USER);
}
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curves->surface, IDWALK_CB_NOP);
}
static void curves_blend_write(BlendWriter *writer, ID *id, const void *id_address)
@ -186,6 +187,7 @@ static void curves_blend_read_lib(BlendLibReader *reader, ID *id)
for (int a = 0; a < curves->totcol; a++) {
BLO_read_id_address(reader, curves->id.lib, &curves->mat[a]);
}
BLO_read_id_address(reader, curves->id.lib, &curves->surface);
}
static void curves_blend_read_expand(BlendExpander *expander, ID *id)
@ -194,6 +196,7 @@ static void curves_blend_read_expand(BlendExpander *expander, ID *id)
for (int a = 0; a < curves->totcol; a++) {
BLO_expand(expander, curves->mat[a]);
}
BLO_expand(expander, curves->surface);
}
IDTypeInfo IDType_ID_CV = {

View File

@ -448,7 +448,7 @@ uint64_t BKE_library_id_can_use_filter_id(const ID *id_owner)
case ID_WS:
return FILTER_ID_SCE;
case ID_CV:
return FILTER_ID_MA;
return FILTER_ID_MA | FILTER_ID_OB;
case ID_PT:
return FILTER_ID_MA;
case ID_VO:

View File

@ -115,6 +115,15 @@ typedef struct Curves {
short totcol;
short _pad2[3];
/**
* Used as base mesh when curves represent e.g. hair or fur. This surface is used in edit modes.
* When set, the curves will have attributes that indicate a position on this surface. This is
* used for deforming the curves when the surface is deformed dynamically.
*
* This is expected to be a mesh object.
*/
struct Object *surface;
/* Draw Cache. */
void *batch_cache;
} Curves;

View File

@ -16,6 +16,8 @@
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "WM_types.h"
#ifdef RNA_RUNTIME
# include "BLI_math_vector.h"
@ -265,6 +267,13 @@ static void rna_def_curves(BlenderRNA *brna)
RNA_def_property_collection_funcs(
prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
prop = RNA_def_property(srna, "surface", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll");
RNA_def_property_ui_text(prop, "Surface", "Mesh object that the curves can be attached to");
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
/* attributes */
rna_def_attributes_common(srna);