Commit Graph

258 Commits

Author SHA1 Message Date
4ca67869cc Code cleanup: remove unused includes
Opted to keep includes if they are used indirectly (even if removing is possible).
2014-05-01 04:47:51 +10:00
6f153046e0 Reduce overhead when sampling texture images for brushes. The tests can
be cached and reused.
2014-04-13 19:03:14 +03:00
617557b08e Code cleanup: remove TRUE/FALSE & WITH_BOOL_COMPAT define 2014-04-01 15:22:28 +11:00
d3309ac5c9 Code cleanup: correct arg size 2014-03-29 08:42:59 +11:00
03af4cbf91 Code cleanup: style 2014-03-07 13:28:39 +11:00
9ecf73f703 Follow up to the offset scale fix for texture painting: texture mask had
the same issue.
2014-03-04 20:36:03 +02:00
3c3c2cd53c Fix issue with texture painting: Tex slot scale was being applied twice. 2014-03-02 19:40:39 +02:00
a1a0ebbf49 Code cleanup: use length squared where possible 2014-02-02 02:24:48 +11:00
1f2136b329 Python/Depsgraph: bpy.data.*.is_updated now detects add/remove of any datablock.
Previously this only worked for some datablocks relevant to rendering, now it
can be used to detect if any type of datablock was added or removed (but not
yet to detect if it was modified, we need many more depsgraph tags for that).

Most of the changes are some function parameter changes, the important parts
are the DAG_id_type_tag calls.

Reviewed By: sergey, brecht

Differential Revision: https://developer.blender.org/D195
2014-01-15 16:47:53 +01:00
cda89813df Fix for possible NULL pointer use in brush image sampling 2013-12-17 13:19:54 +11:00
f0675b14d8 Refactoring/cleanup, borrowed from soc-2013-paint branch.
* Move symmetry options to the paint struct (where all paint systems can
make use of it)

* Rename draw_pressure to stroke_active. This is what is really checked
on those occasions that this is used. Also move turning on/off of this
option to the stroke level and avoid doing it on every stroke system.

* Rename BRUSH_RESTORE_MESH to BRUSH_DRAG_DOT. In image painting this
won't restore any mesh, so better have a name that is directly linked to
what the flag actually does.
2013-12-09 22:40:02 +02:00
d3f3fb89cc Fix T37670: Paint mode + procedural map colours error
Summary:
Seems to be known TODO in the code, but no idea why it
was never solved, especially since tweak is so much easy.

It might be arguable that we need to support painting
color space, but it's still much better to convert to
sRGB space. It's gonna to cover 90% of cases anyway.

Reviewers: campbellbarton, brecht

Reviewed By: brecht

Maniphest Tasks: T37670

Differential Revision: http://developer.blender.org/D65
2013-12-03 22:13:15 +06:00
beae4f498d code cleanup: spelling 2013-10-31 14:10:01 +00:00
43bd8c2b28 Undo the front-facing only commit for clay strips brushes, it adds an
attenuation that should really be optional. There's also a minor
performance penalty and all this only for one problematic case. In case
the tool flattens two surfaces, users can manually set the front face
only option. A better non-attenuating way to cull such vertices can be
added later.

Also flatten brush should calculate the flatten plane from the original
vertices or the flattening will not converge for planes offsets
different than zero.

Reported by Michalis Zissiou, thanks!
2013-09-16 02:24:41 +00:00
9f87d9963e fix weird issue after last commit where grab brush would not work and
also warnings fix and description fix.
2013-09-14 00:35:41 +00:00
b1179c4752 Sculpting:
* Cleanup for previous commit and reduce some local variable referencing
* Add support for brushes that operate on frontfaces only and do not
show the option for those brushes. Currently only clay strips is in the
list but this may change according to artist feedback. This should take
care of the "sticky" surface problem completely.
2013-09-13 23:58:00 +00:00
4b1436b525 Ctr-Alt-F radial control operator for texture painting, controls the
rotation of the brush mask texture.

Unfortunately secondary path does not work here because we do not have a
permanent switch to choose between primary-secondary brush texture. Use
operator property instead.
2013-09-05 14:02:59 +00:00
4095fac849 Fix crash caused by own commit to optimize out curvemapping
initialization. In sculpt mode, when using shift-click to switch to the
smooth brush it was possible to ommit initialization of curvemapping for
that brush.
2013-08-19 19:41:38 +00:00
9db32483f3 Minor optimization for paint systems, initialize the paint curve before
the stroke and skip checking for initialization each time we request the
curve value.
2013-08-19 19:04:39 +00:00
1dd7156c4c Fix #36058: Displace Modifier errors using a baked Image and displace baking inconsistency between 2.67/2.68RC and previous versions
This was in fact really nasty bug, caused by multitex_nodes
function using global variable R (which is a copy of current
renderer). this variable is not initialized to anything
meaningful for until first rendering (preview or final)
happened.

