Commit Graph

529 Commits

Author SHA1 Message Date
11d98718bc Indentation fix. 2014-05-09 12:19:27 +09:00
Dalai Felinto
97641a0ec9 Bake API - bpy.ops.object.bake()
New operator that can calls a bake function to the current render engine when available. This commit provides no feature for the users, but allows external engines to be accessed by the operator and be integrated with the baking api.

The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an array of floats with the result.

The Blender Internal (and multires) system is still running independent, but we eventually will pipe it through the API as well. Cycles baking will come next as a separated commit

Python Operator:
----------------
The operator can be called with some arguments, or a user interface can be created for it. In that case the arguments can be ommited and the interface can expose the settings from bpy.context.scene.render.bake

bpy.ops.object.bake(type='COMBINED', filepath="", width=512, height=512, margin=16, use_selected_to_active=False, cage_extrusion=0, cage="", normal_space='TANGENT', normal_r='POS_X', normal_g='POS_Y', normal_b='POS_Z', save_mode='INTERNAL', use_clear=False, use_split_materials=False, use_automatic_name=False)
Note: external save mode is currently disabled.

Supported Features:
------------------
 * Margin - Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture.

 * Selected to Active - bake shading on the surface of selected object to the active object. The rays are cast from the lowpoly object inwards towards the highpoly object. If the highpoly object is not entirely involved by the lowpoly object, you can tweak the rays start point with Cage Extrusion. For even more control of the cage you can use a Cage object.

 * Cage Extrusion - distance to use for the inward ray cast when using selected to active

 * Custom Cage - object to use as cage (instead of the lowpoly object).

 * Normal swizzle - change the axis that gets mapped to RGB

 * Normal space - save as tangent or object normal spaces

Supported Passes:
-----------------
Any pass that is supported by Blender renderlayer system. Though it's up to the external engine to provide a valid enum with its supported passes. Normal passes get a special treatment since we post-process them to converted and "swizzled"

Development Notes for External Engines:
---------------------------------------
(read them in bake_api.c)

* For a complete implementation example look at the Cycles Bake commit (next).

Review: D421
Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge

Normal map pipeline "consulting" by Andy Davies (metalliandy)
Original design by Brecht van Lommel.

The entire commit history can be found on the branch: bake-cycles
2014-05-02 21:19:08 -03:00
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
a2c107aef1 Code cleanup: use 'const' for arrays (blenkernel) 2014-04-27 00:25:15 +10:00
617557b08e Code cleanup: remove TRUE/FALSE & WITH_BOOL_COMPAT define 2014-04-01 15:22:28 +11:00
7b7196e3ad Code cleanup: modifier_skin_customdata_ensure was a bad level call 2014-03-16 21:55:30 +11:00
2097e621ed Code cleanup: use r_ prefix for return args 2014-03-16 03:26:23 +11:00
0e97550fb3 Mesh Data: disable two-sided for new meshes (see: T37518) 2014-02-12 02:46:43 +11: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
2ebe4f69a9 Compilation error fix and strict warning silence for previous commits 2014-01-13 16:33:18 +06:00
d01bb0b8b6 Avoid memcpy to self when validating UV layer name 2014-01-13 16:27:05 +06:00
62aa004c25 Style Cleanup: whitespace 2014-01-12 22:05:24 +11:00
0a61116e54 Fix for converting unfilled 3d text into a mesh 2013-12-23 12:12:40 +11:00
ac38f2584f Code Cleanup: replace ABS() with fabsf() when used with float expressions. 2013-12-01 13:11:12 +11:00
cc55913798 Fix T37225: UV map for closed curves incorrectly generated
Summary:
Curve ORCO was not calculating properly for cyclic 2D curves.

- Needed to split vertices for blender internal renderer.
  Otherwise it's not possible to map last face to a proper
  texture location.

- Needed to tweak curve->mesh conversion to respect cyclic
  flag along U direction.

- Removed check for orcodm in curve.c:add_orco_dm since
  this code is only called if there're enabled constructive
  modifiers on the curve.

Reviewers: brecht

Maniphest Tasks: T37225

