1
1

Compare commits

...

784 Commits

Author SHA1 Message Date
58d6cbba6d Merge branch 'master' into temp-ghash-setops 2015-06-29 17:10:42 +02: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
bcfe38aa03 Fix T44964: Bisect tool /w nonuniform scale 2015-06-08 22:30:45 +10:00
303c912093 Fix crash introduced by recent node tree localization
It should not add temporary datablocks to the bmain.
2015-06-08 14:10:43 +02:00
ec0ba4095f Fix T44979: Crash when rendering with more threads than the system ones
Revert "Nodes: Remove hardcoded BLENDER_MAX_THREADS number of threads"

This reverts commit fdc653e8ce.

The threads override is not affected by the scene, and hence the limit of the
threads was not giving correct result. Need to re-consider some things here.
2015-06-08 13:53:54 +02:00
d63615272c Use context manager for reading addon headers 2015-06-08 21:21:54 +10:00
07d51141ae Fix: a broken symlink to an addon resulted in a blank addon tab
The addons tab in the User Settings window would be empty, due to
a FileNotFound error. This error can be caused by a broken symlink,
which is now treated the same was as a file that misses its bl_info
dictionary.
2015-06-08 12:08:43 +02:00
87629b2a74 RNA: Object.shape_key_remove method
Python had no ability to remove shape keys
Original D1169 from @lichtwerk, with edits
2015-06-08 19:52:04 +10:00
546a0e2d96 Fix T44989: Crash on linking external OSL material
Issue was caused by passing NULL bmain to the path remap function when
localizing the node tree.

Paths are to be remapped, otherwise mapping of paths to OSL scripts
might happen in a wrong way.
2015-06-08 11:15:40 +02:00
0589a814ba Cycles: Fix crash doing render preview of external OSL script 2015-06-08 11:15:40 +02:00
2ebaa69676 Cycles: Move requested feature conversion to an own function
This way it could be used for the shader/baking kernels easily n the future.
making those kernels more optimal.
2015-06-08 11:15:40 +02:00
8c2750bc82 Cycles: Remove round-up trickery for max closure in split OpenCL kernel
Round-up was only enabled for viewport render, which was for a long time hardcoded to
use 64 closures. This was done in order to avoid unnecessary kernel re-compilations
when tweaking the shader tree.

We could enable selective closure compilation in the viewport later if it'll give
measurable speed improvements, but even then round-up is to happen outside of the
device level,

This commit also removes early output which happened in cases when max closure did
not change. It was wrong because other requested kernel features might have been
changed.
2015-06-08 11:15:39 +02:00
c6c06285a7 Cycles: Remove requirement of using experimental kernel for hair and blur on AMD
Those features are not selectively compiled, so there's no real benefit of hiding
them under the experimental feature set.
2015-06-08 11:15:39 +02:00
27ed75271c Cycles: Make hair, object and motion blur selective compiled into OpenCL
This features are now based on the scene settings, so scenes without those features
used are rendered even faster.

This gives about 30% speedup on the AMD A10 APU here, but at the same time it does
not mean such an improvement will happen on all the hardware. That being said, the
Tonga device here seems to have no measurable difference.

In any case it seems handy to have for the future, when we'll want to support SSS
in the kernel or to port selective compilation/split kernel to CUDA devices.
2015-06-08 11:15:39 +02:00
267c7b098d Fix "View All" operation in image space not available with locked interface 2015-06-08 11:15:39 +02:00
7c5944137e Fix T44995: Crash loading packed image 2015-06-08 18:21:54 +10:00
b54e95a5c8 Alternative fix copying windows from popup dialogs
It could still crash if the window was freed and another was activated. see T44688.
2015-06-08 16:02:57 +10:00
22a4fcb146 Fix T44991: Apply transform skips poly-radius 2015-06-08 12:58:50 +10:00
99fba34b8d rename wiki -> manual 2015-06-08 11:34:07 +10:00
9927849708 Fix T44984: wrong texture clamping when applying saturation > 1.0
Applying saturation > 1.0 in HSV space easily leads to negative values in RGB space,
so we have to clamp again...
2015-06-07 16:56:58 +02:00
b79a33e2d4 Allow compilation of cycles network with WITH_CYCLES_LOGGING is ON 2015-06-07 15:24:31 +02:00
de953bf7b8 Don't show smoke domain when render-only enabled
D1339 from @scorpion81
2015-06-07 21:52:11 +10:00
86bb0d1a35 MakeDupliFace: select new objects 2015-06-07 17:44:25 +10:00
404f9ddc37 Cleanup: use staticmethods 2015-06-07 17:40:39 +10:00
bf010c4a15 Cleanup: pep8 2015-06-07 17:28:02 +10:00
5aade17bdf Revert "BGE : KX_VertexProxy support for more than 2 UV channel."
This reverts commit fb0dd596e9.

This commit reintroduced a deprecated API that we'd rather not see in a
release. A better solution is being worked on.
2015-06-06 13:12:27 -07:00
c5748f3cc7 View3D: avoid jumping placing cursor /w lock on
The view would jump each time, now compensate by adjusting the cursor panning.
Less jarring and helps avoid problems when the cursor gets outside the view, see: T40353
2015-06-07 02:50:50 +10:00
60621940d0 Use threshold for selecting side-of-axis 2015-06-07 02:09:41 +10:00
Julian Eisel
4ee2ae97c3 Cleanup: Typos 2015-06-06 15:32:59 +02:00
50a1ad5bb3 Cleanup 2015-06-06 21:02:16 +10:00
94e7ac5b97 Fix wrong usage of THB_NORMAL size when generating .blend file thumbnail at save time.
We do not use that size of preview anymore, only THB_LARGE...
2015-06-05 19:42:59 +02:00
68cdd2b361 Fix T44961, bevel spikes out when certain angles near 180.
Made the test for whether one can "see" an adjacent edge less
knife-close to 180. This means it will chose to slide along
such an edge less often, and avoid some spikes.
2015-06-05 13:00:41 -04:00
e708042aa0 Cleanup:
Get rid of static functions that pass the exact same arguments in the
same order to other function.
2015-06-05 16:13:15 +02:00
28f798f86e Cycles: Initial support for OpenCL capabilities reports
For now it's just generic information, still need to expose memory, workgorup
sizes and so on.
2015-06-05 14:17:30 +02:00
d5bca524d5 Fix T44960: Crash with 'Shape Cut' in edit hair mode.
This is only supported for mesh objects so far.
Also, abort in case there are no faces in dm (instead of crashing on NULL BVH tree...).
2015-06-05 13:06:01 +02:00
304ee9af8d Depsgraph: Report to the console when the new depsgraph is used 2015-06-05 15:37:41 +05:00
907f804ad8 Depsgraph: Fix typo in header guard comment 2015-06-05 15:37:41 +05:00
fb92c553f1 ImBuf: Fix compilation error with latest OIIO
Latest OIIO libraries are using Boost libraries from the public headers.
2015-06-05 15:37:40 +05:00
ffaf271ab9 BMesh: decimator, allow vgroup factor over 1
Can be useful to apply more extreme weighting
2015-06-05 15:26:37 +10:00
aca40295e8 Check ftell return values 2015-06-05 11:46:01 +10:00
b2e5c017a1 BGE: correct ftell use in LoadGlobalDict 2015-06-05 11:16:46 +10:00
f3434e5f82 BGE Cleanup: remove dead code for collide, visible and twoside variables
As material is not NULL at this stage there is no need to do a NULL
check. Also to remove dead code

Reviewers: dfelinto, panzergame, hg1, moguri

Reviewed By: panzergame, hg1, moguri

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1330
2015-06-05 02:24:23 +02:00
2cbe60b476 New "use placeholders" feature of the sequencer did not detect correct
filenames.

Added BLI_path utility functions to decompose a path name and
extract the frame number. It should be useful in autocollapse
feature as well
2015-06-04 20:40:44 +02:00
455ca1b28f BMesh decimate, improve behavior with weights
Add slider to adjust the influence of weights relative to geometry distortion.
This allows subtle influences to be applied - without drastic changes in behavior.
2015-06-05 02:56:11 +10:00
c64f491f9f Fix modifiers stack not recalculated when mapping requirements change
Reported by pixaal on irc, basically reproducable by inserting bevel
modifier on cube and entering/exiting texture paint mode.

Now object stores last needsMapping variable as well as customdata mask.

Also now texture painting only needs mapping when we are in texture
paint selection mode, so modifiers that don't support mapping can still
be used to paint now.
2015-06-04 17:40:10 +02:00
Julian Eisel
91d424b82a Fix tooltip colors not initialized correctly
Already committed similar fix (rBbeaed66f292dd) but saw it appearing on
other peoples screens a few times since them. Never was able to recreate
though.
This should make sure everything is initialized fine, so if we see it
appearing again, then it's likely because of manual tweaks or the
version saved in the .blend.
2015-06-04 17:07:05 +02:00
4a26f3b569 correct last commit 2015-06-04 23:47:03 +10:00
06f4bac104 BMesh: decimator minor edits 2015-06-04 23:42:10 +10:00
cf7a5e93f8 Fix buffer overrun searching program path on win32 2015-06-04 16:48:56 +10:00
3eb38a79d8 Loading raw targa now sets the filetype 2015-06-04 16:36:11 +10:00
061b59a1d4 Cleanup: redundant checks 2015-06-04 15:51:49 +10:00
81e3deadea Fix for leak creating stereo images 2015-06-04 15:41:28 +10:00
7a0f57cd01 Cleanup: clarify order of precedence: &/? 2015-06-04 15:41:27 +10:00
896f08bde8 Fix T41177. Bevel shouldn't try to slide along edge when can't see it. 2015-06-03 15:19:48 -04:00
451a077511 I18n extract: better handling of commandline args. 2015-06-03 17:15:00 +02:00
e4ab526ad1 Make reading previews from .blend file more robust.
Hit a case here where rect pointer was not NULL, when h & w were both zero...
Shall not happen, but better not crash on such cases!
2015-06-03 16:42:08 +02:00
b9c563061c Do not show brush cursor for fill brush (size not supported) 2015-06-03 12:04:47 +02:00
43913fe212 Fix inconsistencies in texture paint UI T44929, T44927:
* lock alpha only works in projective painting
* fill threshold only works in 2D painting
2015-06-03 11:33:40 +02:00
b07be730b2 Fix error calculating bmesh normals
edge vector stack was left un-cleared.
2015-06-03 18:10:43 +10:00
6fbb580e51 BLI_stack: gtest for clear 2015-06-03 18:09:12 +10:00
1dbcccf5f9 BLI_stack, add clear function. 2015-06-03 18:07:30 +10:00
ebebc4ded1 Correct own fix reference before assignment
3rd fix for silly exception conversion!
2015-06-03 17:11:01 +10:00
2517f5c97c Fix memory leak loading multi-layer OpenEXR 2015-06-03 16:24:07 +10:00
e695b34505 Fix memory leak loading single-layer OpenEXR
Internal EXR API specifically avoids freeing non-file streams.
2015-06-03 16:24:00 +10:00
52795932a7 Fix for RMB Menu title including shortcut 2015-06-03 15:03:28 +10:00
2c7cb8ce59 Fix UI string clip (reverse search separator char)
The string may have many '|' characters, only the last is clipped.
2015-06-03 15:03:28 +10:00
b3d2b035c4 Cleanup: check button flag for shortcut delimiter 2015-06-03 14:35:41 +10:00
23f1c6835f Fix multires update (reading char * as an int *) 2015-06-03 13:42:44 +10:00
c07a11b83b Fix object align crash (use-after-free) 2015-06-03 13:42:44 +10:00
4056253627 Cleanup: metaballs called memcpy with NULL source
Simplify logic and use realloc
2015-06-03 13:42:44 +10:00
c0ca70a3b2 Correct vert/edge slide poll functions
Would crash trying to access outside the 3D view.
2015-06-03 13:42:44 +10:00
2be3ebd15d Correct own recent error printing Python exception 2015-06-03 13:42:44 +10:00
fd8b6021c4 Fix race condition
Exposed when checking on T44871
2015-06-03 11:01:44 +10:00
469c0695ac ImBuf: Fix memory leak around EXR handle's multiView 2015-06-02 22:43:23 +05:00
fd1ea5e3db Fix T44742. Bevel now avoids vertex meshes when only two edges are beveled.
Also, changed the algorithm for generating the vertex meshes when not all
edges into a vertex are beveled. Now it tries to slide along edges that
form part of the silhouette when possible; when not possible, it tries
to snap to the best plane in between the beveled edges.
2015-06-02 09:25:05 -04:00
9454377c71 Fix T36994: Make link modifier fails (soft body) 2015-06-02 20:23:01 +10:00
7724b26ab2 Cleanup: use const for object copy funcs 2015-06-02 20:21:45 +10:00
95b9d6d9c2 Fix operator exec /w popups that close the window
Related to T44688, note supporting this case isn't so nice,
but seems it can be made to work.
2015-06-02 19:01:24 +10:00
5f5e05b3eb Fix compilation error after recent commit 2015-06-02 13:11:03 +05:00
89025958af Fix T44921: Node editor, nodes position not maintained after Material panel changes
Also improved a bit behavior of adding new nodes, now they will not overlap that
badly. Still not ideal, but further improvements better not to happen at bcon4.
2015-06-02 12:32:43 +05:00
23b068ce8a Fix T44922: Split kernel renders black when using Bump node
Was missing feature detection in the BumpNode in the previous selective nodes
compilation commit.
2015-06-02 11:53:10 +05:00
660234bfba Fix own mistake searching python binary 2015-06-02 15:42:03 +10:00
aa2bdcccfc Simplify Win32 extension check 2015-06-02 15:38:14 +10:00
c67abff7f0 Fix drawing text on >2gig buffers (stamp for eg) 2015-06-02 14:59:31 +10:00
abc4a3d455 Fix T44869: Crash rendering >2gb images 2015-06-02 13:28:24 +10:00
33a7b72678 Fix T44919: BGE marhutils attrs leak memory 2015-06-02 11:08:17 +10:00
b53836d2c9 UI: tweaks to ID and non ID preview templates
- label is shown on a UI_UNIT_Y heigh instead of 0.2 * total button size
- vertically centering non-ID previews labels
- making some constants dependent on ui units
2015-06-01 21:37:56 +02:00
9e850addae template id previews: changes for consistency with icon views template
- elongate the buttons to acomodate the icon without the label overlapping.
- removing the blue background
- adding a consistent margin all around the popup
2015-06-01 21:37:56 +02:00
32cf18d9a2 template ID previews: quick fix for buttons region overlapping the search button 2015-06-01 21:37:56 +02:00
27c1262e21 Fix T44908: Blender crashes when trying to use cycles experimental displacement
The issue was caused by the reshuffle needed to make objects flags have proper
object's bounding box to solve regressions in SSS objects intersecting volumes.

There's actually a feedback loop happening here, which is now solved in quite
naive way -- for the true displacement we consider all objects are capable of
intersecting volumes, synchronize object flags prior to displacement shader
tasks runs and then re-update object flags for proper bounding box.

Not sure what will be the proper solution here, we can't do preliminary check
of intersection for displacement shader, but on the other hand we don't really
need this flag for displacement shader anyway.
2015-06-02 00:04:30 +05:00
a73d4b859a Thumbnails: fix bad handling of invalid thumbnails, cleanup and deduplication.
Invalid thumbnails (missing mtime metadata) are to be re-generated, not ignored!
2015-06-01 19:42:56 +02:00
bec3131112 Font Preview: much better handling of i18n case.
We have to regenerate previews when we change language. But we also need to do it
when translation is changed or added for a language, etc.

Previously, we were storing one preview per language, which was also stuffing
preview dir with (potentially) tens of PNGs per font file, if user plays with translations.

Now we use a better system, which is storing an additional optional metadata in previews
(some hexdigest), that Blender can use in addition to datetime to decide when to regenerate
previews.

This is only used (and needed) by font previews so far, but can easily be reused for other
types of previews if needed.
2015-06-01 19:42:56 +02:00
2d8880643d Font Preview: fallback to default english strings in case translated ones have not enough chars in current font.
This avoids some ugly 'missing char' in previews - not all cases of course, but most common ones.

A complete solution would be much much more involved, and probably not worth it here.
Definitively not before a release, at least!
2015-06-01 19:42:56 +02:00
7173069cbe Fix T44915 vertex color lost when adding new layer in edit mode.
Was copying new layer colors to old layer colors.
2015-06-01 19:06:46 +02:00
893677a76a Disable writing a crash file completely on Windows.
We had some reports where users did not even read the "Not supported on
release builds" message, and arguably writing a file sort of indicates
that the file may include something useful.
2015-06-01 18:54:03 +02:00
a6101cde06 Cycles XML API: * Add Bump and Holdout Node * Add todo comments for various things. * SSS falloff now works. 2015-06-01 19:56:39 +05:00
b10bc3a6ec Cycles: Number keys 0-3 can be used in interactive mode now to set max bounces. 2015-06-01 19:56:36 +05:00
3127d47029 Cycles: Fix wrong max nodes group used for the viewport render 2015-06-01 19:49:53 +05:00
9d4d55e78b Cycles: Strip meaningless empty output form the MVidia OpenCL compiler 2015-06-01 19:49:53 +05:00
f0a0b1eaac Cycles: Assert in the cases when SVM node was not handled
This will help figuring out cases when node was not properly handled by the SVM
by aborting execution on CPU, where all the nodes are expected to be supported.
2015-06-01 19:49:52 +05:00
ecd4ee75af Cycles: Implement selective nodes compilation
This commits finishes initial selective nodes compilation into kernel, which
helps a lot performance-wise for AMD OpenCL kernels.

Split by node groups is based on statistics from simple scenes like BMW and
more complex scenes like mango and gooseberry production files. Further
tweaks are always possible, but it should be a good starting point.

TODO: Still need to ignore unused nodes when calculating requested shader
features.
2015-06-01 19:49:52 +05:00
c0235da53c Cycles: Fix some typos in the selective modes compilation 2015-06-01 19:49:52 +05:00
399a27b261 Cycles: Code cleanup, spaces around keyword and brace 2015-06-01 19:49:52 +05:00
f45f2ac687 Cycles: Fix missing features gathering from the bump graph 2015-06-01 19:49:52 +05:00
4d8cf1329d Cycles: Add bump feature for selective nodes compilation
For now it is unused in the kernel, actual usage will come with
the next commits.
2015-06-01 19:49:52 +05:00
36ef6d1532 Cycles: Report build flags used for the OpenCL kernel compilation
For now it's reported to the stdout, matching to the CUDA behavior.
In the future we can hide this into GLog logging once the kernels
are considered all stable and so.
2015-06-01 19:49:52 +05:00
14251e8b45 Cycles: Shader node features are to be inherited from the base class 2015-06-01 19:49:52 +05:00
1fc6563917 Fix T44894: Round two.
We cannot `direct_link_packedfile()` twice on a same address, because this tries to
map again pf->data address, which leads to nothing (NULL).

So now, since `ima->packedfile` and `ima->packedfiles` are mutually exclusive
in 'live' blender data anyway, we either read one or the other.

