[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38815] branches/soc-2011-onion: Added MyPaint brushlib to extern library directory.

Jason Wilkins Jason.A.Wilkins at gmail.com
Fri Jul 29 12:47:38 CEST 2011


Revision: 38815
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38815
Author:   jwilkins
Date:     2011-07-29 10:47:37 +0000 (Fri, 29 Jul 2011)
Log Message:
-----------
Added MyPaint brushlib to extern library directory.  May not build with scons.  Might only build with MSVC.

Modified Paths:
--------------
    branches/soc-2011-onion/CMakeLists.txt
    branches/soc-2011-onion/extern/CMakeLists.txt
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/CMakeLists.txt
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/SConscript

Added Paths:
-----------
    branches/soc-2011-onion/extern/brushlib/
    branches/soc-2011-onion/extern/brushlib/CMakeLists.txt
    branches/soc-2011-onion/extern/brushlib/COPYING
    branches/soc-2011-onion/extern/brushlib/README
    branches/soc-2011-onion/extern/brushlib/SConscript
    branches/soc-2011-onion/extern/brushlib/__init__.py
    branches/soc-2011-onion/extern/brushlib/brush.hpp
    branches/soc-2011-onion/extern/brushlib/brushlib.hpp
    branches/soc-2011-onion/extern/brushlib/brushsettings.py
    branches/soc-2011-onion/extern/brushlib/generate.py
    branches/soc-2011-onion/extern/brushlib/helpers.hpp
    branches/soc-2011-onion/extern/brushlib/mapping.hpp
    branches/soc-2011-onion/extern/brushlib/surface.hpp
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_brushlib.cpp
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_brushlib.h

