GPv2: LineArt: Conversion code
Adds conversion code for the lineart modifier for Grease Pencil 3. Pull Request: https://projects.blender.org/blender/blender/pulls/118791
This commit is contained in:
@@ -15,6 +15,8 @@ struct GreasePencilDrawing;
|
||||
struct ListBase;
|
||||
struct Main;
|
||||
struct Object;
|
||||
struct LineartGpencilModifierData;
|
||||
struct GreasePencilLineartModifierData;
|
||||
|
||||
namespace blender::bke::greasepencil::convert {
|
||||
|
||||
@@ -30,4 +32,9 @@ void layer_adjustments_to_modifiers(Main &bmain,
|
||||
const bGPdata &src_object_data,
|
||||
Object &dst_object);
|
||||
|
||||
void lineart_wrap_v3(const LineartGpencilModifierData *lmd_legacy,
|
||||
GreasePencilLineartModifierData *lmd);
|
||||
void lineart_unwrap_v3(LineartGpencilModifierData *lmd_legacy,
|
||||
const GreasePencilLineartModifierData *lmd);
|
||||
|
||||
} // namespace blender::bke::greasepencil::convert
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_ID_enums.h"
|
||||
#include "DNA_brush_types.h"
|
||||
#include "DNA_gpencil_modifier_types.h"
|
||||
#include "DNA_grease_pencil_types.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
@@ -2769,5 +2770,3 @@ static void write_layer_tree(GreasePencil &grease_pencil, BlendWriter *writer)
|
||||
grease_pencil.root_group_ptr->wrap().prepare_for_dna_write();
|
||||
write_layer_tree_group(writer, grease_pencil.root_group_ptr);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -1598,6 +1598,16 @@ static void legacy_object_modifier_weight_proximity(Object &object, GpencilModif
|
||||
false);
|
||||
}
|
||||
|
||||
static void legacy_object_modifier_weight_lineart(Object &object, GpencilModifierData &legacy_md)
|
||||
{
|
||||
ModifierData &md = legacy_object_modifier_common(
|
||||
object, eModifierType_GreasePencilWeightAngle, legacy_md);
|
||||
auto &md_lineart = reinterpret_cast<GreasePencilLineartModifierData &>(md);
|
||||
auto &legacy_md_lineart = reinterpret_cast<LineartGpencilModifierData &>(legacy_md);
|
||||
|
||||
greasepencil::convert::lineart_wrap_v3(&legacy_md_lineart, &md_lineart);
|
||||
}
|
||||
|
||||
static void legacy_object_modifiers(Main & /*bmain*/, Object &object)
|
||||
{
|
||||
BLI_assert(BLI_listbase_is_empty(&object.modifiers));
|
||||
@@ -1671,6 +1681,8 @@ static void legacy_object_modifiers(Main & /*bmain*/, Object &object)
|
||||
case eGpencilModifierType_Simplify:
|
||||
case eGpencilModifierType_Texture:
|
||||
case eGpencilModifierType_Lineart:
|
||||
legacy_object_modifier_weight_lineart(object, *gpd_md);
|
||||
break;
|
||||
case eGpencilModifierType_Shrinkwrap:
|
||||
case eGpencilModifierType_Envelope:
|
||||
case eGpencilModifierType_Outline:
|
||||
@@ -1707,4 +1719,98 @@ void legacy_gpencil_object(Main &bmain, Object &object)
|
||||
BKE_object_free_derived_caches(&object);
|
||||
}
|
||||
|
||||
void lineart_wrap_v3(const LineartGpencilModifierData *lmd_legacy,
|
||||
GreasePencilLineartModifierData *lmd)
|
||||
{
|
||||
#define LMD_WRAP(var) lmd->var = lmd_legacy->var
|
||||
|
||||
LMD_WRAP(edge_types);
|
||||
LMD_WRAP(source_type);
|
||||
LMD_WRAP(use_multiple_levels);
|
||||
LMD_WRAP(level_start);
|
||||
LMD_WRAP(level_end);
|
||||
LMD_WRAP(source_camera);
|
||||
LMD_WRAP(light_contour_object);
|
||||
LMD_WRAP(source_object);
|
||||
LMD_WRAP(source_collection);
|
||||
LMD_WRAP(target_material);
|
||||
STRNCPY(lmd->source_vertex_group, lmd_legacy->source_vertex_group);
|
||||
STRNCPY(lmd->vgname, lmd_legacy->vgname);
|
||||
LMD_WRAP(overscan);
|
||||
LMD_WRAP(shadow_camera_fov);
|
||||
LMD_WRAP(shadow_camera_size);
|
||||
LMD_WRAP(shadow_camera_near);
|
||||
LMD_WRAP(shadow_camera_far);
|
||||
LMD_WRAP(opacity);
|
||||
lmd->thickness = lmd_legacy->thickness / 2;
|
||||
LMD_WRAP(mask_switches);
|
||||
LMD_WRAP(material_mask_bits);
|
||||
LMD_WRAP(intersection_mask);
|
||||
LMD_WRAP(shadow_selection);
|
||||
LMD_WRAP(silhouette_selection);
|
||||
LMD_WRAP(crease_threshold);
|
||||
LMD_WRAP(angle_splitting_threshold);
|
||||
LMD_WRAP(chain_smooth_tolerance);
|
||||
LMD_WRAP(chaining_image_threshold);
|
||||
LMD_WRAP(calculation_flags);
|
||||
LMD_WRAP(flags);
|
||||
LMD_WRAP(stroke_depth_offset);
|
||||
LMD_WRAP(level_start_override);
|
||||
LMD_WRAP(level_end_override);
|
||||
LMD_WRAP(edge_types_override);
|
||||
LMD_WRAP(shadow_selection_override);
|
||||
LMD_WRAP(shadow_use_silhouette_override);
|
||||
LMD_WRAP(cache);
|
||||
LMD_WRAP(la_data_ptr);
|
||||
|
||||
#undef LMD_WRAP
|
||||
}
|
||||
|
||||
void lineart_unwrap_v3(LineartGpencilModifierData *lmd_legacy,
|
||||
const GreasePencilLineartModifierData *lmd)
|
||||
{
|
||||
#define LMD_UNWRAP(var) lmd_legacy->var = lmd->var
|
||||
|
||||
LMD_UNWRAP(edge_types);
|
||||
LMD_UNWRAP(source_type);
|
||||
LMD_UNWRAP(use_multiple_levels);
|
||||
LMD_UNWRAP(level_start);
|
||||
LMD_UNWRAP(level_end);
|
||||
LMD_UNWRAP(source_camera);
|
||||
LMD_UNWRAP(light_contour_object);
|
||||
LMD_UNWRAP(source_object);
|
||||
LMD_UNWRAP(source_collection);
|
||||
LMD_UNWRAP(target_material);
|
||||
STRNCPY(lmd_legacy->source_vertex_group, lmd->source_vertex_group);
|
||||
STRNCPY(lmd_legacy->vgname, lmd->vgname);
|
||||
LMD_UNWRAP(overscan);
|
||||
LMD_UNWRAP(shadow_camera_fov);
|
||||
LMD_UNWRAP(shadow_camera_size);
|
||||
LMD_UNWRAP(shadow_camera_near);
|
||||
LMD_UNWRAP(shadow_camera_far);
|
||||
LMD_UNWRAP(opacity);
|
||||
lmd_legacy->thickness = lmd->thickness * 2;
|
||||
LMD_UNWRAP(mask_switches);
|
||||
LMD_UNWRAP(material_mask_bits);
|
||||
LMD_UNWRAP(intersection_mask);
|
||||
LMD_UNWRAP(shadow_selection);
|
||||
LMD_UNWRAP(silhouette_selection);
|
||||
LMD_UNWRAP(crease_threshold);
|
||||
LMD_UNWRAP(angle_splitting_threshold);
|
||||
LMD_UNWRAP(chain_smooth_tolerance);
|
||||
LMD_UNWRAP(chaining_image_threshold);
|
||||
LMD_UNWRAP(calculation_flags);
|
||||
LMD_UNWRAP(flags);
|
||||
LMD_UNWRAP(stroke_depth_offset);
|
||||
LMD_UNWRAP(level_start_override);
|
||||
LMD_UNWRAP(level_end_override);
|
||||
LMD_UNWRAP(edge_types_override);
|
||||
LMD_UNWRAP(shadow_selection_override);
|
||||
LMD_UNWRAP(shadow_use_silhouette_override);
|
||||
LMD_UNWRAP(cache);
|
||||
LMD_UNWRAP(la_data_ptr);
|
||||
|
||||
#undef LMD_UNWRAP
|
||||
}
|
||||
|
||||
} // namespace blender::bke::greasepencil::convert
|
||||
|
||||
@@ -879,11 +879,6 @@ struct GreasePencilLineartModifierData;
|
||||
struct LineartData;
|
||||
struct Scene;
|
||||
|
||||
void MOD_lineart_wrap_modifier_v3(const LineartGpencilModifierData *lmd_legacy,
|
||||
GreasePencilLineartModifierData *lmd);
|
||||
void MOD_lineart_unwrap_modifier_v3(LineartGpencilModifierData *lmd_legacy,
|
||||
const GreasePencilLineartModifierData *lmd);
|
||||
|
||||
void MOD_lineart_destroy_render_data(struct LineartGpencilModifierData *lmd_legacy);
|
||||
void MOD_lineart_destroy_render_data_v3(struct GreasePencilLineartModifierData *lmd);
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "BKE_gpencil_legacy.h"
|
||||
#include "BKE_gpencil_modifier_legacy.h"
|
||||
#include "BKE_grease_pencil.hh"
|
||||
#include "BKE_grease_pencil_legacy_convert.hh"
|
||||
#include "BKE_lib_id.hh"
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_mesh.hh"
|
||||
@@ -3558,100 +3559,6 @@ static void lineart_destroy_render_data(LineartData *ld)
|
||||
lineart_mem_destroy(&ld->render_data_pool);
|
||||
}
|
||||
|
||||
void MOD_lineart_wrap_modifier_v3(const LineartGpencilModifierData *lmd_legacy,
|
||||
GreasePencilLineartModifierData *lmd)
|
||||
{
|
||||
#define LMD_WRAP(var) lmd->var = lmd_legacy->var
|
||||
|
||||
LMD_WRAP(edge_types);
|
||||
LMD_WRAP(source_type);
|
||||
LMD_WRAP(use_multiple_levels);
|
||||
LMD_WRAP(level_start);
|
||||
LMD_WRAP(level_end);
|
||||
LMD_WRAP(source_camera);
|
||||
LMD_WRAP(light_contour_object);
|
||||
LMD_WRAP(source_object);
|
||||
LMD_WRAP(source_collection);
|
||||
LMD_WRAP(target_material);
|
||||
STRNCPY(lmd->source_vertex_group, lmd_legacy->source_vertex_group);
|
||||
STRNCPY(lmd->vgname, lmd_legacy->vgname);
|
||||
LMD_WRAP(overscan);
|
||||
LMD_WRAP(shadow_camera_fov);
|
||||
LMD_WRAP(shadow_camera_size);
|
||||
LMD_WRAP(shadow_camera_near);
|
||||
LMD_WRAP(shadow_camera_far);
|
||||
LMD_WRAP(opacity);
|
||||
LMD_WRAP(thickness);
|
||||
LMD_WRAP(mask_switches);
|
||||
LMD_WRAP(material_mask_bits);
|
||||
LMD_WRAP(intersection_mask);
|
||||
LMD_WRAP(shadow_selection);
|
||||
LMD_WRAP(silhouette_selection);
|
||||
LMD_WRAP(crease_threshold);
|
||||
LMD_WRAP(angle_splitting_threshold);
|
||||
LMD_WRAP(chain_smooth_tolerance);
|
||||
LMD_WRAP(chaining_image_threshold);
|
||||
LMD_WRAP(calculation_flags);
|
||||
LMD_WRAP(flags);
|
||||
LMD_WRAP(stroke_depth_offset);
|
||||
LMD_WRAP(level_start_override);
|
||||
LMD_WRAP(level_end_override);
|
||||
LMD_WRAP(edge_types_override);
|
||||
LMD_WRAP(shadow_selection_override);
|
||||
LMD_WRAP(shadow_use_silhouette_override);
|
||||
LMD_WRAP(cache);
|
||||
LMD_WRAP(la_data_ptr);
|
||||
|
||||
#undef LMD_WRAP
|
||||
}
|
||||
|
||||
void MOD_lineart_unwrap_modifier_v3(LineartGpencilModifierData *lmd_legacy,
|
||||
const GreasePencilLineartModifierData *lmd)
|
||||
{
|
||||
#define LMD_UNWRAP(var) lmd_legacy->var = lmd->var
|
||||
|
||||
LMD_UNWRAP(edge_types);
|
||||
LMD_UNWRAP(source_type);
|
||||
LMD_UNWRAP(use_multiple_levels);
|
||||
LMD_UNWRAP(level_start);
|
||||
LMD_UNWRAP(level_end);
|
||||
LMD_UNWRAP(source_camera);
|
||||
LMD_UNWRAP(light_contour_object);
|
||||
LMD_UNWRAP(source_object);
|
||||
LMD_UNWRAP(source_collection);
|
||||
LMD_UNWRAP(target_material);
|
||||
STRNCPY(lmd_legacy->source_vertex_group, lmd->source_vertex_group);
|
||||
STRNCPY(lmd_legacy->vgname, lmd->vgname);
|
||||
LMD_UNWRAP(overscan);
|
||||
LMD_UNWRAP(shadow_camera_fov);
|
||||
LMD_UNWRAP(shadow_camera_size);
|
||||
LMD_UNWRAP(shadow_camera_near);
|
||||
LMD_UNWRAP(shadow_camera_far);
|
||||
LMD_UNWRAP(opacity);
|
||||
LMD_UNWRAP(thickness);
|
||||
LMD_UNWRAP(mask_switches);
|
||||
LMD_UNWRAP(material_mask_bits);
|
||||
LMD_UNWRAP(intersection_mask);
|
||||
LMD_UNWRAP(shadow_selection);
|
||||
LMD_UNWRAP(silhouette_selection);
|
||||
LMD_UNWRAP(crease_threshold);
|
||||
LMD_UNWRAP(angle_splitting_threshold);
|
||||
LMD_UNWRAP(chain_smooth_tolerance);
|
||||
LMD_UNWRAP(chaining_image_threshold);
|
||||
LMD_UNWRAP(calculation_flags);
|
||||
LMD_UNWRAP(flags);
|
||||
LMD_UNWRAP(stroke_depth_offset);
|
||||
LMD_UNWRAP(level_start_override);
|
||||
LMD_UNWRAP(level_end_override);
|
||||
LMD_UNWRAP(edge_types_override);
|
||||
LMD_UNWRAP(shadow_selection_override);
|
||||
LMD_UNWRAP(shadow_use_silhouette_override);
|
||||
LMD_UNWRAP(cache);
|
||||
LMD_UNWRAP(la_data_ptr);
|
||||
|
||||
#undef LMD_UNWRAP
|
||||
}
|
||||
|
||||
void MOD_lineart_destroy_render_data_v3(GreasePencilLineartModifierData *lmd)
|
||||
{
|
||||
LineartData *ld = lmd->la_data_ptr;
|
||||
@@ -3671,9 +3578,9 @@ void MOD_lineart_destroy_render_data_v3(GreasePencilLineartModifierData *lmd)
|
||||
void MOD_lineart_destroy_render_data(LineartGpencilModifierData *lmd_legacy)
|
||||
{
|
||||
GreasePencilLineartModifierData lmd;
|
||||
MOD_lineart_wrap_modifier_v3(lmd_legacy, &lmd);
|
||||
greasepencil::convert::lineart_wrap_v3(lmd_legacy, &lmd);
|
||||
MOD_lineart_destroy_render_data_v3(&lmd);
|
||||
MOD_lineart_unwrap_modifier_v3(lmd_legacy, &lmd);
|
||||
greasepencil::convert::lineart_unwrap_v3(lmd_legacy, &lmd);
|
||||
}
|
||||
|
||||
LineartCache *MOD_lineart_init_cache()
|
||||
@@ -5325,10 +5232,10 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph,
|
||||
{
|
||||
bool ret = false;
|
||||
GreasePencilLineartModifierData lmd;
|
||||
MOD_lineart_wrap_modifier_v3(lmd_legacy, &lmd);
|
||||
greasepencil::convert::lineart_wrap_v3(lmd_legacy, &lmd);
|
||||
ret = MOD_lineart_compute_feature_lines_v3(
|
||||
depsgraph, lmd, cached_result, enable_stroke_depth_offset);
|
||||
MOD_lineart_unwrap_modifier_v3(lmd_legacy, &lmd);
|
||||
greasepencil::convert::lineart_unwrap_v3(lmd_legacy, &lmd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "BKE_global.hh"
|
||||
#include "BKE_gpencil_modifier_legacy.h"
|
||||
#include "BKE_grease_pencil.hh"
|
||||
#include "BKE_grease_pencil_legacy_convert.hh"
|
||||
#include "BKE_object.hh"
|
||||
|
||||
#include "BLI_math_matrix.h"
|
||||
@@ -1300,7 +1302,7 @@ bool lineart_main_try_generate_shadow(Depsgraph *depsgraph,
|
||||
{
|
||||
bool ret = false;
|
||||
GreasePencilLineartModifierData lmd;
|
||||
MOD_lineart_wrap_modifier_v3(lmd_legacy, &lmd);
|
||||
blender::bke::greasepencil::convert::lineart_wrap_v3(lmd_legacy, &lmd);
|
||||
ret = lineart_main_try_generate_shadow_v3(depsgraph,
|
||||
scene,
|
||||
original_ld,
|
||||
@@ -1310,7 +1312,7 @@ bool lineart_main_try_generate_shadow(Depsgraph *depsgraph,
|
||||
r_eeln,
|
||||
r_calculated_edges_eln_list,
|
||||
r_shadow_ld_if_reproject);
|
||||
MOD_lineart_unwrap_modifier_v3(lmd_legacy, &lmd);
|
||||
blender::bke::greasepencil::convert::lineart_unwrap_v3(lmd_legacy, &lmd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -3066,7 +3066,7 @@ typedef struct GreasePencilLineartModifierData {
|
||||
*
|
||||
* Do not change any of the data below since the layout of these
|
||||
* data is currently shared with the old line art modifier.
|
||||
* See `MOD_lineart_wrap_modifier_v3` for how it works. */
|
||||
* See `BKE_grease_pencil_lineart_wrap_v3` for how it works. */
|
||||
|
||||
uint16_t edge_types; /* line type enable flags, bits in eLineartEdgeFlag */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user