Tested from/to official 2.74 and current master, everything looks fine now.
2015-06-01 13:12:41 +02:00
c8711b6f6f Fix T40621: Tablet in walk mode fails
Add support for walk mode /w absolute pointing devices.
2015-06-01 20:07:57 +10:00
07a6d4ed75 WM: include tablet data in WM_event_print 2015-06-01 17:40:52 +10:00
bfa7586ba3 Fix T44747: Drag toggle /w nodes (glitch)
It was possible to perform actions while performing a drag-toggle.
2015-06-01 16:40:43 +10:00
565faadd8e Cleanup: doxygen comments 2015-06-01 14:56:07 +10:00
668f1f9554 Fix for leak in BM_uv_element_map_create
Also correct over alloc and redundant alloc.
2015-06-01 14:16:28 +10:00
b147473f02 Fix T44892: Cursor warp, invoked outside the area
If an operator starts outside an area, don't use warping.
(problematic for menu's).
2015-06-01 12:03:02 +10:00
4b4695223a Fix vertex slide regression /w rotated objects 2015-06-01 11:26:35 +10:00
a8d6c69d76 Fix T44894: Broken packed image import from older .blend file.
rBe5fbeba0b3a6e9eea not only restored forward compat, it also broke backward compat...
for no reason at all even, exising ima->packedfile is only used by read/versionning
code if .blend version is below 274.4 (i.e. no multi-image packing exists).
2015-05-31 18:28:28 +02:00
3ca0870023 Improvements to the Freestyle Python API (needed by the SVG Exporter)
This patch adds some new functionality to the Freestyle Python API, notably:

  - MaterialBP1D, checks whether the supplied arguments have the same material
  - Fixes a potential crash in CurvePoint.fedge (due to NULL pointer)
  - Makes (error handling in) boolean predicates more robust
  - Adds a BoundingBox type, to make working with bounding boxes easier
  - Adds several new functions (get_object_name, get_strokes, is_poly_clockwise, material_from_fedge)
  - Adds a StrokeCollector StrokeShader, that collects all the strokes from a specific call to Operators.create()
  - Adds hashing and rich comparison to the FrsMaterial type

These new features (most of them, anyway) are needed for making a more robust SVG exporter that supports holes in fills.

Reviewers: kjym3, campbellbarton

Subscribers: campbellbarton

Projects: #bf_blender

Differential Revision: https://developer.blender.org/D1245
2015-05-31 23:16:45 +09:00
Julian Eisel
3100fbef5e Fix ugly drawing of closed panels in horizontal layout
Also minor cleanup
2015-05-31 14:34:55 +02:00
f5a471ef86 Python: avoid mutable default param values
D1328 by @yedpodtrzitko
2015-05-31 15:58:58 +10:00
67bebc42f4 UI: comments (doxygen tweaks) 2015-05-31 14:20:03 +10:00
28ef76d0f0 BGE Cleanup: Removing flen variable where it is not used 2015-05-30 18:30:34 +02:00
71dcaa7744 BGE Cleanup: Identical code for both if/else branches 2015-05-30 18:15:11 +02:00
a5a1d4aa3a fix T44884: corrected a wrong usage of the CustomLayer API (due to a misunderstanding) 2015-05-30 14:19:01 +02:00
0a4bf5317f Correct own error with recent commit
Caused entering an invalid number to leak.
2015-05-30 20:26:26 +10:00
0187356613 python tar.gz changed structure due to python.exe being added. remove /lib/ from cmake as lib and bin are both in the tar.gz 2015-05-30 09:44:44 +02:00
1d34d3ee06 python tar.gz changed structure due to python.exe being added.
remove /lib/ from cmake as lib and bin are both in the tar.gz
2015-05-30 09:27:13 +02:00
36d47ce203 Fix leak in BMesh convex hull operator 2015-05-30 16:17:04 +10:00
8b494e03be Fix reading uninitialized buffer 2015-05-30 14:48:42 +10:00
Julian Eisel
1a0c961746 Cleanup: Use true/false for bool, naming 2015-05-29 21:35:13 +02:00
9755986637 BGE: Fix memory leak when unable to add wheel 2015-05-29 17:03:54 +02:00
51bec8e22e fix T44884: Index counter for active UV Map used wrong offset 2015-05-29 16:20:33 +02:00
9876d1f299 Yet another attempt to fix T44869
Fix some integer overflow cases in colormanagement code
2015-05-29 15:43:21 +02:00
dea3f7f5ff GHOST get rid of unused warnings 2015-05-29 15:13:47 +02:00
2f2f7c0e87 Fix T44882, color picker in texpainting doing linear interpolation even
when mipmap is off.

We used to always have nearest interpolation for texpaint but at least
make this work with mipmap off correctly.

Also added conversion casts to avoid integer overflow in filtering code
2015-05-29 13:38:20 +02:00
1bede8644a Fix T44880: transparency filter is only valid with raytransp, not ztransp. 2015-05-29 12:26:58 +02:00
52cfd0eef8 Fix T44879, data transfer modifier was missing a copy function 2015-05-29 11:38:57 +02:00
7b743defd4 Fix wrong 'check context' handling in addon i18n messages generator.
Reported (with patch) by yedpodtrzitko (yed podtrzitko), thanks a bunch!

Differential Revision: https://developer.blender.org/D1327
2015-05-29 11:08:26 +02:00
166408cfe2 UI cleanup: removing if, condition was already tested 2015-05-29 09:27:23 +01:00
af434fea71 BMesh: select linked /w delimiters & wire edges
Add support for using edge delimiters mixed with wire edges.

Code isn't so elegant but users will expect this.
2015-05-29 14:41:39 +10:00
3511e2d6ae Cycles: Enable Object Motion on AMD OpenCL.
Like Camera Motion, only available in the Experimental kernel.
This should be it for the upcoming release, we now support almost everything, apart from Transparent Shadows, SSS and Volume.
2015-05-28 22:10:53 +02:00
Julian Eisel
d3556268d5 Aaaaand another fullscreen glitch
Steps to reproduce were: Set a *Properties Editor* to fullscreen-
>render->Info Editor is set to Image Editor instead of Properties Editor
2015-05-28 20:08:03 +02:00
Julian Eisel
23c7d14afd Fix another fullscreen toggle glitch
Steps to reproduce were: Set 3DView to fullscreen->render->toggle out of
fullscreen->escape->Area doesn't change back to 3DView
2015-05-28 19:48:28 +02:00
18208c8ad9 Fix T44872
All musgrave tupes use intensity, never hide it.
2015-05-28 18:05:50 +02:00
bdf242fa21 BGE Cleanup: Remove old commented Sumo physics code 2015-05-28 17:50:39 +02:00
3b158d2e05 BGE Cleanup: The value of ikconstraint cannot be NULL at this stage and
therefore it is not necessary the NULL check.
2015-05-28 17:18:50 +02:00
8dc6fabc34 Optimize render part commiting to render queue to mitigate delay in
T44869.

There are a couple of issues here:

* Code repeatedly calculated center of ready rendered parts even though
they would not change while the operation was done.

* Code would calculate distance of tiles from center multiple times

* Code would traverse all items, even the ones already sorted
* Traversal used linked lists which is quite slow.

Mitigated these by doing one pass for the center, a second to calculate
distances and a qsort at the end.

Should result in O (n * (log n + 2)) instead of O (n * (n * 2))
complexity, plus the number of repeated operations is much less as well.
2015-05-28 17:01:09 +02:00
eb476c2816 Depsgraph: Cleanup, multiple private functions are to be in anonymous namespace 2015-05-28 13:51:54 +05:00
f777983d5b Add missing particle system tagging on update to the new depsgraph
It's not ideal and mimics weak legacy code, but so close to bcon4 we'd better
not start re-considering the way how particle works..
2015-05-28 13:51:54 +05:00
d9b6768521 Fix T44688: Stereo3D time-sequential crashes 2015-05-28 18:46:15 +10:00
f3161c97a6 Ghost/X11: allow creating windows to fail
Would exit, problematic for setting stereo3d modes which aren't always supported.
2015-05-28 18:46:15 +10:00
4be7258f00 WM: remove windows if they fail to initialize 2015-05-28 18:46:15 +10:00
3dd346c2a1 Cleanup: warning 2015-05-28 18:46:14 +10:00
89c56f6e47 Install_deps: fix different 'libfreetype2' devel package name on fedora and suse... *sigh* 2015-05-28 10:38:48 +02:00
56f6aa977a Multi-value, multi-button cancel keeps value set 2015-05-28 15:52:53 +10:00
2480bbff56 Multi-value cancel, keeps scale set 2015-05-28 15:50:51 +10:00
dc1586063b BMesh: correct flag check (own mistake) 2015-05-28 12:11:35 +10:00
3e0c6a8ca2 BMesh: util functions to get edge loops from verts 2015-05-28 11:46:58 +10:00
46d8bcb617 Cleanup: Remove unused Noise Basis texture code.
Same as last commit, code is unused and this one actually would have required some fixes,
as these variants output values outside the 0-1 value range, which doesn't fit Cycles shader design.
2015-05-28 01:07:37 +02:00
20f6a0f2d7 Cleanup: Remove unused Voronoi texture code.
Let's finally delete this code, after 4 years of being unused,
there really is no excuse anymore.

If we decide to extend the procedural textures in SVM, we can do this anytime in the future.
2015-05-28 00:36:33 +02:00
930bf58478 Clamp min/max frame rate for player 2015-05-27 20:02:53 +02:00
07def553d2 Fix T44745 non manifold edges of mesh do not work when smoothing in
multires.

Code had special guards for such edges to stop this from happening. I
don't see why this is needed though since code above assigns smoothed
positions for all vertices in the grid.

After removing the guards I saw that this in fact was the only place
where grd adjacency was used, so I completely removed it.
2015-05-27 19:52:12 +02:00
9aea98d33c BGE: Add missing m_jumping initialization 2015-05-27 18:19:38 +02:00
c5a8a4e9d8 Fix mismatch in strings length compute in filebrowser, leading to annoying '...' in longest filename.
We must take kerning into account everywhere! Note this will disappear in upcomming filebrowser
refactor anyway.

Reported through IRC by Pablo (venomgfx), thanks.
2015-05-27 17:25:55 +02:00
Quentin Wenger
be4d34ca86 BGE Python API: Completing doc for bge.types.KX_FontObject
This adds description of the Font object and about its (only one)
attribute, as well as an example of use.

Reviewers: campbellbarton, fsiddi, dfelinto, moguri

Reviewed By: dfelinto

Subscribers: lordloki

Projects: #documentation, #game_engine

Differential Revision: https://developer.blender.org/D863
2015-05-27 17:18:43 +02:00
9fc1033429 Fix T44748: Particle is not displayed definitely when I use a new dependence graph 2015-05-27 19:22:52 +05:00
b52af946cd Forgot this in the last commit 2015-05-27 14:43:54 +02:00
c449d4e336 Fix jpeg preview for exr renders broken. 2015-05-27 14:41:51 +02:00
4bf64e841c Correct convex-hull for recent join-tri changes 2015-05-27 21:43:35 +10:00
0e00072ff0 fix:T44856 reverted triangluation back to bmesh ( apparently broken by commit rB51f33 ) 2015-05-27 13:19:40 +02:00
0e02ad8b64 Fix off by one error in display of start/end frame in sequencer. 2015-05-27 12:17:16 +02:00
4c1efcc829 Code cleanup, silence some warnings when building without legacy depsgraph 2015-05-27 13:10:26 +05:00
1fd2e6232a Fix compilation error with legacy depsgraph disabled 2015-05-27 13:09:57 +05:00
e665a60a85 Fix T44854: Creating hooks from curve to objects doesn't work
The issue was introduced in e529882 by doing wrong range checking.
2015-05-27 13:08:17 +05:00
92022218c2 Cycles: Code cleanup, split kernel 2015-05-27 13:08:17 +05:00
da192fb3a7 Missing NULL check getting selected obdata 2015-05-27 11:14:39 +10:00
77f0f3c54e Fix parent tips staying selected after separate 2015-05-27 10:35:14 +10:00
c3810c596e Use PKey for edit-armature separate
As used already for mesh & curves.

Add confirmation menu for curve & armature,
since this isn't such a common operation and undoing leaves object data
(long term bug/todo to fix).
2015-05-27 09:56:50 +10:00
84ad20acef Fix T44833: Can't use ccl_local space in non-kernel functions
This commit re-shuffles code in split kernel once again and makes it so common
parts which is in the headers is only responsible to making all the work needed
for specified ray index. Getting ray index, checking for it's validity and
enqueuing tasks are now happening in the device specified part of the kernel.

This actually makes sense because enqueuing is indeed device-specified and i.e.
with CUDA we'll want to enqueue kernels from kernel and avoid CPU roundtrip.

TODO:
- Kernel comments are still placed in the common header files, but since queue
  related stuff is not passed to those functions those comments might need to
  be split as well.

  Just currently read them considering that they're also covering the way how
  all devices are invoking the common code path.

- Arguments might need to be wrapped into KernelGlobals, so we don't ened to
  pass all them around as function arguments.
2015-05-26 22:54:02 +05:00
4ffcc6ff56 Fix T44497: Crash on deleting curve handle with hook modifier
It was possible race condition on empty curves -- it's possible that curve
object is fully updated and path is null in that cases, Proper way to deal
with this is to check curve_cache for non-NULL.
2015-05-26 22:36:18 +05:00
6245f4a39c Cycles: Enable advanced shading for NVidia OpenCL kernel
It was kept disabled due to render artifacts which weer in fact caused by bad
memory access, which is fixed in the previous commit.

We now also can make it enabled in regular AMD split kernel after someone tests
the updated code.
2015-05-26 21:29:21 +05:00
cf19012fb0 Fix T44831: Crash when using Intel OpenCL with split kernel
The issue was caused by underallocation of object motion related arrays,
which happened by accident.
2015-05-26 21:29:21 +05:00
b90c7dd730 Building without OpenEXR works again 2015-05-26 17:49:08 +02:00
d45c4af469 Cleanup: update comment 2015-05-27 00:00:31 +10:00
89b6c72f8d Cleanup: python 2015-05-26 23:53:47 +10:00
6973e26bf9 Fix T44036: Add option to bake into current action instead of creating a new one.
This is needed when you want to bake only part of an armature's bones, since they
all share a single action, otherwise you'd lose non-baked bones' animation...
2015-05-26 15:32:06 +02:00
a23fbc71a1 Cleanup, add comment for old code. 2015-05-26 14:38:24 +02:00
a64cb4185e Trying to pack image with invalid path crashes 2015-05-26 13:46:14 +02:00
8299284389 Correct own recent error, uninitialized var use 2015-05-26 21:36:49 +10:00
3c9da38e7e Style cleanup: space after keyword 2015-05-26 16:15:52 +05:00
7487a4d4ac Fix T44763: Surface Panel does not update correctly according to Node Output for Cycles UI 2015-05-26 16:15:34 +05:00
d20fd2da72 Revert "Cleanup: set var twice"
This reverts commit eb799dc350.

I recommend reading code before doing cleanup, next time...
2015-05-26 13:01:29 +02:00
bfe0ea4069 Fix own sillyness 2015-05-26 12:58:32 +02:00
ded0004f8b Don't crash with pie menus with more than 8 items.
This will print a warning and users will get overlap of pie buttons, but
it should be quick paper over the cracks and at least should keep
blender working until a more complete fix is coded.
2015-05-26 12:09:51 +02:00
718bc078a8 Fix T44740: Tweak events stuck (ignored release)
Tweak event was being added to the end of the event queue (out of order),
meaning any mouse releases already in the queue wouldn't be used to exit the gesture.
Gestures could get stuck (mostly when the system wasn't able to handle events fast enough).

Now tweak events are now added in order.
2015-05-26 20:07:58 +10:00
de68066c1c Fix multilayer OpenEXR not supporting metadata.
This will fix exporting of metadata and importing for imbufs, but image
editor will not display these metadata since multilayer gets converted
to renderresult, which does not support metadata display yet.
This commit is more meant for external image editors/viewers.
2015-05-26 12:02:30 +02:00
e5fbeba0b3 Images: Solve broken forward compatibility with packed images
Use first packed image as legacy image->packedfile, so saving .blend file with
latest builds makes it so packed images are not lost when opening with previous
releases.

This will only work reliably if mutliview is not used, otherwise it'll be only
first view in the .blend file, which is rather expected since previous releases
are not aware of views.
2015-05-26 14:46:05 +05:00
569a2035c7 GHOST: flush event printer output 2015-05-26 18:51:51 +10:00
de0c269c28 Fix T44821: Making warp shortcut fails
Using OBJECT prefix for editmode operators causes
shortcuts to go into the wrong keymap.
2015-05-26 17:55:34 +10:00
2c3c477223 Cleanup: warning, spelling 2015-05-26 16:46:33 +10:00
9b1ca19396 Fix RMB menu in popup, included 'Header' submenu 2015-05-26 16:45:01 +10:00
e4dc44d7ab Depsgraph: Fix for uninitialized variable in root depsnode 2015-05-26 11:34:18 +05:00
abf7378e44 Fix T44697: Multi-value edit /w layers fails
Not such a nice solution, but good to have this working.
2015-05-26 15:20:46 +10:00
8715fd0925 BMesh: join tris, split angle limit in two
Use a separate limit for face-angle and shape comparisons.

There was no way to join non-rectangular, co-planer tries.
2015-05-26 14:27:38 +10:00
9ce20d3341 BMesh: join tris now delimits all UV/Color layers
Previously was only checking active layers

Also add delimit by edge seam
2015-05-26 13:42:59 +10:00
eb799dc350 Cleanup: set var twice 2015-05-26 10:25:01 +10:00
de21604cf4 Minor cleanup... 2015-05-25 22:24:46 +02:00
1ac0fef345 Fix widget_draw_preview() not taking into account given alpha.
Needed to get correct 'inactive' effect on buttons with big previews.
2015-05-25 22:06:25 +02:00
e092a58fb5 I18n message extractor script: py code: do not consider strings inside 'Compare' AST nodes.
Otherwise, we'd get 'MOVIE' from `text="Build Proxy / Timecode" if clip.source == 'MOVIE' else "Build Proxy")`...
2015-05-25 21:17:49 +02:00
5e66827029 Fix T44842: Modal Timer (template) should return {'CANCELLED'} when cancelled! 2015-05-25 17:43:28 +02:00
6b5f3f5fef preview buttons: tiny optimization 2015-05-25 15:38:12 +01:00
Dalai Felinto
3a7691b73f Fix T44836: crash when multi-view is enabled and switching to BI rendered viewport display 2015-05-25 10:15:18 -03:00
2464395b6d Depsgraph: Avoid unnecessary char*/string conversion when creating RNAPathKey 2015-05-25 18:05:19 +05:00
0b9a65b2ae Fix T44709: New Depsgraph not evaluating driver interactively
Issue was caused by drivers which uses component of an array as a target,
this was not handled properly in the RNA path key.
2015-05-25 18:03:06 +05:00
a80c1e50bc Fix T44822: python enums' itemf callback did not handle 'NULL' context case.
Enum's itemf callback can be called without context in some cases (UI, doc generation...).
Python's enum properties did not handle this at all - it's kind of odd this did not cause
more trouble and wasn't notice earlier... Probably dynamic enums using context are not
much used in py code.

Note about nodes: those are heavy users of dynamic enum with context. Now,
we expect `NodeCategory.poll()` and `NodeItem.poll()` to always be called with
a valid context (since when there is no context available, we can assume `poll()`
is always True). `NodeCategory.items()`, however, must accept NULL context, so if
you use custom `items` callable for your custom node categories, you may need
to update it (as was done here for builtin `node_group_items()`).
2015-05-25 14:24:49 +02:00
39b85e452f Fix T44815: Sound bake doesn't check filepath 2015-05-25 22:13:18 +10:00
62f2d9b566 Cycles: Fix compilation error of split kernel
The code was failing to compile on runtime because of some path differences,
and it seems we don't need to specify full path to the file which originally
seemed to be needed to make include directives expansion working correct.
2015-05-25 14:18:01 +05:00
153cebd95b BGE: Fix bug with default material and MTFace.
It set default material even if there are a MTface but no blender material.
Tested in GLSL and Multitexture.

Reviewers: HG1
2015-05-25 10:33:04 +02:00
a5a648c7c6 Fix error redoing shrink fatten
Use a property to store even-offset option.
2015-05-25 15:45:56 +10:00
7fd93dc8dc Fix bend in object mode (wasn't rotating objects) 2015-05-25 10:37:09 +10:00
fe9ce6603c Fix memory leak /w bend tool 2015-05-25 10:37:09 +10:00
7b60a0f64b Cleanup: const char for operator ID's 2015-05-25 10:37:09 +10:00
a3ef51bba5 Fix T44833, OpenCL compile error on AMD.
This was broken after the kernel file restructure.
Variables allocated in the __local address space can only be defined
inside a __kernel function.

We probably need to solve this a bit differently once we do the CUDA
kernel split, but this fix shoud be good enough until then.
2015-05-25 01:02:06 +02:00
c3ab5b3089 Fix T44830, wrong sample progress number when using split device.
Value was not set, moved it out of the constructor into
device_opencl_create() now.
2015-05-25 00:37:01 +02:00
025a646114 Fix T44823: No menu entry for Circle Select in UV/Image editor. 2015-05-24 19:27:59 +02:00
78918e761f Fix T44814: 'preview' icons would not greyout.
Since they are premultiplied, we need separated handling of colors and alpha blending
if we want additional alpha factor to work OK.
2015-05-24 18:35:14 +02:00
a28adf1b35 Some more minor cleanup in new icon preview code. 2015-05-24 16:50:15 +02:00
febf8cb01d Cleanup: style 2015-05-25 00:19:39 +10:00
7f89bc8e85 Fix rare crash duplicating fluidsim 2015-05-25 00:19:39 +10:00
f9b6f5756c Fix crash clearing skin data on non mesh 2015-05-25 00:08:43 +10:00
0305e9604b Fix RNA type access 2015-05-25 00:08:43 +10:00
7456f06097 Fix unreported bug with recent enum icon preview changes, would show bad in case of mixing
items with and without label.
2015-05-24 15:49:04 +02:00
4737722968 Fix error joining tris -> quads
Incorrect flag check, would need to run multiple times.
2015-05-24 21:54:21 +10:00
2da9a39418 BGE : Fix black material on meshes without materials in blenderplayer.
Blenderplayer forgot to initialize the default material (defmaterail) with function init_def_material().
This reverts also the plumber commit 2fa4a48bce.

Reviewers: campbellbarton
2015-05-24 11:46:57 +02:00
78250f1d1d IconView template: adding optional labels to popup buttons 2015-05-23 16:21:05 +01:00
f01c6e185f Cleanup: typos 2015-05-23 22:38:47 +10:00
f340595dba Quadric: add common why doubles are used. 2015-05-23 22:37:46 +10:00
bc83076355 Math Lib: update API usage info 2015-05-23 22:37:37 +10:00
25f5d2b4d7 Fix (unreported) broken RNA Image pack handling since multiview merge.
Was breaking loading of embedded FBX images (among other things, most likely).
2015-05-22 23:28:41 +02:00
e529882be0 Fix second crashing part of T44497, out of bounds access to hook
modifier data.

Unfortunately seems like we also lose the hook mapping by doing this,
but this can be fixed later and is probably a separate issue.
2015-05-22 16:59:22 +02:00
cd9dc3143c BGE: grey out Alpha and Specular sliders when Transparency panel is
unchecked
2015-05-22 16:03:38 +02:00
2c503d8303 Cycles: Restructure kernel files organization
Since the kernel split work we're now having quite a few of new files, majority
of which are related on the kernel entry points. Keeping those files in the
root kernel folder will eventually make it really hard to follow which files are
actual implementation of Cycles kernel.

Those files are now moved to kernel/kernels/<device_type>. This way adding extra
entry points will be less noisy. It is also nice to have all device-specific
files grouped together.

Another change is in the way how split kernel invokes logic. Previously all the
logic was implemented directly in the .cl files, which makes it a bit tricky to
re-use the logic across other devices. Since we'll likely be looking into doing
same split work for CUDA devices eventually it makes sense to move logic from
.cl files to header files. Those files are stored in kernel/split. This does not
mean the header files will not give error messages when tried to be included
from other devices and their arguments will likely be changed, but having such
separation is a good start anyway.

There should be no functional changes.

Reviewers: juicyfruit, dingto

Differential Revision: https://developer.blender.org/D1314
2015-05-22 16:31:34 +05:00
7f4d5850fe SCons: Don't install SConscript into Cycles kernel folder 2015-05-22 16:00:26 +05:00
be6479c9ea Fix T44801: Blender crash in UV-editor.
Mistake in cleanup rB30b45d55... Odd compiler did not yell at that. :|
2015-05-22 11:01:22 +02:00
ed2cb8de2f Fix for join faces ignoring angle limit
Angle limit for join-faces was more advice then actual limit.
Now joining entire selection, gives assurance that no faces above the limit will be merged.

The purpose of this was to allow users to isolate 2 faces and always join them.
Instead, support this by bypassing limit only when its not set and 2 faces are selected.
2015-05-22 18:14:03 +10:00
476feb622c BMesh: extrude region didnt copy edge flags
Newly created edges around regions wouldn't get the edge flags from surrounding geometry.
2015-05-22 11:00:14 +10:00
a934730368 Cycles: Remove TM / R and whitespace from OpenCL device names.
Was already done for CPU devices, now we also do this for OpenCL.
2015-05-21 23:43:18 +02:00
53eab562b4 Cleanup: Remove some outdated comments related to split kernel. 2015-05-21 20:32:20 +02:00
8843a09df3 Fix T44744, tangents incorrect in edit mode.
Really bad code here, index of fetched data was basically totally off
and unrelated to what it should be.
2015-05-21 20:28:17 +02:00
e8014352c6 Yet another crappy Intel driver added for correct SSAO support. 2015-05-21 18:37:48 +02:00
f6062638c1 Fix crash in blenderplayer when scrubbing off screen.
Was cache referencing deleted or NULL items.

Reported by Kopias on irc
2015-05-21 17:37:11 +02:00
a39efae03d Fix T44778 missing specular transparency slider in game engine 2015-05-21 16:37:37 +02:00
d3c67bc81e Fix T44791 triangles when painting on a texpaint plane
Problem was float precision issues across tile boundaries. Since we are
comparing pixels, give a small tolerance when comparing clipped vertices
against triangle lines.
2015-05-21 16:06:42 +02:00
069adb8104 SCons: Fix for missing avx and avx2 cycles kernels
SCons was checking for a particular compiler version to see whether compiler
flags are available or not, but compiler ID was only set on OSX.

Now it should be set on Linux as well.
2015-05-21 18:46:57 +05:00
25bedeca9b GPencil Eraser Size-Saving Fix
On second thought, the eraser size should be saved even if the brush type is not
eraser, as we can toggle this now.
2015-05-22 01:21:29 +12:00
389564c711 Fix T44774: Grease Pencil eraser size reset after exiting session
Previously, it would only save the eraser size if the session ended properly,
instead of being cancelled. However, that wouldn't happen if exiting the session
using Esc.
2015-05-22 01:21:28 +12:00
03eee4dce7 BMesh: decrease decimate epsilon
Since using doubles to calculate cost,
using topology fallback cost isn't needed as much.
2015-05-21 22:46:33 +10:00
4b8dcfc0f5 Fix T44795: same menu item for different command in node editor.
We have too much of those cases in our UI, if we want to keep operators doing
several similar/related but yet different tasks, we should have a real way to
support it on label/icon/tip side too. Easier to say than to do though. :|
2015-05-21 13:20:54 +02:00
7938bd1877 Cycles: Remove OSL from split headers
Split kernel is mainly useful for GPUs which can not support OSL in visible
future anyway.
2015-05-21 16:12:50 +05:00
329f704601 Cycles: Move utility atomics function to util_atomic.h
No functional changes, just better to keep all atomic function in a single place,
they might become handy later.
2015-05-21 16:12:50 +05:00
e37c4e5819 Fix T44780: Decimate planar creates concave edges
Float precision was causing problems for decimate,
small faces that create a nearly flat surface were detected as having no 'cost' to collapse.
2015-05-21 21:06:30 +10:00
6ee653352b Math Lib: double versions of vector funcs
- add_vn_vn_d
- add_vn_vnvn_d
- mul_vn_db
2015-05-21 21:06:29 +10:00
6b40a4bcb1 Fix T44794: Blend From Shape tool X Icon UI Bug?
Note: maybe we could even make `RNA_property_is_unlink()` always return false
for enum properties? But well, guess being explicit here does not hurt...
2015-05-21 12:00:31 +02:00
d4c676e81b Cycles: CYCLES_OPRNCL_DEBUG now affects on split kernel as well 2015-05-21 14:30:33 +05:00
f18d77b874 Cycles: Restore some lost custom cflags passed to the kernel compilation
They were lost during simplification of kernel loading but might be rather
crucial for the performance.

Also made it so cflags are shared across kernels. Surely it might lead to
some unwanted kernel re-compilation but at the same time they might easily
run out of sync with the changes in kernel and so.
2015-05-21 14:05:53 +05:00
aa54d93a29 BMesh: decimate improvement for flat surfaces
Previously decimate on flat areas of a mesh would more or less randomly collapse edges.
(giving bad topology).

This commit includes a topology 'cost', so smaller edges on flat surfaces collapse first.
2015-05-21 16:41:08 +10:00
2c000cc9fc Fix mesh mirror failing on isolated verts 2015-05-21 13:01:44 +10:00
9bfea67751 UI: Use Ctrl+Wheel to cycle values
Conflicted with Alt for editing multiple values.
This could also conflict with global frame change at times.
2015-05-21 11:06:24 +10:00
1aa1a53115 UI: ignore mouse wheel while editing text
Mouse wheel was used as home/end.
Was annoying since it could happen by accident.
2015-05-21 10:46:22 +10:00
2b0613b948 Fix: GPU_shader_export fails /w some lamp attrs
first/last vars missed some values.

D1309 by @NHA
2015-05-21 08:48:21 +10:00
148ed4e05e Cycles: Cleanup, synchronize name across file name, program and kernel names 2015-05-20 23:10:07 +05:00
6f48df45ee Cycles: Simplify code around kernel loading 2015-05-20 23:10:07 +05:00
093d11df35 BGE: Some changes for the constraint document
* Change the constraint type alignment to vertical.
* Changed PHY_CONE_TWIST_CONSTRAINT to the correct value.
* Some minor changes.
2015-05-20 18:49:18 +02:00
2c5d5a9feb BGE: Remove chapter in KX_WorldInfo python API 2015-05-20 18:36:02 +02:00
Martijn Berger
8dd9b7cc5f Cycles standalone, add device type in output listing 2015-05-20 17:11:09 +02:00
b5bf5b36f1 BMesh: decimate, test for face flip was too low
Created overlapping faces in T44780
2015-05-21 00:00:13 +10:00
24e1d7f4f4 BMesh: decimate wasn't using face/edge centers
When calculating quadrics, using the first-vertex isn't correct.
2015-05-21 00:00:13 +10:00
8edfcf653a Movie Clip: Invlaidate clip cache when changing timecode 2015-05-20 17:52:58 +05:00
44a6109ca9 Clip Editor: Make it more obvious that Rebuild Proxy also rebuilds Timecode 2015-05-20 17:52:57 +05:00
77ef3f9041 Fix T44717: use_negative_frames ignored /w graph-editor
D1303 by @barfot
2015-05-20 21:58:33 +10:00
eb6bab25ba Add dedicated command argument to switch depsgraph to a single-threaded evaluation
This way it is possible to have single threaded depsgraph but threaded other areas
which is handy for torubleshooting.

he argument is: --debug-depsgraph-no-threads
2015-05-20 15:48:29 +05:00
8c6a9b9edc Fix reserve frames in sequencer failing with big frame ranges.
Detect frame range automatically from number of digits.
2015-05-20 12:42:00 +02:00
f4d064a5b2 Send color managed signal if input spaces changes during image saving
We're currently only supporting save to a default format color space, which
makes it a bit tricky to prevent ImBuf from being changed.

For until when saving to a custom colorspace works we'll just reload image
if the space changes.
2015-05-20 15:33:30 +05:00
28b2977be9 Atomic operations: Add function declarations at the top of the header
No functional changes, just helps grasping what operations are actually
supported.
2015-05-20 11:57:17 +05:00
5d30c23c35 doxygen: corrections/updates
Also add depsgraph & physics
2015-05-20 14:12:22 +10:00
922d5ed939 doxygen: update config 2015-05-20 14:09:43 +10:00
f0c143ca72 doxygen: rename included files (they were ignored) 2015-05-20 13:06:42 +10:00
a1e8547877 BGE: Use CameCase code style for KX_WorldInfo python API. 2015-05-19 23:13:30 +02:00
377822729c BGE: Fix T40555: LibLoad material caching issue
Previously we don't merge material cached list, it create dangling pointer and memory leak.
Now we merge material cache list during the scene merge, and remove material in this list during the library free.

Reviewers: agoose77, dfelinto, hg1, pgi, campbellbarton, moguri

Reviewed By: campbellbarton, moguri

Subscribers: campbellbarton, youle, kupoman

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1278
2015-05-19 19:24:14 +02:00
fccf253e36 Support string metadata loading for OpenEXR files. 2015-05-19 18:32:41 +02:00
150a4b23ba Fix part of T44768 Yet another Intel driver failing on viewport Ambient
occlusion

(Maybe we should add drivers that DO work instead, but in the future
those will be much more since Intel claims to have fixed the issue)
2015-05-19 16:25:42 +02:00
158c891520 Clear animation list to avoid referencing freed memory. 2015-05-19 16:15:55 +02:00
df0a1fa3c5 Fix T44766: Connect fails /w selected ngon edges 2015-05-19 23:51:57 +10:00
07e9fb8ec6 BMesh: calls to store selection at the list head 2015-05-19 23:51:57 +10:00
d3cc7419a3 BMesh: add BM_edge_pair_share_face_by_len 2015-05-19 23:51:57 +10:00
78411dc7d7 Fix T44755 set_value node output in node tree not properly converted to
color in GLSL

Issue here is that intermediate result was clipped as an optimization in
such nodes and thus not converted to the correct type properly. Now only
clip those values if types match.
This keeps both the optimization and the conversion. I looked at
converting uniform types always but it's more involved to compare types
at conversion time for such links because the type was getting
overridden during link duplication.
2015-05-19 15:37:08 +02:00
dc3533030a Fix T44553.
Front face option did not get the correct normals to function - area
normal would always point to the direction of the stroke
2015-05-19 11:49:46 +02:00
e8561e966d Fix T44762: Materials flicker in edit-mode 2015-05-19 19:13:25 +10:00
ac636a3c97 Fix T44759: Blender has problems reading and writing 42k images to PNG 2015-05-19 13:02:52 +05:00
293df68ebd Object Drawing: avoid redundant material update 2015-05-19 18:00:20 +10:00
eb05e87e16 BMesh: editmode drawing set every faces material
Check for changes in material (as other drawing code already does)
2015-05-19 18:00:19 +10:00
da34136de1 Cycles: Check for validity of the tiles arrays in progressive refine
In certain configurations (for example when start resolution is set to small
value for background render and progressive refine enabled) number of tiles
might change in the tile manager. This situation will confuse progressive
refine feature and likely cause crash.

We might also add some settings verification in the session constructor, but
having an assert with brief explanation about what's wrong should already be
much better than nothing.
2015-05-19 12:42:07 +05:00
f868be6295 Cycles: Check for whether update/write callbacks are set prior to calling them
This changes the progressive refine part, regular update was already checking
for whether callbacks are set.
2015-05-19 12:42:07 +05:00
ddb1a068e9 SCons: install Python executable when its bundled 2015-05-19 16:44:19 +10:00
e698299e4f CMake: install Python executable when its bundled 2015-05-19 16:44:19 +10:00
d5a85f87b0 Python: search for 'python' and 'python#.#' 2015-05-19 16:44:19 +10:00
3d70a04a8a CMake: remove temp assignment, unused vars 2015-05-19 16:44:18 +10:00
183b643774 Building without Python works again 2015-05-19 11:38:07 +10:00
65328fadc3 Final solution for Intel card Ambient Occlusion in T43987.
Forgot to account for offscreen case in addition to compositing
2015-05-18 22:10:54 +02:00
Julian Eisel
598c2dffe9 Fix T44708: UI label should use plural
Just to keep commit ratio up while being busy preparing for final exams
;)
2015-05-18 21:29:57 +02:00
192fddb324 BGE: Fix blenderplayer bad call stubs not updated.
Please (dfelinto) compile the bge to avoid these kind of problems.
2015-05-18 18:54:13 +02:00
5fa0b8778b BGE: Set default envMap resolution to 512 pixels
I propose to change  the environment map render default resolution (600) to 512 (Thanks brecht for the correction... I don't know why I said dpi) (to make it compatible with this script: http://en.wikibooks.org/wiki/GLSL_Pr...cting_Surfaces ) to make cubeMap reflections easier and avoid this error:

invalid envmap size please render with CubeRes @ power of two
unable to initialize image(0) in MAMaterial, image will not be available

http://blenderartists.org/forum/showthread.php?371232-BGE-proposal-Set-default-envMap-resolution-to-512-dpi

http://blenderartists.org/forum/showthread.php?370026-Problem-with-cube-map-textures (post 11)

Author : youle (Ulysse MARTIN)

Reviewers: hg1, agoose77, lordloki, moguri, panzergame, dfelinto

Reviewed By: panzergame, dfelinto

Subscribers: brecht

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1306
2015-05-18 18:12:40 +02:00
Dalai Felinto
947b756d5e Multi-View: small cleranup/refactor with RE_pass_find_by_type and RE_RenderLayerGetPass 2015-05-18 10:57:59 -03:00
cecd1f98a4 Fix T44752: Clip Editor doesn't respect ColorSpace setting when playback after Prefetch 2015-05-18 16:40:52 +05:00
45afc02f11 Solve threading conflict related on proxy group's inverse matrix
It was possible that two threads will start calculating proxy group's inverted
matrix and store it in the object itself. This isn't good idea because it means
some threads might be using partially written matrix.
2015-05-18 16:40:52 +05:00
61f9f508a4 Make object material drivers evaluation thread safe
Previously it was very easy to run into situation when two objects are sharing
the same materials with drivers which will cause threading access issues.

This actually only needed for the old depsgraph, but since it's still the one
we're using by default we'd better solve this issue.
2015-05-18 16:40:52 +05:00
8540907d60 Attempt to make drivers more safe for threading
There were some reported data race conditions in the python interpreter which
seems to be rather valid.

Surely this is not very pretty solution, but it might solve some annoying bugs
related on threading.
2015-05-18 16:40:52 +05:00
40091ff83a Correction to early output in the parallel range implementation
The used heuristic of checking the value prior to lock is not totally safe
because assignment is not atomic and check might not give proper result.
2015-05-18 16:40:51 +05:00
b88597c218 Make switching to threaded malloc safe to be called from threads
For a long time this function was only intended to be used from the main thread,
but since out implementation of parallel range (which is currently only used by
mesh deform modifier) we might want to switch to threaded alloc from object
update thread.

Now we're using spinlock around the check, which makes the code safe to be used
from all over the place.

We might consider using a bit of atomics operations magic there, but it's not so
much important for now, this code is not used in the performance critical code
path.
2015-05-18 16:40:51 +05:00
17388794ce Filebrowser: Do not intent to draw empty strings, loss of time.
Fixes assert raised in `UI_text_clip_middle_ex()` when trying to draw (empty) 'size' string
for appended/linked blender datablocks.
2015-05-18 13:02:05 +02:00
bf93316c52 Fix assert in outliner regarding WM and SCR ID types... 2015-05-18 12:53:31 +02:00
5dfe88adba Fix T44553: Dyntopo ignores front-face option
When 'Front Faces' brush option was enabled, dyntop would still adjust detail on back-faces.
2015-05-18 18:22:31 +10:00
3dfce097e4 Cleanup: use const for Imbuf file types 2015-05-18 16:27:08 +10:00
924f31e54f Fix T44543: painted texture lost after first save
Fix for T36639 caused all path changes to reload (which could loose user content).

Change behavior:

- Only reload data when a flag is explicitly passed
  (currently only used by Find Files operator)
- Don't reload images which have been painted onto and not saved (dirty flag set).
2015-05-18 13:42:47 +10:00
662746fdd4 Fix multi-drag & multi-select, Alt press mid-drag
This would enable multi-value-editing in the middle of the drag action.
2015-05-18 11:52:59 +10:00
88acb3c599 Fix T44707: cycles border render regression 2015-05-18 11:37:19 +10:00
29aae4db38 UI: errors in buttons now show in info report
Mistakes in button expressions were previously only printed to the console.
2015-05-18 10:02:29 +10:00
3ed009af96 Change behavior of cycles xml to conform the spec: "Each XML document has exactly one single root element" 2015-05-17 23:41:38 +02:00
0b5bf9d419 BGE: Fix T42244 LibLoad crash with logic brick KX_TouchSensor
I remove duplicate and wrong code which treat the special case of KX_TouchSensor.
And Also the re-conversion of linked logic brick.
2015-05-17 22:19:09 +02:00
Julian Eisel
d1230ca723 Fix Node Editor using wrong snap element menu when called from shortcut
Kudos to @kopias for notifying me :)
2015-05-17 19:47:03 +02:00
105b87a3f7 Cycles: Enable advanced shading on AMD / OpenCL.
That is needed for Motion Blur and Render Passes to work properly.
I hope there are no nasty side effects, but we need to test this.
2015-05-17 19:29:33 +02:00
dae566894a Cycles / OpenCL: Enable Camera Motion and Hair for AMD.
Only enabled for the Experimental kernel though, so the feature set must
be changed in the UI to use the features.
2015-05-17 18:46:25 +02:00
14c2bc53c0 Cleanup: Typos, typos everywhere. :D 2015-05-17 18:32:31 +02:00
4139686817 Fix T44713: GLSL and BI inconsistency converting color to float node socket. 2015-05-17 18:18:04 +02:00
3cff7768d5 Fix T44718: Cycles GLSL not working for NURBS objects. 2015-05-17 17:25:57 +02:00
43ee3f4040 Fix T44739: OS X RMB emulation giving wrong mouse button release event. 2015-05-17 16:55:18 +02:00
48ed2b6309 UV editor: make Ctrl+E menu with mark/clear seam, instead of always marking. 2015-05-17 16:54:14 +02:00
a622cdaad8 Buildbot: Make sure files are readable by www group 2015-05-17 19:28:12 +05:00
2b9d806432 Fix T44084 - Cursor gets reset after MMB scrolling in another area while in GPencil Continous Draw Mode 2015-05-18 02:25:32 +12:00
206f29c12c Fix T44685 - In grease pencil stroke editing, selecting points is offset by a few pixels
The problem was that it was aborting too early after stumbling across a point which
might fit within the bounds required. This commit improves the logic here to solve
this and a few other little bugs like that.

Disclaimer: There are still a few cases where it randomly ends up picking something
way off. However, this only seems to occur very sporadically, so it's hard to say
how bad the problem may be.
2015-05-18 02:03:39 +12:00
30b45d5591 BMesh: don't check winding for uv-vert-map
Made link-select separate front/back with projected UV's
2015-05-17 23:06:41 +10:00
b68fa820d6 Fix T44715: crash compositing with undefined node due to re-save in older version 2015-05-17 13:44:22 +02:00
3b359f1fea BGE: Fix T43761 No re-creation of display list after a mesh modification.
I also removed unused flags in RAS_ListRasterizer.cpp.
2015-05-17 12:53:57 +02:00
4d45f47920 Fix T44737: Missing 'Spin' op entry in surface (NURBS) tools/menu. 2015-05-17 12:45:07 +02:00
effb912061 Cycles Standalone: Expose various light settings. 2015-05-17 12:36:42 +02:00
dad2850cc5 Numeric Input for Pose Breakdowner/Slide/Push Tools 2015-05-17 22:28:25 +12:00
347843f6fe Cycles Standalone: Update help screen. 2015-05-17 12:10:30 +02:00
f51fef63aa Fix own error deleting previews 2015-05-17 17:26:01 +10:00
847ec075eb Cleanup: pep8 2015-05-17 17:26:01 +10:00
02cbc3c1e0 Cleanup: indentation 2015-05-17 17:25:57 +10:00
daeb3069cf Cleanup: typos 2015-05-17 16:09:32 +10:00
6ba128129d CMake: correct file listing 2015-05-17 16:09:15 +10:00
60f60ed496 CMake: fixes for own checking script
don't error if generated files are missing.
2015-05-17 16:05:38 +10:00
6c15f3044b Yet another attempt to fix Intel case for T43987 2015-05-16 23:09:11 +02:00
dcacc54e07 Freestyle: Fix for stroke rendering performed with multi-views enabled.
Per-view Freestyle stroke rendering needs to be done without multi-views.
2015-05-16 23:59:14 +09:00
4c0f0eb338 Fix T44691 Freestyle render crashes when Views is on (Blender Internal).
In pipeline.c the function add_freestyle() was supposed to be called once
per frame, but after the Multi-view merge the function are called as many
as the number of views.  There were however a few Freestyle parameters
that have to be initialized per frame, and initializing one of the
parameters for each view was causing double freeing of allocated memory
which was enough to result in a crash.
2015-05-16 23:59:11 +09:00
a49534ae48 setting some RNA defaults for nodes 2015-05-16 13:04:40 +01:00
dddb4f655c BMesh: link-select-pick now supports redo
Without this you can't change delimiter options without editing the keymap.
2015-05-16 20:53:35 +10:00
3aa4a0e787 BMesh: add UV delimit for select-linked, dissolve 2015-05-16 12:21:31 +10:00
05c4c2409e BMesh: add sharp edge delimiter 2015-05-16 10:18:38 +10:00
5cc55486ee BMesh: select linked, support other delimiters
Use same options as limited dissolve (adds material & winding)
2015-05-16 10:17:46 +10:00
1bb3d0d485 Select linked seam limit, now works for picking
Second half of fix for also T42510
2015-05-16 09:35:35 +10:00
eeadd19eb5 Cleanup: use define for playback frame limiter 2015-05-16 08:35:25 +10:00
80c0097210 Only initialize icons in background mode.
Also enable this for headless builds too.

Calling UI_icons_init would initialize matcaps, brushes etc...
2015-05-16 06:21:26 +10:00
b931afe55e Fix new 'custom previews/icons' py feature crashing in background mode.
We want this even without UI, some scripts may use it in a background processing
mode to avoid too heavy process in actual 'user' blender...
2015-05-15 20:12:25 +02:00
08f30ef31c Fix T44724: missing menu entries for 'view fit' (F) in clip/image editors. 2015-05-15 19:49:00 +02:00
2d479421af Fix crasher in new lazy-rebuild outliner's treehash.
treehash must always been checked before used!

Reported on irc by sebastian_k and investigated by sergey, thanks!
2015-05-15 19:29:18 +02:00
5dc22fbbfb BGE: Fix T41299 Group API for child object in dupli instance group. 2015-05-15 19:17:15 +02:00
ce0d3112e4 Scene audio naming cleanup:
Remane sound_scene_handle to playback handle.
sound_scene_handle was a part of scene so we could see code like scene-
often in the same function.

If I understand things correctly, in audaspace lingo, the
playback_handle corresponds to a Reader while the scene_sound
corresponds to a Factory.

More cleanups will be done here later, but changing this now because my
brain hurts trying to remember which is which...
2015-05-15 16:51:46 +02:00
3d658bf7a7 BGE: Fix stupid typo error in DupliGroupRecurse 2015-05-15 16:25:45 +02:00
371e5f25a0 BGE: Cleanup : merge 3 loop in 1 in function DupliGroupRecurse. 2015-05-15 16:20:06 +02:00
f4e8e70b5d Add really simple memory reduction scheme for internal animation player.
Holds 30 frames in memory. Could make it check memory instead but that
should suffice for now to make sure blender does not crash on me with
movie files.

Previously the system would load eveything in memory so something like
playing caminandes in player would swap after 30 seconds in local
computer.
2015-05-15 16:01:01 +02:00
31e96cbf96 Cleanup: style, spelling 2015-05-15 23:38:53 +10:00
2fa4a48bce BGE: Fix T44700 mesh without material in blenderplayer.
If a mesh doesn't have a material we don't initialize the mSavedData in KX_BlenderMaterial to avoid crash.
2015-05-15 14:54:38 +02:00
7c06190882 Cycles: Make animated seed a builtin feature.
For animations, you often want an animated render seed (noise pattern).

This could be done by e.g. setting a driver on the seed value.
Now it's a little checkbox, that can be enabled.

The animated seed is based on the current Blender frame and
the seed value itself. Simply enabling it, will already result in an animated
seed (different on each Blender frame), but it can be randomized further
by setting a different seed value.

Disabled per default, so no backward compatibility break.

Differential Revision: https://developer.blender.org/D1285
2015-05-15 13:54:59 +02:00
e4c93dc7db Zoom to frame options, requested by the Hwoozeberry (dutch translation)
team.

There are 3 options here:

1) Keep range (previous behaviour)
2) Seconds - allows a specified offset in seconds around current frame
3) keyframes - zoom to include a number of keyframes around the cursor

