1
1

Compare commits

...

1051 Commits

Author SHA1 Message Date
Julian Eisel
8d09ca96a7 Some tweaks for introduction of draw-styles 2015-08-15 01:56:54 +02:00
Julian Eisel
d693aa3590 Merge branch 'master' into temp-ui-widget-refactor
Conflicts:
	source/blender/editors/interface/interface_widgets.c
2015-08-15 01:00:03 +02:00
Julian Eisel
119cda0a0d Cleanup: Avoid calling function twice
Own stupidness from rB17422124eca332
2015-08-14 22:23:06 +02:00
Julian Eisel
9b729adb6e Remove redundant workaround for T41548
Reverts 7a026971dc which isn't needed anymore after b347f523cececdf
2015-08-14 22:23:06 +02:00
Julian Eisel
d9a720a709 Fix T45750: Closing search menu by clicking root button doesn't work when clicking on lower half 2015-08-14 22:23:06 +02:00
fa86efdc97 Fix T40070, Bevel didn't bend as expected sometimes.
Two problems fixed. One, the comparison of angles to
'almost straight' or 'almost zero' needed a bigger epsilon.
Two, using the corner normal instead of the average face normal
is usually the right thing to do, and what the code was doing,
but in some cases the corner normal could be very wrong.
2015-08-14 15:51:27 -04:00
18648bef7b Fix dyntopo not warning anymore when vertex colors or uvs are present.
We check against loop data now, not tessface data
2015-08-14 17:11:31 +02:00
Julian Eisel
5fafd493c2 Fix unnecessarily added undo steps when deleting only scene
Steps to reproduce were: startup.blend, move any object, delete active scene (nothing happens), undo (nothing happens), second undo is needed to revert object transformation
2015-08-14 15:54:58 +02:00
a662980f31 Remove already-ifdef'ed out PRE_275_ALGORITHM code from bevel.
The new algorithm has soaked enough that we are unlikely to go back now.
2015-08-14 09:46:49 -04:00
d94137ee7d Outliner: Context menu for scenes
Adds context menu for scenes in the outliner, for now, with only a 'Delete' entry.

D1448 by @lichtwerk, review by @aligorith and @Severin
2015-08-14 15:22:52 +02:00
8b286bf35a Cleanup: style 2015-08-14 17:46:26 +10:00
fdfd87f2f4 Docs: comment BHead.code values 2015-08-14 17:40:55 +10:00
3fa0a1a5bc Add real boundbox support to lattice, and update armature one.
* draw lattice boundingboxes in 3dView [if "show_bounds" is used -- an option previously pretty useless for lattices]
* give proper values for lattice objects ".bound_box" in bpy
* give proper values for armature objects ".bound_box" in bpy
* lets users use "Dimensions" [in 3dView Transform panel] on lattices and armatures
* remove redundant calculations in "boundbox_armature()"

Armatures boundingboxes were already drawn in 3dView, if "show_bounds" was used.

Based on report T45735: Lattice's bounding_box doesn't update,
and a comment in code by @campbellbarton ("later we may want to add dimensions for lattice, armature etc too").

Revision: https://developer.blender.org/D1460
2015-08-13 18:12:08 +02:00
d2383ec6c0 Fix T45783: Problem selecting all objects on a layer from a script if any 3d view is in local mode.
Do not take into account lay bits used for local view, when doing exact match.
2015-08-13 14:25:26 +02:00
828710d2ac Fix T45782: bpy.ops.object.select_by_layer match='SHARED' option is not working.
Looks like some half-done change from enum to bool (or vice-versa), that op was just broken!
2015-08-13 13:18:45 +02:00
c62eb919ec Fix T45775: Bad 'Normal' transform space for edge of non-uniformed scaled object.
Non-uniform scaled obmat will lead to transformation not preserving angles, so
we must ensure our normal is orthogonal to the edge **after** applying obmat.
2015-08-13 12:45:13 +02:00
487d2cb4f3 Displace Modifier: add an option to displace along (averaged) custom normals, instead of vertex normals.
User suggestion/request from 'boby'.
2015-08-12 18:21:41 +02:00
883b420a51 Fix T45739: Number slider precision handling inconsistent between unit systems.
When using unit system, step was multiplied by 100, could really not find any good reason to that.
Easy to revert anyway if needed, but in this case please explain why in code. ;)

Investigated and patch by Thomas Radeke (ThomasR), thanks.
2015-08-12 16:43:41 +02:00
39ce0a9916 Fix T44049, edge bevel with sometimes breaks UVs.
Fairly large changes to bevel code to do a better job
of keeping UVs from crossing islands, etc.
Updated http://wiki.blender.org/index.php/Dev:2.5/Source/Modeling/Bevel
to explain algorithm used for maintaining UVs.
Updated the bevel_regression.blend tests in lib tests.
2015-08-12 10:18:58 -04:00
4eefba091d Fix 'hard crash' part of T45768 (when merging all vertices of a mesh, we have no more edges to draw). 2015-08-12 11:42:35 +02:00
8a2371e408 Usual UI message cleanup/fixes. 2015-08-11 22:29:16 +02:00
253ee0b490 install_deps: fix broken force/skip-osd options.
Bash scripts are such a PITA, having to redefine the options in three different places... :(
2015-08-11 22:08:01 +02:00
b36c6b9c47 BGE: Fix delete constraint for replicated physics controllers.
Replicated controllers didn't free constraints list before.
2015-08-11 21:49:54 +02:00
d22153425a Cycles: Enable some extra debug prints for OpenCL kernel loading 2015-08-11 18:03:54 +02:00
a790e172d0 BGE: Fix T38448: Bullet constraint memory leak. 2015-08-11 13:02:17 +02:00
10dbe966e1 Add WM_event_add/remove_timer_notifier() helpers.
This basically does the 'timer' part of Jobs system: it sends a given notifier on every timer step.

This is needed for background tasks (not full-fledged jobs, lighter BLI_tasks based) that want to update UI
(like for up-comming new thumbnail handling in filebrowser).
2015-08-11 12:11:48 +02:00
bccc6c393c BGE: Fix T33187 constraints replication for libloaded objects.
Reviewers: Moguri
2015-08-11 11:30:23 +02:00
c1506454ec UI drag&drop: make code able to free dragpoin if needed.
Only for image and strings for now. Needed for incomming filebrowser work.
2015-08-10 18:01:11 +02:00
8d37aaeca1 Data previews: add utils to generate/clear previews.
Not much to add, you can now clear previews from current .blend file, or a set of non-opened files.
Likewise, you can generate previews (for mat/tex, objects, groups, scenes, ...).
2015-08-10 17:45:16 +02:00
8f837e0ac5 BGE: Fix T33564: UI obstacle panel disable for character and no collision objects. 2015-08-10 17:32:09 +02:00
7b467a6fea Cycles: Fix for typo in previous commit 2015-08-10 17:24:14 +02:00
3c77822f96 BGE: Fix T19377 restore dynamics after unparenting object.
Reviewers: scorpion81
2015-08-10 17:08:11 +02:00
0c82ba4213 Data previews: add preview to Object, Group and Scene.
This commit does not add anything yet to users, it’s purely internal one.
Useful commit is next. ;)
2015-08-10 15:41:28 +02:00
d70ffd375f BLI_threads: add an helper to wait on a condition using a global mutex.
Also, factorized internal code to get global mutex from its ID.
2015-08-10 15:03:31 +02:00
c6d13716c1 Install_deps: add basic listing of needed dependencies to error message for unsupported distro. 2015-08-10 13:09:57 +02:00
65c3207517 BGE: Fix T44782 suspend/restore dynamics on inactive object. 2015-08-09 19:17:24 +02:00
49f3998a0f Install_deps: add (non-tested) OSD-building code.
Not tested for fedora-like and arch distro, would expect it to work though. Please report otherwise.

Also, always inatll git now (and a few other XOrg -dev packages).
2015-08-09 15:58:53 +02:00
64dc38f089 install_deps: Add libxcursor packages, seems to be needed now? 2015-08-09 15:42:27 +02:00
ded665a2c9 Compile fix cycles network. This code is crusty and not super
functional. But is should compile.
2015-08-09 15:31:32 +02:00
Dalai Felinto
63265fd0c3 Cycles: Follow up on cc0bbc28 (Collapse multiview panel) 2015-08-09 00:25:34 -03:00
d9fc9882dc Optimize reading of fcurves
Reading fcurves wasn't really optimal because restoring fcu->group pointer was
changing lasthit pointer, which required full lookup over the oldnewmap happened
at the next call to newdatadr().

This reduces loading franck_sheep.blend file from ~2.2sec to 1.5sec.
2015-08-08 22:17:03 +02:00
cc0bbc28e2 Collapse multiview panel in render layers by default
This is not so much common panel to access to and having it fully
visible just adds clutterness in cases when one only need to work
with render passes.
2015-08-08 20:55:51 +02:00
f4ba4c6826 Fix for SeqCache hash ignoring multi-view
Thanks to @chadf for finding
2015-08-09 13:53:36 +10:00
115c867190 Fix: opening missing file didnt remove in recent-files.txt
Refactor recent-file.txt handling, split into smaller functions.
It wasn't possible to write the current state to disk (depended on current context).
2015-08-09 13:12:21 +10:00
281f4eb964 SPeedup for particle point cache reading
Order of saving and reading particle point cache was totally different which
made newdataadr() falling back to full data block list traversal for every
point cache entry.

This commit makes it so reading code uses the same order of reading structs
and lists ad the writing code. This required to add special version of list
linking which is capable of running a callback after linking a list element.
This seems to be more robust approach than splitting writing code into
several loops.
2015-08-08 19:54:20 +02:00
Dalai Felinto
e1cea53066 Fix T45705: Selected to Active Cycles Baking no longer working 2015-08-08 14:40:41 -03:00
a9f6b27281 Use polygon normals for baking 2015-08-09 11:05:25 +10:00
e229d66e99 Fix crash baking in cycles
Error in recent move to looptri
2015-08-09 08:29:23 +10:00
dbdc55ab6a Support building OpenSubdiv libraries under Debian (Ubuntu) with our build_deps.sh script.
Use --skip-osd to skip building opensubdiv libs,
use --force-osd to force a rebuild of the libs.

I added all needed user information (where to find the include dir, which -D options to set) to the print_info method that is called at the end too, so it should be pretty intuitive to use.

Reviewers: sergey, mont29

Reviewed By: mont29

Subscribers: mont29

Differential Revision: https://developer.blender.org/D1452
2015-08-08 14:12:02 +02:00
Julian Eisel
fef31aadc4 Remove leftover from sticky keys 2015-08-08 02:37:03 +02:00
8af8bab0c5 Fix T45726: Wrong handling of 'failed to generate' audio waveform data in VSE strip draw code. 2015-08-07 23:42:32 +02:00
Dalai Felinto
e96e0ddbee Fix T45715: Blender crashes when creating Environment Map textures in Multi-View mode 2015-08-07 15:46:18 -03:00
Dalai Felinto
58133d4ab2 Fix T45721: Panoramic render in Cycles camera : depth of field issue with bump maps - patch by Brecht Van Lommel 2015-08-07 15:04:12 -03:00
96f20c34a2 Data Transfer operator: Add a 'freeze' setting to prevent operator from re-running when changing settings.
This is likely weak design, but allows people to change several settings without having to wait
several tenth of seconds each time, when e.g. transferring UVs between heavy geometries.
2015-08-07 16:35:39 +02:00
c677bd44ce Fix (unreported) crash in mesh remap (i.e. data transfer).
Issue from rBabbd82a50, loops data were not correctly protected against multi-freeing in bvhtree data.
2015-08-07 16:35:38 +02:00
930fc7d157 Mesh remap: Fix two potential numeric issues in corner cases, and enhance poly projection.
Null-area face could generate an int overflow, and potential numerical imprecision in face area computation
could lead to negative number of rays-to-cast (though highly unlikely).

Also, use domnant axis of poly normal as 'flattening' one, instead of always using Z axis.

Points raised by Campbell, thanks!
2015-08-07 16:35:38 +02:00
c30c3fde51 Attempt to fix T45718, crash when enabling GLSL mode with UV layers.
I can't  reproduce issue here but crash is most likely caused by passing
a NULL pointer to glUniform2fv.

This is caused by OpenSubdiv changes to the codegen module, which pass
mtex layers to the uniform system
even when not needed.

Since Sergey is demoing OpenSubdiv in a few days, I'll
go with the easy fix for now which is just checking for NULL pointer, but
this needs to be fixed properly at some point.
2015-08-07 16:16:23 +02:00
9becee445e Fix scrubbing only treated as animation for sequencer
Intent was to act as animation everywhere
2015-08-07 15:39:32 +02:00
Julian Eisel
20bd253809 Fix T45713: Numselect for confirm popup not working anymore 2015-08-07 14:39:50 +02:00
44384c698d BGe: Fix T45597 wrong object layer for linked object in blenderplayer. 2015-08-06 17:07:26 +02:00
f5a333fe65 Fix: Sliders in animeditors were getting drawn too far left
Sliders in for FCurves in the animation editors were leaving space for
one extra setting that they didn't need to be accounting for (and which
wasn't shown, as it isn't valid for FCurves).
2015-08-07 02:46:38 +12:00
599d8291ad AnimEditors FModifiers toggle: Add a bit more space beside it so that it doesn't seem to collide with the mute toggle 2015-08-07 02:46:37 +12:00
579329388a Fix T45166: Keyframes pasted at wrong position when NLA strip has offset
Paste keyframes code seemed to have overlooked the NLA mapping issue, causing
keyframes to get pasted in the wrong places.
2015-08-07 02:46:37 +12:00
0e80e3d20c No need to count layers to check empty 2015-08-07 00:00:28 +10:00
b9ce21fd0f GPencil UI: Streamline the data panel workflow
Restored the "New Layer" button in the NKEY Grease Pencil panel (as was found
pre-2.73) for two cases:
 1) When no Grease Pencil datablock is active - This shortcut makes it possible to
    add a new layer to start drawing in with a single click again (instead of two
    clicks - one to add a datablock, and a second to add the layer)

 2) When there are no layers - There is no need to display the UI list in this case,
    thus saving a bit more space in the rare cases where this applies.
2015-08-07 01:48:27 +12:00
376e729de0 T44932: Disable pressure handling for "poly" mode too 2015-08-07 01:48:27 +12:00
e660079e47 StopGap Fix for T44932: Ignore pressure values when drawing straight line segments with GPencil
After some testing of the behaviour of this stuff, it became clear that the current
pressure handling here isn't very useful. The initial point would invariably get a
low pressure value (due to the way that the initial tap needs time to "take"), while
the end of the stroke suffers from similar issues (i.e. when the pen is released).
Meanwhile, the line thickness would flicker while drawing the stroke, as the endpoint
pressure varied.

So, until we find a better way, all straight line segments are now drawn without
pressure sensitivity.
2015-08-07 01:48:26 +12:00
c587302ea1 Timeline: Make GPencil keyframes slightly taller than normal keyframes to make them easier to distinguish
This commit makes GPencil keyframes in the timeline slightly taller (80% height
vs 60% height) so that they will not be that easily confused.
2015-08-07 01:48:26 +12:00
03b2bccca8 Remove MFace use w/ fluidsim 2015-08-06 22:33:45 +10:00
8f45e1156f Docs: comment BKE_scene_set_background 2015-08-06 21:03:35 +10:00
2c5efd5b3f Fix typo in cmake when OpenSubdiv is not found 2015-08-06 11:51:18 +02:00
be1a684755 Fix T45695: Assigning material reverts MaterialSlot.link
Setting the material was resetting the link bit, this is OK from the UI,
confusing for scripts.
2015-08-06 18:07:44 +10:00
fa4172c28c OpenSubdiv: Make sure faces are exported with consistent normal
This is currently a requirement of OpenSudiv and original orientation code
was depending on this quite a lot.

This makes mesh conversion and comparison slower but solves some crashes.
With some trickery it could be optimized and become closer to original
performance.

Probably Campbell has some nice ideas here as well :)
2015-08-06 09:49:13 +02:00
ced9381e20 Simplify defvert_remove_group(), use realloc
Patch by @chadf
2015-08-06 16:52:39 +10:00
c2cfec64e3 Cleanup: unused warning 2015-08-06 16:52:28 +10:00
43c756ac95 CMake: AUDASPACE_ROOT_DIR wasn't working 2015-08-06 13:03:07 +10:00
300f33a8ea Cleanup: style (match other find modules) 2015-08-06 13:03:07 +10:00
fdc8b12726 Cleanup: whitespace, unused var 2015-08-06 13:03:07 +10:00
5af7257309 Cleanup: whitespace 2015-08-06 13:03:07 +10:00
89edddb26c Fix T45691 crash on material view
Call glProgramUniform1i only when OpenSubdiv is requested and only when
the GPU supports it.
2015-08-06 01:09:07 +02:00
868d3605ee Fix T45693: Fix for using 4-component vector as 3 component in osd shader 2015-08-05 21:35:38 +02:00
4140312c36 OpenSubdiv: Make sure normals passed to OSD are all up to date
Solves shading artifacts with animated characters.
2015-08-05 19:19:05 +02:00
02f553cc7a OpenSubdiv: Changes to texturing
Use first material slot for until multiple materials are fully supported.

Also respect setMaterial()'s return value to avoid drawing unnecessary
geometry.
2015-08-05 18:29:43 +02:00
9a995c11d3 OpenSubdiv: Initial OsdMesh construction missed clearing out-of-date coords flag 2015-08-05 16:07:32 +02:00
5fe5118845 Cleanup: unused warning 2015-08-05 23:50:22 +10:00
5e050918d8 Fix dereference before NULL check 2015-08-05 23:47:13 +10:00
11bfeb45ce OpenSubdiv: Completely avoid possible access to non-existing CPU data
Make it so CCGDM reports 0 number of geometry when it uses GPU backend for
drawing. This screws up a bit statistics in info header and requires to have
some special handle of CCGDM in the drawing code, but makes it so non of the
areas will try to access non-existing geometry.
2015-08-05 15:11:50 +02:00
6146fdc7b0 OpenSubdiv: Edit mode was not checking for Use OpenSubdiv flag 2015-08-05 14:51:08 +02:00
0208c95986 OpenSubdiv: Correction to previous commit 2015-08-05 14:46:27 +02:00
6cba20a8e6 OpenSubdiv: Tweaks to AABB calculation when using opensubdiv for subsurf
Use coarse coordinates to calculate AABB which gives much better approximation
of AABB than using unity AABB size.
2015-08-05 14:43:51 +02:00
5b76f72904 Mirror modifier: Fix for wrong dependency relations
Mirror modifier was reporting that it depends on geometry of the object
used for mirror center which is incorrect -- only object matrix is needed
for modifier evaluation.
2015-08-05 14:29:18 +02:00
8d179e3c1f OpenSubdiv: Resolve regression with unity AABB for CCGDM calculated on CPU 2015-08-05 14:20:40 +02:00
0ea45676d0 OpenSubdiv: Fix crash happening when disabling Use OpenSubdiv option
The issue was caused by the changes from this morning.
2015-08-05 14:15:46 +02:00
a474409f0b OpenSubdiv: Enable by default on the supported platforms
This commit makes sure Linux and Windows buildbots are using OpenSubdiv
and also enables OpenSubdiv by default on Windows.

OSX is kept disabled still, this is due to OpenGL restrictions which are
not solved in any way yet.

Linux is defaults to OpenSubdiv disabled because it needs precompiled
library.

The documentation could be found there:

  http://wiki.blender.org/index.php/User:Nazg-gul/OpenSubdiv
2015-08-05 13:29:39 +02:00
c54df2ad47 Remove files from recent-files list on failed open 2015-08-05 21:26:10 +10:00
cae25ff240 Fix T45647: Incorrect results w/ color spill node 2015-08-05 21:26:10 +10:00
d4a9da28e8 Doc fix: rather then -> rather than 2015-08-05 12:48:04 +02:00
7742926403 Only show interpolation buttons w/ bezier splines 2015-08-05 20:28:31 +10:00
7853cb3c5a Remove redundant addition in BKE_mesh_calc_volume 2015-08-05 20:26:52 +10:00
a7442bef59 Fix selecting linked edges 2015-08-05 20:24:27 +10:00
25f381a9b2 Fix T45641: crash cutting meta-strips 2015-08-05 20:18:57 +10:00
80c50a1d49 OpenSubdiv: Make subsurf behavior closer to original one when built with OpenSubdiv but without enabling option 2015-08-05 11:55:06 +02:00
b5c602c9c2 Buildbot config: disable gooseberry branch from nightly builds
There's no updates happening in the gooseberry branch, so no really reason
to waste time on rebuilding the branch overnight.
2015-08-05 11:45:52 +02:00
864c154a41 Buildbot config: remove windows scons and mingw builders
They are defunct at this moment, no reason to try scheduling builds on them.
2015-08-05 11:44:36 +02:00
Julian Eisel
d39e18853f Nodes: Link lines & link arrows not scaling to DPI/pixelsize correctly 2015-08-04 21:56:43 +02:00
c18e6fd87c Cycles: Remove 32bit cuda workaroudn and disable cubins for buildbot
Recent changes to kernel broke compilation of the kernels again, need some
other kind of solution for this issue.

Don't have much time for this currently, but will be addressed before the
release.

Meanwhile it's better to have some buildbot builds instead of totally failing
one.
2015-08-04 18:50:37 +02:00
8bd425188c OpenSubdiv: Preparation for enabling it for linux buildbot 2015-08-04 18:33:55 +02:00
687a321be3 OpenSubdiv: Modifiers module missed WITH_OPENSUBDIV define 2015-08-04 18:32:21 +02:00
ea40df582f OpenSubdiv: Fix for missing OpenMP device when building with SCons 2015-08-04 18:25:34 +02:00
16b619b77d OpenSubdiv: Correction for compute devices detection in SCons
SCons was still using file names from 2.x branch.
2015-08-04 18:18:21 +02:00
dfc672f8bb SCons: Fix for really nasty bug with polluting configuration environment
The issue was caused by the following construction:

  def = env['SOMETHING']
  defs.append('SOMETHING_MORE')

Since first assignment was actually referencing environment option it was totally
polluted hawing weird and wonderful side effects on all other areas of Blender.
2015-08-04 18:06:28 +02:00
1fc32249f5 Fix fast navigate winding being incorrect (apparent when backface
culling was on)
2015-08-04 16:03:20 +02:00
Julian Eisel
4041e654cd Nodes: Make method to detect hovered link during transform more predictable/responsive
The old method:
The "old" method used the node dimensions to get a number of lines and checked if they intersect with the node link. Issue with this is that only a small part of the actual node surface is checked, making the method a bit unpredictable or unresponsive.

The new method:
The new method checks for intersections within the entire node surface. If multiple links are intersected, the node with the smallest distance from the *upper left corner* to the link is chosen.

Reviewed by @campbellbarton (tm)
2015-08-04 15:25:19 +02:00
07b525ffe2 Remove alloc checks in laplaciansmooth
These arrays aren't especially big or likely to fail.
2015-08-04 22:34:29 +10:00
4b6fba355c Remesh modifier has unnecessary MFace calculation 2015-08-04 22:11:43 +10:00
ae9ccec7c4 Missed from last commit 2015-08-04 22:08:21 +10:00
f1a9a8cbfd Remove MFace use w/ laplacian smooth
Use polygons for calculation
2015-08-04 21:58:35 +10:00
c1938eb127 OpenSubdiv: Report when OSD can't be enabled due to dependencies
Should be useful for debugging cases when enabling the option doesn't
cause any performance improvements.
2015-08-04 12:23:53 +02:00
b50916d172 OpenSubdiv: forgot this in the previous commit
Need to find better approach for dealing with shadeless materials.
2015-08-04 11:04:27 +02:00
abb976ae88 OpenSubdiv: Optimize drawing shader
The idea is to cut as much code as possible and use compile-time
ifdefs rather than runtime if() statements.

Gives about 2x speedup on catmark_car model from OpenSubdiv repository
making our FPS much closer to what glViewer is capable of.
2015-08-04 10:52:50 +02:00
cff288cf3a Use PyC_ParseBool to parse bools
This could cause problems since they could be any int,
then passed directly to internal functions that assume bools.
2015-08-04 18:49:42 +10:00
62c8f46ab6 Docs: comment functions in BLI & Py API 2015-08-05 02:09:03 +10:00
Mateo de Mayo
23f54076db BGE: Added getActionName() function to KX_GameObject()
It works similar to getActionFrame(), you have to give a layer or not (for layer 0) as the argument and it returns the name of the animation that the object is currently playing.

Example:

```
import bge
own = bge.logic.getCurrentController().owner
own.playAction("SomeAction",0,20)
print(own.getActionName())
```
>> SomeAction

Here is an example file, just open the blend file with the terminal opened
and press P, you can see how the current animation is being printed:
{F217484}

Reviewers: moguri, hg1, panzergame, campbellbarton

Reviewed By: panzergame

Subscribers: campbellbarton, hg1, #game_engine

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1443
2015-08-04 00:10:33 +02:00
Julian Eisel
8dbe598192 Merge branch 'master' into temp-ui-widget-refactor 2015-08-03 23:50:08 +02:00
73522e1157 OpenSubdiv: Fix/workaround for missing generated coordinates in viewport
This actually requires some bigger work to make it fully supported but
for now at least avoid breaking shading with OpenSundiv option disabled.
2015-08-03 20:39:00 +02:00
0951ea2c6d OpenSubdiv: Support shadeless shading 2015-08-03 20:18:33 +02:00
c2dc6aa946 OpenSubdiv: Smooth shading became broken in recent commit 2015-08-03 19:47:40 +02:00
9b51a9e885 Sculpt: Fix tiling with brushes that use a locked plane
Patch by Tilman Blumhagen, thanks!
2015-08-03 19:41:34 +02:00
2411027a79 Multires sculpting drawing optimization:
Use OpenGL 3.2 extension ARB_draw_elements_base_vertex, which allows us
to add offset in index buffer indices automatically. This should reduce
the number of draw calls significantly.

We may have some errors on the Mac with VBO setting off.
OSX OpenGL extensions don't play well with vertex arrays.
Will test that more later.

We might also use a full element buffer here, like we do when hiding
some quads, but this approach keeps the memory savings intended
originally.
2015-08-03 19:09:21 +02:00
7667ad2d4e OpenSubdiv: Made it a modifier option to enable OSD for viewport
The idea of this commit is to make it so we can enable OpenSubdiv by default
for the release builds but keep it limited to the viewport only for a specific
meshes. This is a temporary solution for until all the needed features are
supported on the OpenSubdiv side.

Flag itself is done as a dedicated field in modifier DNA so we can easily
remove it in the future without ending up with some temporary flag hanging
around forever.
2015-08-03 17:51:18 +02:00
e90fea72c1 Fix T45654 fast navigate artifacts.
Was overdrawing the buffer, in case of fast drawing just use one
draw call. Should also make performance quite smoother.

Note:
Just discovered we are doing one draw call - per grid - in multires
apparently to keep reusing the same element buffer.
This is horribly, dreadfully slow and will check about fixing it later.
2015-08-03 17:47:03 +02:00
e5f7b0f330 OpenSubdiv: Avoid crashes when GPU subsurf is tried to be used on CPU
The issue was caused by CCG code being confused by number of geometry returned
by utility functions in the case of the skipped grids.

Made it so that code is always only working with CCG data and handled drawing
code in a bit special way now.

This solves such crashes as i.e. snapping.
2015-08-03 16:44:46 +02:00
Julian Eisel
76a74e2c58 Merge branch 'master' into temp-ui-widget-refactor 2015-08-03 16:18:15 +02:00
Julian Eisel
ae50da6ea6 Cleanup: Naming, get rid of a XXX 2015-08-03 16:17:02 +02:00
4a0f3bece3 OpenSubdiv: Make new geometry relations ensures dependent data exists on CPU 2015-08-03 16:04:33 +02:00
7cfb05dcb0 OpenSubdiv: Resolve crashes when other object depends on subsurf-ed object
Cases like using subsurfed object as a boolean operand can't be evaluated
on GPU and needs to have all the CCG on CPU.

This commit resolves existing configuration to survive, but new configurations
would need to have some sort of forced object update so all the data is being
moved on CPU if it was previously on GPU.
2015-08-03 15:57:22 +02:00
b4e1b7b18c OpenSubdiv: Remove workaround for simple subdivision mode
This case is now supposed to be supported by OpenSubdiv.
2015-08-03 15:30:25 +02:00
b26eb47961 OpenSubdiv: Corrections to GLSL version
Was own mistake in the last minute fixes, now matcaps should
work just fine.
2015-08-03 15:27:42 +02:00
9036fa6b2e Fix buffer overrun lofting nurbs 2015-08-03 23:18:09 +10:00
1d549530d8 Fix own mistake in curve refactor 2015-08-03 23:06:03 +10:00
8d945bf3cb OpenSubdiv: More proper loop for UV map evaluation on CPU
This is just updating code from our side, actual evaluation is still
disabled because it doesn't support face farying data evaluation.
2015-08-03 14:50:31 +02:00
3a9897f8ce OpenSubdiv: Fix crash caused by applying subsurf on non-mesh object 2015-08-03 14:33:03 +02:00
3aa2dd74b5 OpenSubdiv: Correction to vert edge/face orientation code
non-manifold case didn't start ordering from the correct edge.
2015-08-03 14:27:34 +02:00
60c8cdf763 OpenSubdiv: Switch CPU evaluator to use uniform refinement
This way the result matches GPU viewport and becomes really close to out
legacy subsurf code.
2015-08-03 14:27:31 +02:00
4bf26fda97 OpenSubdiv: Mark non-manifold verts as sharp 2015-08-03 14:27:31 +02:00
11ad18c82a OpenSubdiv: Disable topology check happening from OpenSubdiv side
This check doesn't handle multiple non-manifolds cases which is rather
really annoying currently.
2015-08-03 14:27:31 +02:00
dd1e7f16ca OpenSubdiv: Work on better vert edge/face orientation code
Previous version of code didn't handle cases like hourglass connectivity
with loose edge. The new code is supposed to handle all this cases.
2015-08-03 14:27:31 +02:00
c2c4e02d41 Fix T45620: Coplanar faces w/ flipped normals not selected 2015-08-03 20:47:37 +10:00
1b8afac652 Cleanup: remove redundant normalize 2015-08-03 20:47:36 +10:00
Martijn Berger
230d93ad54 Fix bgl so that get-methods that take a string use strings instead of bgl buffer objects again 2015-08-03 12:20:08 +02:00
42d65ef5cc Add bool parser for PyArg_ParseTuple
Use for mathutils.bvhtree
2015-08-03 20:00:16 +10:00
0f690e2186 Fix T45625: Unpredictable grid fill
Detect when there are < 3 corners & automatically calculating the span isn't useful.
2015-08-03 17:44:50 +10:00
1dd4e933d8 Fix grid-fill offset option
Wasn't applied relative to the active vertex.
2015-08-03 16:14:22 +10:00
88d63905a8 Fix T45644: bpy.utils.smpte_from_frame drops frame
D1444 by @lichtwerk, with minor fix & docstring updates
2015-08-03 14:01:24 +10:00
Julian Eisel
73310f25fe Add widget type for search menu back 2015-08-03 01:02:05 +02:00
Julian Eisel
4db51cf00e Add widget type for preview widget 2015-08-03 00:29:31 +02:00
Julian Eisel
e28f359007 Merge branch 'master' into temp-ui-widget-refactor 2015-08-02 23:58:23 +02:00
Julian Eisel
e022e44af0 Minor Cleanup 2015-08-02 23:57:51 +02:00
00857bec52 Fix T45649: Adding Point Density Texture to World Color Crashes Blender.
Crash was caused by missing field in NodeShaderTexPointDensity.

Committed with @dingto blessings.
2015-08-02 23:46:38 +02:00
Julian Eisel
e896f4e77d Use auto-offset after adding node from search menu as well 2015-08-02 15:42:16 +02:00
93d1acfb5c correct ifdef 2015-08-02 23:36:42 +10:00
4cf92c4831 Aduaspace: fixing playback in the game engine. 2015-08-02 11:27:02 +02:00
559e1434d8 parenthisize macro args to avoid errors 2015-08-02 13:54:06 +10:00
a4f55617d1 Cleanup: quiet int overflow warnings 2015-08-02 12:53:12 +10:00
Julian Eisel
3b4a8f1cfa Fix VSE showing FPS during scrubbing
Was intended to be disabled in rBa3b86611a8182, but disabled 3D View FPS drawing instead of VSE drawing. Triple checked but 3D View doesn't draw FPS now, so everything seems fine now.

Note: To recreate this you had to play animation once before scrubbing.
2015-08-02 00:10:52 +02:00
Julian Eisel
2ec0d53034 Fix VSE not able to playback after scrubbing (and a couple of crashes)
After scrubbing, Blender kept thinking an animation is played (see animation "Play" button), even after mouse release. This resulted in a couple of crashes, e.g. by pressing Alt+a and then Esc.

(Also minor cleanup)
2015-08-01 23:59:39 +02:00
Julian Eisel
a3c5de3e3c Use Auto-offset for move_detach_links (alt+D) operator too 2015-08-01 21:01:14 +02:00
Julian Eisel
6098e48d0c Correction to previous commit, git messed up icon binaries :/ 2015-08-01 18:35:42 +02:00
Julian Eisel
47bc66fc8d Note Editor: Auto-offset nodes on insertion
Implements "Auto-offset" (called "insert offset" in code) feature for Node Editor, developed during and after LSOC :)
Idea and sponsoring by Sebastian König, blendFX, Mathias Eimann, Mikavaa, Knick Design

When you drop a node with at least one input and one output socket onto a an existing connection between two nodes, Auto-offset will, depending on the direction setting, automatically and animated move the left or right and all of its following nodes away to make room for the new node.
The direction for offsetting can be toggled while you are moving the node by pressing „T“.

The auto-offset is enabled by default but can be disabled in the header of the node-editor. The offset margin can be changed in the editing section of the User Preferences.

Thanks a lot to the sponsors, and especially to Sebastian who helped *a lot* with this. That's how users can help developing Blender!
2015-08-01 17:56:44 +02:00
Julian Eisel
31bf82c17d Node Editor: A bunch of new utility functions
Needed for node insert offset (Auto-offset in UI), but kept separate so people notice it without having to check insert offset commit (not for commit ratio of course ;) )
2015-08-01 17:23:32 +02:00
Julian Eisel
fa1945c9e5 Allow accessing modal keymap strings directly from keymap
Previously you had to pass operator which in some cases might not be available or hard to get.
2015-08-01 13:01:30 +02:00
2904007d31 Docs: Python API, minor edits to download link 2015-08-01 20:10:25 +10:00
e31f8e756f Fix T45582: Connect vertex hangs
With multiple branches it was possible the search could run for a long time,
especially when there was no possible path to the target.

Now use a heap to keep track of the best path and finish immediately once its reached.
2015-08-01 19:04:09 +10:00
0e9051fbfe BMesh connect pair, fallback to identity matrix
For overlapping vertices, a matrix for the operation can't be calculated.
2015-08-01 15:11:45 +10:00
d894fcb799 Replace checks for tessface w/ polygons
In these cases we're only checking the mesh has faces.
2015-08-01 14:42:14 +10:00
c851d1d045 Missed when updating effects to looptri 2015-08-01 14:37:20 +10:00
c4b2bef163 Remove MFace use w/ cloth 2015-08-01 14:13:59 +10:00
49f88326af Docs: doxy cleanup/minor edits 2015-08-01 12:37:52 +10:00
1c626f823d Complete fix for T45618
Two issues here, normal update was not happening due to own sillyness in
viewport refactor, also normal update code still used triangles.
Now reused Campbell's poly normal recalculation code.
2015-07-31 22:52:37 +02:00
Dalai Felinto
527ee3f1f1 Fix T45632: motion blur (2d filter) not working - in OSX at least
This regression was introduced in Blende 2.73a when we went through a
ghost context refactoring :(
2015-07-31 16:45:05 -03:00
03f00eb91d Docs: doxy corrections 2015-07-31 23:44:37 +10:00
12b7850d4f Cycles: Fix for transmissive microfacet sampling
This is an alternate fix for T40964 which resolves bad handling of
caustics reported in T45609.

There were too much transmission rays being discarded by the original
fix, which caused by caustic light being totally disabled. There is
still some room for investigation why exactly original paper didn't
work that well, could be caused by the way how the pdf is calculated.

In any case current results seems rather correct now.
2015-07-31 13:46:58 +02:00
Julian Eisel
6cad17291c Merge branch 'master' into temp-ui-widget-refactor 2015-07-31 13:46:37 +02:00
55fead4767 Use polygon normals for sculpt drawing
Wasn't working correctly since using MLoopTri,
this is improved over 2.75 which only handled tris & quads.
2015-07-31 21:04:23 +10:00
31fe49626f Remove MFace use w/ softbody 2015-07-31 19:17:39 +10:00
63215aea6f Use looptri's for softbody face collision 2015-07-31 19:01:51 +10:00
70f8b5b1ff Don't calculate tessface before sculpting 2015-07-31 16:19:58 +10:00
7575dbaf2a Docs: MLoopTri info and example usage 2015-07-31 15:41:07 +10:00
c582e186d9 Replace MFace w/ vert-tri's for collision modifier
Note that the collision modifier doesn't have any use for Loop indices,
so to avoid duplicating the loop array too,
MVertTri has been added which simply stores vertex indices (runtime only).
2015-07-31 14:00:07 +10:00
6b7313be94 Don't initialize CDDM with MFace from Meshes
Caused crash because MFace is no longer a layer which is added unless requested,
causing CDDM to have numTessFaceData nonzero, but mface set to NULL.
2015-07-31 11:57:50 +10:00
4d4c3b36a7 Cleanup: Remove unused variable in PathState. 2015-07-30 21:07:37 +02:00
2ec00ea0c1 Move tangents and baking to looptris:
Notes:

* Code in rendering and in game engine will still convert
tangents to a tessface representation. Added code that
takes care of tangent layer only, might be removed
when BGE and rendering goes full mlooptri mode.

* Baking should work discovered some dead code while
I was working on the patch, also tangents are broken
when baking from multires (also in master), but those
are separate issues that can be fixed later.

This should fix T45491 as well
2015-07-30 14:43:58 +02:00
9d335d29c7 CustomData: quiet error on 0 element copy 2015-07-30 22:14:59 +10:00
2ae67de944 Fix T45577 tiled sculpting not working with brushes requiring a sculpt
plane.

Make sure sculpt plane is recalculated for every tiled dab.

Note this is not the optimum thing to do, we could cache the original
sculpt plane and reuse that, but this would require us to rearrange the
logic of tiled sculpting somewhat. This can be a TODO, but for now this
will fix the issue.
2015-07-30 14:10:54 +02:00
820d191626 OpenSubdiv: Add CMake option to enable -Werror in subsurf code 2015-07-30 10:31:22 +02:00
5c7cdfcb42 OpenSubdiv: Remove debug-only leftover 2015-07-30 10:22:31 +02:00
7b8230898e Cleanup: safe-free macro for collision modifier 2015-07-30 15:44:03 +10:00
5fabcd099b Use looptri for smoke bvhtree
Missed from D1424
2015-07-30 14:52:55 +10:00
75e387d6c5 error reordering args 2015-07-30 09:58:00 +10:00
4737b12462 Cycles: Fix issue in closure merge function.
* Did not check data2, this partially fixes T45583.
* Initialize data2 in some closures to avoid potential problems.

Differential Revision: https://developer.blender.org/D1436
2015-07-29 22:04:36 +02:00
d49703b298 Fix SCons path issue on Windows. 2015-07-29 21:48:24 +02:00
7380166db2 OpenSubdiv: Workaround for vertices which are adjacent to several manifold islands 2015-07-29 18:41:05 +02:00
26c1ae81be OpenSubdiv: Proper detection of crease changes 2015-07-29 18:05:29 +02:00
48c2f7b288 OpenSubdiv: Some debug-only code sneaked into previous commit 2015-07-29 17:43:43 +02:00
51c1927ccb OpenSubdiv: Make topology orientation optional 2015-07-29 17:41:57 +02:00
717a303a18 OpenSubdiv: Fixes for crease in non-manifold meshes
Basically non-manifold edges are expected to be sharp by OpenSubdiv.

There\s still some work required, see the inlined comment.
2015-07-29 17:38:06 +02:00
ce5e62b78a OpenSubdiv: Typo fixes in comments 2015-07-29 17:13:15 +02:00
b8e2b8ae8a OpenSubdiv: Rework vert-edge and vert-face ordering
Now the code survives multiple non-manifolds happening on the vert.

Still not totally optimal but at least gives much better mesh support.
2015-07-29 17:13:15 +02:00
af6bbab5b4 OpenSubdiv: Fix for weirdly ordered lines 2015-07-29 17:13:15 +02:00
becf20e29f Fix T45605 crash with editmode selection on solidify modifier.
Looks like derivedmesh draw code always assumed a mesh is available.
Make sure that if we use a bmesh, a flag is used to control that.
2015-07-29 16:22:01 +02:00
30679179dd Audaspace: fixes for building with Quicktime on Mac. 2015-07-29 16:13:22 +02:00
a3b86611a8 Do not show fps while scrubbing. 2015-07-29 15:15:55 +02:00
cbf936a332 Gooseberry animation feature: Add toggle that disables modifiers on fcurves.
Feature is found as per channel option in graph editor.
2015-07-29 14:56:03 +02:00
ce1bc1838b Clean channels tool for Hwoozeberry.
Basically it's a clean keyframes tool, but also removes a channel if the
only remaining keyframe has the default value only and is not used by
drivers or generative modifiers.

It's was used to help with performance of keyframe-heavy scenes in
gooseberry.

Note, as always the curve left after the clean tool is used is not the
same as the original, so this tool is better used before doing custom
editing of fcurves and after initial keyframe insertion, to get rid
of any unwanted keyframes inserted while doing mass keyframe insertion
(by selecting all bones and pressing I for instance)
2015-07-29 14:45:50 +02:00
18af73e461 Add mathutils.bvhtree API
Originally D966 by @lukastoenne, with own additions

- trees can be initialized from Object's, BMesh,
  or passed in as vert+polygon arrays.
- original indices of ngons/faces are used. (instead of tessellated indices).
- ray_cast, find_nearest methods
- find overlapping faces between 2 trees
2015-07-29 21:24:12 +10:00
ba32d9d4cd Expose bvhtree_sphereray_tri_intersection for general use 2015-07-29 21:22:28 +10:00
8e9534a850 OpenSubdiv: Make empty meshes supported and not crashing 2015-07-29 13:10:19 +02:00
8b84c5f9de Port optimization from gooseberry branch:
Treat scrubbing as animation.

This is checked during various updates to avoid
some costly calculations.
2015-07-29 12:52:03 +02:00
18c0a15e1e Cleanup 2015-07-29 20:18:22 +10:00
90655d06d4 Math Lib: add isect_tri_tri_epsilon_v3 function 2015-07-29 20:11:54 +10:00
792d66527b Remove not really helpful debug print
If it's still considered useful please move it inside G.debug or ifdef code.
2015-07-29 12:01:41 +02:00
d4b5dd31a3 ImBuf: Fixes for openexr images
- Fixed crash loading multilayer EXR
- Fixed another memory leak loading multilayer EXR
2015-07-29 11:59:29 +02:00
32157d8d01 Triangulate wasn't clearing arena after each use 2015-07-29 12:01:55 +10:00
339915a962 Optimize PySequence_Fast usage
Access arrays directly, avoiding type-check every time.
2015-07-29 10:49:35 +10:00
96f08bf9a8 Fix leaks in mathutils PySequence_Fast usage 2015-07-29 10:49:35 +10:00
376e4c945e Fix leak in BPy_BMElem_PySeq_As_Array
Also add BPy_BMElem_PySeq_As_Array_FAST
2015-07-29 10:49:34 +10:00
d226a4ba6d Fix leak in PyC_AsArray
Would only happen when the list-length was an unexpected size.

Also add PyC_AsArray_FAST
2015-07-29 10:49:34 +10:00
31cb14f5de Cleanup: check exact error w/ mathutils functions 2015-07-29 10:49:34 +10:00
cff71fee21 Cleanup: style 2015-07-29 10:49:34 +10:00
Dalai Felinto
c6688aeddd Fix build with Quicktime after Audaspace update 2015-07-28 21:48:13 -03:00
335c3013f4 Sequencer: Disable Refresh Sequencer button while rendering
This code is not thread-safe and there's no easy way to synchronize
render and viewport threads for this operation, so for until we've
got some nicer solution we just disable dangerous buttons.
2015-07-28 18:28:35 +02:00
79a51f0839 cdderivedmesh: don't prepare a normal buffer when selecting, even
if we skip creating the selection color layer.
2015-07-28 18:24:21 +02:00
1e6e3dcbd7 Fix T45529: Texture Compositor node composition artifact (random pixels)
The issue was caused by the non-threaded texture API used by the node.
While the node itself is single threaded there might be texture nodes
in different execution groups running in parallel.
2015-07-28 17:56:04 +02:00
20c5c5e14b Audaspace: fixing a memory access violation in the audio device list. 2015-07-28 17:40:36 +02:00
a6b2650c7d Cycles: Correction to image extension type commits
Clipping wasn't working totally correct, need to check original coordinates,
not the integer ones,

Now CPU gives the same exact results for both SVM and OSL, CUDA is still doing
something crazy with edges.
2015-07-28 16:31:27 +02:00
971affb436 Fix T45590: Some more missing glsl functions
Also SSS node was using wrong Normal input index.
2015-07-28 15:57:14 +02:00
be047fe455 Audaspace: building without audaspace.
- Fixed building without for cmake.
- Scons can now build without audaspace too.
2015-07-28 14:53:06 +02:00
f29625922f Cycles: Expose Clip image extension type
This type causes pixels outside of 0..1 coordinate range to become transparent.
2015-07-28 14:39:53 +02:00
4690281b17 Cycles: Add implementation of clip extension mode
For now there's no OpenCL support, it'll come later.
2015-07-28 14:36:08 +02:00
3fba620858 Cycles: Prepare for more image extension types support
Basically just replace boolean periodic flag with extension type enum in the
device API.
2015-07-28 14:14:24 +02:00
29ebb56f4d Audaspace: support the device list returned by the new audaspace library.
- use the device names returned from the library.
- system settings UI changed as new audaspace might contain longer and more device names.
2015-07-28 14:01:53 +02:00
a0cbebf404 Audaspace: fixing problems for the merge to master suggested by Campbell and Sergey.
- rename WITH_EXTERNAL_AUDASPACE to WITH_SYSTEM_AUDASPACE.
- rename C/PYAUDASPACE to AUDASPACE_C/PY
- simplifying cmake defines and includes.
- fixing include paths and enabling WITH_SYSTEM_AUDASPACE for windows.
- fixing scons building.
- other minor build system fixes.
2015-07-28 14:01:53 +02:00
58956f3b91 Audaspace: fix the new wm_playanim.c (from gooseberry branch) to use the new API. 2015-07-28 14:01:52 +02:00
f700c1f3a8 Audaspace: name fixes and external library update. 2015-07-28 14:01:52 +02:00
009bb9e5c9 Audaspace: adapt internal C-API naming to external audaspace library. 2015-07-28 14:01:52 +02:00
8528d76dad Audaspace: external audaspace library update. 2015-07-28 14:01:52 +02:00
733073550f Audaspace: use standalone library.
- Added the cmake configuration option WITH_EXTERNAL_AUDASPACE.
- Fixes to build without standalone library as well.
2015-07-28 14:01:52 +02:00
96dd213e7e Audaspace: preparing to use standalone library.
- Renamed some functions.
- Using C API instead of C++ in the game engine, as the standalone is C++11.
2015-07-28 14:01:52 +02:00
d3acfa1d87 BGE: Navmesh fixes and improvements
The navigation mesh functionality was broken for quite a while. This patch
contains fixes: recalculating tesselations before getting the number of
tesselation faces (it otherwise returned 0) before calculating the navmesh,
and calling `DM_ensure_tessface()` on the navmesh's `DerivedMesh` object
(which fixes visualisation in Blender). This allows one to create a new
navmesh, which also works in the BGE.

Furthermore, the patch adds several return values, and shows more error
messages when things go wrong. In several places in the navmesh creation
code, return codes weren't checked and errors silently ignored.

Reviewers: nicks, brita_, campbellbarton, lordloki, moguri, panzergame

Reviewed By: panzergame

Differential Revision: https://developer.blender.org/D1435
2015-07-28 13:54:41 +02:00
038d6ce2cc Cycles: Correction to image extension setting commit
Technically it was all wrong and it should have been called Extend instead
of Clip. Got confused by the naming in different libraries.

More options are still to come.
2015-07-28 13:41:09 +02:00
c6396d9204 Fix for file unpack checking existing files
Wasn't expanding the path '//' before checking the path on-disk.
2015-07-28 21:35:35 +10:00
cd324654b0 Fix T45581: GPU failed to find function node_bsdf_refraction
This commit fixes shader tree compilation, but the shading result wouldn't be
doing actual refraction because it's a bit involved change which isn't really
considered a bug for now. There are more closures which are falling back to
diffuse BSDF currently.
2015-07-28 11:17:18 +02:00
ad7e3c302e CMake: modify recent platform defaults
Now only disable Jack and NDof on OSX

Also comment main block for platform checks
2015-07-28 17:58:47 +10:00
33bac1f401 CMake: use same defaults on all-platforms
Previously Linux had disabled libs that were enabled on other platforms.
Use a reduced feature set on all, since libs such as Jack & OSL aren't totally reliable on Win/OSX.

Keep 'option_defaults_init' since platform maintainers may want to adjust later.
2015-07-28 14:48:12 +10:00
6df3e3a959 Jpeg2000: Fixed for DCP pipeline
Profile and color space were not properly set.
2015-07-27 22:35:24 +02:00
2b632dd8c2 BGE: Fix T37074: GLSL max texture units limit
Actually for the the amount of GLSL textures units is limited by the amount of multitexture units (GL_MAX_TEXTURE_UNITS_ARB).
Most of the Nvidia graphic cards supports only 4 multitexture units, so Nvidia users can not use more then 4 GLSL textures for a custom shader.
This patch removes this limitation by using GL_MAX_TEXTURE_IMAGE_UNITS_ARB if GLSL is supported, but still limit the amount to the maximum texture limit of 8.

Reviewers: lordloki, agoose77, danielstokes, panzergame, sybren, moguri

Reviewed By: panzergame, sybren, moguri

Projects: #game_engine, #game_rendering

Maniphest Tasks: T37074

Differential Revision: https://developer.blender.org/D1389
2015-07-27 20:34:13 +02:00
7973363e34 Cycles: Final-ish tweaks for 32bit cubin compilation 2015-07-27 16:55:50 +02:00
40a866dad4 Doc fix: wolrd -> world
The documentation for bge.types.KX_WorldInfo had two typos.
2015-07-27 15:53:15 +02:00
168bb36bc9 Buildbot: Include branch name to the cmake builds 2015-07-27 14:21:20 +02:00
61e4800b45 Cycles: One more attempt to fix compilation of 32bit CUDA kernels 2015-07-27 14:18:20 +02:00
79ffa03620 Compositor: Add note that bilateral blur is not really correct
The code does stupid box filter which doesn't give nice results and doesn't
match old compositor at all. Need some better gaussian weighting here. Will
look into it later.
2015-07-27 14:15:50 +02:00
c61e4f2683 Don't allocate MFace's by default
This removes CD_MASK_MFACE from CD_MASK_BAREMESH, CD_MASK_DERIVEDMESH and others.

Callers that need it must explicitly add it to their data-masks.
2015-07-27 21:47:41 +10:00
67fe5726af Use loop data instead of face data
Replace checks in various places
2015-07-27 21:47:40 +10:00
15676bcc85 Error in looptri update, was checking wrong layer-type 2015-07-27 21:47:40 +10:00
76beb7b7d4 BGE: Fix T19241: draw debug shape with overlay/background scene.
It's for the function render.drawLine and physics debug.
2015-07-27 13:49:06 +02:00
ba146899c8 Image painting 2D:
Deprecate wrap (BRUSH_TORUS) option, we now have paint flags for tiling
and we can reuse those. Also allows seperate tiling in X/Y
direction for 2D painting now.

Only one tiling is allowed for now.

Options can be found in new "Tiling" panel under the tools tab.

For version patching, we just turn off brush wrapping,
to allow reuse of the flag in the future.
New option is paint mode wide instead of per brush so
a brush having the old wrap option will not enable it
for the whole mode in the version patch.
2015-07-27 12:55:57 +02:00
e355d557f8 CPack: Use hash of the head for the file name
Upstream is not always configured ad might give empty results.

Ideally we need to re-use the same code as we use for buildinfo,
but it's also a bit of a question which exact hash we want to put
to the name by default.
2015-07-27 12:20:16 +02:00
ce092a58a2 Buildbot: Missed this in the previous commit 2015-07-27 11:49:05 +02:00
e5d7cbd191 Buildbot: Attempt to make windows cmake builds names matching buldbot's names
Did this in packaging buildbot rule because of several reasons:

- CMake doesn't deliver name of package which we expect it to be for buildbot
- CMake doesn't really know that building happens for buildbot
- Making default CPAck name matching buildbot's naming is kinda stupid

Probably we can pass CPack name via command line arguments, but i'm happy with
the current state and one might change things in the future.
2015-07-27 11:17:57 +02:00
20ec508ca3 Replace MFace with MLoopTri in laplacian_deform 2015-07-27 18:03:09 +10:00
b74fa38581 Missed last commit 2015-07-27 16:46:12 +10:00
e48c4d73d3 Replace MFace with looptri for dynamicpaint
D1429 by @lichtwerk, with edits
2015-07-27 16:01:56 +10:00
cdf2dbeb1f Cleanup: deprecate some G.fileflags comment others 2015-07-27 10:55:19 +10:00
2fe7e60633 Fix T45563: Crash rendering hair dupli's 2015-07-27 10:04:20 +10:00
Martijn Berger
27a20c2c60 Make cmake windows 32 bit buildbot use the 120xp toolkit, restoring
windows XP compatibility

Fixes T45559
2015-07-26 21:14:24 +02:00
fb7281fb6a Fix T26141: render setting affects only first scene. 2015-07-26 18:01:56 +02:00
c27a1cfd63 Fix bug in particle API accessing the emitter 2015-07-26 12:22:23 +10:00
Julian Eisel
88ebffec96 Fix T45510: Animation channel textbox field to small
It now takes (almost) the whole available width of the region. Icons on the right hand side are hidden during text input now, they can't be used then anyway. Using this space for the text input button makes more sense.
2015-07-26 02:12:16 +02:00
Julian Eisel
1fab327fdf Fix T45562: Crashing pre 2.5 file with grid subdivisions set to 0
Seems like the original version patch for this wasn't made correctly.
2015-07-26 00:18:44 +02:00
8fa1da9213 minor cleanup, reuse existing variable 2015-07-25 22:32:55 +02:00
f1f4a16eab Convert CCGSubsurf VBO system to also sort hidden and visible faces.
It's not actually used during drawing though.
2015-07-25 22:02:43 +02:00
53f6a31c4d GPU Buffers:
This commit begins implementation of the idea about hidden face
separation outlined in

http://code.blender.org/2015/06/optimizing-blenders-real-time-mesh-

We split hidden and visible faces to different parts of the triangle
buffer.
Mapped drawing will now skip iterating through hidden polys.
Of course the final target, when all derived mesh types use
VBO sorting, is to skip checking for hide flag per face
completely. All faces will be pre-sorted anyway and we'll
be able to draw them with one draw call.
2015-07-25 20:00:49 +02:00
17e3f905e1 Style cleanup + fix sign on previous commit. 2015-07-25 18:02:07 +02:00
a6b1e281eb Cleanup - we don't need a bogus enable material function, just pass
NULL.

All derivedmesh types check if we have an enable function, we can get
rid of this.
2015-07-25 17:18:45 +02:00
e2652bc5ad Fix tile feature not working outside mesh boundaries.
We need to generate strokes up to a brush radius around the bounding
box.
2015-07-25 16:21:09 +02:00
5878050a4b Fix T45515, dynamic paint not displaying colors correctly.
Looptri refactor artifact
2015-07-25 16:16:37 +02:00
50a46a5973 GPU buffer materials:
Separate and reuse some shared code.

Also avoid counting for information we already know,
such as total loop triangles etc.
2015-07-25 14:42:26 +02:00
38e19536bf Fix compile warning in 04b369 2015-07-25 14:00:46 +02:00
04b3694d93 BGE: Fix T35454: Soft body joints crash.
Constraint on soft bodies are special and return 0 as constraint id.
So we have to check that the id is not 0 in function setParam, getParam, getAppliedImpulse and removeConstraint.
2015-07-25 13:50:15 +02:00
221aee7ecd BGE: Fix T45278 sleeping deactivation with overlay scene.
this commit fix also angular and linear threshold sleeping value update via bge.constraints.
2015-07-25 13:09:01 +02:00
9ff869e4fb Fix T45555 crash with subsurf edge drawing.
Loose edge count was double. It didn't fail on own
tests because they had a small number of loose edges,
but for bigger meshes it hit garbage indices at draw time
and crashed.

Also cleaned up the code to make it less verbose and easier to
understand how indices are counted.

Hope it's the last edge-related fix (fingers crossed)
2015-07-25 12:51:35 +02:00
9dc0fed877 Fix grease pencil selection
When zoomed in could int overflow and select the wrong vertex.

also correct clipping check.
2015-07-25 20:36:12 +10:00
8cd14d421e Fix T45553: Object parent_type 'ARMATURE' disappeared in Blender 2.75.
Own stupid mistake in rBb318795c3b3d (ideally we should really not have that kind of ugly hacks :/ ).
2015-07-25 10:39:04 +02:00
9939c18900 BGE: Fix T35288 Touch/Ray/Mouse sensor and Constraint actuator with material check doesn't work.
Now we look at all materials instead of the first. So m_auxilary_info is useless and removed.
2015-07-25 09:43:06 +02:00
e301cf3ec2 Cleanup: double-promotion warnings 2015-07-25 13:26:20 +10:00
2a286829f7 Correct check for angle-rake stroke 2015-07-25 13:07:05 +10:00
Julian Eisel
b284667681 Merge branch 'master' into temp-ui-widget-refactor 2015-07-25 00:53:16 +02:00
e4b716a03f Cleanup: warnings, style 2015-07-25 07:44:25 +10:00
5acce60d37 Compositor: Fixes for the debug pass
This commit fixes issues with wrong socket type being added to the Cycles debug
pass compositor operation, which lead to crashes with non-value pass types.

This commit also reverts socket renaming thing because while it's was behaving
ok on runtime file reload might have loose the links which is annoying.
2015-07-24 23:05:11 +02:00
7c5c7b5ef6 Fix T45537: cycles bake crashes with motionblur on
The crash was due to baking with motion blur but without a camera.

Reviewed by Brecht.
2015-07-24 21:18:17 +02:00
75f8f1907a Experiment with setting proper socket name for debug pass 2015-07-24 18:41:54 +02:00
33bd2c1597 Deduplicate some logic around debug passes 2015-07-24 17:45:14 +02:00
68a9d80739 Compositor: Make it work for debug passes other than float 2015-07-24 17:16:29 +02:00
d2fac7df32 BGE: Fix T45544 Adding Armatures takes an increasing amount of logic time
Armatures were not totaly freed (only the armature object not the armature) and the original armature user count was not decrease after replication.
2015-07-24 17:08:55 +02:00
dc80ff9b56 Fix T45541 crash when mixing flat and smooth shaded faces in sculpt
mode.

Issue from looptri merge.
2015-07-24 16:28:38 +02:00
a028575c4a Compositor: Allow using debug pass output in the compositor
Currently only works correct with single float output, RGBA and vector are not
supported so if one need to use this passes he'll need to wait a bit still.

It is coming, don't worry.
2015-07-24 15:39:09 +02:00
54e6413d67 Make it easier to create debug passes with more than 1 channel 2015-07-24 15:39:09 +02:00
6322867e54 Cycles: Don't explicitly add debug passes, this is now handled via RNA 2015-07-24 15:39:09 +02:00
eff1b54362 Fix subsurf edge drawing when more than one loose edge vert exists 2015-07-24 14:39:52 +02:00
b55ed89b66 Fix yet another issue caused by my recent changes. 2015-07-24 14:32:11 +02:00
2dce6dccbb Fix out of bounds memory access when copying loose vertices in cddm
Caused by own fix for too much allocated memory not taking all code
into account.
2015-07-24 12:24:57 +02:00
95f698f840 Adjust CMake platform dependant release options 2015-07-24 19:39:36 +10:00
d6ebf72f9f Fix for building with OpenSubdiv 2015-07-24 17:11:50 +10:00
dc6153453a Cleanup: comments (remove outdated & update) 2015-07-24 16:59:39 +10:00
7f32601159 PyAPI: update bgl to OpenGL 3.3
Adds (currently unused) deprecated option
so we can remove support for older API versions.
2015-07-24 16:48:40 +10:00
07fa1b49d9 parenthisize macro args to avoid errors 2015-07-24 15:53:52 +10:00
8d237503c5 Compile Fix: setenv() is not defined for mingw either 2015-07-24 15:08:43 +12:00
20d516dc35 Fix: Autokeying of buttons doesn't work on NLA Strip properties 2015-07-24 14:20:16 +12:00
15cb94c65a Fix: NLA Strip properties cannot be keyframed if Visual Keying/Only Needed options are enabled 2015-07-24 14:20:15 +12:00
ea3dae74d8 Cleanup: remove redundant __doc__ from bgl 2015-07-24 09:45:25 +10:00
3b362950e9 Cleanup: move defines inside bgl C source
- remove number-of-args arg from BGL_Wrap.
- use doxy groups.
2015-07-24 09:35:39 +10:00
b8481f4683 Minor cleanup - use integers for counters. 2015-07-23 23:21:19 +02:00
0c0db92d7a Sculpt Tiling Feature
Adds 3D-Tiling options to the sculpt tool. This is very similar to the
symmetry options in the sense that it replicates the strokes. For tiling
this replication happens with a linear offset to fill the whole object
along one or more axis.
This allows to create geometry that can be tiled seamless. One use case
is the creation of tileable textures by sculpting high resolution
geometry and then rendering it with an orthographic camera to create
maps for diffuse, normal, etc

Notes:

Patch by Tilman Blumhagen with minor changes (move tile flags to paint
symmetry flags).

After some feedback from artists, leaving tiling value to constant
offset, though I suspect that some method that uses the object
bounding box dynamically might be good to have too. It can
be added later though :)

Thanks a lot for the patch!

Patch: D1426
2015-07-23 22:52:27 +02:00
36630b7e85 Fix memory leaks mesh w/ mesh remapping 2015-07-24 05:04:33 +10:00
d47e565598 Subsurf: Optimize edge drawing, now it uses VBOs.
Also the refactor exposed an error where we requested too much
memory from the video memory in general for all mesh types.

Now we are back to normal :)
2015-07-23 20:02:57 +02:00
b3ac7c07ff Added NlaStrip.fcurves.find(data_path, array_index=0)
This is the same as D1427 / 89e5c75666
except for NlaStrip.fcurves instead of Action.fcurves. It makes finding
a specific fcurve in Python much easier, as you don't need a Python-side
loop any more.

Reviewers: aligorith

Reviewed By: aligorith

Differential Revision: https://developer.blender.org/D1430
2015-07-23 15:38:25 +02:00
0e2bbd0904 Freestyle: Fix for round/square stroke caps causing line thinning.
This is a regression introduced in rBce729677db3e and rBb408d8af31c9.

RoundCapShader and SquareCapsShader had to remove (almost) overlapping
stroke vertices to avoid sudden thinning of line thickness.  For instance,
the test .blend file from https://developer.blender.org/T36425#231460
suffered from the reported line thinning (although T36425 was originally
caused by a different bug).
2015-07-23 20:29:23 +09:00
6ee2f79f33 Cycles: Previous commit broke compilation on Windows
Apparently MSVC doesn't have setenv() function.
2015-07-23 12:53:23 +05:00
1788293a01 Fix T45381: Crash Blender 2.75 in Win7 x64 AMD card
Previous fix didn't work well enough because on Windows Python has different
environment than Blender ans setting variables in there made no effect from
Blender point of view.
2015-07-23 12:10:38 +02:00
cc5d48e8dd Use looptri for sampling UV's in smoke.c
D1424 by @scorpion81
2015-07-23 20:08:26 +10:00
253f416a36 Fix regression of custom nodes not triggering material preview re-render
Issue was introduced in b0df196.It's not the nicest ever solution but it's
quite close to be as nice as we can do it with current custom nodes and
notifier system design.
2015-07-23 11:50:13 +02:00
08fbc303e1 Cycles: Resolve compilation error of avx2 kernel with certain compilers
It was redefined macro happening with Clang 3.6 here.
2015-07-23 11:48:54 +02:00
4be7fb7651 ImBuf: Fix OpenExr leaking memory when reading file with IB_test flag 2015-07-23 09:11:26 +02:00
b6cf4f777d Use looptri for smoke collisions & particle edit 2015-07-23 17:07:14 +10:00
5c98848895 Use looptri for RNA BVH functions 2015-07-23 15:40:47 +10:00
6aabc1bde4 Cleanup; duplicate header 2015-07-23 15:40:47 +10:00
0a249f9853 Cleanup: arg names 2015-07-23 15:17:26 +10:00
abbd82a504 Use looptri for mesh remapping 2015-07-23 15:10:12 +10:00
8155d25d39 Utility function to get poly -> looptri mapping 2015-07-23 15:08:27 +10:00
60822ec183 Use looptri for BVH raycast (simple cases) 2015-07-23 14:41:09 +10:00
717046ad2a Use looptri for volume snapping 2015-07-23 14:41:09 +10:00
748899a50a Missed adding BVH callbacks in recent commit 2015-07-23 14:41:09 +10:00
0bf2b207e2 Add missing break checking for tangents 2015-07-23 11:51:03 +10:00
368bd34573 Mesh Deform: support for ngons when binding
Weights were calculated using tessellation data, giving slightly uneven weighting.
Now only use tessellation for ray-cast but weight the influences from the original polygons.

Also cache arrays from derived-mesh, they we're called each intersection.
2015-07-23 11:30:47 +10:00
0b7d0f913d Fix weight painting + mask not drawing in latest master.
Same issue as vertex painting - though one might wonder if we really
need to set material on such occasions.
2015-07-22 16:58:18 +02:00
0795f62ddf GPU debug: Only flush stderr if needed. 2015-07-22 13:57:57 +02:00
5983280b4f Use looptri for MeshDeform modifier 2015-07-22 21:40:45 +10:00
b604d5ade0 Add bvhtree_from_mesh_looptri utility function 2015-07-22 21:40:45 +10:00
b305041ce6 Add DM_get_looptri_array utility function 2015-07-22 21:40:41 +10:00
a6f00bb75c Use doxy sections in bvhutils 2015-07-22 21:32:14 +10:00
df41f7bf4f Use const for BVH mesh arrays 2015-07-22 21:32:14 +10:00
f9a6780dc6 Cleanup: use struct for storing callback data 2015-07-22 21:32:14 +10:00
75d1723518 OpenSubdiv: Optimize speed of topology refiner construction
Now the conversion code uses mesh element mapping to speed up lookups.
Gives really nice speed improvement here, but the cost is higher memory
usage during refiner construction.

On the dragon scene here topology refiner construction time goes down
from 5 seconds to around 0.01.

It's possible to reduce the memory footprint by allocating mapping in
stages (don't allocate all of them at once, but do it on demand only
and free them after they're not needed anymore).
2015-07-22 12:51:10 +02:00
461340525e OpenSubdiv: Resolve crash when trying to do weight mcol 2015-07-22 12:01:38 +02:00
945f32e66d Fix crash with recent refactor of customdata writing.
Caused by own rBff3d535bc2a6309 - since we now only write the exact amount of layers
needed to store saved customdata, we have to adjust CustomData->maxlayer too.

Otherwise, on next read, customdata code believes it has more layers allocated than
actual number.

Issue reported by Campbell over IRC, thanks.
2015-07-22 11:58:18 +02:00
cf6002737d Don't make Python classes of StructRNA on startup
This gives small start time speedup, classes are lazy loaded instead.

Keep existing behavior in debug builds to catch any errors early.
2015-07-22 19:51:03 +10:00
3dd8f287e1 Render preview: Make preview render database lazily loaded
Gives about 5-10% of startup time improvement here.
2015-07-22 11:25:21 +02:00
ec8b7edf53 Fix: solved issue with "make doc_py"
The error was "ValueError: Function <function normal_at_I0D at 0x7f2aad1feb70>
has keyword-only arguments or annotations, use getfullargspec() API which can
support them", and was first seen in eeeb845d33
2015-07-22 10:31:31 +02:00
e3461a02ac Fix T43779: Cycles texture interpolation issues
That was basically not an issue with interpolation, but rather missing wrapping
options and periodic wrapping was always used.

It's still a bit questionable why certain graphics cards were doing clamping in
the file from the report, that's not something what is expected to happen from
the settings of textures being passed to GPU. In any case this issue i still
didn't manage to reproduce on any of the available GPUs, might be something
related on driver glitch or so.

In any case CPU now should behave just fine, rest of the issues we'll need to be
able to reproduce first.
2015-07-21 22:13:25 +02:00
f2c54df625 Cycles: Expose image image extension mapping to the image manager
Currently only two mappings are supported by API, which is Repeat (old behavior)
and new Clip behavior. Internally this extension is being converted to periodic
flag which was already supported but wasn't exposed.

There's no support for OpenCL yet because of the way how we pack images into a
single texture.

Those settings are not exposed to UI or anywhere else and there should be no
functional changes so far.
2015-07-21 21:58:19 +02:00
dc3563ff48 Cycles: Implement camera zoom motion blur
Works totally similar to camera motion blur and majority of the changes are
related on just passing extra arguments to sync() functions.

Couple of things still to look into:

- Motion pass will not include motion caused by the zoom.
- Only perspective cameras are supported currently.
- Motion is being interpolated on projected coordinates, which might give
  different results from constructing projection matrix from interpolated
  field of view.

  This could be good enough for us, but we need to consider improving this
  at some point.

Reviewers: juicyfruit, dingto

Reviewed By: dingto

Differential Revision: https://developer.blender.org/D1383
2015-07-21 17:40:03 +02:00
1df42798d4 Try to remap buffer before rejecting.
I suspect code here can be cleaned up but for now try this.
Alternatively we can check for errors around buffer allocation
but this needs bigger changes.
2015-07-21 16:41:13 +02:00
89e5c75666 Added Action.fcurves.find(data_path, array_index=0)
Finding a specific F-Curve is often needed in Python, and usually
consists of a construct like:

```
 [fcurve
  for fcurve in ob.animation_data.action.fcurves
  if fcurve.data_path == "location"][1]
```

This can now be written as
`ob.animation_data.action.fcurves.find('location', 1)`

This new function `Action.fcurves.find()` is still O(N) in the number
of FCurves in the Action, but at least it allows us to remove
boiler-plate code. It is also faster than the Python equivalent, as
only the found F-Curve is converted to Python.

Reviewers: campbellbarton, aligorith

Reviewed By: aligorith

Differential Revision: https://developer.blender.org/D1427
2015-07-21 16:01:26 +02:00
e7fc8d98f5 Failure to alllocate vertex buffer would not fall back to vertex array
properly.

This should fix failure to use vertex arrays in OSX with high
polycounts.

Note this will not suffice as a fix when we move to VBOs exclusively
(GL 3+), we'll have to think of some way to separate huge meshes to many
VBOs.
2015-07-21 15:42:11 +02:00
78041fa14a Fix: fixed UI description of Action.new() function 2015-07-21 14:44:48 +02:00
9ae39a1312 Math Lib: use vector funcs for isect_line_line_v2_point 2015-07-21 21:49:29 +10:00
ff3d535bc2 Fix T45471: Blend file: Bad old_addr handling in mesh's customdata writing.
Issue is rather well explained in T45471: our current customdata writing code easily generates several different blocks in blend file with same 'old' address. This is bad, because those addresses are used as 'uid' during reading process (it kind of work in Blender's own reading process, by mere luck mostly, but breaks the file specs).

Solution (suggested by Campbell, thanks) implemented by this patch is to avoid duplicating everything, and instead just overwrite what we needs to skip some cdlayers on write:
* the CustomData's `totlayer` number;
* the CustomData's `layers` array of CustomDataLayer (keeping its original address using the `writestruct_at_address` helper).

New design allows us to get completely rid of the no_free flag stuff in `write_customdata()`.

Note that this implies written data is **not** directly valid from Blend PoV, since its written typemap does not match written layers (this is not an issue because typemap is rebuilt on read anyway - and it's easy to fix this if really needed).

Also, the backward compatibility saving of mface data remains an issue here, see comment in code.

Reviewers: sergey, campbellbarton

Projects: #bf_blender

Maniphest Tasks: T45471

Differential Revision: https://developer.blender.org/D1425
2015-07-21 12:02:11 +02:00
b91d64a3d1 Cycles: Another attempt to solve CUDA compilation errors on 32bit platforms 2015-07-21 11:42:59 +02:00
b0df19667f Fix T45317: Cycles material preview unnecessarily re-rendering
The issue was caused by wrong fix for T22741 which forced redraws on any window
event, like Expose. Use proper NV_WM | ND_UNDO listener instead,
2015-07-21 11:26:42 +02:00
b23c6c430f Fix assert in Outliner. 2015-07-21 10:43:22 +02:00
7ae44e8a30 Cycles: Workaround for sm_50 on 32bit platform
Basically this commit totally disables new SVN Voxel node, which solves some
of the compiler's issues.
2015-07-21 10:18:04 +02:00
23831b2161 Cleanup: style 2015-07-21 17:29:23 +10:00
ae00011956 Fix T45496: Crash loading file during preview
Regression from multi-view
2015-07-21 16:02:27 +10:00
9eb6dcbb46 Fix T45453: Driver button's ignore DPI 2015-07-21 15:30:34 +10:00
a48db0894a Fix T45363: Bone attrs ignore editing all selected 2015-07-21 15:22:32 +10:00
39cf1de33d Fix Clear vertex group ignoring selected option
Thanks to @chadf for spotting
2015-07-21 14:35:48 +10:00
9dc9f84740 Fix T45458: Edge Slide Mirror doesn't preserve UVs 2015-07-21 14:15:31 +10:00
5e1a8055f4 Fix T45361: Camera does not rotate in walk mode 2015-07-21 13:02:11 +10:00
3c911ff8a5 Fix T45450: Loop-select fails to cycle between overlapping edges 2015-07-21 12:27:41 +10:00
1d9fbdc9a0 Fix T45455: Select linked issue w/ hidden faces 2015-07-21 12:02:11 +10:00
1d02d34de9 Fix T45434: GPencil on editmode surface fails
Z-offset use for drawing & picking was problematic for extracting locations from depth values.

Use flag to optionally disable.
2015-07-21 11:12:39 +10:00
ef950d6937 Fix T45502: Crash showing thumbnails 2015-07-21 10:01:42 +10:00
2bfa950438 Cleanup: warning 2015-07-21 09:54:23 +10:00
b5f282b211 Remove nonnull attribute, NULL arg is valid here. 2015-07-21 09:41:48 +10:00
30772b6f09 SCons: Weirdly enough at some point scons became broken in OpenSubdiv branch 2015-07-20 22:43:13 +02:00
3d36489672 OpenSubdiv: Commit of OpenSubdiv integration into Blender
This commit contains all the remained parts needed for initial integration of
OpenSubdiv into Blender's subdivision surface code. Includes both GPU and CPU
backends which works in the following way:

- When SubSurf modifier is the last in the modifiers stack then GPU pipeline
  of OpenSubdiv is used, making viewport performance as fast as possible.

  This also requires graphscard with GLSL 1.5 support. If this requirement is
  not met, then no GPU pipeline is used at all.

- If SubSurf is not a last modifier or if DerivesMesh is being evaluated for
  rendering then CPU limit evaluation API from OpenSubdiv is used. This only
  replaces the legacy evaluation code from CCGSubSurf_legacy, but keeps CCG
  structures exactly the same as they used to be for ages now.

This integration is fully covered with ifdef and not enabled by default
because there are several TODOs to be solved first:

- Face varying data interpolation is not really cleanly implemented for GPU
  in OpenSubdiv 3.0. It is also not implemented for limit evaluation API.

  This basically means we'll have really hard time supporting UVs.

- Limit evaluation only works with adaptivly subdivided meshes so far, which
  basically means all the points of CCG are pushed to the limit. This gives
  different result from old code.

- There are some serious optimizations possible on the topology refiner
  creation, which would speed up initial OpenSubdiv mesh creation.

- There are some hardcoded asumptions in the GPU and DerivedMesh areas which
  could be generalized.

  That's something where Antony and Campbell can help, making it so the code
  is structured in a way which is reusable by all planned viewport projects.

- There are also some workarounds in the dependency graph to make sure OpenGL
  buffers are only freed from the main thread.

Those who'll be wanting to make experiments with this code should grab dev
branch (NOT master) from

  https://github.com/Nazg-Gul/OpenSubdiv/tree/dev

There are some patches applied in there which we're working on on getting
into upstream.
2015-07-20 22:29:26 +02:00
2466c4f8ce OpenSubdiv: Add OpenSubdiv files which are related on the CCGSubSurf and GPU
Those files are still not in use (SCons will tyr to compile new CCGSubSurf files
but no code will be in use at all because those new files are fully wrapped by
ifdef WITH_OPENSUBDIV check).
2015-07-20 22:29:25 +02:00
a040157e5d OpenSubdiv: Add new OpenSubdiv related files
This includes C-API bindings in intern/opensubdiv and CMAke module
which finds the OpenSubdiv library. This filea are not in use so
far, making it a separate commit to make actual integration commit
more clear.
2015-07-20 22:29:25 +02:00
ccc3c2dbda CCGSubSurf: Split file into several smaller ones
This is a preparation commit for having OpenSubdiv integrated into Blender
and new layout is the following:

- CCGSubSurf.c contains implementation of common functions used by both
  legacy subdivisions code and by the new code in the future.

- CCGSubSurf_inline.h contains internal functions which are to be inlined
  due to the performance reasons. Those functions are only ment to be used
  bu CCGSubSurf* files.

- CCGSubSurf_intern.h contains declarations of private functions and data
  structures used by CCGSubSurf module.

- CCGSubSurf_legacy.c contains legacy implementation of subdivision algorithm.

- CCHSubSurf_util.c contains utility functions which are not directly related
  on the subdivision code (i.e. debug functions, hash implementation etc).

There should be no functional changes so far.
2015-07-20 22:29:25 +02:00
6190d75b5a Usual UI messages fixes. 2015-07-20 22:22:31 +02:00
a4a3d5650d Minor optimization in CustomData_update_typemap(). 2015-07-20 17:28:29 +02:00
66dd9fbf22 Fix (unreported) broken MixWeight modifier in debug builds.
defvert_find_index() & co now assert when '-1' invalid vgroup index is passed.
We used to rely on NULL value returned in this case, but with the assert...

The assert completely stalls blender actually (repeated for every vertex!).
So much better to not call that func when vgroup index is invalid.
2015-07-20 16:55:46 +02:00
9ee1f96a0f Fix (unreported) potential serious bug in CustomData_merge().
It was always only using the flags from the first source layer of a given type, not from
the layer actually being handled.

This was (probably) more or less harmless for the CD_FLAG_NOCOPY test,
but could be really bad when checking CD_FLAG_NOFREE, and when
copying the flags over to new copied data!
2015-07-20 16:25:01 +02:00
40d4da829c Fix/Workaround for CMake buildinfo error
Correcting the paths for buildinfo to point to the real header,
ended up breaking buildinfo (by not running every build).

It turns out we relied on the output _never_ existing,
so CMake generates a new buildinfo each time.
This is quite bad, but I didn't see a way for CMake to do this,
so explicitly point to a missing file and comment whats going on.
2015-07-20 23:27:56 +10:00
432d24f998 Fix recent own stupidity with indexed sculpt drawing. 2015-07-20 15:28:05 +02:00
ed3b19f46d Ugly hack to avoid GLEW context error printing when initializing GLX. 2015-07-20 14:56:36 +02:00
db38a65b02 Filter the debug callback to only report errors unless debug value is
20.

stderr was getting flooded with too many error messages, most of which
were not really relevant.
2015-07-20 14:46:11 +02:00
2e2164d5d4 Resolve compiler warning for clang 2015-07-20 22:31:19 +10:00
Julian Eisel
f2c6b7cdda Fix search menus being drawn transparent
Reverts rBb22061e98946a. Don't think it's worth using an extra widget type for this.
2015-07-20 13:33:45 +02:00
Julian Eisel
d2fc12d73e Add widget type for separator line 2015-07-20 12:50:57 +02:00
87328bde47 Fix T45218: Crash when trying to open System in the User preferences
Fix T45381: Crash Blender 2.75 in Win7 x64 AMD card

The issue is basically caused by graphics card driver which crashes when
querying OpenCL platforms. This isn't something we can really solve from
the CLEW side, because opencl.dll does exist in old driver and even has
all the needed symbols, but first ever call to clGetPlatformIDs crashes.

While rest of the blender works fine with those older ATI/AMD cards it's
really needed to solve crashes of OpenCL device enumeration.

Solution here is to force disable OpenCL platforms if we've detected that
display card is using old ATI/AMD driver. It's not really proper solution
so it's done in the python side where it's easy to do tweaks. Reasoning
behind this change is:

- If one uses really old driver it's likely because it's the latest one
  he/she can ever to install (because of discontinued support from AMD).

- If old card is used it's likely to not have dedicated GPUs for rendering.

- Even if there's a dedicated GPU device enumeration is likely to crash
  because of attempt to query OpenCL from the old card.

There are still some tweaks needed likely, but this commit should make
some of the configurations to work.
2015-07-20 12:46:56 +02:00
bd28c25f9b Fix broken GLEW initialization. Initialize GLEW twice, once to get GLX
extensions, once to get final context extensions.

Not so nice because we get a warning on startup from GLEW, but at least
it GL extensions should work now.
2015-07-20 12:35:58 +02:00
5f25b91b65 Dyntopo should be supported on systems without VBOs now. 2015-07-20 12:18:39 +02:00
Julian Eisel
50bd598a17 Correct prev commit: Remove unused functions and quiet warning 2015-07-20 12:14:49 +02:00
cb6fc9d141 Use abstraction to unbind buffers, should avoid crashes in systems that
don't support VBOs.

Exposed by initialization error in GLEW, which should be fixed
seperately.
2015-07-20 12:12:28 +02:00
Julian Eisel
bd46a92deb New widget type for colorband 2015-07-20 12:07:09 +02:00
Julian Eisel
b2e18d25b0 Merge branch 'master' into temp-ui-widget-refactor 2015-07-20 11:11:27 +02:00
Julian Eisel
08b3e9a49c New widget types for HSV circle and cube 2015-07-20 11:09:46 +02:00
422ffd252a Pixel format selection now favours a format with a number of samples
closer to the one requested on Windows.

Patch D1384 by Benoit Bolsee.
2015-07-20 10:59:30 +02:00
05ee9d2dd0 Minor edits for consistency 2015-07-20 17:07:40 +10:00
bf6ac302cd Correct own error w/ recent changes to triangulate 2015-07-20 16:12:30 +10:00
e3f86c6580 Replace MFace use by MLoopTri w/ heat-weighting
D1418 by @scorpion81 with edits
2015-07-20 14:42:48 +10:00
e5e9fbfaf0 Replace MFace use by MLoopTri w/ remash modifier
D1419 by @lichtwerk
2015-07-20 14:42:35 +10:00
86e6d6695e GHOST/X11: Support GLX-Context flags
GHOST_ContextGLX was incomplete, ignoring profile-mask and profile-flags.
2015-07-20 13:32:20 +10:00
b368724464 Fix define issues w/ WITH_GL_PROFILE_COMPAT off
This still fails to build, but at least fail where its supposed to (using unsupported API's).
2015-07-20 13:08:26 +10:00
cd91fd655d GHOST: use simple stack array for glx attributes 2015-07-20 11:45:42 +10:00
98bf205c39 GHOST: correct GLX flag w/ WITH_GL_PROFILE_CORE
note that this is currently ignored, but better at least build for now.
2015-07-20 11:32:49 +10:00
b3e7a51ebd Freestyle: disabled debug code in ViewMapBuilder::ComputeIntersections(). 2015-07-20 06:18:03 +09:00
ee263c2566 Freestyle: Removed tesselated forms of silhouettes for displaying in the UI.
The tesselated silhouettes were not used in Freestyle for Blender at all.
2015-07-20 06:18:01 +09:00
1f748d2324 Freestyle: code cleanup.
Removed unnecessary header files and replaced some other heade files with
forward class declarations.
2015-07-20 06:18:00 +09:00
160c65845d Freestyle: minor optimization for space in the FEdgeXDetector.
Member variables and auto variables were changed from real (double) to float
in most part of the FEdgeXDetector (except for curvature computations).
2015-07-20 06:17:59 +09:00
86572dd7c9 Freestyle: commented part of FEdgeXDetector::ProcessRidgeFace() that has no effect. 2015-07-20 06:17:57 +09:00
b9895df36f Freestyle: internal switch from double to float in mesh loading and construction of winged edges. 2015-07-20 06:17:55 +09:00
6705786540 Freestyle: minor optimization for space from mesh importing to feature edge detection.
Several class member variables were removed (at the cost of computing their values
when retrieved) or changed to a type of smaller size.  Also fixed whitespace.
2015-07-20 06:17:54 +09:00
431cee2ba0 Freestyle: minor code cleanup. 2015-07-20 06:17:53 +09:00
66423364ca Freestyle: removed redundant instantiation of vector objects. 2015-07-20 06:17:51 +09:00
be980c4ee4 Freestyle: minor optimization for space by using a pointer to a const char array instead of std::string. 2015-07-20 06:17:50 +09:00
e58d788340 Cleanup: style
Also 'com' as abbreviation for center-of-mass is a bit confusing, rename to 'center'.
2015-07-20 05:30:08 +10:00
23a4f547e7 Convert rigidbody conversion to looptri.
Patch D1417 by Martin Felke, with minor edits thanks!
2015-07-19 19:10:41 +02:00
a597a380bb Properly fix T45477
Code was actually skipping setting color selection indices and previous
commit actually broke mask selection in texture painting.
All should work now.
2015-07-19 18:35:09 +02:00
8f1c1ef3a9 Fix T45477 wrong edge selection.
Caused by own changes to framebuffer selection code, code was not
packing color ids correctly.
2015-07-19 18:04:21 +02:00
d712dc5a1d Fix T45495: Armatures using the iTaSC IK solver causes UI truncation in bone constraints panel.
Caused by rB404f9ddc37fc, cleanup is OK but please double-check changes before committing. :(
2015-07-19 16:25:48 +02:00
Julian Eisel
74eb56fe7e New widget type for vertical HSV slider 2015-07-19 14:39:56 +02:00
23c76039d9 CMake: correct generated location for buildinfo.h 2015-07-19 09:53:38 +10:00
1e10e4e2e3 Fix error when getting the commit time fails
While this should work, allow the build to succeed if for some reason the command fails.
2015-07-19 09:51:49 +10:00
4bca8a6bc5 Fix T45484: Regression OpenCL split: access violation
That was a primary school error caused by moving statements inside assert()
which effectivly disabled crucial code in release builds.
2015-07-18 23:30:19 +02:00
faeac63f68 Cycles: Fix compilation of OpenCL kernel after point density commit 2015-07-18 23:10:46 +02:00
003b56801c Point density: Workaround for possible race condition
There was possible race condition in the point density sampling caused
by access to the same data in particle system from sampling thread and
sampling initialization.

Could have happened when two different point density textures were using
same particle system
2015-07-18 22:57:02 +02:00
9b40616249 Cycles: Point density texture support
This commit implements point density texture for Cycles shading nodes.

It's done via creating voxel texture at shader compilation time, Not
totally memory efficient, but avoids adding sampling code to kernel
(which keeps render time as low as possible), In the future this will
be compensated by using OpenVDB for more efficient storage of sparse
volume data.

Sampling of the voxel texture is happening at blender side and the
same code is used as for Blender Internal's renderer.

This texture is controlled by only object, particle system and radius.
Linear falloff is used and there's no turbulence. This is because
falloff is expected to happen using Curve Mapping node. Turbulence
will be done as a distortion on the input coordinate. It's already
possible to fake it using nose textures and in the future we can add
more proper turbulence distortion node, which then could also be used
for 2D texture mapping.

Particle color support is done by Lukas, thanks!
2015-07-18 22:49:10 +02:00
7d10798af2 Cycles: Add voxel texture sampler shader node
The idea of this node is to sampling of 3D voxels at a given coordinate
supporting different mapping strategies (world space mapping, object
local space etc).

Currently not in use, it's a preparation step for supporting point density
textures.
2015-07-18 22:09:20 +02:00
2f15a1f66e Point density: Add utility function to sample density outside of render pipeline
Not currently used, it's a preparation for the further work.

Should not be functional changes.
2015-07-18 21:42:39 +02:00
92a37993a5 Cycles: Camera frustum space object culling scene simplification
The idea is to give artists a simplier way to control memory usage in such
scenes as grass fields by doing automatic object culling based on whether
object is visible in the frame or not.

This is controlled on per-object level. In order to use this option few steps
are required:

- Enable Simplify in scene settings

- Enable Camera Cull option in the Simplify panel

- Set camera cull margin (measured in relative value to the render resolution)
  This setting is used to avoid possible flickering caused by changes in shadow
  which are cast by objects outside of the frame.

- Enable Camera Cull for objects which are desired to be culled
  (object culling option could be found in Option panel in object buttons).

There is still room for improvements, but this worked quite well during
Gooseberry open movie project, so think it's useful feature even in it's current
non-ideal state.
2015-07-18 18:17:22 +02:00
Julian Eisel
2b73dff7cf Add and use widget API function for draw callback routine
Had to make some further tweaks to make this work nicely, but everything should work fine.
2015-07-18 16:39:01 +02:00
2ccfbf2f81 Cycles: Commit file missing from conditionally compiling baking kernel 2015-07-18 16:26:41 +02:00
cf14437ac9 Cycles: Log requested device features
Useful to have this always logged because otherwise it's needed to remove cached
kernels and check build flags to see which features are enabled.
2015-07-18 16:02:09 +02:00
45b5bf034b Cycles; Make baking a feature-specific option
This means render devices now might skip building baking kernels in cases when
only actual render-related functionality is used.

For now it's only implemented for OpenCL split kernel device and mainly needed
to work around some compiler-specific bugs which crashes on building the kernel.

Using OpenCL for baking might still crash the driver, but at least there is now
higher probability of that GPU will be usable to render the scene.

Real fix should actually be done in the driver side.
2015-07-18 16:02:08 +02:00
36a952e3e4 Cycles: Use feature-selective base kernel compilation when using split kernel
The idea is to make all kernels as small as possible to work around possible
issues with buggy drivers which might fail building feature-complete kernels.

It's indeed just a workaround to make at last simple test scenes to render
on OpenCL. Real fix should happen from the driver side.
2015-07-18 16:02:08 +02:00
5e4a8c6a87 Cycles: Some cleanup if OpenCL base kernel load_kernel()
Hopefully makes it less clumzy, should be no functional changes still.
2015-07-18 16:02:08 +02:00
025eda57da Cycles: Make OpenCL cache follow out code style a bit closer 2015-07-18 16:02:08 +02:00
2ad3a1d41e Use gpu-buffers for UV-edge drawing 2015-07-18 23:51:44 +10:00
f5629b7265 Fix/enhance behavior of VES's 'alt-rmb' selection.
Main issue in previous code was that you could not shift-alt-rmb select several
contiguous strips, result was pretty much unusable.

Also, enhanced general behavior of this selection mode, now (similar to alt-rm clicking
on handles), when you alt-rmb click on a same strip several times, you alternate between:
* Strip is selected, neighbor handles are selected;
* Strip and its handles are selected, neighbor handles are selected.
…which allows you to either grab or slide the strip.

And refactored a bit code too, linked_handle has a complete different logic
than without this option, simpler and clearer to completely separate them in code.

Initial issue reported by Leon Cheung on IRC, thanks!
2015-07-18 14:45:11 +02:00
cdd1be44c5 Replace MFace w/ MLoopTri in imapaint_pick_uv
D1415 by @scorpion81, with minor edits
2015-07-18 22:10:58 +10:00
df4d25991e Fix (IRC reported) inverted behavior of select more/less in VSE.
Also, cleaned up a bit that code, and added releavnt entries in Select menu.

Reported on IRC by Leon Cheung, thanks!
2015-07-18 11:55:08 +02:00
bbed6af857 CMake: Disable Werror in extern/libmv for now
It gives issues with Glog compiled in release mode.

Need to revisit the directory layout here and compiler flag, because technically
libmv is now more an intern/ library and i'll actually prefer it to be covered
with strict flags as well. But it's a bit tricky because of libraries which we
don't maintain are in the libmv subfolder.
2015-07-18 11:16:25 +02:00
ecb3e0fe73 Cleanup: whitespace & break placement 2015-07-18 19:03:22 +10:00
2199a3e38b CMake: Add option to enable -Werror cflag in some areas
It is rather annoying attitude nowadays to use const qualifier all over the
place, including using it for multi-dimensional arrays. This isn't really
supported in GCC prior to version 5.0 because it considers such an arrays
to be a "pointer to a const pointer" which gives implicit casting errors.

It's not possible to disable this particular type of warnings treated as
errors in any GCC version prior to 5.0 as well, meaning currently usage of
-Werror globally in Blender code is not possible at all.

This commit makes it possible to use -Werror in areas which are complaint
with older GCC versions. New advanced CMake options are:

- WITH_COMPOSITOR_WERROR
- WITH_LIBMV_WERROR
- WITH_CYCLES_WERROR
2015-07-18 10:49:51 +02:00
086ae3ea04 Cleanup: whitespace, wrong indent level 2015-07-18 18:42:59 +10:00
752eb64d60 Cleanup: whitespace (CMake) 2015-07-18 18:42:35 +10:00
Julian Eisel
eba5bd3340 Merge branch 'master' into temp-ui-widget-refactor 2015-07-18 10:00:09 +02:00
Julian Eisel
b22061e989 Remove redundant draw call 2015-07-18 09:59:11 +02:00
Julian Eisel
5d021e3331 Fix uninitialized usage of uiWidgetDrawBase 2015-07-18 09:56:49 +02:00
7c5dd14689 CMake: Fix indentation around LLVM detection code 2015-07-18 09:40:33 +02:00
3e83a0d92d Cleanup: ws 2015-07-18 06:01:38 +10:00
7b30e2386b Only use material callback when enabled
Vert/Face select in painting modes weren't drawing after recent changes.
2015-07-18 05:39:01 +10:00
b45749727c Add check for GPU materials enable state 2015-07-18 05:30:13 +10:00
32f7b4a358 Avoid getting the original index if its not needed 2015-07-18 04:57:58 +10:00
e6711119f2 Absent-mindedness...Remove testing code 2015-07-17 19:13:22 +02:00
712098b1c8 Fix GLSL code not working correctly for Macs without VBO, again report
by scorpion81 on irc
2015-07-17 19:12:24 +02:00
c1290e441e Fix T45469: Vertex Group weight = 0.0 in scene 2. 2015-07-17 18:49:58 +02:00
20de6f01ed Fix T45464: Blender Sequencer "Select Strips to the Left" produces opposite behavior to what is intended.
Logic was just broken for the LEFT case here.

Also cleaned up and made behavior more consistant between strips and markers.
2015-07-17 18:32:59 +02:00
3a15ec337e Fix issue reported by scorpion81 on irc: material mode + flat shading
artifacts in cycles textured mode.
2015-07-17 18:30:40 +02:00
85809e836e Avoid double index lookup mesh/selection drawing 2015-07-18 00:01:44 +10:00
d4c0617496 Avoid accessing MTFace drawing subsurf 2015-07-17 23:52:41 +10:00
955c13d614 Fix another index error, made multimaterial mapped meshes draw
incorrectly.
2015-07-17 15:15:53 +02:00
7c06167982 Change winding of looptris in subsurf so they point to the same
direction as the surface.
2015-07-17 14:56:10 +02:00
5f09348fe8 Fix crash texpainting on subsurfed meshes.
Unfortunately, loops and polys are generated, therefore we need to keep
copies. Still not painting after this commit but at least no crash now.
2015-07-17 14:46:05 +02:00
82e27f5093 Cleanup: ws & correct comment 2015-07-17 22:09:30 +10:00
416d164fec Projection Paint: move to looptri data 2015-07-17 21:59:07 +10:00
e1606e8c87 Don't create MFace's when calculating normals
Instead only create MFace layer when its requested
2015-07-17 21:59:07 +10:00
19614f4395 Add macro BKE_MESH_TESSTRI_VINDEX_ORDER
gives the index of a vertex in a looptri
2015-07-17 21:59:07 +10:00
c23d29c58e Fix T45465
Easy one, we don't draw quads anymore. Also normal
didn't use polygon index
2015-07-17 13:27:46 +02:00
1b8e0d03d4 Fix no longer being possible to display a suzanne with 8 levels of
subdivision.

Classic integet overflow/size_t substitution case. Machines are getting
powerful enough to easily expose these kinds of error now.
2015-07-17 12:25:44 +02:00
0b121d6a5d Cleanup image's poll funcs.
Checking space returned from CTX_wm_space_image() is SPACE_IMAGE type... tssst. :)
2015-07-17 12:19:57 +02:00
1255ac12a6 Fix T45462: Do not enale 'replace image' op with packed images. 2015-07-17 12:19:57 +02:00
37017d149e Let's use proper helpers for debug-only vars... 2015-07-17 12:19:57 +02:00
9bcf1bb266 Fix for nodeitems module using the NODE_MT_add menu types from bl_ui.
This is basically a bad-level call: ui scripts are registered *after*
the modules. It only works for addons because those are loaded even
later.

Now the nodeitems_utils module just defines a function which is then
called by the UI script, rather than the other way around.
2015-07-17 11:59:24 +02:00
4052384be3 Make strict flags happy in release builds 2015-07-17 09:54:21 +02:00
Julian Eisel
b947998a51 New widget types for drawing scrollbars using widget pipeline
Had to add UI_WTYPE_SCROLL_BACK and UI_WTYPE_SCROLL_INNER since they need different rectangles, drawing and states. Also renamed UI_WTYPE_SCROLL to UI_WTYPE_LISTSCROLL as it's only used for lists.
2015-07-17 02:48:25 +02:00
Julian Eisel
2a325a0eb9 Cleanup: Naming, comments, redundant defines, ... 2015-07-17 00:50:00 +02:00
Julian Eisel
94adf2cc5f Cleanup: Move widget_type function to widgets.c and widget type enum to widget.h
And suddenly, things are soooo much nicer ;)
2015-07-16 23:22:48 +02:00
Julian Eisel
80af1f10fc Merge branch 'master' into temp-ui-widget-refactor 2015-07-16 21:55:59 +02:00
Julian Eisel
56c6bd646a New widget type for preview menu items
Also to avoid special draw calls.

Note: This adds iconid and str args to uiWidgetDrawType->text callback, which is currently only needed for preview menu items (could also be done differently), but in future this might be handy to get rid of uiBut usage on this level.
2015-07-16 21:44:42 +02:00
40936307dd Remove MTFace DM_paint_uvlayer_active_get func 2015-07-17 04:26:17 +10:00
67acde92bb Fix for error in looptri commit
Sculpting w/ subsurf crashed
2015-07-17 04:22:24 +10:00
9d090c4717 Split ray_face_intersection into quad/tri versions
Since many callers only need a single triangle
2015-07-17 04:15:24 +10:00
595a491e63 Add tessellation data to DerivedMesh (LoopTri)
This stores loop indices into the loop array giving easier acess
to data such as vertex-colors and UV's,
removing the need to store an MFace duplicate of custom-data.

This doesn't yet move all internal code from MFace to LoopTri just yet.

Only applies to:
- opengl drawing
- sculpting (pbvh)
- vertex/weight paint

Thanks to @psy-fi for review, fixes and improvements to drawing!
2015-07-17 03:55:14 +10:00
Julian Eisel
85eb2ea3bb Avoid special drawing calls for labels within menus by adding a widget type for them 2015-07-16 19:50:21 +02:00
Julian Eisel
f45c2a9cb5 Aaaand finally: Use new pipeline for text drawing as well 2015-07-16 19:09:51 +02:00
Dalai Felinto
c8f6313487 Fix T45428: Sometimes in a dupligroup linked actuators are not triggered
Revert "BGE: Cleanup : merge 3 loop in 1 in function DupliGroupRecurse."

This reverts commit 371e5f25a0.

The fix is basically to revert the cleanup commit 371e5f25 (and 3d658bf7)
Also 5dc22fbbf had to be adapted to the reverted code.

Conflicts:
	source/gameengine/Ketsji/KX_Scene.cpp
2015-07-16 12:53:20 -03:00
2fe9224375 Fix T45459: Edge Length with Separate Units Displayed As 1m 100cm.
Our 'unit epsilon' was too small, given the fact we only display up to four digits usually...
2015-07-16 17:45:51 +02:00
f2087b4830 Fix T45451: File Browser crash on 16bits PNG image previews.
Issue was that with those files, Blender generate a float image by default, not a byte one...

Now, we ensure in two places we only get a byte imbuf for our thumbnails!
2015-07-16 17:28:25 +02:00
4feef7d4f8 Fix for the previous commit: overallocation of an array 2015-07-16 17:26:20 +02:00
247d922ce5 Fix T45446: Crash when baking a certain object
Issue was caused by deform vert layer existing in the mesh.
Solved in quite simple way, but it still might be missing
some other layers.

Any custom data experts around to check if it's correct?
2015-07-16 17:25:13 +02:00
3e3e7ee41c Sculpt draw code:
Remove legacy code completely, now dyntopo, multires et al even work on
GL 1.1 for really hardcore users :p

Real purpose here though is to be able to have fast multires drawing
even with VBO off, since it requires using indices for vertex buffers.

Also made own code elf puke an eaten normal update function which
made multires not update normals in solid mode...sorry.
2015-07-16 17:12:03 +02:00
6568b6d1cd Fix T45456: Error's in splash don't restore cursor 2015-07-16 17:28:20 +10:00
01a8216a4b Disable check for recent-files.txt existing
slows startup on remote, network fs... etc.
2015-07-16 17:15:00 +10:00
Stefan Werner
51385f6fe8 Fix T45447: Area light importance sampling improvement
Turning on importance sampling on area lights increases noise on diffuse
surfaces. This was caused by PDF calculated for an intersected point on
light instead of original light position.

Patch by Stefan with some own modifications.
2015-07-16 08:33:13 +02:00
b00c49838a Optimize Vertex Color update
Avoid recalculating the material color when its the same as the last.
2015-07-16 15:49:15 +10:00
Julian Eisel
a3a56d9aaf Time to use new pipeline for widget states
Still don't really like having this on low draw level, think a better solution would be to handle this via flags and update widgets based on these flags before drawing, but old logic is pretty confusing and spaghettiish here, so would prefer to rework states from scratch at some point.
2015-07-16 03:43:59 +02:00
Julian Eisel
03bfc42f74 Merge branch 'master' into temp-ui-widget-refactor 2015-07-16 01:20:35 +02:00
e6364c64f2 Icons: Add new 'library_data_broken' one. 2015-07-15 20:28:09 +02:00
13c39e90b3 VBO offscreen selection drawing, cdderivedmesh
Get rid of legacy drawing, it's only used for selection,
    in which case we can prepare a temporary color buffer and draw
    at once. Code is not complete here because we still redundantly
    set the draw color in the draw function and don't ommit hidden
    faces automatically. Still it works 100% without immediate mode
    now.
2015-07-15 18:50:02 +02:00
2daa4db8a0 Fix own stupid error in yesterday's refactor of recursive dir creation.
Missed adding return value in one place.

Thanks a lot to Thomas Szepe for reporting the issue and finding the solution!

Question remains: how could MSVC allow such a code to compile in some cases
(own win64 + scons buildbot win32 were OK with that it seems!).
Crappy compiler, not comming to the rescue of stupid dev...
2015-07-15 17:43:04 +02:00
548e650252 Cycles: Merging of patch from OSX went wrong in the previous change
That's what happens when you can't commit from a system you're making
changes at and someone is behind your back...

Sorry for the noise.
2015-07-15 15:12:19 +02:00
2b97ad348c Cycles: Missed this in the previous commit 2015-07-15 15:11:02 +02:00
32c6d92cb0 Fix T45439 crash with subsurf when many materials present.
Silly oversight on the viewport patch
2015-07-15 14:58:10 +02:00
56bf25d219 Cycles: Enable OpenCL rendering on Apple OSX
Requires having latest El Capitan beta 3 OSX due to ome crucial fixes made in the
compiler. Supports same features as NVidia OpenCL apart from CMJ (there's no
experimental feature set support in megakernel yet).

Uses megakernel internally, which works much better than the split kernel. Split
kernel is not supported on OSX still, needs to be investigated still.

Some more details can be found there:

  http://wiki.blender.org/index.php/Dev:2.6/Source/Render/Cycles/OpenCL#AMD_on_OSX
2015-07-15 14:20:59 +02:00
4143b8a6c7 Fix autosmooth with recent DM optimizations
Also avoid multiple float->short conversions for the same normal.
2015-07-15 14:34:56 +10:00
72c7e12a5d DerivedMesh: minor changes to callback use
- use void instead of float for array arg (cast in the switch statement)
- remove unused args
- use const for poly-mapping and user_data args
2015-07-15 12:42:41 +10:00
7407ed7637 Cleanup: ws 2015-07-15 12:08:32 +10:00
52fa5b12e1 Cleanup: ws 2015-07-15 11:43:23 +10:00
Nikolaus Leopold
f2620c9df1 Minor English grammar typo fixes.
This fixes T45433.

Reviewers: Severin, kevindietrich

Reviewed By: kevindietrich

Projects: #bf_blender, #user_interface

Differential Revision: https://developer.blender.org/D1408
2015-07-15 03:33:10 +02:00
dfd383ca00 Fix overdrawing and errors with textured and mapped drawing 2015-07-14 23:49:03 +02:00
9cc1953210 Usual i18n messages fixes... 2015-07-14 21:41:24 +02:00
Julian Eisel
e50904f9c9 Merge branch 'master' into temp-ui-widget-refactor 2015-07-14 21:09:26 +02:00
Julian Eisel
0e06f4c491 Fix weirdly appearing and disappearing compile error 2015-07-14 21:06:59 +02:00
8a17918555 Fix T45424: Blender able to create folders with invalid characters at the end of the name.
In fact, filebrowser was not making any checks for invalid file/dir names here!

Added checks in the three places that should be protected:
* Renaming.
* Creating dirs.
* Typing in filename field.
2015-07-14 18:57:38 +02:00
d7b9202567 BLI_path_utils: fix/enhance BLI_filename_make_safe(), add BLI_path_make_safe().
BLI_filename_make_safe had several issues:
* Would replace all dots ('.'), not a great idea since it would break extensions.
* Was not checking for 'control' ASCII chars (though unlikely, better to be safe here).
* Win32 only: was not checking for forbidden names (con, aux, ltp0, com0, etc.).

New BLI_path_make_safe() simply checks each path's item with BLI_filename_make_safe().
2015-07-14 18:57:38 +02:00
d0c5eac4b7 BLI_fileops: Make BLI_dir_create_recursive() return success/error status.
Handy to know directly whether a file creation succeeded or not.

Also, made a few more changes in this func, and harmonized a bit win32/*nix versions.
2015-07-14 18:57:38 +02:00
38940662e5 Particle Info node support for GLSL mode and the internal render.
With this patch "Particle Info" node from Cycles works in GLSL and BI

Alexander (Blend4Web Team)

Reviewers: psy-fi
Note: moved particle info to object render instance instead of
shadeinput during review - Antony.

Differential Revision: https://developer.blender.org/D1313
2015-07-14 18:52:29 +02:00
107e34407d Display optimizations part 1.
This patch changes the way we draw meshes by introducing
indexed drawing. This makes it possible to easily
upload and rearrange faces ad lib according to any criteria.

Currently we use material sorting but textured sorting and
hiding will be added to optimize textured drawing and skip
per face testing.

It also adds support for vertex buffers for subsurf
modifiers (Except from GLSL drawing), making drawing of
subsurf much faster without need for bogus modifiers.

Tests show that we gain approximately 20-25% performance
by that for solid mode drawing with up to 50% gains for
material drawing. Textured drawing should also have a
small performance gain, but more substantial optimizations
are possible there.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D1406
2015-07-14 16:48:23 +02:00
1b8b9063f8 Correct last commit 2015-07-14 23:37:11 +10:00
0918461d61 Move from MTFace to MTexPoly w/ texture checks
Part of moving away from MFace.
2015-07-14 22:36:00 +10:00
2cffd6649b Match face tessellation order in edimode
add a negated version of axis_dominant_v3_to_m3
2015-07-14 22:29:31 +10:00
655f498ca7 Cleanup: headers (wm) 2015-07-14 22:29:31 +10:00
cba0858ccd Fix for recent optimization commit in endian switch
Pre-4.8 GCC had a bug which lead to non-exposed __builtin_bswap16() symbol.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624 for details.
2015-07-14 11:33:50 +02:00
82740cd282 Fix T45423: depsgraph: crash in IDDepsNode::tag_update
Two issues fixed in this commit:

- Clearing or adding animation via python should ensure relations are valid.
- Animation component animation data might be null caused by removing animation
  from python.
2015-07-14 11:21:04 +02:00
9c80e52a89 Make tooltip parsable by human compilers (thanks to Pablo for
suggestion)
2015-07-14 11:19:13 +02:00
6ba4a917a3 Data Transfer: very minor cleanup... 2015-07-14 11:13:56 +02:00
85004461ea Workaround for non-bleeding edge compilers and const cast of pointer arrays. 2015-07-14 09:56:00 +02:00
a79d47b14e Cycles: Add logging to detected OpenCL platforms and devices
Happens on verbosity level 2, should help looking into some of the
bug reports in the tracker.
2015-07-14 09:56:00 +02:00
Julian Eisel
52ce543f4d Merge branch 'master' into temp-ui-widget-refactor 2015-07-14 02:11:52 +02:00
Julian Eisel
0a202fdfce Get rid of uiWidgetType drawing callbacks (which are now used on a lower level) 2015-07-14 02:07:45 +02:00
Julian Eisel
d032de3bae Let's not use default callbacks for uiWidgetType->draw 2015-07-14 01:49:08 +02:00
7ad9ca72dd Cleanup: replace BLI_split_file_part w/ BLI_path_basename 2015-07-14 09:34:53 +10:00
b7c42ef93e Cleanup: use ascii as suffix (as with utf8) 2015-07-14 09:17:00 +10:00
2de497eee0 BKE_deform: assert on invalid args
Will phase these out eventually
2015-07-14 08:41:15 +10:00
Julian Eisel
29166b3ae3 Fix drawing glitch with menu items 2015-07-13 23:45:00 +02:00
8c0b5c02de Draw emboss when area is full but in quad-split 2015-07-14 07:31:46 +10:00
Julian Eisel
d6c93298b5 Use new pipeline for link line drawing as well 2015-07-13 23:31:33 +02:00
9f78aa4c36 Fix T45348: Collapse gives sel verts in face mode 2015-07-14 07:02:35 +10:00
55374426c6 EditMesh: show angles of adjacent selected verts
Useful since moving vertices will change angles on adjacent,
unselected face-corners too.
2015-07-14 06:30:02 +10:00
eee2d8e45c Fix T45247: Softbody ignores lattice weight
Now multiply the lattice wight by the goal weight too.
2015-07-14 06:20:31 +10:00
240646f506 Softbody goal weights cleanup
- avoid searching for vertex group for each vertex.
- add support for mass and spring weights to lattice.
- multiply the vertex group weight by the overall goal weight value.
2015-07-14 06:20:30 +10:00
6a982a080c Add some pedantic casts, since some guys around like to take all warnings from their compilers as errors, even the stupidest ones! 2015-07-13 22:00:49 +02:00
Dalai Felinto
4050b49f97 increase mathutils callback count (BGE devs, read the log)
This was causing the BGE to crash on Debug mode when built with "break on asserts", meaning the BGE was not debuggeable.
Please make sure to test patches in debug mode with the proper flags enabled before committing
2015-07-13 16:11:59 -03:00
Dalai Felinto
34a7156705 RNA assert: make object game state to comply with RNA_property_boolean_get_index() 1/0 requirement 2015-07-13 15:52:05 -03:00
406b9aa7b1 Fix T45402: Transform crash w/ project+align snap
Only euler rotations were checked for.
Also delta rotations caused random/unusable output.
2015-07-14 04:30:16 +10:00
6f7926c61c Fix T45394: Motion tracking constraints did not work with Cycles motion blur 2015-07-13 18:17:46 +02:00
dd44754c5f Data Transfer: Add an option to 'auto-transform' destination mesh so that it matches best the source one.
This allows to match and transfer data between two meshes with similar shape but complete arbitrary different transform.

Note that the result will be best if the meshes (more precisely, their vertices) are exact copies of each other.
Otherwise, method used can only perform an approximated best match, which means you'll likely get better
results if you 'visually' make them match in 3D space (and use 'Object Transform') instead.
2015-07-13 18:05:38 +02:00
e93b969ac9 Add BLI_math_statistics, where stats tool shall be!
For now, only contains some 3x3 matrix covariance computing.
2015-07-13 18:05:38 +02:00
0e9842dd04 Add BLI_math_solver, where non-linear solvers should be.
For now, only has an eigen solver for 3×3 (symmetric) matrix.
2015-07-13 18:05:38 +02:00
582e7a6347 Add a skeleton of C API for Eigen3.
Title says pretty much everything. For now, only thing available is a solver of eigen
values/vectors for self-adjoint matrices.

We can easily add more when needed.

Thanks to Sergey and Campbell for quick review.
2015-07-13 18:05:38 +02:00
0119539e4b Add icon scale argument for ui-template-previews 2015-07-14 01:46:25 +10:00
e7b3803317 Allow spin/screw to run outside 3D view
This lets scripts call them
2015-07-14 00:55:04 +10:00
b16bf6da80 Fix T45364: NEW DEPSGRAPH: New Torus created can't be transformed
Linking objects to a scene via python should ensure relations are properly
updated for that scene.
2015-07-13 16:00:39 +02:00
9f63cbf4a7 Fix T45333: Volume Scatter crash blender 2015-07-13 18:54:26 +05:00
a2f7997e05 Freestyle: Fix compilation error with strict compiler flags 2015-07-13 15:24:56 +02:00
686e8e452c Fix T45390: Cycles experimental displacement method ignores scaling when render
From artists perspective it makes sense to always apply displacement in a local
space.

TODO: Double-check that BVH is being packed properly. From quick tests seems it's
all fine, but might be missing some obvious failure still.
2015-07-13 15:24:56 +02:00
2d32b92d77 Cleanup: IMB prefix for ImBuf defines 2015-07-13 22:00:07 +10:00
e142ae77ca Imbuf types refactor.
ImBuf types were getting stored as bitflags in a 32bit integer which had
    already run out of space. Solved the problem by separating file type to
    an ftype enum, and file specific options to foptions.

    Reviewed by Campbell, thanks a lot!
2015-07-13 13:58:17 +02:00
107bbee4c7 Use regex for cmake config parsing 2015-07-13 20:05:26 +10:00
5201748f5f Fix T45397: Frameserver rendering no longer works in 2.75 or 2.75a
Issue was caused by a typo in original multiview commit.
2015-07-13 11:10:33 +02:00
1dd92f352b Fix T45385: Crash on render occurring when two hair modifiers are active that both use a UV mapped material for render
Not sure it's totally correct solution, but seems reasonable because it's
possible dmcache is set to ISCHILD.

Someone more familiar with the particles code might want to revisit this :)
2015-07-13 11:01:34 +02:00
f4f7348c41 Minor tweaking to Knife header text.
Confirm/cancel shall always be first, and also makes more sense to have
define cut/close cut/new cut together.
2015-07-12 21:52:59 +02:00
c1a5e6b2fd Shortcut-to-string converter: add 'dbl-' in front of key when expecting a double-click.
I think this is the only Keymap value we really need to handle here...
2015-07-12 21:39:59 +02:00
c2bcf2dc05 Add new modalkeymap usage in helper header message to Knife tool. 2015-07-12 21:32:16 +02:00
36c15f4194 Add new modalkeymap usage in helper header message to Fly mode. 2015-07-12 21:14:06 +02:00
1b297567c0 Cleanup: style 2015-07-13 03:48:08 +10:00
feffbe974b Remove redundant string copy 2015-07-13 03:43:41 +10:00
1893e5e4c2 Missed essential part in previous commit.
Or how to epic fail a fix when working on two different systems.
Or how to increase your commit rate.
2015-07-12 19:04:31 +02:00
7e9c347c8c Fix T45375: Cant clear temp fluid cache after closing Blender (Windows).
There was two different issues here actually:
* Own (very high) stupidity only gave 8 chars to file name (sic).
* list dir returns dirpaths without a trailing slahs, but expects them to have it it seems. :|
2015-07-12 18:49:02 +02:00
d54e77b66d Cycles: Expose "Max Bounces" for the world light.
When using MIS, the world is treated as regular light and in this case
we can now also limit the maximum amount of bounces, the background light
will contribute to the scene.

This can improve performance in some cases, where it's e.g. sufficient to
only have a contribution on first 1-2 bounces.
Examples can be found in the differential.

Differential revision: https://developer.blender.org/D1399
2015-07-12 17:56:54 +02:00
6ffc988ae3 BGE Clean-up: New EXP prefix for the BGE Expression module
The expression module now uses an EXP prefix and it follows a
distribution similar to blender.

Additionally the hash function in EXP_HashedPtr.h was simplified and the
files EXP_C-Api.h &.EXP_C-Api.cpp were deleted because were unused.

Reviewers: campbellbarton, moguri, sybren, hg1

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1221
2015-07-12 16:58:12 +02:00
5b0f674e09 Fix crash in redraw timer
Was modifying wrong regions flag, that could also be NULL.
2015-07-13 00:21:08 +10:00
8d48f8e0b0 Add ability for redraw timer to run for fixed time
Also avoid accessing context vars in timer loop.
2015-07-12 22:57:35 +10:00
2fd3b9ad84 PyAPI: Use separate writes for operator reports
This allows us to temp override the stdout and extract individual reports
2015-07-12 22:26:14 +10:00
532b735ee8 Docs; Py API gotcha's section
Minor corrections and cleanup
2015-07-12 20:50:44 +10:00
5c8fc8e505 Use const for direntry strings 2015-07-12 05:50:07 +10:00
Julian Eisel
8c67b8ffe9 File Browser: Fix possible bug and some minor tweaks
BLI_add_slash appended to a char *, a potential buffer overflow

Also partially removed an assert, which failed after changing file format of a saved image. We need a better way to handle such cases.
2015-07-11 21:44:42 +02:00
7b1489b93b Error in last commit 2015-07-12 05:35:44 +10:00
968351d916 Minor changes for more efficient endian switching 2015-07-12 05:33:04 +10:00
17ebbc06e2 Use const for sculpt vars
resolves building with gcc4.9
2015-07-12 03:50:39 +10:00
5a19d9d8f3 ImBuf: Fix compilation error with older libpng
Older libpng library does not use const pointer to a memory.

The exact version is a bit of a guess here, maybe needs tweaks to it tho.
2015-07-11 19:18:20 +02:00
3a810bfed6 remove redundant casts 2015-07-12 02:53:37 +10:00
eed7efa151 error in own last commit 2015-07-12 02:31:46 +10:00
b610ec50de Add Thai and Khmer charsets to our i18n font. 2015-07-11 18:03:18 +02:00
a6259d4290 Avoid static var for OpenEXR 2015-07-12 01:45:30 +10:00
e42e01875e Make Iris image loading thread-safe
Needed for thumbnails
2015-07-12 01:13:33 +10:00
2410797ab1 ImBuf: cleanup, use const for memory passed in 2015-07-12 01:07:59 +10:00
03d8907ca7 Add some basic report/timing/logging tool as util py module progress_report.
It supports any level of sub-steps, timing, messaging, and uses WindowManage.progress API
to report progress in UI, in addition to console printing.
2015-07-11 16:50:22 +02:00
114e7eaa09 Add WM_framebuffer_to_index_array
Convert buffer to index in one loop,
also minor cleanup to backbuf/selection functions.

- Use IMB_rectcpy instead of inline pixel copy.
- Redundant WM_framebuffer_to_index call.
2015-07-11 23:21:41 +10:00
Julian Eisel
02b3618873 File Browser: Keep file name after changing directory
Actually this was an intentional change in rBaeeb23efa28dc to prevent Blender from trying to open the old file from the new directory. Issue is that this is really bad for saving and basically breaks "Save As".

Some more tweaks were needed to make it work like before, so now it keeps the name of the last selected file, but clears it when selecting a folder.
2015-07-11 05:48:02 +02:00
909fa34c5f BLI_matrix space_transform: Add a 'local-invariant' setter.
`BLI_space_transform_from_matrices()` defines a 'global-invariant' transform
(same point in global space, two different coordinates in local and target spaces).

New `BLI_space_transform_global_from_matrices()` is kind of opposite, it defines
a 'local-invariant' transform (two different points in global space, same coordinates in local and target spaces).

Useful to 'match' meshes.
2015-07-11 00:04:27 +02:00
Julian Eisel
bf3fe67862 Fix T45405: Crash on opening a file (in filebrowser code)
Quoting Bastien from IRC: "Filebrowser is a nest of bad surprises" -- indeed :S
2015-07-10 22:09:14 +02:00
f3d5af4172 Cleanup: use const for mesh functions 2015-07-11 04:39:27 +10:00
0875cb07cc Cleanup: use const for gpu buffer 2015-07-11 03:25:28 +10:00
78cae5bad9 Cleanup: remove redundant includes 2015-07-11 02:49:04 +10:00
3443686399 Sequencer: changes to text effect strip
- default alignment to lower center.
- placement is now relative,
  so changing output size keeps correct placement.
- instead of center override, add align option (left/right/center).

Also don't use pixel-size for setting the font size, on new strips.
Better not have UI prefs impact low level API's.
2015-07-11 02:30:26 +10:00
Julian Eisel
9a3dfa1f21 Fix crash when appending from File Browser
Again own mistake in rBaeeb23efa28dc1
2015-07-10 17:49:58 +02:00
e7a48113a9 Freestyle: Missing __all__ symbols added in D963. 2015-07-10 23:15:59 +09:00
25638a9656 Code cleanup: White space and dead code. 2015-07-10 23:15:57 +09:00
Folkert de Vries
eeeb845d33 Freestyle: new stroke modifiers
This patch introduces a couple new stroke modifiers. The ones currently implemented are based on prototypes by @kjym3 and myself.

The new modifiers:
  - Tangent
  - Thickness noise
  - Crease Angle
  - Simplification
  - Curvature 3D

The documentation for these new modifier types can be found [[ http://www.blender.org/manual/render/freestyle/parameter_editor/index.html | in the manual ]]:

{F134441}
(left: AnisotropicThicknessShader, right: NoiseThicknessShader)

{F140499}
(left: Curvature 3D, right: Simplification)

Author: Folkert de Vries (flokkievids)

Reviewers: kjym3

Subscribers: #user_interface, plasmasolutions, kjym3

Projects: #bf_blender

Differential Revision: https://developer.blender.org/D963
2015-07-10 23:15:56 +09:00
7837f0e833 BLI_math 'compare' cleanup & enhancements.
This commit:
* Adds a 'compare_ff' function for absolute 'almost equal' comparison of floats.
* Makes 'compare_vxvx' functions use that new 'compare_ff' one.
* Adds a 'compare_ff_relative' function for secured ulp-based relative comparison of floats.
* Adds matching 'compare_vxvx_relative' functions.
* Adds some basic tests for compare_ff_relative.

See https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

Note that we could replace our python/mathutils' EXPP_FloatsAreEqual() by BLI's compare_ff_relative
(using a very small absolute max_diff), but these do not have exact same behavior...
Left a comment there for now, we can do it later if/when we are sure it won't break anything!
2015-07-10 15:02:43 +02:00
bbcbd2eed9 REmove stupid apple check on OMP in weightvg modifier.
This is handled in build files...
2015-07-10 09:56:10 +02:00
a8b8d60c50 CustomData: deprecate CD_ID_MCOL 2015-07-10 16:47:39 +10:00
a7ed374459 makesrna: use int64 for rounding check
Harmless but larger values would overflow
2015-07-10 16:42:36 +10:00
66f1c3b882 DNA: replace GCC poison with ifdef for enums 2015-07-10 15:58:50 +10:00
Julian Eisel
9ebe875dcc Porting second half of widgets to new drawing pipeline 2015-07-10 03:31:22 +02:00
Julian Eisel
58c50e786a Merge branch 'master' into temp-ui-widget-refactor 2015-07-10 01:10:03 +02:00
Julian Eisel
5513fdc629 Fix T45398: Saving file from File Browser doesn't work if no file is selected
Own mistake in rBaeeb23efa28dc16e20
2015-07-09 23:48:55 +02:00
Julian Eisel
f766a61626 File Browser: (Re-)Allow selecting '..' parent entry for file navigation
Selecting '..' entry was intentionally disabled in rB76b4fad6dbda1b10c, however, for file navigation this can be really useful. So this basically allows selecting '..' entry again, *if it is the only entry to select*. It won't be selected using box select, select all or when expanding selection.
2015-07-09 19:48:03 +02:00
Julian Eisel
aeeb23efa2 File Browser: Improve usage of Enter-key to open files/directories
From a user-POV this makes following changes:
* Adds support for using the Enter-key to open directories
* Updates the upper text-buttons for file and directory on selection
* Last selected file/directory is opened now (in sync with upper text-buttons)
* Changes text in open button to "Open Directory" if a directory is selected

D1349, Reviewed by @mont29
2015-07-09 18:40:34 +02:00
26bd1a766a Cleanup: warnings 2015-07-09 19:39:37 +10:00
a837797740 Cleanup: quiet warning 2015-07-09 19:33:02 +10:00
980ea4e54f Use it->second instead of (*it).second in KX_BlenderSceneConverter. 2015-07-09 09:45:21 +02:00
cdbb60b0a3 Select Shortest Path for edit-curve
D1391 by @pink.vertex with own fixes/edits
2015-07-09 17:03:00 +10:00
ee1b1b9e59 Curve: change rules wrt active bezier
Activate the vertex even if only a single handle is selected
2015-07-09 14:52:01 +10:00
bbc4a92318 Curve selection, de-duplicate & cleanup 2015-07-09 14:39:24 +10:00
Julian Eisel
0d3a3347f0 Port first half of the widgets to new pipeline (drawing only)
Also lots of structuring and cleanup.

Tested each button individually, seems everything is fine (menu items are doing weird things though, didn't investigate yet).
2015-07-09 04:19:41 +02:00
Julian Eisel
db5e89ad5c Initial refactor of interface widget architecture
Initial refactor of interface widget architecture towards the following goals:
* Widget Draw Styles (see T45025 - heavily overlaps with this)
* Isolating widget code to make it more future proof
* Adding callback based widgets handling module (currently handled in interface_handler.c)

Adds the following folders/files:
interface/widgets/
interface/widgets/widgets.c
interface/widgets/widgets.h
interface/widgets/widgets_draw/
interface/widgets/widgets_draw/drawstyle_classic.c
interface/widgets/widgets_draw/widgets_draw.c
interface/widgets/widgets_draw/widgets_draw_intern.h

Not sure if editors/interface/ is the right place for this, but depends on some further decisions.
2015-07-09 01:13:22 +02:00
ec64bf17e3 Select Similar for edit-curve
D1381 by @johnroper100 with edits
2015-07-09 03:03:19 +10:00
161bbfcd19 Add BKE_nurb_bpoint_calc_normal 2015-07-09 02:56:04 +10:00
4a328a7689 EditCurve: move selection into own file 2015-07-09 00:09:26 +10:00
de6b4dc7f7 Fix/Cleanup mesh remap dest transformation in tree/source space.
In org work, bvhtree helpers were modifying passed co/no in place according to given transform.

However, during review pass we decided this was bad, and made them modify copies. But this broke
some cases where we'd do extra tests after bvhtree query, expecting tmp_co to be in tree (aka source) space!

Further more, since in quite a few cases we were already doing that transform outside of bvhtree helpers,
decided to remove this alltogether from the helpers - makes things more clear and easy to follow,
avoids needless copy of vector, and ensures we are always using tmp_co in its transformed version!
2015-07-07 19:29:17 +02:00
30b7aafe33 Correct default enum values
Had assert creating cheat sheet
2015-07-07 23:10:08 +10:00
3dc86f586c Cycles: Add debug print about CLEW initialization status 2015-07-07 14:37:12 +02:00
37539962fe Cycles: Add an option to force disable all OpenCL devices
This way it's possible to disable OpenCL devices for AMD devices
which are considered whitelisted.
2015-07-07 14:18:45 +02:00
0c14a897dd BGE: Fix wrong current logic manager in collision callback. 2015-07-07 13:37:27 +02:00
1d021956f5 Remove redundant lists, link instead 2015-07-07 21:25:51 +10:00
86f09e58d4 Remove unnecessary constant info
Noting every constant as an int isnt helping,
this is only meant to be passed to only.
2015-07-07 21:17:33 +10:00
5af1daa2dc Fix for recent error, ngons now flipped correctly 2015-07-07 20:29:13 +10:00
23aa425cd9 Using proper subtype in game object velocity clamping properties.
The game.velocity_{min,max} and game.angular_velocity_{min,max} object
RNA properties did not use a subtype, and thus velocity was always
displayed as radians or blender units instead of the configured units.

Reviewed by: campbellbarton
2015-07-07 11:59:28 +02:00
afa25b1136 Minor simplification for uv edge drawing 2015-07-07 15:08:45 +10:00
Quentin Wenger
6ed1a1abe2 BGE: bge.texture API documentation enhancement
This patch attempts to improve and review the documentation of bge.texture, as requested in the [[ http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/GameEngine#Video_Texture | TODO list ]].

More specifically, it

  - fixes the rst syntax, including titles of the examples bge.texture.py and bge.texture.1.py;

  - adds, standardizes and reviews description of the API elements, particularly signatures, types, etc.

  - adds SOURCE_* constants to the doc

  - splits the doc into thematical parts (Video, Image, Texture, and Filter Classes, Functions, Constants).

Notes:

  - The parameter "mode" of ImageBuff.plot has to be described better. Actually, the whole set of IMB_BLEND_* constants (from IMB_imbuf.h) should be exposed to Python. I'll do that in a future diff, and complete the doc at the same moment (adding those IMB_BLEND_* constants to the Constants part of this doc).

  - The option of using webcams in VideoFFmpeg is still particularly not well documented. I am planning to make a proposal about fixing T18634 (and its corresponding TODO in the list) by integrating OpenCV in the BGE (and Blender?). The idea would then probably be to add a new class, f.ex. ImageWebcam, making this functionnality more specialized. So for now I don't think it is worth to document that part much.

This patch fixes T44284 too.

Reviewers: moguri, kupoman, campbellbarton, panzergame, lordloki

Reviewed By: panzergame, lordloki

Subscribers: hg1

Projects: #game_engine, #game_python, #documentation

Maniphest Tasks: T44284

Differential Revision: https://developer.blender.org/D1352
2015-07-06 21:48:25 +02:00
791b5fe9d0 Fix T45331, a bevel regression for 2.75.
Got bad results when two beveled edges form straight line
and there are two or more unbeveled edges attached to either
side of the connecting vertex.
2015-07-06 13:27:01 -04:00
Dalai Felinto
93608e4f3b Fix T45237: Dither does not work 2015-07-06 11:51:40 -03:00
Dalai Felinto
6a132aa65d Fix T45290: Selecting passes in image editor does no longer work
This issue was introduced with the wrong fix I committed for dither (rB56ca7f34)
Which also means T45237 has to be re-open
2015-07-06 11:15:16 -03:00
12583287e7 BGE: Fix T45341: Crash when camera is eliminated
A null check is added to avoid crashes when the camera is removed during
the game and no other is available
2015-07-06 15:40:50 +02:00
266459c7da Fix T45328: Crash upon finishing render with 'Cache Result' enabled 2015-07-06 12:35:11 +02:00
be07ab58c6 BGE Fix T45207: Camera actuator shakes with low height
The camera-aiming code was using a near-zero-length cross product, which
caused oscillations. Thresholding on the cross product length seems to
fix this.

Reviewers: lucky3, Matpi, lordloki

Reviewed By: lordloki

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1387
2015-07-06 12:20:29 +02:00
28d712b238 Remove redundant face-flipping check 2015-07-06 19:21:19 +10:00
72565fbf30 Cleanup: style, spelling 2015-07-06 17:45:11 +10:00
499308d079 CMake: use cmake commands where possible 2015-07-06 13:34:32 +10:00
15c301f533 Change default for bevel to match previous behavior.
Have reconsidered and feel it best to try matching previous behavior
(doing "loop slides" where possible) as default. This will avoid the
need to change regression tests, among other things.
2015-07-05 13:31:26 -04:00
12aff8d783 Add 'loop slide' option to bevel. See T45260
Current behavior of bevel is to 'loop slide' along unbeveled edges
when possible, but this produces uneven bevel widths sometimes,
so this option lets user choose between having the loop slide effect
or having more even bevel widths. Trying it out with default being
'no loop slide', so different from current behavior. May reverse this
choice later, depending on user reactions.
2015-07-05 09:53:17 -04:00
51e9a814c9 Correct vert-slide helper-line scale
Was invalid in perspective view
2015-07-05 22:35:04 +10:00
6022bfbc05 Correct comment 2015-07-05 22:19:01 +10:00
2b63ec2894 Fix T45319: Set same precision for 3D cursor location as other locations (objects', vertices', etc.). 2015-07-05 10:55:59 +02:00
6de7f3c747 GPencil: use ctrl+x/del for dissolve
Move dissolve into own operator (as with mesh/armature)
2015-07-05 14:34:17 +10:00
68d72e2164 Add key toggle (V) to bevel tool to turn vertex-only on/off. 2015-07-04 10:14:47 -04:00
8d15cad449 Cleanup: Typo in comment. 2015-07-04 13:17:29 +02:00
631b53bad4 RNA: Match enum string to UI name
Having different terminology for enum's is confusing for scripters.
2015-07-04 13:02:59 +10:00
b997bda9f9 BGE: Fix T45259 collision sensor registration. 2015-07-03 23:48:26 +02:00
749f346ce0 BGE: Add alpha to coverage render mode.
This patch add a new option for transparency meshes : Alpha to coverage, in the game setting panel in material.
The alpha to coverage request a multisample, the best is 8x but 4x and 2x can also give nice render.

4x alpha clip : http://www.pasteall.org/pic/show.php?id=89464
4x alpha to coverage : http://www.pasteall.org/pic/show.php?id=89463

Reviewers: moguri, kupoman, campbellbarton, psy-fi

Reviewed By: psy-fi

Subscribers: lordloki, rdb

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1354
2015-07-03 19:03:29 +02:00
c503d17353 Fix T45281: IOR Value Slider with "Ctrl" modifier does not increment as intended.
Looks like a typo in rB1b8069bd?
2015-07-03 18:56:59 +02:00
e42609db49 Fix T45283: Blender crashes on some grayscale PNGs with alpha.
PNG_COLOR_TYPE_GRAY colortype can have some values for alpha, in the same way as
PNG_COLOR_TYPE_PALETTE colortype.

In this case, we need two channels (grayscale and alpha), not one.
2015-07-03 18:30:58 +02:00
97b431e42d BGE: Add integer uniforms for 2D Filter
Actually it is only possible to pass float properties to a 2D filter (GLSL fragment shader).
This patch allows also to use integer properties for the 2D filter.

Reviewers: sybren, agoose77, kupoman, moguri, lordloki, panzergame

Reviewed By: lordloki, panzergame

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1370
2015-07-03 17:07:31 +02:00
1ace3272aa Walk mode: Add modal shortcuts in UI (header help message). 2015-07-03 15:55:22 +02:00
9133f5a357 Cleanup: 'return' parameters to the end of functions, and use 'r_' prefix for them. 2015-07-03 15:55:22 +02:00
947cdb3acd UI: add ability to access/generate 'shortcuts strings' of modal keymaps.
We already had that for global keymaps (used e.g. to generate shortcuts for menu entries),
but this wasn’t possible for modal keymaps yet (e.g. help message in header during
transforms and other modal operation).

This commit only adds needing background code, it does not change anything from user PoV.
Modal operators will be updated to use it in comming weeks.

Thanks to Campbell for revisions & suggestions. :)

Differential Revision: https://developer.blender.org/D780
2015-07-03 15:55:22 +02:00
36426c3ee2 Cycles: Code cleanup, double semicolon 2015-07-03 15:44:57 +02:00
3129685f38 Sequencer: srt export support.
This commit adds a new operator that will compile the list of text
strips into an srt file. No positioning is supported yet but will
be added later.

The operator can be found in the effect panel in the strip properties.
2015-07-03 12:38:43 +02:00
c864f5d140 Cycles: Error enqueueing split kernels should no longer cause infinite loop 2015-07-03 12:13:38 +02:00
145ab8c49e BGE: Extend Python API for KX_BlenderMaterial (specular, diffuse…)
Add support for material diffuse, specular… in KX_BlenderMaterial python proxy. And use mathutils in KX_BlenderMaterial for the specular and diffuse color in KX_BlenderMaterial.

Reviewers: sybren, brita_, kupoman, agoose77, dfelinto, moguri, campbellbarton, hg1

Reviewed By: moguri, campbellbarton, hg1

Subscribers: dfelinto

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1298
2015-07-03 11:47:48 +02:00
659e5234af Cycles: Use explicit indices for split kernel queues 2015-07-03 11:05:28 +02:00
b9f89b1647 Cycles: Code cleanup in split kernel, whitespaces 2015-07-03 11:03:56 +02:00
Dalai Felinto
80f344fd95 Multi-View UI: convergence is only useless for the parallel camera (toe-in still uses it) 2015-07-03 01:11:35 -03:00
c702dabc3d Fix vertex slide regression w/ rotated objects
This could only be done with certain rotations.
2015-07-03 10:57:38 +10:00
2b5e150db0 BLI_GHash: add BLI_gset_str_new helpers. 2015-07-02 20:35:05 +02:00
626a287c89 Support debug contexts on win32 2015-07-02 20:06:02 +02:00
00808eb39a Make OpenGL debug contexts a flag --debug-gpu instead of a compile time
option.

This makes sense, since contexts get created at runtime, there is little
reason to require recompilation for this.

Only works on linux currently, will be doing more OSs later
2015-07-02 19:30:17 +02:00
Dalai Felinto
a5b2841aa0 RNA Doc: Camera shift affects all cameras (perspective, orthographic and even panoramic) 2015-07-02 13:53:36 -03:00
Dalai Felinto
fdb474fc8a Game Engine: Camera Lens Shift: support to change it during game 2015-07-02 13:51:30 -03:00
145d3540b3 Text effect strip for sequencer.
Is pretty much what it says :)
Easy subtitles for everyone!

Supports size, positioning,
a cheap shadow effect (probably will need more work),
and autocentering on x axis.

Now you can go wild with long spanish names
in your soap opera videos.

Will probably be refined as days go by,
but at least it's now ready for testing.
2015-07-02 18:46:46 +02:00
2723d10704 Render: Solve wrong vertex parent in linked objects with Locked UI
The cleanup function was a bit too much aggressive here, made it much more
conservative. It means memory usage will not be so low anymore, and to
address this we'll need to make this function depsgraph aware.
2015-07-02 16:12:08 +02:00
84b8ce32a4 Fix crash in background mode after the NDof deadzone commit 2015-07-02 15:59:12 +02:00
d96842bf19 Fix: Keyframe indicators for NLA Strip properties fails if the AnimData has an active action 2015-07-02 23:39:34 +12:00
fabc4fc720 BGE: remove check for area in start-game operator
This prevented the BGE from being started from the command-line,
the exec() function checked already.

Also use API calls to find area, region.
2015-07-02 21:31:39 +10:00
e61ead7d4c BGE: Fix T45267 Lib load without material caching. 2015-07-02 12:27:14 +02:00
db8ccc18f7 Fix T45269: Blender 2.75 crashes when I run my the game
Velocity clamping on static objects caused a crash.
2015-07-02 12:05:49 +02:00
e80e4c937b BGE: Fix T45196 armature action on libloading. 2015-07-02 11:56:49 +02:00
1393695145 Linux desktop spec: Add a 'Keyword' field. 2015-07-02 08:53:45 +02:00
1844160a22 DerivedMesh: cleanup & minor edirs
- place return args last position
- move crazyspace function out of DerivedMesh header
- use bool for args
- flow control on own lines to ease debugging
2015-07-02 16:20:22 +10:00
10c1f208b7 Minor edits to --help 2015-07-02 13:17:06 +10:00
Julian Eisel
b05cf040cb Cleanup: Use bool instead of int 2015-07-01 21:48:42 +02:00
5edff01920 Transform: use snap-to-grid behavior from D910
Excuse the trashing here, but seems users prefer this most (though both can be useful).

Note that the UI remains the same,
so this is an option for 'Incremental' snapping instead of a new snapping mode.
2015-07-02 02:20:54 +10:00
19da2d4124 Linux XDesktop spec: add '%f' file specifier to 'Exec' field.
Also reorder alphabetically generic names & comments, and add french comment.
2015-07-01 17:40:34 +02:00
12a8d7e6c4 Cleanup: Make select grouped effect code a bit more readable 2015-07-01 17:37:14 +02:00
6781cf0049 Refactoring:
Make sure SEQ_TYPE_EFFECT is only used as a flag, not as number
comparison.
This should allow us to add new non-effect types in between
effect types (every 8 indices).

Dirty, but alternative of separating type/subtype means we lose
forward compatibility.
2015-07-01 17:33:10 +02:00
607dca0705 BGE: Fix T44069 playing action during libfree. 2015-07-01 16:51:48 +02:00
d3709f4e79 Correct --help message 2015-07-02 00:24:10 +10:00
1a44237d82 Removing gaps will now also move the scene markers, unless markers are
locked
2015-07-01 16:25:28 +02:00
f525483d83 Sequencer metadata:
Add option to render strip metadata to final result, bypassing current
scene metadata.
2015-07-01 15:23:21 +02:00
0e084f93d9 BGE: Remove KX_PolygonMaterial reference in documentation. 2015-07-01 14:56:02 +02:00
d3109a1937 BPlayer compile fix © 2015-07-01 12:34:04 +02:00
53d12bbe04 atomic_ops: Fix MSVC versions of add/sub returning original value instead of result of operation.
Thanks to Brecht for tip about how to fix this!
2015-07-01 12:25:32 +02:00
174d5cf627 atomic_ops: fix typo in func names (uint32 instead of uint64). 2015-07-01 12:25:31 +02:00
78de47ca24 Cycles: Fix zero-size buffer allocation with OpenCL devices
This is not really supported by OpenCL but might happen in certain
configurations. There might be some remained cases when this happens
but so far can not find any,
2015-07-01 11:56:48 +02:00
9b64ebc605 Fix T45253: Particle emitter volume mode and grid mode broken in 2.75.x
This is a regression since dced56f and root of the issue comes to the fact
that grid distribution sets UNEXIST flag during distribution, which is then
being reset in initialize_all_particles().

This commit solves the issue, but it's not really nice and some smart guy
might want to revisit it.
2015-07-01 10:32:30 +02:00
95a1e99909 Particles: Code cleanup, whitespace 2015-07-01 09:33:52 +02:00
a77edab320 Cleanup: use bools 2015-07-01 16:57:18 +10:00
58d65dd976 Cleanup: use cross_v2v2 function 2015-07-01 16:37:05 +10:00
d9046ccbd4 Cleanup: doxygen comments 2015-07-01 16:30:26 +10:00
1779452eb4 Cleanup: use swap math funcs 2015-07-01 16:02:30 +10:00
45b2218341 User Prefs for NDOF dead-zone
D1344 with edits
2015-07-01 13:45:19 +10:00
b71c27a446 Use macro for user-prefs version checks 2015-07-01 12:48:53 +10:00
cf1bac3f69 Cycles: Solve some harmless NULL pointer magic
Was harmless but confused some sanity checks, also kinda makes sense
to be more verbose about what's going on there.
2015-06-30 23:41:19 +02:00
Julian Eisel
5e9b43cc61 Fix 1px gap in regions drawn with region overlap 2015-06-30 21:04:25 +02:00
6510e40500 Fix T45240: New depsgraph ignores animation applied on the curve data 2015-06-30 18:11:21 +02:00
21db9fff12 Fix T45238: New depsgraph flickers with the lattice modifier 2015-06-30 18:00:24 +02:00
00bfca2178 Fix T45241: New depsgraph was lacking update of python drivers on time change
It's quite tricky to see if the driver actually depends on time or not,
so currently used approach when we'll be doing some extra updates.

This seems to correspond to how old depsgraph was dealing with this.
2015-06-30 17:34:57 +02:00
c1d6a26842 Fix T45239: New depsgraph does not work with IK pole target 2015-06-30 16:48:43 +02:00
7039808899 Fix T45251 custom directory not taken into account for image proxies. 2015-06-30 16:31:30 +02:00
72d21fbd34 Fix for mistake in grid-snap patch 2015-06-30 23:55:14 +10:00
6de17c60bf Select flush deleting edgeloop in edge mode too 2015-06-30 22:50:32 +10:00
df19da3a8b CMake: remove helper text
Its out of date, better use the wiki building docs.
2015-06-30 22:46:55 +10:00
3bb698646a CMake: minor edits 2015-06-30 22:44:27 +10:00
c07bba1b05 Transform: add back absolute snapping option
This ensures that vertices are grid-aligned while transforming,
instead of just snapping the input values for translate.
2015-06-30 19:14:46 +10:00
5d3ba4fb80 Cleanup: transform grid snap round, not floor 2015-06-30 18:26:37 +10:00
cec0138bcc Note that closest_point_on_mesh is in object space 2015-06-30 15:47:44 +10:00
cfd36476a1 Cleanup: use const for screen functions 2015-06-30 15:31:55 +10:00
d59721e47a Cleanup: move BLI_char_switch into BLI_string 2015-06-30 15:18:03 +10:00
d17cb3f75f Cleanup: use BLI_str prefix for BLI_replacestrN 2015-06-30 14:50:34 +10:00
8bef305b6d Cleanup: move BLI_timestr to BLI_timecode 2015-06-30 14:47:31 +10:00
Dalai Felinto
56ca7f34dd Fix T45237: Dither dosn't work in Blender Internal Renderer after Multi-View 2015-06-29 18:10:15 -03:00
Julian Eisel
40d19b519d Node Editor: Use Smaller Factor for Grid Snapping
An attempt to treat @sebastian_k's blood pressure a bit.
2015-06-29 22:05:13 +02:00
079b41dd37 Remove WITH_TESTS_PERFORMANCE option.
Performance tests now have their own CMake macro, which ensures they do not get
added to ctest list, so we do not have to bother about them anymore, and can always
build them (when GTests are enabled, of course).
2015-06-29 20:26:58 +02:00
117bcfe039 GTests: do not add 'performance' tests to auto-ran tests (with ctest or 'make test')... 2015-06-29 18:15:02 +02:00
a8bc5f0cdb Fix .obj testing. 2015-06-29 18:14:27 +02:00
Dalai Felinto
f12b1790a0 Fix 73841 : Game Engine - Camera Lens Shift
This is essential for video projection, and the alternative until now was to manually change the projection matrix via Python.
( http://www.blender.org/manual/game_engine/camera/introduction.html#camera-lens-shift
- this page will be removed as soon as I commit this)

Also this is working for perspective and orto cameras BUT if the sensor is not AUTO it will only look correct in blenderplayer (this is an unrelated bug, but just in case someone runs into it while testing this, now you know why you got the issue).

Kudos for the BlenderVR project for supporting this feature development.

Differential Revision: https://developer.blender.org/D1379
2015-06-29 10:45:27 -03:00
Dalai Felinto
3d12d4b94f Fix T45234: Stereo Parallel vs. Off-Axis
Parallel rendering was not working.

The idea of having parallel convergence mode to render as parallel but
visualize as off-axis was good, but it was leading to some complications
in the code.

I think it's more clear to the user if parallel looks and render as
parallel, and if she wants to pre-visualize the converged planes, simply
temporarily set the camera to off-axis.
2015-06-29 10:24:25 -03:00
295d0c52a2 Fix T45022: Update missing when linking objects with new depsgraph 2015-06-29 12:59:21 +02:00
e35a26fbef Fix T45156: scaling region crash 2015-06-29 20:48:00 +10:00
6654ec7de7 Fix T45154: Translation binary file(blender.mo) for Japanese is too small
The issue was caused by some changes made to msgfmt which were needed to make
modified (cleaned-up, stripped-comments messages) working.

Unfortunately that fix was merged into the release branch, so this fix is to
be ported there as well and verified against rc1 translations.
2015-06-29 12:27:59 +02:00
827ccc343f Partial fix T45156: scaling region crash
'ar->winy' may not be initialized, making regions zoom in (past limits)
and attempt to draw very large text (~10x10k size characters), often crashing.

Fix isn't complete since it only corrects factory startup.
2015-06-29 16:49:23 +10:00
e6f7f36e40 Cleanup: Style in for loops header. 2015-06-29 00:56:04 +02:00
e245a57640 Fix T45227: Light optimization commit broke world MIS 2015-06-28 20:47:35 +02:00
68478aea01 Cycles: Avoid having duplication of BVH arrays during build
Previous idea behind having vector during building and array for actual storage
was needed in order to minimize amount of re-allocations happening during the
build, but it lead to double memory overhead used by those arrays at the vector
to array conversion stage.

Issue with such approach was that for BVH without spatial split size of arrays
is known in advance and it never changes, which made vector to array conversion
totally redundant.

Also after testing with several rather complex from spatial split scenes (such
as trees) it seems even conservative approach of reallocation (when we perform
re-allocation when leaf does not fit into the memory) doesn't give measurable
difference in time.

This makes it so we can switch to array, which will avoid unneeded memory
re-allocations when spatial split is disabled without harming other cases.

it's a bit difficult to measure exact benefit of this change on our production
files here, but depending on the scene it might give quite reasonable memory
save.
2015-06-28 18:15:25 +02:00
b506f3d328 Cycles: Add assert to an array at() function to be sure we don't have bad memory access 2015-06-28 18:15:25 +02:00
d9ef528d05 Cycles: Minor code style cleanup, whitesaces 2015-06-28 18:15:25 +02:00
9f48aa45ad BGE: added clamping of angular velocity.
Angular velocity clamping was missing from the BGE. It is implemented
similarly to the linear velocity clamping. It is needed to be able to
drive physical simulations of systems that have a limited rotational
speed.

Reviewed by: campbellbarton, panzergame, ton

Differential Revision: https://developer.blender.org/D1365
2015-06-28 12:54:53 +02:00
c5c2883ce0 BGE Fix: apply velocity clamping on every physics subtick
This patch uses the Bullet "internal tick callback" functionality to
ensure that velocity clamping is performed after every physics update.
This makes a difference when physics subticks > 1, as in that case the
too-high velocity could have impacted the simulation.

This patch follows the examples at [1] and [2]; the latter example
also explains that the way we limit velocity in the BGE (before this
patch) is wrong.

[1] http://bulletphysics.org/mediawiki-1.5.8/index.php/Simulation_Tick_Callbacks
[2] http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Code_Snippets#I_want_to_cap_the_speed_of_my_spaceship;

Reviewed by: panzergame

Differential Revision: https://developer.blender.org/D1364
2015-06-28 12:54:53 +02:00
32319dd106 Cleanup: remove BLI prefix from BKE funcs 2015-06-28 19:09:52 +10:00
2ef3c43c5d Fix T45214: BI render: maximum saturation bug in shadow pass with non-shadow lighting.
In case scene lighting would only have non-shadow light source, shadow intensity
would remain to 'pitch black'...
2015-06-28 10:53:07 +02:00
3d616ccba8 Temporarily disable absolute snapping
This really should have been finalized as a design task first,
there are too many open topics on how it should work.
2015-06-28 10:13:11 +10:00
aac5485fca Fix T45216: File Browser shows negative sizes for large files.
Simply backport small part of work from asset-experiments here (using double and
adding tera-bytes unit), looks like off_t is not always 64bits even on a 64bit OS...
2015-06-27 23:39:48 +02:00
008da0ff5e Cycles: Use aligned blender allocator when using guarded allocation
This way we solve possible issues caused by regular allocator not being aware of
some classes preferring 16 bytes alignment needed for SSE to work properly. This
caused random crashes during rendering.

Now we always use aligned allocation in GuardedAllocator which shouldn't be any
measurable performance impact and the code is only used by developers after
defining special symbol, so there is no impact on release builds at all.
2015-06-27 21:07:43 +02:00
3d7329950e OpenGL debug contexts:
Enable debug output in debug contexts for gl 4.3+
2015-06-27 17:20:30 +02:00
4d74180b9f Cycles: Fix for wrong device enumeration in CUDA
it is the same issue as described in the previous commit, original changes
in this area were wrong and only worked on a bugger optimus driver which
simply appeared to work by co-incident and in fact used wrong device..
2015-06-27 15:13:08 +02:00
09dc470982 Cycles: Rework the way how OpenCL devices are created
It was annoying copy-paste happened across OpenCL device constructor, device
enumeration and split kernel checks. Now those areas are using an utility
function which returns pairs of platform and device IDs for devices which are
supported by Cycles and enumeration is happening inside that list.

This makes it so filtering is happening in a single place, so there's no need
to keep 3 different functions in sync.

This commit also fixes a bug with wrong enumeration of devices caused by recent
fixes. Those fixes were in fact wrong and only happened to appear to be working
on laptop with optimus card on Linux. Root of those issues is in fact in bad
Linux driver for optimus cards.
2015-06-27 15:13:08 +02:00
17f12fc71a Cycles: Allow using custom allocators for vector class 2015-06-27 15:13:08 +02:00
9260c0c2ba Cycles: Ignore light which has no contribution to the scene
This commit makes it so light which has zero energy or doesn't has
emission shader at all is being ignored by the path tracing.
2015-06-27 15:13:08 +02:00
48ef0501b7 Transform: absolute grid snapping
D910 by @donfabio with edits

New icon for menu is still TODO
2015-06-27 20:03:28 +10:00
e2d3e36ca7 Cycles standalone: add support for reading UV coordinates to the XML scene reader 2015-06-27 12:05:05 +02:00
c68322c7e5 Cleanup: int/uint mismatch in printf... 2015-06-27 11:02:58 +02:00
e170d6be7f Cleanup: all params of BLI_str partition funcs can be const... 2015-06-27 11:00:47 +02:00
ecb6a6df52 OpenEXR cleanup: get rid of public IMB_exr_split_token, use BLI str helpers instead of own cooking. 2015-06-27 10:24:54 +02:00
ff7a46cfad GTests for new 'end' option of BLI_str_partition_ex(). 2015-06-27 10:24:54 +02:00
4d043c99dc Extend BLI_str_partition_ex: add possibility to define a right limit to the string.
Now you can define `end` pointer as right limit of the string (allows to easily search
in substring, especially useful when searching from right).
2015-06-27 10:24:54 +02:00
e78b03f9e9 Fix part of code in load_image_single() wrongly disabled when WITH_OPENEXR was disabled. 2015-06-27 10:24:54 +02:00
ab85c5f980 Fix crasher when loading multiview OpenEXR image.
With multiview/multilayer OpenEXR file, `load_image_single()` will return NULL ibuf,
since it has already populated ima (with `image_create_multiview()` or
`image_create_multilayer()` calls).

Also, added some more checks before doing `IMB_ImBufFromStereo3d()`, to be sure
we do have enough slots in ibuf_arr, and we do not overwrite second ibuf either.
2015-06-27 10:24:54 +02:00
851d7535d9 Fix T45204: String Splitting Function Bug: Using OpenEXR function even if compiled without OpenEXR.
Seriously!!!

Also, fix a potential buffer overrun here.

This should be backported to final release.
2015-06-27 10:24:54 +02:00
ddeb8c595f Cleanup: Fix a typo in world MIS.
Found by Lukas Stockner, thanks!
2015-06-26 21:36:28 +02:00
c58b5acefd Fix crash on undoing after 8690ea6
Forgot to clear the mutex when reloading the scene.
2015-06-26 17:50:08 +02:00
79c106705a Make code compile with GPU_DEBUG 2015-06-26 17:40:54 +02:00
8690ea611e Fix T45199 crash when editing material nodes.
Issue is data race between preview job and GPU nodetree evaluation when
localizing the nodetree. Data race happens due to localizations doing
overrides on original nodes' new_node variable.

Solution here could probably be to use a hash for mapping of old to new
nodes but will prefer simple brute force lock for now.
2015-06-26 14:47:53 +02:00
09e89f01a6 Cleanup: transform center
store global center in transform struct,
some code was calculating all the time, this is useful to keep available.
2015-06-26 16:21:04 +10:00
c74255181e Cleanup: transform aspect
Transform code had duplicate aspect checking,
now store aspect in TransInfo.aspect for reuse.
2015-06-26 15:45:09 +10:00
2cdcb1c171 Revert "Fix off by one error in display of start/end frame in sequencer."
This reverts commit 0e02ad8b64.

Initial commit was done so visual result fits with animation cursor
in timeline but this makes it so it looks like one extra frame is
rendered. Other idea would be to render one less frame for sequencer
but this is not so nice either. Generally here's no way to be
fully consistent here, but at least let's be workflow-consistent
2015-06-25 20:10:30 +02:00
0e83b0854f Fix T45191 Speed strip behaviour not easy to predict.
Code here calculated speed based on underlying strip start position,
which was not really visible, making prediction of the result really
difficult. Things here are simple: As long as the strip exists,
manipulate the current frame by the provided factor.
2015-06-25 19:49:08 +02:00
284d294f2c Fix T45190 effect muting does not restore original sequencer display. 2015-06-25 18:21:58 +02:00
c0ea3099c5 Correct error in recent refactor
Closed loops missed last line
2015-06-25 22:11:25 +10:00
ef57051e9c Select flush was missing in delete edge-loop 2015-06-25 21:06:47 +10:00
8e95303414 splash fix, previous had color conversion error 2015-06-25 18:44:45 +10:00
c40205738b Weight Paint: replace Blend with Smooth tool
Improved behavior

- can smooth # iterations
- option to expand/contract weights
- optionally mix with all/selected/unselected
2015-06-25 16:17:24 +10:00
ba98e6148b API calls for converting weights to float array 2015-06-25 16:17:24 +10:00
42314b32f2 Cleanup: generalize weight paint poll function 2015-06-25 08:32:09 +10:00
Quentin Wenger
6f17fb8630 BGE: Missing dot in 2d filter actuator documentation. 2015-06-24 22:34:55 +02:00
Quentin Wenger
fc668df245 BGE: Fix 2dfilter actuator mode constants. 2015-06-24 15:31:55 +02:00
Quentin Wenger
49aa7b1261 BGE: Fix color used as background in VideoTexture.
Now we use color converted (if we do a color management) by the setter for background color in VideoTexture (ImageRender & ImageMirror).

Reviewers:panzergame
2015-06-24 13:03:23 +02:00
1676fcded0 WeightPaint Blend: don't stack mem for dverts
Bad assumption since this could be a large list
2015-06-24 20:42:02 +10:00
c40759e678 Cleanup: warnings 2015-06-24 18:42:16 +10:00
a09af2dc7b Fix edge/vert slide UV-correct, small face error
Decrease epsilon to prevent flickering with small faces.
2015-06-24 11:21:54 +10:00
9ce738e0f6 Fix edge/vert slide UV-correct & non-planar faces
non-flat ngons would give instability (bad UV's).
2015-06-24 11:21:54 +10:00
a33b1ce500 Correct recent error 2015-06-24 11:21:54 +10:00
Dalai Felinto
227aefc18b RNA: exposing image_user settings for ImageTextureNodes
This is required in order to access image sequence frame_duration and
frame_offset among other settings.
2015-06-23 21:19:58 -03:00
0d4cca6593 Fix edge/vert slide UV-correct & zero length edges
When calculating loop angle weighting, skip overlapping vertices.
2015-06-24 09:54:23 +10:00
f1bad1d16b Improve dist_***_to_corner_v3v3v3 precision
Remove offset before calculating distance.

Define 'plane3' to BLI_math, since we often don't need the 4th component.
2015-06-24 07:21:11 +10:00
40a345a9c7 Cleanup: style 2015-06-24 05:13:43 +10:00
04e9a707f4 Subsurf: Make color layer aquisition order for textured draw match
cdderivedmesh
2015-06-23 17:48:46 +02:00
b318795c3b Fix T45051: Curve parent bug.
PARCURVE is deprecated parting type, should never have been exposed to user!

Not a regression, but safe enough for final 2.75 imho.
2015-06-23 17:35:55 +02:00
90b4131d16 BGE: Fix 57065a, missing dots. 2015-06-23 14:57:38 +02:00
57065a6df5 Minor tweaks to bge.constraints docs 2015-06-23 21:58:08 +10:00
1c251d7cb6 Update bge.constraints API doc
D1357 by @Matpi with edits.
2015-06-23 21:37:28 +10:00
72e812de7c Fix T45123: 2D line intersection fails
Co-linear lines could detect as intersecting even if they weren't overlapping.
2015-06-23 21:01:12 +10:00
ec8e0336a9 Cleanup: use 2d math funcs for line intersection 2015-06-23 21:01:11 +10:00
7ecb199d86 Fix stupid mistake 2015-06-23 12:58:33 +02:00
cb5aecdae9 Code cleanup: Use enums for redraw timer operator, makes things more
readable
2015-06-23 12:53:33 +02:00
91fde2891c Fix edge drawing, total loose edges can only be determined -after- the
edge buffer has been setup (this is where they are counted)
2015-06-23 12:06:36 +02:00
cd7853be22 CMake: quiet warnings in GTest 2015-06-23 14:34:52 +10:00
4e8092e2e4 CMake: support multiple args to remove_cc_flag 2015-06-23 14:30:08 +10:00
f1917a2188 Allow editing the text editor line directly
Alternate solution for T44855
2015-06-23 10:17:00 +10:00
d6e180e75a Fix T45117: Dark dupli-face objects (regression) 2015-06-23 08:02:00 +10:00
74f7ef1240 Missed changing default arg in addon_utils.disable 2015-06-23 07:25:10 +10:00
e2fa6663d3 Fix T44320: UV island overlap considered linked 2015-06-23 07:07:52 +10:00
80192b5391 Fixed compilation error in editor/animation/anim_markers 2015-06-22 20:38:25 +02:00
Julian Eisel
f0c5ed39ee Fix T45149: Normal Node shows a hole in its sphere with heigh scale facs 2015-06-22 20:35:49 +02:00
211a95b538 Fix T45034: MirrorBall rendering on wrong camera axis
This was a mistake in the original code from D1079.

With the current way how direction ot mirror ball works camera should look
into negative Y direction. Corrected it in the camera matrix synchronization,
so no extra calculations are needed at the render time.

That's a bit annoying, but we'd better port it to the release branch, or
otherwise we'll end up with files created with wrong camera mapping after
2.75 release.
2015-06-22 20:09:52 +02:00
a1609791ca Fix T45148, stupid own mistake, the two functions are not the same,
shouldn't have collapsed them
2015-06-22 19:40:07 +02:00
4faccf0a78 Revert "Lock markers now also disallows selection of markers"
This reverts commit 37fd262805.
2015-06-22 19:40:07 +02:00
d979ac4cc9 BGE: Fix T45110, T44174, armature animations update and mirror render.
Reveiwers:Moguri, Matpi, youle
2015-06-22 18:16:31 +02:00
5e241e3028 Fix T45145, multiview selection fix not working for scaled matrices.
Multiview code already accounts for scale, do not scale frame before
multiplying with matrix.
2015-06-22 15:55:36 +02:00
7119a0f67d Fix T45136, only draw edges if there's something to draw. 2015-06-22 15:18:04 +02:00
3044e9fd31 Cycles: Respect duplicator's object motion blur settings
The idea is to make it possible to control linked duplicated objects motion
blur from the scene file without need to do overrides on the linked object
settings. Currently only supported for dupligroup duplication and all now
if duplicator object has motion blur disabled then it'll be inherited into
all the duplicated objects.

There should be no regressions/changes in look of existing files because
objects do have motion blur enabled by default.
2015-06-22 13:53:04 +02:00
b5b8599342 Fix T45144: Multi-value-edit ignored range 2015-06-22 19:36:30 +10:00
63c9f51133 Fix camera stereo logic use /w regular select 2015-06-22 18:23:59 +10:00
c119187be0 Fix T45133: Crash drawing material buttons 2015-06-22 16:51:22 +10:00
63f62cd757 Fix memory leak /w multi-drag over a single button 2015-06-22 08:27:56 +10:00
857c9e14f7 Cleanup: Get rid of some ugly magic numbers... 2015-06-21 22:37:39 +02:00
43f6ed908f Fix T45135: More cleanup of extreme max values in operator properties.
INT_/FLOAT_MAX are sometimes valid choices, but most of the time more
sensible values should be used here!
2015-06-21 21:56:35 +02:00
6057548058 Fix/Cleanup possibility to type insane values in 'add' operators options.
Our 'hard limit' values was too often max_int/float here, mis-typing could
lead to crash (or infinite hanging) of Blender, see e.g.
http://blender.stackexchange.com/questions/32790/blender-forces-computer-to-reboot-after-mistyping-extreme-value-for-resolution-i
2015-06-21 16:06:44 +02:00
8be4d76204 Change defaults for planar-face tool 2015-06-21 12:52:37 +10:00
9ddb624a88 Cleanup: quiet warning 2015-06-21 12:33:55 +10:00
8d752141ce Support for platforms /wo malloc_usable_size
Was only used for stats, netbsd doesn't define this function.
2015-06-21 12:33:55 +10:00
e3d6269ec4 BMesh: replace BLI_array -> BLI_stack 2015-06-21 09:46:12 +10:00
cdb0cf3ec7 BMesh: replace BLI_array -> BLI_stack
Also use more direct custom-data access.
2015-06-21 09:19:12 +10:00
aeda4dca77 Threads: Cache result of syscall when querying number of system threads
Number of system threads is quite difficult to change without need of blender
restart, so we can cache result of the systcalls (which are not really cheap)
in order to be able to call BLI_system_thread_count() without worrying of
performance issues in that function.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D1342
2015-06-20 22:10:30 +02:00
a95b0e0e9d Cycles: Another fix for OSX, sm_50 experimental actually also fails to compile
Didn't notice it originally because compilation was threaded.
2015-06-20 19:40:23 +02:00
5e2835037a Cycles: Tweak to previous commit, experimental sm_52 works on Linux but not OSX 2015-06-20 19:01:24 +02:00
34d665a4a4 Cycles: Un-inline triangle_intersect_precalc() on Apple OpenCL
This gives quite the same problems as experimental CUDA kernels
and for until it's found a root cause of the problem we'd just
explicitly uninline the function.
2015-06-20 18:00:30 +02:00
63dd554ff1 Cycles: Don't show pre-sm_20 CUDA cards in the device list 2015-06-20 17:34:12 +02:00
5a4b51992e SCons: Enable sm_52 CUDA kernel on all platforms 2015-06-20 17:01:21 +02:00
845854959f Cycles: Cleanup, make it more obvious which platform requires workaround for triangle intersection
Should be no functional changes.
2015-06-20 17:01:21 +02:00
2a305580b2 BGE: Fix T38030: wrong vertex index returned by KX_PolyProxy
Fix T38030.
In c++ source we use one list for triangles and an other for quads, but KX_PolyProxy doesn't care about that and return the vertex offset in its list. So we just have to compute the offset of each RAS_DisplayArray to its previous to have an absolute vertex index.

Reviewers: moguri, campbellbarton, kupoman, agoose77, brita_, hg1

Reviewed By: agoose77, hg1

Projects: #game_engine

Maniphest Tasks: T38030

Differential Revision: https://developer.blender.org/D1324
2015-06-20 14:21:31 +02:00
6b3a43ccb4 BGE: dissallow calling reverse on internal clists 2015-06-20 20:02:16 +10:00
b6820c9522 missed last commit 2015-06-20 19:47:34 +10:00
e019d8fb8c Transform: UV islands were split by winding
This meant front/back faces from a projection would be seen as separate islands.
2015-06-20 19:28:51 +10:00
e3fe56d9d1 Minor edit to transform-uv-island center calc
Only count each UV to influence the center once.
2015-06-20 19:13:49 +10:00
72a2d22f03 support ninja for netbeans projects 2015-06-20 18:24:06 +10:00
5a69b93f57 Sculpt lasso (used shorts for no good reason) 2015-06-20 17:58:52 +10:00
973afa0172 Cleanup: use listbase clear 2015-06-20 17:09:05 +10:00
f6c661a38f BMesh: simplify join-tri's 2015-06-20 16:48:59 +10:00
e807520a1e BMesh: minor optimization for UV island walker 2015-06-20 16:40:39 +10:00
74b32a23f7 Cleanup: checks for unsupported MSVC versions 2015-06-20 15:17:32 +10:00
4addabaed8 Cleanup: unused vars 2015-06-20 15:17:21 +10:00
2de34ba31d Fix T45109: multi-view regression /w screen-cast 2015-06-20 14:54:02 +10:00
51188ecbf1 BGE Cleanup: Translation of several comments in Dutch 2015-06-20 01:19:32 +02:00
8e1ba0b805 BGE Cleanup: remove dead code at SetCenterOfMassTransform
Basically, at this line body is always NULL and the code is never
executed

Reviewers: moguri, hg1, panzergame, agoose77

Reviewed By: hg1, panzergame, agoose77

Subscribers: blueprintrandom

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1331
2015-06-20 01:00:22 +02:00
1d6c025c42 SCons: Fix missing file in kernel when building on OSX 2015-06-19 21:26:47 +02:00
037181cf1c SCons: Another attempt to fix bundling on OSX 2015-06-19 19:52:47 +02:00
27eb2b1017 SCons: Fix wrong bunding of Cycles kernel on OSX platform 2015-06-19 19:38:51 +02:00
e9406256d0 BGE: Simplify collision callback registration.
Remove list m_triggerController and just use getter CcdPhysicsController->Registered().

Reviewers: sybren, agoose77
2015-06-19 16:40:42 +02:00
ae0ed5e9d5 RNA: Don't fill in color grid array when built without smoke
Array length is set to 0 in that case, so filling in first element is
likely to cause memory corruptions.
2015-06-19 13:55:31 +02:00
Johannes Meng
9affa8450a Expose smoke simulation velocities in Python API
This patch exposes smoke simulation velocities in the Python API,
similar to how density and flame grids are exposed.

This is useful to export velocities to an external renderer using Python.

Reviewers: campbellbarton, sergey

Reviewed By: sergey

Subscribers: sergey

Projects: #bf_blender

Differential Revision: https://developer.blender.org/D1366
2015-06-19 13:50:34 +02:00
9d796df4f6 Support half float file format storage for Multilayer EXR
Quite straightforward implementation -- all the conversion magic is
happening in IMB_exr_write_channels() and remained changes are only
needed to pass information whether channels is to be converted to
half float or not.

Regular file output will use full-float for Z pass, which matches
behavior of the single layer EXR files. But when saving happens
with File Output node then all the passes are respecting half float
settings because it's not possible to distinguish whether we're
saving Z pass or not.

Reviewers: juicyfruit, campbellbarton

Reviewed By: campbellbarton

Subscribers: maxon, effstops, fsiddi

Differential Revision: https://developer.blender.org/D1353
2015-06-19 13:34:11 +02:00
0d3555fe2e Transform: Add individual origins for UV islands
Useful for scaling all UV islands
2015-06-19 21:17:03 +10:00
0f171d4a25 BLI_threads Queue: add BLI_thread_queue_is_empty().
Avoids counting the whole queue when we only want to check whether it is empty or not!
2015-06-19 12:31:26 +02:00
1cf1f48893 Cleanup: fix mismatch in printf formating (int/unsigned int).
Noisy and annoying with new gcc5...
2015-06-19 12:31:25 +02:00
52e95ad3d3 BLI_stack: BLI_stack_pop_n_reverse
Useful to fill an array in the order its added.
2015-06-19 20:19:37 +10:00
d4aeec9204 BLI_stack: function comments 2015-06-19 15:54:42 +10:00
9b3722b414 avoid assert with bmesh inset 2015-06-19 09:41:39 +10:00
d8cef42a14 Fix leak in edge-offset 2015-06-19 06:03:47 +10:00
Dalai Felinto
a1e01fda24 Fix T45104: RGBA PNG Stereo 3d Anaglyph renders turn all shades of black into alpha in 2.75 RC1 2015-06-18 13:56:11 -03:00
e1fd7b9ca9 Cycles: Report currently sampling tile when CPU is working on the last tile
This is mainly useful for the render farms output when logging might stop at
the "Path Tracing Tile N/N" string, which makes it a bit difficult to follow
what exactly is happening (node going crazy, hardware issues or just last tile
is too much heavy).

This is more like an experiment, might be changed in the future.
2015-06-18 16:15:37 +02:00
7e529c2a64 Return non-zero exit code when running blender from the command line and reading file has failed
This way automated scripts can actually see if some issue happened.
2015-06-18 14:07:39 +02:00
4ed6605d65 Cycles: Don't show devices which does not support OpenCL 1.1 in the menu
They'll be checked for the version later and that check will fail anyway,
so better to not allow user to see unsupported device in the list.

Also corrected one more issue with the device enumeration.
2015-06-18 11:26:22 +02:00
28c34d332f Assert when relative paths are passed to IO ops
This is typically an error (& hangs a few seconds on win32), best catch early.
2015-06-18 12:49:10 +10:00
03efc37a6e Transform: Improve UV creation efficiency
- was doing 2x spin-locks, multi-view check and hash-lookup per face-corner.
- avoid doing customdata layer lookup per face.
2015-06-18 12:27:48 +10:00
7165d979ae Fix crash transforming UV /w PET-connected mode 2015-06-18 12:23:55 +10:00
3468038ed5 Fix transform connected UVs memory leak 2015-06-18 12:23:54 +10:00
7fbf264c67 Update netbeans project file generator 2015-06-18 12:23:54 +10:00
530034511c Freestyle: Fix for wrong assertion failure upon inverted face normals.
The assertion code was not taking quad faces into account.

Problem report by Folkert de Vries (flokkievids) through personal
communications, thanks!
2015-06-18 08:28:35 +09:00
18f228d593 update hand written rst docs
- minor corrections
- link to new manual
- wrap lines at 120
2015-06-18 08:00:46 +10:00
Quentin Wenger
a62392dea7 BGE: remove outdated doc of KX_PolygonMaterial, update doc of KX_BlenderMaterial
This patch suppresses the outdated KX_PolygonMaterial.rst documentation file and moves the example contained in it into KX_BlenderMaterial.rst.
The file KX_BlenderMaterial.rst receives some extra formatting changes (lists are not supported in methods arguments types).

Reviewers: kupoman, campbellbarton, lordloki, panzergame, moguri

Reviewed By: panzergame, moguri

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1355
2015-06-17 22:43:29 +02:00
3ce4a58aa9 Cleanup: duplicate includes 2015-06-18 06:32:01 +10:00
937ecaf77e BMesh: Add edge-offset option: cap-endpoint
Creating triangles at endpoints is often not so good, disable by default.
2015-06-18 03:17:20 +10:00
da61c36f2a Revert "Fix/Workaround T44662: Freestyle gives no visual output when the Save Buffers option is enabled"
This reverts commit ab417f31f4.

This workaround caused serious memory corruption issues which is not really acceptable
for the release. We'll be likely sticking to a more limited release when using freestyle
with saved buffers for until proper solution is implemented.

Conflicts:
	source/blender/render/intern/source/pipeline.c
2015-06-17 18:02:02 +02:00
fc35b758ad Fix T44682: Save Buffers canceled renders show nothing in Image Editor
The issue was caused by render pipeline freeing render parts prior to finishing
exr file writing which resulted in unfinished parts not being written into the
file by save_empty_result_tiles().

As a temporary solution we do explicitly write unfinished parts as empty tiles
to the exr file prior to freeing parts.

Not ideal solution, but should work for the release.
2015-06-17 17:50:50 +02:00
e96d1c7965 CMake: use parent scope setting cflags in funcion 2015-06-18 00:59:07 +10:00
0dcda51836 Revert "Correct recent commit replacing macro's /w MSVC"
This reverts commit 810f8928d6.

Worked by accident with MSVC, real fix next...
2015-06-18 00:58:58 +10:00
37fd262805 Lock markers now also disallows selection of markers 2015-06-17 16:59:17 +02:00
bd5ea70a75 Compositor: Fix stupid type in incrementing number of finished tiles 2015-06-17 16:32:07 +02:00
01f21f8026 Report proper frame and time to the console when doing compositing 2015-06-17 16:30:27 +02:00
42d5df448c Cleanup, use define instead of magic number 2015-06-17 16:29:31 +02:00
0119c63405 Print elapsed time when rendering from the command line 2015-06-17 16:06:33 +02:00
bcc4957877 Flush stdout prior of calling render stats callback
Without this extra flush order of stat prints is undefined in the
output. which makes it rather tricky to write custom output in a
reliable way.
2015-06-17 15:49:09 +02:00
0b79c5ed29 Cycles: Report total and render time to the log
This includes total render time spent on rendering since render() was
invoked and also prints time of actual rendering (without synchronization
step).
2015-06-17 14:07:51 +02:00
e1ce9220d6 Fix me being stupid commit.
Copy modifiers operator would copy modifier to all strips, even
unselected ones.
2015-06-17 13:54:36 +02:00
3b57f075a8 Fix (unreported) redo of 'bone envelope distance resize' transform op not working
(it would behave like 'bone envelope resize' instead).

Issue comes from the fact this transform op shares some common points with both BoneResize
and BoneEnvelope operations. However, trying to re-use `TFM_BONE_ENVELOPE` itself in this case
is bad idea, since this mode gets stored in transform op and is directly re-used for redo,
by-passing the whole init phase that shall be done in `TFM_BONESIZE` mode... So now,
we add a real new mode, `TFM_BONE_ENVELOPE_DIST`, while keeping most of existing code
and all existing behavior.

This is slightly hackish - but was already anyway, and avoids creating a full new set of
function for pretty much the same thing. As a side note, also makes it possible to
resize envelope distance outside of envelope viewing mode (from py or by adding a custom
shortcut).
2015-06-17 12:30:30 +02:00
e0ae59f5d8 Cleanup: use floorf instead of floor when dealing with floats. 2015-06-17 12:02:53 +02:00
aee4527101 Cleanup/Fix unreported: many 'transform' apply was not updating t->values with final values.
This means redo panel of matching operators would not get correct values set in case
those were entered with numinput, or some snapping was used...
2015-06-17 12:02:53 +02:00
ae3e37b899 Cycles: Fix wrong numbering of OpenCL devices when some of them are skipped
Skipped devices did not reflect in the device number, which might result in bad
array indices.

This might also resolve T45037, and need to be ported to a release branch.
2015-06-17 11:35:39 +02:00
364d934951 Fix T45059: Image open /w relative paths & anim
- would hang on win32 (checking network share?)
- made the path absolute on all systems
2015-06-17 16:05:35 +10:00
a1c6b73de7 Fix leak getting image frame-range from filesel 2015-06-17 16:05:01 +10:00
5b833de521 ImBuf: Assert when read/write gets relative paths
We _never_ want this, so better not fail silently.
2015-06-17 15:53:35 +10:00
c03dcc5421 CMake: set advanced var 2015-06-17 14:25:05 +10:00
810f8928d6 Correct recent commit replacing macro's /w MSVC 2015-06-17 13:16:21 +10:00
81b37f5e92 CMake: use functions instead of macros
Reduces issues with vars leaking into the parent scope.
2015-06-17 09:38:24 +10:00
ecdbe3cc63 Cleanup: style 2015-06-17 07:06:59 +10:00
2689247f98 Correct last commit
avoid sqrt
2015-06-17 06:54:35 +10:00
770dfead86 Fix T45096: Bad UVs /w EdgeSlide & zero-area faces 2015-06-17 05:51:09 +10:00
aab2da9e65 Optimize drawing of outlines as well 2015-06-16 21:44:40 +02:00
fbff0e68a4 Drawing speedup:
We really don't need to iterate all edges of the mesh every frame to
search for loose edges, this calculation can be cached when filling the
edge index buffer.
2015-06-16 20:55:37 +02:00
5ca3f3d811 Partial Fix T44997: Propagate pose on selected keyframes only included those after the current frame
This behaviour was confusing, since "selected keyframes" suggests that it covers
all selected keyframes (instead of trying to do this based on frame ranges).
2015-06-17 01:49:29 +12:00
c55cf743cd Fix T45088: Wrong tooltip for 'Object Transform' option of transfer data. 2015-06-16 14:17:26 +02:00
94eb2647d5 BGE: correct case for createConstraint keyword 2015-06-16 21:22:41 +10:00
b986f955e9 Disable assert for polyfill
Would fail on some zero-area ngons.
2015-06-16 21:13:22 +10:00
173c1133a8 Fix own mistake selecting linked 2015-06-16 20:33:36 +10:00
fa823dc828 Cleanup: style 2015-06-16 10:32:41 +10:00
b1a92f2b3a Fix T44701: Buffer overrun reading directories 2015-06-16 10:04:28 +10:00
532e29cd76 Win32: make DIR struct opaque 2015-06-16 10:03:12 +10:00
291152e127 Add back ray bounces debug code, can be useful nevertheless.
Just need to keep in mind that these are not indirect bounces in the pass then.
2015-06-16 00:39:11 +02:00
6d63446710 BGE: Fix for precision lost in setBackground/getBackground at Video Texture
Now internally the variables are processed as floats avoiding int->float->char conversions that are causing precision lost.

A check for int numbers is maintained to keep compatibility with old behaviour.

Reviewers: ben2610, campbellbarton, moguri, hg1

Reviewed By: moguri, hg1

Subscribers: campbellbarton

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1301
2015-06-16 00:05:25 +02:00
53e3e46332 Cycles / Branched Path: Some simplifications for main loop.
The main loop only handles transparent intersections from the camera ray.
Therefore we can simplify some things.

* Avoid PATH_RAY_CAMERA check, this is always true.
* Avoid path_state_next() call, we can just set transparent flag and increase transparent bounces. This way we avoid the function call and some branching.

Also remove debug num_ray_bounces++, this is incorrect here as no indirect bounce happens here.

Should be no functional changes.
2015-06-15 23:50:29 +02:00
888ed6b7f1 Cleanup comment and remove now redundant define. 2015-06-15 23:35:38 +02:00
099aaea447 Cycles: Move branched path tracking into own file
Code there started becoming a bit too big, by splitting it up it'll make it
easier to do improvements or extending the features in there.

The layout is not totally final yet, would need to try de-duplicating parts
of code from split kernel with non-split integrators,
2015-06-15 23:02:42 +02:00
6c23497185 Fix T45086: Crash showing scopes
Was a rounding issue, which was previously solved by quite simple check.
Well, let's do the same check again :)
2015-06-15 22:17:16 +02:00
1c707a2392 BGE: Fix T43918: adding submodule bge.app including attribute version.
This patch adds the submodule app to bge. apps contains constants similar to bpy.app, particularly version (tuple of three ints like 2.75.1).

It was requested in T43918 and set as TODO.

The patch also adds rst doc for the module.

Reviewers: moguri, kupoman, lordloki, panzergame, campbellbarton

Reviewed By: lordloki, panzergame, campbellbarton

Subscribers: marcino15

Projects: #game_logic, #game_python, #game_engine

Differential Revision: https://developer.blender.org/D1348
2015-06-15 21:46:56 +02:00
124b25cf9d Usual minor i18n/UI messages fixes. 2015-06-15 21:38:36 +02:00
a44a0cf443 Copy strip modifier operator for sequencer
Copies from active strip to selected strips, found in modifier panel
2015-06-15 21:23:24 +02:00
b633c2857f Fix integer division error with image scopes 2015-06-16 04:16:27 +10:00
3f7ea7489e Cleanup: quiet assert for zero-length axis 2015-06-16 04:16:27 +10:00
bf57c91ead Depsgrtaph: Adding shapekey should update relations
This is needed for the new granular depsgraph, otherwise graph is not
containing all the operations needed for proper update.

And the same is actually needed onwhen removing shape key.
2015-06-15 18:55:26 +02:00
473d46263b Fix T44980: Shapekeys with driver not working with new depsgraph in 2.75 test build
Was just a few missing dependencies.
2015-06-15 18:50:43 +02:00
05b2ab1109 Fix typo in previous commit 2015-06-15 15:40:40 +02:00
9090d64544 Fix T45060: Brush size snaps back to default max 2015-06-15 22:27:52 +10:00
d7cd8ff891 Fix T45052: Compositing-Masks are not editable with new DepsGraph
This commit fixes missing updates of masks with the new dependency graph
in a way which is safe for backport into master branch.

Compositor nodes will not receive needed update callback yet, this will
be solved after mask and compositor are becoming a proper node in the
graph, it is considered a TODO now.
2015-06-15 13:41:32 +02:00
5b8af1d1f1 Fix T44704: BGE regression importing bpy.types 2015-06-15 21:11:45 +10:00
edfe2d6691 BGE: fix use after free 2015-06-15 20:56:44 +10:00
fd629d2fb8 Cleanup: quiet warning 2015-06-15 19:56:43 +10:00
644e2250ce Add missing file 2015-06-15 18:14:24 +10:00
d8e994b35f BMesh: edge-offset feature (Ctrl+Shift+R)
Ability to quickly add 2x edge loops  on either side of selected loops.
2015-06-15 11:03:13 +10:00
3efc0aca54 Revert "Revert "Disable key accelerators for splash screen""
This reverts commit 7f3dcbe17f.

Please check with authors first, this bug was already fixed since RC1.
2015-06-15 10:59:53 +10:00
7f3dcbe17f Revert "Disable key accelerators for splash screen"
This reverts commit 7b0c327b94.
The problem with this commit is that the "move to layer" functionality by hitting M,1 f.e. didn't work anymore...

Campbell, would be great if you could look into this again, as I'm not experienced in this specific region..
2015-06-15 00:54:28 +02:00
e464cbae3b Edge Slide: refactor direction calc into function 2015-06-15 04:56:07 +10:00
9cefd5612d GHost: Attempt to fix compilation error on older OSX systems
The issue was caused by using NotificationCenter which is only available
since 10.9 so trying to build blender on OSX with 10.7 SDK would fail.

Now it should be possible to build blender with SDK 10.7 and at the same
time official builds should still be doing proper weak-linking to a
notification center.
2015-06-14 14:36:05 +02:00
eb0310950c Fix error enabling an already enabled addon
Would run register() twice causing warning with `register_module()`
which expects new classes to be defined.

Now run unregister() before re-registering.
2015-06-14 22:26:42 +10:00
1862991862 Fix '--addons' argument
- only enable addons which aren't already enabled
- use 'persistent' load option (new file wont reset)
2015-06-14 22:18:44 +10:00
b9fe261255 Fix addon_utils.check
Second return value could be None instead of False.
2015-06-14 21:47:02 +10:00
91b23992ce Fix T41870: Cycles OSL - Changing rotation value in anisotropic shader crashes Blender
Older OSX has major issues with sincos() function, it's likely a big in OSL
or LLVM. For until we've updated to new versions of this libraries we'll use
a workaround to prevent possible crashes on all the platforms.

Shouldn't be that bad because it's mainly used for anisotropic shader where
angle is usually constant.

This fix is safe for inclusion into final Blender 2.75 release.
2015-06-14 13:14:11 +02:00
208a917b73 CMake: note env var 2015-06-14 10:05:03 +10:00
52997272aa CMake: disable OSL if cycles is disabled 2015-06-14 09:50:33 +10:00
1e9348efdc CMake: minor edits to lite config 2015-06-14 09:34:42 +10:00
424e5be046 Makefile support for using NPROCS as an env var 2015-06-14 08:27:29 +10:00
a2d4c26aa2 BMesh: use define for string 2015-06-14 08:27:29 +10:00
b1ed12bfec Compilation error fixes for older GCC/CLang compilers
Avoid data type re-declaration, it's not really working on current FreeBSD's 9
system and CLang-3.0 from OSX.

This is not a good idea to do such sort of copy-paste anyway.

If someone knows better way of dealing with this please go ahead and correct
the code :)
2015-06-13 22:19:50 +02:00
1c81bcffde addon_utils default mismatch /w enable/disable
default_set argument is now False for both.
2015-06-14 05:14:43 +10:00
75a86d6a8e Fix for building without Python 2015-06-14 04:53:10 +10:00
a1ac42f5eb Fix (d4e5df) blenderplayer compiling.
dfelinto is the second time that you forgot to modify bad_level_call_stubs/stubs.c. Please compile with the blenderplayer to see the error.
2015-06-13 20:23:48 +02:00
4835fe06f1 Fix T45062: Make it clear in tooltip that 'double sided' mesh option only affects
OpenGL (viewport), and not render engines.
2015-06-13 19:45:45 +02:00
Dalai Felinto
9326820a1b Multi-View: Show multiview image properties only in the places where
they are supported

aka, remove multiview properties from the texture panel, the textures
node (image), and any other parts.

The multiview options are now to be explicitly set in the image template
in order to have them available in the respective panel
2015-06-13 14:09:22 -03:00
Dalai Felinto
e944af67f7 Multi-View: Fix - stereo 3d background image in viewport not working
The functionality was there, but the UI was missing, since I introduced
the use_mutliview option in the Image datablocks.

Note: when opening the image via the background image UI it has its
views data mangled. I'll look at that. Meanwhile the fix is to toggle
Use Multi-View manually in the UI.
2015-06-13 14:09:22 -03:00
41d5ff6fe9 Cycles: Avoid compilation warnings when building without passes support 2015-06-13 19:07:48 +02:00
d3e16df4f1 Cycles: Solve possible buffer overrun when using too much closures
Glass BSDF was doing some magic with copying weigths from initial closure
onto refraction one and the code was not checking properly for the number
of closures.
2015-06-13 18:51:48 +02:00
1cbf748e0c Cycles: Add assert check to shader closure merge function 2015-06-13 18:17:16 +02:00
0f42b8aee0 Cycles: Fix compilation error with motion blur disabled on CPU 2015-06-13 18:16:32 +02:00
097aa852cf Cycles: Silent paranoid uninitialized GCC warnings in release kernels 2015-06-13 16:29:54 +02:00
Dalai Felinto
54b824106b Multi-View: Some Stereo 3D modes require a special drawing all the time
some 3d methods change the window arrangment, thus they shouldn't
toggle on/off just because there is no 3d elements being drawn

The optimized solution would be to draw only the left eye in those
cases, but there is some issue going on with that, so this commit will
do for now.
2015-06-13 11:29:05 -03:00
0bf0aa6625 Fix: Don't show "Clear Keyframes" option in RMB menu for NLA Strip properties
Since these FCurves for these properties cannot be deleted, this operator is useless
in this case.
2015-06-14 01:21:48 +12:00
0b51e7d991 Fix: "Delete Keyframes" RMB-menu option didn't work on NLA Strip properties 2015-06-14 01:21:47 +12:00
38a60418f7 Msgfmt: Fix for generating .mo files from .po without comments 2015-06-13 14:04:47 +02:00
60ddaf045a Python API: use cached translation tables
bpy.path.clean_name() and AddPresetBase.as_filename() were doing
inefficient search-replace of individual characters.

Use cached replacement table instead.
2015-06-13 19:47:32 +10:00
02a496c61c Translations utils: add needed bits to update git repo together with svn trunk. 2015-06-13 11:42:54 +02:00
7bac8348bf Fix scons compilation 2015-06-13 17:40:50 +12:00
Julian Eisel
7182677620 Cleanup: Correct comment
Own mistake from rBf9972fa53eaab4
2015-06-12 19:38:46 +02:00
1b8a785d83 Armature: add armature dissolve
Works like mesh dissolve (access from delete or Ctrl+X)
2015-06-13 03:24:07 +10:00
07562a4afb Edge slide (minor change, use existing vertex) 2015-06-13 03:24:07 +10:00
9e91313a97 CMake: remove comment 2015-06-13 03:23:58 +10:00
6f36e1f872 Fix compilation error on Windows
The issue was caused by conflicting declaration of HKEY
happening in our WM code and somewhere deeper in atomic
operations headers hierarchy.
2015-06-12 17:32:09 +05:00
efe4af8fcb Fix T45018 camera not easily selectable in multiview.
Generally for scene choosing a view to use for selection is not
straightforward, but camera should at least be easily selectable.
2015-06-12 17:21:07 +02:00
a9d3f663d3 UI: Use numselect for redo-popup (for move layers) 2015-06-13 00:39:19 +10:00
e2e414218b UI: Vertex Mark/Clear Sharp menu, match edge menu 2015-06-13 00:34:36 +10:00
0d95b41f9e Revert "UI: move sharp/smooth out of vertex menu"
This reverts commit d6b57436ef.
2015-06-13 00:34:36 +10:00
7823ca06da Support metadata display in clip editor 2015-06-12 15:26:23 +02:00
4fae3620d0 De-duplicate stamp callback 2015-06-12 15:29:56 +02:00
850bb80aef Fix for building without audiospace 2015-06-12 15:29:56 +02:00
69e96509a6 Fix for building without ffmpeg 2015-06-12 23:01:23 +10:00
f2bd6d73e6 Fix T45048: wrong tooltips in Video Sequence Editor's "Strip" Menu (mute/unmute). 2015-06-12 14:04:31 +02:00
6c44265bc9 Merge all changes to blenderplayer from gooseberry branch:
* Allows sound playback for movies
* Allow play-pause with space button
* Allow displaying a position indicator with the I button
2015-06-12 12:12:24 +02:00
34c3beb339 Cycles: Fix missing node distance update when only two child intersected in QBVH 2015-06-12 10:06:46 +02:00
520fb5c8cd Fix T45041: (2.75RC) blender crashes when I choose 'Refresh DataBlock Previews'.
Not sure where this sneaked in, but we for sure need a valid context (otherwise
we'd need to pass a Main alog too).

This is to be backported to final 2.75.
2015-06-12 09:55:04 +02:00
4ab47a7670 BLI_linklist, avoid full list search for append
For areas that require append, store the last node,
Previous behavior would too easily hide poorly performing code.

Also avoid (prepend, reverse) where possible.
2015-06-12 17:13:34 +10:00
5893a3445e Use prepend instead of append (avoids list search) 2015-06-12 17:08:10 +10:00
37b8153afe Cleanup: unused var 2015-06-12 17:08:10 +10:00
Julian Eisel
7ca40c1061 File Browser: Two more minor fixes for arrow keys selection
* Unset active file on opening/resetting file list
* Accidentally placed NULL check in the middle of the function - not a
big deal as it's highly unlikely that it fails (removed it but added
assert)
2015-06-12 06:25:43 +02:00
Julian Eisel
2205950274 File Browser: Ensure active file is unset if no file is selected
Otherwise arrow keys navigation might start from this file instead of
the last/first file in the list.
2015-06-12 04:46:49 +02:00
6a33d13ae7 Expose Background AO and Transparent flag to XML API 2015-06-12 00:32:00 +02:00
596eadf0e1 Cycles: Add debug pass which shows number of instance pushes during camera ray intersection
TODO: We might want to refactor debug passes into PASS_DEBUG and some
debug_type (similar to Blender's side passes) to avoid issue of running
out of bits.
2015-06-12 00:12:03 +02:00
b3cc602adc Cycles: Remove meaningless debug traversal steps increment from QBVH volume code 2015-06-11 23:54:57 +02:00
f6748183a2 Cycles: Enable transparent shadows for experimental AMD kernel
They're working just fine on AMD Tonga GPU and probably other architectures,
lets enable it under the experimental feature set and see what exact system
configuration gives issues.
2015-06-11 23:49:21 +02:00
7dae8e54cc Fix wrong proxy pointer hanging around after making all local
The issue was caused because of the following circumstances:

- Making All Local will just iterate all IDs and clear linked flags
- It will not do anything with objects which are already local (and
  since proxy rig is local nothing will be changing it).

This commit makes it so id_clear_lib_data() takes care of clearing
all related proxy pointers, avoiding situations when proxy rig will
point to a local armature.

Reviewers: campbellbarton

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D1276
2015-06-11 23:47:00 +02:00
774e034d40 Make scopes update multi-threaded
This commits makes scopes evaluation multithreaded by using OpenMP
for the outer loop of pixel processor. it also makes all the changes
needed for keeping performance as high as possible by keeping data
local to thread for as long as it's possible.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D1334
2015-06-11 23:37:49 +02:00
9c5995c062 Image scopes: Make sample line saving check local
Previously it was using accumulative counter of saved lines and so on in order
to detect cases when new sample is to be saved. This is not quite possible to
do with threaded scopes update.

Change it now with non-accumulative approach which saves a bit different lines
due to slightly different rounding, but this things are not strictly defined
anyway and results are close enough to each other.
2015-06-11 23:29:03 +02:00
b496819fcc Image scopes: Make all variables local, prepare to threaded evaluate
Doing this as a separate commit so it's easier to troubleshoot in the future
if some regression happens.
2015-06-11 23:29:03 +02:00
b666593775 Cycles: Remove Bump Node from the graph, if Height input is not connected.
This way we can avoid building the split kernel with NODE_FEATURE_BUMP enabled, in case we don't need it.
2015-06-11 23:09:38 +02:00
96d9801423 Masking: Numpad-. now centers view to selected control points
Currently feather points are being ignored, it could be improved in the future.
2015-06-11 22:46:42 +02:00
b4446b505f Cleanup some style in new 'keyboard select' code.
Really hate onliner checks (if/else)...
2015-06-11 20:03:55 +02:00
5114637967 Fix T45016, mask animation data lost after layer rename
We need to fix up animation data.
2015-06-11 19:34:21 +02:00
8c2619a11a Fix T45032 allow float rotational values for numpad rotation 2015-06-11 18:13:22 +02:00
Julian Eisel
939948c233 File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the
arrow keys. All directions (up, down, left, right) are possible.

When to Select, When to Deselect?
Standard behaviour is selecting, however if we move into a block of
already selected files (meaning 2+ files are selected) we start
deselecting

Possible Selection Methods
Simple selection (arrow-key): All other files are deselected
Expand selection (Shift+arrow key): Add to/remove from existing
selection
ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing
selection and fill everything in-between

From which file do we start navigating?
From each available selection method (Mouse-, Walk-, All-, Border
Select), we use the last selected file. If there's no selection at all
we use the first (down/right arrow) or last (up/left arrow) file.
(Ideally, the view would automatically be set to the new selection, but
this behaviour overlaps with an other patch I've been working on, so
prefer to do that separately)

(Also tweaks color for highlighted file for better feedback)

D1297, Review done by @campbellbarton, thx a lot :)
2015-06-11 17:20:29 +02:00
356afe0085 Fix possible NULL pointer use 2015-06-11 23:58:53 +10:00
6a0a205cb4 Cycles: Simplify volume_phase_eval().
This simplification is safe, as the call to volume_phase_eval() is guarded behind a CLOSURE_IS_PHASE check, which is equal to
CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID. I don't think we will add more phase functions anytime soon, if at all.
2015-06-11 15:18:33 +02:00
af4d10703b Release cycle: Blender 2.76 BCon 1, alpha 2015-06-11 15:11:07 +02:00
102e18d05c Expose debug type into the interface
This way it is now possible to select which exact debug pass is to be used
by the render engine. Accessible from the Passes panel.

Currently it could only be one debug pass, in the future we can make menus
and image users smarter and support multiple passes of the same type.
2015-06-11 14:53:15 +02:00
2bd6de5bbb Cycles: Add debug pass showing average number of ray bounces per pixel
Quite straightforward implementation, but still needs some work for the split
kernel. Includes both regular and split kernel implementation for that.

The pass is not exposed to the interface yet because it's currently not really
easy to have same pass listed in the menu multiple times.
2015-06-11 14:53:15 +02:00
3438130a94 Use more proper flag for psys reconstruction after memory optimization 2015-06-11 14:53:15 +02:00
abc9c26ec8 Fix for unwanted particle re-distribution happening due to memory optimization
The issue was caused by memory optimization marking particle system to recalc,
and because of the way how particle flags works it was possible that it'll
cause particle's re-distribution. Now this memory optimization will act the
same as loading the file.

This commit appears to be safe according to our render farm and is safe to
be included into final release.
2015-06-11 14:53:15 +02:00
a6803bf564 Compositor: Use atomics to update finished tiles progress
Integer is not safe for incremental by multiple threads and if one is unlucky
enough that could cause progress re[reports to go totally nuts.
2015-06-11 14:53:15 +02:00
bb5e46f105 Fix T44871: Blender hangs when using masking, dilate-erode and soften node
The issue was caused by wrong order of locks acquisition in the compositor image node.
2015-06-11 14:53:15 +02:00
41564a402e BMesh: flatten faces operator 2015-06-11 21:54:06 +10:00
ee37de75e6 BMesh: add BMO_ITER_INDEX macro 2015-06-11 21:54:06 +10:00
867cd2048e Replace linked-list insert-sort with merge-sort
Original code from eglib, modified for reuse with multiple linked-list implementations.

Adds sort functions: BLI_linklist_sort, BLI_linklist_sort_r
2015-06-11 21:54:06 +10:00
b8b57d2da9 BLI_listbase: match arg order with BLI_qsort_r 2015-06-11 21:54:06 +10:00
958c20872a Add argument --python-expr to pass Python directly
This works like Python's -c argument, handy to be able to avoid writing small scripts to disk.
2015-06-11 21:54:06 +10:00
Dalai Felinto
087c82e392 Error message fix - In the manual (thus for the user) we are referring to this as "Multi-View", not "Multiview" 2015-06-10 16:23:19 -03:00
f167f434d9 Support alternate python command 2015-06-11 04:14:43 +10:00
8e0ab3d42f Picky edits to previous commit. 2015-06-10 17:29:46 +02:00
825892ae7a Fix T45017: Crash when running 'track markers' operator with no clip loaded.
CLIP_OT_track_markers was missing a poll callback.
2015-06-10 17:24:08 +02:00
3560e36ee9 CMake: Fix typo in OIIO module 2015-06-10 16:51:52 +02:00
ec3c2d3be9 Fix T45009: Bad 'tri area computation' code in knife tool.
Was causing wrong selection of 'outside' face.
2015-06-10 16:35:52 +02:00
91e767c99c 2.75 splash
by Gooseberry team
2015-06-11 00:01:13 +10:00
ab417f31f4 Fix/Workaround T44662: Freestyle gives no visual output when the Save Buffers option is enabled
For now we solve this for non-multiview renders by merging exr file back into
full render result prior to rendering freestyle strokes. Multiview case is
still to be supported tho.
2015-06-10 13:41:37 +02:00
73a104b8e8 Fix T44968: Python executable crashes due to missing .DLL
For now we work this around by copying python DLL to the
bin folder. Ideally the DLL should be shared between blender
and python, but that's a bit tricky to do on windows.
2015-06-10 13:41:06 +05:00
9f911f62dc Fix T45013 negative curve falloff not working.
Was doing clamping as fix for T42984. Seems we can ommit clamping for
sculpting if we make sure overlap is not zero with negative values.

Control for clamping is moved to the "Use Clipping" function of curves
(which is on by default), so both bugs remain squashed and advanced
users can now properly utilize curves in sculpting, though not all
brushes work well with negative curves.
2015-06-10 13:32:28 +02:00
6e844da9da GTest: add test for listbase sorting
Check for correct sort and stable order for matching values.
2015-06-10 20:26:56 +10:00
0446c73c4a WM: toggling expanded could raise exception
Missing module case wasn't checked for.
2015-06-10 19:33:38 +10:00
bc69eafa98 UI: option to pass "icon_value" to menus
D1336 by @lichtwerk

Also remove verbose description, UI docs can explain use-case in more detail.
2015-06-10 17:39:18 +10:00
08687ee380 Correct typos
D1337 by @lichtwerk
2015-06-10 17:28:43 +10:00
45d4fadebd Tooltip cleanup: show_metadata should be same between image editor/ 2015-06-09 18:25:25 +02:00
7b0c327b94 Disable key accelerators for splash screen 2015-06-09 23:34:24 +10:00
9a83e112be Fix T45002: sculpt show brush toggle no longer working. 2015-06-09 15:13:52 +02:00
3092e1031d Fix T45003: some UI/i18n issues.
* Do not translate renderlayers' names, those are data, not UI (defined by user).
* Translate passes' names, even in button itself (menu items were already translated).
* Translate 'ID type' in ID eyedropper helper message.

Also, added i18n context to IDType private struct, and `BKE_idcode_to_translation_context()`
helper, much more generic and easy to maintain than the private util in interface_template.c.
2015-06-09 15:00:56 +02:00
af980a20a4 Fix T37746: Presets in splash failed to redraw 2015-06-09 21:55:35 +10:00
6c8f2049f6 Fix wrong name displayed for the debug passes 2015-06-09 10:53:54 +02:00
cb9bd23d0c Fix T44930: File-select in redo panel, disables UI 2015-06-09 17:17:22 +10:00
Dalai Felinto
e1b8ed8dd4 Multiview: fix Time Sequential crash when screen is fullscreen T44688
ED_screen_duplicate() was never written to support non-fullscreen modes.
This is prior to the hidden ui fullscreen commit, and it's quite ancient
in Blender's code (since Jan/08 - 1363134d)

That's why duplicate window, and new screen operators are disabled when
screen is full.
2015-06-08 18:48:52 -03:00
962f764d58 WM: refactor window code for stereo3d
Window copy code made it hard to test fixes.
2015-06-09 01:27:40 +10:00
f8385de5ed Remove redundant NULL check 2015-06-09 01:27:40 +10:00
Julian Eisel
ffdeba49e6 Fix yet another fullscreen glitch
Steps to reproduce were: Toggle fullscreen->F12->F3->ESC 2x->3D View
changed to Image Editor and didn't change back.

Actually it doesn't work 100% as wanted since it exits the fullscreen
when pressing ESC to exit Image Editor but it's hard to support all
cases with such a weird spaghetti code.
2015-06-08 17:20:21 +02:00
Julian Eisel
4f94947157 Fix T44976: 3D View turns into an Image Editor after saving render
result

Was a case of two stacked temporary fullscreens, so a quite extreme
situation.
2015-06-08 16:04:00 +02:00
1248 changed files with 55336 additions and 26279 deletions

View File

@@ -53,7 +53,9 @@ if(NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
endif()
if(NOT EXECUTABLE_OUTPUT_PATH)
set(FIRST_RUN "TRUE")
set(FIRST_RUN TRUE)
else()
set(FIRST_RUN FALSE)
endif()
# this starts out unset
@@ -71,7 +73,6 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE NDEBU
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL NDEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO NDEBUG)
#-----------------------------------------------------------------------------
# Set policy
@@ -129,7 +130,7 @@ macro(option_defaults_init)
set(${_var} ON)
list(APPEND _init_vars "${_var}")
endforeach()
unset(_INC)
unset(_var)
endmacro()
# remove from namespace
@@ -157,25 +158,30 @@ option_defaults_init(
_init_SDL
_init_FFTW3
_init_GAMEENGINE
_init_OPENSUBDIV
)
# customize...
if(UNIX AND NOT APPLE)
if (UNIX AND NOT APPLE)
# some of these libraries are problematic on Linux
# disable less important dependencies by default
set(_init_BUILDINFO OFF)
set(_init_CODEC_FFMPEG OFF)
set(_init_CYCLES_OSL OFF)
set(_init_IMAGE_OPENEXR OFF)
set(_init_IMAGE_REDCODE OFF)
set(_init_INPUT_NDOF OFF)
set(_init_JACK OFF)
set(_init_LIBMV_SCHUR_SPECIALIZATION OFF)
set(_init_OPENCOLLADA OFF)
set(_init_OPENCOLORIO OFF)
set(_init_SDL OFF)
set(_init_FFTW3 OFF)
set(_init_GAMEENGINE OFF)
set(_init_OPENSUBDIV OFF)
elseif(WIN32)
set(_init_JACK OFF)
elseif(APPLE)
set(_init_INPUT_NDOF OFF)
set(_init_JACK OFF)
set(_init_OPENSUBDIV OFF)
endif()
@@ -220,7 +226,15 @@ mark_as_advanced(WITH_SYSTEM_BULLET)
option(WITH_GAMEENGINE "Enable Game Engine" ${_init_GAMEENGINE})
option(WITH_PLAYER "Build Player" OFF)
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
# Compositor
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
option(WITH_COMPOSITOR_WERROR "Treat warnings as errors in compositor code" OFF)
mark_as_advanced(WITH_COMPOSITOR_WERROR)
option(WITH_OPENSUBDIV "Enable OpenSubdiv for surface subdivision" _init_OPENSUBDIV)
option(WITH_SUBSURF_WERROR "Treat warnings as errors in subsurf code" OFF)
mark_as_advanced(WITH_COMPOSITOR_WERROR)
# GHOST Windowing Library Options
option(WITH_GHOST_DEBUG "Enable debugging output for the GHOST library" OFF)
@@ -238,7 +252,13 @@ option(WITH_HEADLESS "Build without graphical support (renderfarm, server m
mark_as_advanced(WITH_HEADLESS)
option(WITH_AUDASPACE "Build with blenders audio library (only disable if you know what you're doing!)" ON)
option(WITH_SYSTEM_AUDASPACE "Build with external audaspace library installed on the system (only enable if you know what you're doing!)" OFF)
mark_as_advanced(WITH_AUDASPACE)
mark_as_advanced(WITH_SYSTEM_AUDASPACE)
if(NOT WITH_AUDASPACE)
set(WITH_SYSTEM_AUDASPACE OFF)
endif()
option(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" ON)
@@ -317,9 +337,11 @@ if(UNIX AND NOT APPLE)
endif()
# Camera/motion tracking
option(WITH_LIBMV "Enable libmv structure from motion library" ON)
option(WITH_LIBMV "Enable Libmv structure from motion library" ON)
option(WITH_LIBMV_SCHUR_SPECIALIZATIONS "Enable fixed-size schur specializations." ${_init_LIBMV_SCHUR_SPECIALIZATION})
option(WITH_LIBMV_WERROR "Treat warnings as errors in Libmv (and Blender's motion tracking) code")
mark_as_advanced(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
mark_as_advanced(WITH_LIBMV_WERROR)
# Freestyle
option(WITH_FREESTYLE "Enable Freestyle (advanced edges rendering)" ON)
@@ -353,18 +375,20 @@ if(UNIX AND NOT APPLE)
endif()
# Cycles
option(WITH_CYCLES "Enable cycles Render Engine" ON)
option(WITH_CYCLES_STANDALONE "Build cycles standalone application" OFF)
option(WITH_CYCLES_STANDALONE_GUI "Build cycles standalone with GUI" OFF)
option(WITH_CYCLES "Enable Cycles Render Engine" ON)
option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
option(WITH_CYCLES_OSL "Build Cycles with OSL support" ${_init_CYCLES_OSL})
option(WITH_CYCLES_CUDA_BINARIES "Build cycles CUDA binaries" OFF)
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF)
set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 sm_50 sm_52 CACHE STRING "CUDA architectures to build binaries for")
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
unset(PLATFORM_DEFAULT)
option(WITH_CYCLES_LOGGING "Build cycles with logging support" ON)
option(WITH_CYCLES_DEBUG "Build cycles with extra debug capabilities" OFF)
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
option(WITH_CYCLES_DEBUG "Build Cycles with extra debug capabilities" OFF)
option(WITH_CYCLES_WERROR "Treat warnings as errors in Cycles code" OFF)
mark_as_advanced(WITH_CYCLES_LOGGING)
mark_as_advanced(WITH_CYCLES_DEBUG)
mark_as_advanced(WITH_CYCLES_WERROR)
# LLVM
option(WITH_LLVM "Use LLVM" OFF)
@@ -394,7 +418,6 @@ option(WITH_BOOST "Enable features depending on boost" ON)
# Unit testsing
option(WITH_GTESTS "Enable GTest unit testing" OFF)
option(WITH_TESTS_PERFORMANCE "Enable performance tests" OFF)
# Documentation
@@ -411,7 +434,6 @@ option(WITH_GL_EGL "Use the EGL OpenGL system library instead of th
option(WITH_GL_PROFILE_COMPAT "Support using the OpenGL 'compatibility' profile. (deprecated)" ON )
option(WITH_GL_PROFILE_CORE "Support using the OpenGL 3.2+ 'core' profile." OFF)
option(WITH_GL_PROFILE_ES20 "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)" OFF)
option(WITH_GPU_DEBUG "Create a debug OpenGL context (allows inserting custom messages and getting notifications for bad GL use)" OFF)
mark_as_advanced(
WITH_GLEW_MX
@@ -420,7 +442,6 @@ mark_as_advanced(
WITH_GL_PROFILE_COMPAT
WITH_GL_PROFILE_CORE
WITH_GL_PROFILE_ES20
WITH_GPU_DEBUG
)
if(WITH_GL_PROFILE_COMPAT)
@@ -450,6 +471,7 @@ mark_as_advanced(WITH_CPP11)
# Dependency graph
option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
mark_as_advanced(WITH_LEGACY_DEPSGRAPH)
# avoid using again
option_defaults_clear()
@@ -654,6 +676,13 @@ endif()
# auto enable openimageio for cycles
if(WITH_CYCLES)
set(WITH_OPENIMAGEIO ON)
# auto enable llvm for cycles_osl
if(WITH_CYCLES_OSL)
set(WITH_LLVM ON CACHE BOOL "" FORCE)
endif()
else()
set(WITH_CYCLES_OSL OFF)
endif()
# auto enable openimageio linking dependencies
@@ -662,11 +691,6 @@ if(WITH_OPENIMAGEIO)
set(WITH_IMAGE_TIFF ON)
endif()
# auto enable llvm for cycles_osl
if(WITH_CYCLES_OSL)
set(WITH_LLVM ON CACHE BOOL "" FORCE)
endif()
# don't store paths to libs for portable distribution
if(WITH_INSTALL_PORTABLE)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
@@ -693,6 +717,34 @@ if(HAVE_STDBOOL_H)
add_definitions(-DHAVE_STDBOOL_H)
endif()
if(WITH_AUDASPACE)
if(WITH_SYSTEM_AUDASPACE)
set(AUDASPACE_DEFINITIONS
-DWITH_AUDASPACE
-DWITH_SYSTEM_AUDASPACE
"-DAUD_DEVICE_H=<AUD_Device.h>"
"-DAUD_SPECIAL_H=<AUD_Special.h>"
"-DAUD_SOUND_H=<AUD_Sound.h>"
"-DAUD_HANDLE_H=<AUD_Handle.h>"
"-DAUD_SEQUENCE_H=<AUD_Sequence.h>"
"-DAUD_TYPES_H=<AUD_Types.h>"
"-DAUD_PYTHON_H=<python/PyAPI.h>"
)
else()
set(AUDASPACE_C_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
set(AUDASPACE_PY_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
set(AUDASPACE_DEFINITIONS
-DWITH_AUDASPACE
"-DAUD_DEVICE_H=<AUD_C-API.h>"
"-DAUD_SPECIAL_H=<AUD_C-API.h>"
"-DAUD_SOUND_H=<AUD_C-API.h>"
"-DAUD_HANDLE_H=<AUD_C-API.h>"
"-DAUD_SEQUENCE_H=<AUD_C-API.h>"
"-DAUD_TYPES_H=<AUD_Space.h>"
)
endif()
endif()
#-----------------------------------------------------------------------------
# Check for valid directories
# ... a partial checkout may cause this.
@@ -794,6 +846,14 @@ if(WITH_X11)
endif()
# ----------------------------------------------------------------------------
# Main Platform Checks
#
# - UNIX
# - WIN32
# - APPLE
if(UNIX AND NOT APPLE)
macro(find_package_wrapper)
if(WITH_STATIC_LIBS)
@@ -862,6 +922,13 @@ if(UNIX AND NOT APPLE)
endif()
# Audio IO
if(WITH_SYSTEM_AUDASPACE)
find_package_wrapper(Audaspace)
if(NOT AUDASPACE_FOUND OR NOT AUDASPACE_C_FOUND)
message(FATAL_ERROR "Audaspace external library not found!")
endif()
endif()
if(WITH_OPENAL)
find_package_wrapper(OpenAL)
if(NOT OPENAL_FOUND)
@@ -1062,9 +1129,9 @@ if(UNIX AND NOT APPLE)
endif()
if(WITH_LLVM)
find_package_wrapper(LLVM)
find_package_wrapper(LLVM)
if(NOT LLVM_FOUND)
if(NOT LLVM_FOUND)
set(WITH_LLVM OFF)
message(STATUS "LLVM not found")
endif()
@@ -1075,6 +1142,18 @@ if(UNIX AND NOT APPLE)
set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--version-script='${CMAKE_SOURCE_DIR}/source/creator/blender.map'")
endif()
if(WITH_OPENSUBDIV)
find_package_wrapper(OpenSubdiv)
set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARIES})
set(OPENSUBDIV_LIBPATH) # TODO, remove and reference the absolute path everywhere
if(NOT OPENSUBDIV_FOUND)
set(WITH_OPENSUBDIV OFF)
message(STATUS "OpenSubdiv not found")
endif()
endif()
# OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm)
@@ -1112,12 +1191,12 @@ if(UNIX AND NOT APPLE)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if ("${LD_VERSION}" MATCHES "GNU gold")
if("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
else ()
message(INFO "GNU gold linker isn't available, using the default system linker.")
endif ()
else()
message(STATUS "GNU gold linker isn't available, using the default system linker.")
endif()
unset(LD_VERSION)
# CLang is the same as GCC for now.
@@ -1495,6 +1574,13 @@ elseif(WIN32)
)
endif()
if(WITH_OPENSUBDIV)
set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include)
set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBPATH}/osdCPU.lib ${OPENSUBDIV_LIBPATH}/osdGPU.lib)
find_package(OpenSubdiv)
endif()
if(WITH_SDL)
set(SDL ${LIBDIR}/sdl)
set(SDL_INCLUDE_DIR ${SDL}/include)
@@ -1502,6 +1588,16 @@ elseif(WIN32)
set(SDL_LIBPATH ${SDL}/lib)
endif()
# Audio IO
if(WITH_SYSTEM_AUDASPACE)
set(AUDASPACE_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
set(AUDASPACE_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace.lib)
set(AUDASPACE_C_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
set(AUDASPACE_C_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-c.lib)
set(AUDASPACE_PY_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
set(AUDASPACE_PY_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-py.lib)
endif()
# used in many places so include globally, like OpenGL
blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}")
@@ -1821,6 +1917,17 @@ elseif(APPLE)
endif()
endif()
if(WITH_OPENSUBDIV)
set(OPENSUBDIV ${LIBDIR}/opensubdiv)
set(OPENSUBDIV_LIBPATH ${OPENSUBDIV}/lib)
find_library(OSL_LIB_UTIL NAMES osdutil PATHS ${OPENSUBDIV_LIBPATH})
find_library(OSL_LIB_CPU NAMES osdCPU PATHS ${OPENSUBDIV_LIBPATH})
find_library(OSL_LIB_GPU NAMES osdGPU PATHS ${OPENSUBDIV_LIBPATH})
set(OPENSUBDIV_INCLUDE_DIR ${OPENSUBDIV}/include)
set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR})
list(APPEND OPENSUBDIV_LIBRARIES ${OSL_LIB_UTIL} ${OSL_LIB_CPU} ${OSL_LIB_GPU})
endif()
if(WITH_JACK)
find_library(JACK_FRAMEWORK
NAMES jackmp
@@ -2348,10 +2455,6 @@ if(WITH_GL_EGL)
list(APPEND GL_DEFINITIONS -DWITH_EGL)
endif()
if(WITH_GPU_DEBUG)
list(APPEND GL_DEFINITIONS -DWITH_GPU_DEBUG)
endif()
#-----------------------------------------------------------------------------
# Configure OpenMP.
if(WITH_OPENMP)
@@ -2758,25 +2861,29 @@ include(build_files/cmake/packaging.cmake)
# Print Final Configuration
if(FIRST_RUN)
set(_config_msg "\n* Blender Configuration *")
macro(info_cfg_option
_setting)
set(_msg " * ${_setting}")
set(_config_msg "\nBlender Configuration\n=====================")
function(info_cfg_option
_setting
)
set(_msg " - ${_setting}")
string(LENGTH "${_msg}" _len)
while("32" GREATER "${_len}")
set(_msg "${_msg} ")
math(EXPR _len "${_len} + 1")
endwhile()
set(_config_msg "${_config_msg}\n${_msg}${${_setting}}")
endmacro()
set(_config_msg "${_config_msg}\n${_msg}${${_setting}}" PARENT_SCOPE)
endfunction()
macro(info_cfg_text
_text)
set(_config_msg "${_config_msg}\n\n ${_text}")
function(info_cfg_text
_text
)
endmacro()
set(_config_msg "${_config_msg}\n\n ${_text}" PARENT_SCOPE)
endfunction()
message(STATUS "C Compiler: \"${CMAKE_C_COMPILER_ID}\"")
message(STATUS "C++ Compiler: \"${CMAKE_CXX_COMPILER_ID}\"")
@@ -2855,7 +2962,6 @@ if(FIRST_RUN)
info_cfg_option(WITH_GL_PROFILE_COMPAT)
info_cfg_option(WITH_GL_PROFILE_CORE)
info_cfg_option(WITH_GL_PROFILE_ES20)
info_cfg_option(WITH_GPU_DEBUG)
if(WIN32)
info_cfg_option(WITH_GL_ANGLE)
endif()

View File

@@ -43,6 +43,11 @@ ifndef BUILD_DIR
BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE)
endif
# Allow to use alternative binary (pypy3, etc)
ifndef PYTHON
PYTHON:=python3
endif
# -----------------------------------------------------------------------------
# additional targets for the build configuration
@@ -76,18 +81,20 @@ endif
# -----------------------------------------------------------------------------
# Get the number of cores for threaded build
NPROCS:=1
ifeq ($(OS), Linux)
NPROCS:=$(shell nproc)
endif
ifeq ($(OS), Darwin)
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f3)
endif
ifeq ($(OS), FreeBSD)
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
endif
ifeq ($(OS), NetBSD)
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
ifndef NPROCS
NPROCS:=1
ifeq ($(OS), Linux)
NPROCS:=$(shell nproc)
endif
ifeq ($(OS), Darwin)
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f3)
endif
ifeq ($(OS), FreeBSD)
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
endif
ifeq ($(OS), NetBSD)
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
endif
endif
@@ -117,12 +124,12 @@ all: FORCE
@echo
@echo Configuring Blender ...
# if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
# $(CMAKE_CONFIG); \
# fi
# # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
# # $(CMAKE_CONFIG); \
# # fi
# do this always incase of failed initial build, could be smarter here...
$(CMAKE_CONFIG)
# # do this always incase of failed initial build, could be smarter here...
@$(CMAKE_CONFIG)
@echo
@echo Building Blender ...
@@ -201,6 +208,12 @@ help: FORCE
@echo " * tgz - create a compressed archive of the source code."
@echo " * update - updates git and all submodules"
@echo ""
@echo "Environment Variables"
@echo " * BUILD_CMAKE_ARGS - arguments passed to CMake."
@echo " * BUILD_DIR - override default build path."
@echo " * PYTHON - use this for the Python command (used for checking tools)."
@echo " * NPROCS - number of processes to use building (auto-detect when omitted)."
@echo ""
@echo "Documentation Targets (not associated with building blender)"
@echo " * doc_py - generate sphinx python api docs"
@echo " * doc_doxy - generate doxygen C/C++ docs"
@@ -210,6 +223,7 @@ help: FORCE
@echo "Information"
@echo " * help - this help message"
@echo " * help_features - show a list of optional features when building"
@echo ""
# -----------------------------------------------------------------------------
# Packages
@@ -233,21 +247,21 @@ test: FORCE
# run pep8 check check on scripts we distribute.
test_pep8: FORCE
python3 tests/python/pep8.py > test_pep8.log 2>&1
$(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
@echo "written: test_pep8.log"
# run some checks on our cmakefiles.
test_cmake: FORCE
python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
$(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
@echo "written: test_cmake_consistency.log"
# run deprecation tests, see if we have anything to remove.
test_deprecated: FORCE
python3 tests/check_deprecated.py
$(PYTHON) tests/check_deprecated.py
test_style_c: FORCE
# run our own checks on C/C++ style
PYTHONIOENCODING=utf_8 python3 \
PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
"$(BLENDER_DIR)/source/blender" \
"$(BLENDER_DIR)/source/creator" \
@@ -256,7 +270,7 @@ test_style_c: FORCE
test_style_c_qtc: FORCE
# run our own checks on C/C++ style
USE_QTC_TASK=1 \
PYTHONIOENCODING=utf_8 python3 \
PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
"$(BLENDER_DIR)/source/blender" \
"$(BLENDER_DIR)/source/creator" \
@@ -268,7 +282,7 @@ test_style_c_qtc: FORCE
test_style_osl: FORCE
# run our own checks on C/C++ style
PYTHONIOENCODING=utf_8 python3 \
PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
"$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
"$(BLENDER_DIR)/release/scripts/templates_osl"
@@ -277,7 +291,7 @@ test_style_osl: FORCE
test_style_osl_qtc: FORCE
# run our own checks on C/C++ style
USE_QTC_TASK=1 \
PYTHONIOENCODING=utf_8 python3 \
PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
"$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
"$(BLENDER_DIR)/release/scripts/templates_osl" \
@@ -290,10 +304,10 @@ test_style_osl_qtc: FORCE
#
project_qtcreator: FORCE
python3 build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
$(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
project_netbeans: FORCE
python3 build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
$(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
project_eclipse: FORCE
cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
@@ -306,39 +320,39 @@ project_eclipse: FORCE
check_cppcheck: FORCE
$(CMAKE_CONFIG)
cd "$(BUILD_DIR)" ; \
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
"$(BLENDER_DIR)/check_cppcheck.txt"
@echo "written: check_cppcheck.txt"
check_clang_array: FORCE
$(CMAKE_CONFIG)
cd "$(BUILD_DIR)" ; \
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
check_splint: FORCE
$(CMAKE_CONFIG)
cd "$(BUILD_DIR)" ; \
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
check_sparse: FORCE
$(CMAKE_CONFIG)
cd "$(BUILD_DIR)" ; \
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
check_smatch: FORCE
$(CMAKE_CONFIG)
cd "$(BUILD_DIR)" ; \
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
check_spelling_py: FORCE
cd "$(BUILD_DIR)" ; \
PYTHONIOENCODING=utf_8 python3 \
PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
"$(BLENDER_DIR)/release/scripts"
check_spelling_c: FORCE
cd "$(BUILD_DIR)" ; \
PYTHONIOENCODING=utf_8 python3 \
PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
"$(BLENDER_DIR)/source" \
"$(BLENDER_DIR)/intern/cycles" \
@@ -347,7 +361,7 @@ check_spelling_c: FORCE
check_spelling_c_qtc: FORCE
cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
PYTHONIOENCODING=utf_8 python3 \
PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
"$(BLENDER_DIR)/source" \
"$(BLENDER_DIR)/intern/cycles" \
@@ -358,7 +372,7 @@ check_spelling_c_qtc: FORCE
check_spelling_osl: FORCE
cd "$(BUILD_DIR)" ;\
PYTHONIOENCODING=utf_8 python3 \
PYTHONIOENCODING=utf_8 $(PYTHON) \
"$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
"$(BLENDER_DIR)/intern/cycles/kernel/shaders"
@@ -404,10 +418,10 @@ doc_dna: FORCE
@echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
doc_man: FORCE
python3 doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
$(PYTHON) doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
help_features: FORCE
@python3 -c \
@$(PYTHON) -c \
"import re; \
print('\n'.join([ \
w for l in open('"$(BLENDER_DIR)"/CMakeLists.txt', 'r').readlines() \

View File

@@ -514,6 +514,10 @@ if env['WITH_BF_STATICCXX']:
else:
print '\tcould not remove stdc++ library from LLIBS, WITH_BF_STATICCXX may not work for your platform'
# audaspace is needed for the game engine
if not env['WITH_BF_AUDASPACE']:
env['WITH_BF_GAMEENGINE'] = False
# check target for blenderplayer. Set WITH_BF_PLAYER if found on cmdline
if 'blenderplayer' in B.targets:
env['WITH_BF_PLAYER'] = True
@@ -540,13 +544,25 @@ else:
env['CPPFLAGS'].append('-D__LITTLE_ENDIAN__')
# TODO, make optional (as with CMake)
env['CPPFLAGS'].append('-DWITH_AUDASPACE')
env['CPPFLAGS'].append('-DWITH_AVI')
env['CPPFLAGS'].append('-DWITH_OPENNL')
if env['OURPLATFORM'] not in ('win32-vc', 'win64-vc'):
env['CPPFLAGS'].append('-DHAVE_STDBOOL_H')
# Audaspace
if env['WITH_BF_AUDASPACE']:
env['BF_AUDASPACE_C_INC'] = '#intern/audaspace/intern'
env['BF_AUDASPACE_PY_INC'] = '#intern/audaspace/intern'
env['BF_AUDASPACE_DEF'] = ['WITH_AUDASPACE']
env['BF_AUDASPACE_DEF'].append('AUD_DEVICE_H="<AUD_C-API.h>"')
env['BF_AUDASPACE_DEF'].append('AUD_SPECIAL_H="<AUD_C-API.h>"')
env['BF_AUDASPACE_DEF'].append('AUD_SOUND_H="<AUD_C-API.h>"')
env['BF_AUDASPACE_DEF'].append('AUD_HANDLE_H="<AUD_C-API.h>"')
env['BF_AUDASPACE_DEF'].append('AUD_SEQUENCE_H="<AUD_C-API.h>"')
env['BF_AUDASPACE_DEF'].append('AUD_TYPES_H="<AUD_Space.h>"')
# OpenGL
if env['WITH_BF_GL_PROFILE_COMPAT']:
@@ -766,6 +782,8 @@ if B.targets != ['cudakernels']:
data_to_c_simple("release/datafiles/preview_cycles.blend")
# --- glsl ---
data_to_c_simple("source/blender/gpu/shaders/gpu_shader_geometry.glsl")
data_to_c_simple("source/blender/gpu/shaders/gpu_program_smoke_frag.glsl")
data_to_c_simple("source/blender/gpu/shaders/gpu_program_smoke_color_frag.glsl")
@@ -789,6 +807,7 @@ if B.targets != ['cudakernels']:
data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_depth_resolve.glsl")
data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_vert.glsl")
data_to_c_simple("intern/opencolorio/gpu_shader_display_transform.glsl")
data_to_c_simple("intern/opensubdiv/gpu_shader_opensubd_display.glsl")
# --- blender ---
data_to_c_simple("release/datafiles/bfont.pfb")
@@ -1300,6 +1319,15 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
allinstall += windlls
# TODO(sergey): For unti we've got better way to deal with python binary
if env['WITH_BF_PYTHON']:
py_target = os.path.join(env['BF_INSTALLDIR'], VERSION, 'python', 'bin')
if env['BF_DEBUG']:
allinstall += env.Install(dir=py_target, source = ['${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll'])
else:
allinstall += env.Install(dir=py_target, source = ['${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll'])
if env['OURPLATFORM'] == 'win64-mingw':
dllsources = []

View File

@@ -27,9 +27,10 @@ getopt \
-o s:i:t:h \
--long source:,install:,tmp:,info:,threads:,help,no-sudo,with-all,with-opencollada,\
ver-ocio:,ver-oiio:,ver-llvm:,ver-osl:,\
force-all,force-python,force-numpy,force-boost,force-ocio,force-oiio,force-llvm,force-osl,force-opencollada,\
force-ffmpeg,\
skip-python,skip-numpy,skip-boost,skip-ocio,skip-openexr,skip-oiio,skip-llvm,skip-osl,skip-ffmpeg,skip-opencollada,\
force-all,force-python,force-numpy,force-boost,force-ocio,force-oiio,force-llvm,force-osl,force-osd,\
force-ffmpeg,force-opencollada,\
skip-python,skip-numpy,skip-boost,skip-ocio,skip-openexr,skip-oiio,skip-llvm,skip-osl,skip-osd,\
skip-ffmpeg,skip-opencollada,\
required-numpy: \
-- "$@" \
)
@@ -138,6 +139,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--force-osl
Force the rebuild of OpenShadingLanguage.
--force-osd
Force the rebuild of OpenSubdiv.
--force-opencollada
Force the rebuild of OpenCOLLADA.
@@ -174,6 +178,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
--skip-osl
Unconditionally skip OpenShadingLanguage installation/building.
--skip-osd
Unconditionally skip OpenSubdiv installation/building.
--skip-opencollada
Unconditionally skip OpenCOLLADA installation/building.
@@ -233,6 +240,12 @@ OSL_VERSION_MIN=$OSL_VERSION
OSL_FORCE_REBUILD=false
OSL_SKIP=false
# OpenSubdiv needs to be compiled for now
OSD_VERSION="3.0.2"
OSD_VERSION_MIN=$OSD_VERSION
OSD_FORCE_REBUILD=false
OSD_SKIP=false
# Version??
OPENCOLLADA_VERSION="1.3"
OPENCOLLADA_FORCE_REBUILD=false
@@ -375,6 +388,11 @@ while true; do
OSL_VERSION_MIN=$OSL_VERSION
shift; shift; continue
;;
--ver-osd)
OSD_VERSION="$2"
OSD_VERSION_MIN=$OSD_VERSION
shift; shift; continue
;;
--force-all)
PYTHON_FORCE_REBUILD=true
NUMPY_FORCE_REBUILD=true
@@ -384,6 +402,7 @@ while true; do
OIIO_FORCE_REBUILD=true
LLVM_FORCE_REBUILD=true
OSL_FORCE_REBUILD=true
OSD_FORCE_REBUILD=true
OPENCOLLADA_FORCE_REBUILD=true
FFMPEG_FORCE_REBUILD=true
shift; continue
@@ -417,6 +436,9 @@ while true; do
--force-osl)
OSL_FORCE_REBUILD=true; shift; continue
;;
--force-osd)
OSD_FORCE_REBUILD=true; shift; continue
;;
--force-opencollada)
OPENCOLLADA_FORCE_REBUILD=true; shift; continue
;;
@@ -447,6 +469,9 @@ while true; do
--skip-osl)
OSL_SKIP=true; shift; continue
;;
--skip-osd)
OSD_SKIP=true; shift; continue
;;
--skip-opencollada)
OPENCOLLADA_SKIP=true; shift; continue
;;
@@ -509,6 +534,14 @@ OSL_SOURCE_REPO=( "https://github.com/Nazg-Gul/OpenShadingLanguage.git" )
OSL_SOURCE_REPO_UID="22ee5ea298fd215430dfbd160b5aefd507f06db0"
OSL_SOURCE_REPO_BRANCH="blender-fixes"
OSD_USE_REPO=true
# Script foo to make the version string compliant with the archive name:
# ${Varname//SearchForThisChar/ReplaceWithThisChar}
OSD_SOURCE=( "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v${OSD_VERSION//./_}.tar.gz" )
OSD_SOURCE_REPO=( "https://github.com/PixarAnimationStudios/OpenSubdiv.git" )
OSD_SOURCE_REPO_UID="404659fffa659da075d1c9416e4fc939139a84ee"
OSD_SOURCE_REPO_BRANCH="dev"
OPENCOLLADA_SOURCE=( "https://github.com/KhronosGroup/OpenCOLLADA.git" )
OPENCOLLADA_REPO_UID="3335ac164e68b2512a40914b14c74db260e6ff7d"
FFMPEG_SOURCE=( "http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2" )
@@ -1522,6 +1555,99 @@ compile_OSL() {
run_ldconfig "osl"
}
#### Build OSD ####
_init_osd() {
_src=$SRC/OpenSubdiv-$OSD_VERSION
_git=true
_inst=$INST/osd-$OSD_VERSION
_inst_shortcut=$INST/osd
}
clean_OSD() {
_init_osd
_clean
}
compile_OSD() {
# To be changed each time we make edits that would modify the compiled result!
osd_magic=0
_init_osd
# Clean install if needed!
magic_compile_check osd-$OSD_VERSION $osd_magic
if [ $? -eq 1 -o $OSD_FORCE_REBUILD == true ]; then
clean_OSD
fi
if [ ! -d $_inst ]; then
INFO "Building OpenSubdiv-$OSD_VERSION"
prepare_opt
if [ ! -d $_src ]; then
mkdir -p $SRC
if [ $OSD_USE_REPO == true ]; then
git clone ${OSD_SOURCE_REPO[0]} $_src
else
download OSD_SOURCE[@] "$_src.tar.gz"
INFO "Unpacking OpenSubdiv-$OSD_VERSION"
tar -C $SRC --transform "s,(.*/?)OpenSubdiv-[^/]*(.*),\1OpenSubdiv-$OSD_VERSION\2,x" \
-xf $_src.tar.gz
fi
fi
cd $_src
if [ $OSD_USE_REPO == true ]; then
git remote set-url origin ${OSD_SOURCE_REPO[0]}
# XXX For now, always update from latest repo...
git pull --no-edit -X theirs origin $OSD_SOURCE_REPO_BRANCH
# Stick to same rev as windows' libs...
git checkout $OSD_SOURCE_REPO_UID
git reset --hard
fi
# Always refresh the whole build!
if [ -d build ]; then
rm -rf build
fi
mkdir build
cd build
cmake_d="-D CMAKE_BUILD_TYPE=Release"
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
# ptex is only needed when nicholas bishop is ready
cmake_d="$cmake_d -D NO_PTEX=1"
cmake_d="$cmake_d -D NO_CLEW=1"
# maya plugin, docs, tutorials, regression tests and examples are not needed
cmake_d="$cmake_d -D NO_MAYA=1 -D NO_DOC=1 -D NO_TUTORIALS=1 -D NO_REGRESSION=1 -DNO_EXAMPLES=1"
cmake $cmake_d ..
make -j$THREADS && make install
make clean
if [ -d $_inst ]; then
_create_inst_shortcut
else
ERROR "OpenSubdiv-$OSD_VERSION failed to compile, exiting"
exit 1
fi
magic_compile_set osd-$OSD_VERSION $osd_magic
cd $CWD
INFO "Done compiling OpenSubdiv-$OSD_VERSION!"
else
INFO "Own OpenSubdiv-$OSD_VERSION is up to date, nothing to do!"
INFO "If you want to force rebuild of this lib, use the --force-osd option."
fi
run_ldconfig "osd"
}
#### Build OpenCOLLADA ####
_init_opencollada() {
_src=$SRC/OpenCOLLADA-$OPENCOLLADA_VERSION
@@ -1813,8 +1939,9 @@ install_DEB() {
THEORA_DEV="libtheora-dev"
_packages="gawk cmake cmake-curses-gui scons build-essential libjpeg-dev libpng-dev \
libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev \
libncurses5-dev libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV \
libfreetype6-dev libx11-dev \
libxcursor-dev libxi-dev wget libsqlite3-dev libxrandr-dev libxinerama-dev \
libbz2-dev libncurses5-dev libssl-dev liblzma-dev libreadline-dev $OPENJPEG_DEV \
libopenal-dev libglew-dev libglewmx-dev yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV \
libsdl1.2-dev libfftw3-dev patch bzip2 libxml2-dev libtinyxml-dev"
@@ -2089,6 +2216,20 @@ install_DEB() {
fi
fi
PRINT ""
if $OSD_SKIP; then
WARNING "Skipping OpenSubdiv installation, as requested..."
else
if $have_llvm; then
install_packages_DEB flex bison libtbb-dev
# No package currently!
PRINT ""
compile_OSD
else
WARNING "No LLVM available, cannot build OSD!"
fi
fi
if $WITH_OPENCOLLADA; then
PRINT ""
if $OPENCOLLADA_SKIP; then
@@ -2287,9 +2428,9 @@ install_RPM() {
OGG_DEV="libogg-devel"
THEORA_DEV="libtheora-devel"
_packages="gcc gcc-c++ make scons libtiff-devel libjpeg-devel\
libpng-devel libX11-devel libXi-devel wget ncurses-devel \
readline-devel $OPENJPEG_DEV openal-soft-devel \
_packages="gcc gcc-c++ git make cmake scons libtiff-devel libjpeg-devel\
libpng-devel libX11-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel \
wget ncurses-devel readline-devel $OPENJPEG_DEV openal-soft-devel \
glew-devel yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV patch \
libxml2-devel yaml-cpp-devel tinyxml-devel"
@@ -2516,7 +2657,7 @@ install_RPM() {
else
if $have_llvm; then
# No package currently!
install_packages_RPM flex bison git
install_packages_RPM flex bison
if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
install_packages_RPM tbb-devel
fi
@@ -2527,12 +2668,29 @@ install_RPM() {
fi
fi
PRINT ""
if $OSD_SKIP; then
WARNING "Skipping OpenSubdiv installation, as requested..."
else
if $have_llvm; then
# No package currently!
install_packages_RPM flex bison
if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
install_packages_RPM tbb-devel
fi
PRINT ""
compile_OSD
else
WARNING "No LLVM available, cannot build OSD!"
fi
fi
if $WITH_OPENCOLLADA; then
PRINT ""
if $OPENCOLLADA_SKIP; then
WARNING "Skipping OpenCOLLADA installation, as requested..."
else
install_packages_RPM pcre-devel git
install_packages_RPM pcre-devel
# Find path to libxml shared lib...
_XML2_LIB=`rpm -ql libxml2-devel | grep -e ".*/libxml2.so"`
# No package...
@@ -2640,7 +2798,8 @@ install_ARCH() {
OGG_DEV="libogg"
THEORA_DEV="libtheora"
_packages="base-devel scons cmake libxi glew libpng libtiff wget openal \
_packages="base-devel git scons cmake \
libxi libxcursor libxrandr libxinerama glew libpng libtiff wget openal \
$OPENJPEG_DEV $VORBIS_DEV $OGG_DEV $THEORA_DEV yasm sdl fftw \
libxml2 yaml-cpp tinyxml"
@@ -2827,7 +2986,7 @@ install_ARCH() {
clean_OSL
else
#XXX Note: will fail to build with LLVM 3.2!
install_packages_ARCH git intel-tbb
install_packages_ARCH intel-tbb
PRINT ""
compile_OSL
fi
@@ -2836,6 +2995,20 @@ install_ARCH() {
fi
fi
PRINT ""
if $OSD_SKIP; then
WARNING "Skipping OpenSubdiv installation, as requested..."
else
if $have_llvm; then
# No package currently? Just build for now!
install_packages_ARCH intel-tbb
PRINT ""
compile_OSD
else
WARNING "No LLVM available, cannot build OSD!"
fi
fi
if $WITH_OPENCOLLADA; then
PRINT ""
if $OPENCOLLADA_SKIP; then
@@ -2846,7 +3019,7 @@ install_ARCH() {
install_packages_ARCH opencollada
clean_OpenCOLLADA
else
install_packages_ARCH pcre git
install_packages_ARCH pcre
PRINT ""
compile_OpenCOLLADA
fi
@@ -3011,6 +3184,14 @@ print_info() {
_buildargs="$_buildargs $_1 $_2"
fi
if [ -d $INST/osd ]; then
_1="-D WITH_OPENSUBDIV=ON"
_2="-D OPENSUBDIV_ROOT_DIR=$INST/osd"
PRINT " $_1"
PRINT " $_2"
_buildargs="$_buildargs $_1 $_2"
fi
if $WITH_OPENCOLLADA; then
_1="-D WITH_OPENCOLLADA=ON"
PRINT " $_1"
@@ -3077,6 +3258,13 @@ print_info() {
PRINT "BF_OSL = '$INST/osl'"
fi
if [ "$OSD_SKIP" = false ]; then
PRINT "WITH_BF_OPENSUBDIV = True"
if [ -d $INST/osd ]; then
PRINT "BF_OPENSUBDIV = '$INST/osd'"
fi
fi
if [ "$BOOST_SKIP" = false ]; then
PRINT "WITH_BF_BOOST = True"
if [ -d $INST/boost ]; then
@@ -3123,7 +3311,27 @@ elif [ -f /etc/redhat-release -o /etc/SuSE-release ]; then
DISTRO="RPM"
install_RPM
else
ERROR "Failed to detect distribution type"
ERROR "Failed to detect distribution type."
PRINT ""
PRINT "Your distribution is not supported by this script, you'll have to install dependencies and"
PRINT "dev packages yourself (list non-exhaustive, but should cover most needs):"
PRINT " * Basics of dev environment (cmake or scons, gcc, svn , git, ...)."
PRINT " * Python$PYTHON_VERSION_MIN, numpy."
PRINT " * libboost$BOOST_VERSION_MIN (locale, filesystem, regex, system, thread, wave)."
PRINT " * libjpeg, libpng, libtiff, libopenjpeg, libopenal."
PRINT " * ffmpeg (with libvorbis, libogg, libtheora, libx264, libmp3lame, libxvidcore, libvpx, ...)."
PRINT " * libx11, libxcursor, libxi, libxrandr, libxinerama (and other libx... as needed)."
PRINT " * libsqlite3, libbz2, libssl, libfftw3, libxml2, libtinyxml, yasm, libyaml-cpp."
PRINT " * libsdl1.2, libglew, libglewmx."
PRINT " * libopencolorio$OCIO_VERSION_MIN, libopenexr$OPENEXR_VERSION_MIN, libopenimageio$OIIO_VERSION_MIN."
PRINT " * llvm-$LLVM_VERSION (with clang)."
PRINT ""
PRINT "Most of up-listed packages are available in recent distributions. The following are likely not,"
PRINT "you'll have to build them (they are all optional, though):"
PRINT " * OpenShadingLanguage (from https://github.com/Nazg-Gul/OpenShadingLanguage.git, branch blender-fixes, commit 22ee5ea298fd215430dfbd160b5aefd507f06db0)."
PRINT " * OpenSubDiv (from https://github.com/PixarAnimationStudios/OpenSubdiv.git, branch dev, commit 404659fffa659da075d1c9416e4fc939139a84ee)."
PRINT " * OpenCollada (from https://github.com/KhronosGroup/OpenCOLLADA.git, branch master, commit 3335ac164e68b2512a40914b14c74db260e6ff7d)."
PRINT ""
exit 1
fi

View File

@@ -2,4 +2,5 @@ BF_BUILDDIR = '../blender-build/linux-glibc211-i686'
BF_INSTALLDIR = '../blender-install/linux-glibc211-i686'
BF_NUMJOBS = 1
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
#BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
BF_CYCLES_CUDA_BINARIES_ARCH = []

View File

@@ -166,6 +166,15 @@ BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
# Ocean Simulation
WITH_BF_OCEANSIM = True
# OpenSubdiv
WITH_BF_OPENSUBDIV = True
WITH_BF_STATICOPENSUBDIV = True
BF_OPENSUBDIV = '/opt/lib/opensubdiv'
BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include'
BF_OPENSUBDIV_LIB = 'osdCPU osdGPU'
BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib'
BF_OPENSUBDIV_LIB_STATIC = '${BF_OPENSUBDIV}/lib/libosdCPU.a ${BF_OPENSUBDIV}/lib/libosdGPU.a'
# Compilation and optimization
BF_DEBUG = False
REL_CCFLAGS = ['-DNDEBUG', '-O2', '-msse', '-msse2'] # C & C++

View File

@@ -166,6 +166,15 @@ BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
# Ocean Simulation
WITH_BF_OCEANSIM = True
# OpenSubdiv
WITH_BF_OPENSUBDIV = True
WITH_BF_STATICOPENSUBDIV = True
BF_OPENSUBDIV = '/opt/lib/opensubdiv'
BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include'
BF_OPENSUBDIV_LIB = 'osdCPU osdGPU'
BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib'
BF_OPENSUBDIV_LIB_STATIC = '${BF_OPENSUBDIV}/lib/libosdCPU.a ${BF_OPENSUBDIV}/lib/libosdGPU.a'
# Compilation and optimization
BF_DEBUG = False
REL_CCFLAGS = ['-DNDEBUG', '-O2', '-msse', '-msse2'] # C & C++

View File

@@ -4,7 +4,7 @@
# <pep8 compliant>
# List of the branches being built automatically overnight
NIGHT_SCHEDULE_BRANCHES = [None, "gooseberry"]
NIGHT_SCHEDULE_BRANCHES = [None]
# List of the branches available for force build
FORCE_SCHEDULE_BRANCHES = ["master", "gooseberry", "experimental-build"]
@@ -305,12 +305,12 @@ add_builder(c, 'mac_x86_64_10_6_scons', 'darwin-9.x.universal', generic_builder,
add_builder(c, 'mac_i386_10_6_scons', 'darwin-9.x.universal', generic_builder, hour=11)
add_builder(c, 'linux_glibc211_i386_scons', '', generic_builder, hour=1)
add_builder(c, 'linux_glibc211_x86_64_scons', '', generic_builder, hour=2)
add_builder(c, 'win32_scons_vc2013', 'windows_vc12', generic_builder, hour=1)
add_builder(c, 'win64_scons_vc2013', 'win64_vc12', generic_builder, hour=2)
#add_builder(c, 'win32_scons_vc2013', 'windows_vc12', generic_builder, hour=1)
#add_builder(c, 'win64_scons_vc2013', 'win64_vc12', generic_builder, hour=2)
add_builder(c, 'win32_cmake_vc2013', 'windows_vc12', generic_builder, hour=3)
add_builder(c, 'win64_cmake_vc2013', 'win64_vc12', generic_builder, hour=4)
#add_builder(c, 'mingw_win32_scons', 'mingw32', generic_builder, hour=4)
add_builder(c, 'mingw_win64_scons', 'mingw64', generic_builder, hour=3)
#add_builder(c, 'mingw_win64_scons', 'mingw64', generic_builder, hour=3)
#add_builder(c, 'freebsd_i386_cmake', '', generic_builder, hour=1)
#add_builder(c, 'freebsd_x86_64_cmake', '', generic_builder, hour=2)

View File

@@ -57,7 +57,10 @@ if 'cmake' in builder:
retcode = subprocess.call(['cmake', blender_dir] + cmake_options)
if retcode != 0:
sys.exit(retcode)
if 'win' in builder:
if 'win32' in builder:
retcode = subprocess.call(['msbuild', 'INSTALL.vcxproj', '/Property:PlatformToolset=v120_xp', '/p:Configuration=Release'])
elif 'win64' in builder:
retcode = subprocess.call(['msbuild', 'INSTALL.vcxproj', '/p:Configuration=Release'])
else:
retcode = subprocess.call(['make', '-s', '-j4', 'install'])

View File

@@ -123,14 +123,26 @@ else:
os.remove(f)
retcode = subprocess.call(['cpack', '-G', 'ZIP'])
result_file = [f for f in os.listdir('.') if os.path.isfile(f) and f.endswith('.zip')][0]
os.rename(result_file, "{}.zip".format(builder))
# TODO(sergey): Such magic usually happens in SCon's packaging bu we don't have it
# in the CMake yet. For until then we do some magic here.
tokens = result_file.split('-')
blender_version = tokens[1].split('.')
blender_full_version = '.'.join(blender_version[0:2])
git_hash = tokens[2].split('.')[1]
platform = builder.split('_')[0]
builderified_name = 'blender-{}-{}-{}'.format(blender_full_version, git_hash, platform)
if branch != '':
builderified_name = branch + "-" + builderified_name
os.rename(result_file, "{}.zip".format(builderified_name))
# create zip file
try:
upload_zip = "buildbot_upload.zip"
if os.path.exists(upload_zip):
os.remove(upload_zip)
z = zipfile.ZipFile(upload_zip, "w", compression=zipfile.ZIP_STORED)
z.write("{}.zip".format(builder))
z.write("{}.zip".format(builderified_name))
z.close()
sys.exit(retcode)
except Exception as ex:

View File

@@ -0,0 +1,113 @@
# - Try to find audaspace
# Once done, this will define
#
# AUDASPACE_FOUND - system has audaspace
# AUDASPACE_INCLUDE_DIRS - the audaspace include directories
# AUDASPACE_LIBRARIES - link these to use audaspace
# AUDASPACE_C_FOUND - system has audaspace's C binding
# AUDASPACE_C_INCLUDE_DIRS - the audaspace's C binding include directories
# AUDASPACE_C_LIBRARIES - link these to use audaspace's C binding
# AUDASPACE_PY_FOUND - system has audaspace's python binding
# AUDASPACE_PY_INCLUDE_DIRS - the audaspace's python binding include directories
# AUDASPACE_PY_LIBRARIES - link these to use audaspace's python binding
IF(NOT AUDASPACE_ROOT_DIR AND NOT $ENV{AUDASPACE_ROOT_DIR} STREQUAL "")
SET(AUDASPACE_ROOT_DIR $ENV{AUDASPACE_ROOT_DIR})
ENDIF()
SET(_audaspace_SEARCH_DIRS
${AUDASPACE_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
)
# Use pkg-config to get hints about paths
FIND_PACKAGE(PkgConfig)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(AUDASPACE_PKGCONF audaspace)
ENDIF(PKG_CONFIG_FOUND)
# Include dir
FIND_PATH(AUDASPACE_INCLUDE_DIR
NAMES ISound.h
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES include/audaspace
)
# Library
FIND_LIBRARY(AUDASPACE_LIBRARY
NAMES audaspace
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_LIBRARY_DIRS}
PATH_SUFFIXES lib lib64
)
# Include dir
FIND_PATH(AUDASPACE_C_INCLUDE_DIR
NAMES AUD_Sound.h
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES include/audaspace
)
# Library
FIND_LIBRARY(AUDASPACE_C_LIBRARY
NAMES audaspace-c
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_LIBRARY_DIRS}
PATH_SUFFIXES lib lib64
)
# Include dir
FIND_PATH(AUDASPACE_PY_INCLUDE_DIR
NAMES python/PyAPI.h
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES include/audaspace
)
# Library
FIND_LIBRARY(AUDASPACE_PY_LIBRARY
NAMES audaspace-py
HINTS ${_audaspace_SEARCH_DIRS}
PATHS ${AUDASPACE_PKGCONF_LIBRARY_DIRS}
PATH_SUFFIXES lib lib64
)
FIND_PACKAGE(PackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Audaspace DEFAULT_MSG AUDASPACE_LIBRARY AUDASPACE_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Audaspace_C DEFAULT_MSG AUDASPACE_C_LIBRARY AUDASPACE_C_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Audaspace_Py DEFAULT_MSG AUDASPACE_PY_LIBRARY AUDASPACE_PY_INCLUDE_DIR)
IF(AUDASPACE_FOUND)
SET(AUDASPACE_LIBRARIES ${AUDASPACE_LIBRARY})
SET(AUDASPACE_INCLUDE_DIRS ${AUDASPACE_INCLUDE_DIR})
ENDIF(AUDASPACE_FOUND)
IF(AUDASPACE_C_FOUND)
SET(AUDASPACE_C_LIBRARIES ${AUDASPACE_C_LIBRARY})
SET(AUDASPACE_C_INCLUDE_DIRS ${AUDASPACE_C_INCLUDE_DIR})
ENDIF(AUDASPACE_C_FOUND)
IF(AUDASPACE_PY_FOUND)
SET(AUDASPACE_PY_LIBRARIES ${AUDASPACE_PY_LIBRARY})
SET(AUDASPACE_PY_INCLUDE_DIRS ${AUDASPACE_PY_INCLUDE_DIR})
ENDIF(AUDASPACE_PY_FOUND)
MARK_AS_ADVANCED(
AUDASPACE_LIBRARY
AUDASPACE_LIBRARIES
AUDASPACE_INCLUDE_DIR
AUDASPACE_INCLUDE_DIRS
AUDASPACE_C_LIBRARY
AUDASPACE_C_LIBRARIES
AUDASPACE_C_INCLUDE_DIR
AUDASPACE_C_INCLUDE_DIRS
AUDASPACE_PY_LIBRARY
AUDASPACE_PY_LIBRARIES
AUDASPACE_PY_INCLUDE_DIR
AUDASPACE_PY_INCLUDE_DIRS
)

View File

@@ -59,7 +59,8 @@ FIND_LIBRARY(OPENIMAGEIO_LIBRARY
FIND_FILE(OPENIMAGEIO_IDIFF
NAMES
idiff
${OPENIMAGEIO_ROOT_DIR}
HINTS
${OPENIMAGEIO_ROOT_DIR}
PATH_SUFFIXES
bin
)

View File

@@ -0,0 +1,111 @@
# - Find OpenSubdiv library
# Find the native OpenSubdiv includes and library
# This module defines
# OPENSUBDIV_INCLUDE_DIRS, where to find OpenSubdiv headers, Set when
# OPENSUBDIV_INCLUDE_DIR is found.
# OPENSUBDIV_LIBRARIES, libraries to link against to use OpenSubdiv.
# OPENSUBDIV_ROOT_DIR, the base directory to search for OpenSubdiv.
# This can also be an environment variable.
# OPENSUBDIV_FOUND, if false, do not try to use OpenSubdiv.
#
# also defined, but not for general use are
# OPENSUBDIV_LIBRARY, where to find the OpenSubdiv library.
#=============================================================================
# Copyright 2013 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# If OPENSUBDIV_ROOT_DIR was defined in the environment, use it.
IF(NOT OPENSUBDIV_ROOT_DIR AND NOT $ENV{OPENSUBDIV_ROOT_DIR} STREQUAL "")
SET(OPENSUBDIV_ROOT_DIR $ENV{OPENSUBDIV_ROOT_DIR})
ENDIF()
SET(_opensubdiv_FIND_COMPONENTS
osdGPU
osdCPU
)
SET(_opensubdiv_SEARCH_DIRS
${OPENSUBDIV_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt/lib/opensubdiv
)
FIND_PATH(OPENSUBDIV_INCLUDE_DIR
NAMES
opensubdiv/osd/mesh.h
HINTS
${_opensubdiv_SEARCH_DIRS}
PATH_SUFFIXES
include
)
SET(_opensubdiv_LIBRARIES)
FOREACH(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
FIND_LIBRARY(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
HINTS
${_opensubdiv_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
LIST(APPEND _opensubdiv_LIBRARIES "${OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY}")
ENDFOREACH()
MACRO(OPENSUBDIV_CHECK_CONTROLLER
controller_include_file
variable_name)
IF(EXISTS "${OPENSUBDIV_INCLUDE_DIR}/opensubdiv/osd/${controller_include_file}")
SET(${variable_name} TRUE)
ELSE()
SET(${variable_name} FALSE)
ENDIF()
ENDMACRO()
# handle the QUIETLY and REQUIRED arguments and set OPENSUBDIV_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSubdiv DEFAULT_MSG
_opensubdiv_LIBRARIES OPENSUBDIV_INCLUDE_DIR)
IF(OPENSUBDIV_FOUND)
SET(OPENSUBDIV_LIBRARIES ${_opensubdiv_LIBRARIES})
SET(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR})
# Find available compute controllers.
FIND_PACKAGE(OpenMP)
IF(OPENMP_FOUND)
SET(OPENSUBDIV_HAS_OPENMP TRUE)
ELSE()
SET(OPENSUBDIV_HAS_OPENMP FALSE)
ENDIF()
OPENSUBDIV_CHECK_CONTROLLER("tbbEvaluator.h" OPENSUBDIV_HAS_TBB)
OPENSUBDIV_CHECK_CONTROLLER("clEvaluator.h" OPENSUBDIV_HAS_OPENCL)
OPENSUBDIV_CHECK_CONTROLLER("cudaEvaluator.h" OPENSUBDIV_HAS_CUDA)
OPENSUBDIV_CHECK_CONTROLLER("glXFBEvaluator.h" OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
OPENSUBDIV_CHECK_CONTROLLER("glComputeEvaluator.h" OPENSUBDIV_HAS_GLSL_COMPUTE)
ENDIF(OPENSUBDIV_FOUND)
MARK_AS_ADVANCED(
OPENSUBDIV_INCLUDE_DIR
)
FOREACH(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
MARK_AS_ADVANCED(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY)
ENDFOREACH()

View File

@@ -12,7 +12,7 @@
#
#=============================================================================
macro(BLENDER_SRC_GTEST NAME SRC EXTRA_LIBS)
macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
if(WITH_GTESTS)
get_property(_current_include_directories
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -40,10 +40,20 @@ macro(BLENDER_SRC_GTEST NAME SRC EXTRA_LIBS)
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TESTS_OUTPUT_DIR}"
INCLUDE_DIRECTORIES "${TEST_INC}")
add_test(${NAME}_test ${TESTS_OUTPUT_DIR}/${NAME}_test)
if(${DO_ADD_TEST})
add_test(${NAME}_test ${TESTS_OUTPUT_DIR}/${NAME}_test)
endif()
endif()
endmacro()
macro(BLENDER_TEST NAME EXTRA_LIBS)
BLENDER_SRC_GTEST("${NAME}" "${NAME}_test.cc" "${EXTRA_LIBS}")
macro(BLENDER_SRC_GTEST NAME SRC EXTRA_LIBS)
BLENDER_SRC_GTEST_EX("${NAME}" "${SRC}" "${EXTRA_LIBS}" "TRUE")
endmacro()
macro(BLENDER_TEST NAME EXTRA_LIBS)
BLENDER_SRC_GTEST_EX("${NAME}" "${NAME}_test.cc" "${EXTRA_LIBS}" "TRUE")
endmacro()
macro(BLENDER_TEST_PERFORMANCE NAME EXTRA_LIBS)
BLENDER_SRC_GTEST_EX("${NAME}" "${NAME}_test.cc" "${EXTRA_LIBS}" "FALSE")
endmacro()

View File

@@ -97,6 +97,10 @@ if(EXISTS ${SOURCE_DIR}/.git)
WORKING_DIRECTORY ${SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_COMMIT_TIMESTAMP
OUTPUT_STRIP_TRAILING_WHITESPACE)
# May fail in rare cases
if(MY_WC_COMMIT_TIMESTAMP STREQUAL "")
set(MY_WC_COMMIT_TIMESTAMP 0)
endif()
# Update GIT index before getting dirty files
execute_process(COMMAND git update-index -q --refresh

View File

@@ -40,6 +40,7 @@ from project_info import (
# is_py,
cmake_advanced_info,
cmake_compiler_defines,
cmake_cache_var,
project_name_get,
)
@@ -71,6 +72,10 @@ def create_nb_project_main():
# be tricky, get the project name from git if we can!
PROJECT_NAME = project_name_get()
make_exe = cmake_cache_var("CMAKE_MAKE_PROGRAM")
make_exe_basename = os.path.basename(make_exe)
# --------------- NB spesific
defines = [("%s=%s" % cdef) if cdef[1] else cdef[0] for cdef in defines]
defines += [cdef.replace("#define", "").strip() for cdef in cmake_compiler_defines()]
@@ -131,9 +136,9 @@ def create_nb_project_main():
f = open(join(PROJECT_DIR_NB, "configurations.xml"), 'w')
f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
f.write('<configurationDescriptor version="94">\n')
f.write('<configurationDescriptor version="95">\n')
f.write(' <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">\n')
f.write(' <df name="0" root="%s">\n' % SOURCE_DIR) # base_root_rel
f.write(' <df root="%s" name="0">\n' % SOURCE_DIR) # base_root_rel
# write files!
files_rel_local = [normpath(relpath(join(CMAKE_DIR, path), SOURCE_DIR)) for path in files_rel]
@@ -185,16 +190,27 @@ def create_nb_project_main():
f.write(' <toolsSet>\n')
f.write(' <compilerSet>default</compilerSet>\n')
f.write(' <dependencyChecking>false</dependencyChecking>\n')
f.write(' <rebuildPropChanged>false</rebuildPropChanged>\n')
f.write(' </toolsSet>\n')
f.write(' <dependencyChecking>false</dependencyChecking>\n')
f.write(' <rebuildPropChanged>false</rebuildPropChanged>\n')
f.write(' <codeAssistance>\n')
f.write(' </codeAssistance>\n')
f.write(' <makefileType>\n')
f.write(' <makeTool>\n')
f.write(' <buildCommandWorkingDir>.</buildCommandWorkingDir>\n')
f.write(' <buildCommand>${MAKE} -f Makefile</buildCommand>\n')
f.write(' <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>\n')
if make_exe_basename == "ninja":
build_cmd = "ninja"
clean_cmd = "ninja -t clean"
else:
build_cmd = "${MAKE} -f Makefile"
clean_cmd = "${MAKE} -f Makefile clean"
f.write(' <buildCommand>%s</buildCommand>\n' % build_cmd)
f.write(' <cleanCommand>%s</cleanCommand>\n' % clean_cmd)
f.write(' <executablePath>./bin/blender</executablePath>\n')
del build_cmd, clean_cmd
def write_toolinfo():
f.write(' <incDir>\n')
@@ -221,10 +237,11 @@ def create_nb_project_main():
f.write(' \n')
for path in files_rel_local:
is_c = path.endswith(".c")
f.write(' <item path="%s"\n' % path)
f.write(' ex="false"\n')
f.write(' tool="1"\n')
f.write(' flavor2="0">\n')
f.write(' tool="%d"\n' % (0 if is_c else 1))
f.write(' flavor2="%d">\n' % (3 if is_c else 0))
f.write(' </item>\n')
f.write(' <runprofile version="9">\n')

View File

@@ -1,5 +1,4 @@
# turn everything OFF except for python which defaults to ON
# and is needed for the UI
# Turn everything ON thats expected for an official release builds.
#
# Example usage:
# cmake -C../blender/build_files/cmake/config/blender_full.cmake ../blender
@@ -13,6 +12,7 @@ set(WITH_CODEC_SNDFILE ON CACHE BOOL "" FORCE)
set(WITH_CYCLES ON CACHE BOOL "" FORCE)
set(WITH_FFTW3 ON CACHE BOOL "" FORCE)
set(WITH_LIBMV ON CACHE BOOL "" FORCE)
set(WITH_LIBMV_SCHUR_SPECIALIZATIONS ON CACHE BOOL "" FORCE)
set(WITH_GAMEENGINE ON CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR ON CACHE BOOL "" FORCE)
set(WITH_FREESTYLE ON CACHE BOOL "" FORCE)
@@ -52,11 +52,18 @@ set(WITH_X11_XF86VMODE ON CACHE BOOL "" FORCE)
set(WITH_PLAYER ON CACHE BOOL "" FORCE)
set(WITH_MEM_JEMALLOC ON CACHE BOOL "" FORCE)
# platform dependant options
if(UNIX AND NOT APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_DOC_MANPAGE ON CACHE BOOL "" FORCE)
endif()
if(APPLE)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif(WIN32)
set(WITH_JACK OFF CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV ON CACHE BOOL "" FORCE)
elseif (APPLE)
set(WITH_JACK ON CACHE BOOL "" FORCE)
set(WITH_CODEC_QUICKTIME ON CACHE BOOL "" FORCE)
set(WITH_OPENSUBDIV OFF CACHE BOOL "" FORCE)
endif()

View File

@@ -16,6 +16,7 @@ set(WITH_CODEC_SNDFILE OFF CACHE BOOL "" FORCE)
set(WITH_CYCLES OFF CACHE BOOL "" FORCE)
set(WITH_FFTW3 OFF CACHE BOOL "" FORCE)
set(WITH_LIBMV OFF CACHE BOOL "" FORCE)
set(WITH_LLVM OFF CACHE BOOL "" FORCE)
set(WITH_GAMEENGINE OFF CACHE BOOL "" FORCE)
set(WITH_COMPOSITOR OFF CACHE BOOL "" FORCE)
set(WITH_FREESTYLE OFF CACHE BOOL "" FORCE)

View File

@@ -48,7 +48,7 @@ macro(list_insert_before
unset(_index)
endmacro()
function (list_assert_duplicates
function(list_assert_duplicates
list_id
)
@@ -104,21 +104,31 @@ macro(file_list_suffix
endmacro()
macro(target_link_libraries_optimized TARGET LIBS)
function(target_link_libraries_optimized
TARGET
LIBS
)
foreach(_LIB ${LIBS})
target_link_libraries(${TARGET} optimized "${_LIB}")
endforeach()
unset(_LIB)
endmacro()
endfunction()
function(target_link_libraries_debug
TARGET
LIBS
)
macro(target_link_libraries_debug TARGET LIBS)
foreach(_LIB ${LIBS})
target_link_libraries(${TARGET} debug "${_LIB}")
endforeach()
unset(_LIB)
endmacro()
endfunction()
function(target_link_libraries_decoupled
target
libraries_var
)
macro(target_link_libraries_decoupled target libraries_var)
if(NOT MSVC)
target_link_libraries(${target} ${${libraries_var}})
else()
@@ -127,14 +137,15 @@ macro(target_link_libraries_decoupled target libraries_var)
file_list_suffix(_libraries_debug "${${libraries_var}}" "_d")
target_link_libraries_debug(${target} "${_libraries_debug}")
target_link_libraries_optimized(${target} "${${libraries_var}}")
unset(_libraries_debug)
endif()
endmacro()
endfunction()
# Nicer makefiles with -I/1/foo/ instead of -I/1/2/3/../../foo/
# use it instead of include_directories()
macro(blender_include_dirs
includes)
function(blender_include_dirs
includes
)
set(_ALL_INCS "")
foreach(_INC ${ARGV})
get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
@@ -145,13 +156,12 @@ macro(blender_include_dirs
##endif()
endforeach()
include_directories(${_ALL_INCS})
unset(_INC)
unset(_ABS_INC)
unset(_ALL_INCS)
endmacro()
endfunction()
function(blender_include_dirs_sys
includes
)
macro(blender_include_dirs_sys
includes)
set(_ALL_INCS "")
foreach(_INC ${ARGV})
get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
@@ -161,13 +171,11 @@ macro(blender_include_dirs_sys
##endif()
endforeach()
include_directories(SYSTEM ${_ALL_INCS})
unset(_INC)
unset(_ABS_INC)
unset(_ALL_INCS)
endmacro()
endfunction()
macro(blender_source_group
sources)
function(blender_source_group
sources
)
# Group by location on disk
source_group("Source Files" FILES CMakeLists.txt)
@@ -177,23 +185,23 @@ macro(blender_source_group
if((${_SRC_EXT} MATCHES ".h") OR
(${_SRC_EXT} MATCHES ".hpp") OR
(${_SRC_EXT} MATCHES ".hh"))
source_group("Header Files" FILES ${_SRC})
else()
source_group("Source Files" FILES ${_SRC})
endif()
endforeach()
unset(_SRC)
unset(_SRC_EXT)
endmacro()
set(GROUP_ID "Header Files")
else()
set(GROUP_ID "Source Files")
endif()
source_group("${GROUP_ID}" FILES ${_SRC})
endforeach()
endfunction()
# only MSVC uses SOURCE_GROUP
macro(blender_add_lib_nolist
function(blender_add_lib_nolist
name
sources
includes
includes_sys)
includes_sys
)
# message(STATUS "Configuring library ${name}")
@@ -213,22 +221,24 @@ macro(blender_add_lib_nolist
# Not for system includes because they can resolve to the same path
# list_assert_duplicates("${includes_sys}")
endmacro()
endfunction()
macro(blender_add_lib
function(blender_add_lib
name
sources
includes
includes_sys)
includes_sys
)
blender_add_lib_nolist(${name} "${sources}" "${includes}" "${includes_sys}")
set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
endmacro()
endfunction()
macro(SETUP_LIBDIRS)
function(SETUP_LIBDIRS)
link_directories(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH})
if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs
@@ -288,24 +298,27 @@ macro(SETUP_LIBDIRS)
if(WIN32 AND NOT UNIX)
link_directories(${PTHREADS_LIBPATH})
endif()
endmacro()
endfunction()
macro(setup_liblinks
target)
function(setup_liblinks
target
)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}" PARENT_SCOPE)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}" PARENT_SCOPE)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}" PARENT_SCOPE)
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE)
target_link_libraries(${target}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${FREETYPE_LIBRARY})
target_link_libraries(
${target}
${PNG_LIBRARIES}
${ZLIB_LIBRARIES}
${FREETYPE_LIBRARY}
)
# since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs
@@ -330,6 +343,9 @@ macro(setup_liblinks
if(WITH_BULLET AND WITH_SYSTEM_BULLET)
target_link_libraries(${target} ${BULLET_LIBRARIES})
endif()
if(WITH_AUDASPACE AND WITH_SYSTEM_AUDASPACE)
target_link_libraries(${target} ${AUDASPACE_C_LIBRARIES} ${AUDASPACE_PY_LIBRARIES})
endif()
if(WITH_OPENAL)
target_link_libraries(${target} ${OPENAL_LIBRARY})
endif()
@@ -357,6 +373,16 @@ macro(setup_liblinks
if(WITH_OPENCOLORIO)
target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
endif()
if(WITH_OPENSUBDIV)
if(WIN32 AND NOT UNIX)
file_list_suffix(OPENSUBDIV_LIBRARIES_DEBUG "${OPENSUBDIV_LIBRARIES}" "_d")
target_link_libraries_debug(${target} "${OPENSUBDIV_LIBRARIES_DEBUG}")
target_link_libraries_optimized(${target} "${OPENSUBDIV_LIBRARIES}")
unset(OPENSUBDIV_LIBRARIES_DEBUG)
else()
target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
endif()
endif()
if(WITH_CYCLES_OSL)
target_link_libraries(${target} ${OSL_LIBRARIES})
endif()
@@ -402,11 +428,13 @@ macro(setup_liblinks
unset(EXPAT_LIB_DEBUG)
endif()
else()
target_link_libraries(${target}
${OPENCOLLADA_LIBRARIES}
${PCRE_LIBRARIES}
${XML2_LIBRARIES}
${EXPAT_LIB})
target_link_libraries(
${target}
${OPENCOLLADA_LIBRARIES}
${PCRE_LIBRARIES}
${XML2_LIBRARIES}
${EXPAT_LIB}
)
endif()
endif()
if(WITH_MEM_JEMALLOC)
@@ -436,9 +464,11 @@ macro(setup_liblinks
${BLENDER_GL_LIBRARIES})
target_link_libraries(${target} ${PLATFORM_LINKLIBS} ${CMAKE_DL_LIBS})
endmacro()
endfunction()
function(SETUP_BLENDER_SORTED_LIBS)
macro(SETUP_BLENDER_SORTED_LIBS)
get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
list(APPEND BLENDER_LINK_LIBS
@@ -578,6 +608,7 @@ macro(SETUP_BLENDER_SORTED_LIBS)
extern_libmv
extern_glog
extern_sdlew
extern_eigen3
bf_intern_glew_mx
)
@@ -656,6 +687,10 @@ macro(SETUP_BLENDER_SORTED_LIBS)
list_insert_after(BLENDER_SORTED_LIBS "ge_logic_ngnetwork" "extern_bullet")
endif()
if(WITH_OPENSUBDIV)
list(APPEND BLENDER_SORTED_LIBS bf_intern_opensubdiv)
endif()
foreach(SORTLIB ${BLENDER_SORTED_LIBS})
set(REMLIB ${SORTLIB})
foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
@@ -674,14 +709,12 @@ macro(SETUP_BLENDER_SORTED_LIBS)
message(STATUS "Blender Skipping: (${REM_MSG})")
endif()
unset(SEARCHLIB)
unset(SORTLIB)
unset(REMLIB)
unset(REM_MSG)
set(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} PARENT_SCOPE)
# for top-level tests
set_property(GLOBAL PROPERTY BLENDER_SORTED_LIBS_PROP ${BLENDER_SORTED_LIBS})
endmacro()
endfunction()
macro(TEST_SSE_SUPPORT
_sse_flags
@@ -903,19 +936,22 @@ endmacro()
# utility macro
macro(remove_cc_flag
flag)
_flag)
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
foreach(flag ${ARGV})
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
endforeach()
unset(flag)
endmacro()
@@ -929,28 +965,34 @@ endmacro()
macro(remove_strict_flags)
if(CMAKE_COMPILER_IS_GNUCC)
remove_cc_flag("-Wstrict-prototypes")
remove_cc_flag("-Wmissing-prototypes")
remove_cc_flag("-Wunused-parameter")
remove_cc_flag("-Wunused-macros")
remove_cc_flag("-Wwrite-strings")
remove_cc_flag("-Wredundant-decls")
remove_cc_flag("-Wundef")
remove_cc_flag("-Wshadow")
remove_cc_flag("-Wdouble-promotion")
remove_cc_flag("-Wold-style-definition")
remove_cc_flag("-Werror=[^ ]+")
remove_cc_flag("-Werror")
remove_cc_flag(
"-Wstrict-prototypes"
"-Wmissing-prototypes"
"-Wmissing-format-attribute"
"-Wunused-local-typedefs"
"-Wunused-macros"
"-Wunused-parameter"
"-Wwrite-strings"
"-Wredundant-decls"
"-Wundef"
"-Wshadow"
"-Wdouble-promotion"
"-Wold-style-definition"
"-Werror=[^ ]+"
"-Werror"
)
# negate flags implied by '-Wall'
add_cc_flag("${CC_REMOVE_STRICT_FLAGS}")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
remove_cc_flag("-Wunused-parameter")
remove_cc_flag("-Wunused-variable")
remove_cc_flag("-Werror=[^ ]+")
remove_cc_flag("-Werror")
remove_cc_flag(
"-Wunused-parameter"
"-Wunused-variable"
"-Werror=[^ ]+"
"-Werror"
)
# negate flags implied by '-Wall'
add_cc_flag("${CC_REMOVE_STRICT_FLAGS}")
@@ -964,11 +1006,15 @@ endmacro()
macro(remove_extra_strict_flags)
if(CMAKE_COMPILER_IS_GNUCC)
remove_cc_flag("-Wunused-parameter")
remove_cc_flag(
"-Wunused-parameter"
)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
remove_cc_flag("-Wunused-parameter")
remove_cc_flag(
"-Wunused-parameter"
)
endif()
if(MSVC)
@@ -1004,37 +1050,39 @@ macro(remove_strict_flags_file
endmacro()
macro(ADD_CHECK_C_COMPILER_FLAG
function(ADD_CHECK_C_COMPILER_FLAG
_CFLAGS
_CACHE_VAR
_FLAG)
_FLAG
)
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
if(${_CACHE_VAR})
# message(STATUS "Using CFLAG: ${_FLAG}")
set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}")
set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}" PARENT_SCOPE)
else()
message(STATUS "Unsupported CFLAG: ${_FLAG}")
endif()
endmacro()
endfunction()
macro(ADD_CHECK_CXX_COMPILER_FLAG
function(ADD_CHECK_CXX_COMPILER_FLAG
_CXXFLAGS
_CACHE_VAR
_FLAG)
_FLAG
)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
if(${_CACHE_VAR})
# message(STATUS "Using CXXFLAG: ${_FLAG}")
set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}")
set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}" PARENT_SCOPE)
else()
message(STATUS "Unsupported CXXFLAG: ${_FLAG}")
endif()
endmacro()
endfunction()
function(get_blender_version)
# extracts header vars and defines them in the parent scope:
@@ -1184,7 +1232,7 @@ endmacro()
# pair of macros to allow libraries to be specify files to install, but to
# only install them at the end so the directories don't get cleared with
# the files in them. used by cycles to install addon.
macro(delayed_install
function(delayed_install
base
files
destination)
@@ -1197,8 +1245,7 @@ macro(delayed_install
endif()
set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_DESTINATIONS ${destination})
endforeach()
unset(f)
endmacro()
endfunction()
# note this is a function instead of a macro so that ${BUILD_TYPE} in targetdir
# does not get expanded in calling but is preserved
@@ -1217,16 +1264,17 @@ function(delayed_do_install
list(GET destinations ${i} d)
install(FILES ${f} DESTINATION ${targetdir}/${d})
endforeach()
unset(f)
endif()
endfunction()
macro(data_to_c
file_from file_to
list_to_add)
function(data_to_c
file_from file_to
list_to_add
)
list(APPEND ${list_to_add} ${file_to})
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
get_filename_component(_file_to_path ${file_to} PATH)
@@ -1237,21 +1285,21 @@ macro(data_to_c
DEPENDS ${file_from} datatoc)
set_source_files_properties(${file_to} PROPERTIES GENERATED TRUE)
unset(_file_to_path)
endmacro()
endfunction()
# same as above but generates the var name and output automatic.
macro(data_to_c_simple
file_from
list_to_add)
function(data_to_c_simple
file_from
list_to_add
)
# remove ../'s
get_filename_component(_file_from ${CMAKE_CURRENT_SOURCE_DIR}/${file_from} REALPATH)
get_filename_component(_file_to ${CMAKE_CURRENT_BINARY_DIR}/${file_from}.c REALPATH)
list(APPEND ${list_to_add} ${_file_to})
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
get_filename_component(_file_to_path ${_file_to} PATH)
@@ -1262,17 +1310,13 @@ macro(data_to_c_simple
DEPENDS ${_file_from} datatoc)
set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE)
unset(_file_from)
unset(_file_to)
unset(_file_to_path)
endmacro()
endfunction()
# macro for converting pixmap directory to a png and then a c file
macro(data_to_c_simple_icons
path_from
list_to_add
)
function(data_to_c_simple_icons
path_from
list_to_add
)
# Conversion steps
# path_from -> _file_from -> _file_to
@@ -1284,6 +1328,7 @@ macro(data_to_c_simple_icons
get_filename_component(_file_to ${CMAKE_CURRENT_BINARY_DIR}/${path_from}.png.c REALPATH)
list(APPEND ${list_to_add} ${_file_to})
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
get_filename_component(_file_to_path ${_file_to} PATH)
@@ -1305,27 +1350,22 @@ macro(data_to_c_simple_icons
)
set_source_files_properties(${_file_from} ${_file_to} PROPERTIES GENERATED TRUE)
unset(_path_from_abs)
unset(_file_from)
unset(_file_to)
unset(_file_to_path)
unset(_icon_files)
endmacro()
endfunction()
# XXX Not used for now...
macro(svg_to_png
file_from
file_to
dpi
list_to_add)
function(svg_to_png
file_from
file_to
dpi
list_to_add
)
# remove ../'s
get_filename_component(_file_from ${CMAKE_CURRENT_SOURCE_DIR}/${file_from} REALPATH)
get_filename_component(_file_to ${CMAKE_CURRENT_SOURCE_DIR}/${file_to} REALPATH)
list(APPEND ${list_to_add} ${_file_to})
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
find_program(INKSCAPE_EXE inkscape)
mark_as_advanced(INKSCAPE_EXE)
@@ -1348,15 +1388,12 @@ macro(svg_to_png
else()
message(WARNING "Inkscape not found, could not re-generate ${_file_to} from ${_file_from}!")
endif()
endfunction()
unset(_file_from)
unset(_file_to)
endmacro()
macro(msgfmt_simple
file_from
list_to_add)
function(msgfmt_simple
file_from
list_to_add
)
# remove ../'s
get_filename_component(_file_from_we ${file_from} NAME_WE)
@@ -1365,6 +1402,7 @@ macro(msgfmt_simple
get_filename_component(_file_to ${CMAKE_CURRENT_BINARY_DIR}/${_file_from_we}.mo REALPATH)
list(APPEND ${list_to_add} ${_file_to})
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
get_filename_component(_file_to_path ${_file_to} PATH)
@@ -1375,15 +1413,11 @@ macro(msgfmt_simple
DEPENDS msgfmt ${_file_from})
set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE)
endfunction()
unset(_file_from_we)
unset(_file_from)
unset(_file_to)
unset(_file_to_path)
endmacro()
macro(find_python_package
package)
function(find_python_package
package
)
string(TOUPPER ${package} _upper_package)
@@ -1421,25 +1455,17 @@ macro(find_python_package
"'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/${package}', "
"'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/${package}', "
"WITH_PYTHON_INSTALL_${_upper_package} option will be ignored when installing python")
set(WITH_PYTHON_INSTALL_${_upper_package} OFF)
set(WITH_PYTHON_INSTALL_${_upper_package} OFF PARENT_SCOPE)
else()
message(STATUS "${package} found at '${PYTHON_${_upper_package}_PATH}'")
endif()
unset(_PY_VER_SPLIT)
unset(_PY_VER_MAJOR)
endif()
unset(_upper_package)
endmacro()
endfunction()
# like Python's 'print(dir())'
macro(print_all_vars)
function(print_all_vars)
get_cmake_property(_vars VARIABLES)
foreach(_var ${_vars})
message("${_var}=${${_var}}")
endforeach()
unset(_vars)
unset(_var)
endmacro()
endfunction()

View File

@@ -24,7 +24,7 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/.git/)
include(FindGit)
if(GIT_FOUND)
message(STATUS "-- Found Git: ${GIT_EXECUTABLE}")
execute_process(COMMAND git rev-parse --short @{u}
execute_process(COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE MY_WC_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE

View File

@@ -130,7 +130,7 @@ def is_project_file(filename):
def cmake_advanced_info():
""" Extracr includes and defines from cmake.
""" Extract includes and defines from cmake.
"""
make_exe = cmake_cache_var("CMAKE_MAKE_PROGRAM")

View File

@@ -59,14 +59,21 @@ def is_c_any(filename):
CMAKE_DIR = "."
def cmake_cache_var(var):
cache_file = open(join(CMAKE_DIR, "CMakeCache.txt"))
lines = [l_strip for l in cache_file for l_strip in (l.strip(),) if l_strip if not l_strip.startswith("//") if not l_strip.startswith("#")]
cache_file.close()
def cmake_cache_var_iter():
import re
re_cache = re.compile(r'([A-Za-z0-9_\-]+)?:?([A-Za-z0-9_\-]+)?=(.*)$')
with open(join(CMAKE_DIR, "CMakeCache.txt"), 'r', encoding='utf-8') as cache_file:
for l in cache_file:
match = re_cache.match(l.strip())
if match is not None:
var, type_, val = match.groups()
yield (var, type_ or "", val)
for l in lines:
if l.split(":")[0] == var:
return l.split("=", 1)[-1]
def cmake_cache_var(var):
for var_iter, type_iter, value_iter in cmake_cache_var_iter():
if var == var_iter:
return value_iter
return None

View File

@@ -52,6 +52,8 @@ BF_CXX = '/usr'
WITH_BF_STATICCXX = False
BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
WITH_BF_AUDASPACE = True
# we use simply jack framework
WITH_BF_JACK = True
BF_JACK = '/Library/Frameworks/Jackmp.framework'
@@ -213,6 +215,12 @@ WITH_BF_FREESTYLE = True
#OpenMP ( will be checked for compiler support and turned off eventually )
WITH_BF_OPENMP = True
WITH_BF_OPENSUBDIV = False
BF_OPENSUBDIV = LIBDIR + '/opensubdiv'
BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include'
BF_OPENSUBDIV_LIB = 'osdCPU osdGPU'
BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib'
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = True
BF_RAYOPTIMIZATION_SSE_FLAGS = []

View File

@@ -26,6 +26,8 @@ BF_CXX = '/usr'
WITH_BF_STATICCXX = False
BF_CXX_LIB_STATIC = '${BF_CXX}/lib/libstdc++.a'
WITH_BF_AUDASPACE = True
WITH_BF_JACK = False
BF_JACK = '/usr'
BF_JACK_INC = '${BF_JACK}/include/jack'
@@ -206,7 +208,7 @@ WITH_BF_CYCLES = WITH_BF_OIIO and WITH_BF_BOOST
WITH_BF_CYCLES_CUDA_BINARIES = False
BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc'
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
WITH_BF_OPENMP = True
@@ -226,6 +228,14 @@ BF_3DMOUSE_LIB_STATIC = '${BF_3DMOUSE_LIBPATH}/libspnav.a'
#Freestyle
WITH_BF_FREESTYLE = True
WITH_BF_OPENSUBDIV = False
WITH_BF_STATICOPENSUBDIV = False
BF_OPENSUBDIV = '/usr'
BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include'
BF_OPENSUBDIV_LIB = 'osdCPU osdGPU'
BF_OPENSUBDIV_LIB_STATIC = '${BF_OPENSUBDIV_LIBPATH}/libosdGPU.a ${BF_OPENSUBDIV_LIBPATH}/libosdCPU.a'
BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib'
##
CC = 'gcc'
CXX = 'g++'

View File

@@ -23,6 +23,8 @@ BF_FFMPEG_LIBPATH = LIBDIR + '/ffmpeg/lib'
BF_FFMPEG_INC = LIBDIR + '/ffmpeg/include'
BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-55.dll ${BF_FFMPEG_LIBPATH}/avcodec-55.dll ${BF_FFMPEG_LIBPATH}/avdevice-55.dll ${BF_FFMPEG_LIBPATH}/avutil-52.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll'
WITH_BF_AUDASPACE = True
WITH_BF_JACK = False
BF_JACK = LIBDIR + '/jack'
BF_JACK_INC = '${BF_JACK}/include'
@@ -145,7 +147,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib/opencollada'
WITH_BF_CYCLES = True
WITH_BF_CYCLES_CUDA_BINARIES = False
BF_CYCLES_CUDA_NVCC = "" # Path to the NVIDIA CUDA compiler
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
WITH_BF_OIIO = True
BF_OIIO = LIBDIR + '/openimageio'
@@ -166,6 +168,12 @@ BF_BOOST_LIB = 'boost_date_time-mgw46-mt-s-1_49 boost_filesystem-mgw46-mt-s-1_49
BF_BOOST_LIB_INTERNATIONAL = 'boost_locale-mgw46-mt-s-1_49'
BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
WITH_BF_OPENSUBDIV = False
BF_OPENSUBDIV = LIBDIR + '/opensubdiv'
BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include'
BF_OPENSUBDIV_LIB = 'osdCPU osdGPU'
BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib'
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = True
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-msse']

View File

@@ -42,6 +42,8 @@ BF_ICONV_INC = '${BF_ICONV}/include'
BF_ICONV_LIB = 'iconv'
BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
WITH_BF_AUDASPACE = True
WITH_BF_JACK = False
BF_JACK = LIBDIR + '/jack'
BF_JACK_INC = '${BF_JACK}/include ${BF_FFMPEG}/include/msvc'
@@ -208,6 +210,12 @@ BF_RAYOPTIMIZATION_SSE_FLAGS = ['/arch:SSE']
#Freestyle
WITH_BF_FREESTYLE = True
WITH_BF_OPENSUBDIV = True
BF_OPENSUBDIV = LIBDIR + '/opensubdiv'
BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include'
BF_OPENSUBDIV_LIB = 'osdCPU osdGPU'
BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib'
WITH_BF_STATICOPENGL = False
BF_OPENGL_INC = '${BF_OPENGL}/include'
BF_OPENGL_LIBINC = '${BF_OPENGL}/lib'

View File

@@ -22,6 +22,8 @@ BF_FFMPEG_LIBPATH = LIBDIR + '/ffmpeg/lib'
BF_FFMPEG_INC = LIBDIR + '/ffmpeg/include'
BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll ${BF_FFMPEG_LIBPATH}/swresample-0.dll ${BF_FFMPEG_LIBPATH}/xvidcore.dll'
WITH_BF_AUDASPACE = True
WITH_BF_JACK = False
BF_JACK = LIBDIR + '/jack'
BF_JACK_INC = '${BF_JACK}/include'
@@ -144,7 +146,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib/opencollada'
WITH_BF_CYCLES = True
WITH_BF_CYCLES_CUDA_BINARIES = False
BF_CYCLES_CUDA_NVCC = "" # Path to the NVIDIA CUDA compiler
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
WITH_BF_OIIO = True
BF_OIIO = LIBDIR + '/openimageio'
@@ -165,6 +167,12 @@ BF_BOOST_LIB = 'boost_date_time-mgw47-mt-s-1_49 boost_date_time-mgw47-mt-sd-1_49
BF_BOOST_LIB_INTERNATIONAL = ' boost_locale-mgw47-mt-s-1_49 boost_locale-mgw47-mt-sd-1_49'
BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
WITH_BF_OPENSUBDIV = False
BF_OPENSUBDIV = LIBDIR + '/opensubdiv'
BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include'
BF_OPENSUBDIV_LIB = 'osdCPU osdGPU'
BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib'
#Ray trace optimization
WITH_BF_RAYOPTIMIZATION = True
BF_RAYOPTIMIZATION_SSE_FLAGS = ['-mmmx', '-msse', '-msse2']

View File

@@ -55,6 +55,8 @@ BF_SDL_INC = '${BF_SDL}/include'
BF_SDL_LIB = 'SDL2.lib'
BF_SDL_LIBPATH = '${BF_SDL}/lib'
WITH_BF_AUDASPACE = True
WITH_BF_JACK = False
BF_PTHREADS = LIBDIR + '/pthreads'
@@ -212,6 +214,12 @@ BF_RAYOPTIMIZATION_SSE_FLAGS = ['']
#Freestyle
WITH_BF_FREESTYLE = True
WITH_BF_OPENSUBDIV = True
BF_OPENSUBDIV = LIBDIR + '/opensubdiv'
BF_OPENSUBDIV_INC = '${BF_OPENSUBDIV}/include'
BF_OPENSUBDIV_LIB = 'osdCPU osdGPU'
BF_OPENSUBDIV_LIBPATH = '${BF_OPENSUBDIV}/lib'
WITH_BF_STATICOPENGL = False
BF_OPENGL_INC = '${BF_OPENGL}/include'
BF_OPENGL_LIBINC = '${BF_OPENGL}/lib'

View File

@@ -242,6 +242,11 @@ def setup_staticlibs(lenv):
if lenv['WITH_BF_STATIC3DMOUSE']:
statlibs += Split(lenv['BF_3DMOUSE_LIB_STATIC'])
if lenv['WITH_BF_OPENSUBDIV']:
libincs += Split(lenv['BF_OPENSUBDIV_LIBPATH'])
if lenv['WITH_BF_STATICOPENSUBDIV']:
statlibs += Split(lenv['BF_OPENSUBDIV_LIB_STATIC'])
# setting this last so any overriding of manually libs could be handled
if lenv['OURPLATFORM'] not in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross', 'win64-mingw'):
# We must remove any previous items defining this path, for same reason stated above!
@@ -344,6 +349,13 @@ def setup_syslibs(lenv):
if not lenv['WITH_BF_STATICPNG']:
syslibs += Split(lenv['BF_PNG_LIB'])
if lenv['WITH_BF_OPENSUBDIV']:
if not lenv['WITH_BF_STATICOPENSUBDIV']:
if lenv['BF_DEBUG'] and lenv['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'):
syslibs += [osdlib+'_d' for osdlib in Split(lenv['BF_OPENSUBDIV_LIB'])]
else:
syslibs += Split(lenv['BF_OPENSUBDIV_LIB'])
# Hack to pass OSD libraries to linker before extern_{clew,cuew}
for syslib in create_blender_liblist(lenv, 'system'):
syslibs.append(os.path.basename(syslib))
@@ -764,7 +776,7 @@ def AppIt(target=None, source=None, env=None):
commands.getoutput(cmd)
cmd = 'cp -R %s/kernel/*.h %s/kernel/*.cl %s/kernel/*.cu %s/kernel/' % (croot, croot, croot, cinstalldir)
commands.getoutput(cmd)
cmd = 'cp -R %s/kernel/svm %s/kernel/closure %s/kernel/geom %s/util/util_color.h %s/util/util_half.h %s/util/util_math.h %s/util/util_math_fast.h %s/util/util_transform.h %s/util/util_types.h %s/kernel/' % (croot, croot, croot, croot, croot, croot, croot, croot, croot, cinstalldir)
cmd = 'cp -R %s/kernel/svm %s/kernel/closure %s/kernel/geom %s/kernel/split %s/kernel/kernels %s/util/util_color.h %s/util/util_half.h %s/util/util_math.h %s/util/util_math_fast.h %s/util/util_transform.h %s/util/util_types.h %s/util/util_atomic.h %s/kernel/' % (croot, croot, croot, croot, croot, croot, croot, croot, croot, croot, croot, croot, cinstalldir)
commands.getoutput(cmd)
cmd = 'cp -R %s/../intern/cycles/kernel/*.cubin %s/lib/' % (builddir, cinstalldir)
commands.getoutput(cmd)

View File

@@ -107,6 +107,7 @@ def print_arguments(args, bc):
def validate_arguments(args, bc):
opts_list = [
'WITH_BF_FREESTYLE', 'WITH_BF_PYTHON', 'WITH_BF_PYTHON_SAFETY', 'WITH_BF_PYTHON_SECURITY', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'BF_PYTHON_LIBPATH_ARCH', 'WITH_BF_STATICPYTHON', 'WITH_OSX_STATICPYTHON', 'BF_PYTHON_LIB_STATIC', 'BF_PYTHON_DLL', 'BF_PYTHON_ABI_FLAGS',
'WITH_BF_AUDASPACE', 'BF_AUDASPACE_C_INC', 'BF_AUDASPACE_PY_INC', 'BF_AUDASPACE_DEF',
'WITH_BF_OPENAL', 'BF_OPENAL', 'BF_OPENAL_INC', 'BF_OPENAL_LIB', 'BF_OPENAL_LIBPATH', 'WITH_BF_STATICOPENAL', 'BF_OPENAL_LIB_STATIC',
'WITH_BF_SDL', 'BF_SDL', 'BF_SDL_INC', 'BF_SDL_LIB', 'BF_SDL_LIBPATH', 'WITH_BF_SDL_DYNLOAD',
'WITH_BF_JACK', 'BF_JACK', 'BF_JACK_INC', 'BF_JACK_LIB', 'BF_JACK_LIBPATH', 'WITH_BF_JACK_DYNLOAD',
@@ -182,7 +183,8 @@ def validate_arguments(args, bc):
'WITH_BF_BOOST', 'WITH_BF_STATICBOOST', 'BF_BOOST', 'BF_BOOST_INC', 'BF_BOOST_LIB', 'BF_BOOST_LIB_INTERNATIONAL', 'BF_BOOST_LIB_STATIC', 'BF_BOOST_LIBPATH',
'WITH_BF_LIBMV', 'WITH_BF_LIBMV_SCHUR_SPECIALIZATIONS',
'WITH_BF_CYCLES_OSL', 'WITH_BF_STATICOSL', 'BF_OSL', 'BF_OSL_INC', 'BF_OSL_LIB', 'BF_OSL_LIBPATH', 'BF_OSL_LIB_STATIC', 'BF_OSL_COMPILER',
'WITH_BF_LLVM', 'WITH_BF_STATICLLVM', 'BF_LLVM', 'BF_LLVM_LIB', 'BF_LLVM_LIBPATH', 'BF_LLVM_LIB_STATIC', 'BF_PROGRAM_LINKFLAGS'
'WITH_BF_LLVM', 'WITH_BF_STATICLLVM', 'BF_LLVM', 'BF_LLVM_LIB', 'BF_LLVM_LIBPATH', 'BF_LLVM_LIB_STATIC', 'BF_PROGRAM_LINKFLAGS',
'WITH_BF_OPENSUBDIV', 'WITH_BF_STATICOPENSUBDIV', 'BF_OPENSUBDIV', 'BF_OPENSUBDIV_INC', 'BF_OPENSUBDIV_LIB', 'BF_OPENSUBDIV_LIBPATH', 'BF_OPENSUBDIV_LIB_STATIC'
]
# Have options here that scons expects to be lists
@@ -297,6 +299,11 @@ def read_opts(env, cfg, args):
('BF_OPENAL_LIBPATH', 'Path to OpenAL library', ''),
(BoolVariable('WITH_BF_STATICOPENAL', 'Staticly link to openal', False)),
(BoolVariable('WITH_BF_AUDASPACE', 'Build with audaspace if true', True)),
('BF_AUDASPACE_C_INC', 'audaspace-c include path', ''),
('BF_AUDASPACE_PY_INC', 'audaspace-py include path', ''),
('BF_AUDASPACE_DEF', 'audaspace defines', ''),
(BoolVariable('WITH_BF_SDL', 'Use SDL if true', False)),
('BF_SDL', 'SDL base path', ''),
('BF_SDL_INC', 'SDL include path', ''),
@@ -656,6 +663,14 @@ def read_opts(env, cfg, args):
('BF_PROGRAM_LINKFLAGS', 'Link flags applied only to final binaries (blender and blenderplayer, not makesrna/makesdna)', ''),
(BoolVariable('WITH_BF_OPENSUBDIV', 'Build with OpenSubdiv library', False)),
(BoolVariable('WITH_BF_STATICOPENSUBDIV', 'Staticly link to OpenColorIO', False)),
('BF_OPENSUBDIV', 'OpenSubdiv root path', ''),
('BF_OPENSUBDIV_INC', 'OpenSubdiv include path', ''),
('BF_OPENSUBDIV_LIB', 'OpenSubdiv library', ''),
('BF_OPENSUBDIV_LIBPATH', 'OpenSubdiv library path', ''),
('BF_OPENSUBDIV_LIB_STATIC', 'OpenSubdiv static library', ''),
(BoolVariable('WITH_BF_CPP11', '"Build with C++11 standard enabled, for development use only!', False)),
(BoolVariable('WITH_BF_LEGACY_DEPSGRAPH', 'Build Blender with legacy dependency graph', True)),

View File

@@ -1,104 +0,0 @@
Blender CMake build system
============================
Contents
---------------
1. Introduction
2. Obtaining CMake
3. Building Blender
4. Generic Setup
5. Configuring the build after SVN updates
1. Introduction
---------------
This document describes general usage of the new CMake scripts. The
inner workings will be described in blender-cmake-dev.txt (TODO).
2. Obtaining CMake
------------------
CMake for can either be downloaded using your favorite package manager
or is also available from the CMake website at http://www.cmake.org
The website also contains some documentation on CMake usage but I found
the man page alone pretty helpful.
3. Building Blender
-------------------
Building Blender requires obtaining a compiler, library dependencies,
and correct setup depending on the system. For details on how to set
up a build on various operating systems, see the wiki documentation:
http://wiki.blender.org/index.php/Dev:Doc/Building_Blender
4. Generic Setup
----------------
CMake allows one to generate the build project files and binary objects
outside the source tree which can be pretty handy in working and experimenting
with different Blender configurations (Audio/NoAudio, GameEngine/NoGameEngine etc.)
while maintaining a clean source tree. It also makes it possible to generate files
for different build systems on the same source tree. This also has benefits for
general SVN management for the developer as patches and submit logs are much cleaner.
Create a directory outside the blender source tree where you would like to build
Blender (from now on called $BLENDERBUILD). On the commandline you can then run
the cmake command to generate your initial build files. First just run 'cmake' which
will inform you what the available generators are. Thn you can run
'cmake -G generator $BLENDERSOURCE' to generate the build files. Here is an example
of all this for Xcode:
% mkdir $BLENDERBUILD
% cd $BLENDERBUILD
% cmake
...
...
--version [file] = Show program name/version banner and exit.
Generators
The following generators are available on this platform:
KDevelop3 = Generates KDevelop 3 project files.
Unix Makefiles = Generates standard UNIX makefiles.
Xcode = Generate XCode project files.
% cmake -G Xcode $BLENDERSOURCE
...
...
-- Configuring blender
-- Configuring blenderplayer
-- Configuring done
-- Generating done
-- Build files have been written to: $BLENDERBUILD
This will generate the build files with default values. Specific features can
be enabled or disabled by running the ccmake "GUI" from $BLENDERBUILD as follows:
% ccmake $BLENDERSOURCE
A number of options appear which can be changed depending on your needs and
available dependencies (e.g. setting WITH_OPENEXR to OFF will disable support
for OpenEXR). It will also allow you to override default and detected paths
(e.g. Python directories) and compile and link flags. When you are satisfied
used ccmake to re-configure the build files and exit.
It is also possible to use the commandline of 'cmake' to override certain
of these settings.
5. Configuring the build after SVN updates
------------------------------------------
The $BLENDERBUILD directory maintains a file called CMakeCache.txt which
remembers the initial run's settings for subsequent generation runs. After
SVN updates that contain changes to the build system, rebuilding Blender will
automatically invoke CMake to regenerate the CMakeCache.txt and other files
as needed.
/Jacques Beaurain (jbinto)

View File

@@ -7,7 +7,7 @@
* These pages document the source code of blender.
*
* \subsection implinks Important Links
* - <a href="http://developer.blender.org">developer.blender.org</a> with bug tracker
* - <a href="http://developer.blender.org">developer.blender.org</a> with bug tracker.
* - <a href="http://wiki.blender.org/index.php/Dev:Contents">Development documents</a> on our wiki.
*
* \subsection blother Other

View File

@@ -11,7 +11,6 @@
/** \defgroup bmesh BMesh
* \ingroup blender
*/
/** \defgroup texture Texturing */
/** \defgroup compositor Compositing */
/** \defgroup python Python
@@ -322,7 +321,7 @@
* \ingroup gui
*/
/** \defgroup externformats external formats */
/** \defgroup externformats External Formats */
/** \defgroup collada COLLADA
* \ingroup externformats

View File

@@ -2,8 +2,8 @@
Texture Replacement
+++++++++++++++++++
Example of how to replace a texture in game with an external image.
createTexture() and removeTexture() are to be called from a module Python
Controller.
``createTexture()`` and ``removeTexture()`` are to be called from a
module Python Controller.
"""
from bge import logic
from bge import texture

View File

@@ -1,7 +1,8 @@
"""
Basic Video Playback
++++++++++++++++++++
Example of how to replace a texture in game with a video. It needs to run everyframe
Example of how to replace a texture in game with a video. It needs to run
everyframe.
"""
import bge
from bge import texture

View File

@@ -31,7 +31,7 @@ class SimpleMouseOperator(bpy.types.Operator):
y = bpy.props.IntProperty()
def execute(self, context):
# rather then printing, use the report function,
# rather than printing, use the report function,
# this way the message appears in the header,
self.report({'INFO'}, "Mouse coords are %d %d" % (self.x, self.y))
return {'FINISHED'}

View File

@@ -1,7 +1,7 @@
"""
Note that when keying data paths which contain nested properties this must be
done from the :class:`ID` subclass, in this case the :class:`Armature` rather
then the bone.
than the bone.
"""
import bpy

View File

@@ -0,0 +1,47 @@
Application Data (bge.app)
==========================
Module to access application values that remain unchanged during runtime.
.. module:: bge.app
.. data:: version
The Blender/BGE version as a tuple of 3 ints, eg. (2, 75, 1).
.. note:: Version tuples can be compared simply with (in)equality symbols;
for example, ``(2, 74, 5) <= (2, 75, 0)`` returns True (lexical order).
:type: tuple of three ints
.. data:: version_string
The Blender/BGE version formatted as a string, eg. "2.75 (sub 1)".
:type: str
.. data:: version_char
The Blender/BGE version character (for minor releases).
:type: str
.. data:: has_texture_ffmpeg
True if the BGE has been built with FFmpeg support, enabling use of :class:`~bge.texture.ImageFFmpeg` and :class:`~bge.texture.VideoFFmpeg`.
:type: bool
.. data:: has_joystick
True if the BGE has been built with joystick support.
:type: bool
.. data:: has_physics
True if the BGE has been built with physics support.
:type: bool

View File

@@ -4,75 +4,77 @@ Physics Constraints (bge.constraints)
.. module:: bge.constraints
.. literalinclude:: ../examples/bge.constraints.py
:language: rest
:lines: 2-4
Examples
--------
.. include:: ../examples/bge.constraints.py
:start-line: 1
:end-line: 4
.. literalinclude:: ../examples/bge.constraints.py
:lines: 6-
.. function:: createConstraint(physicsid_1, physicsid_2, constraint_type, pivot_X, pivot_y, pivot_z, axis_x, axis_y, axis_z, flag)
Functions
---------
.. function:: createConstraint( \
physicsid_1, physicsid_2, constraint_type, \
pivot_x=0.0, pivot_y=0.0, pivot_z=0.0, \
axis_x=0.0, axis_y=0.0, axis_z=0.0, flag=0)
Creates a constraint.
Constraints types:
- :class:`POINTTOPOINT_CONSTRAINT`
- :class:`LINEHINGE_CONSTRAINT`
- :class:`ANGULAR_CONSTRAINT`
- :class:`CONETWIST_CONSTRAINT`
- :class:`VEHICLE_CONSTRAINT`
- :class:`GENERIC_6DOF_CONSTRAINT`
:arg physicsid_1: the physics id of the first object in constraint.
:arg physicsid_1: The physics id of the first object in constraint.
:type physicsid_1: int
:arg physicsid_2: the physics id of the second object in constraint.
:arg physicsid_2: The physics id of the second object in constraint.
:type physicsid_2: int
:arg constrainttype: the type of the constraint.
:type constrainttype: int
:arg constraint_type: The type of the constraint, see `Create Constraint Constants`_.
:arg pivot_X: pivot X position (optional).
:type pivot_X: float
:type constraint_type: int
:arg pivot_Y: pivot Y position (optional).
:type pivot_Y: float
:arg pivot_x: Pivot X position. (optional)
:type pivot_x: float
:arg pivot_Z: pivot Z position (optional).
:type pivot_Z: float
:arg pivot_y: Pivot Y position. (optional)
:type pivot_y: float
:arg axis_X: X axis angle in degrees (optional).
:type axis_X: float
:arg pivot_z: Pivot Z position. (optional)
:type pivot_z: float
:arg axis_Y: Y axis angle in degrees (optional).
:type axis_Y: float
:arg axis_x: X axis angle in degrees. (optional)
:type axis_x: float
:arg axis_Z: Z axis angle in degrees (optional).
:type axis_Z: float
:arg axis_y: Y axis angle in degrees. (optional)
:type axis_y: float
:arg flag: 128 to disable collision between linked bodies (optional).
:arg axis_z: Z axis angle in degrees. (optional)
:type axis_z: float
:arg flag: 128 to disable collision between linked bodies. (optional)
:type flag: int
:return: a constraint wrapper.
:rtype: :class:`bge.types.KX_ConstraintWrapper`
.. attribute:: error
Symbolic constant string that indicates error.
:return: A constraint wrapper.
:rtype: :class:`~bge.types.KX_ConstraintWrapper`
.. function:: exportBulletFile(filename)
export a .bullet file
Exports a file representing the dynamics world (usually using ``.bullet`` extension).
:arg filename: File name
:type filename: string
See `Bullet binary serialization <http://bulletphysics.org/mediawiki-1.5.8/index.php/Bullet_binary_serialization>`__.
:arg filename: File path.
:type filename: str
.. function:: getAppliedImpulse(constraintId)
:arg constraintId: The id of the constraint.
:type constraintId: int
:return: the most recent applied impulse.
:return: The most recent applied impulse.
:rtype: float
.. function:: getVehicleConstraint(constraintId)
@@ -80,16 +82,16 @@ Physics Constraints (bge.constraints)
:arg constraintId: The id of the vehicle constraint.
:type constraintId: int
:return: a vehicle constraint object.
:rtype: :class:`bge.types.KX_VehicleWrapper`
:return: A vehicle constraint object.
:rtype: :class:`~bge.types.KX_VehicleWrapper`
.. function:: getCharacter(gameobj)
:arg gameobj: The game object with the character physics.
:type gameobj: :class:`bge.types.KX_GameObject`
:type gameobj: :class:`~bge.types.KX_GameObject`
:return: character wrapper
:rtype: :class:`bge.types.KX_CharacterWrapper`
:return: Character wrapper.
:rtype: :class:`~bge.types.KX_CharacterWrapper`
.. function:: removeConstraint(constraintId)
@@ -143,23 +145,8 @@ Physics Constraints (bge.constraints)
Sets the debug mode.
Debug modes:
- :class:`DBG_NODEBUG`
- :class:`DBG_DRAWWIREFRAME`
- :class:`DBG_DRAWAABB`
- :class:`DBG_DRAWFREATURESTEXT`
- :class:`DBG_DRAWCONTACTPOINTS`
- :class:`DBG_NOHELPTEXT`
- :class:`DBG_DRAWTEXT`
- :class:`DBG_PROFILETIMINGS`
- :class:`DBG_ENABLESATCOMPARISION`
- :class:`DBG_DISABLEBULLETLCP`
- :class:`DBG_ENABLECCD`
- :class:`DBG_DRAWCONSTRAINTS`
- :class:`DBG_DRAWCONSTRAINTLIMITS`
- :class:`DBG_FASTWIREFRAME`
:arg mode: The new debug mode, see `Debug Mode Constants`_.
:arg mode: The new debug mode.
:type mode: int
.. function:: setGravity(x, y, z)
@@ -178,7 +165,8 @@ Physics Constraints (bge.constraints)
.. function:: setLinearAirDamping(damping)
.. note::
Not implemented.
Not implemented
Sets the linear air damping for rigidbodies.
@@ -238,144 +226,111 @@ Physics Constraints (bge.constraints)
.. function:: setUseEpa(epa)
Not implemented.
.. note::
Not implemented
Constants
+++++++++
.. attribute:: error
Symbolic constant string that indicates error.
:type: str
Debug Mode Constants
^^^^^^^^^^^^^^^^^^^^
Debug mode to be used with :func:`setDebugMode`.
.. data:: DBG_NODEBUG
.. note::
Debug mode to be used with function :class:`setDebugMode`
No debug.
.. data:: DBG_DRAWWIREFRAME
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw wireframe in debug.
.. data:: DBG_DRAWAABB
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw Axis Aligned Bounding Box in debug.
.. data:: DBG_DRAWFREATURESTEXT
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw freatures text in debug.
Draw features text in debug.
.. data:: DBG_DRAWCONTACTPOINTS
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw contact points in debug.
.. data:: DBG_NOHELPTEXT
.. note::
Debug mode to be used with function :class:`setDebugMode`
Debug without help text.
.. data:: DBG_DRAWTEXT
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw text in debug.
.. data:: DBG_PROFILETIMINGS
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw profile timings in debug.
.. data:: DBG_ENABLESATCOMPARISION
.. note::
Debug mode to be used with function :class:`setDebugMode`
Enable sat comparision in debug.
.. data:: DBG_DISABLEBULLETLCP
.. note::
Debug mode to be used with function :class:`setDebugMode`
Disable Bullet LCP.
.. data:: DBG_ENABLECCD
.. note::
Debug mode to be used with function :class:`setDebugMode`
Enable Continous Colision Detection in debug.
Enable Continous Collision Detection in debug.
.. data:: DBG_DRAWCONSTRAINTS
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw constraints in debug.
.. data:: DBG_DRAWCONSTRAINTLIMITS
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw constraint limits in debug.
.. data:: DBG_FASTWIREFRAME
.. note::
Debug mode to be used with function :class:`setDebugMode`
Draw a fast wireframe in debug.
.. data:: POINTTOPOINT_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
Create Constraint Constants
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Constraint type to be used with :func:`createConstraint`.
.. data:: POINTTOPOINT_CONSTRAINT
.. to do
.. data:: LINEHINGE_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do
.. data:: ANGULAR_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do
.. data:: CONETWIST_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do
.. data:: VEHICLE_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do
.. data:: GENERIC_6DOF_CONSTRAINT
.. note::
Constraint type to be used with function :class:`createConstraint`
.. to do

View File

@@ -894,6 +894,8 @@ Various
2D Filter
---------
.. _Two-D-FilterActuator-mode:
.. data:: RAS_2DFILTER_BLUR
:value: 2
@@ -1288,5 +1290,3 @@ See :class:`bge.types.KX_StateActuator.operation`
Add bits to state mask
:value: 3
.. _Two-D-FilterActuator-mode:

File diff suppressed because it is too large Load Diff

View File

@@ -7,11 +7,66 @@ base class --- :class:`PyObjectPlus`
.. class:: KX_BlenderMaterial(PyObjectPlus)
KX_BlenderMaterial
This is the interface to materials in the game engine.
Materials define the render state to be applied to mesh objects.
The example below shows a simple GLSL shader setup allowing to dynamically mix two texture channels
in a material. All materials of the object executing this script should have two textures using
separate UV maps in the two first texture channels.
The code works for both Multitexture and GLSL rendering modes.
.. code-block:: python
from bge import logic
vertex_shader = """
void main(void)
{
// simple projection of the vertex position to view space
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// coordinate of the 1st texture channel
gl_TexCoord[0] = gl_MultiTexCoord0;
// coordinate of the 2nd texture channel
gl_TexCoord[1] = gl_MultiTexCoord1;
}
"""
fragment_shader ="""
uniform sampler2D texture_0;
uniform sampler2D texture_1;
uniform float factor;
void main(void)
{
vec4 color_0 = texture2D(texture_0, gl_TexCoord[0].st);
vec4 color_1 = texture2D(texture_1, gl_TexCoord[1].st);
gl_FragColor = mix(color_0, color_1, factor);
}
"""
object = logic.getCurrentController().owner
for mesh in object.meshes:
for material in mesh.materials:
shader = material.getShader()
if shader is not None:
if not shader.isValid():
shader.setSource(vertex_shader, fragment_shader, True)
# get the first texture channel of the material
shader.setSampler('texture_0', 0)
# get the second texture channel of the material
shader.setSampler('texture_1', 1)
# pass another uniform to the shader
shader.setUniform1f('factor', 0.3)
.. attribute:: shader
The materials shader.
The material's shader.
:type: :class:`BL_Shader`
@@ -34,39 +89,83 @@ base class --- :class:`PyObjectPlus`
:return: the material's shader
:rtype: :class:`BL_Shader`
.. attribute:: alpha
The material's alpha transparency.
:type: float between 0.0 and 1.0 inclusive
.. attribute:: hardness
How hard (sharp) the material's specular reflection is.
:type: integer between 1 and 511 inclusive
.. attribute:: emit
Amount of light to emit.
:type: float between 0.0 and 2.0 inclusive
.. attribute:: specularIntensity
How intense (bright) the material's specular reflection is.
:type: float between 0.0 and 1.0 inclusive
.. attribute:: diffuseIntensity
The material's amount of diffuse reflection.
:type: float between 0.0 and 1.0 inclusive
.. attribute:: specularColor
The material's specular color.
:type: :class:`mathutils.Color`
.. attribute:: diffuseColor
The material's diffuse color.
:type: :class:`mathutils.Color`
.. method:: setBlending(src, dest)
Set the pixel color arithmetic functions.
:arg src: Specifies how the red, green, blue, and alpha source blending factors are computed.
:type src: Value in...
:arg src: Specifies how the red, green, blue, and alpha source blending factors are computed, one of...
* :data:`~bgl.GL_ZERO`
* :data:`~bgl.GL_ONE`
* :data:`~bgl.GL_SRC_COLOR`
* :data:`~bgl.GL_ONE_MINUS_SRC_COLOR`
* :data:`~bgl.GL_DST_COLOR`
* :data:`~bgl.GL_ONE_MINUS_DST_COLOR`
* :data:`~bgl.GL_SRC_ALPHA`
* :data:`~bgl.GL_ONE_MINUS_SRC_ALPHA`
* :data:`~bgl.GL_DST_ALPHA`
* :data:`~bgl.GL_ONE_MINUS_DST_ALPHA`
* :data:`~bgl.GL_SRC_ALPHA_SATURATE`
:type src: int
* GL_ZERO,
* GL_ONE,
* GL_SRC_COLOR,
* GL_ONE_MINUS_SRC_COLOR,
* GL_DST_COLOR,
* GL_ONE_MINUS_DST_COLOR,
* GL_SRC_ALPHA,
* GL_ONE_MINUS_SRC_ALPHA,
* GL_DST_ALPHA,
* GL_ONE_MINUS_DST_ALPHA,
* GL_SRC_ALPHA_SATURATE
:arg dest: Specifies how the red, green, blue, and alpha destination blending factors are computed.
:type dest: Value in...
* GL_ZERO
* GL_ONE
* GL_SRC_COLOR
* GL_ONE_MINUS_SRC_COLOR
* GL_DST_COLOR
* GL_ONE_MINUS_DST_COLOR
* GL_SRC_ALPHA
* GL_ONE_MINUS_SRC_ALPHA
* GL_DST_ALPHA
* GL_ONE_MINUS_DST_ALPHA
* GL_SRC_ALPHA_SATURATE
:arg dest: Specifies how the red, green, blue, and alpha destination blending factors are computed, one of...
* :data:`~bgl.GL_ZERO`
* :data:`~bgl.GL_ONE`
* :data:`~bgl.GL_SRC_COLOR`
* :data:`~bgl.GL_ONE_MINUS_SRC_COLOR`
* :data:`~bgl.GL_DST_COLOR`
* :data:`~bgl.GL_ONE_MINUS_DST_COLOR`
* :data:`~bgl.GL_SRC_ALPHA`
* :data:`~bgl.GL_ONE_MINUS_SRC_ALPHA`
* :data:`~bgl.GL_DST_ALPHA`
* :data:`~bgl.GL_ONE_MINUS_DST_ALPHA`
* :data:`~bgl.GL_SRC_ALPHA_SATURATE`
:type dest: int
.. method:: getMaterialIndex()

View File

@@ -51,6 +51,18 @@ base class --- :class:`KX_GameObject`
:type: float
.. attribute:: shift_x
The camera's horizontal shift.
:type: float
.. attribute:: shift_y
The camera's vertical shift.
:type: float
.. attribute:: perspective
True if this camera has a perspective transform, False for an orthographic projection.

View File

@@ -137,7 +137,30 @@ base class --- :class:`SCA_IObject`
.. note::
A value of 0.0 disables this option (rather then setting it stationary).
A value of 0.0 disables this option (rather than setting it stationary).
.. attribute:: angularVelocityMin
Enforces the object keeps rotating at a minimum velocity. A value of 0.0 disables this.
:type: non-negative float
.. note::
Applies to dynamic and rigid body objects only.
While objects are stationary the minimum velocity will not be applied.
.. attribute:: angularVelocityMax
Clamp the maximum angular velocity to prevent objects rotating beyond a set speed.
A value of 0.0 disables clamping; it does not stop rotation.
:type: non-negative float
.. note::
Applies to dynamic and rigid body objects only.
.. attribute:: localInertia
@@ -949,6 +972,16 @@ base class --- :class:`SCA_IObject`
:return: The current frame of the action
:rtype: float
.. method:: getActionName(layer=0)
Gets the name of the current action playing in the supplied layer.
:arg layer: The layer that you want to get the action name from.
:type layer: integer
:return: The name of the current action
:rtype: string
.. method:: setActionFrame(frame, layer=0)
Set the current frame of the action playing in the supplied layer.

View File

@@ -51,7 +51,7 @@ base class --- :class:`SCA_IObject`
.. attribute:: materials
:type: list of :class:`KX_BlenderMaterial` or :class:`KX_PolygonMaterial` types
:type: list of :class:`KX_BlenderMaterial` type
.. attribute:: numPolygons

View File

@@ -23,7 +23,7 @@ base class --- :class:`SCA_IObject`
The material of the polygon.
:type: :class:`KX_PolygonMaterial` or :class:`KX_BlenderMaterial`
:type: :class:`KX_BlenderMaterial`
.. attribute:: texture_name
@@ -84,7 +84,7 @@ base class --- :class:`SCA_IObject`
.. method:: getMaterial()
:return: The polygon material
:rtype: :class:`KX_PolygonMaterial` or :class:`KX_BlenderMaterial`
:rtype: :class:`KX_BlenderMaterial`
.. method:: getTextureName()

View File

@@ -1,250 +0,0 @@
KX_PolygonMaterial(PyObjectPlus)
================================
.. module:: bge.types
base class --- :class:`PyObjectPlus`
.. class:: KX_PolygonMaterial(PyObjectPlus)
This is the interface to materials in the game engine.
Materials define the render state to be applied to mesh objects.
.. warning::
Some of the methods/variables are CObjects. If you mix these up, you will crash blender.
.. code-block:: python
from bge import logic
vertex_shader = """
void main(void)
{
// original vertex position, no changes
gl_Position = ftransform();
// coordinate of the 1st texture channel
gl_TexCoord[0] = gl_MultiTexCoord0;
// coordinate of the 2nd texture channel
gl_TexCoord[1] = gl_MultiTexCoord1;
}
"""
fragment_shader ="""
uniform sampler2D color_0;
uniform sampler2D color_1;
uniform float factor;
void main(void)
{
vec4 color_0 = texture2D(color_0, gl_TexCoord[0].st);
vec4 color_1 = texture2D(color_1, gl_TexCoord[1].st);
gl_FragColor = mix(color_0, color_1, factor);
}
"""
object = logic.getCurrentController().owner
object = cont.owner
for mesh in object.meshes:
for material in mesh.materials:
shader = material.getShader()
if shader != None:
if not shader.isValid():
shader.setSource(vertex_shader, fragment_shader, True)
# get the first texture channel of the material
shader.setSampler('color_0', 0)
# get the second texture channel of the material
shader.setSampler('color_1', 1)
# pass another uniform to the shader
shader.setUniform1f('factor', 0.3)
.. attribute:: texture
Texture name.
:type: string (read-only)
.. attribute:: gl_texture
OpenGL texture handle (eg for glBindTexture(GL_TEXTURE_2D, gl_texture).
:type: integer (read-only)
.. attribute:: material
Material name.
:type: string (read-only)
.. attribute:: tface
Texture face properties.
:type: CObject (read-only)
.. attribute:: tile
Texture is tiling.
:type: boolean
.. attribute:: tilexrep
Number of tile repetitions in x direction.
:type: integer
.. attribute:: tileyrep
Number of tile repetitions in y direction.
:type: integer
.. attribute:: drawingmode
Drawing mode for the material.
- 2 (drawingmode & 4) Textured
- 4 (drawingmode & 16) Light
- 14 (drawingmode & 16384) 3d Polygon Text.
:type: bitfield
.. attribute:: transparent
This material is transparent. All meshes with this
material will be rendered after non transparent meshes from back
to front.
:type: boolean
.. attribute:: zsort
Transparent polygons in meshes with this material will be sorted back to
front before rendering.
Non-Transparent polygons will be sorted front to back before rendering.
:type: boolean
.. attribute:: diffuse
The diffuse color of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0].
:type: list [r, g, b]
.. attribute:: specular
The specular color of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0].
:type: list [r, g, b]
.. attribute:: shininess
The shininess (specular exponent) of the material. 0.0 <= shininess <= 128.0.
:type: float
.. attribute:: specularity
The amount of specular of the material. 0.0 <= specularity <= 1.0.
:type: float
.. method:: updateTexture(tface, rasty)
Updates a realtime animation.
:arg tface: Texture face (eg mat.tface)
:type tface: CObject
:arg rasty: Rasterizer
:type rasty: CObject
.. method:: setTexture(tface)
Sets texture render state.
:arg tface: Texture face
:type tface: CObject
.. code-block:: python
mat.setTexture(mat.tface)
.. method:: activate(rasty, cachingInfo)
Sets material parameters for this object for rendering.
Material Parameters set:
#. Texture
#. Backface culling
#. Line drawing
#. Specular Colour
#. Shininess
#. Diffuse Colour
#. Polygon Offset.
:arg rasty: Rasterizer instance.
:type rasty: CObject
:arg cachingInfo: Material cache instance.
:type cachingInfo: CObject
.. method:: setCustomMaterial(material)
Sets the material state setup object.
Using this method, you can extend or completely replace the gameengine material
to do your own advanced multipass effects.
Use this method to register your material class. Instead of the normal material,
your class's activate method will be called just before rendering the mesh.
This should setup the texture, material, and any other state you would like.
It should return True to render the mesh, or False if you are finished. You should
clean up any state Blender does not set before returning False.
Activate Method Definition:
.. code-block:: python
def activate(self, rasty, cachingInfo, material):
:arg material: The material object.
:type material: instance
.. code-block:: python
class PyMaterial:
def __init__(self):
self.pass_no = -1
def activate(self, rasty, cachingInfo, material):
# Activate the material here.
#
# The activate method will be called until it returns False.
# Every time the activate method returns True the mesh will
# be rendered.
#
# rasty is a CObject for passing to material.updateTexture()
# and material.activate()
# cachingInfo is a CObject for passing to material.activate()
# material is the KX_PolygonMaterial instance this material
# was added to
# default material properties:
self.pass_no += 1
if self.pass_no == 0:
material.activate(rasty, cachingInfo)
# Return True to do this pass
return True
# clean up and return False to finish.
self.pass_no = -1
return False
# Create a new Python Material and pass it to the renderer.
mat.setCustomMaterial(PyMaterial())

View File

@@ -1,4 +1,4 @@
KX_WordlInfo(PyObjectPlus)
KX_WorldInfo(PyObjectPlus)
=============================
.. module:: bge.types
@@ -7,7 +7,7 @@ base class --- :class:`PyObjectPlus`
.. class:: KX_WorldInfo(PyObjectPlus)
A wolrd object.
A world object.
.. code-block:: python

View File

@@ -7,7 +7,7 @@ base class --- :class:`SCA_IActuator`
.. class:: SCA_2DFilterActuator(SCA_IActuator)
Create, enable and disable 2D filters
Create, enable and disable 2D filters.
The following properties don't have an immediate effect.
You must active the actuator to get the result.
@@ -29,7 +29,7 @@ base class --- :class:`SCA_IActuator`
.. attribute:: mode
Type of 2D filter, use one of :ref:`these constants <Two-D-FilterActuator-mode>`
Type of 2D filter, use one of :ref:`these constants <Two-D-FilterActuator-mode>`.
:type: integer

View File

@@ -121,7 +121,7 @@ Here are some more complex examples:
bpy.context.scene.render.layers["RenderLayer"].samples
# access to the current weight paint brush size
bpy.context.tool_settings.weight_paint.brush.size
bpy.context.tool_settings.weight_paint.brush.size
# check if the window is fullscreen
bpy.context.window.screen.show_fullscreen
@@ -141,15 +141,16 @@ When starting out scripting you will often run into the problem where you're not
There are a few ways to do this.
- Use the Python console's auto-complete to inspect properties. *This can be hit-and-miss but has the advantage
- Use the Python console's auto-complete to inspect properties.
*This can be hit-and-miss but has the advantage
that you can easily see the values of properties and assign them to interactively see the results.*
- Copy the Data-Path from the user interface. *Explained further in :ref:`Copy Data Path <info_data_path_copy>`*
- Using the documentation to follow references. *Explained further in :ref:`Indirect Data Access <info_data_path_indirect>`*
- Copy the Data-Path from the user interface.
*Explained further in :ref:`Copy Data Path <info_data_path_copy>`*
- Using the documentation to follow references.
*Explained further in :ref:`Indirect Data Access <info_data_path_indirect>`*
.. _info_data_path_copy
.. _info_data_path_copy:
Copy Data Path
--------------
@@ -172,7 +173,8 @@ you won't be doing collection look-ups on every access and typically you'll want
then access each :class:`bpy.types.ID` instance by name.
Type in the ID path into a Python console :mod:`bpy.context.active_object`. Include the trailing dot and don't hit "enter", yet.
Type in the ID path into a Python console :mod:`bpy.context.active_object`.
Include the trailing dot and don't hit "enter", yet.
Now right-click on the button and select **Copy Data Path**, then paste the result into the console.
@@ -191,7 +193,7 @@ Hit "enter" and you'll get the current value of 1. Now try changing the value to
You can see the value update in the Subdivision-Surface modifier's UI as well as the cube.
.. _info_data_path_indirect
.. _info_data_path_indirect:
Indirect Data Access
--------------------
@@ -201,32 +203,24 @@ For this example we'll go over something more involved, showing the steps to acc
Lets say we want to access the texture of a brush via Python, to adjust its ``contrast`` for example.
- Start in the default scene and enable 'Sculpt' mode from the 3D-View header.
- From the toolbar expand the **Texture** panel and add a new texture.
*Notice the texture button its self doesn't have very useful links (you can check the tool-tips).*
- The contrast setting isn't exposed in the sculpt toolbar, so view the texture in the properties panel...
- In the properties button select the Texture context.
- Select the Brush icon to show the brush texture.
- Expand the **Colors** panel to locate the **Contrast** button.
- Right click on the contrast button and select **Online Python Reference** This takes you to ``bpy.types.Texture.contrast``
- Now we can see that ``contrast`` is a property of texture, so next we'll check on how to access the texture from the brush.
- Expand the *Colors* panel to locate the *Contrast* button.
- Right click on the contrast button and select **Online Python Reference**
This takes you to ``bpy.types.Texture.contrast``
- Now we can see that ``contrast`` is a property of texture,
so next we'll check on how to access the texture from the brush.
- Check on the **References** at the bottom of the page, sometimes there are many references, and it may take
some guess work to find the right one, but in this case its obviously ``Brush.texture``.
*Now we know that the texture can be accessed from* ``bpy.data.brushes["BrushName"].texture``
*but normally you won't want to access the brush by name, so we'll see now to access the active brush instead.*
- So the next step is to check on where brushes are accessed from via the **References**.
In this case there is simply ``bpy.context.brush`` which is all we need.
Now you can use the Python console to form the nested properties needed to access brush textures contrast,
logically we now know.
@@ -282,7 +276,8 @@ are interested to check on the source code.
.. note::
Not all operators can be called usefully from Python, for more on this see :ref:`using operators <using_operators>`.
Not all operators can be called usefully from Python,
for more on this see :ref:`using operators <using_operators>`.
Info View
@@ -294,7 +289,8 @@ This is located above the file-menu which can be dragged down to display its con
Select the **Script** screen that comes default with Blender to see its output.
You can perform some actions and see them show up - delete a vertex for example.
Each entry can be selected (Right-Mouse-Button), then copied :kbd:`Control-C`, usually to paste in the text editor or python console.
Each entry can be selected (Right-Mouse-Button),
then copied :kbd:`Control-C`, usually to paste in the text editor or python console.
.. note::

View File

@@ -1,16 +1,20 @@
*************
Best Practice
*************
When writing your own scripts python is great for new developers to pick up and become productive, but you can also pick up odd habits or at least write scripts that are not easy for others to understand.
When writing your own scripts python is great for new developers to pick up and become productive,
but you can also pick up odd habits or at least write scripts that are not easy for others to understand.
For your own work this is of course fine, but if you want to collaborate with others or have your work included with blender there are practices we encourage.
For your own work this is of course fine,
but if you want to collaborate with others or have your work included with blender there are practices we encourage.
Style Conventions
=================
For Blender/Python development we have chosen to follow python suggested style guide to avoid mixing styles amongst our own scripts and make it easier to use python scripts from other projects.
For Blender/Python development we have chosen to follow python suggested style guide to avoid mixing styles
amongst our own scripts and make it easier to use python scripts from other projects.
Using our style guide for your own scripts makes it easier if you eventually want to contribute them to blender.
@@ -18,22 +22,17 @@ This style guide is known as pep8 and can be found `here <http://www.python.org/
A brief listing of pep8 criteria.
* camel caps for class names: MyClass
* all lower case underscore separated module names: my_module
* indentation of 4 spaces (no tabs)
* spaces around operators. ``1 + 1``, not ``1+1``
* only use explicit imports, (no importing '*')
* don't use single line: ``if val: body``, separate onto 2 lines instead.
- camel caps for class names: MyClass
- all lower case underscore separated module names: my_module
- indentation of 4 spaces (no tabs)
- spaces around operators. ``1 + 1``, not ``1+1``
- only use explicit imports, (no importing ``*``)
- don't use single line: ``if val: body``, separate onto 2 lines instead.
As well as pep8 we have other conventions used for blender python scripts.
* Use single quotes for enums, and double quotes for strings.
- Use single quotes for enums, and double quotes for strings.
Both are of course strings but in our internal API enums are unique items from a limited set. eg.
@@ -42,9 +41,11 @@ As well as pep8 we have other conventions used for blender python scripts.
bpy.context.scene.render.image_settings.file_format = 'PNG'
bpy.context.scene.render.filepath = "//render_out"
* pep8 also defines that lines should not exceed 79 characters, we felt this is too restrictive so this is optional per script.
- pep8 also defines that lines should not exceed 79 characters,
we felt this is too restrictive so this is optional per script.
Periodically we run checks for pep8 compliance on blender scripts, for scripts to be included in this check add this line as a comment at the top of the script.
Periodically we run checks for pep8 compliance on blender scripts,
for scripts to be included in this check add this line as a comment at the top of the script.
``# <pep8 compliant>``
@@ -58,72 +59,75 @@ User Interface Layout
Some notes to keep in mind when writing UI layouts:
* UI code is quite simple. Layout declarations are there to easily create a decent layout.
- UI code is quite simple. Layout declarations are there to easily create a decent layout.
General rule here: If you need more code for the layout declaration,
then for the actual properties, you do it wrong.
General rule here: If you need more code for the layout declaration, then for the actual properties, you do it wrong.
Example layouts:
* layout()
- layout()
The basic layout is a simple Top -> Bottom layout.
The basic layout is a simple Top -> Bottom layout.
.. code-block:: python
layout.prop()
layout.prop()
layout.prop()
layout.prop()
* layout.row()
- layout.row()
Use row(), when you want more than 1 property in one line.
Use row(), when you want more than 1 property in one line.
.. code-block:: python
row = layout.row()
row.prop()
row.prop()
* layout.column()
row = layout.row()
row.prop()
row.prop()
- layout.column()
Use column(), when you want your properties in a column.
.. code-block:: python
col = layout.column()
col.prop()
col.prop()
* layout.split()
col = layout.column()
col.prop()
col.prop()
This can be used to create more complex layouts. For example you can split the layout and create two column() layouts next to each other.
- layout.split()
This can be used to create more complex layouts.
For example you can split the layout and create two column() layouts next to each other.
Don't use split, when you simply want two properties in a row. Use row() for that.
.. code-block:: python
split = layout.split()
col = split.column()
col.prop()
col.prop()
col = split.column()
col.prop()
col.prop()
split = layout.split()
col = split.column()
col.prop()
col.prop()
col = split.column()
col.prop()
col.prop()
Declaration names:
Try to only use these variable names for layout declarations:
* row for a row() layout
* col for a column() layout
* split for a split() layout
* flow for a column_flow() layout
* sub for a sub layout (a column inside a column for example)
- row for a row() layout
- col for a column() layout
- split for a split() layout
- flow for a column_flow() layout
- sub for a sub layout (a column inside a column for example)
Script Efficiency
=================
List Manipulation (General Python Tips)
---------------------------------------
@@ -133,7 +137,8 @@ Searching for list items
In Python there are some handy list functions that save you having to search through the list.
Even though you're not looping on the list data **python is**, so you need to be aware of functions that will slow down your script by searching the whole list.
Even though you're not looping on the list data **python is**,
so you need to be aware of functions that will slow down your script by searching the whole list.
.. code-block:: python
@@ -145,11 +150,16 @@ Even though you're not looping on the list data **python is**, so you need to be
Modifying Lists
^^^^^^^^^^^^^^^
In python we can add and remove from a list, this is slower when the list length is modified, especially at the start of the list, since all the data after the index of modification needs to be moved up or down 1 place.
In python we can add and remove from a list, this is slower when the list length is modified,
especially at the start of the list, since all the data after the index of
modification needs to be moved up or down 1 place.
The most simple way to add onto the end of the list is to use ``my_list.append(list_item)`` or ``my_list.extend(some_list)`` and the fastest way to remove an item is ``my_list.pop()`` or ``del my_list[-1]``.
The most simple way to add onto the end of the list is to use
``my_list.append(list_item)`` or ``my_list.extend(some_list)`` and the fastest way to
remove an item is ``my_list.pop()`` or ``del my_list[-1]``.
To use an index you can use ``my_list.insert(index, list_item)`` or ``list.pop(index)`` for list removal, but these are slower.
To use an index you can use ``my_list.insert(index, list_item)`` or ``list.pop(index)``
for list removal, but these are slower.
Sometimes its faster (but more memory hungry) to just rebuild the list.
@@ -193,7 +203,8 @@ Use...
my_list.extend([a, b, c...])
Note that insert can be used when needed, but it is slower than append especially when inserting at the start of a long list.
Note that insert can be used when needed,
but it is slower than append especially when inserting at the start of a long list.
This example shows a very sub-optimal way of making a reversed list.
@@ -205,7 +216,8 @@ This example shows a very sub-optimal way of making a reversed list.
reverse_list.insert(0, list_item)
Python provides more convenient ways to reverse a list using the slice method, but you may want to time this before relying on it too much:
Python provides more convenient ways to reverse a list using the slice method,
but you may want to time this before relying on it too much:
.. code-block:: python
@@ -220,7 +232,8 @@ Use ``my_list.pop(index)`` rather than ``my_list.remove(list_item)``
This requires you to have the index of the list item but is faster since ``remove()`` will search the list.
Here is an example of how to remove items in 1 loop, removing the last items first, which is faster (as explained above).
Here is an example of how to remove items in 1 loop,
removing the last items first, which is faster (as explained above).
.. code-block:: python
@@ -232,7 +245,9 @@ Here is an example of how to remove items in 1 loop, removing the last items fir
my_list.pop(list_index)
This example shows a fast way of removing items, for use in cases where you can alter the list order without breaking the scripts functionality. This works by swapping 2 list items, so the item you remove is always last.
This example shows a fast way of removing items,
for use in cases where you can alter the list order without breaking the scripts functionality.
This works by swapping 2 list items, so the item you remove is always last.
.. code-block:: python
@@ -251,7 +266,9 @@ When removing many items in a large list this can provide a good speedup.
Avoid Copying Lists
^^^^^^^^^^^^^^^^^^^
When passing a list/dictionary to a function, it is faster to have the function modify the list rather than returning a new list so python doesn't have to duplicate the list in memory.
When passing a list/dictionary to a function,
it is faster to have the function modify the list rather than returning
a new list so python doesn't have to duplicate the list in memory.
Functions that modify a list in-place are more efficient than functions that create new lists.
@@ -296,20 +313,26 @@ Pythons string joining function. To join a list of strings
>>> file.write(" ".join([str1, str2, str3, "\n"]))
join is fastest on many strings, `string formatting <http://docs.python.org/py3k/library/string.html#string-formatting>`_ is quite fast too (better for converting data types). String arithmetic is slowest.
join is fastest on many strings,
`string formatting <http://docs.python.org/py3k/library/string.html#string-formatting>`__
is quite fast too (better for converting data types). String arithmetic is slowest.
Parsing Strings (Import/Exporting)
----------------------------------
Since many file formats are ASCII, the way you parse/export strings can make a large difference in how fast your script runs.
Since many file formats are ASCII,
the way you parse/export strings can make a large difference in how fast your script runs.
There are a few ways to parse strings when importing them into Blender.
Parsing Numbers
^^^^^^^^^^^^^^^
Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``, float() will work for an int too but it's faster to read ints with int().
Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``,
float() will work for an int too but it's faster to read ints with int().
Checking String Start/End
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -322,7 +345,8 @@ Use...
>>> if line.startswith("vert "):
Using ``startswith()`` is slightly faster (approx 5%) and also avoids a possible error with the slice length not matching the string length.
Using ``startswith()`` is slightly faster (approx 5%) and also avoids a possible
error with the slice length not matching the string length.
my_string.endswith("foo_bar") can be used for line endings too.
@@ -336,15 +360,19 @@ Use try/except Sparingly
The **try** statement is useful to save time writing error checking code.
However **try** is significantly slower than an **if** since an exception has to be set each time, so avoid using **try** in areas of your code that execute in a loop and runs many times.
However **try** is significantly slower than an **if** since an exception has to be set each time,
so avoid using **try** in areas of your code that execute in a loop and runs many times.
There are cases where using **try** is faster than checking whether the condition will raise an error, so it is worth experimenting.
There are cases where using **try** is faster than checking whether the condition will raise an error,
so it is worth experimenting.
Value Comparison
----------------
Python has two ways to compare values ``a == b`` and ``a is b``, the difference is that ``==`` may run the objects comparison function ``__cmp__()`` whereas ``is`` compares identity, that both variables reference the same item in memory.
Python has two ways to compare values ``a == b`` and ``a is b``,
the difference is that ``==`` may run the objects comparison function ``__cmp__()`` whereas ``is`` compares identity,
that both variables reference the same item in memory.
In cases where you know you are checking for the same value which is referenced from multiple places, ``is`` is faster.
@@ -362,3 +390,4 @@ While developing a script it's good to time it to be aware of any changes in per
# do something...
print("My Script Finished: %.4f sec" % time.time() - time_start)

View File

@@ -2,7 +2,8 @@
Gotchas
*******
This document attempts to help you work with the Blender API in areas that can be troublesome and avoid practices that are known to give instability.
This document attempts to help you work with the Blender API in areas
that can be troublesome and avoid practices that are known to give instability.
.. _using_operators:
@@ -10,16 +11,15 @@ This document attempts to help you work with the Blender API in areas that can b
Using Operators
===============
Blender's operators are tools for users to access, that python can access them too is very useful nevertheless operators have limitations that can make them cumbersome to script.
Blender's operators are tools for users to access, that Python can access them too is very useful
nevertheless operators have limitations that can make them cumbersome to script.
Main limits are...
* Can't pass data such as objects, meshes or materials to operate on (operators use the context instead)
* The return value from calling an operator gives the success (if it finished or was canceled),
- Can't pass data such as objects, meshes or materials to operate on (operators use the context instead)
- The return value from calling an operator gives the success (if it finished or was canceled),
in some cases it would be more logical from an API perspective to return the result of the operation.
* Operators poll function can fail where an API function would raise an exception giving details on exactly why.
- Operators poll function can fail where an API function would raise an exception giving details on exactly why.
Why does an operator's poll fail?
@@ -32,20 +32,28 @@ When calling an operator gives an error like this:
Which raises the question as to what the correct context might be?
Typically operators check for the active area type, a selection or active object they can operate on, but some operators are more picky about when they run.
Typically operators check for the active area type, a selection or active object they can operate on,
but some operators are more picky about when they run.
In most cases you can figure out what context an operator needs simply be seeing how it's used in Blender and thinking about what it does.
In most cases you can figure out what context an operator needs
simply be seeing how it's used in Blender and thinking about what it does.
Unfortunately if you're still stuck - the only way to **really** know whats going on is to read the source code for the poll function and see what its checking.
Unfortunately if you're still stuck - the only way to **really** know
whats going on is to read the source code for the poll function and see what its checking.
For python operators it's not so hard to find the source since it's included with Blender and the source file/line is included in the operator reference docs.
For Python operators it's not so hard to find the source
since it's included with Blender and the source file/line is included in the operator reference docs.
Downloading and searching the C code isn't so simple, especially if you're not familiar with the C language but by searching the operator name or description you should be able to find the poll function with no knowledge of C.
Downloading and searching the C code isn't so simple,
especially if you're not familiar with the C language but by searching the
operator name or description you should be able to find the poll function with no knowledge of C.
.. note::
Blender does have the functionality for poll functions to describe why they fail, but its currently not used much, if you're interested to help improve our API feel free to add calls to ``CTX_wm_operator_poll_msg_set`` where its not obvious why poll fails.
Blender does have the functionality for poll functions to describe why they fail,
but its currently not used much, if you're interested to help improve our API
feel free to add calls to ``CTX_wm_operator_poll_msg_set`` where its not obvious why poll fails.
>>> bpy.ops.gpencil.draw()
RuntimeError: Operator bpy.ops.gpencil.draw.poll() Failed to find Grease Pencil data to draw into
@@ -54,36 +62,45 @@ Downloading and searching the C code isn't so simple, especially if you're not f
The operator still doesn't work!
--------------------------------
Certain operators in Blender are only intended for use in a specific context, some operators for example are only called from the properties window where they check the current material, modifier or constraint.
Certain operators in Blender are only intended for use in a specific context,
some operators for example are only called from the properties window where they check the current material,
modifier or constraint.
Examples of this are:
* :mod:`bpy.ops.texture.slot_move`
* :mod:`bpy.ops.constraint.limitdistance_reset`
* :mod:`bpy.ops.object.modifier_copy`
* :mod:`bpy.ops.buttons.file_browse`
- :mod:`bpy.ops.texture.slot_move`
- :mod:`bpy.ops.constraint.limitdistance_reset`
- :mod:`bpy.ops.object.modifier_copy`
- :mod:`bpy.ops.buttons.file_browse`
Another possibility is that you are the first person to attempt to use this operator in a script and some modifications need to be made to the operator to run in a different context, if the operator should logically be able to run but fails when accessed from a script it should be reported to the bug tracker.
Another possibility is that you are the first person to attempt to use this operator
in a script and some modifications need to be made to the operator to run in a different context,
if the operator should logically be able to run but fails when accessed from a script
it should be reported to the bug tracker.
Stale Data
==========
No updates after setting values
-------------------------------
Sometimes you want to modify values from python and immediately access the updated values, eg:
Sometimes you want to modify values from Python and immediately access the updated values, eg:
Once changing the objects :class:`bpy.types.Object.location` you may want to access its transformation right after from :class:`bpy.types.Object.matrix_world`, but this doesn't work as you might expect.
Once changing the objects :class:`bpy.types.Object.location`
you may want to access its transformation right after from :class:`bpy.types.Object.matrix_world`,
but this doesn't work as you might expect.
Consider the calculations that might go into working out the object's final transformation, this includes:
* animation function curves.
* drivers and their pythons expressions.
* constraints
* parent objects and all of their f-curves, constraints etc.
- animation function curves.
- drivers and their Python expressions.
- constraints
- parent objects and all of their f-curves, constraints etc.
To avoid expensive recalculations every time a property is modified, Blender defers making the actual calculations until they are needed.
To avoid expensive recalculations every time a property is modified,
Blender defers making the actual calculations until they are needed.
However, while the script runs you may want to access the updated values.
In this case you need to call :class:`bpy.types.Scene.update` after modifying values, for example:
@@ -94,7 +111,9 @@ In this case you need to call :class:`bpy.types.Scene.update` after modifying va
bpy.context.scene.update()
Now all dependent data (child objects, modifiers, drivers... etc) has been recalculated and is available to the script.
Now all dependent data (child objects, modifiers, drivers... etc)
has been recalculated and is available to the script.
Can I redraw during the script?
-------------------------------
@@ -103,23 +122,33 @@ The official answer to this is no, or... *"You don't want to do that"*.
To give some background on the topic...
While a script executes Blender waits for it to finish and is effectively locked until its done, while in this state Blender won't redraw or respond to user input.
Normally this is not such a problem because scripts distributed with Blender tend not to run for an extended period of time, nevertheless scripts *can* take ages to execute and its nice to see whats going on in the view port.
While a script executes Blender waits for it to finish and is effectively locked until its done,
while in this state Blender won't redraw or respond to user input.
Normally this is not such a problem because scripts distributed with Blender
tend not to run for an extended period of time,
nevertheless scripts *can* take ages to execute and its nice to see whats going on in the view port.
Tools that lock Blender in a loop and redraw are highly discouraged since they conflict with Blenders ability to run multiple operators at once and update different parts of the interface as the tool runs.
Tools that lock Blender in a loop and redraw are highly discouraged
since they conflict with Blenders ability to run multiple operators
at once and update different parts of the interface as the tool runs.
So the solution here is to write a **modal** operator, that is - an operator which defines a modal() function, See the modal operator template in the text editor.
So the solution here is to write a **modal** operator, that is - an operator which defines a modal() function,
See the modal operator template in the text editor.
Modal operators execute on user input or setup their own timers to run frequently, they can handle the events or pass through to be handled by the keymap or other modal operators.
Modal operators execute on user input or setup their own timers to run frequently,
they can handle the events or pass through to be handled by the keymap or other modal operators.
Transform, Painting, Fly-Mode and File-Select are example of a modal operators.
Writing modal operators takes more effort than a simple ``for`` loop that happens to redraw but is more flexible and integrates better with Blenders design.
Writing modal operators takes more effort than a simple ``for`` loop
that happens to redraw but is more flexible and integrates better with Blenders design.
**Ok, Ok! I still want to draw from python**
**Ok, Ok! I still want to draw from Python**
If you insist - yes its possible, but scripts that use this hack wont be considered for inclusion in Blender and any issues with using it wont be considered bugs, this is also not guaranteed to work in future releases.
If you insist - yes its possible, but scripts that use this hack wont be considered
for inclusion in Blender and any issues with using it wont be considered bugs,
this is also not guaranteed to work in future releases.
.. code-block:: python
@@ -129,16 +158,18 @@ If you insist - yes its possible, but scripts that use this hack wont be conside
Modes and Mesh Access
=====================
When working with mesh data you may run into the problem where a script fails to run as expected in edit-mode. This is caused by edit-mode having its own data which is only written back to the mesh when exiting edit-mode.
When working with mesh data you may run into the problem where a script fails to run as expected in edit-mode.
This is caused by edit-mode having its own data which is only written back to the mesh when exiting edit-mode.
A common example is that exporters may access a mesh through ``obj.data`` (a :class:`bpy.types.Mesh`) but the user is in edit-mode, where the mesh data is available but out of sync with the edit mesh.
A common example is that exporters may access a mesh through ``obj.data`` (a :class:`bpy.types.Mesh`)
but the user is in edit-mode, where the mesh data is available but out of sync with the edit mesh.
In this situation you can...
* Exit edit-mode before running the tool.
* Explicitly update the mesh by calling :class:`bmesh.types.BMesh.to_mesh`.
* Modify the script to support working on the edit-mode data directly, see: :mod:`bmesh.from_edit_mesh`.
* Report the context as incorrect and only allow the script to run outside edit-mode.
- Exit edit-mode before running the tool.
- Explicitly update the mesh by calling :class:`bmesh.types.BMesh.to_mesh`.
- Modify the script to support working on the edit-mode data directly, see: :mod:`bmesh.from_edit_mesh`.
- Report the context as incorrect and only allow the script to run outside edit-mode.
.. _info_gotcha_mesh_faces:
@@ -146,35 +177,55 @@ In this situation you can...
NGons and Tessellation Faces
============================
Since 2.63 NGons are supported, this adds some complexity since in some cases you need to access triangles/quads still (some exporters for example).
Since 2.63 NGons are supported, this adds some complexity
since in some cases you need to access triangles/quads still (some exporters for example).
There are now 3 ways to access faces:
* :class:`bpy.types.MeshPolygon` - this is the data structure which now stores faces in object mode (access as ``mesh.polygons`` rather then ``mesh.faces``).
* :class:`bpy.types.MeshTessFace` - the result of triangulating (tessellated) polygons, the main method of face access in 2.62 or older (access as ``mesh.tessfaces``).
* :class:`bmesh.types.BMFace` - the polygons as used in editmode.
- :class:`bpy.types.MeshPolygon` -
this is the data structure which now stores faces in object mode
(access as ``mesh.polygons`` rather than ``mesh.faces``).
- :class:`bpy.types.MeshTessFace` -
the result of triangulating (tessellated) polygons,
the main method of face access in 2.62 or older (access as ``mesh.tessfaces``).
- :class:`bmesh.types.BMFace` -
the polygons as used in editmode.
For the purpose of the following documentation, these will be referred to as polygons, tessfaces and bmesh-faces respectively.
For the purpose of the following documentation,
these will be referred to as polygons, tessfaces and bmesh-faces respectively.
5+ sided faces will be referred to as ``ngons``.
Support Overview
----------------
+--------------+------------------------------+--------------------------------+--------------------------------+
|Usage |:class:`bpy.types.MeshPolygon`|:class:`bpy.types.MeshTessFace` |:class:`bmesh.types.BMFace` |
+==============+==============================+================================+================================+
|Import/Create |Bad (inflexible) |Fine (supported as upgrade path)|Best |
+--------------+------------------------------+--------------------------------+--------------------------------+
|Manipulate |Bad (inflexible) |Bad (loses ngons) |Best |
+--------------+------------------------------+--------------------------------+--------------------------------+
|Export/Output |Good (ngons) |Good (When ngons can't be used) |Good (ngons, memory overhead) |
+--------------+------------------------------+--------------------------------+--------------------------------+
.. list-table::
:header-rows: 1
:stub-columns: 1
* - Usage
- :class:`bpy.types.MeshPolygon`
- :class:`bpy.types.MeshTessFace`
- :class:`bmesh.types.BMFace`
* - Import/Create
- Poor *(inflexible)*
- Good *(supported as upgrade path)*
- Best
* - Manipulate
- Poor *(inflexible)*
- Poor *(loses ngons)*
- Best
* - Export/Output
- Good *(ngon support)*
- Good *(When ngons can't be used)*
- Good *(ngons, extra memory overhead)*
.. note::
Using the :mod:`bmesh` api is completely separate api from :mod:`bpy`, typically you would would use one or the other based on the level of editing needed, not simply for a different way to access faces.
Using the :mod:`bmesh` api is completely separate api from :mod:`bpy`,
typically you would would use one or the other based on the level of editing needed,
not simply for a different way to access faces.
Creating
@@ -182,9 +233,18 @@ Creating
All 3 datatypes can be used for face creation.
* polygons are the most efficient way to create faces but the data structure is _very_ rigid and inflexible, you must have all your vertes and faces ready and create them all at once. This is further complicated by the fact that each polygon does not store its own verts (as with tessfaces), rather they reference an index and size in :class:`bpy.types.Mesh.loops` which are a fixed array too.
* tessfaces ideally should not be used for creating faces since they are really only tessellation cache of polygons, however for scripts upgrading from 2.62 this is by far the most straightforward option. This works by creating tessfaces and when finished - they can be converted into polygons by calling :class:`bpy.types.Mesh.update`. The obvious limitation is ngons can't be created this way.
* bmesh-faces are most likely the easiest way for new scripts to create faces, since faces can be added one by one and the api has features intended for mesh manipulation. While :class:`bmesh.types.BMesh` uses more memory it can be managed by only operating on one mesh at a time.
- polygons are the most efficient way to create faces but the data structure is _very_ rigid and inflexible,
you must have all your vertes and faces ready and create them all at once.
This is further complicated by the fact that each polygon does not store its own verts (as with tessfaces),
rather they reference an index and size in :class:`bpy.types.Mesh.loops` which are a fixed array too.
- tessfaces ideally should not be used for creating faces since they are really only tessellation cache of polygons,
however for scripts upgrading from 2.62 this is by far the most straightforward option.
This works by creating tessfaces and when finished -
they can be converted into polygons by calling :class:`bpy.types.Mesh.update`.
The obvious limitation is ngons can't be created this way.
- bmesh-faces are most likely the easiest way for new scripts to create faces,
since faces can be added one by one and the api has features intended for mesh manipulation.
While :class:`bmesh.types.BMesh` uses more memory it can be managed by only operating on one mesh at a time.
Editing
@@ -192,18 +252,24 @@ Editing
Editing is where the 3 data types vary most.
* polygons are very limited for editing, changing materials and options like smooth works but for anything else they are too inflexible and are only intended for storage.
* tessfaces should not be used for editing geometry because doing so will cause existing ngons to be tessellated.
* bmesh-faces are by far the best way to manipulate geometry.
- Polygons are very limited for editing,
changing materials and options like smooth works but for anything else
they are too inflexible and are only intended for storage.
- Tessfaces should not be used for editing geometry because doing so will cause existing ngons to be tessellated.
- BMesh-Faces are by far the best way to manipulate geometry.
Exporting
---------
All 3 data types can be used for exporting, the choice mostly depends on whether the target format supports ngons or not.
All 3 data types can be used for exporting,
the choice mostly depends on whether the target format supports ngons or not.
* polygons are the most direct & efficient way to export providing they convert into the output format easily enough.
* tessfaces work well for exporting to formats which dont support ngons, in fact this is the only place where their use is encouraged.
* bmesh-faces can work for exporting too but may not be necessary if polygons can be used since using bmesh gives some overhead because its not the native storage format in object mode.
- Polygons are the most direct & efficient way to export providing they convert into the output format easily enough.
- Tessfaces work well for exporting to formats which dont support ngons,
in fact this is the only place where their use is encouraged.
- BMesh-Faces can work for exporting too but may not be necessary if polygons can be used
since using bmesh gives some overhead because its not the native storage format in object mode.
Upgrading Importers from 2.62
@@ -213,9 +279,9 @@ Importers can be upgraded to work with only minor changes.
The main change to be made is used the tessellation versions of each attribute.
* mesh.faces --> :class:`bpy.types.Mesh.tessfaces`
* mesh.uv_textures --> :class:`bpy.types.Mesh.tessface_uv_textures`
* mesh.vertex_colors --> :class:`bpy.types.Mesh.tessface_vertex_colors`
- mesh.faces --> :class:`bpy.types.Mesh.tessfaces`
- mesh.uv_textures --> :class:`bpy.types.Mesh.tessface_uv_textures`
- mesh.vertex_colors --> :class:`bpy.types.Mesh.tessface_vertex_colors`
Once the data is created call :class:`bpy.types.Mesh.update` to convert the tessfaces into polygons.
@@ -223,7 +289,9 @@ Once the data is created call :class:`bpy.types.Mesh.update` to convert the tess
Upgrading Exporters from 2.62
-----------------------------
For exporters the most direct way to upgrade is to use tessfaces as with importing however its important to know that tessfaces may **not** exist for a mesh, the array will be empty as if there are no faces.
For exporters the most direct way to upgrade is to use tessfaces as with importing
however its important to know that tessfaces may **not** exist for a mesh,
the array will be empty as if there are no faces.
So before accessing tessface data call: :class:`bpy.types.Mesh.update` ``(calc_tessface=True)``.
@@ -231,7 +299,8 @@ So before accessing tessface data call: :class:`bpy.types.Mesh.update` ``(calc_t
EditBones, PoseBones, Bone... Bones
===================================
Armature Bones in Blender have three distinct data structures that contain them. If you are accessing the bones through one of them, you may not have access to the properties you really need.
Armature Bones in Blender have three distinct data structures that contain them.
If you are accessing the bones through one of them, you may not have access to the properties you really need.
.. note::
@@ -241,7 +310,9 @@ Armature Bones in Blender have three distinct data structures that contain them.
Edit Bones
----------
``bpy.context.object.data.edit_bones`` contains a editbones; to access them you must set the armature mode to edit mode first (editbones do not exist in object or pose mode). Use these to create new bones, set their head/tail or roll, change their parenting relationships to other bones, etc.
``bpy.context.object.data.edit_bones`` contains a editbones;
to access them you must set the armature mode to edit mode first (editbones do not exist in object or pose mode).
Use these to create new bones, set their head/tail or roll, change their parenting relationships to other bones, etc.
Example using :class:`bpy.types.EditBone` in armature editmode:
@@ -261,7 +332,9 @@ Returns an editbone only in edit mode.
Bones (Object Mode)
-------------------
``bpy.context.object.data.bones`` contains bones. These *live* in object mode, and have various properties you can change, note that the head and tail properties are read-only.
``bpy.context.object.data.bones`` contains bones.
These *live* in object mode, and have various properties you can change,
note that the head and tail properties are read-only.
Example using :class:`bpy.types.Bone` in object or pose mode:
@@ -281,7 +354,9 @@ Accessible but read-only
Pose Bones
----------
``bpy.context.object.pose.bones`` contains pose bones. This is where animation data resides, i.e. animatable transformations are applied to pose bones, as are constraints and ik-settings.
``bpy.context.object.pose.bones`` contains pose bones.
This is where animation data resides, i.e. animatable transformations
are applied to pose bones, as are constraints and ik-settings.
Examples using :class:`bpy.types.PoseBone` in object or pose mode:
@@ -296,19 +371,27 @@ Examples using :class:`bpy.types.PoseBone` in object or pose mode:
.. note::
Notice the pose is accessed from the object rather than the object data, this is why blender can have 2 or more objects sharing the same armature in different poses.
Notice the pose is accessed from the object rather than the object data,
this is why blender can have 2 or more objects sharing the same armature in different poses.
.. note::
Strictly speaking PoseBone's are not bones, they are just the state of the armature, stored in the :class:`bpy.types.Object` rather than the :class:`bpy.types.Armature`, the real bones are however accessible from the pose bones - :class:`bpy.types.PoseBone.bone`
Strictly speaking PoseBone's are not bones, they are just the state of the armature,
stored in the :class:`bpy.types.Object` rather than the :class:`bpy.types.Armature`,
the real bones are however accessible from the pose bones - :class:`bpy.types.PoseBone.bone`
Armature Mode Switching
-----------------------
While writing scripts that deal with armatures you may find you have to switch between modes, when doing so take care when switching out of editmode not to keep references to the edit-bones or their head/tail vectors. Further access to these will crash blender so its important the script clearly separates sections of the code which operate in different modes.
While writing scripts that deal with armatures you may find you have to switch between modes,
when doing so take care when switching out of edit-mode not to keep references
to the edit-bones or their head/tail vectors.
Further access to these will crash blender so its important the script
clearly separates sections of the code which operate in different modes.
This is mainly an issue with editmode since pose data can be manipulated without having to be in pose mode, however for operator access you may still need to enter pose mode.
This is mainly an issue with editmode since pose data can be manipulated without having to be in pose mode,
however for operator access you may still need to enter pose mode.
Data Names
@@ -343,10 +426,13 @@ Or with name assignment...
Data names may not match the assigned values if they exceed the maximum length, are already used or an empty string.
Its better practice not to reference objects by names at all, once created you can store the data in a list, dictionary, on a class etc, there is rarely a reason to have to keep searching for the same data by name.
Its better practice not to reference objects by names at all,
once created you can store the data in a list, dictionary, on a class etc,
there is rarely a reason to have to keep searching for the same data by name.
If you do need to use name references, its best to use a dictionary to maintain a mapping between the names of the imported assets and the newly created data, this way you don't run this risk of referencing existing data from the blend file, or worse modifying it.
If you do need to use name references, its best to use a dictionary to maintain
a mapping between the names of the imported assets and the newly created data,
this way you don't run this risk of referencing existing data from the blend file, or worse modifying it.
.. code-block:: python
@@ -358,18 +444,22 @@ If you do need to use name references, its best to use a dictionary to maintain
# normally some code, or function calls...
# use own dictionary rather then bpy.data
# use own dictionary rather than bpy.data
mesh = mesh_name_mapping[meshid]
Library Collisions
------------------
Blender keeps data names unique - :class:`bpy.types.ID.name` so you can't name two objects, meshes, scenes etc the same thing by accident.
Blender keeps data names unique - :class:`bpy.types.ID.name` so you can't name two objects,
meshes, scenes etc the same thing by accident.
However when linking in library data from another blend file naming collisions can occur, so its best to avoid referencing data by name at all.
However when linking in library data from another blend file naming collisions can occur,
so its best to avoid referencing data by name at all.
This can be tricky at times and not even blender handles this correctly in some case (when selecting the modifier object for eg you can't select between multiple objects with the same name), but its still good to try avoid problems in this area.
This can be tricky at times and not even blender handles this correctly in some case
(when selecting the modifier object for eg you can't select between multiple objects with the same name),
but its still good to try avoid problems in this area.
If you need to select between local and library data, there is a feature in ``bpy.data`` members to allow for this.
@@ -394,21 +484,23 @@ If you need to select between local and library data, there is a feature in ``bp
Relative File Paths
===================
Blenders relative file paths are not compatible with standard python modules such as ``sys`` and ``os``.
Blenders relative file paths are not compatible with standard Python modules such as ``sys`` and ``os``.
Built in python functions don't understand blenders ``//`` prefix which denotes the blend file path.
Built in Python functions don't understand blenders ``//`` prefix which denotes the blend file path.
A common case where you would run into this problem is when exporting a material with associated image paths.
>>> bpy.path.abspath(image.filepath)
>>> bpy.path.abspath(image.filepath)
When using blender data from linked libraries there is an unfortunate complication since the path will be relative to the library rather then the open blend file. When the data block may be from an external blend file pass the library argument from the :class:`bpy.types.ID`.
When using blender data from linked libraries there is an unfortunate complication
since the path will be relative to the library rather than the open blend file.
When the data block may be from an external blend file pass the library argument from the :class:`bpy.types.ID`.
>>> bpy.path.abspath(image.filepath, library=image.library)
>>> bpy.path.abspath(image.filepath, library=image.library)
These returns the absolute path which can be used with native python modules.
These returns the absolute path which can be used with native Python modules.
Unicode Problems
@@ -449,23 +541,28 @@ Here are 2 ways around filesystem encoding issues:
>>> bpy.context.object.name = filepath_utf8
Unicode encoding/decoding is a big topic with comprehensive python documentation, to avoid getting stuck too deep in encoding problems - here are some suggestions:
Unicode encoding/decoding is a big topic with comprehensive Python documentation,
to avoid getting stuck too deep in encoding problems - here are some suggestions:
* Always use utf-8 encoiding or convert to utf-8 where the input is unknown.
- Always use utf-8 encoding or convert to utf-8 where the input is unknown.
- Avoid manipulating filepaths as strings directly, use ``os.path`` functions instead.
- Use ``os.fsencode()`` / ``os.fsdecode()`` instead of built in string decoding functions when operating on paths.
- To print paths or to include them in the user interface use ``repr(path)`` first
or ``"%r" % path`` with string formatting.
* Avoid manipulating filepaths as strings directly, use ``os.path`` functions instead.
.. note::
* Use ``os.fsencode()`` / ``os.fsdecode()`` rather then the built in string decoding functions when operating on paths.
* To print paths or to include them in the user interface use ``repr(path)`` first or ``"%r" % path`` with string formatting.
* **Possibly** - use bytes instead of python strings, when reading some input its less trouble to read it as binary data though you will still need to decide how to treat any strings you want to use with Blender, some importers do this.
Sometimes it's preferrable to avoid string encoding issues by using bytes instead of Python strings,
when reading some input its less trouble to read it as binary data
though you will still need to decide how to treat any strings you want to use with Blender,
some importers do this.
Strange errors using 'threading' module
=======================================
Python threading with Blender only works properly when the threads finish up before the script does. By using ``threading.join()`` for example.
Python threading with Blender only works properly when the threads finish up before the script does.
By using ``threading.join()`` for example.
Heres an example of threading supported by Blender:
@@ -504,7 +601,8 @@ Heres an example of threading supported by Blender:
t.join()
This an example of a timer which runs many times a second and moves the default cube continuously while Blender runs **(Unsupported)**.
This an example of a timer which runs many times a second and moves
the default cube continuously while Blender runs **(Unsupported)**.
.. code-block:: python
@@ -521,38 +619,48 @@ This an example of a timer which runs many times a second and moves the default
my_timer()
Use cases like the one above which leave the thread running once the script finishes may seem to work for a while but end up causing random crashes or errors in Blender's own drawing code.
Use cases like the one above which leave the thread running once the script finishes
may seem to work for a while but end up causing random crashes or errors in Blender's own drawing code.
So far, no work has gone into making Blender's python integration thread safe, so until its properly supported, best not make use of this.
So far, no work has gone into making Blender's Python integration thread safe,
so until its properly supported, best not make use of this.
.. note::
Pythons threads only allow co-currency and won't speed up your scripts on multi-processor systems, the ``subprocess`` and ``multiprocess`` modules can be used with Blender and make use of multiple CPU's too.
Pythons threads only allow co-currency and won't speed up your scripts on multi-processor systems,
the ``subprocess`` and ``multiprocess`` modules can be used with Blender and make use of multiple CPU's too.
Help! My script crashes Blender
===============================
Ideally it would be impossible to crash Blender from python however there are some problems with the API where it can be made to crash.
Ideally it would be impossible to crash Blender from Python
however there are some problems with the API where it can be made to crash.
Strictly speaking this is a bug in the API but fixing it would mean adding memory verification on every access since most crashes are caused by the python objects referencing Blenders memory directly, whenever the memory is freed, further python access to it can crash the script. But fixing this would make the scripts run very slow, or writing a very different kind of API which doesn't reference the memory directly.
Strictly speaking this is a bug in the API but fixing it would mean adding memory verification
on every access since most crashes are caused by the Python objects referencing Blenders memory directly,
whenever the memory is freed, further Python access to it can crash the script.
But fixing this would make the scripts run very slow,
or writing a very different kind of API which doesn't reference the memory directly.
Here are some general hints to avoid running into these problems.
* Be aware of memory limits, especially when working with large lists since Blender can crash simply by running out of memory.
* Many hard to fix crashes end up being because of referencing freed data, when removing data be sure not to hold any references to it.
* Modules or classes that remain active while Blender is used, should not hold references to data the user may remove, instead, fetch data from the context each time the script is activated.
* Crashes may not happen every time, they may happen more on some configurations/operating-systems.
- Be aware of memory limits,
especially when working with large lists since Blender can crash simply by running out of memory.
- Many hard to fix crashes end up being because of referencing freed data,
when removing data be sure not to hold any references to it.
- Modules or classes that remain active while Blender is used,
should not hold references to data the user may remove, instead,
fetch data from the context each time the script is activated.
- Crashes may not happen every time, they may happen more on some configurations/operating-systems.
.. note::
To find the line of your script that crashes you can use the ``faulthandler`` module.
See `faulthandler docs <http://docs.python.org/dev/library/faulthandler.html>`_.
While the crash may be in Blenders C/C++ code, this can help a lot to track down the area of the script that causes the crash.
While the crash may be in Blenders C/C++ code,
this can help a lot to track down the area of the script that causes the crash.
Undo/Redo
@@ -572,28 +680,36 @@ This example shows how you can tell undo changes the memory locations.
>>> hash(bpy.context.object)
-9223372036849951740
As suggested above, simply not holding references to data when Blender is used interactively by the user is the only way to ensure the script doesn't become unstable.
As suggested above, simply not holding references to data when Blender is used
interactively by the user is the only way to ensure the script doesn't become unstable.
Undo & Library Data
^^^^^^^^^^^^^^^^^^^
One of the advantages with Blenders library linking system that undo can skip checking changes in library data since it is assumed to be static.
One of the advantages with Blenders library linking system that undo
can skip checking changes in library data since it is assumed to be static.
Tools in Blender are not allowed to modify library data.
Python however does not enforce this restriction.
This can be useful in some cases, using a script to adjust material values for example.
But its also possible to use a script to make library data point to newly created local data, which is not supported since a call to undo will remove the local data but leave the library referencing it and likely crash.
But its also possible to use a script to make library data point to newly created local data,
which is not supported since a call to undo will remove the local data
but leave the library referencing it and likely crash.
So it's best to consider modifying library data an advanced usage of the API and only to use it when you know what you're doing.
So it's best to consider modifying library data an advanced usage of the API
and only to use it when you know what you're doing.
Edit Mode / Memory Access
-------------------------
Switching edit-mode ``bpy.ops.object.mode_set(mode='EDIT')`` / ``bpy.ops.object.mode_set(mode='OBJECT')`` will re-allocate objects data, any references to a meshes vertices/polygons/uvs, armatures bones, curves points etc cannot be accessed after switching edit-mode.
Switching edit-mode ``bpy.ops.object.mode_set(mode='EDIT')`` / ``bpy.ops.object.mode_set(mode='OBJECT')``
will re-allocate objects data,
any references to a meshes vertices/polygons/uvs, armatures bones,
curves points etc cannot be accessed after switching edit-mode.
Only the reference to the data its self can be re-accessed, the following example will crash.
@@ -608,7 +724,8 @@ Only the reference to the data its self can be re-accessed, the following exampl
print(polygons)
So after switching edit-mode you need to re-access any object data variables, the following example shows how to avoid the crash above.
So after switching edit-mode you need to re-access any object data variables,
the following example shows how to avoid the crash above.
.. code-block:: python
@@ -622,13 +739,15 @@ So after switching edit-mode you need to re-access any object data variables, th
print(polygons)
These kinds of problems can happen for any functions which re-allocate the object data but are most common when switching edit-mode.
These kinds of problems can happen for any functions which re-allocate
the object data but are most common when switching edit-mode.
Array Re-Allocation
-------------------
When adding new points to a curve or vertices's/edges/polygons to a mesh, internally the array which stores this data is re-allocated.
When adding new points to a curve or vertices's/edges/polygons to a mesh,
internally the array which stores this data is re-allocated.
.. code-block:: python
@@ -639,15 +758,20 @@ When adding new points to a curve or vertices's/edges/polygons to a mesh, intern
# this will crash!
point.co = 1.0, 2.0, 3.0
This can be avoided by re-assigning the point variables after adding the new one or by storing indices's to the points rather then the points themselves.
This can be avoided by re-assigning the point variables after adding the new one or by storing
indices's to the points rather than the points themselves.
The best way is to sidestep the problem altogether add all the points to the curve at once. This means you don't have to worry about array re-allocation and its faster too since reallocating the entire array for every point added is inefficient.
The best way is to sidestep the problem altogether add all the points to the curve at once.
This means you don't have to worry about array re-allocation and its faster too
since reallocating the entire array for every point added is inefficient.
Removing Data
-------------
**Any** data that you remove shouldn't be modified or accessed afterwards, this includes f-curves, drivers, render layers, timeline markers, modifiers, constraints along with objects, scenes, groups, bones.. etc.
**Any** data that you remove shouldn't be modified or accessed afterwards,
this includes f-curves, drivers, render layers, timeline markers, modifiers, constraints
along with objects, scenes, groups, bones.. etc.
The ``remove()`` api calls will invalidate the data they free to prevent common mistakes.
@@ -658,12 +782,13 @@ The following example shows how this precortion works.
mesh = bpy.data.meshes.new(name="MyMesh")
# normally the script would use the mesh here...
bpy.data.meshes.remove(mesh)
print(mesh.name) # <- give an exception rather then crashing:
print(mesh.name) # <- give an exception rather than crashing:
# ReferenceError: StructRNA of type Mesh has been removed
But take care because this is limited to scripts accessing the variable which is removed, the next example will still crash.
But take care because this is limited to scripts accessing the variable which is removed,
the next example will still crash.
.. code-block:: python
@@ -676,9 +801,11 @@ But take care because this is limited to scripts accessing the variable which is
sys.exit
========
Some python modules will call ``sys.exit()`` themselves when an error occurs, while not common behavior this is something to watch out for because it may seem as if blender is crashing since ``sys.exit()`` will quit blender immediately.
Some Python modules will call ``sys.exit()`` themselves when an error occurs,
while not common behavior this is something to watch out for because it may seem
as if Blender is crashing since ``sys.exit()`` will close Blender immediately.
For example, the ``optparse`` module will print an error and exit if the arguments are invalid.
An ugly way of troubleshooting this is to set ``sys.exit = None`` and see what line of python code is quitting, you could of course replace ``sys.exit`` with your own function but manipulating python in this way is bad practice.
For example, the ``argparse`` module will print an error and exit if the arguments are invalid.
An ugly way of troubleshooting this is to set ``sys.exit = None`` and see what line of Python code is quitting,
you could of course replace ``sys.exit`` with your own function but manipulating Python in this way is bad practice.

View File

@@ -1,18 +1,25 @@
.. _info_overview:
*******************
Python API Overview
*******************
This document is to give an understanding of how python and blender fit together, covering some of the functionality that isn't obvious from reading the API reference and example scripts.
This document is to give an understanding of how Python and Blender fit together,
covering some of the functionality that isn't obvious from reading the API reference and example scripts.
Python in Blender
=================
Blender embeds a python interpreter which is started with blender and stays active. This interpreter runs scripts to draw the user interface and is used for some of Blender's internal tools too.
Blender embeds a Python interpreter which is started with Blender and stays active.
This interpreter runs scripts to draw the user interface and is used for some of Blender's internal tools too.
This is a typical python environment so tutorials on how to write python scripts will work running the scripts in blender too. Blender provides the :mod:`bpy` module to the python interpreter. This module can be imported in a script and gives access to blender data, classes, and functions. Scripts that deal with blender data will need to import this module.
This is a typical Python environment so tutorials on how to write Python scripts
will work running the scripts in Blender too.
Blender provides the :mod:`bpy` module to the Python interpreter.
This module can be imported in a script and gives access to Blender data, classes, and functions.
Scripts that deal with Blender data will need to import this module.
Here is a simple example of moving a vertex of the object named **Cube**:
@@ -21,84 +28,96 @@ Here is a simple example of moving a vertex of the object named **Cube**:
import bpy
bpy.data.objects["Cube"].data.vertices[0].co.x += 1.0
This modifies Blender's internal data directly. When you run this in the interactive console you will see the 3D viewport update.
This modifies Blender's internal data directly.
When you run this in the interactive console you will see the 3D viewport update.
The Default Environment
=======================
When developing your own scripts it may help to understand how blender sets up its python environment. Many python scripts come bundled with blender and can be used as a reference because they use the same API that script authors write tools in. Typical usage for scripts include: user interface, import/export, scene manipulation, automation, defining your own toolset and customization.
When developing your own scripts it may help to understand how Blender sets up its Python environment.
Many Python scripts come bundled with Blender and can be used as a reference
because they use the same API that script authors write tools in.
Typical usage for scripts include: user interface, import/export,
scene manipulation, automation, defining your own toolset and customization.
On startup blender scans the ``scripts/startup/`` directory for python modules and imports them. The exact location of this directory depends on your installation. `See the directory layout docs <http://wiki.blender.org/index.php/Doc:2.6/Manual/Introduction/Installing_Blender/DirectoryLayout>`_
On startup Blender scans the ``scripts/startup/`` directory for Python modules and imports them.
The exact location of this directory depends on your installation.
`See the directory layout docs
<https://www.blender.org/manual/getting_started/installing_blender/directorylayout.html>`__
Script Loading
==============
This may seem obvious but it's important to note the difference between executing a script directly or importing it as a module.
This may seem obvious but it's important to note the difference
between executing a script directly or importing it as a module.
Scripts that extend blender - define classes that exist beyond the scripts execution, this makes future access to these classes (to unregister for example) more difficult than importing as a module where class instance is kept in the module and can be accessed by importing that module later on.
Scripts that extend Blender - define classes that exist beyond the scripts execution,
this makes future access to these classes (to unregister for example)
more difficult than importing as a module where class instance is kept
in the module and can be accessed by importing that module later on.
For this reason it's preferable to only use directly execute scripts that don't extend blender by registering classes.
For this reason it's preferable to only use directly execute scripts that don't extend Blender by registering classes.
Here are some ways to run scripts directly in blender.
Here are some ways to run scripts directly in Blender.
* Loaded in the text editor and press **Run Script**.
- Loaded in the text editor and press **Run Script**.
- Typed or pasted into the interactive console.
- Execute a Python file from the command line with Blender, eg:
* Typed or pasted into the interactive console.
.. code-block:: sh
* Execute a python file from the command line with blender, eg:
``blender --python /home/me/my_script.py``
blender --python /home/me/my_script.py
To run as modules:
* The obvious way, ``import some_module`` command from the text window or interactive console.
* Open as a text block and tick "Register" option, this will load with the blend file.
* copy into one of the directories ``scripts/startup``, where they will be automatically imported on startup.
* define as an addon, enabling the addon will load it as a python module.
- The obvious way, ``import some_module`` command from the text window or interactive console.
- Open as a text block and tick "Register" option, this will load with the blend file.
- copy into one of the directories ``scripts/startup``, where they will be automatically imported on startup.
- define as an addon, enabling the addon will load it as a Python module.
Addons
------
Some of blenders functionality is best kept optional, alongside scripts loaded at startup we have addons which are kept in their own directory ``scripts/addons``, and only load on startup if selected from the user preferences.
Some of Blenders functionality is best kept optional,
alongside scripts loaded at startup we have addons which are kept in their own directory ``scripts/addons``,
and only load on startup if selected from the user preferences.
The only difference between addons and built-in python modules is that addons must contain a **bl_info** variable which blender uses to read metadata such as name, author, category and URL.
The only difference between addons and built-in Python modules is that addons must contain a ``bl_info``
variable which Blender uses to read metadata such as name, author, category and URL.
The user preferences addon listing uses **bl_info** to display information about each addon.
`See Addons <http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons>`_ for details on the **bl_info** dictionary.
`See Addons <http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons>`__
for details on the ``bl_info`` dictionary.
Integration through Classes
===========================
Running python scripts in the text editor is useful for testing but youll want to extend blender to make tools accessible like other built-in functionality.
Running Python scripts in the text editor is useful for testing but you'll
want to extend Blender to make tools accessible like other built-in functionality.
The blender python api allows integration for:
The Blender Python api allows integration for:
* :class:`bpy.types.Panel`
* :class:`bpy.types.Menu`
* :class:`bpy.types.Operator`
* :class:`bpy.types.PropertyGroup`
* :class:`bpy.types.KeyingSet`
* :class:`bpy.types.RenderEngine`
- :class:`bpy.types.Panel`
- :class:`bpy.types.Menu`
- :class:`bpy.types.Operator`
- :class:`bpy.types.PropertyGroup`
- :class:`bpy.types.KeyingSet`
- :class:`bpy.types.RenderEngine`
This is intentionally limited. Currently, for more advanced features such as mesh modifiers, object types, or shader nodes, C/C++ must be used.
This is intentionally limited. Currently, for more advanced features such as mesh modifiers,
object types, or shader nodes, C/C++ must be used.
For python intergration Blender defines methods which are common to all types. This works by creating a python subclass of a Blender class which contains variables and functions specified by the parent class which are pre-defined to interface with Blender.
For Python integration Blender defines methods which are common to all types.
This works by creating a Python subclass of a Blender class which contains variables and functions
specified by the parent class which are pre-defined to interface with Blender.
For example:
@@ -115,15 +134,20 @@ For example:
bpy.utils.register_class(SimpleOperator)
First note that we subclass a member of :mod:`bpy.types`, this is common for all classes which can be integrated with blender and used so we know if this is an Operator and not a Panel when registering.
First note that we subclass a member of :mod:`bpy.types`,
this is common for all classes which can be integrated with Blender and
used so we know if this is an Operator and not a Panel when registering.
Both class properties start with a **bl_** prefix. This is a convention used to distinguish blender properties from those you add yourself.
Both class properties start with a ``bl_`` prefix.
This is a convention used to distinguish Blender properties from those you add yourself.
Next see the execute function, which takes an instance of the operator and the current context. A common prefix is not used for functions.
Next see the execute function, which takes an instance of the operator and the current context.
A common prefix is not used for functions.
Lastly the register function is called, this takes the class and loads it into blender. See `Class Registration`_.
Lastly the register function is called, this takes the class and loads it into Blender. See `Class Registration`_.
Regarding inheritance, blender doesn't impose restrictions on the kinds of class inheritance used, the registration checks will use attributes and functions defined in parent classes.
Regarding inheritance, Blender doesn't impose restrictions on the kinds of class inheritance used,
the registration checks will use attributes and functions defined in parent classes.
class mix-in example:
@@ -141,11 +165,20 @@ class mix-in example:
bpy.utils.register_class(SimpleOperator)
Notice these classes don't define an ``__init__(self)`` function. While ``__init__()`` and ``__del__()`` will be called if defined, the class instances lifetime only spans the execution. So a panel for example will have a new instance for every redraw, for this reason there is rarely a cause to store variables in the panel instance. Instead, persistent variables should be stored in Blenders data so that the state can be restored when blender is restarted.
Notice these classes don't define an ``__init__(self)`` function.
While ``__init__()`` and ``__del__()`` will be called if defined,
the class instances lifetime only spans the execution.
So a panel for example will have a new instance for every redraw,
for this reason there is rarely a cause to store variables in the panel instance.
Instead, persistent variables should be stored in Blenders
ata so that the state can be restored when Blender is restarted.
.. note:: Modal operators are an exception, keeping their instance variable as blender runs, see modal operator template.
.. note::
So once the class is registered with blender, instancing the class and calling the functions is left up to blender. In fact you cannot instance these classes from the script as you would expect with most python API's.
Modal operators are an exception, keeping their instance variable as Blender runs, see modal operator template.
So once the class is registered with Blender, instancing the class and calling the functions is left up to Blender.
In fact you cannot instance these classes from the script as you would expect with most Python API's.
To run operators you can call them through the operator api, eg:
@@ -154,7 +187,8 @@ To run operators you can call them through the operator api, eg:
import bpy
bpy.ops.object.simple_operator()
User interface classes are given a context in which to draw, buttons window, file header, toolbar etc, then they are drawn when that area is displayed so they are never called by python scripts directly.
User interface classes are given a context in which to draw, buttons window, file header, toolbar etc,
then they are drawn when that area is displayed so they are never called by Python scripts directly.
Registration
@@ -164,9 +198,10 @@ Registration
Module Registration
-------------------
Blender modules loaded at startup require ``register()`` and ``unregister()`` functions. These are the *only* functions that blender calls from your code, which is otherwise a regular python module.
Blender modules loaded at startup require ``register()`` and ``unregister()`` functions.
These are the *only* functions that Blender calls from your code, which is otherwise a regular Python module.
A simple blender/python module can look like this:
A simple Blender/Python module can look like this:
.. code-block:: python
@@ -184,12 +219,16 @@ A simple blender/python module can look like this:
if __name__ == "__main__":
register()
These functions usually appear at the bottom of the script containing class registration sometimes adding menu items. You can also use them for internal purposes setting up data for your own tools but take care since register won't re-run when a new blend file is loaded.
These functions usually appear at the bottom of the script containing class registration sometimes adding menu items.
You can also use them for internal purposes setting up data for your own tools but take care
since register won't re-run when a new blend file is loaded.
The register/unregister calls are used so it's possible to toggle addons and reload scripts while blender runs.
If the register calls were placed in the body of the script, registration would be called on import, meaning there would be no distinction between importing a module or loading its classes into blender.
The register/unregister calls are used so it's possible to toggle addons and reload scripts while Blender runs.
If the register calls were placed in the body of the script, registration would be called on import,
meaning there would be no distinction between importing a module or loading its classes into Blender.
This becomes problematic when a script imports classes from another module making it difficult to manage which classes are being loaded and when.
This becomes problematic when a script imports classes from another module
making it difficult to manage which classes are being loaded and when.
The last 2 lines are only for testing:
@@ -199,19 +238,24 @@ The last 2 lines are only for testing:
register()
This allows the script to be run directly in the text editor to test changes.
This ``register()`` call won't run when the script is imported as a module since ``__main__`` is reserved for direct execution.
This ``register()`` call won't run when the script is imported as a module
since ``__main__`` is reserved for direct execution.
Class Registration
------------------
Registering a class with blender results in the class definition being loaded into blender, where it becomes available alongside existing functionality.
Registering a class with Blender results in the class definition being loaded into Blender,
where it becomes available alongside existing functionality.
Once this class is loaded you can access it from :mod:`bpy.types`, using the bl_idname rather than the classes original name.
Once this class is loaded you can access it from :mod:`bpy.types`,
using the bl_idname rather than the classes original name.
When loading a class, blender performs sanity checks making sure all required properties and functions are found, that properties have the correct type, and that functions have the right number of arguments.
When loading a class, Blender performs sanity checks making sure all required properties and functions are found,
that properties have the correct type, and that functions have the right number of arguments.
Mostly you will not need concern yourself with this but if there is a problem with the class definition it will be raised on registering:
Mostly you will not need concern yourself with this but if there is a problem
with the class definition it will be raised on registering:
Using the function arguments ``def execute(self, context, spam)``, will raise an exception:
@@ -225,9 +269,13 @@ Using ``bl_idname = 1`` will raise.
Multiple-Classes
^^^^^^^^^^^^^^^^
Loading classes into blender is described above, for simple cases calling :mod:`bpy.utils.register_class` (SomeClass) is sufficient, but when there are many classes or a packages submodule has its own classes it can be tedious to list them all for registration.
Loading classes into Blender is described above,
for simple cases calling :mod:`bpy.utils.register_class` (SomeClass) is sufficient,
but when there are many classes or a packages submodule has its own
classes it can be tedious to list them all for registration.
For more convenient loading/unloading :mod:`bpy.utils.register_module` (module) and :mod:`bpy.utils.unregister_module` (module) functions exist.
For more convenient loading/unloading :mod:`bpy.utils.register_module` (module)
and :mod:`bpy.utils.unregister_module` (module) functions exist.
A script which defines many of its own operators, panels menus etc. you only need to write:
@@ -239,13 +287,19 @@ A script which defines many of its own operators, panels menus etc. you only nee
def unregister():
bpy.utils.unregister_module(__name__)
Internally blender collects subclasses on registrable types, storing them by the module in which they are defined. By passing the module name to :mod:`bpy.utils.register_module` blender can register all classes created by this module and its submodules.
Internally Blender collects subclasses on registrable types, storing them by the module in which they are defined.
By passing the module name to :mod:`bpy.utils.register_module`
Blender can register all classes created by this module and its submodules.
Inter Classes Dependencies
^^^^^^^^^^^^^^^^^^^^^^^^^^
When customizing blender you may want to group your own settings together, after all, they will likely have to co-exist with other scripts. To group these properties classes need to be defined, for groups within groups or collections within groups you can find yourself having to deal with order of registration/unregistration.
When customizing Blender you may want to group your own settings together,
after all, they will likely have to co-exist with other scripts.
To group these properties classes need to be defined,
for groups within groups or collections within groups
you can find yourself having to deal with order of registration/unregistration.
Custom properties groups are themselves classes which need to be registered.
@@ -311,7 +365,9 @@ Say you want to store material settings for a custom engine.
Manipulating Classes
^^^^^^^^^^^^^^^^^^^^
Properties can be added and removed as blender runs, normally happens on register or unregister but for some special cases it may be useful to modify types as the script runs.
Properties can be added and removed as Blender runs,
normally happens on register or unregister but for some
special cases it may be useful to modify types as the script runs.
For example:
@@ -341,7 +397,8 @@ This works just as well for PropertyGroup subclasses you define yourself.
Dynamic Defined-Classes (Advanced)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In some cases the specifier for data may not be in blender, renderman shader definitions for example and it may be useful to define types and remove them on the fly.
In some cases the specifier for data may not be in Blender,
renderman shader definitions for example and it may be useful to define types and remove them on the fly.
.. code-block:: python
@@ -360,7 +417,8 @@ In some cases the specifier for data may not be in blender, renderman shader def
.. note::
Notice ``type()`` is called to define the class. This is an alternative syntax for class creation in python, better suited to constructing classes dynamically.
``type()`` is called to define the class.
This is an alternative syntax for class creation in Python, better suited to constructing classes dynamically.
Calling these operators:

View File

@@ -1,3 +1,4 @@
.. _info_quickstart:
***********************
@@ -32,13 +33,15 @@ The Blender/Python API **can't** (yet)...
Before Starting
===============
This document isn't intended to fully cover each topic. Rather, its purpose is to familiarize you with Blender Python API.
This document isn't intended to fully cover each topic.
Rather, its purpose is to familiarize you with Blender Python API.
A quick list of helpful things to know before starting:
- Blender uses Python 3.x; some online documentation still assumes 2.x.
- The interactive console is great for testing one-liners, It also has autocompletion so you can inspect the API quickly.
- The interactive console is great for testing one-liners.
It also has autocompletion so you can inspect the API quickly.
- Button tool tips show Python attributes and operator names.
- Right clicking on buttons and menu items directly links to API documentation.
- For more examples, the text menu has a templates section where some example operators can be found.
@@ -51,15 +54,19 @@ A quick list of helpful things to know before starting:
Running Scripts
---------------
The two most common ways to execute Python scripts are using the built-in text editor or entering commands in the Python console.
The two most common ways to execute Python scripts are using the built-in
text editor or entering commands in the Python console.
Both the **Text Editor** and **Python Console** are space types you can select from the view header.
Both the *Text Editor* and *Python Console* are space types you can select from the view header.
Rather then manually configuring your spaces for Python development, you may prefer to use the **Scripting** screen, included default with Blender, accessible from the top headers screen selector.
Rather than manually configuring your spaces for Python development,
you may prefer to use the *Scripting* screen, included default with Blender,
accessible from the top headers screen selector.
From the text editor you can open ``.py`` files or paste then from the clipboard, then test using **Run Script**.
From the text editor you can open ``.py`` files or paste then from the clipboard, then test using *Run Script*.
The Python Console is typically used for typing in snippets and for testing to get immediate feedback, but can also have entire scripts pasted into it.
The Python Console is typically used for typing in snippets and for testing to get immediate feedback,
but can also have entire scripts pasted into it.
Scripts can also run from the command line with Blender but to learn Blender/Python this isn't essential.
@@ -73,9 +80,11 @@ Data Access
Accessing DataBlocks
^^^^^^^^^^^^^^^^^^^^
Python accesses Blender's data in the same way as the animation system and user interface; this implies that any setting that can be changed via a button can also be changed from Python.
Python accesses Blender's data in the same way as the animation system and user interface;
this implies that any setting that can be changed via a button can also be changed from Python.
Accessing data from the currently loaded blend file is done with the module :mod:`bpy.data`. This gives access to library data. For example:
Accessing data from the currently loaded blend file is done with the module :mod:`bpy.data`.
This gives access to library data. For example:
>>> bpy.data.objects
<bpy_collection[3], BlendDataObjects>
@@ -92,7 +101,8 @@ About Collections
You'll notice that an index as well as a string can be used to access members of the collection.
Unlike Python's dictionaries, both methods are acceptable; however, the index of a member may change while running Blender.
Unlike Python's dictionaries, both methods are acceptable;
however, the index of a member may change while running Blender.
>>> list(bpy.data.objects)
[bpy.data.objects["Cube"], bpy.data.objects["Plane"]]
@@ -107,7 +117,10 @@ Unlike Python's dictionaries, both methods are acceptable; however, the index of
Accessing Attributes
^^^^^^^^^^^^^^^^^^^^
Once you have a data block, such as a material, object, groups etc., its attributes can be accessed much like you would change a setting using the graphical interface. In fact, the tooltip for each button also displays the Python attribute which can help in finding what settings to change in a script.
Once you have a data block, such as a material, object, groups etc.,
its attributes can be accessed much like you would change a setting using the graphical interface.
In fact, the tooltip for each button also displays the Python attribute
which can help in finding what settings to change in a script.
>>> bpy.data.objects[0].name
'Camera'
@@ -119,7 +132,8 @@ Once you have a data block, such as a material, object, groups etc., its attribu
bpy.data.materials['MyMaterial']
For testing what data to access it's useful to use the "Console", which is its own space type. This supports auto-complete, giving you a fast way to dig into different data in your file.
For testing what data to access it's useful to use the "Console", which is its own space type.
This supports auto-complete, giving you a fast way to dig into different data in your file.
Example of a data path that can be quickly found via the console:
@@ -132,7 +146,8 @@ Example of a data path that can be quickly found via the console:
Data Creation/Removal
^^^^^^^^^^^^^^^^^^^^^
Those of you familiar with other Python API's may be surprised that new datablocks in the bpy API can't be created by calling the class:
Those of you familiar with other Python API's may be surprised that
new datablocks in the bpy API can't be created by calling the class:
>>> bpy.types.Mesh()
Traceback (most recent call last):
@@ -141,7 +156,8 @@ Those of you familiar with other Python API's may be surprised that new databloc
This is an intentional part of the API design.
The Blender/Python API can't create Blender data that exists outside the main Blender database (accessed through :mod:`bpy.data`), because this data is managed by Blender (save/load/undo/append... etc).
The Blender/Python API can't create Blender data that exists outside the main Blender database
(accessed through :mod:`bpy.data`), because this data is managed by Blender (save/load/undo/append... etc).
Data is added and removed via methods on the collections in :mod:`bpy.data`, eg:
@@ -155,8 +171,10 @@ Data is added and removed via methods on the collections in :mod:`bpy.data`, eg:
Custom Properties
^^^^^^^^^^^^^^^^^
Python can access properties on any datablock that has an ID (data that can be linked in and accessed from :mod:`bpy.data`.
When assigning a property, you can make up your own names, these will be created when needed or overwritten if they exist.
Python can access properties on any datablock that has an ID
(data that can be linked in and accessed from :mod:`bpy.data`.
When assigning a property, you can make up your own names,
these will be created when needed or overwritten if they exist.
This data is saved with the blend file and copied with objects.
@@ -192,8 +210,10 @@ These properties are valid outside of Python. They can be animated by curves or
Context
-------
While it's useful to be able to access data directly by name or as a list, it's more common to operate on the user's selection.
The context is always available from ``bpy.context`` and can be used to get the active object, scene, tool settings along with many other attributes.
While it's useful to be able to access data directly by name or as a list,
it's more common to operate on the user's selection.
The context is always available from ``bpy.context`` and can be used to get the active object, scene,
tool settings along with many other attributes.
Common-use cases:
@@ -201,7 +221,9 @@ Common-use cases:
>>> bpy.context.selected_objects
>>> bpy.context.visible_bones
Note that the context is read-only. These values cannot be modified directly, though they may be changed by running API functions or by using the data API.
Note that the context is read-only.
These values cannot be modified directly,
though they may be changed by running API functions or by using the data API.
So ``bpy.context.object = obj`` will raise an error.
@@ -209,7 +231,8 @@ But ``bpy.context.scene.objects.active = obj`` will work as expected.
The context attributes change depending on where they are accessed.
The 3D view has different context members than the console, so take care when accessing context attributes that the user state is known.
The 3D view has different context members than the console,
so take care when accessing context attributes that the user state is known.
See :mod:`bpy.context` API reference.
@@ -217,7 +240,9 @@ See :mod:`bpy.context` API reference.
Operators (Tools)
-----------------
Operators are tools generally accessed by the user from buttons, menu items or key shortcuts. From the user perspective they are a tool but Python can run these with its own settings through the :mod:`bpy.ops` module.
Operators are tools generally accessed by the user from buttons, menu items or key shortcuts.
From the user perspective they are a tool but Python can run these with its own settings
through the :mod:`bpy.ops` module.
Examples:
@@ -230,14 +255,16 @@ Examples:
.. note::
The menu item: :menuselection:`Help --> Operator Cheat Sheet` gives a list of all operators and their default values in Python syntax, along with the generated docs.
The menu item: :menuselection:`Help --> Operator Cheat Sheet`
gives a list of all operators and their default values in Python syntax, along with the generated docs.
This is a good way to get an overview of all Blender's operators.
Operator Poll()
^^^^^^^^^^^^^^^
Many operators have a "poll" function which may check that the mouse is in a valid area or that the object is in the correct mode (Edit Mode, Weight Paint etc).
Many operators have a "poll" function which may check that the cursor
is in a valid area or that the object is in the correct mode (Edit Mode, Weight Paint etc).
When an operator's poll function fails within Python, an exception is raised.
For example, calling ``bpy.ops.view3d.render_border()`` from the console raises the following error:
@@ -248,7 +275,8 @@ For example, calling ``bpy.ops.view3d.render_border()`` from the console raises
In this case the context must be the 3d view with an active camera.
To avoid using try/except clauses wherever operators are called you can call the operators own .poll() function to check if it can run in the current context.
To avoid using try/except clauses wherever operators are called you can call the operators
own ``poll()`` function to check if it can run in the current context.
.. code-block:: python
@@ -275,7 +303,8 @@ Example Operator
.. literalinclude:: ../../../release/scripts/templates_py/operator_simple.py
Once this script runs, ``SimpleOperator`` is registered with Blender and can be called from the operator search popup or added to the toolbar.
Once this script runs, ``SimpleOperator`` is registered with Blender
and can be called from the operator search popup or added to the toolbar.
To run the script:
@@ -285,19 +314,23 @@ To run the script:
#. Click the button labeled ``New`` and the confirmation pop up in order to create a new text block.
#. Press :kbd:`Ctrl-V` to paste the code into the text panel (the upper left frame).
#. Click on the button **Run Script**.
#. Move your mouse into the 3D view, press spacebar for the operator search menu, and type "Simple".
#. Move your cursor into the 3D view, press spacebar for the operator search menu, and type "Simple".
#. Click on the "Simple Operator" item found in search.
.. seealso:: The class members with the ``bl_`` prefix are documented in the API
reference :class:`bpy.types.Operator`
.. note:: The output from the ``main`` function is sent to the terminal; in order to see this, be sure to :ref:`use the terminal <use_the_terminal>`.
.. note::
The output from the ``main`` function is sent to the terminal;
in order to see this, be sure to :ref:`use the terminal <use_the_terminal>`.
Example Panel
-------------
Panels register themselves as a class, like an operator. Notice the extra ``bl_`` variables used to set the context they display in.
Panels register themselves as a class, like an operator.
Notice the extra ``bl_`` variables used to set the context they display in.
.. literalinclude:: ../../../release/scripts/templates_py/ui_panel_simple.py
@@ -334,7 +367,8 @@ Blender's Python API can be split up into 3 categories.
Native Types
------------
In simple cases returning a number or a string as a custom type would be cumbersome, so these are accessed as normal Python types.
In simple cases returning a number or a string as a custom type would be cumbersome,
so these are accessed as normal Python types.
- Blender float/int/boolean -> float/int/boolean
- Blender enumerator -> string
@@ -359,7 +393,8 @@ Used for Blender datablocks and collections: :class:`bpy.types.bpy_struct`
For data that contains its own attributes groups/meshes/bones/scenes... etc.
There are 2 main types that wrap Blenders data, one for datablocks (known internally as ``bpy_struct``), another for properties.
There are 2 main types that wrap Blenders data, one for datablocks
(known internally as ``bpy_struct``), another for properties.
>>> bpy.context.object
bpy.data.objects['Cube']
@@ -375,7 +410,9 @@ Mathutils Types
Used for vectors, quaternion, eulers, matrix and color types, accessible from :mod:`mathutils`
Some attributes such as :class:`bpy.types.Object.location`, :class:`bpy.types.PoseBone.rotation_euler` and :class:`bpy.types.Scene.cursor_location` can be accessed as special math types which can be used together and manipulated in various useful ways.
Some attributes such as :class:`bpy.types.Object.location`,
:class:`bpy.types.PoseBone.rotation_euler` and :class:`bpy.types.Scene.cursor_location`
can be accessed as special math types which can be used together and manipulated in various useful ways.
Example of a matrix, vector multiplication:
@@ -410,7 +447,9 @@ Animation
There are 2 ways to add keyframes through Python.
The first is through key properties directly, which is similar to inserting a keyframe from the button as a user. You can also manually create the curves and keyframe data, then set the path to the property. Here are examples of both methods.
The first is through key properties directly, which is similar to inserting a keyframe from the button as a user.
You can also manually create the curves and keyframe data, then set the path to the property.
Here are examples of both methods.
Both examples insert a keyframe on the active object's Z axis.

View File

@@ -1,10 +1,12 @@
***************
Tips and Tricks
***************
Here are various suggestions that you might find useful when writing scripts.
Some of these are just python features that scripters may not have thought to use with blender, others are blender specific.
Some of these are just Python features that scripters may not have thought to use with Blender,
others are Blender specific.
.. _use_the_terminal:
@@ -12,18 +14,21 @@ Some of these are just python features that scripters may not have thought to us
Use The Terminal
================
When writing python scripts, it's useful to have a terminal open, this is not the built-in python console but a terminal application which is used to start blender.
When writing Python scripts, it's useful to have a terminal open,
this is not the built-in Python console but a terminal application which is used to start Blender.
There are 3 main uses for the terminal, these are:
* You can see the output of ``print()`` as your script runs, which is useful to view debug info.
* The error trace-back is printed in full to the terminal which won't always generate an error popup in blender's user interface (depending on how the script is executed).
* If the script runs for too long or you accidentally enter an infinite loop, Ctrl+C in the terminal (Ctrl+Break on Windows) will quit the script early.
- You can see the output of ``print()`` as your script runs, which is useful to view debug info.
- The error trace-back is printed in full to the terminal which won't always generate an error popup in
Blender's user interface (depending on how the script is executed).
- If the script runs for too long or you accidentally enter an infinite loop,
:kbd:`Ctrl-C` in the terminal (:kbd:`Ctrl-Break` on Windows) will quit the script early.
.. note::
For Linux and OSX users this means starting the terminal first, then running blender from within it. On Windows the terminal can be enabled from the help menu.
For Linux and OSX users this means starting the terminal first, then running Blender from within it.
On Windows the terminal can be enabled from the help menu.
Interface Tricks
@@ -33,43 +38,56 @@ Interface Tricks
Access Operator Commands
------------------------
You may have noticed that the tooltip for menu items and buttons includes the ``bpy.ops``... command to run that button, a handy (hidden) feature is that you can press Ctrl+C over any menu item/button to copy this command into the clipboard.
You may have noticed that the tooltip for menu items and buttons includes the ``bpy.ops.[...])`` command
to run that button, a handy (hidden) feature is that you can press :kbd:`Ctrl-C` over
any menu item/button to copy this command into the clipboard.
Access Data Path
----------------
To find the path from an :class:`ID` datablock to its setting isn't always so simple since it may be nested away. To get this quickly you can right click on the setting and select select **Copy Data Path**,
To find the path from an :class:`ID` datablock to its setting isn't always so simple since it may be nested away.
To get this quickly you can right click on the setting and select select **Copy Data Path**,
if this can't be generated, only the property name is copied.
.. note::
This uses the same method for creating the animation path used by :class:`bpy.types.FCurve.data_path` and :class:`bpy.types.DriverTarget.data_path` drivers.
This uses the same method for creating the animation path used by
:class:`bpy.types.FCurve.data_path` and
:class:`bpy.types.DriverTarget.data_path` drivers.
.. _info_show_all_operators
.. _info_show_all_operators:
Show All Operators
==================
While blender logs operators in the Info space, this only reports operators with the ``REGISTER`` option enabeld so as not to flood the Info view with calls to ``bpy.ops.view3d.smoothview`` and ``bpy.ops.view3d.zoom``.
While Blender logs operators in the Info space,
this only reports operators with the ``REGISTER`` option enabeld so as not to flood the *Info* view
with calls to ``bpy.ops.view3d.smoothview`` and ``bpy.ops.view3d.zoom``.
However, for testing it can be useful to see **every** operator called in a terminal, do this by enabling the debug option either by passing the ``--debug-wm`` argument when starting blender or by setting :mod:`bpy.app.debug_wm` to True while blender is running.
However, for testing it can be useful to see **every** operator called in a terminal,
do this by enabling the debug option either by passing the ``--debug-wm`` argument when starting Blender
or by setting :mod:`bpy.app.debug_wm` to ``True`` while Blender is running.
Use an External Editor
======================
Blenders text editor is fine for small changes and writing tests but its not full featured, for larger projects you'll probably want to use a standalone editor or python IDE.
Blenders text editor is fine for small changes and writing tests but its not full featured,
for larger projects you'll probably want to use a standalone editor or Python IDE.
Editing a text file externally and having the same text open in blender does work but isn't that optimal so here are 2 ways you can easily use an external file from blender.
Editing a text file externally and having the same text open in Blender does work but isn't that optimal
so here are 2 ways you can easily use an external file from Blender.
Using the following examples you'll still need textblock in Blender to execute,
but reference an external file rather than including it directly.
Using the following examples you'll still need textblock in blender to execute, but reference an external file rather then including it directly.
Executing External Scripts
--------------------------
This is the equivalent to running the script directly, referencing a scripts path from a 2 line textblock.
This is the equivalent to running the script directly, referencing a scripts path from a 2 line text-block.
.. code-block:: python
@@ -102,12 +120,17 @@ This example shows loading a script in as a module and executing a module functi
myscript.main()
Notice that the script is reloaded every time, this forces use of the modified version, otherwise the cached one in ``sys.modules`` would be used until blender was restarted.
Notice that the script is reloaded every time, this forces use of the modified version,
otherwise the cached one in ``sys.modules`` would be used until Blender was restarted.
The important difference between this and executing the script directly is it has to call a function in the module, in this case ``main()`` but it can be any function, an advantage with this is you can pass arguments to the function from this small script which is often useful for testing different settings quickly.
The important difference between this and executing the script directly is it
has to call a function in the module, in this case ``main()`` but it can be any function,
an advantage with this is you can pass arguments to the function from this
small script which is often useful for testing different settings quickly.
The other issue with this is the script has to be in pythons module search path.
While this is not best practice - for testing you can extend the search path, this example adds the current blend files directory to the search path, then loads the script as a module.
The other issue with this is the script has to be in Pythons module search path.
While this is not best practice - for testing you can extend the search path,
this example adds the current blend files directory to the search path, then loads the script as a module.
.. code-block:: python
@@ -128,71 +151,86 @@ While this is not best practice - for testing you can extend the search path, th
Don't Use Blender!
==================
While developing your own scripts blenders interface can get in the way, manually reloading, running the scripts, opening file import etc. adds overhead.
While developing your own scripts Blenders interface can get in the way,
manually reloading, running the scripts, opening file import etc. adds overhead.
For scripts that are not interactive it can end up being more efficient not to use blenders interface at all and instead execute the script on the command line.
For scripts that are not interactive it can end up being more efficient not to use
Blenders interface at all and instead execute the script on the command line.
.. code-block:: python
.. code-block:: sh
blender --background --python myscript.py
You might want to run this with a blend file so the script has some data to operate on.
.. code-block:: python
.. code-block:: sh
blender myscene.blend --background --python myscript.py
.. note::
Depending on your setup you might have to enter the full path to the blender executable.
Depending on your setup you might have to enter the full path to the Blender executable.
Once the script is running properly in background mode, you'll want to check the output of the script, this depends completely on the task at hand however here are some suggestions.
Once the script is running properly in background mode, you'll want to check the output of the script,
this depends completely on the task at hand however here are some suggestions.
* render the output to an image, use an image viewer and keep writing over the same image each time.
* save a new blend file, or export the file using one of blenders exporters.
* if the results can be displayed as text - print them or write them to a file.
- render the output to an image, use an image viewer and keep writing over the same image each time.
- save a new blend file, or export the file using one of Blenders exporters.
- if the results can be displayed as text - print them or write them to a file.
This can take a little time to setup, but it can be well worth the effort to reduce the time it takes to test changes - you can even have blender running the script ever few seconds with a viewer updating the results, so no need to leave your text editor to see changes.
While this can take a little time to setup, it can be well worth the effort
to reduce the time it takes to test changes - you can even have
Blender running the script every few seconds with a viewer updating the results,
so no need to leave your text editor to see changes.
Use External Tools
==================
When there are no readily available python modules to perform specific tasks it's worth keeping in mind you may be able to have python execute an external command on your data and read the result back in.
When there are no readily available Python modules to perform specific tasks it's
worth keeping in mind you may be able to have Python execute an external command
on your data and read the result back in.
Using external programs adds an extra dependency and may limit who can use the script but to quickly setup your own custom pipeline or writing one-off scripts this can be handy.
Using external programs adds an extra dependency and may limit who can use the script
but to quickly setup your own custom pipeline or writing one-off scripts this can be handy.
Examples include:
* Run The Gimp in batch mode to execute custom scripts for advanced image processing.
* Write out 3D models to use external mesh manipulation tools and read back in the results.
* Convert files into recognizable formats before reading.
- Run The Gimp in batch mode to execute custom scripts for advanced image processing.
- Write out 3D models to use external mesh manipulation tools and read back in the results.
- Convert files into recognizable formats before reading.
Bundled Python & Extensions
===========================
The Blender releases distributed from blender.org include a complete python installation on all platforms, this has the disadvantage that any extensions you have installed in your systems python wont be found by blender.
The Blender releases distributed from blender.org include a complete Python installation on all platforms,
this has the disadvantage that any extensions you have installed in your systems Python wont be found by Blender.
There are 2 ways around this:
* remove blender python sub-directory, blender will then fallback on the systems python and use that instead **python version must match the one that blender comes with**.
- remove Blender Python sub-directory, Blender will then fallback on the systems Python and use that instead
.. warning::
* copy the extensions into blender's python sub-directory so blender can access them, you could also copy the entire python installation into blenders sub-directory, replacing the one blender comes with. This works as long as the python versions match and the paths are created in the same relative locations. Doing this has the advantage that you can redistribute this bundle to others with blender and/or the game player, including any extensions you rely on.
The Python version must match the one that Blender comes with.
- copy the extensions into Blender's Python sub-directory so Blender can access them,
you could also copy the entire Python installation into Blenders sub-directory,
replacing the one Blender comes with.
This works as long as the Python versions match and the paths are created in the same relative locations.
Doing this has the advantage that you can redistribute this bundle to others with Blender and/or the game player,
including any extensions you rely on.
Drop Into a Python Interpreter in Your Script
=============================================
In the middle of a script you may want to inspect some variables, run some function and generally dig about to see whats going on.
In the middle of a script you may want to inspect some variables,
run some function and generally dig about to see whats going on.
.. code-block:: python
@@ -217,10 +255,13 @@ The next example is an equivalent single line version of the script above which
__import__('code').interact(local=dict(globals(), **locals()))
``code.interact`` can be added at any line in the script and will pause the script an launch an interactive interpreter in the terminal, when you're done you can quit the interpreter and the script will continue execution.
``code.interact`` can be added at any line in the script
and will pause the script an launch an interactive interpreter in the terminal,
when you're done you can quit the interpreter and the script will continue execution.
If you have **IPython** installed you can use their ``embed()`` function which will implicitly use the current namespace, this has autocomplete and some useful features that the standard python eval-loop doesn't have.
If you have **IPython** installed you can use its ``embed()`` function which uses the current namespace.
The IPython prompt has auto-complete and some useful features that the standard Python eval-loop doesn't have.
.. code-block:: python
@@ -228,7 +269,7 @@ If you have **IPython** installed you can use their ``embed()`` function which w
IPython.embed()
Admittedly this highlights the lack of any python debugging support built into blender, but its still handy to know.
Admittedly this highlights the lack of any Python debugging support built into Blender, but its still handy to know.
.. note::
@@ -242,27 +283,32 @@ Advanced
Blender as a module
-------------------
From a python perspective it's nicer to have everything as an extension which lets the python script combine many components.
From a Python perspective it's nicer to have everything as an extension
which lets the Python script combine many components.
Advantages include:
* you can use external editors/IDE's with blenders python API and execute scripts within the IDE (step over code, inspect variables as the script runs).
* editors/IDE's can auto complete blender modules & variables.
* existing scripts can import blender API's without having to run inside blender.
- you can use external editors/IDE's with Blenders Python API and execute scripts within the IDE
(step over code, inspect variables as the script runs).
- editors/IDE's can auto complete Blender modules & variables.
- existing scripts can import Blender API's without having to run inside Blender.
This is marked advanced because to run blender as a python module requires a special build option.
This is marked advanced because to run Blender as a Python module requires a special build option.
For instructions on building see `Building blender as a python module <http://wiki.blender.org/index.php/User:Ideasman42/BlenderAsPyModule>`_
For instructions on building see
`Building Blender as a Python module <http://wiki.blender.org/index.php/User:Ideasman42/BlenderAsPyModule>`_
Python Safety (Build Option)
----------------------------
Since it's possible to access data which has been removed (see Gotcha's), this can be hard to track down the cause of crashes.
Since it's possible to access data which has been removed (see Gotcha's),
this can be hard to track down the cause of crashes.
To raise python exceptions on accessing freed data (rather then crashing), enable the CMake build option WITH_PYTHON_SAFETY.
To raise Python exceptions on accessing freed data (rather than crashing),
enable the CMake build option WITH_PYTHON_SAFETY.
This enables data tracking which makes data access about 2x slower
which is why the option isn't enabled in release builds.
This enables data tracking which makes data access about 2x slower which is why the option is not enabled in release builds.

View File

@@ -208,6 +208,7 @@ The objects should move as before.
*Keep this addon open in Blender for the next step - Installing.*
Install The Addon
-----------------
@@ -221,10 +222,11 @@ restrictions that apply to Python modules and end with a ``.py`` extension.
Once the file is on disk, you can install it as you would for an addon downloaded online.
Open the user **File -> User Preferences**, Select the **Addon** section, press **Install Addon...** and select the file.
Open the user :menuselection:`File -> User Preferences`,
Select the *Addon* section, press *Install Addon...* and select the file.
Now the addon will be listed and you can enable it by pressing the check-box, if you want it to be enabled on restart,
press **Save as Default**.
Now the addon will be listed and you can enable it by pressing the check-box,
if you want it to be enabled on restart, press *Save as Default*.
.. note::
@@ -238,7 +240,7 @@ press **Save as Default**.
print(addon_utils.paths())
More is written on this topic here:
`Directory Layout <http://wiki.blender.org/index.php/Doc:2.6/Manual/Introduction/Installing_Blender/DirectoryLayout>`_
`Directory Layout <https://www.blender.org/manual/getting_started/installing_blender/directorylayout.html>`_
Your Second Addon

View File

@@ -234,6 +234,7 @@ else:
EXCLUDE_MODULES = [
"aud",
"bge",
"bge.app"
"bge.constraints",
"bge.events",
"bge.logic",
@@ -262,6 +263,7 @@ else:
"gpu",
"mathutils",
"mathutils.geometry",
"mathutils.bvhtree",
"mathutils.kdtree",
"mathutils.noise",
"freestyle",
@@ -630,7 +632,7 @@ def pyfunc2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_cla
if type(py_func) == MethodType:
return
arg_str = inspect.formatargspec(*inspect.getargspec(py_func))
arg_str = inspect.formatargspec(*inspect.getfullargspec(py_func))
if not is_class:
func_type = "function"
@@ -1598,7 +1600,7 @@ def write_rst_contents(basepath):
fw("\n")
# fw("`A PDF version of this document is also available <%s>`_\n" % BLENDER_PDF_FILENAME)
fw("`A compressed ZIP file of this site is available <%s>`_\n" % BLENDER_ZIP_FILENAME)
fw("This site can be downloaded for offline use `Download the full Documentation (zipped HTML files)<%s>`_\n" % BLENDER_ZIP_FILENAME)
fw("\n")
@@ -1643,7 +1645,7 @@ def write_rst_contents(basepath):
standalone_modules = (
# mathutils
"mathutils", "mathutils.geometry", "mathutils.kdtree", "mathutils.noise",
"mathutils", "mathutils.geometry", "mathutils.bvhtree", "mathutils.kdtree", "mathutils.noise",
# misc
"freestyle", "bgl", "blf", "gpu", "aud", "bpy_extras",
# bmesh, submodules are in own page
@@ -1669,6 +1671,7 @@ def write_rst_contents(basepath):
fw(" bge.texture.rst\n\n")
fw(" bge.events.rst\n\n")
fw(" bge.constraints.rst\n\n")
fw(" bge.app.rst\n\n")
# rna generated change log
fw(title_string("API Info", "=", double=True))
@@ -1794,6 +1797,7 @@ def write_rst_importable_modules(basepath):
"bpy.props" : "Property Definitions",
"mathutils" : "Math Types & Utilities",
"mathutils.geometry" : "Geometry Utilities",
"mathutils.bvhtree" : "BVHTree Utilities",
"mathutils.kdtree" : "KDTree Utilities",
"mathutils.noise" : "Noise Utilities",
"freestyle" : "Freestyle Module",
@@ -1825,6 +1829,7 @@ def copy_handwritten_rsts(basepath):
"bge.texture",
"bge.events",
"bge.constraints",
"bge.app",
"bgl", # "Blender OpenGl wrapper"
"gpu", # "GPU Shader Module"

View File

@@ -29,6 +29,7 @@ remove_strict_flags()
add_subdirectory(rangetree)
add_subdirectory(wcwidth)
add_subdirectory(libmv)
add_subdirectory(Eigen3)
if(WITH_OPENNL)
add_subdirectory(colamd)
@@ -77,7 +78,7 @@ if(WITH_LZMA)
add_subdirectory(lzma)
endif()
if(WITH_CYCLES OR WITH_COMPOSITOR)
if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
add_subdirectory(clew)
add_subdirectory(cuew)
endif()

41
extern/Eigen3/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,41 @@
# ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2015, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Bastien Montagne.
#
# ***** END GPL LICENSE BLOCK *****
set(INC
.
)
set(INC_SYS
)
set(SRC
eigen3_capi.h
intern/eigenvalues.cc
intern/eigenvalues.h
)
blender_add_lib(extern_eigen3 "${SRC}" "${INC}" "${INC_SYS}")

35
extern/Eigen3/SConscript vendored Normal file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/env python
#
# ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2015, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Bastien Montagne.
#
# ***** END GPL LICENSE BLOCK *****
Import('env')
sources = env.Glob('intern/*.cc')
incs = '.'
defs = []
env.BlenderLib('extern_eigen3', sources, Split(incs), defs, libtype=['extern','player'], priority=[10, 185])

32
extern/Eigen3/eigen3_capi.h vendored Normal file
View File

@@ -0,0 +1,32 @@
/*
* ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2015 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Bastien Montagne
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __EIGEN3_C_API_H__
#define __EIGEN3_C_API_H__
#include "intern/eigenvalues.h"
#endif /* __EIGEN3_C_API_H__ */

70
extern/Eigen3/intern/eigenvalues.cc vendored Normal file
View File

@@ -0,0 +1,70 @@
/*
* ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2015 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Bastien Montagne
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __EIGEN3_EIGENVALUES_C_API_CC__
#define __EIGEN3_EIGENVALUES_C_API_CC__
/* Eigen gives annoying huge amount of warnings here, silence them! */
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wlogical-op"
#endif
#include <Eigen/Core>
#include <Eigen/Eigenvalues>
#include "eigenvalues.h"
using Eigen::SelfAdjointEigenSolver;
using Eigen::MatrixXf;
using Eigen::VectorXf;
using Eigen::Map;
using Eigen::Success;
bool EG3_self_adjoint_eigen_solve(const int size, const float *matrix, float *r_eigen_values, float *r_eigen_vectors)
{
SelfAdjointEigenSolver<MatrixXf> eigen_solver;
/* Blender and Eigen matrices are both column-major. */
eigen_solver.compute(Map<MatrixXf>((float *)matrix, size, size));
if (eigen_solver.info() != Success) {
return false;
}
if (r_eigen_values) {
Map<VectorXf>(r_eigen_values, size) = eigen_solver.eigenvalues().transpose();
}
if (r_eigen_vectors) {
Map<MatrixXf>(r_eigen_vectors, size, size) = eigen_solver.eigenvectors();
}
return true;
}
#endif /* __EIGEN3_EIGENVALUES_C_API_CC__ */

40
extern/Eigen3/intern/eigenvalues.h vendored Normal file
View File

@@ -0,0 +1,40 @@
/*
* ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2015 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Blender Foundation,
* Bastien Montagne
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __EIGEN3_EIGENVALUES_C_API_H__
#define __EIGEN3_EIGENVALUES_C_API_H__
#ifdef __cplusplus
extern "C" {
#endif
bool EG3_self_adjoint_eigen_solve(const int size, const float *matrix, float *r_eigen_values, float *r_eigen_vectors);
#ifdef __cplusplus
}
#endif
#endif /* __EIGEN3_EIGENVALUES_C_API_H__ */

3
extern/SConscript vendored
View File

@@ -11,6 +11,7 @@ SConscript(['colamd/SConscript'])
SConscript(['rangetree/SConscript'])
SConscript(['wcwidth/SConscript'])
SConscript(['libmv/SConscript'])
SConscript(['Eigen3/SConscript'])
if env['WITH_BF_GAMEENGINE']:
SConscript(['recastnavigation/SConscript'])
@@ -24,7 +25,7 @@ if env['WITH_BF_ELTOPO']:
if env['WITH_BF_BULLET']:
SConscript(['bullet2/src/SConscript'])
if env['WITH_BF_COMPOSITOR'] or env['WITH_BF_CYCLES']:
if env['WITH_BF_COMPOSITOR'] or env['WITH_BF_CYCLES'] or env['WITH_BF_OPENSUBDIV']:
SConscript (['clew/SConscript'])
SConscript (['cuew/SConscript'])

View File

@@ -6,7 +6,9 @@ Import('env')
sources = ['src/glew.c']
defs = env['BF_GL_DEFINITIONS']
defs = []
defs += env['BF_GL_DEFINITIONS']
if env['WITH_BF_GLEW_MX']:
defs += ['GLEW_MX']
incs = ['include']

View File

@@ -6,7 +6,9 @@ Import('env')
sources = ['src/glew.c']
defs = env['BF_GL_DEFINITIONS']
defs = []
defs += env['BF_GL_DEFINITIONS']
if env['WITH_BF_GLEW_MX']:
defs += ['GLEW_MX']

View File

@@ -21,6 +21,13 @@
#
# ***** END GPL LICENSE BLOCK *****
# avoid noisy warnings
if(CMAKE_COMPILER_IS_GNUCC)
remove_cc_flag(
"-Wmissing-declarations"
)
endif()
set(INC
.
include

View File

@@ -77,8 +77,11 @@ if(WITH_OPENNL)
add_subdirectory(opennl)
endif()
if(WITH_OPENSUBDIV)
add_subdirectory(opensubdiv)
endif()
# only windows needs utf16 converter
if(WIN32)
add_subdirectory(utfconv)
endif()

View File

@@ -27,8 +27,7 @@
Import ('env')
SConscript(['audaspace/SConscript',
'string/SConscript',
SConscript(['string/SConscript',
'ghost/SConscript',
'glew-mx/SConscript',
'guardedalloc/SConscript',
@@ -45,6 +44,9 @@ SConscript(['audaspace/SConscript',
# currently only contains headers
# SConscript('container/SConscript')
if env['WITH_BF_AUDASPACE']:
SConscript(['audaspace/SConscript'])
if env ['WITH_BF_REMESH']:
SConscript(['dualcon/SConscript'])
@@ -63,3 +65,5 @@ if env['WITH_BF_BULLET']:
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-mingw', 'linuxcross', 'win64-vc'):
SConscript(['utfconv/SConscript'])
if env['WITH_BF_OPENSUBDIV']:
SConscript (['opensubdiv/SConscript'])

View File

@@ -123,13 +123,13 @@ atomic_cas_uint64(uint64_t *v, uint64_t old, uint64_t _new)
ATOMIC_INLINE uint64_t
atomic_add_uint64(uint64_t *p, uint64_t x)
{
return InterlockedExchangeAdd64((int64_t *)p, (int64_t)x);
return InterlockedExchangeAdd64((int64_t *)p, (int64_t)x) + x;
}
ATOMIC_INLINE uint64_t
atomic_sub_uint64(uint64_t *p, uint64_t x)
{
return InterlockedExchangeAdd64((int64_t *)p, -((int64_t)x));
return InterlockedExchangeAdd64((int64_t *)p, -((int64_t)x)) - x;
}
ATOMIC_INLINE uint64_t
@@ -215,7 +215,7 @@ atomic_sub_uint64(uint64_t *p, uint64_t x)
}
ATOMIC_INLINE uint64_t
atomic_cas_uint32(uint64_t *v, uint64_t old, uint64_t _new)
atomic_cas_uint64(uint64_t *v, uint64_t old, uint64_t _new)
{
assert(sizeof(uint64_t) == sizeof(unsigned long));
@@ -235,7 +235,7 @@ atomic_sub_uint64(uint64_t *p, uint64_t x)
}
ATOMIC_INLINE uint64_t
atomic_cas_uint32(uint64_t *v, uint64_t old, uint64_t _new)
atomic_cas_uint64(uint64_t *v, uint64_t old, uint64_t _new)
{
return __sync_val_compare_and_swap(v, old, _new);
}
@@ -268,13 +268,13 @@ atomic_cas_uint32(uint32_t *v, uint32_t old, uint32_t _new)
ATOMIC_INLINE uint32_t
atomic_add_uint32(uint32_t *p, uint32_t x)
{
return InterlockedExchangeAdd(p, x);
return InterlockedExchangeAdd(p, x) + x;
}
ATOMIC_INLINE uint32_t
atomic_sub_uint32(uint32_t *p, uint32_t x)
{
return InterlockedExchangeAdd(p, -((int32_t)x));
return InterlockedExchangeAdd(p, -((int32_t)x)) - x;
}
ATOMIC_INLINE uint32_t

View File

@@ -21,6 +21,35 @@
remove_extra_strict_flags()
if(WITH_SYSTEM_AUDASPACE)
set(INC
.
)
set(INC_SYS
${AUDASPACE_C_INCLUDE_DIRS}
${AUDASPACE_PY_INCLUDE_DIRS}
)
set(SRC
intern/AUD_Set.cpp
intern/AUD_Set.h
)
if(WITH_PYTHON)
list(APPEND INC_SYS
${PYTHON_INCLUDE_DIRS}
)
list(APPEND SRC
intern/AUD_PyInit.cpp
intern/AUD_PyInit.h
)
add_definitions(-DWITH_PYTHON)
endif()
else()
set(INC
.
FX
@@ -316,5 +345,6 @@ if(WITH_PYTHON)
)
add_definitions(-DWITH_PYTHON)
endif()
endif()
blender_add_lib(bf_intern_audaspace "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -21,9 +21,15 @@
#
# ***** END LGPL LICENSE BLOCK *****
from os import path
Import ('env')
sources = env.Glob('intern/*.cpp') + env.Glob('FX/*.cpp')
# AUD_PyInit is for external audaspace only
sources.remove(path.join('intern', 'AUD_PyInit.cpp'))
incs = '. intern FX ' + env['BF_PTHREADS_INC'] + ' ' + env['BF_BOOST_INC']
defs = []

View File

@@ -99,7 +99,7 @@ extern "C" {
#include <cassert>
typedef boost::shared_ptr<AUD_IFactory> AUD_Sound;
typedef boost::shared_ptr<AUD_ReadDevice> AUD_Device;
typedef boost::shared_ptr<AUD_IDevice> AUD_Device;
typedef boost::shared_ptr<AUD_IHandle> AUD_Handle;
typedef boost::shared_ptr<AUD_SequencerEntry> AUD_SEntry;
@@ -130,70 +130,69 @@ void AUD_exitOnce()
#endif
}
int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name)
{
boost::shared_ptr<AUD_IDevice> dev;
if (AUD_device.get()) {
AUD_exit();
AUD_exit(NULL);
}
std::string dname = device;
try {
switch(device) {
case AUD_NULL_DEVICE:
if(dname == "Null") {
dev = boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice());
break;
}
#ifdef WITH_SDL
case AUD_SDL_DEVICE:
if (SDL_Init == (void *)0) {
printf("Warning: SDL libraries are not installed\n");
// No break, fall through to default, to return false
}
else {
dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
break;
}
else if(dname == "SDL")
{
dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
}
#endif
#ifdef WITH_OPENAL
case AUD_OPENAL_DEVICE:
else if(dname == "OpenAL")
{
dev = boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
break;
}
#endif
#ifdef WITH_JACK
case AUD_JACK_DEVICE:
else if(dname == "Jack")
{
#ifdef __APPLE__
struct stat st;
if (stat("/Library/Frameworks/Jackmp.framework", &st) != 0) {
printf("Warning: Jack Framework not installed\n");
// No break, fall through to default, to return false
return NULL;
}
else
#endif
if (!AUD_jack_supported()) {
printf("Warning: Jack client not installed\n");
// No break, fall through to default, to return false
printf("Warning: Jack cllient not installed\n");
return NULL;
}
else {
dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice("Blender", specs, buffersize));
break;
dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize));
}
}
#endif
default:
return false;
else
{
return NULL;
}
AUD_device = dev;
AUD_3ddevice = dynamic_cast<AUD_I3DDevice *>(AUD_device.get());
return true;
return (AUD_Device*)1;
}
catch(AUD_Exception&)
{
return false;
return NULL;
}
}
void AUD_exit()
void AUD_exit(AUD_Device* device)
{
AUD_device = boost::shared_ptr<AUD_IDevice>();
AUD_3ddevice = NULL;
@@ -266,7 +265,7 @@ PyObject *AUD_initPython()
return module;
}
void *AUD_getPythonFactory(AUD_Sound *sound)
void *AUD_getPythonSound(AUD_Sound *sound)
{
if (sound) {
Factory *obj = (Factory *) Factory_empty();
@@ -279,7 +278,7 @@ void *AUD_getPythonFactory(AUD_Sound *sound)
return NULL;
}
AUD_Sound *AUD_getPythonSound(void *sound)
AUD_Sound *AUD_getSoundFromPython(void *sound)
{
Factory *factory = checkFactory((PyObject *)sound);
@@ -291,16 +290,26 @@ AUD_Sound *AUD_getPythonSound(void *sound)
#endif
void AUD_lock()
void AUD_Device_lock(AUD_Device* device)
{
AUD_device->lock();
}
void AUD_unlock()
void AUD_Device_unlock(AUD_Device* device)
{
AUD_device->unlock();
}
AUD_Channels AUD_Device_getChannels(AUD_Device* device)
{
return AUD_device->getSpecs().channels;
}
AUD_SampleRate AUD_Device_getRate(AUD_Device* device)
{
return AUD_device->getSpecs().rate;
}
AUD_SoundInfo AUD_getInfo(AUD_Sound *sound)
{
assert(sound);
@@ -326,19 +335,19 @@ AUD_SoundInfo AUD_getInfo(AUD_Sound *sound)
return info;
}
AUD_Sound *AUD_load(const char *filename)
AUD_Sound *AUD_Sound_file(const char *filename)
{
assert(filename);
return new AUD_Sound(new AUD_FileFactory(filename));
}
AUD_Sound *AUD_loadBuffer(unsigned char *buffer, int size)
AUD_Sound *AUD_Sound_bufferFile(unsigned char *buffer, int size)
{
assert(buffer);
return new AUD_Sound(new AUD_FileFactory(buffer, size));
}
AUD_Sound *AUD_bufferSound(AUD_Sound *sound)
AUD_Sound *AUD_Sound_cache(AUD_Sound *sound)
{
assert(sound);
@@ -351,13 +360,13 @@ AUD_Sound *AUD_bufferSound(AUD_Sound *sound)
}
}
AUD_Sound *AUD_monoSound(AUD_Sound *sound)
AUD_Sound *AUD_Sound_rechannel(AUD_Sound *sound, AUD_Channels channels)
{
assert(sound);
try {
AUD_DeviceSpecs specs;
specs.channels = AUD_CHANNELS_MONO;
specs.channels = channels;
specs.rate = AUD_RATE_INVALID;
specs.format = AUD_FORMAT_INVALID;
return new AUD_Sound(new AUD_ChannelMapperFactory(*sound, specs));
@@ -368,7 +377,7 @@ AUD_Sound *AUD_monoSound(AUD_Sound *sound)
}
}
AUD_Sound *AUD_delaySound(AUD_Sound *sound, float delay)
AUD_Sound *AUD_Sound_delay(AUD_Sound *sound, float delay)
{
assert(sound);
@@ -381,7 +390,7 @@ AUD_Sound *AUD_delaySound(AUD_Sound *sound, float delay)
}
}
AUD_Sound *AUD_limitSound(AUD_Sound *sound, float start, float end)
AUD_Sound *AUD_Sound_limit(AUD_Sound *sound, float start, float end)
{
assert(sound);
@@ -394,7 +403,7 @@ AUD_Sound *AUD_limitSound(AUD_Sound *sound, float start, float end)
}
}
AUD_Sound *AUD_pingpongSound(AUD_Sound *sound)
AUD_Sound *AUD_Sound_pingpong(AUD_Sound *sound)
{
assert(sound);
@@ -407,7 +416,7 @@ AUD_Sound *AUD_pingpongSound(AUD_Sound *sound)
}
}
AUD_Sound *AUD_loopSound(AUD_Sound *sound)
AUD_Sound *AUD_Sound_loop(AUD_Sound *sound)
{
assert(sound);
@@ -420,7 +429,7 @@ AUD_Sound *AUD_loopSound(AUD_Sound *sound)
}
}
int AUD_setLoop(AUD_Handle *handle, int loops)
int AUD_Handle_setLoopCount(AUD_Handle *handle, int loops)
{
assert(handle);
@@ -447,13 +456,13 @@ AUD_Sound *AUD_rectifySound(AUD_Sound *sound)
}
}
void AUD_unload(AUD_Sound *sound)
void AUD_Sound_free(AUD_Sound *sound)
{
assert(sound);
delete sound;
}
AUD_Handle *AUD_play(AUD_Sound *sound, int keep)
AUD_Handle *AUD_Device_play(AUD_Device* device, AUD_Sound *sound, int keep)
{
assert(sound);
try {
@@ -468,19 +477,19 @@ AUD_Handle *AUD_play(AUD_Sound *sound, int keep)
return NULL;
}
int AUD_pause(AUD_Handle *handle)
int AUD_Handle_pause(AUD_Handle *handle)
{
assert(handle);
return (*handle)->pause();
}
int AUD_resume(AUD_Handle *handle)
int AUD_Handle_resume(AUD_Handle *handle)
{
assert(handle);
return (*handle)->resume();
}
int AUD_stop(AUD_Handle *handle)
int AUD_Handle_stop(AUD_Handle *handle)
{
assert(handle);
int result = (*handle)->stop();
@@ -488,31 +497,36 @@ int AUD_stop(AUD_Handle *handle)
return result;
}
int AUD_setKeep(AUD_Handle *handle, int keep)
void AUD_Device_stopAll(void* device)
{
AUD_device->stopAll();
}
int AUD_Handle_setKeep(AUD_Handle *handle, int keep)
{
assert(handle);
return (*handle)->setKeep(keep);
}
int AUD_seek(AUD_Handle *handle, float seekTo)
int AUD_Handle_setPosition(AUD_Handle *handle, float seekTo)
{
assert(handle);
return (*handle)->seek(seekTo);
}
float AUD_getPosition(AUD_Handle *handle)
float AUD_Handle_getPosition(AUD_Handle *handle)
{
assert(handle);
return (*handle)->getPosition();
}
AUD_Status AUD_getStatus(AUD_Handle *handle)
AUD_Status AUD_Handle_getStatus(AUD_Handle *handle)
{
assert(handle);
return (*handle)->getStatus();
}
int AUD_setListenerLocation(const float location[3])
int AUD_Device_setListenerLocation(const float location[3])
{
if (AUD_3ddevice) {
AUD_Vector3 v(location[0], location[1], location[2]);
@@ -523,7 +537,7 @@ int AUD_setListenerLocation(const float location[3])
return false;
}
int AUD_setListenerVelocity(const float velocity[3])
int AUD_Device_setListenerVelocity(const float velocity[3])
{
if (AUD_3ddevice) {
AUD_Vector3 v(velocity[0], velocity[1], velocity[2]);
@@ -534,7 +548,7 @@ int AUD_setListenerVelocity(const float velocity[3])
return false;
}
int AUD_setListenerOrientation(const float orientation[4])
int AUD_Device_setListenerOrientation(const float orientation[4])
{
if (AUD_3ddevice) {
AUD_Quaternion q(orientation[3], orientation[0], orientation[1], orientation[2]);
@@ -545,7 +559,7 @@ int AUD_setListenerOrientation(const float orientation[4])
return false;
}
int AUD_setSpeedOfSound(float speed)
int AUD_Device_setSpeedOfSound(void* device, float speed)
{
if (AUD_3ddevice) {
AUD_3ddevice->setSpeedOfSound(speed);
@@ -555,7 +569,7 @@ int AUD_setSpeedOfSound(float speed)
return false;
}
int AUD_setDopplerFactor(float factor)
int AUD_Device_setDopplerFactor(void* device, float factor)
{
if (AUD_3ddevice) {
AUD_3ddevice->setDopplerFactor(factor);
@@ -565,7 +579,7 @@ int AUD_setDopplerFactor(float factor)
return false;
}
int AUD_setDistanceModel(AUD_DistanceModel model)
int AUD_Device_setDistanceModel(void* device, AUD_DistanceModel model)
{
if (AUD_3ddevice) {
AUD_3ddevice->setDistanceModel(model);
@@ -575,7 +589,7 @@ int AUD_setDistanceModel(AUD_DistanceModel model)
return false;
}
int AUD_setSourceLocation(AUD_Handle *handle, const float location[3])
int AUD_Handle_setLocation(AUD_Handle *handle, const float location[3])
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -588,7 +602,7 @@ int AUD_setSourceLocation(AUD_Handle *handle, const float location[3])
return false;
}
int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3])
int AUD_Handle_setVelocity(AUD_Handle *handle, const float velocity[3])
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -601,7 +615,7 @@ int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3])
return false;
}
int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4])
int AUD_Handle_setOrientation(AUD_Handle *handle, const float orientation[4])
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -614,7 +628,7 @@ int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4])
return false;
}
int AUD_setRelative(AUD_Handle *handle, int relative)
int AUD_Handle_setRelative(AUD_Handle *handle, int relative)
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -626,7 +640,7 @@ int AUD_setRelative(AUD_Handle *handle, int relative)
return false;
}
int AUD_setVolumeMaximum(AUD_Handle *handle, float volume)
int AUD_Handle_setVolumeMaximum(AUD_Handle *handle, float volume)
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -638,7 +652,7 @@ int AUD_setVolumeMaximum(AUD_Handle *handle, float volume)
return false;
}
int AUD_setVolumeMinimum(AUD_Handle *handle, float volume)
int AUD_Handle_setVolumeMinimum(AUD_Handle *handle, float volume)
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -650,7 +664,7 @@ int AUD_setVolumeMinimum(AUD_Handle *handle, float volume)
return false;
}
int AUD_setDistanceMaximum(AUD_Handle *handle, float distance)
int AUD_Handle_setDistanceMaximum(AUD_Handle *handle, float distance)
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -662,7 +676,7 @@ int AUD_setDistanceMaximum(AUD_Handle *handle, float distance)
return false;
}
int AUD_setDistanceReference(AUD_Handle *handle, float distance)
int AUD_Handle_setDistanceReference(AUD_Handle *handle, float distance)
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -674,7 +688,7 @@ int AUD_setDistanceReference(AUD_Handle *handle, float distance)
return false;
}
int AUD_setAttenuation(AUD_Handle *handle, float factor)
int AUD_Handle_setAttenuation(AUD_Handle *handle, float factor)
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -686,7 +700,7 @@ int AUD_setAttenuation(AUD_Handle *handle, float factor)
return false;
}
int AUD_setConeAngleOuter(AUD_Handle *handle, float angle)
int AUD_Handle_setConeAngleOuter(AUD_Handle *handle, float angle)
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -698,7 +712,7 @@ int AUD_setConeAngleOuter(AUD_Handle *handle, float angle)
return false;
}
int AUD_setConeAngleInner(AUD_Handle *handle, float angle)
int AUD_Handle_setConeAngleInner(AUD_Handle *handle, float angle)
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -710,7 +724,7 @@ int AUD_setConeAngleInner(AUD_Handle *handle, float angle)
return false;
}
int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume)
int AUD_Handle_setConeVolumeOuter(AUD_Handle *handle, float volume)
{
assert(handle);
boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
@@ -722,7 +736,7 @@ int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume)
return false;
}
int AUD_setSoundVolume(AUD_Handle *handle, float volume)
int AUD_Handle_setVolume(AUD_Handle *handle, float volume)
{
assert(handle);
try {
@@ -732,7 +746,7 @@ int AUD_setSoundVolume(AUD_Handle *handle, float volume)
return false;
}
int AUD_setSoundPitch(AUD_Handle *handle, float pitch)
int AUD_Handle_setPitch(AUD_Handle *handle, float pitch)
{
assert(handle);
try {
@@ -784,13 +798,13 @@ int AUD_setDeviceVolume(AUD_Device *device, float volume)
return false;
}
int AUD_readDevice(AUD_Device *device, data_t *buffer, int length)
int AUD_Device_read(AUD_Device *device, data_t *buffer, int length)
{
assert(device);
assert(buffer);
try {
return (*device)->read(buffer, length);
return boost::dynamic_pointer_cast<AUD_ReadDevice>(*device)->read(buffer, length);
}
catch(AUD_Exception&)
{
@@ -798,12 +812,11 @@ int AUD_readDevice(AUD_Device *device, data_t *buffer, int length)
}
}
void AUD_closeReadDevice(AUD_Device *device)
void AUD_Device_free(AUD_Device *device)
{
assert(device);
try {
delete device;
if(device != &AUD_device)
delete device;
}
catch(AUD_Exception&)
{
@@ -901,7 +914,7 @@ AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds)
return NULL;
}
AUD_Sound *AUD_createSequencer(float fps, int muted)
AUD_Sound *AUD_Sequence_create(float fps, int muted)
{
// specs are changed at a later point!
AUD_Specs specs;
@@ -911,22 +924,22 @@ AUD_Sound *AUD_createSequencer(float fps, int muted)
return sequencer;
}
void AUD_destroySequencer(AUD_Sound *sequencer)
void AUD_Sequence_free(AUD_Sound *sequencer)
{
delete sequencer;
}
void AUD_setSequencerMuted(AUD_Sound *sequencer, int muted)
void AUD_Sequence_setMuted(AUD_Sound *sequencer, int muted)
{
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->mute(muted);
}
void AUD_setSequencerFPS(AUD_Sound *sequencer, float fps)
void AUD_Sequence_setFPS(AUD_Sound *sequencer, float fps)
{
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setFPS(fps);
}
AUD_SEntry *AUD_addSequence(AUD_Sound *sequencer, AUD_Sound *sound,
AUD_SEntry *AUD_Sequence_add(AUD_Sound *sequencer, AUD_Sound *sound,
float begin, float end, float skip)
{
if (!sound)
@@ -934,28 +947,23 @@ AUD_SEntry *AUD_addSequence(AUD_Sound *sequencer, AUD_Sound *sound,
return new AUD_SEntry(((AUD_SequencerFactory *)sequencer->get())->add(*sound, begin, end, skip));
}
void AUD_removeSequence(AUD_Sound *sequencer, AUD_SEntry *entry)
void AUD_Sequence_remove(AUD_Sound *sequencer, AUD_SEntry *entry)
{
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->remove(*entry);
delete entry;
}
void AUD_moveSequence(AUD_SEntry *entry, float begin, float end, float skip)
void AUD_SequenceEntry_move(AUD_SEntry *entry, float begin, float end, float skip)
{
(*entry)->move(begin, end, skip);
}
void AUD_muteSequence(AUD_SEntry *entry, char mute)
void AUD_SequenceEntry_setMuted(AUD_SEntry *entry, char mute)
{
(*entry)->mute(mute);
}
void AUD_setRelativeSequence(AUD_SEntry *entry, char relative)
{
(*entry)->setRelative(relative);
}
void AUD_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound)
void AUD_SequenceEntry_setSound(AUD_SEntry *entry, AUD_Sound *sound)
{
if (sound)
(*entry)->setSound(*sound);
@@ -963,7 +971,7 @@ void AUD_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound)
(*entry)->setSound(AUD_Sound());
}
void AUD_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated)
void AUD_SequenceEntry_setAnimationData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated)
{
AUD_AnimateableProperty *prop = (*entry)->getAnimProperty(type);
if (animated) {
@@ -975,7 +983,7 @@ void AUD_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyType type
}
}
void AUD_setSequencerAnimData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated)
void AUD_Sequence_setAnimationData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated)
{
AUD_AnimateableProperty *prop = dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->getAnimProperty(type);
if (animated) {
@@ -988,21 +996,76 @@ void AUD_setSequencerAnimData(AUD_Sound *sequencer, AUD_AnimateablePropertyType
}
}
void AUD_updateSequenceData(AUD_SEntry *entry, float volume_max, float volume_min,
float distance_max, float distance_reference, float attenuation,
float cone_angle_outer, float cone_angle_inner, float cone_volume_outer)
void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value)
{
(*entry)->updateAll(volume_max, volume_min, distance_max, distance_reference, attenuation,
cone_angle_outer, cone_angle_inner, cone_volume_outer);
assert(sequence);
dynamic_cast<AUD_SequencerFactory *>(sequence->get())->setDistanceModel(static_cast<AUD_DistanceModel>(value));
}
void AUD_updateSequencerData(AUD_Sound *sequencer, float speed_of_sound,
float factor, AUD_DistanceModel model)
void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value)
{
AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sequencer->get());
f->setSpeedOfSound(speed_of_sound);
f->setDopplerFactor(factor);
f->setDistanceModel(model);
assert(sequence);
dynamic_cast<AUD_SequencerFactory *>(sequence->get())->setDopplerFactor(value);
}
void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value)
{
assert(sequence);
dynamic_cast<AUD_SequencerFactory *>(sequence->get())->setSpeedOfSound(value);
}
void AUD_SequenceEntry_setAttenuation(AUD_SEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setAttenuation(value);
}
void AUD_SequenceEntry_setConeAngleInner(AUD_SEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setConeAngleInner(value);
}
void AUD_SequenceEntry_setConeAngleOuter(AUD_SEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setConeAngleOuter(value);
}
void AUD_SequenceEntry_setConeVolumeOuter(AUD_SEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setConeVolumeOuter(value);
}
void AUD_SequenceEntry_setDistanceMaximum(AUD_SEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setDistanceMaximum(value);
}
void AUD_SequenceEntry_setDistanceReference(AUD_SEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setDistanceReference(value);
}
void AUD_SequenceEntry_setRelative(AUD_SEntry* sequence_entry, int value)
{
assert(sequence_entry);
(*sequence_entry)->setRelative(value);
}
void AUD_SequenceEntry_setVolumeMaximum(AUD_SEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setVolumeMaximum(value);
}
void AUD_SequenceEntry_setVolumeMinimum(AUD_SEntry* sequence_entry, float value)
{
assert(sequence_entry);
(*sequence_entry)->setVolumeMinimum(value);
}
void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer)
@@ -1010,12 +1073,12 @@ void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer)
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(AUD_device->getSpecs().specs);
}
void AUD_setSequencerSpecs(AUD_Sound *sequencer, AUD_Specs specs)
void AUD_Sequence_setSpecs(AUD_Sound *sequencer, AUD_Specs specs)
{
dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(specs);
}
void AUD_seekSequencer(AUD_Handle *handle, float time)
void AUD_seekSynchronizer(AUD_Handle *handle, float time)
{
#ifdef WITH_JACK
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
@@ -1030,7 +1093,7 @@ void AUD_seekSequencer(AUD_Handle *handle, float time)
}
}
float AUD_getSequencerPosition(AUD_Handle *handle)
float AUD_getSynchronizerPosition(AUD_Handle *handle)
{
#ifdef WITH_JACK
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
@@ -1045,7 +1108,7 @@ float AUD_getSequencerPosition(AUD_Handle *handle)
}
}
void AUD_startPlayback()
void AUD_playSynchronizer()
{
#ifdef WITH_JACK
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
@@ -1055,7 +1118,7 @@ void AUD_startPlayback()
#endif
}
void AUD_stopPlayback()
void AUD_stopSynchronizer()
{
#ifdef WITH_JACK
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
@@ -1066,7 +1129,7 @@ void AUD_stopPlayback()
}
#ifdef WITH_JACK
void AUD_setSyncCallback(AUD_syncFunction function, void *data)
void AUD_setSynchronizerCallback(AUD_syncFunction function, void *data)
{
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
if (device) {
@@ -1075,7 +1138,7 @@ void AUD_setSyncCallback(AUD_syncFunction function, void *data)
}
#endif
int AUD_doesPlayback()
int AUD_isSynchronizerPlaying()
{
#ifdef WITH_JACK
AUD_JackDevice *device = dynamic_cast<AUD_JackDevice *>(AUD_device.get());
@@ -1151,12 +1214,12 @@ int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_pe
return length;
}
AUD_Sound *AUD_copy(AUD_Sound *sound)
AUD_Sound *AUD_Sound_copy(AUD_Sound *sound)
{
return new boost::shared_ptr<AUD_IFactory>(*sound);
}
void AUD_freeHandle(AUD_Handle *handle)
void AUD_Handle_free(AUD_Handle *handle)
{
delete handle;
}
@@ -1283,14 +1346,9 @@ AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, f
}
}
boost::shared_ptr<AUD_IDevice> AUD_getDevice()
AUD_Device *AUD_Device_getCurrent(void)
{
return AUD_device;
}
AUD_I3DDevice *AUD_get3DDevice()
{
return AUD_3ddevice;
return &AUD_device;
}
int AUD_isJackSupported(void)

View File

@@ -77,22 +77,26 @@ extern void AUD_exitOnce(void);
* \param buffersize The buffersize for the device.
* \return Whether the device has been initialized.
*/
extern int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize);
extern AUD_Device* AUD_init(const char* device, AUD_DeviceSpecs specs, int buffersize, const char* name);
/**
* Unitinitializes an audio device.
*/
extern void AUD_exit(void);
extern void AUD_exit(AUD_Device* device);
/**
* Locks the playback device.
*/
extern void AUD_lock(void);
extern void AUD_Device_lock(AUD_Device* device);
/**
* Unlocks the device.
*/
extern void AUD_unlock(void);
extern void AUD_Device_unlock(AUD_Device* device);
extern AUD_Channels AUD_Device_getChannels(AUD_Device* device);
extern AUD_SampleRate AUD_Device_getRate(AUD_Device* device);
/**
* Returns information about a sound.
@@ -106,7 +110,7 @@ extern AUD_SoundInfo AUD_getInfo(AUD_Sound *sound);
* \param filename The filename of the sound file.
* \return A handle of the sound file.
*/
extern AUD_Sound *AUD_load(const char *filename);
extern AUD_Sound *AUD_Sound_file(const char *filename);
/**
* Loads a sound file.
@@ -114,21 +118,21 @@ extern AUD_Sound *AUD_load(const char *filename);
* \param size The size of the buffer.
* \return A handle of the sound file.
*/
extern AUD_Sound *AUD_loadBuffer(unsigned char *buffer, int size);
extern AUD_Sound *AUD_Sound_bufferFile(unsigned char *buffer, int size);
/**
* Buffers a sound.
* \param sound The sound to buffer.
* \return A handle of the sound buffer.
*/
extern AUD_Sound *AUD_bufferSound(AUD_Sound *sound);
extern AUD_Sound *AUD_Sound_cache(AUD_Sound *sound);
/**
* Rechannels the sound to be mono.
* \param sound The sound to rechannel.
* \return The mono sound.
*/
extern AUD_Sound *AUD_monoSound(AUD_Sound *sound);
extern AUD_Sound *AUD_Sound_rechannel(AUD_Sound *sound, AUD_Channels channels);
/**
* Delays a sound.
@@ -136,7 +140,7 @@ extern AUD_Sound *AUD_monoSound(AUD_Sound *sound);
* \param delay The delay in seconds.
* \return A handle of the delayed sound.
*/
extern AUD_Sound *AUD_delaySound(AUD_Sound *sound, float delay);
extern AUD_Sound *AUD_Sound_delay(AUD_Sound *sound, float delay);
/**
* Limits a sound.
@@ -145,21 +149,21 @@ extern AUD_Sound *AUD_delaySound(AUD_Sound *sound, float delay);
* \param end The stop time in seconds.
* \return A handle of the limited sound.
*/
extern AUD_Sound *AUD_limitSound(AUD_Sound *sound, float start, float end);
extern AUD_Sound *AUD_Sound_limit(AUD_Sound *sound, float start, float end);
/**
* Ping pongs a sound.
* \param sound The sound to ping pong.
* \return A handle of the ping pong sound.
*/
extern AUD_Sound *AUD_pingpongSound(AUD_Sound *sound);
extern AUD_Sound *AUD_Sound_pingpong(AUD_Sound *sound);
/**
* Loops a sound.
* \param sound The sound to loop.
* \return A handle of the looped sound.
*/
extern AUD_Sound *AUD_loopSound(AUD_Sound *sound);
extern AUD_Sound *AUD_Sound_loop(AUD_Sound *sound);
/**
* Sets a remaining loop count of a looping sound that currently plays.
@@ -167,7 +171,7 @@ extern AUD_Sound *AUD_loopSound(AUD_Sound *sound);
* \param loops The count of remaining loops, -1 for infinity.
* \return Whether the handle is valid.
*/
extern int AUD_setLoop(AUD_Handle *handle, int loops);
extern int AUD_Handle_setLoopCount(AUD_Handle *handle, int loops);
/**
* Rectifies a sound.
@@ -180,7 +184,7 @@ extern AUD_Sound *AUD_rectifySound(AUD_Sound *sound);
* Unloads a sound of any type.
* \param sound The handle of the sound.
*/
extern void AUD_unload(AUD_Sound *sound);
extern void AUD_Sound_free(AUD_Sound *sound);
/**
* Plays back a sound file.
@@ -189,28 +193,30 @@ extern void AUD_unload(AUD_Sound *sound);
* paused when its end has been reached.
* \return A handle to the played back sound.
*/
extern AUD_Handle *AUD_play(AUD_Sound *sound, int keep);
extern AUD_Handle *AUD_Device_play(AUD_Device* device, AUD_Sound *sound, int keep);
/**
* Pauses a played back sound.
* \param handle The handle to the sound.
* \return Whether the handle has been playing or not.
*/
extern int AUD_pause(AUD_Handle *handle);
extern int AUD_Handle_pause(AUD_Handle *handle);
/**
* Resumes a paused sound.
* \param handle The handle to the sound.
* \return Whether the handle has been paused or not.
*/
extern int AUD_resume(AUD_Handle *handle);
extern int AUD_Handle_resume(AUD_Handle *handle);
/**
* Stops a playing or paused sound.
* \param handle The handle to the sound.
* \return Whether the handle has been valid or not.
*/
extern int AUD_stop(AUD_Handle *handle);
extern int AUD_Handle_stop(AUD_Handle *handle);
extern void AUD_Device_stopAll(void* device);
/**
* Sets the end behaviour of a playing or paused sound.
@@ -219,7 +225,7 @@ extern int AUD_stop(AUD_Handle *handle);
* paused when its end has been reached.
* \return Whether the handle has been valid or not.
*/
extern int AUD_setKeep(AUD_Handle *handle, int keep);
extern int AUD_Handle_setKeep(AUD_Handle *handle, int keep);
/**
* Seeks a playing or paused sound.
@@ -227,7 +233,7 @@ extern int AUD_setKeep(AUD_Handle *handle, int keep);
* \param seekTo From where the sound file should be played back in seconds.
* \return Whether the handle has been valid or not.
*/
extern int AUD_seek(AUD_Handle *handle, float seekTo);
extern int AUD_Handle_setPosition(AUD_Handle *handle, float seekTo);
/**
* Retrieves the playback position of a handle.
@@ -235,39 +241,39 @@ extern int AUD_seek(AUD_Handle *handle, float seekTo);
* \return The current playback position in seconds or 0.0 if the handle is
* invalid.
*/
extern float AUD_getPosition(AUD_Handle *handle);
extern float AUD_Handle_getPosition(AUD_Handle *handle);
/**
* Returns the status of a playing, paused or stopped sound.
* \param handle The handle to the sound.
* \return The status of the sound behind the handle.
*/
extern AUD_Status AUD_getStatus(AUD_Handle *handle);
extern AUD_Status AUD_Handle_getStatus(AUD_Handle *handle);
/**
* Sets the listener location.
* \param location The new location.
*/
extern int AUD_setListenerLocation(const float location[3]);
extern int AUD_Device_setListenerLocation(const float location[3]);
/**
* Sets the listener velocity.
* \param velocity The new velocity.
*/
extern int AUD_setListenerVelocity(const float velocity[3]);
extern int AUD_Device_setListenerVelocity(const float velocity[3]);
/**
* Sets the listener orientation.
* \param orientation The new orientation as quaternion.
*/
extern int AUD_setListenerOrientation(const float orientation[4]);
extern int AUD_Device_setListenerOrientation(const float orientation[4]);
/**
* Sets the speed of sound.
* This value is needed for doppler effect calculation.
* \param speed The new speed of sound.
*/
extern int AUD_setSpeedOfSound(float speed);
extern int AUD_Device_setSpeedOfSound(void* device, float speed);
/**
* Sets the doppler factor.
@@ -275,13 +281,13 @@ extern int AUD_setSpeedOfSound(float speed);
* listener which is used while calculating the doppler effect.
* \param factor The new doppler factor.
*/
extern int AUD_setDopplerFactor(float factor);
extern int AUD_Device_setDopplerFactor(void* device, float factor);
/**
* Sets the distance model.
* \param model distance model.
*/
extern int AUD_setDistanceModel(AUD_DistanceModel model);
extern int AUD_Device_setDistanceModel(void* device, AUD_DistanceModel model);
/**
* Sets the location of a source.
@@ -289,7 +295,7 @@ extern int AUD_setDistanceModel(AUD_DistanceModel model);
* \param location The new location.
* \return Whether the action succeeded.
*/
extern int AUD_setSourceLocation(AUD_Handle *handle, const float location[3]);
extern int AUD_Handle_setLocation(AUD_Handle *handle, const float location[3]);
/**
* Sets the velocity of a source.
@@ -297,7 +303,7 @@ extern int AUD_setSourceLocation(AUD_Handle *handle, const float location[3]);
* \param velocity The new velocity.
* \return Whether the action succeeded.
*/
extern int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3]);
extern int AUD_Handle_setVelocity(AUD_Handle *handle, const float velocity[3]);
/**
* Sets the orientation of a source.
@@ -305,7 +311,7 @@ extern int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3]);
* \param orientation The new orientation as quaternion.
* \return Whether the action succeeded.
*/
extern int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4]);
extern int AUD_Handle_setOrientation(AUD_Handle *handle, const float orientation[4]);
/**
* Sets whether the source location, velocity and orientation are relative
@@ -314,7 +320,7 @@ extern int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[
* \param relative Whether the source is relative.
* \return Whether the action succeeded.
*/
extern int AUD_setRelative(AUD_Handle *handle, int relative);
extern int AUD_Handle_setRelative(AUD_Handle *handle, int relative);
/**
* Sets the maximum volume of a source.
@@ -322,7 +328,7 @@ extern int AUD_setRelative(AUD_Handle *handle, int relative);
* \param volume The new maximum volume.
* \return Whether the action succeeded.
*/
extern int AUD_setVolumeMaximum(AUD_Handle *handle, float volume);
extern int AUD_Handle_setVolumeMaximum(AUD_Handle *handle, float volume);
/**
* Sets the minimum volume of a source.
@@ -330,7 +336,7 @@ extern int AUD_setVolumeMaximum(AUD_Handle *handle, float volume);
* \param volume The new minimum volume.
* \return Whether the action succeeded.
*/
extern int AUD_setVolumeMinimum(AUD_Handle *handle, float volume);
extern int AUD_Handle_setVolumeMinimum(AUD_Handle *handle, float volume);
/**
* Sets the maximum distance of a source.
@@ -340,7 +346,7 @@ extern int AUD_setVolumeMinimum(AUD_Handle *handle, float volume);
* \param distance The new maximum distance.
* \return Whether the action succeeded.
*/
extern int AUD_setDistanceMaximum(AUD_Handle *handle, float distance);
extern int AUD_Handle_setDistanceMaximum(AUD_Handle *handle, float distance);
/**
* Sets the reference distance of a source.
@@ -348,7 +354,7 @@ extern int AUD_setDistanceMaximum(AUD_Handle *handle, float distance);
* \param distance The new reference distance.
* \return Whether the action succeeded.
*/
extern int AUD_setDistanceReference(AUD_Handle *handle, float distance);
extern int AUD_Handle_setDistanceReference(AUD_Handle *handle, float distance);
/**
* Sets the attenuation of a source.
@@ -357,7 +363,7 @@ extern int AUD_setDistanceReference(AUD_Handle *handle, float distance);
* \param factor The new attenuation.
* \return Whether the action succeeded.
*/
extern int AUD_setAttenuation(AUD_Handle *handle, float factor);
extern int AUD_Handle_setAttenuation(AUD_Handle *handle, float factor);
/**
* Sets the outer angle of the cone of a source.
@@ -365,7 +371,7 @@ extern int AUD_setAttenuation(AUD_Handle *handle, float factor);
* \param angle The new outer angle of the cone.
* \return Whether the action succeeded.
*/
extern int AUD_setConeAngleOuter(AUD_Handle *handle, float angle);
extern int AUD_Handle_setConeAngleOuter(AUD_Handle *handle, float angle);
/**
* Sets the inner angle of the cone of a source.
@@ -373,7 +379,7 @@ extern int AUD_setConeAngleOuter(AUD_Handle *handle, float angle);
* \param angle The new inner angle of the cone.
* \return Whether the action succeeded.
*/
extern int AUD_setConeAngleInner(AUD_Handle *handle, float angle);
extern int AUD_Handle_setConeAngleInner(AUD_Handle *handle, float angle);
/**
* Sets the outer volume of the cone of a source.
@@ -383,7 +389,7 @@ extern int AUD_setConeAngleInner(AUD_Handle *handle, float angle);
* \param volume The new outer volume of the cone.
* \return Whether the action succeeded.
*/
extern int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume);
extern int AUD_Handle_setConeVolumeOuter(AUD_Handle *handle, float volume);
/**
* Sets the volume of a played back sound.
@@ -391,7 +397,7 @@ extern int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume);
* \param volume The new volume, must be between 0.0 and 1.0.
* \return Whether the action succeeded.
*/
extern int AUD_setSoundVolume(AUD_Handle *handle, float volume);
extern int AUD_Handle_setVolume(AUD_Handle *handle, float volume);
/**
* Sets the pitch of a played back sound.
@@ -399,7 +405,7 @@ extern int AUD_setSoundVolume(AUD_Handle *handle, float volume);
* \param pitch The new pitch.
* \return Whether the action succeeded.
*/
extern int AUD_setSoundPitch(AUD_Handle *handle, float pitch);
extern int AUD_Handle_setPitch(AUD_Handle *handle, float pitch);
/**
* Opens a read device, with which audio data can be read.
@@ -434,13 +440,13 @@ extern AUD_Handle *AUD_playDevice(AUD_Device *device, AUD_Sound *sound, float se
* played back currently, in that case the buffer is filled with
* silence.
*/
extern int AUD_readDevice(AUD_Device *device, data_t *buffer, int length);
extern int AUD_Device_read(AUD_Device *device, data_t *buffer, int length);
/**
* Closes a read device.
* \param device The read device.
*/
extern void AUD_closeReadDevice(AUD_Device *device);
extern void AUD_Device_free(AUD_Device *device);
/**
* Reads a sound file into a newly created float buffer.
@@ -466,27 +472,27 @@ extern AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds);
* \param muted Whether the scene is muted.
* \return The new sound scene.
*/
extern AUD_Sound *AUD_createSequencer(float fps, int muted);
extern AUD_Sound *AUD_Sequence_create(float fps, int muted);
/**
* Deletes a sound scene.
* \param sequencer The sound scene.
*/
extern void AUD_destroySequencer(AUD_Sound *sequencer);
extern void AUD_Sequence_free(AUD_Sound *sequencer);
/**
* Sets the muting state of the scene.
* \param sequencer The sound scene.
* \param muted Whether the scene is muted.
*/
extern void AUD_setSequencerMuted(AUD_Sound *sequencer, int muted);
extern void AUD_Sequence_setMuted(AUD_Sound *sequencer, int muted);
/**
* Sets the scene's FPS.
* \param sequencer The sound scene.
* \param fps The new FPS.
*/
extern void AUD_setSequencerFPS(AUD_Sound *sequencer, float fps);
extern void AUD_Sequence_setFPS(AUD_Sound *sequencer, float fps);
/**
* Adds a new entry to the scene.
@@ -497,7 +503,7 @@ extern void AUD_setSequencerFPS(AUD_Sound *sequencer, float fps);
* \param skip How much seconds should be skipped at the beginning.
* \return The entry added.
*/
extern AUD_SEntry *AUD_addSequence(AUD_Sound *sequencer, AUD_Sound *sound,
extern AUD_SEntry *AUD_Sequence_add(AUD_Sound *sequencer, AUD_Sound *sound,
float begin, float end, float skip);
/**
@@ -505,7 +511,7 @@ extern AUD_SEntry *AUD_addSequence(AUD_Sound *sequencer, AUD_Sound *sound,
* \param sequencer The sound scene.
* \param entry The entry to remove.
*/
extern void AUD_removeSequence(AUD_Sound *sequencer, AUD_SEntry *entry);
extern void AUD_Sequence_remove(AUD_Sound *sequencer, AUD_SEntry *entry);
/**
* Moves the entry.
@@ -514,30 +520,21 @@ extern void AUD_removeSequence(AUD_Sound *sequencer, AUD_SEntry *entry);
* \param end The new end time or a negative value if unknown.
* \param skip How many seconds to skip at the beginning.
*/
extern void AUD_moveSequence(AUD_SEntry *entry, float begin, float end, float skip);
extern void AUD_SequenceEntry_move(AUD_SEntry *entry, float begin, float end, float skip);
/**
* Sets the muting state of the entry.
* \param entry The sequenced entry.
* \param mute Whether the entry should be muted or not.
*/
extern void AUD_muteSequence(AUD_SEntry *entry, char mute);
/**
* Sets whether the entrie's location, velocity and orientation are relative
* to the listener.
* \param entry The sequenced entry.
* \param relative Whether the source is relative.
* \return Whether the action succeeded.
*/
extern void AUD_setRelativeSequence(AUD_SEntry *entry, char relative);
extern void AUD_SequenceEntry_setMuted(AUD_SEntry *entry, char mute);
/**
* Sets the sound of the entry.
* \param entry The sequenced entry.
* \param sound The new sound.
*/
extern void AUD_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound);
extern void AUD_SequenceEntry_setSound(AUD_SEntry *entry, AUD_Sound *sound);
/**
* Writes animation data to a sequenced entry.
@@ -547,7 +544,7 @@ extern void AUD_updateSequenceSound(AUD_SEntry *entry, AUD_Sound *sound);
* \param data The data to write.
* \param animated Whether the attribute is animated.
*/
extern void AUD_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated);
extern void AUD_SequenceEntry_setAnimationData(AUD_SEntry *entry, AUD_AnimateablePropertyType type, int frame, float *data, char animated);
/**
* Writes animation data to a sequenced entry.
@@ -557,33 +554,90 @@ extern void AUD_setSequenceAnimData(AUD_SEntry *entry, AUD_AnimateablePropertyTy
* \param data The data to write.
* \param animated Whether the attribute is animated.
*/
extern void AUD_setSequencerAnimData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated);
extern void AUD_Sequence_setAnimationData(AUD_Sound *sequencer, AUD_AnimateablePropertyType type, int frame, float *data, char animated);
/**
* Updates all non-animated parameters of the entry.
* \param entry The sequenced entry.
* \param volume_max The maximum volume.
* \param volume_min The minimum volume.
* \param distance_max The maximum distance.
* \param distance_reference The reference distance.
* \param attenuation The attenuation.
* \param cone_angle_outer The outer cone opening angle.
* \param cone_angle_inner The inner cone opening angle.
* \param cone_volume_outer The volume outside the outer cone.
* Sets the distance model of a sequence.
* param sequence The sequence to set the distance model from.
* param value The new distance model to set.
*/
extern void AUD_updateSequenceData(AUD_SEntry *entry, float volume_max, float volume_min,
float distance_max, float distance_reference, float attenuation,
float cone_angle_outer, float cone_angle_inner, float cone_volume_outer);
extern void AUD_Sequence_setDistanceModel(AUD_Sound* sequence, AUD_DistanceModel value);
/**
* Updates all non-animated parameters of the entry.
* \param sequencer The sound scene.
* \param speed_of_sound The speed of sound for doppler calculation.
* \param factor The doppler factor to control the effect's strength.
* \param model The distance model for distance calculation.
* Sets the doppler factor of a sequence.
* param sequence The sequence to set the doppler factor from.
* param value The new doppler factor to set.
*/
extern void AUD_updateSequencerData(AUD_Sound *sequencer, float speed_of_sound,
float factor, AUD_DistanceModel model);
extern void AUD_Sequence_setDopplerFactor(AUD_Sound* sequence, float value);
/**
* Sets the speed of sound of a sequence.
* param sequence The sequence to set the speed of sound from.
* param value The new speed of sound to set.
*/
extern void AUD_Sequence_setSpeedOfSound(AUD_Sound* sequence, float value);
/**
* Sets the attenuation of a sequence_entry.
* param sequence_entry The sequence_entry to set the attenuation from.
* param value The new attenuation to set.
*/
extern void AUD_SequenceEntry_setAttenuation(AUD_SEntry* sequence_entry, float value);
/**
* Sets the cone angle inner of a sequence_entry.
* param sequence_entry The sequence_entry to set the cone angle inner from.
* param value The new cone angle inner to set.
*/
extern void AUD_SequenceEntry_setConeAngleInner(AUD_SEntry* sequence_entry, float value);
/**
* Sets the cone angle outer of a sequence_entry.
* param sequence_entry The sequence_entry to set the cone angle outer from.
* param value The new cone angle outer to set.
*/
extern void AUD_SequenceEntry_setConeAngleOuter(AUD_SEntry* sequence_entry, float value);
/**
* Sets the cone volume outer of a sequence_entry.
* param sequence_entry The sequence_entry to set the cone volume outer from.
* param value The new cone volume outer to set.
*/
extern void AUD_SequenceEntry_setConeVolumeOuter(AUD_SEntry* sequence_entry, float value);
/**
* Sets the distance maximum of a sequence_entry.
* param sequence_entry The sequence_entry to set the distance maximum from.
* param value The new distance maximum to set.
*/
extern void AUD_SequenceEntry_setDistanceMaximum(AUD_SEntry* sequence_entry, float value);
/**
* Sets the distance reference of a sequence_entry.
* param sequence_entry The sequence_entry to set the distance reference from.
* param value The new distance reference to set.
*/
extern void AUD_SequenceEntry_setDistanceReference(AUD_SEntry* sequence_entry, float value);
/**
* Sets the relative of a sequence_entry.
* param sequence_entry The sequence_entry to set the relative from.
* param value The new relative to set.
*/
extern void AUD_SequenceEntry_setRelative(AUD_SEntry* sequence_entry, int value);
/**
* Sets the volume maximum of a sequence_entry.
* param sequence_entry The sequence_entry to set the volume maximum from.
* param value The new volume maximum to set.
*/
extern void AUD_SequenceEntry_setVolumeMaximum(AUD_SEntry* sequence_entry, float value);
/**
* Sets the volume minimum of a sequence_entry.
* param sequence_entry The sequence_entry to set the volume minimum from.
* param value The new volume minimum to set.
*/
extern void AUD_SequenceEntry_setVolumeMinimum(AUD_SEntry* sequence_entry, float value);
/**
* Sets the audio output specification of the sound scene to the specs of the
@@ -597,31 +651,31 @@ extern void AUD_setSequencerDeviceSpecs(AUD_Sound *sequencer);
* \param sequencer The sound scene.
* \param specs The new specification.
*/
extern void AUD_setSequencerSpecs(AUD_Sound *sequencer, AUD_Specs specs);
extern void AUD_Sequence_setSpecs(AUD_Sound *sequencer, AUD_Specs specs);
/**
* Seeks sequenced sound scene playback.
* \param handle Playback handle.
* \param time Time in seconds to seek to.
*/
extern void AUD_seekSequencer(AUD_Handle *handle, float time);
extern void AUD_seekSynchronizer(AUD_Handle *handle, float time);
/**
* Returns the current sound scene playback time.
* \param handle Playback handle.
* \return The playback time in seconds.
*/
extern float AUD_getSequencerPosition(AUD_Handle *handle);
extern float AUD_getSynchronizerPosition(AUD_Handle *handle);
/**
* Starts the playback of jack transport if possible.
*/
extern void AUD_startPlayback(void);
extern void AUD_playSynchronizer(void);
/**
* Stops the playback of jack transport if possible.
*/
extern void AUD_stopPlayback(void);
extern void AUD_stopSynchronizer(void);
#ifdef WITH_JACK
/**
@@ -629,14 +683,14 @@ extern void AUD_stopPlayback(void);
* \param function The callback function.
* \param data The data parameter for the callback.
*/
extern void AUD_setSyncCallback(AUD_syncFunction function, void *data);
extern void AUD_setSynchronizerCallback(AUD_syncFunction function, void *data);
#endif
/**
* Returns whether jack transport is currently playing.
* \return Whether jack transport is currently playing.
*/
extern int AUD_doesPlayback(void);
extern int AUD_isSynchronizerPlaying(void);
/**
* Reads a sound into a buffer for drawing at a specific sampling rate.
@@ -653,13 +707,13 @@ extern int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int sam
* \param sound Sound to copy.
* \return Copied sound.
*/
extern AUD_Sound *AUD_copy(AUD_Sound *sound);
extern AUD_Sound *AUD_Sound_copy(AUD_Sound *sound);
/**
* Frees a handle.
* \param channel Handle to free.
*/
extern void AUD_freeHandle(AUD_Handle *channel);
extern void AUD_Handle_free(AUD_Handle *channel);
/**
* Creates a new set.
@@ -747,36 +801,22 @@ extern AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *seque
* \param sound The sound factory.
* \return The python factory.
*/
extern void *AUD_getPythonFactory(AUD_Sound *sound);
extern void *AUD_getPythonSound(AUD_Sound *sound);
/**
* Retrieves the sound factory of a python factory.
* \param sound The python factory.
* \return The sound factory.
*/
extern AUD_Sound *AUD_getPythonSound(void *sound);
extern AUD_Sound *AUD_getSoundFromPython(void *sound);
#endif
extern AUD_Device *AUD_Device_getCurrent(void);
extern int AUD_isJackSupported(void);
#ifdef __cplusplus
}
#include <boost/shared_ptr.hpp>
class AUD_IDevice;
class AUD_I3DDevice;
/**
* Returns the current playback device.
* \return The playback device.
*/
boost::shared_ptr<AUD_IDevice> AUD_getDevice();
/**
* Returns the current playback 3D device.
* \return The playback 3D device.
*/
AUD_I3DDevice *AUD_get3DDevice();
#endif
#endif //__AUD_C_API_H__

View File

@@ -33,16 +33,7 @@
#include "AUD_Space.h"
#include <cstring>
#ifdef _MSC_VER
#if (_MSC_VER <= 1500)
typedef short int16_t;
typedef int int32_t;
#else
# include <stdint.h>
#endif
#else
#include <stdint.h>
#endif
typedef void (*AUD_convert_f)(data_t* target, data_t* source, int length);

View File

@@ -0,0 +1,78 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2009-2011 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* Audaspace 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.
*
* AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file audaspace/intern/AUD_PyInit.cpp
* \ingroup audaspaceintern
*/
#include "AUD_PyInit.h"
#include <AUD_Sound.h>
#include <python/PySound.h>
#include <python/PyAPI.h>
extern "C" {
extern void *BKE_sound_get_factory(void *sound);
}
static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args)
{
long int lptr;
if (PyArg_Parse(args, "l:_sound_from_pointer", &lptr)) {
if (lptr) {
AUD_Sound* sound = BKE_sound_get_factory((void *) lptr);
if (sound) {
Sound *obj = (Sound *)Sound_empty();
if (obj) {
obj->sound = AUD_Sound_copy(sound);
return (PyObject *) obj;
}
}
}
}
Py_RETURN_NONE;
}
static PyMethodDef meth_sound_from_pointer[] = {
{"_sound_from_pointer", (PyCFunction)AUD_getSoundFromPointer, METH_O,
"_sound_from_pointer(pointer)\n\n"
"Returns the corresponding :class:`Factory` object.\n\n"
":arg pointer: The pointer to the bSound object as long.\n"
":type pointer: long\n"
":return: The corresponding :class:`Factory` object.\n"
":rtype: :class:`Factory`"}
};
PyObject *AUD_initPython(void)
{
PyObject *module = PyInit_aud();
PyModule_AddObject(module, "_sound_from_pointer", (PyObject *)PyCFunction_New(meth_sound_from_pointer, NULL));
PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module);
return module;
}

View File

@@ -0,0 +1,69 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2009-2011 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* Audaspace 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.
*
* AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file audaspace/intern/AUD_Set.cpp
* \ingroup audaspaceintern
*/
#include <set>
#include "AUD_Set.h"
void *AUD_createSet()
{
return new std::set<void *>();
}
void AUD_destroySet(void *set)
{
delete reinterpret_cast<std::set<void *>*>(set);
}
char AUD_removeSet(void *set, void *entry)
{
if (set)
return reinterpret_cast<std::set<void *>*>(set)->erase(entry);
return 0;
}
void AUD_addSet(void *set, void *entry)
{
if (entry)
reinterpret_cast<std::set<void *>*>(set)->insert(entry);
}
void *AUD_getSet(void *set)
{
if (set) {
std::set<void *>* rset = reinterpret_cast<std::set<void *>*>(set);
if (!rset->empty()) {
std::set<void *>::iterator it = rset->begin();
void *result = *it;
rset->erase(it);
return result;
}
}
return (void*) 0;
}

View File

@@ -0,0 +1,74 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* Copyright 2009-2011 Jörg Hermann Müller
*
* This file is part of AudaSpace.
*
* Audaspace 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.
*
* AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file AUD_Set.h
* \ingroup audaspace
*/
#ifndef __AUD_SET_H__
#define __AUD_SET_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new set.
* \return The new set.
*/
extern void *AUD_createSet(void);
/**
* Deletes a set.
* \param set The set to delete.
*/
extern void AUD_destroySet(void *set);
/**
* Removes an entry from a set.
* \param set The set work on.
* \param entry The entry to remove.
* \return Whether the entry was in the set or not.
*/
extern char AUD_removeSet(void *set, void *entry);
/**
* Adds a new entry to a set.
* \param set The set work on.
* \param entry The entry to add.
*/
extern void AUD_addSet(void *set, void *entry);
/**
* Removes one entry from a set and returns it.
* \param set The set work on.
* \return The entry or NULL if the set is empty.
*/
extern void *AUD_getSet(void *set);
#ifdef __cplusplus
}
#endif
#endif //__AUD_SET_H__

View File

@@ -14,6 +14,11 @@ include(cmake/external_libs.cmake)
# todo: refactor this code to match scons
# note: CXX_HAS_SSE is needed in case passing SSE flags fails altogether (gcc-arm)
if(WITH_CYCLES_WERROR)
ADD_CHECK_C_COMPILER_FLAG(CMAKE_C_FLAGS C_WERROR -Werror)
ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS C_WERROR -Werror)
endif()
if(NOT WITH_CPU_SSE)
set(CXX_HAS_SSE FALSE)
set(CXX_HAS_AVX FALSE)
@@ -154,23 +159,23 @@ add_definitions(
TEST_UNORDERED_MAP_SUPPORT()
if(HAVE_STD_UNORDERED_MAP_HEADER)
if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
add_definitions(-DCYCLES_STD_UNORDERED_MAP)
else()
if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
add_definitions(-DCYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE)
else()
add_definitions(-DCYCLES_NO_UNORDERED_MAP)
message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)")
endif()
endif()
if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
add_definitions(-DCYCLES_STD_UNORDERED_MAP)
else()
if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
add_definitions(-DCYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE)
else()
add_definitions(-DCYCLES_NO_UNORDERED_MAP)
message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)")
endif()
endif()
else()
if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
add_definitions(-DCYCLES_TR1_UNORDERED_MAP)
else()
add_definitions(-DCYCLES_NO_UNORDERED_MAP)
message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)")
endif()
if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
add_definitions(-DCYCLES_TR1_UNORDERED_MAP)
else()
add_definitions(-DCYCLES_NO_UNORDERED_MAP)
message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)")
endif()
endif()
# Logging capabilities using GLog library.

View File

@@ -20,6 +20,7 @@
#include <algorithm>
#include <iterator>
#include "background.h"
#include "camera.h"
#include "film.h"
#include "graph.h"
@@ -850,6 +851,15 @@ static void xml_read_shader(const XMLReadState& state, pugi::xml_node node)
static void xml_read_background(const XMLReadState& state, pugi::xml_node node)
{
/* Background Settings */
Background *bg = state.scene->background;
xml_read_float(&bg->ao_distance, node, "ao_distance");
xml_read_float(&bg->ao_factor, node, "ao_factor");
xml_read_bool(&bg->transparent, node, "transparent");
/* Background Shader */
Shader *shader = state.scene->shaders[state.scene->default_background];
xml_read_bool(&shader->heterogeneous_volume, node, "heterogeneous_volume");
@@ -896,6 +906,7 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node)
/* read vertices and polygons, RIB style */
vector<float3> P;
vector<float> UV;
vector<int> verts, nverts;
xml_read_float3_array(P, node, "P");
@@ -967,6 +978,31 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node)
index_offset += nverts[i];
}
if(xml_read_float_array(UV, node, "UV")) {
ustring name = ustring("UVMap");
Attribute *attr = mesh->attributes.add(ATTR_STD_UV, name);
float3 *fdata = attr->data_float3();
/* loop over the triangles */
index_offset = 0;
for(size_t i = 0; i < nverts.size(); i++) {
for(int j = 0; j < nverts[i]-2; j++) {
int v0 = verts[index_offset];
int v1 = verts[index_offset + j + 1];
int v2 = verts[index_offset + j + 2];
assert(v0*2+1 < (int)UV.size());
assert(v1*2+1 < (int)UV.size());
assert(v2*2+1 < (int)UV.size());
fdata[0] = make_float3(UV[v0*2], UV[v0*2+1], 0.0);
fdata[1] = make_float3(UV[v1*2], UV[v1*2+1], 0.0);
fdata[2] = make_float3(UV[v2*2], UV[v2*2+1], 0.0);
fdata += 3;
}
}
}
}
/* temporary for test compatibility */

View File

@@ -31,10 +31,12 @@ set(SRC
blender_session.cpp
blender_shader.cpp
blender_sync.cpp
blender_texture.cpp
CCL_api.h
blender_sync.h
blender_session.h
blender_texture.h
blender_util.h
)

View File

@@ -17,11 +17,56 @@
# <pep8 compliant>
def _is_using_buggy_driver():
import bgl
# We need to be conservative here because in multi-GPU systems display card
# might be quite old, but others one might be just good.
#
# So We shouldn't disable possible good dedicated cards just because display
# card seems weak. And instead we only blacklist configurations which are
# proven to cause problems.
if bgl.glGetString(bgl.GL_VENDOR) == "ATI Technologies Inc.":
import re
version = bgl.glGetString(bgl.GL_VERSION)
if version.endswith("Compatibility Profile Context"):
# Old HD 4xxx and 5xxx series drivers did not have driver version
# in the version string, but thsoe cards do not quite work and
# cusing crashes.
return True
regex = re.compile(".*Compatibility Profile Context ([0-9]+(\.[0-9]+)+)$")
if not regex.match(version):
# Skip cards like FireGL
return False
version = regex.sub("\\1", version).split('.')
return int(version[0]) == 8
return False
def _workaround_buggy_drivers():
if _is_using_buggy_driver():
import _cycles
if hasattr(_cycles, "opencl_disable"):
print("Cycles: OpenGL driver known to be buggy, disabling OpenCL platform.")
_cycles.opencl_disable()
def init():
import bpy
import _cycles
import os.path
# Workaroud posibly buggy legacy drivers which crashes on the OpenCL
# device enumeration.
#
# This checks are not really correct because they might still fail
# in the case of multiple GPUs. However, currently buggy drivers
# are really old and likely to be used in single GPU systems only
# anyway.
#
# Can't do it in the background mode, so we hope OpenCL is no enabled
# in the user preferences.
if not bpy.app.background:
_workaround_buggy_drivers()
path = os.path.dirname(__file__)
user_path = os.path.dirname(os.path.abspath(bpy.utils.user_resource('CONFIG', '')))

View File

@@ -511,6 +511,19 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
),
)
cls.use_camera_cull = BoolProperty(
name="Use Camera Cull",
description="Allow objects to be culled based on the camera frustum",
default=False,
)
cls.camera_cull_margin = FloatProperty(
name="Camera Cull Margin",
description="Margin for the camera space culling",
default=0.1,
min=0.0, max=5.0
)
@classmethod
def unregister(cls):
del bpy.types.Scene.cycles
@@ -739,6 +752,12 @@ class CyclesWorldSettings(bpy.types.PropertyGroup):
min=1, max=10000,
default=4,
)
cls.max_bounces = IntProperty(
name="Max Bounces",
description="Maximum number of bounces the background light will contribute to the render",
min=0, max=1024,
default=1024,
)
cls.homogeneous_volume = BoolProperty(
name="Homogeneous Volume",
description="When using volume rendering, assume volume has the same density everywhere"
@@ -890,6 +909,12 @@ class CyclesObjectBlurSettings(bpy.types.PropertyGroup):
default=1,
)
cls.use_camera_cull = BoolProperty(
name="Use Camera Cull",
description="Allow this object and its duplicators to be culled by camera space culling",
default=False,
)
@classmethod
def unregister(cls):
del bpy.types.Object.cycles

View File

@@ -431,10 +431,14 @@ class CyclesRender_PT_layer_passes(CyclesButtonsPanel, Panel):
col.prop(rl, "use_pass_emit", text="Emission")
col.prop(rl, "use_pass_environment")
if hasattr(rd, "debug_pass_type"):
layout.prop(rd, "debug_pass_type")
class CyclesRender_PT_views(CyclesButtonsPanel, Panel):
bl_label = "Views"
bl_context = "render_layer"
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, context):
rd = context.scene.render
@@ -644,7 +648,13 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
return CyclesButtonsPanel.poll(context) and ob and ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'}
if CyclesButtonsPanel.poll(context) and ob:
if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'}:
return True
if ob.dupli_type == 'GROUP' and ob.dupli_group:
return True
# TODO(sergey): More duplicator types here?
return False
def draw_header(self, context):
layout = self.layout
@@ -678,8 +688,8 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
sub.prop(cob, "motion_steps", text="Steps")
class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
bl_label = "Ray Visibility"
class CyclesObject_PT_cycles_settings(CyclesButtonsPanel, Panel):
bl_label = "Cycles Settings"
bl_context = "object"
bl_options = {'DEFAULT_CLOSED'}
@@ -687,15 +697,19 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
def poll(cls, context):
ob = context.object
return (CyclesButtonsPanel.poll(context) and
ob and ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'} or
ob and ob.dupli_type == 'GROUP' and ob.dupli_group)
ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'}) or
(ob.dupli_type == 'GROUP' and ob.dupli_group)))
def draw(self, context):
layout = self.layout
scene = context.scene
cscene = scene.cycles
ob = context.object
cob = ob.cycles
visibility = ob.cycles_visibility
layout.label(text="Ray Visibility:")
flow = layout.column_flow()
flow.prop(visibility, "camera")
@@ -707,6 +721,12 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
if ob.type != 'LAMP':
flow.prop(visibility, "shadow")
col = layout.column()
col.label(text="Performance:")
row = col.row()
row.active = scene.render.use_simplify and cscene.use_camera_cull
row.prop(cob, "use_camera_cull")
class CYCLES_OT_use_shading_nodes(Operator):
"""Enable nodes on a material, world or lamp"""
@@ -1031,6 +1051,7 @@ class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
sub.prop(cworld, "sample_map_resolution")
if use_branched_path(context):
sub.prop(cworld, "samples")
sub.prop(cworld, "max_bounces")
col = split.column()
col.label(text="Volume:")
@@ -1216,7 +1237,8 @@ class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
@classmethod
def poll(cls, context):
node = context.texture_node
return node and CyclesButtonsPanel.poll(context)
# TODO(sergey): perform a faster/nicer check?
return node and hasattr(node, 'texture_mapping') and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
@@ -1440,7 +1462,9 @@ class CyclesScene_PT_simplify(CyclesButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
rd = context.scene.render
scene = context.scene
rd = scene.render
cscene = scene.cycles
layout.active = rd.use_simplify
split = layout.split()
@@ -1455,6 +1479,12 @@ class CyclesScene_PT_simplify(CyclesButtonsPanel, Panel):
col.prop(rd, "simplify_subdivision_render", text="Subdivision")
col.prop(rd, "simplify_child_particles_render", text="Child Particles")
col = layout.column()
col.prop(cscene, "use_camera_cull")
subsub = col.column()
subsub.active = cscene.use_camera_cull
subsub.prop(cscene, "camera_cull_margin")
def draw_device(self, context):
scene = context.scene

View File

@@ -207,19 +207,34 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::RenderEngine b_e
}
}
static Transform blender_camera_matrix(const Transform& tfm, CameraType type)
static Transform blender_camera_matrix(const Transform& tfm,
const CameraType type,
const PanoramaType panorama_type)
{
Transform result;
if(type == CAMERA_PANORAMA) {
/* make it so environment camera needs to be pointed in the direction
* of the positive x-axis to match an environment texture, this way
* it is looking at the center of the texture */
result = tfm *
make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
-1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
if(panorama_type == PANORAMA_MIRRORBALL) {
/* Mirror ball camera is looking into the negative Y direction
* which matches texture mirror ball mapping.
*/
result = tfm *
make_transform(1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
}
else {
/* Make it so environment camera needs to be pointed in the direction
* of the positive x-axis to match an environment texture, this way
* it is looking at the center of the texture
*/
result = tfm *
make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
-1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
}
}
else {
/* note the blender camera points along the negative z-axis */
@@ -229,8 +244,11 @@ static Transform blender_camera_matrix(const Transform& tfm, CameraType type)
return transform_clear_scale(result);
}
static void blender_camera_viewplane(BlenderCamera *bcam, int width, int height,
BoundBox2D *viewplane, float *aspectratio, float *sensor_size)
static void blender_camera_viewplane(BlenderCamera *bcam,
int width, int height,
BoundBox2D *viewplane,
float *aspectratio,
float *sensor_size)
{
/* dimensions */
float xratio = (float)width*bcam->pixelaspect.x;
@@ -243,24 +261,34 @@ static void blender_camera_viewplane(BlenderCamera *bcam, int width, int height,
/* sensor fitting */
if(bcam->sensor_fit == BlenderCamera::AUTO) {
horizontal_fit = (xratio > yratio);
*sensor_size = bcam->sensor_width;
if(sensor_size != NULL) {
*sensor_size = bcam->sensor_width;
}
}
else if(bcam->sensor_fit == BlenderCamera::HORIZONTAL) {
horizontal_fit = true;
*sensor_size = bcam->sensor_width;
if(sensor_size != NULL) {
*sensor_size = bcam->sensor_width;
}
}
else {
horizontal_fit = false;
*sensor_size = bcam->sensor_height;
if(sensor_size != NULL) {
*sensor_size = bcam->sensor_height;
}
}
if(horizontal_fit) {
*aspectratio = xratio/yratio;
if(aspectratio != NULL) {
*aspectratio = xratio/yratio;
}
xaspect = *aspectratio;
yaspect = 1.0f;
}
else {
*aspectratio = yratio/xratio;
if(aspectratio != NULL) {
*aspectratio = yratio/xratio;
}
xaspect = 1.0f;
yaspect = *aspectratio;
}
@@ -269,31 +297,37 @@ static void blender_camera_viewplane(BlenderCamera *bcam, int width, int height,
if(bcam->type == CAMERA_ORTHOGRAPHIC) {
xaspect = xaspect*bcam->ortho_scale/(*aspectratio*2.0f);
yaspect = yaspect*bcam->ortho_scale/(*aspectratio*2.0f);
*aspectratio = bcam->ortho_scale/2.0f;
if(aspectratio != NULL) {
*aspectratio = bcam->ortho_scale/2.0f;
}
}
if(bcam->type == CAMERA_PANORAMA) {
/* set viewplane */
*viewplane = bcam->pano_viewplane;
if(viewplane != NULL) {
*viewplane = bcam->pano_viewplane;
}
}
else {
/* set viewplane */
viewplane->left = -xaspect;
viewplane->right = xaspect;
viewplane->bottom = -yaspect;
viewplane->top = yaspect;
if(viewplane != NULL) {
viewplane->left = -xaspect;
viewplane->right = xaspect;
viewplane->bottom = -yaspect;
viewplane->top = yaspect;
/* zoom for 3d camera view */
*viewplane = (*viewplane) * bcam->zoom;
/* zoom for 3d camera view */
*viewplane = (*viewplane) * bcam->zoom;
/* modify viewplane with camera shift and 3d camera view offset */
float dx = 2.0f*(*aspectratio*bcam->shift.x + bcam->offset.x*xaspect*2.0f);
float dy = 2.0f*(*aspectratio*bcam->shift.y + bcam->offset.y*yaspect*2.0f);
/* modify viewplane with camera shift and 3d camera view offset */
float dx = 2.0f*(*aspectratio*bcam->shift.x + bcam->offset.x*xaspect*2.0f);
float dy = 2.0f*(*aspectratio*bcam->shift.y + bcam->offset.y*yaspect*2.0f);
viewplane->left += dx;
viewplane->right += dx;
viewplane->bottom += dy;
viewplane->top += dy;
viewplane->left += dx;
viewplane->right += dx;
viewplane->bottom += dy;
viewplane->top += dy;
}
}
}
@@ -365,11 +399,16 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
cam->bladesrotation = bcam->aperturerotation;
/* transform */
cam->matrix = blender_camera_matrix(bcam->matrix, bcam->type);
cam->matrix = blender_camera_matrix(bcam->matrix,
bcam->type,
bcam->panorama_type);
cam->motion.pre = cam->matrix;
cam->motion.post = cam->matrix;
cam->use_motion = false;
cam->use_perspective_motion = false;
cam->shuttertime = bcam->shuttertime;
cam->fov_pre = cam->fov;
cam->fov_post = cam->fov;
/* border */
cam->border = bcam->border;
@@ -418,13 +457,19 @@ void BlenderSync::sync_camera(BL::RenderSettings b_render, BL::Object b_override
blender_camera_sync(cam, &bcam, width, height);
}
void BlenderSync::sync_camera_motion(BL::Object b_ob, float motion_time)
void BlenderSync::sync_camera_motion(BL::RenderSettings b_render,
BL::Object b_ob,
int width, int height,
float motion_time)
{
if(!b_ob)
return;
Camera *cam = scene->camera;
BL::Array<float, 16> b_ob_matrix;
b_engine.camera_model_matrix(b_ob, b_ob_matrix);
Transform tfm = get_transform(b_ob_matrix);
tfm = blender_camera_matrix(tfm, cam->type);
tfm = blender_camera_matrix(tfm, cam->type, cam->panorama_type);
if(tfm != cam->matrix) {
VLOG(1) << "Camera " << b_ob.name() << " motion detected.";
@@ -437,6 +482,31 @@ void BlenderSync::sync_camera_motion(BL::Object b_ob, float motion_time)
cam->use_motion = true;
}
}
if(cam->type == CAMERA_PERSPECTIVE) {
BlenderCamera bcam;
float aspectratio, sensor_size;
blender_camera_init(&bcam, b_render);
blender_camera_from_object(&bcam, b_engine, b_ob);
blender_camera_viewplane(&bcam,
width, height,
NULL,
&aspectratio,
&sensor_size);
/* TODO(sergey): De-duplicate calculation with camera sync. */
float fov = 2.0f * atanf((0.5f * sensor_size) / bcam.lens / aspectratio);
if(fov != cam->fov) {
VLOG(1) << "Camera " << b_ob.name() << " FOV change detected.";
if(motion_time == -1.0f) {
cam->fov_pre = fov;
cam->use_perspective_motion = true;
}
else if(motion_time == 1.0f) {
cam->fov_post = fov;
cam->use_perspective_motion = true;
}
}
}
}
/* Sync 3D View Camera */

View File

@@ -242,8 +242,16 @@ static void create_mesh_volume_attribute(BL::Object b_ob, Mesh *mesh, ImageManag
bool animated = false;
volume_data->manager = image_manager;
volume_data->slot = image_manager->add_image(Attribute::standard_name(std),
b_ob.ptr.data, animated, frame, is_float, is_linear, INTERPOLATION_LINEAR, true);
volume_data->slot = image_manager->add_image(
Attribute::standard_name(std),
b_ob.ptr.data,
animated,
frame,
is_float,
is_linear,
INTERPOLATION_LINEAR,
EXTENSION_REPEAT,
true);
}
static void create_mesh_volume_attributes(Scene *scene, BL::Object b_ob, Mesh *mesh, float frame)

View File

@@ -215,6 +215,7 @@ void BlenderSync::sync_background_light(bool use_portal)
light->map_resolution = get_int(cworld, "sample_map_resolution");
light->shader = scene->default_background;
light->use_mis = sample_as_light;
light->max_bounces = get_int(cworld, "max_bounces");
int samples = get_int(cworld, "samples");
if(get_boolean(cscene, "use_square_samples"))
@@ -234,8 +235,56 @@ void BlenderSync::sync_background_light(bool use_portal)
/* Object */
Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::DupliObject b_dupli_ob,
Transform& tfm, uint layer_flag, float motion_time, bool hide_tris, bool *use_portal)
/* TODO(sergey): Not really optimal, consider approaches based on k-DOP in order
* to reduce number of objects which are wrongly considered visible.
*/
static bool object_boundbox_clip(Scene *scene,
BL::Object b_ob,
Transform& tfm,
float margin)
{
Camera *cam = scene->camera;
Transform& worldtondc = cam->worldtondc;
BL::Array<float, 24> boundbox = b_ob.bound_box();
float3 bb_min = make_float3(FLT_MAX, FLT_MAX, FLT_MAX),
bb_max = make_float3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
bool all_behind = true;
for(int i = 0; i < 8; ++i) {
float3 p = make_float3(boundbox[3 * i + 0],
boundbox[3 * i + 1],
boundbox[3 * i + 2]);
p = transform_point(&tfm, p);
p = transform_point(&worldtondc, p);
if(p.z >= -margin) {
all_behind = false;
}
p /= p.z;
bb_min = min(bb_min, p);
bb_max = max(bb_max, p);
}
if(!all_behind) {
if(bb_min.x >= 1.0f + margin ||
bb_min.y >= 1.0f + margin ||
bb_max.x <= -margin ||
bb_max.y <= -margin)
{
return true;
}
return false;
}
return true;
}
Object *BlenderSync::sync_object(BL::Object b_parent,
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
BL::DupliObject b_dupli_ob,
Transform& tfm,
uint layer_flag,
float motion_time,
bool hide_tris,
bool use_camera_cull,
float camera_cull_margin,
bool *use_portal)
{
BL::Object b_ob = (b_dupli_ob ? b_dupli_ob.object() : b_parent);
bool motion = motion_time != 0.0f;
@@ -253,6 +302,11 @@ Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_P
if(!object_is_mesh(b_ob))
return NULL;
/* Perform camera space culling. */
if(use_camera_cull && object_boundbox_clip(scene, b_ob, tfm, camera_cull_margin)) {
return NULL;
}
/* key to lookup object */
ObjectKey key(b_parent, persistent_id, b_ob);
Object *object;
@@ -261,7 +315,9 @@ Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_P
if(motion) {
object = object_map.find(key);
if(object && (scene->need_motion() == Scene::MOTION_PASS || object_use_motion(b_ob))) {
if(object && (scene->need_motion() == Scene::MOTION_PASS ||
object_use_motion(b_parent, b_ob)))
{
/* object transformation */
if(tfm != object->tfm) {
VLOG(1) << "Object " << b_ob.name() << " motion detected.";
@@ -342,8 +398,8 @@ Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_P
mesh->use_motion_blur = false;
if(object_use_motion(b_ob)) {
if(object_use_deform_motion(b_ob)) {
if(object_use_motion(b_parent, b_ob)) {
if(object_use_deform_motion(b_parent, b_ob)) {
mesh->motion_steps = object_motion_steps(b_ob);
mesh->use_motion_blur = true;
}
@@ -478,6 +534,18 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time)
mesh_motion_synced.clear();
}
bool allow_camera_cull = false;
float camera_cull_margin = 0.0f;
if(b_scene.render().use_simplify()) {
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
allow_camera_cull = scene->camera->type != CAMERA_PANORAMA &&
!b_scene.render().use_multiview() &&
get_boolean(cscene, "use_camera_cull");
if(allow_camera_cull) {
camera_cull_margin = get_float(cscene, "camera_cull_margin");
}
}
/* object loop */
BL::Scene::object_bases_iterator b_base;
BL::Scene b_sce = b_scene;
@@ -500,6 +568,12 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time)
if(!hide) {
progress.set_sync_status("Synchronizing object", b_ob.name());
PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
bool use_camera_cull = allow_camera_cull && get_boolean(cobject, "use_camera_cull");
if(use_camera_cull) {
/* Need to have proper projection matrix. */
scene->camera->update();
}
if(b_ob.is_duplicator() && !object_render_hide_duplis(b_ob)) {
/* dupli objects */
b_ob.dupli_list_create(b_scene, dupli_settings);
@@ -519,7 +593,16 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time)
BL::Array<int, OBJECT_PERSISTENT_ID_SIZE> persistent_id = b_dup->persistent_id();
/* sync object and mesh or light data */
Object *object = sync_object(b_ob, persistent_id.data, *b_dup, tfm, ob_layer, motion_time, hide_tris, &use_portal);
Object *object = sync_object(b_ob,
persistent_id.data,
*b_dup,
tfm,
ob_layer,
motion_time,
hide_tris,
use_camera_cull,
camera_cull_margin,
&use_portal);
/* sync possible particle data, note particle_id
* starts counting at 1, first is dummy particle */
@@ -539,7 +622,16 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time)
if(!object_render_hide(b_ob, true, true, hide_tris)) {
/* object itself */
Transform tfm = get_transform(b_ob.matrix_world());
sync_object(b_ob, NULL, PointerRNA_NULL, tfm, ob_layer, motion_time, hide_tris, &use_portal);
sync_object(b_ob,
NULL,
PointerRNA_NULL,
tfm,
ob_layer,
motion_time,
hide_tris,
use_camera_cull,
camera_cull_margin,
&use_portal);
}
}
@@ -567,7 +659,11 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, float motion_time)
mesh_motion_synced.clear();
}
void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override, void **python_thread_state)
void BlenderSync::sync_motion(BL::RenderSettings b_render,
BL::SpaceView3D b_v3d,
BL::Object b_override,
int width, int height,
void **python_thread_state)
{
if(scene->need_motion() == Scene::MOTION_NONE)
return;
@@ -587,6 +683,9 @@ void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override, void
/* note iteration over motion_times set happens in sorted order */
foreach(float relative_time, motion_times) {
VLOG(1) << "Synchronizing motion for the relative time "
<< relative_time << ".";
/* fixed shutter time to get previous and next frame for motion pass */
float shuttertime;
@@ -606,8 +705,12 @@ void BlenderSync::sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override, void
python_thread_state_save(python_thread_state);
/* sync camera, only supports two times at the moment */
if(relative_time == -1.0f || relative_time == 1.0f)
sync_camera_motion(b_cam, relative_time);
if(relative_time == -1.0f || relative_time == 1.0f) {
sync_camera_motion(b_render,
b_cam,
width, height,
relative_time);
}
/* sync object */
sync_objects(b_v3d, relative_time);

View File

@@ -22,6 +22,7 @@
#include "blender_session.h"
#include "util_foreach.h"
#include "util_logging.h"
#include "util_md5.h"
#include "util_opengl.h"
#include "util_path.h"
@@ -486,6 +487,19 @@ static PyObject *system_info_func(PyObject * /*self*/, PyObject * /*value*/)
return PyUnicode_FromString(system_info.c_str());
}
#ifdef WITH_OPENCL
static PyObject *opencl_disable_func(PyObject * /*self*/, PyObject * /*value*/)
{
VLOG(2) << "Disabling OpenCL platform.";
#ifdef WIN32
putenv("CYCLES_OPENCL_TEST=NONE");
#else
setenv("CYCLES_OPENCL_TEST", "NONE", 1);
#endif
Py_RETURN_NONE;
}
#endif
static PyMethodDef methods[] = {
{"init", init_func, METH_VARARGS, ""},
{"create", create_func, METH_VARARGS, ""},
@@ -501,6 +515,9 @@ static PyMethodDef methods[] = {
#endif
{"available_devices", available_devices_func, METH_NOARGS, ""},
{"system_info", system_info_func, METH_NOARGS, ""},
#ifdef WITH_OPENCL
{"opencl_disable", opencl_disable_func, METH_NOARGS, ""},
#endif
{NULL, NULL, 0, NULL},
};

View File

@@ -32,6 +32,7 @@
#include "util_color.h"
#include "util_foreach.h"
#include "util_function.h"
#include "util_logging.h"
#include "util_progress.h"
#include "util_time.h"
@@ -121,7 +122,12 @@ void BlenderSession::create_session()
if(session_pause == false) {
/* full data sync */
sync->sync_view(b_v3d, b_rv3d, width, height);
sync->sync_data(b_v3d, b_engine.camera_override(), &python_thread_state);
sync->sync_data(b_render,
b_v3d,
b_engine.camera_override(),
width, height,
&python_thread_state,
b_rlay_name.c_str());
}
}
else {
@@ -271,6 +277,10 @@ static PassType get_pass_type(BL::RenderPass b_pass)
{
if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSAL_STEPS)
return PASS_BVH_TRAVERSAL_STEPS;
if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSED_INSTANCES)
return PASS_BVH_TRAVERSED_INSTANCES;
if(b_pass.debug_type() == BL::RenderPass::debug_type_RAY_BOUNCES)
return PASS_RAY_BOUNCES;
break;
}
#endif
@@ -437,9 +447,6 @@ void BlenderSession::render()
/* add passes */
vector<Pass> passes;
Pass::add(PASS_COMBINED, passes);
#ifdef WITH_CYCLES_DEBUG
Pass::add(PASS_BVH_TRAVERSAL_STEPS, passes);
#endif
if(session_params.device.advanced_shading) {
@@ -471,7 +478,12 @@ void BlenderSession::render()
/* update scene */
sync->sync_camera(b_render, b_engine.camera_override(), width, height);
sync->sync_data(b_v3d, b_engine.camera_override(), &python_thread_state, b_rlay_name.c_str());
sync->sync_data(b_render,
b_v3d,
b_engine.camera_override(),
width, height,
&python_thread_state,
b_rlay_name.c_str());
/* update number of samples per layer */
int samples = sync->get_layer_samples();
@@ -497,6 +509,11 @@ void BlenderSession::render()
break;
}
double total_time, render_time;
session->progress.get_time(total_time, render_time);
VLOG(1) << "Total render time: " << total_time;
VLOG(1) << "Render time (without synchronization): " << render_time;
/* clear callback */
session->write_render_tile_cb = function_null;
session->update_render_tile_cb = function_null;
@@ -532,6 +549,11 @@ void BlenderSession::bake(BL::Object b_object, const string& pass_type, const in
size_t object_index = OBJECT_NONE;
int tri_offset = 0;
/* Set baking flag in advance, so kernel loading can check if we need
* any baking capabilities.
*/
scene->bake_manager->set_baking(true);
/* ensure kernels are loaded before we do any scene updates */
session->load_kernels();
@@ -554,14 +576,18 @@ void BlenderSession::bake(BL::Object b_object, const string& pass_type, const in
/* update scene */
sync->sync_camera(b_render, b_engine.camera_override(), width, height);
sync->sync_data(b_v3d, b_engine.camera_override(), &python_thread_state);
sync->sync_data(b_render,
b_v3d,
b_engine.camera_override(),
width, height,
&python_thread_state,
b_rlay_name.c_str());
/* get buffer parameters */
SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background);
BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_v3d, b_rv3d, scene->camera, width, height);
scene->bake_manager->set_shader_limit((size_t)b_engine.tile_x(), (size_t)b_engine.tile_y());
scene->bake_manager->set_baking(true);
/* set number of samples */
session->tile_manager.set_samples(session_params.samples);
@@ -697,7 +723,12 @@ void BlenderSession::synchronize()
}
/* data and camera synchronize */
sync->sync_data(b_v3d, b_engine.camera_override(), &python_thread_state);
sync->sync_data(b_render,
b_v3d,
b_engine.camera_override(),
width, height,
&python_thread_state,
b_rlay_name.c_str());
if(b_rv3d)
sync->sync_view(b_v3d, b_rv3d, width, height);
@@ -863,12 +894,12 @@ void BlenderSession::update_status_progress()
scene += ", " + b_rview_name;
}
else {
BLI_timestr(total_time, time_str, sizeof(time_str));
BLI_timecode_string_from_time_simple(time_str, sizeof(time_str), total_time);
timestatus = "Time:" + string(time_str) + " | ";
}
if(remaining_time > 0) {
BLI_timestr(remaining_time, time_str, sizeof(time_str));
BLI_timecode_string_from_time_simple(time_str, sizeof(time_str), remaining_time);
timestatus += "Remaining:" + string(time_str) + " | ";
}
@@ -1001,6 +1032,18 @@ void BlenderSession::builtin_image_info(const string &builtin_name, void *builti
is_float = true;
}
else {
/* TODO(sergey): Check we're indeed in shader node tree. */
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_Node, builtin_data, &ptr);
BL::Node b_node(ptr);
if(b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
channels = 4;
width = height = depth = b_point_density_node.resolution();
is_float = true;
}
}
}
bool BlenderSession::builtin_image_pixels(const string &builtin_name, void *builtin_data, unsigned char *pixels)
@@ -1143,6 +1186,17 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
fprintf(stderr, "Cycles error: unexpected smoke volume resolution, skipping\n");
}
else {
/* TODO(sergey): Check we're indeed in shader node tree. */
PointerRNA ptr;
RNA_pointer_create(NULL, &RNA_Node, builtin_data, &ptr);
BL::Node b_node(ptr);
if(b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
int length;
b_point_density_node.calc_point_density(b_scene, &length, &pixels);
}
}
return false;
}

View File

@@ -22,6 +22,7 @@
#include "scene.h"
#include "shader.h"
#include "blender_texture.h"
#include "blender_sync.h"
#include "blender_util.h"
@@ -589,14 +590,17 @@ static ShaderNode *add_node(Scene *scene,
/* TODO(sergey): Does not work properly when we change builtin type. */
if(b_image.is_updated()) {
scene->image_manager->tag_reload_image(image->filename,
image->builtin_data,
(InterpolationType)b_image_node.interpolation());
scene->image_manager->tag_reload_image(
image->filename,
image->builtin_data,
(InterpolationType)b_image_node.interpolation(),
(ExtensionType)b_image_node.extension());
}
}
image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()];
image->interpolation = (InterpolationType)b_image_node.interpolation();
image->extension = (ExtensionType)b_image_node.extension();
image->projection_blend = b_image_node.projection_blend();
get_tex_mapping(&image->tex_mapping, b_image_node.texture_mapping());
node = image;
@@ -629,7 +633,8 @@ static ShaderNode *add_node(Scene *scene,
if(b_image.is_updated()) {
scene->image_manager->tag_reload_image(env->filename,
env->builtin_data,
INTERPOLATION_LINEAR);
INTERPOLATION_LINEAR,
EXTENSION_REPEAT);
}
}
env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
@@ -736,6 +741,36 @@ static ShaderNode *add_node(Scene *scene,
uvm->from_dupli = b_uvmap_node.from_dupli();
node = uvm;
}
else if(b_node.is_a(&RNA_ShaderNodeTexPointDensity)) {
BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
PointDensityTextureNode *point_density = new PointDensityTextureNode();
point_density->filename = b_point_density_node.name();
point_density->space =
PointDensityTextureNode::space_enum[(int)b_point_density_node.space()];
point_density->interpolation =
(InterpolationType)b_point_density_node.interpolation();
point_density->builtin_data = b_point_density_node.ptr.data;
/* Transformation form world space to texture space. */
BL::Object b_ob(b_point_density_node.object());
if(b_ob) {
float3 loc, size;
point_density_texture_space(b_point_density_node, loc, size);
point_density->tfm =
transform_translate(-loc) * transform_scale(size) *
transform_inverse(get_transform(b_ob.matrix_world()));
}
/* TODO(sergey): Use more proper update flag. */
if(true) {
scene->image_manager->tag_reload_image(
point_density->filename,
point_density->builtin_data,
point_density->interpolation,
EXTENSION_REPEAT);
}
node = point_density;
}
if(node)
graph->add(node);

View File

@@ -145,7 +145,12 @@ bool BlenderSync::sync_recalc()
return recalc;
}
void BlenderSync::sync_data(BL::SpaceView3D b_v3d, BL::Object b_override, void **python_thread_state, const char *layer)
void BlenderSync::sync_data(BL::RenderSettings b_render,
BL::SpaceView3D b_v3d,
BL::Object b_override,
int width, int height,
void **python_thread_state,
const char *layer)
{
sync_render_layers(b_v3d, layer);
sync_integrator();
@@ -157,7 +162,11 @@ void BlenderSync::sync_data(BL::SpaceView3D b_v3d, BL::Object b_override, void *
mesh_synced.clear(); /* use for objects and motion sync */
sync_objects(b_v3d);
sync_motion(b_v3d, b_override, python_thread_state);
sync_motion(b_render,
b_v3d,
b_override,
width, height,
python_thread_state);
mesh_synced.clear();
}

View File

@@ -53,7 +53,12 @@ public:
/* sync */
bool sync_recalc();
void sync_data(BL::SpaceView3D b_v3d, BL::Object b_override, void **python_thread_state, const char *layer = 0);
void sync_data(BL::RenderSettings b_render,
BL::SpaceView3D b_v3d,
BL::Object b_override,
int width, int height,
void **python_thread_state,
const char *layer = 0);
void sync_render_layers(BL::SpaceView3D b_v3d, const char *layer);
void sync_integrator();
void sync_camera(BL::RenderSettings b_render, BL::Object b_override, int width, int height);
@@ -75,7 +80,11 @@ private:
void sync_lamps(bool update_all);
void sync_materials(bool update_all);
void sync_objects(BL::SpaceView3D b_v3d, float motion_time = 0.0f);
void sync_motion(BL::SpaceView3D b_v3d, BL::Object b_override, void **python_thread_state);
void sync_motion(BL::RenderSettings b_render,
BL::SpaceView3D b_v3d,
BL::Object b_override,
int width, int height,
void **python_thread_state);
void sync_film();
void sync_view();
void sync_world(bool update_all);
@@ -85,12 +94,23 @@ private:
void sync_nodes(Shader *shader, BL::ShaderNodeTree b_ntree);
Mesh *sync_mesh(BL::Object b_ob, bool object_updated, bool hide_tris);
void sync_curves(Mesh *mesh, BL::Mesh b_mesh, BL::Object b_ob, bool motion, int time_index = 0);
Object *sync_object(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::DupliObject b_dupli_ob,
Transform& tfm, uint layer_flag, float motion_time, bool hide_tris, bool *use_portal);
Object *sync_object(BL::Object b_parent,
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
BL::DupliObject b_dupli_ob,
Transform& tfm,
uint layer_flag,
float motion_time,
bool hide_tris,
bool use_camera_cull,
float camera_cull_margin,
bool *use_portal);
void sync_light(BL::Object b_parent, int persistent_id[OBJECT_PERSISTENT_ID_SIZE], BL::Object b_ob, Transform& tfm, bool *use_portal);
void sync_background_light(bool use_portal);
void sync_mesh_motion(BL::Object b_ob, Object *object, float motion_time);
void sync_camera_motion(BL::Object b_ob, float motion_time);
void sync_camera_motion(BL::RenderSettings b_render,
BL::Object b_ob,
int width, int height,
float motion_time);
/* particles */
bool sync_dupli_particle(BL::Object b_ob, BL::DupliObject b_dup, Object *object);

View File

@@ -0,0 +1,116 @@
/*
* Copyright 2011-2015 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "blender_texture.h"
CCL_NAMESPACE_BEGIN
namespace {
/* Point density helpers. */
static void density_texture_space_invert(float3& loc,
float3& size)
{
if(size.x != 0.0f) size.x = 0.5f/size.x;
if(size.y != 0.0f) size.y = 0.5f/size.y;
if(size.z != 0.0f) size.z = 0.5f/size.z;
loc = loc*size - make_float3(0.5f, 0.5f, 0.5f);
}
static void density_object_texture_space(BL::Object b_ob,
float radius,
float3& loc,
float3& size)
{
if(b_ob.type() == BL::Object::type_MESH) {
BL::Mesh b_mesh(b_ob.data());
loc = get_float3(b_mesh.texspace_location());
size = get_float3(b_mesh.texspace_size());
}
else {
/* TODO(sergey): Not supported currently. */
}
/* Adjust texture space to include density points on the boundaries. */
size = size + make_float3(radius, radius, radius);
density_texture_space_invert(loc, size);
}
static void density_particle_system_texture_space(
BL::Object b_ob,
BL::ParticleSystem b_particle_system,
float radius,
float3& loc,
float3& size)
{
if(b_particle_system.settings().type() == BL::ParticleSettings::type_HAIR) {
/* TODO(sergey): Not supported currently. */
return;
}
Transform tfm = get_transform(b_ob.matrix_world());
Transform itfm = transform_inverse(tfm);
float3 min = make_float3(FLT_MAX, FLT_MAX, FLT_MAX),
max = make_float3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
float3 particle_size = make_float3(radius, radius, radius);
for(int i = 0; i < b_particle_system.particles.length(); ++i) {
BL::Particle particle = b_particle_system.particles[i];
float3 location = get_float3(particle.location());
location = transform_point(&itfm, location);
min = ccl::min(min, location - particle_size);
max = ccl::max(max, location + particle_size);
}
/* Calculate texture space from the particle bounds. */
loc = (min + max) * 0.5f;
size = (max - min) * 0.5f;
density_texture_space_invert(loc, size);
}
} /* namespace */
void point_density_texture_space(BL::ShaderNodeTexPointDensity b_point_density_node,
float3& loc,
float3& size)
{
/* Fallback values. */
loc = make_float3(0.0f, 0.0f, 0.0f);
size = make_float3(0.0f, 0.0f, 0.0f);
BL::Object b_ob(b_point_density_node.object());
if(!b_ob) {
return;
}
if(b_point_density_node.point_source() ==
BL::ShaderNodeTexPointDensity::point_source_PARTICLE_SYSTEM)
{
BL::ParticleSystem b_particle_system(
b_point_density_node.particle_system());
if(b_particle_system) {
density_particle_system_texture_space(b_ob,
b_particle_system,
b_point_density_node.radius(),
loc,
size);
}
}
else {
density_object_texture_space(b_ob,
b_point_density_node.radius(),
loc,
size);
}
}
CCL_NAMESPACE_END

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2011-2015 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BLENDER_TEXTURE_H__
#define __BLENDER_TEXTURE_H__
#include <stdlib.h>
#include "blender_sync.h"
CCL_NAMESPACE_BEGIN
void point_density_texture_space(BL::ShaderNodeTexPointDensity b_point_density_node,
float3& loc,
float3& size);
CCL_NAMESPACE_END
#endif /* __BLENDER_TEXTURE_H__ */

View File

@@ -28,7 +28,7 @@
* todo: clean this up ... */
extern "C" {
void BLI_timestr(double _time, char *str, size_t maxlen);
size_t BLI_timecode_string_from_time_simple(char *str, size_t maxlen, double time_seconds);
void BKE_image_user_frame_calc(void *iuser, int cfra, int fieldnr);
void BKE_image_user_file_path(void *iuser, void *ima, char *path);
unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame);
@@ -354,11 +354,20 @@ static inline void mesh_texture_space(BL::Mesh b_mesh, float3& loc, float3& size
}
/* object used for motion blur */
static inline bool object_use_motion(BL::Object b_ob)
static inline bool object_use_motion(BL::Object b_parent, BL::Object b_ob)
{
PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
bool use_motion = get_boolean(cobject, "use_motion_blur");
/* If motion blur is enabled for the object we also check
* whether it's enabled for the parent object as well.
*
* This way we can control motion blur from the dupligroup
* duplicator much easier.
*/
if(use_motion && b_parent.ptr.data != b_ob.ptr.data) {
PointerRNA parent_cobject = RNA_pointer_get(&b_parent.ptr, "cycles");
use_motion &= get_boolean(parent_cobject, "use_motion_blur");
}
return use_motion;
}
@@ -375,11 +384,20 @@ static inline uint object_motion_steps(BL::Object b_ob)
}
/* object uses deformation motion blur */
static inline bool object_use_deform_motion(BL::Object b_ob)
static inline bool object_use_deform_motion(BL::Object b_parent, BL::Object b_ob)
{
PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
bool use_deform_motion = get_boolean(cobject, "use_deform_motion");
/* If motion blur is enabled for the object we also check
* whether it's enabled for the parent object as well.
*
* This way we can control motion blur from the dupligroup
* duplicator much easier.
*/
if(use_deform_motion && b_parent.ptr.data != b_ob.ptr.data) {
PointerRNA parent_cobject = RNA_pointer_get(&b_parent.ptr, "cycles");
use_deform_motion &= get_boolean(parent_cobject, "use_deform_motion");
}
return use_deform_motion;
}

View File

@@ -190,11 +190,12 @@ void BVH::build(Progress& progress)
}
/* build nodes */
vector<int> prim_type;
vector<int> prim_index;
vector<int> prim_object;
BVHBuild bvh_build(objects, prim_type, prim_index, prim_object, params, progress);
BVHBuild bvh_build(objects,
pack.prim_type,
pack.prim_index,
pack.prim_object,
params,
progress);
BVHNode *root = bvh_build.run();
if(progress.get_cancel()) {
@@ -202,14 +203,6 @@ void BVH::build(Progress& progress)
return;
}
/* todo: get rid of this copy */
pack.prim_type = prim_type;
pack.prim_index = prim_index;
pack.prim_object = prim_object;
prim_type.free_memory();
prim_index.free_memory();
prim_object.free_memory();
/* compute SAH */
if(!params.top_level)
pack.SAH = root->computeSubtreeSAHCost(params);

View File

@@ -65,15 +65,18 @@ public:
/* Constructor / Destructor */
BVHBuild::BVHBuild(const vector<Object*>& objects_,
vector<int>& prim_type_, vector<int>& prim_index_, vector<int>& prim_object_,
const BVHParams& params_, Progress& progress_)
: objects(objects_),
prim_type(prim_type_),
prim_index(prim_index_),
prim_object(prim_object_),
params(params_),
progress(progress_),
progress_start_time(0.0)
array<int>& prim_type_,
array<int>& prim_index_,
array<int>& prim_object_,
const BVHParams& params_,
Progress& progress_)
: objects(objects_),
prim_type(prim_type_),
prim_index(prim_index_),
prim_object(prim_object_),
params(params_),
progress(progress_),
progress_start_time(0.0)
{
spatial_min_overlap = 0.0f;
}
@@ -446,18 +449,10 @@ BVHNode *BVHBuild::create_object_leaf_nodes(const BVHReference *ref, int start,
return new LeafNode(bounds, 0, 0, 0);
}
else if(num == 1) {
if(start == prim_index.size()) {
assert(params.use_spatial_split);
prim_type.push_back(ref->prim_type());
prim_index.push_back(ref->prim_index());
prim_object.push_back(ref->prim_object());
}
else {
prim_type[start] = ref->prim_type();
prim_index[start] = ref->prim_index();
prim_object[start] = ref->prim_object();
}
assert(start < prim_type.size());
prim_type[start] = ref->prim_type();
prim_index[start] = ref->prim_index();
prim_object[start] = ref->prim_object();
uint visibility = objects[ref->prim_object()]->visibility;
return new LeafNode(ref->bounds(), visibility, start, start+1);
@@ -484,17 +479,9 @@ BVHNode *BVHBuild::create_primitive_leaf_node(const int *p_type,
int num)
{
for(int i = 0; i < num; ++i) {
if(start + i == prim_index.size()) {
assert(params.use_spatial_split);
prim_type.push_back(p_type[i]);
prim_index.push_back(p_index[i]);
prim_object.push_back(p_object[i]);
}
else {
prim_type[start + i] = p_type[i];
prim_index[start + i] = p_index[i];
prim_object[start + i] = p_object[i];
}
prim_type[start + i] = p_type[i];
prim_index[start + i] = p_index[i];
prim_object[start + i] = p_object[i];
}
return new LeafNode(bounds, visibility, start, start + num);
}
@@ -535,6 +522,19 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range)
}
}
/* Extend an array when needed. */
if(prim_type.size() < range.end()) {
assert(params.use_spatial_split);
/* TODO(sergey): We might want to look into different policies of
* re-allocation here, so on the one hand we would not do as much
* re-allocations and on the other hand will have small memory
* overhead.
*/
prim_type.resize(range.end());
prim_index.resize(range.end());
prim_object.resize(range.end());
}
/* Create leaf nodes for every existing primitive. */
BVHNode *leaves[PRIMITIVE_NUM_TOTAL + 1] = {NULL};
int num_leaves = 0;

View File

@@ -42,13 +42,12 @@ class BVHBuild
{
public:
/* Constructor/Destructor */
BVHBuild(
const vector<Object*>& objects,
vector<int>& prim_type,
vector<int>& prim_index,
vector<int>& prim_object,
const BVHParams& params,
Progress& progress);
BVHBuild(const vector<Object*>& objects,
array<int>& prim_type,
array<int>& prim_index,
array<int>& prim_object,
const BVHParams& params,
Progress& progress);
~BVHBuild();
BVHNode *run();
@@ -99,9 +98,9 @@ protected:
int num_original_references;
/* output primitive indexes and objects */
vector<int>& prim_type;
vector<int>& prim_index;
vector<int>& prim_object;
array<int>& prim_type;
array<int>& prim_index;
array<int>& prim_object;
/* build parameters */
BVHParams params;

View File

@@ -31,6 +31,29 @@
CCL_NAMESPACE_BEGIN
/* Device Requested Features */
std::ostream& operator <<(std::ostream &os,
const DeviceRequestedFeatures& requested_features)
{
os << "Experimental features: "
<< (requested_features.experimental ? "On" : "Off") << std::endl;
os << "Max closure count: " << requested_features.max_closure << std::endl;
os << "Max nodes group: " << requested_features.max_nodes_group << std::endl;
/* TODO(sergey): Decode bitflag into list of names. */
os << "Nodes features: " << requested_features.nodes_features << std::endl;
/* TODO(sergey): Make it utility function to convert bool to string. */
os << "Use hair: "
<< (requested_features.use_hair ? "True" : "False") << std::endl;
os << "Use object motion: "
<< (requested_features.use_object_motion ? "True" : "False") << std::endl;
os << "Use camera motion: "
<< (requested_features.use_camera_motion ? "True" : "False") << std::endl;
os << "Use Baking: "
<< (requested_features.use_baking ? "True" : "False") << std::endl;
return os;
}
/* Device */
Device::~Device()

View File

@@ -97,6 +97,9 @@ public:
bool use_object_motion;
bool use_camera_motion;
/* Denotes whether baking functionality is needed. */
bool use_baking;
DeviceRequestedFeatures()
{
/* TODO(sergey): Find more meaningful defaults. */
@@ -107,6 +110,7 @@ public:
use_hair = false;
use_object_motion = false;
use_camera_motion = false;
use_baking = false;
}
bool modified(const DeviceRequestedFeatures& requested_features)
@@ -114,10 +118,18 @@ public:
return !(experimental == requested_features.experimental &&
max_closure == requested_features.max_closure &&
max_nodes_group == requested_features.max_nodes_group &&
nodes_features == requested_features.nodes_features);
nodes_features == requested_features.nodes_features &&
use_hair == requested_features.use_hair &&
use_object_motion == requested_features.use_object_motion &&
use_camera_motion == requested_features.use_camera_motion &&
use_baking == requested_features.use_baking);
}
};
std::ostream& operator <<(std::ostream &os,
const DeviceRequestedFeatures& requested_features);
/* Device */
struct DeviceDrawParams {
@@ -161,10 +173,10 @@ public:
virtual void tex_alloc(const char * /*name*/,
device_memory& /*mem*/,
InterpolationType interpolation = INTERPOLATION_NONE,
bool periodic = false)
ExtensionType extension = EXTENSION_REPEAT)
{
(void)interpolation; /* Ignored. */
(void)periodic; /* Ignored. */
(void)extension; /* Ignored. */
};
virtual void tex_free(device_memory& /*mem*/) {};

Some files were not shown because too many files have changed in this diff Show More