[Bf-blender-cvs] [ac344bd027d] lineart-shadow: Merge branch 'temp-lineart-contained' into lineart-shadow
YimingWu
noreply at git.blender.org
Mon May 23 10:22:07 CEST 2022
Commit: ac344bd027da00d39fc610bb0a04ca231e2e499a
Author: YimingWu
Date: Mon May 23 14:27:26 2022 +0800
Branches: lineart-shadow
https://developer.blender.org/rBac344bd027da00d39fc610bb0a04ca231e2e499a
Merge branch 'temp-lineart-contained' into lineart-shadow
===================================================================
===================================================================
diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index ee7c82311d8,3abff68fcd5..1db17f810da
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@@ -134,10 -124,21 +126,23 @@@ static bool lineart_triangle_edge_image
static void lineart_add_edge_to_array(LineartPendingEdges *pe, LineartEdge *e);
+ static void lineart_bounding_area_link_triangle_cas(LineartRenderBuffer *rb,
+ LineartBoundingArea *root_ba,
+ LineartTriangle *tri,
+ double *LRUB,
+ int recursive,
+ int recursive_level,
+ bool do_intersection,
+ struct LineartIsecThread *th);
+
+ static void lineart_free_bounding_area_memory(LineartBoundingArea *ba, bool recursive);
+
+ static void lineart_free_bounding_area_memories(LineartRenderBuffer *rb);
+
static LineartCache *lineart_init_cache(void);
+static void lineart_clear_linked_edges(LineartRenderBuffer *rb);
+
static void lineart_discard_segment(LineartRenderBuffer *rb, LineartEdgeSegment *es)
{
BLI_spin_lock(&rb->lock_cuts);
@@@ -2273,14 -2129,8 +2268,14 @@@ static void lineart_geometry_object_loa
BLI_spin_unlock(&re_buf->lock_task);
elem_link_node->element_count = allocate_la_e;
elem_link_node->object_ref = orig_ob;
+ elem_link_node->obindex = ob_info->obindex;
+
+ LineartElementLinkNode *shadow_eln = NULL;
+ if (shadow_elns) {
+ shadow_eln = lineart_find_matching_eln(shadow_elns, ob_info->obindex);
+ }
- // Start of the edge/seg arr
+ /* Start of the edge/seg arr */
LineartEdge *la_edge;
LineartEdgeSegment *la_seg;
la_edge = la_edge_arr;
@@@ -2560,17 -2373,17 +2555,21 @@@ static void lineart_object_load_single_
float use_mat[4][4],
bool is_render,
LineartObjectLoadTaskInfo *olti,
-- int thread_count)
++ int thread_count,
++ int obindex)
{
LineartObjectInfo *obi = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartObjectInfo));
obi->usage = lineart_usage_check(scene->master_collection, ob, is_render);
obi->override_intersection_mask = lineart_intersection_mask_check(scene->master_collection, ob);
++ obi->silhouette_group = lineart_silhouette_group_check(scene->master_collection, ob);
Mesh *use_mesh;
if (obi->usage == OBJECT_LRT_EXCLUDE) {
return;
}
++ obi->obindex = obindex << LRT_OBINDEX_SHIFT;
++
/* Prepare the matrix used for transforming this specific object (instance). This has to be
* done before mesh boundbox check because the function needs that. */
mul_m4db_m4db_m4fl_uniq(obi->model_view_proj, rb->view_projection, use_mat);
@@@ -2672,6 -2482,6 +2671,10 @@@ static void lineart_main_load_geometrie
bool is_render = eval_mode == DAG_EVAL_RENDER;
FOREACH_SCENE_OBJECT_BEGIN (scene, ob) {
++ /* Do the increment even for discarded objects, so that in different culling conditions we can
++ * get the same reference to the same object. */
++ obindex++;
++
Object *eval_ob = DEG_get_evaluated_object(depsgraph, ob);
if (!eval_ob) {
@@@ -2679,17 -2489,17 +2682,34 @@@
}
if (BKE_object_visibility(eval_ob, eval_mode) & OB_VISIBLE_SELF) {
-- lineart_object_load_single_instance(
-- rb, depsgraph, scene, eval_ob, eval_ob, eval_ob->obmat, is_render, olti, thread_count);
++ lineart_object_load_single_instance(rb,
++ depsgraph,
++ scene,
++ eval_ob,
++ eval_ob,
++ eval_ob->obmat,
++ is_render,
++ olti,
++ thread_count,
++ obindex);
}
if (allow_duplicates) {
ListBase *dupli = object_duplilist(depsgraph, scene, eval_ob);
LISTBASE_FOREACH (DupliObject *, dob, dupli) {
++ obindex++;
if (BKE_object_visibility(eval_ob, eval_mode) &
(OB_VISIBLE_PARTICLES | OB_VISIBLE_INSTANCES)) {
Object *ob_ref = (dob->type & OB_DUPLIPARTS) ? eval_ob : dob->ob;
-- lineart_object_load_single_instance(
-- rb, depsgraph, scene, dob->ob, ob_ref, dob->mat, is_render, olti, thread_count);
++ lineart_object_load_single_instance(rb,
++ depsgraph,
++ scene,
++ dob->ob,
++ ob_ref,
++ dob->mat,
++ is_render,
++ olti,
++ thread_count,
++ obindex);
}
}
free_object_duplilist(dupli);
@@@ -3561,21 -3344,14 +3587,24 @@@ static void lineart_destroy_render_data
for (int i = 0; i < rb->bounding_area_initial_count; i++) {
lineart_end_bounding_area_recursive(&rb->initial_bounding_areas[i]);
}
++ lineart_free_bounding_area_memories(rb);
- if (rb->pending_edges.array) {
- MEM_freeN(rb->pending_edges.array);
+ lineart_mem_destroy(&rb->render_data_pool);
+}
+
+static void lineart_destroy_render_data(LineartRenderBuffer *rb)
+{
+ if (rb == NULL) {
+ return;
}
- lineart_free_bounding_area_memories(rb);
+ BLI_spin_end(&rb->lock_task);
+ BLI_spin_end(&rb->lock_cuts);
+ BLI_spin_end(&rb->render_data_pool.lock_mem);
+
+ lineart_destroy_render_data_keep_init(rb);
+
+ lineart_mem_destroy(&rb->render_data_pool);
}
void MOD_lineart_destroy_render_data(LineartGpencilModifierData *lmd)
@@@ -4260,31 -4078,6 +4340,32 @@@ static void lineart_bounding_area_link_
}
}
+static void lineart_clear_linked_edges_recursive(LineartRenderBuffer *rb,
+ LineartBoundingArea *root_ba)
+{
+ if (root_ba->child) {
+ for (int i = 0; i < 4; i++) {
+ lineart_clear_linked_edges_recursive(rb, &root_ba->child[i]);
+ }
+ }
- else {
- root_ba->line_count = 0;
- root_ba->max_line_count = 128;
- root_ba->linked_lines = lineart_mem_acquire(&rb->render_data_pool,
- sizeof(LineartEdge *) * root_ba->max_line_count);
++ if (root_ba->linked_lines) {
++ MEM_freeN(root_ba->linked_lines);
+ }
++ root_ba->line_count = 0;
++ root_ba->max_line_count = 128;
++ root_ba->linked_lines = MEM_callocN(sizeof(LineartEdge *) * root_ba->max_line_count,
++ "cleared lineart edges");
+}
+static void lineart_clear_linked_edges(LineartRenderBuffer *rb)
+{
+ LineartBoundingArea *ba = rb->initial_bounding_areas;
- for (int i = 0; i < rb->tile_count_x; i++) {
++ for (int i = 0; i < rb->tile_count_y; i++) {
+ for (int j = 0; j < rb->tile_count_x; j++) {
- lineart_clear_linked_edges_recursive(rb, &ba[i * LRT_BA_ROWS + j]);
++ lineart_clear_linked_edges_recursive(rb, &ba[i * rb->tile_count_x + j]);
+ }
+ }
+}
+
/**
* Link lines to their respective bounding areas.
*/
@@@ -4529,47 -4324,31 +4613,31 @@@ static void lineart_create_edges_from_i
if (!th->current) {
continue;
}
- total_lines += th->current;
- }
-
- if (!total_lines) {
- return;
- }
-
- /* We don't care about removing duplicated vert in this method, chaning can handle that,
- * and it saves us from using locks and look up tables. */
- LineartVert *v = lineart_mem_acquire(rb->edge_data_pool, sizeof(LineartVert) * total_lines * 2);
- LineartEdge *e = lineart_mem_acquire(rb->edge_data_pool, sizeof(LineartEdge) * total_lines);
- LineartEdgeSegment *es = lineart_mem_acquire(rb->edge_data_pool,
- sizeof(LineartEdgeSegment) * total_lines);
-
- LineartElementLinkNode *eln = lineart_mem_acquire(rb->edge_data_pool,
- sizeof(LineartElementLinkNode));
- eln->element_count = total_lines;
- eln->pointer = e;
- eln->flags |= LRT_ELEMENT_INTERSECTION_DATA;
- BLI_addhead(&rb->line_buffer_pointers, eln);
-
- for (int i = 0; i < d->thread_count; i++) {
- LineartIsecThread *th = &d->threads[i];
- if (!th->current) {
- continue;
- }
+ /* We don't care about removing duplicated vert in this method, chaning can handle that, and it
+ * saves us from using locks and look up tables. */
+ LineartVertIntersection *v = lineart_mem_acquire(
+ &rb->render_data_pool, sizeof(LineartVertIntersection) * th->current * 2);
+ LineartEdge *e = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartEdge) * th->current);
+ LineartEdgeSegment *es = lineart_mem_acquire(&rb->render_data_pool,
+ sizeof(LineartEdgeSegment) * th->current);
for (int j = 0; j < th->current; j++) {
- LineartVert *v1 = v;
- LineartVert *v2 = v + 1;
+ LineartVertIntersection *v1i = v;
+ LineartVertIntersection *v2i = v + 1;
LineartIsecSingle *is = &th->array[j];
+ v1i->intersecting_with = is->tri1;
+ v2i->intersecting_with = is->tri2;
+ LineartVert *v1 = (LineartVert *)v1i;
+ LineartVert *v2 = (LineartVert *)v2i;
+ v1->flag |= LRT_VERT_HAS_INTERSECTI
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list