Differential Revision: http://developer.blender.org/D45
2013-11-26 03:02:13 +06:00
0469971b05 Fix T37465: UV Coords we're incorrect when converting from a curve 2013-11-22 20:41:00 +11:00
647f425265 Fix [#37394] UV Map cannot be renamed.
Own epic failure! CustomData_get_named_layer() returns a relative index, not an absolute one. :(
2013-11-10 20:32:27 +00:00
ffec71db84 Fix issues reported by coverity scan in recent changes to customdata code. 2013-10-01 12:48:41 +00:00
577e6e0290 Followup to r60416, we need to get cdlayers from bmesh everywhere! sorry... 2013-09-29 15:09:48 +00:00
8fa068d30a Fix [#36841] UV-Maps cannot be renamed in EditMode
Own error in r60260, in edit mode we need to use bmesh's cdata!
2013-09-29 06:47:07 +00:00
5342d57a5e allocate bmesh data from known sizes where possible (was still using defaults in places),
add macros for initializing BMAllocTemplate's, also add assert on invalid use of bmesh_sfme()
2013-09-24 03:31:00 +00:00
2cca73eeb1 Fix [#36759] UV Project - Specified UV Map doesnt work properly
In fact, the issue was that names of mloopuv/mtespoly layers could very easily get out of sync (a simple rename was enough), while most tools (such as the UVProject modifier) expect matching layers to have the same name!

Now matching names are check on load, and renaming of a layer through RNA is guaranted to be synchronized with its counterparts.

Thanks to Brecht & Campbell for reviews.
2013-09-20 11:14:08 +00:00
2646bbdccb move mesh evaluation functions (normal, mapping, smooth group... etc, calculations) into mesh_evaluate.c.
mesh.c was over 4k lines and complex functions mixed in with general library management.
2013-09-09 02:11:44 +00:00
37bad42b9d Ack... Followup to r59743: in fact, bitflags groups are not always wanted/needed, thanks to Campell for notifying me about this!
So now, their generation is controlled by a flag, else previous "simple values" group ids are generated (one per poly region, no need here to reduce the number of used IDs!).

Will update obj exporter too.
2013-09-02 18:33:06 +00:00
6ac7b03b2c Fix [#36636] Incorrect assignment of Smoothing Groups on export
In fact, smooth groups are supposed to be bitflags, not simply integer values (would be far too much simple!). This adds quite a bit of work, as with only 32 values, we can't just assign one to each group. Somewhat related to the "Four colors theorem"! ;)

Here we simply use the first available bit for current smooth group (i.e. first bit not used by any of the already defined contiguous groups).
2013-09-02 17:14:41 +00:00
27df6a3b54 scanfill curves, ngons, masks had their own memarena code and would allocate a new one for every fill.
now use BLI_memarena and support passing the arena into the fill function, so the arena is re-used, when scanfill is called in a loop.
2013-08-28 02:07:54 +00:00
defb8812a7 fix [#36301] Mirror modifier does not mirror vertex normals when there are no faces. 2013-08-27 02:25:15 +00:00
bbce51d116 replace hashes with sets where possible. 2013-08-25 20:03:45 +00:00
25ffb79a0b use reserve argument for more edgehashs 2013-08-24 14:40:15 +00:00
0b88b4fad7 when the size of an edgehash is known or can be guessed,
pass in the argument to reserve the size.
2013-08-24 13:47:57 +00:00
f320c5ae9e fix for leak in make_edges_mdata() if there were no edges to create,
also reserve the total number of edges in the hash when its created.
2013-08-24 13:13:29 +00:00
f2acb10b6b edge hash: take an arg for the guarded-malloc string (as ghash does) 2013-08-24 13:08:55 +00:00
017392d603 fix/workaround [#36519] Origin to Center of Mass" failes when faces have an area of zero 2013-08-20 09:42:18 +00:00
f030758515 Tag object-data level boundbox as invalid rather than freeing it
Object update used to free object-data level bounding box to trigger
it's re-calculation in the future. Such a freeing performed from
object update isn't thread-safe because mesh could be shared between
multiple objects.

Rather than freeing bounding box, tag it's as invalid, this is safe
from threading point of view and also prevents unnecessary memory
re-allocation.

Object-level bounding box is still reallocating, but think we could
change this easily in the future as well.

--
svn merge -r58154:58156 -r59258:59259 ^/branches/soc-2013-depsgraph_mt
2013-08-19 09:58:28 +00:00
7ef3f98de1 Made curves almost thread-safe
Now modifier stack wouldn't modify original curve's nurbs
and will operate on a copy of nurbs.

This makes it possible to process curve object update with
shared curve datablocks from multiple threads. There's no
big overhead for creating a copy of nurbs comparing to old
behavior which was allocating original vertex array and
apply coordinates on curve after all modifier are applied.

The only remained issue with curves is curve's bounding box
and texture space. It's not thread-safe, but it wouldn't
lead to crashes -- it just could lead to either memory
leak or wrong texture coordinates due to difference in
modifiers stacks of objects which shares the same curve.

--
svn merge -r57959:57961 ^/branches/soc-2013-depsgraph_mt
2013-08-19 09:36:40 +00:00
527ddb0a5b Move bevel list and path from Curve to Object datablock
I know this is not so much nice to have this guys hanging
around in a general Object datablock and ideally they better
be wrapped around into a structure like DerivedMesh or
something like this. But this is pure runtime only stuff and
we could re-wrap them around later.

Main purpose of this is making curves more thread safe,
so no separate threads will ever start freeing the same path
or the same bevel list.

It also makes sense because path and bevel shall include
deformation coming from modifiers which are applying on
pre-tesselation point and different objects could have
different set of modifiers. This used to be really confusing
in the past and now data which depends on object is stored
in an object, making things clear for understanding even.

This doesn't make curve code fully thread-safe due to
pre-tesselation modifiers still modifies actual nurbs and
lock is still needed in makeDispListsCurveTypes, but this
change makes usage of paths safe for threading.

Once modifiers will stop modifying actual nurbs, curves
will be fully safe for threading.

Actually, this commit also contains wrapping runtime curve
members into own structure

This allows easier assignment on file loading, keeps curve-
specific runtime data grouped and saves couple of bytes in
Object for non-curve types.

--
svn merge -r57938:57939 ^/branches/soc-2013-depsgraph_mt
svn merge -r57957:57958^/branches/soc-2013-depsgraph_mt
2013-08-19 09:25:24 +00:00
503b7d5b9a add materials.clear() method, matching other python list method. 2013-08-14 11:29:58 +00:00
4982f200fa move alloca define into its own header since its not related to BLI_array 2013-07-28 10:38:25 +00:00
02468b290a code cleanup: use MEM_mallocN rather then MEM_callocN when the array is
overwritten immediately after.
2013-07-19 10:41:16 +00:00
e68618a5f2 Fix memory leak in BKE_mesh_vert_poly_map_create. 2013-07-16 00:34:03 +00:00
abe84a4f43 Fix #36139: cycles not taking texture spacing settings into account for
generated coordinates on text objects.
2013-07-15 11:11:36 +00:00
878608d1cf fix regression [#36141] Crash with skin and remesh modifier in edit mode. 2013-07-14 23:27:47 +00:00
6d9de6a72b fix [#35975] "Select Linked" = "Select All" in Weight Paint mode?
looks like this was broken since bmesh merge.
2013-07-03 09:53:06 +00:00
e64ae3ad7c fix [#35914] Blender crashes when trying to use vertex selection masking on a copy directly after using SHIFT+d 2013-06-30 22:04:03 +00:00
23d3c64b59 fixed Blender crash, but unclear when this situation can happen 2013-06-29 08:38:17 +00:00
603258d763 fix for zero length normalize before scanfill for meshes and other minor changes. 2013-06-27 04:32:44 +00:00
a7858767f4 fix [#35858] Weight Paint: Hiding faces isnt flushing the flag to the vertices. 2013-06-26 02:47:56 +00:00
afb200f217 calculate polygon normals for BKE_mesh_recalc_tessellation() inline rather then using scanfills function. 2013-06-24 18:13:33 +00:00
f35264706a Construct orco UV layer for curve when applying constructive modifier
Also construct orco uv layer when converting curve to a mesh.

This makes it possible to preserve automatically generated coordinates
("use uv for mapping" option) when using constructive modifiers or
converting curve to the mesh.

With cycles nothing special is needed to preserve texture mapping
after such operations, in blender internal you'll need to change
texture mapping from Generated to UV.

This feature is useful on it's own and also would help in potential
switch 3d viewport to always use DM to draw objects, which would
help making drawing more thread-safe.
2013-06-20 13:27:48 +00:00