[Bf-blender-cvs] [bb38766ba68] temp-lanpr-review: LANPR: Clipping topology data error fixed.
YimingWu
noreply at git.blender.org
Wed Nov 20 10:23:46 CET 2019
Commit: bb38766ba68cb187ad0b57033402486f4cac0f48
Author: YimingWu
Date: Wed Nov 20 15:01:04 2019 +0800
Branches: temp-lanpr-review
https://developer.blender.org/rBbb38766ba68cb187ad0b57033402486f4cac0f48
LANPR: Clipping topology data error fixed.
Also cleaned up some dead code inside.
===================================================================
M source/blender/editors/include/ED_lanpr.h
M source/blender/editors/lanpr/lanpr_chain.c
M source/blender/editors/lanpr/lanpr_cpu.c
===================================================================
diff --git a/source/blender/editors/include/ED_lanpr.h b/source/blender/editors/include/ED_lanpr.h
index 12470708cd0..14645ef414b 100644
--- a/source/blender/editors/include/ED_lanpr.h
+++ b/source/blender/editors/include/ED_lanpr.h
@@ -461,7 +461,7 @@ BLI_INLINE int lanpr_LineIntersectTest2d(
double x;
double y;
double Ratio;
- double xDiff = (a2[0] - a1[0]); /* +DBL_EPSILON; */
+ double xDiff = (a2[0] - a1[0]);
double xDiff2 = (b2[0] - b1[0]);
if (xDiff == 0) {
diff --git a/source/blender/editors/lanpr/lanpr_chain.c b/source/blender/editors/lanpr/lanpr_chain.c
index b863ddac884..19db3c6228f 100644
--- a/source/blender/editors/lanpr/lanpr_chain.c
+++ b/source/blender/editors/lanpr/lanpr_chain.c
@@ -579,12 +579,6 @@ static void lanpr_connect_two_chains(LANPR_RenderBuffer *UNUSED(rb),
((LANPR_RenderLineChainItem *)onto->chain.first)->prev = sub->chain.last;
onto->chain.first = sub->chain.first;
}
- /* ((LANPR_RenderLineChainItem*)sub->chain.first)->occlusion = */
- /* ((LANPR_RenderLineChainItem*)onto->chain.first)->occlusion; */
- /* ((LANPR_RenderLineChainItem*)onto->chain.last)->occlusion = */
- /* ((LANPR_RenderLineChainItem*)onto->chain.first)->occlusion; */
- /* ((LANPR_RenderLineChainItem*)sub->chain.last)->occlusion = */
- /* ((LANPR_RenderLineChainItem*)onto->chain.first)->occlusion; */
}
/* this only does head-tail connection. */
@@ -748,11 +742,11 @@ void ED_lanpr_discard_short_chains(LANPR_RenderBuffer *rb, float threshold)
int ED_lanpr_count_chain(LANPR_RenderLineChain *rlc)
{
LANPR_RenderLineChainItem *rlci;
- int Count = 0;
+ int count = 0;
for (rlci = rlc->chain.first; rlci; rlci = rlci->next) {
- Count++;
+ count++;
}
- return Count;
+ return count;
}
void ED_lanpr_chain_clear_picked_flag(LANPR_RenderBuffer *rb)
diff --git a/source/blender/editors/lanpr/lanpr_cpu.c b/source/blender/editors/lanpr/lanpr_cpu.c
index bee023be3d2..c843c06fe1f 100644
--- a/source/blender/editors/lanpr/lanpr_cpu.c
+++ b/source/blender/editors/lanpr/lanpr_cpu.c
@@ -70,7 +70,6 @@
extern LANPR_SharedResource lanpr_share;
extern const char *RE_engine_id_BLENDER_LANPR;
-struct Object;
/* Own functions */
@@ -172,7 +171,7 @@ LANPR_LineLayerComponent *ED_lanpr_new_line_component(SceneLANPR *lanpr)
return llc;
}
-static int lanpr_add_line_layer_exec(struct bContext *C, struct wmOperator *UNUSED(op))
+static int lanpr_add_line_layer_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
SceneLANPR *lanpr = &scene->lanpr;
@@ -185,7 +184,7 @@ static int lanpr_add_line_layer_exec(struct bContext *C, struct wmOperator *UNUS
return OPERATOR_FINISHED;
}
-static int lanpr_delete_line_layer_exec(struct bContext *C, struct wmOperator *UNUSED(op))
+static int lanpr_delete_line_layer_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
SceneLANPR *lanpr = &scene->lanpr;
@@ -216,7 +215,7 @@ static int lanpr_delete_line_layer_exec(struct bContext *C, struct wmOperator *U
return OPERATOR_FINISHED;
}
-static int lanpr_move_line_layer_exec(struct bContext *C, struct wmOperator *op)
+static int lanpr_move_line_layer_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
SceneLANPR *lanpr = &scene->lanpr;
@@ -244,7 +243,7 @@ static int lanpr_move_line_layer_exec(struct bContext *C, struct wmOperator *op)
return OPERATOR_FINISHED;
}
-static int lanpr_add_line_component_exec(struct bContext *C, struct wmOperator *UNUSED(op))
+static int lanpr_add_line_component_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
SceneLANPR *lanpr = &scene->lanpr;
@@ -253,7 +252,7 @@ static int lanpr_add_line_component_exec(struct bContext *C, struct wmOperator *
return OPERATOR_FINISHED;
}
-static int lanpr_delete_line_component_exec(struct bContext *C, struct wmOperator *op)
+static int lanpr_delete_line_component_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
SceneLANPR *lanpr = &scene->lanpr;
@@ -282,7 +281,7 @@ static int lanpr_delete_line_component_exec(struct bContext *C, struct wmOperato
return OPERATOR_FINISHED;
}
-static int ED_lanpr_rebuild_all_commands_exec(struct bContext *C, struct wmOperator *UNUSED(op))
+static int ED_lanpr_rebuild_all_commands_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
SceneLANPR *lanpr = &scene->lanpr;
@@ -295,7 +294,7 @@ static int ED_lanpr_rebuild_all_commands_exec(struct bContext *C, struct wmOpera
return OPERATOR_FINISHED;
}
-static int lanpr_enable_all_line_types_exec(struct bContext *C, struct wmOperator *UNUSED(op))
+static int lanpr_enable_all_line_types_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
SceneLANPR *lanpr = &scene->lanpr;
@@ -325,7 +324,7 @@ static int lanpr_enable_all_line_types_exec(struct bContext *C, struct wmOperato
return OPERATOR_FINISHED;
}
-static int lanpr_auto_create_line_layer_exec(struct bContext *C, struct wmOperator *op)
+static int lanpr_auto_create_line_layer_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
SceneLANPR *lanpr = &scene->lanpr;
@@ -354,7 +353,7 @@ static int lanpr_auto_create_line_layer_exec(struct bContext *C, struct wmOperat
return OPERATOR_FINISHED;
}
-void SCENE_OT_lanpr_add_line_layer(struct wmOperatorType *ot)
+void SCENE_OT_lanpr_add_line_layer(wmOperatorType *ot)
{
ot->name = "Add Line Layer";
@@ -363,7 +362,7 @@ void SCENE_OT_lanpr_add_line_layer(struct wmOperatorType *ot)
ot->exec = lanpr_add_line_layer_exec;
}
-void SCENE_OT_lanpr_delete_line_layer(struct wmOperatorType *ot)
+void SCENE_OT_lanpr_delete_line_layer(wmOperatorType *ot)
{
ot->name = "Delete Line Layer";
@@ -372,7 +371,7 @@ void SCENE_OT_lanpr_delete_line_layer(struct wmOperatorType *ot)
ot->exec = lanpr_delete_line_layer_exec;
}
-void SCENE_OT_lanpr_rebuild_all_commands(struct wmOperatorType *ot)
+void SCENE_OT_lanpr_rebuild_all_commands(wmOperatorType *ot)
{
ot->name = "Refresh Drawing Commands";
@@ -381,7 +380,7 @@ void SCENE_OT_lanpr_rebuild_all_commands(struct wmOperatorType *ot)
ot->exec = ED_lanpr_rebuild_all_commands_exec;
}
-void SCENE_OT_lanpr_auto_create_line_layer(struct wmOperatorType *ot)
+void SCENE_OT_lanpr_auto_create_line_layer(wmOperatorType *ot)
{
ot->name = "Auto Create Line Layer";
@@ -390,7 +389,7 @@ void SCENE_OT_lanpr_auto_create_line_layer(struct wmOperatorType *ot)
ot->exec = lanpr_auto_create_line_layer_exec;
}
-void SCENE_OT_lanpr_move_line_layer(struct wmOperatorType *ot)
+void SCENE_OT_lanpr_move_line_layer(wmOperatorType *ot)
{
static const EnumPropertyItem line_layer_move[] = {
{1, "UP", 0, "Up", ""}, {-1, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL}};
@@ -410,7 +409,7 @@ void SCENE_OT_lanpr_move_line_layer(struct wmOperatorType *ot)
"Direction",
"Direction to move the active line layer towards");
}
-void SCENE_OT_lanpr_enable_all_line_types(struct wmOperatorType *ot)
+void SCENE_OT_lanpr_enable_all_line_types(wmOperatorType *ot)
{
ot->name = "Enable All Line Types";
ot->description = "Enable All Line Types In This Line Layer";
@@ -418,7 +417,7 @@ void SCENE_OT_lanpr_enable_all_line_types(struct wmOperatorType *ot)
ot->exec = lanpr_enable_all_line_types_exec;
}
-void SCENE_OT_lanpr_add_line_component(struct wmOperatorType *ot)
+void SCENE_OT_lanpr_add_line_component(wmOperatorType *ot)
{
ot->name = "Add Line Component";
@@ -427,7 +426,7 @@ void SCENE_OT_lanpr_add_line_component(struct wmOperatorType *ot)
ot->exec = lanpr_add_line_component_exec;
}
-void SCENE_OT_lanpr_delete_line_component(struct wmOperatorType *ot)
+void SCENE_OT_lanpr_delete_line_component(wmOperatorType *ot)
{
ot->name = "Delete Line Component";
@@ -893,42 +892,31 @@ static int lanpr_point_inside_triangle3de(tnsVector3d v,
sub_v3_v3v3_db(l, v1, v0);
sub_v3_v3v3_db(r, v, v1);
- /* tmat_normalize_self_3d(l); */
- /* tmat_normalize_self_3d(r); */
cross_v3_v3v3_db(N1, l, r);
sub_v3_v3v3_db(l, v2, v1);
sub_v3_v3v3_db(r, v, v2);
- /* tmat_normalize_self_3d(l); */
- /* tmat_normalize_self_3d(r); */
cross_v3_v3v3_db(N2, l, r);
if ((d = dot_v3v3_db(N1, N2)) < 0) {
return 0;
}
- /* if (d<DBL_EPSILON) return -1; */
sub_v3_v3v3_db(l, v0, v2);
sub_v3_v3v3_db(r, v, v0);
- /* tmat_normalize_self_3d(l); */
- /* tmat_normalize_self_3d(r); */
cross_v3_v3v3_db(N1, l, r);
if ((d = dot_v3v3_db(N1, N2)) < 0) {
return 0;
}
- /* if (d<DBL_EPSILON) return -1; */
sub_v3_v3v3_db(l, v1, v0);
sub_v3_v3v3_db(r, v, v1);
- /* tmat_normalize_self_3d(l); */
- /* tmat_normalize_self_3d(r); */
cross_v3_v3v3_db(N2, l, r);
if ((d = dot_v3v3_db(N1, N2)) < 0) {
return 0;
}
- /* if (d<DBL_EPSILON) return -1; */
return 1;
}
@@ -1008,6 +996,11 @@ static void lanpr_post_triangle(LANPR_RenderTriangle *rt, LANPR_RenderTriangle *
#define RT_AT(head, rb, offset) ((unsigned char *)head + offset * rb->triangle_size)
+
+/** This function cuts triangles that are (partially or fully) behind near clipping plane.
+ * for triangles that crossing the near plane, it will generate new 1 or 2 triangles with
+ * new topology that represents the trimmed triangle. (which then became a triangle or square)
+*/
static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
{
LANPR_RenderLine *rl;
@@ -1052,52 +1045,57 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
}
o = reln->object_ref;
for (i = 0; i < reln->element_count; i++) {
- int In1 = 0, In2 = 0, In3 = 0;
+
+ /* These three represents points that are in the clipping range or not*/
+ int in0 = 0, in1 = 0, in2 = 0;
+
+ /* Select the triangle in the array. */
rt = (void *)(((unsigned char *)reln->pointer) + rb->triangle_size * i);
+#ifdef DEBUG
+ /* Debug purpose */
printf("z%f w%f z%f w%f z%f w%f\n",
rt->v[0]->fbcoord[2], rt->v[0]->fbcoord[1],
rt->v[1]->fbcoord[2], rt->v[1]->fbcoord[1],
rt->v[2]->fbcoord[2], rt->v[2]->fbco
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list