Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-05-03 13:51:53 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-05-03 13:54:59 +0400
commitb7f085d9c128f31d576c732c6439b5a71e8922ee (patch)
tree8a1fdc2e95470f61d9121b18b125dc272e87d536 /source/blender/blenkernel
parent6ec2d72eca618be05e9bf0723886b10e6d5efa46 (diff)
Patch D246: Texture Marks for freestyle strokes, written and contributed by Paolo Acampora.
Reviewers: brecht, kjym3, #freestyle Reviewed By: brecht, kjym3 Differential Revision: https://developer.blender.org/D246
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_context.h1
-rw-r--r--source/blender/blenkernel/BKE_node.h2
-rw-r--r--source/blender/blenkernel/BKE_texture.h3
-rw-r--r--source/blender/blenkernel/intern/context.c14
-rw-r--r--source/blender/blenkernel/intern/library.c2
-rw-r--r--source/blender/blenkernel/intern/library_query.c14
-rw-r--r--source/blender/blenkernel/intern/linestyle.c30
-rw-r--r--source/blender/blenkernel/intern/node.c8
-rw-r--r--source/blender/blenkernel/intern/texture.c43
9 files changed, 116 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index 877e376b343..e30c8ecee2b 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -234,6 +234,7 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBas
struct Main *CTX_data_main(const bContext *C);
struct Scene *CTX_data_scene(const bContext *C);
struct ToolSettings *CTX_data_tool_settings(const bContext *C);
+struct FreestyleLineStyle *CTX_data_linestyle_from_scene(struct Scene *scene);
const char *CTX_data_mode_string(const bContext *C);
int CTX_data_mode_enum(const bContext *C);
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 1d76cabf78b..13a32ee1528 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -44,6 +44,7 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
+#include "DNA_linestyle_types.h"
#include "RNA_types.h"
@@ -632,6 +633,7 @@ struct NodeTreeIterStore {
Tex *tex;
Lamp *lamp;
World *world;
+ FreestyleLineStyle *linestyle;
};
void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *bmain);
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index c136a30595d..4ad84dceb53 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -41,6 +41,7 @@ struct bNode;
struct Brush;
struct ColorBand;
struct EnvMap;
+struct FreestyleLineStyle;
struct HaloRen;
struct Lamp;
struct LampRen;
@@ -85,6 +86,7 @@ void BKE_texture_make_local(struct Tex *tex);
struct Tex *give_current_object_texture(struct Object *ob);
struct Tex *give_current_material_texture(struct Material *ma);
struct Tex *give_current_lamp_texture(struct Lamp *la);
+struct Tex *give_current_linestyle_texture(struct FreestyleLineStyle *linestyle);
struct Tex *give_current_world_texture(struct World *world);
struct Tex *give_current_brush_texture(struct Brush *br);
struct Tex *give_current_particle_texture(struct ParticleSettings *part);
@@ -98,6 +100,7 @@ void set_current_brush_texture(struct Brush *br, struct Tex *tex);
void set_current_world_texture(struct World *wo, struct Tex *tex);
void set_current_material_texture(struct Material *ma, struct Tex *tex);
void set_current_lamp_texture(struct Lamp *la, struct Tex *tex);
+void set_current_linestyle_texture(struct FreestyleLineStyle *linestyle, struct Tex *tex);
void set_current_particle_texture(struct ParticleSettings *part, struct Tex *tex);
bool has_current_material_texture(struct Material *ma);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index f3ee5c5440c..89ba2e9d68b 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -36,6 +36,7 @@
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_object_types.h"
+#include "DNA_linestyle_types.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
@@ -47,6 +48,7 @@
#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_screen.h"
+#include "BKE_freestyle.h"
#include "RNA_access.h"
@@ -1090,3 +1092,15 @@ int CTX_data_visible_pose_bones(const bContext *C, ListBase *list)
return ctx_data_collection_get(C, "visible_pose_bones", list);
}
+FreestyleLineStyle *CTX_data_linestyle_from_scene(Scene *scene)
+{
+ SceneRenderLayer *actsrl = BLI_findlink(&scene->r.layers, scene->r.actlay);
+ FreestyleConfig *config = &actsrl->freestyleConfig;
+ FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config);
+
+ if (lineset) {
+ return lineset->linestyle;
+ }
+
+ return NULL;
+}
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index a899f81b0d6..6306971a612 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -52,6 +52,7 @@
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
+#include "DNA_linestyle_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
@@ -1364,6 +1365,7 @@ void id_clear_lib_data(Main *bmain, ID *id)
case ID_LA: ntree = ((Lamp *)id)->nodetree; break;
case ID_WO: ntree = ((World *)id)->nodetree; break;
case ID_TE: ntree = ((Tex *)id)->nodetree; break;
+ case ID_LS: ntree = ((FreestyleLineStyle *)id)->nodetree; break;
}
if (ntree)
ntree->id.lib = NULL;
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index b59cc74f69e..e9bdc3679c1 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -39,6 +39,7 @@
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
+#include "DNA_linestyle_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
@@ -450,6 +451,19 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
}
break;
}
+
+ case ID_LS:
+ {
+ FreestyleLineStyle *linestyle = (FreestyleLineStyle *) id;
+ for (i = 0; i < MAX_MTEX; i++) {
+ if (linestyle->mtex[i]) {
+ library_foreach_mtex(&data, linestyle->mtex[i]);
+ }
+ }
+ CALLBACK_INVOKE(linestyle->nodetree, IDWALK_NOP);
+ break;
+ }
+
}
#undef CALLBACK_INVOKE_ID
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 54ae0120c1b..ee55cf72419 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -46,6 +46,7 @@
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_linestyle.h"
+#include "BKE_node.h"
#include "BKE_texture.h"
#include "BKE_colortools.h"
#include "BKE_animsys.h"
@@ -80,7 +81,7 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle)
linestyle->thickness = 3.0f;
linestyle->thickness_position = LS_THICKNESS_CENTER;
linestyle->thickness_ratio = 0.5f;
- linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING;
+ linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING | LS_TEXTURE;
linestyle->chaining = LS_CHAINING_PLAIN;
linestyle->rounds = 3;
linestyle->min_angle = DEG2RADF(0.0f);
@@ -90,6 +91,7 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle)
linestyle->split_length = 100;
linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
linestyle->integration_type = LS_INTEGRATION_MEAN;
+ linestyle->texstep = 1.0f;
BLI_listbase_clear(&linestyle->color_modifiers);
BLI_listbase_clear(&linestyle->alpha_modifiers);
@@ -119,6 +121,19 @@ void BKE_free_linestyle(FreestyleLineStyle *linestyle)
{
LineStyleModifier *m;
+ MTex *mtex;
+ int a;
+
+ for (a = 0; a < MAX_MTEX; a++) {
+ mtex = linestyle->mtex[a];
+ if (mtex && mtex->tex) mtex->tex->id.us--;
+ if (mtex) MEM_freeN(mtex);
+ }
+ if (linestyle->nodetree) {
+ ntreeFreeTree(linestyle->nodetree);
+ MEM_freeN(linestyle->nodetree);
+ }
+
BKE_free_animdata(&linestyle->id);
while ((m = (LineStyleModifier *)linestyle->color_modifiers.first))
BKE_remove_linestyle_color_modifier(linestyle, m);
@@ -134,10 +149,22 @@ FreestyleLineStyle *BKE_copy_linestyle(FreestyleLineStyle *linestyle)
{
FreestyleLineStyle *new_linestyle;
LineStyleModifier *m;
+ int a;
new_linestyle = BKE_new_linestyle(linestyle->id.name + 2, NULL);
BKE_free_linestyle(new_linestyle);
+ for (a = 0; a < MAX_MTEX; a++) {
+ if (linestyle->mtex[a]) {
+ new_linestyle->mtex[a] = MEM_mallocN(sizeof(MTex), "BKE_copy_linestyle");
+ memcpy(new_linestyle->mtex[a], linestyle->mtex[a], sizeof(MTex));
+ id_us_plus((ID *)new_linestyle->mtex[a]->tex);
+ }
+ }
+ if (linestyle->nodetree) {
+ linestyle->nodetree = ntreeCopyTree(linestyle->nodetree);
+ }
+
new_linestyle->r = linestyle->r;
new_linestyle->g = linestyle->g;
new_linestyle->b = linestyle->b;
@@ -167,6 +194,7 @@ FreestyleLineStyle *BKE_copy_linestyle(FreestyleLineStyle *linestyle)
new_linestyle->dash3 = linestyle->dash3;
new_linestyle->gap3 = linestyle->gap3;
new_linestyle->panel = linestyle->panel;
+ new_linestyle->texstep = linestyle->texstep;
for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next)
BKE_copy_linestyle_color_modifier(new_linestyle, m);
for (m = (LineStyleModifier *)linestyle->alpha_modifiers.first; m; m = m->next)
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index db65e8c30d4..38dd36b9e6a 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -44,6 +44,7 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
+#include "DNA_linestyle_types.h"
#include "BLI_string.h"
#include "BLI_math.h"
@@ -1866,6 +1867,7 @@ bNodeTree *ntreeFromID(ID *id)
case ID_WO: return ((World *)id)->nodetree;
case ID_TE: return ((Tex *)id)->nodetree;
case ID_SCE: return ((Scene *)id)->nodetree;
+ case ID_LS: return ((FreestyleLineStyle *)id)->nodetree;
default: return NULL;
}
}
@@ -3661,6 +3663,7 @@ void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *b
ntreeiter->tex = bmain->tex.first;
ntreeiter->lamp = bmain->lamp.first;
ntreeiter->world = bmain->world.first;
+ ntreeiter->linestyle = bmain->linestyle.first;
}
bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
bNodeTree **r_nodetree, struct ID **r_id)
@@ -3695,6 +3698,11 @@ bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
*r_id = (ID *)ntreeiter->world;
ntreeiter->world = ntreeiter->world->id.next;
}
+ else if (ntreeiter->linestyle) {
+ *r_nodetree = ntreeiter->linestyle->nodetree;
+ *r_id = (ID *)ntreeiter->linestyle;
+ ntreeiter->linestyle = ntreeiter->linestyle->id.next;
+ }
else {
return false;
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 75f2fd121dc..3e95da622ac 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -51,6 +51,7 @@
#include "DNA_node_types.h"
#include "DNA_color_types.h"
#include "DNA_particle_types.h"
+#include "DNA_linestyle_types.h"
#include "IMB_imbuf.h"
@@ -999,6 +1000,41 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex)
}
}
+Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle)
+{
+ MTex *mtex = NULL;
+ Tex *tex = NULL;
+
+ if (linestyle) {
+ mtex = linestyle->mtex[(int)(linestyle->texact)];
+ if (mtex) tex = mtex->tex;
+ }
+
+ return tex;
+}
+
+void set_current_linestyle_texture(FreestyleLineStyle *linestyle, Tex *newtex)
+{
+ int act = linestyle->texact;
+
+ if (linestyle->mtex[act] && linestyle->mtex[act]->tex)
+ id_us_min(&linestyle->mtex[act]->tex->id);
+
+ if (newtex) {
+ if (!linestyle->mtex[act]) {
+ linestyle->mtex[act] = add_mtex();
+ linestyle->mtex[act]->texco = TEXCO_STROKE;
+ }
+
+ linestyle->mtex[act]->tex = newtex;
+ id_us_plus(&newtex->id);
+ }
+ else if (linestyle->mtex[act]) {
+ MEM_freeN(linestyle->mtex[act]);
+ linestyle->mtex[act] = NULL;
+ }
+}
+
bNode *give_current_material_texture_node(Material *ma)
{
if (ma && ma->use_nodes && ma->nodetree)
@@ -1048,6 +1084,10 @@ bool give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
*mtex_ar = ((Lamp *)id)->mtex;
if (act) *act = (((Lamp *)id)->texact);
break;
+ case ID_LS:
+ *mtex_ar = ((FreestyleLineStyle *)id)->mtex;
+ if (act) *act = (((FreestyleLineStyle *)id)->texact);
+ break;
case ID_PA:
*mtex_ar = ((ParticleSettings *)id)->mtex;
if (act) *act = (((ParticleSettings *)id)->texact);
@@ -1076,6 +1116,9 @@ void set_active_mtex(ID *id, short act)
case ID_LA:
((Lamp *)id)->texact = act;
break;
+ case ID_LS:
+ ((FreestyleLineStyle *)id)->texact = act;
+ break;
case ID_PA:
((ParticleSettings *)id)->texact = act;
break;