Since multitex_nodes might be used outside of render pipeline,
made it so whether CM is on or off as an argument to functions
multitex_ext_safe and multitex_ext. Now multitex_nodes() is
only shall be used for stuff happening from render pipeline!

Also needed to make some changes to other places, so all the
usages of texture sampling knows for the fact whether CM is
on or off.

And one more change is related on behavior of dispalcement,
wave, warp, weightvg modifiers and smoke. They'll be always
using CM off since texture is used for influence, not for
color.

It's rather bigger patch, but it's mostly straightforward
changes, which we really need to be done.

Reviewed by Brecht, thanks!
2013-07-15 14:47:58 +00:00
b7396654e1 fix for bad NULL check in bmo_connect_pair, also remove duplicate checks in if statements and redundant initialization vars. 2013-07-13 16:25:47 +00:00
418011907c remove nan copyrights from code added since blender become opensource (copy paste errors), also remove BKE_script.h 2013-07-02 10:14:59 +00:00
70eaf2fe44 Image paint: 2D painting now supports texture masks and does masking more
consistent with projection painting.

Also did some refactoring of this code, moving the brush image creation code
out of brush.c and making it consistent with image updating code.
2013-05-12 09:14:13 +00:00
d7e8356846 Fix 2D painting gave squares rather than a disk for the "Max" curve falloff shape. 2013-05-01 19:50:37 +00:00
950b4f5ec9 style cleanup 2013-05-01 02:53:45 +00:00
576e579925 More painting fixes:
* 2D image painting with textures that contained alpha did not work correctly,
  had been broken for a while.

* 2D image panels texture (mask) panels showed wrong buttons for texture overlay.

* Texture map mode 3D now also uses masking, like Tiled and Stencil the texture
  does not move along with the brush so it works fine.

* 2D image paint View mapping did not work correct, especially noticeable with
  Rake rotation.

* Masking is now disabled for the smear tool, this can't really work because
  the original image is constantly changing and gave artifacts.
2013-04-30 16:07:52 +00:00
3b04b861bd Fix another part of #35141: there was no way to reset the stencil transform after e.g.
scaling it along one axis, now there's a Reset Transform button.

The Image Aspect button is now also hidden unless the texture is an image texture.
And also hide the color wheel for painting tools that don't use colors.
2013-04-30 10:32:02 +00:00
9461af89f1 Fix #35141: stencil and 3D texture mode did not work with 2D image paint. 2013-04-30 09:59:40 +00:00
63f05576b8 More image painting fixes:
* 2D image painting support for masking to limit the max contribution of a stroke
  to a pixel, to get it working compatible with projection painting. Not strictly
  a bugfix, but the inconsistency here was annoying.

* Fix python errors in Texture Mask panel in image editor, was missing overlay
  options.

* Clamp paint mask to 0..1 in case some texture exceeds it, this could give black
  pixels due to integer overflow.
2013-04-30 06:07:42 +00:00
8f9150871c Fix part of #34233: bad alpha blending for 2D image painting. This is a very
old issue, the formulas here were never quite right, should all work ok now
with byte and float images.

Some differences:

* Colors with zero alpha from the background will never have an influence, so
  you don't get alpha fringes when painting over such areas. This does give
  hard edges when looking at the RGB channels alone, but there's no way to
  avoid that and fringes at the same time, same behavior as other painting apps.

* Add/Subtract/Multiply/Lighten/Darken now leave the alpha channel unchanged
  and work only the RGB channels, again same behavior as many other apps.

* Erase/Add alpha now compensates for premultiplied float images to keep the
  straight RGB colors the same.