Options 2 and 3 have their own properties to tweak the behaviour and all
options can be found in User Preferences->Interface under the 2D
viewports section.

Number 3 will probably need some refinement so commiting here for the
hwoozeberry team to test first.
2015-05-15 13:39:30 +02:00
c86a6f3efb Cycles: Enable CMJ for Intel/NVidia experimental split kernels
It is still disabled for AMD devices since can't test if it works fine
on this hardware.
2015-05-15 13:22:47 +05:00
c2b9f78415 Cycles: Pass __KERNEL_EXPERIMENTAL__ to OpenCL split kernels
Experimental feature set id currently unavailable for megakernel, it'll
require some changes to the cache system to distinguish cached regular
kernels from cached experimental kernels.

Currently unused, but some features will be enabled soon.
2015-05-15 13:22:47 +05:00
2ab909a88c Cycles: Make experimental kernel build option more generic
Previously it was explicitly mentioning it's NVidia kernel related option,
but in fact it's also handy for the OpenCL kernel.
2015-05-15 13:22:47 +05:00
c9e8888f87 Cycles: Disable bake OpenCL kernel for NVidia devices prior to sm_30
Driver fails to compile kernel in reasonable time for those devices here,
so for easier testing of the OpenCL split kernel work disabling bake kernel
for now.
2015-05-15 13:22:47 +05:00
960d7df56f Cycles: Pass device compute capabilities to kernel via build options
This way it's possible to do device-selective feature disabling/enabling.
Currently only supported for NVidia devices via OpenCL extension.
2015-05-15 13:22:47 +05:00
650fbd09f7 OpenCL wrangler: Add some of the extension defines 2015-05-15 13:22:47 +05:00
03f9d5a4cf Cycles: Cleanup, move build options string calculation into the device class
This way it's easier to access platform name, device ID and other stuff which
might be needed to define build options.
2015-05-15 13:22:47 +05:00
ba9dbaae64 Fix T42510: Limit by seams fails in edge/vert mode 2015-05-15 17:14:02 +10:00
547b676181 BMesh: add loop-shell walker 2015-05-15 17:07:57 +10:00
cfe54245a8 Correct recent cleanup
Removed call which was still needed
2015-05-15 11:29:34 +10:00
bc371030a7 BMesh: rename loop walker -> edgeloop 2015-05-15 10:55:56 +10:00
Julian Eisel
a92d8a34a8 Add material reorder buttons for Cycles as well 2015-05-15 01:25:03 +02:00
Julian Eisel
7549ec7301 Fix some issues found by Coverity Scan
Some of them are just brain dead code, some are potential bugs.
2015-05-15 01:08:41 +02:00
3c10ec96b5 Cycles: Enable object motion blur on Intel OpenCL platform
This required allocating some memory related on object transform needed
by ShaderData and currently it is done for all the platforms. Since we're
targeting full feature-complete platforms this is rather acceptable at
this point and in the future we'll do selective NO_HAIR/NO_SSS/NO_BLUR
kernels.

This is experimental still and in fact there're some major issues on
NVidia platform and it's not really clear if it's a bug in compiler,
some uninitizlied variable or other kind of issue.
2015-05-15 00:48:12 +05:00
03565218d5 Cycles: Various fixes
Some stupid fixes like spaces around operator and missing semicolon,
plus fix for wrong detecting of ShaderData SOA size. Thar was harmless
since there's only one closure array, but still better to fix this.
2015-05-15 00:42:05 +05:00
f6c6dd44de Cycles: Remove meaningless ifdef checks for features in device_opencl
This file was actually checking for features enabled on CPU and surely all
of them were enabled, so removing them does not cause any difference.

ideally we'll need to do runtime feature detection and just pass some stuff
as NULL to the kernel, or maybe also have variadic kernel entry points which
is also possible quite easily.
2015-05-14 23:44:19 +05:00
5c34266383 Cycles: Enable camera motion blur in split kernel for Intel/NVidia
It's good for testing and seems to work quite reliably here.

This probably not totally cheap in terms of performance, but this we
could solve quite easily by selective kernel compilation once other
things are tested/proved to be reliable.
2015-05-14 23:35:19 +05:00
0a60c7d8ee Cycles: Fix missing camera-in-volume update when using certain render layers configurations 2015-05-14 19:08:13 +05:00
3d3d805b64 Cycles: Prepare code for OpenCL camera/motion blur
The kernels are now compiling just fine, but there're some issues
during rendering. This is still to be investigated.
2015-05-14 18:48:56 +05:00
5a63edb929 Cycles: Use special _auto versions of transform function in motion blur code
Doing this as a separate commit so it's easier to revert in the future, once
OpenCL 2.0 is becoming our requirement.
2015-05-14 18:48:56 +05:00
33439626f1 Cycles: Add transformation functions with specified addrspace
This is required for OpenCL prior to 2.0 and those functions will become
handy when working on camera/motion blur support in split kernel.
2015-05-14 18:48:56 +05:00
79aa50dc53 Cycles: Enable hair for split kernels when using Intel or NVidia drivers
Apart from simply enabling this features needed changes to the code were done.
Technical change, replacing SD access from "simple" structure to SOA.
2015-05-14 18:48:56 +05:00
e7f2aec81b BGE: Add 'Lock Translation' for dynamic objects
The XYZ translation lock was missing for dynamic object.

Reviewed By: panzergame
2015-05-14 15:23:42 +02:00
1ccc417477 Invert value calculation for percentages it makes more sense that way 2015-05-14 14:22:57 +02:00
7aa74dfe5e Radial operator:
Percentage properties use interaction like factors with number feedback
and easier way to go predict lower percentages.
2015-05-14 14:01:33 +02:00
057a8c6250 Add clear seams to uv editor 2015-05-14 12:48:47 +02:00
8bf9e1412f BGE: Fix: Double jumps are not working with character motion actuator
The actual character motion actuator triggers every frame the jump method.
Adding an edge detection to trigger the jump method.

Reviewers: lordloki, sybren, moguri

Reviewed By: moguri

Differential Revision: https://developer.blender.org/D1220
2015-05-14 09:45:51 +02:00
687f6a9752 BGE: Code Cleanup: LOD hysteresis calculation
* Cleanup duplicated code.
* Remove unnecessary "this->"

Reviewers: kupoman, lordloki

Reviewed By: kupoman, lordloki

Differential Revision: https://developer.blender.org/D1293
2015-05-14 09:40:03 +02:00
434086dc53 install_deps.sh: correct typo 2015-05-14 13:13:13 +10:00
9207c8d669 Fix project paint worldspace coord calc from seam
Surprising this worked at all, would show errors with non-flat-quads.
2015-05-14 13:06:19 +10:00
0e80eb82e0 Cycles: Resize light_data after possible light removal. 2015-05-14 01:13:40 +02:00
67eb2c7897 Cycles: Remove Emission shaders from the graph if color or strength is 0. 2015-05-14 01:13:40 +02:00
da1038c768 UI: Copy to selected nodes now filtered by type
Was needed because sockets are very generic type which would match on unrelated values.
2015-05-14 06:27:51 +10:00
fc31bae66f Cleanup: Avoid temp variable in portal sampling code. 2015-05-13 19:54:52 +02:00
93867ae549 Cycles: Cleanup: use generic utility function to set kernel arguments 2015-05-13 19:56:24 +05:00
51a6bc8faa Cycles: Inline sizeof of elements needed for the split kernel
No need to store them in the class, they're unlikely to be changed
and if they do change we're in big trouble anyway.

More appropriate approach would be then to typedef this things in
kernel_types.h, but still use inlined sizeof(),
2015-05-13 19:56:24 +05:00
0a6e32173e Cleanup / Cycles: De-Duplicate Portal data fetch and side check. 2015-05-13 16:05:30 +02:00
730e61b446 Clip editor: Selecting curves in graph view always extends tracks selection
Was actually an old TODO, hopefully solved now in a way so everyone is happy.
2015-05-13 16:11:26 +05:00
0d64e26740 Clip editor: Deselecting with shift-LMB does not work in graph view 2015-05-13 15:55:32 +05:00
38eab96f9b Fix T44683: Unable to mute movie clip when using stabilized display 2015-05-13 14:28:24 +05:00
ae9e38c5ad Fix T44689: New Depsgraph crash
Simple highschool rated issue -- uninitialized variable :)
2015-05-13 14:07:37 +05:00
1a0fb7e9ae Project Paint: enable old bleed UV calculation
Was disabled because other values weren't quite right.
2015-05-13 18:26:56 +10:00
a050d6063c Project Paint: resolve ugly bleed artifacts
Use the bilinear reverse to find the pixel to bleed from.
Was using pixel space which didn't work well.
2015-05-13 18:04:46 +10:00
3e782756e3 Project Paint: simplify uv bleed factor calc 2015-05-13 17:48:54 +10:00
7969b238db Fix T39775: Skin modifier crash 2015-05-13 16:08:19 +10:00
7742a8f09c Cleanup: reduce scope for win32, Linux vars 2015-05-13 16:08:19 +10:00
Dalai Felinto
c78df8f9ee Duplicate Render->RenderData.views for thread safety (as we do for layers)
This fixes nothing at the moment, but better safe than sorry since there
are still a few strange multiview issues around.
2015-05-13 01:03:19 -03:00
abb80abf8a UI: check visible layers when reading context
This resolves a problem where selected items edited for multi-value-editig
could include objects not in any visible views (unlocked layers, local view... etc).
2015-05-13 11:00:23 +10:00
08bbea9362 UI: multi-value-edit, distable alt+lmb on sliders 2015-05-13 10:32:30 +10:00
898b6491ed UI: multi-value-edit, tint button while editing
Currently re-uses node-flag (which is only used to tint color too)
2015-05-13 10:01:13 +10:00
91ec8d8d1e UI: multi-value-editing, copy value when typed in 2015-05-13 09:50:08 +10:00
bbadc3aecd UI: nodes support for multi-value-editing 2015-05-13 09:48:41 +10:00
Dalai Felinto
274b0838c7 Multi-View: return correct number of views when rendering only one of the stereo pairs
Without this fix ViewerNode would continously trash the views/buffer
when disabling either stereo eye.
2015-05-12 18:46:09 -03:00
b3334d936f Edit last commit, redundant 'data' in RNA path 2015-05-13 07:40:21 +10:00
ee3dde2d49 UI: ObData support for copy-to-selected
Now multi-object editing works for obdata too.
2015-05-13 07:25:04 +10:00
Dalai Felinto
3e519860e5 Fix T44684 Compositor backdrop isn't updating correctly 2015-05-12 18:20:05 -03:00
e4cd4c383f Cleanup: style 2015-05-13 06:10:49 +10:00
3160740421 Fix T40762: Python can't access macro values 2015-05-13 05:26:29 +10:00
b01dd748b6 Dyntopo PBVH build optimization:
Optimize the full rebuild case for now (though same code can be adapted to
partial redraws)

Main changes here:

* Calculate bounding centroid for faces only once (instead of every intermediate node)
* Faces do not get added to GSets immediately, instead we track a face
array which has faces that belong in a node in consecutive order.
Nodes just keep accounting of start and length in the array.
* Due to faces not being added to GSets, we can skip doing cleanup of GSets
and readdition for each intermediate node and instead only
add the faces to the final leafs node GSets when those nodes are created.

Results:
For a 1.9 million face test model, PBVH generation time (roughly measured by undoing) is
dropped from 6 seconds to about 4 seconds. Still too high, but still a nice improvement.

TODO:
Thread some parts. Unfortunately threading the GSet assignment part might not help much since
we'd need a lot of locking to avoid collisions with node assignments, especially for unique vertices.
2015-05-12 21:03:16 +02:00
f097453006 Fix missing define in blenloader
It caused blender versions compiled with scons not having proper
build date/hash stored in the .blend file.
2015-05-12 19:53:31 +05:00
Dalai Felinto
15016e1497 small cleanup on render_result_new()
(making the duplicate code more like the original one)
2015-05-12 11:38:24 -03:00
f0f481031c Fix T44616: Cycles crashes loading 42k by 21k textures
Simple integer overflow issue.

TODO(sergey): Check on CPU cubic sampling, it might also need size_t.
2015-05-12 18:48:55 +05:00
7c2905b8ec Fix T44398: Compositing displace node makes image fuzzy with zero displacement
EWA filtering with zero derivatives is introducing some fuzzyness into the
image. Currently solved by using regular sampling for cases when derivatives
are zero, which should also make compo faster in that areas.

Still need to look into checking if EWA filter can be tweaked in a way so
no fuzzyness is introduced.
2015-05-12 17:24:07 +05:00
8697c19e91 Depsgraph: Don't use C++11 function binding with MSVC
It has some weird incompatibility with the way how Boost and GCC C++11
function bindings works, resulting in compilation errors.
2015-05-12 16:41:23 +05:00
909d3228b1 BGE : Fix Bullet shape margin for triangle mesh static objects 2015-05-12 13:38:46 +02:00
615a7aea55 Depsgraph: Attempt to fix alignment issue on 32bit platforms 2015-05-12 16:36:34 +05:00
29529d2ac3 ImBuf: Update stubs so strict compiler is happy about unused arguments
Also use C++-style unused arguments tagging instead of legacy c-style.
It's less annoying this way because does not require adding argument to
two places of the function.
2015-05-12 16:25:39 +05:00
bac7353801 Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:

- More granular dependency relation nature, which solves issues with fake cycles
  in the dependencies.

- Move towards all-animatable, by better integration of drivers into the system.

- Lay down some basis for upcoming copy-on-write, overrides and so on.

The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.

It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.

There are number of assorted documents related on the design of the new system:

* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph

There are also some user-related information online:

* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/

Kudos to everyone who was involved into the project:

- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
  project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
  issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 16:06:37 +05:00
a09341469e Depsgraph: Add evaluation callbacks for granular nodes update
This commit only adds callbacks which then later be used with major dependency
graph commit, keeping the upcoming commit more clean to follow.

Should be no functional changes so far still.
2015-05-12 16:06:37 +05:00
051688b34c Depsgraph: Make ob_get_parent_matrix() more public and reusable
Currently still only used from object.c, but in the next commit it'll be also
used from granular object update callbacks.
2015-05-12 16:06:36 +05:00
08d87514d3 Depsgraph: Add utility function to check whether modifier depends on time
Currently unused, based on the code from old depsgraph.c. The purpose is to
re-sue the code over old and new depsgraph in an easy way.
2015-05-12 16:06:36 +05:00
31f0c27ae7 Depsgraph: Add additional relations/id update tags
This calls are not strictly speaking needed for the old dependency graph, but
due to more granular nature of upcoming depsgraph more actions requires update
of relations of IDs.

On the one hand this extra tags could be wrapped with if() statements, but on
the other hand it makes sense to keep tag in sync so it's clear if some issue
is caused by missing/extra tag or by depsgraph itself.
2015-05-12 16:06:36 +05:00
87fd166654 Depsgraph: Add utility function to tag pose for recalc
Currently this function only tags pose itself, totally matching previous
behavior. But this will be needed in the future once new dependency graph
is landed, because of it's granular nature which relies on the fact that
pose channels are all up to date when building the graph.

Should be no functional changes so far.
2015-05-12 16:06:36 +05:00
dbbe721c2a Depsgraph: Move update-related functions into own files
Currently it is just moving existing functions into a new file,
but in the future those new files will be grown much more due
to upcoming more granular scene updates.

Should be no functional changes.
2015-05-12 16:06:36 +05:00
ae00e42bc2 Fix T44677: Normal Edit Modifier Radial Mode broken with target object.
Very stupid mistake, odd nobody hit this earlier... :/
2015-05-12 10:57:39 +02:00
20e561dd6a PyAPI: Remove release method, just use delitem 2015-05-12 18:43:30 +10:00
f6dc0e918b Minor tweaks to preview templates 2015-05-12 18:29:06 +10:00
34c78a659b Doc: add bpy.utils.previews
Updated sphinx_doc_gen.py to better handle pure py-classes.
2015-05-12 18:24:32 +10:00
f727df6076 Doc: correct rst syntax
also remove some API docs from example
2015-05-12 18:23:29 +10:00
311f6cac92 Doc: replace addons -> scripts in docstring
Theres nothing add-on specific here.
2015-05-12 18:23:29 +10:00
8a231185aa Doc: minor fixes
- check for class/static methods assumed nonzero args.
- subclass references and set-flag items are now sorted.
- use 'order' for Py operator mix-ins,
  so operator settings don't show in random order.
2015-05-12 18:23:24 +10:00
8478c71a7b BGE: Adding material IPO support to GLSL materials
Most of this patch was created by Daniel Stokes, I'm mostly just cleaning
it up and testing it. Still todo: hardness. I need to figure out how to
handle the integer -> float conversion on a dynamic uniform.

Reviewers: psy-fi, brecht

Reviewed By: psy-fi

Subscribers: psy-fi

Differential Revision: https://developer.blender.org/D511
2015-05-11 23:05:04 -07:00
ce504cffad Freestyle: Fix for assertion failure in viewport preview.
An assertion to check if `re->clipsta` < 0 (added as part of addressing
T36009 in rBrB795034c17d76bef2a15e576ac9c70ae2268a823b) was failing when
Freestyle viewport preview rendering takes place in the camera view with
an orthographic camera (in this case, the user-defined clipping range is
used without changes, so that `re->clipsta` is positive).  The
`re->clipsta` property has a negative value only when the 3D viewport is
in an orthographic view but not in the camera view.  It seems that this
viewport setting cannot be identified from rendering settings accessible
from Freestyle.  Now a negative `re->clipsta` value is directly checked
instead, without relying on other render flags.
2015-05-12 02:18:24 +09:00
c7bccb30bf Cycles: check for F16C support with __cpuid, as we do for BMI and BMI2 2015-05-11 15:49:36 +00:00
1bf685488c Collada Exporter: sanitize a bit lnor export.
In case `BKE_mesh_calc_normals_split()` would fail, exporter would read
uninitialized random mem... Should not happen, but better be safe than sorry.
2015-05-11 17:22:18 +02:00
2c4736e6db Clearing preview image shall also unset 'user edited' flag! 2015-05-11 17:12:31 +02:00
4fc3188112 Cycles: Get rid of one more OpenGL matrix manipulation/push/pop. 2015-05-11 16:41:18 +02:00
d30f664c04 Expose PreviewImage & custom icons to py API.
This commit mainly:

* Exposes PreviewImage struct in RNA, including ways for user to set images data.
* Adds a new kind of PreviewImage, using a file path and IMB_thumb to get image.
* Adds a new kind of custom icon using PreviewImage, unrelated to ID previews system.
* Adds a python API (utils.previews) to allow python scripts to access those custom previews/icons.

Note that loading image from files' thumbnails is done when needed (deferred loading), not
when defining the custom preview/icon.

WARNING: for release addons who would want to use this, please keep it to a strict minimum, really needed level.
We do not want our UI to explode under hundreds of different flashy icons!

For more info, see also the release notes of Blender 2.75 (http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.75/Addons)
and the example/templates featured with Blender.

Patch by Campbell (ideasman42), Inês (brita) and Bastien (mont29).

Differential Revision: https://developer.blender.org/D1255
2015-05-11 16:37:15 +02:00
e38f914421 Cycles: use vertex buffers when possible to draw tiles on the screen.
Not terribly necessary in this case, since we are just drawing a quad,
but makes blender overall more GL 3.x core ready.
2015-05-11 16:28:41 +02:00
cc1883468d Keep valgrind happy by using tight vec3 packing instead of lax vec4 with
an unused coordinate missing.
2015-05-11 14:14:06 +02:00
5588a51c9c Cycles OpenGL: Don't use full matrix transform when we can just use
simple addition.
2015-05-11 13:10:19 +02:00
94549adec4 Merge branch 'master' into temp-ghash-setops 2015-03-21 09:07:10 +01:00
77a4d705c7 Merge branch 'master' into temp-ghash-setops 2015-03-20 16:56:12 +01:00
f808f36c12 Get rid of varargs in union & co functions (using variadic macros instead). 2015-03-20 16:55:10 +01:00
b6f0c9e25a Some improvements/tweaks from review. 2015-03-20 15:15:26 +01:00
ecc9fe9945 Merge branch 'master' into temp-ghash-setops 2015-03-20 12:54:41 +01:00
4e3bc21492 Remove public GHash API for union/inter/diff/symmdiff.
This is dead easy to add back when we want (or use other naming if we really
like them better), core code remains exactly the same anyway.

Note we keep checks (isdisjoint, isequal, etc.) for ghashes though, those are
pure-keys non-modifying operations anyway, so here set ops for ghash are
definitively valid (equivalent of set ops on dict.keys() views in py).
2015-03-20 12:04:03 +01:00
88ae44a363 Fix for updates in master... 2015-03-20 12:04:03 +01:00
df587b03c3 Revert "Remove gtests."
This reverts commit 2b8fac2a153e135d0f6cc7621a3755901477fd3d.
2015-03-20 12:04:03 +01:00
1df3713365 Remove gtests. 2015-03-20 12:04:03 +01:00
23b42a5e69 Squashed commit of temp-ghash-experiments, minus the 'hash storage' part. 2015-03-20 12:04:03 +01:00
896 changed files with 36746 additions and 11688 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
@@ -197,7 +198,6 @@ option(WITH_PYTHON "Enable Embedded Python API (only disable for develop
option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default" ON)
mark_as_advanced(WITH_PYTHON) # dont want people disabling this unless they really know what they are doing.
mark_as_advanced(WITH_PYTHON_SECURITY) # some distributions see this as a security issue, rather than have them patch it, make a build option.
set(WITH_PYTHON_SECURITY ON CACHE BOOL "ON" FORCE) # temp force on.
option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency, only enable for development)." OFF)
mark_as_advanced(WITH_PYTHON_SAFETY)
@@ -449,6 +449,10 @@ endif()
option(WITH_CPP11 "Build with C++11 standard enabled, for development use only!" OFF)
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()
@@ -652,6 +656,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
@@ -660,11 +671,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)
@@ -1842,14 +1848,14 @@ elseif(APPLE)
if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
# normally cached but not since we include them with blender
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
# set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
# set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
# set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled
else()
# module must be compiled against Python framework
set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m")
set(PYTHON_BINARY "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
set(PYTHON_EXECUTABLE "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
#set(PYTHON_LIBRARY python${PYTHON_VERSION})
set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m")
#set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python") # won't build with this enabled
@@ -2756,25 +2762,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}\"")

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

@@ -470,6 +470,14 @@ if env['OURPLATFORM']=='darwin':
################### End Automatic configuration for OSX ##################
#############################################################################
if env['OURPLATFORM'] == 'linux' and not env['C_COMPILER_ID']:
command = ["%s"%env['CC'], "--version"]
line = btools.get_command_output(command)
if line.startswith('gcc'):
env['C_COMPILER_ID'] = 'gcc'
elif 'clang' in line[0]:
env['C_COMPILER_ID'] = 'clang'
if env['WITH_BF_OPENMP'] == 1:
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
env['CCFLAGS'].append('/openmp')
@@ -1020,14 +1028,16 @@ if env['OURPLATFORM']!='darwin':
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel')
source=os.listdir('intern/cycles/kernel')
if '__pycache__' in source: source.remove('__pycache__')
source.remove('kernel.cpp')
source.remove('CMakeLists.txt')
source.remove('SConscript')
source.remove('svm')
source.remove('closure')
source.remove('geom')
source.remove('shaders')
source.remove('osl')
source.remove('split')
source=['intern/cycles/kernel/'+s for s in source]
source.append('intern/cycles/util/util_atomic.h')
source.append('intern/cycles/util/util_color.h')
source.append('intern/cycles/util/util_half.h')
source.append('intern/cycles/util/util_math.h')
@@ -1053,6 +1063,12 @@ if env['OURPLATFORM']!='darwin':
if '__pycache__' in source: source.remove('__pycache__')
source=['intern/cycles/kernel/geom/'+s for s in source]
scriptinstall.append(env.Install(dir=dir,source=source))
# split
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'split')
source=os.listdir('intern/cycles/kernel/split')
if '__pycache__' in source: source.remove('__pycache__')
source=['intern/cycles/kernel/split/'+s for s in source]
scriptinstall.append(env.Install(dir=dir,source=source))
# licenses
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'license')
@@ -1284,6 +1300,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

@@ -1374,7 +1374,7 @@ EOF
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
cmake_d="$cmake_d -D LLVM_ENABLE_FFI=ON"
cmake_d="$cmake_d -D LLVM_TARGETS_TO_BUILD=X86"
cmake_d="$cmake_d -D -DLLVM_ENABLE_TERMINFO=OFF"
cmake_d="$cmake_d -D LLVM_ENABLE_TERMINFO=OFF"
if [ -d $_FFI_INCLUDE_DIR ]; then
cmake_d="$cmake_d -D FFI_INCLUDE_DIR=$_FFI_INCLUDE_DIR"
@@ -2287,7 +2287,7 @@ install_RPM() {
OGG_DEV="libogg-devel"
THEORA_DEV="libtheora-devel"
_packages="gcc gcc-c++ make scons libtiff-devel freetype-devel libjpeg-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 \
glew-devel yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV patch \
@@ -2301,7 +2301,7 @@ install_RPM() {
if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
OPENEXR_DEV="openexr-devel"
_packages="$_packages libsqlite3x-devel fftw-devel SDL-devel"
_packages="$_packages freetype-devel libsqlite3x-devel fftw-devel SDL-devel"
if $WITH_ALL; then
_packages="$_packages jack-audio-connection-kit-devel"
@@ -2339,7 +2339,7 @@ install_RPM() {
elif [ $RPM = "SUSE" ]; then
OPENEXR_DEV="libopenexr-devel"
_packages="$_packages cmake sqlite3-devel fftw3-devel libSDL-devel"
_packages="$_packages cmake freetype2-devel sqlite3-devel fftw3-devel libSDL-devel"
PRINT ""
install_packages_RPM $_packages

View File

@@ -124,10 +124,12 @@ else:
directory = 'public_html/download'
try:
filename = os.path.join(directory, packagename)
zf = z.open(package)
f = file(os.path.join(directory, packagename), "wb")
f = file(filename, "wb")
shutil.copyfileobj(zf, f)
os.chmod(filename, 0644)
zf.close()
z.close()

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

@@ -66,6 +66,14 @@ IF(DEFINED PYTHON_LIBPATH)
SET(_IS_LIB_PATH_DEF ON)
ENDIF()
STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
SET(_python_SEARCH_DIRS
${PYTHON_ROOT_DIR}
"$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}"
"/opt/py${_PYTHON_VERSION_NO_DOTS}"
"/opt/lib/python-${PYTHON_VERSION}"
)
# only search for the dirs if we havn't already
IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_LIB_PATH_DEF))
@@ -75,14 +83,7 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
"dm;dmu;du;d" # debug
)
STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
SET(_python_SEARCH_DIRS
${PYTHON_ROOT_DIR}
"$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}"
"/opt/py${_PYTHON_VERSION_NO_DOTS}"
"/opt/lib/python-${PYTHON_VERSION}"
)
FOREACH(_CURRENT_ABI_FLAGS ${_python_ABI_FLAGS})
#IF(CMAKE_BUILD_TYPE STREQUAL Debug)
@@ -147,6 +148,7 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
ENDIF()
IF(PYTHON_LIBRARY AND PYTHON_LIBPATH AND PYTHON_INCLUDE_DIR AND PYTHON_INCLUDE_CONFIG_DIR)
SET(_PYTHON_ABI_FLAGS "${_CURRENT_ABI_FLAGS}")
break()
ELSE()
# ensure we dont find values from 2 different ABI versions
@@ -169,7 +171,6 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
UNSET(_CURRENT_PATH)
UNSET(_python_ABI_FLAGS)
UNSET(_python_SEARCH_DIRS)
ENDIF()
UNSET(_IS_INC_DEF)
@@ -201,14 +202,28 @@ IF(PYTHONLIBSUNIX_FOUND)
# XXX No more valid with debian-like py3.4 packages...
# GET_FILENAME_COMPONENT(PYTHON_LIBPATH ${PYTHON_LIBRARY} PATH)
# not used
# SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
# not required for build, just used when bundling Python.
FIND_PROGRAM(
PYTHON_EXECUTABLE
NAMES
"python${PYTHON_VERSION}${_PYTHON_ABI_FLAGS}"
"python${PYTHON_VERSION}"
"python"
HINTS
${_python_SEARCH_DIRS}
PATH_SUFFIXES bin
)
ENDIF()
UNSET(_PYTHON_VERSION_NO_DOTS)
UNSET(_PYTHON_ABI_FLAGS)
UNSET(_python_SEARCH_DIRS)
MARK_AS_ADVANCED(
PYTHON_INCLUDE_DIR
PYTHON_INCLUDE_CONFIG_DIR
PYTHON_LIBRARY
PYTHON_LIBPATH
PYTHON_SITE_PACKAGES
PYTHON_EXECUTABLE
)

View File

@@ -28,13 +28,17 @@ if not sys.version.startswith("3"):
sys.version.partition(" ")[0])
sys.exit(1)
from cmake_consistency_check_config import IGNORE, UTF8_CHECK, SOURCE_DIR
from cmake_consistency_check_config import (
IGNORE,
UTF8_CHECK,
SOURCE_DIR,
BUILD_DIR,
)
import os
from os.path import join, dirname, normpath, splitext
print("Scanning:", SOURCE_DIR)
global_h = set()
global_c = set()
global_refs = {}
@@ -134,6 +138,7 @@ def cmake_get_src(f):
if found:
cmake_base = dirname(f)
cmake_base_bin = os.path.join(BUILD_DIR, os.path.relpath(cmake_base, SOURCE_DIR))
while it is not None:
i += 1
@@ -154,6 +159,8 @@ def cmake_get_src(f):
# replace dirs
l = l.replace("${CMAKE_CURRENT_SOURCE_DIR}", cmake_base)
l = l.replace("${CMAKE_CURRENT_BINARY_DIR}", cmake_base_bin)
l = l.strip('"')
if not l:
pass
@@ -193,13 +200,16 @@ def cmake_get_src(f):
raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file))
elif context_name == "INC":
if os.path.isdir(new_file):
if new_file.startswith(BUILD_DIR):
# assume generated path
pass
elif os.path.isdir(new_file):
new_path_rel = os.path.relpath(new_file, cmake_base)
if new_path_rel != l:
print("overly relative path:\n %s:%d\n %s\n %s" % (f, i, l, new_path_rel))
## Save time. just replace the line
# # Save time. just replace the line
# replace_line(f, i - 1, new_path_rel)
else:
@@ -230,10 +240,6 @@ def cmake_get_src(f):
filen.close()
for cmake in source_list(SOURCE_DIR, is_cmake):
cmake_get_src(cmake)
def is_ignore(f):
for ig in IGNORE:
if ig in f:
@@ -241,73 +247,83 @@ def is_ignore(f):
return False
# First do stupid check, do these files exist?
print("\nChecking for missing references:")
is_err = False
errs = []
for f in (global_h | global_c):
if f.endswith("dna.c"):
continue
def main():
if not os.path.exists(f):
refs = global_refs[f]
if refs:
for cf, i in refs:
errs.append((cf, i))
else:
raise Exception("CMake referenecs missing, internal error, aborting!")
is_err = True
print("Scanning:", SOURCE_DIR)
errs.sort()
errs.reverse()
for cf, i in errs:
print("%s:%d" % (cf, i))
# Write a 'sed' script, useful if we get a lot of these
# print("sed '%dd' '%s' > '%s.tmp' ; mv '%s.tmp' '%s'" % (i, cf, cf, cf, cf))
for cmake in source_list(SOURCE_DIR, is_cmake):
cmake_get_src(cmake)
# First do stupid check, do these files exist?
print("\nChecking for missing references:")
is_err = False
errs = []
for f in (global_h | global_c):
if f.startswith(BUILD_DIR):
continue
if not os.path.exists(f):
refs = global_refs[f]
if refs:
for cf, i in refs:
errs.append((cf, i))
else:
raise Exception("CMake referenecs missing, internal error, aborting!")
is_err = True
errs.sort()
errs.reverse()
for cf, i in errs:
print("%s:%d" % (cf, i))
# Write a 'sed' script, useful if we get a lot of these
# print("sed '%dd' '%s' > '%s.tmp' ; mv '%s.tmp' '%s'" % (i, cf, cf, cf, cf))
if is_err:
raise Exception("CMake referenecs missing files, aborting!")
del is_err
del errs
if is_err:
raise Exception("CMake referenecs missing files, aborting!")
del is_err
del errs
# now check on files not accounted for.
print("\nC/C++ Files CMake doesnt know about...")
for cf in sorted(source_list(SOURCE_DIR, is_c)):
if not is_ignore(cf):
if cf not in global_c:
print("missing_c: ", cf)
# now check on files not accounted for.
print("\nC/C++ Files CMake doesnt know about...")
for cf in sorted(source_list(SOURCE_DIR, is_c)):
if not is_ignore(cf):
if cf not in global_c:
print("missing_c: ", cf)
# check if automake builds a corrasponding .o file.
'''
if cf in global_c:
out1 = os.path.splitext(cf)[0] + ".o"
out2 = os.path.splitext(cf)[0] + ".Po"
out2_dir, out2_file = out2 = os.path.split(out2)
out2 = os.path.join(out2_dir, ".deps", out2_file)
if not os.path.exists(out1) and not os.path.exists(out2):
print("bad_c: ", cf)
'''
# check if automake builds a corrasponding .o file.
'''
if cf in global_c:
out1 = os.path.splitext(cf)[0] + ".o"
out2 = os.path.splitext(cf)[0] + ".Po"
out2_dir, out2_file = out2 = os.path.split(out2)
out2 = os.path.join(out2_dir, ".deps", out2_file)
if not os.path.exists(out1) and not os.path.exists(out2):
print("bad_c: ", cf)
'''
print("\nC/C++ Headers CMake doesnt know about...")
for hf in sorted(source_list(SOURCE_DIR, is_c_header)):
if not is_ignore(hf):
if hf not in global_h:
print("missing_h: ", hf)
print("\nC/C++ Headers CMake doesnt know about...")
for hf in sorted(source_list(SOURCE_DIR, is_c_header)):
if not is_ignore(hf):
if hf not in global_h:
print("missing_h: ", hf)
if UTF8_CHECK:
# test encoding
import traceback
for files in (global_c, global_h):
for f in sorted(files):
if os.path.exists(f):
# ignore outside of our source tree
if "extern" not in f:
i = 1
try:
for l in open(f, "r", encoding="utf8"):
i += 1
except UnicodeDecodeError:
print("Non utf8: %s:%d" % (f, i))
if i > 1:
traceback.print_exc()
if UTF8_CHECK:
# test encoding
import traceback
for files in (global_c, global_h):
for f in sorted(files):
if os.path.exists(f):
# ignore outside of our source tree
if "extern" not in f:
i = 1
try:
for l in open(f, "r", encoding="utf8"):
i += 1
except UnicodeDecodeError:
print("Non utf8: %s:%d" % (f, i))
if i > 1:
traceback.print_exc()
if __name__ == "__main__":
main()

