[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18040] branches/blender2.5/blender: 2. 5 - node editor
Nathan Letwory
jesterking at letwory.net
Wed Dec 24 11:33:13 CET 2008
Revision: 18040
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18040
Author: jesterking
Date: 2008-12-24 11:33:10 +0100 (Wed, 24 Dec 2008)
Log Message:
-----------
2.5 - node editor
Commit of WIP code (what code isn't wip, these days ;)
- only drawing code as basis to work further from (and have less conflicts between different systems I work on)
Modified Paths:
--------------
branches/blender2.5/blender/config/win32-vc-config.py
branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h
branches/blender2.5/blender/source/blender/editors/screen/glutil.c
branches/blender2.5/blender/source/blender/editors/space_node/node_header.c
branches/blender2.5/blender/source/blender/editors/space_node/node_intern.h
branches/blender2.5/blender/source/blender/editors/space_node/space_node.c
Added Paths:
-----------
branches/blender2.5/blender/source/blender/editors/space_node/drawnode.c
branches/blender2.5/blender/source/blender/editors/space_node/node_draw.c
branches/blender2.5/blender/source/blender/editors/space_node/node_edit.c
Modified: branches/blender2.5/blender/config/win32-vc-config.py
===================================================================
--- branches/blender2.5/blender/config/win32-vc-config.py 2008-12-24 10:13:11 UTC (rev 18039)
+++ branches/blender2.5/blender/config/win32-vc-config.py 2008-12-24 10:33:10 UTC (rev 18040)
@@ -167,7 +167,7 @@
CC = 'cl.exe'
CXX = 'cl.exe'
-CCFLAGS = ['/nologo', '/Ob1', '/J', '/W3', '/Gd', '/MT']
+CCFLAGS = ['/nologo', '/Ob1', '/J', '/W4', '/Gd', '/MT']
CXXFLAGS = ['/EHsc']
BF_DEBUG_CCFLAGS = ['/Zi', '/FR${TARGET}.sbr']
Modified: branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h 2008-12-24 10:13:11 UTC (rev 18039)
+++ branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h 2008-12-24 10:33:10 UTC (rev 18040)
@@ -31,6 +31,7 @@
struct rcti;
struct rctf;
+void fdrawbezier(float vec[4][3]);
void fdrawline(float x1, float y1, float x2, float y2);
void fdrawbox(float x1, float y1, float x2, float y2);
void sdrawline(short x1, short y1, short x2, short y2);
Modified: branches/blender2.5/blender/source/blender/editors/screen/glutil.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/glutil.c 2008-12-24 10:13:11 UTC (rev 18039)
+++ branches/blender2.5/blender/source/blender/editors/screen/glutil.c 2008-12-24 10:33:10 UTC (rev 18040)
@@ -49,6 +49,34 @@
/* ******************************************** */
+void fdrawbezier(float vec[4][3])
+{
+ float dist;
+ float curve_res = 24, spline_step = 0.0f;
+
+ dist= 0.5f*ABS(vec[0][0] - vec[3][0]);
+
+ /* check direction later, for top sockets */
+ vec[1][0]= vec[0][0]+dist;
+ vec[1][1]= vec[0][1];
+
+ vec[2][0]= vec[3][0]-dist;
+ vec[2][1]= vec[3][1];
+ /* we can reuse the dist variable here to increment the GL curve eval amount*/
+ dist = 1.0f/curve_res;
+
+ cpack(0x0);
+ glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]);
+ glBegin(GL_LINE_STRIP);
+ while (spline_step < 1.000001f) {
+ /*if(do_shaded)
+ UI_ThemeColorBlend(th_col1, th_col2, spline_step);*/
+ glEvalCoord1f(spline_step);
+ spline_step += dist;
+ }
+ glEnd();
+}
+
void fdrawline(float x1, float y1, float x2, float y2)
{
float v[2];
Copied: branches/blender2.5/blender/source/blender/editors/space_node/drawnode.c (from rev 17971, trunk/blender/source/blender/src/drawnode.c)
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_node/drawnode.c (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/space_node/drawnode.c 2008-12-24 10:33:10 UTC (rev 18040)
@@ -0,0 +1,2759 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): David Millan Escriva, Juho Vepsäläinen
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
+#include "DNA_ID.h"
+#include "DNA_node_types.h"
+#include "DNA_image_types.h"
+#include "DNA_material_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_action_types.h"
+#include "DNA_color_types.h"
+#include "DNA_customdata_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_space_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_text_types.h"
+#include "DNA_userdef_types.h"
+
+#include "BKE_global.h"
+#include "BKE_image.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_material.h"
+#include "BKE_node.h"
+#include "BKE_object.h"
+#include "BKE_texture.h"
+#include "BKE_text.h"
+#include "BKE_utildefines.h"
+
+#include "CMP_node.h"
+#include "SHD_node.h"
+
+/* #include "BDR_gpencil.h" XXX */
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+/*
+#include "BIF_drawgpencil.h"
+#include "BIF_interface.h"
+#include "BIF_interface_icons.h"
+#include "BIF_language.h"
+#include "BIF_mywindow.h"
+#include "BIF_previewrender.h"
+#include "BIF_resources.h"
+#include "BIF_screen.h"
+#include "BIF_space.h"
+*/
+
+/* XXX
+#include "BSE_drawipo.h"
+#include "BSE_node.h"
+#include "BSE_view.h"
+*/
+
+
+#include "BMF_Api.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "UI_text.h"
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+/*
+#include "RE_pipeline.h"
+#include "IMB_imbuf_types.h"*/
+
+/*#include "blendef.h"
+#include "butspace.h"*/
+/*#include "interface.h"*/ /* urm... for rasterpos_safe, roundbox */
+/*#include "mydevice.h"*/
+#if 0
+//extern void autocomplete_uv(char *str, void *arg_v);
+extern int verify_valid_uv_name(char *str);
+
+/* autocomplete callback for buttons */
+static void autocomplete_vcol(char *str, void *arg_v)
+{
+ Mesh *me;
+ CustomDataLayer *layer;
+ AutoComplete *autocpl;
+ int a;
+
+ if(str[0]==0)
+ return;
+
+ autocpl= autocomplete_begin(str, 32);
+
+ /* search if str matches the beginning of name */
+ for(me= G.main->mesh.first; me; me=me->id.next)
+ for(a=0, layer= me->fdata.layers; a<me->fdata.totlayer; a++, layer++)
+ if(layer->type == CD_MCOL)
+ autocomplete_do_name(autocpl, layer->name);
+
+ autocomplete_end(autocpl, str);
+}
+
+static int verify_valid_vcol_name(char *str)
+{
+ Mesh *me;
+ CustomDataLayer *layer;
+ int a;
+
+ if(str[0]==0)
+ return 1;
+
+ /* search if str matches the name */
+ for(me= G.main->mesh.first; me; me=me->id.next)
+ for(a=0, layer= me->fdata.layers; a<me->fdata.totlayer; a++, layer++)
+ if(layer->type == CD_MCOL)
+ if(strcmp(layer->name, str)==0)
+ return 1;
+
+ return 0;
+}
+
+static void snode_drawstring(SpaceNode *snode, char *str, int okwidth)
+{
+ char drawstr[NODE_MAXSTR];
+ int width;
+
+ if(str[0]==0 || okwidth<4) return;
+
+ BLI_strncpy(drawstr, str, NODE_MAXSTR);
+ width= snode->aspect*UI_GetStringWidth(snode->curfont, drawstr, 0);
+
+ if(width > okwidth) {
+ int len= strlen(drawstr)-1;
+
+ while(width > okwidth && len>=0) {
+ drawstr[len]= 0;
+
+ width= snode->aspect*UI_GetStringWidth(snode->curfont, drawstr, 0);
+ len--;
+ }
+ if(len==0) return;
+ }
+ UI_DrawString(snode->curfont, drawstr, 0);
+
+}
+
+/* ****************** GENERAL CALLBACKS FOR NODES ***************** */
+
+static void node_ID_title_cb(void *node_v, void *unused_v)
+{
+ bNode *node= node_v;
+
+ if(node->id) {
+ test_idbutton(node->id->name+2); /* library.c, verifies unique name */
+ BLI_strncpy(node->name, node->id->name+2, 21);
+
+ // allqueue(REDRAWBUTSSHADING, 0);
+ // allqueue(REDRAWNODE, 0);
+ // allqueue(REDRAWOOPS, 0);
+ }
+}
+
+
+static void node_but_title_cb(void *node_v, void *but_v)
+{
+ bNode *node= node_v;
+ struct uiBut *bt= but_v;
+ BLI_strncpy(node->name, bt->drawstr, NODE_MAXSTR);
+
+ // allqueue(REDRAWNODE, 0);
+}
+
+static void node_group_alone_cb(void *node_v, void *unused_v)
+{
+ bNode *node= node_v;
+
+ nodeCopyGroup(node);
+
+ // allqueue(REDRAWNODE, 0);
+}
+
+/* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */
+
+static int node_buts_group(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
+{
+ if(block && node->id) {
+ uiBut *bt;
+ short width;
+
+ uiBlockBeginAlign(block);
+
+ /* name button */
+ width= (short)(butr->xmax-butr->xmin - (node->id->us>1?19.0f:0.0f));
+ bt= uiDefBut(block, TEX, B_NOP, "NT:",
+ butr->xmin, butr->ymin, width, 19,
+ node->id->name+2, 0.0, 19.0, 0, 0, "NodeTree name");
+ uiButSetFunc(bt, node_ID_title_cb, node, NULL);
+
+ /* user amount */
+ if(node->id->us>1) {
+ char str1[32];
+ sprintf(str1, "%d", node->id->us);
+ bt= uiDefBut(block, BUT, B_NOP, str1,
+ butr->xmax-19, butr->ymin, 19, 19,
+ NULL, 0, 0, 0, 0, "Displays number of users.");
+ uiButSetFunc(bt, node_group_alone_cb, node, NULL);
+ }
+
+ uiBlockEndAlign(block);
+ }
+ return 19;
+}
+
+static int node_buts_value(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
+{
+ if(block) {
+ bNodeSocket *sock= node->outputs.first; /* first socket stores value */
+
+ uiDefButF(block, NUM, B_NODE_EXEC+node->nr, "",
+ butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20,
+ sock->ns.vec, sock->ns.min, sock->ns.max, 10, 2, "");
+
+ }
+ return 20;
+}
+
+static int node_buts_rgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
+{
+ if(block) {
+ bNodeSocket *sock= node->outputs.first; /* first socket stores value */
+ if(sock) {
+ /* enforce square box drawing */
+ uiBlockSetEmboss(block, UI_EMBOSSP);
+
+ uiDefButF(block, HSVCUBE, B_NODE_EXEC+node->nr, "",
+ butr->xmin, butr->ymin, butr->xmax-butr->xmin, 12,
+ sock->ns.vec, 0.0f, 1.0f, 3, 0, "");
+ uiDefButF(block, HSVCUBE, B_NODE_EXEC+node->nr, "",
+ butr->xmin, butr->ymin+15, butr->xmax-butr->xmin, butr->ymax-butr->ymin -15 -15,
+ sock->ns.vec, 0.0f, 1.0f, 2, 0, "");
+ uiDefButF(block, COL, B_NOP, "",
+ butr->xmin, butr->ymax-12, butr->xmax-butr->xmin, 12,
+ sock->ns.vec, 0.0, 0.0, -1, 0, "");
+ /* the -1 above prevents col button to popup a color picker */
+
+ uiBlockSetEmboss(block, UI_EMBOSS);
+ }
+ }
+ return 30 + (int)(node->width-NODE_DY);
+}
+
+static int node_buts_mix_rgb(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
+{
+ if(block) {
+ uiBut *bt;
+ int a_but= (ntree->type==NTREE_COMPOSIT);
+
+ /* blend type */
+ uiBlockBeginAlign(block);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list