Modified: branches/soc-2011-onion/CMakeLists.txt
===================================================================
--- branches/soc-2011-onion/CMakeLists.txt	2011-07-29 07:58:03 UTC (rev 38814)
+++ branches/soc-2011-onion/CMakeLists.txt	2011-07-29 10:47:37 UTC (rev 38815)
@@ -179,13 +179,15 @@
 option(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
 
 # Misc
-option(WITH_RAYOPTIMIZATION	"Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
+option(WITH_RAYOPTIMIZATION "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
 if(UNIX AND NOT APPLE)
 	option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
 endif()
 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
-option(WITH_ONSURFACEBRUSH       "Enable use of the 'on-surface brush' for paint/sculpt.  Requires a stencil buffer, GL_depth_texture, and GLSL" ON)
 
+option(WITH_BRUSHLIB       "Enable MyPaint brushlib for paint/sculpt" ON)
+option(WITH_ONSURFACEBRUSH "Enable use of the 'on-surface brush' for paint/sculpt.  Requires a stencil buffer, GL_depth_texture, and GLSL" ON)
+
 # disable for now, but plan to support on all platforms eventually
 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
 mark_as_advanced(WITH_MEM_JEMALLOC)
@@ -1075,6 +1077,10 @@
 	add_definitions(-DWITH_ONSURFACEBRUSH)
 endif(WITH_ONSURFACEBRUSH)
 
+if(WITH_BRUSHLIB)
+	add_definitions(-DWITH_BRUSHLIB)
+endif(WITH_BRUSHLIB)
+
 if(WITH_IMAGE_OPENJPEG)
 	if(UNIX AND NOT APPLE)
 		# dealt with above

Modified: branches/soc-2011-onion/extern/CMakeLists.txt
===================================================================
--- branches/soc-2011-onion/extern/CMakeLists.txt	2011-07-29 07:58:03 UTC (rev 38814)
+++ branches/soc-2011-onion/extern/CMakeLists.txt	2011-07-29 10:47:37 UTC (rev 38815)
@@ -58,3 +58,7 @@
 if(WITH_LZMA)
 	add_subdirectory(lzma)
 endif()
+
+if(WITH_BRUSHLIB)
+	add_subdirectory(brushlib)
+endif()


Property changes on: branches/soc-2011-onion/extern/brushlib
___________________________________________________________________
Added: bugtraq:number
   + true

Added: branches/soc-2011-onion/extern/brushlib/CMakeLists.txt
===================================================================
--- branches/soc-2011-onion/extern/brushlib/CMakeLists.txt	                        (rev 0)
+++ branches/soc-2011-onion/extern/brushlib/CMakeLists.txt	2011-07-29 10:47:37 UTC (rev 38815)
@@ -0,0 +1,51 @@
+# $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) 2011, Jason Wilkins
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): None
+#
+# ***** END GPL LICENSE BLOCK *****
+
+ADD_CUSTOM_COMMAND(
+	OUTPUT brushsettings.hpp
+	COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/generate.py ${CMAKE_CURRENT_SOURCE_DIR}
+	DEPENDS brushsettings.hpp ${CMAKE_CURRENT_SOURCE_DIR}/generate.py
+	)
+
+set(INC
+)
+
+set(INC_SYS
+	${PYTHON_INCLUDE_DIR}
+)
+
+set(SRC
+	brush.hpp
+	brushlib.hpp
+	helpers.hpp
+	mapping.hpp
+	surface.hpp
+	brushsettings.hpp
+)
+
+blender_add_lib(extern_brushlib "${SRC}" "${INC}" "${INC_SYS}")
+
+SET_TARGET_PROPERTIES(extern_brushlib PROPERTIES LINKER_LANGUAGE CXX)

Added: branches/soc-2011-onion/extern/brushlib/COPYING
===================================================================
--- branches/soc-2011-onion/extern/brushlib/COPYING	                        (rev 0)
+++ branches/soc-2011-onion/extern/brushlib/COPYING	2011-07-29 10:47:37 UTC (rev 38815)
@@ -0,0 +1,14 @@
+brushlib - The MyPaint Brush Library
+Copyright (C) 2008-2011 Martin Renold and contributors
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Added: branches/soc-2011-onion/extern/brushlib/README
===================================================================
--- branches/soc-2011-onion/extern/brushlib/README	                        (rev 0)
+++ branches/soc-2011-onion/extern/brushlib/README	2011-07-29 10:47:37 UTC (rev 38815)
@@ -0,0 +1,7 @@
+brushlib - The MyPaint Brush Library
+
+This is a self-contained C++ library that is isolated from MyPaint.
+
+Documentation can be found in the wiki:
+http://wiki.mypaint.info/Brushlib
+

Added: branches/soc-2011-onion/extern/brushlib/SConscript
===================================================================
--- branches/soc-2011-onion/extern/brushlib/SConscript	                        (rev 0)
+++ branches/soc-2011-onion/extern/brushlib/SConscript	2011-07-29 10:47:37 UTC (rev 38815)
@@ -0,0 +1,5 @@
+Import('env', 'python')
+env.Execute(python + ' generate.py .')
+env.Clean('.', 'brushsettings.hpp')
+env.Clean('.', Glob('*.pyc'))
+

Added: branches/soc-2011-onion/extern/brushlib/__init__.py
===================================================================
Added: branches/soc-2011-onion/extern/brushlib/brush.hpp
===================================================================
--- branches/soc-2011-onion/extern/brushlib/brush.hpp	                        (rev 0)
+++ branches/soc-2011-onion/extern/brushlib/brush.hpp	2011-07-29 10:47:37 UTC (rev 38815)
@@ -0,0 +1,787 @@
+/* brushlib - The MyPaint Brush Library
+ * Copyright (C) 2007-2011 Martin Renold <martinxyz at gmx.ch>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+#if WITH_GLIB
+#include <glib.h>
+#endif
+
+#include <math.h>
+//#include "Python.h"
+
+#include "brushsettings.hpp"
+#include "mapping.hpp"
+
+#define ACTUAL_RADIUS_MIN 0.2
+#define ACTUAL_RADIUS_MAX 800 // safety guard against radius like 1e20 and against rendering overload with unexpected brush dynamics
+
+/* The Brush class stores two things:
+   b) settings: constant during a stroke (eg. size, spacing, dynamics, color selected by the user)
+   a) states: modified during a stroke (eg. speed, smudge colors, time/distance to next dab, position filter states)
+
+   FIXME: Actually those are two orthogonal things. Should separate them:
+          a) brush settings class that is saved/loaded/selected  (without states)
+          b) brush core class to draw the dabs (using an instance of the above)
+
+   In python, there are two kinds of instances from this: a "global
+   brush" which does the cursor tracking, and the "brushlist" where
+   the states are ignored. When a brush is selected, its settings are
+   copied into the global one, leaving the state intact.
+ */
+
+
+class Brush {
+public:
+  bool print_inputs; // debug menu
+  // for stroke splitting (undo/redo)
+  double stroke_total_painting_time;
+  double stroke_current_idling_time; 
+
+private:
+  // see also brushsettings.py
+
+  // the states (get_state, set_state, reset) that change during a stroke
+  float states[STATE_COUNT];
+  GRand * rng;
+
+  // Those mappings describe how to calculate the current value for each setting.
+  // Most of settings will be constant (eg. only their base_value is used).
+  Mapping * settings[BRUSH_SETTINGS_COUNT];
+
+  // the current value of all settings (calculated using the current state)
+  float settings_value[BRUSH_SETTINGS_COUNT];
+
+  // cached calculation results
+  float speed_mapping_gamma[2], speed_mapping_m[2], speed_mapping_q[2];
+
+  bool reset_requested;
+
+public:
+  Brush() {
+    for (int i=0; i<BRUSH_SETTINGS_COUNT; i++) {
+      settings[i] = new Mapping(INPUT_COUNT);
+    }
+    rng = g_rand_new();
+    print_inputs = false;
+    
+    for (int i=0; i<STATE_COUNT; i++) {
+      states[i] = 0;
+    }
+    new_stroke();
+
+    settings_base_values_have_changed();
+
+    reset_requested = true;
+  }
+
+  ~Brush() {
+    for (int i=0; i<BRUSH_SETTINGS_COUNT; i++) {
+      delete settings[i];
+    }
+    g_rand_free (rng); rng = NULL;
+  }
+
+  void reset()
+  {
+    reset_requested = true;
+  }
+
+  void new_stroke()
+  {
+    stroke_current_idling_time = 0;
+    stroke_total_painting_time = 0;
+  }
+
+  void set_base_value (int id, float value) {
+    assert (id >= 0 && id < BRUSH_SETTINGS_COUNT);
+    settings[id]->base_value = value;
+
+    settings_base_values_have_changed ();
+  }
+
+  void set_mapping_n (int id, int input, int n) {
+    assert (id >= 0 && id < BRUSH_SETTINGS_COUNT);
+    settings[id]->set_n (input, n);
+  }
+
+  void set_mapping_point (int id, int input, int index, float x, float y) {
+    assert (id >= 0 && id < BRUSH_SETTINGS_COUNT);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list