View File

@@ -74,3 +74,6 @@ IGNORE = (
UTF8_CHECK = True
SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))))
# doesn't have to exist, just use as reference
BUILD_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(SOURCE_DIR, "..", "build"))))

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

@@ -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

@@ -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
@@ -402,11 +415,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 +451,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
@@ -524,6 +541,7 @@ macro(SETUP_BLENDER_SORTED_LIBS)
bf_blenloader
bf_imbuf
bf_blenlib
bf_depsgraph
bf_intern_ghost
bf_intern_string
bf_avi
@@ -673,14 +691,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
@@ -902,19 +918,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()
@@ -928,28 +947,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}")
@@ -963,11 +988,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)
@@ -1003,37 +1032,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:
@@ -1183,7 +1214,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)
@@ -1196,8 +1227,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
@@ -1216,16 +1246,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)
@@ -1236,21 +1267,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)
@@ -1261,17 +1292,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
@@ -1283,6 +1310,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)
@@ -1304,27 +1332,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)
@@ -1347,15 +1370,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)
@@ -1364,6 +1384,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)
@@ -1374,15 +1395,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)
@@ -1420,25 +1437,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

@@ -112,3 +112,9 @@ elseif(UNIX)
"tar.bz2")
endif()
unset(MAJOR_VERSION)
unset(MINOR_VERSION)
unset(PATCH_VERSION)
unset(BUILD_REV)

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

@@ -206,7 +206,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

View File

@@ -145,7 +145,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'

View File

@@ -144,7 +144,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'

View File

@@ -372,7 +372,7 @@ def propose_priorities():
def creator(env):
sources = ['creator.c']# + Blender.buildinfo(env, "dynamic") + Blender.resources
incs = ['#/intern/guardedalloc', '#/source/blender/blenlib', '#/source/blender/blenkernel', '#/source/blender/editors/include', '#/source/blender/blenloader', '#/source/blender/imbuf', '#/source/blender/renderconverter', '#/source/blender/render/extern/include', '#/source/blender/windowmanager', '#/source/blender/makesdna', '#/source/blender/makesrna', '#/source/gameengine/BlenderRoutines', '#/extern/glew/include', '#/source/blender/gpu', env['BF_OPENGL_INC']]
incs = ['#/intern/guardedalloc', '#/source/blender/blenlib', '#/source/blender/blenkernel', '#/source/blender/depsgraph', '#/source/blender/editors/include', '#/source/blender/blenloader', '#/source/blender/imbuf', '#/source/blender/renderconverter', '#/source/blender/render/extern/include', '#/source/blender/windowmanager', '#/source/blender/makesdna', '#/source/blender/makesrna', '#/source/gameengine/BlenderRoutines', '#/extern/glew/include', '#/source/blender/gpu', env['BF_OPENGL_INC']]
defs = []
@@ -630,7 +630,7 @@ def WinPyBundle(target=None, source=None, env=None):
py_tar+= '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '.tar.gz'
py_target = env.subst(env['BF_INSTALLDIR']).lstrip("#")
py_target = os.path.join(py_target, VERSION, 'python', 'lib')
py_target = os.path.join(py_target, VERSION, 'python')
def printexception(func,path,ex):
if os.path.exists(path): #do not report if path does not exist. eg on a fresh build.
print str(func) + ' failed on ' + str(path)
@@ -764,7 +764,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)
@@ -843,6 +843,7 @@ def UnixPyBundle(target=None, source=None, env=None):
py_src = env.subst( env['BF_PYTHON_LIBPATH'] + '/python'+env['BF_PYTHON_VERSION'] )
py_target = env.subst( dir + '/python/' + target_lib + '/python'+env['BF_PYTHON_VERSION'] )
py_target_bin = env.subst(dir + '/python/bin')
# This is a bit weak, but dont install if its been installed before, makes rebuilds quite slow.
if os.path.exists(py_target):
@@ -862,6 +863,11 @@ def UnixPyBundle(target=None, source=None, env=None):
except:
pass
# install the executable
run("rm -rf '%s'" % py_target_bin)
os.makedirs(py_target_bin)
run("cp '%s' '%s'" % (env.subst(env['BF_PYTHON_BINARY']), py_target_bin))
run("cp -R '%s' '%s'" % (py_src, os.path.dirname(py_target)))
run("rm -rf '%s/distutils'" % py_target)
run("rm -rf '%s/lib2to3'" % py_target)

View File

@@ -199,7 +199,7 @@ def validate_arguments(args, bc):
'LLIBS', 'PLATFORM_LINKFLAGS', 'MACOSX_ARCHITECTURE', 'MACOSX_SDK', 'XCODE_CUR_VER', 'C_COMPILER_ID',
'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS', 'MACOSX_DEPLOYMENT_TARGET',
'WITH_BF_CYCLES_DEBUG', 'WITH_BF_CYCLES_LOGGING',
'WITH_BF_CPP11'
'WITH_BF_CPP11', 'WITH_BF_LEGACY_DEPSGRAPH',
]
@@ -657,6 +657,8 @@ 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_CPP11', '"Build with C++11 standard enabled, for development use only!', False)),
(BoolVariable('WITH_BF_LEGACY_DEPSGRAPH', 'Build Blender with legacy dependency graph', True)),
) # end of opts.AddOptions()
return localopts

File diff suppressed because it is too large Load Diff

View File

@@ -10,26 +10,14 @@
* \ingroup intern
*/
/** \defgroup boolop boolop
* \ingroup intern
*/
/** \defgroup ctr container
* \ingroup intern
*/
/** \defgroup decimation decimation
* \ingroup intern
*/
/** \defgroup elbeem elbeem
* \ingroup intern
*/
/** \defgroup bsp bsp
* \ingroup intern
*/
/** \defgroup iksolver iksolver
* \ingroup intern
*/

View File

@@ -93,36 +93,44 @@
/* ================================ */
/** \defgroup blender blender */
/** \defgroup blender Blender */
/** \defgroup blf blenfont
/** \defgroup blf BlenFont
* \ingroup blender
*/
/** \defgroup bke blenkernel
/** \defgroup bke BlenKernel
* \ingroup blender
*/
/** \defgroup bli blenlib
/** \defgroup bli BlenLib
* \ingroup blender
*/
/** \defgroup nodes nodes
/** \defgroup depsgraph Dependency Graph
* \ingroup blender
*/
/** \defgroup cmpnodes cmpnodes
/** \defgroup bph Physics
* \ingroup blender
*/
/** \defgroup nodes Nodes
* \ingroup blender
*/
/** \defgroup cmpnodes Nodes (Compositor)
* \ingroup nodes
*/
/** \defgroup shdnodes shdnodes
/** \defgroup shdnodes Nodes (Shader)
* \ingroup nodes
*/
/** \defgroup texnodes texnodes
/** \defgroup texnodes Nodes (Texture)
* \ingroup nodes
*/
/** \defgroup modifiers modifiers
/** \defgroup modifiers Object Modifiers
* \ingroup blender
*/
@@ -132,29 +140,29 @@
* \ingroup blender
*/
/** \defgroup ikplugin ikplugin
/** \defgroup ikplugin IK Plugin
* \ingroup blender
*/
/** \defgroup DNA sDNA
/** \defgroup DNA Struct DNA (File Format)
* \ingroup blender data
*/
/** \defgroup RNA RNA
/** \defgroup RNA RNA (Data API)
* \ingroup blender data
*/
/** \defgroup blenloader .blend read and write functions
/** \defgroup blenloader Blend file IO
* \ingroup blender data
* \todo check if \ref blo and \ref blenloader groups can be
* merged in docs.
*/
/** \defgroup quicktime quicktime
/** \defgroup quicktime QuickTime
* \ingroup blender
/** \defgroup gui GUI */
/** \defgroup wm windowmanager
/** \defgroup wm Window Manager
* \ingroup blender gui
*/
@@ -324,7 +332,7 @@
* \ingroup externformats
*/
/** \defgroup imbuf IMage Buffer
/** \defgroup imbuf Image Buffer (ImBuf)
* \ingroup blender
*/

View File

@@ -1,6 +1,6 @@
"""
.. _operator-execution_context:
"""
Execution Context
-----------------

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,73 +4,84 @@ 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.
:arg physicsid_1: the physics id of the first object in constraint
:type physicsid: int
: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
:type physicsid2: int
:arg physicsid_2: The physics id of the second object in constraint.
:type physicsid_2: int
:arg constrainttype: the type of the constraint. The constraint types are:
:type constrainttype: int
- :class:`POINTTOPOINT_CONSTRAINT`
- :class:`LINEHINGE_CONSTRAINT`
- :class:`ANGULAR_CONSTRAINT`
- :class:`CONETWIST_CONSTRAINT`
- :class:`VEHICLE_CONSTRAINT`
- :class:`GENERIC_6DOF_CONSTRAINT`
:arg pivot_X: pivot X position
:type pivot_X: float (optional)
:arg constraint_type: The type of the constraint, one of...
:arg pivot_Y: pivot Y position
:type pivot_Y: float (optional)
- :class:`POINTTOPOINT_CONSTRAINT`
- :class:`LINEHINGE_CONSTRAINT`
- :class:`ANGULAR_CONSTRAINT`
- :class:`CONETWIST_CONSTRAINT`
- :class:`VEHICLE_CONSTRAINT`
- :class:`GENERIC_6DOF_CONSTRAINT`
:arg pivot_Z: pivot Z position
:type pivot_Z: float (optional)
:type constraint_type: int
:arg axis_X: X axis angle in degrees
:type axis_X: float (optional)
:arg pivot_x: Pivot X position. (optional)
:type pivot_x: float
:arg axis_Y: Y axis angle in degrees
:type axis_Y: float (optional)
:arg pivot_y: Pivot Y position. (optional)
:type pivot_y: float
:arg axis_Z: Z axis angle in degrees
:type axis_Z: float (optional)
:arg pivot_z: Pivot Z position. (optional)
:type pivot_z: float
:arg flag: 128 to disable collision between linked bodies
:type flag: int (optional)
:arg axis_x: X axis angle in degrees. (optional)
:type axis_x: float
:return: a constraint wrapper.
:rtype: :class:`bge.types.KX_ConstraintWrapper`
:arg axis_y: Y axis angle in degrees. (optional)
:type axis_y: float
.. attribute:: error
:arg axis_z: Z axis angle in degrees. (optional)
:type axis_z: float
Symbolic constant string that indicates error.
:arg flag: 128 to disable collision between linked bodies. (optional)
:type flag: int
: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)
@@ -78,16 +89,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)
@@ -141,7 +152,8 @@ Physics Constraints (bge.constraints)
Sets the debug mode.
Debug modes:
:arg mode: The new debug mode.
- :class:`DBG_NODEBUG`
- :class:`DBG_DRAWWIREFRAME`
- :class:`DBG_DRAWAABB`
@@ -157,7 +169,6 @@ Physics Constraints (bge.constraints)
- :class:`DBG_DRAWCONSTRAINTLIMITS`
- :class:`DBG_FASTWIREFRAME`
:arg mode: The new debug mode.
:type mode: int
.. function:: setGravity(x, y, z)
@@ -176,7 +187,8 @@ Physics Constraints (bge.constraints)
.. function:: setLinearAirDamping(damping)
.. note::
Not implemented.
Not implemented
Sets the linear air damping for rigidbodies.
@@ -236,144 +248,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:

View File