Next: fix projection painting.
2013-04-27 12:51:23 +00:00
51010f5035 Allow hiding separate hiding of overlays on stroke. 2013-04-23 00:32:51 +00:00
157244b13c Add stencil control for mask overlay. Key combinations are the same as
regular stencil but use Alt as well, so Alt-Rclick is translation, Alt-
clamping to avoid scaling of stencil to zero.
2013-04-23 00:06:22 +00:00
c0eadedb70 Support more mapping modes for alpha masks. Tiled, stencil and random 2013-04-22 10:46:01 +00:00
c1276960e8 Fix some names, and move overlay flag to overlay_flags. 2013-04-16 15:59:02 +00:00
53c9507c28 Option to hide overlay during a stroke. To enable, press the brush icon
next to the overlay alpha.
2013-04-16 15:02:41 +00:00
a305452275 Paint refactoring commit, non-disruptive (in theory :p)
* Fix precision overflow issue with overlay previews,
* Expose alpha mask mapping to UI (still not functional but coming soon).
* More overlay refactoring:

Overlay now does minimal checking for texture refresh.
Instead, we now have invalidation flags to set an aspect of the brush
overlay as invalid. This is necessary because this way we will be able to
separate and preview different brush attributes on the overlays, using
different textures:

These attributes/aspects are:

Primary texture (main texture for sculpt, vertex, imapaint)
Secondary texture (mask/alpha texture for imapaint)
Cursor texture (cursor texture. It involves brush strength and curves)

Modified the relevant RNA property update functions and C update callback
functions to call the relevant cursor invalidation functions instead
of checking every frame for multiple properties.

Properties that affect this are:

Image changes, if image is used by current brush,
Texture slot changes, similarly
Curve changes,
Object mode change invalidates the cursor
Paint tool change invalidates the cursor.

These changes give slightly more invalidation cases than simply
comparing the relevant properties each frame, but these do not occur in
performance critical moments and it's a much more elegant system than
adding more variables to check per frame each time we add something on
the system.
2013-04-12 17:21:31 +00:00
cf76d73b83 code cleanup: quiet some warnings and style 2013-04-05 15:45:10 +00:00
e8d532f1dd style cleanup 2013-03-31 03:28:46 +00:00
1fea6220a2 Woot woot commit.
Stencil style texture mapping. Ready for field testing and user feedback.

This commit adds stencil like brushes, like those that existed on old ptex branch.
(with the exception of clip colour)
To control the position of the stencil, you use

Q: translation
Shift - Q: scaling
Ctrl - Q: rotation

There's extra work that has been done to make this work:

* Support for coloured overlay in vertex/texture painting
* Also made A button do stroke mode selection like in sculpt mode,
when mask painting is inactive.

There are some TODOs to work on during bcon3:

* Support tiled and stencil mode in 2D painting. Support alpha textures also.
* Tidy up overlay code. There's some confusion there due
to the way we use the primary brush texture sometimes for alpha, other times
for colour control.

WIP design docs will be in

http://wiki.blender.org/index.php/User:Psy-Fi/New_Brush_Tool_Design
2013-03-31 00:38:50 +00:00
36d25daa09 style cleanup 2013-03-26 22:45:06 +00:00
1942452ce5 Paint system:
Random texture mapping
* Support for 2d painting.
* Better random generation and useof the result.
2013-03-26 21:34:39 +00:00
64d161de87 style cleanup:
also rename mesh_getVertexCos() --> BKE_mesh_vertexCos_get() to match curve function.
2013-03-26 07:29:01 +00:00
e1a54214bb code cleanup:
- remove unused defines.
- quiet some shadow warnings.
- bevel, ifdef out some asserts that are too common.
- style
2013-03-25 02:41:30 +00:00
ceb3225db7 Alpha mask textures porting part 1: Support for projective texturing.
Also add random mapping to brushes.
2013-03-25 01:00:16 +00:00
e7c15beaf6 code cleanup: use booleans for mesh and selection code. 2013-03-19 23:17:44 +00:00
526d79d688 Fix: jittered brushes are not jittered, reported by kursad karatas.
Issue is sharing using global random generator which is shared with
particle system which resets the seed due to some scene/option
combination. Since it may be desirable to get predictable results with
particles, made sure brushes allocate their own random number generator
on startup and use that for jittering.
2013-03-19 14:25:12 +00:00
e2b2d083e0 Fix "can't paint" bug no.1, painting with black on image editor did not
paint. Was own regression when optimizing colour operations. I will not
use an alpha bit mask since it may run into portability issues with byte
order.
2013-03-17 18:09:09 +00:00
99ee23aec5 Support for rake in 2D image painting. 2013-03-15 09:48:51 +00:00
92d45811c3 fix reading out of buffer bounds for recent vertex paint commit. 2013-03-14 05:59:34 +00:00
5684352858 Fix silly mistake that could lead to crash. Also, slight cleanup/rename
and comments
2013-03-14 03:47:20 +00:00