@@ -218,6 +218,8 @@ When the texture object is deleted, the new texture is deleted and the old textu
background color
:type: int or float list [r, g, b, a] in [0.0, 255.0]
.. attribute:: capsize
size of render area
@@ -315,6 +317,8 @@ When the texture object is deleted, the new texture is deleted and the old textu
background color
:type: int or float list [r, g, b, a] in [0.0, 255.0]
.. attribute:: capsize
size of render area

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`
@@ -38,35 +93,37 @@ base class --- :class:`PyObjectPlus`
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

@@ -28,7 +28,8 @@ base class --- :class:`PyObjectPlus`
* Lowerlimit > Upperlimit -> axis is free
* Lowerlimit < Upperlimit -> axis it limited in that range
PHY_LINEHINGE_CONSTRAINT = 2 or PHY_ANGULAR_CONSTRAINT = 3:
For PHY_LINEHINGE_CONSTRAINT = 2 or PHY_ANGULAR_CONSTRAINT = 3:
axis = 3 is a constraint limit, with low/high limit value
* 3: X axis angle
@@ -37,7 +38,8 @@ base class --- :class:`PyObjectPlus`
:arg value1 (max): Set the maximum limit of the axis
:type value1: float
PHY_CONE_TWIST_CONSTRAINT = 3:
For PHY_CONE_TWIST_CONSTRAINT = 4:
axis = 3..5 are constraint limits, high limit values
* 3: X axis angle
* 4: Y axis angle
@@ -48,7 +50,8 @@ base class --- :class:`PyObjectPlus`
:arg value1 (max): Set the maximum limit of the axis
:type value1: float
PHY_GENERIC_6DOF_CONSTRAINT = 12:
For PHY_GENERIC_6DOF_CONSTRAINT = 12:
axis = 0..2 are constraint limits, with low/high limit value
* 0: X axis position
* 1: Y axis position

View File

@@ -7,6 +7,26 @@ base class --- :class:`KX_GameObject`
.. class:: KX_FontObject(KX_GameObject)
TODO.
A Font object.
.. code-block:: python
# Display a message about the exit key using a Font object.
import bge
co = bge.logic.getCurrentController()
font = co.owner
exit_key = bge.events.EventToString(bge.logic.getExitKey())
if exit_key.endswith("KEY"):
exit_key = exit_key[:-3]
font.text = "Press key '%s' to quit the game." % exit_key
.. attribute:: text
The text displayed by this Font object.
:type: string

View File

@@ -139,6 +139,29 @@ base class --- :class:`SCA_IObject`
A value of 0.0 disables this option (rather then 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
the object's inertia vector in local coordinates. Read only.

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

@@ -25,12 +25,6 @@ base class --- :class:`SCA_IObject`
:type: Vector((u, v))
.. attribute:: uvs
A list of all the texture coordinates of the vertex.
:type: list of Vector((u, v))
.. attribute:: normal
The normal of the vertex.
@@ -126,24 +120,18 @@ base class --- :class:`SCA_IObject`
:arg pos: the new position for this vertex in local coordinates.
.. method:: getUV(index=0)
.. method:: getUV()
Gets the UV (texture) coordinates of this vertex.
:arg index: the UV (texture) channel (optional).
:type index: integer
:return: this vertexes UV (texture) coordinates.
:rtype: Vector((u, v))
.. method:: setUV(uv, index=0)
.. method:: setUV(uv)
Sets the UV (texture) coordinates of this vertex.
:arg uv: the UV (texture) coordinate of this vertex.
:type uv: Vector((u, v))
:arg index: the UV (texture) channel (optional).
:type index: integer
:type: Vector((u, v))
.. method:: getUV2()
@@ -152,16 +140,14 @@ base class --- :class:`SCA_IObject`
:return: this vertexes UV (texture) coordinates.
:rtype: Vector((u, v))
.. deprecated:: use :meth:`getUV`
.. method:: setUV2(uv)
.. method:: setUV2(uv, unit)
Sets the 2nd UV (texture) coordinates of this vertex.
:arg uv: the 2nd (texture) UV coordinate of this vertex.
:type uv: Vector((u, v))
:type: Vector((u, v))
.. deprecated:: use :meth:`setUV`
:arg unit: optional argument, FLAT==1, SECOND_UV==2, defaults to SECOND_UV
:arg unit: integer
.. method:: getRGBA()

View File

@@ -16,11 +16,7 @@ base class --- :class:`PyObjectPlus`
sce = bge.logic.getCurrentScene()
sce.world.mist_color = [1.0, 0.0, 0.0]
*********
Constants
*********
sce.world.mistColor = [1.0, 0.0, 0.0]
.. data:: KX_MIST_QUADRATIC
@@ -34,53 +30,49 @@ Constants
Type of inverse quadratic attenuation used to fade mist.
**********
Attributes
**********
.. attribute:: mist_enable
.. attribute:: mistEnable
Return the state of the mist.
:type: bool
.. attribute:: mist_start
.. attribute:: mistStart
The mist start point.
:type: float
.. attribute:: mist_distance
.. attribute:: mistDistance
The mist distance fom the start point to reach 100% mist.
:type: float
.. attribute:: mist_intensity
.. attribute:: mistIntensity
The mist intensity.
:type: float
.. attribute:: mist_type
.. attribute:: mistType
The type of mist - must be KX_MIST_QUADRATIC, KX_MIST_LINEAR or KX_MIST_INV_QUADRATIC
.. attribute:: mist_color
.. attribute:: mistColor
The color of the mist. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
Mist and background color sould always set to the same color.
:type: :class:`mathutils.Vector`
.. attribute:: background_color
.. attribute:: backgroundColor
The color of the background. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
Mist and background color sould always set to the same color.
:type: :class:`mathutils.Vector`
.. attribute:: ambient_color
.. attribute:: ambientColor
The color of the ambient light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].

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

@@ -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 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.
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 then 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 then 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",
@@ -257,6 +258,7 @@ else:
"bpy.props",
"bpy.types", # supports filtering
"bpy.utils",
"bpy.utils.previews",
"bpy_extras",
"gpu",
"mathutils",
@@ -454,9 +456,11 @@ ClassMethodDescriptorType = type(dict.__dict__['fromkeys'])
MethodDescriptorType = type(dict.get)
GetSetDescriptorType = type(int.real)
StaticMethodType = type(staticmethod(lambda: None))
from types import (MemberDescriptorType,
MethodType,
)
from types import (
MemberDescriptorType,
MethodType,
FunctionType,
)
_BPY_STRUCT_FAKE = "bpy_struct"
_BPY_PROP_COLLECTION_FAKE = "bpy_prop_collection"
@@ -633,19 +637,26 @@ def pyfunc2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_cla
func_type = "function"
# ther rest are class methods
elif arg_str.startswith("(self, "):
arg_str = "(" + arg_str[7:]
elif arg_str.startswith("(self, ") or arg_str == "(self)":
arg_str = "()" if (arg_str == "(self)") else ("(" + arg_str[7:])
func_type = "method"
elif arg_str.startswith("(cls, "):
arg_str = "(" + arg_str[6:]
arg_str = "()" if (arg_str == "(cls)") else ("(" + arg_str[6:])
func_type = "classmethod"
else:
func_type = "staticmethod"
fw(ident + ".. %s:: %s%s\n\n" % (func_type, identifier, arg_str))
if py_func.__doc__:
write_indented_lines(ident + " ", fw, py_func.__doc__)
doc = py_func.__doc__
if (not doc) or (not doc.startswith(".. %s:: " % func_type)):
fw(ident + ".. %s:: %s%s\n\n" % (func_type, identifier, arg_str))
ident_temp = ident + " "
else:
ident_temp = ident
if doc:
write_indented_lines(ident_temp, fw, doc)
fw("\n")
del doc, ident_temp
if is_class:
write_example_ref(ident + " ", fw, module_name + "." + type_name + "." + identifier)
@@ -861,7 +872,7 @@ def pymodule2sphinx(basepath, module_name, module, title):
module_dir_value_type.sort(key=lambda triple: str(triple[2]))
for attribute, value, value_type in module_dir_value_type:
if value_type == types.FunctionType:
if value_type == FunctionType:
pyfunc2sphinx("", fw, module_name, None, attribute, value, is_class=False)
elif value_type in {types.BuiltinMethodType, types.BuiltinFunctionType}: # both the same at the moment but to be future proof
# note: can't get args from these, so dump the string as is
@@ -916,19 +927,24 @@ def pymodule2sphinx(basepath, module_name, module, title):
fw(value.__doc__)
else:
fw(".. class:: %s\n\n" % type_name)
write_indented_lines(" ", fw, value.__doc__, False)
write_indented_lines(" ", fw, value.__doc__, True)
else:
fw(".. class:: %s\n\n" % type_name)
fw("\n")
write_example_ref(" ", fw, module_name + "." + type_name)
descr_items = [(key, descr) for key, descr in sorted(value.__dict__.items()) if not key.startswith("__")]
descr_items = [(key, descr) for key, descr in sorted(value.__dict__.items()) if not key.startswith("_")]
for key, descr in descr_items:
if type(descr) == ClassMethodDescriptorType:
py_descr2sphinx(" ", fw, descr, module_name, type_name, key)
# needed for pure python classes
for key, descr in descr_items:
if type(descr) == FunctionType:
pyfunc2sphinx(" ", fw, module_name, type_name, key, descr, is_class=True)
for key, descr in descr_items:
if type(descr) == MethodDescriptorType:
py_descr2sphinx(" ", fw, descr, module_name, type_name, key)
@@ -1239,6 +1255,7 @@ def pyrna2sphinx(basepath):
fw("\n\n")
subclass_ids = [s.identifier for s in structs.values() if s.base is struct if not rna_info.rna_id_ignore(s.identifier)]
subclass_ids.sort()
if subclass_ids:
fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in subclass_ids) + "\n\n")
@@ -1607,6 +1624,7 @@ def write_rst_contents(basepath):
# py modules
"bpy.utils",
"bpy.utils.previews",
"bpy.path",
"bpy.app",
"bpy.app.handlers",
@@ -1652,6 +1670,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))
@@ -1808,6 +1827,7 @@ def copy_handwritten_rsts(basepath):
"bge.texture",
"bge.events",
"bge.constraints",
"bge.app",
"bgl", # "Blender OpenGl wrapper"
"gpu", # "GPU Shader Module"

View File

@@ -171,6 +171,7 @@ extern "C" {
/* Convex Hull */
PL_DECLARE_HANDLE(plConvexHull);
plConvexHull plConvexHullCompute(float (*coords)[3], int count);
void plConvexHullDelete(plConvexHull hull);
int plConvexHullNumVertices(plConvexHull hull);
int plConvexHullNumFaces(plConvexHull hull);
void plConvexHullGetVertex(plConvexHull hull, int n, float coords[3], int *original_index);

View File

@@ -15,7 +15,7 @@ subject to the following restrictions:
/**
* @mainpage Bullet Documentation
* @page Bullet Documentation
*
* @section intro_sec Introduction
* Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ).

View File

@@ -413,6 +413,12 @@ plConvexHull plConvexHullCompute(float (*coords)[3], int count)
return reinterpret_cast<plConvexHull>(computer);
}
void plConvexHullDelete(plConvexHull hull)
{
btConvexHullComputer *computer(reinterpret_cast< btConvexHullComputer* >(hull));
delete computer;
}
int plConvexHullNumVertices(plConvexHull hull)
{
btConvexHullComputer *computer(reinterpret_cast< btConvexHullComputer* >(hull));

View File

@@ -2751,6 +2751,30 @@ CLEW_FUN_EXPORT PFNCLGETGLCONTEXTINFOKHR __clewGetGLContextInfoKH
#endif
#define clGetGLContextInfoKHR CLEW_GET_FUN(__clewGetGLContextInfoKHR )
/* cl_ext */
/******************************************
* cl_nv_device_attribute_query extension *
******************************************/
/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
#define CL_DEVICE_WARP_SIZE_NV 0x4003
#define CL_DEVICE_GPU_OVERLAP_NV 0x4004
#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
/*********************************
* cl_amd_device_attribute_query *
*********************************/
#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
/*********************************
* cl_arm_printf extension
*********************************/
#define CL_PRINTF_CALLBACK_ARM 0x40B0
#define CL_PRINTF_BUFFERSIZE_ARM 0x40B1
#define CLEW_SUCCESS 0 //!< Success error code
#define CLEW_ERROR_OPEN_FAILED -1 //!< Error code for failing to open the dynamic library

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,6 +77,27 @@
# define LG_SIZEOF_INT 2
#endif
/************************/
/* Function prototypes. */
#if (LG_SIZEOF_PTR == 3 || LG_SIZEOF_INT == 3)
ATOMIC_INLINE uint64_t atomic_add_uint64(uint64_t *p, uint64_t x);
ATOMIC_INLINE uint64_t atomic_sub_uint64(uint64_t *p, uint64_t x);
ATOMIC_INLINE uint64_t atomic_cas_uint64(uint64_t *v, uint64_t old, uint64_t _new);
#endif
ATOMIC_INLINE uint32_t atomic_add_uint32(uint32_t *p, uint32_t x);
ATOMIC_INLINE uint32_t atomic_sub_uint32(uint32_t *p, uint32_t x);
ATOMIC_INLINE uint32_t atomic_cas_uint32(uint32_t *v, uint32_t old, uint32_t _new);
ATOMIC_INLINE size_t atomic_add_z(size_t *p, size_t x);
ATOMIC_INLINE size_t atomic_sub_z(size_t *p, size_t x);
ATOMIC_INLINE size_t atomic_cas_z(size_t *v, size_t old, size_t _new);
ATOMIC_INLINE unsigned atomic_add_u(unsigned *p, unsigned x);
ATOMIC_INLINE unsigned atomic_sub_u(unsigned *p, unsigned x);
ATOMIC_INLINE unsigned atomic_cas_u(unsigned *v, unsigned old, unsigned _new);
/******************************************************************************/
/* 64-bit operations. */
#if (LG_SIZEOF_PTR == 3 || LG_SIZEOF_INT == 3)

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

@@ -34,12 +34,8 @@ cycles.Depends('../../source/blender/makesrna/intern/RNA_blender_cpp.h', 'makesr
sources = cycles.Glob('bvh/*.cpp') + cycles.Glob('device/*.cpp') + cycles.Glob('kernel/*.cpp') + cycles.Glob('render/*.cpp') + cycles.Glob('subd/*.cpp') + cycles.Glob('util/*.cpp') + cycles.Glob('blender/*.cpp')
sources.append(path.join('kernel', 'kernels', 'cpu', 'kernel.cpp'))
sources.remove(path.join('util', 'util_view.cpp'))
sources.remove(path.join('kernel', 'kernel_sse2.cpp'))
sources.remove(path.join('kernel', 'kernel_sse3.cpp'))
sources.remove(path.join('kernel', 'kernel_sse41.cpp'))
sources.remove(path.join('kernel', 'kernel_avx.cpp'))
sources.remove(path.join('kernel', 'kernel_avx2.cpp'))
incs = []
defs = []
@@ -146,7 +142,7 @@ for kernel_type in kernel_flags.keys():
defs.append('WITH_KERNEL_' + kernel_type.upper())
for kernel_type in kernel_flags.keys():
kernel_source = path.join('kernel', 'kernel_' + kernel_type + '.cpp')
kernel_source = path.join('kernel', 'kernels', 'cpu', 'kernel_' + kernel_type + '.cpp')
kernel_cxxflags = Split(env['CXXFLAGS'])
kernel_cxxflags.append(kernel_flags[kernel_type].split())
kernel_defs = defs[:]

View File

@@ -21,6 +21,7 @@
#include "device.h"
#include "scene.h"
#include "session.h"
#include "integrator.h"
#include "util_args.h"
#include "util_foreach.h"
@@ -272,6 +273,7 @@ static void keyboard(unsigned char key)
else if(key == 'i')
options.interactive = !(options.interactive);
/* Navigation */
else if(options.interactive && (key == 'w' || key == 'a' || key == 's' || key == 'd')) {
Transform matrix = options.session->scene->camera->matrix;
float3 translate;
@@ -294,6 +296,25 @@ static void keyboard(unsigned char key)
options.session->reset(session_buffer_params(), options.session_params.samples);
}
/* Set Max Bounces */
else if(options.interactive && (key == '0' || key == '1' || key == '2' || key == '3')) {
int bounce;
switch(key) {
case '0': bounce = 0; break;
case '1': bounce = 1; break;
case '2': bounce = 2; break;
case '3': bounce = 3; break;
default: bounce = 0; break;
}
options.session->scene->integrator->max_bounce = bounce;
/* Update and Reset */
options.session->scene->integrator->need_update = true;
options.session->reset(session_buffer_params(), options.session_params.samples);
}
}
#endif
@@ -377,7 +398,8 @@ static void options_parse(int argc, const char **argv)
printf("Devices:\n");
foreach(DeviceInfo& info, devices) {
printf(" %s%s\n",
printf(" %-10s%s%s\n",
Device::string_from_type(info.type).c_str(),
info.description.c_str(),
(info.display_device)? " (display)": "");
}

View File

@@ -20,6 +20,7 @@
#include <algorithm>
#include <iterator>
#include "background.h"
#include "camera.h"
#include "film.h"
#include "graph.h"
@@ -391,6 +392,10 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
for(pugi::xml_node node = graph_node.first_child(); node; node = node.next_sibling()) {
ShaderNode *snode = NULL;
/* ToDo: Add missing nodes
* RGBCurvesNode, VectorCurvesNode, RGBRampNode and ConvertNode (RGB -> BW).
*/
if(string_iequals(node.name(), "image_texture")) {
ImageTextureNode *img = new ImageTextureNode();
@@ -401,6 +406,8 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
xml_read_enum(&img->projection, ImageTextureNode::projection_enum, node, "projection");
xml_read_float(&img->projection_blend, node, "projection_blend");
/* ToDo: Interpolation */
snode = img;
}
else if(string_iequals(node.name(), "environment_texture")) {
@@ -513,6 +520,11 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
xml_read_float3(&normal->direction, node, "direction");
snode = normal;
}
else if(string_iequals(node.name(), "bump")) {
BumpNode *bump = new BumpNode();
xml_read_bool(&bump->invert, node, "invert");
snode = bump;
}
else if(string_iequals(node.name(), "mapping")) {
snode = new MappingNode();
}
@@ -567,6 +579,9 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
else if(string_iequals(node.name(), "background")) {
snode = new BackgroundNode();
}
else if(string_iequals(node.name(), "holdout")) {
snode = new HoldoutNode();
}
else if(string_iequals(node.name(), "absorption_volume")) {
snode = new AbsorptionVolumeNode();
}
@@ -575,7 +590,14 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
}
else if(string_iequals(node.name(), "subsurface_scattering")) {
SubsurfaceScatteringNode *sss = new SubsurfaceScatteringNode();
//xml_read_enum(&sss->falloff, SubsurfaceScatteringNode::falloff_enum, node, "falloff");
string falloff;
xml_read_string(&falloff, node, "falloff");
if(falloff == "cubic")
sss->closure = CLOSURE_BSSRDF_CUBIC_ID;
else
sss->closure = CLOSURE_BSSRDF_GAUSSIAN_ID;
snode = sss;
}
else if(string_iequals(node.name(), "geometry")) {
@@ -619,6 +641,7 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
snode = new InvertNode();
}
else if(string_iequals(node.name(), "mix")) {
/* ToDo: Tag Mix case for optimization */
MixNode *mix = new MixNode();
xml_read_enum(&mix->type, MixNode::type_enum, node, "type");
xml_read_bool(&mix->use_clamp, node, "use_clamp");
@@ -828,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");
@@ -874,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");
@@ -945,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 */
@@ -1034,13 +1092,28 @@ static void xml_read_light(const XMLReadState& state, pugi::xml_node node)
xml_read_float(&light->sizev, node, "sizev");
xml_read_float3(&light->axisu, node, "axisu");
xml_read_float3(&light->axisv, node, "axisv");
/* Portal? (Area light only) */
xml_read_bool(&light->is_portal, node, "is_portal");
/* Generic */
xml_read_float(&light->size, node, "size");
xml_read_float3(&light->dir, node, "dir");
xml_read_float3(&light->co, node, "P");
light->co = transform_point(&state.tfm, light->co);
/* Settings */
xml_read_bool(&light->cast_shadow, node, "cast_shadow");
xml_read_bool(&light->use_mis, node, "use_mis");
xml_read_int(&light->samples, node, "samples");
xml_read_int(&light->max_bounces, node, "max_bounces");
/* Ray Visibility */
xml_read_bool(&light->use_diffuse, node, "use_diffuse");
xml_read_bool(&light->use_glossy, node, "use_glossy");
xml_read_bool(&light->use_transmission, node, "use_transmission");
xml_read_bool(&light->use_scatter, node, "use_scatter");
state.scene->lights.push_back(light);
}
@@ -1184,7 +1257,8 @@ static void xml_read_include(const XMLReadState& state, const string& src)
XMLReadState substate = state;
substate.base = path_dirname(path);
xml_read_scene(substate, doc);
pugi::xml_node cycles = doc.child("cycles");
xml_read_scene(substate, cycles);
}
else {
fprintf(stderr, "%s read error: %s\n", src.c_str(), parse_result.description());

View File

@@ -30,8 +30,10 @@ bl_info = {
import bpy
from . import engine
from . import version_update
from . import (
engine,
version_update,
)
class CyclesRender(bpy.types.RenderEngine):

View File

@@ -394,6 +394,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default=0,
)
cls.use_animated_seed = BoolProperty(
name="Use Animated Seed",
description="Use different seed values (and hence noise patterns) at different frames",
default=False,
)
cls.sample_clamp_direct = FloatProperty(
name="Clamp Direct",
description="If non-zero, the maximum value for a direct sample, "

View File

@@ -18,7 +18,11 @@
import bpy
from bpy.types import Panel, Menu, Operator, UIList
from bpy.types import (
Panel,
Menu,
Operator,
)
class CYCLES_MT_sampling_presets(Menu):
@@ -55,6 +59,7 @@ def use_cpu(context):
return (device_type == 'NONE' or cscene.device == 'CPU')
def use_branched_path(context):
cscene = context.scene.cycles
device_type = context.user_preferences.system.compute_device_type
@@ -135,7 +140,11 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
col = split.column()
sub = col.column(align=True)
sub.label("Settings:")
sub.prop(cscene, "seed")
seed_sub = sub.row(align=True)
seed_sub.prop(cscene, "seed")
seed_sub.prop(cscene, "use_animated_seed", text="", icon="TIME")
sub.prop(cscene, "sample_clamp_direct")
sub.prop(cscene, "sample_clamp_indirect")
@@ -422,6 +431,9 @@ 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"
@@ -438,7 +450,6 @@ class CyclesRender_PT_views(CyclesButtonsPanel, Panel):
rd = scene.render
rv = rd.views.active
layout.active = rd.use_multiview
basic_stereo = (rd.views_format == 'STEREO_3D')
@@ -514,12 +525,12 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
sub = col.column(align=True)
sub.label("Viewport:")
subhq = sub.column()
subhq.active = hq_support;
subhq.active = hq_support
subhq.prop(dof_options, "use_high_quality")
sub.prop(dof_options, "fstop")
if dof_options.use_high_quality and hq_support:
sub.prop(dof_options, "blades")
col = split.column()
col.label("Aperture:")
@@ -552,11 +563,16 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
ob = context.object
slot = context.material_slot
space = context.space_data
is_sortable = len(ob.material_slots) > 1
if ob:
rows = 1
if (is_sortable):
rows = 4
row = layout.row()
row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=1)
row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
col = row.column(align=True)
col.operator("object.material_slot_add", icon='ZOOMIN', text="")
@@ -564,6 +580,12 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
if is_sortable:
col.separator()
col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
if ob.mode == 'EDIT':
row = layout.row(align=True)
row.operator("object.material_slot_assign", text="Assign")
@@ -625,7 +647,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
@@ -668,8 +696,8 @@ 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
@@ -714,9 +742,14 @@ def find_node(material, nodetype):
if material and material.node_tree:
ntree = material.node_tree
active_output_node = None
for node in ntree.nodes:
if getattr(node, "type", None) == nodetype:
return node
if getattr(node, "is_active_output", True):
return node
if not active_output_node:
active_output_node = node
return active_output_node
return None

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 */
@@ -365,7 +380,9 @@ 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;
@@ -424,7 +441,7 @@ void BlenderSync::sync_camera_motion(BL::Object b_ob, float motion_time)
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.";

View File

@@ -261,7 +261,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 +344,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;
}

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"
@@ -271,6 +272,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
@@ -439,6 +444,7 @@ void BlenderSession::render()
Pass::add(PASS_COMBINED, passes);
#ifdef WITH_CYCLES_DEBUG
Pass::add(PASS_BVH_TRAVERSAL_STEPS, passes);
/* Pass::add(PASS_RAY_BOUNCES, passes); */
#endif
if(session_params.device.advanced_shading) {
@@ -497,6 +503,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;
@@ -1020,18 +1031,19 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name, void *buil
unsigned char *image_pixels;
image_pixels = image_get_pixels_for_frame(b_image, frame);
size_t num_pixels = ((size_t)width) * height;
if(image_pixels) {
memcpy(pixels, image_pixels, width * height * channels * sizeof(unsigned char));
memcpy(pixels, image_pixels, num_pixels * channels * sizeof(unsigned char));
MEM_freeN(image_pixels);
}
else {
if(channels == 1) {
memset(pixels, 0, width * height * sizeof(unsigned char));
memset(pixels, 0, num_pixels * sizeof(unsigned char));
}
else {
unsigned char *cp = pixels;
for(int i = 0; i < width * height; i++, cp += channels) {
for(size_t i = 0; i < num_pixels; i++, cp += channels) {
cp[0] = 255;
cp[1] = 0;
cp[2] = 255;
@@ -1043,7 +1055,7 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name, void *buil
/* premultiply, byte images are always straight for blender */
unsigned char *cp = pixels;
for(int i = 0; i < width * height; i++, cp += channels) {
for(size_t i = 0; i < num_pixels; i++, cp += channels) {
cp[0] = (cp[0] * cp[3]) >> 8;
cp[1] = (cp[1] * cp[3]) >> 8;
cp[2] = (cp[2] * cp[3]) >> 8;
@@ -1072,18 +1084,19 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
float *image_pixels;
image_pixels = image_get_float_pixels_for_frame(b_image, frame);
size_t num_pixels = ((size_t)width) * height;
if(image_pixels) {
memcpy(pixels, image_pixels, width * height * channels * sizeof(float));
memcpy(pixels, image_pixels, num_pixels * channels * sizeof(float));
MEM_freeN(image_pixels);
}
else {
if(channels == 1) {
memset(pixels, 0, width * height * sizeof(float));
memset(pixels, 0, num_pixels * sizeof(float));
}
else {
float *fp = pixels;
for(int i = 0; i < width * height; i++, fp += channels) {
for(int i = 0; i < num_pixels; i++, fp += channels) {
fp[0] = 1.0f;
fp[1] = 0.0f;
fp[2] = 1.0f;
@@ -1109,11 +1122,12 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
int width = resolution.x * amplify;
int height = resolution.y * amplify;
int depth = resolution.z * amplify;
size_t num_pixels = ((size_t)width) * height * depth;
if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY)) {
SmokeDomainSettings_density_grid_get_length(&b_domain.ptr, &length);
if(length == width*height*depth) {
if(length == num_pixels) {
SmokeDomainSettings_density_grid_get(&b_domain.ptr, pixels);
return true;
}
@@ -1123,7 +1137,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
* as 1500..3000 K with the first part faded to zero density */
SmokeDomainSettings_flame_grid_get_length(&b_domain.ptr, &length);
if(length == width*height*depth) {
if(length == num_pixels) {
SmokeDomainSettings_flame_grid_get(&b_domain.ptr, pixels);
return true;
}
@@ -1132,7 +1146,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
/* the RGB is "premultiplied" by density for better interpolation results */
SmokeDomainSettings_color_grid_get_length(&b_domain.ptr, &length);
if(length == width*height*depth*4) {
if(length == num_pixels*4) {
SmokeDomainSettings_color_grid_get(&b_domain.ptr, pixels);
return true;
}

View File

@@ -897,7 +897,7 @@ static void add_nodes(Scene *scene,
output_map[b_output->ptr.data] = proxy->outputs[0];
}
if (b_group_ntree) {
if(b_group_ntree) {
add_nodes(scene,
b_engine,
b_data,

View File

@@ -36,6 +36,7 @@
#include "util_debug.h"
#include "util_foreach.h"
#include "util_opengl.h"
#include "util_hash.h"
CCL_NAMESPACE_BEGIN
@@ -195,6 +196,9 @@ void BlenderSync::sync_integrator()
integrator->filter_glossy = get_float(cscene, "blur_glossy");
integrator->seed = get_int(cscene, "seed");
if(get_boolean(cscene, "use_animated_seed"))
integrator->seed = hash_int_2d(b_scene.frame_current(), get_int(cscene, "seed"));
integrator->sampling_pattern = (SamplingPattern)RNA_enum_get(&cscene, "sampling_pattern");
integrator->layer_flag = render_layer.layer;

View File

@@ -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

@@ -33,6 +33,13 @@ CCL_NAMESPACE_BEGIN
/* Device */
Device::~Device()
{
if(!background && vertex_buffer != 0) {
glDeleteBuffers(1, &vertex_buffer);
}
}
void Device::pixels_alloc(device_memory& mem)
{
mem_alloc(mem, MEM_READ_WRITE);
@@ -51,7 +58,7 @@ void Device::pixels_free(device_memory& mem)
mem_free(mem);
}
void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int width, int height, bool transparent,
void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dx, int dy, int width, int height, bool transparent,
const DeviceDrawParams &draw_params)
{
pixels_copy_from(rgba, y, w, h);
@@ -67,6 +74,9 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
/* for multi devices, this assumes the inefficient method that we allocate
* all pixels on the device even though we only render to a subset */
GLhalf *data_pointer = (GLhalf*)rgba.data_pointer;
float vbuffer[16], *basep;
float *vp = NULL;
data_pointer += 4*y*w;
/* draw half float texture, GLSL shader for display transform assumed to be bound */
@@ -83,23 +93,63 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
draw_params.bind_display_space_shader_cb();
}
glPushMatrix();
glTranslatef(0.0f, (float)dy, 0.0f);
if(GLEW_VERSION_1_5) {
if(!vertex_buffer)
glGenBuffers(1, &vertex_buffer);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex2f((float)width, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex2f((float)width, (float)height);
glTexCoord2f(0.0f, 1.0f);
glVertex2f(0.0f, (float)height);
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
/* invalidate old contents - avoids stalling if buffer is still waiting in queue to be rendered */
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW);
glEnd();
vp = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
glPopMatrix();
basep = NULL;
}
else {
basep = vbuffer;
vp = vbuffer;
}
if(vp) {
/* texture coordinate - vertex pair */
vp[0] = 0.0f;
vp[1] = 0.0f;
vp[2] = dx;
vp[3] = dy;
vp[4] = 1.0f;
vp[5] = 0.0f;
vp[6] = (float)width + dx;
vp[7] = dy;
vp[8] = 1.0f;
vp[9] = 1.0f;
vp[10] = (float)width + dx;
vp[11] = (float)height + dy;
vp[12] = 0.0f;
vp[13] = 1.0f;
vp[14] = dx;
vp[15] = (float)height + dy;
if(vertex_buffer)
glUnmapBuffer(GL_ARRAY_BUFFER);
}
glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), basep);
glVertexPointer(2, GL_FLOAT, 4 * sizeof(float), ((char *)basep) + 2 * sizeof(float));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
if(vertex_buffer) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
if(draw_params.unbind_display_space_shader_cb) {
draw_params.unbind_display_space_shader_cb();
@@ -113,7 +163,7 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
/* fallback for old graphics cards that don't support GLSL, half float,
* and non-power-of-two textures */
glPixelZoom((float)width/(float)w, (float)height/(float)h);
glRasterPos2f(0, dy);
glRasterPos2f(dx, dy);
uint8_t *pixels = (uint8_t*)rgba.data_pointer;
@@ -277,13 +327,10 @@ string Device::device_capabilities()
#endif
#ifdef WITH_OPENCL
/* TODO(sergey): Needs proper usable implementation. */
/*
if(device_opencl_init()) {
capabilities += "\nOpenCL device capabilities:\n";
capabilities += device_opencl_capabilities();
}
*/
#endif
return capabilities;

View File

@@ -92,6 +92,11 @@ public:
*/
int nodes_features;
/* BVH/sampling kernel features. */
bool use_hair;
bool use_object_motion;
bool use_camera_motion;
DeviceRequestedFeatures()
{
/* TODO(sergey): Find more meaningful defaults. */
@@ -99,6 +104,9 @@ public:
max_closure = 0;
max_nodes_group = 0;
nodes_features = 0;
use_hair = false;
use_object_motion = false;
use_camera_motion = false;
}
bool modified(const DeviceRequestedFeatures& requested_features)
@@ -119,13 +127,16 @@ struct DeviceDrawParams {
class Device {
protected:
Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background), info(info_), stats(stats_) {}
Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background), vertex_buffer(0), info(info_), stats(stats_) {}
bool background;
string error_msg;
/* used for real time display */
unsigned int vertex_buffer;
public:
virtual ~Device() {}
virtual ~Device();
/* info */
DeviceInfo info;
@@ -178,7 +189,7 @@ public:
/* opengl drawing */
virtual void draw_pixels(device_memory& mem, int y, int w, int h,
int dy, int width, int height, bool transparent,
int dx, int dy, int width, int height, bool transparent,
const DeviceDrawParams &draw_params);
#ifdef WITH_NETWORK

View File

@@ -266,7 +266,7 @@ public:
printf("CUDA version %d.%d detected, build may succeed but only CUDA 6.5 is officially supported.\n", cuda_version/10, cuda_version%10);
/* compile */
string kernel = path_join(kernel_path, "kernel.cu");
string kernel = path_join(kernel_path, path_join("kernels", path_join("cuda", "kernel.cu")));
string include = kernel_path;
const int machine = system_cpu_bits();
@@ -281,7 +281,7 @@ public:
nvcc, major, minor, machine, kernel.c_str(), cubin.c_str(), include.c_str(), cuda_version);
if(experimental)
command += " -D__KERNEL_CUDA_EXPERIMENTAL__";
command += " -D__KERNEL_EXPERIMENTAL__";
if(getenv("CYCLES_CUDA_EXTRA_CFLAGS")) {
command += string(" ") + getenv("CYCLES_CUDA_EXTRA_CFLAGS");
@@ -880,11 +880,12 @@ public:
}
}
void draw_pixels(device_memory& mem, int y, int w, int h, int dy, int width, int height, bool transparent,
void draw_pixels(device_memory& mem, int y, int w, int h, int dx, int dy, int width, int height, bool transparent,
const DeviceDrawParams &draw_params)
{
if(!background) {
PixelMem pmem = pixel_mem_map[mem.device_pointer];
float *vpointer;
cuda_push_context();
@@ -918,23 +919,52 @@ public:
draw_params.bind_display_space_shader_cb();
}
glPushMatrix();
glTranslatef(0.0f, (float)dy, 0.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f((float)w/(float)pmem.w, 0.0f);
glVertex2f((float)width, 0.0f);
glTexCoord2f((float)w/(float)pmem.w, (float)h/(float)pmem.h);
glVertex2f((float)width, (float)height);
glTexCoord2f(0.0f, (float)h/(float)pmem.h);
glVertex2f(0.0f, (float)height);
if(!vertex_buffer)
glGenBuffers(1, &vertex_buffer);
glEnd();
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
/* invalidate old contents - avoids stalling if buffer is still waiting in queue to be rendered */
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW);
glPopMatrix();
vpointer = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
if(vpointer) {
/* texture coordinate - vertex pair */
vpointer[0] = 0.0f;
vpointer[1] = 0.0f;
vpointer[2] = dx;
vpointer[3] = dy;
vpointer[4] = (float)w/(float)pmem.w;
vpointer[5] = 0.0f;
vpointer[6] = (float)width + dx;
vpointer[7] = dy;
vpointer[8] = (float)w/(float)pmem.w;
vpointer[9] = (float)h/(float)pmem.h;
vpointer[10] = (float)width + dx;
vpointer[11] = (float)height + dy;
vpointer[12] = 0.0f;
vpointer[13] = (float)h/(float)pmem.h;
vpointer[14] = dx;
vpointer[15] = (float)height + dy;
glUnmapBuffer(GL_ARRAY_BUFFER);
}
glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), 0);
glVertexPointer(2, GL_FLOAT, 4 * sizeof(float), (char *)NULL + 2 * sizeof(float));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
if(draw_params.unbind_display_space_shader_cb) {
draw_params.unbind_display_space_shader_cb();
@@ -951,7 +981,7 @@ public:
return;
}
Device::draw_pixels(mem, y, w, h, dy, width, height, transparent, draw_params);
Device::draw_pixels(mem, y, w, h, dx, dy, width, height, transparent, draw_params);
}
void thread_run(DeviceTask *task)
@@ -1092,14 +1122,20 @@ void device_cuda_info(vector<DeviceInfo>& devices)
}
vector<DeviceInfo> display_devices;
for(int num = 0; num < count; num++) {
char name[256];
int attr;
if(cuDeviceGetName(name, 256, num) != CUDA_SUCCESS)
continue;
int major, minor;
cuDeviceComputeCapability(&major, &minor, num);
if(major < 2) {
continue;
}
DeviceInfo info;
info.type = DEVICE_CUDA;
@@ -1107,8 +1143,6 @@ void device_cuda_info(vector<DeviceInfo>& devices)
info.id = string_printf("CUDA_%d", num);
info.num = num;
int major, minor;
cuDeviceComputeCapability(&major, &minor, num);
info.advanced_shading = (major >= 2);
info.extended_images = (major >= 3);
info.pack_images = false;
@@ -1133,7 +1167,7 @@ string device_cuda_capabilities(void)
if(result != CUDA_ERROR_NO_DEVICE) {
return string("Error initializing CUDA: ") + cuewErrorString(result);
}
return "No CUDA device found";
return "No CUDA device found\n";
}
int count;

View File

@@ -236,7 +236,7 @@ public:
mem.device_pointer = tmp;
}
void draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int width, int height, bool transparent,
void draw_pixels(device_memory& rgba, int y, int w, int h, int dx, int dy, int width, int height, bool transparent,
const DeviceDrawParams &draw_params)
{
device_ptr tmp = rgba.device_pointer;
@@ -251,7 +251,7 @@ public:
/* adjust math for w/width */
rgba.device_pointer = sub.ptr_map[tmp];
sub.device->draw_pixels(rgba, sy, w, sh, sdy, width, sheight, transparent, draw_params);
sub.device->draw_pixels(rgba, sy, w, sh, dx, sdy, width, sheight, transparent, draw_params);
i++;
}

View File

@@ -19,6 +19,7 @@
#include "device_network.h"
#include "util_foreach.h"
#include "util_logging.h"
#if defined(WITH_NETWORK)

File diff suppressed because it is too large Load Diff

View File

@@ -12,20 +12,20 @@ set(INC_SYS
)
set(SRC
kernel.cpp
kernel.cl
kernel_data_init.cl
kernel_queue_enqueue.cl
kernel_scene_intersect.cl
kernel_lamp_emission.cl
kernel_background_buffer_update.cl
kernel_shader_eval.cl
kernel_holdout_emission_blurring_pathtermination_ao.cl
kernel_direct_lighting.cl
kernel_shadow_blocked.cl
kernel_next_iteration_setup.cl
kernel_sum_all_radiance.cl
kernel.cu
kernels/cpu/kernel.cpp
kernels/opencl/kernel.cl
kernels/opencl/kernel_data_init.cl
kernels/opencl/kernel_queue_enqueue.cl
kernels/opencl/kernel_scene_intersect.cl
kernels/opencl/kernel_lamp_emission.cl
kernels/opencl/kernel_background_buffer_update.cl
kernels/opencl/kernel_shader_eval.cl
kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl
kernels/opencl/kernel_direct_lighting.cl
kernels/opencl/kernel_shadow_blocked.cl
kernels/opencl/kernel_next_iteration_setup.cl
kernels/opencl/kernel_sum_all_radiance.cl
kernels/cuda/kernel.cu
)
set(SRC_HEADERS
@@ -47,6 +47,7 @@ set(SRC_HEADERS
kernel_montecarlo.h
kernel_passes.h
kernel_path.h
kernel_path_branched.h
kernel_path_common.h
kernel_path_state.h
kernel_path_surface.h
@@ -57,7 +58,6 @@ set(SRC_HEADERS
kernel_shader.h
kernel_shaderdata_vars.h
kernel_shadow.h
kernel_split.h
kernel_subsurface.h
kernel_textures.h
kernel_types.h
@@ -154,6 +154,7 @@ set(SRC_GEOM_HEADERS
)
set(SRC_UTIL_HEADERS
../util/util_atomic.h
../util/util_color.h
../util/util_half.h
../util/util_math.h
@@ -161,6 +162,21 @@ set(SRC_UTIL_HEADERS
../util/util_transform.h
../util/util_types.h
)
set(SRC_SPLIT_HEADERS
split/kernel_background_buffer_update.h
split/kernel_data_init.h
split/kernel_direct_lighting.h
split/kernel_holdout_emission_blurring_pathtermination_ao.h
split/kernel_lamp_emission.h
split/kernel_next_iteration_setup.h
split/kernel_scene_intersect.h
split/kernel_shader_eval.h
split/kernel_shadow_blocked.h
split/kernel_split_common.h
split/kernel_sum_all_radiance.h
)
# CUDA module
if(WITH_CYCLES_CUDA_BINARIES)
@@ -186,12 +202,12 @@ if(WITH_CYCLES_CUDA_BINARIES)
endif()
# build for each arch
set(cuda_sources kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_GEOM_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_UTIL_HEADERS})
set(cuda_sources kernels/cuda/kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_GEOM_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_UTIL_HEADERS})
set(cuda_cubins)
macro(CYCLES_CUDA_KERNEL_ADD arch experimental)
if(${experimental})
set(cuda_extra_flags "-D__KERNEL_CUDA_EXPERIMENTAL__")
set(cuda_extra_flags "-D__KERNEL_EXPERIMENTAL__")
set(cuda_cubin kernel_experimental_${arch}.cubin)
else()
set(cuda_extra_flags "")
@@ -212,7 +228,7 @@ if(WITH_CYCLES_CUDA_BINARIES)
COMMAND ${CUDA_NVCC_EXECUTABLE}
-arch=${arch}
-m${CUDA_BITS}
--cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu
--cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernels/cuda/kernel.cu
-o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin}
--ptxas-options="-v"
${cuda_arch_flags}
@@ -260,28 +276,28 @@ include_directories(SYSTEM ${INC_SYS})
if(CXX_HAS_SSE)
list(APPEND SRC
kernel_sse2.cpp
kernel_sse3.cpp
kernel_sse41.cpp
kernels/cpu/kernel_sse2.cpp
kernels/cpu/kernel_sse3.cpp
kernels/cpu/kernel_sse41.cpp
)
set_source_files_properties(kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
set_source_files_properties(kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
set_source_files_properties(kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
set_source_files_properties(kernels/cpu/kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
set_source_files_properties(kernels/cpu/kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
set_source_files_properties(kernels/cpu/kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
endif()
if(CXX_HAS_AVX)
list(APPEND SRC
kernel_avx.cpp
kernels/cpu/kernel_avx.cpp
)
set_source_files_properties(kernel_avx.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX_KERNEL_FLAGS}")
set_source_files_properties(kernels/cpu/kernel_avx.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX_KERNEL_FLAGS}")
endif()
if(CXX_HAS_AVX2)
list(APPEND SRC
kernel_avx2.cpp
kernels/cpu/kernel_avx2.cpp
)
set_source_files_properties(kernel_avx2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}")
set_source_files_properties(kernels/cpu/kernel_avx2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}")
endif()
add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS} ${SRC_GEOM_HEADERS})
@@ -300,22 +316,23 @@ endif()
#add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${KERNEL_PREPROCESSED})
#delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${KERNEL_PREPROCESSED}" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_data_init.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_queue_enqueue.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_scene_intersect.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_lamp_emission.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_background_buffer_update.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_shader_eval.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_holdout_emission_blurring_pathtermination_ao.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_direct_lighting.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_shadow_blocked.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_next_iteration_setup.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_sum_all_radiance.cl" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cu" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_data_init.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_queue_enqueue.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_scene_intersect.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_lamp_emission.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_background_buffer_update.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_shader_eval.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_direct_lighting.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_shadow_blocked.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_next_iteration_setup.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_sum_all_radiance.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/cuda/kernel.cu" ${CYCLES_INSTALL_PATH}/kernel/kernels/cuda)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_CLOSURE_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/closure)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SVM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/svm)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_GEOM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/geom)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_UTIL_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SPLIT_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/split)

View File

@@ -57,8 +57,9 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
build_dir = os.path.join(root_build_dir, 'intern/cycles/kernel')
# source directories and files
kernel_file_rel = os.path.join("kernels", "cuda", "kernel.cu")
source_dir = Dir('.').srcnode().path
kernel_file = os.path.join(source_dir, "kernel.cu")
kernel_file = os.path.join(source_dir, kernel_file_rel)
util_dir = os.path.join(source_dir, "../util")
svm_dir = os.path.join(source_dir, "../svm")
geom_dir = os.path.join(source_dir, "../geom")
@@ -83,11 +84,11 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
nvcc_flags += " -D__KERNEL_DEBUG__"
# dependencies
dependencies = ['kernel.cu'] + kernel.Glob('*.h') + kernel.Glob('../util/*.h') + kernel.Glob('svm/*.h') + kernel.Glob('geom/*.h') + kernel.Glob('closure/*.h')
dependencies = [kernel_file_rel] + kernel.Glob('*.h') + kernel.Glob('../util/*.h') + kernel.Glob('svm/*.h') + kernel.Glob('geom/*.h') + kernel.Glob('closure/*.h')
last_cubin_file = None
configs = (("kernel_%s.cubin", ''),
("kernel_experimental_%s.cubin", ' -D__KERNEL_CUDA_EXPERIMENTAL__'))
("kernel_experimental_%s.cubin", ' -D__KERNEL_EXPERIMENTAL__'))
# add command for each cuda architecture
for arch in cuda_archs:
@@ -105,7 +106,7 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
else:
command = "\"%s\" -arch=%s %s \"%s\" -o \"%s\"" % (nvcc, arch, current_flags, kernel_file, cubin_file)
kernel.Command(cubin_file, 'kernel.cu', command)
kernel.Command(cubin_file, kernel_file_rel, command)
kernel.Depends(cubin_file, dependencies)
kernel_binaries.append(cubin_file)

View File

@@ -107,18 +107,9 @@ ccl_device int volume_absorption_setup(ShaderClosure *sc)
ccl_device float3 volume_phase_eval(const ShaderData *sd, const ShaderClosure *sc, float3 omega_in, float *pdf)
{
float3 eval;
kernel_assert(sc->type == CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID);
switch(sc->type) {
case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
eval = volume_henyey_greenstein_eval_phase(sc, sd->I, omega_in, pdf);
break;
default:
eval = make_float3(0.0f, 0.0f, 0.0f);
break;
}
return eval;
return volume_henyey_greenstein_eval_phase(sc, sd->I, omega_in, pdf);
}
ccl_device int volume_phase_sample(const ShaderData *sd, const ShaderClosure *sc, float randu,

View File

@@ -76,6 +76,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
#if defined(__KERNEL_DEBUG__)
isect->num_traversal_steps = 0;
isect->num_traversed_instances = 0;
#endif
#if defined(__KERNEL_SSE2__)
@@ -362,6 +363,10 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
traversalStack[stackPtr] = ENTRYPOINT_SENTINEL;
nodeAddr = kernel_tex_fetch(__object_node, object);
#if defined(__KERNEL_DEBUG__)
isect->num_traversed_instances++;
#endif
}
}
#endif /* FEATURE(BVH_INSTANCING) */

View File

@@ -32,22 +32,22 @@ ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd,
if(dy) *dy = 0.0f;
#endif
return kernel_tex_fetch(__attributes_float, offset + sd->prim);
return kernel_tex_fetch(__attributes_float, offset + ccl_fetch(sd, prim));
}
else if(elem == ATTR_ELEMENT_CURVE_KEY || elem == ATTR_ELEMENT_CURVE_KEY_MOTION) {
float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
int k1 = k0 + 1;
float f0 = kernel_tex_fetch(__attributes_float, offset + k0);
float f1 = kernel_tex_fetch(__attributes_float, offset + k1);
#ifdef __RAY_DIFFERENTIALS__
if(dx) *dx = sd->du.dx*(f1 - f0);
if(dx) *dx = ccl_fetch(sd, du).dx*(f1 - f0);
if(dy) *dy = 0.0f;
#endif
return (1.0f - sd->u)*f0 + sd->u*f1;
return (1.0f - ccl_fetch(sd, u))*f0 + ccl_fetch(sd, u)*f1;
}
else {
#ifdef __RAY_DIFFERENTIALS__
@@ -71,22 +71,22 @@ ccl_device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd
if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
#endif
return float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + sd->prim));
return float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + ccl_fetch(sd, prim)));
}
else if(elem == ATTR_ELEMENT_CURVE_KEY || elem == ATTR_ELEMENT_CURVE_KEY_MOTION) {
float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
int k1 = k0 + 1;
float3 f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + k0));
float3 f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + k1));
#ifdef __RAY_DIFFERENTIALS__
if(dx) *dx = sd->du.dx*(f1 - f0);
if(dx) *dx = ccl_fetch(sd, du).dx*(f1 - f0);
if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
#endif
return (1.0f - sd->u)*f0 + sd->u*f1;
return (1.0f - ccl_fetch(sd, u))*f0 + ccl_fetch(sd, u)*f1;
}
else {
#ifdef __RAY_DIFFERENTIALS__
@@ -104,22 +104,22 @@ ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
{
float r = 0.0f;
if(sd->type & PRIMITIVE_ALL_CURVE) {
float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
int k1 = k0 + 1;
float4 P_curve[2];
if(sd->type & PRIMITIVE_CURVE) {
if(ccl_fetch(sd, type) & PRIMITIVE_CURVE) {
P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
}
else {
motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve);
motion_curve_keys(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), k0, k1, P_curve);
}
r = (P_curve[1].w - P_curve[0].w) * sd->u + P_curve[0].w;
r = (P_curve[1].w - P_curve[0].w) * ccl_fetch(sd, u) + P_curve[0].w;
}
return r*2.0f;
@@ -130,8 +130,8 @@ ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
ccl_device float3 curve_motion_center_location(KernelGlobals *kg, ShaderData *sd)
{
float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
int k1 = k0 + 1;
float4 P_curve[2];
@@ -139,7 +139,7 @@ ccl_device float3 curve_motion_center_location(KernelGlobals *kg, ShaderData *sd
P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
return float4_to_float3(P_curve[1]) * sd->u + float4_to_float3(P_curve[0]) * (1.0f - sd->u);
return float4_to_float3(P_curve[1]) * ccl_fetch(sd, u) + float4_to_float3(P_curve[0]) * (1.0f - ccl_fetch(sd, u));
}
/* Curve tangent normal */
@@ -148,14 +148,14 @@ ccl_device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
{
float3 tgN = make_float3(0.0f,0.0f,0.0f);
if(sd->type & PRIMITIVE_ALL_CURVE) {
if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu,-sd->I) / len_squared(sd->dPdu)));
tgN = -(-ccl_fetch(sd, I) - ccl_fetch(sd, dPdu) * (dot(ccl_fetch(sd, dPdu),-ccl_fetch(sd, I)) / len_squared(ccl_fetch(sd, dPdu))));
tgN = normalize(tgN);
/* need to find suitable scaled gd for corrected normal */
#if 0
tgN = normalize(tgN - gd * sd->dPdu);
tgN = normalize(tgN - gd * ccl_fetch(sd, dPdu));
#endif
}
@@ -890,7 +890,7 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
if(isect->object != OBJECT_NONE) {
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_itfm;
Transform tfm = ccl_fetch(sd, ob_itfm);
#else
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
#endif
@@ -903,7 +903,7 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
int prim = kernel_tex_fetch(__prim_index, isect->prim);
float4 v00 = kernel_tex_fetch(__curves, prim);
int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
int k1 = k0 + 1;
float3 tg;
@@ -914,14 +914,14 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
float4 P_curve[4];
if(sd->type & PRIMITIVE_CURVE) {
if(ccl_fetch(sd, type) & PRIMITIVE_CURVE) {
P_curve[0] = kernel_tex_fetch(__curve_keys, ka);
P_curve[1] = kernel_tex_fetch(__curve_keys, k0);
P_curve[2] = kernel_tex_fetch(__curve_keys, k1);
P_curve[3] = kernel_tex_fetch(__curve_keys, kb);
}
else {
motion_cardinal_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve);
motion_cardinal_curve_keys(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), ka, k0, k1, kb, P_curve);
}
float3 p[4];
@@ -933,43 +933,43 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
P = P + D*t;
#ifdef __UV__
sd->u = isect->u;
sd->v = 0.0f;
ccl_fetch(sd, u) = isect->u;
ccl_fetch(sd, v) = 0.0f;
#endif
tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3]));
if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) {
sd->Ng = normalize(-(D - tg * (dot(tg, D))));
ccl_fetch(sd, Ng) = normalize(-(D - tg * (dot(tg, D))));
}
else {
/* direction from inside to surface of curve */
float3 p_curr = curvepoint(isect->u, p[0], p[1], p[2], p[3]);
sd->Ng = normalize(P - p_curr);
ccl_fetch(sd, Ng) = normalize(P - p_curr);
/* adjustment for changing radius */
float gd = isect->v;
if(gd != 0.0f) {
sd->Ng = sd->Ng - gd * tg;
sd->Ng = normalize(sd->Ng);
ccl_fetch(sd, Ng) = ccl_fetch(sd, Ng) - gd * tg;
ccl_fetch(sd, Ng) = normalize(ccl_fetch(sd, Ng));
}
}
/* todo: sometimes the normal is still so that this is detected as
* backfacing even if cull backfaces is enabled */
sd->N = sd->Ng;
ccl_fetch(sd, N) = ccl_fetch(sd, Ng);
}
else {
float4 P_curve[2];
if(sd->type & PRIMITIVE_CURVE) {
if(ccl_fetch(sd, type) & PRIMITIVE_CURVE) {
P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
}
else {
motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve);
motion_curve_keys(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), k0, k1, P_curve);
}
float l = 1.0f;
@@ -980,39 +980,39 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
float3 dif = P - float4_to_float3(P_curve[0]);
#ifdef __UV__
sd->u = dot(dif,tg)/l;
sd->v = 0.0f;
ccl_fetch(sd, u) = dot(dif,tg)/l;
ccl_fetch(sd, v) = 0.0f;
#endif
if(flag & CURVE_KN_TRUETANGENTGNORMAL) {
sd->Ng = -(D - tg * dot(tg, D));
sd->Ng = normalize(sd->Ng);
ccl_fetch(sd, Ng) = -(D - tg * dot(tg, D));
ccl_fetch(sd, Ng) = normalize(ccl_fetch(sd, Ng));
}
else {
float gd = isect->v;
/* direction from inside to surface of curve */
sd->Ng = (dif - tg * sd->u * l) / (P_curve[0].w + sd->u * l * gd);
ccl_fetch(sd, Ng) = (dif - tg * ccl_fetch(sd, u) * l) / (P_curve[0].w + ccl_fetch(sd, u) * l * gd);
/* adjustment for changing radius */
if(gd != 0.0f) {
sd->Ng = sd->Ng - gd * tg;
sd->Ng = normalize(sd->Ng);
ccl_fetch(sd, Ng) = ccl_fetch(sd, Ng) - gd * tg;
ccl_fetch(sd, Ng) = normalize(ccl_fetch(sd, Ng));
}
}
sd->N = sd->Ng;
ccl_fetch(sd, N) = ccl_fetch(sd, Ng);
}
#ifdef __DPDU__
/* dPdu/dPdv */
sd->dPdu = tg;
sd->dPdv = cross(tg, sd->Ng);
ccl_fetch(sd, dPdu) = tg;
ccl_fetch(sd, dPdv) = cross(tg, ccl_fetch(sd, Ng));
#endif
if(isect->object != OBJECT_NONE) {
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_tfm;
Transform tfm = ccl_fetch(sd, ob_tfm);
#else
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
#endif

View File

@@ -134,7 +134,7 @@ ccl_device_inline float3 motion_triangle_refine(KernelGlobals *kg, ShaderData *s
return P;
}
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_itfm;
Transform tfm = ccl_fetch(sd, ob_itfm);
#else
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
#endif
@@ -161,7 +161,7 @@ ccl_device_inline float3 motion_triangle_refine(KernelGlobals *kg, ShaderData *s
if(isect->object != OBJECT_NONE) {
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_tfm;
Transform tfm = ccl_fetch(sd, ob_tfm);
#else
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
#endif
@@ -187,7 +187,7 @@ ccl_device_inline float3 motion_triangle_refine_subsurface(KernelGlobals *kg, Sh
#ifdef __INTERSECTION_REFINE__
if(isect->object != OBJECT_NONE) {
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_itfm;
Transform tfm = ccl_fetch(sd, ob_itfm);
#else
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
#endif
@@ -213,7 +213,7 @@ ccl_device_inline float3 motion_triangle_refine_subsurface(KernelGlobals *kg, Sh
if(isect->object != OBJECT_NONE) {
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_tfm;
Transform tfm = ccl_fetch(sd, ob_tfm);
#else
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
#endif

View File

@@ -123,7 +123,7 @@ ccl_device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg
ccl_device_inline void object_position_transform(KernelGlobals *kg, const ShaderData *sd, float3 *P)
{
#ifdef __OBJECT_MOTION__
*P = transform_point(&ccl_fetch(sd, ob_tfm), *P);
*P = transform_point_auto(&ccl_fetch(sd, ob_tfm), *P);
#else
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
*P = transform_point(&tfm, *P);
@@ -135,7 +135,7 @@ ccl_device_inline void object_position_transform(KernelGlobals *kg, const Shader
ccl_device_inline void object_inverse_position_transform(KernelGlobals *kg, const ShaderData *sd, float3 *P)
{
#ifdef __OBJECT_MOTION__
*P = transform_point(&ccl_fetch(sd, ob_itfm), *P);
*P = transform_point_auto(&ccl_fetch(sd, ob_itfm), *P);
#else
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
*P = transform_point(&tfm, *P);
@@ -147,7 +147,7 @@ ccl_device_inline void object_inverse_position_transform(KernelGlobals *kg, cons
ccl_device_inline void object_inverse_normal_transform(KernelGlobals *kg, const ShaderData *sd, float3 *N)
{
#ifdef __OBJECT_MOTION__
*N = normalize(transform_direction_transposed(&ccl_fetch(sd, ob_tfm), *N));
*N = normalize(transform_direction_transposed_auto(&ccl_fetch(sd, ob_tfm), *N));
#else
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
*N = normalize(transform_direction_transposed(&tfm, *N));
@@ -159,7 +159,7 @@ ccl_device_inline void object_inverse_normal_transform(KernelGlobals *kg, const
ccl_device_inline void object_normal_transform(KernelGlobals *kg, const ShaderData *sd, float3 *N)
{
#ifdef __OBJECT_MOTION__
*N = normalize(transform_direction_transposed(&ccl_fetch(sd, ob_itfm), *N));
*N = normalize(transform_direction_transposed_auto(&ccl_fetch(sd, ob_itfm), *N));
#else
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
*N = normalize(transform_direction_transposed(&tfm, *N));
@@ -171,7 +171,7 @@ ccl_device_inline void object_normal_transform(KernelGlobals *kg, const ShaderDa
ccl_device_inline void object_dir_transform(KernelGlobals *kg, const ShaderData *sd, float3 *D)
{
#ifdef __OBJECT_MOTION__
*D = transform_direction(&ccl_fetch(sd, ob_tfm), *D);
*D = transform_direction_auto(&ccl_fetch(sd, ob_tfm), *D);
#else
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
*D = transform_direction(&tfm, *D);
@@ -183,7 +183,7 @@ ccl_device_inline void object_dir_transform(KernelGlobals *kg, const ShaderData
ccl_device_inline void object_inverse_dir_transform(KernelGlobals *kg, const ShaderData *sd, float3 *D)
{
#ifdef __OBJECT_MOTION__
*D = transform_direction(&ccl_fetch(sd, ob_itfm), *D);
*D = transform_direction_auto(&ccl_fetch(sd, ob_itfm), *D);
#else
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
*D = transform_direction(&tfm, *D);
@@ -453,7 +453,7 @@ ccl_device_inline void bvh_instance_pop_factor(KernelGlobals *kg, int object, co
#ifdef __OBJECT_MOTION__
/* Transform ray into object space to enter motion blurred object in BVH */
ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, Transform *tfm)
ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, ccl_addr_space float *t, Transform *tfm)
{
Transform itfm;
*tfm = object_fetch_transform_motion_test(kg, object, ray->time, &itfm);
@@ -497,7 +497,7 @@ ccl_device_inline void qbvh_instance_motion_push(KernelGlobals *kg, int object,
/* Transorm ray to exit motion blurred object in BVH */
ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, Transform *tfm)
ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, ccl_addr_space float *t, Transform *tfm)
{
if(*t != FLT_MAX)
*t *= len(transform_direction(tfm, 1.0f/(*idir)));

View File

@@ -80,6 +80,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
#if defined(__KERNEL_DEBUG__)
isect->num_traversal_steps = 0;
isect->num_traversed_instances = 0;
#endif
ssef tnear(0.0f), tfar(ray->t);
@@ -185,6 +186,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
if(traverseChild == 0) {
if(d1 < d0) {
nodeAddr = c1;
nodeDist = d1;
++stackPtr;
kernel_assert(stackPtr < BVH_QSTACK_SIZE);
traversalStack[stackPtr].addr = c0;
@@ -193,6 +195,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
}
else {
nodeAddr = c0;
nodeDist = d0;
++stackPtr;
kernel_assert(stackPtr < BVH_QSTACK_SIZE);
traversalStack[stackPtr].addr = c1;
@@ -377,6 +380,10 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
traversalStack[stackPtr].dist = -FLT_MAX;
nodeAddr = kernel_tex_fetch(__object_node, object);
#if defined(__KERNEL_DEBUG__)
isect->num_traversed_instances++;
#endif
}
}
#endif /* FEATURE(BVH_INSTANCING) */

View File

@@ -95,10 +95,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
do {
/* Traverse internal nodes. */
while(nodeAddr >= 0 && nodeAddr != ENTRYPOINT_SENTINEL) {
#if defined(__KERNEL_DEBUG__)
isect->num_traversal_steps++;
#endif
ssef dist;
int traverseChild = qbvh_node_intersect(kg,
tnear,

View File

@@ -49,16 +49,25 @@ typedef struct IsectPrecalc {
float Sx, Sy, Sz;
} IsectPrecalc;
/* Workaround for CUDA toolkit 6.5.16. */
#if defined(__KERNEL_CPU__) || !defined(__KERNEL_CUDA_EXPERIMENTAL__) || __CUDA_ARCH__ < 500
#if defined(__KERNEL_CUDA__)
# if (defined(i386) || defined(_M_IX86))
# if __CUDA_ARCH__ > 500
ccl_device_noinline
# else
# else /* __CUDA_ARCH__ > 500 */
ccl_device_inline
# endif
#else
# endif /* __CUDA_ARCH__ > 500 */
# else /* (defined(i386) || defined(_M_IX86)) */
# if defined(__KERNEL_EXPERIMENTAL__) && (__CUDA_ARCH__ >= 500)
ccl_device_noinline
#endif
# else
ccl_device_inline
# endif
# endif /* (defined(i386) || defined(_M_IX86)) */
#elif defined(__KERNEL_OPENCL_APPLE__)
ccl_device_noinline
#else /* defined(__KERNEL_OPENCL_APPLE__) */
ccl_device_inline
#endif /* defined(__KERNEL_OPENCL_APPLE__) */
void triangle_intersect_precalc(float3 dir,
IsectPrecalc *isect_precalc)
{
@@ -306,7 +315,7 @@ ccl_device_inline float3 triangle_refine(KernelGlobals *kg,
return P;
}
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_itfm;
Transform tfm = ccl_fetch(sd, ob_itfm);
#else
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
#endif
@@ -332,7 +341,7 @@ ccl_device_inline float3 triangle_refine(KernelGlobals *kg,
if(isect->object != OBJECT_NONE) {
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_tfm;
Transform tfm = ccl_fetch(sd, ob_tfm);
#else
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
#endif
@@ -361,7 +370,7 @@ ccl_device_inline float3 triangle_refine_subsurface(KernelGlobals *kg,
#ifdef __INTERSECTION_REFINE__
if(isect->object != OBJECT_NONE) {
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_itfm;
Transform tfm = ccl_fetch(sd, ob_itfm);
#else
Transform tfm = object_fetch_transform(kg,
isect->object,
@@ -389,7 +398,7 @@ ccl_device_inline float3 triangle_refine_subsurface(KernelGlobals *kg,
if(isect->object != OBJECT_NONE) {
#ifdef __OBJECT_MOTION__
Transform tfm = sd->ob_tfm;
Transform tfm = ccl_fetch(sd, ob_tfm);
#else
Transform tfm = object_fetch_transform(kg,
isect->object,

View File

@@ -341,12 +341,12 @@ ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L)
ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadiance *L)
{
float3 L_sum, L_direct, L_indirect;
float clamp_direct = kernel_data.integrator.sample_clamp_direct;
float clamp_indirect = kernel_data.integrator.sample_clamp_indirect;
float3 L_sum;
/* Light Passes are used */
#ifdef __PASSES__
float3 L_direct, L_indirect;
float clamp_direct = kernel_data.integrator.sample_clamp_direct;
float clamp_indirect = kernel_data.integrator.sample_clamp_indirect;
if(L->use_light_pass) {
path_radiance_sum_indirect(L);

View File

@@ -1,282 +0,0 @@
/*
* 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 "kernel_split.h"
/*
* Note on kernel_ocl_path_trace_background_buffer_update kernel.
* This is the fourth kernel in the ray tracing logic, and the third
* of the path iteration kernels. This kernel takes care of rays that hit
* the background (sceneintersect kernel), and for the rays of
* state RAY_UPDATE_BUFFER it updates the ray's accumulated radiance in
* the output buffer. This kernel also takes care of rays that have been determined
* to-be-regenerated.
*
* We will empty QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue in this kernel
*
* Typically all rays that are in state RAY_HIT_BACKGROUND, RAY_UPDATE_BUFFER
* will be eventually set to RAY_TO_REGENERATE state in this kernel. Finally all rays of ray_state
* RAY_TO_REGENERATE will be regenerated and put in queue QUEUE_ACTIVE_AND_REGENERATED_RAYS.
*
* The input and output are as follows,
*
* rng_coop ---------------------------------------------|--- kernel_ocl_path_trace_background_buffer_update --|--- PathRadiance_coop
* throughput_coop --------------------------------------| |--- L_transparent_coop
* per_sample_output_buffers ----------------------------| |--- per_sample_output_buffers
* Ray_coop ---------------------------------------------| |--- ray_state
* PathState_coop ---------------------------------------| |--- Queue_data (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
* L_transparent_coop -----------------------------------| |--- Queue_data (QUEUE_ACTIVE_AND_REGENERATED_RAYS)
* ray_state --------------------------------------------| |--- Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
* Queue_data (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS) ----| |--- Queue_index (QUEUE_ACTIVE_AND_REGENERATED_RAYS)
* Queue_index (QUEUE_ACTIVE_AND_REGENERATED_RAYS) ------| |--- work_array
* parallel_samples -------------------------------------| |--- PathState_coop
* end_sample -------------------------------------------| |--- throughput_coop
* kg (globals + data) ----------------------------------| |--- rng_coop
* rng_state --------------------------------------------| |--- Ray
* PathRadiance_coop ------------------------------------| |
* sw ---------------------------------------------------| |
* sh ---------------------------------------------------| |
* sx ---------------------------------------------------| |
* sy ---------------------------------------------------| |
* stride -----------------------------------------------| |
* work_array -------------------------------------------| |--- work_array
* queuesize --------------------------------------------| |
* start_sample -----------------------------------------| |--- work_pool_wgs
* work_pool_wgs ----------------------------------------| |
* num_samples ------------------------------------------| |
*
* note on shader_data : shader_data argument is neither an input nor an output for this kernel. It is just filled and consumed here itself.
* Note on Queues :
* This kernel fetches rays from QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue.
*
* State of queues when this kernel is called :
* At entry,
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE rays
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_UPDATE_BUFFER, RAY_HIT_BACKGROUND, RAY_TO_REGENERATE rays
* At exit,
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE and RAY_REGENERATED rays
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be empty
*/
__kernel void kernel_ocl_path_trace_background_buffer_update(
ccl_global char *globals,
ccl_constant KernelData *data,
ccl_global char *shader_data,
ccl_global float *per_sample_output_buffers,
ccl_global uint *rng_state,
ccl_global uint *rng_coop, /* Required for buffer Update */
ccl_global float3 *throughput_coop, /* Required for background hit processing */
PathRadiance *PathRadiance_coop, /* Required for background hit processing and buffer Update */
ccl_global Ray *Ray_coop, /* Required for background hit processing */
ccl_global PathState *PathState_coop, /* Required for background hit processing */
ccl_global float *L_transparent_coop, /* Required for background hit processing and buffer Update */
ccl_global char *ray_state, /* Stores information on the current state of a ray */
int sw, int sh, int sx, int sy, int stride,
int rng_state_offset_x,
int rng_state_offset_y,
int rng_state_stride,
ccl_global unsigned int *work_array, /* Denotes work of each ray */
ccl_global int *Queue_data, /* Queues memory */
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
int queuesize, /* Size (capacity) of each queue */
int end_sample,
int start_sample,
#ifdef __WORK_STEALING__
ccl_global unsigned int *work_pool_wgs,
unsigned int num_samples,
#endif
#ifdef __KERNEL_DEBUG__
DebugData *debugdata_coop,
#endif
int parallel_samples /* Number of samples to be processed in parallel */
)
{
ccl_local unsigned int local_queue_atomics;
if(get_local_id(0) == 0 && get_local_id(1) == 0) {
local_queue_atomics = 0;
}
barrier(CLK_LOCAL_MEM_FENCE);
int ray_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
if(ray_index == 0) {
/* We will empty this queue in this kernel */
Queue_index[QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS] = 0;
}
char enqueue_flag = 0;
ray_index = get_ray_index(ray_index, QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, Queue_data, queuesize, 1);
#ifdef __COMPUTE_DEVICE_GPU__
/* If we are executing on a GPU device, we exit all threads that are not required.
* If we are executing on a CPU device, then we need to keep all threads active
* since we have barrier() calls later in the kernel. CPU devices
* expect all threads to execute barrier statement.
*/
if(ray_index == QUEUE_EMPTY_SLOT)
return;
#endif
#ifndef __COMPUTE_DEVICE_GPU__
if(ray_index != QUEUE_EMPTY_SLOT) {
#endif
/* Load kernel globals structure and ShaderData strucuture */
KernelGlobals *kg = (KernelGlobals *)globals;
ShaderData *sd = (ShaderData *)shader_data;
#ifdef __KERNEL_DEBUG__
DebugData *debug_data = &debugdata_coop[ray_index];
#endif
ccl_global PathState *state = &PathState_coop[ray_index];
PathRadiance *L = L = &PathRadiance_coop[ray_index];
ccl_global Ray *ray = &Ray_coop[ray_index];
ccl_global float3 *throughput = &throughput_coop[ray_index];
ccl_global float *L_transparent = &L_transparent_coop[ray_index];
ccl_global uint *rng = &rng_coop[ray_index];
#ifdef __WORK_STEALING__
unsigned int my_work;
ccl_global float *initial_per_sample_output_buffers;
ccl_global uint *initial_rng;
#endif
unsigned int sample;
unsigned int tile_x;
unsigned int tile_y;
unsigned int pixel_x;
unsigned int pixel_y;
unsigned int my_sample_tile;
#ifdef __WORK_STEALING__
my_work = work_array[ray_index];
sample = get_my_sample(my_work, sw, sh, parallel_samples, ray_index) + start_sample;
get_pixel_tile_position(&pixel_x, &pixel_y, &tile_x, &tile_y, my_work, sw, sh, sx, sy, parallel_samples, ray_index);
my_sample_tile = 0;
initial_per_sample_output_buffers = per_sample_output_buffers;
initial_rng = rng_state;
#else // __WORK_STEALING__
sample = work_array[ray_index];
int tile_index = ray_index / parallel_samples;
/* buffer and rng_state's stride is "stride". Find x and y using ray_index */
tile_x = tile_index % sw;
tile_y = tile_index / sw;
my_sample_tile = ray_index - (tile_index * parallel_samples);
#endif
rng_state += (rng_state_offset_x + tile_x) + (rng_state_offset_y + tile_y) * rng_state_stride;
per_sample_output_buffers += (((tile_x + (tile_y * stride)) * parallel_samples) + my_sample_tile) * kernel_data.film.pass_stride;
if(IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND)) {
/* eval background shader if nothing hit */
if(kernel_data.background.transparent && (state->flag & PATH_RAY_CAMERA)) {
*L_transparent = (*L_transparent) + average((*throughput));
#ifdef __PASSES__
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
#endif
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
}
if(IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND))
{
#ifdef __BACKGROUND__
/* sample background shader */
float3 L_background = indirect_background(kg, state, ray, sd);
path_radiance_accum_background(L, (*throughput), L_background, state->bounce);
#endif
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
}
}
if(IS_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER)) {
float3 L_sum = path_radiance_clamp_and_sum(kg, L);
kernel_write_light_passes(kg, per_sample_output_buffers, L, sample);
#ifdef __KERNEL_DEBUG__
kernel_write_debug_passes(kg, per_sample_output_buffers, state, debug_data, sample);
#endif
float4 L_rad = make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - (*L_transparent));
/* accumulate result in output buffer */
kernel_write_pass_float4(per_sample_output_buffers, sample, L_rad);
path_rng_end(kg, rng_state, *rng);
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
}
if(IS_STATE(ray_state, ray_index, RAY_TO_REGENERATE)) {
#ifdef __WORK_STEALING__
/* We have completed current work; So get next work */
int valid_work = get_next_work(work_pool_wgs, &my_work, sw, sh, num_samples, parallel_samples, ray_index);
if(!valid_work) {
/* If work is invalid, this means no more work is available and the thread may exit */
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_INACTIVE);
}
#else
if((sample + parallel_samples) >= end_sample) {
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_INACTIVE);
}
#endif
if(IS_STATE(ray_state, ray_index, RAY_TO_REGENERATE)) {
#ifdef __WORK_STEALING__
work_array[ray_index] = my_work;
/* Get the sample associated with the current work */
sample = get_my_sample(my_work, sw, sh, parallel_samples, ray_index) + start_sample;
/* Get pixel and tile position associated with current work */
get_pixel_tile_position(&pixel_x, &pixel_y, &tile_x, &tile_y, my_work, sw, sh, sx, sy, parallel_samples, ray_index);
my_sample_tile = 0;
/* Remap rng_state according to the current work */
rng_state = initial_rng + ((rng_state_offset_x + tile_x) + (rng_state_offset_y + tile_y) * rng_state_stride);
/* Remap per_sample_output_buffers according to the current work */
per_sample_output_buffers = initial_per_sample_output_buffers
+ (((tile_x + (tile_y * stride)) * parallel_samples) + my_sample_tile) * kernel_data.film.pass_stride;
#else
work_array[ray_index] = sample + parallel_samples;
sample = work_array[ray_index];
/* Get ray position from ray index */
pixel_x = sx + ((ray_index / parallel_samples) % sw);
pixel_y = sy + ((ray_index / parallel_samples) / sw);
#endif
/* initialize random numbers and ray */
kernel_path_trace_setup(kg, rng_state, sample, pixel_x, pixel_y, rng, ray);
if(ray->t != 0.0f) {
/* Initialize throughput, L_transparent, Ray, PathState; These rays proceed with path-iteration*/
*throughput = make_float3(1.0f, 1.0f, 1.0f);
*L_transparent = 0.0f;
path_radiance_init(L, kernel_data.film.use_light_pass);
path_state_init(kg, state, rng, sample, ray);
#ifdef __KERNEL_DEBUG__
debug_data_init(debug_data);
#endif
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_REGENERATED);
enqueue_flag = 1;
} else {
/*These rays do not participate in path-iteration */
float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
/* accumulate result in output buffer */
kernel_write_pass_float4(per_sample_output_buffers, sample, L_rad);
path_rng_end(kg, rng_state, *rng);
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
}
}
}
#ifndef __COMPUTE_DEVICE_GPU__
}
#endif
/* Enqueue RAY_REGENERATED rays into QUEUE_ACTIVE_AND_REGENERATED_RAYS; These rays
* will be made active during next SceneIntersectkernel
*/
enqueue_ray_index_local(ray_index, QUEUE_ACTIVE_AND_REGENERATED_RAYS, enqueue_flag, queuesize, &local_queue_atomics, Queue_data, Queue_index);
}

View File

@@ -24,6 +24,7 @@
*/
#if defined(__GNUC__) && defined(NDEBUG)
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
# pragma GCC diagnostic ignored "-Wuninitialized"
#endif
/* Selective nodes compilation. */

View File

@@ -19,6 +19,8 @@ CCL_NAMESPACE_BEGIN
ccl_device_inline void debug_data_init(DebugData *debug_data)
{
debug_data->num_bvh_traversal_steps = 0;
debug_data->num_bvh_traversed_instances = 0;
debug_data->num_ray_bounces = 0;
}
ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
@@ -33,6 +35,16 @@ ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
sample,
debug_data->num_bvh_traversal_steps);
}
if(flag & PASS_BVH_TRAVERSED_INSTANCES) {
kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_instances,
sample,
debug_data->num_bvh_traversed_instances);
}
if(flag & PASS_RAY_BOUNCES) {
kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces,
sample,
debug_data->num_ray_bounces);
}
}
CCL_NAMESPACE_END

View File

@@ -1,137 +0,0 @@
/*
* 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 "kernel_split.h"
/*
* Note on kernel_ocl_path_trace_direct_lighting kernel.
* This is the eighth kernel in the ray tracing logic. This is the seventh
* of the path iteration kernels. This kernel takes care of direct lighting
* logic. However, the "shadow ray cast" part of direct lighting is handled
* in the next kernel.
*
* This kernels determines the rays for which a shadow_blocked() function associated with direct lighting should be executed.
* Those rays for which a shadow_blocked() function for direct-lighting must be executed, are marked with flag RAY_SHADOW_RAY_CAST_DL and
* enqueued into the queue QUEUE_SHADOW_RAY_CAST_DL_RAYS
*
* The input and output are as follows,
*
* rng_coop -----------------------------------------|--- kernel_ocl_path_trace_direct_lighting --|--- BSDFEval_coop
* PathState_coop -----------------------------------| |--- ISLamp_coop
* shader_data --------------------------------------| |--- LightRay_coop
* ray_state ----------------------------------------| |--- ray_state
* Queue_data (QUEUE_ACTIVE_AND_REGENERATED_RAYS) ---| |
* kg (globals + data) ------------------------------| |
* queuesize ----------------------------------------| |
*
* note on shader_DL : shader_DL is neither input nor output to this kernel; shader_DL is filled and consumed in this kernel itself.
* Note on Queues :
* This kernel only reads from the QUEUE_ACTIVE_AND_REGENERATED_RAYS queue and processes
* only the rays of state RAY_ACTIVE; If a ray needs to execute the corresponding shadow_blocked
* part, after direct lighting, the ray is marked with RAY_SHADOW_RAY_CAST_DL flag.
*
* State of queues when this kernel is called :
* state of queues QUEUE_ACTIVE_AND_REGENERATED_RAYS and QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be same
* before and after this kernel call.
* QUEUE_SHADOW_RAY_CAST_DL_RAYS queue will be filled with rays for which a shadow_blocked function must be executed, after this
* kernel call. Before this kernel call the QUEUE_SHADOW_RAY_CAST_DL_RAYS will be empty.
*/
__kernel void kernel_ocl_path_trace_direct_lighting(
ccl_global char *globals,
ccl_constant KernelData *data,
ccl_global char *shader_data, /* Required for direct lighting */
ccl_global char *shader_DL, /* Required for direct lighting */
ccl_global uint *rng_coop, /* Required for direct lighting */
ccl_global PathState *PathState_coop, /* Required for direct lighting */
ccl_global int *ISLamp_coop, /* Required for direct lighting */
ccl_global Ray *LightRay_coop, /* Required for direct lighting */
ccl_global BsdfEval *BSDFEval_coop, /* Required for direct lighting */
ccl_global char *ray_state, /* Denotes the state of each ray */
ccl_global int *Queue_data, /* Queue memory */
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
int queuesize /* Size (capacity) of each queue */
)
{
ccl_local unsigned int local_queue_atomics;
if(get_local_id(0) == 0 && get_local_id(1) == 0) {
local_queue_atomics = 0;
}
barrier(CLK_LOCAL_MEM_FENCE);
char enqueue_flag = 0;
int ray_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
ray_index = get_ray_index(ray_index, QUEUE_ACTIVE_AND_REGENERATED_RAYS, Queue_data, queuesize, 0);
#ifdef __COMPUTE_DEVICE_GPU__
/* If we are executing on a GPU device, we exit all threads that are not required
* If we are executing on a CPU device, then we need to keep all threads active
* since we have barrier() calls later in the kernel. CPU devices,
* expect all threads to execute barrier statement.
*/
if(ray_index == QUEUE_EMPTY_SLOT)
return;
#endif
#ifndef __COMPUTE_DEVICE_GPU__
if(ray_index != QUEUE_EMPTY_SLOT) {
#endif
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
/* Load kernel globals structure and ShaderData structure */
KernelGlobals *kg = (KernelGlobals *)globals;
ShaderData *sd = (ShaderData *)shader_data;
ShaderData *sd_DL = (ShaderData *)shader_DL;
ccl_global PathState *state = &PathState_coop[ray_index];
/* direct lighting */
#ifdef __EMISSION__
if((kernel_data.integrator.use_direct_light && (ccl_fetch(sd, flag) & SD_BSDF_HAS_EVAL))) {
/* sample illumination from lights to find path contribution */
ccl_global RNG* rng = &rng_coop[ray_index];
float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT);
float light_u, light_v;
path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v);
#ifdef __OBJECT_MOTION__
light_ray.time = sd->time;
#endif
LightSample ls;
light_sample(kg, light_t, light_u, light_v, ccl_fetch(sd, time), ccl_fetch(sd, P), state->bounce, &ls);
Ray light_ray;
BsdfEval L_light;
bool is_lamp;
if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce, sd_DL)) {
/* write intermediate data to global memory to access from the next kernel */
LightRay_coop[ray_index] = light_ray;
BSDFEval_coop[ray_index] = L_light;
ISLamp_coop[ray_index] = is_lamp;
/// mark ray state for next shadow kernel
ADD_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL);
enqueue_flag = 1;
}
}
#endif
}
#ifndef __COMPUTE_DEVICE_GPU__
}
#endif
#ifdef __EMISSION__
/* Enqueue RAY_SHADOW_RAY_CAST_DL rays */
enqueue_ray_index_local(ray_index, QUEUE_SHADOW_RAY_CAST_DL_RAYS, enqueue_flag, queuesize, &local_queue_atomics, Queue_data, Queue_index);
#endif
}

View File

@@ -71,7 +71,6 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
return eval;
}
/* The argument sd_DL is meaningful only for split kernel. Other uses can just pass NULL */
ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd,
LightSample *ls, Ray *ray, BsdfEval *eval, bool *is_lamp,
int bounce, int transparent_bounce
@@ -192,7 +191,6 @@ ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, Shader
/* Indirect Lamp Emission */
/* The argument sd is meaningful only for split kernel. Other uses can just pass NULL */
ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, PathState *state, Ray *ray, float3 *emission
#ifdef __SPLIT_KERNEL__
,ShaderData *sd

View File

@@ -1,283 +0,0 @@
/*
* 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 "kernel_split.h"
/*
* Note on kernel_ocl_path_trace_holdout_emission_blurring_pathtermination_ao kernel.
* This is the sixth kernel in the ray tracing logic. This is the fifth
* of the path iteration kernels. This kernel takes care of the logic to process
* "material of type holdout", indirect primitive emission, bsdf blurring,
* probabilistic path termination and AO.
*
* This kernels determines the rays for which a shadow_blocked() function associated with AO should be executed.
* Those rays for which a shadow_blocked() function for AO must be executed are marked with flag RAY_SHADOW_RAY_CAST_ao and
* enqueued into the queue QUEUE_SHADOW_RAY_CAST_AO_RAYS
*
* Ray state of rays that are terminated in this kernel are changed to RAY_UPDATE_BUFFER
*
* The input and output are as follows,
*
* rng_coop ---------------------------------------------|--- kernel_ocl_path_trace_holdout_emission_blurring_pathtermination_ao ---|--- Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
* throughput_coop --------------------------------------| |--- PathState_coop
* PathRadiance_coop ------------------------------------| |--- throughput_coop
* Intersection_coop ------------------------------------| |--- L_transparent_coop
* PathState_coop ---------------------------------------| |--- per_sample_output_buffers
* L_transparent_coop -----------------------------------| |--- PathRadiance_coop
* shader_data ------------------------------------------| |--- ShaderData
* ray_state --------------------------------------------| |--- ray_state
* Queue_data (QUEUE_ACTIVE_AND_REGENERATED_RAYS) -------| |--- Queue_data (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
* Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS) ---| |--- AOAlpha_coop
* kg (globals + data) ----------------------------------| |--- AOBSDF_coop
* parallel_samples -------------------------------------| |--- AOLightRay_coop
* per_sample_output_buffers ----------------------------| |
* sw ---------------------------------------------------| |
* sh ---------------------------------------------------| |
* sx ---------------------------------------------------| |
* sy ---------------------------------------------------| |
* stride -----------------------------------------------| |
* work_array -------------------------------------------| |
* queuesize --------------------------------------------| |
* start_sample -----------------------------------------| |
*
* Note on Queues :
* This kernel fetches rays from the queue QUEUE_ACTIVE_AND_REGENERATED_RAYS and processes only
* the rays of state RAY_ACTIVE.
* There are different points in this kernel where a ray may terminate and reach RAY_UPDATE_BUFFER
* state. These rays are enqueued into QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue. These rays will
* still be present in QUEUE_ACTIVE_AND_REGENERATED_RAYS queue, but since their ray-state has been
* changed to RAY_UPDATE_BUFFER, there is no problem.
*
* State of queues when this kernel is called :
* At entry,
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE and RAY_REGENERATED rays
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_TO_REGENERATE rays.
* QUEUE_SHADOW_RAY_CAST_AO_RAYS will be empty.
* At exit,
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE, RAY_REGENERATED and RAY_UPDATE_BUFFER rays
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_TO_REGENERATE and RAY_UPDATE_BUFFER rays
* QUEUE_SHADOW_RAY_CAST_AO_RAYS will be filled with rays marked with flag RAY_SHADOW_RAY_CAST_AO
*/
__kernel void kernel_ocl_path_trace_holdout_emission_blurring_pathtermination_ao(
ccl_global char *globals,
ccl_constant KernelData *data,
ccl_global char *shader_data, /* Required throughout the kernel except probabilistic path termination and AO */
ccl_global float *per_sample_output_buffers,
ccl_global uint *rng_coop, /* Required for "kernel_write_data_passes" and AO */
ccl_global float3 *throughput_coop, /* Required for handling holdout material and AO */
ccl_global float *L_transparent_coop, /* Required for handling holdout material */
PathRadiance *PathRadiance_coop, /* Required for "kernel_write_data_passes" and indirect primitive emission */
ccl_global PathState *PathState_coop, /* Required throughout the kernel and AO */
Intersection *Intersection_coop, /* Required for indirect primitive emission */
ccl_global float3 *AOAlpha_coop, /* Required for AO */
ccl_global float3 *AOBSDF_coop, /* Required for AO */
ccl_global Ray *AOLightRay_coop, /* Required for AO */
int sw, int sh, int sx, int sy, int stride,
ccl_global char *ray_state, /* Denotes the state of each ray */
ccl_global unsigned int *work_array, /* Denotes the work that each ray belongs to */
ccl_global int *Queue_data, /* Queue memory */
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
int queuesize, /* Size (capacity) of each queue */
#ifdef __WORK_STEALING__
unsigned int start_sample,
#endif
int parallel_samples /* Number of samples to be processed in parallel */
)
{
ccl_local unsigned int local_queue_atomics_bg;
ccl_local unsigned int local_queue_atomics_ao;
if(get_local_id(0) == 0 && get_local_id(1) == 0) {
local_queue_atomics_bg = 0;
local_queue_atomics_ao = 0;
}
barrier(CLK_LOCAL_MEM_FENCE);
char enqueue_flag = 0;
char enqueue_flag_AO_SHADOW_RAY_CAST = 0;
int ray_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
ray_index = get_ray_index(ray_index, QUEUE_ACTIVE_AND_REGENERATED_RAYS, Queue_data, queuesize, 0);
#ifdef __COMPUTE_DEVICE_GPU__
/* If we are executing on a GPU device, we exit all threads that are not required
* If we are executing on a CPU device, then we need to keep all threads active
* since we have barrier() calls later in the kernel. CPU devices
* expect all threads to execute barrier statement.
*/
if(ray_index == QUEUE_EMPTY_SLOT)
return;
#endif
#ifndef __COMPUTE_DEVICE_GPU__
if(ray_index != QUEUE_EMPTY_SLOT) {
#endif
/* Load kernel globals structure and ShaderData structure */
KernelGlobals *kg = (KernelGlobals *)globals;
ShaderData *sd = (ShaderData *)shader_data;
#ifdef __WORK_STEALING__
unsigned int my_work;
unsigned int pixel_x;
unsigned int pixel_y;
#endif
unsigned int tile_x;
unsigned int tile_y;
int my_sample_tile;
unsigned int sample;
ccl_global RNG *rng = 0x0;
ccl_global PathState *state = 0x0;
float3 throughput;
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
throughput = throughput_coop[ray_index];
state = &PathState_coop[ray_index];
rng = &rng_coop[ray_index];
#ifdef __WORK_STEALING__
my_work = work_array[ray_index];
sample = get_my_sample(my_work, sw, sh, parallel_samples, ray_index) + start_sample;
get_pixel_tile_position(&pixel_x, &pixel_y, &tile_x, &tile_y, my_work, sw, sh, sx, sy, parallel_samples, ray_index);
my_sample_tile = 0;
#else // __WORK_STEALING__
sample = work_array[ray_index];
/* buffer's stride is "stride"; Find x and y using ray_index */
int tile_index = ray_index / parallel_samples;
tile_x = tile_index % sw;
tile_y = tile_index / sw;
my_sample_tile = ray_index - (tile_index * parallel_samples);
#endif // __WORK_STEALING__
per_sample_output_buffers += (((tile_x + (tile_y * stride)) * parallel_samples) + my_sample_tile) * kernel_data.film.pass_stride;
/* holdout */
#ifdef __HOLDOUT__
if((ccl_fetch(sd, flag) & (SD_HOLDOUT|SD_HOLDOUT_MASK)) && (state->flag & PATH_RAY_CAMERA)) {
if(kernel_data.background.transparent) {
float3 holdout_weight;
if(ccl_fetch(sd, flag) & SD_HOLDOUT_MASK)
holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
else
holdout_weight = shader_holdout_eval(kg, sd);
/* any throughput is ok, should all be identical here */
L_transparent_coop[ray_index] += average(holdout_weight*throughput);
}
if(ccl_fetch(sd, flag) & SD_HOLDOUT_MASK) {
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
enqueue_flag = 1;
}
}
#endif
}
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
PathRadiance *L = &PathRadiance_coop[ray_index];
/* holdout mask objects do not write data passes */
kernel_write_data_passes(kg, per_sample_output_buffers, L, sd, sample, state, throughput);
/* blurring of bsdf after bounces, for rays that have a small likelihood
* of following this particular path (diffuse, rough glossy) */
if(kernel_data.integrator.filter_glossy != FLT_MAX) {
float blur_pdf = kernel_data.integrator.filter_glossy*state->min_ray_pdf;
if(blur_pdf < 1.0f) {
float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;
shader_bsdf_blur(kg, sd, blur_roughness);
}
}
#ifdef __EMISSION__
/* emission */
if(ccl_fetch(sd, flag) & SD_EMISSION) {
/* todo: is isect.t wrong here for transparent surfaces? */
float3 emission = indirect_primitive_emission(kg, sd, Intersection_coop[ray_index].t, state->flag, state->ray_pdf);
path_radiance_accum_emission(L, throughput, emission, state->bounce);
}
#endif
/* path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
* shader evaluations, only need emission if we are going to terminate */
float probability = path_state_terminate_probability(kg, state, throughput);
if(probability == 0.0f) {
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
enqueue_flag = 1;
}
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
if(probability != 1.0f) {
float terminate = path_state_rng_1D_for_decision(kg, rng, state, PRNG_TERMINATE);
if(terminate >= probability) {
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
enqueue_flag = 1;
} else {
throughput_coop[ray_index] = throughput/probability;
}
}
}
}
#ifdef __AO__
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (ccl_fetch(sd, flag) & SD_AO)) {
/* todo: solve correlation */
float bsdf_u, bsdf_v;
path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
float ao_factor = kernel_data.background.ao_factor;
float3 ao_N;
AOBSDF_coop[ray_index] = shader_bsdf_ao(kg, sd, ao_factor, &ao_N);
AOAlpha_coop[ray_index] = shader_bsdf_alpha(kg, sd);
float3 ao_D;
float ao_pdf;
sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
if(dot(ccl_fetch(sd, Ng), ao_D) > 0.0f && ao_pdf != 0.0f) {
Ray _ray;
_ray.P = ray_offset(ccl_fetch(sd, P), ccl_fetch(sd, Ng));
_ray.D = ao_D;
_ray.t = kernel_data.background.ao_distance;
#ifdef __OBJECT_MOTION__
_ray.time = ccl_fetch(sd, time);
#endif
_ray.dP = ccl_fetch(sd, dP);
_ray.dD = differential3_zero();
AOLightRay_coop[ray_index] = _ray;
ADD_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO);
enqueue_flag_AO_SHADOW_RAY_CAST = 1;
}
}
}
#endif
#ifndef __COMPUTE_DEVICE_GPU__
}
#endif
/* Enqueue RAY_UPDATE_BUFFER rays */
enqueue_ray_index_local(ray_index, QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, enqueue_flag, queuesize, &local_queue_atomics_bg, Queue_data, Queue_index);
#ifdef __AO__
/* Enqueue to-shadow-ray-cast rays */
enqueue_ray_index_local(ray_index, QUEUE_SHADOW_RAY_CAST_AO_RAYS, enqueue_flag_AO_SHADOW_RAY_CAST, queuesize, &local_queue_atomics_ao, Queue_data, Queue_index);
#endif
}

View File

@@ -249,6 +249,25 @@ float background_map_pdf(KernelGlobals *kg, float3 direction)
return (cdf_u.x * cdf_v.x)/(M_2PI_F * M_PI_F * sin_theta * denom);
}
ccl_device_inline bool background_portal_data_fetch_and_check_side(KernelGlobals *kg,
float3 P,
int index,
float3 *lightpos,
float3 *dir)
{
float4 data0 = kernel_tex_fetch(__light_data, (index + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 0);
float4 data3 = kernel_tex_fetch(__light_data, (index + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 3);
*lightpos = make_float3(data0.y, data0.z, data0.w);
*dir = make_float3(data3.y, data3.z, data3.w);
/* Check whether portal is on the right side. */
if(dot(*dir, P - *lightpos) > 1e-5f)
return true;
return false;
}
ccl_device float background_portal_pdf(KernelGlobals *kg,
float3 P,
float3 direction,
@@ -261,19 +280,9 @@ ccl_device float background_portal_pdf(KernelGlobals *kg,
if(p == ignore_portal)
continue;
/* TODO(sergey): Consider moving portal data fetch to a
* dedicated function.
*/
float4 data0 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 0);
float4 data3 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 3);
float3 lightpos = make_float3(data0.y, data0.z, data0.w);
float3 dir = make_float3(data3.y, data3.z, data3.w);
if(dot(dir, P - lightpos) <= 1e-5f) {
/* P is on the wrong side or too close. */
float3 lightpos, dir;
if(!background_portal_data_fetch_and_check_side(kg, P, p, &lightpos, &dir))
continue;
}
if(is_possible) {
/* There's a portal that could be sampled from this position. */
@@ -310,13 +319,8 @@ ccl_device int background_num_possible_portals(KernelGlobals *kg, float3 P)
{
int num_possible_portals = 0;
for(int p = 0; p < kernel_data.integrator.num_portals; p++) {
float4 data0 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 0);
float4 data3 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 3);
float3 lightpos = make_float3(data0.y, data0.z, data0.w);
float3 dir = make_float3(data3.y, data3.z, data3.w);
/* Check whether portal is on the right side. */
if(dot(dir, P - lightpos) > 1e-5f)
float3 lightpos, dir;
if(background_portal_data_fetch_and_check_side(kg, P, p, &lightpos, &dir))
num_possible_portals++;
}
return num_possible_portals;
@@ -340,13 +344,8 @@ ccl_device float3 background_portal_sample(KernelGlobals *kg,
*/
for(int p = 0; p < kernel_data.integrator.num_portals; p++) {
/* Search for the sampled portal. */
float4 data0 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 0);
float4 data3 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 3);
float3 lightpos = make_float3(data0.y, data0.z, data0.w);
float3 dir = make_float3(data3.y, data3.z, data3.w);
/* Check whether portal is on the right side. */
if(dot(dir, P - lightpos) <= 1e-5f)
float3 lightpos, dir;
if(!background_portal_data_fetch_and_check_side(kg, P, p, &lightpos, &dir))
continue;
if(portal == 0) {
@@ -356,16 +355,14 @@ ccl_device float3 background_portal_sample(KernelGlobals *kg,
float3 axisu = make_float3(data1.y, data1.z, data1.w);
float3 axisv = make_float3(data2.y, data2.z, data2.w);
float3 lightPoint = lightpos;
*pdf = area_light_sample(P, &lightPoint,
*pdf = area_light_sample(P, &lightpos,
axisu, axisv,
randu, randv,
true);
*pdf /= num_possible;
*sampled_portal = p;
return normalize(lightPoint - P);
return normalize(lightpos - P);
}
portal--;

View File

@@ -1,176 +0,0 @@
/*
* 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 "kernel_split.h"
/*
* Note on kernel_ocl_path_trace_setup_next_iteration kernel.
* This is the tenth kernel in the ray tracing logic. This is the ninth
* of the path iteration kernels. This kernel takes care of setting up
* Ray for the next iteration of path-iteration and accumulating radiance
* corresponding to AO and direct-lighting
*
* Ray state of rays that are terminated in this kernel are changed to RAY_UPDATE_BUFFER
*
* The input and output are as follows,
*
* rng_coop ---------------------------------------------|--- kernel_ocl_path_trace_setup_next_iteration -|--- Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
* throughput_coop --------------------------------------| |--- Queue_data (QUEUE_HITBF_BUFF_UPDATE_TOREGEN_RAYS)
* PathRadiance_coop ------------------------------------| |--- throughput_coop
* PathState_coop ---------------------------------------| |--- PathRadiance_coop
* shader_data ------------------------------------------| |--- PathState_coop
* ray_state --------------------------------------------| |--- ray_state
* Queue_data (QUEUE_ACTIVE_AND_REGENERATD_RAYS) --------| |--- Ray_coop
* Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS) ---| |--- use_queues_flag
* Ray_coop ---------------------------------------------| |
* kg (globals + data) ----------------------------------| |
* LightRay_dl_coop -------------------------------------|
* ISLamp_coop ------------------------------------------|
* BSDFEval_coop ----------------------------------------|
* LightRay_ao_coop -------------------------------------|
* AOBSDF_coop ------------------------------------------|
* AOAlpha_coop -----------------------------------------|
*
* Note on queues,
* This kernel fetches rays from the queue QUEUE_ACTIVE_AND_REGENERATED_RAYS and processes only
* the rays of state RAY_ACTIVE.
* There are different points in this kernel where a ray may terminate and reach RAY_UPDATE_BUFF
* state. These rays are enqueued into QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue. These rays will
* still be present in QUEUE_ACTIVE_AND_REGENERATED_RAYS queue, but since their ray-state has been
* changed to RAY_UPDATE_BUFF, there is no problem.
*
* State of queues when this kernel is called :
* At entry,
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE, RAY_REGENERATED, RAY_UPDATE_BUFFER rays.
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_TO_REGENERATE and RAY_UPDATE_BUFFER rays
* At exit,
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE, RAY_REGENERATED and more RAY_UPDATE_BUFFER rays.
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_TO_REGENERATE and more RAY_UPDATE_BUFFER rays
*/
__kernel void kernel_ocl_path_trace_setup_next_iteration(
ccl_global char *globals,
ccl_constant KernelData *data,
ccl_global char *shader_data, /* Required for setting up ray for next iteration */
ccl_global uint *rng_coop, /* Required for setting up ray for next iteration */
ccl_global float3 *throughput_coop, /* Required for setting up ray for next iteration */
PathRadiance *PathRadiance_coop, /* Required for setting up ray for next iteration */
ccl_global Ray *Ray_coop, /* Required for setting up ray for next iteration */
ccl_global PathState *PathState_coop, /* Required for setting up ray for next iteration */
ccl_global Ray *LightRay_dl_coop, /* Required for radiance update - direct lighting */
ccl_global int *ISLamp_coop, /* Required for radiance update - direct lighting */
ccl_global BsdfEval *BSDFEval_coop, /* Required for radiance update - direct lighting */
ccl_global Ray *LightRay_ao_coop, /* Required for radiance update - AO */
ccl_global float3 *AOBSDF_coop, /* Required for radiance update - AO */
ccl_global float3 *AOAlpha_coop, /* Required for radiance update - AO */
ccl_global char *ray_state, /* Denotes the state of each ray */
ccl_global int *Queue_data, /* Queue memory */
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
int queuesize, /* Size (capacity) of each queue */
ccl_global char *use_queues_flag /* flag to decide if scene_intersect kernel should use queues to fetch ray index */
)
{
ccl_local unsigned int local_queue_atomics;
if(get_local_id(0) == 0 && get_local_id(1) == 0) {
local_queue_atomics = 0;
}
barrier(CLK_LOCAL_MEM_FENCE);
if(get_global_id(0) == 0 && get_global_id(1) == 0) {
/* If we are here, then it means that scene-intersect kernel
* has already been executed atleast once. From the next time,
* scene-intersect kernel may operate on queues to fetch ray index
*/
use_queues_flag[0] = 1;
/* Mark queue indices of QUEUE_SHADOW_RAY_CAST_AO_RAYS and QUEUE_SHADOW_RAY_CAST_DL_RAYS
* queues that were made empty during the previous kernel
*/
Queue_index[QUEUE_SHADOW_RAY_CAST_AO_RAYS] = 0;
Queue_index[QUEUE_SHADOW_RAY_CAST_DL_RAYS] = 0;
}
char enqueue_flag = 0;
int ray_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
ray_index = get_ray_index(ray_index, QUEUE_ACTIVE_AND_REGENERATED_RAYS, Queue_data, queuesize, 0);
#ifdef __COMPUTE_DEVICE_GPU__
/* If we are executing on a GPU device, we exit all threads that are not required
* If we are executing on a CPU device, then we need to keep all threads active
* since we have barrier() calls later in the kernel. CPU devices,
* expect all threads to execute barrier statement.
*/
if(ray_index == QUEUE_EMPTY_SLOT)
return;
#endif
#ifndef __COMPUTE_DEVICE_GPU__
if(ray_index != QUEUE_EMPTY_SLOT) {
#endif
/* Load kernel globals structure and ShaderData structure */
KernelGlobals *kg = (KernelGlobals *)globals;
ShaderData *sd = (ShaderData *)shader_data;
PathRadiance *L = 0x0;
ccl_global PathState *state = 0x0;
/* Path radiance update for AO/Direct_lighting's shadow blocked */
if(IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL) || IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO)) {
state = &PathState_coop[ray_index];
L = &PathRadiance_coop[ray_index];
float3 _throughput = throughput_coop[ray_index];
if(IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO)) {
float3 shadow = LightRay_ao_coop[ray_index].P;
char update_path_radiance = LightRay_ao_coop[ray_index].t;
if(update_path_radiance) {
path_radiance_accum_ao(L, _throughput, AOAlpha_coop[ray_index], AOBSDF_coop[ray_index], shadow, state->bounce);
}
REMOVE_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO);
}
if(IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL)) {
float3 shadow = LightRay_dl_coop[ray_index].P;
char update_path_radiance = LightRay_dl_coop[ray_index].t;
if(update_path_radiance) {
BsdfEval L_light = BSDFEval_coop[ray_index];
path_radiance_accum_light(L, _throughput, &L_light, shadow, 1.0f, state->bounce, ISLamp_coop[ray_index]);
}
REMOVE_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL);
}
}
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
ccl_global float3 *throughput = &throughput_coop[ray_index];
ccl_global Ray *ray = &Ray_coop[ray_index];
ccl_global RNG* rng = &rng_coop[ray_index];
state = &PathState_coop[ray_index];
L = &PathRadiance_coop[ray_index];
/* compute direct lighting and next bounce */
if(!kernel_path_surface_bounce(kg, rng, sd, throughput, state, L, ray)) {
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
enqueue_flag = 1;
}
}
#ifndef __COMPUTE_DEVICE_GPU__
}
#endif
/* Enqueue RAY_UPDATE_BUFFER rays */
enqueue_ray_index_local(ray_index, QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, enqueue_flag, queuesize, &local_queue_atomics, Queue_data, Queue_index);
}

View File

@@ -324,43 +324,6 @@ ccl_device void kernel_path_ao(KernelGlobals *kg, ShaderData *sd, PathRadiance *
}
}
ccl_device void kernel_branched_path_ao(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, float3 throughput)
{
int num_samples = kernel_data.integrator.ao_samples;
float num_samples_inv = 1.0f/num_samples;
float ao_factor = kernel_data.background.ao_factor;
float3 ao_N;
float3 ao_bsdf = shader_bsdf_ao(kg, sd, ao_factor, &ao_N);
float3 ao_alpha = shader_bsdf_alpha(kg, sd);
for(int j = 0; j < num_samples; j++) {
float bsdf_u, bsdf_v;
path_branched_rng_2D(kg, rng, state, j, num_samples, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
float3 ao_D;
float ao_pdf;
sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
if(dot(ccl_fetch(sd, Ng), ao_D) > 0.0f && ao_pdf != 0.0f) {
Ray light_ray;
float3 ao_shadow;
light_ray.P = ray_offset(ccl_fetch(sd, P), ccl_fetch(sd, Ng));
light_ray.D = ao_D;
light_ray.t = kernel_data.background.ao_distance;
#ifdef __OBJECT_MOTION__
light_ray.time = ccl_fetch(sd, time);
#endif
light_ray.dP = ccl_fetch(sd, dP);
light_ray.dD = differential3_zero();
if(!shadow_blocked(kg, state, &light_ray, &ao_shadow))
path_radiance_accum_ao(L, throughput*num_samples_inv, ao_alpha, ao_bsdf, ao_shadow, state->bounce);
}
}
}
#ifdef __SUBSURFACE__
ccl_device bool kernel_path_subsurface_scatter(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, Ray *ray, float3 *throughput)
@@ -476,7 +439,9 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
#ifdef __KERNEL_DEBUG__
if(state.flag & PATH_RAY_CAMERA) {
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
}
debug_data.num_ray_bounces++;
#endif
#ifdef __LAMP_MIS__
@@ -706,444 +671,6 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
}
#ifdef __BRANCHED_PATH__
/* branched path tracing: bounce off surface and integrate indirect light */
ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGlobals *kg,
RNG *rng, ShaderData *sd, float3 throughput, float num_samples_adjust,
PathState *state, PathRadiance *L)
{
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
const ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
if(!CLOSURE_IS_BSDF(sc->type))
continue;
/* transparency is not handled here, but in outer loop */
if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID)
continue;
int num_samples;
if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
num_samples = kernel_data.integrator.diffuse_samples;
else if(CLOSURE_IS_BSDF_BSSRDF(sc->type))
num_samples = 1;
else if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
num_samples = kernel_data.integrator.glossy_samples;
else
num_samples = kernel_data.integrator.transmission_samples;
num_samples = ceil_to_int(num_samples_adjust*num_samples);
float num_samples_inv = num_samples_adjust/num_samples;
RNG bsdf_rng = cmj_hash(*rng, i);
for(int j = 0; j < num_samples; j++) {
PathState ps = *state;
float3 tp = throughput;
Ray bsdf_ray;
if(!kernel_branched_path_surface_bounce(kg, &bsdf_rng, sd, sc, j, num_samples, &tp, &ps, L, &bsdf_ray))
continue;
kernel_path_indirect(kg, rng, bsdf_ray, tp*num_samples_inv, num_samples, ps, L);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
path_radiance_sum_indirect(L);
path_radiance_reset_indirect(L);
}
}
}
#ifdef __SUBSURFACE__
ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
ShaderData *sd,
PathRadiance *L,
PathState *state,
RNG *rng,
Ray *ray,
float3 throughput)
{
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
if(!CLOSURE_IS_BSSRDF(sc->type))
continue;
/* set up random number generator */
uint lcg_state = lcg_state_init(rng, state, 0x68bc21eb);
int num_samples = kernel_data.integrator.subsurface_samples;
float num_samples_inv = 1.0f/num_samples;
RNG bssrdf_rng = cmj_hash(*rng, i);
/* do subsurface scatter step with copy of shader data, this will
* replace the BSSRDF with a diffuse BSDF closure */
for(int j = 0; j < num_samples; j++) {
ShaderData bssrdf_sd[BSSRDF_MAX_HITS];
float bssrdf_u, bssrdf_v;
path_branched_rng_2D(kg, &bssrdf_rng, state, j, num_samples, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
int num_hits = subsurface_scatter_multi_step(kg, sd, bssrdf_sd, state->flag, sc, &lcg_state, bssrdf_u, bssrdf_v, true);
#ifdef __VOLUME__
Ray volume_ray = *ray;
bool need_update_volume_stack = kernel_data.integrator.use_volumes &&
ccl_fetch(sd, flag) & SD_OBJECT_INTERSECTS_VOLUME;
#endif
/* compute lighting with the BSDF closure */
for(int hit = 0; hit < num_hits; hit++) {
PathState hit_state = *state;
path_state_branch(&hit_state, j, num_samples);
#ifdef __VOLUME__
if(need_update_volume_stack) {
/* Setup ray from previous surface point to the new one. */
float3 P = ray_offset(bssrdf_sd[hit].P, -bssrdf_sd[hit].Ng);
volume_ray.D = normalize_len(P - volume_ray.P,
&volume_ray.t);
kernel_volume_stack_update_for_subsurface(
kg,
&volume_ray,
hit_state.volume_stack);
/* Move volume ray forward. */
volume_ray.P = P;
}
#endif
#if defined(__EMISSION__) && defined(__BRANCHED_PATH__)
/* direct light */
if(kernel_data.integrator.use_direct_light) {
bool all = kernel_data.integrator.sample_all_lights_direct;
kernel_branched_path_surface_connect_light(kg, rng,
&bssrdf_sd[hit], &hit_state, throughput, num_samples_inv, L, all);
}
#endif
/* indirect light */
kernel_branched_path_surface_indirect_light(kg, rng,
&bssrdf_sd[hit], throughput, num_samples_inv,
&hit_state, L);
}
}
}
}
#endif
ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
{
/* initialize */
PathRadiance L;
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
float L_transparent = 0.0f;
path_radiance_init(&L, kernel_data.film.use_light_pass);
PathState state;
path_state_init(kg, &state, rng, sample, &ray);
#ifdef __KERNEL_DEBUG__
DebugData debug_data;
debug_data_init(&debug_data);
#endif
for(;;) {
/* intersect scene */
Intersection isect;
uint visibility = path_state_ray_visibility(kg, &state);
#ifdef __HAIR__
float difl = 0.0f, extmax = 0.0f;
uint lcg_state = 0;
if(kernel_data.bvh.have_curves) {
if((kernel_data.cam.resolution == 1) && (state.flag & PATH_RAY_CAMERA)) {
float3 pixdiff = ray.dD.dx + ray.dD.dy;
/*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
}
extmax = kernel_data.curve.maximum_width;
lcg_state = lcg_state_init(rng, &state, 0x51633e2d);
}
bool hit = scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax);
#else
bool hit = scene_intersect(kg, &ray, visibility, &isect, NULL, 0.0f, 0.0f);
#endif
#ifdef __KERNEL_DEBUG__
if(state.flag & PATH_RAY_CAMERA) {
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
}
#endif
#ifdef __VOLUME__
/* volume attenuation, emission, scatter */
if(state.volume_stack[0].shader != SHADER_NONE) {
Ray volume_ray = ray;
volume_ray.t = (hit)? isect.t: FLT_MAX;
bool heterogeneous = volume_stack_is_heterogeneous(kg, state.volume_stack);
#ifdef __VOLUME_DECOUPLED__
/* decoupled ray marching only supported on CPU */
/* cache steps along volume for repeated sampling */
VolumeSegment volume_segment;
ShaderData volume_sd;
shader_setup_from_volume(kg, &volume_sd, &volume_ray, state.bounce, state.transparent_bounce);
kernel_volume_decoupled_record(kg, &state,
&volume_ray, &volume_sd, &volume_segment, heterogeneous);
/* direct light sampling */
if(volume_segment.closure_flag & SD_SCATTER) {
volume_segment.sampling_method = volume_stack_sampling_method(kg, state.volume_stack);
bool all = kernel_data.integrator.sample_all_lights_direct;
kernel_branched_path_volume_connect_light(kg, rng, &volume_sd,
throughput, &state, &L, all, &volume_ray, &volume_segment);
/* indirect light sampling */
int num_samples = kernel_data.integrator.volume_samples;
float num_samples_inv = 1.0f/num_samples;
for(int j = 0; j < num_samples; j++) {
/* workaround to fix correlation bug in T38710, can find better solution
* in random number generator later, for now this is done here to not impact
* performance of rendering without volumes */
RNG tmp_rng = cmj_hash(*rng, state.rng_offset);
PathState ps = state;
Ray pray = ray;
float3 tp = throughput;
/* branch RNG state */
path_state_branch(&ps, j, num_samples);
/* scatter sample. if we use distance sampling and take just one
* sample for direct and indirect light, we could share this
* computation, but makes code a bit complex */
float rphase = path_state_rng_1D_for_decision(kg, &tmp_rng, &ps, PRNG_PHASE);
float rscatter = path_state_rng_1D_for_decision(kg, &tmp_rng, &ps, PRNG_SCATTER_DISTANCE);
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
&ps, &pray, &volume_sd, &tp, rphase, rscatter, &volume_segment, NULL, false);
(void)result;
kernel_assert(result == VOLUME_PATH_SCATTERED);
if(kernel_path_volume_bounce(kg, rng, &volume_sd, &tp, &ps, &L, &pray)) {
kernel_path_indirect(kg, rng, pray, tp*num_samples_inv, num_samples, ps, &L);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
path_radiance_sum_indirect(&L);
path_radiance_reset_indirect(&L);
}
}
}
/* emission and transmittance */
if(volume_segment.closure_flag & SD_EMISSION)
path_radiance_accum_emission(&L, throughput, volume_segment.accum_emission, state.bounce);
throughput *= volume_segment.accum_transmittance;
/* free cached steps */
kernel_volume_decoupled_free(kg, &volume_segment);
#else
/* GPU: no decoupled ray marching, scatter probalistically */
int num_samples = kernel_data.integrator.volume_samples;
float num_samples_inv = 1.0f/num_samples;
/* todo: we should cache the shader evaluations from stepping
* through the volume, for now we redo them multiple times */
for(int j = 0; j < num_samples; j++) {
PathState ps = state;
Ray pray = ray;
ShaderData volume_sd;
float3 tp = throughput * num_samples_inv;
/* branch RNG state */
path_state_branch(&ps, j, num_samples);
VolumeIntegrateResult result = kernel_volume_integrate(
kg, &ps, &volume_sd, &volume_ray, &L, &tp, rng, heterogeneous);
#ifdef __VOLUME_SCATTER__
if(result == VOLUME_PATH_SCATTERED) {
/* todo: support equiangular, MIS and all light sampling.
* alternatively get decoupled ray marching working on the GPU */
kernel_path_volume_connect_light(kg, rng, &volume_sd, tp, &state, &L);
if(kernel_path_volume_bounce(kg, rng, &volume_sd, &tp, &ps, &L, &pray)) {
kernel_path_indirect(kg, rng, pray, tp, num_samples, ps, &L);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
path_radiance_sum_indirect(&L);
path_radiance_reset_indirect(&L);
}
}
#endif
}
/* todo: avoid this calculation using decoupled ray marching */
kernel_volume_shadow(kg, &state, &volume_ray, &throughput);
#endif
}
#endif
if(!hit) {
/* eval background shader if nothing hit */
if(kernel_data.background.transparent) {
L_transparent += average(throughput);
#ifdef __PASSES__
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
#endif
break;
}
#ifdef __BACKGROUND__
/* sample background shader */
float3 L_background = indirect_background(kg, &state, &ray);
path_radiance_accum_background(&L, throughput, L_background, state.bounce);
#endif
break;
}
/* setup shading */
ShaderData sd;
shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce, state.transparent_bounce);
shader_eval_surface(kg, &sd, 0.0f, state.flag, SHADER_CONTEXT_MAIN);
shader_merge_closures(&sd);
/* holdout */
#ifdef __HOLDOUT__
if(sd.flag & (SD_HOLDOUT|SD_HOLDOUT_MASK)) {
if(kernel_data.background.transparent) {
float3 holdout_weight;
if(sd.flag & SD_HOLDOUT_MASK)
holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
else
holdout_weight = shader_holdout_eval(kg, &sd);
/* any throughput is ok, should all be identical here */
L_transparent += average(holdout_weight*throughput);
}
if(sd.flag & SD_HOLDOUT_MASK)
break;
}
#endif
/* holdout mask objects do not write data passes */
kernel_write_data_passes(kg, buffer, &L, &sd, sample, &state, throughput);
#ifdef __EMISSION__
/* emission */
if(sd.flag & SD_EMISSION) {
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, state.ray_pdf);
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
/* transparency termination */
if(state.flag & PATH_RAY_TRANSPARENT) {
/* path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
* shader evaluations, only need emission if we are going to terminate */
float probability = path_state_terminate_probability(kg, &state, throughput);
if(probability == 0.0f) {
break;
}
else if(probability != 1.0f) {
float terminate = path_state_rng_1D_for_decision(kg, rng, &state, PRNG_TERMINATE);
if(terminate >= probability)
break;
throughput /= probability;
}
}
#ifdef __AO__
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
kernel_branched_path_ao(kg, &sd, &L, &state, rng, throughput);
}
#endif
#ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object */
if(sd.flag & SD_BSSRDF) {
kernel_branched_path_subsurface_scatter(kg, &sd, &L, &state,
rng, &ray, throughput);
}
#endif
if(!(sd.flag & SD_HAS_ONLY_VOLUME)) {
PathState hit_state = state;
#ifdef __EMISSION__
/* direct light */
if(kernel_data.integrator.use_direct_light) {
bool all = kernel_data.integrator.sample_all_lights_direct;
kernel_branched_path_surface_connect_light(kg, rng,
&sd, &hit_state, throughput, 1.0f, &L, all);
}
#endif
/* indirect light */
kernel_branched_path_surface_indirect_light(kg, rng,
&sd, throughput, 1.0f, &hit_state, &L);
/* continue in case of transparency */
throughput *= shader_bsdf_transparency(kg, &sd);
if(is_zero(throughput))
break;
}
path_state_next(kg, &state, LABEL_TRANSPARENT);
ray.P = ray_offset(sd.P, -sd.Ng);
ray.t -= sd.ray_length; /* clipping works through transparent */
#ifdef __RAY_DIFFERENTIALS__
ray.dP = sd.dP;
ray.dD.dx = -sd.dI.dx;
ray.dD.dy = -sd.dI.dy;
#endif
#ifdef __VOLUME__
/* enter/exit volume */
kernel_volume_stack_enter_exit(kg, &sd, state.volume_stack);
#endif
}
float3 L_sum = path_radiance_clamp_and_sum(kg, &L);
kernel_write_light_passes(kg, buffer, &L, sample);
#ifdef __KERNEL_DEBUG__
kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
#endif
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
}
#endif
ccl_device void kernel_path_trace(KernelGlobals *kg,
ccl_global float *buffer, ccl_global uint *rng_state,
int sample, int x, int y, int offset, int stride)
@@ -1175,38 +702,5 @@ ccl_device void kernel_path_trace(KernelGlobals *kg,
path_rng_end(kg, rng_state, rng);
}
#ifdef __BRANCHED_PATH__
ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
ccl_global float *buffer, ccl_global uint *rng_state,
int sample, int x, int y, int offset, int stride)
{
/* buffer offset */
int index = offset + x + y*stride;
int pass_stride = kernel_data.film.pass_stride;
rng_state += index;
buffer += index*pass_stride;
/* initialize random numbers and ray */
RNG rng;
Ray ray;
kernel_path_trace_setup(kg, rng_state, sample, x, y, &rng, &ray);
/* integrate */
float4 L;
if(ray.t != 0.0f)
L = kernel_branched_path_integrate(kg, &rng, sample, ray, buffer);
else
L = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
/* accumulate result in output buffer */
kernel_write_pass_float4(buffer, sample, L);
path_rng_end(kg, rng_state, rng);
}
#endif
CCL_NAMESPACE_END

View File

@@ -0,0 +1,534 @@
/*
* Copyright 2011-2013 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.
*/
CCL_NAMESPACE_BEGIN
#ifdef __BRANCHED_PATH__
ccl_device void kernel_branched_path_ao(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, float3 throughput)
{
int num_samples = kernel_data.integrator.ao_samples;
float num_samples_inv = 1.0f/num_samples;
float ao_factor = kernel_data.background.ao_factor;
float3 ao_N;
float3 ao_bsdf = shader_bsdf_ao(kg, sd, ao_factor, &ao_N);
float3 ao_alpha = shader_bsdf_alpha(kg, sd);
for(int j = 0; j < num_samples; j++) {
float bsdf_u, bsdf_v;
path_branched_rng_2D(kg, rng, state, j, num_samples, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
float3 ao_D;
float ao_pdf;
sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
if(dot(ccl_fetch(sd, Ng), ao_D) > 0.0f && ao_pdf != 0.0f) {
Ray light_ray;
float3 ao_shadow;
light_ray.P = ray_offset(ccl_fetch(sd, P), ccl_fetch(sd, Ng));
light_ray.D = ao_D;
light_ray.t = kernel_data.background.ao_distance;
#ifdef __OBJECT_MOTION__
light_ray.time = ccl_fetch(sd, time);
#endif
light_ray.dP = ccl_fetch(sd, dP);
light_ray.dD = differential3_zero();
if(!shadow_blocked(kg, state, &light_ray, &ao_shadow))
path_radiance_accum_ao(L, throughput*num_samples_inv, ao_alpha, ao_bsdf, ao_shadow, state->bounce);
}
}
}
/* bounce off surface and integrate indirect light */
ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGlobals *kg,
RNG *rng, ShaderData *sd, float3 throughput, float num_samples_adjust,
PathState *state, PathRadiance *L)
{
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
const ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
if(!CLOSURE_IS_BSDF(sc->type))
continue;
/* transparency is not handled here, but in outer loop */
if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID)
continue;
int num_samples;
if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
num_samples = kernel_data.integrator.diffuse_samples;
else if(CLOSURE_IS_BSDF_BSSRDF(sc->type))
num_samples = 1;
else if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
num_samples = kernel_data.integrator.glossy_samples;
else
num_samples = kernel_data.integrator.transmission_samples;
num_samples = ceil_to_int(num_samples_adjust*num_samples);
float num_samples_inv = num_samples_adjust/num_samples;
RNG bsdf_rng = cmj_hash(*rng, i);
for(int j = 0; j < num_samples; j++) {
PathState ps = *state;
float3 tp = throughput;
Ray bsdf_ray;
if(!kernel_branched_path_surface_bounce(kg, &bsdf_rng, sd, sc, j, num_samples, &tp, &ps, L, &bsdf_ray))
continue;
kernel_path_indirect(kg, rng, bsdf_ray, tp*num_samples_inv, num_samples, ps, L);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
path_radiance_sum_indirect(L);
path_radiance_reset_indirect(L);
}
}
}
#ifdef __SUBSURFACE__
ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
ShaderData *sd,
PathRadiance *L,
PathState *state,
RNG *rng,
Ray *ray,
float3 throughput)
{
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
if(!CLOSURE_IS_BSSRDF(sc->type))
continue;
/* set up random number generator */
uint lcg_state = lcg_state_init(rng, state, 0x68bc21eb);
int num_samples = kernel_data.integrator.subsurface_samples;
float num_samples_inv = 1.0f/num_samples;
RNG bssrdf_rng = cmj_hash(*rng, i);
/* do subsurface scatter step with copy of shader data, this will
* replace the BSSRDF with a diffuse BSDF closure */
for(int j = 0; j < num_samples; j++) {
ShaderData bssrdf_sd[BSSRDF_MAX_HITS];
float bssrdf_u, bssrdf_v;
path_branched_rng_2D(kg, &bssrdf_rng, state, j, num_samples, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
int num_hits = subsurface_scatter_multi_step(kg, sd, bssrdf_sd, state->flag, sc, &lcg_state, bssrdf_u, bssrdf_v, true);
#ifdef __VOLUME__
Ray volume_ray = *ray;
bool need_update_volume_stack = kernel_data.integrator.use_volumes &&
ccl_fetch(sd, flag) & SD_OBJECT_INTERSECTS_VOLUME;
#endif
/* compute lighting with the BSDF closure */
for(int hit = 0; hit < num_hits; hit++) {
PathState hit_state = *state;
path_state_branch(&hit_state, j, num_samples);
#ifdef __VOLUME__
if(need_update_volume_stack) {
/* Setup ray from previous surface point to the new one. */
float3 P = ray_offset(bssrdf_sd[hit].P, -bssrdf_sd[hit].Ng);
volume_ray.D = normalize_len(P - volume_ray.P,
&volume_ray.t);
kernel_volume_stack_update_for_subsurface(
kg,
&volume_ray,
hit_state.volume_stack);
/* Move volume ray forward. */
volume_ray.P = P;
}
#endif
#ifdef __EMISSION__
/* direct light */
if(kernel_data.integrator.use_direct_light) {
bool all = kernel_data.integrator.sample_all_lights_direct;
kernel_branched_path_surface_connect_light(kg, rng,
&bssrdf_sd[hit], &hit_state, throughput, num_samples_inv, L, all);
}
#endif
/* indirect light */
kernel_branched_path_surface_indirect_light(kg, rng,
&bssrdf_sd[hit], throughput, num_samples_inv,
&hit_state, L);
}
}
}
}
#endif
ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
{
/* initialize */
PathRadiance L;
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
float L_transparent = 0.0f;
path_radiance_init(&L, kernel_data.film.use_light_pass);
PathState state;
path_state_init(kg, &state, rng, sample, &ray);
#ifdef __KERNEL_DEBUG__
DebugData debug_data;
debug_data_init(&debug_data);
#endif
/* Main Loop
* Here we only handle transparency intersections from the camera ray.
* Indirect bounces are handled in kernel_branched_path_surface_indirect_light().
*/
for(;;) {
/* intersect scene */
Intersection isect;
uint visibility = path_state_ray_visibility(kg, &state);
#ifdef __HAIR__
float difl = 0.0f, extmax = 0.0f;
uint lcg_state = 0;
if(kernel_data.bvh.have_curves) {
if(kernel_data.cam.resolution == 1) {
float3 pixdiff = ray.dD.dx + ray.dD.dy;
/*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
}
extmax = kernel_data.curve.maximum_width;
lcg_state = lcg_state_init(rng, &state, 0x51633e2d);
}
bool hit = scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax);
#else
bool hit = scene_intersect(kg, &ray, visibility, &isect, NULL, 0.0f, 0.0f);
#endif
#ifdef __KERNEL_DEBUG__
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
debug_data.num_ray_bounces++;
#endif
#ifdef __VOLUME__
/* volume attenuation, emission, scatter */
if(state.volume_stack[0].shader != SHADER_NONE) {
Ray volume_ray = ray;
volume_ray.t = (hit)? isect.t: FLT_MAX;
bool heterogeneous = volume_stack_is_heterogeneous(kg, state.volume_stack);
#ifdef __VOLUME_DECOUPLED__
/* decoupled ray marching only supported on CPU */
/* cache steps along volume for repeated sampling */
VolumeSegment volume_segment;
ShaderData volume_sd;
shader_setup_from_volume(kg, &volume_sd, &volume_ray, state.bounce, state.transparent_bounce);
kernel_volume_decoupled_record(kg, &state,
&volume_ray, &volume_sd, &volume_segment, heterogeneous);
/* direct light sampling */
if(volume_segment.closure_flag & SD_SCATTER) {
volume_segment.sampling_method = volume_stack_sampling_method(kg, state.volume_stack);
bool all = kernel_data.integrator.sample_all_lights_direct;
kernel_branched_path_volume_connect_light(kg, rng, &volume_sd,
throughput, &state, &L, all, &volume_ray, &volume_segment);
/* indirect light sampling */
int num_samples = kernel_data.integrator.volume_samples;
float num_samples_inv = 1.0f/num_samples;
for(int j = 0; j < num_samples; j++) {
/* workaround to fix correlation bug in T38710, can find better solution
* in random number generator later, for now this is done here to not impact
* performance of rendering without volumes */
RNG tmp_rng = cmj_hash(*rng, state.rng_offset);
PathState ps = state;
Ray pray = ray;
float3 tp = throughput;
/* branch RNG state */
path_state_branch(&ps, j, num_samples);
/* scatter sample. if we use distance sampling and take just one
* sample for direct and indirect light, we could share this
* computation, but makes code a bit complex */
float rphase = path_state_rng_1D_for_decision(kg, &tmp_rng, &ps, PRNG_PHASE);
float rscatter = path_state_rng_1D_for_decision(kg, &tmp_rng, &ps, PRNG_SCATTER_DISTANCE);
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
&ps, &pray, &volume_sd, &tp, rphase, rscatter, &volume_segment, NULL, false);
(void)result;
kernel_assert(result == VOLUME_PATH_SCATTERED);
if(kernel_path_volume_bounce(kg, rng, &volume_sd, &tp, &ps, &L, &pray)) {
kernel_path_indirect(kg, rng, pray, tp*num_samples_inv, num_samples, ps, &L);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
path_radiance_sum_indirect(&L);
path_radiance_reset_indirect(&L);
}
}
}
/* emission and transmittance */
if(volume_segment.closure_flag & SD_EMISSION)
path_radiance_accum_emission(&L, throughput, volume_segment.accum_emission, state.bounce);
throughput *= volume_segment.accum_transmittance;
/* free cached steps */
kernel_volume_decoupled_free(kg, &volume_segment);
#else
/* GPU: no decoupled ray marching, scatter probalistically */
int num_samples = kernel_data.integrator.volume_samples;
float num_samples_inv = 1.0f/num_samples;
/* todo: we should cache the shader evaluations from stepping
* through the volume, for now we redo them multiple times */
for(int j = 0; j < num_samples; j++) {
PathState ps = state;
Ray pray = ray;
ShaderData volume_sd;
float3 tp = throughput * num_samples_inv;
/* branch RNG state */
path_state_branch(&ps, j, num_samples);
VolumeIntegrateResult result = kernel_volume_integrate(
kg, &ps, &volume_sd, &volume_ray, &L, &tp, rng, heterogeneous);
#ifdef __VOLUME_SCATTER__
if(result == VOLUME_PATH_SCATTERED) {
/* todo: support equiangular, MIS and all light sampling.
* alternatively get decoupled ray marching working on the GPU */
kernel_path_volume_connect_light(kg, rng, &volume_sd, tp, &state, &L);
if(kernel_path_volume_bounce(kg, rng, &volume_sd, &tp, &ps, &L, &pray)) {
kernel_path_indirect(kg, rng, pray, tp, num_samples, ps, &L);
/* for render passes, sum and reset indirect light pass variables
* for the next samples */
path_radiance_sum_indirect(&L);
path_radiance_reset_indirect(&L);
}
}
#endif
}
/* todo: avoid this calculation using decoupled ray marching */
kernel_volume_shadow(kg, &state, &volume_ray, &throughput);
#endif
}
#endif
if(!hit) {
/* eval background shader if nothing hit */
if(kernel_data.background.transparent) {
L_transparent += average(throughput);
#ifdef __PASSES__
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
#endif
break;
}
#ifdef __BACKGROUND__
/* sample background shader */
float3 L_background = indirect_background(kg, &state, &ray);
path_radiance_accum_background(&L, throughput, L_background, state.bounce);
#endif
break;
}
/* setup shading */
ShaderData sd;
shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce, state.transparent_bounce);
shader_eval_surface(kg, &sd, 0.0f, state.flag, SHADER_CONTEXT_MAIN);
shader_merge_closures(&sd);
/* holdout */
#ifdef __HOLDOUT__
if(sd.flag & (SD_HOLDOUT|SD_HOLDOUT_MASK)) {
if(kernel_data.background.transparent) {
float3 holdout_weight;
if(sd.flag & SD_HOLDOUT_MASK)
holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
else
holdout_weight = shader_holdout_eval(kg, &sd);
/* any throughput is ok, should all be identical here */
L_transparent += average(holdout_weight*throughput);
}
if(sd.flag & SD_HOLDOUT_MASK)
break;
}
#endif
/* holdout mask objects do not write data passes */
kernel_write_data_passes(kg, buffer, &L, &sd, sample, &state, throughput);
#ifdef __EMISSION__
/* emission */
if(sd.flag & SD_EMISSION) {
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, state.ray_pdf);
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
}
#endif
/* transparency termination */
if(state.flag & PATH_RAY_TRANSPARENT) {
/* path termination. this is a strange place to put the termination, it's
* mainly due to the mixed in MIS that we use. gives too many unneeded
* shader evaluations, only need emission if we are going to terminate */
float probability = path_state_terminate_probability(kg, &state, throughput);
if(probability == 0.0f) {
break;
}
else if(probability != 1.0f) {
float terminate = path_state_rng_1D_for_decision(kg, rng, &state, PRNG_TERMINATE);
if(terminate >= probability)
break;
throughput /= probability;
}
}
#ifdef __AO__
/* ambient occlusion */
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
kernel_branched_path_ao(kg, &sd, &L, &state, rng, throughput);
}
#endif
#ifdef __SUBSURFACE__
/* bssrdf scatter to a different location on the same object */
if(sd.flag & SD_BSSRDF) {
kernel_branched_path_subsurface_scatter(kg, &sd, &L, &state,
rng, &ray, throughput);
}
#endif
if(!(sd.flag & SD_HAS_ONLY_VOLUME)) {
PathState hit_state = state;
#ifdef __EMISSION__
/* direct light */
if(kernel_data.integrator.use_direct_light) {
bool all = kernel_data.integrator.sample_all_lights_direct;
kernel_branched_path_surface_connect_light(kg, rng,
&sd, &hit_state, throughput, 1.0f, &L, all);
}
#endif
/* indirect light */
kernel_branched_path_surface_indirect_light(kg, rng,
&sd, throughput, 1.0f, &hit_state, &L);
/* continue in case of transparency */
throughput *= shader_bsdf_transparency(kg, &sd);
if(is_zero(throughput))
break;
}
/* Update Path State */
state.flag |= PATH_RAY_TRANSPARENT;
state.transparent_bounce++;
ray.P = ray_offset(sd.P, -sd.Ng);
ray.t -= sd.ray_length; /* clipping works through transparent */
#ifdef __RAY_DIFFERENTIALS__
ray.dP = sd.dP;
ray.dD.dx = -sd.dI.dx;
ray.dD.dy = -sd.dI.dy;
#endif
#ifdef __VOLUME__
/* enter/exit volume */
kernel_volume_stack_enter_exit(kg, &sd, state.volume_stack);
#endif
}
float3 L_sum = path_radiance_clamp_and_sum(kg, &L);
kernel_write_light_passes(kg, buffer, &L, sample);
#ifdef __KERNEL_DEBUG__
kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
#endif
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
}
ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
ccl_global float *buffer, ccl_global uint *rng_state,
int sample, int x, int y, int offset, int stride)
{
/* buffer offset */
int index = offset + x + y*stride;
int pass_stride = kernel_data.film.pass_stride;
rng_state += index;
buffer += index*pass_stride;
/* initialize random numbers and ray */
RNG rng;
Ray ray;
kernel_path_trace_setup(kg, rng_state, sample, x, y, &rng, &ray);
/* integrate */
float4 L;
if(ray.t != 0.0f)
L = kernel_branched_path_integrate(kg, &rng, sample, ray, buffer);
else
L = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
/* accumulate result in output buffer */
kernel_write_pass_float4(buffer, sample, L);
path_rng_end(kg, rng_state, rng);
}
#endif /* __BRANCHED_PATH__ */
CCL_NAMESPACE_END

View File

@@ -37,13 +37,13 @@ CCL_NAMESPACE_BEGIN
#ifdef __OBJECT_MOTION__
ccl_device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, float time)
{
if(sd->flag & SD_OBJECT_MOTION) {
sd->ob_tfm = object_fetch_transform_motion(kg, sd->object, time);
sd->ob_itfm = transform_quick_inverse(sd->ob_tfm);
if(ccl_fetch(sd, flag) & SD_OBJECT_MOTION) {
ccl_fetch(sd, ob_tfm) = object_fetch_transform_motion(kg, ccl_fetch(sd, object), time);
ccl_fetch(sd, ob_itfm) = transform_quick_inverse(ccl_fetch(sd, ob_tfm));
}
else {
sd->ob_tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
sd->ob_itfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
ccl_fetch(sd, ob_tfm) = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
ccl_fetch(sd, ob_itfm) = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
}
}
#endif
@@ -480,6 +480,7 @@ ccl_device void shader_merge_closures(ShaderData *sd)
}
sd->num_closure--;
kernel_assert(sd->num_closure >= 0);
j--;
}
}
@@ -493,7 +494,7 @@ ccl_device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderDa
{
/* this is the veach one-sample model with balance heuristic, some pdf
* factors drop out when using balance heuristic weighting */
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
if(i == skip_bsdf)
continue;
@@ -598,7 +599,7 @@ ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *s
ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness)
{
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
if(CLOSURE_IS_BSDF(sc->type))
@@ -613,7 +614,7 @@ ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID) // todo: make this work for osl
@@ -637,7 +638,7 @@ ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
{
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
@@ -651,7 +652,7 @@ ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
{
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
@@ -665,7 +666,7 @@ ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
{
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
if(CLOSURE_IS_BSDF_TRANSMISSION(sc->type))
@@ -679,7 +680,7 @@ ccl_device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
{
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
if(CLOSURE_IS_BSSRDF(sc->type) || CLOSURE_IS_BSDF_BSSRDF(sc->type))
@@ -694,7 +695,7 @@ ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_fac
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
float3 N = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
if(CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
@@ -722,7 +723,7 @@ ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_b
float3 N = make_float3(0.0f, 0.0f, 0.0f);
float texture_blur = 0.0f, weight_sum = 0.0f;
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
if(CLOSURE_IS_BSSRDF(sc->type)) {
@@ -828,7 +829,7 @@ ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
const ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
if(CLOSURE_IS_BACKGROUND(sc->type))
@@ -849,7 +850,7 @@ ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int
ccl_device_inline void _shader_volume_phase_multi_eval(const ShaderData *sd, const float3 omega_in, float *pdf,
int skip_phase, BsdfEval *result_eval, float sum_pdf, float sum_sample_weight)
{
for(int i = 0; i< sd->num_closure; i++) {
for(int i = 0; i < sd->num_closure; i++) {
if(i == skip_phase)
continue;

View File

@@ -180,7 +180,6 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
* potentially transparent, and only in that case start marching. this gives
* one extra ray cast for the cases were we do want transparency. */
/* The arguments sd_mem and isect_mem are meaningful only for OpenCL split kernel. Other uses can just pass a NULL */
ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ccl_addr_space PathState *state, ccl_addr_space Ray *ray_input, float3 *shadow
#ifdef __SPLIT_KERNEL__
, ShaderData *sd_mem, Intersection *isect_mem

View File

@@ -1,126 +0,0 @@
/*
* 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 "kernel_split.h"
/*
* Note on kernel_ocl_path_trace_shadow_blocked kernel.
* This is the ninth kernel in the ray tracing logic. This is the eighth
* of the path iteration kernels. This kernel takes care of "shadow ray cast"
* logic of the direct lighting and AO part of ray tracing.
*
* The input and output are as follows,
*
* PathState_coop ----------------------------------|--- kernel_ocl_path_trace_shadow_blocked --|
* LightRay_dl_coop --------------------------------| |--- LightRay_dl_coop
* LightRay_ao_coop --------------------------------| |--- LightRay_ao_coop
* ray_state ---------------------------------------| |--- ray_state
* Queue_data(QUEUE_SHADOW_RAY_CAST_AO_RAYS & | |--- Queue_data (QUEUE_SHADOW_RAY_CAST_AO_RAYS & QUEUE_SHADOW_RAY_CAST_AO_RAYS)
QUEUE_SHADOW_RAY_CAST_DL_RAYS) -------| |
* Queue_index(QUEUE_SHADOW_RAY_CAST_AO_RAYS&
QUEUE_SHADOW_RAY_CAST_DL_RAYS) -------| |
* kg (globals + data) -----------------------------| |
* queuesize ---------------------------------------| |
*
* Note on shader_shadow : shader_shadow is neither input nor output to this kernel. shader_shadow is filled and consumed in this kernel itself.
* Note on queues :
* The kernel fetches from QUEUE_SHADOW_RAY_CAST_AO_RAYS and QUEUE_SHADOW_RAY_CAST_DL_RAYS queues. We will empty
* these queues this kernel.
* State of queues when this kernel is called :
* state of queues QUEUE_ACTIVE_AND_REGENERATED_RAYS and QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be same
* before and after this kernel call.
* QUEUE_SHADOW_RAY_CAST_AO_RAYS & QUEUE_SHADOW_RAY_CAST_DL_RAYS will be filled with rays marked with flags RAY_SHADOW_RAY_CAST_AO
* and RAY_SHADOW_RAY_CAST_DL respectively, during kernel entry.
* QUEUE_SHADOW_RAY_CAST_AO_RAYS and QUEUE_SHADOW_RAY_CAST_DL_RAYS will be empty at kernel exit.
*/
__kernel void kernel_ocl_path_trace_shadow_blocked_direct_lighting(
ccl_global char *globals,
ccl_constant KernelData *data,
ccl_global char *shader_shadow, /* Required for shadow blocked */
ccl_global PathState *PathState_coop, /* Required for shadow blocked */
ccl_global Ray *LightRay_dl_coop, /* Required for direct lighting's shadow blocked */
ccl_global Ray *LightRay_ao_coop, /* Required for AO's shadow blocked */
Intersection *Intersection_coop_AO,
Intersection *Intersection_coop_DL,
ccl_global char *ray_state,
ccl_global int *Queue_data, /* Queue memory */
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
int queuesize, /* Size (capacity) of each queue */
int total_num_rays
)
{
#if 0
/* we will make the Queue_index entries '0' in the next kernel */
if(get_global_id(0) == 0 && get_global_id(1) == 0) {
/* We empty this queue here */
Queue_index[QUEUE_SHADOW_RAY_CAST_AO_RAYS] = 0;
Queue_index[QUEUE_SHADOW_RAY_CAST_DL_RAYS] = 0;
}
#endif
int lidx = get_local_id(1) * get_local_id(0) + get_local_id(0);
ccl_local unsigned int ao_queue_length;
ccl_local unsigned int dl_queue_length;
if(lidx == 0) {
ao_queue_length = Queue_index[QUEUE_SHADOW_RAY_CAST_AO_RAYS];
dl_queue_length = Queue_index[QUEUE_SHADOW_RAY_CAST_DL_RAYS];
}
barrier(CLK_LOCAL_MEM_FENCE);
/* flag determining if the current ray is to process shadow ray for AO or DL */
char shadow_blocked_type = -1;
/* flag determining if we need to update L */
char update_path_radiance = 0;
int ray_index = QUEUE_EMPTY_SLOT;
int thread_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
if(thread_index < ao_queue_length + dl_queue_length) {
if(thread_index < ao_queue_length) {
ray_index = get_ray_index(thread_index, QUEUE_SHADOW_RAY_CAST_AO_RAYS, Queue_data, queuesize, 1);
shadow_blocked_type = RAY_SHADOW_RAY_CAST_AO;
} else {
ray_index = get_ray_index(thread_index - ao_queue_length, QUEUE_SHADOW_RAY_CAST_DL_RAYS, Queue_data, queuesize, 1);
shadow_blocked_type = RAY_SHADOW_RAY_CAST_DL;
}
}
if(ray_index == QUEUE_EMPTY_SLOT)
return;
if(IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL) || IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO)) {
/* Load kernel global structure */
KernelGlobals *kg = (KernelGlobals *)globals;
ShaderData *sd_shadow = (ShaderData *)shader_shadow;
ccl_global PathState *state = &PathState_coop[ray_index];
ccl_global Ray *light_ray_dl_global = &LightRay_dl_coop[ray_index];
ccl_global Ray *light_ray_ao_global = &LightRay_ao_coop[ray_index];
Intersection *isect_ao_global = &Intersection_coop_AO[ray_index];
Intersection *isect_dl_global = &Intersection_coop_DL[ray_index];
ccl_global Ray *light_ray_global = shadow_blocked_type == RAY_SHADOW_RAY_CAST_AO ? light_ray_ao_global : light_ray_dl_global;
Intersection *isect_global = RAY_SHADOW_RAY_CAST_AO ? isect_ao_global : isect_dl_global;
float3 shadow;
update_path_radiance = !(shadow_blocked(kg, state, light_ray_global, &shadow, sd_shadow, isect_global));
/* We use light_ray_global's P and t to store shadow and update_path_radiance */
light_ray_global->P = shadow;
light_ray_global->t = update_path_radiance;
}
}

View File

@@ -84,7 +84,7 @@ CCL_NAMESPACE_BEGIN
#define __VOLUME_SCATTER__
/* Experimental on GPU */
#ifdef __KERNEL_CUDA_EXPERIMENTAL__
#ifdef __KERNEL_EXPERIMENTAL__
#define __SUBSURFACE__
#define __CMJ__
#endif
@@ -96,58 +96,40 @@ CCL_NAMESPACE_BEGIN
/* keep __KERNEL_ADV_SHADING__ in sync with opencl_kernel_use_advanced_shading! */
#ifdef __KERNEL_OPENCL_NVIDIA__
#define __KERNEL_SHADING__
/* TODO(sergey): Advanced shading code still requires work
* for split kernel.
*/
# ifndef __SPLIT_KERNEL__
# define __KERNEL_ADV_SHADING__
# else
# define __MULTI_CLOSURE__
# define __TRANSPARENT_SHADOWS__
# define __PASSES__
# define __BACKGROUND_MIS__
# define __LAMP_MIS__
# define __AO__
# define __KERNEL_SHADING__
# define __KERNEL_ADV_SHADING__
# ifdef __KERNEL_EXPERIMENTAL__
# define __CMJ__
# endif
#endif
#ifdef __KERNEL_OPENCL_APPLE__
#define __KERNEL_SHADING__
# define __KERNEL_SHADING__
//#define __KERNEL_ADV_SHADING__
#endif
#ifdef __KERNEL_OPENCL_AMD__
#define __CL_USE_NATIVE__
#define __KERNEL_SHADING__
//__KERNEL_ADV_SHADING__
#define __MULTI_CLOSURE__
//#define __TRANSPARENT_SHADOWS__
#define __PASSES__
#define __BACKGROUND_MIS__
#define __LAMP_MIS__
#define __AO__
//#define __CAMERA_MOTION__
//#define __OBJECT_MOTION__
//#define __HAIR__
//end __KERNEL_ADV_SHADING__
# define __CL_USE_NATIVE__
# define __KERNEL_SHADING__
# define __MULTI_CLOSURE__
# define __PASSES__
# define __BACKGROUND_MIS__
# define __LAMP_MIS__
# define __AO__
# define __CAMERA_MOTION__
# define __OBJECT_MOTION__
# define __HAIR__
# ifdef __KERNEL_EXPERIMENTAL__
# define __TRANSPARENT_SHADOWS__
# endif
#endif
#ifdef __KERNEL_OPENCL_INTEL_CPU__
#define __CL_USE_NATIVE__
#define __KERNEL_SHADING__
/* TODO(sergey): Advanced shading code still requires work
* for split kernel.
*/
# ifndef __SPLIT_KERNEL__
# define __KERNEL_ADV_SHADING__
# else
# define __MULTI_CLOSURE__
# define __TRANSPARENT_SHADOWS__
# define __PASSES__
# define __BACKGROUND_MIS__
# define __LAMP_MIS__
# define __AO__
# define __CL_USE_NATIVE__
# define __KERNEL_SHADING__
# define __KERNEL_ADV_SHADING__
# ifdef __KERNEL_EXPERIMENTAL__
# define __CMJ__
# endif
#endif
@@ -190,6 +172,17 @@ CCL_NAMESPACE_BEGIN
# define __KERNEL_DEBUG__
#endif
/* Scene-based selective featrues compilation/ */
#ifdef __NO_CAMERA_MOTION__
# undef __CAMERA_MOTION__
#endif
#ifdef __NO_OBJECT_MOTION__
# undef __OBJECT_MOTION__
#endif
#ifdef __NO_HAIR__
# undef __HAIR__
#endif
/* Random Numbers */
typedef uint RNG;
@@ -346,6 +339,8 @@ typedef enum PassType {
PASS_LIGHT = (1 << 25), /* no real pass, used to force use_light_pass */
#ifdef __KERNEL_DEBUG__
PASS_BVH_TRAVERSAL_STEPS = (1 << 26),
PASS_BVH_TRAVERSED_INSTANCES = (1 << 27),
PASS_RAY_BOUNCES = (1 << 28),
#endif
} PassType;
@@ -471,11 +466,11 @@ typedef struct differential {
typedef struct Ray {
/* TODO(sergey): This is only needed because current AMD
* compilet has hard time bulding the kernel with this
* compiler has hard time building the kernel with this
* reshuffle. And at the same time reshuffle will cause
* less optimal CPU code in certain places.
*
* We'll get rid of this nasty eception once AMD compiler
* We'll get rid of this nasty exception once AMD compiler
* is fixed.
*/
#ifndef __KERNEL_OPENCL_AMD__
@@ -507,6 +502,7 @@ typedef ccl_addr_space struct Intersection {
#ifdef __KERNEL_DEBUG__
int num_traversal_steps;
int num_traversed_instances;
#endif
} Intersection;
@@ -857,7 +853,9 @@ typedef struct KernelFilm {
#ifdef __KERNEL_DEBUG__
int pass_bvh_traversal_steps;
int pass_pad3, pass_pad4, pass_pad5;
int pass_bvh_traversed_instances;
int pass_ray_bounces;
int pass_pad3;
#endif
} KernelFilm;
@@ -996,6 +994,8 @@ typedef ccl_addr_space struct DebugData {
// Total number of BVH node traversal steps and primitives intersections
// for the camera rays.
int num_bvh_traversal_steps;
int num_bvh_traversed_instances;
int num_ray_bounces;
} DebugData;
#endif

View File

@@ -23,6 +23,7 @@
#include "kernel_globals.h"
#include "kernel_film.h"
#include "kernel_path.h"
#include "kernel_path_branched.h"
#include "kernel_bake.h"
CCL_NAMESPACE_BEGIN

View File

@@ -38,6 +38,7 @@
#include "kernel_globals.h"
#include "kernel_film.h"
#include "kernel_path.h"
#include "kernel_path_branched.h"
#include "kernel_bake.h"
CCL_NAMESPACE_BEGIN

View File

@@ -39,6 +39,7 @@
#include "kernel_globals.h"
#include "kernel_film.h"
#include "kernel_path.h"
#include "kernel_path_branched.h"
#include "kernel_bake.h"
CCL_NAMESPACE_BEGIN

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